170170 * @pwm_refclk_freq: Cache for the reference clock input to the PWM.
171171 */
172172struct ti_sn65dsi86 {
173- struct auxiliary_device bridge_aux ;
174- struct auxiliary_device gpio_aux ;
175- struct auxiliary_device aux_aux ;
176- struct auxiliary_device pwm_aux ;
173+ struct auxiliary_device * bridge_aux ;
174+ struct auxiliary_device * gpio_aux ;
175+ struct auxiliary_device * aux_aux ;
176+ struct auxiliary_device * pwm_aux ;
177177
178178 struct device * dev ;
179179 struct regmap * regmap ;
@@ -468,27 +468,34 @@ static void ti_sn65dsi86_delete_aux(void *data)
468468 auxiliary_device_delete (data );
469469}
470470
471- /*
472- * AUX bus docs say that a non-NULL release is mandatory, but it makes no
473- * sense for the model used here where all of the aux devices are allocated
474- * in the single shared structure. We'll use this noop as a workaround.
475- */
476- static void ti_sn65dsi86_noop ( struct device * dev ) { }
471+ static void ti_sn65dsi86_aux_device_release ( struct device * dev )
472+ {
473+ struct auxiliary_device * aux = container_of ( dev , struct auxiliary_device , dev );
474+
475+ kfree ( aux );
476+ }
477477
478478static int ti_sn65dsi86_add_aux_device (struct ti_sn65dsi86 * pdata ,
479- struct auxiliary_device * aux ,
479+ struct auxiliary_device * * aux_out ,
480480 const char * name )
481481{
482482 struct device * dev = pdata -> dev ;
483+ struct auxiliary_device * aux ;
483484 int ret ;
484485
486+ aux = kzalloc (sizeof (* aux ), GFP_KERNEL );
487+ if (!aux )
488+ return - ENOMEM ;
489+
485490 aux -> name = name ;
486491 aux -> dev .parent = dev ;
487- aux -> dev .release = ti_sn65dsi86_noop ;
492+ aux -> dev .release = ti_sn65dsi86_aux_device_release ;
488493 device_set_of_node_from_dev (& aux -> dev , dev );
489494 ret = auxiliary_device_init (aux );
490- if (ret )
495+ if (ret ) {
496+ kfree (aux );
491497 return ret ;
498+ }
492499 ret = devm_add_action_or_reset (dev , ti_sn65dsi86_uninit_aux , aux );
493500 if (ret )
494501 return ret ;
@@ -497,6 +504,8 @@ static int ti_sn65dsi86_add_aux_device(struct ti_sn65dsi86 *pdata,
497504 if (ret )
498505 return ret ;
499506 ret = devm_add_action_or_reset (dev , ti_sn65dsi86_delete_aux , aux );
507+ if (!ret )
508+ * aux_out = aux ;
500509
501510 return ret ;
502511}
0 commit comments