From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751562AbbCTTXw (ORCPT ); Fri, 20 Mar 2015 15:23:52 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:27982 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750993AbbCTTXs (ORCPT ); Fri, 20 Mar 2015 15:23:48 -0400 X-AuditID: cbfee61b-f79d76d0000024d6-25-550c73c2cac6 From: Bartlomiej Zolnierkiewicz To: Lee Jones , Samuel Ortiz Cc: Johan Hovold , Support Opensource , Milo Kim , patches@opensource.wolfsonmicro.com, Fabio Estevam , Marek Szyprowski , linux-kernel@vger.kernel.org, b.zolnierkie@samsung.com, stable@vger.kernel.org Subject: [PATCH v2 1/5] mfd: max8997: Fix platform device ids to avoid probe failure Date: Fri, 20 Mar 2015 20:23:19 +0100 Message-id: <1426879403-19265-2-git-send-email-b.zolnierkie@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1426879403-19265-1-git-send-email-b.zolnierkie@samsung.com> References: <1426879403-19265-1-git-send-email-b.zolnierkie@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGLMWRmVeSWpSXmKPExsVy+t9jQd1DxTyhBhP+8ltsnLGe1WJWl65F 040eVov7X48yWlzeNYfNYu2Ru+wWy3+tY7FY/vY/m8XpblaLBRsfMVrsbb3I7MDtseKTvse/ w/1MHptWdbJ53Lm2h81j3slAj5cTf7N59G1Zxehx/MZ2Jo/Pm+QCOKO4bFJSczLLUov07RK4 MjbvW8xSsN+j4t7hDawNjM12XYycHBICJhIXu2ezQNhiEhfurWfrYuTiEBKYzihx9dUlJgin k0nic9MGRpAqNgEriYntq4BsDg4RAS+Jnq/yIDXMAmeZJCbueMwGUiMsECbR+fEjG0gNi4Cq xMO7wSBhXgEPiceHzrOAhCUEFCTmTLIBCXMKeEosan4KNl0IqGTb0SOsExh5FzAyrGIUTS1I LihOSs810itOzC0uzUvXS87P3cQIDs1n0jsYVzVYHGIU4GBU4uE9UModKsSaWFZcmXuIUYKD WUmEd2oqT6gQb0piZVVqUX58UWlOavEhRmkOFiVxXiX7thAhgfTEktTs1NSC1CKYLBMHp1QD Y+3JbYsUCs9uzAgxml/x3+iZiE4067sH3kESp1anzdzmuVuYs9mz+rpHXvf9roAj+xdPPlL6 9rbg1hPBj34sEZ70a9rPZ4Hiz/+biCtVJ0vFuswsP8xyr2R1k2at/cPYe1fcdTdJnQx2dAm8 +iW4dfKtP95HPsxrKyxxzD7wsHXzk8Db928WdiqxFGckGmoxFxUnAgDav1RFSQIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 0.911809] [] (show_stack) from [] (dump_stack+0x68/0xb8) [ 0.911837] [] (dump_stack) from [] (warn_slowpath_common+0x64/0x84) [ 0.911854] [] (warn_slowpath_common) from [] (warn_slowpath_fmt+0x30/0x40) [ 0.911871] [] (warn_slowpath_fmt) from [] (sysfs_warn_dup+0x54/0x70) [ 0.911887] [] (sysfs_warn_dup) from [] (sysfs_create_dir_ns+0x88/0x90) [ 0.911910] [] (sysfs_create_dir_ns) from [] (kobject_add_internal+0x9c/0x2c0) [ 0.911926] [] (kobject_add_internal) from [] (kobject_add+0x4c/0x94) [ 0.911950] [] (kobject_add) from [] (device_add+0xb8/0x4d8) [ 0.911969] [] (device_add) from [] (platform_device_add+0x114/0x214) [ 0.911996] [] (platform_device_add) from [] (mfd_add_device+0x240/0x328) [ 0.912013] [] (mfd_add_device) from [] (mfd_add_devices+0xa4/0xe8) [ 0.912030] [] (mfd_add_devices) from [] (max8997_i2c_probe+0x150/0x230) [ 0.912056] [] (max8997_i2c_probe) from [] (i2c_device_probe+0xe8/0x120) [ 0.912076] [] (i2c_device_probe) from [] (driver_probe_device+0x114/0x234) [ 0.912094] [] (driver_probe_device) from [] (bus_for_each_drv+0x5c/0x88) [ 0.912109] [] (bus_for_each_drv) from [] (device_attach+0x70/0x88) [ 0.912124] [] (device_attach) from [] (bus_probe_device+0x84/0xa8) [ 0.912138] [] (bus_probe_device) from [] (device_add+0x3a8/0x4d8) [ 0.912153] [] (device_add) from [] (i2c_new_device+0xfc/0x16c) [ 0.912167] [] (i2c_new_device) from [] (i2c_register_adapter+0x27c/0x490) [ 0.912186] [] (i2c_register_adapter) from [] (s3c24xx_i2c_probe+0x200/0x4dc) [ 0.912205] [] (s3c24xx_i2c_probe) from [] (platform_drv_probe+0x48/0x98) [ 0.912219] [] (platform_drv_probe) from [] (driver_probe_device+0x114/0x234) [ 0.912232] [] (driver_probe_device) from [] (__driver_attach+0x8c/0x90) [ 0.912246] [] (__driver_attach) from [] (bus_for_each_dev+0x54/0x88) [ 0.912262] [] (bus_for_each_dev) from [] (bus_add_driver+0xd8/0x1cc) [ 0.912275] [] (bus_add_driver) from [] (driver_register+0x78/0xf4) [ 0.912291] [] (driver_register) from [] (do_one_initcall+0x80/0x1c4) [ 0.912312] [] (do_one_initcall) from [] (kernel_init_freeable+0x100/0x1cc) [ 0.912330] [] (kernel_init_freeable) from [] (kernel_init+0x8/0xe4) [ 0.912348] [] (kernel_init) from [] (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] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 0.912479] [] (show_stack) from [] (dump_stack+0x68/0xb8) [ 0.912502] [] (dump_stack) from [] (warn_slowpath_common+0x64/0x84) [ 0.912519] [] (warn_slowpath_common) from [] (warn_slowpath_fmt+0x30/0x40) [ 0.912536] [] (warn_slowpath_fmt) from [] (kobject_add_internal+0x238/0x2c0) [ 0.912553] [] (kobject_add_internal) from [] (kobject_add+0x4c/0x94) [ 0.912572] [] (kobject_add) from [] (device_add+0xb8/0x4d8) [ 0.912588] [] (device_add) from [] (platform_device_add+0x114/0x214) [ 0.912611] [] (platform_device_add) from [] (mfd_add_device+0x240/0x328) [ 0.912628] [] (mfd_add_device) from [] (mfd_add_devices+0xa4/0xe8) [ 0.912643] [] (mfd_add_devices) from [] (max8997_i2c_probe+0x150/0x230) [ 0.912665] [] (max8997_i2c_probe) from [] (i2c_device_probe+0xe8/0x120) [ 0.912682] [] (i2c_device_probe) from [] (driver_probe_device+0x114/0x234) [ 0.912700] [] (driver_probe_device) from [] (bus_for_each_drv+0x5c/0x88) [ 0.912714] [] (bus_for_each_drv) from [] (device_attach+0x70/0x88) [ 0.912729] [] (device_attach) from [] (bus_probe_device+0x84/0xa8) [ 0.912743] [] (bus_probe_device) from [] (device_add+0x3a8/0x4d8) [ 0.912758] [] (device_add) from [] (i2c_new_device+0xfc/0x16c) [ 0.912771] [] (i2c_new_device) from [] (i2c_register_adapter+0x27c/0x490) [ 0.912789] [] (i2c_register_adapter) from [] (s3c24xx_i2c_probe+0x200/0x4dc) [ 0.912805] [] (s3c24xx_i2c_probe) from [] (platform_drv_probe+0x48/0x98) [ 0.912820] [] (platform_drv_probe) from [] (driver_probe_device+0x114/0x234) [ 0.912833] [] (driver_probe_device) from [] (__driver_attach+0x8c/0x90) [ 0.912847] [] (__driver_attach) from [] (bus_for_each_dev+0x54/0x88) [ 0.912862] [] (bus_for_each_dev) from [] (bus_add_driver+0xd8/0x1cc) [ 0.912875] [] (bus_add_driver) from [] (driver_register+0x78/0xf4) [ 0.912889] [] (driver_register) from [] (do_one_initcall+0x80/0x1c4) [ 0.912908] [] (do_one_initcall) from [] (kernel_init_freeable+0x100/0x1cc) [ 0.912925] [] (kernel_init_freeable) from [] (kernel_init+0x8/0xe4) [ 0.912942] [] (kernel_init) from [] (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 Cc: Signed-off-by: Bartlomiej Zolnierkiewicz --- stable v3.19+ 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