Source
806
806
struct aem_data *p1, *next1;
807
807
808
808
list_for_each_entry_safe(p1, next1, &driver_data.aem_devices, list)
809
809
if (p1->ipmi.interface == iface)
810
810
aem_delete(p1);
811
811
}
812
812
813
813
/* sysfs support functions */
814
814
815
815
/* AEM device name */
816
-
static ssize_t show_name(struct device *dev, struct device_attribute *devattr,
816
+
static ssize_t name_show(struct device *dev, struct device_attribute *devattr,
817
817
char *buf)
818
818
{
819
819
struct aem_data *data = dev_get_drvdata(dev);
820
820
821
821
return sprintf(buf, "%s%d\n", DRVNAME, data->ver_major);
822
822
}
823
-
static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, 0);
823
+
static SENSOR_DEVICE_ATTR_RO(name, name, 0);
824
824
825
825
/* AEM device version */
826
-
static ssize_t show_version(struct device *dev,
827
-
struct device_attribute *devattr,
828
-
char *buf)
826
+
static ssize_t version_show(struct device *dev,
827
+
struct device_attribute *devattr, char *buf)
829
828
{
830
829
struct aem_data *data = dev_get_drvdata(dev);
831
830
832
831
return sprintf(buf, "%d.%d\n", data->ver_major, data->ver_minor);
833
832
}
834
-
static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, 0);
833
+
static SENSOR_DEVICE_ATTR_RO(version, version, 0);
835
834
836
835
/* Display power use */
837
836
static ssize_t aem_show_power(struct device *dev,
838
837
struct device_attribute *devattr,
839
838
char *buf)
840
839
{
841
840
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
842
841
struct aem_data *data = dev_get_drvdata(dev);
843
842
u64 before, after, delta, time;
844
843
signed long leftover;
924
923
const struct aem_rw_sensor_template *rw)
925
924
{
926
925
struct device *dev = &data->pdev->dev;
927
926
struct sensor_device_attribute *sensors = data->sensors;
928
927
int err;
929
928
930
929
/* Set up read-only sensors */
931
930
while (ro->label) {
932
931
sysfs_attr_init(&sensors->dev_attr.attr);
933
932
sensors->dev_attr.attr.name = ro->label;
934
-
sensors->dev_attr.attr.mode = S_IRUGO;
933
+
sensors->dev_attr.attr.mode = 0444;
935
934
sensors->dev_attr.show = ro->show;
936
935
sensors->index = ro->index;
937
936
938
937
err = device_create_file(dev, &sensors->dev_attr);
939
938
if (err) {
940
939
sensors->dev_attr.attr.name = NULL;
941
940
goto error;
942
941
}
943
942
sensors++;
944
943
ro++;
945
944
}
946
945
947
946
/* Set up read-write sensors */
948
947
while (rw->label) {
949
948
sysfs_attr_init(&sensors->dev_attr.attr);
950
949
sensors->dev_attr.attr.name = rw->label;
951
-
sensors->dev_attr.attr.mode = S_IRUGO | S_IWUSR;
950
+
sensors->dev_attr.attr.mode = 0644;
952
951
sensors->dev_attr.show = rw->show;
953
952
sensors->dev_attr.store = rw->set;
954
953
sensors->index = rw->index;
955
954
956
955
err = device_create_file(dev, &sensors->dev_attr);
957
956
if (err) {
958
957
sensors->dev_attr.attr.name = NULL;
959
958
goto error;
960
959
}
961
960
sensors++;