@@ -99,7 +99,6 @@ struct mvebu_pwm {
99
99
u32 offset ;
100
100
unsigned long clk_rate ;
101
101
struct gpio_desc * gpiod ;
102
- struct pwm_chip chip ;
103
102
spinlock_t lock ;
104
103
struct mvebu_gpio_chip * mvchip ;
105
104
@@ -615,7 +614,7 @@ static const struct regmap_config mvebu_gpio_regmap_config = {
615
614
*/
616
615
static struct mvebu_pwm * to_mvebu_pwm (struct pwm_chip * chip )
617
616
{
618
- return container_of ( chip , struct mvebu_pwm , chip );
617
+ return pwmchip_get_drvdata ( chip );
619
618
}
620
619
621
620
static int mvebu_pwm_request (struct pwm_chip * chip , struct pwm_device * pwm )
@@ -789,6 +788,7 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
789
788
{
790
789
struct device * dev = & pdev -> dev ;
791
790
struct mvebu_pwm * mvpwm ;
791
+ struct pwm_chip * chip ;
792
792
void __iomem * base ;
793
793
u32 offset ;
794
794
u32 set ;
@@ -813,9 +813,11 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
813
813
if (IS_ERR (mvchip -> clk ))
814
814
return PTR_ERR (mvchip -> clk );
815
815
816
- mvpwm = devm_kzalloc (dev , sizeof (struct mvebu_pwm ), GFP_KERNEL );
817
- if (!mvpwm )
818
- return - ENOMEM ;
816
+ chip = devm_pwmchip_alloc (dev , mvchip -> chip .ngpio , sizeof (* mvpwm ));
817
+ if (IS_ERR (chip ))
818
+ return PTR_ERR (chip );
819
+ mvpwm = to_mvebu_pwm (chip );
820
+
819
821
mvchip -> mvpwm = mvpwm ;
820
822
mvpwm -> mvchip = mvchip ;
821
823
mvpwm -> offset = offset ;
@@ -868,13 +870,11 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
868
870
return - EINVAL ;
869
871
}
870
872
871
- mvpwm -> chip .dev = dev ;
872
- mvpwm -> chip .ops = & mvebu_pwm_ops ;
873
- mvpwm -> chip .npwm = mvchip -> chip .ngpio ;
873
+ chip -> ops = & mvebu_pwm_ops ;
874
874
875
875
spin_lock_init (& mvpwm -> lock );
876
876
877
- return devm_pwmchip_add (dev , & mvpwm -> chip );
877
+ return devm_pwmchip_add (dev , chip );
878
878
}
879
879
880
880
#ifdef CONFIG_DEBUG_FS
0 commit comments