All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Fainelli <florian@openwrt.org>
To: linux-mtd@lists.infradead.org,
	Artem Bityutskiy <dedekind1@gmail.com>,
	Brian Norris <norris@broadcom.com>,
	Matthieu CASTET <matthieu.castet@parrot.com>,
	Maxime Bizon <mbizon@freebox.fr>
Cc: David Woodhouse <dwmw2@infradead.org>
Subject: [PATCH 3/4 v2] lib: add crc16_le helper
Date: Wed, 18 Aug 2010 14:01:15 +0200	[thread overview]
Message-ID: <201008181401.15328.florian@openwrt.org> (raw)

This patch adds a crc16_le helper function to lib/crc16.c

Signed-off-by: Matthieu CASTET <matthieu.castet@parrot.com>
Signed-off-by: Florian Fainelli <ffainelli@freebox.fr>
--
diff --git a/include/linux/crc16.h b/include/linux/crc16.h
index 9443c08..6c1c61f 100644
--- a/include/linux/crc16.h
+++ b/include/linux/crc16.h
@@ -26,5 +26,7 @@ static inline u16 crc16_byte(u16 crc, const u8 data)
 	return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff];
 }
 
+extern u16 crc16_le(u16 crc, const u8 *buffer, size_t len);
+
 #endif /* __CRC16_H */
 
diff --git a/lib/crc16.c b/lib/crc16.c
index 8737b08..ec4a95c 100644
--- a/lib/crc16.c
+++ b/lib/crc16.c
@@ -62,6 +62,18 @@ u16 crc16(u16 crc, u8 const *buffer, size_t len)
 }
 EXPORT_SYMBOL(crc16);
 
+u16 crc16_le(u16 crc, u8 const *p, size_t len)
+{
+	int i;
+	while (len--) {
+		crc ^= *p++ << 8;
+		for (i = 0; i < 8; i++)
+			crc = (crc << 1) ^ ((crc & 0x8000) ? 0x8005 : 0);
+	}
+	return crc;
+}
+EXPORT_SYMBOL(crc16_le);
+
 MODULE_DESCRIPTION("CRC16 calculations");
 MODULE_LICENSE("GPL");
 

             reply	other threads:[~2010-08-18 12:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-18 12:01 Florian Fainelli [this message]
2010-08-18 15:43 ` [PATCH 3/4 v2] lib: add crc16_le helper Joakim Tjernlund
2010-08-18 16:10   ` Matthieu CASTET
2010-08-18 16:34     ` Joakim Tjernlund
2010-08-19  7:42       ` Matthieu CASTET
2010-08-19  9:41         ` Joakim Tjernlund
2010-08-20  7:24           ` Florian Fainelli

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=201008181401.15328.florian@openwrt.org \
    --to=florian@openwrt.org \
    --cc=dedekind1@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=matthieu.castet@parrot.com \
    --cc=mbizon@freebox.fr \
    --cc=norris@broadcom.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.