[PATCH] extcon: Remove deadcode

linux@treblig.org posted 1 patch 1 year, 3 months ago
drivers/extcon/extcon.c         | 67 ---------------------------------
include/linux/extcon-provider.h | 10 -----
include/linux/extcon.h          | 20 +---------
3 files changed, 1 insertion(+), 96 deletions(-)
[PATCH] extcon: Remove deadcode
Posted by linux@treblig.org 1 year, 3 months ago
From: "Dr. David Alan Gilbert" <linux@treblig.org>

extcon_get_edev_name() has been unused since it was added in 2015 by
commit 707d7550875a ("extcon: Add extcon_get_edev_name() API to get the
extcon device name")

extcon_get_property_capability() has been unused since it was added
in 2016 by
commit ceaa98f442cf ("extcon: Add the support for the capability of each
property")
(It seems everyone just uses extcon_get_property)

extcon_set_property_sync() has been unused since it was added in 2016
by
commit a580982f0836 ("extcon: Add the synchronization extcon APIs to
support the notification")
Everyone seems to use the none _sync version, and there's one place
where they just call sync after it.

Remove them.

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
---
 drivers/extcon/extcon.c         | 67 ---------------------------------
 include/linux/extcon-provider.h | 10 -----
 include/linux/extcon.h          | 20 +---------
 3 files changed, 1 insertion(+), 96 deletions(-)

diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index e7f55c021e56..41a31cc46004 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -755,63 +755,6 @@ int extcon_set_property(struct extcon_dev *edev, unsigned int id,
 }
 EXPORT_SYMBOL_GPL(extcon_set_property);
 
-/**
- * extcon_set_property_sync() - Set property of an external connector with sync.
- * @edev:	the extcon device
- * @id:		the unique id indicating an external connector
- * @prop:	the property id indicating an extcon property
- * @prop_val:	the pointer including the new value of extcon property
- *
- * Note that when setting the property value of external connector,
- * the external connector should be attached. The each property should
- * be included in the list of supported properties according to extcon type.
- *
- * Returns 0 if success or error number if fail.
- */
-int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id,
-				unsigned int prop,
-				union extcon_property_value prop_val)
-{
-	int ret;
-
-	ret = extcon_set_property(edev, id, prop, prop_val);
-	if (ret < 0)
-		return ret;
-
-	return extcon_sync(edev, id);
-}
-EXPORT_SYMBOL_GPL(extcon_set_property_sync);
-
-/**
- * extcon_get_property_capability() - Get the capability of the property
- *					for an external connector.
- * @edev:	the extcon device
- * @id:		the unique id indicating an external connector
- * @prop:	the property id indicating an extcon property
- *
- * Returns 1 if the property is available or 0 if not available.
- */
-int extcon_get_property_capability(struct extcon_dev *edev, unsigned int id,
-					unsigned int prop)
-{
-	int index;
-
-	if (!edev)
-		return -EINVAL;
-
-	/* Check whether the property is supported or not */
-	if (!is_extcon_property_supported(id, prop))
-		return -EINVAL;
-
-	/* Find the cable index of external connector by using id */
-	index = find_cable_index_by_id(edev, id);
-	if (index < 0)
-		return index;
-
-	return is_extcon_property_capability(edev, id, index, prop);
-}
-EXPORT_SYMBOL_GPL(extcon_get_property_capability);
-
 /**
  * extcon_set_property_capability() - Set the capability of the property
  *					for an external connector.
@@ -1465,16 +1408,6 @@ struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
 EXPORT_SYMBOL_GPL(extcon_find_edev_by_node);
 EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle);
 
-/**
- * extcon_get_edev_name() - Get the name of the extcon device.
- * @edev:	the extcon device
- */
-const char *extcon_get_edev_name(struct extcon_dev *edev)
-{
-	return !edev ? NULL : edev->name;
-}
-EXPORT_SYMBOL_GPL(extcon_get_edev_name);
-
 static int __init extcon_class_init(void)
 {
 	return create_extcon_class();
diff --git a/include/linux/extcon-provider.h b/include/linux/extcon-provider.h
index fa70945f4e6b..4ed3262f4386 100644
--- a/include/linux/extcon-provider.h
+++ b/include/linux/extcon-provider.h
@@ -55,9 +55,6 @@ int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
 int extcon_set_property(struct extcon_dev *edev, unsigned int id,
 				unsigned int prop,
 				union extcon_property_value prop_val);
-int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id,
-				unsigned int prop,
-				union extcon_property_value prop_val);
 int extcon_set_property_capability(struct extcon_dev *edev,
 				unsigned int id, unsigned int prop);
 
@@ -118,13 +115,6 @@ static inline int extcon_set_property(struct extcon_dev *edev, unsigned int id,
 	return 0;
 }
 
-static inline int extcon_set_property_sync(struct extcon_dev *edev,
-				unsigned int id, unsigned int prop,
-				union extcon_property_value prop_val)
-{
-	return 0;
-}
-
 static inline int extcon_set_property_capability(struct extcon_dev *edev,
 				unsigned int id, unsigned int prop)
 {
diff --git a/include/linux/extcon.h b/include/linux/extcon.h
index e596a0abcb27..eb55b25e74ae 100644
--- a/include/linux/extcon.h
+++ b/include/linux/extcon.h
@@ -175,19 +175,14 @@ struct extcon_dev;
 int extcon_get_state(struct extcon_dev *edev, unsigned int id);
 
 /*
- * Following APIs get the property of each external connector.
+ * Following API get the property of each external connector.
  * The 'id' argument indicates the defined external connector
  * and the 'prop' indicates the extcon property.
  *
- * And extcon_get_property_capability() get the capability of the property
- * for each external connector. They are used to get the capability of the
- * property of each external connector based on the id and property.
  */
 int extcon_get_property(struct extcon_dev *edev, unsigned int id,
 				unsigned int prop,
 				union extcon_property_value *prop_val);
-int extcon_get_property_capability(struct extcon_dev *edev,
-				unsigned int id, unsigned int prop);
 
 /*
  * Following APIs register the notifier block in order to detect
@@ -228,9 +223,6 @@ struct extcon_dev *extcon_find_edev_by_node(struct device_node *node);
 struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
 						     int index);
 
-/* Following API get the name of extcon device. */
-const char *extcon_get_edev_name(struct extcon_dev *edev);
-
 #else /* CONFIG_EXTCON */
 static inline int extcon_get_state(struct extcon_dev *edev, unsigned int id)
 {
@@ -244,12 +236,6 @@ static inline int extcon_get_property(struct extcon_dev *edev, unsigned int id,
 	return 0;
 }
 
-static inline int extcon_get_property_capability(struct extcon_dev *edev,
-				unsigned int id, unsigned int prop)
-{
-	return 0;
-}
-
 static inline int extcon_register_notifier(struct extcon_dev *edev,
 				unsigned int id, struct notifier_block *nb)
 {
@@ -312,10 +298,6 @@ static inline struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
 	return ERR_PTR(-ENODEV);
 }
 
-static inline const char *extcon_get_edev_name(struct extcon_dev *edev)
-{
-	return NULL;
-}
 #endif /* CONFIG_EXTCON */
 
 /*
-- 
2.47.0
Re: [PATCH] extcon: Remove deadcode
Posted by Dr. David Alan Gilbert 1 year, 2 months ago
* linux@treblig.org (linux@treblig.org) wrote:
> From: "Dr. David Alan Gilbert" <linux@treblig.org>
> 
> extcon_get_edev_name() has been unused since it was added in 2015 by
> commit 707d7550875a ("extcon: Add extcon_get_edev_name() API to get the
> extcon device name")
> 
> extcon_get_property_capability() has been unused since it was added
> in 2016 by
> commit ceaa98f442cf ("extcon: Add the support for the capability of each
> property")
> (It seems everyone just uses extcon_get_property)
> 
> extcon_set_property_sync() has been unused since it was added in 2016
> by
> commit a580982f0836 ("extcon: Add the synchronization extcon APIs to
> support the notification")
> Everyone seems to use the none _sync version, and there's one place
> where they just call sync after it.
> 
> Remove them.
> 
> Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>

Gentle ping please; no rush.

Dave

> ---
>  drivers/extcon/extcon.c         | 67 ---------------------------------
>  include/linux/extcon-provider.h | 10 -----
>  include/linux/extcon.h          | 20 +---------
>  3 files changed, 1 insertion(+), 96 deletions(-)
> 
> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
> index e7f55c021e56..41a31cc46004 100644
> --- a/drivers/extcon/extcon.c
> +++ b/drivers/extcon/extcon.c
> @@ -755,63 +755,6 @@ int extcon_set_property(struct extcon_dev *edev, unsigned int id,
>  }
>  EXPORT_SYMBOL_GPL(extcon_set_property);
>  
> -/**
> - * extcon_set_property_sync() - Set property of an external connector with sync.
> - * @edev:	the extcon device
> - * @id:		the unique id indicating an external connector
> - * @prop:	the property id indicating an extcon property
> - * @prop_val:	the pointer including the new value of extcon property
> - *
> - * Note that when setting the property value of external connector,
> - * the external connector should be attached. The each property should
> - * be included in the list of supported properties according to extcon type.
> - *
> - * Returns 0 if success or error number if fail.
> - */
> -int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id,
> -				unsigned int prop,
> -				union extcon_property_value prop_val)
> -{
> -	int ret;
> -
> -	ret = extcon_set_property(edev, id, prop, prop_val);
> -	if (ret < 0)
> -		return ret;
> -
> -	return extcon_sync(edev, id);
> -}
> -EXPORT_SYMBOL_GPL(extcon_set_property_sync);
> -
> -/**
> - * extcon_get_property_capability() - Get the capability of the property
> - *					for an external connector.
> - * @edev:	the extcon device
> - * @id:		the unique id indicating an external connector
> - * @prop:	the property id indicating an extcon property
> - *
> - * Returns 1 if the property is available or 0 if not available.
> - */
> -int extcon_get_property_capability(struct extcon_dev *edev, unsigned int id,
> -					unsigned int prop)
> -{
> -	int index;
> -
> -	if (!edev)
> -		return -EINVAL;
> -
> -	/* Check whether the property is supported or not */
> -	if (!is_extcon_property_supported(id, prop))
> -		return -EINVAL;
> -
> -	/* Find the cable index of external connector by using id */
> -	index = find_cable_index_by_id(edev, id);
> -	if (index < 0)
> -		return index;
> -
> -	return is_extcon_property_capability(edev, id, index, prop);
> -}
> -EXPORT_SYMBOL_GPL(extcon_get_property_capability);
> -
>  /**
>   * extcon_set_property_capability() - Set the capability of the property
>   *					for an external connector.
> @@ -1465,16 +1408,6 @@ struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
>  EXPORT_SYMBOL_GPL(extcon_find_edev_by_node);
>  EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle);
>  
> -/**
> - * extcon_get_edev_name() - Get the name of the extcon device.
> - * @edev:	the extcon device
> - */
> -const char *extcon_get_edev_name(struct extcon_dev *edev)
> -{
> -	return !edev ? NULL : edev->name;
> -}
> -EXPORT_SYMBOL_GPL(extcon_get_edev_name);
> -
>  static int __init extcon_class_init(void)
>  {
>  	return create_extcon_class();
> diff --git a/include/linux/extcon-provider.h b/include/linux/extcon-provider.h
> index fa70945f4e6b..4ed3262f4386 100644
> --- a/include/linux/extcon-provider.h
> +++ b/include/linux/extcon-provider.h
> @@ -55,9 +55,6 @@ int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
>  int extcon_set_property(struct extcon_dev *edev, unsigned int id,
>  				unsigned int prop,
>  				union extcon_property_value prop_val);
> -int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id,
> -				unsigned int prop,
> -				union extcon_property_value prop_val);
>  int extcon_set_property_capability(struct extcon_dev *edev,
>  				unsigned int id, unsigned int prop);
>  
> @@ -118,13 +115,6 @@ static inline int extcon_set_property(struct extcon_dev *edev, unsigned int id,
>  	return 0;
>  }
>  
> -static inline int extcon_set_property_sync(struct extcon_dev *edev,
> -				unsigned int id, unsigned int prop,
> -				union extcon_property_value prop_val)
> -{
> -	return 0;
> -}
> -
>  static inline int extcon_set_property_capability(struct extcon_dev *edev,
>  				unsigned int id, unsigned int prop)
>  {
> diff --git a/include/linux/extcon.h b/include/linux/extcon.h
> index e596a0abcb27..eb55b25e74ae 100644
> --- a/include/linux/extcon.h
> +++ b/include/linux/extcon.h
> @@ -175,19 +175,14 @@ struct extcon_dev;
>  int extcon_get_state(struct extcon_dev *edev, unsigned int id);
>  
>  /*
> - * Following APIs get the property of each external connector.
> + * Following API get the property of each external connector.
>   * The 'id' argument indicates the defined external connector
>   * and the 'prop' indicates the extcon property.
>   *
> - * And extcon_get_property_capability() get the capability of the property
> - * for each external connector. They are used to get the capability of the
> - * property of each external connector based on the id and property.
>   */
>  int extcon_get_property(struct extcon_dev *edev, unsigned int id,
>  				unsigned int prop,
>  				union extcon_property_value *prop_val);
> -int extcon_get_property_capability(struct extcon_dev *edev,
> -				unsigned int id, unsigned int prop);
>  
>  /*
>   * Following APIs register the notifier block in order to detect
> @@ -228,9 +223,6 @@ struct extcon_dev *extcon_find_edev_by_node(struct device_node *node);
>  struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
>  						     int index);
>  
> -/* Following API get the name of extcon device. */
> -const char *extcon_get_edev_name(struct extcon_dev *edev);
> -
>  #else /* CONFIG_EXTCON */
>  static inline int extcon_get_state(struct extcon_dev *edev, unsigned int id)
>  {
> @@ -244,12 +236,6 @@ static inline int extcon_get_property(struct extcon_dev *edev, unsigned int id,
>  	return 0;
>  }
>  
> -static inline int extcon_get_property_capability(struct extcon_dev *edev,
> -				unsigned int id, unsigned int prop)
> -{
> -	return 0;
> -}
> -
>  static inline int extcon_register_notifier(struct extcon_dev *edev,
>  				unsigned int id, struct notifier_block *nb)
>  {
> @@ -312,10 +298,6 @@ static inline struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
>  	return ERR_PTR(-ENODEV);
>  }
>  
> -static inline const char *extcon_get_edev_name(struct extcon_dev *edev)
> -{
> -	return NULL;
> -}
>  #endif /* CONFIG_EXTCON */
>  
>  /*
> -- 
> 2.47.0
> 
-- 
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
RE: Re: [PATCH] extcon: Remove deadcode
Posted by MyungJoo Ham 1 year, 2 months ago
From: Dr. David Alan Gilbert / linux@treblig.org
>* linux@treblig.org (linux@treblig.org) wrote:
>> From: "Dr. David Alan Gilbert" <linux@treblig.org>
>> 
>> extcon_get_edev_name() has been unused since it was added in 2015 by
>> commit 707d7550875a ("extcon: Add extcon_get_edev_name() API to get the
>> extcon device name")
>> 
>> extcon_get_property_capability() has been unused since it was added
>> in 2016 by
>> commit ceaa98f442cf ("extcon: Add the support for the capability of each
>> property")
>> (It seems everyone just uses extcon_get_property)
>> 
>> extcon_set_property_sync() has been unused since it was added in 2016
>> by
>> commit a580982f0836 ("extcon: Add the synchronization extcon APIs to
>> support the notification")
>> Everyone seems to use the none _sync version, and there's one place
>> where they just call sync after it.
>> 
>> Remove them.
>> 
>> Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
>
>Gentle ping please; no rush.
>
>Dave

It's not a dead code.

Example: https://github.com/diphons/D8G_Kernel_oxygen/blob/b0717c360f5485badf824fb51cdc8174e2e0a7cb/drivers/usb/dwc3/dwc3-msm.c#L2992

There are drivers (usually .ko) using them, usually Android mobile devices.

Cheers,
MyungJoo
Re: [PATCH] extcon: Remove deadcode
Posted by Dr. David Alan Gilbert 1 year, 2 months ago
* MyungJoo Ham (myungjoo.ham@samsung.com) wrote:
> From: Dr. David Alan Gilbert / linux@treblig.org
> >* linux@treblig.org (linux@treblig.org) wrote:
> >> From: "Dr. David Alan Gilbert" <linux@treblig.org>
> >> 
> >> extcon_get_edev_name() has been unused since it was added in 2015 by
> >> commit 707d7550875a ("extcon: Add extcon_get_edev_name() API to get the
> >> extcon device name")
> >> 
> >> extcon_get_property_capability() has been unused since it was added
> >> in 2016 by
> >> commit ceaa98f442cf ("extcon: Add the support for the capability of each
> >> property")
> >> (It seems everyone just uses extcon_get_property)
> >> 
> >> extcon_set_property_sync() has been unused since it was added in 2016
> >> by
> >> commit a580982f0836 ("extcon: Add the synchronization extcon APIs to
> >> support the notification")
> >> Everyone seems to use the none _sync version, and there's one place
> >> where they just call sync after it.
> >> 
> >> Remove them.
> >> 
> >> Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
> >
> >Gentle ping please; no rush.
> >
> >Dave

Thanks for the reply,

> It's not a dead code.
> 
> Example: https://github.com/diphons/D8G_Kernel_oxygen/blob/b0717c360f5485badf824fb51cdc8174e2e0a7cb/drivers/usb/dwc3/dwc3-msm.c#L2992
> 
> There are drivers (usually .ko) using them, usually Android mobile devices.

Ah hmm;  ok, I'll drop that.
Of course it would be great to get some of these upstreamed rather than us
having mysterious interfaces lying around for ~10 years!

Dave

> Cheers,
> MyungJoo
> 
-- 
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/