Re: [PATCH 2/2] net: qmi_wwan: fix checkpatch warnings
Hi Bjørn, thanks for reviewing. On Wed, Sep 25, 2013 at 3:31 PM, Bjørn Mork wrote: > Sorry, I really don't see the point of this. Yes, the lines are longer > than 80 columns, but breaking them don't improve the readability at > all. On the contrary, IMHO. > > So NAK from me for this part. Which changes do you think do not improve the readability? I'm sure that at least some of them actually improve the readability. Best regards Fabio Porcedda > Fabio Porcedda writes: > >> Signed-off-by: Fabio Porcedda >> --- >> drivers/net/usb/qmi_wwan.c | 56 >> +- >> 1 file changed, 36 insertions(+), 20 deletions(-) >> >> diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c >> index 5f6b6fa..0e59f9e 100644 >> --- a/drivers/net/usb/qmi_wwan.c >> +++ b/drivers/net/usb/qmi_wwan.c >> @@ -143,16 +143,22 @@ static const struct net_device_ops qmi_wwan_netdev_ops >> = { >> .ndo_validate_addr = eth_validate_addr, >> }; >> >> -/* using a counter to merge subdriver requests with our own into a combined >> state */ >> +/* using a counter to merge subdriver requests with our own into a >> + * combined state >> + */ >> static int qmi_wwan_manage_power(struct usbnet *dev, int on) >> { >> struct qmi_wwan_state *info = (void *)&dev->data; >> int rv = 0; >> >> - dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__, >> atomic_read(&info->pmcount), on); >> + dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__, >> + atomic_read(&info->pmcount), on); >> >> - if ((on && atomic_add_return(1, &info->pmcount) == 1) || (!on && >> atomic_dec_and_test(&info->pmcount))) { >> - /* need autopm_get/put here to ensure the usbcore sees the new >> value */ >> + if ((on && atomic_add_return(1, &info->pmcount) == 1) || >> + (!on && atomic_dec_and_test(&info->pmcount))) { >> + /* need autopm_get/put here to ensure the usbcore sees >> + * the new value >> + */ >> rv = usb_autopm_get_interface(dev->intf); >> if (rv < 0) >> goto err; >> @@ -199,7 +205,8 @@ static int qmi_wwan_register_subdriver(struct usbnet >> *dev) >> atomic_set(&info->pmcount, 0); >> >> /* register subdriver */ >> - subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc, >> 4096, &qmi_wwan_cdc_wdm_manage_power); >> + subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc, >> + 4096, &qmi_wwan_cdc_wdm_manage_power); >> if (IS_ERR(subdriver)) { >> dev_err(&info->control->dev, "subdriver registration >> failed\n"); >> rv = PTR_ERR(subdriver); >> @@ -228,7 +235,8 @@ static int qmi_wwan_bind(struct usbnet *dev, struct >> usb_interface *intf) >> struct usb_driver *driver = driver_of(intf); >> struct qmi_wwan_state *info = (void *)&dev->data; >> >> - BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) < sizeof(struct >> qmi_wwan_state))); >> + BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) < >> + sizeof(struct qmi_wwan_state))); >> >> /* set up initial state */ >> info->control = intf; >> @@ -250,7 +258,8 @@ static int qmi_wwan_bind(struct usbnet *dev, struct >> usb_interface *intf) >> goto err; >> } >> if (h->bLength != sizeof(struct usb_cdc_header_desc)) { >> - dev_dbg(&intf->dev, "CDC header len %u\n", >> h->bLength); >> + dev_dbg(&intf->dev, "CDC header len %u\n", >> + h->bLength); >> goto err; >> } >> break; >> @@ -260,7 +269,8 @@ static int qmi_wwan_bind(struct usbnet *dev, struct >> usb_interface *intf) >> goto err; >> } >> if (h->bLength != sizeof(struct usb_cdc_union_desc)) { >> - dev_dbg(&intf->dev, "CDC union
[PATCH 1/2] net: qmi_wwan: add Telit LE920 newer firmware support
Newer firmware use a new pid and a different interface. Signed-off-by: Fabio Porcedda --- drivers/net/usb/qmi_wwan.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index 6312332..5f6b6fa 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c @@ -714,6 +714,7 @@ static const struct usb_device_id products[] = { {QMI_FIXED_INTF(0x2357, 0x0201, 4)},/* TP-LINK HSUPA Modem MA180 */ {QMI_FIXED_INTF(0x2357, 0x9000, 4)},/* TP-LINK MA260 */ {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)},/* Telit LE920 */ + {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)},/* Telit LE920 */ {QMI_FIXED_INTF(0x1e2d, 0x12d1, 4)},/* Cinterion PLxx */ /* 4. Gobi 1000 devices */ -- 1.8.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] net: qmi_wwan: fix checkpatch warnings
Signed-off-by: Fabio Porcedda --- drivers/net/usb/qmi_wwan.c | 56 +- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index 5f6b6fa..0e59f9e 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c @@ -143,16 +143,22 @@ static const struct net_device_ops qmi_wwan_netdev_ops = { .ndo_validate_addr = eth_validate_addr, }; -/* using a counter to merge subdriver requests with our own into a combined state */ +/* using a counter to merge subdriver requests with our own into a + * combined state + */ static int qmi_wwan_manage_power(struct usbnet *dev, int on) { struct qmi_wwan_state *info = (void *)&dev->data; int rv = 0; - dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__, atomic_read(&info->pmcount), on); + dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__, + atomic_read(&info->pmcount), on); - if ((on && atomic_add_return(1, &info->pmcount) == 1) || (!on && atomic_dec_and_test(&info->pmcount))) { - /* need autopm_get/put here to ensure the usbcore sees the new value */ + if ((on && atomic_add_return(1, &info->pmcount) == 1) || + (!on && atomic_dec_and_test(&info->pmcount))) { + /* need autopm_get/put here to ensure the usbcore sees +* the new value +*/ rv = usb_autopm_get_interface(dev->intf); if (rv < 0) goto err; @@ -199,7 +205,8 @@ static int qmi_wwan_register_subdriver(struct usbnet *dev) atomic_set(&info->pmcount, 0); /* register subdriver */ - subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc, 4096, &qmi_wwan_cdc_wdm_manage_power); + subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc, +4096, &qmi_wwan_cdc_wdm_manage_power); if (IS_ERR(subdriver)) { dev_err(&info->control->dev, "subdriver registration failed\n"); rv = PTR_ERR(subdriver); @@ -228,7 +235,8 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) struct usb_driver *driver = driver_of(intf); struct qmi_wwan_state *info = (void *)&dev->data; - BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) < sizeof(struct qmi_wwan_state))); + BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) < + sizeof(struct qmi_wwan_state))); /* set up initial state */ info->control = intf; @@ -250,7 +258,8 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) goto err; } if (h->bLength != sizeof(struct usb_cdc_header_desc)) { - dev_dbg(&intf->dev, "CDC header len %u\n", h->bLength); + dev_dbg(&intf->dev, "CDC header len %u\n", + h->bLength); goto err; } break; @@ -260,7 +269,8 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) goto err; } if (h->bLength != sizeof(struct usb_cdc_union_desc)) { - dev_dbg(&intf->dev, "CDC union len %u\n", h->bLength); + dev_dbg(&intf->dev, "CDC union len %u\n", + h->bLength); goto err; } cdc_union = (struct usb_cdc_union_desc *)buf; @@ -271,15 +281,15 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) goto err; } if (h->bLength != sizeof(struct usb_cdc_ether_desc)) { - dev_dbg(&intf->dev, "CDC ether len %u\n", h->bLength); + dev_dbg(&intf->dev, "CDC ether len %u\n", + h->bLength); goto err; } cdc_ether = (struct usb_cdc_ether_desc *)buf; break; } - /* -* Remember which CDC functional descriptors we've seen. Works + /* Remember which CDC functional descriptors we've seen. Works
[PATCH 2/3] net: usb: cdc_ether: fix checkpatch errors and warnings
Signed-off-by: Fabio Porcedda --- drivers/net/usb/cdc_ether.c | 47 +++-- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index 98aef3b..c36b1c3 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c @@ -33,7 +33,7 @@ #include -#if defined(CONFIG_USB_NET_RNDIS_HOST) || defined(CONFIG_USB_NET_RNDIS_HOST_MODULE) +#if IS_ENABLED(CONFIG_USB_NET_RNDIS_HOST) static int is_rndis(struct usb_interface_descriptor *desc) { @@ -69,8 +69,7 @@ static const u8 mbm_guid[16] = { 0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a, }; -/* - * probes control interface, claims data interface, collects the bulk +/* probes control interface, claims data interface, collects the bulk * endpoints, activates data interface (if needed), maybe sets MTU. * all pure cdc, except for certain firmware workarounds, and knowing * that rndis uses one different rule. @@ -88,7 +87,7 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf) struct usb_cdc_mdlm_desc*desc = NULL; struct usb_cdc_mdlm_detail_desc *detail = NULL; - if (sizeof dev->data < sizeof *info) + if (sizeof(dev->data) < sizeof(*info)) return -EDOM; /* expect strict spec conformance for the descriptors, but @@ -126,10 +125,10 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf) is_activesync(&intf->cur_altsetting->desc) || is_wireless_rndis(&intf->cur_altsetting->desc)); - memset(info, 0, sizeof *info); + memset(info, 0, sizeof(*info)); info->control = intf; while (len > 3) { - if (buf [1] != USB_DT_CS_INTERFACE) + if (buf[1] != USB_DT_CS_INTERFACE) goto next_desc; /* use bDescriptorSubType to identify the CDC descriptors. @@ -139,14 +138,14 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf) * in favor of a complicated OID-based RPC scheme doing what * CDC Ethernet achieves with a simple descriptor. */ - switch (buf [2]) { + switch (buf[2]) { case USB_CDC_HEADER_TYPE: if (info->header) { dev_dbg(&intf->dev, "extra CDC header\n"); goto bad_desc; } info->header = (void *) buf; - if (info->header->bLength != sizeof *info->header) { + if (info->header->bLength != sizeof(*info->header)) { dev_dbg(&intf->dev, "CDC header len %u\n", info->header->bLength); goto bad_desc; @@ -175,7 +174,7 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf) goto bad_desc; } info->u = (void *) buf; - if (info->u->bLength != sizeof *info->u) { + if (info->u->bLength != sizeof(*info->u)) { dev_dbg(&intf->dev, "CDC union len %u\n", info->u->bLength); goto bad_desc; @@ -233,7 +232,7 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf) goto bad_desc; } info->ether = (void *) buf; - if (info->ether->bLength != sizeof *info->ether) { + if (info->ether->bLength != sizeof(*info->ether)) { dev_dbg(&intf->dev, "CDC ether len %u\n", info->ether->bLength); goto bad_desc; @@ -274,8 +273,8 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf) break; } next_desc: - len -= buf [0]; /* bLength */ - buf += buf [0]; + len -= buf[0]; /* bLength */ + buf += buf[0]; } /* Microsoft ActiveSync based and some regular RNDIS devices lack the @@ -379,9 +378,7 @@ void usbnet_cdc_unbind(struct usbnet *dev, struct usb_interface *intf) } EXPORT_SYMBOL_GPL(usbnet_cdc_unbind); -/*- - * - * Communications Device Class, Ethernet Control model +/* Communications Device Class, Ethernet Control model * * Takes two interfaces. The
[PATCH 0/3] net: usb: cdc_ether: improve telit support and code cleanups
Some patches to improve telit modules support and to cleanup the code. Best regards Fabio Porcedda (3): net: usb: cdc_ether: Use wwan interface for Telit modules net: usb: cdc_ether: fix checkpatch errors and warnings net: usb: cdc_ether: use usb.h macros whenever possible drivers/net/usb/cdc_ether.c | 115 1 file changed, 42 insertions(+), 73 deletions(-) -- 1.8.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] net: usb: cdc_ether: use usb.h macros whenever possible
Use USB_DEVICE_AND_INTERFACE_INFO and USB_VENDOR_AND_INTERFACE_INFO macros to reduce boilerplate. Signed-off-by: Fabio Porcedda --- drivers/net/usb/cdc_ether.c | 63 - 1 file changed, 17 insertions(+), 46 deletions(-) diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index c36b1c3..2023f3e 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c @@ -665,58 +665,33 @@ static const struct usb_device_id products[] = { */ { /* ZTE (Vodafone) K3805-Z */ - .match_flags= USB_DEVICE_ID_MATCH_VENDOR -| USB_DEVICE_ID_MATCH_PRODUCT -| USB_DEVICE_ID_MATCH_INT_INFO, - .idVendor = ZTE_VENDOR_ID, - .idProduct = 0x1003, - .bInterfaceClass= USB_CLASS_COMM, - .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, - .bInterfaceProtocol = USB_CDC_PROTO_NONE, + USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1003, USB_CLASS_COMM, + USB_CDC_SUBCLASS_ETHERNET, + USB_CDC_PROTO_NONE), .driver_info = (unsigned long)&wwan_info, }, { /* ZTE (Vodafone) K3806-Z */ - .match_flags= USB_DEVICE_ID_MATCH_VENDOR -| USB_DEVICE_ID_MATCH_PRODUCT -| USB_DEVICE_ID_MATCH_INT_INFO, - .idVendor = ZTE_VENDOR_ID, - .idProduct = 0x1015, - .bInterfaceClass= USB_CLASS_COMM, - .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, - .bInterfaceProtocol = USB_CDC_PROTO_NONE, + USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1015, USB_CLASS_COMM, + USB_CDC_SUBCLASS_ETHERNET, + USB_CDC_PROTO_NONE), .driver_info = (unsigned long)&wwan_info, }, { /* ZTE (Vodafone) K4510-Z */ - .match_flags= USB_DEVICE_ID_MATCH_VENDOR -| USB_DEVICE_ID_MATCH_PRODUCT -| USB_DEVICE_ID_MATCH_INT_INFO, - .idVendor = ZTE_VENDOR_ID, - .idProduct = 0x1173, - .bInterfaceClass= USB_CLASS_COMM, - .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, - .bInterfaceProtocol = USB_CDC_PROTO_NONE, + USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1173, USB_CLASS_COMM, + USB_CDC_SUBCLASS_ETHERNET, + USB_CDC_PROTO_NONE), .driver_info = (unsigned long)&wwan_info, }, { /* ZTE (Vodafone) K3770-Z */ - .match_flags= USB_DEVICE_ID_MATCH_VENDOR -| USB_DEVICE_ID_MATCH_PRODUCT -| USB_DEVICE_ID_MATCH_INT_INFO, - .idVendor = ZTE_VENDOR_ID, - .idProduct = 0x1177, - .bInterfaceClass= USB_CLASS_COMM, - .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, - .bInterfaceProtocol = USB_CDC_PROTO_NONE, + USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1177, USB_CLASS_COMM, + USB_CDC_SUBCLASS_ETHERNET, + USB_CDC_PROTO_NONE), .driver_info = (unsigned long)&wwan_info, }, { /* ZTE (Vodafone) K3772-Z */ - .match_flags= USB_DEVICE_ID_MATCH_VENDOR -| USB_DEVICE_ID_MATCH_PRODUCT -| USB_DEVICE_ID_MATCH_INT_INFO, - .idVendor = ZTE_VENDOR_ID, - .idProduct = 0x1181, - .bInterfaceClass= USB_CLASS_COMM, - .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, - .bInterfaceProtocol = USB_CDC_PROTO_NONE, + USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1181, USB_CLASS_COMM, + USB_CDC_SUBCLASS_ETHERNET, + USB_CDC_PROTO_NONE), .driver_info = (unsigned long)&wwan_info, }, { /* Telit modules */ @@ -734,12 +709,8 @@ static const struct usb_device_id products[] = { }, { /* Various Huawei modems with a network port like the UMG1831 */ - .match_flags= USB_DEVICE_ID_MATCH_VENDOR -| USB_DEVICE_ID_MATCH_INT_INFO, - .idVendor = HUAWEI_VENDOR_ID, - .bInterfaceClass= USB_CLASS_COMM, - .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, - .bInterfaceProtocol = 255, + USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_COMM, + USB_CDC_SUBCLASS_ETHERNET, 255), .driver_info = (unsigned long)&wwan_info, }, { },/* END */ -- 1.8.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/3] net: usb: cdc_ether: Use wwan interface for Telit modules
Signed-off-by: Fabio Porcedda Cc: # 3.0+ as far back as it applies cleanly --- drivers/net/usb/cdc_ether.c | 5 + 1 file changed, 5 insertions(+) diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index 03ad4dc..98aef3b 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c @@ -726,6 +726,11 @@ static const struct usb_device_id products [] = { .bInterfaceProtocol = USB_CDC_PROTO_NONE, .driver_info = (unsigned long)&wwan_info, }, { + /* Telit modules */ + USB_VENDOR_AND_INTERFACE_INFO(0x1bc7, USB_CLASS_COMM, + USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), + .driver_info = (kernel_ulong_t) &wwan_info, +}, { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), .driver_info = (unsigned long) &cdc_info, -- 1.8.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] driver core: add helper macro for platform_driver_probe() boilerplate
Hi Greg, I'm sorry, In the previous email I used your wrong email address, in this email I've used your correct email address. Best regards Fabio Porcedda On Wed, Jan 9, 2013 at 12:15 PM, Fabio Porcedda wrote: > For simple modules that contain a single platform_driver without any > additional setup code then ends up being a block of duplicated > boilerplate. This patch adds a new macro, > module_platform_driver_probe(), which replaces the > module_init()/module_exit() registrations with template functions. > > This macro use the same idea of module_platform_driver(). > > This macro is useful to stop the misuse of module_platform_driver() for > removing the platform_driver_probe() boilerplate. > > Signed-off-by: Fabio Porcedda > Cc: Greg Kroah-Hartman Cc: Greg Kroah-Hartman (linuxfoundation.org) > --- > include/linux/platform_device.h | 18 ++ > 1 file changed, 18 insertions(+) > > diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h > index a9ded9a..c082c71 100644 > --- a/include/linux/platform_device.h > +++ b/include/linux/platform_device.h > @@ -204,6 +204,24 @@ static inline void platform_set_drvdata(struct > platform_device *pdev, void *data > module_driver(__platform_driver, platform_driver_register, \ > platform_driver_unregister) > > +/* module_platform_driver_probe() - Helper macro for drivers that don't do > + * anything special in module init/exit. This eliminates a lot of > + * boilerplate. Each module may only use this macro once, and > + * calling it replaces module_init() and module_exit() > + */ > +#define module_platform_driver_probe(__platform_driver, __platform_probe) \ > +static int __init __platform_driver##_init(void) \ > +{ \ > + return platform_driver_probe(&(__platform_driver), \ > +__platform_probe);\ > +} \ > +module_init(__platform_driver##_init); \ > +static void __exit __platform_driver##_exit(void) \ > +{ \ > + platform_driver_unregister(&(__platform_driver)); \ > +} \ > +module_exit(__platform_driver##_exit); > + > extern struct platform_device *platform_create_bundle(struct platform_driver > *driver, > int (*probe)(struct platform_device > *), > struct resource *res, unsigned int > n_res, > -- > 1.8.0.3 > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/3] watchdog: convert drivers/watchdog/* to use module_platform_driver_probe
This makes the code a bit smaller by getting rid of some boilerplate code. Signed-off-by: Fabio Porcedda Cc: linux-watch...@vger.kernel.org Cc: Wim Van Sebroeck Cc: Linus Walleij --- drivers/watchdog/at32ap700x_wdt.c | 12 +--- drivers/watchdog/at91sam9_wdt.c | 13 + drivers/watchdog/coh901327_wdt.c | 12 +--- drivers/watchdog/imx2_wdt.c | 12 +--- drivers/watchdog/txx9wdt.c| 13 + 5 files changed, 5 insertions(+), 57 deletions(-) diff --git a/drivers/watchdog/at32ap700x_wdt.c b/drivers/watchdog/at32ap700x_wdt.c index 2896430..7a715e3 100644 --- a/drivers/watchdog/at32ap700x_wdt.c +++ b/drivers/watchdog/at32ap700x_wdt.c @@ -436,17 +436,7 @@ static struct platform_driver at32_wdt_driver = { .shutdown = at32_wdt_shutdown, }; -static int __init at32_wdt_init(void) -{ - return platform_driver_probe(&at32_wdt_driver, at32_wdt_probe); -} -module_init(at32_wdt_init); - -static void __exit at32_wdt_exit(void) -{ - platform_driver_unregister(&at32_wdt_driver); -} -module_exit(at32_wdt_exit); +module_platform_driver_probe(at32_wdt_driver, at32_wdt_probe); MODULE_AUTHOR("Hans-Christian Egtvedt "); MODULE_DESCRIPTION("Watchdog driver for Atmel AT32AP700X"); diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c index d864dc4..60bc700 100644 --- a/drivers/watchdog/at91sam9_wdt.c +++ b/drivers/watchdog/at91sam9_wdt.c @@ -331,18 +331,7 @@ static struct platform_driver at91wdt_driver = { }, }; -static int __init at91sam_wdt_init(void) -{ - return platform_driver_probe(&at91wdt_driver, at91wdt_probe); -} - -static void __exit at91sam_wdt_exit(void) -{ - platform_driver_unregister(&at91wdt_driver); -} - -module_init(at91sam_wdt_init); -module_exit(at91sam_wdt_exit); +module_platform_driver_probe(at91wdt_driver, at91wdt_probe); MODULE_AUTHOR("Renaud CERRATO "); MODULE_DESCRIPTION("Watchdog driver for Atmel AT91SAM9x processors"); diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c index cb5da5c..b9b8a8b 100644 --- a/drivers/watchdog/coh901327_wdt.c +++ b/drivers/watchdog/coh901327_wdt.c @@ -451,17 +451,7 @@ static struct platform_driver coh901327_driver = { .resume = coh901327_resume, }; -static int __init coh901327_init(void) -{ - return platform_driver_probe(&coh901327_driver, coh901327_probe); -} -module_init(coh901327_init); - -static void __exit coh901327_exit(void) -{ - platform_driver_unregister(&coh901327_driver); -} -module_exit(coh901327_exit); +module_platform_driver_probe(coh901327_driver, coh901327_probe); MODULE_AUTHOR("Linus Walleij "); MODULE_DESCRIPTION("COH 901 327 Watchdog"); diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c index 9a45d029..bc17dec 100644 --- a/drivers/watchdog/imx2_wdt.c +++ b/drivers/watchdog/imx2_wdt.c @@ -342,17 +342,7 @@ static struct platform_driver imx2_wdt_driver = { }, }; -static int __init imx2_wdt_init(void) -{ - return platform_driver_probe(&imx2_wdt_driver, imx2_wdt_probe); -} -module_init(imx2_wdt_init); - -static void __exit imx2_wdt_exit(void) -{ - platform_driver_unregister(&imx2_wdt_driver); -} -module_exit(imx2_wdt_exit); +module_platform_driver_probe(imx2_wdt_driver, imx2_wdt_probe); MODULE_AUTHOR("Wolfram Sang"); MODULE_DESCRIPTION("Watchdog driver for IMX2 and later"); diff --git a/drivers/watchdog/txx9wdt.c b/drivers/watchdog/txx9wdt.c index 98e1637..b04c92b 100644 --- a/drivers/watchdog/txx9wdt.c +++ b/drivers/watchdog/txx9wdt.c @@ -172,18 +172,7 @@ static struct platform_driver txx9wdt_driver = { }, }; -static int __init watchdog_init(void) -{ - return platform_driver_probe(&txx9wdt_driver, txx9wdt_probe); -} - -static void __exit watchdog_exit(void) -{ - platform_driver_unregister(&txx9wdt_driver); -} - -module_init(watchdog_init); -module_exit(watchdog_exit); +module_platform_driver_probe(txx9wdt_driver, txx9wdt_probe); MODULE_DESCRIPTION("TXx9 Watchdog Driver"); MODULE_LICENSE("GPL"); -- 1.8.0.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] usb: converto drivers/usb/* to use module_platform_driver_probe()
This patch converts the drivers in drivers/usb/* to use the module_platform_driver_probe() macro which makes the code smaller and a bit simpler. Signed-off-by: Fabio Porcedda Cc: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman Cc: Felipe Balbi Cc: Nicolas Ferre Cc: Eric Miao Cc: Russell King Cc: Haojian Zhuang --- drivers/usb/gadget/at91_udc.c | 12 +--- drivers/usb/gadget/atmel_usba_udc.c | 12 +--- drivers/usb/gadget/fusb300_udc.c| 13 + drivers/usb/gadget/imx_udc.c| 12 +--- drivers/usb/gadget/lpc32xx_udc.c| 12 +--- drivers/usb/gadget/m66592-udc.c | 12 +--- drivers/usb/gadget/pxa25x_udc.c | 15 +++ drivers/usb/gadget/r8a66597-udc.c | 15 ++- drivers/usb/otg/gpio_vbus.c | 12 +--- drivers/usb/otg/msm_otg.c | 13 + 10 files changed, 13 insertions(+), 115 deletions(-) diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index f4a21f6..0143ffa 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -1982,17 +1982,7 @@ static struct platform_driver at91_udc_driver = { }, }; -static int __init udc_init_module(void) -{ - return platform_driver_probe(&at91_udc_driver, at91udc_probe); -} -module_init(udc_init_module); - -static void __exit udc_exit_module(void) -{ - platform_driver_unregister(&at91_udc_driver); -} -module_exit(udc_exit_module); +module_platform_driver_probe(at91_udc_driver, at91udc_probe); MODULE_DESCRIPTION("AT91 udc driver"); MODULE_AUTHOR("Thomas Rathbone, David Brownell"); diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index a7aed84..bc19496 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c @@ -2066,17 +2066,7 @@ static struct platform_driver udc_driver = { }, }; -static int __init udc_init(void) -{ - return platform_driver_probe(&udc_driver, usba_udc_probe); -} -module_init(udc_init); - -static void __exit udc_exit(void) -{ - platform_driver_unregister(&udc_driver); -} -module_exit(udc_exit); +module_platform_driver_probe(udc_driver, usba_udc_probe); MODULE_DESCRIPTION("Atmel USBA UDC driver"); MODULE_AUTHOR("Haavard Skinnemoen (Atmel)"); diff --git a/drivers/usb/gadget/fusb300_udc.c b/drivers/usb/gadget/fusb300_udc.c index 72cd5e6..fc7cb09 100644 --- a/drivers/usb/gadget/fusb300_udc.c +++ b/drivers/usb/gadget/fusb300_udc.c @@ -1547,15 +1547,4 @@ static struct platform_driver fusb300_driver = { }, }; -static int __init fusb300_udc_init(void) -{ - return platform_driver_probe(&fusb300_driver, fusb300_probe); -} - -module_init(fusb300_udc_init); - -static void __exit fusb300_udc_cleanup(void) -{ - platform_driver_unregister(&fusb300_driver); -} -module_exit(fusb300_udc_cleanup); +module_platform_driver_probe(fusb300_driver, fusb300_probe); diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c index a0eb857..8efd755 100644 --- a/drivers/usb/gadget/imx_udc.c +++ b/drivers/usb/gadget/imx_udc.c @@ -1556,17 +1556,7 @@ static struct platform_driver udc_driver = { .resume = imx_udc_resume, }; -static int __init udc_init(void) -{ - return platform_driver_probe(&udc_driver, imx_udc_probe); -} -module_init(udc_init); - -static void __exit udc_exit(void) -{ - platform_driver_unregister(&udc_driver); -} -module_exit(udc_exit); +module_platform_driver_probe(udc_driver, imx_udc_probe); MODULE_DESCRIPTION("IMX USB Device Controller driver"); MODULE_AUTHOR("Darius Augulis "); diff --git a/drivers/usb/gadget/lpc32xx_udc.c b/drivers/usb/gadget/lpc32xx_udc.c index dd1c9b1..aa04089 100644 --- a/drivers/usb/gadget/lpc32xx_udc.c +++ b/drivers/usb/gadget/lpc32xx_udc.c @@ -3458,17 +3458,7 @@ static struct platform_driver lpc32xx_udc_driver = { }, }; -static int __init udc_init_module(void) -{ - return platform_driver_probe(&lpc32xx_udc_driver, lpc32xx_udc_probe); -} -module_init(udc_init_module); - -static void __exit udc_exit_module(void) -{ - platform_driver_unregister(&lpc32xx_udc_driver); -} -module_exit(udc_exit_module); +module_platform_driver_probe(lpc32xx_udc_driver, lpc32xx_udc_probe); MODULE_DESCRIPTION("LPC32XX udc driver"); MODULE_AUTHOR("Kevin Wells "); diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c index b6401f1..dfce0cf 100644 --- a/drivers/usb/gadget/m66592-udc.c +++ b/drivers/usb/gadget/m66592-udc.c @@ -1753,14 +1753,4 @@ static struct platform_driver m66592_driver = { }, }; -static int __init m66592_udc_init(void) -{ - return platform_driver_probe(&m66592_driver, m66592_probe); -} -module_init(m66592_udc_init); - -static void __exit m66592_udc_cleanup(void) -{ - platform_driver_unreg
[PATCH 1/3] driver core: add helper macro for platform_driver_probe() boilerplate
For simple modules that contain a single platform_driver without any additional setup code then ends up being a block of duplicated boilerplate. This patch adds a new macro, module_platform_driver_probe(), which replaces the module_init()/module_exit() registrations with template functions. This macro use the same idea of module_platform_driver(). This macro is useful to stop the misuse of module_platform_driver() for removing the platform_driver_probe() boilerplate. Signed-off-by: Fabio Porcedda Cc: Greg Kroah-Hartman --- include/linux/platform_device.h | 18 ++ 1 file changed, 18 insertions(+) diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index a9ded9a..c082c71 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -204,6 +204,24 @@ static inline void platform_set_drvdata(struct platform_device *pdev, void *data module_driver(__platform_driver, platform_driver_register, \ platform_driver_unregister) +/* module_platform_driver_probe() - Helper macro for drivers that don't do + * anything special in module init/exit. This eliminates a lot of + * boilerplate. Each module may only use this macro once, and + * calling it replaces module_init() and module_exit() + */ +#define module_platform_driver_probe(__platform_driver, __platform_probe) \ +static int __init __platform_driver##_init(void) \ +{ \ + return platform_driver_probe(&(__platform_driver), \ +__platform_probe);\ +} \ +module_init(__platform_driver##_init); \ +static void __exit __platform_driver##_exit(void) \ +{ \ + platform_driver_unregister(&(__platform_driver)); \ +} \ +module_exit(__platform_driver##_exit); + extern struct platform_device *platform_create_bundle(struct platform_driver *driver, int (*probe)(struct platform_device *), struct resource *res, unsigned int n_res, -- 1.8.0.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/3] Add and use new macro module_platform_driver_probe()
For simple modules that contain a single platform_driver without any additional setup code then ends up being a block of duplicated boilerplate. This patch adds a new macro, module_platform_driver_probe(), which replaces the module_init()/module_exit() registrations with template functions. This macro use the same idea of module_platform_driver(). This macro is useful to stop the misuse of module_platform_driver() for removing the platform_driver_probe() boilerplate. Convert drivers/usb/* and drivers/watchdog/* to use module_platform_driver_probe(). Best regards Fabio Porcedda (3): driver core: add helper macro for platform_driver_probe() boilerplate watchdog: convert drivers/watchdog/* to use module_platform_driver_probe usb: converto drivers/usb/* to use module_platform_driver_probe() drivers/usb/gadget/at91_udc.c | 12 +--- drivers/usb/gadget/atmel_usba_udc.c | 12 +--- drivers/usb/gadget/fusb300_udc.c| 13 + drivers/usb/gadget/imx_udc.c| 12 +--- drivers/usb/gadget/lpc32xx_udc.c| 12 +--- drivers/usb/gadget/m66592-udc.c | 12 +--- drivers/usb/gadget/pxa25x_udc.c | 15 +++ drivers/usb/gadget/r8a66597-udc.c | 15 ++- drivers/usb/otg/gpio_vbus.c | 12 +--- drivers/usb/otg/msm_otg.c | 13 + drivers/watchdog/at32ap700x_wdt.c | 12 +--- drivers/watchdog/at91sam9_wdt.c | 13 + drivers/watchdog/coh901327_wdt.c| 12 +--- drivers/watchdog/imx2_wdt.c | 12 +--- drivers/watchdog/txx9wdt.c | 13 + include/linux/platform_device.h | 18 ++ 16 files changed, 36 insertions(+), 172 deletions(-) -- 1.8.0.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] usb: gadget: at91_udc: dt: fix platform_data check
Don't fail the initialization check for the platform_data if there is avaiable an associated device tree node. This patch fix the dt support introduced in 3.4-rc1 by commit ("d1494a3 USB: at91: Device udc add dt support"). Tested on a at91sam9260 based board (PRO3-EVK). Signed-off-by: Fabio Porcedda Cc: Stable [v3.4+] Cc: Jean-Christophe PLAGNIOL-VILLARD --- v2: - better description - add stable tag drivers/usb/gadget/at91_udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 1e35963..660fd53 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -1699,7 +1699,7 @@ static int __devinit at91udc_probe(struct platform_device *pdev) int retval; struct resource *res; - if (!dev->platform_data) { + if (!dev->platform_data && !pdev->dev.of_node) { /* small (so we copy it) but critical! */ DBG("missing platform_data\n"); return -ENODEV; -- 1.7.11.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: gadget: at91_udc: fix dt support
Don't fail the initialization check for the platform_data if there is avaiable an associated device tree node. Signed-off-by: Fabio Porcedda --- drivers/usb/gadget/at91_udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index c9e66df..4147219 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -1703,7 +1703,7 @@ static int __devinit at91udc_probe(struct platform_device *pdev) int retval; struct resource *res; - if (!dev->platform_data) { + if (!dev->platform_data && !pdev->dev.of_node) { /* small (so we copy it) but critical! */ DBG("missing platform_data\n"); return -ENODEV; -- 1.7.11.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH for v3.5 0/2] usb: gadget: at91_udc: fix oops regression
On Mon, Jul 23, 2012 at 12:53 PM, Felipe Balbi wrote: > On Fri, Jul 20, 2012 at 10:33:24AM +0200, Fabio Porcedda wrote: >> On Fri, Jul 20, 2012 at 12:50 AM, Greg Kroah-Hartman >> wrote: >> > On Thu, Jul 19, 2012 at 07:16:54PM +0200, Sebastian Andrzej Siewior wrote: >> >> On Thu, Jul 19, 2012 at 03:50:54PM +0200, Fabio Porcedda wrote: >> >> > > I would prefer to fix the bug causing the oops instead of reverting >> >> > > patches. >> >> > >> >> > Me too, it's just that i don't have much time to work on that, and so >> >> > I'm not confident to be able to fix the kernel panic oops in time for >> >> > the v3.5 release. >> >> Yes. If nobody looks into this then the v3.5 kernel will be released and >> >> other >> >> kernels will follow. >> >> Would you now please test it and say that it works with those two patches >> >> I >> >> just posted? >> >> The patches fix both issues, now the driver works again! > > please then resend with all acks and a Cc: sta...@vger.kernel.org so I > can queue it when -rc1 is tagged. Sebastian had already resent the patches with my Tested-by tag added, and the tag: Cc: sta...@kernel.org please read these emails: bug fixes for at91_udc, introduced in v3.5 release cycle http://marc.info/?l=linux-usb&m=134280952400955&w=2 [PATCH 1/2] usb/at91udc: don't overwrite driver data http://marc.info/?l=linux-usb&m=134280952700957&w=2 [PATCH 2/2] usb/at91udc: Don't check for ep->ep.desc http://marc.info/?l=linux-usb&m=134280952700958&w=2 P.S. I'm sorry for the previous email, they where rejected for the erroneous html contents. Best regards -- Fabio Porcedda Software Developer - R&D Cagliari Telit Communications S.p.A. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH for v3.5 0/2] usb: gadget: at91_udc: fix oops regression
On Fri, Jul 20, 2012 at 12:50 AM, Greg Kroah-Hartman wrote: > On Thu, Jul 19, 2012 at 07:16:54PM +0200, Sebastian Andrzej Siewior wrote: >> On Thu, Jul 19, 2012 at 03:50:54PM +0200, Fabio Porcedda wrote: >> > > I would prefer to fix the bug causing the oops instead of reverting >> > > patches. >> > >> > Me too, it's just that i don't have much time to work on that, and so >> > I'm not confident to be able to fix the kernel panic oops in time for >> > the v3.5 release. >> Yes. If nobody looks into this then the v3.5 kernel will be released and >> other >> kernels will follow. >> Would you now please test it and say that it works with those two patches I >> just posted? The patches fix both issues, now the driver works again! Thanks. >> >> Greg: Any chance to get this two bugfixes into the current release? > > It's too late for 3.5, sorry, but patches can always be backported to > stable releases if they are causing problems. > > thanks, > > greg k-h Regards -- Fabio Porcedda -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] usb/at91udc: Don't check for ep->ep.desc
On Thu, Jul 19, 2012 at 7:10 PM, Sebastian Andrzej Siewior wrote: > We used earlier to check for ep->ep.desc to figure out if this ep is > already enabled and if so, abort. > Ido Shayevitz removed the usb_endpoint_descriptor from private udc > structure 5a6506f00 ("usb: gadget: Update at91_udc to use > usb_endpoint_descriptor inside the struct usb_ep") but did not fix up > the ep_enable condition because _now_ the member is always true and we > can't check if this ep is enabled twice. > > Cc: Ido Shayevitz > Signed-off-by: Sebastian Andrzej Siewior > --- > drivers/usb/gadget/at91_udc.c |4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c > index 5fd61e2..22865dd 100644 > --- a/drivers/usb/gadget/at91_udc.c > +++ b/drivers/usb/gadget/at91_udc.c > @@ -475,8 +475,7 @@ static int at91_ep_enable(struct usb_ep *_ep, > unsigned long flags; > > if (!_ep || !ep > - || !desc || ep->ep.desc > - || _ep->name == ep0name > + || !desc || _ep->name == ep0name > || desc->bDescriptorType != USB_DT_ENDPOINT > || (maxpacket = usb_endpoint_maxp(desc)) == 0 > || maxpacket > ep->maxpacket) { > @@ -530,7 +529,6 @@ ok: > tmp |= AT91_UDP_EPEDS; > __raw_writel(tmp, ep->creg); > > - ep->ep.desc = desc; > ep->ep.maxpacket = maxpacket; > > /* > -- > 1.7.10.4 > Now the driver works fine. Tested-by: Fabio Porcedda Regards -- Fabio Porcedda -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] usb/at91udc: don't overwrite driver data
On Thu, Jul 19, 2012 at 7:10 PM, Sebastian Andrzej Siewior wrote: > The driver was converted to the new start/stop interface in f3d8bf34c2 > ("usb: gadget: at91_udc: convert to new style start/stop interface"). > I overlooked that the driver is overwritting the private data which is > used by the composite framework. The udc driver doesn't read it, it is > only writen here > > Signed-off-by: Sebastian Andrzej Siewior > --- > drivers/usb/gadget/at91_udc.c |2 -- > 1 file changed, 2 deletions(-) > > diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c > index 1a4430f..5fd61e2 100644 > --- a/drivers/usb/gadget/at91_udc.c > +++ b/drivers/usb/gadget/at91_udc.c > @@ -1634,7 +1634,6 @@ static int at91_start(struct usb_gadget *gadget, > udc = container_of(gadget, struct at91_udc, gadget); > udc->driver = driver; > udc->gadget.dev.driver = &driver->driver; > - dev_set_drvdata(&udc->gadget.dev, &driver->driver); > udc->enabled = 1; > udc->selfpowered = 1; > > @@ -1655,7 +1654,6 @@ static int at91_stop(struct usb_gadget *gadget, > spin_unlock_irqrestore(&udc->lock, flags); > > udc->gadget.dev.driver = NULL; > - dev_set_drvdata(&udc->gadget.dev, NULL); > udc->driver = NULL; > > DBG("unbound from %s\n", driver->driver.name); > -- > 1.7.10.4 > Now the driver works fine. Tested-by: Fabio Porcedda Regards -- Fabio Porcedda -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH for v3.5 0/2] usb: gadget: at91_udc: fix oops regression
On Wed, Jul 18, 2012 at 11:56 AM, Sebastian Andrzej Siewior wrote: > On Mon, Jul 16, 2012 at 02:50:29PM +0200, Fabio Porcedda wrote: >> PROBLEM: >> 1. >> usb: gadget: at91_udc: kernel oops regression when connecting the usb cable >> >> 2. >> Every time i connect the usb cable the kernel got a oops > Don't really see the difference to 1 You are right. I've tried to follow the "REPORTING-BUGS" format, the point 2. it's just a description of the point 1. >> 3. >> usb gadget arm atmel at91_udc g_ether >> >> 4. >> The latest working kernel release is v3.4, >> the first non-woring release is v3.5-rc1. >> >> I've used an Atmel AT91SAM9260EK board. > > I would prefer to fix the bug causing the oops instead of reverting patches. Me too, it's just that i don't have much time to work on that, and so I'm not confident to be able to fix the kernel panic oops in time for the v3.5 release. IMHO it's not nice to release the v3.5 with a broken at91_udc driver, at least for the AT91SAM9260, i don't know if it's working on any other soc. Best regards -- Fabio Porcedda -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH for v3.5 2/2] usb: gadget: at91_udc: fix regression when connecting the usb cable
Revert "usb: gadget: at91_udc: fix endpoint descriptor dereference" Revert "usb: gadget: Update at91_udc to use usb_endpoint_descriptor inside the struct usb_ep" This reverts commit 5eaee54b1c52a83dc74445792cf49900a8050da8. This reverts commit 5a6506f00efa4b38b181152b69a072e766c7ce92. Tested using the Atmel AT91SAM9260EK board. After connecting the cable the g_ether driver doesn't work as expected. AT91SAM9260EK dmesg output with USB_GADGET_DEBUG defined: udc: active g_ether gadget: suspend g_ether gadget: resume g_ether gadget: suspend g_ether gadget: resume g_ether gadget: full-speed config #1: CDC Ethernet (ECM) udc: bad ep or descriptor g_ether gadget: init ecm g_ether gadget: notify connect false g_ether gadget: activate ecm udc: bad ep or descriptor usb0: enable ep1 --> -22 g_ether gadget: reset ecm [ cut here ] WARNING: at drivers/usb/gadget/u_ether.c:941 ecm_set_alt+0x60/0x1fc() Modules linked in: [] (unwind_backtrace+0x0/0xf0) from [] (warn_slowpath_common+0x4c/0x64) [] (warn_slowpath_common+0x4c/0x64) from [] (warn_slowpath_null+0x1c/0x24) [] (warn_slowpath_null+0x1c/0x24) from [] (ecm_set_alt+0x60/0x1fc) [] (ecm_set_alt+0x60/0x1fc) from [] (composite_setup+0x198/0xc9c) [] (composite_setup+0x198/0xc9c) from [] (at91_udc_irq+0x4a0/0x878) [] (at91_udc_irq+0x4a0/0x878) from [] (handle_irq_event_percpu+0x50/0x1cc) [] (handle_irq_event_percpu+0x50/0x1cc) from [] (handle_irq_event+0x28/0x38) [] (handle_irq_event+0x28/0x38) from [] (handle_level_irq+0x80/0xdc) [] (handle_level_irq+0x80/0xdc) from [] (generic_handle_irq+0x28/0x3c) [] (generic_handle_irq+0x28/0x3c) from [] (handle_IRQ+0x30/0x98) [] (handle_IRQ+0x30/0x98) from [] (__irq_svc+0x38/0x60) [] (__irq_svc+0x38/0x60) from [] (default_idle+0x24/0x40) [] (default_idle+0x24/0x40) from [] (cpu_idle+0x8c/0xcc) [] (cpu_idle+0x8c/0xcc) from [] (start_kernel+0x280/0x2d0) ---[ end trace 0980cb0ba7b8f3cd ]--- g_ether gadget: activate ecm udc: bad ep or descriptor usb0: enable ep1 --> -22 usb host pc linux Ubuntu 12.04: [ 6972.812030] usb 4-2: new full-speed USB device number 8 using uhci_hcd [ 6973.126106] cdc_subset: probe of 4-2:1.0 failed with error -22 [ 6973.228065] cdc_ether: probe of 4-2:1.0 failed with error -32 [ 6973.330068] cdc_subset: probe of 4-2:1.1 failed with error -32 Seems that another way to fix the regression is to remove the check: @@ -475,7 +475,7 @@ static int at91_ep_enable(struct usb_ep *_ep, unsigned long flags; if (!_ep || !ep - || !desc || ep->ep.desc + || !desc || _ep->name == ep0name || desc->bDescriptorType != USB_DT_ENDPOINT || (maxpacket = usb_endpoint_maxp(desc)) == 0 Signed-off-by: Fabio Porcedda Reported-And-Tested-by: Fabio Porcedda Reported-by: Mario Jorge Isidoro Cc: linux-usb@vger.kernel.org Cc: Sebastian Andrzej Siewior Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: Nicolas Ferre Cc: Ido Shayevitz Cc: Jean-Christophe PLAGNIOL-VILLARD --- drivers/usb/gadget/at91_udc.c | 17 + drivers/usb/gadget/at91_udc.h | 3 +++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 7687ccd..9d7bcd9 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -212,7 +212,7 @@ static int proc_udc_show(struct seq_file *s, void *unused) if (udc->enabled && udc->vbus) { proc_ep_show(s, &udc->ep[0]); list_for_each_entry (ep, &udc->gadget.ep_list, ep.ep_list) { - if (ep->ep.desc) + if (ep->desc) proc_ep_show(s, ep); } } @@ -475,7 +475,7 @@ static int at91_ep_enable(struct usb_ep *_ep, unsigned long flags; if (!_ep || !ep - || !desc || ep->ep.desc + || !desc || ep->desc || _ep->name == ep0name || desc->bDescriptorType != USB_DT_ENDPOINT || (maxpacket = usb_endpoint_maxp(desc)) == 0 @@ -530,7 +530,7 @@ ok: tmp |= AT91_UDP_EPEDS; __raw_writel(tmp, ep->creg); - ep->ep.desc = desc; + ep->desc = desc; ep->ep.maxpacket = maxpacket; /* @@ -558,6 +558,7 @@ static int at91_ep_disable (struct usb_ep * _ep) nuke(ep, -ESHUTDOWN); /* restore the endpoint's pristine config */ + ep->desc = NULL; ep->ep.desc = NULL; ep->ep.maxpacket = ep->maxpacket; @@ -617,7 +618,7 @@ static int at91_ep_queue(struct usb_ep *_ep, return -EINVAL; } - if (!_ep || (!ep->ep.desc && ep->ep.name != ep0name)) { + if (!_ep || (!ep->desc && ep->e
[RFC PATCH for v3.5 1/2] usb: gadget: at91_udc: fix oops regression when connecting usb cable
Revert "usb: gadget: at91_udc: convert to new style start/stop interface" This reverts commit f3d8bf34c2c925867322197096ed501ceab8085a. Tested on the Atmel AT91SAM9260EK board. The oops occur every time i connect the usb cable. kernel console output: pgd = c3aec000 [206d6365] *pgd= Internal error: Oops: 1 [#1] ARM Modules linked in: CPU: 0Not tainted (3.5.0-rc7 #22) PC is at __dev_printk+0x20/0x198 LR is at dev_printk+0x2c/0x3c pc : []lr : []psr: 2093 sp : c0365d48 ip : c0309a8c fp : 0001 r10: c0374c78 r9 : c038b900 r8 : c0365e04 r7 : c02e8440 r6 : 0004 r5 : c03877d8 r4 : c030997c r3 : 206d6365 r2 : c0365e04 r1 : c030997c r0 : c02e8440 Flags: nzCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment kernel Control: 0005317f Table: 23aec000 DAC: 0017 Process swapper (pid: 0, stack limit = 0xc0364270) Stack: (0xc0365d48 to 0xc0366000) ... [] (__dev_printk+0x20/0x198) from [] (dev_printk+0x2c/0x3c) [] (dev_printk+0x2c/0x3c) from [] (composite_suspend+0x28/0xc8) [] (composite_suspend+0x28/0xc8) from [] (at91_udc_irq+0xbc/0x878) [] (at91_udc_irq+0xbc/0x878) from [] (handle_irq_event_percpu+0x50/0x1cc) [] (handle_irq_event_percpu+0x50/0x1cc) from [] (handle_irq_event+0x28/0x38) [] (handle_irq_event+0x28/0x38) from [] (handle_level_irq+0x80/0xdc) [] (handle_level_irq+0x80/0xdc) from [] (generic_handle_irq+0x28/0x3c) Mario Jorge Isidoro: "I've tracked the error to line 1099 of the file drivers/usb/gadget/composite.c This line is in the function "static int composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)" line 1099: req->zero = 0; // req is NULL, this is where it blows up The function is called from the function "static void handle_setup(struct at91_udc *udc, struct at91_ep *ep, u32 csr)" in drivers/usb/gadget/at91_udc.c on line 1246 line 1246: status = udc->driver->setup(&udc->gadget, &pkt.r); So, from at91_udc_irq to composite_setup the path seems to be: at91_udc_irq (line 1490) -> handle_ep0 (line 1289) -> handle_setup (line 1264) -> composite_setup" Signed-off-by: Fabio Porcedda Reported-And-Tested-by: Fabio Porcedda Reported-And-Tested-by: Mario Jorge Isidoro Cc: linux-usb@vger.kernel.org Cc: Sebastian Andrzej Siewior Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: Nicolas Ferre Cc: Ido Shayevitz Cc: Jean-Christophe PLAGNIOL-VILLARD --- drivers/usb/gadget/at91_udc.c | 60 +-- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 1a4430f..7687ccd 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -977,18 +977,18 @@ static int at91_set_selfpowered(struct usb_gadget *gadget, int is_on) return 0; } -static int at91_start(struct usb_gadget *gadget, - struct usb_gadget_driver *driver); -static int at91_stop(struct usb_gadget *gadget, - struct usb_gadget_driver *driver); +static int at91_start(struct usb_gadget_driver *driver, + int (*bind)(struct usb_gadget *)); +static int at91_stop(struct usb_gadget_driver *driver); + static const struct usb_gadget_ops at91_udc_ops = { .get_frame = at91_get_frame, .wakeup = at91_wakeup, .set_selfpowered= at91_set_selfpowered, .vbus_session = at91_vbus_session, .pullup = at91_pullup, - .udc_start = at91_start, - .udc_stop = at91_stop, + .start = at91_start, + .stop = at91_stop, /* * VBUS-powered devices may also also want to support bigger @@ -1626,34 +1626,66 @@ static void at91_vbus_timer(unsigned long data) schedule_work(&udc->vbus_timer_work); } -static int at91_start(struct usb_gadget *gadget, - struct usb_gadget_driver *driver) +static int at91_start(struct usb_gadget_driver *driver, + int (*bind)(struct usb_gadget *)) { - struct at91_udc *udc; + struct at91_udc *udc = &controller; + int retval; + unsigned long flags; + + if (!driver + || driver->max_speed < USB_SPEED_FULL + || !bind + || !driver->setup) { + DBG("bad parameter.\n"); + return -EINVAL; + } + + if (udc->driver) { + DBG("UDC already has a gadget driver\n"); + return -EBUSY; + } - udc = container_of(gadget, struct at91_udc, gadget); udc->driver = driver; udc->gadget.dev.driver = &driver->driver; dev_set_drvdata(&udc->gadget.dev, &driver->driver); udc-&g
[RFC PATCH for v3.5 0/2] usb: gadget: at91_udc: fix oops regression
Hi all, as reported in previous emails, me and Mario Jorge Isidoro have reported a kernel oops using the at91_udc & g_ether driver: http://marc.info/?l=linux-usb&m=134139521606528&w=2 http://marc.info/?l=linux-usb&m=134159125907159&w=2 PROBLEM: 1. usb: gadget: at91_udc: kernel oops regression when connecting the usb cable 2. Every time i connect the usb cable the kernel got a oops 3. usb gadget arm atmel at91_udc g_ether 4. The latest working kernel release is v3.4, the first non-woring release is v3.5-rc1. I've used an Atmel AT91SAM9260EK board. Through bisect we have found that: - the oops is present after commit: f3d8bf34c2c925867322197096ed501ceab8085a - the fix 5eaee54b1c52a83dc74445792cf49900a8050da8 for the build issue of 5a6506f00efa4b38b181152b69a072e766c7ce92 caused another regression. I don't have enough time to fix properly those commits, i suggest for the v3.5 release to just revert those three commits: f3d8bf34c2c925867322197096ed501ceab8085a 5eaee54b1c52a83dc74445792cf49900a8050da8 5a6506f00efa4b38b181152b69a072e766c7ce92 More details in the folloing patches. Fabio Porcedda (2): usb: gadget: at91_udc: fix oops regression when connecting usb cable usb: gadget: at91_udc: fix regression when connecting the usb cable drivers/usb/gadget/at91_udc.c | 77 ++- drivers/usb/gadget/at91_udc.h | 3 ++ 2 files changed, 58 insertions(+), 22 deletions(-) -- 1.7.11.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: NULL pointer dereference in at91_udc on start of connection
> -Original Message- > From: Sebastian Andrzej Siewior [mailto:sebast...@breakpoint.cc] > Sent: terça-feira, 10 de Julho de 2012 16:37 > To: Mario Jorge Isidoro > Cc: Fabio Porcedda; Sebastian Andrzej Siewior; ba...@ti.com; > gre...@linuxfoundation.org; linux-usb@vger.kernel.org; Nicolas Ferre; Ido > Shayevitz; Jean-Christophe PLAGNIOL-VILLARD > Subject: Re: NULL pointer dereference in at91_udc on start of connection > > On Tue, Jul 10, 2012 at 03:54:06PM +0100, Mario Jorge Isidoro wrote: >> I've found that the following change also works, if someone doesn't want to >> simply eliminate the check >> diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c >> index 7687ccd..33a6999 100644 >> --- a/drivers/usb/gadget/at91_udc.c >> +++ b/drivers/usb/gadget/at91_udc.c >> @@ -475,7 +475,7 @@ static int at91_ep_enable(struct usb_ep *_ep, >> unsigned long flags; >> >> if (!_ep || !ep >> - || !desc || ep->ep.desc >> + || !desc || !ep->ep.desc > > This check ensures that you do not try to enable an endpoint twice. Once > enabled, ep->ep.desc should be set. > >> || _ep->name == ep0name > ep.desc is always NULL for ep0 and this one should not be enabled. Therefore > you have this check here. > >> || desc->bDescriptorType != USB_DT_ENDPOINT >> || (maxpacket = usb_endpoint_maxp(desc)) == 0 > > That means with this change you should not get any endpoints enabled and it > should not work at all. Can you acknowledge this? After removing the check || ep->ep.desc the driver seems to work fine. I was able to successfully transfer a file using the tftp protocol. I try to summarize the results: 1) first case - latest HEAD without any modifications (v3.5-rc6-117-g918227b) when i connect the usb gadget cable i got: Unable to handle kernel paging request at virtual address 206d6365 pgd = c3ac8000 [206d6365] *pgd= Internal error: Oops: 1 [#1] ARM Modules linked in: CPU: 0Not tainted (3.5.0-rc6+ #20) PC is at __dev_printk+0x20/0x198 LR is at dev_printk+0x2c/0x3c pc : []lr : []psr: 2093 sp : c0365de0 ip : c0309a0c fp : 0001 r10: c0374c78 r9 : c038b900 r8 : c0365e9c r7 : c02e83c0 r6 : 0005 r5 : c03877d8 r4 : c03098fc r3 : 206d6365 r2 : c0365e9c r1 : c03098fc r0 : c02e83c0 Flags: nzCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment kernel Control: 0005317f Table: 23ac8000 DAC: 0017 Process swapper (pid: 0, stack limit = 0xc0364270) Stack: (0xc0365de0 to 0xc0366000) 5de0: 0001 c036c070 c03908d8 00e6 c038c230 00c9 5e00: c03908d8 0007 c03908d8 c001f130 0400 0010 00c9 5e20: 2093 0001 c038c230 000b c038c230 c037265c 0006 0007 5e40: c001f4e8 5e60: c038cb3b 000b c004b15c 6093 c0387ae4 c03877d8 0005 5e80: 4093 c038b900 c0374c78 0001 c017ad90 c038b900 c0309a0c 5ea0: c0365ea4 c0365eb4 c03877d8 c01e0cdc c0309a0c c01e0cb4 c03877d8 0100 5ec0: 0005 c01ded98 0001 0001 0065 c038b900 5ee0: c0377448 c396f6e0 000a 000a c038b900 c0374c78 5f00: 0001 c0054c1c 41069265 2035cc2c c0374c78 000a 5f20: c0365f94 20004000 41069265 2035cc2c c0054dc0 c0374c78 c0056ee8 5f40: c037bde0 c0054598 00c0 c000fe0c c000ff64 a013 fefff000 c000ebb8 5f60: 0005317f 0005217f a013 c0364000 c038ba48 c036ebbc c000ff40 5f80: 20004000 41069265 2035cc2c a0d3 c0365fa8 c000ff58 c000ff64 5fa0: a013 6093 c001012c c036c0a0 c038b9a0 c035e304 5fc0: c0422320 c034271c c0342278 c035e304 5fe0: 00053175 c036c01c c035e300 c036ebb4 20008040 [] (__dev_printk+0x20/0x198) from [] (dev_printk+0x2c/0x3c) [] (dev_printk+0x2c/0x3c) from [] (composite_suspend+0x28/0xc8) [] (composite_suspend+0x28/0xc8) from [] (at91_udc_irq+0xbc/0x878) [] (at91_udc_irq+0xbc/0x878) from [] (handle_irq_event_percpu+0x50/0x1cc) [] (handle_irq_event_percpu+0x50/0x1cc) from [] (handle_irq_event+0x28/0x38) [] (handle_irq_event+0x28/0x38) from [] (handle_level_irq+0x80/0xdc) [] (handle_level_irq+0x80/0xdc) from [] (generic_handle_irq+0x28/0x3c) [] (generic_handle_irq+0x28/0x3c) from [] (handle_IRQ+0x30/0x98) [] (handle_IRQ+0x30/0x98) from [] (__irq_svc+0x38/0x60) [] (__irq_svc+0x38/0x60) from [] (default_idle+0x24/0x40) [] (default_idle+0x24/0x40) from [] (cpu_idle+0x8c/0xcc) [] (cpu_idle+0x8c/0xcc) from [] (start_kernel+0x280/0x2d0) Code: e1a08002 0a4f e59430c0 e353 (15936000) ---[ end trace d80a9f0f67ad16c0 ]--- Ke
Re: NULL pointer dereference in at91_udc on start of connection
On Fri, Jul 6, 2012 at 8:06 PM, Mario Jorge Isidoro wrote: > Hi Fabio, > > I tried 3.4 and you were right, it still works fine. > > For the 'struct at91_ep' has no member named 'desc' error I tried commenting > the offending declaration (|| ep->desc) > and it builds without any error. During the bisect run this happened several > times and I think, but am not sure, that some of > this attempts worked fine without displaying the original error. I'm happy to say that with the v3.5-rc6, after reverting the commit f3d8bf34c2c925867322197096ed501ceab8085a and removing the following line: diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 7687ccd..98339a2 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -475,7 +475,6 @@ static int at91_ep_enable(struct usb_ep *_ep, unsigned long flags; if (!_ep || !ep - || !desc || ep->ep.desc || _ep->name == ep0name || desc->bDescriptorType != USB_DT_ENDPOINT || (maxpacket = usb_endpoint_maxp(desc)) == 0 Now the at91_udc driver with g_ether it's working again. I don't understand the reason, but now it seems to work fine. If there isn't a better solution i propose to revert the commit f3d8bf34c2c925867322197096ed501ceab8085a and remove the line on the at91_udc driver. Best regards -- Fabio Porcedda -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: NULL pointer dereference in at91_udc on start of connection
LK_DEV_RAM=y CONFIG_BLK_DEV_RAM_SIZE=8192 CONFIG_SCSI=y CONFIG_BLK_DEV_SD=y CONFIG_SCSI_MULTI_LUN=y CONFIG_NETDEVICES=y CONFIG_MII=y CONFIG_MACB=y # CONFIG_INPUT_MOUSEDEV_PSAUX is not set # CONFIG_INPUT_KEYBOARD is not set # CONFIG_INPUT_MOUSE is not set # CONFIG_SERIO is not set CONFIG_SERIAL_ATMEL=y CONFIG_SERIAL_ATMEL_CONSOLE=y # CONFIG_HW_RANDOM is not set CONFIG_I2C=y CONFIG_I2C_CHARDEV=y CONFIG_I2C_GPIO=y # CONFIG_HWMON is not set CONFIG_WATCHDOG=y CONFIG_WATCHDOG_NOWAYOUT=y CONFIG_AT91SAM9X_WATCHDOG=y # CONFIG_USB_HID is not set CONFIG_USB=y CONFIG_USB_MON=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_STORAGE=y CONFIG_USB_STORAGE_DEBUG=y CONFIG_USB_GADGET=y CONFIG_USB_AT91=y CONFIG_USB_ETH=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_AT91SAM9=y CONFIG_EXT2_FS=y CONFIG_VFAT_FS=y CONFIG_TMPFS=y CONFIG_UBIFS_FS=y CONFIG_CRAMFS=y CONFIG_NLS_CODEPAGE_437=y CONFIG_NLS_CODEPAGE_850=y CONFIG_NLS_ISO8859_1=y CONFIG_DEBUG_KERNEL=y CONFIG_DEBUG_USER=y CONFIG_DEBUG_LL=y Best regards -- Fabio Porcedda -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html