From patchwork Mon Nov 8 13:46:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 12608413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B841C433EF for ; Mon, 8 Nov 2021 13:46:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BADBE6115A for ; Mon, 8 Nov 2021 13:46:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BADBE6115A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QU5S+DgMJ7t2Ei7twJBllW2fembU/6MRhkunItEIGqc=; b=BgFPGdjyiOkwa9 fCQ8mvIsftG35CIH/RQxbXZHCxT+eQWQBOfEyx6hkcSQ+vPfWeXb1oB7OzYo+HUxGD3TaGCQ8mt0r 35WT/2t764RG+3mjbxTVKTxDAsMCl1jS1CHHiRoOSle99mbH+D2lt+4raiqDGQK6uBFm46MiLV4Ph yo3+VvFGWwg74/brr6XVOCz5c6lZgezdpDfNUnfddfikQiPpv9LxQdAlpXChoSbkbe9qK68i35qj5 JKhS5N0AaA/4177ykfpUJt5gYBL1C/zGWDtFtXrrDMAupQ1luFV+N3BtfmOSRpiZh7noFkrhuTxeF MKbGzAoResFOwwHSsxFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mk4yx-00GWb1-DV; Mon, 08 Nov 2021 13:46:43 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mk4ys-00GWZ0-7q for linux-amlogic@lists.infradead.org; Mon, 08 Nov 2021 13:46:41 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mk4yn-0004Ug-Kw; Mon, 08 Nov 2021 14:46:33 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1mk4ym-00069F-5t; Mon, 08 Nov 2021 14:46:32 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1mk4ym-0002pL-4o; Mon, 08 Nov 2021 14:46:32 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Thierry Reding , Lee Jones Cc: Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , linux-pwm@vger.kernel.org, linux-amlogic@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH 3/4] pwm: meson: Simplify duplicated per-channel tracking Date: Mon, 8 Nov 2021 14:46:26 +0100 Message-Id: <20211108134628.120474-3-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211108134628.120474-1-u.kleine-koenig@pengutronix.de> References: <20211108134628.120474-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=rNZrjCvgYmAqlJ5riojVlnaxpCf4wtmwd9yLL/nP0PM=; m=5XgqPhF6+YixcIl9jZOqNtNzkP5opD+m/1BKa93KXaM=; p=wj2PEOpn/8zNM06wPsEr602+lpcO38hRz6y9qIvpvBg=; g=2eaf700f1bee0410d39a81c3eecddf3d6da7db05 X-Patch-Sig: m=pgp; i=u.kleine-koenig@pengutronix.de; s=0x0D2511F322BFAB1C1580266BE2DCDD9132669BD6; b=iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmGJKi0ACgkQwfwUeK3K7An8igf+INv cesPBBF3ca/KVzDkShBEJWZ1BVxrlZYKESmYp1sHbfMBtt2rAqQdGULLf70AYEiyzwi+5I4wPPrKk 9MyOapg0LS6ioCsC1ItQENjdArGwEybcHlx3uUNLPXPFatVe940MWOGbTA0NoDZoI907tysjtfAA6 6Iz1n58FZTyedYOjeyoJFOTEYSpITgd08jtD+morYCqD1h8sg/3fDWDcq9VkgDfeHHdrxnPgTa5mk izu2biIvenHBJ5eW53m5gkeyPQkFDde7S38uc01IPj+yM5AtPNH/37J+9Lg+2gYT12WYJCi84D52B lHkM7e1T4OsKs9ZVhX6R3NX2sMk8YPw== X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-amlogic@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211108_054638_357328_CB6EE26B X-CRM114-Status: GOOD ( 12.96 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org The driver tracks per-channel data via struct pwm_device::chip_data and struct meson_pwm::channels[]. The latter holds the actual data, the former is only a pointer to the latter. So simplify by using struct meson_pwm::channels[] consistently. Signed-off-by: Uwe Kleine-König Reviewed-by: Martin Blumenstingl --- drivers/pwm/pwm-meson.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c index 1fbe54a2abfe..908e314c7c00 100644 --- a/drivers/pwm/pwm-meson.c +++ b/drivers/pwm/pwm-meson.c @@ -141,12 +141,13 @@ static int meson_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) return err; } - return pwm_set_chip_data(pwm, channel); + return 0; } static void meson_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) { - struct meson_pwm_channel *channel = pwm_get_chip_data(pwm); + struct meson_pwm *meson = to_meson_pwm(chip); + struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm]; clk_disable_unprepare(channel->clk); } @@ -154,7 +155,7 @@ static void meson_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm, const struct pwm_state *state) { - struct meson_pwm_channel *channel = pwm_get_chip_data(pwm); + struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm]; unsigned int duty, period, pre_div, cnt, duty_cnt; unsigned long fin_freq; @@ -217,7 +218,7 @@ static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm, static void meson_pwm_enable(struct meson_pwm *meson, struct pwm_device *pwm) { - struct meson_pwm_channel *channel = pwm_get_chip_data(pwm); + struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm]; struct meson_pwm_channel_data *channel_data; unsigned long flags; u32 value; @@ -260,8 +261,8 @@ static void meson_pwm_disable(struct meson_pwm *meson, struct pwm_device *pwm) static int meson_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, const struct pwm_state *state) { - struct meson_pwm_channel *channel = pwm_get_chip_data(pwm); struct meson_pwm *meson = to_meson_pwm(chip); + struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm]; int err = 0; if (!state)