mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-01 02:36:02 +00:00
pwm: imx27: Make use of devm_pwmchip_alloc() function
This prepares the pwm-imx27 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. Also convert the to_pwm_imx27_chip() helper macro to a static inline to get some type safety. Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Link: https://lore.kernel.org/r/3da748c80e9bbe29e7c119190dbc4bd67d159f22.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
175f53a78c
commit
dcef3929e0
@ -83,7 +83,6 @@ struct pwm_imx27_chip {
|
||||
struct clk *clk_ipg;
|
||||
struct clk *clk_per;
|
||||
void __iomem *mmio_base;
|
||||
struct pwm_chip chip;
|
||||
|
||||
/*
|
||||
* The driver cannot read the current duty cycle from the hardware if
|
||||
@ -93,7 +92,10 @@ struct pwm_imx27_chip {
|
||||
unsigned int duty_cycle;
|
||||
};
|
||||
|
||||
#define to_pwm_imx27_chip(chip) container_of(chip, struct pwm_imx27_chip, chip)
|
||||
static inline struct pwm_imx27_chip *to_pwm_imx27_chip(struct pwm_chip *chip)
|
||||
{
|
||||
return pwmchip_get_drvdata(chip);
|
||||
}
|
||||
|
||||
static int pwm_imx27_clk_prepare_enable(struct pwm_imx27_chip *imx)
|
||||
{
|
||||
@ -303,13 +305,15 @@ MODULE_DEVICE_TABLE(of, pwm_imx27_dt_ids);
|
||||
|
||||
static int pwm_imx27_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct pwm_chip *chip;
|
||||
struct pwm_imx27_chip *imx;
|
||||
int ret;
|
||||
u32 pwmcr;
|
||||
|
||||
imx = devm_kzalloc(&pdev->dev, sizeof(*imx), GFP_KERNEL);
|
||||
if (imx == NULL)
|
||||
return -ENOMEM;
|
||||
chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*imx));
|
||||
if (IS_ERR(chip))
|
||||
return PTR_ERR(chip);
|
||||
imx = to_pwm_imx27_chip(chip);
|
||||
|
||||
imx->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
|
||||
if (IS_ERR(imx->clk_ipg))
|
||||
@ -321,9 +325,7 @@ static int pwm_imx27_probe(struct platform_device *pdev)
|
||||
return dev_err_probe(&pdev->dev, PTR_ERR(imx->clk_per),
|
||||
"failed to get peripheral clock\n");
|
||||
|
||||
imx->chip.ops = &pwm_imx27_ops;
|
||||
imx->chip.dev = &pdev->dev;
|
||||
imx->chip.npwm = 1;
|
||||
chip->ops = &pwm_imx27_ops;
|
||||
|
||||
imx->mmio_base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(imx->mmio_base))
|
||||
@ -338,7 +340,7 @@ static int pwm_imx27_probe(struct platform_device *pdev)
|
||||
if (!(pwmcr & MX3_PWMCR_EN))
|
||||
pwm_imx27_clk_disable_unprepare(imx);
|
||||
|
||||
return devm_pwmchip_add(&pdev->dev, &imx->chip);
|
||||
return devm_pwmchip_add(&pdev->dev, chip);
|
||||
}
|
||||
|
||||
static struct platform_driver imx_pwm_driver = {
|
||||
|
Loading…
Reference in New Issue
Block a user