From patchwork Fri Jun 17 10:09:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 9183269 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 426D06075F for ; Fri, 17 Jun 2016 10:19:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3008628388 for ; Fri, 17 Jun 2016 10:19:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2474328399; Fri, 17 Jun 2016 10:19:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9B14528388 for ; Fri, 17 Jun 2016 10:18:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bDqq1-0006dT-EY; Fri, 17 Jun 2016 10:17:21 +0000 Received: from mail-bn1bon0057.outbound.protection.outlook.com ([157.56.111.57] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bDqpW-00062p-MJ for linux-arm-kernel@lists.infradead.org; Fri, 17 Jun 2016 10:16:53 +0000 Received: from BN3PR0301CA0066.namprd03.prod.outlook.com (10.160.152.162) by CY1PR0301MB1628.namprd03.prod.outlook.com (10.162.166.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.517.8; Fri, 17 Jun 2016 10:16:28 +0000 Received: from BN1AFFO11FD020.protection.gbl (2a01:111:f400:7c10::122) by BN3PR0301CA0066.outlook.office365.com (2a01:111:e400:401e::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.523.12 via Frontend Transport; Fri, 17 Jun 2016 10:16:28 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; nxp.com; dmarc=none action=none header.from=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD020.mail.protection.outlook.com (10.58.52.80) with Microsoft SMTP Server (TLS) id 15.1.511.7 via Frontend Transport; Fri, 17 Jun 2016 10:16:28 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u5HAFbSs029984; Fri, 17 Jun 2016 03:16:21 -0700 From: Peter Chen To: , , , , , Subject: [PATCH 06/12] power: pwrseq: change common helpers as generic Date: Fri, 17 Jun 2016 18:09:19 +0800 Message-ID: <1466158165-9380-7-git-send-email-peter.chen@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466158165-9380-1-git-send-email-peter.chen@nxp.com> References: <1466158165-9380-1-git-send-email-peter.chen@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131106321884833576; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(5003940100001)(586003)(50466002)(19580405001)(19580395003)(2201001)(2171001)(68736007)(48376002)(87936001)(5001770100001)(97736004)(189998001)(11100500001)(229853001)(105606002)(47776003)(106466001)(36756003)(76176999)(50986999)(6806005)(86362001)(92566002)(5008740100001)(104016004)(85426001)(2950100001)(33646002)(81166006)(77096005)(356003)(8666005)(8676002)(50226002)(81156014)(4326007)(8936002)(2906002)(41533002)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB1628; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; CAT:NONE; LANG:en; CAT:NONE; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD020; 1:a128Hn+H4vyNkxYvfrK+LDoeURQT04v13LWMNKsMq2NgJgFTguYPNeDQPYmanYzUPsaix6n4GHdWB1VLlZWlFkm5DkfOZn3BX1K7p82prUu7CVgYnzcXN7MjDoA+Pe1Ao771GUpp32JvC255GspB8Ugp0WzLOc+sg0oKSAOmyAgnPEi+t8SQ/KBbTKnPTNKhYQzCHNGv5hoRzHjtAbccjEgZsLEailQFiXSKVXmLdFQixQby2sJ6/ZEuCS+i8DY4Z/Jai3MjU/0K8OqjCwxWGIh2cm2AdBkn5ZJ9lZfcj2O0tnEW9Fpmjk4MMYccI1xxSapHeAH4uPD8lA4fx4zYOHu5rA1V/NcCl5zw2tWpFp5MXAJriZ5dFXsMudmfAJYQShUzanVGRmCbfFi3ScMmLu66i2lWEjv9Lu0rZhLwpvGGZ90NlHJ71oZ7DfiIQwYtOxMhu5RTBAqo/DRxAN3sMSSSk/Uhe9oXrl49tQ0iMpymZnXrSdq2I9eCJpOCa9+GDVHARbeKS3dUbPgatPe2/bA4WjAU7sU/i4rkZdSlo/gEbHX/6NHYkNZUQgXdi5LyJKy+wzuWYfnHsU9V9j+cp10DPcdM6Dz8M5dFi7bM+pZlg9Bu1TdA1bacp4nq0qy74qDZa6zf0Aa6/1EeattRKHGhh63JTUB6IZa1QUN2DfkcZMFhSkYw8U+ZlYp2ShR/7oYkAZw5/lAT8VloFkwUSbnJyN50W5s3a03i2P1SziA= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 75e311d7-76e1-4c60-85c7-08d396987235 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1628; 2:RbMThzOG3+75DLk57z1zf2EShgEg/nxuNt+tktXQBuwjEGeDj8YRnEsULSx4Kikrkl7P0DSXs4kBAr97ghiKikXDaQCN9rt+eA0rGN415qXMeeewGbhkvQ8+t2ZktoYquBI8yP0htjI7zVgiVewerd5YFbJTmliUjM4EsiP7HZ/NkrR7QJ+bI9b0BqztE5z5; 3:DnaCfhmHHGqBILGLJi5V8dToch+zX6+dc5VmENrhOBIrQqaMMPTqlU946m31ChO1l1pBxHJbGc7zpvNgI8rmovu3LPIq7xou1FprPxY61rmyT+R+NoJ9ZTHNYeDoVpplqRJPmoB47tTng8PYj8qs13KXCDQ+uormr/Y/VP92Vmg1OOn8QSq3cQbA/f7uixa72d3gtG0SVzCLiWCddk0OkgH4H1hf0fDWyFKRIpB3H8Y= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1628; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1628; 25:Xx+WmlSKzq5TD88ocEJrVvTXeiJ3vh4edt7sNDA8LwvtBZjRT7y1vIJWi1+tpUbRe6SnR3st1PI3Hk3as9blILIQ4KtHsKpLmqmr+FAdJ6trQsJ0xNQ80o4LxS33RWPxhTfHk3aY2GTJX28GLRu5YCffie65+3ClOHv78jMP+r8sIBS/zTpjgzvOW+W0ZQKOcwibfCKQ4iXolpn/dirV6BADgqoZDww3k2LAC2JjKIBs0Fd/6zD1wvlaq4Kx31DCvz30mjncq5/72J3rv4BW/J7FK9/feoSdbrsHYoCUfdLZMm7m7jsg8OxuWwYyeBeTRt8HzkafMfoYbJjGbv5MFRQax5cJnTFynx9iBzCrZVg4jevhBrUJAe9sVPgmCpWwrWV21ukB316Pc8GAxnlvuUgADKnJAUJA6K0y/E7E8T7HRWNzU7wCdhLK77bczvAPOM4NulFrCkOrB1eaguk7yOsJXeJfAUO9CnR3YgFDyRgieKToru18MPz7mKTFPDA+taneVd7VhfbS4sLi8R9WmuPZHR9eq38H+jUfvoEZxJFw95PzVfPLp1b2GNYhBlaGHMQbwdp80qAr364Rq6yZ9rGDF0nk/zhZabyGsNorGCnqhENs4KXp0D13O/3tkqANl2jKluu0MuIlHCRxcppAXu5pnq44Rc2CGETgNsBiRWNrXVus07cq20FGQxailVVNO/Opy8lALGrwnFvl/kLwWhR6Sy44bBrZT7Ak99VSiFk= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13023025)(13024025)(13015025)(13018025)(13017025)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:CY1PR0301MB1628; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB1628; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1628; 4:zx905RP+VGOhBmZPFdkhTWLvlNXo7TekPek7r0E+gZ/K1saO/pDeqczi23KoppYjlFOhAHp60Ndbaw17ra0g+XgatN/T2gDNsohFwBSZmFHc+rDYdhnz5dRpWYVLMv2rMPPHh51L9F+WpqDP5z1ZdNYLrvascFpiPDlIrvdP80zd8dEclb76ZuOY44Kx8Q7CtjbeNHun600LEyN8evh6ySr1M3nIQGTcp5QT4mPI6MJCCq63bX6aisQwZ6WjrEgucD6ucZX9+Y99oXx0EkkYwsxxbxfMVJRvETru8Z3jsD9cwfJ8ZTFJyscLP4G5HbmMcCRu4qelDEkQhnGfeo/tlmMRGKu7Tu+AQO0oben6V9cOp+QCrzF+eTFfFPC1M9xVdV2e8++JJDSG0KWXzbAONJTK81ceDFPiD0J+1zDi6IYeLHWunxe/i1t3jowO6izmD20//w6bdQmS3rdnH2K1+C9tzoQ/DmyNvtIKN1sP7BQdC0Exp3DoHB/RrZCzP7mwuniNw/aPgMtbbOSDSAoafw== X-Forefront-PRVS: 09760A0505 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB1628; 23:cRO9ea3PlT44RcxBWqWlyWgzjWyH1iMQj5BSzFF?= =?us-ascii?Q?Zqsud+Fuk0Q8gKEWMP12LUN+sJPy5RzL8xWW9LwuEokyyaFxdQO+0TgZydu2?= =?us-ascii?Q?KMDElwf30aX13GOJQCPVg1eXuSyjEqjAr+kkZoTFM/foyRzo+RnIAjVX2pR5?= =?us-ascii?Q?/QnGaI7VWaySMu41JiId9F2JXUK3cTI8uxbU2njqZjjTPrCHcwmCaR+80eR1?= =?us-ascii?Q?Zs9s6Gj4BjBk8oAFxDyu2SaBFtVmrdowcDbyTTNos8RjICxISdQKeVsrkxDM?= =?us-ascii?Q?6V86FruZknRV4FDYP6G0+dkE5ORRzki6XN2bW1VmJDHjwhVX/w65a2N7mZy1?= =?us-ascii?Q?mdfj1BCaXAVL8HbdSLUAnILPCYS1jFZER/DzfB4zEQYlXpoB/918PXT2KZPe?= =?us-ascii?Q?NGR833/XZKo72VlUlOimLtr/SaGpG1oQ4AYH/HmBcN4JwuxIPX1qIM04a4Ol?= =?us-ascii?Q?TxzvyOeDuesa587FyrAq5yL3juVvJG5UtUZB9AEdcVMhr37XRoE2GIzDCpnR?= =?us-ascii?Q?upjBgMxj+/Ta/LNbyVBg+qhBlH2LxY4Hh7svGMuC3S3xY9fr2tsNUdH7EfpG?= =?us-ascii?Q?vY+oXdAD5CHgce+9sL48wGTFLQcBig2+s8IKEIwtXvaY/m7tWYfKegJe2ZVJ?= =?us-ascii?Q?H3m+C27s4ruKrQOyeWVPBhG5f+SS+1nYFSnCs3LankMf//pncAW90EEAMV5M?= =?us-ascii?Q?3xVjdQfmaET06hoYwOqc9r20/9n8yw29vDkdH0lBWyETuniqfrfrn+kTVoNt?= =?us-ascii?Q?0XCqBJMHz4pH6U4LcUd20DpJawQmmqWc4X1gc7UcI6BwjLegGi7W+guckWAM?= =?us-ascii?Q?PEAxLZNwCuZkVNb8bh4KbukHqnudTmcxf+A8fC/hDgnz9mQMR8d/TzH37Lb4?= =?us-ascii?Q?LbhV8W5Vtp9AKBKtIiI4+WSrf6ZGC4PDKGehf5rospqRXEM5jDaT5ZEsP29X?= =?us-ascii?Q?TSPDzEf5bMyGnSV9ecMT7MGlXfet7uqvdbEbsF9U91ggC+TJ8aUiVG7RZ8Jl?= =?us-ascii?Q?3hhcF2w1nqPuxgbXIkIMQlb0cTWhLWjy/uuyxtim4rWU58mvru0IQbNNDOE5?= =?us-ascii?Q?rWhTCtrUNfRUanFcjl1dcUqZ3zguObwOcqlPaQa3CTPAI+ilh7gikmU0sdXM?= =?us-ascii?Q?do0YcwObB7OyhPtoEG1LD9b/aVxyxwoy+stiAkvH7rJPsOZiiTKnaXhCXXus?= =?us-ascii?Q?86bTvvTr+xpBvV/xxKuVOZvoOY1WAvs9/eXfrx5KQmncfaYhQbv6um/mkSw?= =?us-ascii?Q?=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1628; 6:AHAufIuspzAmsYJUhBXg8PkM6ytXpt6DxPmh7UzEDuZK5giyxf5X3HpTWRyW0zh0El3Cjt0Iesc9nWOJ7oQK4FB80+O3TLTi8lVOuzncJnv3gWJA3MKDULfPYipRMaPJMJeg4U6ejHvIY7Oi/pWBcZvgcC/bGjynyndca/lpY6Vo2H0HB2rJFqdT352QtjnwkDB8uH9ubG+0+ii6RC4PyKuoKGYg76D/bfb/NNGV9QlNAHX8VOV75vheuyqZu8ZRUMbCCh4zJa2p96re6PceeGboyNJRcRzYVD40yBAOcq0=; 5:siOJYCQwDUcLtqP1lUu80rFEyYPcfvbyya7rHygLxFQgX1TISeo0Ep2gyFRFZ+6gXCW/saZGU5FgFbuFBT/bh9Zo9TRlenB76mXJMyYTL4WwQt2RAYAukfeqtgubbo8LebhchzC3qnieaEulOCTw//swR38z+SVwe1bb5pnO2ME=; 24:g2/8fz9RP72K5U0QYa27H5cxFXmvMNmL8q/UqBFBDtT0tFgC14iYC+KRP2qCAatc01PvnVyrB+cxTr76Z4nzkeY5Lu65SIxJFhnAoSaWVuM=; 7:Ziic91tTFQzmX66WYX2sDYQoKvpBv5lNkEXr/pjPMcYVPZ/U4uAxMuv+9P2FxbyQZ6asIezFBsayw9+PYeOpAgd+plCJ/YubvOtiQw/T6HiDJnswbzNOQvQYq5k0o1OqCVTmNe4/r+Xg9eQKt+CqaXG+IE3+UwjXzMdqsp8nLC/XuRAxj93zhQzjrHmi2V3U+PDgKC+0WbhF2dTAj+/3iA== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2016 10:16:28.1713 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1628 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160617_031651_184247_FBF8FA96 X-CRM114-Status: GOOD ( 17.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, k.kozlowski@samsung.com, stephen.boyd@linaro.org, oscar@naiandei.net, arnd@arndb.de, pawel.moll@arm.com, linux-pm@vger.kernel.org, s.hauer@pengutronix.de, linux-usb@vger.kernel.org, linux-mmc@vger.kernel.org, mail@maciej.szmigiero.name, troy.kisky@boundarydevices.com, javier@osg.samsung.com, Peter Chen , p.zabel@pengutronix.de, festevam@gmail.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP These helpers are only used by mmc now, change them as generic and do corresponding changes at mmc code. Meanwhile, change return value of helper pwrseq_pre_power_on since it may occur error during enable clock/regulator, etc. Signed-off-by: Peter Chen --- drivers/mmc/core/host.c | 8 +++++-- drivers/power/pwrseq/pwrseq.c | 45 ++++++++++++++++++------------------ drivers/power/pwrseq/pwrseq_simple.c | 10 +++++--- include/linux/pwrseq.h | 31 ++++++++++++++----------- 4 files changed, 52 insertions(+), 42 deletions(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 1db7d58..c8ffd9b 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -322,7 +322,11 @@ int mmc_of_parse(struct mmc_host *host) host->dsr_req = 0; } - return mmc_pwrseq_alloc(host); + host->pwrseq = pwrseq_alloc(host->parent->of_node, "mmc-pwrseq"); + if (IS_ERR(host->pwrseq)) + return PTR_ERR(host->pwrseq); + else + return 0; } EXPORT_SYMBOL(mmc_of_parse); @@ -462,7 +466,7 @@ EXPORT_SYMBOL(mmc_remove_host); */ void mmc_free_host(struct mmc_host *host) { - mmc_pwrseq_free(host); + pwrseq_free(host->pwrseq); put_device(&host->class_dev); } diff --git a/drivers/power/pwrseq/pwrseq.c b/drivers/power/pwrseq/pwrseq.c index 495a19d..25e4dfd 100644 --- a/drivers/power/pwrseq/pwrseq.c +++ b/drivers/power/pwrseq/pwrseq.c @@ -5,37 +5,38 @@ * * License terms: GNU General Public License (GPL) version 2 * - * MMC power sequence management + * Power sequence management helpers */ + +#include #include #include #include #include #include -#include static DEFINE_MUTEX(pwrseq_list_mutex); static LIST_HEAD(pwrseq_list); -int mmc_pwrseq_alloc(struct mmc_host *host) +struct pwrseq *pwrseq_alloc(const struct device_node *node, + const char *phandle_name) { struct device_node *np; - struct pwrseq *p; + struct pwrseq *p, *pwrseq = NULL; - np = of_parse_phandle(host->parent->of_node, "mmc-pwrseq", 0); + np = of_parse_phandle(node, phandle_name, 0); if (!np) - return 0; + return NULL; mutex_lock(&pwrseq_list_mutex); list_for_each_entry(p, &pwrseq_list, pwrseq_node) { if (p->dev->of_node == np) { if (!try_module_get(p->owner)) - dev_err(host->parent, + dev_err(p->dev, "increasing module refcount failed\n"); else - host->pwrseq = p; - + pwrseq = p; break; } } @@ -43,19 +44,21 @@ int mmc_pwrseq_alloc(struct mmc_host *host) of_node_put(np); mutex_unlock(&pwrseq_list_mutex); - if (!host->pwrseq) - return -EPROBE_DEFER; + if (!pwrseq) + return ERR_PTR(-EPROBE_DEFER); - dev_info(host->parent, "allocated mmc-pwrseq\n"); + dev_info(p->dev, "pwrseq is allocated\n"); - return 0; + return pwrseq; } -EXPORT_SYMBOL_GPL(mmc_pwrseq_alloc); +EXPORT_SYMBOL_GPL(pwrseq_alloc); -void pwrseq_pre_power_on(struct pwrseq *pwrseq) +int pwrseq_pre_power_on(struct pwrseq *pwrseq) { if (pwrseq && pwrseq->ops->pre_power_on) - pwrseq->ops->pre_power_on(pwrseq); + return pwrseq->ops->pre_power_on(pwrseq); + else + return 0; } EXPORT_SYMBOL_GPL(pwrseq_pre_power_on); @@ -73,16 +76,12 @@ void pwrseq_power_off(struct pwrseq *pwrseq) } EXPORT_SYMBOL_GPL(pwrseq_power_off); -void mmc_pwrseq_free(struct mmc_host *host) +void pwrseq_free(struct pwrseq *pwrseq) { - struct pwrseq *pwrseq = host->pwrseq; - - if (pwrseq) { + if (pwrseq) module_put(pwrseq->owner); - host->pwrseq = NULL; - } } -EXPORT_SYMBOL_GPL(mmc_pwrseq_free); +EXPORT_SYMBOL_GPL(pwrseq_free); int pwrseq_register(struct pwrseq *pwrseq) { diff --git a/drivers/power/pwrseq/pwrseq_simple.c b/drivers/power/pwrseq/pwrseq_simple.c index 93807a6..349443f 100644 --- a/drivers/power/pwrseq/pwrseq_simple.c +++ b/drivers/power/pwrseq/pwrseq_simple.c @@ -44,16 +44,20 @@ static void mmc_pwrseq_simple_set_gpios_value(struct mmc_pwrseq_simple *pwrseq, } } -static void mmc_pwrseq_simple_pre_power_on(struct pwrseq *_pwrseq) +static int mmc_pwrseq_simple_pre_power_on(struct pwrseq *_pwrseq) { struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(_pwrseq); + int ret = 0; if (!IS_ERR(pwrseq->ext_clk) && !pwrseq->clk_enabled) { - clk_prepare_enable(pwrseq->ext_clk); - pwrseq->clk_enabled = true; + ret = clk_prepare_enable(pwrseq->ext_clk); + if (!ret) + pwrseq->clk_enabled = true; } mmc_pwrseq_simple_set_gpios_value(pwrseq, 1); + + return 0; } static void mmc_pwrseq_simple_post_power_on(struct pwrseq *_pwrseq) diff --git a/include/linux/pwrseq.h b/include/linux/pwrseq.h index fcc8fd8..f726e7e 100644 --- a/include/linux/pwrseq.h +++ b/include/linux/pwrseq.h @@ -8,14 +8,6 @@ #ifndef _LINUX_PWRSEQ_H #define _LINUX_PWRSEQ_H -#include - -struct pwrseq_ops { - void (*pre_power_on)(struct pwrseq *pwrseq); - void (*post_power_on)(struct pwrseq *pwrseq); - void (*power_off)(struct pwrseq *pwrseq); -}; - struct pwrseq { const struct pwrseq_ops *ops; struct device *dev; @@ -23,16 +15,23 @@ struct pwrseq { struct module *owner; }; +struct pwrseq_ops { + int (*pre_power_on)(struct pwrseq *pwrseq); + void (*post_power_on)(struct pwrseq *pwrseq); + void (*power_off)(struct pwrseq *pwrseq); +}; + #ifdef CONFIG_POWER_SEQ int pwrseq_register(struct pwrseq *pwrseq); void pwrseq_unregister(struct pwrseq *pwrseq); -void pwrseq_pre_power_on(struct pwrseq *pwrseq); +int pwrseq_pre_power_on(struct pwrseq *pwrseq); void pwrseq_post_power_on(struct pwrseq *pwrseq); void pwrseq_power_off(struct pwrseq *pwrseq); -int mmc_pwrseq_alloc(struct mmc_host *host); -void mmc_pwrseq_free(struct mmc_host *host); +struct pwrseq *pwrseq_alloc(const struct device_node *node, + const char *phandle_name); +void pwrseq_free(struct pwrseq *pwrseq); #else /* CONFIG_POWER_SEQ */ @@ -41,11 +40,15 @@ static inline int pwrseq_register(struct pwrseq *pwrseq) return -ENOSYS; } static inline void pwrseq_unregister(struct pwrseq *pwrseq) {} -static inline void pwrseq_pre_power_on(struct pwrseq *pwrseq) {} +static inline int pwrseq_pre_power_on(struct pwrseq *pwrseq) {} static inline void pwrseq_post_power_on(struct pwrseq *pwrseq) {} static inline void pwrseq_power_off(struct pwrseq *pwrseq) {} -static inline int mmc_pwrseq_alloc(struct mmc_host *host) { return 0; } -static inline void mmc_pwrseq_free(struct mmc_host *host) {} +static inline struct pwrseq *pwrseq_alloc(const struct device_node *node, + const char *phandle_name) +{ + return NULL; +} +static inline void pwrseq_free(struct mmc_host *host) {} #endif /* CONFIG_POWER_SEQ */