diff mbox series

[linux,dev-4.13,4/4] fsi/occ: Don't set driver data late

Message ID 20180518013500.18005-4-benh@kernel.crashing.org
State Superseded, archived
Headers show
Series [linux,dev-4.13,1/4] fsi/occ: Add retries on SBE errors | expand

Commit Message

Benjamin Herrenschmidt May 18, 2018, 1:35 a.m. UTC
Until now, the OCC driver was setting the driver data after
registering the character device and the hwmon device.

This might have been intentional, as doing so makes the initial
probe of the OCC by the hwmon device fail while the data is NULL
(provided you are lucky and the hwmon driver doesn't get bound
asynchronously). That failure used to be necessary, otherwise
the driver would try to access the SBE fifo at a time when it's
not ready, causing all sort of problems.

The new SBE fifo driver is much more robust and will return an
appropriate error code, so that (fragile) tweak is no longer
necessary.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/fsi/fsi-occ.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Andrew Jeffery May 21, 2018, 5:44 a.m. UTC | #1
On Fri, 18 May 2018, at 11:05, Benjamin Herrenschmidt wrote:
> Until now, the OCC driver was setting the driver data after
> registering the character device and the hwmon device.
> 
> This might have been intentional, as doing so makes the initial
> probe of the OCC by the hwmon device fail while the data is NULL
> (provided you are lucky and the hwmon driver doesn't get bound
> asynchronously). That failure used to be necessary, otherwise
> the driver would try to access the SBE fifo at a time when it's
> not ready, causing all sort of problems.
> 
> The new SBE fifo driver is much more robust and will return an
> appropriate error code, so that (fragile) tweak is no longer
> necessary.
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

+1000

Reviewed-by: Andrew Jeffery <andrew@aj.id.au>

> ---
>  drivers/fsi/fsi-occ.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/fsi/fsi-occ.c b/drivers/fsi/fsi-occ.c
> index 4bda1b435ecb..170fd8020829 100644
> --- a/drivers/fsi/fsi-occ.c
> +++ b/drivers/fsi/fsi-occ.c
> @@ -836,6 +836,8 @@ static int occ_probe(struct platform_device *pdev)
>  		occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX, GFP_KERNEL);
>  	}
>  
> +	platform_set_drvdata(pdev, occ);
> +
>  	snprintf(occ->name, sizeof(occ->name), "occ%d", occ->idx);
>  	occ->mdev.fops = &occ_fops;
>  	occ->mdev.minor = MISC_DYNAMIC_MINOR;
> @@ -854,8 +856,6 @@ static int occ_probe(struct platform_device *pdev)
>  	if (!hwmon_dev)
>  		dev_warn(dev, "failed to create hwmon device\n");
>  
> -	platform_set_drvdata(pdev, occ);
> -
>  	return 0;
>  }
>  
> -- 
> 2.17.0
>
diff mbox series

Patch

diff --git a/drivers/fsi/fsi-occ.c b/drivers/fsi/fsi-occ.c
index 4bda1b435ecb..170fd8020829 100644
--- a/drivers/fsi/fsi-occ.c
+++ b/drivers/fsi/fsi-occ.c
@@ -836,6 +836,8 @@  static int occ_probe(struct platform_device *pdev)
 		occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX, GFP_KERNEL);
 	}
 
+	platform_set_drvdata(pdev, occ);
+
 	snprintf(occ->name, sizeof(occ->name), "occ%d", occ->idx);
 	occ->mdev.fops = &occ_fops;
 	occ->mdev.minor = MISC_DYNAMIC_MINOR;
@@ -854,8 +856,6 @@  static int occ_probe(struct platform_device *pdev)
 	if (!hwmon_dev)
 		dev_warn(dev, "failed to create hwmon device\n");
 
-	platform_set_drvdata(pdev, occ);
-
 	return 0;
 }