From: Hans de Goede <hdegoede@redhat.com>
To: Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Hans de Goede <hdegoede@redhat.com>, linux-input@vger.kernel.org
Subject: [PATCH 3/5] HID: lenovo: Rename fn_lock sysfs attr handlers to make them generic
Date: Sat, 4 Jul 2020 15:27:40 +0200 [thread overview]
Message-ID: <20200704132742.60197-4-hdegoede@redhat.com> (raw)
In-Reply-To: <20200704132742.60197-1-hdegoede@redhat.com>
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>
---
drivers/hid/hid-lenovo.c | 28 +++++++++++++++++-----------
1 file 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
};
--
2.26.2
next prev parent reply other threads:[~2020-07-04 13:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-04 13:27 [PATCH 0/5] HID: lenovo: Add ThinkPad 10 Ultrabook Keyboard support Hans de Goede
2020-07-04 13:27 ` [PATCH 1/5] HID: lenovo: Merge tpkbd and cptkbd data structures Hans de Goede
2020-07-04 13:27 ` [PATCH 2/5] HID: lenovo: Factor out generic parts of the LED code Hans de Goede
2020-07-04 13:27 ` Hans de Goede [this message]
2020-07-04 13:27 ` [PATCH 4/5] HID: lenovo: Add ThinkPad 10 Ultrabook Keyboard support Hans de Goede
2020-07-04 13:27 ` [PATCH 5/5] HID: lenovo: Add ThinkPad 10 Ultrabook Keyboard fn_lock support Hans de Goede
2020-07-07 10:43 ` [PATCH 0/5] HID: lenovo: Add ThinkPad 10 Ultrabook Keyboard support Jiri Kosina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200704132742.60197-4-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).