diff mbox

memory: omap-gpmc: Make 'bank-width' property optional

Message ID 20171103095706.ws5itsccxe6pwv7d@lenoch (mailing list archive)
State New, archived
Headers show

Commit Message

Ladislav Michl Nov. 3, 2017, 9:57 a.m. UTC
Value of device_width is previously read from documented
'gpmc,device-width' property. For now leave 'bank-width'
as a fallback for older DT blobs.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
---
 drivers/memory/omap-gpmc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Roger Quadros Nov. 3, 2017, 12:15 p.m. UTC | #1
On 03/11/17 11:57, Ladislav Michl wrote:
> Value of device_width is previously read from documented
> 'gpmc,device-width' property. For now leave 'bank-width'
> as a fallback for older DT blobs.

bank-width is mandatory for NOR devices only.

> 
> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
> ---
>  drivers/memory/omap-gpmc.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
> index 24b584b74d84..3dc9706e1f15 100644
> --- a/drivers/memory/omap-gpmc.c
> +++ b/drivers/memory/omap-gpmc.c
> @@ -2152,10 +2152,15 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
>  		gpmc_configure(GPMC_CONFIG_WP, 0);
>  		gpmc_s.device_nand = true;
>  	} else {
> +		/*
> +		 * Some older DT blobs are missing device-width property,
> +		 * so try to read bank-width and fail if neither works.
> +		 */

I'd get rid of the above comment and rather say, NOR devices use bank-width
to specify device width.

>  		ret = of_property_read_u32(child, "bank-width",
>  					   &gpmc_s.device_width);
> -		if (ret < 0) {
> -			dev_err(&pdev->dev, "%pOF has no 'bank-width' property\n",
> +		if (ret < 0 && !gpmc_s.device_width) {
> +			dev_err(&pdev->dev,
> +				"%pOF has no 'gpmc,device-width' property\n",
>  				child);
>  			goto err;
>  		}
> 

I'm ok with the approach.
We could also update the DT binding documentation to say
"'gpmc,device-width' is mandatory if device is not NOR or NAND type.
For NOR, bank-width is used and for NAND nand-bus-width is used to figure
out the device-width"

And update the patch commit log accordingly.
diff mbox

Patch

diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
index 24b584b74d84..3dc9706e1f15 100644
--- a/drivers/memory/omap-gpmc.c
+++ b/drivers/memory/omap-gpmc.c
@@ -2152,10 +2152,15 @@  static int gpmc_probe_generic_child(struct platform_device *pdev,
 		gpmc_configure(GPMC_CONFIG_WP, 0);
 		gpmc_s.device_nand = true;
 	} else {
+		/*
+		 * Some older DT blobs are missing device-width property,
+		 * so try to read bank-width and fail if neither works.
+		 */
 		ret = of_property_read_u32(child, "bank-width",
 					   &gpmc_s.device_width);
-		if (ret < 0) {
-			dev_err(&pdev->dev, "%pOF has no 'bank-width' property\n",
+		if (ret < 0 && !gpmc_s.device_width) {
+			dev_err(&pdev->dev,
+				"%pOF has no 'gpmc,device-width' property\n",
 				child);
 			goto err;
 		}