diff mbox series

[v2,2/2] gpio: dwapb: warn about deprecated property use

Message ID 20201119060921.311747-3-damien.lemoal@wdc.com
State New
Headers show
Series Fix dwapb gpio snps,nr-gpios property handling | expand

Commit Message

Damien Le Moal Nov. 19, 2020, 6:09 a.m. UTC
In dwapb_gpio_get_pdata(), add a warning to signal the fact that a
device tree is using the deprecated "snps,nr-gpios" property instead of
the standard "ngpios" property.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/gpio/gpio-dwapb.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Comments

Serge Semin Nov. 25, 2020, 9 p.m. UTC | #1
Hello Damien

On Thu, Nov 19, 2020 at 03:09:21PM +0900, Damien Le Moal wrote:
> In dwapb_gpio_get_pdata(), add a warning to signal the fact that a

> device tree is using the deprecated "snps,nr-gpios" property instead of

> the standard "ngpios" property.


Instead of printing the warning from the driver I'd suggest to do that
from the quirk. That'd be better from maintainability point of view.
So when all the snps,nr-gpios properties are removed from dts'es,
we'll need to discard the quirk only. Otherwise if the warning and
quirk are separated, we may forget to remove the later.

-Sergey

> 

> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>

> ---

>  drivers/gpio/gpio-dwapb.c | 14 +++++++++++---

>  1 file changed, 11 insertions(+), 3 deletions(-)

> 

> diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c

> index 2a9046c0fb16..242b058e6630 100644

> --- a/drivers/gpio/gpio-dwapb.c

> +++ b/drivers/gpio/gpio-dwapb.c

> @@ -553,7 +553,7 @@ static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev)

>  	struct dwapb_platform_data *pdata;

>  	struct dwapb_port_property *pp;

>  	int nports;

> -	int i;

> +	int i, ret;

>  

>  	nports = device_get_child_node_count(dev);

>  	if (nports == 0)

> @@ -582,8 +582,16 @@ static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev)

>  			return ERR_PTR(-EINVAL);

>  		}

>  

> -		if (fwnode_property_read_u32(fwnode, "ngpios", &pp->ngpio) &&

> -		    fwnode_property_read_u32(fwnode, "snps,nr-gpios", &pp->ngpio)) {

> +		ret = fwnode_property_read_u32(fwnode, "ngpios", &pp->ngpio);

> +		if (ret) {

> +			ret = fwnode_property_read_u32(fwnode, "snps,nr-gpios",

> +						       &pp->ngpio);

> +			if (!ret) {

> +				dev_warn(dev,

> +					 "deprecated \"snps,nr-gpios\" property, update device tree to use \"ngpios\".\n");

> +			}

> +		}

> +		if (ret) {

>  			dev_info(dev,

>  				 "failed to get number of gpios for port%d\n",

>  				 i);

> -- 

> 2.28.0

>
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
index 2a9046c0fb16..242b058e6630 100644
--- a/drivers/gpio/gpio-dwapb.c
+++ b/drivers/gpio/gpio-dwapb.c
@@ -553,7 +553,7 @@  static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev)
 	struct dwapb_platform_data *pdata;
 	struct dwapb_port_property *pp;
 	int nports;
-	int i;
+	int i, ret;
 
 	nports = device_get_child_node_count(dev);
 	if (nports == 0)
@@ -582,8 +582,16 @@  static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev)
 			return ERR_PTR(-EINVAL);
 		}
 
-		if (fwnode_property_read_u32(fwnode, "ngpios", &pp->ngpio) &&
-		    fwnode_property_read_u32(fwnode, "snps,nr-gpios", &pp->ngpio)) {
+		ret = fwnode_property_read_u32(fwnode, "ngpios", &pp->ngpio);
+		if (ret) {
+			ret = fwnode_property_read_u32(fwnode, "snps,nr-gpios",
+						       &pp->ngpio);
+			if (!ret) {
+				dev_warn(dev,
+					 "deprecated \"snps,nr-gpios\" property, update device tree to use \"ngpios\".\n");
+			}
+		}
+		if (ret) {
 			dev_info(dev,
 				 "failed to get number of gpios for port%d\n",
 				 i);