Skip to contentSkip to conversation

usb driver for intellon based PLC like devolo dlan duo

PATCH Superseded Peter Holik 6 participants 17 messages Apr 17, 2009 – Apr 19, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb driver for intellon based PLC like devolo dlan duo

---
 drivers/net/usb/Kconfig    |    7 +
 drivers/net/usb/Makefile   |    2 +-
 drivers/net/usb/intellon.c |  273 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 281 insertions(+), 1 deletions(-)
 create mode 100644 drivers/net/usb/intellon.c
drivers/net/usb/Kconfig +7 -0
index 8ee2103..068faa5 100644
@@ -345,4 +345,11 @@ config USB_HSO
 	  To compile this driver as a module, choose M here: the
 	  module will be called hso.
 
+config USB_NET_INTELLON
+	tristate "Intellon PLC based usb adapter"
+	depends on USB_USBNET
+	help
+	  Choose this option if you're using a PLC (Powerline Communications)
+	  solution with an Intellon chip, like the "devolo dLan duo".
+
 endmenu
drivers/net/usb/Makefile +1 -1
index 88a87ee..0fccfe9 100644
@@ -19,4 +19,4 @@ obj-$(CONFIG_USB_NET_CDC_SUBSET)	+= cdc_subset.o
 obj-$(CONFIG_USB_NET_ZAURUS)	+= zaurus.o
 obj-$(CONFIG_USB_NET_MCS7830)	+= mcs7830.o
 obj-$(CONFIG_USB_USBNET)	+= usbnet.o
-
+obj-$(CONFIG_USB_NET_INTELLON)	+= intellon.o
drivers/net/usb/intellon.c new file +273 -0

273 lines not on this page · raw message

Signature · 1 line
1.6.2.1
Acked-by on v1 1/1
#1 lore raw

Hi Peter,

Nice to see such a driver coming up!

Le Friday 17 April 2009 16:10:24 Peter Holik, vous avez écrit :

Quoted 14 lines
---
 drivers/net/usb/Kconfig    |    7 +
 drivers/net/usb/Makefile   |    2 +-
 drivers/net/usb/intellon.c |  273
++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 281
insertions(+), 1 deletions(-)
 create mode 100644 drivers/net/usb/intellon.c
drivers/net/usb/Kconfig +0 -0
index 8ee2103..068faa5 100644

drivers/net/usb/Kconfig config USB_HSO · line 354

Quoted 10 lines
drivers/net/usb/Kconfig +7 -0
@@ -345,4 +345,11 @@ config USB_HSO
 	  To compile this driver as a module, choose M here: the
 	  module will be called hso.
 
+config USB_NET_INTELLON
+	tristate "Intellon PLC based usb adapter"
+	depends on USB_USBNET
+	help
+	  Choose this option if you're using a PLC (Powerline Communications)
+	  solution with an Intellon chip, like the "devolo dLan duo".
+

Please be more specific, i.e: using a USB-based PLC (...) solution. There might be support for PLC PHYs connected to a MII-bus in a near future, even though they will not reside in drivers/net/usb/.

drivers/net/usb/Makefile obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o · line 22

Quoted 11 lines
drivers/net/usb/Kconfig +0 -0
 endmenu
drivers/net/usb/Makefile +1 -1
index 88a87ee..0fccfe9 100644
@@ -19,4 +19,4 @@ obj-$(CONFIG_USB_NET_CDC_SUBSET)	+= cdc_subset.o
 obj-$(CONFIG_USB_NET_ZAURUS)	+= zaurus.o
 obj-$(CONFIG_USB_NET_MCS7830)	+= mcs7830.o
 obj-$(CONFIG_USB_USBNET)	+= usbnet.o
-
+obj-$(CONFIG_USB_NET_INTELLON)	+= intellon.o

I would not name this intellon for the same reasons as explained below, but rather int51x1.c since this driver will for instance not work with HomePlug AV designs which use different Intellon integrated chips like the 6000 and 6300 series.

drivers/net/usb/intellon.c line 4

Quoted 10 lines
drivers/net/usb/intellon.c new file +4 -0
new file mode 100644
index 0000000..c9fcc38
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 2009 Peter Holik
+ *
+ * Intellon PLC (Powerline Communications) usb net driver

Intellon INT51x1 PLC ...
[snip]

drivers/net/usb/intellon.c line 61

Quoted 10 lines
drivers/net/usb/intellon.c new file +10 -0
+
+static u8 nibble(unsigned char c)
+{
+	if (likely(isdigit(c)))
+		return c - '0';
+	c = toupper(c);
+	if (likely(isxdigit(c)))
+		return 10 + c - 'A';
+	return 0;
+}

Please prefix this with intellon_ (or int51x1_) for instance to avoid any possible namespace clash.

Quoted 8 lines
drivers/net/usb/intellon.c new file +8 -0
+
+static inline int get_ethernet_addr(struct usbnet *dev)
+{
+	int             tmp, i;
+	unsigned char   buf [13];
+
+	tmp = usb_string(dev->udev, 3, buf, sizeof buf);
+	if (tmp != 12) {

drivers/net/usb/intellon.c line 79

Quoted 10 lines
drivers/net/usb/intellon.c new file +10 -0
+		devdbg(dev, "bad MAC string fetch, %d\n", tmp);
+		if (tmp >= 0)
+			tmp = -EINVAL;
+		return tmp;
+	}
+	for (i = tmp = 0; i < 6; i++, tmp += 2)
+		dev->net->dev_addr [i] =
+			(nibble(buf [tmp]) << 4) + nibble(buf [tmp + 1]);
+	return 0;
+}

Same here.

Please fix the intellon prefixing with something more specific to the driver like int51x1_ and I am ok with that driver.

Signature · 4 lines
Best regards, Florian Fainelli
Email : [email protected]
http://openwrt.org
-------------------------------
#2 lore raw
Quoted 40 lines · Florian Fainelli

drivers/net/usb/intellon.c line 4

Quoted 10 lines
drivers/net/usb/intellon.c new file +4 -0
new file mode 100644
index 0000000..c9fcc38
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 2009 Peter Holik
+ *
+ * Intellon PLC (Powerline Communications) usb net driver

Intellon INT51x1 PLC ...
[snip]

drivers/net/usb/intellon.c line 61

Quoted 10 lines
drivers/net/usb/intellon.c new file +10 -0
+
+static u8 nibble(unsigned char c)
+{
+	if (likely(isdigit(c)))
+		return c - '0';
+	c = toupper(c);
+	if (likely(isxdigit(c)))
+		return 10 + c - 'A';
+	return 0;
+}

Please prefix this with intellon_ (or int51x1_) for instance to avoid any possible namespace clash.

Quoted 12 lines
drivers/net/usb/intellon.c new file +12 -0
+
+static inline int get_ethernet_addr(struct usbnet *dev)
+{
+	int             tmp, i;
+	unsigned char   buf [13];
+
+	tmp = usb_string(dev->udev, 3, buf, sizeof buf);
+	if (tmp != 12) {
+		devdbg(dev, "bad MAC string fetch, %d\n", tmp);
+		if (tmp >= 0)
+			tmp = -EINVAL;
+		return tmp;
Quoted 8 lines

drivers/net/usb/intellon.c line 79

Quoted 6 lines
drivers/net/usb/intellon.c new file +6 -0
+	}
+	for (i = tmp = 0; i < 6; i++, tmp += 2)
+		dev->net->dev_addr [i] =
+			(nibble(buf [tmp]) << 4) + nibble(buf [tmp + 1]);
+	return 0;
+}

Same here.

FWIW, I think it's pretty common to name static functions in a .c file, which perform auxiliary function, not really specific to the context without the respective context-prefix. Of course, it might indeed happen that a global symbol "nibble" or "get_ethernet_addr" gets introduced at some point thus leading to a conflict, but this seems to be unlikely. And in any case the one who introduces such a symbol will have to grep the entire kernel anyway.

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

maintainer
#3 lore raw

From: Guennadi Liakhovetski <[email protected]>
Date: Fri, 17 Apr 2009 21:07:52 +0200 (CEST)

Quoted 3 lines

FWIW, I think it's pretty common to name static functions in a .c file, which perform auxiliary function, not really specific to the context without the respective context-prefix.

I'll remember to think of you next time I run grep on the tree.

#4 lore raw
Quoted 8 lines · David Miller

From: Guennadi Liakhovetski <[email protected]>
Date: Fri, 17 Apr 2009 21:07:52 +0200 (CEST)

Quoted 3 lines

FWIW, I think it's pretty common to name static functions in a .c file, which perform auxiliary function, not really specific to the context without the respective context-prefix.

I'll remember to think of you next time I run grep on the tree.

Thanks David, very nice of you:-)

Once an MMC driver has been submitted for a specific platform, which apparently has been derived from an MMC driver for a similar platform. And the submitter has preserved the function prefix... So most functions in the two drivers were called equally. Now that was bad, and I was the one to complain about it, no idea what was the end result with that driver though.

What I actually meant is that I don't necessarily consider it very inconvenient if different drivers have functions like reg_write() or whatever. I cannot think of many situations when this can be confusing. If you are working with that file and see a call to reg_write() you know where to look for it. If you have an Oops in that function - you just look one function up in the backtrace. One of the cases that might be difficult is if you have an Oops in such a function without a backtrace and it is in a module. Ok, in this case it might be difficult to find out what that was. Otherwise - why would you want to grep the sources for such a function?

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

maintainer
#5 lore raw

From: Guennadi Liakhovetski <[email protected]>
Date: Sat, 18 Apr 2009 21:54:11 +0200 (CEST)

Quoted 2 lines

If you are working with that file and see a call to reg_write() you know where to look for it.

I would never use such a generic name for a driver local routine.

For example, in the tg3 driver we use "tr32()" and "tw32()" so that at least some inkling of the driver name, even if it is just one character, prefixes the name.

This extends to other driver's I've written. The niu driver thus uses "tr64()" and "nw64()".

This is just common sense as far as I'm concerned. It is just as straight forward as not using variable names like 'foo'.

maintainer
#6 lore raw

From: David Miller <[email protected]>
Date: Sat, 18 Apr 2009 21:15:03 -0700 (PDT)

Quoted 2 lines

This extends to other driver's I've written. The niu driver thus uses "tr64()" and "nw64()".

        ^^^^^

Typo, meant "nr64()" of course :)

#7 lore raw
In reply to David Miller
Quoted 6 lines · David Miller

From: Guennadi Liakhovetski <[email protected]>
Date: Sat, 18 Apr 2009 21:54:11 +0200 (CEST)

Quoted 2 lines

If you are working with that file and see a call to reg_write() you know where to look for it.

Quoted 8 lines

I would never use such a generic name for a driver local routine.

For example, in the tg3 driver we use "tr32()" and "tw32()" so that at least some inkling of the driver name, even if it is just one character, prefixes the name.

This extends to other driver's I've written. The niu driver thus uses "tr64()" and "nw64()".

Ok, we currently have drivers for mt9m001, mt9m111, mt9t031, and mt9v022. Which letter would you take for them?:-) You'd have to take at least two characters like "m0", "m1", "t0", and "v0" but that wouldn't be very intuitive IMHO either. Take four characters like m001r16() and it looks pretty bad compared to all routines being called mt9m001_*.

Quoted 2 lines

This is just common sense as far as I'm concerned. It is just as straight forward as not using variable names like 'foo'.

I'd say that's subjective (not the latter, but the former):-)

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

maintainer
#8 lore raw

From: Guennadi Liakhovetski <[email protected]>
Date: Sun, 19 Apr 2009 10:32:24 +0200 (CEST)

Quoted 5 lines

Ok, we currently have drivers for mt9m001, mt9m111, mt9t031, and mt9v022. Which letter would you take for them?:-) You'd have to take at least two characters like "m0", "m1", "t0", and "v0" but that wouldn't be very intuitive IMHO either. Take four characters like m001r16() and it looks pretty bad compared to all routines being called mt9m001_*.

Then mt9m001_FOO() is what you use if you know that such other similar names exist.

#9 lore raw
In reply to Florian Fainelli
Quoted 3 lines

Hi Peter,

Nice to see such a driver coming up!

thanks

Quoted 28 lines

Le Friday 17 April 2009 16:10:24 Peter Holik, vous avez écrit :

Quoted 14 lines
---
 drivers/net/usb/Kconfig    |    7 +
 drivers/net/usb/Makefile   |    2 +-
 drivers/net/usb/intellon.c |  273
++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 281
insertions(+), 1 deletions(-)
 create mode 100644 drivers/net/usb/intellon.c
drivers/net/usb/Kconfig +0 -0
index 8ee2103..068faa5 100644

drivers/net/usb/Kconfig config USB_HSO · line 354

Quoted 10 lines
drivers/net/usb/Kconfig +7 -0
@@ -345,4 +345,11 @@ config USB_HSO
 	  To compile this driver as a module, choose M here: the
 	  module will be called hso.
 
+config USB_NET_INTELLON
+	tristate "Intellon PLC based usb adapter"
+	depends on USB_USBNET
+	help
+	  Choose this option if you're using a PLC (Powerline Communications)
+	  solution with an Intellon chip, like the "devolo dLan duo".
+

Please be more specific, i.e: using a USB-based PLC (...) solution.

Quoted 2 lines

There might be support for PLC PHYs connected to a MII-bus in a near future, even though they will not reside in drivers/net/usb/.

What do you mean with the last sentence?

Quoted 8 lines
Quoted 8 lines
drivers/net/usb/Kconfig +0 -0
 endmenu
drivers/net/usb/Makefile +0 -0
index 88a87ee..0fccfe9 100644
@@ -19,4 +19,4 @@ obj-$(CONFIG_USB_NET_CDC_SUBSET)	+= cdc_subset.o
 obj-$(CONFIG_USB_NET_ZAURUS)	+= zaurus.o
 obj-$(CONFIG_USB_NET_MCS7830)	+= mcs7830.o
Quoted 8 lines

drivers/net/usb/Makefile obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o · line 22

Quoted 3 lines
drivers/net/usb/Makefile +1 -1
 obj-$(CONFIG_USB_USBNET)	+= usbnet.o
-
+obj-$(CONFIG_USB_NET_INTELLON)	+= intellon.o

I would not name this intellon for the same reasons as explained below, but rather int51x1.c since this driver will for instance not work with HomePlug AV designs which use different Intellon integrated chips like the 6000 and 6300 series.

work in progress...

Quoted 40 lines

drivers/net/usb/intellon.c line 4

Quoted 10 lines
drivers/net/usb/intellon.c new file +4 -0
new file mode 100644
index 0000000..c9fcc38
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 2009 Peter Holik
+ *
+ * Intellon PLC (Powerline Communications) usb net driver

Intellon INT51x1 PLC ...
[snip]

drivers/net/usb/intellon.c line 61

Quoted 10 lines
drivers/net/usb/intellon.c new file +10 -0
+
+static u8 nibble(unsigned char c)
+{
+	if (likely(isdigit(c)))
+		return c - '0';
+	c = toupper(c);
+	if (likely(isxdigit(c)))
+		return 10 + c - 'A';
+	return 0;
+}

Please prefix this with intellon_ (or int51x1_) for instance to avoid any possible namespace clash.

Quoted 12 lines
drivers/net/usb/intellon.c new file +12 -0
+
+static inline int get_ethernet_addr(struct usbnet *dev)
+{
+	int             tmp, i;
+	unsigned char   buf [13];
+
+	tmp = usb_string(dev->udev, 3, buf, sizeof buf);
+	if (tmp != 12) {
+		devdbg(dev, "bad MAC string fetch, %d\n", tmp);
+		if (tmp >= 0)
+			tmp = -EINVAL;
+		return tmp;
Quoted 8 lines

drivers/net/usb/intellon.c line 79

Quoted 6 lines
drivers/net/usb/intellon.c new file +6 -0
+	}
+	for (i = tmp = 0; i < 6; i++, tmp += 2)
+		dev->net->dev_addr [i] =
+			(nibble(buf [tmp]) << 4) + nibble(buf [tmp + 1]);
+	return 0;
+}

Same here.

Disagree, because i've taken "nibble" and "get_ethernet_addr" from cdc_ether.c to have the same code (the version of Jan was different).

Quoted 2 lines

Please fix the intellon prefixing with something more specific to the driver like int51x1_ and I am ok with that driver.

ok

cu Peter

#10 lore raw

Le Saturday 18 April 2009 08:48:22 Peter Holik, vous avez écrit :

Quoted 34 lines
Quoted 3 lines

Hi Peter,

Nice to see such a driver coming up!

thanks

Quoted 28 lines

Le Friday 17 April 2009 16:10:24 Peter Holik, vous avez écrit :

Quoted 14 lines
---
 drivers/net/usb/Kconfig    |    7 +
 drivers/net/usb/Makefile   |    2 +-
 drivers/net/usb/intellon.c |  273
++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 281
insertions(+), 1 deletions(-)
 create mode 100644 drivers/net/usb/intellon.c
drivers/net/usb/Kconfig +0 -0
index 8ee2103..068faa5 100644

drivers/net/usb/Kconfig config USB_HSO · line 354

Quoted 10 lines
drivers/net/usb/Kconfig +7 -0
@@ -345,4 +345,11 @@ config USB_HSO
 	  To compile this driver as a module, choose M here: the
 	  module will be called hso.
 
+config USB_NET_INTELLON
+	tristate "Intellon PLC based usb adapter"
+	depends on USB_USBNET
+	help
+	  Choose this option if you're using a PLC (Powerline Communications)
+	  solution with an Intellon chip, like the "devolo dLan duo".
+

Please be more specific, i.e: using a USB-based PLC (...) solution.

Quoted 4 lines
Quoted 2 lines

There might be support for PLC PHYs connected to a MII-bus in a near future, even though they will not reside in drivers/net/usb/.

What do you mean with the last sentence?

I mean that one might come up with a design that uses Intellon PLC PHY chips only with a custom MAC chip, not integrated MAC+PHY chips only, therefore a more specific naming is required, that's purely cosmetic though.

Quoted 18 lines
Quoted 17 lines

drivers/net/usb/Makefile obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o · line 22

Quoted 12 lines
drivers/net/usb/Kconfig +0 -0
 endmenu
drivers/net/usb/Makefile +1 -1
index 88a87ee..0fccfe9 100644
@@ -19,4 +19,4 @@ obj-$(CONFIG_USB_NET_CDC_SUBSET)	+= cdc_subset.o
 obj-$(CONFIG_USB_NET_ZAURUS)	+= zaurus.o
 obj-$(CONFIG_USB_NET_MCS7830)	+= mcs7830.o
 obj-$(CONFIG_USB_USBNET)	+= usbnet.o
-
+obj-$(CONFIG_USB_NET_INTELLON)	+= intellon.o

I would not name this intellon for the same reasons as explained below, but rather int51x1.c since this driver will for instance not work with HomePlug AV designs which use different Intellon integrated chips like the 6000 and 6300 series.

Quoted 1 line

work in progress...

Cool :)

Quoted 2 lines

Disagree, because i've taken "nibble" and "get_ethernet_addr" from cdc_ether.c to have the same code (the version of Jan was different).

Ok.

Signature · 4 lines
Best regards, Florian Fainelli
Email : [email protected]
http://openwrt.org
-------------------------------
#11 lore raw
Quoted 35 lines · Florian Fainelli

Le Saturday 18 April 2009 08:48:22 Peter Holik, vous avez écrit :

Quoted 34 lines
Quoted 3 lines

Hi Peter,

Nice to see such a driver coming up!

thanks

Quoted 28 lines

Le Friday 17 April 2009 16:10:24 Peter Holik, vous avez écrit :

Quoted 17 lines

---
 drivers/net/usb/Kconfig    |    7 + drivers/net/usb/Makefile   |    2 +- drivers/net/usb/intellon.c |  273 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 281 insertions(+), 1 deletions(-)
 create mode 100644 drivers/net/usb/intellon.c

drivers/net/usb/Kconfig +0 -0
index 8ee2103..068faa5 100644
@@ -345,4 +345,11 @@ config USB_HSO

     To compile this driver as a module, choose M here: the module will be called hso.

drivers/net/usb/Kconfig config USB_HSO · line 354

Quoted 7 lines
drivers/net/usb/Kconfig +7 -0
+config USB_NET_INTELLON
+  tristate "Intellon PLC based usb adapter"
+  depends on USB_USBNET
+  help
+    Choose this option if you're using a PLC (Powerline Communications)
+    solution with an Intellon chip, like the "devolo dLan duo".
+

Please be more specific, i.e: using a USB-based PLC (...) solution.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

There might be support for PLC PHYs connected to a MII-bus in a near future, even though they will not reside in drivers/net/usb/.

What do you mean with the last sentence?

I mean that one might come up with a design that uses Intellon PLC PHY chips only with a custom MAC chip, not integrated MAC+PHY chips only, therefore a more specific naming is required, that's purely cosmetic though.

Those chips that look like PHY chips are just fancy A/D D/A converters.

When connected via Ethernet the chips don't need any drivers. But the higher speed devices need firmware loaded. Firmware is loaded by writing normal packets to the device with a specific Intellon owned Ethernet address. I load the firmware in u-boot so that I can NFS boot, but you could also load it in Linux. These chips have an embedded ARM9 core.

More work could be done to integrate Linux commands for changing the Ethernet address, link encryption key, etc. I just statically set these in my firmware image. You change them by writing packets to the special address.

Powerline networking uses technology that is very similar to 802.11g but with different error recovery encoding. I suspect it is possible to build a powerline device using 802.11 MAC hardware and different firmware.

Signature · 2 lines
Jon Smirl
[email protected]
#12 lore raw
In reply to Peter Holik

Am Freitag 17 April 2009 16:10:24 schrieb Peter Holik:

+static int intellon_rx_fixup(struct usbnet *dev, struct sk_buff *skb) +{
+ int len;
+
+ if (unlikely(skb->len < INTELLON_HEADER_SIZE)) {
+ deverr(dev, "unexpected tiny rx frame");
+ return 0;
+ }
+
+ len = (skb->data[skb->len - 2] | (skb->data[skb->len - 1] << 8));

Please use a conversion function.

+ } else {
+ struct sk_buff *skb2;
+
+ skb2 = skb_copy_expand(skb,

+                               INTELLON_HEADER_SIZE,
+                               need_tail,
+                               flags);

+ dev_kfree_skb_any(skb);
+ if (!skb2)
+ return skb2;

If you return NULL in an error case, write it so explicitely.

+ __skb_push(skb, INTELLON_HEADER_SIZE);
+
+ skb->data[0] = pack_len & 0xFF;
+ skb->data[1] = (pack_len & 0x700) >> 8;

Again, a conversion function is called for.

Regards
Oliver

#13 lore raw
Quoted 13 lines

Am Freitag 17 April 2009 16:10:24 schrieb Peter Holik:

drivers/net/usb/intellon.c new file +10 -0
+static int intellon_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
+{
+       int len;
+
+       if (unlikely(skb->len < INTELLON_HEADER_SIZE)) {
+               deverr(dev, "unexpected tiny rx frame");
+               return 0;
+       }
+
+       len = (skb->data[skb->len - 2] | (skb->data[skb->len - 1] << 8));
Quoted 1 line

Please use a conversion function.

do you mean

len = le16_to_cpu(skb->data[skb->len - 2] | (skb->data[skb->len - 1] << 8));

Quoted 11 lines
drivers/net/usb/intellon.c new file +10 -0
+       } else {
+               struct sk_buff *skb2;
+
+               skb2 = skb_copy_expand(skb,
+                               INTELLON_HEADER_SIZE,
+                               need_tail,
+                               flags);
+               dev_kfree_skb_any(skb);
+               if (!skb2)
+                       return skb2;
Quoted 1 line

If you return NULL in an error case, write it so explicitely.

ok

Quoted 6 lines
drivers/net/usb/intellon.c new file +4 -0
+       __skb_push(skb, INTELLON_HEADER_SIZE);
+
+       skb->data[0] = pack_len & 0xFF;
+       skb->data[1] = (pack_len & 0x700) >> 8;

Again, a conversion function is called for.

is this correct

__le16 *len;
.
.
.
pack_len &= 0x07ff;

  len = (__le16 *) __skb_push(skb, INT51X1_HEADER_SIZE);
  *len = cpu_to_le16(pack_len);

cu Peter

#14 lore raw

Am Samstag 18 April 2009 09:16:28 schrieb Peter Holik:

Quoted 8 lines
Quoted 3 lines

+ len = (skb->data[skb->len - 2] | (skb->data[skb->len - 1] << 8));

Please use a conversion function.

do you mean

len = le16_to_cpu(skb->data[skb->len - 2] | (skb->data[skb->len - 1] << 8));

Without the "|". Just dereference the pointer.

Quoted 4 lines
  pack_len &= 0x07ff;

  len = (__le16 *) __skb_push(skb, INT51X1_HEADER_SIZE);
  *len = cpu_to_le16(pack_len);

That's correct.

Regards
Oliver

#15 lore raw
Quoted 4 lines

Am Samstag 18 April 2009 09:16:28 schrieb Peter Holik:

Quoted 2 lines
Quoted 2 lines

+ len = (skb->data[skb->len - 2] | (skb->data[skb->len - 1] << 8));

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Please use a conversion function.

do you mean

len = le16_to_cpu(skb->data[skb->len - 2] | (skb->data[skb->len - 1] << 8));

Without the "|". Just dereference the pointer.

this way?

len = le16_to_cpu(*(__le16 *)&skb->data[skb->len - 2]);

cu Peter

#16 lore raw

Am Samstag 18 April 2009 10:41:37 schrieb Peter Holik:

Quoted 5 lines
Quoted 1 line

Without the "|". Just dereference the pointer.

this way?

len = le16_to_cpu(*(__le16 *)&skb->data[skb->len - 2]);

That does the job.

Regards
Oliver