提交 02cc097e 编写于 作者: P Peter Wu 提交者: Jiri Kosina

HID: logitech-hidpp: do not return the name length

We do not make any use of the actual name length get through
hidpp_get_device_name(). Original patch by Benjamin Tissoires, this
patch also replaces a (now) unnecessary goto by return NULL.
Signed-off-by: NPeter Wu <peter@lekensteyn.nl>
Signed-off-by: NBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 552f12eb
...@@ -461,7 +461,7 @@ static int hidpp_devicenametype_get_device_name(struct hidpp_device *hidpp, ...@@ -461,7 +461,7 @@ static int hidpp_devicenametype_get_device_name(struct hidpp_device *hidpp,
return count; return count;
} }
static char *hidpp_get_device_name(struct hidpp_device *hidpp, u8 *name_length) static char *hidpp_get_device_name(struct hidpp_device *hidpp)
{ {
u8 feature_type; u8 feature_type;
u8 feature_index; u8 feature_index;
...@@ -473,28 +473,23 @@ static char *hidpp_get_device_name(struct hidpp_device *hidpp, u8 *name_length) ...@@ -473,28 +473,23 @@ static char *hidpp_get_device_name(struct hidpp_device *hidpp, u8 *name_length)
ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_GET_DEVICE_NAME_TYPE, ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_GET_DEVICE_NAME_TYPE,
&feature_index, &feature_type); &feature_index, &feature_type);
if (ret) if (ret)
goto out_err; return NULL;
ret = hidpp_devicenametype_get_count(hidpp, feature_index, ret = hidpp_devicenametype_get_count(hidpp, feature_index,
&__name_length); &__name_length);
if (ret) if (ret)
goto out_err; return NULL;
name = kzalloc(__name_length + 1, GFP_KERNEL); name = kzalloc(__name_length + 1, GFP_KERNEL);
if (!name) if (!name)
goto out_err; return NULL;
*name_length = __name_length + 1;
while (index < __name_length) while (index < __name_length)
index += hidpp_devicenametype_get_device_name(hidpp, index += hidpp_devicenametype_get_device_name(hidpp,
feature_index, index, name + index, feature_index, index, name + index,
__name_length - index); __name_length - index);
return name; return name;
out_err:
*name_length = 0;
return NULL;
} }
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
...@@ -989,7 +984,6 @@ static void hidpp_overwrite_name(struct hid_device *hdev, bool use_unifying) ...@@ -989,7 +984,6 @@ static void hidpp_overwrite_name(struct hid_device *hdev, bool use_unifying)
{ {
struct hidpp_device *hidpp = hid_get_drvdata(hdev); struct hidpp_device *hidpp = hid_get_drvdata(hdev);
char *name; char *name;
u8 name_length;
if (use_unifying) if (use_unifying)
/* /*
...@@ -999,7 +993,7 @@ static void hidpp_overwrite_name(struct hid_device *hdev, bool use_unifying) ...@@ -999,7 +993,7 @@ static void hidpp_overwrite_name(struct hid_device *hdev, bool use_unifying)
*/ */
name = hidpp_get_unifying_name(hidpp); name = hidpp_get_unifying_name(hidpp);
else else
name = hidpp_get_device_name(hidpp, &name_length); name = hidpp_get_device_name(hidpp);
if (!name) if (!name)
hid_err(hdev, "unable to retrieve the name of the device"); hid_err(hdev, "unable to retrieve the name of the device");
...@@ -1053,7 +1047,6 @@ static void hidpp_connect_event(struct hidpp_device *hidpp) ...@@ -1053,7 +1047,6 @@ static void hidpp_connect_event(struct hidpp_device *hidpp)
bool connected = atomic_read(&hidpp->connected); bool connected = atomic_read(&hidpp->connected);
struct input_dev *input; struct input_dev *input;
char *name, *devm_name; char *name, *devm_name;
u8 name_length;
if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)
wtp_connect(hdev, connected); wtp_connect(hdev, connected);
...@@ -1080,7 +1073,7 @@ static void hidpp_connect_event(struct hidpp_device *hidpp) ...@@ -1080,7 +1073,7 @@ static void hidpp_connect_event(struct hidpp_device *hidpp)
return; return;
} }
name = hidpp_get_device_name(hidpp, &name_length); name = hidpp_get_device_name(hidpp);
if (!name) { if (!name) {
hid_err(hdev, "unable to retrieve the name of the device"); hid_err(hdev, "unable to retrieve the name of the device");
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册