{"id":809314,"url":"http://patchwork.ozlabs.org/api/1.0/patches/809314/?format=json","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.0/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20170903150031.18179-2-marek.behun@nic.cz>","date":"2017-09-03T15:00:23","name":"[U-Boot,1/9] lib: Add CRC32-C","commit_ref":"85d8bf57131a21424b50e50884372e813345f09a","pull_url":null,"state":"accepted","archived":false,"hash":"0e7d94f69b5dd6e1bffe983ab755922d4e616dc9","submitter":{"id":71605,"url":"http://patchwork.ozlabs.org/api/1.0/people/71605/?format=json","name":"Marek Behún","email":"marek.behun@nic.cz"},"delegate":{"id":3651,"url":"http://patchwork.ozlabs.org/api/1.0/users/3651/?format=json","username":"trini","first_name":"Tom","last_name":"Rini","email":"trini@ti.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170903150031.18179-2-marek.behun@nic.cz/mbox/","series":[{"id":1246,"url":"http://patchwork.ozlabs.org/api/1.0/series/1246/?format=json","date":"2017-09-03T15:00:25","name":"Add single-device read-only BTRFS support","version":1,"mbox":"http://patchwork.ozlabs.org/series/1246/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/809314/checks/","tags":{},"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tsecure) header.d=nic.cz header.i=@nic.cz header.b=\"Y9JYoESL\"; \n\tdkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xlbsy6N5Wz9t2y\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon,  4 Sep 2017 01:06:46 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid A3ABCC21E21; Sun,  3 Sep 2017 15:03:31 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 7E701C21EFC;\n\tSun,  3 Sep 2017 15:01:40 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 38F63C21C4F; Sun,  3 Sep 2017 15:01:34 +0000 (UTC)","from mail.nic.cz (mail.nic.cz [217.31.204.67])\n\tby lists.denx.de (Postfix) with ESMTPS id 51616C21D70\n\tfor <u-boot@lists.denx.de>; Sun,  3 Sep 2017 15:01:33 +0000 (UTC)","from dellmb.labs.office.nic.cz (unknown\n\t[IPv6:2001:1488:fffe:6:8982:ed8c:62b1:c0c8])\n\tby mail.nic.cz (Postfix) with ESMTP id E88846222D;\n\tSun,  3 Sep 2017 17:01:32 +0200 (CEST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,\n\tT_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default;\n\tt=1504450893; bh=+wqr3W4b3ZwRLXIbbL1VNiqCpDZG3hJCdk4uCLqo+NQ=;\n\th=From:To:Date;\n\tb=Y9JYoESLfHp6ZRajc73iUaSwaAHCdHPA8Cnurkd3WX/L9UinbsqCcPKl5DM2FPlFf\n\t8Eo7Mv9h9b9rL479lpszyoGopj2ngIAywGjK1XTamXF5cEg7HQ+mpR3MbP8VCi44J2\n\tEevmPLjU5u2yJwerMqc/9+UzHFBvZsNa1av+54Ls=","From":"=?utf-8?q?Marek_Beh=C3=BAn?= <marek.behun@nic.cz>","To":"u-boot@lists.denx.de","Date":"Sun,  3 Sep 2017 17:00:23 +0200","Message-Id":"<20170903150031.18179-2-marek.behun@nic.cz>","X-Mailer":"git-send-email 2.13.5","In-Reply-To":"<20170903150031.18179-1-marek.behun@nic.cz>","References":"<20170903150031.18179-1-marek.behun@nic.cz>","X-Virus-Scanned":"clamav-milter 0.99.2 at mail","X-Virus-Status":"Clean","Cc":"Tomas Hlavacek <tomas.hlavacek@nic.cz>, Stefan Roese <sr@denx.de>,\n\t=?utf-8?q?Andreas_F=C3=A4rber?= <afaerber@suse.de>","Subject":"[U-Boot] [PATCH 1/9] lib: Add CRC32-C","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"This is needed for BTRFS.\n\nSigned-off-by: Marek Behun <marek.behun@nic.cz>\n\n create mode 100644 lib/crc32c.c","diff":"diff --git a/include/u-boot/crc.h b/include/u-boot/crc.h\nindex 6764d58bab..6d08f5df98 100644\n--- a/include/u-boot/crc.h\n+++ b/include/u-boot/crc.h\n@@ -28,4 +28,8 @@ uint32_t crc32_no_comp (uint32_t, const unsigned char *, uint);\n void crc32_wd_buf(const unsigned char *input, uint ilen,\n \t\t    unsigned char *output, uint chunk_sz);\n \n+/* lib/crc32c.c */\n+void crc32c_init(uint32_t *, uint32_t);\n+uint32_t crc32c_cal(uint32_t, const char *, int, uint32_t *);\n+\n #endif /* _UBOOT_CRC_H */\ndiff --git a/lib/Kconfig b/lib/Kconfig\nindex fe337acaeb..29e55dbe1d 100644\n--- a/lib/Kconfig\n+++ b/lib/Kconfig\n@@ -146,6 +146,9 @@ config SHA_PROG_HW_ACCEL\n config MD5\n \tbool\n \n+config CRC32C\n+\tbool\n+\n endmenu\n \n menu \"Compression Support\"\ndiff --git a/lib/Makefile b/lib/Makefile\nindex 2eef1eb80e..a58ce0f815 100644\n--- a/lib/Makefile\n+++ b/lib/Makefile\n@@ -67,6 +67,7 @@ obj-y += display_options.o\n CFLAGS_display_options.o := $(if $(BUILD_TAG),-DBUILD_TAG='\"$(BUILD_TAG)\"')\n obj-$(CONFIG_BCH) += bch.o\n obj-y += crc32.o\n+obj-$(CONFIG_CRC32C) += crc32c.o\n obj-y += ctype.o\n obj-y += div64.o\n obj-y += hang.o\ndiff --git a/lib/crc32c.c b/lib/crc32c.c\nnew file mode 100644\nindex 0000000000..322c08ff5d\n--- /dev/null\n+++ b/lib/crc32c.c\n@@ -0,0 +1,38 @@\n+/*\n+ * Copied from Linux kernel crypto/crc32c.c\n+ * Copyright (c) 2004 Cisco Systems, Inc.\n+ * Copyright (c) 2008 Herbert Xu <herbert@gondor.apana.org.au>\n+ *\n+ * This program is free software; you can redistribute it and/or modify it\n+ * under the terms of the GNU General Public License as published by the Free\n+ * Software Foundation; either version 2 of the License, or (at your option)\n+ * any later version.\n+ * SPDX-License-Identifier:\tGPL-2.0+\n+ */\n+\n+#include <common.h>\n+#include <compiler.h>\n+\n+uint32_t crc32c_cal(uint32_t crc, const char *data, int length,\n+\t\t    uint32_t *crc32c_table)\n+{\n+\twhile (length--)\n+\t\tcrc = crc32c_table[(u8)(crc ^ *data++)] ^ (crc >> 8);\n+\n+\treturn crc;\n+}\n+\n+void crc32c_init(uint32_t *crc32c_table, uint32_t pol)\n+{\n+\tint i, j;\n+\tuint32_t v;\n+\tconst uint32_t poly = pol; /* Bit-reflected CRC32C polynomial */\n+\n+\tfor (i = 0; i < 256; i++) {\n+\t\tv = i;\n+\t\tfor (j = 0; j < 8; j++)\n+\t\t\tv = (v >> 1) ^ ((v & 1) ? poly : 0);\n+\n+\t\tcrc32c_table[i] = v;\n+\t}\n+}\n","prefixes":["U-Boot","1/9"]}