lkml.org 
[lkml]   [2021]   [Oct]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 10/13] power: supply: bq25890: Add support for registering the Vbus boost converter as a regulator
On Sat, Oct 30, 2021 at 9:28 PM Hans de Goede <hdegoede@redhat.com> wrote:
>
> The bq25890_charger code supports enabling/disabling the boost converter
> based on usb-phy notifications. But the usb-phy framework is not used on
> all boards/platforms. At support for registering the Vbus boost converter
> as a standard regulator when there is no usb-phy on the board.
>
> Also add support for providing regulator_init_data through platform_data
> for use on boards where device-tree is not used and the platform code must
> thus provide the regulator_init_data.

...

> @@ -1018,6 +1059,21 @@ static int bq25890_probe(struct i2c_client *client,
> INIT_WORK(&bq->usb_work, bq25890_usb_work);
> bq->usb_nb.notifier_call = bq25890_usb_notifier;
> usb_register_notifier(bq->usb_phy, &bq->usb_nb);
> +#ifdef CONFIG_REGULATOR
> + } else {
> + struct bq25890_platform_data *pdata = dev_get_platdata(dev);
> + struct regulator_config cfg = { };
> + struct regulator_dev *reg;
> +
> + cfg.dev = dev;
> + cfg.driver_data = bq;
> + if (pdata)
> + cfg.init_data = pdata->regulator_init_data;
> +
> + reg = devm_regulator_register(dev, &bq25890_vbus_desc, &cfg);
> + if (IS_ERR(reg))
> + return dev_err_probe(dev, PTR_ERR(reg), "registering regulator");
> +#endif
> }

}
#ifdef
else {
...
}
#endif

is a bit better to maintain (less error prone in case of new code).

...

> +#ifndef _BQ25890_CHARGER_H_
> +#define _BQ25890_CHARGER_H_

> +#include <linux/regulator/machine.h>

struct regulator_init_data;

should be sufficient, no header is needed.

> +struct bq25890_platform_data {
> + const struct regulator_init_data *regulator_init_data;
> +};
> +
> +#endif

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2021-10-31 00:15    [W:0.252 / U:1.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site