Skip to content

Commit ef550c5

Browse files
jwrdegoedeJiri Kosina
authored andcommitted
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 <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 484921f commit ef550c5

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

drivers/hid/hid-lenovo.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,32 +249,38 @@ static void lenovo_features_set_cptkbd(struct hid_device *hdev)
249249
hid_err(hdev, "Sensitivity setting failed: %d\n", ret);
250250
}
251251

252-
static ssize_t attr_fn_lock_show_cptkbd(struct device *dev,
252+
static ssize_t attr_fn_lock_show(struct device *dev,
253253
struct device_attribute *attr,
254254
char *buf)
255255
{
256256
struct hid_device *hdev = to_hid_device(dev);
257-
struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev);
257+
struct lenovo_drvdata *data = hid_get_drvdata(hdev);
258258

259-
return snprintf(buf, PAGE_SIZE, "%u\n", cptkbd_data->fn_lock);
259+
return snprintf(buf, PAGE_SIZE, "%u\n", data->fn_lock);
260260
}
261261

262-
static ssize_t attr_fn_lock_store_cptkbd(struct device *dev,
262+
static ssize_t attr_fn_lock_store(struct device *dev,
263263
struct device_attribute *attr,
264264
const char *buf,
265265
size_t count)
266266
{
267267
struct hid_device *hdev = to_hid_device(dev);
268-
struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev);
268+
struct lenovo_drvdata *data = hid_get_drvdata(hdev);
269269
int value;
270270

271271
if (kstrtoint(buf, 10, &value))
272272
return -EINVAL;
273273
if (value < 0 || value > 1)
274274
return -EINVAL;
275275

276-
cptkbd_data->fn_lock = !!value;
277-
lenovo_features_set_cptkbd(hdev);
276+
data->fn_lock = !!value;
277+
278+
switch (hdev->product) {
279+
case USB_DEVICE_ID_LENOVO_CUSBKBD:
280+
case USB_DEVICE_ID_LENOVO_CBTKBD:
281+
lenovo_features_set_cptkbd(hdev);
282+
break;
283+
}
278284

279285
return count;
280286
}
@@ -309,10 +315,10 @@ static ssize_t attr_sensitivity_store_cptkbd(struct device *dev,
309315
}
310316

311317

312-
static struct device_attribute dev_attr_fn_lock_cptkbd =
318+
static struct device_attribute dev_attr_fn_lock =
313319
__ATTR(fn_lock, S_IWUSR | S_IRUGO,
314-
attr_fn_lock_show_cptkbd,
315-
attr_fn_lock_store_cptkbd);
320+
attr_fn_lock_show,
321+
attr_fn_lock_store);
316322

317323
static struct device_attribute dev_attr_sensitivity_cptkbd =
318324
__ATTR(sensitivity, S_IWUSR | S_IRUGO,
@@ -321,7 +327,7 @@ static struct device_attribute dev_attr_sensitivity_cptkbd =
321327

322328

323329
static struct attribute *lenovo_attributes_cptkbd[] = {
324-
&dev_attr_fn_lock_cptkbd.attr,
330+
&dev_attr_fn_lock.attr,
325331
&dev_attr_sensitivity_cptkbd.attr,
326332
NULL
327333
};

0 commit comments

Comments
 (0)