diff options
author | Benjamin Tissoires <benjamin.tissoires@redhat.com> | 2016-07-13 12:06:06 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2016-08-05 07:39:17 -0400 |
commit | e7749f6e5f9d33da189f7bc7d757349ad4716f00 (patch) | |
tree | 8719d4ab2a9b600cfa6468976991d908bf2c7315 | |
parent | f9036bd43602562f549ace170391c932f28446cd (diff) |
HID: wacom: EKR: have one array of struct remotes instead of many arrays
No functional changes, just a prep patch for the one after.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r-- | drivers/hid/wacom.h | 6 | ||||
-rw-r--r-- | drivers/hid/wacom_sys.c | 53 | ||||
-rw-r--r-- | drivers/hid/wacom_wac.c | 2 |
3 files changed, 32 insertions, 29 deletions
diff --git a/drivers/hid/wacom.h b/drivers/hid/wacom.h index 110ea6793b99..6b8df67b3653 100644 --- a/drivers/hid/wacom.h +++ b/drivers/hid/wacom.h | |||
@@ -120,8 +120,10 @@ struct wacom_remote { | |||
120 | spinlock_t remote_lock; | 120 | spinlock_t remote_lock; |
121 | struct kfifo remote_fifo; | 121 | struct kfifo remote_fifo; |
122 | struct kobject *remote_dir; | 122 | struct kobject *remote_dir; |
123 | struct attribute_group remote_group[WACOM_MAX_REMOTES]; | 123 | struct { |
124 | __u32 serial[WACOM_MAX_REMOTES]; | 124 | struct attribute_group group; |
125 | u32 serial; | ||
126 | } remotes[WACOM_MAX_REMOTES]; | ||
125 | }; | 127 | }; |
126 | 128 | ||
127 | struct wacom { | 129 | struct wacom { |
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 9121e72c1b40..c3b269237af5 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c | |||
@@ -1308,16 +1308,16 @@ static int wacom_remote_create_attr_group(struct wacom *wacom, __u32 serial, | |||
1308 | int error = 0; | 1308 | int error = 0; |
1309 | struct wacom_remote *remote = wacom->remote; | 1309 | struct wacom_remote *remote = wacom->remote; |
1310 | 1310 | ||
1311 | remote->remote_group[index].name = devm_kasprintf(&wacom->hdev->dev, | 1311 | remote->remotes[index].group.name = devm_kasprintf(&wacom->hdev->dev, |
1312 | GFP_KERNEL, | 1312 | GFP_KERNEL, |
1313 | "%d", serial); | 1313 | "%d", serial); |
1314 | if (!remote->remote_group[index].name) | 1314 | if (!remote->remotes[index].group.name) |
1315 | return -ENOMEM; | 1315 | return -ENOMEM; |
1316 | 1316 | ||
1317 | error = __wacom_devm_sysfs_create_group(wacom, remote->remote_dir, | 1317 | error = __wacom_devm_sysfs_create_group(wacom, remote->remote_dir, |
1318 | &remote->remote_group[index]); | 1318 | &remote->remotes[index].group); |
1319 | if (error) { | 1319 | if (error) { |
1320 | remote->remote_group[index].name = NULL; | 1320 | remote->remotes[index].group.name = NULL; |
1321 | hid_err(wacom->hdev, | 1321 | hid_err(wacom->hdev, |
1322 | "cannot create sysfs group err: %d\n", error); | 1322 | "cannot create sysfs group err: %d\n", error); |
1323 | return error; | 1323 | return error; |
@@ -1421,11 +1421,11 @@ static int wacom_initialize_remotes(struct wacom *wacom) | |||
1421 | return -ENOMEM; | 1421 | return -ENOMEM; |
1422 | } | 1422 | } |
1423 | 1423 | ||
1424 | remote->remote_group[0] = remote0_serial_group; | 1424 | remote->remotes[0].group = remote0_serial_group; |
1425 | remote->remote_group[1] = remote1_serial_group; | 1425 | remote->remotes[1].group = remote1_serial_group; |
1426 | remote->remote_group[2] = remote2_serial_group; | 1426 | remote->remotes[2].group = remote2_serial_group; |
1427 | remote->remote_group[3] = remote3_serial_group; | 1427 | remote->remotes[3].group = remote3_serial_group; |
1428 | remote->remote_group[4] = remote4_serial_group; | 1428 | remote->remotes[4].group = remote4_serial_group; |
1429 | 1429 | ||
1430 | remote->remote_dir = kobject_create_and_add("wacom_remote", | 1430 | remote->remote_dir = kobject_create_and_add("wacom_remote", |
1431 | &wacom->hdev->dev.kobj); | 1431 | &wacom->hdev->dev.kobj); |
@@ -1442,7 +1442,7 @@ static int wacom_initialize_remotes(struct wacom *wacom) | |||
1442 | 1442 | ||
1443 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { | 1443 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { |
1444 | wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN; | 1444 | wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN; |
1445 | remote->serial[i] = 0; | 1445 | remote->remotes[i].serial = 0; |
1446 | } | 1446 | } |
1447 | 1447 | ||
1448 | error = devm_add_action_or_reset(&wacom->hdev->dev, | 1448 | error = devm_add_action_or_reset(&wacom->hdev->dev, |
@@ -1903,16 +1903,17 @@ fail: | |||
1903 | static void wacom_remote_destroy_one(struct wacom *wacom, unsigned int index) | 1903 | static void wacom_remote_destroy_one(struct wacom *wacom, unsigned int index) |
1904 | { | 1904 | { |
1905 | struct wacom_remote *remote = wacom->remote; | 1905 | struct wacom_remote *remote = wacom->remote; |
1906 | u32 serial = remote->serial[index]; | 1906 | u32 serial = remote->remotes[index].serial; |
1907 | int i; | 1907 | int i; |
1908 | 1908 | ||
1909 | if (remote->remote_group[index].name) | 1909 | if (remote->remotes[index].group.name) |
1910 | devres_release_group(&wacom->hdev->dev, &remote->serial[index]); | 1910 | devres_release_group(&wacom->hdev->dev, |
1911 | &remote->remotes[index]); | ||
1911 | 1912 | ||
1912 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { | 1913 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { |
1913 | if (remote->serial[i] == serial) { | 1914 | if (remote->remotes[i].serial == serial) { |
1914 | remote->serial[i] = 0; | 1915 | remote->remotes[i].serial = 0; |
1915 | remote->remote_group[i].name = NULL; | 1916 | remote->remotes[i].group.name = NULL; |
1916 | wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN; | 1917 | wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN; |
1917 | } | 1918 | } |
1918 | } | 1919 | } |
@@ -1929,30 +1930,30 @@ static int wacom_remote_create_one(struct wacom *wacom, u32 serial, | |||
1929 | * check to make sure this serial isn't already paired. | 1930 | * check to make sure this serial isn't already paired. |
1930 | */ | 1931 | */ |
1931 | for (k = 0; k < WACOM_MAX_REMOTES; k++) { | 1932 | for (k = 0; k < WACOM_MAX_REMOTES; k++) { |
1932 | if (remote->serial[k] == serial) | 1933 | if (remote->remotes[k].serial == serial) |
1933 | break; | 1934 | break; |
1934 | } | 1935 | } |
1935 | 1936 | ||
1936 | if (k < WACOM_MAX_REMOTES) { | 1937 | if (k < WACOM_MAX_REMOTES) { |
1937 | remote->serial[index] = serial; | 1938 | remote->remotes[index].serial = serial; |
1938 | return 0; | 1939 | return 0; |
1939 | } | 1940 | } |
1940 | 1941 | ||
1941 | if (!devres_open_group(dev, &remote->serial[index], GFP_KERNEL)) | 1942 | if (!devres_open_group(dev, &remote->remotes[index], GFP_KERNEL)) |
1942 | return -ENOMEM; | 1943 | return -ENOMEM; |
1943 | 1944 | ||
1944 | error = wacom_remote_create_attr_group(wacom, serial, index); | 1945 | error = wacom_remote_create_attr_group(wacom, serial, index); |
1945 | if (error) | 1946 | if (error) |
1946 | goto fail; | 1947 | goto fail; |
1947 | 1948 | ||
1948 | remote->serial[index] = serial; | 1949 | remote->remotes[index].serial = serial; |
1949 | 1950 | ||
1950 | devres_close_group(dev, &remote->serial[index]); | 1951 | devres_close_group(dev, &remote->remotes[index]); |
1951 | return 0; | 1952 | return 0; |
1952 | 1953 | ||
1953 | fail: | 1954 | fail: |
1954 | devres_release_group(dev, &remote->serial[index]); | 1955 | devres_release_group(dev, &remote->remotes[index]); |
1955 | remote->serial[index] = 0; | 1956 | remote->remotes[index].serial = 0; |
1956 | return error; | 1957 | return error; |
1957 | } | 1958 | } |
1958 | 1959 | ||
@@ -1986,15 +1987,15 @@ static void wacom_remote_work(struct work_struct *work) | |||
1986 | serial = data.remote[i].serial; | 1987 | serial = data.remote[i].serial; |
1987 | if (data.remote[i].connected) { | 1988 | if (data.remote[i].connected) { |
1988 | 1989 | ||
1989 | if (remote->serial[i] == serial) | 1990 | if (remote->remotes[i].serial == serial) |
1990 | continue; | 1991 | continue; |
1991 | 1992 | ||
1992 | if (remote->serial[i]) | 1993 | if (remote->remotes[i].serial) |
1993 | wacom_remote_destroy_one(wacom, i); | 1994 | wacom_remote_destroy_one(wacom, i); |
1994 | 1995 | ||
1995 | wacom_remote_create_one(wacom, serial, i); | 1996 | wacom_remote_create_one(wacom, serial, i); |
1996 | 1997 | ||
1997 | } else if (remote->serial[i]) { | 1998 | } else if (remote->remotes[i].serial) { |
1998 | wacom_remote_destroy_one(wacom, i); | 1999 | wacom_remote_destroy_one(wacom, i); |
1999 | } | 2000 | } |
2000 | } | 2001 | } |
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index ce1089f1142d..aee07613040d 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c | |||
@@ -808,7 +808,7 @@ static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len) | |||
808 | touch_ring_mode = (data[11] & 0xC0) >> 6; | 808 | touch_ring_mode = (data[11] & 0xC0) >> 6; |
809 | 809 | ||
810 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { | 810 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { |
811 | if (remote->serial[i] == serial) | 811 | if (remote->remotes[i].serial == serial) |
812 | wacom->led.groups[i].select = touch_ring_mode; | 812 | wacom->led.groups[i].select = touch_ring_mode; |
813 | } | 813 | } |
814 | 814 | ||