Skip to contentSkip to conversation

mtd: bcm47xxsflash: use platform_(set|get)_drvdata

PATCH Superseded Rafał Miłecki 3 participants 4 messages Jan 16, 2017 Memory technology devices (MTD)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: bcm47xxsflash: use platform_(set|get)_drvdata

From: Rafał Miłecki <[email protected]>

We have generic place & helpers for storing platform driver data so there is no reason for using custom priv pointer.

This patch will be followed by cleaning struct bcma_sflash which will go through another tree where bcma development happens.

---
 drivers/mtd/devices/bcm47xxsflash.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/devices/bcm47xxsflash.c +3 -3
index 514be04..4decd8c 100644
@@ -284,7 +284,6 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
 	b47s = devm_kzalloc(dev, sizeof(*b47s), GFP_KERNEL);
 	if (!b47s)
 		return -ENOMEM;
-	sflash->priv = b47s;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
@@ -334,6 +333,8 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
 	b47s->size = sflash->size;
 	bcm47xxsflash_fill_mtd(b47s, &pdev->dev);
 
+	platform_set_drvdata(pdev, b47s);
+
 	err = mtd_device_parse_register(&b47s->mtd, probes, NULL, NULL, 0);
 	if (err) {
 		pr_err("Failed to register MTD device: %d\n", err);
@@ -349,8 +350,7 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
 
 static int bcm47xxsflash_bcma_remove(struct platform_device *pdev)
 {
-	struct bcma_sflash *sflash = dev_get_platdata(&pdev->dev);
-	struct bcm47xxsflash *b47s = sflash->priv;
+	struct bcm47xxsflash *b47s = platform_get_drvdata(pdev);
 
 	mtd_device_unregister(&b47s->mtd);
 	iounmap(b47s->window);
Signature · 1 line
2.10.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

We have generic place & helpers for storing platform driver data so there is no reason for using custom priv pointer.

This patch will be followed by cleaning struct bcma_sflash which will go through another tree where bcma development happens.

Quoted 36 lines
---
 drivers/mtd/devices/bcm47xxsflash.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/devices/bcm47xxsflash.c +3 -3
index 514be04..4decd8c 100644
@@ -284,7 +284,6 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
 	b47s = devm_kzalloc(dev, sizeof(*b47s), GFP_KERNEL);
 	if (!b47s)
 		return -ENOMEM;
-	sflash->priv = b47s;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
@@ -334,6 +333,8 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
 	b47s->size = sflash->size;
 	bcm47xxsflash_fill_mtd(b47s, &pdev->dev);
 
+	platform_set_drvdata(pdev, b47s);
+
 	err = mtd_device_parse_register(&b47s->mtd, probes, NULL, NULL, 0);
 	if (err) {
 		pr_err("Failed to register MTD device: %d\n", err);
@@ -349,8 +350,7 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
 
 static int bcm47xxsflash_bcma_remove(struct platform_device *pdev)
 {
-	struct bcma_sflash *sflash = dev_get_platdata(&pdev->dev);
-	struct bcm47xxsflash *b47s = sflash->priv;
+	struct bcm47xxsflash *b47s = platform_get_drvdata(pdev);
 
 	mtd_device_unregister(&b47s->mtd);
 	iounmap(b47s->window);
Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw
In reply to Rafał Miłecki
Quoted 7 lines · On Mon, 16 Jan 2017 14:04:09 +0100 Rafał Miłecki <[email protected]> wrote:

From: Rafał Miłecki <[email protected]>

We have generic place & helpers for storing platform driver data so there is no reason for using custom priv pointer.

This patch will be followed by cleaning struct bcma_sflash which will go through another tree where bcma development happens.

Why not removing the ->priv field from the bcma_sflash struct definition in this patch?
If it needs to go through a different tree we can ack the patch and let the other maintainer(s) take the whole series.

Note that ->mtd seems to be unused, and should probably be removed as well (in a separate patch of course). But I guess you already know that.

Quoted 37 lines
---
 drivers/mtd/devices/bcm47xxsflash.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/devices/bcm47xxsflash.c +3 -3
index 514be04..4decd8c 100644
@@ -284,7 +284,6 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
 	b47s = devm_kzalloc(dev, sizeof(*b47s), GFP_KERNEL);
 	if (!b47s)
 		return -ENOMEM;
-	sflash->priv = b47s;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
@@ -334,6 +333,8 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
 	b47s->size = sflash->size;
 	bcm47xxsflash_fill_mtd(b47s, &pdev->dev);
 
+	platform_set_drvdata(pdev, b47s);
+
 	err = mtd_device_parse_register(&b47s->mtd, probes, NULL, NULL, 0);
 	if (err) {
 		pr_err("Failed to register MTD device: %d\n", err);
@@ -349,8 +350,7 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
 
 static int bcm47xxsflash_bcma_remove(struct platform_device *pdev)
 {
-	struct bcma_sflash *sflash = dev_get_platdata(&pdev->dev);
-	struct bcm47xxsflash *b47s = sflash->priv;
+	struct bcm47xxsflash *b47s = platform_get_drvdata(pdev);
 
 	mtd_device_unregister(&b47s->mtd);
 	iounmap(b47s->window);
#3 lore raw
Quoted 8 lines · Boris Brezillon
Quoted 5 lines · On Mon, 16 Jan 2017 14:04:09 +0100 Rafał Miłecki <[email protected]> wrote:

From: Rafał Miłecki <[email protected]>

We have generic place & helpers for storing platform driver data so there is no reason for using custom priv pointer.

Quoted 7 lines
Quoted 2 lines

This patch will be followed by cleaning struct bcma_sflash which will go through another tree where bcma development happens.

Why not removing the ->priv field from the bcma_sflash struct definition in this patch?
If it needs to go through a different tree we can ack the patch and let the other maintainer(s) take the whole series.

I can try that. As this will be more mtd-focused, I guess I should rather get Kalle's ack. I'll work on that.

Signature · 1 line
Rafał