@@ -197,7 +197,7 @@ struct ti_sn65dsi86 {
197
197
DECLARE_BITMAP (gchip_output , SN_NUM_GPIOS );
198
198
#endif
199
199
#if defined(CONFIG_PWM )
200
- struct pwm_chip pchip ;
200
+ struct pwm_chip * pchip ;
201
201
bool pwm_enabled ;
202
202
atomic_t pwm_pin_busy ;
203
203
#endif
@@ -1374,7 +1374,7 @@ static void ti_sn_pwm_pin_release(struct ti_sn65dsi86 *pdata)
1374
1374
1375
1375
static struct ti_sn65dsi86 * pwm_chip_to_ti_sn_bridge (struct pwm_chip * chip )
1376
1376
{
1377
- return container_of (chip , struct ti_sn65dsi86 , pchip );
1377
+ return pwmchip_get_drvdata (chip );
1378
1378
}
1379
1379
1380
1380
static int ti_sn_pwm_request (struct pwm_chip * chip , struct pwm_device * pwm )
@@ -1585,23 +1585,28 @@ static const struct pwm_ops ti_sn_pwm_ops = {
1585
1585
static int ti_sn_pwm_probe (struct auxiliary_device * adev ,
1586
1586
const struct auxiliary_device_id * id )
1587
1587
{
1588
+ struct pwm_chip * chip ;
1588
1589
struct ti_sn65dsi86 * pdata = dev_get_drvdata (adev -> dev .parent );
1589
1590
1590
- pdata -> pchip .dev = & adev -> dev ;
1591
- pdata -> pchip .ops = & ti_sn_pwm_ops ;
1592
- pdata -> pchip .npwm = 1 ;
1593
- pdata -> pchip .of_xlate = of_pwm_single_xlate ;
1591
+ pdata -> pchip = chip = devm_pwmchip_alloc (& adev -> dev , 1 , 0 );
1592
+ if (IS_ERR (chip ))
1593
+ return PTR_ERR (chip );
1594
+
1595
+ pwmchip_set_drvdata (chip , pdata );
1596
+
1597
+ chip -> ops = & ti_sn_pwm_ops ;
1598
+ chip -> of_xlate = of_pwm_single_xlate ;
1594
1599
1595
1600
devm_pm_runtime_enable (& adev -> dev );
1596
1601
1597
- return pwmchip_add (& pdata -> pchip );
1602
+ return pwmchip_add (chip );
1598
1603
}
1599
1604
1600
1605
static void ti_sn_pwm_remove (struct auxiliary_device * adev )
1601
1606
{
1602
1607
struct ti_sn65dsi86 * pdata = dev_get_drvdata (adev -> dev .parent );
1603
1608
1604
- pwmchip_remove (& pdata -> pchip );
1609
+ pwmchip_remove (pdata -> pchip );
1605
1610
1606
1611
if (pdata -> pwm_enabled )
1607
1612
pm_runtime_put_sync (& adev -> dev );
0 commit comments