Browse Source

Driver core: driver_attribute parameters can often be const*

Many struct driver_attribute descriptors are purely read-only
structures, and there's no need to change them. Therefore make
the promise not to, which will let those descriptors be put in
a ro section.

Signed-off-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Phil Carmody 15 năm trước cách đây
mục cha
commit
099c2f21d8

+ 2 - 2
Documentation/driver-model/driver.txt

@@ -226,5 +226,5 @@ struct driver_attribute driver_attr_debug;
 This can then be used to add and remove the attribute from the
 This can then be used to add and remove the attribute from the
 driver's directory using:
 driver's directory using:
 
 
-int driver_create_file(struct device_driver *, struct driver_attribute *);
-void driver_remove_file(struct device_driver *, struct driver_attribute *);
+int driver_create_file(struct device_driver *, const struct driver_attribute *);
+void driver_remove_file(struct device_driver *, const struct driver_attribute *);

+ 2 - 2
Documentation/filesystems/sysfs.txt

@@ -358,7 +358,7 @@ DRIVER_ATTR(_name, _mode, _show, _store)
 
 
 Creation/Removal:
 Creation/Removal:
 
 
-int driver_create_file(struct device_driver *, struct driver_attribute *);
-void driver_remove_file(struct device_driver *, struct driver_attribute *);
+int driver_create_file(struct device_driver *, const struct driver_attribute *);
+void driver_remove_file(struct device_driver *, const struct driver_attribute *);
 
 
 
 

+ 2 - 2
drivers/base/driver.c

@@ -98,7 +98,7 @@ EXPORT_SYMBOL_GPL(driver_find_device);
  * @attr: driver attribute descriptor.
  * @attr: driver attribute descriptor.
  */
  */
 int driver_create_file(struct device_driver *drv,
 int driver_create_file(struct device_driver *drv,
-		       struct driver_attribute *attr)
+		       const struct driver_attribute *attr)
 {
 {
 	int error;
 	int error;
 	if (drv)
 	if (drv)
@@ -115,7 +115,7 @@ EXPORT_SYMBOL_GPL(driver_create_file);
  * @attr: driver attribute descriptor.
  * @attr: driver attribute descriptor.
  */
  */
 void driver_remove_file(struct device_driver *drv,
 void driver_remove_file(struct device_driver *drv,
-			struct driver_attribute *attr)
+			const struct driver_attribute *attr)
 {
 {
 	if (drv)
 	if (drv)
 		sysfs_remove_file(&drv->p->kobj, &attr->attr);
 		sysfs_remove_file(&drv->p->kobj, &attr->attr);

+ 2 - 2
include/linux/device.h

@@ -166,9 +166,9 @@ struct driver_attribute driver_attr_##_name =		\
 	__ATTR(_name, _mode, _show, _store)
 	__ATTR(_name, _mode, _show, _store)
 
 
 extern int __must_check driver_create_file(struct device_driver *driver,
 extern int __must_check driver_create_file(struct device_driver *driver,
-					   struct driver_attribute *attr);
+					const struct driver_attribute *attr);
 extern void driver_remove_file(struct device_driver *driver,
 extern void driver_remove_file(struct device_driver *driver,
-			       struct driver_attribute *attr);
+			       const struct driver_attribute *attr);
 
 
 extern int __must_check driver_add_kobj(struct device_driver *drv,
 extern int __must_check driver_add_kobj(struct device_driver *drv,
 					struct kobject *kobj,
 					struct kobject *kobj,