extcon: Add devm_extcon_dev_allocate/free to manage the resource of extcon device
This patch add device managed devm_extcon_dev_{allocate,free} to automatically free the memory of extcon_dev structure without handling free operation. Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Reviewed-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
@@ -196,6 +196,9 @@ extern struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name);
|
||||
*/
|
||||
extern struct extcon_dev *extcon_dev_allocate(const char **cables);
|
||||
extern void extcon_dev_free(struct extcon_dev *edev);
|
||||
extern struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
|
||||
const char **cables);
|
||||
extern void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev);
|
||||
|
||||
/*
|
||||
* get/set/update_state access the 32b encoded state value, which represents
|
||||
@@ -280,6 +283,14 @@ static inline struct extcon_dev *extcon_dev_allocate(const char **cables)
|
||||
|
||||
static inline void extcon_dev_free(struct extcon_dev *edev) { }
|
||||
|
||||
static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
|
||||
const char **cables)
|
||||
{
|
||||
return ERR_PTR(-ENOSYS);
|
||||
}
|
||||
|
||||
static inline void devm_extcon_dev_free(struct extcon_dev *edev) { }
|
||||
|
||||
static inline u32 extcon_get_state(struct extcon_dev *edev)
|
||||
{
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user