diff options
Diffstat (limited to 'drivers/pwm/pwm-meson.c')
| -rw-r--r-- | drivers/pwm/pwm-meson.c | 25 | 
1 files changed, 10 insertions, 15 deletions
| diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c index 6e44fc855c64..207e594c2d99 100644 --- a/drivers/pwm/pwm-meson.c +++ b/drivers/pwm/pwm-meson.c @@ -37,6 +37,8 @@  #define MISC_B_EN		BIT(1)  #define MISC_A_EN		BIT(0) +#define MESON_NUM_PWMS		2 +  static const unsigned int mux_reg_shifts[] = {  	MISC_A_CLK_SEL_SHIFT,  	MISC_B_CLK_SEL_SHIFT @@ -62,6 +64,7 @@ struct meson_pwm_data {  struct meson_pwm {  	struct pwm_chip chip;  	const struct meson_pwm_data *data; +	struct meson_pwm_channel channels[MESON_NUM_PWMS];  	void __iomem *base;  	/*  	 * Protects register (write) access to the REG_MISC_AB register @@ -444,8 +447,7 @@ static const struct of_device_id meson_pwm_matches[] = {  };  MODULE_DEVICE_TABLE(of, meson_pwm_matches); -static int meson_pwm_init_channels(struct meson_pwm *meson, -				   struct meson_pwm_channel *channels) +static int meson_pwm_init_channels(struct meson_pwm *meson)  {  	struct device *dev = meson->chip.dev;  	struct clk_init_data init; @@ -454,7 +456,7 @@ static int meson_pwm_init_channels(struct meson_pwm *meson,  	int err;  	for (i = 0; i < meson->chip.npwm; i++) { -		struct meson_pwm_channel *channel = &channels[i]; +		struct meson_pwm_channel *channel = &meson->channels[i];  		snprintf(name, sizeof(name), "%s#mux%u", dev_name(dev), i); @@ -489,18 +491,16 @@ static int meson_pwm_init_channels(struct meson_pwm *meson,  	return 0;  } -static void meson_pwm_add_channels(struct meson_pwm *meson, -				   struct meson_pwm_channel *channels) +static void meson_pwm_add_channels(struct meson_pwm *meson)  {  	unsigned int i;  	for (i = 0; i < meson->chip.npwm; i++) -		pwm_set_chip_data(&meson->chip.pwms[i], &channels[i]); +		pwm_set_chip_data(&meson->chip.pwms[i], &meson->channels[i]);  }  static int meson_pwm_probe(struct platform_device *pdev)  { -	struct meson_pwm_channel *channels;  	struct meson_pwm *meson;  	struct resource *regs;  	int err; @@ -518,18 +518,13 @@ static int meson_pwm_probe(struct platform_device *pdev)  	meson->chip.dev = &pdev->dev;  	meson->chip.ops = &meson_pwm_ops;  	meson->chip.base = -1; -	meson->chip.npwm = 2; +	meson->chip.npwm = MESON_NUM_PWMS;  	meson->chip.of_xlate = of_pwm_xlate_with_flags;  	meson->chip.of_pwm_n_cells = 3;  	meson->data = of_device_get_match_data(&pdev->dev); -	channels = devm_kcalloc(&pdev->dev, meson->chip.npwm, -				sizeof(*channels), GFP_KERNEL); -	if (!channels) -		return -ENOMEM; - -	err = meson_pwm_init_channels(meson, channels); +	err = meson_pwm_init_channels(meson);  	if (err < 0)  		return err; @@ -539,7 +534,7 @@ static int meson_pwm_probe(struct platform_device *pdev)  		return err;  	} -	meson_pwm_add_channels(meson, channels); +	meson_pwm_add_channels(meson);  	platform_set_drvdata(pdev, meson); | 

