From patchwork Tue Dec 2 12:45:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yadwinder Singh Brar X-Patchwork-Id: 5419731 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 882E29F1C5 for ; Tue, 2 Dec 2014 12:46:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D1D8202BE for ; Tue, 2 Dec 2014 12:46:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A697820253 for ; Tue, 2 Dec 2014 12:46:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754578AbaLBMqx (ORCPT ); Tue, 2 Dec 2014 07:46:53 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:47492 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751211AbaLBMqw (ORCPT ); Tue, 2 Dec 2014 07:46:52 -0500 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NFY0007XGU1RU90@mailout2.samsung.com>; Tue, 02 Dec 2014 21:46:49 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.126]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 1A.A9.18484.9B4BD745; Tue, 02 Dec 2014 21:46:49 +0900 (KST) X-AuditID: cbfee68f-f791c6d000004834-25-547db4b99105 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id E8.DA.09430.9B4BD745; Tue, 02 Dec 2014 21:46:49 +0900 (KST) Received: from localhost.localdomain ([107.108.83.81]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NFY00FNRGSDKNA0@mmp1.samsung.com>; Tue, 02 Dec 2014 21:46:49 +0900 (KST) From: Yadwinder Singh Brar To: devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: lee.jones@linaro.org, sameo@linux.intel.com, akpm@linux-foundation.org, tomasz.figa@gmail.com, robh+dt@kernel.org, yadi.brar01@gmail.com, Yadwinder Singh Brar Subject: [PATCH] mfd: max77686: Fix parent of rtc device Date: Tue, 02 Dec 2014 18:15:39 +0530 Message-id: <1417524339-4604-1-git-send-email-yadi.brar@samsung.com> X-Mailer: git-send-email 1.7.0.4 In-reply-to: <1417523620-4311-1-git-send-email-yadi.brar@samsung.com> References: <1417523620-4311-1-git-send-email-yadi.brar@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMLMWRmVeSWpSXmKPExsWyRsSkTnfnltoQg5fvtSzmrF/DZjH/yDlW i/tfjzJabHp8jdVixvl9TBate4+wW5zuZrVYtesPo8Xc342sFnOmv2Ny4PLYOesuu8emVZ1s Hneu7WHzODHjN4vHvJOBHpuX1Hv0bVnF6PF5k1wARxSXTUpqTmZZapG+XQJXxuVF/WwFL8Qr +hemNjB2CHcxcnBICJhIXDuv1sXICWSKSVy4t56ti5GLQ0hgKaPEhrctzBAJE4mdCycwQiQW MUqcPn+XESQhJNDGJLHyhybIIDYBI4lXx+xAwiICmRKXWtcwgdQzC+xjlJi4eQ3YIGEBC4lV W3eC2SwCqhIvj6wDs3kFXCQ+rZzOBLFMQaJ12SF2kJmcAq4Sv1ZyQ6xykVi9sR3sOAmBQ+wS T7esY4KYIyDxbfIhFohnZCU2HYC6WVLi4IobLBMYhRcwMqxiFE0tSC4oTkovMtYrTswtL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MVzX0kum9vFx81Xs5nDadaleI7InUu1Hdy3JNd3yhm4z90UpO2lJHW3X2Gz 6VzxFfqpwsIJU62Y599+zceays6cWGvjm3wgWSO7qVzpxVHuKbPC/yYceSVYZnR0w52LvTfC 56SlJURHP1mvxFKckWioxVxUnAgALwWDEdECAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP rtc have different i2c client than power(pmic) block. So rtc device should sit under its own i2c client in device hierarchy, which reflects in sysfs also. This patch modifies code to register rtc cell with rtc->dev as parent. Without this patch : # ls /sys/class/i2c-adapter/i2c-0/0-0009/ driver max77686-pmic modalias power uevent max77686-clk max77686-rtc name subsystem After applying patch : # ls /sys/class/i2c-adapter/i2c-0/0-0006/ driver/ modalias power/ uevent max77686-rtc/ name subsystem/ Signed-off-by: Yadwinder Singh Brar Reviewed-by: Krzysztof Kozlowski --- Or Can we follow another (exhaustive but more cleaner) approach, which will be more like code refactoring and cleanup rather than only fix: Since rtc uses i2c client, which gets created using i2c_new_dummy() and is not shared by any other cell of max77686. So we can covert rtc platform driver itself to i2c client driver. It will also allow to expilicitly describe max77686-rtc in DT which we can't do now. It can be applicable to some other existing and new mfd pmic drivers. Any suggestion/comments ? --- drivers/mfd/max77686.c | 22 ++++++++++++++++++++-- 1 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c index 929795e..22c0948 100644 --- a/drivers/mfd/max77686.c +++ b/drivers/mfd/max77686.c @@ -39,10 +39,13 @@ static const struct mfd_cell max77686_devs[] = { { .name = "max77686-pmic", }, - { .name = "max77686-rtc", }, { .name = "max77686-clk", }, }; +static const struct mfd_cell max77686_rtc_dev[] = { + { .name = "max77686-rtc", }, +}; + static const struct mfd_cell max77802_devs[] = { { .name = "max77802-pmic", }, { .name = "max77802-clk", }, @@ -332,14 +335,27 @@ static int max77686_i2c_probe(struct i2c_client *i2c, goto err_del_irqc; } + if (max77686->type == TYPE_MAX77686) { + ret = mfd_add_devices(&max77686->rtc->dev, -1, max77686_rtc_dev, + 1, NULL, 0, NULL); + if (ret < 0) { + dev_err(&max77686->rtc->dev, + "failed to add RTC device %d\n", ret); + goto err_del_rtc_irqc; + } + } + ret = mfd_add_devices(max77686->dev, -1, cells, n_devs, NULL, 0, NULL); if (ret < 0) { dev_err(&i2c->dev, "failed to add MFD devices: %d\n", ret); - goto err_del_rtc_irqc; + goto err_del_rtc_dev; } return 0; +err_del_rtc_dev: + if (max77686->type == TYPE_MAX77686) + mfd_remove_devices(&max77686->rtc->dev); err_del_rtc_irqc: regmap_del_irq_chip(max77686->irq, max77686->rtc_irq_data); err_del_irqc: @@ -356,6 +372,8 @@ static int max77686_i2c_remove(struct i2c_client *i2c) struct max77686_dev *max77686 = i2c_get_clientdata(i2c); mfd_remove_devices(max77686->dev); + if (max77686->type == TYPE_MAX77686) + mfd_remove_devices(&max77686->rtc->dev); regmap_del_irq_chip(max77686->irq, max77686->rtc_irq_data); regmap_del_irq_chip(max77686->irq, max77686->irq_data);