Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754913AbcJGSX6 (ORCPT ); Fri, 7 Oct 2016 14:23:58 -0400 Received: from mail-db5eur01on0113.outbound.protection.outlook.com ([104.47.2.113]:22656 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754563AbcJGSXt (ORCPT ); Fri, 7 Oct 2016 14:23:49 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=bhuvanchandra.dv@toradex.com; Subject: Re: [PATCH v2 2/6] pwm: core: make the PWM_POLARITY flag in DTB optional To: Lukasz Majewski References: <20161001101235.24598-1-bhuvanchandra.dv@toradex.com> <20161001101235.24598-3-bhuvanchandra.dv@toradex.com> <20161006083642.6a28a629@jawa> CC: , , , , , , , , , , , Lothar Wassmann From: Bhuvanchandra DV Message-ID: <815c2a76-a22d-8938-6d27-ff3da5694791@toradex.com> Date: Fri, 7 Oct 2016 10:19:57 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161006083642.6a28a629@jawa> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [115.115.243.34] X-ClientProxiedBy: KL1PR02CA0033.apcprd02.prod.outlook.com (10.165.15.43) To VI1PR05MB1407.eurprd05.prod.outlook.com (10.162.125.156) X-MS-Office365-Filtering-Correlation-Id: 3b53b556-8aa0-4588-135a-08d3ee6dc0d9 X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB1407;2:ptV6INeMJFWpSEsV4NM88WY/4FQJL+KioVJ5tZxaGfpc8ciih2pjFEWvY5CwbDuhsobup8kBIeLY91gqnVnFSfEQRGdWXjFG3ujMiqnyMxGsKBxrua9b335IzDFgg45AVBp0xr1jHAphjIVU30X+njy8vc1nptQQk9n2d7+mCJHCH9CIzu7pY9PWjVFIaIW1X5Y0Nu/1ak7rFXKIn/6VwA==;3:0UoJkQ3uZlTTAX13ak+8h4m4K4XwNl5ZdJzcNNjc/l3Ziro+6NGczr+HypEFczWvGeZkMIgr6POiCL6pz7suHV8OHELKahIFy2KMMksJQPs5EsYS04I9bypoPhyH1pew0BgF8iGWFFmPhf2CWB7Vjw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VI1PR05MB1407; X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB1407;25:BYReEkhl3zEAxxCdJnB1J7fR/IzL2lu3m2JQFxbuJW35C9GlcWSYEosLWFS3SMUb1UMi2C0hFc/oZH+Ps37+O4WkSo6BngxBE/+BMW6q6MthOedyY2JZv0rli263LxJHY+wGU9M7KREHqcGGNVDGavwM8+cvlE/HaiEomxluE+r4n+9opPtzaDdLuQT8/fQwHyqi9lxbWUVfrqtirFRwbjBOfv8AeNTxGjHr8yIHCiS7M0uSbKYuBts507Ae41GaWaTFnHBNcIhabT0tTjbSFK7/+QWNd7SkLQP85xwo6h1E5R/VLooyrnp8EG09JtRVAQnT1ZpEQT7NDCJ4JWrGfz8F8Av055XocA3Js3Rdv44HO5IfpfFujRWKy0fxmx/AzdIY7MocpE0QHg4UJ4hkKau2r+UMUcwclWRQXsxRezhfo0mntikgM6BtgVNlwPg9/NLfMuoCWKmaAGYwbvqxfdlo68IUSI6iYHOr4UW1BwCvuouP74EMsHEFhxq5INl4LAhrhajngQz/BGDCzz5J7F6ycEVcx5owp0T1VXxWz3mUX4TunBXfftJvevoY9orvioPFMZN7IxCpUkxfTJqTYKU93f/ewoDKodhVOsTKkzFsh7h1adGdfmhI93Uixe4COrWG8Zz0n4A2UDWj8W8f7VlLOYlMxIx3NZkthNqs+yh+k/BlQ1gtaolHRnp9Wg8TFVPrVMp2qgCR6y53XMmd0IM9AOURr/ki9Jr6zVLpy40= X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB1407;31:eJV4R2r799/lLQKQy3NIG5opNAdp0B5UFvPZFeNxMGm7D9z8L1dimoDyrGiSsZ1Qddc5blFnKWAmYQXAw2X1Aa7d3r/m0eFofxu0wfI/2AVakDjkde9nP5TDdTrI3MB6oxPPpfcjewbCpwyQMmmDhohWzfqKKUWSa0sRqUvhvljA1oekIXQOzTM1GxymwhAzMIjLVyXH2hiqK3R3JdM2+shwLgXpf0kR39cKK7MHyCTxg0OopUUR3ilDEqLZ+472ePcBQtArOsrARzEQg4mLWA==;20:P63dJxVCJd3A3VOwKplbYVqVRZ7s6E2c2cYmxyrX7bykXmVGLQBCyNyZR7l8HX1b4KMoC78vh+ydlrk+xRSio2NSHHWmKFHu0u9HioKUggb3QHYRw9l72Q3a6fArhVpRSUkrisSKxNjNZYDVMz/lA50kJabF+PfxH0mF0avoLe5EumLkF39p9nb+/gv8zjK2jeFvscSm8RDlNJNCKYW+IGwPFoKjwV/kNiXMCMhSeZUp/9U9pvZI3RWabDwMjdiMyW36rOsiQfcvZGgU82tX34GHZD5H4rqO2NaHKl4ja546myhZsSVGOVCmqX/dXRgHjEt6F8cAoQXGT7tPqT651g== 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:VI1PR05MB1407;BCL:0;PCL:0;RULEID:;SRVR:VI1PR05MB1407; X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB1407;4:itDZvv0MCcJsAvq54774TkoBORPRjx0ooV4zTmeEg19cFi2fN1VqW+13kLD8PZ3ULG2cOm7XBSY2eM/bmUBRbPAoe5a1WuWkFHTNMC+lr6b1N0rtjB2CGyRZwvfqYnd3hfm6V6nv7fCZvcSVnik3vCyWEOd4VRCNVhxrIGd6AcNbgMxa6lCNC7ZxN2eEPeMs8X+3AWftYsut53R3KB8m6NSU6671azoi5cELbQxAOTsWS6lPjabFLEBv6LDn9kipuUjq1mG536EwVRcxadFcSRnZcr1beM5vYlw8+TTmk6cTDH+n1YTQ5e4uEu+JaBGfXAKFyPEEZ6+ZkaSuJsbjRVCxBv02MOt63fgK2wtrzmlWnS242WXAY0g6BsXpm6eacAjKZFyt87IWpQ4PaQAvAEQsPLSI1EFhp0gPD11Mzts= X-Forefront-PRVS: 0088C92887 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6049001)(7916002)(189002)(24454002)(199003)(2950100002)(65806001)(6666003)(65956001)(47776003)(66066001)(83506001)(6916009)(33646002)(50986999)(101416001)(76176999)(54356999)(42186005)(19580405001)(19580395003)(105586002)(110136003)(106356001)(23676002)(31686004)(305945005)(7416002)(8666005)(7736002)(65826007)(7846002)(5660300001)(36756003)(81166006)(81156014)(8676002)(68736007)(77096005)(97736004)(189998001)(4326007)(4001350100001)(50466002)(64126003)(2870700001)(586003)(3846002)(6116002)(2906002)(86362001)(92566002)(31696002)(7059030);DIR:OUT;SFP:1102;SCL:1;SRVR:VI1PR05MB1407;H:[10.18.0.138];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtWSTFQUjA1TUIxNDA3OzIzOnhGM25oRzVqLzE5YTB0clFmc1puMVFid3ll?= =?utf-8?B?V2dqcXNFMVFLam11d0l1Z1Aza3ZMZlBTSVpTOTQ2TDgzTW1YNVh4WkxOVnE5?= =?utf-8?B?NHU3Z2xQZWF1RXRDSlBBRlF6bjJPbzBNVGlOL3Y3WjEyZjFTQmM1SzBCV0Fw?= =?utf-8?B?Y1E3NVdlYjNLdC9NUnVZV280NHc0dE5NRGZ6WTk2TlhRaEFGK0k5MzF4SmtM?= =?utf-8?B?cldwZUpIa29GeU9pZ1BYRldwa0ZjbHNCNXNQU0lQVWxuQ0FaUnl2aUZROW9H?= =?utf-8?B?RzZBczhYYXljVDdidjZ6M2ZnZnpURXc1TEY1R0ludDduU2lGdk5HbnI3Z2hq?= =?utf-8?B?Q1ZPNDduV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kYl0IYZ6RUawM1xS2de53K0may1eDli0HU+s2gqdrkz03EyVWZdnxjMgrh9b5tjyS9v4xqSQlF/9F0hZGlE9NVUquvtIAlZ8Z12RgJoD0e23N0J+mD9mTD0Gc4zxEgMS9rpzDMwEHeq6F+RikAcIJYoZTOps3VnmmOr+3yT4=;24:x0sGZIFonJ87H0pC8U4KXlCEVLDhXp5ylBCHJJdOaCO3OI7VWuE3aurG21r3MCB410RYDuV4Qf6onxqQWHkSESJa0wpZGrh/1fYycD5OQC8=;7:EH8irM5dLc8237PDkG+359WeQUWdBPn6lfQ24kmWEaA6CMJxkId9W+0FFHJMiYXNi/7y8OZmPj9oGgfsA4DIdYO9QMSanAR2z0eIHC5JzZ9e1yYHp+74Wm7cZLrttl/s3icfTs/Gg6rvMtoxsE78bNX0lc0/nDQs6DFRsO+yGtyQ3Mki+oYM5tqaenTqw4rveZC4OHTgT2gIHqizqL++hJF6FsSNUH4RS59voHLMskLzUksqPAAcmJxPnKgnibsSJ1HjjtWG8uvKEY6RnMAEyCmK8jn2HlAXkQygjOHwrclj6w5PcVNtVoz8fhRzLgo8AYvdEcC/RtSp+NNeaRX8+g== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: toradex.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2016 04:52:30.6028 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB1407 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3338 Lines: 109 Hi Lukasz, On 10/06/16 12:06, Lukasz Majewski wrote: > Hi Bhuvanchandra, > >> 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); > ^^^^^^^^^^^^^^^^ > here we should set pwm->args.polarity, since > the pwm_set_polarity() calls pwm_apply_state() > which requires duty_cycle and period to be set. > > In this particular moment it is not yet set and > polarity is not properly configured. Agreed. Will do a clean v3 patchset along with the patch you sent (pwm: core: Use pwm->args.polarity to setup PWM_POLARITY_INVERSED). -- Bhuvan > > Patch fixing this will be sent as a reply to this e-mail. Please just > squash it and test on your platform. > > Best regards, > Ɓukasz Majewski > >> + 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;