提交 001dac87 编写于 作者: D David Herrmann 提交者: Jiri Kosina

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: NDavid Herrmann <dh.herrmann@gmail.com>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 f8966048
...@@ -1160,6 +1160,7 @@ static void wiimote_destroy(struct wiimote_data *wdata) ...@@ -1160,6 +1160,7 @@ static void wiimote_destroy(struct wiimote_data *wdata)
wiimote_leds_destroy(wdata); wiimote_leds_destroy(wdata);
power_supply_unregister(&wdata->battery); power_supply_unregister(&wdata->battery);
kfree(wdata->battery.name);
input_unregister_device(wdata->accel); input_unregister_device(wdata->accel);
input_unregister_device(wdata->ir); input_unregister_device(wdata->ir);
input_unregister_device(wdata->input); input_unregister_device(wdata->input);
...@@ -1216,9 +1217,14 @@ static int wiimote_hid_probe(struct hid_device *hdev, ...@@ -1216,9 +1217,14 @@ static int wiimote_hid_probe(struct hid_device *hdev,
wdata->battery.properties = wiimote_battery_props; wdata->battery.properties = wiimote_battery_props;
wdata->battery.num_properties = ARRAY_SIZE(wiimote_battery_props); wdata->battery.num_properties = ARRAY_SIZE(wiimote_battery_props);
wdata->battery.get_property = wiimote_battery_get_property; wdata->battery.get_property = wiimote_battery_get_property;
wdata->battery.name = "wiimote_battery";
wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY; wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY;
wdata->battery.use_for_apm = 0; wdata->battery.use_for_apm = 0;
wdata->battery.name = kasprintf(GFP_KERNEL, "wiimote_battery_%s",
wdata->hdev->uniq);
if (!wdata->battery.name) {
ret = -ENOMEM;
goto err_battery_name;
}
ret = power_supply_register(&wdata->hdev->dev, &wdata->battery); ret = power_supply_register(&wdata->hdev->dev, &wdata->battery);
if (ret) { if (ret) {
...@@ -1254,6 +1260,8 @@ static int wiimote_hid_probe(struct hid_device *hdev, ...@@ -1254,6 +1260,8 @@ static int wiimote_hid_probe(struct hid_device *hdev,
return ret; return ret;
err_battery: err_battery:
kfree(wdata->battery.name);
err_battery_name:
input_unregister_device(wdata->input); input_unregister_device(wdata->input);
wdata->input = NULL; wdata->input = NULL;
err_input: err_input:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册