lkml.org 
[lkml]   [2012]   [Sep]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 19/40] PCI, sysfs: Clean up rescan/remove with schedule_callback
Date
Change to use three return according to Bjorn.

Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/pci-sysfs.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 60e04b2..b308558 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -340,7 +340,7 @@ static ssize_t
remove_store(struct device *dev, struct device_attribute *dummy,
const char *buf, size_t count)
{
- int ret = 0;
+ int err;
unsigned long val;

if (strict_strtoul(buf, 0, &val) < 0)
@@ -349,10 +349,13 @@ remove_store(struct device *dev, struct device_attribute *dummy,
/* An attribute cannot be unregistered by one of its own methods,
* so we have to use this roundabout approach.
*/
- if (val)
- ret = device_schedule_callback(dev, remove_callback);
- if (ret)
- count = ret;
+ if (!val)
+ return count;
+
+ err = device_schedule_callback(dev, remove_callback);
+ if (err)
+ return err;
+
return count;
}

@@ -372,17 +375,17 @@ static ssize_t
dev_bus_rescan_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- int ret = 0;
+ int err;
unsigned long val;

if (strict_strtoul(buf, 0, &val) < 0)
return -EINVAL;
+ if (!val)
+ return count;

- if (val)
- ret = device_schedule_callback(dev, bus_rescan_callback);
-
- if (ret)
- count = ret;
+ err = device_schedule_callback(dev, bus_rescan_callback);
+ if (err)
+ return err;

return count;
}
--
1.7.7


\
 
 \ /
  Last update: 2012-09-19 22:01    [W:0.164 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site