Received: by 10.192.165.148 with SMTP id m20csp3584934imm; Mon, 30 Apr 2018 02:54:00 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrYStPVahx5baEJTl9BiWNorWOaJPbkftBhP8k5yqCzWGSgA7Jg8jHyU2h9hzpkGPXpfbfN X-Received: by 10.98.160.68 with SMTP id r65mr11115701pfe.235.1525082039957; Mon, 30 Apr 2018 02:53:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525082039; cv=none; d=google.com; s=arc-20160816; b=bIvx60u2T3+64ZUwyL6Rh0YUsd1IbXzFd6w3d5So3rZ3pOZHe8zdjiFKZcvXnmRowc J8mbrio2l0PAVVaRpdoILFlUXV/bs1Z8XCVMnT2a3zpWP4MyYY5dPEGCNfFw0Lp2YJPM PRyFaiuPiTLvkalIglObSWtyEYzeLwOb04IKlg1Uf1KUZPgks5ZYl4qKxH95qyknIWpj tLPq9DvbBCAGzPRXAOM186atZv2wCDo5w5f1bVvYAwv18NVLLfAK1UXspSTCgJXDhdnM s50XNiXeRwAvyCzg3KHduLNCRhXk2gki5PSjuW15C8TkkMwrEo4/G6Uvet53/5K6x8Hx 4hPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=wT74rgCsD1mNwP5LYNX6hwgUMiGnfTDE1Mk9TZ12klM=; b=o6URF/CegeIoBiIGmwruZstpwQgP1N0uRVG5urdhAaPpP9ShqWdwhLbL5vY363NrXR xg1whj2qceLd81CBAK7gtvY0h1o4NgSajhjK9Y2QfGe8fvtpc30kZ3st0JhXE1Ii7I2e bvskkT0iF/R6GNQzAlWH17dn0gTuo7jut6evpOUBGVs9aqSdU0+UjWZ1kvF253Pe8rYv xgew2Qj98wL17H+YX8qIW8RCJJm2wh1z4VKrmuagc5toMMbzJOMslU6xtJLeNm6PTSAS mivQUps4jh3mqh9+ut9hTyDx90h+ySvfEg3XrSQPN/wdKrMhJjHUxbzFT1gcqBuebe1p oJ7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GsLv83/W; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2-v6si7458809plz.226.2018.04.30.02.53.46; Mon, 30 Apr 2018 02:53:59 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GsLv83/W; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752729AbeD3JwG (ORCPT + 99 others); Mon, 30 Apr 2018 05:52:06 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:46351 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751513AbeD3JwD (ORCPT ); Mon, 30 Apr 2018 05:52:03 -0400 Received: by mail-wr0-f195.google.com with SMTP id o2-v6so4535238wrj.13; Mon, 30 Apr 2018 02:52:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wT74rgCsD1mNwP5LYNX6hwgUMiGnfTDE1Mk9TZ12klM=; b=GsLv83/WgplR4EEcsrv8+spjgZsrJig4Vn+n8sn6mL6NVEvdDTOkZD0FQchFXQvg4F iDg4aOGXOGJqYNbI70LLX4mS1YcwZXZAyv0W5wff1hvhLXZpKAZc3DapatM4bgPnt8tf nMSOyPdjCQCylE4IilXCyGmRKPWIPk0uGerVfGc4MWQD1qjT2yNL+T3jGGlc/yFGDdOb kdJbe+c9Wr+x45dke46o9XP1s7c1qsRRzIhPnbEVlW5aITDU2TlL9uvSO1KUVR9meMdl kTdJzrHqfpcgIWIJbSdsC/hIsFUQ6x9EVLRTgWnkFK/Nqchy2FYLopOSn4dDpskzcJSl C8Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wT74rgCsD1mNwP5LYNX6hwgUMiGnfTDE1Mk9TZ12klM=; b=FXd/rRzdxyRz5doF3bImIyxwhjiE52U1SSdyK0JtC0JGvjuYmbPCxiJDJiI4ykB0Dr Uho40mYLISuKhNWOkuia4LhCkuyiGrx6DaRtEKKHkSEKGIiA7O/+MsEGj6Jz+oS7Uh8a +0TXYAdEF4Y5ss/OJwUsaI52AUUVyGD3DC/vtNI6vhRS+Ll7oDAaBram5qwVRMMtcr1e Z/o9JTT/DW0XMbA/aEfcDBx18CuoGb4jMfWuw607vKB6sjvp8IsH60LLse6k0FCIEfv+ pKwuLQzwolK8ebPw3tJ8aYzl+/oxC5GnqfFeeh1AwXN3+myJUBEfK4kjOGtePF43k4ve tDSg== X-Gm-Message-State: ALQs6tCYonhR2n3h0ElcuGEzxdezqnMmLk8rZQm26QggqCTh5dgEekG/ hu3lA7ffi++5j8+TTA1WQl8= X-Received: by 2002:adf:adf0:: with SMTP id w103-v6mr8860635wrc.101.1525081921346; Mon, 30 Apr 2018 02:52:01 -0700 (PDT) Received: from localhost (p200300E41F041C0032947E635CB49D15.dip0.t-ipconnect.de. [2003:e4:1f04:1c00:3294:7e63:5cb4:9d15]) by smtp.gmail.com with ESMTPSA id u8sm6897913wmf.3.2018.04.30.02.52.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Apr 2018 02:52:00 -0700 (PDT) Date: Mon, 30 Apr 2018 11:51:59 +0200 From: Thierry Reding To: Rajkumar Rampelli Cc: robh+dt@kernel.org, mark.rutland@arm.com, jonathanh@nvidia.com, jdelvare@suse.com, linux@roeck-us.net, corbet@lwn.net, catalin.marinas@arm.com, will.deacon@arm.com, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, pombredanne@nexb.com, mmaddireddy@nvidia.com, mperttunen@nvidia.com, arnd@arndb.de, timur@codeaurora.org, andy.gross@linaro.org, xuwei5@hisilicon.com, elder@linaro.org, heiko@sntech.de, krzk@kernel.org, ard.biesheuvel@linaro.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, ldewangan@nvidia.com Subject: Re: [PATCH V2 1/9] pwm: core: Add support for PWM HW driver with pwm capture only Message-ID: <20180430095159.GD2476@ulmo> References: <1521607244-29734-1-git-send-email-rrajk@nvidia.com> <1521607244-29734-2-git-send-email-rrajk@nvidia.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="+B+y8wtTXqdUj1xM" Content-Disposition: inline In-Reply-To: <1521607244-29734-2-git-send-email-rrajk@nvidia.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --+B+y8wtTXqdUj1xM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Mar 21, 2018 at 10:10:36AM +0530, Rajkumar Rampelli wrote: > Add support for pwm HW driver which has only capture functionality. > This helps to implement the PWM based Tachometer driver which reads > the PWM output signals from electronic fans. >=20 > PWM Tachometer captures the period and duty cycle of the PWM signal >=20 > Add conditional checks for callabacks enable(), disable(), config() > to check if they are supported by the client driver or not. Skip these > callbacks if they are not supported. >=20 > Signed-off-by: Rajkumar Rampelli > --- >=20 > V2: Added if conditional checks for pwm callbacks since drivers may > implements only pwm capture functionality. >=20 > drivers/pwm/core.c | 21 +++++++++++++++------ > 1 file changed, 15 insertions(+), 6 deletions(-) >=20 > diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c > index 1581f6a..f70fe68 100644 > --- a/drivers/pwm/core.c > +++ b/drivers/pwm/core.c > @@ -246,6 +246,10 @@ static bool pwm_ops_check(const struct pwm_ops *ops) > if (ops->apply) > return true; > =20 > + /* driver supports capture operation */ > + if (ops->capture) > + return true; > + > return false; > } > =20 > @@ -495,7 +499,8 @@ int pwm_apply_state(struct pwm_device *pwm, struct pw= m_state *state) > * ->apply(). > */ > if (pwm->state.enabled) { > - pwm->chip->ops->disable(pwm->chip, pwm); > + if (pwm->chip->ops->disable) > + pwm->chip->ops->disable(pwm->chip, pwm); This is not a good idea. It means that you'll be able to successfully configure a capture-only PWM channel for output. I think all of the output configuration functions should return an error (-ENOSYS?) for capture-only devices, much like we return -ENOSYS for pwm_capture() if the driver doesn't implement capture support. Thierry --+B+y8wtTXqdUj1xM Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAlrm5z8ACgkQ3SOs138+ s6GW/A/+MImm7BmQSd+UOQUP4N0vddntkXN9FGKsxb1wIZPQBPMKfmH5xpBzfb61 hz1s8KLWOpgqEZQVs7eVp2ICQEOXNgwKdCWbHPsHIU+FUf5zd1ESd7rNu9IrddhR ZM2lU8YGaREnIFPt2dFpjLVuXA8ak7id02RdeoylpLRaTlgcdE3q1AEY5ewnTNRn JLI4eEroYAfwtJVC5PSvdZvD5Diq2H+ASe+McYSAbTg8+rHQ3w4KMmTIKoEiv4Us UCwF89+zCm3K+AVcvdCe2jBSc2OtZm6QXY9BrhIBnGf4D9fGWBTQ0cmZpHtcxHhf YOqyb+tM1rFgZutFgcrJ2fmFRZp2wrJjGByilhwEWfrdM57zrCQSLPWdnELOIETM 4aGyI1cmKc2DIdXI4Ksv7PRN3LBvvxq8H0Revozmi1MfNWrcB2Qr7sgvBNYTHTfi T5TWD8oWJ6rs9E+JUJd7SU2fimoDft7i7bbA26mKFN65Y+i7jgCi3d/lTDhVMMA0 nby4wCgKDGnTK9vXsNK93WhUB5R3d6jXAgOePb3UotYIcE2z4hUv8I0Rp24PJWh4 s4zL38OPugoEI0iPfTodURu1m7F1QK2wOdd48OzQBRiQ9nFXywm8KLVxVLZoSck6 xsY1+I848Lu/UNHULnbaCY163rDTcM9/PJwRFrnuCA2Lpr/9M/s= =yusN -----END PGP SIGNATURE----- --+B+y8wtTXqdUj1xM--