From patchwork Mon May 31 19:49:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12289957 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B16FEC4709E for ; Mon, 31 May 2021 19:49:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 927556128A for ; Mon, 31 May 2021 19:49:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232064AbhEaTvW (ORCPT ); Mon, 31 May 2021 15:51:22 -0400 Received: from mga14.intel.com ([192.55.52.115]:39326 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231624AbhEaTvS (ORCPT ); Mon, 31 May 2021 15:51:18 -0400 IronPort-SDR: pa3cvLMOxdJSs/GYct9eK+swECJ5e4lk0T+2sJysaVEfyXB6NEmiUnq90uHl2bIjSlVdTVQtkL tmZuN9sBXekg== X-IronPort-AV: E=McAfee;i="6200,9189,10001"; a="203215209" X-IronPort-AV: E=Sophos;i="5.83,238,1616482800"; d="scan'208";a="203215209" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2021 12:49:30 -0700 IronPort-SDR: o+p5JjvtZT6GahBTqKGHMK0fSLH3FVnQjA9jeNY6bjoZofTVwuWYV9q2ODK2oX44C//5aIO5FY CK37vW79+FkA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,238,1616482800"; d="scan'208";a="446696425" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 31 May 2021 12:49:28 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 079C6F2; Mon, 31 May 2021 22:49:51 +0300 (EEST) From: Andy Shevchenko To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Andy Shevchenko , Flavio Suligoi , Thierry Reding , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, linux-acpi@vger.kernel.org Cc: Jonathan Corbet , Lee Jones , "Rafael J. Wysocki" , Len Brown Subject: [PATCH v2 2/7] pwm: core: Always require PWM flags to be provided Date: Mon, 31 May 2021 22:49:42 +0300 Message-Id: <20210531194947.10770-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531194947.10770-1-andriy.shevchenko@linux.intel.com> References: <20210531194947.10770-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org It makes little sense to make PWM flags optional since in case of multi-channel consumer the flags can be optional only for the last listed channel. Thus always require PWM flags to be provided. Fixes: 4a6ef8e37c4d ("pwm: Add support referencing PWMs from ACPI") Signed-off-by: Andy Shevchenko --- v2: no change drivers/pwm/core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index c165c5822703..25f7b3370672 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -852,8 +852,10 @@ static struct pwm_chip *device_to_pwmchip(struct device *dev) * * This is analogous to of_pwm_get() except con_id is not yet supported. * ACPI entries must look like - * Package () {"pwms", Package () - * { , , [, ]}} + * Package () { "pwms", Package () { + * , , , , + * } + * } * * Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded * error code on failure. @@ -877,7 +879,7 @@ static struct pwm_device *acpi_pwm_get(struct fwnode_handle *fwnode) if (!acpi) return ERR_PTR(-EINVAL); - if (args.nargs < 2) + if (args.nargs < 3) return ERR_PTR(-EPROTO); chip = device_to_pwmchip(&acpi->dev); @@ -891,7 +893,7 @@ static struct pwm_device *acpi_pwm_get(struct fwnode_handle *fwnode) pwm->args.period = args.args[1]; pwm->args.polarity = PWM_POLARITY_NORMAL; - if (args.nargs > 2 && args.args[2] & PWM_POLARITY_INVERTED) + if (args.args[2] & PWM_POLARITY_INVERTED) pwm->args.polarity = PWM_POLARITY_INVERSED; #endif