aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/wacom_sys.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/wacom_sys.c')
-rw-r--r--drivers/hid/wacom_sys.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 545986cfb978..ffe59a19b3a3 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -703,18 +703,6 @@ struct wacom_hdev_data {
703static LIST_HEAD(wacom_udev_list); 703static LIST_HEAD(wacom_udev_list);
704static DEFINE_MUTEX(wacom_udev_list_lock); 704static DEFINE_MUTEX(wacom_udev_list_lock);
705 705
706static bool compare_device_paths(struct hid_device *hdev_a,
707 struct hid_device *hdev_b, char separator)
708{
709 int n1 = strrchr(hdev_a->phys, separator) - hdev_a->phys;
710 int n2 = strrchr(hdev_b->phys, separator) - hdev_b->phys;
711
712 if (n1 != n2 || n1 <= 0 || n2 <= 0)
713 return false;
714
715 return !strncmp(hdev_a->phys, hdev_b->phys, n1);
716}
717
718static bool wacom_are_sibling(struct hid_device *hdev, 706static bool wacom_are_sibling(struct hid_device *hdev,
719 struct hid_device *sibling) 707 struct hid_device *sibling)
720{ 708{
@@ -737,10 +725,10 @@ static bool wacom_are_sibling(struct hid_device *hdev,
737 * the same physical parent device path. 725 * the same physical parent device path.
738 */ 726 */
739 if (hdev->vendor == sibling->vendor && hdev->product == sibling->product) { 727 if (hdev->vendor == sibling->vendor && hdev->product == sibling->product) {
740 if (!compare_device_paths(hdev, sibling, '/')) 728 if (!hid_compare_device_paths(hdev, sibling, '/'))
741 return false; 729 return false;
742 } else { 730 } else {
743 if (!compare_device_paths(hdev, sibling, '.')) 731 if (!hid_compare_device_paths(hdev, sibling, '.'))
744 return false; 732 return false;
745 } 733 }
746 734
@@ -787,7 +775,7 @@ static struct wacom_hdev_data *wacom_get_hdev_data(struct hid_device *hdev)
787 775
788 /* Try to find an already-probed interface from the same device */ 776 /* Try to find an already-probed interface from the same device */
789 list_for_each_entry(data, &wacom_udev_list, list) { 777 list_for_each_entry(data, &wacom_udev_list, list) {
790 if (compare_device_paths(hdev, data->dev, '/')) { 778 if (hid_compare_device_paths(hdev, data->dev, '/')) {
791 kref_get(&data->kref); 779 kref_get(&data->kref);
792 return data; 780 return data;
793 } 781 }
@@ -1371,7 +1359,7 @@ static int wacom_led_groups_alloc_and_register_one(struct device *dev,
1371 if (!devres_open_group(dev, &wacom->led.groups[group_id], GFP_KERNEL)) 1359 if (!devres_open_group(dev, &wacom->led.groups[group_id], GFP_KERNEL))
1372 return -ENOMEM; 1360 return -ENOMEM;
1373 1361
1374 leds = devm_kzalloc(dev, sizeof(struct wacom_led) * count, GFP_KERNEL); 1362 leds = devm_kcalloc(dev, count, sizeof(struct wacom_led), GFP_KERNEL);
1375 if (!leds) { 1363 if (!leds) {
1376 error = -ENOMEM; 1364 error = -ENOMEM;
1377 goto err; 1365 goto err;
@@ -1471,7 +1459,7 @@ static int wacom_led_groups_allocate(struct wacom *wacom, int count)
1471 struct wacom_group_leds *groups; 1459 struct wacom_group_leds *groups;
1472 int error; 1460 int error;
1473 1461
1474 groups = devm_kzalloc(dev, sizeof(struct wacom_group_leds) * count, 1462 groups = devm_kcalloc(dev, count, sizeof(struct wacom_group_leds),
1475 GFP_KERNEL); 1463 GFP_KERNEL);
1476 if (!groups) 1464 if (!groups)
1477 return -ENOMEM; 1465 return -ENOMEM;