From: Michal Nazarewicz <mnazarewicz@google.com>
To: "Alan Stern" <stern@rowland.harvard.edu>,
"Sergey Senozhatsky" <sergey.senozhatsky@gmail.com>
Cc: "Greg Kroah-Hartman" <gregkh@suse.de>,
"Chris Wright" <chrisw@sous-sol.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Michal Nazarewicz <mina86@mina86.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: [PATCH] usb: core: Change usb_create_sysfs_intf_files()' return type to void
Date: Thu, 24 Mar 2011 16:13:41 +0100 [thread overview]
Message-ID: <7269aca0469928347bbff55c8c2efd1c86cf1f4b.1300979212.git.mina86@mina86.com> (raw)
From: Michal Nazarewicz <mina86@mina86.com>
The usb_create_sysfs_intf_files() function always returned zero even
if it failed to create sysfs fails. Since this is a desired behaviour
there is no need to return return code at all. This commit changes
function's return type (form int) to void.
Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
drivers/usb/core/sysfs.c | 7 +++----
drivers/usb/core/usb.c | 3 +--
drivers/usb/core/usb.h | 2 +-
3 files changed, 5 insertions(+), 7 deletions(-)
The below patch has not been tested (not even compiled), just a quick scatch.
> On Thu, 24 Mar 2011, Sergey Senozhatsky wrote:
>> I just noticed that usb_create_sysfs_intf_files() ignores
>> device_create_file() return code and sets intf->sysfs_files_created
>> to 1, even if sysfs_add_file_mode() returned -ENOMEM (or later
>> sysfs_add_one() returned -EEXIST).
>>
>> Shouldn't we check retval for 0 before setting
>> intf->sysfs_files_created?
On Thu, 24 Mar 2011 15:55:08 +0100, Alan Stern <stern@rowland.harvard.edu> wrote:
> No. We want this routine to succeed even if the sysfs files can't be
> created. The interface string attribute is more or less optional.
>
> It would be okay to add a comment explaining this, so that other people
> don't make the same mistake (which has already happened -- you're not
> the first).
Can we also drop the return value completely then?
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 6781c36..e729480 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -842,11 +842,10 @@ const struct attribute_group *usb_interface_groups[] = {
NULL
};
-int usb_create_sysfs_intf_files(struct usb_interface *intf)
+void usb_create_sysfs_intf_files(struct usb_interface *intf)
{
struct usb_device *udev = interface_to_usbdev(intf);
struct usb_host_interface *alt = intf->cur_altsetting;
- int retval;
if (intf->sysfs_files_created || intf->unregistering)
return 0;
@@ -855,9 +854,9 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf)
!(udev->quirks & USB_QUIRK_CONFIG_INTF_STRINGS))
alt->string = usb_cache_string(udev, alt->desc.iInterface);
if (alt->string)
- retval = device_create_file(&intf->dev, &dev_attr_interface);
+ /* We don't care if the function actually fails. */
+ device_create_file(&intf->dev, &dev_attr_interface);
intf->sysfs_files_created = 1;
- return 0;
}
void usb_remove_sysfs_intf_files(struct usb_interface *intf)
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 079cb57..08b74f8 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -948,8 +948,7 @@ static int usb_bus_notify(struct notifier_block *nb, unsigned long action,
if (dev->type == &usb_device_type)
(void) usb_create_sysfs_dev_files(to_usb_device(dev));
else if (dev->type == &usb_if_device_type)
- (void) usb_create_sysfs_intf_files(
- to_usb_interface(dev));
+ usb_create_sysfs_intf_files(to_usb_interface(dev));
break;
case BUS_NOTIFY_DEL_DEVICE:
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index a9cf484..d51ab6a 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -4,7 +4,7 @@
extern int usb_create_sysfs_dev_files(struct usb_device *dev);
extern void usb_remove_sysfs_dev_files(struct usb_device *dev);
-extern int usb_create_sysfs_intf_files(struct usb_interface *intf);
+extern void usb_create_sysfs_intf_files(struct usb_interface *intf);
extern void usb_remove_sysfs_intf_files(struct usb_interface *intf);
extern int usb_create_ep_devs(struct device *parent,
struct usb_host_endpoint *endpoint,
--
1.7.3.1
next reply other threads:[~2011-03-24 15:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-24 15:13 Michal Nazarewicz [this message]
2011-03-24 15:52 ` Alan Stern
2011-03-24 16:02 ` Michal Nazarewicz
2011-03-25 11:22 ` [PATCHv2] " Michal Nazarewicz
2011-03-25 15:33 ` Alan Stern
2011-03-25 17:03 ` [PATCHv3] " Alan Stern
2011-04-13 23:23 ` Greg KH
2011-04-14 15:47 ` Michal Nazarewicz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7269aca0469928347bbff55c8c2efd1c86cf1f4b.1300979212.git.mina86@mina86.com \
--to=mnazarewicz@google.com \
--cc=chrisw@sous-sol.org \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mina86@mina86.com \
--cc=sergey.senozhatsky@gmail.com \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®