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

Commit 4a3ad20c authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Driver core: coding style fixes



Fix up a number of coding style issues in the drivers/base/ directory
that have annoyed me over the years.  checkpatch.pl is now very happy.

Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e374a2bf
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -54,11 +54,11 @@ extern int bus_add_device(struct device * dev);
extern void bus_attach_device(struct device *dev);
extern void bus_remove_device(struct device *dev);

extern int bus_add_driver(struct device_driver *);
extern void bus_remove_driver(struct device_driver *);
extern int bus_add_driver(struct device_driver *drv);
extern void bus_remove_driver(struct device_driver *drv);

extern void driver_detach(struct device_driver *drv);
extern int driver_probe_device(struct device_driver *, struct device *);
extern int driver_probe_device(struct device_driver *drv, struct device *dev);

extern void sysdev_shutdown(void);
extern int sysdev_suspend(pm_message_t state);
+140 −150
Original line number Diff line number Diff line
@@ -46,8 +46,8 @@ static void bus_put(struct bus_type *bus)
		kset_put(&bus->p->subsys);
}

static ssize_t
drv_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
static ssize_t drv_attr_show(struct kobject *kobj, struct attribute *attr,
			     char *buf)
{
	struct driver_attribute *drv_attr = to_drv_attr(attr);
	struct driver_private *drv_priv = to_driver(kobj);
@@ -58,8 +58,7 @@ drv_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
	return ret;
}

static ssize_t
drv_attr_store(struct kobject * kobj, struct attribute * attr,
static ssize_t drv_attr_store(struct kobject *kobj, struct attribute *attr,
			      const char *buf, size_t count)
{
	struct driver_attribute *drv_attr = to_drv_attr(attr);
@@ -89,14 +88,11 @@ static struct kobj_type driver_ktype = {
	.release	= driver_release,
};


/*
 * sysfs bindings for buses
 */


static ssize_t
bus_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
static ssize_t bus_attr_show(struct kobject *kobj, struct attribute *attr,
			     char *buf)
{
	struct bus_attribute *bus_attr = to_bus_attr(attr);
	struct bus_type_private *bus_priv = to_bus(kobj);
@@ -107,8 +103,7 @@ bus_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
	return ret;
}

static ssize_t
bus_attr_store(struct kobject * kobj, struct attribute * attr,
static ssize_t bus_attr_store(struct kobject *kobj, struct attribute *attr,
			      const char *buf, size_t count)
{
	struct bus_attribute *bus_attr = to_bus_attr(attr);
@@ -135,6 +130,7 @@ int bus_create_file(struct bus_type * bus, struct bus_attribute * attr)
		error = -EINVAL;
	return error;
}
EXPORT_SYMBOL_GPL(bus_create_file);

void bus_remove_file(struct bus_type *bus, struct bus_attribute *attr)
{
@@ -143,6 +139,7 @@ void bus_remove_file(struct bus_type * bus, struct bus_attribute * attr)
		bus_put(bus);
	}
}
EXPORT_SYMBOL_GPL(bus_remove_file);

static struct kobj_type bus_ktype = {
	.sysfs_ops	= &bus_sysfs_ops,
@@ -219,11 +216,14 @@ static ssize_t driver_bind(struct device_driver *drv,
		if (dev->parent)
			up(&dev->parent->sem);

		if (err > 0) 		/* success */
		if (err > 0) {
			/* success */
			err = count;
		else if (err == 0)	/* driver didn't accept device */
		} else if (err == 0) {
			/* driver didn't accept device */
			err = -ENODEV;
		}
	}
	put_device(dev);
	bus_put(bus);
	return err;
@@ -284,7 +284,6 @@ static struct device * next_device(struct klist_iter * i)
 * to retain this data, it should do, and increment the reference
 * count in the supplied callback.
 */

int bus_for_each_dev(struct bus_type *bus, struct device *start,
		     void *data, int (*fn)(struct device *, void *))
{
@@ -302,6 +301,7 @@ int bus_for_each_dev(struct bus_type * bus, struct device * start,
	klist_iter_exit(&i);
	return error;
}
EXPORT_SYMBOL_GPL(bus_for_each_dev);

/**
 * bus_find_device - device iterator for locating a particular device.
@@ -320,7 +320,7 @@ int bus_for_each_dev(struct bus_type * bus, struct device * start,
 */
struct device *bus_find_device(struct bus_type *bus,
			       struct device *start, void *data,
				int (*match)(struct device *, void *))
			       int (*match)(struct device *dev, void *data))
{
	struct klist_iter i;
	struct device *dev;
@@ -336,7 +336,7 @@ struct device * bus_find_device(struct bus_type *bus,
	klist_iter_exit(&i);
	return dev;
}

EXPORT_SYMBOL_GPL(bus_find_device);

static struct device_driver *next_driver(struct klist_iter *i)
{
@@ -369,7 +369,6 @@ static struct device_driver * next_driver(struct klist_iter * i)
 * in the callback. It must also be sure to increment the refcount
 * so it doesn't disappear before returning to the caller.
 */

int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
		     void *data, int (*fn)(struct device_driver *, void *))
{
@@ -387,6 +386,7 @@ int bus_for_each_drv(struct bus_type * bus, struct device_driver * start,
	klist_iter_exit(&i);
	return error;
}
EXPORT_SYMBOL_GPL(bus_for_each_drv);

static int device_add_attrs(struct bus_type *bus, struct device *dev)
{
@@ -513,13 +513,15 @@ void bus_remove_device(struct device * dev)
	if (dev->bus) {
		sysfs_remove_link(&dev->kobj, "subsystem");
		remove_deprecated_bus_links(dev);
		sysfs_remove_link(&dev->bus->p->devices_kset->kobj, dev->bus_id);
		sysfs_remove_link(&dev->bus->p->devices_kset->kobj,
				  dev->bus_id);
		device_remove_attrs(dev->bus, dev);
		if (dev->is_registered) {
			dev->is_registered = 0;
			klist_del(&dev->knode_bus);
		}
		pr_debug("bus: '%s': remove device %s\n", dev->bus->name, dev->bus_id);
		pr_debug("bus: '%s': remove device %s\n",
			 dev->bus->name, dev->bus_id);
		device_release_driver(dev);
		bus_put(dev->bus);
	}
@@ -534,19 +536,19 @@ static int driver_add_attrs(struct bus_type * bus, struct device_driver * drv)
		for (i = 0; attr_name(bus->drv_attrs[i]); i++) {
			error = driver_create_file(drv, &bus->drv_attrs[i]);
			if (error)
				goto Err;
				goto err;
		}
	}
 Done:
done:
	return error;
 Err:
err:
	while (--i >= 0)
		driver_remove_file(drv, &bus->drv_attrs[i]);
	goto Done;
	goto done;
}


static void driver_remove_attrs(struct bus_type * bus, struct device_driver * drv)
static void driver_remove_attrs(struct bus_type *bus,
				struct device_driver *drv)
{
	int i;

@@ -625,7 +627,6 @@ static DRIVER_ATTR(uevent, S_IWUSR, NULL, driver_uevent_store);
/**
 * bus_add_driver - Add a driver to the bus.
 * @drv: driver.
 *
 */
int bus_add_driver(struct device_driver *drv)
{
@@ -695,7 +696,6 @@ int bus_add_driver(struct device_driver *drv)
 * it from its bus's list of drivers. Finally, we drop the reference
 * to the bus we took in bus_add_driver().
 */

void bus_remove_driver(struct device_driver *drv)
{
	if (!drv->bus)
@@ -712,7 +712,6 @@ void bus_remove_driver(struct device_driver * drv)
	bus_put(drv->bus);
}


/* Helper for bus_rescan_devices's iter */
static int __must_check bus_rescan_devices_helper(struct device *dev,
						  void *data)
@@ -741,6 +740,7 @@ int bus_rescan_devices(struct bus_type * bus)
{
	return bus_for_each_dev(bus, NULL, NULL, bus_rescan_devices_helper);
}
EXPORT_SYMBOL_GPL(bus_rescan_devices);

/**
 * device_reprobe - remove driver for a device and probe for a new driver
@@ -796,15 +796,15 @@ static int bus_add_attrs(struct bus_type * bus)
		for (i = 0; attr_name(bus->bus_attrs[i]); i++) {
			error = bus_create_file(bus, &bus->bus_attrs[i]);
			if (error)
				goto Err;
				goto err;
		}
	}
 Done:
done:
	return error;
 Err:
err:
	while (--i >= 0)
		bus_remove_file(bus, &bus->bus_attrs[i]);
	goto Done;
	goto done;
}

static void bus_remove_attrs(struct bus_type *bus)
@@ -922,6 +922,7 @@ int bus_register(struct bus_type * bus)
out:
	return retval;
}
EXPORT_SYMBOL_GPL(bus_register);

/**
 * bus_unregister - remove a bus from the system
@@ -941,6 +942,7 @@ void bus_unregister(struct bus_type * bus)
	kset_unregister(&bus->p->subsys);
	kfree(bus->p);
}
EXPORT_SYMBOL_GPL(bus_unregister);

int bus_register_notifier(struct bus_type *bus, struct notifier_block *nb)
{
@@ -973,15 +975,3 @@ int __init buses_init(void)
		return -ENOMEM;
	return 0;
}


EXPORT_SYMBOL_GPL(bus_for_each_dev);
EXPORT_SYMBOL_GPL(bus_find_device);
EXPORT_SYMBOL_GPL(bus_for_each_drv);

EXPORT_SYMBOL_GPL(bus_register);
EXPORT_SYMBOL_GPL(bus_unregister);
EXPORT_SYMBOL_GPL(bus_rescan_devices);

EXPORT_SYMBOL_GPL(bus_create_file);
EXPORT_SYMBOL_GPL(bus_remove_file);
+70 −70
Original line number Diff line number Diff line
@@ -23,8 +23,8 @@
#define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr)
#define to_class(obj) container_of(obj, struct class, subsys.kobj)

static ssize_t
class_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
static ssize_t class_attr_show(struct kobject *kobj, struct attribute *attr,
			       char *buf)
{
	struct class_attribute *class_attr = to_class_attr(attr);
	struct class *dc = to_class(kobj);
@@ -35,8 +35,7 @@ class_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
	return ret;
}

static ssize_t
class_attr_store(struct kobject * kobj, struct attribute * attr,
static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr,
				const char *buf, size_t count)
{
	struct class_attribute *class_attr = to_class_attr(attr);
@@ -78,9 +77,9 @@ static struct kset *class_kset;
int class_create_file(struct class *cls, const struct class_attribute *attr)
{
	int error;
	if (cls) {
	if (cls)
		error = sysfs_create_file(&cls->subsys.kobj, &attr->attr);
	} else
	else
		error = -EINVAL;
	return error;
}
@@ -94,7 +93,8 @@ void class_remove_file(struct class * cls, const struct class_attribute * attr)
static struct class *class_get(struct class *cls)
{
	if (cls)
		return container_of(kset_get(&cls->subsys), struct class, subsys);
		return container_of(kset_get(&cls->subsys),
				    struct class, subsys);
	return NULL;
}

@@ -104,7 +104,6 @@ static void class_put(struct class * cls)
		kset_put(&cls->subsys);
}


static int add_class_attrs(struct class *cls)
{
	int i;
@@ -114,15 +113,15 @@ static int add_class_attrs(struct class * cls)
		for (i = 0; attr_name(cls->class_attrs[i]); i++) {
			error = class_create_file(cls, &cls->class_attrs[i]);
			if (error)
				goto Err;
				goto error;
		}
	}
 Done:
done:
	return error;
 Err:
error:
	while (--i >= 0)
		class_remove_file(cls, &cls->class_attrs[i]);
	goto Done;
	goto done;
}

static void remove_class_attrs(struct class *cls)
@@ -281,9 +280,8 @@ void class_device_remove_bin_file(struct class_device *class_dev,
		sysfs_remove_bin_file(&class_dev->kobj, attr);
}

static ssize_t
class_device_attr_show(struct kobject * kobj, struct attribute * attr,
		       char * buf)
static ssize_t class_device_attr_show(struct kobject *kobj,
				      struct attribute *attr, char *buf)
{
	struct class_device_attribute *class_dev_attr = to_class_dev_attr(attr);
	struct class_device *cd = to_class_dev(kobj);
@@ -294,8 +292,8 @@ class_device_attr_show(struct kobject * kobj, struct attribute * attr,
	return ret;
}

static ssize_t
class_device_attr_store(struct kobject * kobj, struct attribute * attr,
static ssize_t class_device_attr_store(struct kobject *kobj,
				       struct attribute *attr,
				       const char *buf, size_t count)
{
	struct class_device_attribute *class_dev_attr = to_class_dev_attr(attr);
@@ -324,8 +322,8 @@ static void class_dev_release(struct kobject * kobj)
	else if (cls->release)
		cls->release(cd);
	else {
		printk(KERN_ERR "Class Device '%s' does not have a release() function, "
			"it is broken and must be fixed.\n",
		printk(KERN_ERR "Class Device '%s' does not have a release() "
			"function, it is broken and must be fixed.\n",
			cd->class_id);
		WARN_ON(1);
	}
@@ -436,7 +434,8 @@ static int class_uevent(struct kset *kset, struct kobject *kobj,
			add_uevent_var(env, "PHYSDEVBUS=%s", dev->bus->name);

		if (dev->driver)
			add_uevent_var(env, "PHYSDEVDRIVER=%s", dev->driver->name);
			add_uevent_var(env, "PHYSDEVDRIVER=%s",
				       dev->driver->name);
	}

	if (class_dev->uevent) {
@@ -480,15 +479,15 @@ static int class_device_add_attrs(struct class_device * cd)
			error = class_device_create_file(cd,
						&cls->class_dev_attrs[i]);
			if (error)
				goto Err;
				goto err;
		}
	}
 Done:
done:
	return error;
 Err:
err:
	while (--i >= 0)
		class_device_remove_file(cd, &cls->class_dev_attrs[i]);
	goto Done;
	goto done;
}

static void class_device_remove_attrs(struct class_device *cd)
@@ -512,7 +511,8 @@ static int class_device_add_groups(struct class_device * cd)
			error = sysfs_create_group(&cd->kobj, cd->groups[i]);
			if (error) {
				while (--i >= 0)
					sysfs_remove_group(&cd->kobj, cd->groups[i]);
					sysfs_remove_group(&cd->kobj,
							   cd->groups[i]);
				goto out;
			}
		}
@@ -524,12 +524,10 @@ static int class_device_add_groups(struct class_device * cd)
static void class_device_remove_groups(struct class_device *cd)
{
	int i;
	if (cd->groups) {
		for (i = 0; cd->groups[i]; i++) {
	if (cd->groups)
		for (i = 0; cd->groups[i]; i++)
			sysfs_remove_group(&cd->kobj, cd->groups[i]);
}
	}
}

static ssize_t show_dev(struct class_device *class_dev, char *buf)
{
@@ -670,9 +668,11 @@ int class_device_register(struct class_device *class_dev)
/**
 * class_device_create - creates a class device and registers it with sysfs
 * @cls: pointer to the struct class that this device should be registered to.
 * @parent: pointer to the parent struct class_device of this new device, if any.
 * @parent: pointer to the parent struct class_device of this new device, if
 * any.
 * @devt: the dev_t for the char device to be added.
 * @device: a pointer to a struct device that is assiociated with this class device.
 * @device: a pointer to a struct device that is assiociated with this class
 * device.
 * @fmt: string for the class device's name
 *
 * This function can be used by char device classes.  A struct
+95 −108
Original line number Diff line number Diff line
@@ -51,8 +51,8 @@ EXPORT_SYMBOL(dev_driver_string);
#define to_dev(obj) container_of(obj, struct device, kobj)
#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr)

static ssize_t
dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr,
			     char *buf)
{
	struct device_attribute *dev_attr = to_dev_attr(attr);
	struct device *dev = to_dev(kobj);
@@ -63,8 +63,7 @@ dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
	return ret;
}

static ssize_t
dev_attr_store(struct kobject * kobj, struct attribute * attr,
static ssize_t dev_attr_store(struct kobject *kobj, struct attribute *attr,
			      const char *buf, size_t count)
{
	struct device_attribute *dev_attr = to_dev_attr(attr);
@@ -101,8 +100,8 @@ static void device_release(struct kobject * kobj)
	else if (dev->class && dev->class->dev_release)
		dev->class->dev_release(dev);
	else {
		printk(KERN_ERR "Device '%s' does not have a release() function, "
			"it is broken and must be fixed.\n",
		printk(KERN_ERR "Device '%s' does not have a release() "
			"function, it is broken and must be fixed.\n",
			dev->bus_id);
		WARN_ON(1);
	}
@@ -185,7 +184,8 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
		add_uevent_var(env, "PHYSDEVBUS=%s", dev->bus->name);

		if (dev->driver)
			add_uevent_var(env, "PHYSDEVDRIVER=%s", dev->driver->name);
			add_uevent_var(env, "PHYSDEVDRIVER=%s",
				       dev->driver->name);
	}
#endif

@@ -327,7 +327,8 @@ static int device_add_groups(struct device *dev,
			error = sysfs_create_group(&dev->kobj, groups[i]);
			if (error) {
				while (--i >= 0)
					sysfs_remove_group(&dev->kobj, groups[i]);
					sysfs_remove_group(&dev->kobj,
							   groups[i]);
				break;
			}
		}
@@ -406,13 +407,11 @@ static struct device_attribute devt_attr =
/* kset to create /sys/devices/  */
struct kset *devices_kset;


/**
 * device_create_file - create sysfs attribute file for device.
 * @dev: device.
 * @attr: device attribute descriptor.
 */

int device_create_file(struct device *dev, struct device_attribute *attr)
{
	int error = 0;
@@ -428,7 +427,6 @@ int device_create_file(struct device * dev, struct device_attribute * attr)
 * @dev: device.
 * @attr: device attribute descriptor.
 */

void device_remove_file(struct device *dev, struct device_attribute *attr)
{
	if (get_device(dev)) {
@@ -510,7 +508,6 @@ static void klist_children_put(struct klist_node *n)
	put_device(dev);
}


/**
 * device_initialize - init device structure.
 * @dev: device.
@@ -521,7 +518,6 @@ static void klist_children_put(struct klist_node *n)
 * that, though it can also be called separately, so one
 * may use @dev's fields (e.g. the refcount).
 */

void device_initialize(struct device *dev)
{
	dev->kobj.kset = devices_kset;
@@ -870,7 +866,6 @@ int device_add(struct device *dev)
	goto Done;
}


/**
 * device_register - register a device with the system.
 * @dev: pointer to the device structure
@@ -882,14 +877,12 @@ int device_add(struct device *dev)
 * have a clearly defined need to use and refcount the device
 * before it is added to the hierarchy.
 */

int device_register(struct device *dev)
{
	device_initialize(dev);
	return device_add(dev);
}


/**
 * get_device - increment reference count for device.
 * @dev: device.
@@ -898,13 +891,11 @@ int device_register(struct device *dev)
 * we do take care to provide for the case that we get a NULL
 * pointer passed in.
 */

struct device *get_device(struct device *dev)
{
	return dev ? to_dev(kobject_get(&dev->kobj)) : NULL;
}


/**
 * put_device - decrement reference count.
 * @dev: device in question.
@@ -916,7 +907,6 @@ void put_device(struct device * dev)
		kobject_put(&dev->kobj);
}


/**
 * device_del - delete device from system.
 * @dev: device.
@@ -930,7 +920,6 @@ void put_device(struct device * dev)
 * NOTE: this should be called manually _iff_ device_add() was
 * also called manually.
 */

void device_del(struct device *dev)
{
	struct device *parent = dev->parent;
@@ -996,7 +985,6 @@ void device_unregister(struct device * dev)
	put_device(dev);
}


static struct device *next_device(struct klist_iter *i)
{
	struct klist_node *n = klist_next(i);
@@ -1016,7 +1004,7 @@ static struct device * next_device(struct klist_iter * i)
 * other than 0, we break out and return that value.
 */
int device_for_each_child(struct device *parent, void *data,
		     int (*fn)(struct device *, void *))
			  int (*fn)(struct device *dev, void *data))
{
	struct klist_iter i;
	struct device *child;
@@ -1045,7 +1033,7 @@ int device_for_each_child(struct device * parent, void * data,
 * and not iterate over any more devices.
 */
struct device *device_find_child(struct device *parent, void *data,
				  int (*match)(struct device *, void *))
				 int (*match)(struct device *dev, void *data))
{
	struct klist_iter i;
	struct device *child;
@@ -1312,8 +1300,7 @@ static int device_move_class_links(struct device *dev,
					  class_name);
		if (error)
			sysfs_remove_link(&dev->kobj, "device");
	}
	else
	} else
		error = 0;
out:
	kfree(class_name);
+58 −61
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ int device_bind_driver(struct device *dev)
		driver_bound(dev);
	return ret;
}
EXPORT_SYMBOL_GPL(device_bind_driver);

static atomic_t probe_count = ATOMIC_INIT(0);
static DECLARE_WAIT_QUEUE_HEAD(probe_waitqueue);
@@ -240,6 +241,7 @@ int device_attach(struct device * dev)
	up(&dev->sem);
	return ret;
}
EXPORT_SYMBOL_GPL(device_attach);

static int __driver_attach(struct device *dev, void *data)
{
@@ -280,6 +282,7 @@ int driver_attach(struct device_driver * drv)
{
	return bus_for_each_dev(drv->bus, NULL, drv, __driver_attach);
}
EXPORT_SYMBOL_GPL(driver_attach);

/*
 * __device_release_driver() must be called with @dev->sem held.
@@ -327,7 +330,7 @@ void device_release_driver(struct device * dev)
	__device_release_driver(dev);
	up(&dev->sem);
}

EXPORT_SYMBOL_GPL(device_release_driver);

/**
 * driver_detach - detach driver from all devices it controls.
@@ -359,9 +362,3 @@ void driver_detach(struct device_driver * drv)
		put_device(dev);
	}
}

EXPORT_SYMBOL_GPL(device_bind_driver);
EXPORT_SYMBOL_GPL(device_release_driver);
EXPORT_SYMBOL_GPL(device_attach);
EXPORT_SYMBOL_GPL(driver_attach);
Loading