Skip to contentSkip to conversation

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

PATCH Applied Rafał Miłecki 4 participants 4 messages Jan 16, 2017 – Feb 8, 2017

Subsystems (2)
lore
Share & tools
lore

Rafał Miłecki

author maintainer
#0 lore raw

PATCH v2 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 allows cleaning up struct bcma_sflash from unneeded fields.

---
Kalle: This is mtd focused patch, so I guess it should go through mtd tree. Do
you find bcma change important enough to care to Ack it? :)

---
 drivers/mtd/devices/bcm47xxsflash.c         | 6 +++---
 include/linux/bcma/bcma_driver_chipcommon.h | 3 ---
 2 files changed, 3 insertions(+), 6 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);
include/linux/bcma/bcma_driver_chipcommon.h +0 -3
index b20e3d5..2f1c690 100644
@@ -593,9 +593,6 @@ struct bcma_sflash {
 	u32 blocksize;
 	u16 numblocks;
 	u32 size;
-
-	struct mtd_info *mtd;
-	void *priv;
 };
 #endif
 
Signature · 1 line
2.10.1
Acked-by on v2 1/1
#1 lore raw
Quoted 10 lines · Rafa=C5=82 Mi=C5=82ecki <[email protected]> writes:

From: Rafa=C5=82 Mi=C5=82ecki <[email protected]>

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

This allows cleaning up struct bcma_sflash from unneeded fields.

---
Kalle: This is mtd focused patch, so I guess it should go through mtd tre=

e. Do

Quoted 1 line

you find bcma change important enough to care to Ack it? :)

Sure :)

Feel free to take the patch via mtd tree, I'm not expecting to see any conflicts with this patch. For the bcma part:

--=20
Kalle Valo

Acked-by on v2 1/1
#2 lore raw
In reply to Rafał Miłecki
Quoted 8 lines · On Mon, 16 Jan 2017 17:28:18 +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 allows cleaning up struct bcma_sflash from unneeded fields.

Quoted 53 lines

---
Kalle: This is mtd focused patch, so I guess it should go through mtd tree. Do
you find bcma change important enough to care to Ack it? :)

---
 drivers/mtd/devices/bcm47xxsflash.c         | 6 +++---
 include/linux/bcma/bcma_driver_chipcommon.h | 3 ---
 2 files changed, 3 insertions(+), 6 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);
include/linux/bcma/bcma_driver_chipcommon.h +0 -3
index b20e3d5..2f1c690 100644
@@ -593,9 +593,6 @@ struct bcma_sflash {
 	u32 blocksize;
 	u16 numblocks;
 	u32 size;
-
-	struct mtd_info *mtd;
-	void *priv;
 };
 #endif
 
Applied
#3 lore raw
In reply to Rafał Miłecki
Quoted 11 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 allows cleaning up struct bcma_sflash from unneeded fields.

---
Kalle: This is mtd focused patch, so I guess it should go through mtd tree. Do
you find bcma change important enough to care to Ack it? :)

Applied to l2-mtd.git.