drivers: usb: core: Adapt source to styleguide
cover drivers: usb: core: Adapt source to styleguide
Hi,
I patches several files in drivers/usb/core/ to adapt them to the kernel styleguide.
Most of these patches are whitespace/indention fixes.
As these patches are only style-patches, I just compiled the kernel, no compile errors or warnings. So I think everything seems to be okay!
Note: I did not fix all ERROR messages from the scripts/checkpatch.pl script, as I don't know what to do with "do not use assignments in if-condition" messages.
Matthias Beyer (6):
drivers: usb: core: {file,hub,sysfs,usb}.c: Whitespace fixes
drivers: usb: core: file.c: moved asterisk to variable name
drivers: usb: core: hub.c: Comments shouldnt be C99 // comment style
drivers: usb: core: devio.c: Coding style fixes
drivers: usb: core: devio.c: Braces around switch
drivers: usb: core: devio.c: Else should be on closing braces
drivers/usb/core/devio.c | 97 ++++++++++++++++++++------------------- drivers/usb/core/file.c | 8 ++-- drivers/usb/core/hub.c | 115 +++++++++++++++++++++++------------------------ drivers/usb/core/sysfs.c | 5 ++- drivers/usb/core/usb.c | 2 +- 5 files changed, 116 insertions(+), 111 deletions(-)
Signature · 1 line
1.8.4
PATCH 1/6 drivers: usb: core: {file,hub,sysfs,usb}.c: Whitespace fixes
including:
- removing of trailing whitespace
- removing spaces before array indexing (foo [] to foo[])
- reindention of a switch-case block
- spaces to tabs
--- drivers/usb/core/file.c | 6 +-- drivers/usb/core/hub.c | 111 +++++++++++++++++++++++------------------------ drivers/usb/core/sysfs.c | 5 ++- drivers/usb/core/usb.c | 2 +- 4 files changed, 62 insertions(+), 62 deletions(-)
drivers/usb/core/file.c +3 -3
@@ -8,7 +8,7 @@* (C) Copyright Deti Fliegl 1999 (new USB architecture) * (C) Copyright Randy Dunlap 2000 * (C) Copyright David Brownell 2000-2001 (kernel hotplug, usb_device_id, -more docs, etc) +* more docs, etc) * (C) Copyright Yggdrasil Computing, Inc. 2000 * (usb_device_id matching changes by Adam J. Richter) * (C) Copyright Greg Kroah-Hartman 2002-2003
@@ -44,7 +44,7 @@ static int usb_open(struct inode * inode, struct file * file) file->f_op = new_fops;/* Curiouser and curiouser... NULL ->open() as "no device" ? */ if (file->f_op->open) - err = file->f_op->open (inode,file); + err = file->f_op->open (inode, file);if (err) {fops_put (file->f_op); file->f_op =fops_get (old_fops);
@@ -166,7 +166,7 @@ int usb_register_dev(struct usb_interface *intf,char *temp;#ifdef CONFIG_USB_DYNAMIC_MINORS -/* +/* * We don't care what the device tries to start at, we want to start * at zero to pack the devices into the smallest available space with * no holes in the minor range.
drivers/usb/core/hub.c +55 -56
274 lines not on this page · raw message
drivers/usb/core/sysfs.c +3 -2
@@ -390,7 +390,8 @@ static DEVICE_ATTR_RW(autosuspend);static const char on_string[] ="on" ;static const char auto_string[] ="auto" ; -static void warn_level (void ) { +static void warn_level (void ) +{static int level_warned;if (!level_warned) {
@@ -644,7 +645,7 @@ static ssize_t authorized_store(struct device *dev, result =usb_deauthorize_device (usb_dev); else result =usb_authorize_device (usb_dev); -return result <0 ? result : size; +return result <0 ? result : size; } static DEVICE_ATTR_IGNORE_LOCKDEP(authorized, S_IRUGO | S_IWUSR, authorized_show, authorized_store);
drivers/usb/core/usb.c +1 -1
@@ -497,7 +497,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, dev->authorized =1 ; else { dev->authorized = usb_hcd->authorized_default; - dev->wusb =usb_bus_is_wusb (bus)?1 :0 ; + dev->wusb =usb_bus_is_wusb (bus) ?1 :0 ; }return dev; }
Signature · 1 line
1.8.4
PATCH 2/6 drivers: usb: core: file.c: moved asterisk to variable name
In reply to Matthias Beyer--- drivers/usb/core/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/core/file.c +1 -1
@@ -27,7 +27,7 @@static const struct file_operations *usb_minors[MAX_USB_MINORS ];static DECLARE_RWSEM (minor_rwsem); -static int usb_open (struct inode * inode,struct file * file) +static int usb_open (struct inode *inode,struct file *file) {int minor =iminor (inode);const struct file_operations *c;
Signature · 1 line
1.8.4
PATCH 3/6 drivers: usb: core: hub.c: Comments shouldnt be C99 // comment style
In reply to Matthias Beyer--- drivers/usb/core/hub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/core/hub.c +2 -2
@@ -2488,7 +2488,7 @@ error_device_descriptor:usb_autosuspend_device (usb_dev); error_autoresume: out_authorized: -usb_unlock_device (usb_dev);// complements locktree +usb_unlock_device (usb_dev);/* complements locktree */ return result; }
@@ -3210,7 +3210,7 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)if (status ==0 && !port_is_suspended (hub, portstatus)) goto SuspendCleared; -// dev_dbg(hub->intfdev, "resume port %d\n", port1); +/* dev_dbg(hub->intfdev, "resume port %d\n", port1); */ set_bit (port1, hub->busy_bits);
Signature · 1 line
1.8.4
PATCH 4/6 drivers: usb: core: devio.c: Coding style fixes
In reply to Matthias BeyerWhitespace fixes, including:
- Whitespace after if-keyword
- Spaces to Tabs
Other coding style fixes:
- Added braces for if-else blocks where missing
--- drivers/usb/core/devio.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-)
drivers/usb/core/devio.c +20 -19
@@ -1222,7 +1222,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,return -ENOENT ; u =0 ; -switch (uurb->type) { +switch (uurb->type) {case USBDEVFS_URB_TYPE_CONTROL :if (!usb_endpoint_xfer_control (&ep->desc))return -EINVAL ;
@@ -1636,32 +1636,32 @@ static int proc_reapurbnonblock(struct dev_state *ps, void __user *arg)static int proc_control_compat (struct dev_state *ps,struct usbdevfs_ctrltransfer32 __user *p32) { -struct usbdevfs_ctrltransfer __user *p; -__u32 udata; - p =compat_alloc_user_space (sizeof (*p)); -if (copy_in_user (p, p32, (sizeof (*p32) -sizeof (compat_caddr_t))) || -get_user (udata, &p32->data) || +struct usbdevfs_ctrltransfer __user *p; +__u32 udata; + p =compat_alloc_user_space (sizeof (*p)); +if (copy_in_user (p, p32, (sizeof (*p32) -sizeof (compat_caddr_t))) || +get_user (udata, &p32->data) ||put_user (compat_ptr (udata), &p->data))return -EFAULT ; -return proc_control (ps, p); +return proc_control (ps, p); }static int proc_bulk_compat (struct dev_state *ps,struct usbdevfs_bulktransfer32 __user *p32) { -struct usbdevfs_bulktransfer __user *p; -compat_uint_t n; -compat_caddr_t addr; +struct usbdevfs_bulktransfer __user *p; +compat_uint_t n; +compat_caddr_t addr; - p =compat_alloc_user_space (sizeof (*p)); + p =compat_alloc_user_space (sizeof (*p)); -if (get_user (n, &p32->ep) ||put_user (n, &p->ep) || -get_user (n, &p32->len) ||put_user (n, &p->len) || -get_user (n, &p32->timeout) ||put_user (n, &p->timeout) || -get_user (addr, &p32->data) ||put_user (compat_ptr (addr), &p->data)) -return -EFAULT ; +if (get_user (n, &p32->ep) ||put_user (n, &p->ep) || +get_user (n, &p32->len) ||put_user (n, &p->len) || +get_user (n, &p32->timeout) ||put_user (n, &p->timeout) || +get_user (addr, &p32->data) ||put_user (compat_ptr (addr), &p->data)) +return -EFAULT ; -return proc_bulk (ps, p); +return proc_bulk (ps, p); }static int proc_disconnectsignal_compat (struct dev_state *ps,void __user *arg) {
@@ -1838,9 +1838,10 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)return -ENODEV ; } -if (ps->dev->state !=USB_STATE_CONFIGURED ) +if (ps->dev->state !=USB_STATE_CONFIGURED ) { retval = -EHOSTUNREACH ; -else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) + } +else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) { retval = -EINVAL ; else switch (ctl->ioctl_code) {
Signature · 1 line
1.8.4
Greg KH
maintainerRe: [PATCH 4/6] drivers: usb: core: devio.c: Coding style fixes
drivers/usb/core/devio.c static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) · line 1846
Quoted 12 lines · Matthias Beyer
drivers/usb/core/devio.c +3
-2@@ -1838,9 +1838,10 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)return -ENODEV ; } -if (ps->dev->state !=USB_STATE_CONFIGURED ) +if (ps->dev->state !=USB_STATE_CONFIGURED ) { retval = -EHOSTUNREACH ; -else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) + } +else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) { retval = -EINVAL ; else switch (ctl->ioctl_code) {
I don't think you actually built the code after you made this change :(
drivers/usb/core/devio.c: In function ‘proc_ioctl’:drivers/usb/core/devio.c:1844:2: error: expected ‘}’ before ‘else’
Please be more careful.
thanks,
greg k-h
PATCH 1/1 drivers: usb: core: devio.c: Coding style fixes
In reply to Matthias BeyerWhitespace fixes, including:
- Whitespace after if-keyword
- Spaces to Tabs
Other coding style fixes:
- Added braces for if-else blocks where missing
--- drivers/usb/core/devio.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-)
drivers/usb/core/devio.c +21 -19
@@ -1222,7 +1222,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,return -ENOENT ; u =0 ; -switch (uurb->type) { +switch (uurb->type) {case USBDEVFS_URB_TYPE_CONTROL :if (!usb_endpoint_xfer_control (&ep->desc))return -EINVAL ;
@@ -1636,32 +1636,32 @@ static int proc_reapurbnonblock(struct dev_state *ps, void __user *arg)static int proc_control_compat (struct dev_state *ps,struct usbdevfs_ctrltransfer32 __user *p32) { -struct usbdevfs_ctrltransfer __user *p; -__u32 udata; - p =compat_alloc_user_space (sizeof (*p)); -if (copy_in_user (p, p32, (sizeof (*p32) -sizeof (compat_caddr_t))) || -get_user (udata, &p32->data) || +struct usbdevfs_ctrltransfer __user *p; +__u32 udata; + p =compat_alloc_user_space (sizeof (*p)); +if (copy_in_user (p, p32, (sizeof (*p32) -sizeof (compat_caddr_t))) || +get_user (udata, &p32->data) ||put_user (compat_ptr (udata), &p->data))return -EFAULT ; -return proc_control (ps, p); +return proc_control (ps, p); }static int proc_bulk_compat (struct dev_state *ps,struct usbdevfs_bulktransfer32 __user *p32) { -struct usbdevfs_bulktransfer __user *p; -compat_uint_t n; -compat_caddr_t addr; +struct usbdevfs_bulktransfer __user *p; +compat_uint_t n; +compat_caddr_t addr; - p =compat_alloc_user_space (sizeof (*p)); + p =compat_alloc_user_space (sizeof (*p)); -if (get_user (n, &p32->ep) ||put_user (n, &p->ep) || -get_user (n, &p32->len) ||put_user (n, &p->len) || -get_user (n, &p32->timeout) ||put_user (n, &p->timeout) || -get_user (addr, &p32->data) ||put_user (compat_ptr (addr), &p->data)) -return -EFAULT ; +if (get_user (n, &p32->ep) ||put_user (n, &p->ep) || +get_user (n, &p32->len) ||put_user (n, &p->len) || +get_user (n, &p32->timeout) ||put_user (n, &p->timeout) || +get_user (addr, &p32->data) ||put_user (compat_ptr (addr), &p->data)) +return -EFAULT ; -return proc_bulk (ps, p); +return proc_bulk (ps, p); }static int proc_disconnectsignal_compat (struct dev_state *ps,void __user *arg) {
@@ -1838,10 +1838,12 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)return -ENODEV ; } -if (ps->dev->state !=USB_STATE_CONFIGURED ) +if (ps->dev->state !=USB_STATE_CONFIGURED ) { retval = -EHOSTUNREACH ; -else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) + } +else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) { retval = -EINVAL ; + }else switch (ctl->ioctl_code) {/* disconnect kernel driver from interface */
Signature · 1 line
1.8.4
Re: [PATCH 1/1] drivers: usb: core: devio.c: Coding style fixes
Hello.
Quoted 18 lines · Matthias Beyer
Whitespace fixes, including:
- Whitespace after if-keyword
- Spaces to TabsOther coding style fixes:
- Added braces for if-else blocks where missing
Signed-off-by Matthias Beyer <[email protected]>--- drivers/usb/core/devio.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-)drivers/usb/core/devio.c +0
-0
[...]
drivers/usb/core/devio.c static int proc_reapurbnonblock(struct dev_state *ps, void __user *arg) · line 1640
Quoted 11 lines
drivers/usb/core/devio.c +2
-5@@ -1636,32 +1636,32 @@ static int proc_reapurbnonblock(struct dev_state *ps, void __user *arg)static int proc_control_compat (struct dev_state *ps,struct usbdevfs_ctrltransfer32 __user *p32) { -struct usbdevfs_ctrltransfer __user *p; -__u32 udata; - p =compat_alloc_user_space (sizeof (*p)); - if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) || - get_user(udata, &p32->data) || +struct usbdevfs_ctrltransfer __user *p; +__u32 udata;
Could you also add an empty line here, for consistency with the below code?
Quoted 39 lines
drivers/usb/core/devio.c +14
-11+ p =compat_alloc_user_space (sizeof (*p)); +if (copy_in_user (p, p32, (sizeof (*p32) -sizeof (compat_caddr_t))) || +get_user (udata, &p32->data) ||put_user (compat_ptr (udata), &p->data))return -EFAULT ; -return proc_control (ps, p); +return proc_control (ps, p); }static int proc_bulk_compat (struct dev_state *ps,struct usbdevfs_bulktransfer32 __user *p32) { -struct usbdevfs_bulktransfer __user *p; -compat_uint_t n; -compat_caddr_t addr; +struct usbdevfs_bulktransfer __user *p; +compat_uint_t n; +compat_caddr_t addr; - p =compat_alloc_user_space (sizeof (*p)); + p =compat_alloc_user_space (sizeof (*p)); -if (get_user (n, &p32->ep) ||put_user (n, &p->ep) || -get_user (n, &p32->len) ||put_user (n, &p->len) || -get_user (n, &p32->timeout) ||put_user (n, &p->timeout) || -get_user (addr, &p32->data) ||put_user (compat_ptr (addr), &p->data)) -return -EFAULT ; +if (get_user (n, &p32->ep) ||put_user (n, &p->ep) || +get_user (n, &p32->len) ||put_user (n, &p->len) || +get_user (n, &p32->timeout) ||put_user (n, &p->timeout) || +get_user (addr, &p32->data) ||put_user (compat_ptr (addr), &p->data)) +return -EFAULT ; -return proc_bulk (ps, p); +return proc_bulk (ps, p); }static int proc_disconnectsignal_compat (struct dev_state *ps,void __user *arg) {
drivers/usb/core/devio.c static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) · line 1844
Quoted 9 lines
drivers/usb/core/devio.c +3
-2@@ -1838,10 +1838,12 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)return -ENODEV ; } -if (ps->dev->state !=USB_STATE_CONFIGURED ) +if (ps->dev->state !=USB_STATE_CONFIGURED ) { retval = -EHOSTUNREACH ; -else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) + } +else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) {
No, } and *else* should be on the same line. But wait, both arms of *if*
are single statements, so why you added {} in the first place? :-/
drivers/usb/core/devio.c static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) · line 1846
Quoted 2 lines
drivers/usb/core/devio.c +1
-0retval = -EINVAL ; + }
WBR, Sergei
Greg KH
maintainerRe: [PATCH 1/1] drivers: usb: core: devio.c: Coding style fixes
In reply to Matthias BeyerQuoted 8 lines · Matthias Beyer
Whitespace fixes, including:
- Whitespace after if-keyword
- Spaces to TabsOther coding style fixes:
- Added braces for if-else blocks where missing
When doing coding style cleanups, please only do one thing per patch. You are doing a bunch of different things here, all in one patch, which isn't good so I can't take it, sorry.
Please split this up into different patches and I will be glad to accept it.
thanks,
greg k-h
v2 cover Coding style fixes
Actually this is the third reroll of this patchseries, but I just figured out how to place this "v2" thing in the patches... sorry for that!
As Greg KH requested:
I splitted the coding style fixes into several patches. The replacing of spaces by tabs in proc_reapurbnonblock() and proc_control_compat() is splitted into two patches. As the patch for adding braces around the switch-block in here did not apply (don't know why), this patch series resubmits it (also splitted).
Note: This patch series makes the remaining patches from the origin patch series _obsolete_. So you have not to apply 5/6 and 6/6 from the origin patch series (I would be confused if it still works)!
Btw: If you are stressed out by me sending coding style fixes, I wouldn't take it wrong if you would redirect me to a submaintainer or so!
Best regards!
Matthias Beyer (5):
drivers: usb: core: devio.c: Spaces to tabs for proc_reapurbnonblock()
drivers: usb: core: devio.c: Spaces to tabs for proc_control_compat()
drivers: usb: core: devio.c: Braces around if-elseif-else
drivers: usb: core: devio.c: Reindented switch-block
drivers: usb: core: devio.c: Put arguments on new line
drivers/usb/core/devio.c | 95 +++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 46 deletions(-)
Signature · 1 line
1.8.4
PATCH v2 1/5 drivers: usb: core: devio.c: Spaces to tabs for proc_reapurbnonblock()
Replaced spaces by tabs for proc_reapurbnonblock() function.
--- drivers/usb/core/devio.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/usb/core/devio.c +6 -6
@@ -1636,14 +1636,14 @@ static int proc_reapurbnonblock(struct dev_state *ps, void __user *arg)static int proc_control_compat (struct dev_state *ps,struct usbdevfs_ctrltransfer32 __user *p32) { -struct usbdevfs_ctrltransfer __user *p; -__u32 udata; - p =compat_alloc_user_space (sizeof (*p)); -if (copy_in_user (p, p32, (sizeof (*p32) -sizeof (compat_caddr_t))) || -get_user (udata, &p32->data) || +struct usbdevfs_ctrltransfer __user *p; +__u32 udata; + p =compat_alloc_user_space (sizeof (*p)); +if (copy_in_user (p, p32, (sizeof (*p32) -sizeof (compat_caddr_t))) || +get_user (udata, &p32->data) ||put_user (compat_ptr (udata), &p->data))return -EFAULT ; -return proc_control (ps, p); +return proc_control (ps, p); } static int proc_bulk_compat(struct dev_state *ps,
Signature · 1 line
1.8.4
PATCH v2 2/5 drivers: usb: core: devio.c: Spaces to tabs for proc_control_compat()
In reply to Matthias BeyerReplaced spaces by tabs for proc_control_compat() function.
--- drivers/usb/core/devio.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/usb/core/devio.c +10 -10
@@ -1649,19 +1649,19 @@ static int proc_control_compat(struct dev_state *ps,static int proc_bulk_compat (struct dev_state *ps,struct usbdevfs_bulktransfer32 __user *p32) { -struct usbdevfs_bulktransfer __user *p; -compat_uint_t n; -compat_caddr_t addr; +struct usbdevfs_bulktransfer __user *p; +compat_uint_t n; +compat_caddr_t addr; - p =compat_alloc_user_space (sizeof (*p)); + p =compat_alloc_user_space (sizeof (*p)); -if (get_user (n, &p32->ep) ||put_user (n, &p->ep) || -get_user (n, &p32->len) ||put_user (n, &p->len) || -get_user (n, &p32->timeout) ||put_user (n, &p->timeout) || -get_user (addr, &p32->data) ||put_user (compat_ptr (addr), &p->data)) -return -EFAULT ; +if (get_user (n, &p32->ep) ||put_user (n, &p->ep) || +get_user (n, &p32->len) ||put_user (n, &p->len) || +get_user (n, &p32->timeout) ||put_user (n, &p->timeout) || +get_user (addr, &p32->data) ||put_user (compat_ptr (addr), &p->data)) +return -EFAULT ; -return proc_bulk (ps, p); +return proc_bulk (ps, p); }static int proc_disconnectsignal_compat (struct dev_state *ps,void __user *arg) {
Signature · 1 line
1.8.4
PATCH v2 3/5 drivers: usb: core: devio.c: Braces around if-elseif-else
In reply to Matthias BeyerThis patch applies the rules for braces to the if-elseif-else statement in proc_ioctl().
As the kernel styleguide says: If there is at least one multiline block in a if-else branching, we should add braces around all blocks. This includes braces around the switch-statement on the else branch, which needs a reindent after adding the braces.
--- drivers/usb/core/devio.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/usb/core/devio.c +6 -4
@@ -1222,7 +1222,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,return -ENOENT ; u =0 ; -switch (uurb->type) { +switch (uurb->type) {case USBDEVFS_URB_TYPE_CONTROL :if (!usb_endpoint_xfer_control (&ep->desc))return -EINVAL ;
@@ -1838,11 +1838,12 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)return -ENODEV ; } -if (ps->dev->state !=USB_STATE_CONFIGURED ) +if (ps->dev->state !=USB_STATE_CONFIGURED ) { retval = -EHOSTUNREACH ; -else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) + }else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) { retval = -EINVAL ; -else switch (ctl->ioctl_code) { + }else { +switch (ctl->ioctl_code) {/* disconnect kernel driver from interface */ case USBDEVFS_DISCONNECT :
@@ -1874,6 +1875,7 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) retval = -ENOTTY ; } } + }/* cleanup and return */ if (retval >= 0
Signature · 1 line
1.8.4
Greg KH
maintainerRe: [PATCH v2 3/5] drivers: usb: core: devio.c: Braces around if-elseif-else
Quoted 43 lines · Matthias Beyer
This patch applies the rules for braces to the if-elseif-else statement in
proc_ioctl().As the kernel styleguide says: If there is at least one multiline block in a if-else branching, we should add braces around all blocks. This includes braces around the switch-statement on the else branch, which needs a reindent after adding the braces.
Signed-off-by Matthias Beyer <[email protected]>--- drivers/usb/core/devio.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/usb/core/devio.c +5
-4@@ -1222,7 +1222,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,return -ENOENT ; u =0 ; -switch (uurb->type) { +switch (uurb->type) {case USBDEVFS_URB_TYPE_CONTROL :if (!usb_endpoint_xfer_control (&ep->desc))return -EINVAL ;@@ -1838,11 +1838,12 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)return -ENODEV ; } -if (ps->dev->state !=USB_STATE_CONFIGURED ) +if (ps->dev->state !=USB_STATE_CONFIGURED ) { retval = -EHOSTUNREACH ; -else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) + }else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) { retval = -EINVAL ; -else switch (ctl->ioctl_code) { + }else { +switch (ctl->ioctl_code) {/* disconnect kernel driver from interface */ case USBDEVFS_DISCONNECT :
drivers/usb/core/devio.c static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) · line 1878
Quoted 4 lines
drivers/usb/core/devio.c +1
-0@@ -1874,6 +1875,7 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) retval = -ENOTTY ; } } + }
Two braces in line like that should scream at you that something is wrong with the indentation here.
I'd leave it alone for the switch statement, as it's not needed.
Actually this whole thing should be fine, it's correct, right?
thanks,
greg k-h
PATCH v2 4/5 drivers: usb: core: devio.c: Reindented switch-block
In reply to Matthias BeyerReindented the switch-block.
--- drivers/usb/core/devio.c | 56 ++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-)
drivers/usb/core/devio.c +28 -28
@@ -1843,39 +1843,39 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) }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 ; +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 - retval = -EBUSY ; -break ; +/* let kernel drivers try to (re)bind to the interface */ +case USBDEVFS_CONNECT : +if (!intf->dev.driver) + retval =device_attach (&intf->dev); +else + retval = -EBUSY ; +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); -if (retval == -ENOIOCTLCMD ) +/* 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); +if (retval == -ENOIOCTLCMD ) + retval = -ENOTTY ; + } } } - }/* cleanup and return */ if (retval >= 0
Signature · 1 line
1.8.4
PATCH v2 5/5 drivers: usb: core: devio.c: Put arguments on new line
In reply to Matthias BeyerTo fit the 80-cols convention, this patch moves the arguments (the second and third one) for driver->unlocked_ioctl() onto a new line.
--- drivers/usb/core/devio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/core/devio.c +2 -1
@@ -1870,7 +1870,8 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)if (driver ==NULL || driver->unlocked_ioctl ==NULL ) { retval = -ENOTTY ; }else { - retval = driver->unlocked_ioctl (intf, ctl->ioctl_code, buf); + retval = driver->unlocked_ioctl (intf, + ctl->ioctl_code, buf);if (retval == -ENOIOCTLCMD ) retval = -ENOTTY ; }
Signature · 1 line
1.8.4
Greg KH
maintainerRe: [PATCH v2 5/5] drivers: usb: core: devio.c: Put arguments on new line
Quoted 13 lines · Matthias Beyer
To fit the 80-cols convention, this patch moves the arguments (the second and third one) for
driver->unlocked_ioctl()onto a new line.Signed-off-by Matthias Beyer <[email protected]>--- drivers/usb/core/devio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/usb/core/devio.c +0
-0
drivers/usb/core/devio.c static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) · line 1874
Quoted 6 lines
drivers/usb/core/devio.c +2
-1@@ -1870,7 +1870,8 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)if (driver ==NULL || driver->unlocked_ioctl ==NULL ) { retval = -ENOTTY ; }else { - retval = driver->unlocked_ioctl (intf, ctl->ioctl_code, buf); + retval = driver->unlocked_ioctl (intf, + ctl->ioctl_code, buf);
Nah, it looks worse this way, just leave it alone.
thanks,
greg k-h
PATCH 5/6 drivers: usb: core: devio.c: Braces around switch
In reply to Matthias BeyerAdded braces around switch statement as the styleguide tells us. Indented the switch-block for it and split a function call (driver->unlocked_ioctl() on line 1876) arguments to several lines to fit the 80-column convention.
--- drivers/usb/core/devio.c | 60 ++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 27 deletions(-)
drivers/usb/core/devio.c +33 -27
@@ -1843,36 +1843,42 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) }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 ; + } +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 - retval = -EBUSY ; -break ; +/* let kernel drivers try to (re)bind to the interface */ +case USBDEVFS_CONNECT : +if (!intf->dev.driver) + retval =device_attach (&intf->dev); +else + retval = -EBUSY ; +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); -if (retval == -ENOIOCTLCMD ) +/* 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); +if (retval == -ENOIOCTLCMD ) + retval = -ENOTTY ; + } } }
Signature · 1 line
1.8.4
Greg KH
maintainerRe: [PATCH 5/6] drivers: usb: core: devio.c: Braces around switch
Quoted 8 lines · Matthias Beyer
Added braces around switch statement as the styleguide tells us. Indented the switch-block for it and split a function call (
driver->unlocked_ioctl()on line 1876) arguments to several lines to fit the 80-column convention.Signed-off-by Matthias Beyer <[email protected]>--- drivers/usb/core/devio.c | 60 ++++++++++++++++++++++++++----------------------
This patch has fuzz, due to me not applying your previous one, so I can't apply it.
Can you fix it up, and resend the remaining patches that I didn't apply in this series?
thanks,
greg k-h
PATCH 1/1 drivers: usb: core: devio.c: Braces around switch (updated)
In reply to Matthias BeyerAdded braces around switch statement as the styleguide tells us. Indented the switch-block for it and split a function call (driver->unlocked_ioctl() on line 1876) arguments to several lines to fit the 80-column convention.
--- drivers/usb/core/devio.c | 63 +++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 30 deletions(-)
drivers/usb/core/devio.c +33 -30
@@ -1840,40 +1840,43 @@ static int proc_ioctl(struct 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))) { + }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 ; + }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 - retval = -EBUSY ; -break ; +/* let kernel drivers try to (re)bind to the interface */ +case USBDEVFS_CONNECT : +if (!intf->dev.driver) + retval =device_attach (&intf->dev); +else + retval = -EBUSY ; +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); -if (retval == -ENOIOCTLCMD ) +/* 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); +if (retval == -ENOIOCTLCMD ) + retval = -ENOTTY ; + } } }
Signature · 1 line
1.8.4
Greg KH
maintainerRe: [PATCH 1/1] drivers: usb: core: devio.c: Braces around switch (updated)
Quoted 4 lines · Matthias Beyer
Added braces around switch statement as the styleguide tells us. Indented the switch-block for it and split a function call (
driver->unlocked_ioctl()on line 1876) arguments to several lines to fit the 80-column convention.
This patch doesn't apply at all, any reason why?
confused,
greg k-h
PATCH 6/6 drivers: usb: core: devio.c: Else should be on closing braces
In reply to Matthias Beyermoved else keyword of if-else construct to closing braces.
--- drivers/usb/core/devio.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/usb/core/devio.c +2 -4
@@ -1840,11 +1840,9 @@ static int proc_ioctl(struct 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))) { + }else if (!(intf =usb_ifnum_to_if (ps->dev, ctl->ifno))) { retval = -EINVAL ; - } -else { + }else {switch (ctl->ioctl_code) {/* disconnect kernel driver from interface */
Signature · 1 line
1.8.4
Greg KH
maintainerQuoted 5 lines · Matthias Beyer
Hi,
I patches several files in
drivers/usb/core/to adapt them to the kernel styleguide.
Quoted 7 lines
Most of these patches are whitespace/indention fixes.
As these patches are only style-patches, I just compiled the kernel, no compile errors or warnings. So I think everything seems to be okay!
Note: I did not fix all ERROR messages from the
scripts/checkpatch.plscript, as I don't know what to do with "do not use assignments in if-condition" messages.
You can fix those up if you want. An example would be:
bad code: if ((x = foo() == NULL) do_something(); good code: x = foo(); if (x == NULL) do_something();
Hope this helps,
greg k-h