mbox series

[v2,0/2] Fix dwapb gpio snps,nr-gpios property handling

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

Message

Damien Le Moal Nov. 19, 2020, 6:09 a.m. UTC
Two patches in this series to fix handling of the "snps,nr-gpios"
property of the Synopsis DW apb gpio controller. Parsing of this
deprecated property triggers an device tree parsing error in
of_link_to_suppliers(). This is fixed in patch 1.

Patch 2 adds a warning message in the dwapb gpio driver to signal that a
device tree still uses this deprecated property.

The first patch is extracted from the series "RISC-V Kendryte K210
support improvments".

Damien Le Moal (2):
  of: Fix property supplier parsing
  gpio: dwapb: warn about deprecated property use

 drivers/gpio/gpio-dwapb.c | 14 +++++++++++---
 drivers/of/property.c     | 16 +++++++++++++++-
 2 files changed, 26 insertions(+), 4 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
>