[PATCH] rewrite isd200_init_info for readability

2015-08-28 Thread Kris Borer
Previously, Coccinelle would issue the following false positive:

isd200.c:1478:14-18: ERROR: reference preceded by free on line 1472

This change rewrites the isd200_init_info function to have more explicit
execution pathways to make it easier for scripts and humans to parse.

Signed-off-by: Kris Borer kbo...@gmail.com
---
 drivers/usb/storage/isd200.c | 30 +-
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
index 1bac215..39afd70 100644
--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -1456,30 +1456,26 @@ static void isd200_free_info_ptrs(void *info_)
  */
 static int isd200_init_info(struct us_data *us)
 {
-   int retStatus = ISD200_GOOD;
struct isd200_info *info;
 
info = kzalloc(sizeof(struct isd200_info), GFP_KERNEL);
if (!info)
-   retStatus = ISD200_ERROR;
-   else {
-   info-id = kzalloc(ATA_ID_WORDS * 2, GFP_KERNEL);
-   info-RegsBuf = kmalloc(sizeof(info-ATARegs), GFP_KERNEL);
-   info-srb.sense_buffer =
-   kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL);
-   if (!info-id || !info-RegsBuf || !info-srb.sense_buffer) {
-   isd200_free_info_ptrs(info);
-   kfree(info);
-   retStatus = ISD200_ERROR;
-   }
-   }
+   return ISD200_ERROR;
 
-   if (retStatus == ISD200_GOOD) {
-   us-extra = info;
-   us-extra_destructor = isd200_free_info_ptrs;
+   info-id = kzalloc(ATA_ID_WORDS * 2, GFP_KERNEL);
+   info-RegsBuf = kmalloc(sizeof(info-ATARegs), GFP_KERNEL);
+   info-srb.sense_buffer = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL);
+
+   if (!info-id || !info-RegsBuf || !info-srb.sense_buffer) {
+   isd200_free_info_ptrs(info);
+   kfree(info);
+   return ISD200_ERROR;
}
 
-   return retStatus;
+   us-extra = info;
+   us-extra_destructor = isd200_free_info_ptrs;
+
+   return ISD200_GOOD;
 }
 
 /**
-- 
1.9.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


[PATCH v2] usb: message: remove redundant declaration

2015-08-25 Thread Kris Borer
Fix the Sparse warning:

message.c:1390:21: warning: symbol 'i' shadows an earlier one
message.c:1294:13: originally declared here

Signed-off-by: Kris Borer kbo...@gmail.com
---
 drivers/usb/core/message.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index f368d20..5f07e4e 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1387,8 +1387,6 @@ int usb_set_interface(struct usb_device *dev, int 
interface, int alternate)
 * new altsetting.
 */
if (manual) {
-   int i;
-
for (i = 0; i  alt-desc.bNumEndpoints; i++) {
epaddr = alt-endpoint[i].desc.bEndpointAddress;
pipe = __create_pipe(dev,
-- 
1.9.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


[PATCH] usb: message: remove redundant declaration

2015-08-24 Thread Kris Borer
Fix the Sparse warning:

message.c:1390:21: warning: symbol 'i' shadows an earlier one
message.c:1294:13: originally declared here

Signed-off-by: Kris Borer kbo...@gmail.com
---
 drivers/usb/core/message.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index f368d20..e83648d 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1387,7 +1387,6 @@ int usb_set_interface(struct usb_device *dev, int 
interface, int alternate)
 * new altsetting.
 */
if (manual) {
-   int i;
 
for (i = 0; i  alt-desc.bNumEndpoints; i++) {
epaddr = alt-endpoint[i].desc.bEndpointAddress;
-- 
1.9.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


[PATCH] usb: hub: remove redundant declarations

2015-08-21 Thread Kris Borer
Fix two occurrences of the Sparse warning:

warning: symbol XXX shadows an earlier one

Signed-off-by: Kris Borer kbo...@gmail.com
---
 drivers/usb/core/hub.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 431839b..a0db6a4 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1070,7 +1070,7 @@ static void hub_activate(struct usb_hub *hub, enum 
hub_activation_type type)
 * for HUB_POST_RESET, but it's easier not to.
 */
if (type == HUB_INIT) {
-   unsigned delay = hub_power_on_good_delay(hub);
+   delay = hub_power_on_good_delay(hub);
 
hub_power_on(hub, false);
INIT_DELAYED_WORK(hub-init_work, hub_init_func2);
@@ -1404,7 +1404,6 @@ static int hub_configure(struct usb_hub *hub,
/* FIXME for USB 3.0, skip for now */
if ((wHubCharacteristics  HUB_CHAR_COMPOUND) 
!(hub_is_superspeed(hdev))) {
-   int i;
charportstr[USB_MAXCHILDREN + 1];
 
for (i = 0; i  maxchild; i++)
-- 
1.9.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


[PATCH] usb: hub: remove assignment from if condition

2015-08-11 Thread Kris Borer
Fix one occurrence of the checkpatch.pl error:

ERROR: do not use assignment in if condition

The semantic patch that makes this change is:

// smpl
@@
identifier i;
expression E, E2, E3;
statement S1, S2;
binary operator b;
@@

+ i = E;
  if (
- (i = E)
+ i
  b
  ...  E2  E3 ) S1 else S2
// /smpl

Signed-off-by: Kris Borer kbo...@gmail.com
---
 drivers/usb/core/hub.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index a0b22be..78bd0d6 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -671,8 +671,8 @@ resubmit:
if (hub-quiescing)
return;
 
-   if ((status = usb_submit_urb(hub-urb, GFP_ATOMIC)) != 0
-status != -ENODEV  status != -EPERM)
+   status = usb_submit_urb(hub-urb, GFP_ATOMIC);
+   if (status != 0  status != -ENODEV  status != -EPERM)
dev_err(hub-intfdev, resubmit -- %d\n, status);
 }
 
-- 
1.9.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


[PATCH] usb: endpoint: convert spaces to tabs

2015-08-10 Thread Kris Borer
Fix one occurrence of the checkpatch error:

ERROR: code indent should use tabs where possible

Signed-off-by: Kris Borer kbo...@gmail.com
---
 drivers/usb/core/endpoint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 39a2402..101983b 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -51,7 +51,7 @@ static ssize_t wMaxPacketSize_show(struct device *dev,
 {
struct ep_device *ep = to_ep_device(dev);
return sprintf(buf, %04x\n,
-   usb_endpoint_maxp(ep-desc)  0x07ff);
+   usb_endpoint_maxp(ep-desc)  0x07ff);
 }
 static DEVICE_ATTR_RO(wMaxPacketSize);
 
-- 
1.9.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


[PATCH] usb: otg_whitelist: remove whitespace

2015-08-09 Thread Kris Borer
Fix one occurrence of the checkpatch error:

ERROR: space prohibited before open square bracket '['

Signed-off-by: Kris Borer kbo...@gmail.com
---
 drivers/usb/core/otg_whitelist.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/core/otg_whitelist.h b/drivers/usb/core/otg_whitelist.h
index a6315ab..a95b0c9 100644
--- a/drivers/usb/core/otg_whitelist.h
+++ b/drivers/usb/core/otg_whitelist.h
@@ -16,7 +16,7 @@
  * YOU _SHOULD_ CHANGE THIS LIST TO MATCH YOUR PRODUCT AND ITS TESTING!
  */
 
-static struct usb_device_id whitelist_table [] = {
+static struct usb_device_id whitelist_table[] = {
 
 /* hubs are optional in OTG, but very handy ... */
 { USB_DEVICE_INFO(USB_CLASS_HUB, 0, 0), },
-- 
1.9.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


[PATCH] usb: devio: fix spacing

2015-08-07 Thread Kris Borer
Fix two occurrences of the checkpatch.pl error:

ERROR: space prohibited before that ',' (ctx:WxW)

Fix one occurrence of the checkpatch error:

ERROR: space required before the open parenthesis '('

Signed-off-by: Kris Borer kbo...@gmail.com
---
 drivers/usb/core/devio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index ed6d1d5..38ae877c 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -103,7 +103,7 @@ MODULE_PARM_DESC(usbfs_snoop, true to log all usbfs 
traffic);
 #define snoop(dev, format, arg...) \
do {\
if (usbfs_snoop)\
-   dev_info(dev , format , ## arg);\
+   dev_info(dev, format, ## arg);  \
} while (0)
 
 enum snoop_when {
@@ -1321,7 +1321,7 @@ static int proc_do_submiturb(struct usb_dev_state *ps, 
struct usbdevfs_urb *uurb
is_in = (uurb-endpoint  USB_ENDPOINT_DIR_MASK) != 0;
 
u = 0;
-   switch(uurb-type) {
+   switch (uurb-type) {
case USBDEVFS_URB_TYPE_CONTROL:
if (!usb_endpoint_xfer_control(ep-desc))
return -EINVAL;
-- 
1.9.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


[PATCH v2] usb: devio: remove assignment from if condition

2015-08-04 Thread Kris Borer
Fix five occurrences of the checkpatch.pl error:

ERROR: do not use assignment in if condition

The semantic patch that makes this change is:

// smpl
@@
identifier i;
expression E;
statement S1, S2;
@@

+ i = E;
  if (
- (i = E)
+ i
  ) S1 else S2

@@
identifier i;
expression E;
statement S;
constant c;
binary operator b;
@@

+ i = E;
  if (
- (i = E)
+ i
  b
  c ) S
// /smpl

Signed-off-by: Kris Borer kbo...@gmail.com
---
 drivers/usb/core/devio.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 986abde..ed6d1d5 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1082,7 +1082,8 @@ static int proc_bulk(struct usb_dev_state *ps, void 
__user *arg)
ret = usbfs_increase_memory_usage(len1 + sizeof(struct urb));
if (ret)
return ret;
-   if (!(tbuf = kmalloc(len1, GFP_KERNEL))) {
+   tbuf = kmalloc(len1, GFP_KERNEL);
+   if (!tbuf) {
ret = -ENOMEM;
goto done;
}
@@ -1224,7 +1225,8 @@ static int proc_setintf(struct usb_dev_state *ps, void 
__user *arg)
 
if (copy_from_user(setintf, arg, sizeof(setintf)))
return -EFAULT;
-   if ((ret = checkintf(ps, setintf.interface)))
+   ret = checkintf(ps, setintf.interface);
+   if (ret)
return ret;
 
destroy_async_on_interface(ps, setintf.interface);
@@ -1393,7 +1395,8 @@ static int proc_do_submiturb(struct usb_dev_state *ps, 
struct usbdevfs_urb *uurb
number_of_packets = uurb-number_of_packets;
isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) *
   number_of_packets;
-   if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL)))
+   isopkt = kmalloc(isofrmlen, GFP_KERNEL);
+   if (!isopkt)
return -ENOMEM;
if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) {
ret = -EFAULT;
@@ -1904,7 +1907,8 @@ static int proc_releaseinterface(struct usb_dev_state 
*ps, void __user *arg)
 
if (get_user(ifnum, (unsigned int __user *)arg))
return -EFAULT;
-   if ((ret = releaseintf(ps, ifnum))  0)
+   ret = releaseintf(ps, ifnum);
+   if (ret  0)
return ret;
destroy_async_on_interface (ps, ifnum);
return 0;
@@ -1919,7 +1923,8 @@ static int proc_ioctl(struct usb_dev_state *ps, struct 
usbdevfs_ioctl *ctl)
struct usb_driver   *driver = NULL;
 
/* alloc buffer */
-   if ((size = _IOC_SIZE(ctl-ioctl_code))  0) {
+   size = _IOC_SIZE(ctl-ioctl_code);
+   if (size  0) {
buf = kmalloc(size, GFP_KERNEL);
if (buf == NULL)
return -ENOMEM;
-- 
1.9.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


[PATCH] usb: devio: remove assignment from if condition

2015-08-03 Thread Kris Borer
Fix six occurrences of the checkpatch.pl error:

ERROR: do not use assignment in if condition

The semantic patch that makes this change is:

// smpl
@@
identifier i;
expression E;
statement S1, S2;
@@

+ i = E;
  if (
- (i = E)
+ i
  ) S1 else S2

@@
identifier i;
expression E;
statement S;
constant c;
binary operator b;
@@

+ i = E;
  if (
- (i = E)
+ i
  b
  c ) S
// /smpl

Signed-off-by: Kris Borer kbo...@gmail.com
---
 drivers/usb/core/devio.c | 78 +++-
 1 file changed, 44 insertions(+), 34 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 986abde..4b6521b 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1082,7 +1082,8 @@ static int proc_bulk(struct usb_dev_state *ps, void 
__user *arg)
ret = usbfs_increase_memory_usage(len1 + sizeof(struct urb));
if (ret)
return ret;
-   if (!(tbuf = kmalloc(len1, GFP_KERNEL))) {
+   tbuf = kmalloc(len1, GFP_KERNEL);
+   if (!tbuf) {
ret = -ENOMEM;
goto done;
}
@@ -1224,7 +1225,8 @@ static int proc_setintf(struct usb_dev_state *ps, void 
__user *arg)
 
if (copy_from_user(setintf, arg, sizeof(setintf)))
return -EFAULT;
-   if ((ret = checkintf(ps, setintf.interface)))
+   ret = checkintf(ps, setintf.interface);
+   if (ret)
return ret;
 
destroy_async_on_interface(ps, setintf.interface);
@@ -1393,7 +1395,8 @@ static int proc_do_submiturb(struct usb_dev_state *ps, 
struct usbdevfs_urb *uurb
number_of_packets = uurb-number_of_packets;
isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) *
   number_of_packets;
-   if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL)))
+   isopkt = kmalloc(isofrmlen, GFP_KERNEL);
+   if (!isopkt)
return -ENOMEM;
if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) {
ret = -EFAULT;
@@ -1904,7 +1907,8 @@ static int proc_releaseinterface(struct usb_dev_state 
*ps, void __user *arg)
 
if (get_user(ifnum, (unsigned int __user *)arg))
return -EFAULT;
-   if ((ret = releaseintf(ps, ifnum))  0)
+   ret = releaseintf(ps, ifnum);
+   if (ret  0)
return ret;
destroy_async_on_interface (ps, ifnum);
return 0;
@@ -1919,7 +1923,8 @@ static int proc_ioctl(struct usb_dev_state *ps, struct 
usbdevfs_ioctl *ctl)
struct usb_driver   *driver = NULL;
 
/* alloc buffer */
-   if ((size = _IOC_SIZE(ctl-ioctl_code))  0) {
+   size = _IOC_SIZE(ctl-ioctl_code);
+   if (size  0) {
buf = kmalloc(size, GFP_KERNEL);
if (buf == NULL)
return -ENOMEM;
@@ -1940,38 +1945,43 @@ static int proc_ioctl(struct usb_dev_state *ps, struct 
usbdevfs_ioctl *ctl)
 
if (ps-dev-state != USB_STATE_CONFIGURED)
retval = -EHOSTUNREACH;
-   else if (!(intf = usb_ifnum_to_if(ps-dev, ctl-ifno)))
-   retval = -EINVAL;
-   else switch (ctl-ioctl_code) {
-
-   /* disconnect kernel driver from interface */
-   case USBDEVFS_DISCONNECT:
-   if (intf-dev.driver) {
-   driver = to_usb_driver(intf-dev.driver);
-   dev_dbg(intf-dev, disconnect by usbfs\n);
-   usb_driver_release_interface(driver, intf);
-   } else
-   retval = -ENODATA;
-   break;
-
-   /* let kernel drivers try to (re)bind to the interface */
-   case USBDEVFS_CONNECT:
-   if (!intf-dev.driver)
-   retval = device_attach(intf-dev);
+   else {
+   intf = usb_ifnum_to_if(ps-dev, ctl-ifno);
+   if (!intf)
+   retval = -EINVAL;
else
-   retval = -EBUSY;
-   break;
+   switch (ctl-ioctl_code) {
+
+   /* disconnect kernel driver from interface */
+   case USBDEVFS_DISCONNECT:
+   if (intf-dev.driver) {
+   driver = to_usb_driver(intf-dev.driver);
+   dev_dbg(intf-dev, disconnect by usbfs\n);
+   usb_driver_release_interface(driver, intf);
+   } else
+   retval = -ENODATA;
+   break;
 
-   /* talk directly to the interface's driver */
-   default:
-   if (intf-dev.driver)
-   driver = to_usb_driver(intf-dev.driver);
-   if (driver == NULL || driver-unlocked_ioctl == NULL) {
-   retval = -ENOTTY;
-   } else {
-   retval = driver-unlocked_ioctl(intf, ctl-ioctl_code, 
buf

[PATCH v2] usb: move assignment out of if condition

2015-07-02 Thread Kris Borer
Fix four occurrences of checkpatch.pl error:

ERROR: do not use assignment in if condition

Signed-off-by: Kris Borer kbo...@gmail.com
---
 drivers/usb/core/hcd.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index be5b207..3204a4d 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2683,12 +2683,14 @@ int usb_add_hcd(struct usb_hcd *hcd,
 * bottom up so that hcds can customize the root hubs before hub_wq
 * starts talking to them.  (Note, bus id is assigned early too.)
 */
-   if ((retval = hcd_buffer_create(hcd)) != 0) {
+   retval = hcd_buffer_create(hcd);
+   if (retval != 0) {
dev_dbg(hcd-self.controller, pool alloc failed\n);
goto err_create_buf;
}
 
-   if ((retval = usb_register_bus(hcd-self))  0)
+   retval = usb_register_bus(hcd-self);
+   if (retval  0)
goto err_register_bus;
 
rhdev = usb_alloc_dev(NULL, hcd-self, 0);
@@ -2734,9 +2736,13 @@ int usb_add_hcd(struct usb_hcd *hcd,
/* reset is misnamed; its role is now one-time init. the controller
 * should already have been reset (and boot firmware kicked off etc).
 */
-   if (hcd-driver-reset  (retval = hcd-driver-reset(hcd))  0) {
-   dev_err(hcd-self.controller, can't setup: %d\n, retval);
-   goto err_hcd_driver_setup;
+   if (hcd-driver-reset) {
+   retval = hcd-driver-reset(hcd);
+   if (retval  0) {
+   dev_err(hcd-self.controller, can't setup: %d\n,
+   retval);
+   goto err_hcd_driver_setup;
+   }
}
hcd-rh_pollable = 1;
 
@@ -2766,7 +2772,8 @@ int usb_add_hcd(struct usb_hcd *hcd,
}
 
/* starting here, usbcore will pay attention to this root hub */
-   if ((retval = register_root_hub(hcd)) != 0)
+   retval = register_root_hub(hcd);
+   if (retval != 0)
goto err_register_root_hub;
 
retval = sysfs_create_group(rhdev-dev.kobj, usb_bus_attr_group);
-- 
1.9.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


[PATCH] usb: move assignment out of if condition

2015-06-30 Thread Kris Borer
Fix four occurrences of the checkpatch.pl error:

ERROR: do not use assignment in if condition

Signed-off-by: Kris Borer kbo...@gmail.com
---
 drivers/usb/core/hcd.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index be5b207..e268c45 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2683,12 +2683,13 @@ int usb_add_hcd(struct usb_hcd *hcd,
 * bottom up so that hcds can customize the root hubs before hub_wq
 * starts talking to them.  (Note, bus id is assigned early too.)
 */
-   if ((retval = hcd_buffer_create(hcd)) != 0) {
+   retval = hcd_buffer_create(hcd);
+   if (retval != 0) {
dev_dbg(hcd-self.controller, pool alloc failed\n);
goto err_create_buf;
}
-
-   if ((retval = usb_register_bus(hcd-self))  0)
+   retval = usb_register_bus(hcd-self);
+   if (retval  0)
goto err_register_bus;
 
rhdev = usb_alloc_dev(NULL, hcd-self, 0);
@@ -2734,7 +2735,8 @@ int usb_add_hcd(struct usb_hcd *hcd,
/* reset is misnamed; its role is now one-time init. the controller
 * should already have been reset (and boot firmware kicked off etc).
 */
-   if (hcd-driver-reset  (retval = hcd-driver-reset(hcd))  0) {
+   retval = hcd-driver-reset(hcd);
+   if (hcd-driver-reset  retval  0) {
dev_err(hcd-self.controller, can't setup: %d\n, retval);
goto err_hcd_driver_setup;
}
@@ -2766,7 +2768,8 @@ int usb_add_hcd(struct usb_hcd *hcd,
}
 
/* starting here, usbcore will pay attention to this root hub */
-   if ((retval = register_root_hub(hcd)) != 0)
+   retval = register_root_hub(hcd);
+   if (retval != 0)
goto err_register_root_hub;
 
retval = sysfs_create_group(rhdev-dev.kobj, usb_bus_attr_group);
-- 
1.9.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


[PATCH] usb: fix coding style issue

2015-06-16 Thread Kris Borer
Fixed coding style issue: newline after declaration

Signed-off-by: Kris Borer kbo...@gmail.com
---
 drivers/usb/core/driver.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 818369a..6b5063e 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -160,6 +160,7 @@ static ssize_t remove_id_store(struct device_driver 
*driver, const char *buf,
spin_lock(usb_driver-dynids.lock);
list_for_each_entry_safe(dynid, n, usb_driver-dynids.list, node) {
struct usb_device_id *id = dynid-id;
+
if ((id-idVendor == idVendor) 
(id-idProduct == idProduct)) {
list_del(dynid-node);
-- 
1.9.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


[PATCH] usb: buffer: fix 2 coding style issues

2015-06-01 Thread Kris Borer
Fixed two coding style issues: sizeof parens and newline after declaration

Signed-off-by: Kris Borer kbo...@gmail.com
---
 drivers/usb/core/buffer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index 506b969..89f2e77 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -70,7 +70,7 @@ int hcd_buffer_create(struct usb_hcd *hcd)
size = pool_max[i];
if (!size)
continue;
-   snprintf(name, sizeof name, buffer-%d, size);
+   snprintf(name, sizeof(name), buffer-%d, size);
hcd-pool[i] = dma_pool_create(name, hcd-self.controller,
size, size, 0);
if (!hcd-pool[i]) {
@@ -95,6 +95,7 @@ void hcd_buffer_destroy(struct usb_hcd *hcd)
 
for (i = 0; i  HCD_BUFFER_POOLS; i++) {
struct dma_pool *pool = hcd-pool[i];
+
if (pool) {
dma_pool_destroy(pool);
hcd-pool[i] = NULL;
-- 
1.9.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