aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-04-02 13:58:34 -0400
committerJiri Kosina <jkosina@suse.cz>2013-04-04 03:38:42 -0400
commit001dac87052903d6850c064737bab004bed94789 (patch)
tree94fb7cde551e4701f250a377d80e8d5cfc0fc6d0 /drivers/hid
parentf8966048c128eff4f57f7c9e7f71360ebd10e1a9 (diff)
HID: wiimote: use unique battery names
Battery device names must be unique, otherwise registration fails if multiple Wii Remotes are connected. This breaks the sysfs API, but there is no known application that uses the Wii Remote battery that I know of so we should go ahead and apply this. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-wiimote-core.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
index 0fb8ab93db68..f1c7a113b614 100644
--- a/drivers/hid/hid-wiimote-core.c
+++ b/drivers/hid/hid-wiimote-core.c
@@ -1160,6 +1160,7 @@ static void wiimote_destroy(struct wiimote_data *wdata)
1160 wiimote_leds_destroy(wdata); 1160 wiimote_leds_destroy(wdata);
1161 1161
1162 power_supply_unregister(&wdata->battery); 1162 power_supply_unregister(&wdata->battery);
1163 kfree(wdata->battery.name);
1163 input_unregister_device(wdata->accel); 1164 input_unregister_device(wdata->accel);
1164 input_unregister_device(wdata->ir); 1165 input_unregister_device(wdata->ir);
1165 input_unregister_device(wdata->input); 1166 input_unregister_device(wdata->input);
@@ -1216,9 +1217,14 @@ static int wiimote_hid_probe(struct hid_device *hdev,
1216 wdata->battery.properties = wiimote_battery_props; 1217 wdata->battery.properties = wiimote_battery_props;
1217 wdata->battery.num_properties = ARRAY_SIZE(wiimote_battery_props); 1218 wdata->battery.num_properties = ARRAY_SIZE(wiimote_battery_props);
1218 wdata->battery.get_property = wiimote_battery_get_property; 1219 wdata->battery.get_property = wiimote_battery_get_property;
1219 wdata->battery.name = "wiimote_battery";
1220 wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY; 1220 wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY;
1221 wdata->battery.use_for_apm = 0; 1221 wdata->battery.use_for_apm = 0;
1222 wdata->battery.name = kasprintf(GFP_KERNEL, "wiimote_battery_%s",
1223 wdata->hdev->uniq);
1224 if (!wdata->battery.name) {
1225 ret = -ENOMEM;
1226 goto err_battery_name;
1227 }
1222 1228
1223 ret = power_supply_register(&wdata->hdev->dev, &wdata->battery); 1229 ret = power_supply_register(&wdata->hdev->dev, &wdata->battery);
1224 if (ret) { 1230 if (ret) {
@@ -1254,6 +1260,8 @@ err_free:
1254 return ret; 1260 return ret;
1255 1261
1256err_battery: 1262err_battery:
1263 kfree(wdata->battery.name);
1264err_battery_name:
1257 input_unregister_device(wdata->input); 1265 input_unregister_device(wdata->input);
1258 wdata->input = NULL; 1266 wdata->input = NULL;
1259err_input: 1267err_input: