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

From: Andy Shevchenko
Date: Wed Apr 05 2023 - 11:28:35 EST


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>
---
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)
{
--
2.40.0.1.gaa8946217a0b