[PATCH linux dev-4.7 08/12] mtd: spi-nor: aspeed: introduce a device under aspeed_smc_controller

Cédric Le Goater clg at kaod.org
Fri Oct 14 23:38:00 AEDT 2016


This will be useful for readability and also logging.

Signed-off-by: Cédric Le Goater <clg at kaod.org>
---
 drivers/mtd/spi-nor/aspeed-smc.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/spi-nor/aspeed-smc.c b/drivers/mtd/spi-nor/aspeed-smc.c
index b22e07d3ef32..86a9ec60fd7a 100644
--- a/drivers/mtd/spi-nor/aspeed-smc.c
+++ b/drivers/mtd/spi-nor/aspeed-smc.c
@@ -214,6 +214,8 @@ struct aspeed_smc_per_chip {
 };
 
 struct aspeed_smc_controller {
+	struct device *dev;
+
 	struct mutex mutex;			/* controller access mutex */
 	const struct aspeed_smc_info *info;	/* type info of controller */
 	void __iomem *regs;			/* controller registers */
@@ -436,7 +438,7 @@ static void __iomem *window_start(struct aspeed_smc_controller *controller,
 	return controller->windows + offset;
 }
 
-static int aspeed_smc_probe(struct platform_device *dev)
+static int aspeed_smc_probe(struct platform_device *pdev)
 {
 	struct aspeed_smc_controller *controller;
 	const struct of_device_id *match;
@@ -446,29 +448,31 @@ static int aspeed_smc_probe(struct platform_device *dev)
 	int err = 0;
 	unsigned int n;
 
-	match = of_match_device(aspeed_smc_matches, &dev->dev);
+	match = of_match_device(aspeed_smc_matches, &pdev->dev);
 	if (!match || !match->data)
 		return -ENODEV;
 	info = match->data;
 
-	controller = devm_kzalloc(&dev->dev, sizeof(*controller) +
+	controller = devm_kzalloc(&pdev->dev, sizeof(*controller) +
 		info->nce * sizeof(controller->chips[0]), GFP_KERNEL);
 	if (!controller)
 		return -ENOMEM;
 	controller->info = info;
 	mutex_init(&controller->mutex);
-	platform_set_drvdata(dev, controller);
+	platform_set_drvdata(pdev, controller);
 
-	r = platform_get_resource(dev, IORESOURCE_MEM, 0);
-	controller->regs = devm_ioremap_resource(&dev->dev, r);
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	controller->regs = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(controller->regs))
 		return PTR_ERR(controller->regs);
 
-	r = platform_get_resource(dev, IORESOURCE_MEM, 1);
-	controller->windows = devm_ioremap_resource(&dev->dev, r);
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	controller->windows = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(controller->windows))
 		return PTR_ERR(controller->windows);
 
+	controller->dev = &pdev->dev;
+
 	/* The pinmux or bootloader will disable legacy mode. */
 
 	/*
@@ -476,7 +480,7 @@ static int aspeed_smc_probe(struct platform_device *dev)
 	 * is shared by the host.
 	 */
 
-	for_each_available_child_of_node(dev->dev.of_node, child) {
+	for_each_available_child_of_node(controller->dev->of_node, child) {
 		struct platform_device *cdev;
 		struct aspeed_smc_per_chip *chip;
 		u32 reg;
@@ -494,7 +498,8 @@ static int aspeed_smc_probe(struct platform_device *dev)
 		 * The creating the device node for the child here allows its
 		 * use for error reporting via dev_err below.
 		 */
-		cdev = of_platform_device_create_or_find(child, &dev->dev);
+		cdev = of_platform_device_create_or_find(child,
+							 controller->dev);
 		if (!cdev)
 			continue;
 
@@ -509,7 +514,7 @@ static int aspeed_smc_probe(struct platform_device *dev)
 				n, dev_name(controller->chips[n]->nor.dev));
 			continue;
 		}
-		chip = devm_kzalloc(&dev->dev, sizeof(*chip), GFP_KERNEL);
+		chip = devm_kzalloc(controller->dev, sizeof(*chip), GFP_KERNEL);
 		if (!chip)
 			continue;
 
@@ -533,7 +538,8 @@ static int aspeed_smc_probe(struct platform_device *dev)
 		 */
 		mutex_lock(&controller->mutex);
 		reg = readl(controller->regs + TYPE_SETTING_REG);
-		dev_dbg(&dev->dev, "flash type and setting was %08x\n", reg);
+		dev_dbg(controller->dev, "flash type and setting was %08x\n",
+			reg);
 		reg |= 1 << (info->we0 + n); /* WEn */
 		if (info->hastype) {
 			reg &= ~(3 << (n * 2));
-- 
2.7.4



More information about the openbmc mailing list