Skip to content

Commit

Permalink
HID: uclogic: Expose firmware name via sysfs
Browse files Browse the repository at this point in the history
Some vendors reuse the same product ID for different tablets, making it
difficult for userspace to figure out which table is connected.
While matching the device name has been used in the past by userspace to
workaround this limitation, some devices have shown that this is not
always a valid approach [1].

However, if userspace could access the firmware version name, it would
be possible to know which tablet is actually connected by matching it
against a list of known firmware names [2].

This patch exposes the firmware version name via sysfs attribute.

Link: linuxwacom/libwacom#609  [1]
Link: linuxwacom/libwacom#610  [2]
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
  • Loading branch information
JoseExposito committed Mar 21, 2024
1 parent e63d87d commit bc1c864
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions drivers/hid/hid-uclogic-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ static void uclogic_inrange_timeout(struct timer_list *t)
input_sync(input);
}

static ssize_t fw_name_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct hid_device *hdev = to_hid_device(dev);
struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);

return sysfs_emit(buf, "%s\n", drvdata->params.fw_name);
}

static DEVICE_ATTR_RO(fw_name);

static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
{
Expand Down Expand Up @@ -217,6 +228,10 @@ static int uclogic_probe(struct hid_device *hdev,
goto failure;
}

rc = device_create_file(&hdev->dev, &dev_attr_fw_name);
if (rc)
hid_warn(hdev, "Unable to create sysfs attribute \"fw_name\", errno %d\n", rc);

return 0;
failure:
/* Assume "remove" might not be called if "probe" failed */
Expand Down Expand Up @@ -477,6 +492,7 @@ static void uclogic_remove(struct hid_device *hdev)
del_timer_sync(&drvdata->inrange_timer);
hid_hw_stop(hdev);
kfree(drvdata->desc_ptr);
device_remove_file(&hdev->dev, &dev_attr_fw_name);
uclogic_params_cleanup(&drvdata->params);
}

Expand Down

0 comments on commit bc1c864

Please sign in to comment.