Hi Petr, On 2026-10-10T12:42:50, Petr Hodina via B4 Relay <[email protected]> wrote: > button: adc: implement get_code() > > Implement .get_code in button_adc_ops and add linux_code > to button_adc_priv.
Please can you add a sentence on why this is needed, e.g. which caller needs the key code from an adc-keys button (button-kbd, bootmenu, a particular board)? > > Signed-off-by: Petr Hodina <[email protected]> > > drivers/button/button-adc.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > diff --git a/drivers/button/button-adc.c b/drivers/button/button-adc.c > @@ -49,6 +51,16 @@ static enum button_state_t button_adc_get_state(struct > udevice *dev) > +static int button_adc_get_code(struct udevice *dev) > +{ > + struct button_adc_priv *priv = dev_get_priv(dev); > + > + if (!priv->linux_code) > + return -ENODATA; > + > + return priv->linux_code; > +} The sandbox test.dts already has linux,code values (KEY_F3/F4/F5) on the adc-keys buttons. Please can you extend dm_test_button_keys_adc() in test/dm/button.c to check button_get_code() for button3, button4 and button5? > diff --git a/drivers/button/button-adc.c b/drivers/button/button-adc.c > @@ -93,6 +105,8 @@ static int button_adc_of_to_plat(struct udevice *dev) > + priv->linux_code = ofnode_read_u32_default(dev_ofnode(dev), > + "linux,code", 0); You can use dev_read_u32_default(dev, "linux,code", 0) here, which fits on one line and matches the dev_read_u32() call in button-gpio. Treating the property as optional is fine, even though the Linux adc-keys binding requires it. Regards, Simon
