Re: [PATCH] Input: axp20x-pek - add support for AXP313A variant
From: Dmitry Torokhov
Date: Tue Jun 02 2026 - 22:25:43 EST
On Wed, Jun 03, 2026 at 09:38:54AM +0800, steven wrote:
> 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.
>
> The sysfs attributes (startup/shutdown) will return -EOPNOTSUPP when
> accessed on AXP313A devices.
>
> Signed-off-by: steven <steven@xxxxxxxxxxxxxxx>
> ---
> 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
>
> v1: https://lore.kernel.org/all/tencent_5F1FF80489E702360F352F889570656BF608@xxxxxx/
> ---
> drivers/input/misc/axp20x-pek.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
> index d4e2fc9a937f..de43eef0c0ea 100644
> --- a/drivers/input/misc/axp20x-pek.c
> +++ b/drivers/input/misc/axp20x-pek.c
> @@ -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)
> @@ -93,6 +100,9 @@ static ssize_t axp20x_show_attr(struct device *dev,
> unsigned int val;
> int ret, i;
>
> + if (!time)
> + return -EOPNOTSUPP;
Use is_visible to control whether attributes are accessible.
Thanks.
--
Dmitry