Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4aca67e5 authored by Andrew Morton's avatar Andrew Morton Committed by Greg Kroah-Hartman
Browse files

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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 873760fb
Loading
Loading
Loading
Loading
+10 −12
Original line number Diff line number Diff line
@@ -329,22 +329,20 @@ static int device_add_attrs(struct bus_type * bus, struct device * dev)
	int error = 0;
	int i;

	if (bus->dev_attrs) {
	if (!bus->dev_attrs)
		return 0;

	for (i = 0; attr_name(bus->dev_attrs[i]); i++) {
		error = device_create_file(dev,&bus->dev_attrs[i]);
			if (error)
				goto Err;
		if (error) {
			while (--i >= 0)
				device_remove_file(dev, &bus->dev_attrs[i]);
			break;
		}
	}
 Done:
	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)
{
	int i;