2009-04-13 02:33:51

by Ben Hutchings

[permalink] [raw]
Subject: [PATCH 1/3] crc-itu-t: add bit-reversed calculation

Signed-off-by: Darren Salt <[email protected]>
---
include/linux/crc-itu-t.h | 10 ++++++++++
lib/crc-itu-t.c | 18 ++++++++++++++++++
2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/include/linux/crc-itu-t.h b/include/linux/crc-itu-t.h
index 84920f3..7b2b7ba 100644
--- a/include/linux/crc-itu-t.h
+++ b/include/linux/crc-itu-t.h
@@ -6,6 +6,9 @@
* Poly 0x0x1021 (x^16 + x^12 + x^15 + 1)
* Init 0
*
+ * The bit-reversed buffer variants may be non-standard, but some firmware
+ * loaders require them.
+ *
* This source code is licensed under the GNU General Public License,
* Version 2. See the file COPYING for more details.
*/
@@ -14,15 +17,22 @@
#define CRC_ITU_T_H

#include <linux/types.h>
+#include <linux/bitrev.h>

extern u16 const crc_itu_t_table[256];

extern u16 crc_itu_t(u16 crc, const u8 *buffer, size_t len);
+extern u16 crc_itu_t_bitreversed(u16 crc, const u8 *buffer, size_t len);

static inline u16 crc_itu_t_byte(u16 crc, const u8 data)
{
return (crc << 8) ^ crc_itu_t_table[((crc >> 8) ^ data) & 0xff];
}

+static inline u16 crc_itu_t_bitreversed_byte(u16 crc, const u8 data)
+{
+ return (crc << 8) ^ crc_itu_t_table[((crc >> 8) ^ bitrev8(data)) & 0xff];
+}
+
#endif /* CRC_ITU_T_H */

diff --git a/lib/crc-itu-t.c b/lib/crc-itu-t.c
index a63472b..886981e 100644
--- a/lib/crc-itu-t.c
+++ b/lib/crc-itu-t.c
@@ -64,6 +64,24 @@ u16 crc_itu_t(u16 crc, const u8 *buffer, size_t len)
}
EXPORT_SYMBOL(crc_itu_t);

+/**
+ * crc_itu_t_byte_reversed - Compute the CRC-ITU-T for the data buffer;
+ * the buffer content is assumed to be bit-reversed
+ *
+ * @crc: previous CRC value
+ * @buffer: data pointer
+ * @len: number of bytes in the buffer
+ *
+ * Returns the updated CRC value
+ */
+u16 crc_itu_t_bitreversed(u16 crc, const u8 *buffer, size_t len)
+{
+ while (len--)
+ crc = crc_itu_t_bitreversed_byte(crc, *buffer++);
+ return crc;
+}
+EXPORT_SYMBOL(crc_itu_t_bitreversed);
+
MODULE_DESCRIPTION("CRC ITU-T V.41 calculations");
MODULE_LICENSE("GPL");

--
1.5.6.5


2009-04-22 17:41:39

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 1/3] crc-itu-t: add bit-reversed calculation

On Mon, Apr 13, 2009 at 03:33:37AM +0100, Ben Hutchings wrote:
> Signed-off-by: Darren Salt <[email protected]>

Who wrote this patch, you or Darren?

If you, do you "sign off" on it? And if you did it, does Darren really
also sign off on it?

I see that David has added the firmware to the linux-firmware tree and
done a release, so I'll be glad to take these patches now. Care to
respin them with the proper authorship and signed-off-by information
again?

thanks,

greg k-h

2009-04-22 18:39:26

by Darren Salt

[permalink] [raw]
Subject: Re: [PATCH 1/3] crc-itu-t: add bit-reversed calculation

I demand that Greg KH may or may not have written...

> On Mon, Apr 13, 2009 at 03:33:37AM +0100, Ben Hutchings wrote:
>> Signed-off-by: Darren Salt <[email protected]>

> Who wrote this patch, you or Darren?

I did.

[snip]
--
| Darren Salt | linux or ds at | nr. Ashington, | Toon
| RISC OS, Linux | youmustbejoking,demon,co,uk | Northumberland | Army
| Let's keep the pound sterling

He hath eaten me out of house and home.

2009-04-22 18:50:51

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 1/3] crc-itu-t: add bit-reversed calculation

On Wed, Apr 22, 2009 at 07:32:23PM +0100, Darren Salt wrote:
> I demand that Greg KH may or may not have written...
>
> > On Mon, Apr 13, 2009 at 03:33:37AM +0100, Ben Hutchings wrote:
> >> Signed-off-by: Darren Salt <[email protected]>
>
> > Who wrote this patch, you or Darren?
>
> I did.

Thanks.

Then Ben should keep that authorship information properly when he
forwards patches onward. You can do this by putting:
From: Darren Salt <email_address_here>
as the first line in the body of the email. Our tools will properly
pick it up there and give the correct attribution.

Ben, does this make sense?

thanks,

greg k-h

2009-04-22 18:55:01

by Ben Hutchings

[permalink] [raw]
Subject: Re: [PATCH 1/3] crc-itu-t: add bit-reversed calculation

On Wed, Apr 22, 2009 at 11:44:09AM -0700, Greg KH wrote:
> On Wed, Apr 22, 2009 at 07:32:23PM +0100, Darren Salt wrote:
> > I demand that Greg KH may or may not have written...
> >
> > > On Mon, Apr 13, 2009 at 03:33:37AM +0100, Ben Hutchings wrote:
> > >> Signed-off-by: Darren Salt <[email protected]>
> >
> > > Who wrote this patch, you or Darren?
> >
> > I did.
>
> Thanks.
>
> Then Ben should keep that authorship information properly when he
> forwards patches onward. You can do this by putting:
> From: Darren Salt <email_address_here>
> as the first line in the body of the email. Our tools will properly
> pick it up there and give the correct attribution.
>
> Ben, does this make sense?

Yes, that's what I usually do with other people's patches. It was an
oversight in this case.

Ben.

--
Ben Hutchings
Reality is just a crutch for people who can't handle science fiction.