From: Frank Haverkamp <haver@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: arnd@arndb.de, gregkh@linuxfoundation.org,
cody@linux.vnet.ibm.com, schwidefsky@de.ibm.com,
utz.bacher@de.ibm.com, mmarek@suse.cz, rmallon@gmail.com,
jsvogt@de.ibm.com, MIJUNG@de.ibm.com,
cascardo@linux.vnet.ibm.com, michael@ibmra.de,
haver@linux.vnet.ibm.com
Subject: [RFC 2/2] GenWQE: Make use of the generic CRC kernel infrastructure
Date: Wed, 11 Dec 2013 17:49:23 +0100 [thread overview]
Message-ID: <1386780563-1722-2-git-send-email-haver@linux.vnet.ibm.com> (raw)
In-Reply-To: <1386592244-2521-7-git-send-email-haver@linux.vnet.ibm.com>
Instead of reimplementing the CRC, make use of the generic CRC kernel
infrastructure. Note that GenWQE seems currently the only one using
this particular polynomial.
This change requires a previous patch which adds the GenWQE crc32 to
the generic kernel crc32 support.
Signed-off-by: Frank Haverkamp <haver@linux.vnet.ibm.com>
---
drivers/misc/genwqe/card_base.c | 2 0 + 2 - 0 !
drivers/misc/genwqe/card_base.h | 1 0 + 1 - 0 !
drivers/misc/genwqe/card_utils.c | 39 2 + 37 - 0 !
3 files changed, 2 insertions(+), 40 deletions(-)
--- a/drivers/misc/genwqe/card_base.c
+++ b/drivers/misc/genwqe/card_base.c
@@ -1016,8 +1016,6 @@ static int genwqe_probe(struct pci_dev *
int err;
struct genwqe_dev *cd;
- genwqe_init_crc32();
-
cd = genwqe_dev_alloc();
if (IS_ERR(cd)) {
dev_err(&pci_dev->dev, "err: could not alloc mem (err=%d)!\n",
--- a/drivers/misc/genwqe/card_base.h
+++ b/drivers/misc/genwqe/card_base.h
@@ -441,7 +441,6 @@ int genwqe_ffdc_dump_dma(struct genwqe_
int genwqe_init_debug_data(struct genwqe_dev *cd,
struct genwqe_debug_data *d);
-void genwqe_init_crc32(void);
int genwqe_read_app_id(struct genwqe_dev *cd, char *app_name, int len);
/* Memory allocation/deallocation; dma address handling */
--- a/drivers/misc/genwqe/card_utils.c
+++ b/drivers/misc/genwqe/card_utils.c
@@ -37,6 +37,7 @@
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
+#include <linux/crc32.h>
#include <asm/pgtable.h>
#include "genwqe_driver.h"
@@ -151,34 +152,6 @@ int genwqe_read_app_id(struct genwqe_dev
}
/**
- * genwqe_init_crc32() - Prepare a lookup table for fast crc32 calculations
- *
- * Existing kernel functions seem to use a different polynom,
- * therefore we could not use them here.
- *
- * Genwqe's Polynomial = 0x20044009
- */
-#define CRC32_POLYNOMIAL 0x20044009
-static u32 crc32_tab[256]; /* crc32 lookup table */
-
-void genwqe_init_crc32(void)
-{
- int i, j;
- u32 crc;
-
- for (i = 0; i < 256; i++) {
- crc = i << 24;
- for (j = 0; j < 8; j++) {
- if (crc & 0x80000000)
- crc = (crc << 1) ^ CRC32_POLYNOMIAL;
- else
- crc = (crc << 1);
- }
- crc32_tab[i] = crc;
- }
-}
-
-/**
* genwqe_crc32() - Generate 32-bit crc as required for DDCBs
* @buff: pointer to data buffer
* @len: length of data for calculation
@@ -195,15 +168,7 @@ void genwqe_init_crc32(void)
*/
u32 genwqe_crc32(u8 *buff, size_t len, u32 init)
{
- int i;
- u32 crc;
-
- crc = init;
- while (len--) {
- i = ((crc >> 24) ^ *buff++) & 0xFF;
- crc = (crc << 8) ^ crc32_tab[i];
- }
- return crc;
+ return __crc32g_be(init, buff, len);
}
void *__genwqe_alloc_consistent(struct genwqe_dev *cd, size_t size,
next prev parent reply other threads:[~2013-12-11 16:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-09 12:30 [PATCH 0/6] Generic WorkQueue Engine (GenWQE) device driver (v10) Frank Haverkamp
2013-12-09 12:30 ` [PATCH 1/6] GenWQE PCI support, health monitoring and recovery Frank Haverkamp
2013-12-09 12:30 ` [PATCH 2/6] GenWQE Character device and DDCB queue Frank Haverkamp
2013-12-09 12:30 ` [PATCH 3/6] GenWQE Utility functions Frank Haverkamp
2013-12-09 12:30 ` [PATCH 4/6] GenWQE Debugfs interfaces Frank Haverkamp
2013-12-09 12:30 ` [PATCH 5/6] GenWQE Sysfs interfaces Frank Haverkamp
2013-12-09 12:30 ` [PATCH 6/6] GenWQE Enable driver Frank Haverkamp
2013-12-11 16:49 ` [RFC 1/2] CRC32 Add GenWQE CRC to kernel CRC code Frank Haverkamp
2013-12-19 0:55 ` Greg KH
2013-12-19 9:10 ` Frank Haverkamp
2013-12-11 16:49 ` Frank Haverkamp [this message]
2013-12-18 15:51 ` [PATCH 0/6] Generic WorkQueue Engine (GenWQE) device driver (v10) Frank Haverkamp
2013-12-19 0:52 ` Greg KH
2013-12-20 7:24 ` Frank Haverkamp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1386780563-1722-2-git-send-email-haver@linux.vnet.ibm.com \
--to=haver@linux.vnet.ibm.com \
--cc=MIJUNG@de.ibm.com \
--cc=arnd@arndb.de \
--cc=cascardo@linux.vnet.ibm.com \
--cc=cody@linux.vnet.ibm.com \
--cc=gregkh@linuxfoundation.org \
--cc=jsvogt@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michael@ibmra.de \
--cc=mmarek@suse.cz \
--cc=rmallon@gmail.com \
--cc=schwidefsky@de.ibm.com \
--cc=utz.bacher@de.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®