> Subject: Re: [PATCH v3 2/4] input: bbnsm_pwrkey: Add bbnsm power key > support > > On Tue, Jan 03, 2023 at 15:47, Jacky Bai <ping.bai@xxxxxxx> wrote: > > > The ON/OFF logic inside the BBNSM allows for connecting directly into > > a PMIC or other voltage regulator device. The module has an button > > input signal and a wakeup request input signal. It also has two > > interrupts (set_pwr_off_irq and set_pwr_on_irq) and an active-low PMIC > > enable (pmic_en_b) output. > > > > Add the power key support for the ON/OFF button function found in > > BBNSM module. > > > > Signed-off-by: Jacky Bai <ping.bai@xxxxxxx> > > Reviewed-by: Peng Fan <peng.fan@xxxxxxx> > > --- > > - v2 changes: > > - use device_property_read_u32() to read the property > > We state this in the changelog > > > - clean up the goto return, return directly > > - sort the header file alphabetically > > - rename the file to add 'nxp' prefix > > > > - v3 changes: > > - get the regmap directly from the parent node > > --- ... > > + bbnsm->regmap = syscon_node_to_regmap(np->parent); > > + if (IS_ERR(bbnsm->regmap)) { > > + dev_err(&pdev->dev, "bbnsm pwerkey get regmap failed\n"); > > + return PTR_ERR(bbnsm->regmap); > > + } > > + > > + if (of_property_read_u32(np, "linux,code", &bbnsm->keycode)) { > > But of_property_read_u32() is still used Sorry, it is my fault, will fix it. > > > + bbnsm->keycode = KEY_POWER; > > + dev_warn(&pdev->dev, "KEY_POWER without setting in dts\n"); > > + } > > + > > + bbnsm->irq = platform_get_irq(pdev, 0); > > + if (bbnsm->irq < 0) > > + return -EINVAL; > > + > > + /* config the BBNSM power related register */ > > + regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, BBNSM_DP_EN, > > +BBNSM_DP_EN); > > + > > + /* clear the unexpected interrupt before driver ready */ > > + regmap_write_bits(bbnsm->regmap, BBNSM_EVENTS, > BBNSM_PWRKEY_EVENTS, > > +BBNSM_PWRKEY_EVENTS); > > + > > + timer_setup(&bbnsm->check_timer, bbnsm_pwrkey_check_for_events, > 0); > > + > > + input = devm_input_allocate_device(&pdev->dev); > > + if (!input) { > > + dev_err(&pdev->dev, "failed to allocate the input device\n"); > > + return -ENOMEM; > > + } > > + > > + input->name = pdev->name; > > + input->phys = "bbnsm-pwrkey/input0"; > > + input->id.bustype = BUS_HOST; > > + > > + input_set_capability(input, EV_KEY, bbnsm->keycode); > > + > > + /* input customer action to cancel release timer */ > > + error = devm_add_action(&pdev->dev, bbnsm_pwrkey_act, bbnsm); > > + if (error) { > > + dev_err(&pdev->dev, "failed to register remove action\n"); > > + return error; > > + } > > + > > + bbnsm->input = input; > > + platform_set_drvdata(pdev, bbnsm); > > + > > + error = devm_request_irq(&pdev->dev, bbnsm->irq, > bbnsm_pwrkey_interrupt, > > + IRQF_SHARED, pdev->name, pdev); > > + if (error) { > > + dev_err(&pdev->dev, "interrupt not available.\n"); > > + return error; > > + } > > + > > + error = input_register_device(input); > > + if (error < 0) { > > + dev_err(&pdev->dev, "failed to register input device\n"); > > + return error; > > + } > > + > > + device_init_wakeup(&pdev->dev, true); > > + dev_pm_set_wake_irq(&pdev->dev, bbnsm->irq); > > Can we add some error handling here? > The legacy driver (snvs_pwrkey), which looks a lot like this one, warns whne > irq wake enabling fails, and so do the other drivers keyboard drivers that call > dev_pm_set_wake_irq(). > The error warning removed after v2 based on Alexandre's concern in rtc driver, I can add a dev_warn in v4. Thx. BR Jacky Bai > > + > > + return 0; > > +} > > + > > +static const struct of_device_id bbnsm_pwrkey_ids[] = { > > + { .compatible = "nxp,bbnsm-pwrkey" }, > > + { /* sentinel */ } > > +}; > > +MODULE_DEVICE_TABLE(of, bbnsm_pwrkey_ids); > > + > > +static struct platform_driver bbnsm_pwrkey_driver = { > > + .driver = { > > + .name = "bbnsm_pwrkey", > > + .of_match_table = bbnsm_pwrkey_ids, > > + }, > > + .probe = bbnsm_pwrkey_probe, > > +}; > > +module_platform_driver(bbnsm_pwrkey_driver); > > + > > +MODULE_AUTHOR("Jacky Bai <ping.bai@xxxxxxx>"); > > +MODULE_DESCRIPTION("NXP bbnsm power key Driver"); > > +MODULE_LICENSE("GPL"); > > -- > > 2.37.1