diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-04-29 02:27:34 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-06-20 18:15:03 -0400 |
commit | 70f2817a43c89b784dc2ec3d06ba5bf3064f8235 (patch) | |
tree | 210bbd16599d4e402051e4ec30c82e70b8b427ef | |
parent | 6c1852a08e444a2e66367352a99c0e93c8bf3e97 (diff) |
[PATCH] sysfs: (rest) if show/store is missing return -EIO
sysfs: fix the rest of the kernel so if an attribute doesn't
implement show or store method read/write will return
-EIO instead of 0 or -EINVAL or -EPERM.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/acpi/scan.c | 4 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 4 | ||||
-rw-r--r-- | drivers/firmware/edd.c | 2 | ||||
-rw-r--r-- | drivers/firmware/efivars.c | 4 | ||||
-rw-r--r-- | drivers/infiniband/core/sysfs.c | 2 | ||||
-rw-r--r-- | kernel/params.c | 4 | ||||
-rw-r--r-- | security/seclvl.c | 4 |
7 files changed, 12 insertions, 12 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 119c94093a13..e85885593280 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -65,14 +65,14 @@ static ssize_t acpi_device_attr_show(struct kobject *kobj, | |||
65 | { | 65 | { |
66 | struct acpi_device *device = to_acpi_device(kobj); | 66 | struct acpi_device *device = to_acpi_device(kobj); |
67 | struct acpi_device_attribute *attribute = to_handle_attr(attr); | 67 | struct acpi_device_attribute *attribute = to_handle_attr(attr); |
68 | return attribute->show ? attribute->show(device, buf) : 0; | 68 | return attribute->show ? attribute->show(device, buf) : -EIO; |
69 | } | 69 | } |
70 | static ssize_t acpi_device_attr_store(struct kobject *kobj, | 70 | static ssize_t acpi_device_attr_store(struct kobject *kobj, |
71 | struct attribute *attr, const char *buf, size_t len) | 71 | struct attribute *attr, const char *buf, size_t len) |
72 | { | 72 | { |
73 | struct acpi_device *device = to_acpi_device(kobj); | 73 | struct acpi_device *device = to_acpi_device(kobj); |
74 | struct acpi_device_attribute *attribute = to_handle_attr(attr); | 74 | struct acpi_device_attribute *attribute = to_handle_attr(attr); |
75 | return attribute->store ? attribute->store(device, buf, len) : len; | 75 | return attribute->store ? attribute->store(device, buf, len) : -EIO; |
76 | } | 76 | } |
77 | 77 | ||
78 | static struct sysfs_ops acpi_device_sysfs_ops = { | 78 | static struct sysfs_ops acpi_device_sysfs_ops = { |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 03b5fb2ddcf4..bf62dfe4976a 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -521,7 +521,7 @@ static ssize_t show(struct kobject * kobj, struct attribute * attr ,char * buf) | |||
521 | policy = cpufreq_cpu_get(policy->cpu); | 521 | policy = cpufreq_cpu_get(policy->cpu); |
522 | if (!policy) | 522 | if (!policy) |
523 | return -EINVAL; | 523 | return -EINVAL; |
524 | ret = fattr->show ? fattr->show(policy,buf) : 0; | 524 | ret = fattr->show ? fattr->show(policy,buf) : -EIO; |
525 | cpufreq_cpu_put(policy); | 525 | cpufreq_cpu_put(policy); |
526 | return ret; | 526 | return ret; |
527 | } | 527 | } |
@@ -535,7 +535,7 @@ static ssize_t store(struct kobject * kobj, struct attribute * attr, | |||
535 | policy = cpufreq_cpu_get(policy->cpu); | 535 | policy = cpufreq_cpu_get(policy->cpu); |
536 | if (!policy) | 536 | if (!policy) |
537 | return -EINVAL; | 537 | return -EINVAL; |
538 | ret = fattr->store ? fattr->store(policy,buf,count) : 0; | 538 | ret = fattr->store ? fattr->store(policy,buf,count) : -EIO; |
539 | cpufreq_cpu_put(policy); | 539 | cpufreq_cpu_put(policy); |
540 | return ret; | 540 | return ret; |
541 | } | 541 | } |
diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c index 33b669e6f977..6996476669f1 100644 --- a/drivers/firmware/edd.c +++ b/drivers/firmware/edd.c | |||
@@ -115,7 +115,7 @@ edd_attr_show(struct kobject * kobj, struct attribute *attr, char *buf) | |||
115 | { | 115 | { |
116 | struct edd_device *dev = to_edd_device(kobj); | 116 | struct edd_device *dev = to_edd_device(kobj); |
117 | struct edd_attribute *edd_attr = to_edd_attr(attr); | 117 | struct edd_attribute *edd_attr = to_edd_attr(attr); |
118 | ssize_t ret = 0; | 118 | ssize_t ret = -EIO; |
119 | 119 | ||
120 | if (edd_attr->show) | 120 | if (edd_attr->show) |
121 | ret = edd_attr->show(dev, buf); | 121 | ret = edd_attr->show(dev, buf); |
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index 0287ff65963b..a3451cb94004 100644 --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c | |||
@@ -352,7 +352,7 @@ static ssize_t efivar_attr_show(struct kobject *kobj, struct attribute *attr, | |||
352 | { | 352 | { |
353 | struct efivar_entry *var = to_efivar_entry(kobj); | 353 | struct efivar_entry *var = to_efivar_entry(kobj); |
354 | struct efivar_attribute *efivar_attr = to_efivar_attr(attr); | 354 | struct efivar_attribute *efivar_attr = to_efivar_attr(attr); |
355 | ssize_t ret = 0; | 355 | ssize_t ret = -EIO; |
356 | 356 | ||
357 | if (!capable(CAP_SYS_ADMIN)) | 357 | if (!capable(CAP_SYS_ADMIN)) |
358 | return -EACCES; | 358 | return -EACCES; |
@@ -368,7 +368,7 @@ static ssize_t efivar_attr_store(struct kobject *kobj, struct attribute *attr, | |||
368 | { | 368 | { |
369 | struct efivar_entry *var = to_efivar_entry(kobj); | 369 | struct efivar_entry *var = to_efivar_entry(kobj); |
370 | struct efivar_attribute *efivar_attr = to_efivar_attr(attr); | 370 | struct efivar_attribute *efivar_attr = to_efivar_attr(attr); |
371 | ssize_t ret = 0; | 371 | ssize_t ret = -EIO; |
372 | 372 | ||
373 | if (!capable(CAP_SYS_ADMIN)) | 373 | if (!capable(CAP_SYS_ADMIN)) |
374 | return -EACCES; | 374 | return -EACCES; |
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 5febd6d8b885..90d51b179abe 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c | |||
@@ -71,7 +71,7 @@ static ssize_t port_attr_show(struct kobject *kobj, | |||
71 | struct ib_port *p = container_of(kobj, struct ib_port, kobj); | 71 | struct ib_port *p = container_of(kobj, struct ib_port, kobj); |
72 | 72 | ||
73 | if (!port_attr->show) | 73 | if (!port_attr->show) |
74 | return 0; | 74 | return -EIO; |
75 | 75 | ||
76 | return port_attr->show(p, port_attr, buf); | 76 | return port_attr->show(p, port_attr, buf); |
77 | } | 77 | } |
diff --git a/kernel/params.c b/kernel/params.c index 5513844bec13..d586c35ef8fc 100644 --- a/kernel/params.c +++ b/kernel/params.c | |||
@@ -629,7 +629,7 @@ static ssize_t module_attr_show(struct kobject *kobj, | |||
629 | mk = to_module_kobject(kobj); | 629 | mk = to_module_kobject(kobj); |
630 | 630 | ||
631 | if (!attribute->show) | 631 | if (!attribute->show) |
632 | return -EPERM; | 632 | return -EIO; |
633 | 633 | ||
634 | if (!try_module_get(mk->mod)) | 634 | if (!try_module_get(mk->mod)) |
635 | return -ENODEV; | 635 | return -ENODEV; |
@@ -653,7 +653,7 @@ static ssize_t module_attr_store(struct kobject *kobj, | |||
653 | mk = to_module_kobject(kobj); | 653 | mk = to_module_kobject(kobj); |
654 | 654 | ||
655 | if (!attribute->store) | 655 | if (!attribute->store) |
656 | return -EPERM; | 656 | return -EIO; |
657 | 657 | ||
658 | if (!try_module_get(mk->mod)) | 658 | if (!try_module_get(mk->mod)) |
659 | return -ENODEV; | 659 | return -ENODEV; |
diff --git a/security/seclvl.c b/security/seclvl.c index 8a0ab0d7949e..c8e87b22c9bd 100644 --- a/security/seclvl.c +++ b/security/seclvl.c | |||
@@ -155,7 +155,7 @@ seclvl_attr_store(struct kobject *kobj, | |||
155 | struct seclvl_obj *obj = container_of(kobj, struct seclvl_obj, kobj); | 155 | struct seclvl_obj *obj = container_of(kobj, struct seclvl_obj, kobj); |
156 | struct seclvl_attribute *attribute = | 156 | struct seclvl_attribute *attribute = |
157 | container_of(attr, struct seclvl_attribute, attr); | 157 | container_of(attr, struct seclvl_attribute, attr); |
158 | return (attribute->store ? attribute->store(obj, buf, len) : 0); | 158 | return attribute->store ? attribute->store(obj, buf, len) : -EIO; |
159 | } | 159 | } |
160 | 160 | ||
161 | static ssize_t | 161 | static ssize_t |
@@ -164,7 +164,7 @@ seclvl_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) | |||
164 | struct seclvl_obj *obj = container_of(kobj, struct seclvl_obj, kobj); | 164 | struct seclvl_obj *obj = container_of(kobj, struct seclvl_obj, kobj); |
165 | struct seclvl_attribute *attribute = | 165 | struct seclvl_attribute *attribute = |
166 | container_of(attr, struct seclvl_attribute, attr); | 166 | container_of(attr, struct seclvl_attribute, attr); |
167 | return (attribute->show ? attribute->show(obj, buf) : 0); | 167 | return attribute->show ? attribute->show(obj, buf) : -EIO; |
168 | } | 168 | } |
169 | 169 | ||
170 | /** | 170 | /** |