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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
> ---
>  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
> 



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux