From ddbf7d5a698c4d8553ad2f77cb281d7b37898d34 Mon Sep 17 00:00:00 2001 From: Heiner Kallweit Date: Fri, 30 Sep 2016 17:42:07 -0300 Subject: [media] rc: core: add managed versions of rc_allocate_device and rc_register_device Introduce managed versions of both functions. They allows to simplify the error path in the probe function of rc drivers, and usually also to simplify the remove function. New element managed_alloc in struct rc_dev is needed to correctly handle mixed use, e.g. managed version of rc_register_device and normal version of rc_allocate_device. In addition devm_rc_allocate_device sets rc->dev.parent as having a reference to the parent device might be useful for future extensions. Signed-off-by: Heiner Kallweit Signed-off-by: Mauro Carvalho Chehab --- include/media/rc-core.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'include/media') diff --git a/include/media/rc-core.h b/include/media/rc-core.h index 40188d362486..55281b92105a 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -68,6 +68,7 @@ enum rc_filter_type { * struct rc_dev - represents a remote control device * @dev: driver model's view of this device * @initialized: 1 if the device init has completed, 0 otherwise + * @managed_alloc: devm_rc_allocate_device was used to create rc_dev * @sysfs_groups: sysfs attribute groups * @input_name: name of the input child device * @input_phys: physical path to the input child device @@ -131,6 +132,7 @@ enum rc_filter_type { struct rc_dev { struct device dev; atomic_t initialized; + bool managed_alloc; const struct attribute_group *sysfs_groups[5]; const char *input_name; const char *input_phys; @@ -202,6 +204,14 @@ struct rc_dev { */ struct rc_dev *rc_allocate_device(void); +/** + * devm_rc_allocate_device - Managed RC device allocation + * + * @dev: pointer to struct device + * returns a pointer to struct rc_dev. + */ +struct rc_dev *devm_rc_allocate_device(struct device *dev); + /** * rc_free_device - Frees a RC device * @@ -216,6 +226,14 @@ void rc_free_device(struct rc_dev *dev); */ int rc_register_device(struct rc_dev *dev); +/** + * devm_rc_register_device - Manageded registering of a RC device + * + * @parent: pointer to struct device. + * @dev: pointer to struct rc_dev. + */ +int devm_rc_register_device(struct device *parent, struct rc_dev *dev); + /** * rc_unregister_device - Unregisters a RC device * -- cgit v1.2.3