diff options
| author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2015-01-23 09:01:10 -0500 |
|---|---|---|
| committer | Darren Hart <dvhart@linux.intel.com> | 2015-01-29 00:21:11 -0500 |
| commit | ed52ccbce7ffdde51f116e2cc9de00251f1ff7c5 (patch) | |
| tree | 66acb1e2965a04d96f341ec84309e3e5669d63c5 /drivers | |
| parent | 32d0e4a33773ad68c582999a5b945cc47bb02809 (diff) | |
asus-laptop: use DEVICE_ATTR_xx macros
Use DEVICE_ATTR_{RO,WO,RW} macros to simplify sysfs attributes
declaration.
To declare a "foo" attribute, DEVICE_ATTR_RW() requires foo_show() and
foo_store(), so rename a few functions to satisfy this requirement.
Also put the macro below each related show/store functions for clarity.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/platform/x86/asus-laptop.c | 95 |
1 files changed, 46 insertions, 49 deletions
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index 00f5e8217472..46b274693872 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c | |||
| @@ -856,8 +856,8 @@ static void asus_backlight_exit(struct asus_laptop *asus) | |||
| 856 | * than count bytes. We set eof to 1 if we handle those 2 values. We return the | 856 | * than count bytes. We set eof to 1 if we handle those 2 values. We return the |
| 857 | * number of bytes written in page | 857 | * number of bytes written in page |
| 858 | */ | 858 | */ |
| 859 | static ssize_t show_infos(struct device *dev, | 859 | static ssize_t infos_show(struct device *dev, struct device_attribute *attr, |
| 860 | struct device_attribute *attr, char *page) | 860 | char *page) |
| 861 | { | 861 | { |
| 862 | struct asus_laptop *asus = dev_get_drvdata(dev); | 862 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| 863 | int len = 0; | 863 | int len = 0; |
| @@ -926,6 +926,7 @@ static ssize_t show_infos(struct device *dev, | |||
| 926 | 926 | ||
| 927 | return len; | 927 | return len; |
| 928 | } | 928 | } |
| 929 | static DEVICE_ATTR_RO(infos); | ||
| 929 | 930 | ||
| 930 | static int parse_arg(const char *buf, unsigned long count, int *val) | 931 | static int parse_arg(const char *buf, unsigned long count, int *val) |
| 931 | { | 932 | { |
| @@ -957,15 +958,15 @@ static ssize_t sysfs_acpi_set(struct asus_laptop *asus, | |||
| 957 | /* | 958 | /* |
| 958 | * LEDD display | 959 | * LEDD display |
| 959 | */ | 960 | */ |
| 960 | static ssize_t show_ledd(struct device *dev, | 961 | static ssize_t ledd_show(struct device *dev, struct device_attribute *attr, |
| 961 | struct device_attribute *attr, char *buf) | 962 | char *buf) |
| 962 | { | 963 | { |
| 963 | struct asus_laptop *asus = dev_get_drvdata(dev); | 964 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| 964 | 965 | ||
| 965 | return sprintf(buf, "0x%08x\n", asus->ledd_status); | 966 | return sprintf(buf, "0x%08x\n", asus->ledd_status); |
| 966 | } | 967 | } |
| 967 | 968 | ||
| 968 | static ssize_t store_ledd(struct device *dev, struct device_attribute *attr, | 969 | static ssize_t ledd_store(struct device *dev, struct device_attribute *attr, |
| 969 | const char *buf, size_t count) | 970 | const char *buf, size_t count) |
| 970 | { | 971 | { |
| 971 | struct asus_laptop *asus = dev_get_drvdata(dev); | 972 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| @@ -981,6 +982,7 @@ static ssize_t store_ledd(struct device *dev, struct device_attribute *attr, | |||
| 981 | } | 982 | } |
| 982 | return rv; | 983 | return rv; |
| 983 | } | 984 | } |
| 985 | static DEVICE_ATTR_RW(ledd); | ||
| 984 | 986 | ||
| 985 | /* | 987 | /* |
| 986 | * Wireless | 988 | * Wireless |
| @@ -1014,21 +1016,22 @@ static int asus_wlan_set(struct asus_laptop *asus, int status) | |||
| 1014 | return 0; | 1016 | return 0; |
| 1015 | } | 1017 | } |
| 1016 | 1018 | ||
| 1017 | static ssize_t show_wlan(struct device *dev, | 1019 | static ssize_t wlan_show(struct device *dev, struct device_attribute *attr, |
| 1018 | struct device_attribute *attr, char *buf) | 1020 | char *buf) |
| 1019 | { | 1021 | { |
| 1020 | struct asus_laptop *asus = dev_get_drvdata(dev); | 1022 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| 1021 | 1023 | ||
| 1022 | return sprintf(buf, "%d\n", asus_wireless_status(asus, WL_RSTS)); | 1024 | return sprintf(buf, "%d\n", asus_wireless_status(asus, WL_RSTS)); |
| 1023 | } | 1025 | } |
| 1024 | 1026 | ||
| 1025 | static ssize_t store_wlan(struct device *dev, struct device_attribute *attr, | 1027 | static ssize_t wlan_store(struct device *dev, struct device_attribute *attr, |
| 1026 | const char *buf, size_t count) | 1028 | const char *buf, size_t count) |
| 1027 | { | 1029 | { |
| 1028 | struct asus_laptop *asus = dev_get_drvdata(dev); | 1030 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| 1029 | 1031 | ||
| 1030 | return sysfs_acpi_set(asus, buf, count, METHOD_WLAN); | 1032 | return sysfs_acpi_set(asus, buf, count, METHOD_WLAN); |
| 1031 | } | 1033 | } |
| 1034 | static DEVICE_ATTR_RW(wlan); | ||
| 1032 | 1035 | ||
| 1033 | /*e | 1036 | /*e |
| 1034 | * Bluetooth | 1037 | * Bluetooth |
| @@ -1042,15 +1045,15 @@ static int asus_bluetooth_set(struct asus_laptop *asus, int status) | |||
| 1042 | return 0; | 1045 | return 0; |
| 1043 | } | 1046 | } |
| 1044 | 1047 | ||
| 1045 | static ssize_t show_bluetooth(struct device *dev, | 1048 | static ssize_t bluetooth_show(struct device *dev, struct device_attribute *attr, |
| 1046 | struct device_attribute *attr, char *buf) | 1049 | char *buf) |
| 1047 | { | 1050 | { |
| 1048 | struct asus_laptop *asus = dev_get_drvdata(dev); | 1051 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| 1049 | 1052 | ||
| 1050 | return sprintf(buf, "%d\n", asus_wireless_status(asus, BT_RSTS)); | 1053 | return sprintf(buf, "%d\n", asus_wireless_status(asus, BT_RSTS)); |
| 1051 | } | 1054 | } |
| 1052 | 1055 | ||
| 1053 | static ssize_t store_bluetooth(struct device *dev, | 1056 | static ssize_t bluetooth_store(struct device *dev, |
| 1054 | struct device_attribute *attr, const char *buf, | 1057 | struct device_attribute *attr, const char *buf, |
| 1055 | size_t count) | 1058 | size_t count) |
| 1056 | { | 1059 | { |
| @@ -1058,6 +1061,7 @@ static ssize_t store_bluetooth(struct device *dev, | |||
| 1058 | 1061 | ||
| 1059 | return sysfs_acpi_set(asus, buf, count, METHOD_BLUETOOTH); | 1062 | return sysfs_acpi_set(asus, buf, count, METHOD_BLUETOOTH); |
| 1060 | } | 1063 | } |
| 1064 | static DEVICE_ATTR_RW(bluetooth); | ||
| 1061 | 1065 | ||
| 1062 | /* | 1066 | /* |
| 1063 | * Wimax | 1067 | * Wimax |
| @@ -1071,22 +1075,22 @@ static int asus_wimax_set(struct asus_laptop *asus, int status) | |||
| 1071 | return 0; | 1075 | return 0; |
| 1072 | } | 1076 | } |
| 1073 | 1077 | ||
| 1074 | static ssize_t show_wimax(struct device *dev, | 1078 | static ssize_t wimax_show(struct device *dev, struct device_attribute *attr, |
| 1075 | struct device_attribute *attr, char *buf) | 1079 | char *buf) |
| 1076 | { | 1080 | { |
| 1077 | struct asus_laptop *asus = dev_get_drvdata(dev); | 1081 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| 1078 | 1082 | ||
| 1079 | return sprintf(buf, "%d\n", asus_wireless_status(asus, WM_RSTS)); | 1083 | return sprintf(buf, "%d\n", asus_wireless_status(asus, WM_RSTS)); |
| 1080 | } | 1084 | } |
| 1081 | 1085 | ||
| 1082 | static ssize_t store_wimax(struct device *dev, | 1086 | static ssize_t wimax_store(struct device *dev, struct device_attribute *attr, |
| 1083 | struct device_attribute *attr, const char *buf, | 1087 | const char *buf, size_t count) |
| 1084 | size_t count) | ||
| 1085 | { | 1088 | { |
| 1086 | struct asus_laptop *asus = dev_get_drvdata(dev); | 1089 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| 1087 | 1090 | ||
| 1088 | return sysfs_acpi_set(asus, buf, count, METHOD_WIMAX); | 1091 | return sysfs_acpi_set(asus, buf, count, METHOD_WIMAX); |
| 1089 | } | 1092 | } |
| 1093 | static DEVICE_ATTR_RW(wimax); | ||
| 1090 | 1094 | ||
| 1091 | /* | 1095 | /* |
| 1092 | * Wwan | 1096 | * Wwan |
| @@ -1100,22 +1104,22 @@ static int asus_wwan_set(struct asus_laptop *asus, int status) | |||
| 1100 | return 0; | 1104 | return 0; |
| 1101 | } | 1105 | } |
| 1102 | 1106 | ||
| 1103 | static ssize_t show_wwan(struct device *dev, | 1107 | static ssize_t wwan_show(struct device *dev, struct device_attribute *attr, |
| 1104 | struct device_attribute *attr, char *buf) | 1108 | char *buf) |
| 1105 | { | 1109 | { |
| 1106 | struct asus_laptop *asus = dev_get_drvdata(dev); | 1110 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| 1107 | 1111 | ||
| 1108 | return sprintf(buf, "%d\n", asus_wireless_status(asus, WW_RSTS)); | 1112 | return sprintf(buf, "%d\n", asus_wireless_status(asus, WW_RSTS)); |
| 1109 | } | 1113 | } |
| 1110 | 1114 | ||
| 1111 | static ssize_t store_wwan(struct device *dev, | 1115 | static ssize_t wwan_store(struct device *dev, struct device_attribute *attr, |
| 1112 | struct device_attribute *attr, const char *buf, | 1116 | const char *buf, size_t count) |
| 1113 | size_t count) | ||
| 1114 | { | 1117 | { |
| 1115 | struct asus_laptop *asus = dev_get_drvdata(dev); | 1118 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| 1116 | 1119 | ||
| 1117 | return sysfs_acpi_set(asus, buf, count, METHOD_WWAN); | 1120 | return sysfs_acpi_set(asus, buf, count, METHOD_WWAN); |
| 1118 | } | 1121 | } |
| 1122 | static DEVICE_ATTR_RW(wwan); | ||
| 1119 | 1123 | ||
| 1120 | /* | 1124 | /* |
| 1121 | * Display | 1125 | * Display |
| @@ -1135,8 +1139,8 @@ static void asus_set_display(struct asus_laptop *asus, int value) | |||
| 1135 | * displays hooked up simultaneously, so be warned. See the acpi4asus README | 1139 | * displays hooked up simultaneously, so be warned. See the acpi4asus README |
| 1136 | * for more info. | 1140 | * for more info. |
| 1137 | */ | 1141 | */ |
| 1138 | static ssize_t store_disp(struct device *dev, struct device_attribute *attr, | 1142 | static ssize_t display_store(struct device *dev, struct device_attribute *attr, |
| 1139 | const char *buf, size_t count) | 1143 | const char *buf, size_t count) |
| 1140 | { | 1144 | { |
| 1141 | struct asus_laptop *asus = dev_get_drvdata(dev); | 1145 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| 1142 | int rv, value; | 1146 | int rv, value; |
| @@ -1146,6 +1150,7 @@ static ssize_t store_disp(struct device *dev, struct device_attribute *attr, | |||
| 1146 | asus_set_display(asus, value); | 1150 | asus_set_display(asus, value); |
| 1147 | return rv; | 1151 | return rv; |
| 1148 | } | 1152 | } |
| 1153 | static DEVICE_ATTR_WO(display); | ||
| 1149 | 1154 | ||
| 1150 | /* | 1155 | /* |
| 1151 | * Light Sens | 1156 | * Light Sens |
| @@ -1167,16 +1172,17 @@ static void asus_als_switch(struct asus_laptop *asus, int value) | |||
| 1167 | asus->light_switch = value; | 1172 | asus->light_switch = value; |
| 1168 | } | 1173 | } |
| 1169 | 1174 | ||
| 1170 | static ssize_t show_lssw(struct device *dev, | 1175 | static ssize_t ls_switch_show(struct device *dev, struct device_attribute *attr, |
| 1171 | struct device_attribute *attr, char *buf) | 1176 | char *buf) |
| 1172 | { | 1177 | { |
| 1173 | struct asus_laptop *asus = dev_get_drvdata(dev); | 1178 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| 1174 | 1179 | ||
| 1175 | return sprintf(buf, "%d\n", asus->light_switch); | 1180 | return sprintf(buf, "%d\n", asus->light_switch); |
| 1176 | } | 1181 | } |
| 1177 | 1182 | ||
| 1178 | static ssize_t store_lssw(struct device *dev, struct device_attribute *attr, | 1183 | static ssize_t ls_switch_store(struct device *dev, |
| 1179 | const char *buf, size_t count) | 1184 | struct device_attribute *attr, const char *buf, |
| 1185 | size_t count) | ||
| 1180 | { | 1186 | { |
| 1181 | struct asus_laptop *asus = dev_get_drvdata(dev); | 1187 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| 1182 | int rv, value; | 1188 | int rv, value; |
| @@ -1187,6 +1193,7 @@ static ssize_t store_lssw(struct device *dev, struct device_attribute *attr, | |||
| 1187 | 1193 | ||
| 1188 | return rv; | 1194 | return rv; |
| 1189 | } | 1195 | } |
| 1196 | static DEVICE_ATTR_RW(ls_switch); | ||
| 1190 | 1197 | ||
| 1191 | static void asus_als_level(struct asus_laptop *asus, int value) | 1198 | static void asus_als_level(struct asus_laptop *asus, int value) |
| 1192 | { | 1199 | { |
| @@ -1195,16 +1202,16 @@ static void asus_als_level(struct asus_laptop *asus, int value) | |||
| 1195 | asus->light_level = value; | 1202 | asus->light_level = value; |
| 1196 | } | 1203 | } |
| 1197 | 1204 | ||
| 1198 | static ssize_t show_lslvl(struct device *dev, | 1205 | static ssize_t ls_level_show(struct device *dev, struct device_attribute *attr, |
| 1199 | struct device_attribute *attr, char *buf) | 1206 | char *buf) |
| 1200 | { | 1207 | { |
| 1201 | struct asus_laptop *asus = dev_get_drvdata(dev); | 1208 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| 1202 | 1209 | ||
| 1203 | return sprintf(buf, "%d\n", asus->light_level); | 1210 | return sprintf(buf, "%d\n", asus->light_level); |
| 1204 | } | 1211 | } |
| 1205 | 1212 | ||
| 1206 | static ssize_t store_lslvl(struct device *dev, struct device_attribute *attr, | 1213 | static ssize_t ls_level_store(struct device *dev, struct device_attribute *attr, |
| 1207 | const char *buf, size_t count) | 1214 | const char *buf, size_t count) |
| 1208 | { | 1215 | { |
| 1209 | struct asus_laptop *asus = dev_get_drvdata(dev); | 1216 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| 1210 | int rv, value; | 1217 | int rv, value; |
| @@ -1218,6 +1225,7 @@ static ssize_t store_lslvl(struct device *dev, struct device_attribute *attr, | |||
| 1218 | 1225 | ||
| 1219 | return rv; | 1226 | return rv; |
| 1220 | } | 1227 | } |
| 1228 | static DEVICE_ATTR_RW(ls_level); | ||
| 1221 | 1229 | ||
| 1222 | static int pega_int_read(struct asus_laptop *asus, int arg, int *result) | 1230 | static int pega_int_read(struct asus_laptop *asus, int arg, int *result) |
| 1223 | { | 1231 | { |
| @@ -1234,8 +1242,8 @@ static int pega_int_read(struct asus_laptop *asus, int arg, int *result) | |||
| 1234 | return err; | 1242 | return err; |
| 1235 | } | 1243 | } |
| 1236 | 1244 | ||
| 1237 | static ssize_t show_lsvalue(struct device *dev, | 1245 | static ssize_t ls_value_show(struct device *dev, struct device_attribute *attr, |
| 1238 | struct device_attribute *attr, char *buf) | 1246 | char *buf) |
| 1239 | { | 1247 | { |
| 1240 | struct asus_laptop *asus = dev_get_drvdata(dev); | 1248 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| 1241 | int err, hi, lo; | 1249 | int err, hi, lo; |
| @@ -1247,6 +1255,7 @@ static ssize_t show_lsvalue(struct device *dev, | |||
| 1247 | return sprintf(buf, "%d\n", 10 * hi + lo); | 1255 | return sprintf(buf, "%d\n", 10 * hi + lo); |
| 1248 | return err; | 1256 | return err; |
| 1249 | } | 1257 | } |
| 1258 | static DEVICE_ATTR_RO(ls_value); | ||
| 1250 | 1259 | ||
| 1251 | /* | 1260 | /* |
| 1252 | * GPS | 1261 | * GPS |
| @@ -1274,15 +1283,15 @@ static int asus_gps_switch(struct asus_laptop *asus, int status) | |||
| 1274 | return 0; | 1283 | return 0; |
| 1275 | } | 1284 | } |
| 1276 | 1285 | ||
| 1277 | static ssize_t show_gps(struct device *dev, | 1286 | static ssize_t gps_show(struct device *dev, struct device_attribute *attr, |
| 1278 | struct device_attribute *attr, char *buf) | 1287 | char *buf) |
| 1279 | { | 1288 | { |
| 1280 | struct asus_laptop *asus = dev_get_drvdata(dev); | 1289 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| 1281 | 1290 | ||
| 1282 | return sprintf(buf, "%d\n", asus_gps_status(asus)); | 1291 | return sprintf(buf, "%d\n", asus_gps_status(asus)); |
| 1283 | } | 1292 | } |
| 1284 | 1293 | ||
| 1285 | static ssize_t store_gps(struct device *dev, struct device_attribute *attr, | 1294 | static ssize_t gps_store(struct device *dev, struct device_attribute *attr, |
| 1286 | const char *buf, size_t count) | 1295 | const char *buf, size_t count) |
| 1287 | { | 1296 | { |
| 1288 | struct asus_laptop *asus = dev_get_drvdata(dev); | 1297 | struct asus_laptop *asus = dev_get_drvdata(dev); |
| @@ -1298,6 +1307,7 @@ static ssize_t store_gps(struct device *dev, struct device_attribute *attr, | |||
| 1298 | rfkill_set_sw_state(asus->gps.rfkill, !value); | 1307 | rfkill_set_sw_state(asus->gps.rfkill, !value); |
| 1299 | return rv; | 1308 | return rv; |
| 1300 | } | 1309 | } |
| 1310 | static DEVICE_ATTR_RW(gps); | ||
| 1301 | 1311 | ||
| 1302 | /* | 1312 | /* |
| 1303 | * rfkill | 1313 | * rfkill |
| @@ -1569,19 +1579,6 @@ static void asus_acpi_notify(struct acpi_device *device, u32 event) | |||
| 1569 | asus_input_notify(asus, event); | 1579 | asus_input_notify(asus, event); |
| 1570 | } | 1580 | } |
| 1571 | 1581 | ||
| 1572 | static DEVICE_ATTR(infos, S_IRUGO, show_infos, NULL); | ||
| 1573 | static DEVICE_ATTR(wlan, S_IRUGO | S_IWUSR, show_wlan, store_wlan); | ||
| 1574 | static DEVICE_ATTR(bluetooth, S_IRUGO | S_IWUSR, | ||
| 1575 | show_bluetooth, store_bluetooth); | ||
| 1576 | static DEVICE_ATTR(wimax, S_IRUGO | S_IWUSR, show_wimax, store_wimax); | ||
| 1577 | static DEVICE_ATTR(wwan, S_IRUGO | S_IWUSR, show_wwan, store_wwan); | ||
| 1578 | static DEVICE_ATTR(display, S_IWUSR, NULL, store_disp); | ||
| 1579 | static DEVICE_ATTR(ledd, S_IRUGO | S_IWUSR, show_ledd, store_ledd); | ||
| 1580 | static DEVICE_ATTR(ls_value, S_IRUGO, show_lsvalue, NULL); | ||
| 1581 | static DEVICE_ATTR(ls_level, S_IRUGO | S_IWUSR, show_lslvl, store_lslvl); | ||
| 1582 | static DEVICE_ATTR(ls_switch, S_IRUGO | S_IWUSR, show_lssw, store_lssw); | ||
| 1583 | static DEVICE_ATTR(gps, S_IRUGO | S_IWUSR, show_gps, store_gps); | ||
| 1584 | |||
| 1585 | static struct attribute *asus_attributes[] = { | 1582 | static struct attribute *asus_attributes[] = { |
| 1586 | &dev_attr_infos.attr, | 1583 | &dev_attr_infos.attr, |
| 1587 | &dev_attr_wlan.attr, | 1584 | &dev_attr_wlan.attr, |
