mirror of https://github.com/torvalds/linux.git
pwm: sifive: Make use of devm_pwmchip_alloc() function
This prepares the pwm-sifive driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Link: https://lore.kernel.org/r/30a4cacafe2c323f2531dd1c1126f0bf0fe5e03c.1707900770.git.u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
This commit is contained in:
parent
c4f4af7d79
commit
554d9acae4
|
|
@ -41,7 +41,6 @@
|
||||||
#define PWM_SIFIVE_DEFAULT_PERIOD 10000000
|
#define PWM_SIFIVE_DEFAULT_PERIOD 10000000
|
||||||
|
|
||||||
struct pwm_sifive_ddata {
|
struct pwm_sifive_ddata {
|
||||||
struct pwm_chip chip;
|
|
||||||
struct device *parent;
|
struct device *parent;
|
||||||
struct mutex lock; /* lock to protect user_count and approx_period */
|
struct mutex lock; /* lock to protect user_count and approx_period */
|
||||||
struct notifier_block notifier;
|
struct notifier_block notifier;
|
||||||
|
|
@ -55,7 +54,7 @@ struct pwm_sifive_ddata {
|
||||||
static inline
|
static inline
|
||||||
struct pwm_sifive_ddata *pwm_sifive_chip_to_ddata(struct pwm_chip *chip)
|
struct pwm_sifive_ddata *pwm_sifive_chip_to_ddata(struct pwm_chip *chip)
|
||||||
{
|
{
|
||||||
return container_of(chip, struct pwm_sifive_ddata, chip);
|
return pwmchip_get_drvdata(chip);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pwm_sifive_request(struct pwm_chip *chip, struct pwm_device *pwm)
|
static int pwm_sifive_request(struct pwm_chip *chip, struct pwm_device *pwm)
|
||||||
|
|
@ -231,15 +230,14 @@ static int pwm_sifive_probe(struct platform_device *pdev)
|
||||||
u32 val;
|
u32 val;
|
||||||
unsigned int enabled_pwms = 0, enabled_clks = 1;
|
unsigned int enabled_pwms = 0, enabled_clks = 1;
|
||||||
|
|
||||||
ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
|
chip = devm_pwmchip_alloc(dev, 4, sizeof(*ddata));
|
||||||
if (!ddata)
|
if (IS_ERR(chip))
|
||||||
return -ENOMEM;
|
return PTR_ERR(chip);
|
||||||
|
|
||||||
|
ddata = pwm_sifive_chip_to_ddata(chip);
|
||||||
|
ddata->parent = dev;
|
||||||
mutex_init(&ddata->lock);
|
mutex_init(&ddata->lock);
|
||||||
chip = &ddata->chip;
|
|
||||||
chip->dev = ddata->parent = dev;
|
|
||||||
chip->ops = &pwm_sifive_ops;
|
chip->ops = &pwm_sifive_ops;
|
||||||
chip->npwm = 4;
|
|
||||||
|
|
||||||
ddata->regs = devm_platform_ioremap_resource(pdev, 0);
|
ddata->regs = devm_platform_ioremap_resource(pdev, 0);
|
||||||
if (IS_ERR(ddata->regs))
|
if (IS_ERR(ddata->regs))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue