@@ -89,13 +89,13 @@ static int pwm_device_request(struct pwm_device *pwm, const char *label)
8989 if (test_bit (PWMF_REQUESTED , & pwm -> flags ))
9090 return - EBUSY ;
9191
92- if (!try_module_get (pwm -> chip -> ops -> owner ))
92+ if (!try_module_get (pwm -> chip -> owner ))
9393 return - ENODEV ;
9494
9595 if (pwm -> chip -> ops -> request ) {
9696 err = pwm -> chip -> ops -> request (pwm -> chip , pwm );
9797 if (err ) {
98- module_put (pwm -> chip -> ops -> owner );
98+ module_put (pwm -> chip -> owner );
9999 return err ;
100100 }
101101 }
@@ -208,36 +208,6 @@ static void of_pwmchip_remove(struct pwm_chip *chip)
208208 of_node_put (chip -> dev -> of_node );
209209}
210210
211- /**
212- * pwm_set_chip_data() - set private chip data for a PWM
213- * @pwm: PWM device
214- * @data: pointer to chip-specific data
215- *
216- * Returns: 0 on success or a negative error code on failure.
217- */
218- int pwm_set_chip_data (struct pwm_device * pwm , void * data )
219- {
220- if (!pwm )
221- return - EINVAL ;
222-
223- pwm -> chip_data = data ;
224-
225- return 0 ;
226- }
227- EXPORT_SYMBOL_GPL (pwm_set_chip_data );
228-
229- /**
230- * pwm_get_chip_data() - get private chip data for a PWM
231- * @pwm: PWM device
232- *
233- * Returns: A pointer to the chip-private data for the PWM device.
234- */
235- void * pwm_get_chip_data (struct pwm_device * pwm )
236- {
237- return pwm ? pwm -> chip_data : NULL ;
238- }
239- EXPORT_SYMBOL_GPL (pwm_get_chip_data );
240-
241211static bool pwm_ops_check (const struct pwm_chip * chip )
242212{
243213 const struct pwm_ops * ops = chip -> ops ;
@@ -253,14 +223,16 @@ static bool pwm_ops_check(const struct pwm_chip *chip)
253223}
254224
255225/**
256- * pwmchip_add () - register a new PWM chip
226+ * __pwmchip_add () - register a new PWM chip
257227 * @chip: the PWM chip to add
228+ * @owner: reference to the module providing the chip.
258229 *
259- * Register a new PWM chip.
230+ * Register a new PWM chip. @owner is supposed to be THIS_MODULE, use the
231+ * pwmchip_add wrapper to do this right.
260232 *
261233 * Returns: 0 on success or a negative error code on failure.
262234 */
263- int pwmchip_add (struct pwm_chip * chip )
235+ int __pwmchip_add (struct pwm_chip * chip , struct module * owner )
264236{
265237 struct pwm_device * pwm ;
266238 unsigned int i ;
@@ -272,6 +244,8 @@ int pwmchip_add(struct pwm_chip *chip)
272244 if (!pwm_ops_check (chip ))
273245 return - EINVAL ;
274246
247+ chip -> owner = owner ;
248+
275249 chip -> pwms = kcalloc (chip -> npwm , sizeof (* pwm ), GFP_KERNEL );
276250 if (!chip -> pwms )
277251 return - ENOMEM ;
@@ -306,7 +280,7 @@ int pwmchip_add(struct pwm_chip *chip)
306280
307281 return 0 ;
308282}
309- EXPORT_SYMBOL_GPL (pwmchip_add );
283+ EXPORT_SYMBOL_GPL (__pwmchip_add );
310284
311285/**
312286 * pwmchip_remove() - remove a PWM chip
@@ -338,17 +312,17 @@ static void devm_pwmchip_remove(void *data)
338312 pwmchip_remove (chip );
339313}
340314
341- int devm_pwmchip_add (struct device * dev , struct pwm_chip * chip )
315+ int __devm_pwmchip_add (struct device * dev , struct pwm_chip * chip , struct module * owner )
342316{
343317 int ret ;
344318
345- ret = pwmchip_add (chip );
319+ ret = __pwmchip_add (chip , owner );
346320 if (ret )
347321 return ret ;
348322
349323 return devm_add_action_or_reset (dev , devm_pwmchip_remove , chip );
350324}
351- EXPORT_SYMBOL_GPL (devm_pwmchip_add );
325+ EXPORT_SYMBOL_GPL (__devm_pwmchip_add );
352326
353327/**
354328 * pwm_request_from_chip() - request a PWM device relative to a PWM chip
@@ -976,10 +950,9 @@ void pwm_put(struct pwm_device *pwm)
976950 if (pwm -> chip -> ops -> free )
977951 pwm -> chip -> ops -> free (pwm -> chip , pwm );
978952
979- pwm_set_chip_data (pwm , NULL );
980953 pwm -> label = NULL ;
981954
982- module_put (pwm -> chip -> ops -> owner );
955+ module_put (pwm -> chip -> owner );
983956out :
984957 mutex_unlock (& pwm_lock );
985958}
0 commit comments