From patchwork Sat Oct 1 10:12:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhuvanchandra DV X-Patchwork-Id: 9359131 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 E6BC56086A for ; Sat, 1 Oct 2016 10:17:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D61532984D for ; Sat, 1 Oct 2016 10:17:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA5AB29851; Sat, 1 Oct 2016 10:17:12 +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.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 1387D2984E for ; Sat, 1 Oct 2016 10:17:10 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bqHKW-0002Nk-0Y; Sat, 01 Oct 2016 10:15:40 +0000 Received: from mail-eopbgr10112.outbound.protection.outlook.com ([40.107.1.112] helo=EUR02-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bqHK9-000189-1m for linux-arm-kernel@lists.infradead.org; Sat, 01 Oct 2016 10:15:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toradex.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=AQ8BpbiSTpMQpmRA8SYLY7W9jSvrYx4WCNBsTeKui+g=; b=NbULzK8Khl1uuGIBSpbc9MEZhMyll66X1DYyDXj+ZsTPHkhzoh5IaZVI6YCluFPPnAsSjx1Lkf1Ml1OBZPd3nD9KimbWnoxPDE/Ai0qtlDh1SzKHQhX7swGxX+fhB/KPiQJSEHsK36vMe+wBn3vmzmCEoBUypYyFeKlNjy7zZ30= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=bhuvanchandra.dv@toradex.com; Received: from tdx-in-nb-0014.toradex.int (115.115.243.34) by AM3PR05MB1396.eurprd05.prod.outlook.com (2a01:111:e400:5871::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5; Sat, 1 Oct 2016 10:14:54 +0000 From: Bhuvanchandra DV To: , Subject: [PATCH v2 2/6] pwm: core: make the PWM_POLARITY flag in DTB optional Date: Sat, 1 Oct 2016 15:42:31 +0530 Message-ID: <20161001101235.24598-3-bhuvanchandra.dv@toradex.com> X-Mailer: git-send-email 2.9.2 In-Reply-To: <20161001101235.24598-1-bhuvanchandra.dv@toradex.com> References: <20161001101235.24598-1-bhuvanchandra.dv@toradex.com> MIME-Version: 1.0 X-Originating-IP: [115.115.243.34] X-ClientProxiedBy: PN1PR01CA0050.INDPRD01.PROD.OUTLOOK.COM (2a01:111:e400:5a3d::22) To AM3PR05MB1396.eurprd05.prod.outlook.com (2a01:111:e400:5871::11) X-MS-Office365-Filtering-Correlation-Id: 9fdafc52-9efd-43ec-2337-08d3e9e3cb27 X-Microsoft-Exchange-Diagnostics: 1; AM3PR05MB1396; 2:31IT/3VVfcqBLgGhWs0tSb9XGAi+hcY39W+8QNI1QdTCrJe4nENRccqWgAYqdMVuxcgOcD+VwPmYK/ZgvC2jx85SNgQlVDn9+RVDRzXRZ71IuI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nostics: 1; AM3PR05MB1396; 31:C8iE/XWFPTzl8OlWCo3qFxEMlETmwAl7Mw3xWOSPIJjjoY8yNCOyaAkp4JW0LgIg+OOPINY2hNQ3Hg2J4CumoP+bPfRCwrCssNZVK5YeIqSJH/iXEX9MD1oVkTq4hjRloMJpt3hlBp6Ouh2NvPwjBkiHQpSgZC7xEdKjWbzz9S2G3HKx8bo66te+Of+oVnvA+4RjTibOgucyzrHSnfTYuyWbPKXLd6f+b9wLcljwTDE=; 20:bevFA2sSi6KSueQKMU5PqJv0nxRP8M+8UR7lKtF2MGJPtpXEdkc2AOymAktPBhR8xhrQpPReKPwl8QzBctONnRfmf2iIW2+8eDP40cjVDNpCNaSfZcql8OjuNzwohAM9ciz8IBTXPGxbNIWaln15TyTD8U33UYFvgAE4dx8+s1pYuXqSDHTGrSRwQEuJ4UUpH29lSjL9DffBBUUsPhTYNhnF2iFQNom6l/EO8H51/CRLXnGlG8OZ1r4iF16cYtmkrOp5KSAnLetHoEsP26BucZFWNjXtd1DEO09GwglXbo3f4upDgCP3rxBDJRJQy8L+Ikq5Pjoj3kfaqlwmPkgcLg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001); SRVR:AM3PR05MB1396; BCL:0; PCL:0; RULEID:; SRVR:AM3PR05MB1396; X-Microsoft-Exchange-Diagnostics: 1; AM3PR05MB1396; 4:v2pW9ow92RKX3ZyQErEndi4cdXEZdua0tIvbxaGZ5nBsU0IVefryXCaFMLS/8bm5UJDLlM4dxAUlLidPOe7N0HywY/vfomw9C1CH97ZXS2Jcbw+PMo7kJBt0jmdDMNb3b5jZSCv0PKyvLDxohBMWizA3xNBuwUGdSDU+s+0u0xfPQNe0YWIuKsYYh1Hpwip9lmtSsaPyZrVRh3R4HLm+L41yFL12n3VoHnXVlR+ARf6wLh7FL6aFMlcoLV3WFV1hF/3176pUpD9iorFd8FG6B7VVfQ5lUXMoDhvTqaUMgvr8iIMYF8fpe6ApV8Nho2sQOss0xLBuN4IIMmBdEcdtfLDUeMjDXfuEGX9oD/afe8PksQqPUyldPp2ltArty6mpEZNnlGujGmgpWh5J1jpOUQ== X-Forefront-PRVS: 00826B6158 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(979002)(6009001)(7916002)(199003)(189002)(7416002)(92566002)(36756003)(47776003)(189998001)(6666003)(305945005)(68736007)(229853001)(5001770100001)(97736004)(66066001)(4326007)(33646002)(105586002)(5660300001)(50226002)(106356001)(8666005)(2906002)(586003)(2950100002)(107886002)(50466002)(1076002)(76176999)(81156014)(50986999)(81166006)(7736002)(6116002)(3846002)(5003940100001)(42186005)(7846002)(8676002)(53416004)(101416001)(69596002)(86362001)(19580395003)(4001430100002)(48376002)(19580405001)(7059030)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1102; SCL:1; SRVR:AM3PR05MB1396; H:tdx-in-nb-0014.toradex.int; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: toradex.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM3PR05MB1396; 23:ADeJ506kdUSkG7MBORFbGcGVC1hP3GQoZTGVo98Zs?= =?us-ascii?Q?bijVUts8+vuDcp6XRc5oQSSt8HvdiN+LeX+4xyLTTctft7mtqmWzdQqTwgyA?= =?us-ascii?Q?5DPFquvDiDwStZGu4Y5+lU8NNMyFornFh+8o/WcjR5DnWaA8coX8j97hZbCA?= =?us-ascii?Q?XVzVHCG1d3JiMhoyj/X5d/HAaaWX9ifkPw/bxhG5RilTK8CtqNucQSeU4WyZ?= =?us-ascii?Q?8QWYtq7gXDxtpN7WlHF8151EPOlynLWO6gVdbxzxpN+thFDEJnJxP2Vt4vQZ?= =?us-ascii?Q?meTjmAZPNztI8MUnAKJcRBoY1dQk//nZ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gM435y/jePO3Du7+fUkvA3gGHMr4To77QbBazdLwPDmTStfiYk2/hFfXxiQA7fN0Gd/ikT2kzHtoM SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: toradex.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2016 10:14:54.0628 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR05MB1396 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161001_031517_335407_936CA7AC X-CRM114-Status: GOOD ( 12.43 ) 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, linux-pwm@vger.kernel.org, l.majewski@samsung.com, Bhuvanchandra DV , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, stefan@agner.ch, robh+dt@kernel.org, kernel@pengutronix.de, fabio.estevam@nxp.com, linux-arm-kernel@lists.infradead.org, Lothar Wassmann 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 From: Lothar Wassmann Change the pwm chip driver registration, so that a chip driver that supports polarity inversion can still be used with DTBs that don't provide the 'PWM_POLARITY' flag. This is done to provide polarity inversion support for the pwm-imx driver without having to modify all existing DTS files. Signed-off-by: Lothar Wassmann Signed-off-by: Bhuvanchandra DV Suggested-by: Thierry Reding --- drivers/pwm/core.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 195373e..aae8db3 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -137,9 +137,14 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args) { struct pwm_device *pwm; + /* check, whether the driver supports a third cell for flags */ if (pc->of_pwm_n_cells < 3) return ERR_PTR(-EINVAL); + /* flags in the third cell are optional */ + if (args->args_count < 2) + return ERR_PTR(-EINVAL); + if (args->args[0] >= pc->npwm) return ERR_PTR(-EINVAL); @@ -149,10 +154,12 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args) pwm->args.period = args->args[1]; - if (args->args[2] & PWM_POLARITY_INVERTED) - pwm->args.polarity = PWM_POLARITY_INVERSED; - else - pwm->args.polarity = PWM_POLARITY_NORMAL; + if (args->args_count > 2) { + if (args->args[2] & PWM_POLARITY_INVERTED) + pwm_set_polarity(pwm, PWM_POLARITY_INVERSED); + else + pwm_set_polarity(pwm, PWM_POLARITY_NORMAL); + } return pwm; } @@ -163,9 +170,14 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args) { struct pwm_device *pwm; + /* sanity check driver support */ if (pc->of_pwm_n_cells < 2) return ERR_PTR(-EINVAL); + /* all cells are required */ + if (args->args_count != pc->of_pwm_n_cells) + return ERR_PTR(-EINVAL); + if (args->args[0] >= pc->npwm) return ERR_PTR(-EINVAL); @@ -672,13 +684,6 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id) goto put; } - if (args.args_count != pc->of_pwm_n_cells) { - pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name, - args.np->full_name); - pwm = ERR_PTR(-EINVAL); - goto put; - } - pwm = pc->of_xlate(pc, &args); if (IS_ERR(pwm)) goto put;