From: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
To: <jikos@kernel.org>, <bentiss@kernel.org>
Cc: <linux-input@vger.kernel.org>,
Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Subject: [PATCH -next 1/3] HID: amd_sfh: Move sysfs attributes to a separate file
Date: Sun, 4 Oct 2026 21:29:17 +0530 [thread overview]
Message-ID: <20261004155919.726226-2-Basavaraj.Natikar@amd.com> (raw)
In-Reply-To: <20261004155919.726226-1-Basavaraj.Natikar@amd.com>
The sysfs attribute handling is defined in amd_sfh_pcie.c along with the
PCIe transport code. More attributes will be added and the same handling
is useful across SFH versions.
Therefore, move the attribute definitions, the visibility callback and
the group update helper into a dedicated amd_sfh_sysfs.c file.
No functional change intended.
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
drivers/hid/amd-sfh-hid/Makefile | 1 +
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 55 +------------------
drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c | 73 +++++++++++++++++++++++++
drivers/hid/amd-sfh-hid/amd_sfh_sysfs.h | 19 +++++++
4 files changed, 95 insertions(+), 53 deletions(-)
create mode 100644 drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c
create mode 100644 drivers/hid/amd-sfh-hid/amd_sfh_sysfs.h
diff --git a/drivers/hid/amd-sfh-hid/Makefile b/drivers/hid/amd-sfh-hid/Makefile
index 106514b54d16..a0e4113c94cb 100644
--- a/drivers/hid/amd-sfh-hid/Makefile
+++ b/drivers/hid/amd-sfh-hid/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_AMD_SFH_HID) += amd_sfh.o
amd_sfh-objs := amd_sfh_hid.o
amd_sfh-objs += amd_sfh_client.o
amd_sfh-objs += amd_sfh_pcie.o
+amd_sfh-objs += amd_sfh_sysfs.o
amd_sfh-objs += hid_descriptor/amd_sfh_hid_desc.o
amd_sfh-objs += sfh1_1/amd_sfh_init.o
amd_sfh-objs += sfh1_1/amd_sfh_interface.o
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
index aa09a9538f4f..b3cb13b8c5e8 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
@@ -20,9 +20,9 @@
#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/slab.h>
-#include <linux/string_choices.h>
#include "amd_sfh_pcie.h"
+#include "amd_sfh_sysfs.h"
#include "sfh1_1/amd_sfh_init.h"
#define DRIVER_NAME "pcie_mp2_amd"
@@ -340,57 +340,6 @@ static const struct dmi_system_id dmi_nodevs[] = {
{ }
};
-static ssize_t hpd_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
- struct amd_mp2_dev *mp2 = dev_get_drvdata(dev);
-
- return sysfs_emit(buf, "%s\n", str_enabled_disabled(mp2->dev_en.is_hpd_enabled));
-}
-
-static ssize_t hpd_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct amd_mp2_dev *mp2 = dev_get_drvdata(dev);
- bool enabled;
- int ret;
-
- ret = kstrtobool(buf, &enabled);
- if (ret)
- return ret;
-
- mp2->sfh1_1_ops->toggle_hpd(mp2, enabled);
-
- return count;
-}
-static DEVICE_ATTR_RW(hpd);
-
-static umode_t sfh_attr_is_visible(struct kobject *kobj, struct attribute *attr, int idx)
-{
- struct device *dev = kobj_to_dev(kobj);
- struct amd_mp2_dev *mp2 = dev_get_drvdata(dev);
-
- if (!mp2->sfh1_1_ops || !mp2->dev_en.is_hpd_present)
- return 0;
-
- return attr->mode;
-}
-
-static struct attribute *sfh_attrs[] = {
- &dev_attr_hpd.attr,
- NULL,
-};
-
-static struct attribute_group sfh_attr_group = {
- .attrs = sfh_attrs,
- .is_visible = sfh_attr_is_visible,
-};
-
-static const struct attribute_group *amd_sfh_groups[] = {
- &sfh_attr_group,
- NULL,
-};
-
static DEFINE_IDA(sfh_tm_ida);
static void amd_sfh_maybe_register_tm(struct amd_mp2_dev *mp2)
@@ -448,7 +397,7 @@ static void sfh1_1_init_work(struct work_struct *work)
amd_sfh_clear_intr(mp2);
mp2->init_done = 1;
- rc = sysfs_update_group(&mp2->pdev->dev.kobj, &sfh_attr_group);
+ rc = amd_sfh_update_sysfs(mp2);
if (rc)
dev_warn(&mp2->pdev->dev, "failed to update sysfs group\n");
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c b/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c
new file mode 100644
index 000000000000..db1cc205d25b
--- /dev/null
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.c
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * AMD SFH sysfs attributes
+ *
+ * Copyright (c) 2026, Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * Author: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
+ */
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/string_choices.h>
+#include <linux/sysfs.h>
+
+#include "amd_sfh_common.h"
+#include "amd_sfh_sysfs.h"
+#include "sfh1_1/amd_sfh_init.h"
+
+static ssize_t hpd_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct amd_mp2_dev *mp2 = dev_get_drvdata(dev);
+
+ return sysfs_emit(buf, "%s\n", str_enabled_disabled(mp2->dev_en.is_hpd_enabled));
+}
+
+static ssize_t hpd_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct amd_mp2_dev *mp2 = dev_get_drvdata(dev);
+ bool enabled;
+ int ret;
+
+ ret = kstrtobool(buf, &enabled);
+ if (ret)
+ return ret;
+
+ mp2->sfh1_1_ops->toggle_hpd(mp2, enabled);
+
+ return count;
+}
+static DEVICE_ATTR_RW(hpd);
+
+static umode_t sfh_attr_is_visible(struct kobject *kobj, struct attribute *attr, int idx)
+{
+ struct device *dev = kobj_to_dev(kobj);
+ struct amd_mp2_dev *mp2 = dev_get_drvdata(dev);
+
+ if (!mp2->sfh1_1_ops || !mp2->dev_en.is_hpd_present)
+ return 0;
+
+ return attr->mode;
+}
+
+static struct attribute *sfh_attrs[] = {
+ &dev_attr_hpd.attr,
+ NULL,
+};
+
+static struct attribute_group sfh_attr_group = {
+ .attrs = sfh_attrs,
+ .is_visible = sfh_attr_is_visible,
+};
+
+const struct attribute_group *amd_sfh_groups[] = {
+ &sfh_attr_group,
+ NULL,
+};
+
+int amd_sfh_update_sysfs(struct amd_mp2_dev *mp2)
+{
+ return sysfs_update_group(&mp2->pdev->dev.kobj, &sfh_attr_group);
+}
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.h b/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.h
new file mode 100644
index 000000000000..941b995e2c8f
--- /dev/null
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_sysfs.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * AMD SFH sysfs attributes
+ *
+ * Copyright (c) 2026, Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * Author: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
+ */
+#ifndef AMD_SFH_SYSFS_H
+#define AMD_SFH_SYSFS_H
+
+#include "amd_sfh_common.h"
+
+extern const struct attribute_group *amd_sfh_groups[];
+
+int amd_sfh_update_sysfs(struct amd_mp2_dev *mp2);
+
+#endif
--
2.34.1
next prev parent reply other threads:[~2026-10-04 16:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-04 15:59 [PATCH -next 0/3] HID: amd_sfh: operating-mode telemetry sysfs and accel report fix Basavaraj Natikar
2026-10-04 15:59 ` Basavaraj Natikar [this message]
2026-10-04 15:59 ` [PATCH -next 2/3] HID: amd_sfh: Add operating-mode telemetry sysfs attributes Basavaraj Natikar
2026-10-04 16:11 ` sashiko-bot
2026-10-04 15:59 ` [PATCH -next 3/3] HID: amd_sfh: Remove unsupported motion-state field from accelerometer report Basavaraj Natikar
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=20261004155919.726226-2-Basavaraj.Natikar@amd.com \
--to=basavaraj.natikar@amd.com \
--cc=bentiss@kernel.org \
--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