[PATCH v4 1/2] Input: axp20x-pek - add is_visible callback for sysfs attributes

From: Steven Feng

Date: Wed Jun 03 2026 - 04:08:14 EST


Add an is_visible callback to control the visibility of sysfs attributes
based on hardware capabilities. This is needed to support PMICs that lack
the PEK_KEY register for configuring startup and shutdown timings.

Devices without startup_time configuration will have these attributes
hidden from sysfs, providing a cleaner interface than returning errors
when the attributes are accessed.

This prepares the driver for adding support for the AXP313A variant.

Signed-off-by: Steven Feng <steven@xxxxxxxxxxxxxxx>
---
drivers/input/misc/axp20x-pek.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index 24f9e9d893de..c1a4e5ea1e00 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -193,7 +193,28 @@ static struct attribute *axp20x_attrs[] = {
&dev_attr_shutdown.attr,
NULL,
};
-ATTRIBUTE_GROUPS(axp20x);
+
+static umode_t axp20x_attr_is_visible(struct kobject *kobj,
+ struct attribute *attr, int n)
+{
+ struct device *dev = kobj_to_dev(kobj);
+ struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
+
+ if (!axp20x_pek->info->startup_time)
+ return 0;
+
+ return attr->mode;
+}
+
+static const struct attribute_group axp20x_group = {
+ .attrs = axp20x_attrs,
+ .is_visible = axp20x_attr_is_visible,
+};
+
+static const struct attribute_group *axp20x_groups[] = {
+ &axp20x_group,
+ NULL,
+};

static irqreturn_t axp20x_pek_irq(int irq, void *pwr)
{
--
2.43.0