Received: by 10.223.185.116 with SMTP id b49csp3805734wrg; Mon, 26 Feb 2018 06:25:28 -0800 (PST) X-Google-Smtp-Source: AG47ELv4CMXpzGd2mZS0CkEWGl+oZ3u2PlEmcjawGO8CCJyBEcaVpTMdcemamDMvnc9N6KilsUk7 X-Received: by 2002:a17:902:2845:: with SMTP id e63-v6mr1877853plb.389.1519655128822; Mon, 26 Feb 2018 06:25:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519655128; cv=none; d=google.com; s=arc-20160816; b=BgvC5QA/MVGFNJBzvpejgWtoF/HpwZwgay/GcAXDam9fZHosXlUQkjJZinnMyxVtpN ACd1TaBovmFUyqcPb+pDrXLbeNnrq8k7mbz1F5Rs8rYOqEeM/pMsLjW92vZ23jYrDHqr QUZhSfjociE8fXsqhKz4mQ1Y4A7PXT30gAuegcRPhFMq4qg4QrUAAf1ZBuRfowrKhpRH yOWy2OCj6G3kkNR3smtJFi5lKslz6gIy7YiJmpWt4ED3TkaSpyD25BG5crwH8yxt0oGo TLwU411l5gaOtmI+TSiqgCyecEJfsAMZLdk+npfdscCq4az2gxE7kDm5zKSm55ilbuK6 +DHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=OXlsdcEMvOTTaqVmI5MY4gc7T0iPGDKHIp357v89dzo=; b=NUKcpJ24KoSZhmHZm3h1MZg5uAKT1STqwcdzg2m2MIkDkjj2ygFJ6ImeJpuD6oSvZN S5S9OO+IsniPhRYiChfumQUtxFRRIEvh2OquXVDEGowQtn0dUkEoBk0xw8O2pmJ2YRUS +cf/x/k9HZ4SqAcKmACJr/tgYMyyNxjRMvd/Zk+jL861E3eSjXAe8mXh+yhpouY4h24C GHCGUkhVG2S1u9W4MCfJWH5U4Ksf2ls8rtM8RKttW8Hrk7RDN9gtzJpO0gtlUD5EKIuK yBUYmjIw7mLUyW/fJWgaeyFmc78OaFaN27F66tL1gCZ13Seq6XOu/PlSOV9zV6zTnp2f 8LMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e24si6790803pff.233.2018.02.26.06.25.13; Mon, 26 Feb 2018 06:25:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753594AbeBZOYe (ORCPT + 99 others); Mon, 26 Feb 2018 09:24:34 -0500 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:26276 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753325AbeBZOY1 (ORCPT ); Mon, 26 Feb 2018 09:24:27 -0500 X-IronPort-AV: E=Sophos;i="5.47,396,1515481200"; d="scan'208";a="11497802" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 26 Feb 2018 07:24:26 -0700 Received: from [10.145.6.76] (10.10.76.4) by chn-sv-exch07.mchp-main.com (10.10.76.108) with Microsoft SMTP Server id 14.3.352.0; Mon, 26 Feb 2018 07:24:25 -0700 Subject: Re: [PATCH v3 05/10] pwm: add PWM mode to pwm_config() To: Jani Nikula , Daniel Thompson CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , References: <1519300881-8136-1-git-send-email-claudiu.beznea@microchip.com> <1519300881-8136-6-git-send-email-claudiu.beznea@microchip.com> <20180222123308.mypx2r7n6o63mj5z@oak.lan> <87po4s2hve.fsf@intel.com> From: Claudiu Beznea Message-ID: <3a70b89c-b470-3723-760c-5294d0a75230@microchip.com> Date: Mon, 26 Feb 2018 16:24:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <87po4s2hve.fsf@intel.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26.02.2018 11:57, Jani Nikula wrote: > On Thu, 22 Feb 2018, Daniel Thompson wrote: >> On Thu, Feb 22, 2018 at 02:01:16PM +0200, Claudiu Beznea wrote: >>> Add PWM mode to pwm_config() function. The drivers which uses pwm_config() >>> were adapted to this change. >>> >>> Signed-off-by: Claudiu Beznea >>> --- >>> arch/arm/mach-s3c24xx/mach-rx1950.c | 11 +++++++++-- >>> drivers/bus/ts-nbus.c | 2 +- >>> drivers/clk/clk-pwm.c | 3 ++- >>> drivers/gpu/drm/i915/intel_panel.c | 17 ++++++++++++++--- >>> drivers/hwmon/pwm-fan.c | 2 +- >>> drivers/input/misc/max77693-haptic.c | 2 +- >>> drivers/input/misc/max8997_haptic.c | 6 +++++- >>> drivers/leds/leds-pwm.c | 5 ++++- >>> drivers/media/rc/ir-rx51.c | 5 ++++- >>> drivers/media/rc/pwm-ir-tx.c | 5 ++++- >>> drivers/video/backlight/lm3630a_bl.c | 4 +++- >>> drivers/video/backlight/lp855x_bl.c | 4 +++- >>> drivers/video/backlight/lp8788_bl.c | 5 ++++- >>> drivers/video/backlight/pwm_bl.c | 11 +++++++++-- >>> drivers/video/fbdev/ssd1307fb.c | 3 ++- >>> include/linux/pwm.h | 6 ++++-- >>> 16 files changed, 70 insertions(+), 21 deletions(-) >>> >>> diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c >>> index 2030a6b77a09..696fa25dafd2 100644 >>> --- a/drivers/video/backlight/lm3630a_bl.c >>> +++ b/drivers/video/backlight/lm3630a_bl.c >>> @@ -165,8 +165,10 @@ static void lm3630a_pwm_ctrl(struct lm3630a_chip *pchip, int br, int br_max) >>> { >>> unsigned int period = pchip->pdata->pwm_period; >>> unsigned int duty = br * period / br_max; >>> + struct pwm_caps caps = { }; >>> >>> - pwm_config(pchip->pwmd, duty, period); >>> + pwm_get_caps(pchip->pwmd->chip, pchip->pwmd, &caps); >>> + pwm_config(pchip->pwmd, duty, period, BIT(ffs(caps.modes) - 1)); >> >> Well... I admit I've only really looked at the patches that impact >> backlight but dispersing this really odd looking bit twiddling >> throughout the kernel doesn't strike me a great API design. >> >> IMHO callers should not be required to find the first set bit in >> some specially crafted set of capability bits simply to get sane >> default behaviour. > > Agreed. IMHO the regular use case becomes rather tedious, ugly, and > error prone. Using simply PWM_MODE(NORMAL) instead of BIT(ffs(caps.modes) - 1) would be OK from your side? Or, what about using a function like pwm_mode_first() to get the first supported mode by PWM channel? Or, would you prefer to solve this inside pwm_config() function, let's say, in case an invalid mode is passed as argument, to let pwm_config() to choose the first available PWM mode for PWM channel passed as argument? Thank you, Claudiu Beznea > > BR, > Jani. > >