Re: [PATCH v2 1/5] extcon: Make the allocation and freeing to be private calls

From: Chanwoo Choi
Date: Thu Apr 06 2023 - 15:19:16 EST


Hi,

On 23. 4. 6. 00:27, Andy Shevchenko wrote:
> The extcon_dev_allocate() and extcon_dev_free() are not used
> outside of the extcon framework. Moreover, the struct extcon_dev
> can't be filled outside of the framework either after allocation.
> The registration part, for instance, requires a parent device to
> be set and that's done in the devm_extcon_dev_allocate() wrapper.
>
> Taking the above into account, sumply move the mentioned APIs to
> the private headers.
>
> Alternatively, the pointer to the parent device can be added to
> the extcon_dev_allocate(), but since there are no users and magnitude
> of the change it makes a little sense to go this way.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>

The role of extcon_dev_allocate is not that supporting to touch
the internal data of struct extcon_dev. Some driver needs
the removing sequence between extcon device and their used resource
like irq/opp/regulator or others.

When they need some sequence of resource freeing, it should be supported.
I think that there is no benefit to move into driver/extcon. It might
limit the various use-case of extcon_dev_allocate.


> ---
> drivers/extcon/extcon.h | 4 ++++
> include/linux/extcon-provider.h | 9 ---------
> 2 files changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/extcon/extcon.h b/drivers/extcon/extcon.h
> index 15616446140d..49e4ed9f6450 100644
> --- a/drivers/extcon/extcon.h
> +++ b/drivers/extcon/extcon.h
> @@ -63,4 +63,8 @@ struct extcon_dev {
> struct device_attribute *d_attrs_muex;
> };
>
> +/* Following APIs allocate/free the memory of the extcon device. */
> +struct extcon_dev *extcon_dev_allocate(const unsigned int *cable);
> +void extcon_dev_free(struct extcon_dev *edev);
> +
> #endif /* __LINUX_EXTCON_INTERNAL_H__ */
> diff --git a/include/linux/extcon-provider.h b/include/linux/extcon-provider.h
> index fa70945f4e6b..db474ae3c711 100644
> --- a/include/linux/extcon-provider.h
> +++ b/include/linux/extcon-provider.h
> @@ -25,8 +25,6 @@ void devm_extcon_dev_unregister(struct device *dev,
> struct extcon_dev *edev);
>
> /* Following APIs allocate/free the memory of the extcon device. */
> -struct extcon_dev *extcon_dev_allocate(const unsigned int *cable);
> -void extcon_dev_free(struct extcon_dev *edev);
> struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
> const unsigned int *cable);
> void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev);
> @@ -78,13 +76,6 @@ static inline int devm_extcon_dev_register(struct device *dev,
> static inline void devm_extcon_dev_unregister(struct device *dev,
> struct extcon_dev *edev) { }
>
> -static inline struct extcon_dev *extcon_dev_allocate(const unsigned int *cable)
> -{
> - return ERR_PTR(-ENOSYS);
> -}
> -
> -static inline void extcon_dev_free(struct extcon_dev *edev) { }
> -
> static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
> const unsigned int *cable)
> {

--
Best Regards,
Samsung Electronics
Chanwoo Choi