mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-03 07:38:10 +00:00
Driver core: device_add_attrs() cleanup
Clean up the coding in device_add_attrs() a bit. Cc: Jean Delvare <khali@linux-fr.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
873760fbf4
commit
4aca67e5f5
1 changed files with 10 additions and 12 deletions
|
@ -324,27 +324,25 @@ int bus_for_each_drv(struct bus_type * bus, struct device_driver * start,
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int device_add_attrs(struct bus_type * bus, struct device * dev)
|
static int device_add_attrs(struct bus_type *bus, struct device *dev)
|
||||||
{
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (bus->dev_attrs) {
|
if (!bus->dev_attrs)
|
||||||
for (i = 0; attr_name(bus->dev_attrs[i]); i++) {
|
return 0;
|
||||||
error = device_create_file(dev,&bus->dev_attrs[i]);
|
|
||||||
if (error)
|
for (i = 0; attr_name(bus->dev_attrs[i]); i++) {
|
||||||
goto Err;
|
error = device_create_file(dev,&bus->dev_attrs[i]);
|
||||||
|
if (error) {
|
||||||
|
while (--i >= 0)
|
||||||
|
device_remove_file(dev, &bus->dev_attrs[i]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Done:
|
|
||||||
return error;
|
return error;
|
||||||
Err:
|
|
||||||
while (--i >= 0)
|
|
||||||
device_remove_file(dev,&bus->dev_attrs[i]);
|
|
||||||
goto Done;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void device_remove_attrs(struct bus_type * bus, struct device * dev)
|
static void device_remove_attrs(struct bus_type * bus, struct device * dev)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
Loading…
Reference in a new issue