wacom_sys.c (3888b0d53dfbbc9ebc678a67b2ccebb053ba4aac) wacom_sys.c (04bfa27b429fc45197fbb1a3dfe01585b931824b)
1/*
2 * drivers/input/tablet/wacom_sys.c
3 *
4 * USB Wacom tablet support - system specific code
5 */
6
7/*
8 * This program is free software; you can redistribute it and/or modify

--- 1286 unchanged lines hidden (view full) ---

1295DEVICE_EKR_ATTR_GROUP(4);
1296
1297static int wacom_remote_create_attr_group(struct wacom *wacom, __u32 serial,
1298 int index)
1299{
1300 int error = 0;
1301 struct wacom_remote *remote = wacom->remote;
1302
1/*
2 * drivers/input/tablet/wacom_sys.c
3 *
4 * USB Wacom tablet support - system specific code
5 */
6
7/*
8 * This program is free software; you can redistribute it and/or modify

--- 1286 unchanged lines hidden (view full) ---

1295DEVICE_EKR_ATTR_GROUP(4);
1296
1297static int wacom_remote_create_attr_group(struct wacom *wacom, __u32 serial,
1298 int index)
1299{
1300 int error = 0;
1301 struct wacom_remote *remote = wacom->remote;
1302
1303 remote->serial[index] = serial;
1304
1305 remote->remote_group[index].name = devm_kasprintf(&wacom->hdev->dev,
1306 GFP_KERNEL,
1307 "%d", serial);
1308 if (!remote->remote_group[index].name)
1309 return -ENOMEM;
1310
1311 error = sysfs_create_group(remote->remote_dir,
1312 &remote->remote_group[index]);
1313 if (error) {
1314 hid_err(wacom->hdev,
1315 "cannot create sysfs group err: %d\n", error);
1316 return error;
1317 }
1318
1319 return 0;
1320}
1321
1303 remote->remote_group[index].name = devm_kasprintf(&wacom->hdev->dev,
1304 GFP_KERNEL,
1305 "%d", serial);
1306 if (!remote->remote_group[index].name)
1307 return -ENOMEM;
1308
1309 error = sysfs_create_group(remote->remote_dir,
1310 &remote->remote_group[index]);
1311 if (error) {
1312 hid_err(wacom->hdev,
1313 "cannot create sysfs group err: %d\n", error);
1314 return error;
1315 }
1316
1317 return 0;
1318}
1319
1322static void wacom_remote_destroy_attr_group(struct wacom *wacom, __u32 serial)
1320static void wacom_remote_destroy_attr_group(struct wacom *wacom, unsigned int i)
1323{
1324 struct wacom_remote *remote = wacom->remote;
1321{
1322 struct wacom_remote *remote = wacom->remote;
1325 int i;
1326
1323
1327 if (!serial)
1328 return;
1329
1330 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1331 if (remote->serial[i] == serial) {
1332 remote->serial[i] = 0;
1333 wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN;
1334 if (remote->remote_group[i].name) {
1335 sysfs_remove_group(remote->remote_dir,
1336 &remote->remote_group[i]);
1337 devm_kfree(&wacom->hdev->dev,
1338 (char *)remote->remote_group[i].name);
1339 remote->remote_group[i].name = NULL;
1340 }
1341 }
1342 }
1324 sysfs_remove_group(remote->remote_dir, &remote->remote_group[i]);
1325 devm_kfree(&wacom->hdev->dev, (char *)remote->remote_group[i].name);
1326 remote->remote_group[i].name = NULL;
1343}
1344
1345static int wacom_cmd_unpair_remote(struct wacom *wacom, unsigned char selector)
1346{
1347 const size_t buf_size = 2;
1348 unsigned char *buf;
1349 int retval;
1350

--- 560 unchanged lines hidden (view full) ---

1911 return;
1912
1913fail:
1914 wacom_release_resources(wacom1);
1915 wacom_release_resources(wacom2);
1916 return;
1917}
1918
1327}
1328
1329static int wacom_cmd_unpair_remote(struct wacom *wacom, unsigned char selector)
1330{
1331 const size_t buf_size = 2;
1332 unsigned char *buf;
1333 int retval;
1334

--- 560 unchanged lines hidden (view full) ---

1895 return;
1896
1897fail:
1898 wacom_release_resources(wacom1);
1899 wacom_release_resources(wacom2);
1900 return;
1901}
1902
1903static void wacom_remote_destroy_one(struct wacom *wacom, unsigned int index)
1904{
1905 struct wacom_remote *remote = wacom->remote;
1906 u32 serial = remote->serial[index];
1907 int i;
1908
1909 wacom_remote_destroy_attr_group(wacom, index);
1910
1911 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1912 if (remote->serial[i] == serial) {
1913 remote->serial[i] = 0;
1914 wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN;
1915 }
1916 }
1917}
1918
1919static int wacom_remote_create_one(struct wacom *wacom, u32 serial,
1920 unsigned int index)
1921{
1922 struct wacom_remote *remote = wacom->remote;
1923 int error, k;
1924
1925 /* A remote can pair more than once with an EKR,
1926 * check to make sure this serial isn't already paired.
1927 */
1928 for (k = 0; k < WACOM_MAX_REMOTES; k++) {
1929 if (remote->serial[k] == serial)
1930 break;
1931 }
1932
1933 if (k < WACOM_MAX_REMOTES) {
1934 remote->serial[index] = serial;
1935 return 0;
1936 }
1937
1938 error = wacom_remote_create_attr_group(wacom, serial, index);
1939 if (error)
1940 return error;
1941
1942 remote->serial[index] = serial;
1943
1944 return 0;
1945}
1946
1919static void wacom_remote_work(struct work_struct *work)
1920{
1921 struct wacom *wacom = container_of(work, struct wacom, remote_work);
1922 struct wacom_remote *remote = wacom->remote;
1923 struct wacom_remote_data data;
1924 unsigned long flags;
1925 unsigned int count;
1926 u32 serial;
1947static void wacom_remote_work(struct work_struct *work)
1948{
1949 struct wacom *wacom = container_of(work, struct wacom, remote_work);
1950 struct wacom_remote *remote = wacom->remote;
1951 struct wacom_remote_data data;
1952 unsigned long flags;
1953 unsigned int count;
1954 u32 serial;
1927 int i, k;
1955 int i;
1928
1929 spin_lock_irqsave(&remote->remote_lock, flags);
1930
1931 count = kfifo_out(&remote->remote_fifo, &data, sizeof(data));
1932
1933 if (count != sizeof(data)) {
1934 hid_err(wacom->hdev,
1935 "workitem triggered without status available\n");

--- 8 unchanged lines hidden (view full) ---

1944
1945 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1946 serial = data.remote[i].serial;
1947 if (data.remote[i].connected) {
1948
1949 if (remote->serial[i] == serial)
1950 continue;
1951
1956
1957 spin_lock_irqsave(&remote->remote_lock, flags);
1958
1959 count = kfifo_out(&remote->remote_fifo, &data, sizeof(data));
1960
1961 if (count != sizeof(data)) {
1962 hid_err(wacom->hdev,
1963 "workitem triggered without status available\n");

--- 8 unchanged lines hidden (view full) ---

1972
1973 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1974 serial = data.remote[i].serial;
1975 if (data.remote[i].connected) {
1976
1977 if (remote->serial[i] == serial)
1978 continue;
1979
1952 if (remote->serial[i]) {
1953 wacom_remote_destroy_attr_group(wacom,
1954 remote->serial[i]);
1955 }
1980 if (remote->serial[i])
1981 wacom_remote_destroy_one(wacom, i);
1956
1982
1957 /* A remote can pair more than once with an EKR,
1958 * check to make sure this serial isn't already paired.
1959 */
1960 for (k = 0; k < WACOM_MAX_REMOTES; k++) {
1961 if (remote->serial[k] == serial)
1962 break;
1963 }
1983 wacom_remote_create_one(wacom, serial, i);
1964
1984
1965 if (k < WACOM_MAX_REMOTES) {
1966 remote->serial[i] = serial;
1967 continue;
1968 }
1969 wacom_remote_create_attr_group(wacom, serial, i);
1970
1971 } else if (remote->serial[i]) {
1985 } else if (remote->serial[i]) {
1972 wacom_remote_destroy_attr_group(wacom,
1973 remote->serial[i]);
1986 wacom_remote_destroy_one(wacom, i);
1974 }
1975 }
1976}
1977
1978static int wacom_probe(struct hid_device *hdev,
1979 const struct hid_device_id *id)
1980{
1981 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);

--- 127 unchanged lines hidden ---
1987 }
1988 }
1989}
1990
1991static int wacom_probe(struct hid_device *hdev,
1992 const struct hid_device_id *id)
1993{
1994 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);

--- 127 unchanged lines hidden ---