diff options
Diffstat (limited to 'drivers/hid/hid-sony.c')
-rw-r--r-- | drivers/hid/hid-sony.c | 67 |
1 files changed, 32 insertions, 35 deletions
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 58e0bfadd6bf..8973f087a1a2 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c | |||
@@ -1096,19 +1096,18 @@ static void buzz_set_leds(struct hid_device *hdev, const __u8 *leds) | |||
1096 | hid_hw_request(hdev, report, HID_REQ_SET_REPORT); | 1096 | hid_hw_request(hdev, report, HID_REQ_SET_REPORT); |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | static void sony_set_leds(struct hid_device *hdev, const __u8 *leds, int count) | 1099 | static void sony_set_leds(struct sony_sc *sc, const __u8 *leds, int count) |
1100 | { | 1100 | { |
1101 | struct sony_sc *drv_data = hid_get_drvdata(hdev); | ||
1102 | int n; | 1101 | int n; |
1103 | 1102 | ||
1104 | BUG_ON(count > MAX_LEDS); | 1103 | BUG_ON(count > MAX_LEDS); |
1105 | 1104 | ||
1106 | if (drv_data->quirks & BUZZ_CONTROLLER && count == 4) { | 1105 | if (sc->quirks & BUZZ_CONTROLLER && count == 4) { |
1107 | buzz_set_leds(hdev, leds); | 1106 | buzz_set_leds(sc->hdev, leds); |
1108 | } else { | 1107 | } else { |
1109 | for (n = 0; n < count; n++) | 1108 | for (n = 0; n < count; n++) |
1110 | drv_data->led_state[n] = leds[n]; | 1109 | sc->led_state[n] = leds[n]; |
1111 | schedule_work(&drv_data->state_worker); | 1110 | schedule_work(&sc->state_worker); |
1112 | } | 1111 | } |
1113 | } | 1112 | } |
1114 | 1113 | ||
@@ -1131,7 +1130,8 @@ static void sony_led_set_brightness(struct led_classdev *led, | |||
1131 | if (led == drv_data->leds[n]) { | 1130 | if (led == drv_data->leds[n]) { |
1132 | if (value != drv_data->led_state[n]) { | 1131 | if (value != drv_data->led_state[n]) { |
1133 | drv_data->led_state[n] = value; | 1132 | drv_data->led_state[n] = value; |
1134 | sony_set_leds(hdev, drv_data->led_state, drv_data->led_count); | 1133 | sony_set_leds(drv_data, drv_data->led_state, |
1134 | drv_data->led_count); | ||
1135 | } | 1135 | } |
1136 | break; | 1136 | break; |
1137 | } | 1137 | } |
@@ -1160,30 +1160,28 @@ static enum led_brightness sony_led_get_brightness(struct led_classdev *led) | |||
1160 | return LED_OFF; | 1160 | return LED_OFF; |
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | static void sony_leds_remove(struct hid_device *hdev) | 1163 | static void sony_leds_remove(struct sony_sc *sc) |
1164 | { | 1164 | { |
1165 | struct sony_sc *drv_data; | ||
1166 | struct led_classdev *led; | 1165 | struct led_classdev *led; |
1167 | int n; | 1166 | int n; |
1168 | 1167 | ||
1169 | drv_data = hid_get_drvdata(hdev); | 1168 | BUG_ON(!(sc->quirks & SONY_LED_SUPPORT)); |
1170 | BUG_ON(!(drv_data->quirks & SONY_LED_SUPPORT)); | ||
1171 | 1169 | ||
1172 | for (n = 0; n < drv_data->led_count; n++) { | 1170 | for (n = 0; n < sc->led_count; n++) { |
1173 | led = drv_data->leds[n]; | 1171 | led = sc->leds[n]; |
1174 | drv_data->leds[n] = NULL; | 1172 | sc->leds[n] = NULL; |
1175 | if (!led) | 1173 | if (!led) |
1176 | continue; | 1174 | continue; |
1177 | led_classdev_unregister(led); | 1175 | led_classdev_unregister(led); |
1178 | kfree(led); | 1176 | kfree(led); |
1179 | } | 1177 | } |
1180 | 1178 | ||
1181 | drv_data->led_count = 0; | 1179 | sc->led_count = 0; |
1182 | } | 1180 | } |
1183 | 1181 | ||
1184 | static int sony_leds_init(struct hid_device *hdev) | 1182 | static int sony_leds_init(struct sony_sc *sc) |
1185 | { | 1183 | { |
1186 | struct sony_sc *drv_data; | 1184 | struct hid_device *hdev = sc->hdev; |
1187 | int n, ret = 0; | 1185 | int n, ret = 0; |
1188 | int max_brightness; | 1186 | int max_brightness; |
1189 | int use_colors; | 1187 | int use_colors; |
@@ -1195,11 +1193,10 @@ static int sony_leds_init(struct hid_device *hdev) | |||
1195 | static const char * const color_str[] = { "red", "green", "blue" }; | 1193 | static const char * const color_str[] = { "red", "green", "blue" }; |
1196 | static const __u8 initial_values[MAX_LEDS] = { 0x00, 0x00, 0x00, 0x00 }; | 1194 | static const __u8 initial_values[MAX_LEDS] = { 0x00, 0x00, 0x00, 0x00 }; |
1197 | 1195 | ||
1198 | drv_data = hid_get_drvdata(hdev); | 1196 | BUG_ON(!(sc->quirks & SONY_LED_SUPPORT)); |
1199 | BUG_ON(!(drv_data->quirks & SONY_LED_SUPPORT)); | ||
1200 | 1197 | ||
1201 | if (drv_data->quirks & BUZZ_CONTROLLER) { | 1198 | if (sc->quirks & BUZZ_CONTROLLER) { |
1202 | drv_data->led_count = 4; | 1199 | sc->led_count = 4; |
1203 | max_brightness = 1; | 1200 | max_brightness = 1; |
1204 | use_colors = 0; | 1201 | use_colors = 0; |
1205 | name_len = strlen("::buzz#"); | 1202 | name_len = strlen("::buzz#"); |
@@ -1207,14 +1204,14 @@ static int sony_leds_init(struct hid_device *hdev) | |||
1207 | /* Validate expected report characteristics. */ | 1204 | /* Validate expected report characteristics. */ |
1208 | if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 0, 0, 7)) | 1205 | if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 0, 0, 7)) |
1209 | return -ENODEV; | 1206 | return -ENODEV; |
1210 | } else if (drv_data->quirks & DUALSHOCK4_CONTROLLER) { | 1207 | } else if (sc->quirks & DUALSHOCK4_CONTROLLER) { |
1211 | drv_data->led_count = 3; | 1208 | sc->led_count = 3; |
1212 | max_brightness = 255; | 1209 | max_brightness = 255; |
1213 | use_colors = 1; | 1210 | use_colors = 1; |
1214 | name_len = 0; | 1211 | name_len = 0; |
1215 | name_fmt = "%s:%s"; | 1212 | name_fmt = "%s:%s"; |
1216 | } else { | 1213 | } else { |
1217 | drv_data->led_count = 4; | 1214 | sc->led_count = 4; |
1218 | max_brightness = 1; | 1215 | max_brightness = 1; |
1219 | use_colors = 0; | 1216 | use_colors = 0; |
1220 | name_len = strlen("::sony#"); | 1217 | name_len = strlen("::sony#"); |
@@ -1226,11 +1223,11 @@ static int sony_leds_init(struct hid_device *hdev) | |||
1226 | * only relevant if the driver is loaded after somebody actively set the | 1223 | * only relevant if the driver is loaded after somebody actively set the |
1227 | * LEDs to on | 1224 | * LEDs to on |
1228 | */ | 1225 | */ |
1229 | sony_set_leds(hdev, initial_values, drv_data->led_count); | 1226 | sony_set_leds(sc, initial_values, sc->led_count); |
1230 | 1227 | ||
1231 | name_sz = strlen(dev_name(&hdev->dev)) + name_len + 1; | 1228 | name_sz = strlen(dev_name(&hdev->dev)) + name_len + 1; |
1232 | 1229 | ||
1233 | for (n = 0; n < drv_data->led_count; n++) { | 1230 | for (n = 0; n < sc->led_count; n++) { |
1234 | 1231 | ||
1235 | if (use_colors) | 1232 | if (use_colors) |
1236 | name_sz = strlen(dev_name(&hdev->dev)) + strlen(color_str[n]) + 2; | 1233 | name_sz = strlen(dev_name(&hdev->dev)) + strlen(color_str[n]) + 2; |
@@ -1260,13 +1257,13 @@ static int sony_leds_init(struct hid_device *hdev) | |||
1260 | goto error_leds; | 1257 | goto error_leds; |
1261 | } | 1258 | } |
1262 | 1259 | ||
1263 | drv_data->leds[n] = led; | 1260 | sc->leds[n] = led; |
1264 | } | 1261 | } |
1265 | 1262 | ||
1266 | return ret; | 1263 | return ret; |
1267 | 1264 | ||
1268 | error_leds: | 1265 | error_leds: |
1269 | sony_leds_remove(hdev); | 1266 | sony_leds_remove(sc); |
1270 | 1267 | ||
1271 | return ret; | 1268 | return ret; |
1272 | } | 1269 | } |
@@ -1355,9 +1352,9 @@ static int sony_play_effect(struct input_dev *dev, void *data, | |||
1355 | return 0; | 1352 | return 0; |
1356 | } | 1353 | } |
1357 | 1354 | ||
1358 | static int sony_init_ff(struct hid_device *hdev) | 1355 | static int sony_init_ff(struct sony_sc *sc) |
1359 | { | 1356 | { |
1360 | struct hid_input *hidinput = list_entry(hdev->inputs.next, | 1357 | struct hid_input *hidinput = list_entry(sc->hdev->inputs.next, |
1361 | struct hid_input, list); | 1358 | struct hid_input, list); |
1362 | struct input_dev *input_dev = hidinput->input; | 1359 | struct input_dev *input_dev = hidinput->input; |
1363 | 1360 | ||
@@ -1366,7 +1363,7 @@ static int sony_init_ff(struct hid_device *hdev) | |||
1366 | } | 1363 | } |
1367 | 1364 | ||
1368 | #else | 1365 | #else |
1369 | static int sony_init_ff(struct hid_device *hdev) | 1366 | static int sony_init_ff(struct sony_sc *sc) |
1370 | { | 1367 | { |
1371 | return 0; | 1368 | return 0; |
1372 | } | 1369 | } |
@@ -1718,7 +1715,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
1718 | goto err_stop; | 1715 | goto err_stop; |
1719 | 1716 | ||
1720 | if (sc->quirks & SONY_LED_SUPPORT) { | 1717 | if (sc->quirks & SONY_LED_SUPPORT) { |
1721 | ret = sony_leds_init(hdev); | 1718 | ret = sony_leds_init(sc); |
1722 | if (ret < 0) | 1719 | if (ret < 0) |
1723 | goto err_stop; | 1720 | goto err_stop; |
1724 | } | 1721 | } |
@@ -1737,7 +1734,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
1737 | } | 1734 | } |
1738 | 1735 | ||
1739 | if (sc->quirks & SONY_FF_SUPPORT) { | 1736 | if (sc->quirks & SONY_FF_SUPPORT) { |
1740 | ret = sony_init_ff(hdev); | 1737 | ret = sony_init_ff(sc); |
1741 | if (ret < 0) | 1738 | if (ret < 0) |
1742 | goto err_close; | 1739 | goto err_close; |
1743 | } | 1740 | } |
@@ -1747,7 +1744,7 @@ err_close: | |||
1747 | hid_hw_close(hdev); | 1744 | hid_hw_close(hdev); |
1748 | err_stop: | 1745 | err_stop: |
1749 | if (sc->quirks & SONY_LED_SUPPORT) | 1746 | if (sc->quirks & SONY_LED_SUPPORT) |
1750 | sony_leds_remove(hdev); | 1747 | sony_leds_remove(sc); |
1751 | if (sc->quirks & SONY_BATTERY_SUPPORT) | 1748 | if (sc->quirks & SONY_BATTERY_SUPPORT) |
1752 | sony_battery_remove(sc); | 1749 | sony_battery_remove(sc); |
1753 | sony_cancel_work_sync(sc); | 1750 | sony_cancel_work_sync(sc); |
@@ -1761,7 +1758,7 @@ static void sony_remove(struct hid_device *hdev) | |||
1761 | struct sony_sc *sc = hid_get_drvdata(hdev); | 1758 | struct sony_sc *sc = hid_get_drvdata(hdev); |
1762 | 1759 | ||
1763 | if (sc->quirks & SONY_LED_SUPPORT) | 1760 | if (sc->quirks & SONY_LED_SUPPORT) |
1764 | sony_leds_remove(hdev); | 1761 | sony_leds_remove(sc); |
1765 | 1762 | ||
1766 | if (sc->quirks & SONY_BATTERY_SUPPORT) { | 1763 | if (sc->quirks & SONY_BATTERY_SUPPORT) { |
1767 | hid_hw_close(hdev); | 1764 | hid_hw_close(hdev); |