From 8ae754ebd5edffa0b2a2bafa4879a9ace01d5477 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 5 Nov 2012 16:10:29 +0100 Subject: mfd: ab8500-core: Remove unused ab8500-gpio IRQ ranges The IRQ ranges provided in ab8500-core to be passed on to the ab8500-gpio driver are not only redundant, but they are also causing a warning in the boot log. These IRQ ranges, like any other MFD related IRQ resource are passed though MFD core for automatic conversion to virtual IRQs; however, MFD core does not support IRQ mapping of IRQ ranges. Let's just remove them. Acked-by: Arnd Bergmann Tested-by: Linus Walleij Signed-off-by: Lee Jones Signed-off-by: Samuel Ortiz --- drivers/mfd/ab8500-core.c | 36 ------------------------------------ 1 file changed, 36 deletions(-) (limited to 'drivers/mfd/ab8500-core.c') diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index 1667c77..e7197fe 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c @@ -591,38 +591,6 @@ int ab8500_suspend(struct ab8500 *ab8500) return 0; } -/* AB8500 GPIO Resources */ -static struct resource __devinitdata ab8500_gpio_resources[] = { - { - .name = "GPIO_INT6", - .start = AB8500_INT_GPIO6R, - .end = AB8500_INT_GPIO41F, - .flags = IORESOURCE_IRQ, - } -}; - -/* AB9540 GPIO Resources */ -static struct resource __devinitdata ab9540_gpio_resources[] = { - { - .name = "GPIO_INT6", - .start = AB8500_INT_GPIO6R, - .end = AB8500_INT_GPIO41F, - .flags = IORESOURCE_IRQ, - }, - { - .name = "GPIO_INT14", - .start = AB9540_INT_GPIO50R, - .end = AB9540_INT_GPIO54R, - .flags = IORESOURCE_IRQ, - }, - { - .name = "GPIO_INT15", - .start = AB9540_INT_GPIO50F, - .end = AB9540_INT_GPIO54F, - .flags = IORESOURCE_IRQ, - } -}; - static struct resource __devinitdata ab8500_gpadc_resources[] = { { .name = "HW_CONV_END", @@ -1065,8 +1033,6 @@ static struct mfd_cell __devinitdata ab8500_devs[] = { { .name = "ab8500-gpio", .of_compatible = "stericsson,ab8500-gpio", - .num_resources = ARRAY_SIZE(ab8500_gpio_resources), - .resources = ab8500_gpio_resources, }, { .name = "ab8500-usb", @@ -1083,8 +1049,6 @@ static struct mfd_cell __devinitdata ab8500_devs[] = { static struct mfd_cell __devinitdata ab9540_devs[] = { { .name = "ab8500-gpio", - .num_resources = ARRAY_SIZE(ab9540_gpio_resources), - .resources = ab9540_gpio_resources, }, { .name = "ab9540-usb", -- cgit v1.1 From 8c4203cb5814f53169dc4ff084a65dcf509b6f60 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 5 Nov 2012 16:10:35 +0100 Subject: mfd: ab8500-core: Use devm_* memory/IRQ and allocation/free routines It is better to use devm_* calls, as they allow for easier and more automatic clean-up. Resources are device allocated, so when a device is freed, so are all associated resources. Acked-by: Linus Walleij Signed-off-by: Lee Jones Signed-off-by: Samuel Ortiz --- drivers/mfd/ab8500-core.c | 62 ++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 38 deletions(-) (limited to 'drivers/mfd/ab8500-core.c') diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index e7197fe..2a69dc2 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c @@ -1233,7 +1233,7 @@ static int __devinit ab8500_probe(struct platform_device *pdev) int i; u8 value; - ab8500 = kzalloc(sizeof *ab8500, GFP_KERNEL); + ab8500 = devm_kzalloc(&pdev->dev, sizeof *ab8500, GFP_KERNEL); if (!ab8500) return -ENOMEM; @@ -1243,10 +1243,8 @@ static int __devinit ab8500_probe(struct platform_device *pdev) ab8500->dev = &pdev->dev; resource = platform_get_resource(pdev, IORESOURCE_IRQ, 0); - if (!resource) { - ret = -ENODEV; - goto out_free_ab8500; - } + if (!resource) + return -ENODEV; ab8500->irq = resource->start; @@ -1269,7 +1267,7 @@ static int __devinit ab8500_probe(struct platform_device *pdev) ret = get_register_interruptible(ab8500, AB8500_MISC, AB8500_IC_NAME_REG, &value); if (ret < 0) - goto out_free_ab8500; + return ret; ab8500->version = value; } @@ -1277,7 +1275,7 @@ static int __devinit ab8500_probe(struct platform_device *pdev) ret = get_register_interruptible(ab8500, AB8500_MISC, AB8500_REV_REG, &value); if (ret < 0) - goto out_free_ab8500; + return ret; ab8500->chip_id = value; @@ -1294,14 +1292,13 @@ static int __devinit ab8500_probe(struct platform_device *pdev) ab8500->mask_size = AB8500_NUM_IRQ_REGS; ab8500->irq_reg_offset = ab8500_irq_regoffset; } - ab8500->mask = kzalloc(ab8500->mask_size, GFP_KERNEL); + ab8500->mask = devm_kzalloc(&pdev->dev, ab8500->mask_size, GFP_KERNEL); if (!ab8500->mask) return -ENOMEM; - ab8500->oldmask = kzalloc(ab8500->mask_size, GFP_KERNEL); - if (!ab8500->oldmask) { - ret = -ENOMEM; - goto out_freemask; - } + ab8500->oldmask = devm_kzalloc(&pdev->dev, ab8500->mask_size, GFP_KERNEL); + if (!ab8500->oldmask) + return -ENOMEM; + /* * ab8500 has switched off due to (SWITCH_OFF_STATUS): * 0x01 Swoff bit programming @@ -1355,37 +1352,37 @@ static int __devinit ab8500_probe(struct platform_device *pdev) ret = abx500_register_ops(ab8500->dev, &ab8500_ops); if (ret) - goto out_freeoldmask; + return ret; for (i = 0; i < ab8500->mask_size; i++) ab8500->mask[i] = ab8500->oldmask[i] = 0xff; ret = ab8500_irq_init(ab8500, np); if (ret) - goto out_freeoldmask; + return ret; /* Activate this feature only in ab9540 */ /* till tests are done on ab8500 1p2 or later*/ if (is_ab9540(ab8500)) { - ret = request_threaded_irq(ab8500->irq, NULL, - ab8500_hierarchical_irq, - IRQF_ONESHOT | IRQF_NO_SUSPEND, - "ab8500", ab8500); + ret = devm_request_threaded_irq(&pdev->dev, ab8500->irq, NULL, + ab8500_hierarchical_irq, + IRQF_ONESHOT | IRQF_NO_SUSPEND, + "ab8500", ab8500); } else { - ret = request_threaded_irq(ab8500->irq, NULL, - ab8500_irq, - IRQF_ONESHOT | IRQF_NO_SUSPEND, - "ab8500", ab8500); + ret = devm_request_threaded_irq(&pdev->dev, ab8500->irq, NULL, + ab8500_irq, + IRQF_ONESHOT | IRQF_NO_SUSPEND, + "ab8500", ab8500); if (ret) - goto out_freeoldmask; + return ret; } ret = mfd_add_devices(ab8500->dev, 0, abx500_common_devs, ARRAY_SIZE(abx500_common_devs), NULL, ab8500->irq_base, ab8500->domain); if (ret) - goto out_freeirq; + return ret; if (is_ab9540(ab8500)) ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs, @@ -1396,14 +1393,14 @@ static int __devinit ab8500_probe(struct platform_device *pdev) ARRAY_SIZE(ab8500_devs), NULL, ab8500->irq_base, ab8500->domain); if (ret) - goto out_freeirq; + return ret; if (is_ab9540(ab8500) || is_ab8505(ab8500)) ret = mfd_add_devices(ab8500->dev, 0, ab9540_ab8505_devs, ARRAY_SIZE(ab9540_ab8505_devs), NULL, ab8500->irq_base, ab8500->domain); if (ret) - goto out_freeirq; + return ret; if (!no_bm) { /* Add battery management devices */ @@ -1424,17 +1421,6 @@ static int __devinit ab8500_probe(struct platform_device *pdev) dev_err(ab8500->dev, "error creating sysfs entries\n"); return ret; - -out_freeirq: - free_irq(ab8500->irq, ab8500); -out_freeoldmask: - kfree(ab8500->oldmask); -out_freemask: - kfree(ab8500->mask); -out_free_ab8500: - kfree(ab8500); - - return ret; } static int __devexit ab8500_remove(struct platform_device *pdev) -- cgit v1.1 From 916a871c48ef3ecbc4cac8f185c03160d0b42bfd Mon Sep 17 00:00:00 2001 From: Ulf Hansson Date: Thu, 22 Nov 2012 11:35:40 +0100 Subject: mfd: ab8500-core: Add abx500-clk as an mfd child device Hierarchically, the abx500-clk shall be considered as a child of the ab8500 core. The abx500-clk is intiated at arch init and thus the clks will be available when clients needs them. Cc: Samuel Ortiz Signed-off-by: Ulf Hansson Signed-off-by: Samuel Ortiz --- drivers/mfd/ab8500-core.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/mfd/ab8500-core.c') diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index 2a69dc2..5b8a4de 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c @@ -952,6 +952,10 @@ static struct mfd_cell __devinitdata abx500_common_devs[] = { .of_compatible = "stericsson,ab8500-regulator", }, { + .name = "abx500-clk", + .of_compatible = "stericsson,abx500-clk", + }, + { .name = "ab8500-gpadc", .of_compatible = "stericsson,ab8500-gpadc", .num_resources = ARRAY_SIZE(ab8500_gpadc_resources), -- cgit v1.1 From 4e1328be4d4e4967d54bf7ae3b0805ec53fc4f91 Mon Sep 17 00:00:00 2001 From: Tushar Behera Date: Fri, 23 Nov 2012 17:48:43 +0530 Subject: mfd: ab8500-core: Fix invalid free of devm_ allocated data The objects allocated by devm_* APIs are managed by devres and are freed when the device is detached. Hence there is no need to remove them explicitly in remove function. Signed-off-by: Tushar Behera Acked-by: Linus Walleij Signed-off-by: Samuel Ortiz --- drivers/mfd/ab8500-core.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'drivers/mfd/ab8500-core.c') diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index 5b8a4de..660a09b 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c @@ -1437,11 +1437,6 @@ static int __devexit ab8500_remove(struct platform_device *pdev) sysfs_remove_group(&ab8500->dev->kobj, &ab8500_attr_group); mfd_remove_devices(ab8500->dev); - free_irq(ab8500->irq, ab8500); - - kfree(ab8500->oldmask); - kfree(ab8500->mask); - kfree(ab8500); return 0; } -- cgit v1.1