File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ struct lpg {
77
77
78
78
struct mutex lock ;
79
79
80
- struct pwm_chip pwm ;
80
+ struct pwm_chip * pwm ;
81
81
82
82
const struct lpg_data * data ;
83
83
@@ -978,7 +978,7 @@ static int lpg_pattern_mc_clear(struct led_classdev *cdev)
978
978
979
979
static inline struct lpg * lpg_pwm_from_chip (struct pwm_chip * chip )
980
980
{
981
- return container_of (chip , struct lpg , pwm );
981
+ return pwmchip_get_drvdata (chip );
982
982
}
983
983
984
984
static int lpg_pwm_request (struct pwm_chip * chip , struct pwm_device * pwm )
@@ -1093,13 +1093,17 @@ static const struct pwm_ops lpg_pwm_ops = {
1093
1093
1094
1094
static int lpg_add_pwm (struct lpg * lpg )
1095
1095
{
1096
+ struct pwm_chip * chip ;
1096
1097
int ret ;
1097
1098
1098
- lpg -> pwm . dev = lpg -> dev ;
1099
- lpg -> pwm . npwm = lpg -> num_channels ;
1100
- lpg -> pwm . ops = & lpg_pwm_ops ;
1099
+ lpg -> pwm = chip = devm_pwmchip_alloc ( lpg -> dev , lpg -> num_channels , 0 ) ;
1100
+ if ( IS_ERR ( chip ))
1101
+ return PTR_ERR ( chip ) ;
1101
1102
1102
- ret = devm_pwmchip_add (lpg -> dev , & lpg -> pwm );
1103
+ chip -> ops = & lpg_pwm_ops ;
1104
+ pwmchip_set_drvdata (chip , lpg );
1105
+
1106
+ ret = devm_pwmchip_add (lpg -> dev , chip );
1103
1107
if (ret )
1104
1108
dev_err_probe (lpg -> dev , ret , "failed to add PWM chip\n" );
1105
1109
You can’t perform that action at this time.
0 commit comments