[PATCH 1/5] mfd: max8997: Fix platform device ids to avoid probe failure
From: Bartlomiej Zolnierkiewicz
Date: Fri Mar 20 2015 - 15:02:38 EST
Commit 6e3f62f0793e ("mfd: core: Fix platform-device id generation")
changed the way platform device ids are generated from mfd id base and
cell ids in mfd_add_device(). Unfortunately the change in question
breaks mfd drivers which are using mfd_add_devices() with mfd id base
equal to -1 and non-zero cell ids (used to distinguish cells with
the same name field). The result is that mfd core tries to register
platform devices with the same name which obviously fails and leads
to mfd device probe failure.
Relevant error messages in case of MAX8997 PMIC driver:
[ 0.911674] ------------[ cut here ]------------
[ 0.911706] WARNING: CPU: 0 PID: 1 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x54/0x70()
[ 0.911718] sysfs: cannot create duplicate filename '/devices/13860000.i2c/i2c-0/0-0066/max8997-led'
[ 0.911725] Modules linked in:
[ 0.911742] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.18.0-rc1-00027-g6e3f62f #1557
[ 0.911782] [<c0013cb4>] (unwind_backtrace) from [<c0010d10>] (show_stack+0x10/0x14)
[ 0.911809] [<c0010d10>] (show_stack) from [<c04619c8>] (dump_stack+0x68/0xb8)
[ 0.911837] [<c04619c8>] (dump_stack) from [<c0020c80>] (warn_slowpath_common+0x64/0x84)
[ 0.911854] [<c0020c80>] (warn_slowpath_common) from [<c0020d34>] (warn_slowpath_fmt+0x30/0x40)
[ 0.911871] [<c0020d34>] (warn_slowpath_fmt) from [<c011ec50>] (sysfs_warn_dup+0x54/0x70)
[ 0.911887] [<c011ec50>] (sysfs_warn_dup) from [<c011ecf4>] (sysfs_create_dir_ns+0x88/0x90)
[ 0.911910] [<c011ecf4>] (sysfs_create_dir_ns) from [<c01d5524>] (kobject_add_internal+0x9c/0x2c0)
[ 0.911926] [<c01d5524>] (kobject_add_internal) from [<c01d58d0>] (kobject_add+0x4c/0x94)
[ 0.911950] [<c01d58d0>] (kobject_add) from [<c026f65c>] (device_add+0xb8/0x4d8)
[ 0.911969] [<c026f65c>] (device_add) from [<c027330c>] (platform_device_add+0x114/0x214)
[ 0.911996] [<c027330c>] (platform_device_add) from [<c028d0f0>] (mfd_add_device+0x240/0x328)
[ 0.912013] [<c028d0f0>] (mfd_add_device) from [<c028d3d0>] (mfd_add_devices+0xa4/0xe8)
[ 0.912030] [<c028d3d0>] (mfd_add_devices) from [<c028e3b0>] (max8997_i2c_probe+0x150/0x230)
[ 0.912056] [<c028e3b0>] (max8997_i2c_probe) from [<c0329114>] (i2c_device_probe+0xe8/0x120)
[ 0.912076] [<c0329114>] (i2c_device_probe) from [<c0271cf0>] (driver_probe_device+0x114/0x234)
[ 0.912094] [<c0271cf0>] (driver_probe_device) from [<c0270630>] (bus_for_each_drv+0x5c/0x88)
[ 0.912109] [<c0270630>] (bus_for_each_drv) from [<c0271ba8>] (device_attach+0x70/0x88)
[ 0.912124] [<c0271ba8>] (device_attach) from [<c0271304>] (bus_probe_device+0x84/0xa8)
[ 0.912138] [<c0271304>] (bus_probe_device) from [<c026f94c>] (device_add+0x3a8/0x4d8)
[ 0.912153] [<c026f94c>] (device_add) from [<c03298c0>] (i2c_new_device+0xfc/0x16c)
[ 0.912167] [<c03298c0>] (i2c_new_device) from [<c0329dd0>] (i2c_register_adapter+0x27c/0x490)
[ 0.912186] [<c0329dd0>] (i2c_register_adapter) from [<c032f184>] (s3c24xx_i2c_probe+0x200/0x4dc)
[ 0.912205] [<c032f184>] (s3c24xx_i2c_probe) from [<c027310c>] (platform_drv_probe+0x48/0x98)
[ 0.912219] [<c027310c>] (platform_drv_probe) from [<c0271cf0>] (driver_probe_device+0x114/0x234)
[ 0.912232] [<c0271cf0>] (driver_probe_device) from [<c0271e9c>] (__driver_attach+0x8c/0x90)
[ 0.912246] [<c0271e9c>] (__driver_attach) from [<c02706b0>] (bus_for_each_dev+0x54/0x88)
[ 0.912262] [<c02706b0>] (bus_for_each_dev) from [<c02714f4>] (bus_add_driver+0xd8/0x1cc)
[ 0.912275] [<c02714f4>] (bus_add_driver) from [<c02724bc>] (driver_register+0x78/0xf4)
[ 0.912291] [<c02724bc>] (driver_register) from [<c0008924>] (do_one_initcall+0x80/0x1c4)
[ 0.912312] [<c0008924>] (do_one_initcall) from [<c062cd20>] (kernel_init_freeable+0x100/0x1cc)
[ 0.912330] [<c062cd20>] (kernel_init_freeable) from [<c045da50>] (kernel_init+0x8/0xe4)
[ 0.912348] [<c045da50>] (kernel_init) from [<c000e5b8>] (ret_from_fork+0x14/0x3c)
[ 0.912370] ---[ end trace ca08768d4d1efd62 ]---
[ 0.912382] ------------[ cut here ]------------
[ 0.912402] WARNING: CPU: 0 PID: 1 at lib/kobject.c:240 kobject_add_internal+0x238/0x2c0()
[ 0.912411] kobject_add_internal failed for max8997-led with -EEXIST, don't try to register things with the same name in th
e same directory.
[ 0.912418] Modules linked in:
[ 0.912433] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 3.18.0-rc1-00027-g6e3f62f #1557
[ 0.912458] [<c0013cb4>] (unwind_backtrace) from [<c0010d10>] (show_stack+0x10/0x14)
[ 0.912479] [<c0010d10>] (show_stack) from [<c04619c8>] (dump_stack+0x68/0xb8)
[ 0.912502] [<c04619c8>] (dump_stack) from [<c0020c80>] (warn_slowpath_common+0x64/0x84)
[ 0.912519] [<c0020c80>] (warn_slowpath_common) from [<c0020d34>] (warn_slowpath_fmt+0x30/0x40)
[ 0.912536] [<c0020d34>] (warn_slowpath_fmt) from [<c01d56c0>] (kobject_add_internal+0x238/0x2c0)
[ 0.912553] [<c01d56c0>] (kobject_add_internal) from [<c01d58d0>] (kobject_add+0x4c/0x94)
[ 0.912572] [<c01d58d0>] (kobject_add) from [<c026f65c>] (device_add+0xb8/0x4d8)
[ 0.912588] [<c026f65c>] (device_add) from [<c027330c>] (platform_device_add+0x114/0x214)
[ 0.912611] [<c027330c>] (platform_device_add) from [<c028d0f0>] (mfd_add_device+0x240/0x328)
[ 0.912628] [<c028d0f0>] (mfd_add_device) from [<c028d3d0>] (mfd_add_devices+0xa4/0xe8)
[ 0.912643] [<c028d3d0>] (mfd_add_devices) from [<c028e3b0>] (max8997_i2c_probe+0x150/0x230)
[ 0.912665] [<c028e3b0>] (max8997_i2c_probe) from [<c0329114>] (i2c_device_probe+0xe8/0x120)
[ 0.912682] [<c0329114>] (i2c_device_probe) from [<c0271cf0>] (driver_probe_device+0x114/0x234)
[ 0.912700] [<c0271cf0>] (driver_probe_device) from [<c0270630>] (bus_for_each_drv+0x5c/0x88)
[ 0.912714] [<c0270630>] (bus_for_each_drv) from [<c0271ba8>] (device_attach+0x70/0x88)
[ 0.912729] [<c0271ba8>] (device_attach) from [<c0271304>] (bus_probe_device+0x84/0xa8)
[ 0.912743] [<c0271304>] (bus_probe_device) from [<c026f94c>] (device_add+0x3a8/0x4d8)
[ 0.912758] [<c026f94c>] (device_add) from [<c03298c0>] (i2c_new_device+0xfc/0x16c)
[ 0.912771] [<c03298c0>] (i2c_new_device) from [<c0329dd0>] (i2c_register_adapter+0x27c/0x490)
[ 0.912789] [<c0329dd0>] (i2c_register_adapter) from [<c032f184>] (s3c24xx_i2c_probe+0x200/0x4dc)
[ 0.912805] [<c032f184>] (s3c24xx_i2c_probe) from [<c027310c>] (platform_drv_probe+0x48/0x98)
[ 0.912820] [<c027310c>] (platform_drv_probe) from [<c0271cf0>] (driver_probe_device+0x114/0x234)
[ 0.912833] [<c0271cf0>] (driver_probe_device) from [<c0271e9c>] (__driver_attach+0x8c/0x90)
[ 0.912847] [<c0271e9c>] (__driver_attach) from [<c02706b0>] (bus_for_each_dev+0x54/0x88)
[ 0.912862] [<c02706b0>] (bus_for_each_dev) from [<c02714f4>] (bus_add_driver+0xd8/0x1cc)
[ 0.912875] [<c02714f4>] (bus_add_driver) from [<c02724bc>] (driver_register+0x78/0xf4)
[ 0.912889] [<c02724bc>] (driver_register) from [<c0008924>] (do_one_initcall+0x80/0x1c4)
[ 0.912908] [<c0008924>] (do_one_initcall) from [<c062cd20>] (kernel_init_freeable+0x100/0x1cc)
[ 0.912925] [<c062cd20>] (kernel_init_freeable) from [<c045da50>] (kernel_init+0x8/0xe4)
[ 0.912942] [<c045da50>] (kernel_init) from [<c000e5b8>] (ret_from_fork+0x14/0x3c)
[ 0.912952] ---[ end trace ca08768d4d1efd63 ]---
[ 0.920721] max8997 0-0066: failed to add MFD devices -17
[ 0.921553] max8997: probe of 0-0066 failed with error -17
Changing mfd_add_devices() mfd id base from -1 to 0 and at the same
time setting proper cell ids for all cells fixes the issue.
This fix was tested on Exynos4210 Origen board which is using MAX8997
PMIC (it also fixes Exynos cpufreq support which was broken because
vdd_arm regulator was not available due to MAX8997 PMIC probe failure).
Fixes: 6e3f62f0793e ("mfd: core: Fix platform-device id generation")
Cc: Johan Hovold <johan@xxxxxxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx> # v3.19+
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@xxxxxxxxxxx>
---
drivers/mfd/max8997.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index 595364e..c93dabc 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -41,13 +41,13 @@
#define I2C_ADDR_HAPTIC (0x90 >> 1)
static const struct mfd_cell max8997_devs[] = {
- { .name = "max8997-pmic", },
- { .name = "max8997-rtc", },
- { .name = "max8997-battery", },
- { .name = "max8997-haptic", },
- { .name = "max8997-muic", },
- { .name = "max8997-led", .id = 1 },
- { .name = "max8997-led", .id = 2 },
+ { .name = "max8997-pmic", .id = -1 },
+ { .name = "max8997-rtc", .id = -1 },
+ { .name = "max8997-battery", .id = -1 },
+ { .name = "max8997-haptic", .id = -1 },
+ { .name = "max8997-muic", .id = -1 },
+ { .name = "max8997-led", .id = 0 },
+ { .name = "max8997-led", .id = 1 },
};
#ifdef CONFIG_OF
@@ -234,7 +234,7 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
max8997_irq_init(max8997);
- ret = mfd_add_devices(max8997->dev, -1, max8997_devs,
+ ret = mfd_add_devices(max8997->dev, 0, max8997_devs,
ARRAY_SIZE(max8997_devs),
NULL, 0, NULL);
if (ret < 0) {
--
1.8.2.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/