Input: axp20x-pek - add support for AXP313A variant
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 Input: axp20x-pek - add support for AXP313A variant
Add power button support for the AXP313A PMIC. The AXP313A does not have the PEK_KEY register (0x36) used to configure startup and shutdown timings, unlike AXP20X and AXP221. Create a dedicated axp313a_info configuration with NULL time tables to prevent regmap out-of-bounds access.
For AXP313A, the sysfs attributes (startup/shutdown) are hidden using the is_visible callback, as they are not supported by the hardware.
---
Changes in v3:
- Use is_visible to hide attributes instead of returning -EOPNOTSUPP
- Corrected author name from "steven" to "Steven Feng"
Changes in v2:
- Fixed regmap out-of-bounds access issue reported by Sashiko AI
- Created dedicated axp313a_info with NULL time tables
- Added NULL pointer checks to prevent crashes
- AXP313A lacks PEK_KEY (0x36) per datasheet verification
- Power button still functional using hardware default timings
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
--- drivers/input/misc/axp20x-pek.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-)
drivers/input/misc/axp20x-pek.c +30 -2
@@ -85,6 +85,13 @@ static const struct axp20x_info axp221_info = { .shutdown_mask = AXP20X_PEK_SHUTDOWN_MASK, }; +static const struct axp20x_info axp313a_info = { + .startup_time =NULL , + .startup_mask =0 , + .shutdown_time =NULL , + .shutdown_mask =0 , +}; +static ssize_t axp20x_show_attr (struct device *dev,const struct axp20x_time *time,unsigned int mask,char *buf)
@@ -193,7 +200,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) {
@@ -395,7 +423,7 @@ static const struct platform_device_id axp_pek_id_match[] = { }, { .name = "axp313a-pek", - .driver_data = (kernel_ulong_t)&axp20x_info, + .driver_data = (kernel_ulong_t)&axp313a_info, }, {/* sentinel */ } };
Signature · 1 line
2.43.0
Chen-Yu Tsai
maintainerQuoted 7 lines · Steven Feng
Add power button support for the AXP313A PMIC. The AXP313A does not have the
PEK_KEYregister (0x36) used to configure startup and shutdown timings, unlike AXP20X and AXP221. Create a dedicatedaxp313a_infoconfiguration with NULL time tables to prevent regmap out-of-bounds access.
Quoted 7 lines
For AXP313A, the sysfs attributes (startup/shutdown) are hidden using the
is_visiblecallback, as they are not supported by the hardware.Signed-off-by Steven Feng <[email protected]>---
Changes in v3:
- Useis_visibleto hide attributes instead of returning-EOPNOTSUPP
Adding this should be a separate patch. In the commit message you can say it is needed for a future device added in the next patch.
Quoted 1 line
- Corrected author name from "steven" to "Steven Feng"
Please label the version in the subject as well. The subject should read "[PATCH v3]" for v3. git format-patch -vN ... will do the right thing for you.
ChenYu
Quoted 73 lines
Changes in v2:
- Fixed regmap out-of-bounds access issue reported by Sashiko AI
- Created dedicatedaxp313a_infowith NULL time tables
- Added NULL pointer checks to prevent crashes
- AXP313A lacksPEK_KEY(0x36) per datasheet verification
- Power button still functional using hardware default timingsv2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/--- drivers/input/misc/axp20x-pek.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-)drivers/input/misc/axp20x-pek.c +30
-3@@ -85,6 +85,13 @@ static const struct axp20x_info axp221_info = { .shutdown_mask = AXP20X_PEK_SHUTDOWN_MASK, }; +static const struct axp20x_info axp313a_info = { + .startup_time =NULL , + .startup_mask =0 , + .shutdown_time =NULL , + .shutdown_mask =0 , +}; +static ssize_t axp20x_show_attr (struct device *dev,const struct axp20x_time *time,unsigned int mask,char *buf)@@ -193,7 +200,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) {@@ -395,7 +423,7 @@ static const struct platform_device_id axp_pek_id_match[] = { }, { .name = "axp313a-pek", - .driver_data = (kernel_ulong_t)&axp20x_info, + .driver_data = (kernel_ulong_t)&axp313a_info, }, {/* sentinel */ } }; --2.43.0