summaryrefslogtreecommitdiff
path: root/drivers/hid
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2020-07-04 15:27:40 +0200
committerJiri Kosina <jkosina@suse.cz>2020-07-07 12:42:26 +0200
commitef550c5d0a8e32b9ac080ee83331f23acfe157e3 (patch)
treeb751618eefdb4c51953053cb413a7006f608cc01 /drivers/hid
parent484921f571b1924a49421a999897387f8de33fbf (diff)
HID: lenovo: Rename fn_lock sysfs attr handlers to make them generic
Except for a single call, there is nothing keyboard-model specific about the cptkbd fn_lock sysfs attr handlers, rename them dropping the cptkbd post-/pre-fix, so that they can be re-used for supporting Fn-lock on the Thinkpad 10 ultrabook kbd. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-lenovo.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index feb0cbc6742e..f2eb91704e9c 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -249,23 +249,23 @@ static void lenovo_features_set_cptkbd(struct hid_device *hdev)
hid_err(hdev, "Sensitivity setting failed: %d\n", ret);
}
-static ssize_t attr_fn_lock_show_cptkbd(struct device *dev,
+static ssize_t attr_fn_lock_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct hid_device *hdev = to_hid_device(dev);
- struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev);
+ struct lenovo_drvdata *data = hid_get_drvdata(hdev);
- return snprintf(buf, PAGE_SIZE, "%u\n", cptkbd_data->fn_lock);
+ return snprintf(buf, PAGE_SIZE, "%u\n", data->fn_lock);
}
-static ssize_t attr_fn_lock_store_cptkbd(struct device *dev,
+static ssize_t attr_fn_lock_store(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{
struct hid_device *hdev = to_hid_device(dev);
- struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev);
+ struct lenovo_drvdata *data = hid_get_drvdata(hdev);
int value;
if (kstrtoint(buf, 10, &value))
@@ -273,8 +273,14 @@ static ssize_t attr_fn_lock_store_cptkbd(struct device *dev,
if (value < 0 || value > 1)
return -EINVAL;
- cptkbd_data->fn_lock = !!value;
- lenovo_features_set_cptkbd(hdev);
+ data->fn_lock = !!value;
+
+ switch (hdev->product) {
+ case USB_DEVICE_ID_LENOVO_CUSBKBD:
+ case USB_DEVICE_ID_LENOVO_CBTKBD:
+ lenovo_features_set_cptkbd(hdev);
+ break;
+ }
return count;
}
@@ -309,10 +315,10 @@ static ssize_t attr_sensitivity_store_cptkbd(struct device *dev,
}
-static struct device_attribute dev_attr_fn_lock_cptkbd =
+static struct device_attribute dev_attr_fn_lock =
__ATTR(fn_lock, S_IWUSR | S_IRUGO,
- attr_fn_lock_show_cptkbd,
- attr_fn_lock_store_cptkbd);
+ attr_fn_lock_show,
+ attr_fn_lock_store);
static struct device_attribute dev_attr_sensitivity_cptkbd =
__ATTR(sensitivity, S_IWUSR | S_IRUGO,
@@ -321,7 +327,7 @@ static struct device_attribute dev_attr_sensitivity_cptkbd =
static struct attribute *lenovo_attributes_cptkbd[] = {
- &dev_attr_fn_lock_cptkbd.attr,
+ &dev_attr_fn_lock.attr,
&dev_attr_sensitivity_cptkbd.attr,
NULL
};