提交 09223865 编写于 作者: D Dmitry Torokhov 提交者: Jiri Kosina

HID: input: optionally use device id in battery name

Manufacturers do not always populate serial number in their devices, so
let's fall back to device ID when forming the battery device name. As a
result, batteries in devices without serial number will be named like
this:

	hid-0018:2D1F:510E.0001-battery

(as opposed to hid--battery for the first one, and failing to create
batteries for the subsequent ones).
Signed-off-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 581c4484
...@@ -456,7 +456,9 @@ static int hidinput_setup_battery(struct hid_device *dev, unsigned report_type, ...@@ -456,7 +456,9 @@ static int hidinput_setup_battery(struct hid_device *dev, unsigned report_type,
if (!psy_desc) if (!psy_desc)
return -ENOMEM; return -ENOMEM;
psy_desc->name = kasprintf(GFP_KERNEL, "hid-%s-battery", dev->uniq); psy_desc->name = kasprintf(GFP_KERNEL, "hid-%s-battery",
strlen(dev->uniq) ?
dev->uniq : dev_name(&dev->dev));
if (!psy_desc->name) { if (!psy_desc->name) {
error = -ENOMEM; error = -ENOMEM;
goto err_free_mem; goto err_free_mem;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册