Commit bd7d075a authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Greg Kroah-Hartman

[PATCH] Driver Core: Whitespace fixes

Whitespace and formatting changes (a,b,c -> a, b, c) in drivers/base
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 2d586ba5
...@@ -6,12 +6,13 @@ extern void bus_remove_driver(struct device_driver *); ...@@ -6,12 +6,13 @@ extern void bus_remove_driver(struct device_driver *);
static inline struct class_device *to_class_dev(struct kobject *obj) static inline struct class_device *to_class_dev(struct kobject *obj)
{ {
return container_of(obj,struct class_device,kobj); return container_of(obj, struct class_device, kobj);
} }
static inline static inline
struct class_device_attribute *to_class_dev_attr(struct attribute *_attr) struct class_device_attribute *to_class_dev_attr(struct attribute *_attr)
{ {
return container_of(_attr,struct class_device_attribute,attr); return container_of(_attr, struct class_device_attribute, attr);
} }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2003-2004 Greg Kroah-Hartman <greg@kroah.com> * Copyright (c) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
* Copyright (c) 2003-2004 IBM Corp. * Copyright (c) 2003-2004 IBM Corp.
* *
* This file is released under the GPLv2 * This file is released under the GPLv2
* *
*/ */
...@@ -111,7 +111,7 @@ EXPORT_SYMBOL(class_simple_destroy); ...@@ -111,7 +111,7 @@ EXPORT_SYMBOL(class_simple_destroy);
/** /**
* class_simple_device_add - adds a class device to sysfs for a character driver * class_simple_device_add - adds a class device to sysfs for a character driver
* @cs: pointer to the struct class_simple that this device should be registered to. * @cs: pointer to the struct class_simple that this device should be registered to.
* @dev: the dev_t for the device to be added. * @dev: the dev_t for the 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 * @fmt: string for the class device's name
...@@ -146,8 +146,8 @@ struct class_device *class_simple_device_add(struct class_simple *cs, dev_t dev, ...@@ -146,8 +146,8 @@ struct class_device *class_simple_device_add(struct class_simple *cs, dev_t dev,
s_dev->dev = dev; s_dev->dev = dev;
s_dev->class_dev.dev = device; s_dev->class_dev.dev = device;
s_dev->class_dev.class = &cs->class; s_dev->class_dev.class = &cs->class;
va_start(args,fmt); va_start(args, fmt);
vsnprintf(s_dev->class_dev.class_id, BUS_ID_SIZE, fmt, args); vsnprintf(s_dev->class_dev.class_id, BUS_ID_SIZE, fmt, args);
va_end(args); va_end(args);
retval = class_device_register(&s_dev->class_dev); retval = class_device_register(&s_dev->class_dev);
...@@ -173,10 +173,10 @@ EXPORT_SYMBOL(class_simple_device_add); ...@@ -173,10 +173,10 @@ EXPORT_SYMBOL(class_simple_device_add);
* @cs: pointer to the struct class_simple to hold the pointer * @cs: pointer to the struct class_simple to hold the pointer
* @hotplug: function pointer to the hotplug function * @hotplug: function pointer to the hotplug function
* *
* Implement and set a hotplug function to add environment variables specific to this * Implement and set a hotplug function to add environment variables specific to this
* class on the hotplug event. * class on the hotplug event.
*/ */
int class_simple_set_hotplug(struct class_simple *cs, int class_simple_set_hotplug(struct class_simple *cs,
int (*hotplug)(struct class_device *dev, char **envp, int num_envp, char *buffer, int buffer_size)) int (*hotplug)(struct class_device *dev, char **envp, int num_envp, char *buffer, int buffer_size))
{ {
if ((cs == NULL) || (IS_ERR(cs))) if ((cs == NULL) || (IS_ERR(cs)))
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2002-3 Patrick Mochel * Copyright (c) 2002-3 Patrick Mochel
* Copyright (c) 2002-3 Open Source Development Labs * Copyright (c) 2002-3 Open Source Development Labs
* *
* This file is released under the GPLv2 * This file is released under the GPLv2
* *
*/ */
...@@ -28,8 +28,8 @@ int (*platform_notify_remove)(struct device * dev) = NULL; ...@@ -28,8 +28,8 @@ int (*platform_notify_remove)(struct device * dev) = NULL;
* sysfs bindings for devices. * sysfs bindings for devices.
*/ */
#define to_dev(obj) container_of(obj,struct device,kobj) #define to_dev(obj) container_of(obj, struct device, kobj)
#define to_dev_attr(_attr) container_of(_attr,struct device_attribute,attr) #define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr)
extern struct attribute * dev_default_attrs[]; extern struct attribute * dev_default_attrs[];
...@@ -41,12 +41,12 @@ dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) ...@@ -41,12 +41,12 @@ dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
ssize_t ret = 0; ssize_t ret = 0;
if (dev_attr->show) if (dev_attr->show)
ret = dev_attr->show(dev,buf); ret = dev_attr->show(dev, buf);
return ret; return ret;
} }
static ssize_t static ssize_t
dev_attr_store(struct kobject * kobj, struct attribute * attr, dev_attr_store(struct kobject * kobj, struct attribute * attr,
const char * buf, size_t count) const char * buf, size_t count)
{ {
struct device_attribute * dev_attr = to_dev_attr(attr); struct device_attribute * dev_attr = to_dev_attr(attr);
...@@ -54,7 +54,7 @@ dev_attr_store(struct kobject * kobj, struct attribute * attr, ...@@ -54,7 +54,7 @@ dev_attr_store(struct kobject * kobj, struct attribute * attr,
ssize_t ret = 0; ssize_t ret = 0;
if (dev_attr->store) if (dev_attr->store)
ret = dev_attr->store(dev,buf,count); ret = dev_attr->store(dev, buf, count);
return ret; return ret;
} }
...@@ -153,7 +153,7 @@ int device_create_file(struct device * dev, struct device_attribute * attr) ...@@ -153,7 +153,7 @@ int device_create_file(struct device * dev, struct device_attribute * attr)
{ {
int error = 0; int error = 0;
if (get_device(dev)) { if (get_device(dev)) {
error = sysfs_create_file(&dev->kobj,&attr->attr); error = sysfs_create_file(&dev->kobj, &attr->attr);
put_device(dev); put_device(dev);
} }
return error; return error;
...@@ -168,7 +168,7 @@ int device_create_file(struct device * dev, struct device_attribute * attr) ...@@ -168,7 +168,7 @@ int device_create_file(struct device * dev, struct device_attribute * attr)
void device_remove_file(struct device * dev, struct device_attribute * attr) void device_remove_file(struct device * dev, struct device_attribute * attr)
{ {
if (get_device(dev)) { if (get_device(dev)) {
sysfs_remove_file(&dev->kobj,&attr->attr); sysfs_remove_file(&dev->kobj, &attr->attr);
put_device(dev); put_device(dev);
} }
} }
...@@ -179,7 +179,7 @@ void device_remove_file(struct device * dev, struct device_attribute * attr) ...@@ -179,7 +179,7 @@ void device_remove_file(struct device * dev, struct device_attribute * attr)
* @dev: device. * @dev: device.
* *
* This prepares the device for use by other layers, * This prepares the device for use by other layers,
* including adding it to the device hierarchy. * including adding it to the device hierarchy.
* It is the first half of device_register(), if called by * It is the first half of device_register(), if called by
* that, though it can also be called separately, so one * that, though it can also be called separately, so one
* may use @dev's fields (e.g. the refcount). * may use @dev's fields (e.g. the refcount).
...@@ -187,7 +187,7 @@ void device_remove_file(struct device * dev, struct device_attribute * attr) ...@@ -187,7 +187,7 @@ void device_remove_file(struct device * dev, struct device_attribute * attr)
void device_initialize(struct device *dev) void device_initialize(struct device *dev)
{ {
kobj_set_kset_s(dev,devices_subsys); kobj_set_kset_s(dev, devices_subsys);
kobject_init(&dev->kobj); kobject_init(&dev->kobj);
INIT_LIST_HEAD(&dev->node); INIT_LIST_HEAD(&dev->node);
INIT_LIST_HEAD(&dev->children); INIT_LIST_HEAD(&dev->children);
...@@ -200,7 +200,7 @@ void device_initialize(struct device *dev) ...@@ -200,7 +200,7 @@ void device_initialize(struct device *dev)
* device_add - add device to device hierarchy. * device_add - add device to device hierarchy.
* @dev: device. * @dev: device.
* *
* This is part 2 of device_register(), though may be called * This is part 2 of device_register(), though may be called
* separately _iff_ device_initialize() has been called separately. * separately _iff_ device_initialize() has been called separately.
* *
* This adds it to the kobject hierarchy via kobject_add(), adds it * This adds it to the kobject hierarchy via kobject_add(), adds it
...@@ -221,7 +221,7 @@ int device_add(struct device *dev) ...@@ -221,7 +221,7 @@ int device_add(struct device *dev)
pr_debug("DEV: registering device: ID = '%s'\n", dev->bus_id); pr_debug("DEV: registering device: ID = '%s'\n", dev->bus_id);
/* first, register with generic layer. */ /* first, register with generic layer. */
kobject_set_name(&dev->kobj,dev->bus_id); kobject_set_name(&dev->kobj, dev->bus_id);
if (parent) if (parent)
dev->kobj.parent = &parent->kobj; dev->kobj.parent = &parent->kobj;
...@@ -233,7 +233,7 @@ int device_add(struct device *dev) ...@@ -233,7 +233,7 @@ int device_add(struct device *dev)
goto BusError; goto BusError;
down_write(&devices_subsys.rwsem); down_write(&devices_subsys.rwsem);
if (parent) if (parent)
list_add_tail(&dev->node,&parent->children); list_add_tail(&dev->node, &parent->children);
up_write(&devices_subsys.rwsem); up_write(&devices_subsys.rwsem);
/* notify platform of device entry */ /* notify platform of device entry */
...@@ -258,9 +258,9 @@ int device_add(struct device *dev) ...@@ -258,9 +258,9 @@ int device_add(struct device *dev)
* @dev: pointer to the device structure * @dev: pointer to the device structure
* *
* This happens in two clean steps - initialize the device * This happens in two clean steps - initialize the device
* and add it to the system. The two steps can be called * and add it to the system. The two steps can be called
* separately, but this is the easiest and most common. * separately, but this is the easiest and most common.
* I.e. you should only call the two helpers separately if * I.e. you should only call the two helpers separately if
* have a clearly defined need to use and refcount the device * have a clearly defined need to use and refcount the device
* before it is added to the hierarchy. * before it is added to the hierarchy.
*/ */
...@@ -301,13 +301,13 @@ void put_device(struct device * dev) ...@@ -301,13 +301,13 @@ void put_device(struct device * dev)
* device_del - delete device from system. * device_del - delete device from system.
* @dev: device. * @dev: device.
* *
* This is the first part of the device unregistration * This is the first part of the device unregistration
* sequence. This removes the device from the lists we control * sequence. This removes the device from the lists we control
* from here, has it removed from the other driver model * from here, has it removed from the other driver model
* subsystems it was added to in device_add(), and removes it * subsystems it was added to in device_add(), and removes it
* from the kobject hierarchy. * from the kobject hierarchy.
* *
* NOTE: this should be called manually _iff_ device_add() was * NOTE: this should be called manually _iff_ device_add() was
* also called manually. * also called manually.
*/ */
...@@ -340,7 +340,7 @@ void device_del(struct device * dev) ...@@ -340,7 +340,7 @@ void device_del(struct device * dev)
* we remove it from all the subsystems with device_del(), then * we remove it from all the subsystems with device_del(), then
* we decrement the reference count via put_device(). If that * we decrement the reference count via put_device(). If that
* is the final reference count, the device will be cleaned up * is the final reference count, the device will be cleaned up
* via device_release() above. Otherwise, the structure will * via device_release() above. Otherwise, the structure will
* stick around until the final reference to the device is dropped. * stick around until the final reference to the device is dropped.
*/ */
void device_unregister(struct device * dev) void device_unregister(struct device * dev)
...@@ -358,7 +358,7 @@ void device_unregister(struct device * dev) ...@@ -358,7 +358,7 @@ void device_unregister(struct device * dev)
* @fn: function to be called for each device. * @fn: function to be called for each device.
* *
* Iterate over @dev's child devices, and call @fn for each, * Iterate over @dev's child devices, and call @fn for each,
* passing it @data. * passing it @data.
* *
* We check the return of @fn each time. If it returns anything * We check the return of @fn each time. If it returns anything
* other than 0, we break out and return that value. * other than 0, we break out and return that value.
...@@ -370,8 +370,8 @@ int device_for_each_child(struct device * dev, void * data, ...@@ -370,8 +370,8 @@ int device_for_each_child(struct device * dev, void * data,
int error = 0; int error = 0;
down_read(&devices_subsys.rwsem); down_read(&devices_subsys.rwsem);
list_for_each_entry(child,&dev->children,node) { list_for_each_entry(child, &dev->children, node) {
if((error = fn(child,data))) if((error = fn(child, data)))
break; break;
} }
up_read(&devices_subsys.rwsem); up_read(&devices_subsys.rwsem);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2002-3 Patrick Mochel * Copyright (c) 2002-3 Patrick Mochel
* Copyright (c) 2002-3 Open Source Development Labs * Copyright (c) 2002-3 Open Source Development Labs
* *
* This file is released under the GPLv2 * This file is released under the GPLv2
* *
*/ */
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
#include <linux/string.h> #include <linux/string.h>
#include "base.h" #include "base.h"
#define to_dev(node) container_of(node,struct device,driver_list) #define to_dev(node) container_of(node, struct device, driver_list)
#define to_drv(obj) container_of(obj,struct device_driver,kobj) #define to_drv(obj) container_of(obj, struct device_driver, kobj)
/** /**
* driver_create_file - create sysfs file for driver. * driver_create_file - create sysfs file for driver.
...@@ -28,7 +28,7 @@ int driver_create_file(struct device_driver * drv, struct driver_attribute * att ...@@ -28,7 +28,7 @@ int driver_create_file(struct device_driver * drv, struct driver_attribute * att
{ {
int error; int error;
if (get_driver(drv)) { if (get_driver(drv)) {
error = sysfs_create_file(&drv->kobj,&attr->attr); error = sysfs_create_file(&drv->kobj, &attr->attr);
put_driver(drv); put_driver(drv);
} else } else
error = -EINVAL; error = -EINVAL;
...@@ -45,7 +45,7 @@ int driver_create_file(struct device_driver * drv, struct driver_attribute * att ...@@ -45,7 +45,7 @@ int driver_create_file(struct device_driver * drv, struct driver_attribute * att
void driver_remove_file(struct device_driver * drv, struct driver_attribute * attr) void driver_remove_file(struct device_driver * drv, struct driver_attribute * attr)
{ {
if (get_driver(drv)) { if (get_driver(drv)) {
sysfs_remove_file(&drv->kobj,&attr->attr); sysfs_remove_file(&drv->kobj, &attr->attr);
put_driver(drv); put_driver(drv);
} }
} }
...@@ -76,7 +76,7 @@ void put_driver(struct device_driver * drv) ...@@ -76,7 +76,7 @@ void put_driver(struct device_driver * drv)
* @drv: driver to register * @drv: driver to register
* *
* We pass off most of the work to the bus_add_driver() call, * We pass off most of the work to the bus_add_driver() call,
* since most of the things we have to do deal with the bus * since most of the things we have to do deal with the bus
* structures. * structures.
* *
* The one interesting aspect is that we initialize @drv->unload_sem * The one interesting aspect is that we initialize @drv->unload_sem
...@@ -99,8 +99,8 @@ int driver_register(struct device_driver * drv) ...@@ -99,8 +99,8 @@ int driver_register(struct device_driver * drv)
* *
* Though, once that is done, we attempt to take @drv->unload_sem. * Though, once that is done, we attempt to take @drv->unload_sem.
* This will block until the driver refcount reaches 0, and it is * This will block until the driver refcount reaches 0, and it is
* released. Only modular drivers will call this function, and we * released. Only modular drivers will call this function, and we
* have to guarantee that it won't complete, letting the driver * have to guarantee that it won't complete, letting the driver
* unload until all references are gone. * unload until all references are gone.
*/ */
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2002-3 Patrick Mochel * Copyright (c) 2002-3 Patrick Mochel
* Copyright (c) 2002-3 Open Source Development Labs * Copyright (c) 2002-3 Open Source Development Labs
* *
* This file is released under the GPLv2 * This file is released under the GPLv2
* *
*/ */
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
static decl_subsys(firmware,NULL,NULL); static decl_subsys(firmware, NULL, NULL);
int firmware_register(struct subsystem * s) int firmware_register(struct subsystem * s)
{ {
kset_set_kset_s(s,firmware_subsys); kset_set_kset_s(s, firmware_subsys);
return subsystem_register(s); return subsystem_register(s);
} }
......
...@@ -68,7 +68,7 @@ firmware_timeout_show(struct class *class, char *buf) ...@@ -68,7 +68,7 @@ firmware_timeout_show(struct class *class, char *buf)
* firmware will be provided. * firmware will be provided.
* *
* Note: zero means 'wait for ever' * Note: zero means 'wait for ever'
* *
**/ **/
static ssize_t static ssize_t
firmware_timeout_store(struct class *class, const char *buf, size_t count) firmware_timeout_store(struct class *class, const char *buf, size_t count)
...@@ -121,7 +121,7 @@ firmware_loading_show(struct class_device *class_dev, char *buf) ...@@ -121,7 +121,7 @@ firmware_loading_show(struct class_device *class_dev, char *buf)
/** /**
* firmware_loading_store: - loading control file * firmware_loading_store: - loading control file
* Description: * Description:
* The relevant values are: * The relevant values are:
* *
* 1: Start a load, discarding any previous partial load. * 1: Start a load, discarding any previous partial load.
* 0: Conclude the load and handle the data to the driver code. * 0: Conclude the load and handle the data to the driver code.
...@@ -376,7 +376,7 @@ fw_setup_class_device(struct firmware *fw, struct class_device **class_dev_p, ...@@ -376,7 +376,7 @@ fw_setup_class_device(struct firmware *fw, struct class_device **class_dev_p,
return retval; return retval;
} }
/** /**
* request_firmware: - request firmware to hotplug and wait for it * request_firmware: - request firmware to hotplug and wait for it
* Description: * Description:
* @firmware will be used to return a firmware image by the name * @firmware will be used to return a firmware image by the name
...@@ -457,7 +457,7 @@ release_firmware(const struct firmware *fw) ...@@ -457,7 +457,7 @@ release_firmware(const struct firmware *fw)
/** /**
* register_firmware: - provide a firmware image for later usage * register_firmware: - provide a firmware image for later usage
* *
* Description: * Description:
* Make sure that @data will be available by requesting firmware @name. * Make sure that @data will be available by requesting firmware @name.
* *
...@@ -541,7 +541,7 @@ request_firmware_nowait( ...@@ -541,7 +541,7 @@ request_firmware_nowait(
ret = kernel_thread(request_firmware_work_func, fw_work, ret = kernel_thread(request_firmware_work_func, fw_work,
CLONE_FS | CLONE_FILES); CLONE_FS | CLONE_FILES);
if (ret < 0) { if (ret < 0) {
fw_work->cont(NULL, fw_work->context); fw_work->cont(NULL, fw_work->context);
return ret; return ret;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* *
* Copyright (c) 2002-3 Patrick Mochel * Copyright (c) 2002-3 Patrick Mochel
* Copyright (c) 2002-3 Open Source Development Labs * Copyright (c) 2002-3 Open Source Development Labs
* *
* This file is released under the GPLv2 * This file is released under the GPLv2
* *
*/ */
...@@ -33,7 +33,7 @@ void __init driver_init(void) ...@@ -33,7 +33,7 @@ void __init driver_init(void)
classes_init(); classes_init();
firmware_init(); firmware_init();
/* These are also core pieces, but must come after the /* These are also core pieces, but must come after the
* core core pieces. * core core pieces.
*/ */
platform_bus_init(); platform_bus_init();
......
/* /*
* drivers/base/interface.c - common driverfs interface that's exported to * drivers/base/interface.c - common driverfs interface that's exported to
* the world for all devices. * the world for all devices.
* *
* Copyright (c) 2002-3 Patrick Mochel * Copyright (c) 2002-3 Patrick Mochel
* Copyright (c) 2002-3 Open Source Development Labs * Copyright (c) 2002-3 Open Source Development Labs
* *
* This file is released under the GPLv2 * This file is released under the GPLv2
* *
*/ */
...@@ -16,33 +16,33 @@ ...@@ -16,33 +16,33 @@
/** /**
* detach_state - control the default power state for the device. * detach_state - control the default power state for the device.
* *
* This is the state the device enters when it's driver module is * This is the state the device enters when it's driver module is
* unloaded. The value is an unsigned integer, in the range of 0-4. * unloaded. The value is an unsigned integer, in the range of 0-4.
* '0' indicates 'On', so no action will be taken when the driver is * '0' indicates 'On', so no action will be taken when the driver is
* unloaded. This is the default behavior. * unloaded. This is the default behavior.
* '4' indicates 'Off', meaning the driver core will call the driver's * '4' indicates 'Off', meaning the driver core will call the driver's
* shutdown method to quiesce the device. * shutdown method to quiesce the device.
* 1-3 indicate a low-power state for the device to enter via the * 1-3 indicate a low-power state for the device to enter via the
* driver's suspend method. * driver's suspend method.
*/ */
static ssize_t detach_show(struct device * dev, char * buf) static ssize_t detach_show(struct device * dev, char * buf)
{ {
return sprintf(buf,"%u\n",dev->detach_state); return sprintf(buf, "%u\n", dev->detach_state);
} }
static ssize_t detach_store(struct device * dev, const char * buf, size_t n) static ssize_t detach_store(struct device * dev, const char * buf, size_t n)
{ {
u32 state; u32 state;
state = simple_strtoul(buf,NULL,10); state = simple_strtoul(buf, NULL, 10);
if (state > 4) if (state > 4)
return -EINVAL; return -EINVAL;
dev->detach_state = state; dev->detach_state = state;
return n; return n;
} }
static DEVICE_ATTR(detach_state,0644,detach_show,detach_store); static DEVICE_ATTR(detach_state, 0644, detach_show, detach_store);
struct attribute * dev_default_attrs[] = { struct attribute * dev_default_attrs[] = {
......
...@@ -29,7 +29,7 @@ static ssize_t node_read_cpumap(struct sys_device * dev, char * buf) ...@@ -29,7 +29,7 @@ static ssize_t node_read_cpumap(struct sys_device * dev, char * buf)
return len; return len;
} }
static SYSDEV_ATTR(cpumap,S_IRUGO,node_read_cpumap,NULL); static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumap, NULL);
/* Can be overwritten by architecture specific code. */ /* Can be overwritten by architecture specific code. */
int __attribute__((weak)) hugetlb_report_node_meminfo(int node, char *buf) int __attribute__((weak)) hugetlb_report_node_meminfo(int node, char *buf)
...@@ -54,17 +54,17 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) ...@@ -54,17 +54,17 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
"Node %d LowFree: %8lu kB\n", "Node %d LowFree: %8lu kB\n",
nid, K(i.totalram), nid, K(i.totalram),
nid, K(i.freeram), nid, K(i.freeram),
nid, K(i.totalram-i.freeram), nid, K(i.totalram - i.freeram),
nid, K(i.totalhigh), nid, K(i.totalhigh),
nid, K(i.freehigh), nid, K(i.freehigh),
nid, K(i.totalram-i.totalhigh), nid, K(i.totalram - i.totalhigh),
nid, K(i.freeram-i.freehigh)); nid, K(i.freeram - i.freehigh));
n += hugetlb_report_node_meminfo(nid, buf + n); n += hugetlb_report_node_meminfo(nid, buf + n);
return n; return n;
} }
#undef K #undef K
static SYSDEV_ATTR(meminfo,S_IRUGO,node_read_meminfo,NULL); static SYSDEV_ATTR(meminfo, S_IRUGO, node_read_meminfo, NULL);
static ssize_t node_read_numastat(struct sys_device * dev, char * buf) static ssize_t node_read_numastat(struct sys_device * dev, char * buf)
{ {
...@@ -104,7 +104,7 @@ static ssize_t node_read_numastat(struct sys_device * dev, char * buf) ...@@ -104,7 +104,7 @@ static ssize_t node_read_numastat(struct sys_device * dev, char * buf)
local_node, local_node,
other_node); other_node);
} }
static SYSDEV_ATTR(numastat,S_IRUGO,node_read_numastat,NULL); static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL);
/* /*
* register_node - Setup a driverfs device for a node. * register_node - Setup a driverfs device for a node.
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2002-3 Patrick Mochel * Copyright (c) 2002-3 Patrick Mochel
* Copyright (c) 2002-3 Open Source Development Labs * Copyright (c) 2002-3 Open Source Development Labs
* *
* This file is released under the GPLv2 * This file is released under the GPLv2
* *
* Please see Documentation/driver-model/platform.txt for more * Please see Documentation/driver-model/platform.txt for more
...@@ -116,14 +116,14 @@ int platform_device_register(struct platform_device * pdev) ...@@ -116,14 +116,14 @@ int platform_device_register(struct platform_device * pdev)
pdev->dev.parent = &platform_bus; pdev->dev.parent = &platform_bus;
pdev->dev.bus = &platform_bus_type; pdev->dev.bus = &platform_bus_type;
if (pdev->id != -1) if (pdev->id != -1)
snprintf(pdev->dev.bus_id, BUS_ID_SIZE, "%s%u", pdev->name, pdev->id); snprintf(pdev->dev.bus_id, BUS_ID_SIZE, "%s%u", pdev->name, pdev->id);
else else
strlcpy(pdev->dev.bus_id, pdev->name, BUS_ID_SIZE); strlcpy(pdev->dev.bus_id, pdev->name, BUS_ID_SIZE);
pr_debug("Registering platform device '%s'. Parent at %s\n", pr_debug("Registering platform device '%s'. Parent at %s\n",
pdev->dev.bus_id,pdev->dev.parent->bus_id); pdev->dev.bus_id, pdev->dev.parent->bus_id);
return device_register(&pdev->dev); return device_register(&pdev->dev);
} }
...@@ -139,13 +139,13 @@ void platform_device_unregister(struct platform_device * pdev) ...@@ -139,13 +139,13 @@ void platform_device_unregister(struct platform_device * pdev)
* @dev: device. * @dev: device.
* @drv: driver. * @drv: driver.
* *
* Platform device IDs are assumed to be encoded like this: * Platform device IDs are assumed to be encoded like this:
* "<name><instance>", where <name> is a short description of the * "<name><instance>", where <name> is a short description of the
* type of device, like "pci" or "floppy", and <instance> is the * type of device, like "pci" or "floppy", and <instance> is the
* enumerated instance of the device, like '0' or '42'. * enumerated instance of the device, like '0' or '42'.
* Driver IDs are simply "<name>". * Driver IDs are simply "<name>".
* So, extract the <name> from the platform_device structure, * So, extract the <name> from the platform_device structure,
* and compare it against the name of the driver. Return whether * and compare it against the name of the driver. Return whether
* they match or not. * they match or not.
*/ */
......
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
* and add it to the list of power-controlled devices. sysfs entries for * and add it to the list of power-controlled devices. sysfs entries for
* controlling device power management will also be added. * controlling device power management will also be added.
* *
* A different set of lists than the global subsystem list are used to * A different set of lists than the global subsystem list are used to
* keep track of power info because we use different lists to hold * keep track of power info because we use different lists to hold
* devices based on what stage of the power management process they * devices based on what stage of the power management process they
* are in. The power domain dependencies may also differ from the * are in. The power domain dependencies may also differ from the
* ancestral dependencies that the subsystem list maintains. * ancestral dependencies that the subsystem list maintains.
*/ */
...@@ -74,10 +74,10 @@ int device_pm_add(struct device * dev) ...@@ -74,10 +74,10 @@ int device_pm_add(struct device * dev)
pr_debug("PM: Adding info for %s:%s\n", pr_debug("PM: Adding info for %s:%s\n",
dev->bus ? dev->bus->name : "No Bus", dev->kobj.name); dev->bus ? dev->bus->name : "No Bus", dev->kobj.name);
atomic_set(&dev->power.pm_users,0); atomic_set(&dev->power.pm_users, 0);
down(&dpm_sem); down(&dpm_sem);
list_add_tail(&dev->power.entry,&dpm_active); list_add_tail(&dev->power.entry, &dpm_active);
device_pm_set_parent(dev,dev->parent); device_pm_set_parent(dev, dev->parent);
if ((error = dpm_sysfs_add(dev))) if ((error = dpm_sysfs_add(dev)))
list_del(&dev->power.entry); list_del(&dev->power.entry);
up(&dpm_sem); up(&dpm_sem);
......
...@@ -27,7 +27,7 @@ extern void device_shutdown(void); ...@@ -27,7 +27,7 @@ extern void device_shutdown(void);
*/ */
extern struct semaphore dpm_sem; extern struct semaphore dpm_sem;
/* /*
* The PM lists. * The PM lists.
*/ */
extern struct list_head dpm_active; extern struct list_head dpm_active;
...@@ -37,12 +37,12 @@ extern struct list_head dpm_off_irq; ...@@ -37,12 +37,12 @@ extern struct list_head dpm_off_irq;
static inline struct dev_pm_info * to_pm_info(struct list_head * entry) static inline struct dev_pm_info * to_pm_info(struct list_head * entry)
{ {
return container_of(entry,struct dev_pm_info,entry); return container_of(entry, struct dev_pm_info, entry);
} }
static inline struct device * to_device(struct list_head * entry) static inline struct device * to_device(struct list_head * entry)
{ {
return container_of(to_pm_info(entry),struct device,power); return container_of(to_pm_info(entry), struct device, power);
} }
extern int device_pm_add(struct device *); extern int device_pm_add(struct device *);
...@@ -56,7 +56,7 @@ extern int dpm_sysfs_add(struct device *); ...@@ -56,7 +56,7 @@ extern int dpm_sysfs_add(struct device *);
extern void dpm_sysfs_remove(struct device *); extern void dpm_sysfs_remove(struct device *);
/* /*
* resume.c * resume.c
*/ */
extern void dpm_resume(void); extern void dpm_resume(void);
......
...@@ -39,7 +39,7 @@ void dpm_resume(void) ...@@ -39,7 +39,7 @@ void dpm_resume(void)
if (!dev->power.prev_state) if (!dev->power.prev_state)
resume_device(dev); resume_device(dev);
list_add_tail(entry,&dpm_active); list_add_tail(entry, &dpm_active);
} }
} }
...@@ -48,7 +48,7 @@ void dpm_resume(void) ...@@ -48,7 +48,7 @@ void dpm_resume(void)
* device_resume - Restore state of each device in system. * device_resume - Restore state of each device in system.
* *
* Walk the dpm_off list, remove each entry, resume the device, * Walk the dpm_off list, remove each entry, resume the device,
* then add it to the dpm_active list. * then add it to the dpm_active list.
*/ */
void device_resume(void) void device_resume(void)
...@@ -62,14 +62,14 @@ EXPORT_SYMBOL(device_resume); ...@@ -62,14 +62,14 @@ EXPORT_SYMBOL(device_resume);
/** /**
* device_power_up_irq - Power on some devices. * device_power_up_irq - Power on some devices.
* *
* Walk the dpm_off_irq list and power each device up. This * Walk the dpm_off_irq list and power each device up. This
* is used for devices that required they be powered down with * is used for devices that required they be powered down with
* interrupts disabled. As devices are powered on, they are moved to * interrupts disabled. As devices are powered on, they are moved to
* the dpm_suspended list. * the dpm_suspended list.
* *
* Interrupts must be disabled when calling this. * Interrupts must be disabled when calling this.
*/ */
void dpm_power_up(void) void dpm_power_up(void)
...@@ -78,7 +78,7 @@ void dpm_power_up(void) ...@@ -78,7 +78,7 @@ void dpm_power_up(void)
struct list_head * entry = dpm_off_irq.next; struct list_head * entry = dpm_off_irq.next;
list_del_init(entry); list_del_init(entry);
resume_device(to_device(entry)); resume_device(to_device(entry));
list_add_tail(entry,&dpm_active); list_add_tail(entry, &dpm_active);
} }
} }
......
...@@ -24,9 +24,9 @@ static void runtime_resume(struct device * dev) ...@@ -24,9 +24,9 @@ static void runtime_resume(struct device * dev)
* dpm_runtime_resume - Power one device back on. * dpm_runtime_resume - Power one device back on.
* @dev: Device. * @dev: Device.
* *
* Bring one device back to the on state by first powering it * Bring one device back to the on state by first powering it
* on, then restoring state. We only operate on devices that aren't * on, then restoring state. We only operate on devices that aren't
* already on. * already on.
* FIXME: We need to handle devices that are in an unknown state. * FIXME: We need to handle devices that are in an unknown state.
*/ */
...@@ -55,7 +55,7 @@ int dpm_runtime_suspend(struct device * dev, u32 state) ...@@ -55,7 +55,7 @@ int dpm_runtime_suspend(struct device * dev, u32 state)
if (dev->power.power_state) if (dev->power.power_state)
runtime_resume(dev); runtime_resume(dev);
if (!(error = suspend_device(dev,state))) if (!(error = suspend_device(dev, state)))
dev->power.power_state = state; dev->power.power_state = state;
Done: Done:
up(&dpm_sem); up(&dpm_sem);
...@@ -70,7 +70,7 @@ int dpm_runtime_suspend(struct device * dev, u32 state) ...@@ -70,7 +70,7 @@ int dpm_runtime_suspend(struct device * dev, u32 state)
* *
* This is an update mechanism for drivers to notify the core * This is an update mechanism for drivers to notify the core
* what power state a device is in. Device probing code may not * what power state a device is in. Device probing code may not
* always be able to tell, but we need accurate information to * always be able to tell, but we need accurate information to
* work reliably. * work reliably.
*/ */
void dpm_set_power_state(struct device * dev, u32 state) void dpm_set_power_state(struct device * dev, u32 state)
......
/* /*
* shutdown.c - power management functions for the device tree. * shutdown.c - power management functions for the device tree.
* *
* Copyright (c) 2002-3 Patrick Mochel * Copyright (c) 2002-3 Patrick Mochel
* 2002-3 Open Source Development Lab * 2002-3 Open Source Development Lab
* *
* This file is released under the GPLv2 * This file is released under the GPLv2
* *
*/ */
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "power.h" #include "power.h"
#define to_dev(node) container_of(node,struct device,kobj.entry) #define to_dev(node) container_of(node, struct device, kobj.entry)
extern struct subsystem devices_subsys; extern struct subsystem devices_subsys;
...@@ -29,7 +29,7 @@ int device_detach_shutdown(struct device * dev) ...@@ -29,7 +29,7 @@ int device_detach_shutdown(struct device * dev)
dev->driver->shutdown(dev); dev->driver->shutdown(dev);
return 0; return 0;
} }
return dpm_runtime_suspend(dev,dev->detach_state); return dpm_runtime_suspend(dev, dev->detach_state);
} }
...@@ -38,8 +38,8 @@ int device_detach_shutdown(struct device * dev) ...@@ -38,8 +38,8 @@ int device_detach_shutdown(struct device * dev)
* down last and resume them first. That way, we don't do anything stupid like * down last and resume them first. That way, we don't do anything stupid like
* shutting down the interrupt controller before any devices.. * shutting down the interrupt controller before any devices..
* *
* Note that there are not different stages for power management calls - * Note that there are not different stages for power management calls -
* they only get one called once when interrupts are disabled. * they only get one called once when interrupts are disabled.
*/ */
extern int sysdev_shutdown(void); extern int sysdev_shutdown(void);
...@@ -50,10 +50,10 @@ extern int sysdev_shutdown(void); ...@@ -50,10 +50,10 @@ extern int sysdev_shutdown(void);
void device_shutdown(void) void device_shutdown(void)
{ {
struct device * dev; struct device * dev;
down_write(&devices_subsys.rwsem); down_write(&devices_subsys.rwsem);
list_for_each_entry_reverse(dev,&devices_subsys.kset.list,kobj.entry) { list_for_each_entry_reverse(dev, &devices_subsys.kset.list, kobj.entry) {
pr_debug("shutting down %s: ",dev->bus_id); pr_debug("shutting down %s: ", dev->bus_id);
if (dev->driver && dev->driver->shutdown) { if (dev->driver && dev->driver->shutdown) {
pr_debug("Ok\n"); pr_debug("Ok\n");
dev->driver->shutdown(dev); dev->driver->shutdown(dev);
......
/* /*
* suspend.c - Functions for putting devices to sleep. * suspend.c - Functions for putting devices to sleep.
* *
* Copyright (c) 2003 Patrick Mochel * Copyright (c) 2003 Patrick Mochel
* Copyright (c) 2003 Open Source Development Labs * Copyright (c) 2003 Open Source Development Labs
...@@ -10,18 +10,18 @@ ...@@ -10,18 +10,18 @@
#include <linux/device.h> #include <linux/device.h>
#include "power.h" #include "power.h"
extern int sysdev_suspend(u32 state); extern int sysdev_suspend(u32 state);
/* /*
* The entries in the dpm_active list are in a depth first order, simply * The entries in the dpm_active list are in a depth first order, simply
* because children are guaranteed to be discovered after parents, and * because children are guaranteed to be discovered after parents, and
* are inserted at the back of the list on discovery. * are inserted at the back of the list on discovery.
* *
* All list on the suspend path are done in reverse order, so we operate * All list on the suspend path are done in reverse order, so we operate
* on the leaves of the device tree (or forests, depending on how you want * on the leaves of the device tree (or forests, depending on how you want
* to look at it ;) first. As nodes are removed from the back of the list, * to look at it ;) first. As nodes are removed from the back of the list,
* they are inserted into the front of their destintation lists. * they are inserted into the front of their destintation lists.
* *
* Things are the reverse on the resume path - iterations are done in * Things are the reverse on the resume path - iterations are done in
* forward order, and nodes are inserted at the back of their destination * forward order, and nodes are inserted at the back of their destination
...@@ -44,7 +44,7 @@ int suspend_device(struct device * dev, u32 state) ...@@ -44,7 +44,7 @@ int suspend_device(struct device * dev, u32 state)
dev->power.prev_state = dev->power.power_state; dev->power.prev_state = dev->power.power_state;
if (dev->bus && dev->bus->suspend && !dev->power.power_state) if (dev->bus && dev->bus->suspend && !dev->power.power_state)
error = dev->bus->suspend(dev,state); error = dev->bus->suspend(dev, state);
return error; return error;
} }
...@@ -52,16 +52,16 @@ int suspend_device(struct device * dev, u32 state) ...@@ -52,16 +52,16 @@ int suspend_device(struct device * dev, u32 state)
/** /**
* device_suspend - Save state and stop all devices in system. * device_suspend - Save state and stop all devices in system.
* @state: Power state to put each device in. * @state: Power state to put each device in.
* *
* Walk the dpm_active list, call ->suspend() for each device, and move * Walk the dpm_active list, call ->suspend() for each device, and move
* it to dpm_off. * it to dpm_off.
* Check the return value for each. If it returns 0, then we move the * Check the return value for each. If it returns 0, then we move the
* the device to the dpm_off list. If it returns -EAGAIN, we move it to * the device to the dpm_off list. If it returns -EAGAIN, we move it to
* the dpm_off_irq list. If we get a different error, try and back out. * the dpm_off_irq list. If we get a different error, try and back out.
* *
* If we hit a failure with any of the devices, call device_resume() * If we hit a failure with any of the devices, call device_resume()
* above to bring the suspended devices back to life. * above to bring the suspended devices back to life.
* *
* Note this function leaves dpm_sem held to * Note this function leaves dpm_sem held to
* a) block other devices from registering. * a) block other devices from registering.
...@@ -78,14 +78,14 @@ int device_suspend(u32 state) ...@@ -78,14 +78,14 @@ int device_suspend(u32 state)
while(!list_empty(&dpm_active)) { while(!list_empty(&dpm_active)) {
struct list_head * entry = dpm_active.prev; struct list_head * entry = dpm_active.prev;
struct device * dev = to_device(entry); struct device * dev = to_device(entry);
error = suspend_device(dev,state); error = suspend_device(dev, state);
if (!error) { if (!error) {
list_del(&dev->power.entry); list_del(&dev->power.entry);
list_add(&dev->power.entry,&dpm_off); list_add(&dev->power.entry, &dpm_off);
} else if (error == -EAGAIN) { } else if (error == -EAGAIN) {
list_del(&dev->power.entry); list_del(&dev->power.entry);
list_add(&dev->power.entry,&dpm_off_irq); list_add(&dev->power.entry, &dpm_off_irq);
} else { } else {
printk(KERN_ERR "Could not suspend device %s: " printk(KERN_ERR "Could not suspend device %s: "
"error %d\n", kobject_name(&dev->kobj), error); "error %d\n", kobject_name(&dev->kobj), error);
...@@ -108,8 +108,8 @@ EXPORT_SYMBOL(device_suspend); ...@@ -108,8 +108,8 @@ EXPORT_SYMBOL(device_suspend);
* @state: Power state to enter. * @state: Power state to enter.
* *
* Walk the dpm_off_irq list, calling ->power_down() for each device that * Walk the dpm_off_irq list, calling ->power_down() for each device that
* couldn't power down the device with interrupts enabled. When we're * couldn't power down the device with interrupts enabled. When we're
* done, power down system devices. * done, power down system devices.
*/ */
int device_power_down(u32 state) int device_power_down(u32 state)
...@@ -117,10 +117,10 @@ int device_power_down(u32 state) ...@@ -117,10 +117,10 @@ int device_power_down(u32 state)
int error = 0; int error = 0;
struct device * dev; struct device * dev;
list_for_each_entry_reverse(dev,&dpm_off_irq,power.entry) { list_for_each_entry_reverse(dev, &dpm_off_irq, power.entry) {
if ((error = suspend_device(dev,state))) if ((error = suspend_device(dev, state)))
break; break;
} }
if (error) if (error)
goto Error; goto Error;
if ((error = sysdev_suspend(state))) if ((error = sysdev_suspend(state)))
......
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
* *
* show() returns the current power state of the device. '0' indicates * show() returns the current power state of the device. '0' indicates
* the device is on. Other values (1-3) indicate the device is in a low * the device is on. Other values (1-3) indicate the device is in a low
* power state. * power state.
* *
* store() sets the current power state, which is an integer value * store() sets the current power state, which is an integer value
* between 0-3. If the device is on ('0'), and the value written is * between 0-3. If the device is on ('0'), and the value written is
* greater than 0, then the device is placed directly into the low-power * greater than 0, then the device is placed directly into the low-power
* state (via its driver's ->suspend() method). * state (via its driver's ->suspend() method).
* If the device is currently in a low-power state, and the value is 0, * If the device is currently in a low-power state, and the value is 0,
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
static ssize_t state_show(struct device * dev, char * buf) static ssize_t state_show(struct device * dev, char * buf)
{ {
return sprintf(buf,"%u\n",dev->power.power_state); return sprintf(buf, "%u\n", dev->power.power_state);
} }
static ssize_t state_store(struct device * dev, const char * buf, size_t n) static ssize_t state_store(struct device * dev, const char * buf, size_t n)
...@@ -35,17 +35,17 @@ static ssize_t state_store(struct device * dev, const char * buf, size_t n) ...@@ -35,17 +35,17 @@ static ssize_t state_store(struct device * dev, const char * buf, size_t n)
char * rest; char * rest;
int error = 0; int error = 0;
state = simple_strtoul(buf,&rest,10); state = simple_strtoul(buf, &rest, 10);
if (*rest) if (*rest)
return -EINVAL; return -EINVAL;
if (state) if (state)
error = dpm_runtime_suspend(dev,state); error = dpm_runtime_suspend(dev, state);
else else
dpm_runtime_resume(dev); dpm_runtime_resume(dev);
return error ? error : n; return error ? error : n;
} }
static DEVICE_ATTR(state,0644,state_show,state_store); static DEVICE_ATTR(state, 0644, state_show, state_store);
static struct attribute * power_attrs[] = { static struct attribute * power_attrs[] = {
...@@ -59,10 +59,10 @@ static struct attribute_group pm_attr_group = { ...@@ -59,10 +59,10 @@ static struct attribute_group pm_attr_group = {
int dpm_sysfs_add(struct device * dev) int dpm_sysfs_add(struct device * dev)
{ {
return sysfs_create_group(&dev->kobj,&pm_attr_group); return sysfs_create_group(&dev->kobj, &pm_attr_group);
} }
void dpm_sysfs_remove(struct device * dev) void dpm_sysfs_remove(struct device * dev)
{ {
sysfs_remove_group(&dev->kobj,&pm_attr_group); sysfs_remove_group(&dev->kobj, &pm_attr_group);
} }
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment