2017-09-21 11:29:04

by Suniel Mahesh

[permalink] [raw]
Subject: [PATCH] staging: ccree: Convert to platform_{get,set}_drvdata()

From: Suniel Mahesh <[email protected]>

Platform devices are expected to use wrapper functions,
platform_{get,set}_drvdata() with platform_device as argument,
for getting and setting the driver data. dev_{get,set}_drvdata()
are using &plat_dev->dev.
For wrapper functions we can directly pass a struct platform_device.

dev_set_drvdata() is redundant and therefore removed. The driver core
clears the driver data to NULL after device_release or on probe failure.

Signed-off-by: Suniel Mahesh <[email protected]>
---
Note:
- Patch was tested and built(ARCH=arm) on next-20170921.
No build issues reported, however it was not tested on
real hardware.
---
drivers/staging/ccree/ssi_driver.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index 6d16220..53b4a8c 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -236,7 +236,7 @@ static int init_cc_resources(struct platform_device *plat_dev)
rc = -ENOMEM;
goto post_drvdata_err;
}
- dev_set_drvdata(&plat_dev->dev, new_drvdata);
+ platform_set_drvdata(plat_dev, new_drvdata);
new_drvdata->plat_dev = plat_dev;

new_drvdata->clk = of_clk_get(np, 0);
@@ -415,7 +415,6 @@ static int init_cc_resources(struct platform_device *plat_dev)
cc_clk_off(new_drvdata);
post_drvdata_err:
SSI_LOG_ERR("ccree init error occurred!\n");
- dev_set_drvdata(&plat_dev->dev, NULL);
return rc;
}

@@ -429,7 +428,7 @@ void fini_cc_regs(struct ssi_drvdata *drvdata)
static void cleanup_cc_resources(struct platform_device *plat_dev)
{
struct ssi_drvdata *drvdata =
- (struct ssi_drvdata *)dev_get_drvdata(&plat_dev->dev);
+ (struct ssi_drvdata *)platform_get_drvdata(plat_dev);

ssi_aead_free(drvdata);
ssi_hash_free(drvdata);
@@ -445,7 +444,6 @@ static void cleanup_cc_resources(struct platform_device *plat_dev)
#endif
fini_cc_regs(drvdata);
cc_clk_off(drvdata);
- dev_set_drvdata(&plat_dev->dev, NULL);
}

int cc_clk_on(struct ssi_drvdata *drvdata)
--
1.9.1


2017-09-21 12:17:42

by Suniel Mahesh

[permalink] [raw]
Subject: [PATCH v2] staging: ccree: Convert to platform_{get,set}_drvdata()

From: Suniel Mahesh <[email protected]>

Platform devices are expected to use wrapper functions,
platform_{get,set}_drvdata() with platform_device as argument,
for getting and setting the driver data. dev_{get,set}_drvdata()
are using &plat_dev->dev.
For wrapper functions we can directly pass a struct platform_device.

dev_set_drvdata() is redundant and therefore removed. The driver core
clears the driver data to NULL after device_release or on probe failure.

Signed-off-by: Suniel Mahesh <[email protected]>
---
Changes for v2:
- Rebased on top of staging-testing.
---
Note:
- Patch was tested and built(ARCH=arm) on next-20170921.
No build issues reported, however it was not tested on
real hardware.
---
drivers/staging/ccree/ssi_driver.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index 6d16220..53b4a8c 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -236,7 +236,7 @@ static int init_cc_resources(struct platform_device *plat_dev)
rc = -ENOMEM;
goto post_drvdata_err;
}
- dev_set_drvdata(&plat_dev->dev, new_drvdata);
+ platform_set_drvdata(plat_dev, new_drvdata);
new_drvdata->plat_dev = plat_dev;

new_drvdata->clk = of_clk_get(np, 0);
@@ -415,7 +415,6 @@ static int init_cc_resources(struct platform_device *plat_dev)
cc_clk_off(new_drvdata);
post_drvdata_err:
SSI_LOG_ERR("ccree init error occurred!\n");
- dev_set_drvdata(&plat_dev->dev, NULL);
return rc;
}

@@ -429,7 +428,7 @@ void fini_cc_regs(struct ssi_drvdata *drvdata)
static void cleanup_cc_resources(struct platform_device *plat_dev)
{
struct ssi_drvdata *drvdata =
- (struct ssi_drvdata *)dev_get_drvdata(&plat_dev->dev);
+ (struct ssi_drvdata *)platform_get_drvdata(plat_dev);

ssi_aead_free(drvdata);
ssi_hash_free(drvdata);
@@ -445,7 +444,6 @@ static void cleanup_cc_resources(struct platform_device *plat_dev)
#endif
fini_cc_regs(drvdata);
cc_clk_off(drvdata);
- dev_set_drvdata(&plat_dev->dev, NULL);
}

int cc_clk_on(struct ssi_drvdata *drvdata)
--
1.9.1

2017-10-03 16:29:11

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v2] staging: ccree: Convert to platform_{get,set}_drvdata()

On Thu, Sep 21, 2017 at 05:47:42PM +0530, [email protected] wrote:
> From: Suniel Mahesh <[email protected]>
>
> Platform devices are expected to use wrapper functions,
> platform_{get,set}_drvdata() with platform_device as argument,
> for getting and setting the driver data. dev_{get,set}_drvdata()
> are using &plat_dev->dev.
> For wrapper functions we can directly pass a struct platform_device.
>
> dev_set_drvdata() is redundant and therefore removed. The driver core
> clears the driver data to NULL after device_release or on probe failure.
>
> Signed-off-by: Suniel Mahesh <[email protected]>
> ---
> Changes for v2:
> - Rebased on top of staging-testing.

Can you rebase again, this still does not apply :(

2017-10-04 07:45:37

by Suniel Mahesh

[permalink] [raw]
Subject: [PATCH v3] staging: ccree: Convert to platform_{get,set}_drvdata()

From: Suniel Mahesh <[email protected]>

Platform devices are expected to use wrapper functions,
platform_{get,set}_drvdata() with platform_device as argument,
for getting and setting the driver data. dev_{get,set}_drvdata()
are using &plat_dev->dev.
For wrapper functions we can directly pass a struct platform_device.

dev_set_drvdata() is redundant and therefore removed. The driver core
clears the driver data to NULL after device_release or on probe failure.

Signed-off-by: Suniel Mahesh <[email protected]>
---
Changes for v3:
- Rebased on top of staging-testing as suggested by Greg KH.
- Patch was tested and built(ARCH=arm) on staging-testing.
---
Changes for v2:
- Rebased on top of staging-testing.
---
Note:
- No build issues reported, however it was not tested on
real hardware.
---
drivers/staging/ccree/ssi_driver.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index 795a087..5f03c25 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -215,7 +215,7 @@ static int init_cc_resources(struct platform_device *plat_dev)
rc = -ENOMEM;
goto post_drvdata_err;
}
- dev_set_drvdata(dev, new_drvdata);
+ platform_set_drvdata(plat_dev, new_drvdata);
new_drvdata->plat_dev = plat_dev;

new_drvdata->clk = of_clk_get(np, 0);
@@ -393,7 +393,6 @@ static int init_cc_resources(struct platform_device *plat_dev)
cc_clk_off(new_drvdata);
post_drvdata_err:
dev_err(dev, "ccree init error occurred!\n");
- dev_set_drvdata(dev, NULL);
return rc;
}

@@ -407,7 +406,7 @@ void fini_cc_regs(struct ssi_drvdata *drvdata)
static void cleanup_cc_resources(struct platform_device *plat_dev)
{
struct ssi_drvdata *drvdata =
- (struct ssi_drvdata *)dev_get_drvdata(&plat_dev->dev);
+ (struct ssi_drvdata *)platform_get_drvdata(plat_dev);

ssi_aead_free(drvdata);
ssi_hash_free(drvdata);
@@ -423,7 +422,6 @@ static void cleanup_cc_resources(struct platform_device *plat_dev)
#endif
fini_cc_regs(drvdata);
cc_clk_off(drvdata);
- dev_set_drvdata(&plat_dev->dev, NULL);
}

int cc_clk_on(struct ssi_drvdata *drvdata)
--
1.9.1