Driver core: device_attribute parameters can often be const*
Most device_attributes are const, and are begging to be put in a ro section. However, the create and remove file interfaces were failing to propagate the const promise which the only functions they call offer. Signed-off-by: Phil Carmody <ext-phil.2.carmody@nokia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
8e9b936226
commit
26579ab70a
|
@ -91,8 +91,8 @@ struct device_attribute {
|
||||||
const char *buf, size_t count);
|
const char *buf, size_t count);
|
||||||
};
|
};
|
||||||
|
|
||||||
int device_create_file(struct device *, struct device_attribute *);
|
int device_create_file(struct device *, const struct device_attribute *);
|
||||||
void device_remove_file(struct device *, struct device_attribute *);
|
void device_remove_file(struct device *, const struct device_attribute *);
|
||||||
|
|
||||||
It also defines this helper for defining device attributes:
|
It also defines this helper for defining device attributes:
|
||||||
|
|
||||||
|
@ -316,8 +316,8 @@ DEVICE_ATTR(_name, _mode, _show, _store);
|
||||||
|
|
||||||
Creation/Removal:
|
Creation/Removal:
|
||||||
|
|
||||||
int device_create_file(struct device *device, struct device_attribute * attr);
|
int device_create_file(struct device *dev, const struct device_attribute * attr);
|
||||||
void device_remove_file(struct device * dev, struct device_attribute * attr);
|
void device_remove_file(struct device *dev, const struct device_attribute * attr);
|
||||||
|
|
||||||
|
|
||||||
- bus drivers (include/linux/device.h)
|
- bus drivers (include/linux/device.h)
|
||||||
|
|
|
@ -446,7 +446,8 @@ struct kset *devices_kset;
|
||||||
* @dev: device.
|
* @dev: device.
|
||||||
* @attr: device attribute descriptor.
|
* @attr: device attribute descriptor.
|
||||||
*/
|
*/
|
||||||
int device_create_file(struct device *dev, struct device_attribute *attr)
|
int device_create_file(struct device *dev,
|
||||||
|
const struct device_attribute *attr)
|
||||||
{
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
if (dev)
|
if (dev)
|
||||||
|
@ -459,7 +460,8 @@ int device_create_file(struct device *dev, struct device_attribute *attr)
|
||||||
* @dev: device.
|
* @dev: device.
|
||||||
* @attr: device attribute descriptor.
|
* @attr: device attribute descriptor.
|
||||||
*/
|
*/
|
||||||
void device_remove_file(struct device *dev, struct device_attribute *attr)
|
void device_remove_file(struct device *dev,
|
||||||
|
const struct device_attribute *attr)
|
||||||
{
|
{
|
||||||
if (dev)
|
if (dev)
|
||||||
sysfs_remove_file(&dev->kobj, &attr->attr);
|
sysfs_remove_file(&dev->kobj, &attr->attr);
|
||||||
|
|
|
@ -319,9 +319,9 @@ struct device_attribute {
|
||||||
struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)
|
struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)
|
||||||
|
|
||||||
extern int __must_check device_create_file(struct device *device,
|
extern int __must_check device_create_file(struct device *device,
|
||||||
struct device_attribute *entry);
|
const struct device_attribute *entry);
|
||||||
extern void device_remove_file(struct device *dev,
|
extern void device_remove_file(struct device *dev,
|
||||||
struct device_attribute *attr);
|
const struct device_attribute *attr);
|
||||||
extern int __must_check device_create_bin_file(struct device *dev,
|
extern int __must_check device_create_bin_file(struct device *dev,
|
||||||
struct bin_attribute *attr);
|
struct bin_attribute *attr);
|
||||||
extern void device_remove_bin_file(struct device *dev,
|
extern void device_remove_bin_file(struct device *dev,
|
||||||
|
|
Loading…
Reference in New Issue