From patchwork Wed Feb 14 09:30:48 2024 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: 13556201 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id EB3DBC48BC4 for ; Wed, 14 Feb 2024 09:40:19 +0000 (UTC) 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=wcrvj2oFJo23hmUJlfeOiOCApdrhT61BFx9BKywnuWo=; b=s946gVzmuSX0e3 BqsDrGaCgL7TO4n3ygTO0gn6wbh+Pu1sIL073Z4JnbzmlwWddLpbamTkPEOV6T5qQN1txe1VE4Pkw XEC/LyYmQFv/509cpeeVNMMMxdw2kuaMMyy0QSro7e0RFAjgOK/86qzsDIiudwF8xjftIVnJJLBP2 kWkY0XYMXDp8XYXjBJnANnWY1e+IEhengybRUE+iwSXBTnHbJ1+F9N4aKdd0hp7stvvnUQteJII54 tHbvHZCDGMUoRIluLuFlrhYLkM6AMfq7wNDskJhobDoPDvOvTxOkOj7RV3ngNLn40BwXbh9QxAGk+ pNlVC3Zr5tKAwwpevhgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBkL-0000000COI7-1kJW; Wed, 14 Feb 2024 09:40:05 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfW-0000000CKuJ-1pcZ for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=oeFgKpQmukUIaWih2llisrwGBGNK1YRNGjFQ09PzPoY=; b=IndjrrksWm9D/7Hz8/zJJzSx/y kJFnubEUah0VAM42okUluRoD9GOwMOGVUir5cNVM9eozy/FUu4xB69sxI+PMDVupx3LVxAQMPA6NP fx7o933i4ejXqhMk9+5EVdUBU98tTVxn6n3wi1kxOh2yo0JYdPIcxoYtFRFE/EYDZf6gt/HmVEX9/ XialvzmbIkAoRF3CqjzcZIz05YbJ73n48J4VbX54oaVls7ZDRHfTmmtFcQ+8uik+OILQf5be2HTt0 KY7coRg3VxGkHNsOESTZ0uxx5E+RMYg9wCs9NWUhhSSCdSesvYCMAsGwCdlsfdCL6sJRiL4LIF5HH B6OXl9EA==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfG-0000000GAbr-2My6 for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:03 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBeo-0004N3-Cv; Wed, 14 Feb 2024 10:34:22 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBej-000f6R-Uf; Wed, 14 Feb 2024 10:34:17 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBej-004XzY-2d; Wed, 14 Feb 2024 10:34:17 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: linux-pwm@vger.kernel.org, Claudiu Beznea , Nicolas Ferre , Alexandre Belloni , Florian Fainelli , Ray Jui , Scott Branden , Benson Leung , Shawn Guo , Sascha Hauer , Paul Cercueil , Vladimir Zapolskiy , Matthias Brugger , AngeloGioacchino Del Regno , Neil Armstrong , Kevin Hilman , Krzysztof Kozlowski , Palmer Dabbelt , Paul Walmsley , Fabrice Gasnier , Maxime Coquelin , Alexandre Torgue , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Johan Hovold , Alex Elder , Greg Kroah-Hartman Cc: kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, Broadcom internal kernel review list , Guenter Roeck , chrome-platform@lists.linux.dev, Fabio Estevam , NXP Linux Team , linux-mips@vger.kernel.org, linux-mediatek@lists.infradead.org, Jerome Brunet , Martin Blumenstingl , linux-amlogic@lists.infradead.org, linux-rpi-kernel@lists.infradead.org, Alim Akhtar , linux-samsung-soc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-sunxi@lists.linux.dev, greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev Subject: [PATCH v6 001/164] pwm: Provide an inline function to get the parent device of a given chip Date: Wed, 14 Feb 2024 10:30:48 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=7837; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=VysffgosBaokCEzVr9CapJ6wP73fslCZ+jQWLzJTRHQ=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIhM7NlIMX1uF2GQrQA4FrQMoPchi57Yvz/JC blz73iQwb+JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyITAAKCRCPgPtYfRL+ TuB0B/9P6zT5YFj/8ggZu30wuJh2FhhmcK5IFWEAn3eCqQlBR1+3r98RrH73NV8ruZe1t4nFx0t c6OsWCmmaXgE6NDq1aepB6xNx+u8uuL4EVlihT9QJVyAeyufdWSSbztRhUXrDwn+FS86xswU0hQ OCGoK2SmNoffSL++99SaLb6zwKJeLP/OE7OHvKNMeD++iM8d5m969WslaGj106z8byRgfAb+gh6 HV3n2oUDQFI0N4yfDlHO1Kbc0wLdEc4o1zQa3Kh4g0DpRCV9Wh8qYU/HDpDq4cIQi3DHD9CNJns wVoX4dBy6zyY+YlCipT3YD5PfL124GflRsA1quEFk0pOzKp4 X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093451_096767_40542303 X-CRM114-Status: GOOD ( 24.26 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently a pwm_chip stores in its struct device *dev member a pointer to the parent device. Preparing a change that embeds a full struct device in struct pwm_chip, this accessor function should be used in all drivers directly accessing chip->dev now. This way struct pwm_chip and this new function can be changed without having to touch all drivers in the same change set. Make use of this function in the framework's core sources. Signed-off-by: Uwe Kleine-König Reviewed-by: Greg Kroah-Hartman --- drivers/pwm/core.c | 42 +++++++++++++++++++++--------------------- drivers/pwm/sysfs.c | 4 ++-- include/linux/pwm.h | 5 +++++ 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 1b4c3d0caa82..830a697826af 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -71,18 +71,18 @@ static void pwm_apply_debug(struct pwm_device *pwm, if (s2.polarity != state->polarity && state->duty_cycle < state->period) - dev_warn(chip->dev, ".apply ignored .polarity\n"); + dev_warn(pwmchip_parent(chip), ".apply ignored .polarity\n"); if (state->enabled && last->polarity == state->polarity && last->period > s2.period && last->period <= state->period) - dev_warn(chip->dev, + dev_warn(pwmchip_parent(chip), ".apply didn't pick the best available period (requested: %llu, applied: %llu, possible: %llu)\n", state->period, s2.period, last->period); if (state->enabled && state->period < s2.period) - dev_warn(chip->dev, + dev_warn(pwmchip_parent(chip), ".apply is supposed to round down period (requested: %llu, applied: %llu)\n", state->period, s2.period); @@ -91,20 +91,20 @@ static void pwm_apply_debug(struct pwm_device *pwm, last->period == s2.period && last->duty_cycle > s2.duty_cycle && last->duty_cycle <= state->duty_cycle) - dev_warn(chip->dev, + dev_warn(pwmchip_parent(chip), ".apply didn't pick the best available duty cycle (requested: %llu/%llu, applied: %llu/%llu, possible: %llu/%llu)\n", state->duty_cycle, state->period, s2.duty_cycle, s2.period, last->duty_cycle, last->period); if (state->enabled && state->duty_cycle < s2.duty_cycle) - dev_warn(chip->dev, + dev_warn(pwmchip_parent(chip), ".apply is supposed to round down duty_cycle (requested: %llu/%llu, applied: %llu/%llu)\n", state->duty_cycle, state->period, s2.duty_cycle, s2.period); if (!state->enabled && s2.enabled && s2.duty_cycle > 0) - dev_warn(chip->dev, + dev_warn(pwmchip_parent(chip), "requested disabled, but yielded enabled with duty > 0\n"); /* reapply the state that the driver reported being configured. */ @@ -112,7 +112,7 @@ static void pwm_apply_debug(struct pwm_device *pwm, trace_pwm_apply(pwm, &s1, err); if (err) { *last = s1; - dev_err(chip->dev, "failed to reapply current setting\n"); + dev_err(pwmchip_parent(chip), "failed to reapply current setting\n"); return; } @@ -127,7 +127,7 @@ static void pwm_apply_debug(struct pwm_device *pwm, s1.polarity != last->polarity || (s1.enabled && s1.period != last->period) || (s1.enabled && s1.duty_cycle != last->duty_cycle)) { - dev_err(chip->dev, + dev_err(pwmchip_parent(chip), ".apply is not idempotent (ena=%d pol=%d %llu/%llu) -> (ena=%d pol=%d %llu/%llu)\n", s1.enabled, s1.polarity, s1.duty_cycle, s1.period, last->enabled, last->polarity, last->duty_cycle, @@ -318,7 +318,7 @@ static struct pwm_chip *pwmchip_find_by_name(const char *name) mutex_lock(&pwm_lock); idr_for_each_entry_ul(&pwm_chips, chip, tmp, id) { - const char *chip_name = dev_name(chip->dev); + const char *chip_name = dev_name(pwmchip_parent(chip)); if (chip_name && strcmp(chip_name, name) == 0) { mutex_unlock(&pwm_lock); @@ -456,19 +456,19 @@ EXPORT_SYMBOL_GPL(of_pwm_single_xlate); static void of_pwmchip_add(struct pwm_chip *chip) { - if (!chip->dev || !chip->dev->of_node) + if (!pwmchip_parent(chip) || !pwmchip_parent(chip)->of_node) return; if (!chip->of_xlate) chip->of_xlate = of_pwm_xlate_with_flags; - of_node_get(chip->dev->of_node); + of_node_get(pwmchip_parent(chip)->of_node); } static void of_pwmchip_remove(struct pwm_chip *chip) { - if (chip->dev) - of_node_put(chip->dev->of_node); + if (pwmchip_parent(chip)) + of_node_put(pwmchip_parent(chip)->of_node); } static bool pwm_ops_check(const struct pwm_chip *chip) @@ -479,7 +479,7 @@ static bool pwm_ops_check(const struct pwm_chip *chip) return false; if (IS_ENABLED(CONFIG_PWM_DEBUG) && !ops->get_state) - dev_warn(chip->dev, + dev_warn(pwmchip_parent(chip), "Please implement the .get_state() callback\n"); return true; @@ -500,7 +500,7 @@ int __pwmchip_add(struct pwm_chip *chip, struct module *owner) unsigned int i; int ret; - if (!chip || !chip->dev || !chip->ops || !chip->npwm) + if (!chip || !pwmchip_parent(chip) || !chip->ops || !chip->npwm) return -EINVAL; if (!pwm_ops_check(chip)) @@ -594,15 +594,15 @@ static struct device_link *pwm_device_link_add(struct device *dev, * impact the PM sequence ordering: the PWM supplier may get * suspended before the consumer. */ - dev_warn(pwm->chip->dev, + dev_warn(pwmchip_parent(pwm->chip), "No consumer device specified to create a link to\n"); return NULL; } - dl = device_link_add(dev, pwm->chip->dev, DL_FLAG_AUTOREMOVE_CONSUMER); + dl = device_link_add(dev, pwmchip_parent(pwm->chip), DL_FLAG_AUTOREMOVE_CONSUMER); if (!dl) { dev_err(dev, "failed to create device link to %s\n", - dev_name(pwm->chip->dev)); + dev_name(pwmchip_parent(pwm->chip))); return ERR_PTR(-EINVAL); } @@ -617,7 +617,7 @@ static struct pwm_chip *fwnode_to_pwmchip(struct fwnode_handle *fwnode) mutex_lock(&pwm_lock); idr_for_each_entry_ul(&pwm_chips, chip, tmp, id) - if (chip->dev && device_match_fwnode(chip->dev, fwnode)) { + if (pwmchip_parent(chip) && device_match_fwnode(pwmchip_parent(chip), fwnode)) { mutex_unlock(&pwm_lock); return chip; } @@ -1085,8 +1085,8 @@ static int pwm_seq_show(struct seq_file *s, void *v) seq_printf(s, "%s%d: %s/%s, %d PWM device%s\n", (char *)s->private, chip->id, - chip->dev->bus ? chip->dev->bus->name : "no-bus", - dev_name(chip->dev), chip->npwm, + pwmchip_parent(chip)->bus ? pwmchip_parent(chip)->bus->name : "no-bus", + dev_name(pwmchip_parent(chip)), chip->npwm, (chip->npwm != 1) ? "s" : ""); pwm_dbg_show(chip, s); diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c index 1698609d91c8..3f434a771fb5 100644 --- a/drivers/pwm/sysfs.c +++ b/drivers/pwm/sysfs.c @@ -509,10 +509,10 @@ void pwmchip_sysfs_export(struct pwm_chip *chip) * If device_create() fails the pwm_chip is still usable by * the kernel it's just not exported. */ - parent = device_create(&pwm_class, chip->dev, MKDEV(0, 0), chip, + parent = device_create(&pwm_class, pwmchip_parent(chip), MKDEV(0, 0), chip, "pwmchip%d", chip->id); if (IS_ERR(parent)) { - dev_warn(chip->dev, + dev_warn(pwmchip_parent(chip), "device_create failed for pwm_chip sysfs export\n"); } } diff --git a/include/linux/pwm.h b/include/linux/pwm.h index 8ffe9ae7a23a..07af6910bdce 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -289,6 +289,11 @@ struct pwm_chip { struct pwm_device *pwms; }; +static inline struct device *pwmchip_parent(const struct pwm_chip *chip) +{ + return chip->dev; +} + #if IS_ENABLED(CONFIG_PWM) /* PWM user APIs */ int pwm_apply_might_sleep(struct pwm_device *pwm, const struct pwm_state *state); From patchwork Wed Feb 14 09:30:54 2024 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: 13556150 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 62E11C48BC4 for ; Wed, 14 Feb 2024 09:35:52 +0000 (UTC) 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=cYWIo8zQdkKM5NvWr2Df4dchEHG4mQjCj4ykh1sEBQg=; b=cgiOri5lb6uAxG X0pHOXYVHNj5xQheK5ksiA5fnUV3H/mOEWoR9ULZl+UfFRw+AaPVljpBdfeBvLse/uIhbLLRPKeQJ MQAl15C6Wl8XLmxd3TmiRtvowmOP3mnla9QCvVDSQwdcvo3I803e1FxiN0P68WG6w04Jw/4X/yHYf eGYQx7goqPSmxW8V0BdU6UWDhQQC4reoJLAzDukHdApEpEG6/Ac3pMq9lSaYs1jOJW4hq0Saujq8F 9a9Vwpm5ofzkCH9E0xV6J/T1G+Bo5Ewztn4gCm2s0xQDl7ojZg6TxXejv1Y7Lb1kpmBU8lB79fedv rouyfET23Ck6Z6CcbOOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBg1-0000000CLG4-3AzS; Wed, 14 Feb 2024 09:35:37 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBey-0000000CKG1-1fgN for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:36 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBem-0004OZ-BQ; Wed, 14 Feb 2024 10:34:20 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBek-000f6n-Sl; Wed, 14 Feb 2024 10:34:18 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBek-004Y07-2b; Wed, 14 Feb 2024 10:34:18 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Hector Martin , Sven Peter , linux-pwm@vger.kernel.org Cc: Alyssa Rosenzweig , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 007/164] pwm: apple: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:30:54 +0100 Message-ID: <34cf20a82ca07bb4ec0578b193daa5caed37825e.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2027; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=H2gBKJqPhxEH02LxqBcE7cgJijeXYph95OqB+mGaqEU=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIhS+MJ39Sqrsto1kA5NlX83PDmaY2icjOsha rLePYYgEuKJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIUgAKCRCPgPtYfRL+ TneTB/9Uu3TN3IUSipI7OGzVG7GRlfSeOty7pM8L2m3CkkdsACKFIGn2/OqPg4/it9WNlXHzCK1 4hbCuPBrAvkLlzw/5o4/66SHgVvViFkF8Q41a1+6yO60Yua/r95OiPrMNiu4IOdWN85hkWJwdPt qy89+JAJelGvF5G7hkyhy22EzogTtNX43qMx3bk4NOFn7UyqosvkMTaxyANy0pfIHUIs9auE03O J6qy8nt2OBG5qQrGjDJdQ33WfLFDoGy1eJYyn0ZAnfSAZUFa16EpoOhqNm6+PhjJnZkH1pOkcJw 77l5KXK5VLpXv9VCgYbqka2SZcEgDN7WliWU8Ov+VnwdvNuq X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013432_676979_DF238928 X-CRM114-Status: GOOD ( 15.15 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-apple driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-apple.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-apple.c b/drivers/pwm/pwm-apple.c index 4d755b628d9e..6e58aca2f13c 100644 --- a/drivers/pwm/pwm-apple.c +++ b/drivers/pwm/pwm-apple.c @@ -32,14 +32,13 @@ #define APPLE_PWM_CTRL_OUTPUT_ENABLE BIT(14) struct apple_pwm { - struct pwm_chip chip; void __iomem *base; u64 clkrate; }; static inline struct apple_pwm *to_apple_pwm(struct pwm_chip *chip) { - return container_of(chip, struct apple_pwm, chip); + return pwmchip_get_drvdata(chip); } static int apple_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, @@ -103,13 +102,16 @@ static const struct pwm_ops apple_pwm_ops = { static int apple_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct apple_pwm *fpwm; struct clk *clk; int ret; - fpwm = devm_kzalloc(&pdev->dev, sizeof(*fpwm), GFP_KERNEL); - if (!fpwm) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*fpwm)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + + fpwm = to_apple_pwm(chip); fpwm->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(fpwm->base)) @@ -129,11 +131,9 @@ static int apple_pwm_probe(struct platform_device *pdev) if (fpwm->clkrate > NSEC_PER_SEC) return dev_err_probe(&pdev->dev, -EINVAL, "pwm clock out of range"); - fpwm->chip.dev = &pdev->dev; - fpwm->chip.npwm = 1; - fpwm->chip.ops = &apple_pwm_ops; + chip->ops = &apple_pwm_ops; - ret = devm_pwmchip_add(&pdev->dev, &fpwm->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) return dev_err_probe(&pdev->dev, ret, "unable to add pwm chip"); From patchwork Wed Feb 14 09:30:55 2024 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: 13556141 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 51B80C48BEB for ; Wed, 14 Feb 2024 09:35:32 +0000 (UTC) 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=e+sxy9m+SeRJvl+oXLEqhJ8QvwBOBtTanEDEfW7w5MM=; b=q7v140Qgqf64lV yvj6+5cVPrkND4pPbhwKUxKajBAHHYl1vjgj8hJVKqpio3XauRLw4Ovtb+KOTXIUctPVp3mk5dxrL Jubcvm3wRG4g8P0ZFoVDRn1jm3QLWolEdouOKjliaFV8VQozJPxlMX1BglRDioL6XpIYsHbIswede BERq6EZ3ERREeOvAWsDZkkej4fe75LOx+/jv2V5SKzL8a57W7ULCEmfgIJBNtzlViuM6x13lGcZXs keegBadwRNENF9hjSZqqyCR9/D0PggUdQLNr7M1Zn0LAK+LD9m67/VFkJuSGoFMosItxiHZ7YKvxy Rqqj+a1BY8ep0Sh2CR+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfi-0000000CL0r-2SC1; Wed, 14 Feb 2024 09:35:18 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBev-0000000CK9x-04LL for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:31 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBel-0004Ok-EF; Wed, 14 Feb 2024 10:34:19 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBel-000f71-18; Wed, 14 Feb 2024 10:34:19 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBek-004Y0B-34; Wed, 14 Feb 2024 10:34:18 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Claudiu Beznea , Nicolas Ferre , Alexandre Belloni , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 008/164] pwm: atmel: Change prototype of a helper to prepare further changes Date: Wed, 14 Feb 2024 10:30:55 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2858; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=QIQRTGWYyMDDIqzmMspyZIZGmehbfXvdg62xGI/Tyy0=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIhU1jXvH4ESWAqWsDYttDHJM5uqvSf1HqTuN xSTBs4ZIvSJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIVAAKCRCPgPtYfRL+ TnBsB/96dYVoGauzJJA7c5p/W7a1Y6fZ33BOsOLnX6EMLoSOJfgeDz8QhX3sl/McT59eBlPlaIM M9x5nubm1F4Hb/G5zDHO8/xVjWRiRHkZ0FYciOb8EvEO1hnyka/JsNrODbDdvhvtVgj0BUUWQJk k89FcLo8zmr2RcDCfUhOoDcme8RgPj4szJj8xGt7NoMNOMy8YaeKtzTMdI4h762FbQP1YzwabUA R5snKsGNJnnSdnC/TIawvIeOAHA79JC1bV2sZd7xc/vKYBYo2UGBscS4Y1mJbbZCU2HUwrZryRL FYzu5pOYiIVj2xfv7MKWHK1eP5H/GCg22jgFElzBj8cLIDL8 X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013429_197514_2FCE8D87 X-CRM114-Status: GOOD ( 16.48 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the driver for further changes that will make it harder to determine the pwm_chip from a given atmel_pwm_chip. To just not have to do that, rework atmel_pwm_enable_clk_if_on() to take a pwm_chip. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-atmel.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c index 47bcc8a3bf9d..2f7d6c43be85 100644 --- a/drivers/pwm/pwm-atmel.c +++ b/drivers/pwm/pwm-atmel.c @@ -462,8 +462,9 @@ static const struct of_device_id atmel_pwm_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, atmel_pwm_dt_ids); -static int atmel_pwm_enable_clk_if_on(struct atmel_pwm_chip *atmel_pwm, bool on) +static int atmel_pwm_enable_clk_if_on(struct pwm_chip *chip, bool on) { + struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip); unsigned int i, cnt = 0; unsigned long sr; int ret = 0; @@ -472,7 +473,7 @@ static int atmel_pwm_enable_clk_if_on(struct atmel_pwm_chip *atmel_pwm, bool on) if (!sr) return 0; - cnt = bitmap_weight(&sr, atmel_pwm->chip.npwm); + cnt = bitmap_weight(&sr, chip->npwm); if (!on) goto disable_clk; @@ -480,7 +481,7 @@ static int atmel_pwm_enable_clk_if_on(struct atmel_pwm_chip *atmel_pwm, bool on) for (i = 0; i < cnt; i++) { ret = clk_enable(atmel_pwm->clk); if (ret) { - dev_err(atmel_pwm->chip.dev, + dev_err(chip->dev, "failed to enable clock for pwm %pe\n", ERR_PTR(ret)); @@ -501,6 +502,7 @@ static int atmel_pwm_enable_clk_if_on(struct atmel_pwm_chip *atmel_pwm, bool on) static int atmel_pwm_probe(struct platform_device *pdev) { struct atmel_pwm_chip *atmel_pwm; + struct pwm_chip *chip; int ret; atmel_pwm = devm_kzalloc(&pdev->dev, sizeof(*atmel_pwm), GFP_KERNEL); @@ -521,15 +523,16 @@ static int atmel_pwm_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(atmel_pwm->clk), "failed to get prepared PWM clock\n"); - atmel_pwm->chip.dev = &pdev->dev; - atmel_pwm->chip.ops = &atmel_pwm_ops; - atmel_pwm->chip.npwm = 4; + chip = &atmel_pwm->chip; + chip->dev = &pdev->dev; + chip->ops = &atmel_pwm_ops; + chip->npwm = 4; - ret = atmel_pwm_enable_clk_if_on(atmel_pwm, true); + ret = atmel_pwm_enable_clk_if_on(chip, true); if (ret < 0) return ret; - ret = devm_pwmchip_add(&pdev->dev, &atmel_pwm->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) { dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n"); goto disable_clk; @@ -538,7 +541,7 @@ static int atmel_pwm_probe(struct platform_device *pdev) return 0; disable_clk: - atmel_pwm_enable_clk_if_on(atmel_pwm, false); + atmel_pwm_enable_clk_if_on(chip, false); return ret; } From patchwork Wed Feb 14 09:30:56 2024 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: 13556136 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4AA32C48BEB for ; Wed, 14 Feb 2024 09:34:47 +0000 (UTC) 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=H9zS/7b07Ze6RbQMKUfS69zVi3Ah1296OwmDxTYyQ00=; b=fZ2EnWTKhp67HY fHtXhhsjZ98k4DdtkjylVRPvCRzZxOECp2LvEaxJOryuI2p+GPYoDi5Fu95c0aP7GWVzu7/g3tdUM jp2eXlmx2wlfytsT1gIH1dxwd7WhEindoADU4gmg1r2RhIiSTWzpmqvFfOA5vaalvGpq/FMdjWZnK r9Xvq2ux4tBf08pgxdYsqYTNHn65AlSG+EWgZmZ3QW5FWT2E7mGxKwz2cV2AanwucZqsmKIiM/SKB 3mAeLE7wKYdSFvJSflf7ylDHdWBd3s0uK1V+jf9Hw979euOD7/6VoIn9M7k7QCqKHlJ+C3xHZh7O7 w+Ok5jaoIj38EwdQGvhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBex-0000000CKFs-2FXv; Wed, 14 Feb 2024 09:34:31 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBet-0000000CK8o-3I2s for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:29 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBel-0004On-J5; Wed, 14 Feb 2024 10:34:19 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBel-000f7C-64; Wed, 14 Feb 2024 10:34:19 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBel-004Y0F-0L; Wed, 14 Feb 2024 10:34:19 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Claudiu Beznea , Nicolas Ferre , Alexandre Belloni , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 009/164] pwm: atmel: Make use of pwmchip_parent() accessor Date: Wed, 14 Feb 2024 10:30:56 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1856; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=23C0zswHFbohCvcAG64YSEJS8Mf75jYiZ0e59VSUXJs=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIhV/W2P+HdgVcZyMYogjnFY0gx1xBm8GEPrC gxgZWUsezaJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIVQAKCRCPgPtYfRL+ TnNACACPKROLmSTvBrx/ljyGq2XQpSZvl+A2g+nTl4ucQqryKvHGMNd0e0wmUtUxMI5qGrmP/MH IfpSzly1LPlgOJXoicaTHZfOxXOw+B5Mi2JditW1pe1gXIQODI9zGjKESHzgyzyQ1av2Z0nGI9L vOQ09WYVTt5BWTpGDaY/TRM+AXg5u647fp/Df7aM5644tXWzih7S/2dwHFp2rju9cCDWHNFP2yt v6V/864IVbRG327vnxkGeUPprbg1tmASowLs9vU9wgP/EAvI7c9sY9V8EmaELEQWYOpZ/Zz9c45 pYHpudXs95L8SiN4mvga7Ap58ot+0vlrZ8LJS0rFWwNQEGZd X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013427_930627_505E7858 X-CRM114-Status: GOOD ( 14.58 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org struct pwm_chip::dev is about to change. To not have to touch this driver in the same commit as struct pwm_chip::dev, use the accessor function provided for exactly this purpose. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-atmel.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c index 2f7d6c43be85..96e1676a5c51 100644 --- a/drivers/pwm/pwm-atmel.c +++ b/drivers/pwm/pwm-atmel.c @@ -210,7 +210,7 @@ static int atmel_pwm_calculate_cprd_and_pres(struct pwm_chip *chip, shift = fls(cycles) - atmel_pwm->data->cfg.period_bits; if (shift > PWM_MAX_PRES) { - dev_err(chip->dev, "pres exceeds the maximum value\n"); + dev_err(pwmchip_parent(chip), "pres exceeds the maximum value\n"); return -EINVAL; } else if (shift > 0) { *pres = shift; @@ -321,7 +321,7 @@ static int atmel_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, ret = atmel_pwm_calculate_cprd_and_pres(chip, clkrate, state, &cprd, &pres); if (ret) { - dev_err(chip->dev, + dev_err(pwmchip_parent(chip), "failed to calculate cprd and prescaler\n"); return ret; } @@ -333,7 +333,7 @@ static int atmel_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, } else { ret = clk_enable(atmel_pwm->clk); if (ret) { - dev_err(chip->dev, "failed to enable clock\n"); + dev_err(pwmchip_parent(chip), "failed to enable clock\n"); return ret; } } @@ -481,7 +481,7 @@ static int atmel_pwm_enable_clk_if_on(struct pwm_chip *chip, bool on) for (i = 0; i < cnt; i++) { ret = clk_enable(atmel_pwm->clk); if (ret) { - dev_err(chip->dev, + dev_err(pwmchip_parent(chip), "failed to enable clock for pwm %pe\n", ERR_PTR(ret)); From patchwork Wed Feb 14 09:30:57 2024 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: 13556145 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 489AFC48BC4 for ; Wed, 14 Feb 2024 09:35:39 +0000 (UTC) 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=uk6g5scypoiR8U3LHpUJJkiyu+gbwwvF2INEKdA37wk=; b=q3WTvZJ9zUmI/D 3fxHCjlYaw0hIvSHfgO/YnPMS8Ty0bzcjJ8TskqMZ5ZgqFeaNijWo1DT0cuxsviANEvi5sllcE6Ti 6Z4UmVOK6PrMzjl5dGxBfHcPRAIqDJL5OLpDd8UJTnCwqga+2wM9itJL8z2Oh8xhvwM7N3x49Kocl 3AUq5eUreRUn5UOiMqJJ9JkOOJXIdC3fF8ttH2x4YWp5MsDQTvTTFMBSbvK+SrHvSOBMb6HBMJq6U iPJ+rKmT/lSbZLLCc5N0MHFi6SnUBfG4pgCZOYqtb/Ue1E+5M1cqP+8/QyM+3zxuv1iV4oyptsmZ2 45lxBgfzh7sb9M39tU8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfm-0000000CL3X-2uJB; Wed, 14 Feb 2024 09:35:22 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBew-0000000CKAy-0TiP for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:32 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBel-0004Ov-OO; Wed, 14 Feb 2024 10:34:19 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBel-000f7L-BI; Wed, 14 Feb 2024 10:34:19 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBel-004Y0J-0s; Wed, 14 Feb 2024 10:34:19 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Claudiu Beznea , Nicolas Ferre , Alexandre Belloni , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 010/164] pwm: atmel: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:30:57 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1892; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=a/oPV7jA+XRSFfuYa8Te7aDSBlzQr4lMUCddipHmYqg=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIhWdKgDRAwFWJ7oj7uKs2oJcSqn6/LEno4MN 8aYJ1orAzOJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIVgAKCRCPgPtYfRL+ ThtPCACTzWajUNiVOexvOXLVZzKMuIHhdUIy7xFYY0SE9HdgzKYeIlE7e4j7afKzl79vG3aomIU exqW07VVZogOGmYa0RmnpdGCYfWMv1W/XFHB0nyOpk3pCwCLCz43AqC3ay0mZkZqWtRR/mXL6JF EiEmOBuy2zpkQrjl51HEr30msvT+56qX0AjBbgOG9LpqXdev+85yCTvlICsyUfD+B6qshqCUBNd 0mIzvWvOcR4zoxm9zV4MdTfrNuktoWpjh0dTs9E0IIZ6igre1VShkkmHQThJbkNyt4gO+dw8D9z RvbbPtFKx3onlqefNCJyVYc3H4M7k5m8TLWCm4Q9VXyt4aOS X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013430_227390_DDE83005 X-CRM114-Status: GOOD ( 14.94 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-atmel driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-atmel.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c index 96e1676a5c51..bfb408804d6a 100644 --- a/drivers/pwm/pwm-atmel.c +++ b/drivers/pwm/pwm-atmel.c @@ -77,7 +77,6 @@ struct atmel_pwm_data { }; struct atmel_pwm_chip { - struct pwm_chip chip; struct clk *clk; void __iomem *base; const struct atmel_pwm_data *data; @@ -99,7 +98,7 @@ struct atmel_pwm_chip { static inline struct atmel_pwm_chip *to_atmel_pwm_chip(struct pwm_chip *chip) { - return container_of(chip, struct atmel_pwm_chip, chip); + return pwmchip_get_drvdata(chip); } static inline u32 atmel_pwm_readl(struct atmel_pwm_chip *chip, @@ -505,10 +504,11 @@ static int atmel_pwm_probe(struct platform_device *pdev) struct pwm_chip *chip; int ret; - atmel_pwm = devm_kzalloc(&pdev->dev, sizeof(*atmel_pwm), GFP_KERNEL); - if (!atmel_pwm) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 4, sizeof(*atmel_pwm)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + atmel_pwm = to_atmel_pwm_chip(chip); atmel_pwm->data = of_device_get_match_data(&pdev->dev); atmel_pwm->update_pending = 0; @@ -523,10 +523,7 @@ static int atmel_pwm_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(atmel_pwm->clk), "failed to get prepared PWM clock\n"); - chip = &atmel_pwm->chip; - chip->dev = &pdev->dev; chip->ops = &atmel_pwm_ops; - chip->npwm = 4; ret = atmel_pwm_enable_clk_if_on(chip, true); if (ret < 0) From patchwork Wed Feb 14 09:30:58 2024 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: 13556139 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6E0FEC48BC4 for ; Wed, 14 Feb 2024 09:35:03 +0000 (UTC) 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=z3Pwf3wrX/0Ve1f1iHn7jW9+mvYQzdMJXvl4vLVRt5c=; b=n9qrDQrf+XKNuw MgsaVi7p5W1iG7UnDOu1/JpRC7lUXK1LoXpkisOkhE4Sv5LjZJZn2Tp81RycPC/02RKMVepCJN0ql itJmvoyxIoSTywv+/nlL1RCHnqfcHhffPJ9qm6aGusP329Xs5jbRzrVCDl8xwVCxLwiWkHNZtpywm c3fJqDOYGNmRSIKf8gj0FvTe/auW6UMVGsyYcCVMZiq/HJcT9RYmSH+QYO16EenCfjabPemXIYdmI 7kEyJgFzbFaiLHkCn9fZjjSXiZaHRP2Pjw+meRMq0eP1/n21HjdGdycDkls1L9Hk/Gt3xNpkb5Bgy yuHA0r7Ce43Fv17hltDw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfC-0000000CKXQ-2P0L; Wed, 14 Feb 2024 09:34:46 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBeu-0000000CK90-3MnX for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:30 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBel-0004PA-UD; Wed, 14 Feb 2024 10:34:19 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBel-000f7Z-Gg; Wed, 14 Feb 2024 10:34:19 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBel-004Y0N-1N; Wed, 14 Feb 2024 10:34:19 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 011/164] pwm: atmel-hlcdc: Prepare removing pwm_chip from driver data Date: Wed, 14 Feb 2024 10:30:58 +0100 Message-ID: <0e97342f15540c7330d405eaaf3e68baa8e1e488.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3338; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=y89OcbTy+fiOpfQjg5mC1/J3D4k2pVm31e6norgskAU=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIhXR2pGUnszLY2jeSyJE302rX70+MLmEMuqM ppd1XTQGDuJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIVwAKCRCPgPtYfRL+ To+uB/4iR01+B7kqb0I/Br70QqxvbczTVgomN3vVloHAky+wwppLZPMWh2K8XGZ7nnYBoR++lWn e9lU1zo9mw9Jqjdr9YnA1QlimrjyCCdkrlVMFQcc8Veko+a8AZG8TImGz9tFgBvHYqU+a0lbR2w auPTCbKD7KWr+jRS/mTIghjlDKZtE5fvwI/fTaaslmdy5UoeW6nLkbXsq66vTM2+uTw6N9cuU8H BKkwRwrp1xo86iLiZfBfsrvfzdbCQkktwRnrt5Fht29QqWU8/zqcchWrCk4KlCIgDczb9pnslrP cSlf1okBqB2+QcQsFDTd85/bEun+d6sitLVGqCwHnBapt0S4 X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013428_999893_975A0A46 X-CRM114-Status: GOOD ( 17.77 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the driver for further changes that will drop struct pwm_chip chip from struct atmel_hlcdc_pwm. Use the pwm_chip as driver data instead of the atmel_hlcdc_pwm to get access to the pwm_chip in the .suspend() and .resume() callbacks and atmel_hlcdc_pwm_remove() without using atmel->chip. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-atmel-hlcdc.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c index 1f6fc9a9fcf3..f3f6c951bda5 100644 --- a/drivers/pwm/pwm-atmel-hlcdc.c +++ b/drivers/pwm/pwm-atmel-hlcdc.c @@ -182,10 +182,11 @@ static const struct atmel_hlcdc_pwm_errata atmel_hlcdc_pwm_sama5d3_errata = { static int atmel_hlcdc_pwm_suspend(struct device *dev) { - struct atmel_hlcdc_pwm *atmel = dev_get_drvdata(dev); + struct pwm_chip *chip = dev_get_drvdata(dev); + struct atmel_hlcdc_pwm *atmel = to_atmel_hlcdc_pwm(chip); /* Keep the periph clock enabled if the PWM is still running. */ - if (!pwm_is_enabled(&atmel->chip.pwms[0])) + if (!pwm_is_enabled(&chip->pwms[0])) clk_disable_unprepare(atmel->hlcdc->periph_clk); return 0; @@ -193,11 +194,12 @@ static int atmel_hlcdc_pwm_suspend(struct device *dev) static int atmel_hlcdc_pwm_resume(struct device *dev) { - struct atmel_hlcdc_pwm *atmel = dev_get_drvdata(dev); + struct pwm_chip *chip = dev_get_drvdata(dev); + struct atmel_hlcdc_pwm *atmel = to_atmel_hlcdc_pwm(chip); struct pwm_state state; int ret; - pwm_get_state(&atmel->chip.pwms[0], &state); + pwm_get_state(&chip->pwms[0], &state); /* Re-enable the periph clock it was stopped during suspend. */ if (!state.enabled) { @@ -206,8 +208,7 @@ static int atmel_hlcdc_pwm_resume(struct device *dev) return ret; } - return atmel_hlcdc_pwm_apply(&atmel->chip, &atmel->chip.pwms[0], - &state); + return atmel_hlcdc_pwm_apply(chip, &chip->pwms[0], &state); } static DEFINE_SIMPLE_DEV_PM_OPS(atmel_hlcdc_pwm_pm_ops, @@ -243,6 +244,7 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev) { const struct of_device_id *match; struct device *dev = &pdev->dev; + struct pwm_chip *chip; struct atmel_hlcdc_pwm *atmel; struct atmel_hlcdc *hlcdc; int ret; @@ -262,26 +264,28 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev) atmel->errata = match->data; atmel->hlcdc = hlcdc; - atmel->chip.ops = &atmel_hlcdc_pwm_ops; - atmel->chip.dev = dev; - atmel->chip.npwm = 1; + chip = &atmel->chip; + chip->ops = &atmel_hlcdc_pwm_ops; + chip->dev = dev; + chip->npwm = 1; - ret = pwmchip_add(&atmel->chip); + ret = pwmchip_add(chip); if (ret) { clk_disable_unprepare(hlcdc->periph_clk); return ret; } - platform_set_drvdata(pdev, atmel); + platform_set_drvdata(pdev, chip); return 0; } static void atmel_hlcdc_pwm_remove(struct platform_device *pdev) { - struct atmel_hlcdc_pwm *atmel = platform_get_drvdata(pdev); + struct pwm_chip *chip = platform_get_drvdata(pdev); + struct atmel_hlcdc_pwm *atmel = to_atmel_hlcdc_pwm(chip); - pwmchip_remove(&atmel->chip); + pwmchip_remove(chip); clk_disable_unprepare(atmel->hlcdc->periph_clk); } From patchwork Wed Feb 14 09:30:59 2024 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: 13556207 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 50B4DC48BC4 for ; Wed, 14 Feb 2024 09:41:43 +0000 (UTC) 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=a87PGqOPP5ygaet+C8PpryXZTeS5fNdXXlcRl/ySG1w=; b=IeBfu70/f+Z903 e93vyK6q9IwDLYwO7cgp2LA5ujeHbNpNE2F/al0Dym7rtPvZjRtte89Q2tcJkSt6YZRq2xdQZ8xO8 UstMuF2P5kIQCejok5FlLeeZeXJ9Wz6g/8pUq1coVt7GT1EqQUgfGQybTd5SI87IBEN9jLILm2tMi H7TpmJYea9x8Xq9f5PIeFpCiiLTUQJ4F8uU2/U3ZwU6VCHccSamCJaaEVsgpqFOzMIjaICxk88BBN vmG/pZ/3Ey0B4yxf4VQg3SJk6m3KuR8AWpXsYbn+PR7t/iaqO8qYiVo94wlacS3TvZomRflG/zNKq OB2+YVcOOyQN1IgstBnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBli-0000000CPPo-1IKu; Wed, 14 Feb 2024 09:41:30 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBeu-0000000CK8p-37qT for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:30 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBem-0004Ps-8D; Wed, 14 Feb 2024 10:34:20 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBel-000f7r-NV; Wed, 14 Feb 2024 10:34:19 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBel-004Y0R-23; Wed, 14 Feb 2024 10:34:19 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 012/164] pwm: atmel-hlcdc: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:30:59 +0100 Message-ID: <4724c6a0f052160ac80ba5a3065c9470778b7457.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1845; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=pjKoJkt5G+itH9Jr1SgwiTak3mbHW/dnYfYfs2bBN4c=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIhY0l7YwWooXdOfVU20R+As1H4e9TLg+C2iv 0yO8QQczfaJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIWAAKCRCPgPtYfRL+ TrPkB/wOTyGmtX0w6/vg5cKxJ+nHqovMrGUdwcAivWQhlzYE/bqXkcBKLJNxjWBl2ww7Two6GJD JTEFUde6gJE4Bx4GEM+6Tj78MFLZdhjVf1vzX1LGY541KRUelkE+22eg1Nju2h88GG6vS7y2mVq hJHpOkMBA+x2o7vT6PY0XXjR6ba86zGC2dkSfs9vZgUX1f1Hs7OYhQIfTPKQGtXn37+ziTRh064 H9AQjAjiEvYlkxX6LdlGKuk4sccsS/8VAHOp+Hdvq99N4sReDk3dKX8UHOkSqIiyxKb/QvYi16R UaUJ09LwdRLjxkyaDw2HM1eIz1yVVDafTGeFTzwsr2BkZKhG X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013428_909320_408054C3 X-CRM114-Status: GOOD ( 14.76 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-atmel-hlcdc driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-atmel-hlcdc.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c index f3f6c951bda5..166f1d16aba6 100644 --- a/drivers/pwm/pwm-atmel-hlcdc.c +++ b/drivers/pwm/pwm-atmel-hlcdc.c @@ -28,7 +28,6 @@ struct atmel_hlcdc_pwm_errata { }; struct atmel_hlcdc_pwm { - struct pwm_chip chip; struct atmel_hlcdc *hlcdc; struct clk *cur_clk; const struct atmel_hlcdc_pwm_errata *errata; @@ -36,7 +35,7 @@ struct atmel_hlcdc_pwm { static inline struct atmel_hlcdc_pwm *to_atmel_hlcdc_pwm(struct pwm_chip *chip) { - return container_of(chip, struct atmel_hlcdc_pwm, chip); + return pwmchip_get_drvdata(chip); } static int atmel_hlcdc_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, @@ -251,9 +250,10 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev) hlcdc = dev_get_drvdata(dev->parent); - atmel = devm_kzalloc(dev, sizeof(*atmel), GFP_KERNEL); - if (!atmel) - return -ENOMEM; + chip = devm_pwmchip_alloc(dev, 1, sizeof(*atmel)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + atmel = to_atmel_hlcdc_pwm(chip); ret = clk_prepare_enable(hlcdc->periph_clk); if (ret) @@ -264,10 +264,7 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev) atmel->errata = match->data; atmel->hlcdc = hlcdc; - chip = &atmel->chip; chip->ops = &atmel_hlcdc_pwm_ops; - chip->dev = dev; - chip->npwm = 1; ret = pwmchip_add(chip); if (ret) { From patchwork Wed Feb 14 09:31:00 2024 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: 13556143 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4F292C48BEC for ; Wed, 14 Feb 2024 09:35:34 +0000 (UTC) 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=mWUAL5iPjUqbdI37td1sKYBFvNvNt3ql+rqm6dJEgHA=; b=hbW/KOwMKtqbDf XCNBbYnuoawBD2nbJvFBqeOSrSU2XTCJByhn9IecdCapQlUKBJwuNO+9lfonVZ0Lb80AakzGwiH06 Ju5jwHlTZ3K7B3w9ainfxvynzpK2Zm5H17X9KB+U6MOn+s4kaP7BqwWqgU0jZvSJ9E/s3CcxQIKr0 3oTZAGNKhRY3sfFbP5lo3qUKwTLn7a0JIkIgXywU3RhN7JQL55L8e1fNEEVIr86mEKLCiAPUpnp0p 1XnI54EqI+hV37jsSaqyPCDWe42WQ5Bbu1RAliEQg2K42isr3KA+sV6ZSH7GQCiQtD5GACFd1SPPO 71BKlEVPfFM0BCtsAGBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfl-0000000CL2a-0N0c; Wed, 14 Feb 2024 09:35:21 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBev-0000000CKCH-2RFS for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:32 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBem-0004R6-Kz; Wed, 14 Feb 2024 10:34:20 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBel-000f81-Sb; Wed, 14 Feb 2024 10:34:19 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBel-004Y0V-2a; Wed, 14 Feb 2024 10:34:19 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 013/164] pwm: atmel-tcb: Make use of pwmchip_parent() accessor Date: Wed, 14 Feb 2024 10:31:00 +0100 Message-ID: <463d43cab01f97f3c4247c63cc08e76aa15684c4.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=953; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=X11YFRRXpy/6TObmD0IkFCXyfClShBnw+M24ucXNpp4=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIhZh44bDOEZyf1+SgXF17gAdw0HhqZUbQ8NF CwCqOhz1MaJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIWQAKCRCPgPtYfRL+ TlymCACQyuRBK6ii3fw96UC7bfhuFf6soDt3+TVZ5WsXQ0eVQfzVvEeLsdbrWLvXXB95hfp4qce lNbStzL+sl5gTVRigGjyNzJtbOaRt0cdZPqEkI8SJd9/SC/n7ghkknsVATCD3aoL78mRy/gxCCp ZvIdCU6UPLDAfN1wYBbDXZ6n8KdPGuqMhbWQMADGRijJhESCbfxz1fOxLJt8Ex+3oI4FyzV8zRe VUebQC24bjbj6XqpA3N4zYlABSRH9ufy4bze09JR2kFfzZI9/tpaQ05F3oS6QvALCBeJ0Cb9TjK ZI2N4HQUVtE+q7lwUXwJx42t4PLQZLN8ew3YWw2t8g5akV4N X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013429_744622_6526560E X-CRM114-Status: GOOD ( 13.99 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org struct pwm_chip::dev is about to change. To not have to touch this driver in the same commit as struct pwm_chip::dev, use the accessor function provided for exactly this purpose. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-atmel-tcb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c index d42c897cb85e..80121ab81a01 100644 --- a/drivers/pwm/pwm-atmel-tcb.c +++ b/drivers/pwm/pwm-atmel-tcb.c @@ -327,7 +327,7 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, if ((atcbpwm && atcbpwm->duty > 0 && atcbpwm->duty != atcbpwm->period) && (atcbpwm->div != i || atcbpwm->period != period)) { - dev_err(chip->dev, + dev_err(pwmchip_parent(chip), "failed to configure period_ns: PWM group already configured with a different value\n"); return -EINVAL; } From patchwork Wed Feb 14 09:31:01 2024 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: 13556146 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 14E44C48BEB for ; Wed, 14 Feb 2024 09:35:40 +0000 (UTC) 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=A6wH0gthwytiAZpK5SKEk50QKemUhC+cVNYXXMnvalg=; b=dpp/AzVi9cGsy4 ISqDJkbDF44NbUvUSeFNTVoLwUODp1dcrIb2OV5C+u6fqpp+sfYKQEBnQaWdAmQV3Tg/xko5u4hnL Y71QpiqpyPotgsxNrszUoCHwqLek1/Ps1aMAVhaqq1jM+TUX5Q1+iNdpKjiHeJFAnE+TRrNjgjQYW pbC/YST7EnI1jkc/LzzClTPxEZ99llIWCPL/4eHhHr/4AC4c/LfL0h7tIREsp23vVstXPktK+osRz fygxyXuqpWjkmr7Q05ACvw1dAOyc9PB9KT2cQhx19OCtfzO6xA1SBBEbw5Nt0rgrfgekiUOcF4aEW 8Bfpy8RsaTZV4mCVR+LQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfn-0000000CL4K-40Bd; Wed, 14 Feb 2024 09:35:23 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBew-0000000CKAn-0ucc for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:33 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBem-0004SP-Jt; Wed, 14 Feb 2024 10:34:20 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBem-000f8C-12; Wed, 14 Feb 2024 10:34:20 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBel-004Y0Z-35; Wed, 14 Feb 2024 10:34:19 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 014/164] pwm: atmel-tcb: Prepare removing pwm_chip from driver data Date: Wed, 14 Feb 2024 10:31:01 +0100 Message-ID: <6a90083e9d1ab1c34422161593d6d7a669143217.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2965; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=htoxrxIlwaLwjopQ63rpcgTQhJzSwxqxqj++4pG3I1o=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIhaYM8JRw/Z25vhHWsv0oehVYnQlrBF+AYGC LAxoH1LFeuJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIWgAKCRCPgPtYfRL+ Tvv0B/0UXxoSjXFNxVv/oVSW5xaB3nNgJr09ya84Gy/mT/OeeN9tjbzp4XSc+YRpBAaGq672U0H CpkC2ytUTEMywuN0nYw2VZQ0hmpHr5HKkIoQUSdwCbkO8xbhwvKU+KLBHrI8Bw1urTP+WON9BeI jyMNyUDitPVhieCS50LYZbb5UMizBJCFVKL35zZlLx3kVslpSEqBB8AIz81s3oAWe8Kx++W/JS0 jCpv1NqYbX6SZoeFsQQHaat+X1Lg5Dwg4ZWyjOEo7M+gWJv/yZJ2y0Tf7KY3QA4ec2jU3l3ukUB Eg/e6b3vspTuptCQJ8ZbX0hoOUytaaKCtSiYF6EICx6G5ewW X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013430_346345_DD92481B X-CRM114-Status: GOOD ( 15.08 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the driver for further changes that will drop struct pwm_chip chip from struct atmel_tcb_pwm_chip. Use the pwm_chip as driver data instead of the atmel_tcb_pwm_chip to get access to the pwm_chip in the .suspend() and .resume() callbacks and atmel_tcb_pwm_remove() without using tcbpwm->chip. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-atmel-tcb.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c index 80121ab81a01..9d928e26b403 100644 --- a/drivers/pwm/pwm-atmel-tcb.c +++ b/drivers/pwm/pwm-atmel-tcb.c @@ -388,6 +388,7 @@ static const struct of_device_id atmel_tcb_of_match[] = { static int atmel_tcb_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; const struct of_device_id *match; struct atmel_tcb_pwm_chip *tcbpwm; const struct atmel_tcb_config *config; @@ -436,9 +437,10 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev) } } - tcbpwm->chip.dev = &pdev->dev; - tcbpwm->chip.ops = &atmel_tcb_pwm_ops; - tcbpwm->chip.npwm = NPWM; + chip = &tcbpwm->chip; + chip->dev = &pdev->dev; + chip->ops = &atmel_tcb_pwm_ops; + chip->npwm = NPWM; tcbpwm->channel = channel; tcbpwm->width = config->counter_width; @@ -448,11 +450,11 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev) spin_lock_init(&tcbpwm->lock); - err = pwmchip_add(&tcbpwm->chip); + err = pwmchip_add(chip); if (err < 0) goto err_disable_clk; - platform_set_drvdata(pdev, tcbpwm); + platform_set_drvdata(pdev, chip); return 0; @@ -473,9 +475,10 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev) static void atmel_tcb_pwm_remove(struct platform_device *pdev) { - struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev); + struct pwm_chip *chip = platform_get_drvdata(pdev); + struct atmel_tcb_pwm_chip *tcbpwm = to_tcb_chip(chip); - pwmchip_remove(&tcbpwm->chip); + pwmchip_remove(chip); clk_disable_unprepare(tcbpwm->slow_clk); clk_put(tcbpwm->gclk); @@ -491,7 +494,8 @@ MODULE_DEVICE_TABLE(of, atmel_tcb_pwm_dt_ids); static int atmel_tcb_pwm_suspend(struct device *dev) { - struct atmel_tcb_pwm_chip *tcbpwm = dev_get_drvdata(dev); + struct pwm_chip *chip = dev_get_drvdata(dev); + struct atmel_tcb_pwm_chip *tcbpwm = to_tcb_chip(chip); struct atmel_tcb_channel *chan = &tcbpwm->bkup; unsigned int channel = tcbpwm->channel; @@ -505,7 +509,8 @@ static int atmel_tcb_pwm_suspend(struct device *dev) static int atmel_tcb_pwm_resume(struct device *dev) { - struct atmel_tcb_pwm_chip *tcbpwm = dev_get_drvdata(dev); + struct pwm_chip *chip = dev_get_drvdata(dev); + struct atmel_tcb_pwm_chip *tcbpwm = to_tcb_chip(chip); struct atmel_tcb_channel *chan = &tcbpwm->bkup; unsigned int channel = tcbpwm->channel; From patchwork Wed Feb 14 09:31:02 2024 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: 13556144 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0B8C3C48BED for ; Wed, 14 Feb 2024 09:35:35 +0000 (UTC) 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=qyuQUExCdtTqnST8ZEPvS6WVufD4mXd4n93XmRG7zQM=; b=D0NzgpHj8Cz2qk 5NaVCBBx2vB5+MkWZCNtl9Zd/dWAdt3pIA0975HRHuh5bZhuRytQ2oUDk3UgkFs8dnabt1Oc+Iv6M YY4EcjPgOjWyB/Iz9mk8V+6culCAkWtUUD2XGHE1iu7HDiXHaeyHwlGTbdY3OKo4YUR7MVP2pwB1c qxqjyuC/Iy9L+VzuCAr2SIXVVhn9xLtfKapcEecb/FAOtotlEkWJK6nsiwhHEcVm5vraDe8Wf5IbO Etci7E1WS/qM5ELqtpASECYK33gx/qAYwWMrvCWymO54ZaZIx74Fx/RoWrB1PV/rlHpGc9ZrLnDNk ZA6mdoa7cvoFFEDC9QJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfj-0000000CL1L-1ctF; Wed, 14 Feb 2024 09:35:19 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBev-0000000CKAR-1DfO for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:32 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBem-0004TY-RL; Wed, 14 Feb 2024 10:34:20 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBem-000f8R-62; Wed, 14 Feb 2024 10:34:20 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBem-004Y0d-0M; Wed, 14 Feb 2024 10:34:20 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 015/164] pwm: atmel-tcb: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:31:02 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1793; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=d0p4zq+ZNI+oblJ74VZxgRdDBukuAsuIxyr6xwcPm2Q=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIhb9lxgP6Jqa6m0yw04Es1EWyLphu+Zv2jw3 BPrRFWVuY2JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIWwAKCRCPgPtYfRL+ Tpn+B/wLgkmQyUGhyyBwTsLQv1CUuwwBaSGA67E06qS3GSZB7pw6j/OBHRaPVtew4OnIzqJZ2Qt c9dgomASD+DBkwqDpLjhfXhd1PX3k3afxLZGusBBj3Zt2SZpFQM1tIQ8NcGhOl3q+8STOBknp5+ PmuCW6h1ka0oGeD5D+Ih+Wx4foFilUt/FGhxap9/D2CuPLQGsXC6d8+29R4a8GeES7wwomOViRj RgBRbR6iiMnVG1GIiNWICN6FEe+llli3QetGrkwH8xFTiqmk0UFazpxIWtt6j3ooIIEKMCFiOXS o8pRKirnkoFtrkxgz9KcIF5z3Yn//gRlc1bqMZGzYIsPIB4Y X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013429_454870_A9069CA8 X-CRM114-Status: GOOD ( 15.56 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-atmel-tcb driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-atmel-tcb.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c index 9d928e26b403..528e54c5999d 100644 --- a/drivers/pwm/pwm-atmel-tcb.c +++ b/drivers/pwm/pwm-atmel-tcb.c @@ -47,7 +47,6 @@ struct atmel_tcb_channel { }; struct atmel_tcb_pwm_chip { - struct pwm_chip chip; spinlock_t lock; u8 channel; u8 width; @@ -63,7 +62,7 @@ static const u8 atmel_tcb_divisors[] = { 2, 8, 32, 128, 0, }; static inline struct atmel_tcb_pwm_chip *to_tcb_chip(struct pwm_chip *chip) { - return container_of(chip, struct atmel_tcb_pwm_chip, chip); + return pwmchip_get_drvdata(chip); } static int atmel_tcb_pwm_request(struct pwm_chip *chip, @@ -397,9 +396,10 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev) int err; int channel; - tcbpwm = devm_kzalloc(&pdev->dev, sizeof(*tcbpwm), GFP_KERNEL); - if (tcbpwm == NULL) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, NPWM, sizeof(*tcbpwm)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + tcbpwm = to_tcb_chip(chip); err = of_property_read_u32(np, "reg", &channel); if (err < 0) { @@ -437,10 +437,7 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev) } } - chip = &tcbpwm->chip; - chip->dev = &pdev->dev; chip->ops = &atmel_tcb_pwm_ops; - chip->npwm = NPWM; tcbpwm->channel = channel; tcbpwm->width = config->counter_width; From patchwork Wed Feb 14 09:31:03 2024 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: 13556142 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id BBB47C48BC4 for ; Wed, 14 Feb 2024 09:35:33 +0000 (UTC) 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=GLF6OTzXo23ABGNyf1y1uK95LxlcaIlPnqiSyOH9SLI=; b=3dnqdH9gvRRthP lLBVuIfEN5m00VYAF4ZNrVFOG2e5eb9TE8QBQxy7Rr24bD0LfufJhw5LPc7yyaYEBaYSvhQi5TWS7 QJgXEePfHoHtIzKZ31uyQu7GO+EFt/iLoUNOJz5+se0SkzjWMor18wiRoc3IkotZWF6tgTr9LfbFq d+ixAFmuzPV4fLYdy0JhpN2aSGtIs5xTp58hrGvCWndFC6PrPeCSV892Qc1dpKJ/5EX5ObKGhaLJ3 8DTWMh2eNzKEJbky4oGXIDqHPvepjqO4EKOTg1vc3w0AoouUsm0d2ogqVLu51RypUrvE3WbaYyynX kTUIAIxzpxxV2HBJmlfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfh-0000000CL0M-3SNh; Wed, 14 Feb 2024 09:35:17 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBev-0000000CKAK-1AqC for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:31 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBen-0004UC-4A; Wed, 14 Feb 2024 10:34:21 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBem-000f8V-AY; Wed, 14 Feb 2024 10:34:20 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBem-004Y0h-0n; Wed, 14 Feb 2024 10:34:20 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Florian Fainelli , Ray Jui , Scott Branden , linux-pwm@vger.kernel.org Cc: Broadcom internal kernel review list , linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 016/164] pwm: bcm2835: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:31:03 +0100 Message-ID: <441489772bdfbb2cd206fd534b36c63e8c50843a.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2140; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=UJ7kZSxcKk3H/k/fOQ/8AhXATk/5yZZHRmPO2TCmzGo=; b=owGbwMvMwMXY3/A7olbonx/jabUkhtQzHbE63mqvXs9kTrscyyYYzbPQsDwszW37fXdLgWbrs 3IL5+Z0MhqzMDByMciKKbLYN67JtKqSi+xc++8yzCBWJpApDFycAjCRDG/2/67ZjluTHjPpee9O m8rlGHCOd4JshFT6avcfot5igtWmne8qAi8esVW8IHVsMsOCIvlPf5s0HQ+weF5MM34XnGA1J0E ux9rSUuPNlnmSStMiLkdlXH3NesnUSG36NK9Fp7+efVg3fRXzpend2/Z36v4yeu4T7D53gjovU9 yZV4nb/x5O856qGaDoU/1oQnpk4tWQNLcty4QO+9b+tCyfyGffUs+2eG1qj4U2Q9eCH68Xhz3f5 JvNe7e0+GqA5Q9laQneDe+LI7KfBzlkN/bu3h65NNtl9a2via8Ofs4Q0+va/uba5ENn+tTajF9n /GqNWn7/KjNbTNMVCz7Lc5mn5W5XCB5K8A/ii/12dXofAA== X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013429_413589_2870306C X-CRM114-Status: GOOD ( 14.95 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-bcm2835 driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-bcm2835.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c index 711c174bbe23..aa35acbb0cbc 100644 --- a/drivers/pwm/pwm-bcm2835.c +++ b/drivers/pwm/pwm-bcm2835.c @@ -24,7 +24,6 @@ #define PERIOD_MIN 0x2 struct bcm2835_pwm { - struct pwm_chip chip; void __iomem *base; struct clk *clk; unsigned long rate; @@ -32,7 +31,7 @@ struct bcm2835_pwm { static inline struct bcm2835_pwm *to_bcm2835_pwm(struct pwm_chip *chip) { - return container_of(chip, struct bcm2835_pwm, chip); + return pwmchip_get_drvdata(chip); } static int bcm2835_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) @@ -134,12 +133,14 @@ static void devm_clk_rate_exclusive_put(void *data) static int bcm2835_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct bcm2835_pwm *pc; int ret; - pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); - if (!pc) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 2, sizeof(*pc)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + pc = to_bcm2835_pwm(chip); pc->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(pc->base)) @@ -165,14 +166,12 @@ static int bcm2835_pwm_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, -EINVAL, "failed to get clock rate\n"); - pc->chip.dev = &pdev->dev; - pc->chip.ops = &bcm2835_pwm_ops; - pc->chip.atomic = true; - pc->chip.npwm = 2; + chip->ops = &bcm2835_pwm_ops; + chip->atomic = true; platform_set_drvdata(pdev, pc); - ret = devm_pwmchip_add(&pdev->dev, &pc->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) return dev_err_probe(&pdev->dev, ret, "failed to add pwmchip\n"); From patchwork Wed Feb 14 09:31:04 2024 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: 13556138 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9E292C48BEB for ; Wed, 14 Feb 2024 09:35:00 +0000 (UTC) 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=4j0AFoOV0UItHbjxA5k6h15tD4TySW+SPO+4aOFdTNU=; b=AOeCl8Z8020pJg 7QweHJ1Nz0MCjED3f1lDiRqBe0XafPrBsmxoV2ejPYGqsX45wboou1vRKbbrvcAF45ZaUdCeqGcaE ZKUwFotxq8kRRMP1b5knp6j9aidyeznmj9xLSsuizV6DQypRHr6R/VAWJE/2TCYCM2aoQ78h6untt 3Qatn9EkK6hfrr17Lljwy+AnhPcUCkXG1l4+7ejRuzZmYHtob1vPcu7cVhLrMG7sIaQ2+uNI09k+y sRDn7TslWi+nfWrCjNyTY7Iq26EkS2PQHWuA/YtttY7WcLhCZAcMdj0SoOyhYqfm5wwdki1y9mjPG h7d4/OV1InDu4XAHwTLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBez-0000000CKIL-3bWW; Wed, 14 Feb 2024 09:34:33 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBeu-0000000CK8a-0NqE for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:29 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBen-0004UT-8u; Wed, 14 Feb 2024 10:34:21 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBem-000f8e-Ep; Wed, 14 Feb 2024 10:34:20 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBem-004Y0l-1E; Wed, 14 Feb 2024 10:34:20 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Ray Jui , Scott Branden , linux-pwm@vger.kernel.org Cc: Broadcom internal kernel review list , linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 017/164] pwm: bcm-iproc: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:31:04 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2342; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=KnJ19DF+WYdolraq2C+RV1Rwrj5TWFY7glRMFg+qlK4=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIheKEVCvLf3W1vo7atdEGBV8Qi8xXrKZ/eME FZYt9i8PuiJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIXgAKCRCPgPtYfRL+ TqPhCACkRtK8KG9coWWk42cklp0ktcb66RYZrRbGZjg1wuD5N8S87cZLU/PKMPwaF/ABq0G5eLD zhfC1A5UHvXXyP9Fyot9cod5HVYJauIRVms+VH/Yp5Be9qIt4zerV9xkQgtUcUXrupRHiOZ8rFB En+40kLR8OuWUSFrNKqd19EXYGEZNVT6JmvPyu5j0Wt4xS2UX0cZPVDPIM/WKZcg8GYhFIbwzTn 3OSk3bAS/TqzatTjYfMLACUhH1dC1Umm23xcRn4Qoz2wZDGc/D4Fguqkb19miWdrYp92Kyt+1vi 2EQ97qFUbzH+TwpWEGNm+54KVPBlS1jbS+jPkrO50tr3QBXD X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013428_179644_887649A5 X-CRM114-Status: GOOD ( 17.05 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-bcm-iproc driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-bcm-iproc.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/pwm/pwm-bcm-iproc.c b/drivers/pwm/pwm-bcm-iproc.c index 758254025683..f4c9f10e490e 100644 --- a/drivers/pwm/pwm-bcm-iproc.c +++ b/drivers/pwm/pwm-bcm-iproc.c @@ -34,14 +34,13 @@ #define IPROC_PWM_PRESCALE_MAX 0x3f struct iproc_pwmc { - struct pwm_chip chip; void __iomem *base; struct clk *clk; }; static inline struct iproc_pwmc *to_iproc_pwmc(struct pwm_chip *chip) { - return container_of(chip, struct iproc_pwmc, chip); + return pwmchip_get_drvdata(chip); } static void iproc_pwmc_enable(struct iproc_pwmc *ip, unsigned int channel) @@ -187,20 +186,20 @@ static const struct pwm_ops iproc_pwm_ops = { static int iproc_pwmc_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct iproc_pwmc *ip; unsigned int i; u32 value; int ret; - ip = devm_kzalloc(&pdev->dev, sizeof(*ip), GFP_KERNEL); - if (!ip) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 4, sizeof(*ip)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + ip = to_iproc_pwmc(chip); platform_set_drvdata(pdev, ip); - ip->chip.dev = &pdev->dev; - ip->chip.ops = &iproc_pwm_ops; - ip->chip.npwm = 4; + chip->ops = &iproc_pwm_ops; ip->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(ip->base)) @@ -214,14 +213,14 @@ static int iproc_pwmc_probe(struct platform_device *pdev) /* Set full drive and normal polarity for all channels */ value = readl(ip->base + IPROC_PWM_CTRL_OFFSET); - for (i = 0; i < ip->chip.npwm; i++) { + for (i = 0; i < chip->npwm; i++) { value &= ~(1 << IPROC_PWM_CTRL_TYPE_SHIFT(i)); value |= 1 << IPROC_PWM_CTRL_POLARITY_SHIFT(i); } writel(value, ip->base + IPROC_PWM_CTRL_OFFSET); - ret = devm_pwmchip_add(&pdev->dev, &ip->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) return dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n"); From patchwork Wed Feb 14 09:31:09 2024 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: 13556137 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 25D31C48BEB for ; Wed, 14 Feb 2024 09:34:50 +0000 (UTC) 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=Zz/gkfgS8RPmUe/9pHWxOwp8cPOL9WhDzwZjwu14t30=; b=llQKFgRszwjM0K DmoLPLMcXiu+v1upTGTWNdtUqoLkNjpb2UyrabExFSQCU63wkxZoSvNuU3oBcv3AvBXUFBMOixNil um68LnbRF8S0Twnjr5UzDGyR+r/VPhDDb0QRnl2TJgO94viqzcTuhHLliuUMIUmkZ+6/DZZJWetHu dMOkajoL/mLO2oa73tLQ9PqXRCLWLtuXuJ6EdcXwu1I9FmsCrOUrUs9z84ge9x47MINtI99FnQHYS nGUWZJWslrjQnQDglQZf6Peaq1Axc5VY3YdImStonIbvELh6745y7d7Lh5Y0K1ItTU/sbWVjl21gI ekVfvhxcfsjZ13STo0qA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBf1-0000000CKKN-3neC; Wed, 14 Feb 2024 09:34:36 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBeu-0000000CK8y-0LOz for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:30 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBeo-0004X9-3I; Wed, 14 Feb 2024 10:34:22 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBen-000f9D-9i; Wed, 14 Feb 2024 10:34:21 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBen-004Y15-0j; Wed, 14 Feb 2024 10:34:21 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Florian Fainelli , linux-pwm@vger.kernel.org Cc: Broadcom internal kernel review list , linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 022/164] pwm: brcmstb: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:31:09 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2069; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=TZC2i850mmZA7TRa+F19cdXeyXFOZTXIsdwaUd0XKe0=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIhjDjuK1PCkOBbp78U6s5ncfexyDWoTig+kP azv5llnzEyJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIYwAKCRCPgPtYfRL+ Tvk9B/9QuqdXnZYIXbPY5QyGEzKpv/yIQf8Fmo1Xe7pN9/J5ElhywFqhNhcllPZbhNbh+arQM4p XrWWvB+c/eY/1bIHdYR+qe007WvGWDyghR1UvCXW2tCmP0qTftJF81EC4PzKWlZ8mWKvDSM1qDd 82swaanWPhvIK94zSaL/O32aLLYftK3YyYCQ8CP/woJYXHyvl1+gQg8n1o4/qIvQSmVbKTF4icT dBLmykfHutIGuFXtOBtw5hDEHf9/lOEjCsyt4wJhR1Ehc0tdw7OdEy7v+HnwPSdN99p55G1zEri C/Wck1OKykQc1okg7VOl/I5icwNqc7dps7BZmnzzvwN/4tk9 X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013428_186337_B6E68971 X-CRM114-Status: GOOD ( 14.60 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-brcmstb driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-brcmstb.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-brcmstb.c b/drivers/pwm/pwm-brcmstb.c index 0fdeb0b2dbf3..82d27d07ba91 100644 --- a/drivers/pwm/pwm-brcmstb.c +++ b/drivers/pwm/pwm-brcmstb.c @@ -54,7 +54,6 @@ struct brcmstb_pwm { void __iomem *base; struct clk *clk; - struct pwm_chip chip; }; static inline u32 brcmstb_pwm_readl(struct brcmstb_pwm *p, @@ -77,7 +76,7 @@ static inline void brcmstb_pwm_writel(struct brcmstb_pwm *p, u32 value, static inline struct brcmstb_pwm *to_brcmstb_pwm(struct pwm_chip *chip) { - return container_of(chip, struct brcmstb_pwm, chip); + return pwmchip_get_drvdata(chip); } /* @@ -230,12 +229,14 @@ MODULE_DEVICE_TABLE(of, brcmstb_pwm_of_match); static int brcmstb_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct brcmstb_pwm *p; int ret; - p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); - if (!p) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 2, sizeof(*p)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + p = to_brcmstb_pwm(chip); p->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(p->clk)) @@ -244,15 +245,13 @@ static int brcmstb_pwm_probe(struct platform_device *pdev) platform_set_drvdata(pdev, p); - p->chip.dev = &pdev->dev; - p->chip.ops = &brcmstb_pwm_ops; - p->chip.npwm = 2; + chip->ops = &brcmstb_pwm_ops; p->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(p->base)) return PTR_ERR(p->base); - ret = devm_pwmchip_add(&pdev->dev, &p->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret) return dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n"); From patchwork Wed Feb 14 09:31:12 2024 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: 13556140 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 57A5DC48BC4 for ; Wed, 14 Feb 2024 09:35:31 +0000 (UTC) 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=pYgjnz1K0nvrJzfzfoSTlXLZjy33DiSiwvJUBGU9gkA=; b=2sDE83lQoPcnpj 7oWM3YMmNFMwuhzFYQayFKZHMU3f4/1jXQmqA54Xi8Akh+HoDHKL2iMBEr5Z83mUuHzaaqcTtyv+p HGoZibX29vK0CmP+jT/VUS7yAsG1Dzkf0aw1t5nMxAF2BiIB8SX/iAY+QJzc3LbRlZ40Ur8+zQLXp aBPJYkq3TQap1aBMo3XCsvQ49BUhempZoLHRUEINo6b/lK+kNiT8ifQfCIdXe7uqq5K/9+oiHaO5p Elnqv6ryd6zWccgKtVn3h3KgSccwOeC/aiYMji50DSUhZsoDcIdX9hDksbW3QJYbbGcOKe4AYvedw ZVkGxBX0/+xuCA97PYQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfh-0000000CKzx-0bbz; Wed, 14 Feb 2024 09:35:17 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBev-0000000CK9z-0CQH for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:31 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBeo-0004Ya-OW; Wed, 14 Feb 2024 10:34:22 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBen-000f9e-P7; Wed, 14 Feb 2024 10:34:21 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBen-004Y1G-2H; Wed, 14 Feb 2024 10:34:21 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Alexander Shiyan , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 025/164] pwm: clps711x: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:31:12 +0100 Message-ID: <334e633bb8e4c26dc59883b068466387769b65f9.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2072; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=gyrgGlXTWMnebiB+hz+WH9nrN2SBwKfFMXH7r00+5dc=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIhnaOjCBHGn+o3Ok1bhX2UuEaK5pP+4nxTtw Y7mKhj77zGJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIZwAKCRCPgPtYfRL+ TpQUCACTA48IuaJcdy+Fxk0TIVBsStrCdx6SpohDDGeuSnPQaWFkYtE30BesEY1u7IUFLoY/wpz wCmN71AhHPrlWqr1Uj+poAmfUj0gAm9rFnDNpkN4y5fnUsswXIyCbb7g+mPJUYvSSswTSLHlJ83 UNaIfprDAmKGyAGbVoXHXtKr23EshX8G/ty3GbJsz08xrUIPBzDiZ7LCqMsy63kgB2dDCzvgUrd EbPK1THpdS3YTGRaQPfrJNGSBXkTKvCadzykEaWuPLOosNQIxKZjtr9i4WIw1Cd4RQ1d4Ov4+UM RD9UmBX2Rc6DJTKHqwFzs1XeCL/VuCLSAHaNWo8mMe+Tu7hw X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013429_202374_66DC064D X-CRM114-Status: GOOD ( 15.46 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-clps711x driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-clps711x.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-clps711x.c b/drivers/pwm/pwm-clps711x.c index f3b4af7963be..c950e1dbd2b8 100644 --- a/drivers/pwm/pwm-clps711x.c +++ b/drivers/pwm/pwm-clps711x.c @@ -12,7 +12,6 @@ #include struct clps711x_chip { - struct pwm_chip chip; void __iomem *pmpcon; struct clk *clk; spinlock_t lock; @@ -20,7 +19,7 @@ struct clps711x_chip { static inline struct clps711x_chip *to_clps711x_chip(struct pwm_chip *chip) { - return container_of(chip, struct clps711x_chip, chip); + return pwmchip_get_drvdata(chip); } static int clps711x_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) @@ -76,11 +75,13 @@ static const struct pwm_ops clps711x_pwm_ops = { static int clps711x_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct clps711x_chip *priv; - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 2, sizeof(*priv)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + priv = to_clps711x_chip(chip); priv->pmpcon = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(priv->pmpcon)) @@ -90,13 +91,11 @@ static int clps711x_pwm_probe(struct platform_device *pdev) if (IS_ERR(priv->clk)) return PTR_ERR(priv->clk); - priv->chip.ops = &clps711x_pwm_ops; - priv->chip.dev = &pdev->dev; - priv->chip.npwm = 2; + chip->ops = &clps711x_pwm_ops; spin_lock_init(&priv->lock); - return devm_pwmchip_add(&pdev->dev, &priv->chip); + return devm_pwmchip_add(&pdev->dev, chip); } static const struct of_device_id __maybe_unused clps711x_pwm_dt_ids[] = { From patchwork Wed Feb 14 09:31:34 2024 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: 13556151 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id BCD50C48BC4 for ; Wed, 14 Feb 2024 09:36:01 +0000 (UTC) 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=agOiFBf7/h/+H8iHqoAMtvR7SWRASFBaFR0Fmy4xr4U=; b=zLSNEHxxaigSK5 keshKTKdaUGJ1gBhvV7TjgWFPhvJguPS6f29+F6dg8peRIuglFMNlw0OCPsE84OD6aF0V7COttvqJ MsyQbKcVvXi4rspL57AcD1JQZ6VGrP4TX6luBDibSjcsWEtk4RAH1bfi66KGkSqVHqOg3mojGGlG6 dYk4L1W43z5AA4sPbBtf9li0mu/qBNRT754/ptZvAxTzqxbglQPCieu6SyTyU1SZvVEPCdN25G35R 59FxuyCOo+hKqsbiJeHQPfHG78T+qLZC12B2aKPeF966Y9jVbA8dOd2TMMAxVNCgac+ZksmoJ1I0T FeMdg20Q+cjeyZp6dZlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBg6-0000000CLKE-3JyZ; Wed, 14 Feb 2024 09:35:42 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBey-0000000CKG5-2Huu for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:36 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBer-0004if-MN; Wed, 14 Feb 2024 10:34:25 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBer-000fBl-5H; Wed, 14 Feb 2024 10:34:25 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBer-004Y2r-0F; Wed, 14 Feb 2024 10:34:25 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Shawn Guo , Sascha Hauer , linux-pwm@vger.kernel.org Cc: Fabio Estevam , NXP Linux Team , linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 047/164] pwm: imx1: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:31:34 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2190; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=NGI4f/O27bDdWqiTxX59BIzQ7kMifE+Op4tqWuQH41Q=; b=owGbwMvMwMXY3/A7olbonx/jabUkhtQzHQ219XNCZ61bIZnSdtW+gGnxjm29WT9Vp2d0mUx8M +dNRXlJJ6MxCwMjF4OsmCKLfeOaTKsqucjOtf8uwwxiZQKZwsDFKQATieHnYFgyr7n2iWeF/Lal QqINXMpvJuxTPe08T2bGpYpfk/jYfsb4PU16Xx58rZvr1NZD2YWa3JNty6wtVmlp3s6LDW/yv1t 3duY09Rlqq82bA/b6nfeUe5T2iOu5UMrjhQysarNtrOP8HoQfcv5Zys8543dD8t3IX5ZJcgl3kn Y7+3Iw+WoaK8msW/CHfarveot1ItmT1O/qduQynhOKWpc2d4ajycuoLuXzpaeURTnvRHVv+huxn I3berebWEqT5YragnclTbOd9DhKnZYa+v/XCGv747+/zPvAg+dXyxOLZtWcvCPtzvz76+aIby+l a7jPltz1eCC9wfKe2J7ISyHn1u+1Mp74IMbmcf3emsk7AA== X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013432_888356_170D2C06 X-CRM114-Status: GOOD ( 15.25 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-imx1 driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Also convert the to_pwm_imx1_chip() helper macro to a static inline to get some type safety. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-imx1.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-imx1.c b/drivers/pwm/pwm-imx1.c index d175d895f22a..1d2aae2d278f 100644 --- a/drivers/pwm/pwm-imx1.c +++ b/drivers/pwm/pwm-imx1.c @@ -28,10 +28,12 @@ struct pwm_imx1_chip { struct clk *clk_ipg; struct clk *clk_per; void __iomem *mmio_base; - struct pwm_chip chip; }; -#define to_pwm_imx1_chip(chip) container_of(chip, struct pwm_imx1_chip, chip) +static inline struct pwm_imx1_chip *to_pwm_imx1_chip(struct pwm_chip *chip) +{ + return pwmchip_get_drvdata(chip); +} static int pwm_imx1_clk_prepare_enable(struct pwm_chip *chip) { @@ -156,11 +158,13 @@ MODULE_DEVICE_TABLE(of, pwm_imx1_dt_ids); static int pwm_imx1_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct pwm_imx1_chip *imx; - imx = devm_kzalloc(&pdev->dev, sizeof(*imx), GFP_KERNEL); - if (!imx) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*imx)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + imx = to_pwm_imx1_chip(chip); imx->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); if (IS_ERR(imx->clk_ipg)) @@ -172,15 +176,13 @@ static int pwm_imx1_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(imx->clk_per), "failed to get peripheral clock\n"); - imx->chip.ops = &pwm_imx1_ops; - imx->chip.dev = &pdev->dev; - imx->chip.npwm = 1; + chip->ops = &pwm_imx1_ops; imx->mmio_base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(imx->mmio_base)) return PTR_ERR(imx->mmio_base); - return devm_pwmchip_add(&pdev->dev, &imx->chip); + return devm_pwmchip_add(&pdev->dev, chip); } static struct platform_driver pwm_imx1_driver = { From patchwork Wed Feb 14 09:31:35 2024 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: 13556152 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E245AC48BEB for ; Wed, 14 Feb 2024 09:36:02 +0000 (UTC) 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=s9EupK3Kb8REzDlY9szScl6oGwe6twE8EE4bIti0A/A=; b=kfyIrUodwPb7Mt +pU2ZlGQNQ7idZH8fIcqy79hdVYALTau4AO9+diyUoI9czSKHbBXZQwfcPS6YLd8DGiGPLdp9sbIa 51NbJPgghNMN4NTRzArmpp8Z1LusiCdvM+gUBpGRY+h6Ai70kG2x0k1JYaF+5s54aIKRcL8QkWSjx A0dp6GHRmVTC2glRSjvNM8GleSU5UYwSWJKBah8g2k+YJwQ9wCX0ArvDHtLznPQlvEcvmfV0pn02Q TtBYUMQ7ui64rCvByt2uLTDySZwF6qETRpVhonWW6gl9gd1big5yLg41oY1+JHKdg3tJN/TCNWwQg cn/KOXtGbuQtjAYd3iAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBgB-0000000CLOR-1tcB; Wed, 14 Feb 2024 09:35:47 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBey-0000000CKG9-3RbZ for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:36 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBer-0004jL-Uu; Wed, 14 Feb 2024 10:34:25 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBer-000fBp-Al; Wed, 14 Feb 2024 10:34:25 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBer-004Y2v-0m; Wed, 14 Feb 2024 10:34:25 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Shawn Guo , Sascha Hauer , linux-pwm@vger.kernel.org Cc: Fabio Estevam , NXP Linux Team , linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 048/164] pwm: imx27: Make use of pwmchip_parent() accessor Date: Wed, 14 Feb 2024 10:31:35 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1489; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=RuNDzuLdvJRxR0ckpJ+3ys/tCVKtgBXKMYvbIUdoyZg=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIiBZ0q35U/jB2Oz5eygTO2iXNMY+QWm/6azQ ShvztQDekKJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIgQAKCRCPgPtYfRL+ TjIjCACeZlXTYvp10oOet167MF9Mb7oGaPaSnHl6Xj/Pdp2HT2IrmANnlQNDwI5qE4oYBKa4t/D IRRTLwy0eOOTYsQOfgx9CT9Hx+gRDtjv4fG7yU7sLd8WHoKwFvK0PAxrDwPF86tFnIaJzYvxkVR RJNiQiIvIsScfUSS8phZ3Ff2Lp5DWQnmXdz7DmpfeuxOiQlPmlmT/4NsVIxdR+DIZ/QOQYXyHpB 8q/nXK9wafiZSY2dwgCvg5P2uLXQJPVi/KMY5lrnmr8B0Yw2X1EBdiwF8OZ0Y03RftP18jZE3pB gOcdcsN1ttMUOBuJ2oDkf6IrPLPazZbGa8Ls3w3OZTnFfDqS X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013433_095827_0A2BF236 X-CRM114-Status: GOOD ( 13.96 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org struct pwm_chip::dev is about to change. To not have to touch this driver in the same commit as struct pwm_chip::dev, use the accessor function provided for exactly this purpose. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-imx27.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pwm/pwm-imx27.c b/drivers/pwm/pwm-imx27.c index 7d9bc43f12b0..5d796453519a 100644 --- a/drivers/pwm/pwm-imx27.c +++ b/drivers/pwm/pwm-imx27.c @@ -145,7 +145,7 @@ static int pwm_imx27_get_state(struct pwm_chip *chip, state->polarity = PWM_POLARITY_INVERSED; break; default: - dev_warn(chip->dev, "can't set polarity, output disconnected"); + dev_warn(pwmchip_parent(chip), "can't set polarity, output disconnected"); } prescaler = MX3_PWMCR_PRESCALER_GET(val); @@ -177,7 +177,7 @@ static int pwm_imx27_get_state(struct pwm_chip *chip, static void pwm_imx27_sw_reset(struct pwm_chip *chip) { struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip); - struct device *dev = chip->dev; + struct device *dev = pwmchip_parent(chip); int wait_count = 0; u32 cr; @@ -196,7 +196,7 @@ static void pwm_imx27_wait_fifo_slot(struct pwm_chip *chip, struct pwm_device *pwm) { struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip); - struct device *dev = chip->dev; + struct device *dev = pwmchip_parent(chip); unsigned int period_ms; int fifoav; u32 sr; From patchwork Wed Feb 14 09:31:36 2024 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: 13556154 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7A705C48BEB for ; Wed, 14 Feb 2024 09:36:15 +0000 (UTC) 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=IWLUn0kYbAVh8J7qP7GW324cON+ucDB/5aZDfDJ5hcA=; b=Tt9MfMhRtwNumQ wGZVgUBzuRXJa+NLOW/hrfnY+O0UfM0AiNgeXeCmPWwTElYrl++nR9L5NnCVWMJaISZUCKFVAv2ns k8BdID4XOiwonSxD7WhL6+Q8UhYOFagtMkh9tprsqFfkaGOemi9ASB+cQpH7z9M8fR+L6/oZVFL3y 1UYxvlp/8c3rbioBWjOeznYb2HI6G6Qp8c0LYYo97wJ+QVbk1xxOkna+n3O+lZKB4062p/PCFCLEw /M/3RiMV7OMdf2ZqiM+DC9RKeWR6H35GIA1JRw/FnpoIBhGwlqkT5gDahmZbc3y9BtojgHf3o/Ozm CqauHdtrc9dJ5Q8G0Jnw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBgN-0000000CLYH-0iaW; Wed, 14 Feb 2024 09:35:59 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBez-0000000CKGr-27RU for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:37 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBes-0004kP-7l; Wed, 14 Feb 2024 10:34:26 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBer-000fBt-Fs; Wed, 14 Feb 2024 10:34:25 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBer-004Y2z-1K; Wed, 14 Feb 2024 10:34:25 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Shawn Guo , Sascha Hauer , linux-pwm@vger.kernel.org Cc: Fabio Estevam , NXP Linux Team , linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de, Philipp Zabel Subject: [PATCH v6 049/164] pwm: imx27: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:31:36 +0100 Message-ID: <3da748c80e9bbe29e7c119190dbc4bd67d159f22.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2566; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=4UWwN6hGhiY3Lx7k+3TOX6wn+Xv0GX/Yqr4Jly9g4dU=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIiCoMyHMnax0/a5dj1s9bzyMpQ5xVyhOVTUA Bwp3ETRb1uJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIggAKCRCPgPtYfRL+ ToLiCACtMp9qRiqlRtgeSPqkkWCu+MrQfUFpPF2i6qdpImT3z1MaizkXm8kHeTJt+/0ICnuv+3p w/Fl+s4BOPJLmt2z6poDDyB2OlKlU3QhgPt20BCxVCPkYl+jRM+2GCMVwzHe9wMtF9zjqTZuWNF EOUml6N4SAYv7rR2NOw3rrAphdEB/7CDwJHe2+05MQoeSPTfR4s9/4CsK9275JKPH9Fn9pGBG6D k2HYMhf79EFHqhGyznpiwaWMGjnfqKIutFWs2lJ3Cla+Vzvde/grZLwxye/VRfSVyuXhTB7BD2C WeUEdqe9cbEsB02+LUOH4LPUd1HmyZ2ykVyvEBLlh/j7elx3 X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013433_674876_DB35BFFE X-CRM114-Status: GOOD ( 16.29 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-imx27 driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Also convert the to_pwm_imx27_chip() helper macro to a static inline to get some type safety. Reviewed-by: Philipp Zabel Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-imx27.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-imx27.c b/drivers/pwm/pwm-imx27.c index 5d796453519a..54589f0b3b78 100644 --- a/drivers/pwm/pwm-imx27.c +++ b/drivers/pwm/pwm-imx27.c @@ -83,7 +83,6 @@ struct pwm_imx27_chip { struct clk *clk_ipg; struct clk *clk_per; void __iomem *mmio_base; - struct pwm_chip chip; /* * The driver cannot read the current duty cycle from the hardware if @@ -93,7 +92,10 @@ struct pwm_imx27_chip { unsigned int duty_cycle; }; -#define to_pwm_imx27_chip(chip) container_of(chip, struct pwm_imx27_chip, chip) +static inline struct pwm_imx27_chip *to_pwm_imx27_chip(struct pwm_chip *chip) +{ + return pwmchip_get_drvdata(chip); +} static int pwm_imx27_clk_prepare_enable(struct pwm_imx27_chip *imx) { @@ -306,13 +308,15 @@ MODULE_DEVICE_TABLE(of, pwm_imx27_dt_ids); static int pwm_imx27_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct pwm_imx27_chip *imx; int ret; u32 pwmcr; - imx = devm_kzalloc(&pdev->dev, sizeof(*imx), GFP_KERNEL); - if (imx == NULL) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*imx)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + imx = to_pwm_imx27_chip(chip); imx->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); if (IS_ERR(imx->clk_ipg)) @@ -324,9 +328,7 @@ static int pwm_imx27_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(imx->clk_per), "failed to get peripheral clock\n"); - imx->chip.ops = &pwm_imx27_ops; - imx->chip.dev = &pdev->dev; - imx->chip.npwm = 1; + chip->ops = &pwm_imx27_ops; imx->mmio_base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(imx->mmio_base)) @@ -341,7 +343,7 @@ static int pwm_imx27_probe(struct platform_device *pdev) if (!(pwmcr & MX3_PWMCR_EN)) pwm_imx27_clk_disable_unprepare(imx); - return devm_pwmchip_add(&pdev->dev, &imx->chip); + return devm_pwmchip_add(&pdev->dev, chip); } static struct platform_driver imx_pwm_driver = { From patchwork Wed Feb 14 09:31:37 2024 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: 13556153 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 5E423C48BEB for ; Wed, 14 Feb 2024 09:36:11 +0000 (UTC) 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=hEHXhM1xB3k9sjyUpITWXt6fw/eUCqs37oVMrGnQK9o=; b=KOB3U/LZF4lxky GjwBDShHOMR/G2MXdMo0uhp5vU2YA2+ConX09rOMQz8u6JaOoTeqdLgq5Ee5lr5ZmgdVLX10TjMHz 7gb5ReBgrPlZLiAMgZt3wPQT06xB+rQA1KeiIDyGBjw22yCfNxi2lsu6FGbl6Z4pSPSOxgBSMYfh9 y3yAz9Xz765JPy2s87GjQ/CwRSOow6xVwIp+5SGKZ+93jwDCXgC4Y2YrbNHBSPIQGvwEfvdOpIfbX PxlPNviiq8IvslV/WjGeGkPacz11u2tKgV/Spkk5sZ+gpyolpIG+0pKDKx8rphCYnq+zsryP+0q9i FM4rUaAlq+dQCln4qVuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBgG-0000000CLSO-3aQg; Wed, 14 Feb 2024 09:35:52 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBez-0000000CKGP-1A3U for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:36 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBes-0004lg-8Z; Wed, 14 Feb 2024 10:34:26 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBer-000fBx-L8; Wed, 14 Feb 2024 10:34:25 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBer-004Y33-1q; Wed, 14 Feb 2024 10:34:25 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Shawn Guo , Sascha Hauer , linux-pwm@vger.kernel.org Cc: Fabio Estevam , NXP Linux Team , linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 050/164] pwm: imx-tpm: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:31:37 +0100 Message-ID: <5de5d53295fa445d58a79f83421dd3406166c3c6.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2599; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=aV+8xYJnCvfIi2Ta/CNMW2gzEdLgM6XRsj1xOw9beLQ=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIiE/gw/YmlmFDigqQyu8T9Vq/opOc0QDk9gQ 4+iAIXSPJKJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIhAAKCRCPgPtYfRL+ TmvqB/0cP4uicdQzdlVh23o8AAcr/9AMQbQ9cCTPO6hAoWmajR+nMwXrXsSChYGmb+6TRjoUiPd +meksPH5p6+LCH+RyqHXRArVuDlfZBN200wJIrrJQr5Ho3wTIYT1zUBI1GD5QRG5piuytRnb9We AzxPNm0rSR5Toog9IWoqvphMK6zjQV3PWj9EBaN5elnYIDKPhoXuzEv9KHq3l8vJHXkzoH6jhvH 0mN2S3GhqmujbO4RPAQPfVcT1rAiIl7/wdnDXnFOJOMNrey98QumZ5YiQ3Qrzh+GbMZ69U2iLFs AaIumHHJZnMAO7wJXWr3AmbQVJGRyRvYWLBNJhFuz67Fimkq X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013433_478667_3EC539E4 X-CRM114-Status: GOOD ( 16.33 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-tmp driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-imx-tpm.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c index 9fc290e647e1..b04b974c5f32 100644 --- a/drivers/pwm/pwm-imx-tpm.c +++ b/drivers/pwm/pwm-imx-tpm.c @@ -57,7 +57,6 @@ #define PWM_IMX_TPM_MOD_MOD GENMASK(PWM_IMX_TPM_MOD_WIDTH - 1, 0) struct imx_tpm_pwm_chip { - struct pwm_chip chip; struct clk *clk; void __iomem *base; struct mutex lock; @@ -75,7 +74,7 @@ struct imx_tpm_pwm_param { static inline struct imx_tpm_pwm_chip * to_imx_tpm_pwm_chip(struct pwm_chip *chip) { - return container_of(chip, struct imx_tpm_pwm_chip, chip); + return pwmchip_get_drvdata(chip); } /* @@ -336,35 +335,40 @@ static const struct pwm_ops imx_tpm_pwm_ops = { static int pwm_imx_tpm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct imx_tpm_pwm_chip *tpm; + void __iomem *base; int ret; + unsigned int npwm; u32 val; - tpm = devm_kzalloc(&pdev->dev, sizeof(*tpm), GFP_KERNEL); - if (!tpm) - return -ENOMEM; + base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) + return PTR_ERR(base); + + /* get number of channels */ + val = readl(base + PWM_IMX_TPM_PARAM); + npwm = FIELD_GET(PWM_IMX_TPM_PARAM_CHAN, val); + + chip = devm_pwmchip_alloc(&pdev->dev, npwm, sizeof(*tpm)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + tpm = to_imx_tpm_pwm_chip(chip); platform_set_drvdata(pdev, tpm); - tpm->base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(tpm->base)) - return PTR_ERR(tpm->base); + tpm->base = base; tpm->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(tpm->clk)) return dev_err_probe(&pdev->dev, PTR_ERR(tpm->clk), "failed to get PWM clock\n"); - tpm->chip.dev = &pdev->dev; - tpm->chip.ops = &imx_tpm_pwm_ops; - - /* get number of channels */ - val = readl(tpm->base + PWM_IMX_TPM_PARAM); - tpm->chip.npwm = FIELD_GET(PWM_IMX_TPM_PARAM_CHAN, val); + chip->ops = &imx_tpm_pwm_ops; mutex_init(&tpm->lock); - ret = devm_pwmchip_add(&pdev->dev, &tpm->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret) return dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n"); From patchwork Wed Feb 14 09:31:47 2024 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: 13556148 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CD76AC48BC4 for ; Wed, 14 Feb 2024 09:35:44 +0000 (UTC) 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=NaNXY/33CY4MuiggIysqCZQ5CXWgIKZ8dn+vIwreePY=; b=f47p8KwCV0q/BZ udU1jBlivgJxtDKO8OcXfczBlryObUVFoYw0vBYudXwvYnAQXtyGN4n9C/N/dkaaaXnjF1obL7Ebn jgoW8ZsTVN+piV2ctZxP8HOACpVeIuiaxKOXODd25poKRHHTxe/9fk56rKbzNce9XmOy6GuRJyAHR M0DoF3LQIMenASgp3VR1XlZCpK0g/LtXkjcNvd42ft0vLSz5TKPVQHwoqDcAecmMAUtWd4D+graNC w+XFRD4rXMhHx7DzL/8Gup6jEs6/K8k4bj60A/AI7ZNwLc87DZQgtw6KfS9/hGWa9fbgUBwFF1/g+ R3R/5TUoe2qic4irYC5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfp-0000000CL5X-20U6; Wed, 14 Feb 2024 09:35:25 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBey-0000000CKG2-1m2k for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:34 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBev-0004va-9z; Wed, 14 Feb 2024 10:34:29 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBet-000fCW-50; Wed, 14 Feb 2024 10:34:27 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBet-004Y3h-0F; Wed, 14 Feb 2024 10:34:27 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Vladimir Zapolskiy , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 060/164] pwm: lpc18xx-sct: Drop hardly used member from driver private data Date: Wed, 14 Feb 2024 10:31:47 +0100 Message-ID: <427a719a24dd7ff5ebbac3e260a1773c094c7489.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1382; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=YDTFgxPpr51UWO9J5V5J32JzwomS+rPJbEeNSQqkdnE=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIiPAl702P79APm18zuoqL+EetmK4EZ2kLZ4I UtEWnAZ6rGJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIjwAKCRCPgPtYfRL+ TiuyCACk2zuyu3mfzN4HOMD+qXLtB9AblHyVUIO7uE7FTxniqdppYLttc/UXaC0fJTNj89LHJ5K IJHEjuOvH0pYJzmWjqdEo3tf+BqwERYKcdPdS3J9nIbsa1DJieB/vkwmEC+92Yj2KHupTHOZG6p Ib4QdS0kxriB1w9vP9dc1L+wR5GccFs2O2PQyZlJVSOCWI71fINw+O9GnUpPigwRIVTGzTaUNkc 0rXlDFhgjBrBDwTgywPTfD414XXut8kbF9ZjPJtgxszOez+0RgVp/ZRazPxIF3KrlPRASt/lUdV glAVqG1sS7qzlKhfXDlx40gATxamc/MfJXDL9gtB4E7eN3Ey X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013432_581667_7274C7F1 X-CRM114-Status: GOOD ( 14.61 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The device pointer is only used once in lpc18xx_pwm_request(). There the pwm_chip is available, too, which has a pointer to the same structure. Replace the usage accordingly and drop the then write-only member variable. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-lpc18xx-sct.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/pwm/pwm-lpc18xx-sct.c b/drivers/pwm/pwm-lpc18xx-sct.c index fe891fa71a1d..754ea2c3f49b 100644 --- a/drivers/pwm/pwm-lpc18xx-sct.c +++ b/drivers/pwm/pwm-lpc18xx-sct.c @@ -92,7 +92,6 @@ struct lpc18xx_pwm_data { }; struct lpc18xx_pwm_chip { - struct device *dev; struct pwm_chip chip; void __iomem *base; struct clk *pwm_clk; @@ -289,7 +288,7 @@ static int lpc18xx_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) LPC18XX_PWM_EVENT_MAX); if (event >= LPC18XX_PWM_EVENT_MAX) { - dev_err(lpc18xx_pwm->dev, + dev_err(chip->dev, "maximum number of simultaneous channels reached\n"); return -EBUSY; } @@ -358,8 +357,6 @@ static int lpc18xx_pwm_probe(struct platform_device *pdev) if (!lpc18xx_pwm) return -ENOMEM; - lpc18xx_pwm->dev = &pdev->dev; - lpc18xx_pwm->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(lpc18xx_pwm->base)) return PTR_ERR(lpc18xx_pwm->base); From patchwork Wed Feb 14 09:31:48 2024 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: 13556147 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A031EC48BEB for ; Wed, 14 Feb 2024 09:35:44 +0000 (UTC) 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=9BtnbtVz2f2ujAlQkuQtqN8uR/L4vGtMufIsR3JeiEE=; b=32fZvBZDnwK9Fg SZ83QxJXWuNacbXJ+B6mJ9Z8C+J3eDH2P/YbI1hn8+U/tL4aBKooSXiSW9MT01f4P1emunSIxaxN3 ZMD/fT93d2wT24ZPVnitLo3XanK4/uhKAO85uzRUzYLLPosJb00k1DFttwy58mTcWVOxgdBK5GUUs Yqb7x6MDE2HF8A7Do8cfpgMBIgynqgWRgYXsCNt/2AGVqoXNDeWlxxNoeMz/YtTFcBBmJCAnZhOfz aCvAg5ad/jNog+PLB07RKZ52WhnVscRrdtBx5af03DWGzSooTm2X6vEFJufn/weyYQRwk8yX4+9v6 uSdx0WDMF/nZSopfcz6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfr-0000000CL7P-3Uoa; Wed, 14 Feb 2024 09:35:27 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBey-0000000CKFz-1Mte for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:34 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBev-0004wV-0K; Wed, 14 Feb 2024 10:34:29 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBet-000fCZ-AB; Wed, 14 Feb 2024 10:34:27 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBet-004Y3l-0l; Wed, 14 Feb 2024 10:34:27 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Vladimir Zapolskiy , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 061/164] pwm: lpc18xx-sct: Make use of pwmchip_parent() accessor Date: Wed, 14 Feb 2024 10:31:48 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1673; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=+bU0R7GzLyDnXaxxwxDrWA+el/qKWufFtdcDxFbKLdM=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIiQx7bvzJLGCmTglV2Tklq0yjzqAK/QCCh3R Lo2SDnKYuaJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIkAAKCRCPgPtYfRL+ TgyKCACXbucjr3qoqaKV+QgrkfnarjjPe03jgVt8KNVxDU9OukyI4k3zWl8xf/BFtoildVIITav mn6FsZmlnh5jS7O6NPmr1vmuC/pwqD8kodI5SMEuvAqZBplI1FdGfkX9izbipczgvGih2pHNlTf TyysdxD10rclBmOMiMf6xbN/uqS4jWiL2+p4Eo++Jr6QRleB82jeCLwpcbkXBA81VqVAaZurpMf gfrxVh18V7VJA3Gf78UbKsolHF44MiViH6WftA5Y+K2rbWo9diSuDhp6NNMQoVMKKSlpVRog8DA Q5AzSmVyv1DScdG0vBhB6wOeb6geqkfl+jwegZmg5hnyzjNA X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013432_559298_5FA5E966 X-CRM114-Status: GOOD ( 12.64 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org struct pwm_chip::dev is about to change. To not have to touch this driver in the same commit as struct pwm_chip::dev, use the accessor function provided for exactly this purpose. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-lpc18xx-sct.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pwm/pwm-lpc18xx-sct.c b/drivers/pwm/pwm-lpc18xx-sct.c index 754ea2c3f49b..46eeca27d9ab 100644 --- a/drivers/pwm/pwm-lpc18xx-sct.c +++ b/drivers/pwm/pwm-lpc18xx-sct.c @@ -197,7 +197,7 @@ static int lpc18xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, if (period_ns < lpc18xx_pwm->min_period_ns || period_ns > lpc18xx_pwm->max_period_ns) { - dev_err(chip->dev, "period %d not in range\n", period_ns); + dev_err(pwmchip_parent(chip), "period %d not in range\n", period_ns); return -ERANGE; } @@ -213,7 +213,7 @@ static int lpc18xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, */ if (requested_events > 2 && lpc18xx_pwm->period_ns != period_ns && lpc18xx_pwm->period_ns) { - dev_err(chip->dev, "conflicting period requested for PWM %u\n", + dev_err(pwmchip_parent(chip), "conflicting period requested for PWM %u\n", pwm->hwpwm); mutex_unlock(&lpc18xx_pwm->period_lock); return -EBUSY; @@ -288,7 +288,7 @@ static int lpc18xx_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) LPC18XX_PWM_EVENT_MAX); if (event >= LPC18XX_PWM_EVENT_MAX) { - dev_err(chip->dev, + dev_err(pwmchip_parent(chip), "maximum number of simultaneous channels reached\n"); return -EBUSY; } From patchwork Wed Feb 14 09:31:49 2024 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: 13556155 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A6425C48BEB for ; Wed, 14 Feb 2024 09:36:22 +0000 (UTC) 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=0qfFDDTJ0cMqmvVwclKhvCPVFDlYFXDCcM+Rzy6X9mk=; b=mCo5zo5zHZXvGW jECpMplv+hT9Iu9Rj5gYyHkh9K3FRjgjAVkXuNDccXplTDsEHDnMHc/slpczQRndjwZMmD5NEW7uT ZP3Vu1YB+eDUvhd9fbS80oedJr1Mdqvv08jQFb21YFuLv812OTLDgLaena76sV+S9QGYsFiuvVVnR IWGLBPdViMXsyPGiZS1kBVMv5f3vo00D/kUHglvUZ+/JwonsfkQzluyC549FUVbIZjO4J7NIzVdkr jvuob9F2Rc+SMZaH2JE2ZFcpQ+Lt+JTXxglrxe6h5Sxqx/y6KsuQ7rdU/mi3/ejGm4PufVNsBjAAw wO33IUhM3BxZTFvo4kzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBgS-0000000CLcw-2155; Wed, 14 Feb 2024 09:36:04 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBez-0000000CKH9-2UMV for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:37 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBew-0004xK-89; Wed, 14 Feb 2024 10:34:30 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBet-000fCc-FA; Wed, 14 Feb 2024 10:34:27 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBet-004Y3p-1G; Wed, 14 Feb 2024 10:34:27 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Vladimir Zapolskiy , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 062/164] pwm: lpc18xx-sct: Prepare removing pwm_chip from driver data Date: Wed, 14 Feb 2024 10:31:49 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2552; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=3da8qrj1JzLsfU2rOYyBMIHXaXMB5GdW4GAulxI0eRc=; b=owGbwMvMwMXY3/A7olbonx/jabUkhtQzHRPt47KY1T6/9gq5HHjvGb+wAk/v/H1sZZW3ZSZfi frnd4+tk9GYhYGRi0FWTJHFvnFNplWVXGTn2n+XYQaxMoFMYeDiFICJnK7jYOiJTpA9uXbFniLL K1F3mrI5Bf7WqC/Z9vqu+5bdG9zWKR6wyWOM7Lt5R2m2sBbb6T0vcv+yWv+r1U4X/DWtRDWybVG 65FZOxijVrgTe+9KL07doMvRWRIckXvuxQpvZMY9rI7vZz3pbjejUWf9nymlEMfyYtr/M7cvB7r Nb4hryC2NUXsW98Iy3vR7i+SmQ8+/p14av5b87zFx8p+tlgH2yR9OVsuxJXkz5d8/vu+2wuHFJ5 I3QpZVx1yTk5jD6r9kcOWFLpHPw7c/sJT3ibJOPyT698z3GWUn/TbpWEJfSFNsa7ZP9h9I6FkXn P5kY52PFt4+pev22Lt5nCrZfbB5u+x1Y4DLDTJFnkoIqAA== X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013433_826897_A4A6ABB1 X-CRM114-Status: GOOD ( 14.05 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the driver for further changes that will drop struct pwm_chip chip from struct lpc18xx_pwm_chip. Use the pwm_chip as driver data instead of the lpc18xx_pwm_chip to get access to the pwm_chip in lpc18xx_pwm_remove() without using lpc18xx_pwm->chip. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-lpc18xx-sct.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/pwm/pwm-lpc18xx-sct.c b/drivers/pwm/pwm-lpc18xx-sct.c index 46eeca27d9ab..9b1e8141aec7 100644 --- a/drivers/pwm/pwm-lpc18xx-sct.c +++ b/drivers/pwm/pwm-lpc18xx-sct.c @@ -348,6 +348,7 @@ MODULE_DEVICE_TABLE(of, lpc18xx_pwm_of_match); static int lpc18xx_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct lpc18xx_pwm_chip *lpc18xx_pwm; int ret; u64 val; @@ -356,6 +357,7 @@ static int lpc18xx_pwm_probe(struct platform_device *pdev) GFP_KERNEL); if (!lpc18xx_pwm) return -ENOMEM; + chip = &lpc18xx_pwm->chip; lpc18xx_pwm->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(lpc18xx_pwm->base)) @@ -386,9 +388,9 @@ static int lpc18xx_pwm_probe(struct platform_device *pdev) lpc18xx_pwm->min_period_ns = DIV_ROUND_UP(NSEC_PER_SEC, lpc18xx_pwm->clk_rate); - lpc18xx_pwm->chip.dev = &pdev->dev; - lpc18xx_pwm->chip.ops = &lpc18xx_pwm_ops; - lpc18xx_pwm->chip.npwm = LPC18XX_NUM_PWMS; + chip->dev = &pdev->dev; + chip->ops = &lpc18xx_pwm_ops; + chip->npwm = LPC18XX_NUM_PWMS; /* SCT counter must be in unify (32 bit) mode */ lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_CONFIG, @@ -420,21 +422,22 @@ static int lpc18xx_pwm_probe(struct platform_device *pdev) val |= LPC18XX_PWM_PRE(0); lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_CTRL, val); - ret = pwmchip_add(&lpc18xx_pwm->chip); + ret = pwmchip_add(chip); if (ret < 0) return dev_err_probe(&pdev->dev, ret, "pwmchip_add failed\n"); - platform_set_drvdata(pdev, lpc18xx_pwm); + platform_set_drvdata(pdev, chip); return 0; } static void lpc18xx_pwm_remove(struct platform_device *pdev) { - struct lpc18xx_pwm_chip *lpc18xx_pwm = platform_get_drvdata(pdev); + struct pwm_chip *chip = platform_get_drvdata(pdev); + struct lpc18xx_pwm_chip *lpc18xx_pwm = to_lpc18xx_pwm_chip(chip); u32 val; - pwmchip_remove(&lpc18xx_pwm->chip); + pwmchip_remove(chip); val = lpc18xx_pwm_readl(lpc18xx_pwm, LPC18XX_PWM_CTRL); lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_CTRL, From patchwork Wed Feb 14 09:31:50 2024 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: 13556149 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 5B725C48BEB for ; Wed, 14 Feb 2024 09:35:51 +0000 (UTC) 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=QV9WZvnp7YRyTmLV+7/aRN5FyZ7dtXjVBefWk4GHG7I=; b=aanyeGgE3xoNCS /YC1rgqxDKYFXI65fnQtvCUxcOUEzad8xF1q4cwv+cF5Cl+OiofWjegRzSXTTb4FuWsHsRCp2uev8 PUy2DuEJq6cXsHYHcd7ttEyJZD/r7yek+kH0GDQrN/ljKZ/2GuipO6YqAUKNmYDMIWIuTgqFxrPYW eM5KbLn8C9xWexdmZDqON2qDPrfYO6uk+xtr9gPZjs4z3AIGfjCUsw67eJGCnWRzQO4DDdp4fBLec Fg1eB1yD6OLvvNFZbNgDtf3YaXKwQdwuYL19TyP88a0eZqQwuz6Iht4r2mEygxrQY2R8LGTkT+w3i gTPFvZxZvmooj0UODPaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfv-0000000CLAx-34cX; Wed, 14 Feb 2024 09:35:31 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBey-0000000CKFy-1mQc for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:35 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBev-0004yW-7P; Wed, 14 Feb 2024 10:34:29 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBet-000fCf-Lk; Wed, 14 Feb 2024 10:34:27 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBet-004Y3t-1v; Wed, 14 Feb 2024 10:34:27 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Vladimir Zapolskiy , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 063/164] pwm: lpc18xx-sct: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:31:50 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2018; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=MFtSyVVhuFf8aJtBBT9xCKFdFlNzZwELSw07Ki+RCLI=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIiTG24niAzJdEnN7lcf6OV9nLPjQr0PQc5Yq l4ksZ65xUGJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIkwAKCRCPgPtYfRL+ TikdB/9sCRSfX2aS8SITDexQCpDJaZv3TkZ+1JU1Hvq8S1Wfb3sUCLFoIAavrhAZF2xbmT2IQLk sY4LJzSy48P2j7RvowpwC5XnJbEC2Xgcez1dsM8hfCc7fiXUSH6FtKtR4ydTSBG0NEvFfD/2yUt v2WoLUThYudQwW/rr7ipCuu5o2QHcrKKaijkBwiAHAORVwZ+A2ja6bDJZJ/xKuKIMB+sVU5Bx2O XcbQCo0pLWrxdxX0QJAGnJOWyqBElH0mh3CNXSVeXZwlnfewftgJtP+N0p5iM7x01UapTg5i8q1 FflBasCfTnH2HO2ncGEmsmGdz1m/yWxXVOMEGirmv/0mKHmq X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013432_677726_BBFB5562 X-CRM114-Status: GOOD ( 14.48 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-lpc18xx-sct driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-lpc18xx-sct.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-lpc18xx-sct.c b/drivers/pwm/pwm-lpc18xx-sct.c index 9b1e8141aec7..04b76d257fd8 100644 --- a/drivers/pwm/pwm-lpc18xx-sct.c +++ b/drivers/pwm/pwm-lpc18xx-sct.c @@ -92,7 +92,6 @@ struct lpc18xx_pwm_data { }; struct lpc18xx_pwm_chip { - struct pwm_chip chip; void __iomem *base; struct clk *pwm_clk; unsigned long clk_rate; @@ -109,7 +108,7 @@ struct lpc18xx_pwm_chip { static inline struct lpc18xx_pwm_chip * to_lpc18xx_pwm_chip(struct pwm_chip *chip) { - return container_of(chip, struct lpc18xx_pwm_chip, chip); + return pwmchip_get_drvdata(chip); } static inline void lpc18xx_pwm_writel(struct lpc18xx_pwm_chip *lpc18xx_pwm, @@ -353,11 +352,10 @@ static int lpc18xx_pwm_probe(struct platform_device *pdev) int ret; u64 val; - lpc18xx_pwm = devm_kzalloc(&pdev->dev, sizeof(*lpc18xx_pwm), - GFP_KERNEL); - if (!lpc18xx_pwm) - return -ENOMEM; - chip = &lpc18xx_pwm->chip; + chip = devm_pwmchip_alloc(&pdev->dev, LPC18XX_NUM_PWMS, sizeof(*lpc18xx_pwm)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + lpc18xx_pwm = to_lpc18xx_pwm_chip(chip); lpc18xx_pwm->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(lpc18xx_pwm->base)) @@ -388,9 +386,7 @@ static int lpc18xx_pwm_probe(struct platform_device *pdev) lpc18xx_pwm->min_period_ns = DIV_ROUND_UP(NSEC_PER_SEC, lpc18xx_pwm->clk_rate); - chip->dev = &pdev->dev; chip->ops = &lpc18xx_pwm_ops; - chip->npwm = LPC18XX_NUM_PWMS; /* SCT counter must be in unify (32 bit) mode */ lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_CONFIG, From patchwork Wed Feb 14 09:31:51 2024 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: 13556156 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B47FBC48BEB for ; Wed, 14 Feb 2024 09:36:25 +0000 (UTC) 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=QrCjEvZfhSutI/EbePUZB9YCQiVQQG+JmH2rGGd02fI=; b=f5kNPOPQ7hK7x0 jdg070QTaJeeVF6ws2Dj+C6QxCXuv1cQFuBnN4WDbOEDtu5XM6ftw4tvPtqFf3rEB5jMLmaDOkDsC L+q8saZm7G8tJMXVO/Vi1jdoz6lTXBGn7aFT6VVZNvoWldpqzH1e8eX8WCa/6GcdG1uzOkpEh6mog 3hcAUbs26uIVl0OW6JJjVOhIwhh4boi7SXcIaKidJjF6RVlAhHzZRlLWPU1BBUJ6iEfi2HMUP5DnE ds8NI0n4kIqR7CYJyZ+m/0glCqCLHIM6E3V6DueWB37AzuXadGT10iVuI9QJOB3jY124vYH/IHnrj mbEZ9QVVP+z3AfFX01ug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBgW-0000000CLgv-2xkK; Wed, 14 Feb 2024 09:36:08 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBf0-0000000CKI3-0GjO for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:37 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBew-0004zN-Hz; Wed, 14 Feb 2024 10:34:30 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBet-000fCi-QP; Wed, 14 Feb 2024 10:34:27 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBet-004Y3x-2M; Wed, 14 Feb 2024 10:34:27 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Vladimir Zapolskiy , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 064/164] pwm: lpc32xx: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:31:51 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2513; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=9+ydUUPJChIWcJuM2euO9t4tqkll+AAJcdhAZlftnWM=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIiU9I8RCrycIAIENM0D6vXLedzLyxSUOh5A4 708jlsDJrOJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIlAAKCRCPgPtYfRL+ TnL6B/0aFdgNecr+BI53mDuzCbv+9Amvt0m6S6FbZaRFiBNBy8chumxk1bhxMN+h2f5a1VMkMPn oVzHDTZ+B40kFdqK+VD7I1xaNXUtSy6G1nvYg0WpjalC1EAx6tTgaFXy2kyEdlGyGr+MNsOVoGJ YKj9OEutGH1OGdOX7VoVUnYQ/zhJlDRxa2qVUhg5fmZUugckOqxIQClniu6B9mX/Hqde1kau2qR gINyQzDoEx06duHroYeOQoY0KLapLsqqHp4+2hC1IJFxwPrxpwkXtCn6HlvKoXrEVrbJFluE7Z4 9N9+o25oKbclDKqY9i9afEFf6Pz/rRQGWIWES3bO5Y9nOoSr X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013434_278343_27A428E9 X-CRM114-Status: GOOD ( 17.66 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-lpc32xx driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Also convert the to_lpc32xx_pwm_chip() helper macro to a static inline to get some type safety. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-lpc32xx.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/pwm/pwm-lpc32xx.c b/drivers/pwm/pwm-lpc32xx.c index 1d9f3e7a2434..c748537e57d1 100644 --- a/drivers/pwm/pwm-lpc32xx.c +++ b/drivers/pwm/pwm-lpc32xx.c @@ -15,7 +15,6 @@ #include struct lpc32xx_pwm_chip { - struct pwm_chip chip; struct clk *clk; void __iomem *base; }; @@ -23,8 +22,10 @@ struct lpc32xx_pwm_chip { #define PWM_ENABLE BIT(31) #define PWM_PIN_LEVEL BIT(30) -#define to_lpc32xx_pwm_chip(_chip) \ - container_of(_chip, struct lpc32xx_pwm_chip, chip) +static inline struct lpc32xx_pwm_chip *to_lpc32xx_pwm_chip(struct pwm_chip *chip) +{ + return pwmchip_get_drvdata(chip); +} static int lpc32xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, int duty_ns, int period_ns) @@ -119,13 +120,15 @@ static const struct pwm_ops lpc32xx_pwm_ops = { static int lpc32xx_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct lpc32xx_pwm_chip *lpc32xx; int ret; u32 val; - lpc32xx = devm_kzalloc(&pdev->dev, sizeof(*lpc32xx), GFP_KERNEL); - if (!lpc32xx) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*lpc32xx)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + lpc32xx = to_lpc32xx_pwm_chip(chip); lpc32xx->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(lpc32xx->base)) @@ -135,16 +138,14 @@ static int lpc32xx_pwm_probe(struct platform_device *pdev) if (IS_ERR(lpc32xx->clk)) return PTR_ERR(lpc32xx->clk); - lpc32xx->chip.dev = &pdev->dev; - lpc32xx->chip.ops = &lpc32xx_pwm_ops; - lpc32xx->chip.npwm = 1; + chip->ops = &lpc32xx_pwm_ops; /* If PWM is disabled, configure the output to the default value */ val = readl(lpc32xx->base); val &= ~PWM_PIN_LEVEL; writel(val, lpc32xx->base); - ret = devm_pwmchip_add(&pdev->dev, &lpc32xx->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) { dev_err(&pdev->dev, "failed to add PWM chip, error %d\n", ret); return ret; From patchwork Wed Feb 14 09:31:55 2024 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: 13556175 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8DDE6C48BC4 for ; Wed, 14 Feb 2024 09:39:28 +0000 (UTC) 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=UYulsZlI57wGF66w7lHJnrXBpoRsUwN4fxOV3gSxSlY=; b=ZUKLeciVGbpmch 03KTNt6PHDjZqkPuGS5j40lvEZ2HrnAW0irv+9t+UIu/dqCJH/O0hSGBcJct4/iWH7ovdDwCrTFE+ sam4pEdHzTs5FISknxGJdvs2ey3Ze00fQp68QbOhiGpy8y4mbFVx+P0+qCVhfu3SQ0kQsnIyGe4hK jB0ZSmKSliqjOGE/Plt1+Sy3lIlYVlkBQpcYTZ+FLDaDJJG7Ycq4jT1QVSfKgrTh2nSF/z1TJKZUO 5dhYhlDYVYT0zYz8D8ML4FsjlyhF8H5eOo6zBPdeFHsGZYtbbyDlbYfXHbAt2mY+cxmik6RQPY3qB DD98Boap9m/r1mYvTAAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBjV-0000000CNWw-0GCl; Wed, 14 Feb 2024 09:39:13 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfO-0000000CKiu-1BLl for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:34:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=BcKeOMFeRyLt0DNwQC4iOgRvHayp0Kf3VhyAm9cl0A8=; b=YqpJETtwcyxEFy//+RqTGgZvYs 8hfeG2RnheopE8bzrq1qcAYCrlzTAKMVm8eBoEq+J7EbVBWQXvjrUBitjsFZEZ8WehUviloytlS8/ MYQiQ647fIRtUBmWKGithheG8h8cWRv0NuJIZia8YkYpTdVehHiD4aUiaAzH2OZW89vPkGnhp1Wcp RF5ihyXzGcSqy3pjSBEreaQmnAtI3h5KIWZsMTn3DkJvHhGD983eGLnsZ2lVybigXt9WxUr54fyMZ xC5jO66XbBiOw3msyDOjUFrVryUivVHKon2hyYXKzLvcjUqDMKrSbCMt1Kqf3c75Hh53ubUXwg3iF fHC7w5Ow==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfE-0000000GAXK-2PnI for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:56 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBex-00052s-I7; Wed, 14 Feb 2024 10:34:31 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBeu-000fCx-Er; Wed, 14 Feb 2024 10:34:28 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBeu-004Y4N-1C; Wed, 14 Feb 2024 10:34:28 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Matthias Brugger , AngeloGioacchino Del Regno , linux-pwm@vger.kernel.org Cc: kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH v6 068/164] pwm: mediatek: Make use of pwmchip_parent() accessor Date: Wed, 14 Feb 2024 10:31:55 +0100 Message-ID: <819996ee175bec0ab71acc385c78e7233617e136.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=891; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=n8WkmK8zXwx0gmZde1hbERzcObCWJ/WjRRDw6pi2QYM=; b=owGbwMvMwMXY3/A7olbonx/jabUkhtQzHTNqnCdu5w6NzOSoYjL7v00q3Pd7/NxNi/zrWKxDV laFysV2MhqzMDByMciKKbLYN67JtKqSi+xc++8yzCBWJpApDFycAjCRV0Hs/xPiQ72OXtl0mivD +1RIt0HttdWHC8XEjvzSPPJw0UTHk87cnSk3YmPW7642fL44ps725xw/gZZNHVk/HqpNqRWPNGG ssXW+19+7jK9m8WqtqGuHtkiv4pm0LJGlIrrN76HpQX29SW4iX9Qdoh//V6vcle7zw8/hepHq09 TnghF7f/wMNXs/50b+KpW37Q9zY3W3d0w1czSW4fS/uEctdVvoLuFItU8TL/M112yWzvTY75Zl6 fv11Tkl86U1fn/icx9VFSzcKanbLNi8Rcq9c4bv1BP8Px2k/QIvNxg/m3ur3/+IIWvpD/GSjIcu xn9XNRfkb3qpWLC3+yGXxQyFC+lui28ER/m/u/P+rN4jAA== X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093448_940559_EC18F808 X-CRM114-Status: GOOD ( 13.19 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org struct pwm_chip::dev is about to change. To not have to touch this driver in the same commit as struct pwm_chip::dev, use the accessor function provided for exactly this purpose. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-mediatek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c index 562102a47ac0..6cf7543a3826 100644 --- a/drivers/pwm/pwm-mediatek.c +++ b/drivers/pwm/pwm-mediatek.c @@ -149,7 +149,7 @@ static int pwm_mediatek_config(struct pwm_chip *chip, struct pwm_device *pwm, if (clkdiv > PWM_CLK_DIV_MAX) { pwm_mediatek_clk_disable(chip, pwm); - dev_err(chip->dev, "period of %d ns not supported\n", period_ns); + dev_err(pwmchip_parent(chip), "period of %d ns not supported\n", period_ns); return -EINVAL; } From patchwork Wed Feb 14 09:31:56 2024 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: 13556160 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6E96BC48BC4 for ; Wed, 14 Feb 2024 09:36:40 +0000 (UTC) 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=bpnEtFSUDjjrsc1o/ikuAS/+BV3vE3PxjoxsXv+KKIo=; b=umgVktkSOxJjsK GGHEbMORe3I1Mmc6uWuSqhVWvGofI88P3LdnCwee0SQO8kHKXm5S7vfrDJjm+myE3p3xesdYsrfmK fovttddLk4RYRlK6p/uvRfsIidgKzT1ygzT5nB5egyHsv6VMPa/XbIZVxroV2JR6INypIA6Y/w3Un ik11JhmZhV9XAj/LTbE3LQqX8HHx9L1R3/KzQmKvatrw2uAIk7TOMm1XNQCZBRnliBMAGtSyWv7w/ TpvD0OgBbnLuUfLUeGaUNr9a92WQDryd9iOY+l7zx6RcULyBYEqVNewCvBx3Lb2RSoxfFPF+lSKK+ X1CfmvzXFOoKedLWoVNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBgm-0000000CLvg-3iym; Wed, 14 Feb 2024 09:36:24 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBf4-0000000CKLw-1UFq for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:42 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBex-000544-Ot; Wed, 14 Feb 2024 10:34:31 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBeu-000fD0-KV; Wed, 14 Feb 2024 10:34:28 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBeu-004Y4R-1k; Wed, 14 Feb 2024 10:34:28 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Matthias Brugger , AngeloGioacchino Del Regno , linux-pwm@vger.kernel.org Cc: kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH v6 069/164] pwm: mediatek: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:31:56 +0100 Message-ID: <513b2037c00ebf2f3a69472f4b99adaf4fb40d83.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3214; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=efjqoTt2JNTkS/blkL8nCUoyaB7R1fYI93LJBT5sUFk=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIiaeLfnYLOw4DotMB2SXw03iCB2wYUsxsOpk cYDh43ACSaJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyImgAKCRCPgPtYfRL+ TnthB/91VfbI7Gnxixao020csS6NwOC2xRsfijHkmra/QOHIKisTw/QsU5yq7ml5F8jBoFb+C1q Gf5s2PPhlexsn8Q3fGs2LISIaseVvU+CfkuZejsVr9oU69DO/bwOPeQM1bvcywQ17fipCSgNEjb 4gfHujipg9I+syZdnxCK9UdvjHQYfUY9rB3SHSBDzWqUfFlnKVu4ZjxKGPZDSAbmTzOlnnc6UUz QOMw3xM1eW2oghJKfENs4NGOuQkGiuu1PZcL3Z9ZDq8X8UO78fFgC/z8GJnzfHYmrubaJ6M17x8 2kjZhLTumvzbtPrCaU/JDtglaKs86O3M6wL7z1dkF4NXD9/v X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013438_591505_4385E87E X-CRM114-Status: GOOD ( 19.44 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-mediatek driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-mediatek.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c index 6cf7543a3826..c5fca0f1ebc7 100644 --- a/drivers/pwm/pwm-mediatek.c +++ b/drivers/pwm/pwm-mediatek.c @@ -42,7 +42,6 @@ struct pwm_mediatek_of_data { /** * struct pwm_mediatek_chip - struct representing PWM chip - * @chip: linux PWM chip representation * @regs: base address of PWM chip * @clk_top: the top clock generator * @clk_main: the clock used by PWM core @@ -50,7 +49,6 @@ struct pwm_mediatek_of_data { * @soc: pointer to chip's platform data */ struct pwm_mediatek_chip { - struct pwm_chip chip; void __iomem *regs; struct clk *clk_top; struct clk *clk_main; @@ -69,7 +67,7 @@ static const unsigned int mtk_pwm_reg_offset_v2[] = { static inline struct pwm_mediatek_chip * to_pwm_mediatek_chip(struct pwm_chip *chip) { - return container_of(chip, struct pwm_mediatek_chip, chip); + return pwmchip_get_drvdata(chip); } static int pwm_mediatek_clk_enable(struct pwm_chip *chip, @@ -232,21 +230,26 @@ static const struct pwm_ops pwm_mediatek_ops = { static int pwm_mediatek_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct pwm_mediatek_chip *pc; + const struct pwm_mediatek_of_data *soc; unsigned int i; int ret; - pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); - if (!pc) - return -ENOMEM; + soc = of_device_get_match_data(&pdev->dev); - pc->soc = of_device_get_match_data(&pdev->dev); + chip = devm_pwmchip_alloc(&pdev->dev, soc->num_pwms, sizeof(*pc)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + pc = to_pwm_mediatek_chip(chip); + + pc->soc = soc; pc->regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(pc->regs)) return PTR_ERR(pc->regs); - pc->clk_pwms = devm_kmalloc_array(&pdev->dev, pc->soc->num_pwms, + pc->clk_pwms = devm_kmalloc_array(&pdev->dev, soc->num_pwms, sizeof(*pc->clk_pwms), GFP_KERNEL); if (!pc->clk_pwms) return -ENOMEM; @@ -261,7 +264,7 @@ static int pwm_mediatek_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk_main), "Failed to get main clock\n"); - for (i = 0; i < pc->soc->num_pwms; i++) { + for (i = 0; i < soc->num_pwms; i++) { char name[8]; snprintf(name, sizeof(name), "pwm%d", i + 1); @@ -272,11 +275,9 @@ static int pwm_mediatek_probe(struct platform_device *pdev) "Failed to get %s clock\n", name); } - pc->chip.dev = &pdev->dev; - pc->chip.ops = &pwm_mediatek_ops; - pc->chip.npwm = pc->soc->num_pwms; + chip->ops = &pwm_mediatek_ops; - ret = devm_pwmchip_add(&pdev->dev, &pc->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) return dev_err_probe(&pdev->dev, ret, "pwmchip_add() failed\n"); From patchwork Wed Feb 14 09:31:57 2024 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: 13556159 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 03998C48BC4 for ; Wed, 14 Feb 2024 09:36:38 +0000 (UTC) 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=DrFiNYwNwtYEeviEGGjELEnekeZW3O9glgv0C83gK7c=; b=rlhJckqHtlApS4 wBeG3R2pBLCRR2n9UlmTv/jaeH+Q/UmirQCYqxGB7SIG2oFK/gHN6djNiNHDxHYXWY9BqzPHKcFBH OFLeLd57tcKXhQgdCUaRruFtwUqg5kAZrSCgvq+NQVoh3+O36CkNJYImRPSETSzBVjug53lZPCBau Nd1UpUI80A1viQp4DiUSuZHG2zuySWG/2gzsW2dArZRR14wnZEQO+1CCDr2E7k0bPZMNOGZd0Ntsa P25E9pWrCNEf/wTFUl5PHOXPkvk/aQgA2oL+pH7KfOhzd4Rnnd0Vi+W23uJVsG7BKyHowRFICj3Js Skvt8XOWpeW0ZcZL78JQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBgh-0000000CLrL-3oJF; Wed, 14 Feb 2024 09:36:19 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBf3-0000000CKLG-3eQu for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:41 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBew-00055O-EF; Wed, 14 Feb 2024 10:34:30 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBeu-000fD6-Pq; Wed, 14 Feb 2024 10:34:28 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBeu-004Y4V-2J; Wed, 14 Feb 2024 10:34:28 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Neil Armstrong , Kevin Hilman , linux-pwm@vger.kernel.org Cc: Jerome Brunet , Martin Blumenstingl , linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 070/164] pwm: meson: Change prototype of a few helpers to prepare further changes Date: Wed, 14 Feb 2024 10:31:57 +0100 Message-ID: <157084e1dd464da0097edba880240868c1c0b27e.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5267; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=nznIKwEERklBb4k0h0BWwYopUbH9um6rOZd4hcpdvBU=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIibWWdmu8Q5kvUUWYhyG+ileLxF6l3vdzMDq u/Wqi6F21GJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyImwAKCRCPgPtYfRL+ TinEB/4xcfRCnc2talpzXOwvLODJTjeujAtEQebuBJzt55qg4FEDblt4tc7gPlSJNJeC3Ym2m7N 8WzwcVRazbk/Jwgn0IxYnKxegjWXQ6FP5wYfT98HJwDf3Gn6F0yX42PQyyES3/yazzWh0/UVP9j qBU9GvzFA9a8HlHj5Dqb7lE8itCsu+4ixOIciZ+PHUJB0GTj0kxuyfM9da0Ygdhk8o6S7JBmjVQ xMhf4yE0LYPC8SbHrNrZAhvkn8YqaszeH5rKCc+mwQMUJbYxLKAmEaxpj2S/XdwTfqH6VJHmoWA ItWZ4qlj0cPhUIR78wDVgjvJ0aGhTzicZm51GoxVap4TP1N2 X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013438_174494_180F3FFB X-CRM114-Status: GOOD ( 18.85 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the driver for further changes that will make it harder to determine the pwm_chip from a given meson_pwm. To just not have to do that, rework meson_pwm_calc(), meson_pwm_enable(), meson_pwm_disable() and meson_pwm_init_channels() to take a pwm_chip. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-meson.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c index 2971bbf3b5e7..7ce41811537d 100644 --- a/drivers/pwm/pwm-meson.c +++ b/drivers/pwm/pwm-meson.c @@ -143,9 +143,10 @@ static void meson_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) clk_disable_unprepare(channel->clk); } -static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm, +static int meson_pwm_calc(struct pwm_chip *chip, struct pwm_device *pwm, const struct pwm_state *state) { + struct meson_pwm *meson = to_meson_pwm(chip); struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm]; unsigned int cnt, duty_cnt; unsigned long fin_freq; @@ -169,19 +170,19 @@ static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm, fin_freq = clk_round_rate(channel->clk, freq); if (fin_freq == 0) { - dev_err(meson->chip.dev, "invalid source clock frequency\n"); + dev_err(chip->dev, "invalid source clock frequency\n"); return -EINVAL; } - dev_dbg(meson->chip.dev, "fin_freq: %lu Hz\n", fin_freq); + dev_dbg(chip->dev, "fin_freq: %lu Hz\n", fin_freq); cnt = div_u64(fin_freq * period, NSEC_PER_SEC); if (cnt > 0xffff) { - dev_err(meson->chip.dev, "unable to get period cnt\n"); + dev_err(chip->dev, "unable to get period cnt\n"); return -EINVAL; } - dev_dbg(meson->chip.dev, "period=%llu cnt=%u\n", period, cnt); + dev_dbg(chip->dev, "period=%llu cnt=%u\n", period, cnt); if (duty == period) { channel->hi = cnt; @@ -192,7 +193,7 @@ static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm, } else { duty_cnt = div_u64(fin_freq * duty, NSEC_PER_SEC); - dev_dbg(meson->chip.dev, "duty=%llu duty_cnt=%u\n", duty, duty_cnt); + dev_dbg(chip->dev, "duty=%llu duty_cnt=%u\n", duty, duty_cnt); channel->hi = duty_cnt; channel->lo = cnt - duty_cnt; @@ -203,8 +204,9 @@ static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm, return 0; } -static void meson_pwm_enable(struct meson_pwm *meson, struct pwm_device *pwm) +static void meson_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) { + struct meson_pwm *meson = to_meson_pwm(chip); struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm]; struct meson_pwm_channel_data *channel_data; unsigned long flags; @@ -215,7 +217,7 @@ static void meson_pwm_enable(struct meson_pwm *meson, struct pwm_device *pwm) err = clk_set_rate(channel->clk, channel->rate); if (err) - dev_err(meson->chip.dev, "setting clock rate failed\n"); + dev_err(chip->dev, "setting clock rate failed\n"); spin_lock_irqsave(&meson->lock, flags); @@ -230,8 +232,9 @@ static void meson_pwm_enable(struct meson_pwm *meson, struct pwm_device *pwm) spin_unlock_irqrestore(&meson->lock, flags); } -static void meson_pwm_disable(struct meson_pwm *meson, struct pwm_device *pwm) +static void meson_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) { + struct meson_pwm *meson = to_meson_pwm(chip); unsigned long flags; u32 value; @@ -269,16 +272,16 @@ static int meson_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, channel->hi = ~0; channel->lo = 0; - meson_pwm_enable(meson, pwm); + meson_pwm_enable(chip, pwm); } else { - meson_pwm_disable(meson, pwm); + meson_pwm_disable(chip, pwm); } } else { - err = meson_pwm_calc(meson, pwm, state); + err = meson_pwm_calc(chip, pwm, state); if (err < 0) return err; - meson_pwm_enable(meson, pwm); + meson_pwm_enable(chip, pwm); } return 0; @@ -432,10 +435,11 @@ static const struct of_device_id meson_pwm_matches[] = { }; MODULE_DEVICE_TABLE(of, meson_pwm_matches); -static int meson_pwm_init_channels(struct meson_pwm *meson) +static int meson_pwm_init_channels(struct pwm_chip *chip) { + struct meson_pwm *meson = to_meson_pwm(chip); struct clk_parent_data mux_parent_data[MESON_MAX_MUX_PARENTS] = {}; - struct device *dev = meson->chip.dev; + struct device *dev = chip->dev; unsigned int i; char name[255]; int err; @@ -445,7 +449,7 @@ static int meson_pwm_init_channels(struct meson_pwm *meson) mux_parent_data[i].name = meson->data->parent_names[i]; } - for (i = 0; i < meson->chip.npwm; i++) { + for (i = 0; i < chip->npwm; i++) { struct meson_pwm_channel *channel = &meson->channels[i]; struct clk_parent_data div_parent = {}, gate_parent = {}; struct clk_init_data init = {}; @@ -543,7 +547,7 @@ static int meson_pwm_probe(struct platform_device *pdev) meson->data = of_device_get_match_data(&pdev->dev); - err = meson_pwm_init_channels(meson); + err = meson_pwm_init_channels(&meson->chip); if (err < 0) return err; From patchwork Wed Feb 14 09:31:58 2024 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: 13556157 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id BC085C48BEB for ; Wed, 14 Feb 2024 09:36:31 +0000 (UTC) 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=99H+Q6yjQptLqm3hcGYBec+k6/SvjN0n24PiPocBtvk=; b=QM69IFpZhiesJI 0gxf2OkQ/W9LEjg4dDFm6kVH5Ue47yM58xjCKBuIQ80zVblO/2ZUydA2qmgXsdKhzXLh80/ApChfB 2UbDo9pR/hntchrzOXKG1teyHkdBQqu9cxZlyTXdxyG4fy3aWIg9dcQMLZwirTsfDo/F43Q3CRHAK OYly9xpMJFqZArqvtrcrTBB7li75/vHaQTDZ2IiSJM2NEWO29xinGGFpymsUt88GJP1sworFExnCz mVeG5kTBSxU5O13XEw6XmdtZpHvQU2uin3vIZBblyigAP1JAIueQlF2hJajPqf8aSrBjg64IJoVlH heEFpqIqsUkrqg7Elsjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBgf-0000000CLoU-0NE2; Wed, 14 Feb 2024 09:36:17 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBf3-0000000CKLF-3Aa8 for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:40 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBew-00056v-Pb; Wed, 14 Feb 2024 10:34:30 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBeu-000fDA-V0; Wed, 14 Feb 2024 10:34:28 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBeu-004Y4Z-2p; Wed, 14 Feb 2024 10:34:28 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Neil Armstrong , Kevin Hilman , linux-pwm@vger.kernel.org Cc: Jerome Brunet , Martin Blumenstingl , linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 071/164] pwm: meson: Make use of pwmchip_parent() accessor Date: Wed, 14 Feb 2024 10:31:58 +0100 Message-ID: <02d5f32001c4d0817fa79f5831cfd16b7e345f00.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2795; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=lGUecNCwBfcrdR1yv/aBSypKpDhhdu1IeSjEpVahTX8=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIicu0Qm2x0kESKafacDQMOK2tGhj6by91QPQ 8xM4An/CGiJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyInAAKCRCPgPtYfRL+ TtQaCACrgQRjkPmjo63SZIBLq/BColLa6bOlmKXmO3Lu+7q7KYKjyFJ23MJYIwb0GFMM0tTThqx lKmYG3szeg8npTWTEkLza2H8WSoRxztqcaa06BjuN4EzK4IZ39BvSIzTsMkjshGEyJpQL5JV1Lr ENynJWyjfdzNZR4HU1gxESxp77P5g1dmZU5cKA9nX1l80ZkzuweNlfpYcIRCKIOLYsh+8phmrfM +wWe33LvwP1mDIBbq6InqTfCfuZVRzXwT/fum4MnFpy21ikeki2Vl9GRfIOEcxHWLSxRE29G2qj Hpet/6aqXEfxAEKKulkzRBk5QNMgGtcCu/I4c7Lxdmmo5Y7j X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013438_057916_2831ED8E X-CRM114-Status: GOOD ( 14.81 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org struct pwm_chip::dev is about to change. To not have to touch this driver in the same commit as struct pwm_chip::dev, use the accessor function provided for exactly this purpose. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-meson.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c index 7ce41811537d..8f67d6ba443d 100644 --- a/drivers/pwm/pwm-meson.c +++ b/drivers/pwm/pwm-meson.c @@ -122,7 +122,7 @@ static int meson_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) { struct meson_pwm *meson = to_meson_pwm(chip); struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm]; - struct device *dev = chip->dev; + struct device *dev = pwmchip_parent(chip); int err; err = clk_prepare_enable(channel->clk); @@ -170,19 +170,19 @@ static int meson_pwm_calc(struct pwm_chip *chip, struct pwm_device *pwm, fin_freq = clk_round_rate(channel->clk, freq); if (fin_freq == 0) { - dev_err(chip->dev, "invalid source clock frequency\n"); + dev_err(pwmchip_parent(chip), "invalid source clock frequency\n"); return -EINVAL; } - dev_dbg(chip->dev, "fin_freq: %lu Hz\n", fin_freq); + dev_dbg(pwmchip_parent(chip), "fin_freq: %lu Hz\n", fin_freq); cnt = div_u64(fin_freq * period, NSEC_PER_SEC); if (cnt > 0xffff) { - dev_err(chip->dev, "unable to get period cnt\n"); + dev_err(pwmchip_parent(chip), "unable to get period cnt\n"); return -EINVAL; } - dev_dbg(chip->dev, "period=%llu cnt=%u\n", period, cnt); + dev_dbg(pwmchip_parent(chip), "period=%llu cnt=%u\n", period, cnt); if (duty == period) { channel->hi = cnt; @@ -193,7 +193,7 @@ static int meson_pwm_calc(struct pwm_chip *chip, struct pwm_device *pwm, } else { duty_cnt = div_u64(fin_freq * duty, NSEC_PER_SEC); - dev_dbg(chip->dev, "duty=%llu duty_cnt=%u\n", duty, duty_cnt); + dev_dbg(pwmchip_parent(chip), "duty=%llu duty_cnt=%u\n", duty, duty_cnt); channel->hi = duty_cnt; channel->lo = cnt - duty_cnt; @@ -217,7 +217,7 @@ static void meson_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) err = clk_set_rate(channel->clk, channel->rate); if (err) - dev_err(chip->dev, "setting clock rate failed\n"); + dev_err(pwmchip_parent(chip), "setting clock rate failed\n"); spin_lock_irqsave(&meson->lock, flags); @@ -439,7 +439,7 @@ static int meson_pwm_init_channels(struct pwm_chip *chip) { struct meson_pwm *meson = to_meson_pwm(chip); struct clk_parent_data mux_parent_data[MESON_MAX_MUX_PARENTS] = {}; - struct device *dev = chip->dev; + struct device *dev = pwmchip_parent(chip); unsigned int i; char name[255]; int err; From patchwork Wed Feb 14 09:31:59 2024 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: 13556162 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 86E41C48BC4 for ; Wed, 14 Feb 2024 09:36:58 +0000 (UTC) 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=BAxrhc0BfcmcfbFp3c4mOcE3Z+nvTru6AWwmEvm5zkE=; b=iUzmhMD/6fFnAG 3hooa8mQBefYCVxO1X5c7QVAeYala7ijHPbJcgmpZflOgUqr0IEWfVpw6ixJnajiUIAyo3w0+SPrS TLcInb10pMDbN1OePopOR78px23ajjsLBQcIucuve10Rjb48jrXYcGIoioxBEYSQ3o8KBSV3aW4A8 IRBZqE3m1hDY3S3vrGONiIIRZxmzW+1TECprJqmIxeyqTozxV8N8t/tXIS6vlMyXATqqATKej63gX EzqZNY9V+MYFB6mmw89cdza64ij6foVNPE5rX0zKPlhZ/QHLb6mew54Af3kOIsmnLWwMJPt8zLKAx yvMNuqu8uOuW+3l/+uyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBh6-0000000CMEr-2MWu; Wed, 14 Feb 2024 09:36:44 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBf5-0000000CKNi-2s9J for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:44 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBey-000581-Ds; Wed, 14 Feb 2024 10:34:32 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBev-000fDD-3s; Wed, 14 Feb 2024 10:34:29 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBev-004Y4d-07; Wed, 14 Feb 2024 10:34:29 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Neil Armstrong , Kevin Hilman , linux-pwm@vger.kernel.org Cc: Jerome Brunet , Martin Blumenstingl , linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 072/164] pwm: meson: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:31:59 +0100 Message-ID: <6cc57880e910e6ffd8df15bc4a41c42fe9523293.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2224; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=kX6EFouZB5MYYiTP4tBFnKgAGjASoigtowFicYD6b3E=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIidWfVfn7Dw31SNgaFp2QH7liUSRq2yticDS k3FNJPT/eCJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyInQAKCRCPgPtYfRL+ TjH1B/9AxarRd3srRCG4XrdO83IxtL0DmP5pCLuH6j5u/UYe7Kk+l/xY/+94TOtwPBYp1BTVmJI b6EzX4/KHExsWdsEzep5p8Jt5jyMcM6h4AbZN3kpYWXSdyfy9As0Im1B8t16p6iQEsYvb6CfAfR j3YKtbEnOMGLoUP8qPyIjd7SPTbTyNjf1Jo/yM43unho5vWK4C8Fmzm8NKbYgJcgBmoCYBphUMz t71ruog4QHRUlskKN6z24IDsiIJZp6I07JFTaTdmQe7XYxX/R/Ehn85k7cdijUmlvTs3YQZ60Ma 1IgMCwWM4ojT4nxudd55eWUf1X8Oc9u29UiMWvPxRZOvSSLj X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013439_926905_97B34A29 X-CRM114-Status: GOOD ( 14.16 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-meson driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-meson.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c index 8f67d6ba443d..40a5b64c26f5 100644 --- a/drivers/pwm/pwm-meson.c +++ b/drivers/pwm/pwm-meson.c @@ -102,7 +102,6 @@ struct meson_pwm_data { }; struct meson_pwm { - struct pwm_chip chip; const struct meson_pwm_data *data; struct meson_pwm_channel channels[MESON_NUM_PWMS]; void __iomem *base; @@ -115,7 +114,7 @@ struct meson_pwm { static inline struct meson_pwm *to_meson_pwm(struct pwm_chip *chip) { - return container_of(chip, struct meson_pwm, chip); + return pwmchip_get_drvdata(chip); } static int meson_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) @@ -529,29 +528,29 @@ static int meson_pwm_init_channels(struct pwm_chip *chip) static int meson_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct meson_pwm *meson; int err; - meson = devm_kzalloc(&pdev->dev, sizeof(*meson), GFP_KERNEL); - if (!meson) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, MESON_NUM_PWMS, sizeof(*meson)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + meson = to_meson_pwm(chip); meson->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(meson->base)) return PTR_ERR(meson->base); spin_lock_init(&meson->lock); - meson->chip.dev = &pdev->dev; - meson->chip.ops = &meson_pwm_ops; - meson->chip.npwm = MESON_NUM_PWMS; + chip->ops = &meson_pwm_ops; meson->data = of_device_get_match_data(&pdev->dev); - err = meson_pwm_init_channels(&meson->chip); + err = meson_pwm_init_channels(chip); if (err < 0) return err; - err = devm_pwmchip_add(&pdev->dev, &meson->chip); + err = devm_pwmchip_add(&pdev->dev, chip); if (err < 0) return dev_err_probe(&pdev->dev, err, "failed to register PWM chip\n"); From patchwork Wed Feb 14 09:32:01 2024 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: 13556164 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9D994C48BED for ; Wed, 14 Feb 2024 09:37:08 +0000 (UTC) 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=DvtiHZEwtlP3/AxXGVc32NuJSWT6wLNWgzvt9CJO2pk=; b=U8qelFWYeDPt0S z/BMD6fIubRa1w1S4vWjIm+/kcbpsKvHkcsrUrQWtK8QXUrm4OA1jBdC3COuNBFh2gV0m3zP0V7cT HxNaJyQ31jg21YsnX4oFFzuixZ5MrK4loq+MGOHs6eTuPcRiG7S1z6To6NRtB4dIv1FRaU0qi1QUT q5WEr4pKjaz+dZH+Hr9eVX2aIupq2O0cjzuq2ztgIBfVcaoKgf3N+J/R7OGWvWNtDR/kMLCz9xZzl BLHpBUSZ09JLoB0lGdWbWelxKnZN9XMXB4/cDxkblQP8vE7wGPMDVgEjuS5SfUbIuxF/RuAh7vMHI LGp80P/423EyHl5YlA/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBhF-0000000CMN5-2QwL; Wed, 14 Feb 2024 09:36:53 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBf5-0000000CKNh-2qT8 for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:46 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBey-00059n-Jr; Wed, 14 Feb 2024 10:34:32 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBev-000fDL-DC; Wed, 14 Feb 2024 10:34:29 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBev-004Y4l-14; Wed, 14 Feb 2024 10:34:29 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Matthias Brugger , AngeloGioacchino Del Regno , linux-pwm@vger.kernel.org Cc: kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH v6 074/164] pwm: mtk-disp: Make use of pwmchip_parent() accessor Date: Wed, 14 Feb 2024 10:32:01 +0100 Message-ID: <93ba7ef22f8d26f17e64326249d5da54ab8014ea.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1790; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=HAz7THBaqE1zk9nd2+emun7+lN7VcaMz4+VVJrgwc3M=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIif0wO7RFm/4/BsEVKEHGZ573THDXi+L/vlk Kj9Odwc3S+JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyInwAKCRCPgPtYfRL+ Tmj/B/9Qj8v7A2vPAcgJSB+sK+gj+ELCffwiTM40ITMm/GUjgSRb+fhnLZLulIEs8jCB6xW6jO7 wq97LDk0pK6j0pX6QkFRotwJYQc73WaisDTO0v5BOCVGd0RZxF2rKoVnNh1dMHrvdsq1LOEn6SV zsLrDHGeiHh90fbHGZSAcDRCuj0RWY+Zg6pl0moF2dvaHGpfp6t++1nWNzkdXZsHN5twlq4MzH7 HZAodjYUK0BoQL9nDYwMqE1DU351NtKD5ZpMx/P0yZjOup3LaBqpu+ONzGWdXGUDaEzOFxXL9Er UthAF4IfDBNlVaf13fQcHvAJPP11MpJ6A7Gt6s6BFA3y5dwt X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013440_087234_F778E4C3 X-CRM114-Status: GOOD ( 12.81 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org struct pwm_chip::dev is about to change. To not have to touch this driver in the same commit as struct pwm_chip::dev, use the accessor function provided for exactly this purpose. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-mtk-disp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pwm/pwm-mtk-disp.c b/drivers/pwm/pwm-mtk-disp.c index a72f7be36996..186aa5c04435 100644 --- a/drivers/pwm/pwm-mtk-disp.c +++ b/drivers/pwm/pwm-mtk-disp.c @@ -91,14 +91,14 @@ static int mtk_disp_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, if (!mdp->enabled) { err = clk_prepare_enable(mdp->clk_main); if (err < 0) { - dev_err(chip->dev, "Can't enable mdp->clk_main: %pe\n", + dev_err(pwmchip_parent(chip), "Can't enable mdp->clk_main: %pe\n", ERR_PTR(err)); return err; } err = clk_prepare_enable(mdp->clk_mm); if (err < 0) { - dev_err(chip->dev, "Can't enable mdp->clk_mm: %pe\n", + dev_err(pwmchip_parent(chip), "Can't enable mdp->clk_mm: %pe\n", ERR_PTR(err)); clk_disable_unprepare(mdp->clk_main); return err; @@ -181,13 +181,13 @@ static int mtk_disp_pwm_get_state(struct pwm_chip *chip, err = clk_prepare_enable(mdp->clk_main); if (err < 0) { - dev_err(chip->dev, "Can't enable mdp->clk_main: %pe\n", ERR_PTR(err)); + dev_err(pwmchip_parent(chip), "Can't enable mdp->clk_main: %pe\n", ERR_PTR(err)); return err; } err = clk_prepare_enable(mdp->clk_mm); if (err < 0) { - dev_err(chip->dev, "Can't enable mdp->clk_mm: %pe\n", ERR_PTR(err)); + dev_err(pwmchip_parent(chip), "Can't enable mdp->clk_mm: %pe\n", ERR_PTR(err)); clk_disable_unprepare(mdp->clk_main); return err; } From patchwork Wed Feb 14 09:32:02 2024 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: 13556158 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E248DC48BC4 for ; Wed, 14 Feb 2024 09:36:31 +0000 (UTC) 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=coTEkGBG3RiVvRXZOif1i1Vj2WN0VhIw0Ccodjf4z2s=; b=EpSJ15Cl3PwXjV y8keBlvlbiPDU0Yx8JBQpy3kyeJaaMScc5xcMJbZczTD+xvYdbG1FooI553xu1RD4WmurivY4Xao1 PYyPyqjrr9x+vXiV6EJx6wAoZpkGoeyMXha4ggFr/Ptx8HM4mAsK5cd6qWGn/DbOAS5TwI+iiR63V 8JWkHbqI3oCx/lPtjoDllm/YZFQHjHczhn7v+x8AaAafZMtO1Ced1xO90UFmEGfA7zKVJTTySzhYw 8KJMFBikxZeXYPk/S0nwK0mHmMOpwPxUoNB8vuyaWieqxUOTnudzKTc3eNAMceVlJ82fqkUqRTSsQ O9+tJVg1COEwCoxLukFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBgb-0000000CLki-1zFo; Wed, 14 Feb 2024 09:36:13 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBf3-0000000CKKY-2E5o for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:40 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBex-0005Ag-K0; Wed, 14 Feb 2024 10:34:31 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBev-000fDP-IF; Wed, 14 Feb 2024 10:34:29 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBev-004Y4p-1Z; Wed, 14 Feb 2024 10:34:29 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Matthias Brugger , AngeloGioacchino Del Regno , linux-pwm@vger.kernel.org Cc: kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH v6 075/164] pwm: mtk-disp: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:32:02 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2148; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=MbksikhrFe2+cIq8JkZ1a1wrryjv2J/w24px7Bciwsw=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIihfEUe+P2Au0+Ds1rdA4i5NuI4cs8yEyfaR 9/IXXjJLX6JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIoQAKCRCPgPtYfRL+ TgFhB/9RyFBE3JtdEgMwThz2E8luf65p0NdjcC/slHQC/wiczIzYIKItruhFvdHwrGPDwbyzYSa MCK7YoK6vi3C6+bkncYD0gebq+0b4z7Oc36ZmM0oFK1YCeFX/m1mhzFELLRqAB6fatAtXypkQde hsE6PHuPbU0wDnREupWjm6zh8APN0wzxw0cwsIZjbStQGOFLBZlgxVrqpODYZT/Fh34ZN2qaKfj EuxshcqckGZZMozEk7XuKIsQeJJWfEynd3lTnSw2FXBZgLVJBNU0CV/TRPg1Lu0zfe8vcKW3JEN w8LP/r48bgsH99MbUPH1KekHjZhnfOH8FGIoLE341UfNv8WV X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013437_909410_4984C99A X-CRM114-Status: GOOD ( 16.10 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-mtk-disp driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-mtk-disp.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-mtk-disp.c b/drivers/pwm/pwm-mtk-disp.c index 186aa5c04435..bafd6b6195f6 100644 --- a/drivers/pwm/pwm-mtk-disp.c +++ b/drivers/pwm/pwm-mtk-disp.c @@ -42,7 +42,6 @@ struct mtk_pwm_data { }; struct mtk_disp_pwm { - struct pwm_chip chip; const struct mtk_pwm_data *data; struct clk *clk_main; struct clk *clk_mm; @@ -52,7 +51,7 @@ struct mtk_disp_pwm { static inline struct mtk_disp_pwm *to_mtk_disp_pwm(struct pwm_chip *chip) { - return container_of(chip, struct mtk_disp_pwm, chip); + return pwmchip_get_drvdata(chip); } static void mtk_disp_pwm_update_bits(struct mtk_disp_pwm *mdp, u32 offset, @@ -231,12 +230,14 @@ static const struct pwm_ops mtk_disp_pwm_ops = { static int mtk_disp_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct mtk_disp_pwm *mdp; int ret; - mdp = devm_kzalloc(&pdev->dev, sizeof(*mdp), GFP_KERNEL); - if (!mdp) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*mdp)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + mdp = to_mtk_disp_pwm(chip); mdp->data = of_device_get_match_data(&pdev->dev); @@ -254,11 +255,9 @@ static int mtk_disp_pwm_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(mdp->clk_mm), "Failed to get mm clock\n"); - mdp->chip.dev = &pdev->dev; - mdp->chip.ops = &mtk_disp_pwm_ops; - mdp->chip.npwm = 1; + chip->ops = &mtk_disp_pwm_ops; - ret = devm_pwmchip_add(&pdev->dev, &mdp->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) return dev_err_probe(&pdev->dev, ret, "pwmchip_add() failed\n"); From patchwork Wed Feb 14 09:32:03 2024 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: 13556208 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 63AE3C48BEB for ; Wed, 14 Feb 2024 09:41:46 +0000 (UTC) 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=E5DwCA2F1ajNwbamzHudfue6jWy9/YZl6Uoxfmm8WWI=; b=lkOV+Z2dY4hvRY 3xH+9X3G3g7HhYhDi9cI9op9ldDehytOqxrwfmFsVIZ+yauiDUMpM5P8QYAVm9ZTns3B8a4jlvgRq ILqiIKx5bARVPjc2L08YmOsNH9NNhU6eLzAnAlaspWpSCf3auKVS7wefVbtCT4xOcJ7PJg7L7r+hx XAxHXRblGC15UnxowDIbXT1OMGw3B2zUcRuRQwikr77D2yEeTmkbOTrLH5AwAAIQSn4FLNG1SdERO oSynLnUuF2n7JIlc1HLQxzI5DbJrVKqP1D/1S0Ds9aWPZRUM59FOqR+Qb3F3sU7iUDUB00MZKuwhd jPHEtWIiz2Bp5yk/Qnkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBll-0000000CPRG-49K2; Wed, 14 Feb 2024 09:41:34 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfJ-0000000CKe7-0fKu for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:34:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=uixPPOrgUYEQZA1oMU3R/Fh5vj7TchLmGyW+OZ9eafA=; b=SpEexI+GxKwXdTXjUh5y80ZuE3 3+ZSUTEHb0Q7xnYNVSBw9HsSbsTyCCbcTL5WJ939f9GJCnVC5EloYvwWygC1O3He7ooJ30SjNjdpn 9QHwYycgFvsQT/WI9gMHsrSy33TiIrvoxT3hgg/fZlLM05DICsjsNC3kCNHwMey+f4KkOSLVz05ut AmxElaRai2TXgvg8OO7s+ZkfAvuEsNX89pWv2mJiUp+RHSxwJmJQMPrugmri5QlB7x6eBP+rw/P5w SCmo+k1M0BkOSSw6SmekI76ZLpd2UbgVhiZkctsQGEztbxHG9yT3aqsRZeeVXjttMnU/A30kbtr1J wTcGBxOw==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfD-0000000GAX8-28pD for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:51 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBex-0005BL-OR; Wed, 14 Feb 2024 10:34:31 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBev-000fDT-Nj; Wed, 14 Feb 2024 10:34:29 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBev-004Y4t-26; Wed, 14 Feb 2024 10:34:29 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Shawn Guo , Sascha Hauer , linux-pwm@vger.kernel.org Cc: Fabio Estevam , NXP Linux Team , linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 076/164] pwm: mxs: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:32:03 +0100 Message-ID: <39203f3bfbf4e97654db78bdc7e0c9a2b72c1368.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2683; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=J7Q/ySzr1SnXL3Xb1UpGW2qKuGEU0uAEaDqOHNNsQbA=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIiienos8NlNA5Wn/vmFIeeF8BMW+W6L88TKE 3qMZVd0uxmJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIogAKCRCPgPtYfRL+ Ts4GB/9mAH5SxUERaXpyeeyvLUo9MhJvj2z0zVnOmGuX5KEtIaKdnf8f/F8f60rXPh2aWZh0AeC vJyCpvuEfUlfxQPcS0TKg0m7BR3RfTCkUL++bwc3bLYEfBKTZIyjZKvedBsrtMUT22czjnpsu50 MT0T8Gc4xApTZGZOxHRDc5evC+4LO4sN7oQzk3pna0nCuAAgbQL4toY0gNGOZXbYdNG2eBB9e36 TxstaeBg6h0pOkTrA6kuK5sSoembDzIJV5XaJkzbeDaXUp/PU7giQDpOLxleOdZv+aHwD098zVL uJVjmjWu/0kahulP8zD7VTtQX6SbDmnUbnKrgutvF39ESc8Z X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093447_867447_62277A5F X-CRM114-Status: GOOD ( 17.12 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-mxs driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Also convert the to_mxs_pwm_chip() helper macro to a static inline to get some type safety. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-mxs.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/pwm/pwm-mxs.c b/drivers/pwm/pwm-mxs.c index 1b5e787d78f1..8cad214b1c29 100644 --- a/drivers/pwm/pwm-mxs.c +++ b/drivers/pwm/pwm-mxs.c @@ -37,12 +37,14 @@ static const u8 cdiv_shift[PERIOD_CDIV_MAX] = { }; struct mxs_pwm_chip { - struct pwm_chip chip; struct clk *clk; void __iomem *base; }; -#define to_mxs_pwm_chip(_chip) container_of(_chip, struct mxs_pwm_chip, chip) +static inline struct mxs_pwm_chip *to_mxs_pwm_chip(struct pwm_chip *chip) +{ + return pwmchip_get_drvdata(chip); +} static int mxs_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, const struct pwm_state *state) @@ -120,12 +122,21 @@ static const struct pwm_ops mxs_pwm_ops = { static int mxs_pwm_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; + struct pwm_chip *chip; struct mxs_pwm_chip *mxs; + u32 npwm; int ret; - mxs = devm_kzalloc(&pdev->dev, sizeof(*mxs), GFP_KERNEL); - if (!mxs) - return -ENOMEM; + ret = of_property_read_u32(np, "fsl,pwm-number", &npwm); + if (ret < 0) { + dev_err(&pdev->dev, "failed to get pwm number: %d\n", ret); + return ret; + } + + chip = devm_pwmchip_alloc(&pdev->dev, npwm, sizeof(*mxs)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + mxs = to_mxs_pwm_chip(chip); mxs->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(mxs->base)) @@ -135,21 +146,14 @@ static int mxs_pwm_probe(struct platform_device *pdev) if (IS_ERR(mxs->clk)) return PTR_ERR(mxs->clk); - mxs->chip.dev = &pdev->dev; - mxs->chip.ops = &mxs_pwm_ops; - - ret = of_property_read_u32(np, "fsl,pwm-number", &mxs->chip.npwm); - if (ret < 0) { - dev_err(&pdev->dev, "failed to get pwm number: %d\n", ret); - return ret; - } + chip->ops = &mxs_pwm_ops; /* FIXME: Only do this if the PWM isn't already running */ ret = stmp_reset_block(mxs->base); if (ret) return dev_err_probe(&pdev->dev, ret, "failed to reset PWM\n"); - ret = devm_pwmchip_add(&pdev->dev, &mxs->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) { dev_err(&pdev->dev, "failed to add pwm chip %d\n", ret); return ret; From patchwork Wed Feb 14 09:32:12 2024 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: 13556262 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9F2D8C48BC4 for ; Wed, 14 Feb 2024 10:45:55 +0000 (UTC) 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=d5hQIoi//BxRTIAO7PDGz7RMtJJinBeYioZpAnxCLrk=; b=SV5DWYMv0xpMpP R0b3/M0MJRykt6Pbf/TJDs8/gf+XsIsh52AjB2uugjavP152LNFx0Etx7tjUswO9CMqeBo52GSvi+ 3BbD0vlsBjjplTYbrc8yH8wLNL/7kKwKYZl4+W2OzYZZat2Ex5jPK3yP/JZ9OawFIMdu/CwyUX1F4 jMtOC+WMY7lPOjKNKbR6GZSM36jAkRB8MnFFZJ8GraMxBEqaT7u3UH0yq8nP4FZ7zXuFaozgg/MZY cN63EAqs3evXLJAptu8UuT29iaybN0M/igj/6EFEynC4jzxcjFbEm/qeDcZX1W+bmfybBgXrT60ij NMT1lLYLst/CV2ZKp49g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raClr-0000000CZUI-0GVj; Wed, 14 Feb 2024 10:45:43 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfW-0000000CKuH-1eUQ for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=RsDH3gWRwitRMq8rLjOQHbLCQuTZp64GjYqBBCamem4=; b=LiXgW8lLHUkWtgK0BJZELWBfZF CMhzsJzPyJCw207yodgbjlad4ndvzAmP8442IXSMl6I8x+266bDT12qCVpG1JqlWjPv94L1p0GfUS wGv2tK/fAE15UfMtP5XkYOKz8C/jzgafC58JR9s5ejD2uJfC1xKsNEMGrvUjgqgf+8GtSHiip+7Ij SkIEdKJXxg3t09AHsBWoBBs+kFuFsN8iM26dvZbwbctqhRA+CUze1u+WyKlrIHQB63xP9QraBdhPX E4leS5zAyIzzFUYaXXD7D0IiLqMEpCJI1Dvr+xohJD782Loo2r8OFbdMc1Hs6g6gR+uze4+Irb+cG bTcgVmaw==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfE-0000000GAXH-0Vgo for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:02 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf0-0005JQ-EV; Wed, 14 Feb 2024 10:34:34 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBex-000fE0-3i; Wed, 14 Feb 2024 10:34:31 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBex-004Y5T-07; Wed, 14 Feb 2024 10:34:31 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Florian Fainelli , linux-pwm@vger.kernel.org Cc: Broadcom internal kernel review list , linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 085/164] pwm: raspberrypi-poe: Make use of pwmchip_parent() accessor Date: Wed, 14 Feb 2024 10:32:12 +0100 Message-ID: <6758bcddb150f2c4353469937f1a68ecb87465ed.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=953; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=tckScFPWS6URzhmSZ5hzAZ/IN0qAPlMBZCNdmE0zraw=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIisB8V/68e/2Dm6u/ZpfffFdjoQSCAshbIDN jsAFuWqwCiJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIrAAKCRCPgPtYfRL+ TioHB/9nX5RKM/BXRhHRjK/0H0GOuMXLQRmMc2/LsBU1Yg7sbmfBinQrMpLB4l3EzqHvpbVjF4L 5XpzhBxaig5Cjod26SZhBJgjMENWc0pZjpsT0Z3kpox0RlvmATkHwA31aX4pi5HUhRZYN2SDs4l QFy+ESyt9T7D5Hn7mGIfagoeTABKRfowH8HCWEitmgex1YvER/aHqGuaf9EwX0NISy9SBPvuLwn vt7XDmeghl/szuhEbK8YoxcwGiIq5t+M8aU4Zu0UMDBP/+KGoWqSueg9GcYx5C65KePCpd9M7om SVri1DtEQg5C0So3dAQX8DpUrQU4Utu7kXLI/kzrBdB9RtgM X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093448_621534_8C346F2F X-CRM114-Status: GOOD ( 13.01 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org struct pwm_chip::dev is about to change. To not have to touch this driver in the same commit as struct pwm_chip::dev, use the accessor function provided for exactly this purpose. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-raspberrypi-poe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-raspberrypi-poe.c b/drivers/pwm/pwm-raspberrypi-poe.c index 1ad814fdec6b..f10e8a624c51 100644 --- a/drivers/pwm/pwm-raspberrypi-poe.c +++ b/drivers/pwm/pwm-raspberrypi-poe.c @@ -122,7 +122,7 @@ static int raspberrypi_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, ret = raspberrypi_pwm_set_property(rpipwm->firmware, RPI_PWM_CUR_DUTY_REG, duty_cycle); if (ret) { - dev_err(chip->dev, "Failed to set duty cycle: %pe\n", + dev_err(pwmchip_parent(chip), "Failed to set duty cycle: %pe\n", ERR_PTR(ret)); return ret; } From patchwork Wed Feb 14 09:32:13 2024 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: 13556214 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 73225C48BC4 for ; Wed, 14 Feb 2024 09:42:12 +0000 (UTC) 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=k0kWRkdpK+v5ErymWaDf6WCN2NN9N/LS0W55xR9par0=; b=jsHlfI1xaubHEC 8g6RGOvDgYQ1j6mAA2WRKwGz/KgKE8P94Kf2IRo4kSxngIhYp8mzzj5qgv7jiPj2/miehqIr1tguc zZJpCF5eJgPS54afuJPIfte9hZYszE8iEA5jXZayfomGijF50EKlvv6m1Ko84P1mVhE1hurEjrHBV OdQGH/BThoCT3u6DD5B9tvKbb9PHFN9C+0+489SRvsS86bjGazdhFjn8kXA2K4aC1jfO+uhRd/VDY RBhqlAnhie2jJl61i3K02X/YgYUuobrpNFJ1NftwMi2NsflDZjUEQbhwcmbUXVkeCAUMp62ZLAGBM 4eR6E7BPszDDuVFegtJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBmA-0000000CPjd-2sVl; Wed, 14 Feb 2024 09:41:58 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBf9-0000000CKTL-158l for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:52 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf1-0005KJ-27; Wed, 14 Feb 2024 10:34:35 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBex-000fE3-90; Wed, 14 Feb 2024 10:34:31 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBex-004Y5X-0e; Wed, 14 Feb 2024 10:34:31 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Florian Fainelli , linux-pwm@vger.kernel.org Cc: Broadcom internal kernel review list , linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 086/164] pwm: raspberrypi-poe: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:32:13 +0100 Message-ID: <4654a6438ab618574afc3bb73bf402df7c254ee2.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2408; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=LHD4KLDIlnSOmaaf0KhlfAHXjBY/NkanePlRIZG5x/4=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIiuaL6COMjsLc2xQnGML7e7jx4vDk4i+jV9H s5paEdepI2JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIrgAKCRCPgPtYfRL+ TkeTCACb4LDfuHpSG74Dl1hcc6QrORxW/V5xEeTbblX9EsbJiffkjAO5F7O0kpnuU4ARXQm5okm gGQRk1DWW3C3uHkhEkQDstJK0q9at1K0ZuSskzEYBijv4paCboVET37qyeNOASJ/gBlq/m5IJZ7 LBdHCYjMEN2SIzIAhqjlVh12m0cAf4EJYILdWcu8ttmC0zeOXMmuxpTUqPxLXlgAQapwq8ED6Rj 9iHQyQtfrhYnIpOmN771tBa+T3lMGJXuRJaBgVaUAN+IkfpxOQyXZs5vFUM86O04hsfZ607s4OC FMY6Cx23pbiGVrwV/tTGneVa+brjpeZdSKCSC9zyZNwWGcOd X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013443_520907_E1C68ABF X-CRM114-Status: GOOD ( 14.68 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-raspberrypi-poe driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-raspberrypi-poe.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-raspberrypi-poe.c b/drivers/pwm/pwm-raspberrypi-poe.c index f10e8a624c51..8921e7ea2cea 100644 --- a/drivers/pwm/pwm-raspberrypi-poe.c +++ b/drivers/pwm/pwm-raspberrypi-poe.c @@ -27,7 +27,6 @@ struct raspberrypi_pwm { struct rpi_firmware *firmware; - struct pwm_chip chip; unsigned int duty_cycle; }; @@ -40,7 +39,7 @@ struct raspberrypi_pwm_prop { static inline struct raspberrypi_pwm *raspberrypi_pwm_from_chip(struct pwm_chip *chip) { - return container_of(chip, struct raspberrypi_pwm, chip); + return pwmchip_get_drvdata(chip); } static int raspberrypi_pwm_set_property(struct rpi_firmware *firmware, @@ -142,6 +141,7 @@ static int raspberrypi_pwm_probe(struct platform_device *pdev) struct device_node *firmware_node; struct device *dev = &pdev->dev; struct rpi_firmware *firmware; + struct pwm_chip *chip; struct raspberrypi_pwm *rpipwm; int ret; @@ -157,14 +157,14 @@ static int raspberrypi_pwm_probe(struct platform_device *pdev) return dev_err_probe(dev, -EPROBE_DEFER, "Failed to get firmware handle\n"); - rpipwm = devm_kzalloc(&pdev->dev, sizeof(*rpipwm), GFP_KERNEL); - if (!rpipwm) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, RASPBERRYPI_FIRMWARE_PWM_NUM, + sizeof(*rpipwm)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + rpipwm = raspberrypi_pwm_from_chip(chip); rpipwm->firmware = firmware; - rpipwm->chip.dev = dev; - rpipwm->chip.ops = &raspberrypi_pwm_ops; - rpipwm->chip.npwm = RASPBERRYPI_FIRMWARE_PWM_NUM; + chip->ops = &raspberrypi_pwm_ops; ret = raspberrypi_pwm_get_property(rpipwm->firmware, RPI_PWM_CUR_DUTY_REG, &rpipwm->duty_cycle); @@ -173,7 +173,7 @@ static int raspberrypi_pwm_probe(struct platform_device *pdev) return ret; } - return devm_pwmchip_add(dev, &rpipwm->chip); + return devm_pwmchip_add(dev, chip); } static const struct of_device_id raspberrypi_pwm_of_match[] = { From patchwork Wed Feb 14 09:32:18 2024 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: 13556161 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3AA1CC48BEC for ; Wed, 14 Feb 2024 09:36:49 +0000 (UTC) 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=OUGx1KYcbJCjcanaD4FJaKdOCPYBLMzFRrShMJD5H6Y=; b=qClfbUhj3ApIad 1y6ZEmg6648BU2Y/ox9tuwD2vz0spVWOH6bJBLvPlXwUGSCYR43kDXf8ifcJEq0VkCqPNlQDpQkW6 hJaDKrcpCaou2mPuhPy0k5wAbkyFRC3mZAz8KktHbjgBpJwI/dLjA1IOBkPOti7UCa+gbP0p2/r1Q sCnVcqsKkZxhUYVNH6DCuECX1LYFnsbYTmxcmLX1hvt3ucb7K6PWHjR6Rdt+B9cLkYQT+J4M5JfoV CpcaOise14el9AhqxgE6725QoGKyZPfBrRfSi0tXqV7sdxvCNbvEFV3f/AOfQRSBw+bcQZg6fLFya 5PIOAhp6p3S0GtYHWBhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBgt-0000000CM1y-2Wbn; Wed, 14 Feb 2024 09:36:31 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBf4-0000000CKLx-1lJE for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:42 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf0-0005NI-8x; Wed, 14 Feb 2024 10:34:34 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBex-000fEM-SF; Wed, 14 Feb 2024 10:34:31 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBex-004Y5q-2Y; Wed, 14 Feb 2024 10:34:31 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Heiko Stuebner , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 091/164] pwm: rochchip: Prepare removing pwm_chip from driver data Date: Wed, 14 Feb 2024 10:32:18 +0100 Message-ID: <301657442c578cc8d330ad2b07463d59fed4bff6.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2308; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=IKTf684HbAbCFxV/P3BN2Q+Ew9cnAV7p+JKFfoj1v3k=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIizoVhC0FRyoze4sZvNk4frGiCMCNVmrvi9M JGTTXoVeSKJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIswAKCRCPgPtYfRL+ To66B/9bBWqw86Vi8ALhIjsb6DA2j/fZlrFMRghd87lmbzOpKe6/tZdipPrZgwiwVXriuSOudXZ /CwapgIrtBTNdkqOnRN3qAzSLbHBEpSplM/x5v9X8OtEO0M1rS/Lo64rWB4t2lZsDxAKGBD2h9o UfJhjI/XHr7X8Mj5SVrx0bAkzMgPJXRnHzAId1ZdkPDnSewMV3i01WzEwhRiIu4pk7s4NiqRPGL XCohn1umvYkQswCTDMbtglvViPlMNxH67zvh4WesNLKiugpsBA5F9iqXo25BKUngE5YQ5lYdhm+ 9b7H6NmCNMYOIooRfxcjJFAVxpBcbLZvvZ9fIjJpJPcmwsg8 X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013438_620980_9C908334 X-CRM114-Status: GOOD ( 13.95 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the driver for further changes that will drop struct pwm_chip chip from struct rockchip_pwm_chip. Use the pwm_chip as driver data instead of the rockchip_pwm_chip to get access to the pwm_chip in rockchip_pwm_remove() without using pc->chip. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-rockchip.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c index a7c647e37837..c001eb6b17ae 100644 --- a/drivers/pwm/pwm-rockchip.c +++ b/drivers/pwm/pwm-rockchip.c @@ -296,6 +296,7 @@ MODULE_DEVICE_TABLE(of, rockchip_pwm_dt_ids); static int rockchip_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct rockchip_pwm_chip *pc; u32 enable_conf, ctrl; bool enabled; @@ -304,6 +305,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev) pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); if (!pc) return -ENOMEM; + chip = &pc->chip; pc->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(pc->base)) @@ -337,18 +339,18 @@ static int rockchip_pwm_probe(struct platform_device *pdev) goto err_clk; } - platform_set_drvdata(pdev, pc); + platform_set_drvdata(pdev, chip); pc->data = device_get_match_data(&pdev->dev); - pc->chip.dev = &pdev->dev; - pc->chip.ops = &rockchip_pwm_ops; - pc->chip.npwm = 1; + chip->dev = &pdev->dev; + chip->ops = &rockchip_pwm_ops; + chip->npwm = 1; enable_conf = pc->data->enable_conf; ctrl = readl_relaxed(pc->base + pc->data->regs.ctrl); enabled = (ctrl & enable_conf) == enable_conf; - ret = pwmchip_add(&pc->chip); + ret = pwmchip_add(chip); if (ret < 0) { dev_err_probe(&pdev->dev, ret, "pwmchip_add() failed\n"); goto err_pclk; @@ -372,9 +374,10 @@ static int rockchip_pwm_probe(struct platform_device *pdev) static void rockchip_pwm_remove(struct platform_device *pdev) { - struct rockchip_pwm_chip *pc = platform_get_drvdata(pdev); + struct pwm_chip *chip = platform_get_drvdata(pdev); + struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip); - pwmchip_remove(&pc->chip); + pwmchip_remove(chip); clk_unprepare(pc->pclk); clk_unprepare(pc->clk); From patchwork Wed Feb 14 09:32:19 2024 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: 13556163 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E6DA1C48BC4 for ; Wed, 14 Feb 2024 09:37:06 +0000 (UTC) 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=XkSFn8owMlAltE9cGq7JFykSLejASmiF0v7mOSQJoMo=; b=ZwE698BWMulDjt DzesdadmxbpXEkZgwy+m6UHc22ANHQXOJLSwTRv+P+c8FASCZfXhDFOh73Jhp+DMTfTnlC6dMlFwh DfSu9m/qSfp+4JSKE5ESo9CZNlNC5QupvW+sknbyVRAX/HnccCIbigKbC8D+DzNH8lehj8fd2rI2m WrMtuRT0UFIghnO45ihQ6RSM9zSE78S/T0tvdQB51loDnUQQV6Vom4lIfP1fECod/kT9v+BVB/jim WPPhDU5kBkRJkOWOqU0LmC1fLHryXtS178pC3ExedTepMW7Ofz1wUIfF9sukyYd8dj6oWPU2Kj7sn jrTGQ98gCDYbNUmVNaeg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBhB-0000000CMJA-1E3f; Wed, 14 Feb 2024 09:36:49 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBf5-0000000CKNf-2vb6 for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:45 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf1-0005O6-EN; Wed, 14 Feb 2024 10:34:35 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBey-000fEQ-19; Wed, 14 Feb 2024 10:34:32 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBex-004Y5v-35; Wed, 14 Feb 2024 10:34:31 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Heiko Stuebner , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 092/164] pwm: rockchip: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:32:19 +0100 Message-ID: <61a3f48710e3e795beb2e496c8c673bbc0f6c932.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1883; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=MaLv9HpNc3gSSboEx4AXhzrUji0bPoNdjQWHXjg6D1M=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIi0Q6jh5jQS1v0LelA5uwPTo5/sscfBg/Ssl 7WKx/rIVaWJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyItAAKCRCPgPtYfRL+ TpfkB/9Xwu5KMbDTzywn8HbUynu522uvpHjJwdLBAp2qurcNabbuhZh1rPBJ6Ns71N+B78IwtKl J0cs1MpD7vpS4oEeQEvE7W1nXAk+1TptdgjBVYeP3JCJgPuuQHtH8Q6oF/P/gdP5s2KX2l5F6xD jdYkisWyowUXdUBL26ZNg1lyqKe1Hpd6rbdHaXWoa/ZfQD63zX7oT1nXLhu+984N1ISGYQhVliz gKvbA60uzAvTo+8XH/PfVohRpTOgDqcAs+I5xQb9HLYU/j7A3Mc0LEKgodN/JZ1xDaWNZIHW+va ymq4dIJRczio3WRyasU1g6W6WgLiL0HHKxETKa4aul0UvAW4 X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013440_056720_0FD71A20 X-CRM114-Status: GOOD ( 14.81 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-rockchip driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-rockchip.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c index c001eb6b17ae..0fa7575dbb54 100644 --- a/drivers/pwm/pwm-rockchip.c +++ b/drivers/pwm/pwm-rockchip.c @@ -30,7 +30,6 @@ #define PWM_LP_DISABLE (0 << 8) struct rockchip_pwm_chip { - struct pwm_chip chip; struct clk *clk; struct clk *pclk; const struct rockchip_pwm_data *data; @@ -54,7 +53,7 @@ struct rockchip_pwm_data { static inline struct rockchip_pwm_chip *to_rockchip_pwm_chip(struct pwm_chip *chip) { - return container_of(chip, struct rockchip_pwm_chip, chip); + return pwmchip_get_drvdata(chip); } static int rockchip_pwm_get_state(struct pwm_chip *chip, @@ -302,10 +301,10 @@ static int rockchip_pwm_probe(struct platform_device *pdev) bool enabled; int ret, count; - pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); - if (!pc) - return -ENOMEM; - chip = &pc->chip; + chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*pc)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + pc = to_rockchip_pwm_chip(chip); pc->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(pc->base)) @@ -342,9 +341,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev) platform_set_drvdata(pdev, chip); pc->data = device_get_match_data(&pdev->dev); - chip->dev = &pdev->dev; chip->ops = &rockchip_pwm_ops; - chip->npwm = 1; enable_conf = pc->data->enable_conf; ctrl = readl_relaxed(pc->base + pc->data->regs.ctrl); From patchwork Wed Feb 14 09:32:23 2024 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: 13556213 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DDCAFC48BEB for ; Wed, 14 Feb 2024 09:42:09 +0000 (UTC) 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=aav3D/F1sInz/MNqjBBHV4X4+cDRyPdExqdkkukiceU=; b=0PCj99jEJpyzOj TszEB7Es06wdL8Z5aAo7pXTvbwGjUy//3G8SzsmSyrOgHnMDiRyiEnYqrULWBnOzToMs5o41mH++q 8Nd9LMSgutiDatUT5ofn69O2iNgMLFNVjmHcv5c2X+h+B1865P1ygehShW8s8dzxyy4sabcrvuabX txskerGNWXfUyYoF4vpzGkabo4taLwVAa11dZbABn/WHmf9uZWvM/c4bREJ3tZFC16SjXNOPfVtQ1 Czj8ojkEiHb/YaI2L8HhL1RDZxonaDuT662qS436Al9lvFYxY84rzmByb3B/Lqrc+rszLAQmnwfd1 dkf1Ud3HBP1YU0elyT1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBm5-0000000CPff-4AfC; Wed, 14 Feb 2024 09:41:54 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfH-0000000CKcY-1A2c for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:34:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=77xukX4g0zdxjb5pL8QmqSiL6tj09dqFzgMrf1XV/y0=; b=SmqmHepD4ADNqVUslg+XB2GA3b AQLIEHcLEK5m6K4ovtpQpFq1ybHRP7MI4tBamoZj+cJQ9oUz+uXi0sJC9789uldSbNLo0PGx84D9i HZW3i2hZorDfFkoRmxY81vu6yUXvT9OX6SeeskR+0Z/E2U1q3WuGsPGlU/INhaZ7R06B3EoDL/Qqx bNhpq96lCqK+9BVPnMEuQJDs8zVJTsTkPU42tevsiizufp2CQxjd9mr5JXoExz+Q9mEMQp9C/5BsC wT05QeI+5FhDrEq8b2jNA4Al2N4Xj1E9nMc2TtMKBnful4dzTlHuEyr9nm1Xgu4/mt5Z5BLRTM/e8 xJtLVvGg==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfC-0000000GAX9-49aG for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:49 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf1-0005RU-QD; Wed, 14 Feb 2024 10:34:35 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBey-000fEe-JU; Wed, 14 Feb 2024 10:34:32 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBey-004Y6B-1g; Wed, 14 Feb 2024 10:34:32 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Krzysztof Kozlowski , linux-pwm@vger.kernel.org Cc: Alim Akhtar , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH v6 096/164] pwm: samsung: Simplify code to determine the pwmchip's parent device Date: Wed, 14 Feb 2024 10:32:23 +0100 Message-ID: <4e8400a42979b6be0b80dff5ae964d8e9d6232eb.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1945; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=gI6fgHjRyxH3Qt9HapAhSqq3xRfx+GZ8KpfHRdKhT88=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIi5dffod7rgEsvr7NFa/8oDDNfXE0QdPB0pK AogvDV4MFqJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIuQAKCRCPgPtYfRL+ TvmIB/9nfm11krcHO1WDkPaq7yn2sgHJkG66SC3mgGtRwWSzNdGf/Ks1qwm2m/TFR6YHBMwrdNt 4w0c6pE+eeDaavHQPPDhwdIqzBcnp/G0kpQ4DxH/Yz2Fv92OZ0fiooDBDo8/QJ6D9d5sm+yppQE S3E7lId+KqwiaGBfR6b0byZPO0POor/7YLack1khWjziXBuwIo2QUkEcOWGAaOdZ5ID0PlQD7LU VnsdFMh6cPm7Xvtt1MxXUyCRHds7jqHLAcug99K2kEEgII/iV718Zh1xTqvPO4z6vxXfpBqEZxn Xz3kis9kVqYIWMyMZqCorBhflwXaaehhP7zLzc+h9bbbQyDM X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093447_507730_9993D9A0 X-CRM114-Status: GOOD ( 12.22 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There is already a pointer to the pwmchip, make use of it directly instead of using the struct samsung_pwm_chip *our_chip just obtained from it. This also has the advantage of not using struct samsung_pwm_chip::chip any more which will be dropped soon. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-samsung.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c index 6e77302f7368..0f9a2a5e3ebc 100644 --- a/drivers/pwm/pwm-samsung.c +++ b/drivers/pwm/pwm-samsung.c @@ -326,12 +326,12 @@ static int __pwm_samsung_config(struct pwm_chip *chip, struct pwm_device *pwm, period = NSEC_PER_SEC / period_ns; - dev_dbg(our_chip->chip.dev, "duty_ns=%d, period_ns=%d (%u)\n", + dev_dbg(chip->dev, "duty_ns=%d, period_ns=%d (%u)\n", duty_ns, period_ns, period); tin_rate = pwm_samsung_calc_tin(our_chip, pwm->hwpwm, period); - dev_dbg(our_chip->chip.dev, "tin_rate=%lu\n", tin_rate); + dev_dbg(chip->dev, "tin_rate=%lu\n", tin_rate); tin_ns = NSEC_PER_SEC / tin_rate; tcnt = period_ns / tin_ns; @@ -355,8 +355,7 @@ static int __pwm_samsung_config(struct pwm_chip *chip, struct pwm_device *pwm, /* -1UL will give 100% duty. */ --tcmp; - dev_dbg(our_chip->chip.dev, - "tin_ns=%u, tcmp=%u/%u\n", tin_ns, tcmp, tcnt); + dev_dbg(chip->dev, "tin_ns=%u, tcmp=%u/%u\n", tin_ns, tcmp, tcnt); /* Update PWM registers. */ writel(tcnt, our_chip->base + REG_TCNTB(pwm->hwpwm)); @@ -368,7 +367,7 @@ static int __pwm_samsung_config(struct pwm_chip *chip, struct pwm_device *pwm, * shortly afer this update (before it autoreloaded the new values). */ if (oldtcmp == (u32) -1) { - dev_dbg(our_chip->chip.dev, "Forcing manual update"); + dev_dbg(chip->dev, "Forcing manual update"); pwm_samsung_manual_update(our_chip, pwm); } From patchwork Wed Feb 14 09:32:24 2024 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: 13556195 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6193BC48BC4 for ; Wed, 14 Feb 2024 09:39:38 +0000 (UTC) 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=1sP3VR7SEHgsDVLpSnUZJ194sMUAZt+mCjX16icj+q8=; b=F+cEUWlz7mJvQs plxWj8THka+sSnJNsGDcFY2xm6KYXnJ2RA+pf2bGPCarjNbUv5h/SnvKmCEXaYBVadpCVB3TsdMcX Z9c1Kt1sUTCutVYRRvzzIyFnd9qtPTX/L2GT7tRaZUTibEQ/qnMRxffp+uvg4W4K7rlXoAGmVItqG KvLmkZmRxoPPCElUDK/tvyPk2fdraDCnUS9ysgiX43MkVtY8TyDprwUfmPN0QoudyFB9bXrxhYHck nj/yUz/CJKVdUdKuz5xgsCBbqla84PVrv3S/xw7b0Xxq6LffiIY+45xMCwAdA6oilXgmYa77PE2Xo u4Fc2DpWk+4XS9tFArIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBjc-0000000CNct-1aeC; Wed, 14 Feb 2024 09:39:20 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfU-0000000CKqj-06JE for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=IclYCuABXw6OxctvCL/bCAJvMqHGqIFyYsSEdYqkkUM=; b=q06CGaa3aY3ffVX4PA84gE8dk8 JrOi4NeQNERVTe7GMx126tvf1SxNXjejrS6EttnqPFBpyGhMxq3msH0v2FlDS0NNulHAlqBvH+cis 3P/N2/YCOkBSeVCF6hVnpgTEyMkpq4JeBb+hUkgNzJo4MGusfCnPuJTQW9hT7RQ1XGPxM0Vy6UnFO B75ddWaNcweYrWwd3AfVlvxECXCCLpGVC3pxXRrywhep2qWQhhGY3J8dyiAeb3zGh4XIVeu4HgeVg xGU7ERaQ4kthGWP9F6wZnes+btlZJg8ujz/4hew76jFGlUE67grvD/VIbT7n5oK0Q4/Q/tMS916Qu ebQn98AA==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfE-0000000GAXJ-2Pjo for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:00 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf2-0005Ss-Pr; Wed, 14 Feb 2024 10:34:36 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBey-000fEk-Pb; Wed, 14 Feb 2024 10:34:32 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBey-004Y6F-2J; Wed, 14 Feb 2024 10:34:32 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Krzysztof Kozlowski , linux-pwm@vger.kernel.org Cc: Alim Akhtar , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH v6 097/164] pwm: samsung: Change prototype of helpers to prepare further changes Date: Wed, 14 Feb 2024 10:32:24 +0100 Message-ID: <33ea7d7fbf3be4a542ae8aafa213470c5831487e.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5324; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=nipCLLMDWvTbNQBD2/LQ6KGkbMAdcFJTiu0fWjzZ3NQ=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIi6JSgJnfb/o/v1UGfK1a40dVFvZSJlDgqKg Xk6KeC51PSJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIugAKCRCPgPtYfRL+ TuvLB/4s6CYTlewRyBSFA8yqp2ewf3X+euU/JvyxQzepa8SVKlsrV4tnHeD+xFnp+RqgpAFO5JU e6LfiEBaE6UV0labcIneyRzPIjgbuMRflcg3lHFjscxkp8PxEdubdCq5O9AKwjVmzaDN0C8Q0IL KEITIuzA+A0qRlQL0GpLK9AFixeLfdELnSB89xosG1buGODiys5KZin48/E1FfYeIf+zOB8ST/6 qDxMp+WFilHpw2dDNO3wNip+D9kZNgjlcrssD/gJ6OIJCLrvZtov0n10aFN3rvxK62ucJo1XpHy CGuidjlALj1MtuKxTuNb5rqEi1HmUxIR0tZyroklEVeN7FhR X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093449_117134_A611BDC8 X-CRM114-Status: GOOD ( 18.90 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the driver for further changes that will make it harder to determine the pwm_chip from a given samsung_pwm_chip. To just not have to do that, rework pwm_samsung_calc_tin() and pwm_samsung_parse_dt take a pwm_chip. Also use the pwm_chip as driver data instead of the samsung_pwm_chip. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-samsung.c | 41 ++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c index 0f9a2a5e3ebc..ecd612adf19d 100644 --- a/drivers/pwm/pwm-samsung.c +++ b/drivers/pwm/pwm-samsung.c @@ -181,9 +181,10 @@ static unsigned long pwm_samsung_get_tin_rate(struct samsung_pwm_chip *our_chip, return rate / (reg + 1); } -static unsigned long pwm_samsung_calc_tin(struct samsung_pwm_chip *our_chip, +static unsigned long pwm_samsung_calc_tin(struct pwm_chip *chip, unsigned int chan, unsigned long freq) { + struct samsung_pwm_chip *our_chip = to_samsung_pwm_chip(chip); struct samsung_pwm_variant *variant = &our_chip->variant; unsigned long rate; struct clk *clk; @@ -197,12 +198,12 @@ static unsigned long pwm_samsung_calc_tin(struct samsung_pwm_chip *our_chip, return rate; } - dev_warn(our_chip->chip.dev, + dev_warn(chip->dev, "tclk of PWM %d is inoperational, using tdiv\n", chan); } rate = pwm_samsung_get_tin_rate(our_chip, chan); - dev_dbg(our_chip->chip.dev, "tin parent at %lu\n", rate); + dev_dbg(chip->dev, "tin parent at %lu\n", rate); /* * Compare minimum PWM frequency that can be achieved with possible @@ -329,7 +330,7 @@ static int __pwm_samsung_config(struct pwm_chip *chip, struct pwm_device *pwm, dev_dbg(chip->dev, "duty_ns=%d, period_ns=%d (%u)\n", duty_ns, period_ns, period); - tin_rate = pwm_samsung_calc_tin(our_chip, pwm->hwpwm, period); + tin_rate = pwm_samsung_calc_tin(chip, pwm->hwpwm, period); dev_dbg(chip->dev, "tin_rate=%lu\n", tin_rate); @@ -506,9 +507,10 @@ static const struct of_device_id samsung_pwm_matches[] = { }; MODULE_DEVICE_TABLE(of, samsung_pwm_matches); -static int pwm_samsung_parse_dt(struct samsung_pwm_chip *our_chip) +static int pwm_samsung_parse_dt(struct pwm_chip *chip) { - struct device_node *np = our_chip->chip.dev->of_node; + struct samsung_pwm_chip *our_chip = to_samsung_pwm_chip(chip); + struct device_node *np = chip->dev->of_node; const struct of_device_id *match; struct property *prop; const __be32 *cur; @@ -522,7 +524,7 @@ static int pwm_samsung_parse_dt(struct samsung_pwm_chip *our_chip) of_property_for_each_u32(np, "samsung,pwm-outputs", prop, cur, val) { if (val >= SAMSUNG_PWM_NUM) { - dev_err(our_chip->chip.dev, + dev_err(chip->dev, "%s: invalid channel index in samsung,pwm-outputs property\n", __func__); continue; @@ -533,7 +535,7 @@ static int pwm_samsung_parse_dt(struct samsung_pwm_chip *our_chip) return 0; } #else -static int pwm_samsung_parse_dt(struct samsung_pwm_chip *our_chip) +static int pwm_samsung_parse_dt(struct pwm_chip *chip) { return -ENODEV; } @@ -543,6 +545,7 @@ static int pwm_samsung_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct samsung_pwm_chip *our_chip; + struct pwm_chip *chip; unsigned int chan; int ret; @@ -550,13 +553,14 @@ static int pwm_samsung_probe(struct platform_device *pdev) if (our_chip == NULL) return -ENOMEM; - our_chip->chip.dev = &pdev->dev; - our_chip->chip.ops = &pwm_samsung_ops; - our_chip->chip.npwm = SAMSUNG_PWM_NUM; + chip = &our_chip->chip; + chip->dev = &pdev->dev; + chip->ops = &pwm_samsung_ops; + chip->npwm = SAMSUNG_PWM_NUM; our_chip->inverter_mask = BIT(SAMSUNG_PWM_NUM) - 1; if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) { - ret = pwm_samsung_parse_dt(our_chip); + ret = pwm_samsung_parse_dt(chip); if (ret) return ret; } else { @@ -593,9 +597,9 @@ static int pwm_samsung_probe(struct platform_device *pdev) our_chip->tclk0 = devm_clk_get(&pdev->dev, "pwm-tclk0"); our_chip->tclk1 = devm_clk_get(&pdev->dev, "pwm-tclk1"); - platform_set_drvdata(pdev, our_chip); + platform_set_drvdata(pdev, chip); - ret = pwmchip_add(&our_chip->chip); + ret = pwmchip_add(chip); if (ret < 0) { dev_err(dev, "failed to register PWM chip\n"); clk_disable_unprepare(our_chip->base_clk); @@ -612,17 +616,18 @@ static int pwm_samsung_probe(struct platform_device *pdev) static void pwm_samsung_remove(struct platform_device *pdev) { - struct samsung_pwm_chip *our_chip = platform_get_drvdata(pdev); + struct pwm_chip *chip = platform_get_drvdata(pdev); + struct samsung_pwm_chip *our_chip = to_samsung_pwm_chip(chip); - pwmchip_remove(&our_chip->chip); + pwmchip_remove(chip); clk_disable_unprepare(our_chip->base_clk); } static int pwm_samsung_resume(struct device *dev) { - struct samsung_pwm_chip *our_chip = dev_get_drvdata(dev); - struct pwm_chip *chip = &our_chip->chip; + struct pwm_chip *chip = dev_get_drvdata(dev); + struct samsung_pwm_chip *our_chip = to_samsung_pwm_chip(chip); unsigned int i; for (i = 0; i < SAMSUNG_PWM_NUM; i++) { From patchwork Wed Feb 14 09:32:25 2024 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: 13556199 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0D157C48BEB for ; Wed, 14 Feb 2024 09:40:10 +0000 (UTC) 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=LPuXAvBesnb5JgOrHkPepe0UnsIHwQd9LYeEfxtYim8=; b=dgBZ5fR6hsz2CK tGzyV2bdgq28jAJ3YGzRhf+oCeX0IdpPhBpLxc4eePb/roylMF+2LYNdJNo3LF3BTe/CbV9OaW1Hm pgGSo4zYQzQ2UzS8k2JDNPi3vjksrA1qRyTVBuQ6/MHF+C6mTyQgg7slqW+kl4Shsq+5rqUocAGCM e24AnZ038wWyE9eXPH5PjmMRfykNoX986XVR88s7DXqxHWLqgvSrm2JytaQEkX9i+SMdWGWBlGz7P 0SidTmTlJRbyf42Y6kFfDyzFoVW7tiTXKlBECgtlDx6i2SBF2/IJj6WEZkbeLaR8FDZbvR2JUkSX8 mFTT0xXES3S1Ljkx/Jaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBkC-0000000COBe-0p2U; Wed, 14 Feb 2024 09:39:56 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfW-0000000CKuB-1Rwf for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=vu/CdUWWt3zubDABkOMSf0aE1x4rrvpM/kXThvAy36w=; b=Gi8mqfz72do2JMcVA3vG1CeBt+ Ns2yeGqu0aHwxm/q3SFhFbS2B6Jcv6yF5en552XTLJ7pir40QJL9Jdos+WHrevsnYyIOmgu+k4Ln4 ojeUbHP+ZDV/K174yGn37/yljLv4elUbrzypWV3SVNOCZddqHsgK6FfFroyqbxvJ7u3WXw433j4hb M4cfk4cZNQJZvZGf0BkHuvq7jAPIKxQwqd/tRyNJ1zmJQXqfEUwxviIjUPsLOi8oh18nJUEtOyVdP /wRNL2/n2cYWUiwb3oWEIm/VCR61BT+b6bmyesO42Wo/KaABPBF3E1oPwZVJpnaSxba54sySgUad/ F/5ul3zA==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfD-0000000GAXC-2aVs for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:02 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf2-0005Tq-QF; Wed, 14 Feb 2024 10:34:36 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBey-000fEo-UE; Wed, 14 Feb 2024 10:34:32 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBey-004Y6J-2l; Wed, 14 Feb 2024 10:34:32 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Krzysztof Kozlowski , linux-pwm@vger.kernel.org Cc: Alim Akhtar , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH v6 098/164] pwm: samsung: Make use of pwmchip_parent() accessor Date: Wed, 14 Feb 2024 10:32:25 +0100 Message-ID: <421ee291a065aeae7a1552f22da4173313e789ad.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3488; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=dtj8pBhqbTvcBaJAEjUaKJM7LAj26UkY+/gbMpOgPPc=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIi8dRtUNe0zYA+s0OHD5sj0QsHY4X9kSVwDe Uj6zO+Q6myJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIvAAKCRCPgPtYfRL+ TsP5B/98DHYE2m1eQEfspjC38cwFhD/0cfp6nXL8UnHUglrlUDv2OcJB6R90d05IF1jL9A2gZZX G27m3+MIAMQbBE1D+eEdY+Qy8cXcJU+FgYFYQzddOBYTm44kOE9hfUBTHzYwBrhNMZiQ3AgNhyD cMKaZ9vb8mSmskMYCC9vcaJr+0/XuqV7yNjAtTLTZNib8JJlC57Jp2/tin12K+epNeCjTAjBrrQ wlR/tdZ+FKA4zWSTwWnflo48ogRgE4qj+FYqENuvkf6E+iiAgRgeYghTe2vVQoXK6mcdrPRzKhY zVVwowv0fzaXNJdhn/cmcgvr7EeiLFy6kbyp630rZ7md2ypF X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093448_023960_26100DDB X-CRM114-Status: GOOD ( 13.18 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org struct pwm_chip::dev is about to change. To not have to touch this driver in the same commit as struct pwm_chip::dev, use the accessor function provided for exactly this purpose. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-samsung.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c index ecd612adf19d..cabdcdf37ec9 100644 --- a/drivers/pwm/pwm-samsung.c +++ b/drivers/pwm/pwm-samsung.c @@ -198,12 +198,12 @@ static unsigned long pwm_samsung_calc_tin(struct pwm_chip *chip, return rate; } - dev_warn(chip->dev, + dev_warn(pwmchip_parent(chip), "tclk of PWM %d is inoperational, using tdiv\n", chan); } rate = pwm_samsung_get_tin_rate(our_chip, chan); - dev_dbg(chip->dev, "tin parent at %lu\n", rate); + dev_dbg(pwmchip_parent(chip), "tin parent at %lu\n", rate); /* * Compare minimum PWM frequency that can be achieved with possible @@ -233,7 +233,7 @@ static int pwm_samsung_request(struct pwm_chip *chip, struct pwm_device *pwm) struct samsung_pwm_chip *our_chip = to_samsung_pwm_chip(chip); if (!(our_chip->variant.output_mask & BIT(pwm->hwpwm))) { - dev_warn(chip->dev, + dev_warn(pwmchip_parent(chip), "tried to request PWM channel %d without output\n", pwm->hwpwm); return -EINVAL; @@ -327,12 +327,12 @@ static int __pwm_samsung_config(struct pwm_chip *chip, struct pwm_device *pwm, period = NSEC_PER_SEC / period_ns; - dev_dbg(chip->dev, "duty_ns=%d, period_ns=%d (%u)\n", + dev_dbg(pwmchip_parent(chip), "duty_ns=%d, period_ns=%d (%u)\n", duty_ns, period_ns, period); tin_rate = pwm_samsung_calc_tin(chip, pwm->hwpwm, period); - dev_dbg(chip->dev, "tin_rate=%lu\n", tin_rate); + dev_dbg(pwmchip_parent(chip), "tin_rate=%lu\n", tin_rate); tin_ns = NSEC_PER_SEC / tin_rate; tcnt = period_ns / tin_ns; @@ -356,7 +356,7 @@ static int __pwm_samsung_config(struct pwm_chip *chip, struct pwm_device *pwm, /* -1UL will give 100% duty. */ --tcmp; - dev_dbg(chip->dev, "tin_ns=%u, tcmp=%u/%u\n", tin_ns, tcmp, tcnt); + dev_dbg(pwmchip_parent(chip), "tin_ns=%u, tcmp=%u/%u\n", tin_ns, tcmp, tcnt); /* Update PWM registers. */ writel(tcnt, our_chip->base + REG_TCNTB(pwm->hwpwm)); @@ -368,7 +368,7 @@ static int __pwm_samsung_config(struct pwm_chip *chip, struct pwm_device *pwm, * shortly afer this update (before it autoreloaded the new values). */ if (oldtcmp == (u32) -1) { - dev_dbg(chip->dev, "Forcing manual update"); + dev_dbg(pwmchip_parent(chip), "Forcing manual update"); pwm_samsung_manual_update(our_chip, pwm); } @@ -510,7 +510,7 @@ MODULE_DEVICE_TABLE(of, samsung_pwm_matches); static int pwm_samsung_parse_dt(struct pwm_chip *chip) { struct samsung_pwm_chip *our_chip = to_samsung_pwm_chip(chip); - struct device_node *np = chip->dev->of_node; + struct device_node *np = pwmchip_parent(chip)->of_node; const struct of_device_id *match; struct property *prop; const __be32 *cur; @@ -524,7 +524,7 @@ static int pwm_samsung_parse_dt(struct pwm_chip *chip) of_property_for_each_u32(np, "samsung,pwm-outputs", prop, cur, val) { if (val >= SAMSUNG_PWM_NUM) { - dev_err(chip->dev, + dev_err(pwmchip_parent(chip), "%s: invalid channel index in samsung,pwm-outputs property\n", __func__); continue; From patchwork Wed Feb 14 09:32:26 2024 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: 13556168 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 61527C48BC4 for ; Wed, 14 Feb 2024 09:39:19 +0000 (UTC) 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=kGl6BDW33kzyhERGbRtmFPBUpRwmp+0S6nQ7w/vPiSQ=; b=hzCNSfdtmPbCNq h6ZNpS7Hc/ZhFNRmG1KjpSH3z7Oul7n2PHqF947REDCbn5T/Yh6dm6w2zgsKn4Siwex2ppUselcA6 3ay3zM3wlVBMO6V4MFIVAyReJwhAghHdfNapYja5EL5xKHfQEJALnIKaaS2pWrhzDRX6crn0Qy95W fNijsEwPJWU5FkPM/hBDuZf1Ajk0XldAN4AvVF2Bi3Lj1c1o3h1rLwmypjwLA5qZIQHr3R01dqJKV vTvrgKPVMLadDKcyS6zAR+GGZ3t8UE9u4I4rEgycNCHgID/5ha2ZljCX5TNpg5fSZMmbCykhgA2OT IHLASuEeIFSi9OHn9qsw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBjO-0000000CNSm-0m3o; Wed, 14 Feb 2024 09:39:06 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfL-0000000CKfr-06ga for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:34:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=y91g4yI4rseGyKyD7ymZrjgxRrLB8caOVwuH2Bejqcc=; b=ha0P5sp63Ezcsi1TQgxoxcNhOg +7qQGTvJY9H3AS8ZRmI0a43srnhiQpgIOMbe2GFVp/5bwTRSRhXm0IT9cCMJbO1X99Q2VBEXH1PZj D6EIJLV9743G9yX7KlKXXtCpjw3UcDl/b1h7iyGFlPovXZEpmIgrYLWM74qlkWW6QGzMUdoE60pQU Peu2wCLtTYXMqHM/gwe6/OgaAP2phx0ycNOWEZWVRDD0BWrC+6puXC5HJBfYAKNSjcfndIugI+DqZ Axd6+Amqk3/wHaVapcLF6/KzvPA3DWsHyGkPq+BPXbyDOtKwhxA+6sunLphQ8ffdvp+ZGQmYVSsk4 jmACPejg==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfE-0000000GAXF-00GO for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:53 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf2-0005V0-5E; Wed, 14 Feb 2024 10:34:36 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBez-000fEs-3E; Wed, 14 Feb 2024 10:34:33 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBez-004Y6N-04; Wed, 14 Feb 2024 10:34:33 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Krzysztof Kozlowski , linux-pwm@vger.kernel.org Cc: Alim Akhtar , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH v6 099/164] pwm: samsung: Simplify by using devm functions in probe Date: Wed, 14 Feb 2024 10:32:26 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2301; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=3v6X/rsxer0vDPK7DKg5bXut2iQNblBHiv/m7ZhnHuY=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIi9JgUZ1qPpDDBkOWLudUXKLXy1s3CQlmeMd X1eK4wZ7P6JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIvQAKCRCPgPtYfRL+ TkDECACOQhL3yH4vO+rA5qPmJEOOHzv6MLKcO3Cvdj6aq+DSb+1yq9+x16z5AuhgyzgFUmopefY DAnN7FxMHjLrX+KCzhiBhErdQkB4CM8Qr1jmLq/4914ZQ/USoTzx00oI112ko5qPHbJkMku0KzW LY6w40l5kgP4WL8voUyTrnF6sR1lYgftUaG7HmPxA1CEv+q6iGBMN5EyLezxjIyaVYlETWZ8m4S odZMZEN+bgvH6qt9njfe1Kuu1UOkd5iP+KnMNSo5mWNZYGwXQSjd4HRzUgSVFXr2484m5alH+iS tmhQVfVvAPgmBG9OGQNIzT1vjd6YKDI10vL92/Ip3Pfe0d2V X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093448_696522_74E31C48 X-CRM114-Status: GOOD ( 14.54 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org With using devm_clk_get_enabled() and devm_pwmchip_add() the .remove_new() callback can be dropped and an error path in .probe() simplified. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-samsung.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c index cabdcdf37ec9..81a2e66e927e 100644 --- a/drivers/pwm/pwm-samsung.c +++ b/drivers/pwm/pwm-samsung.c @@ -577,18 +577,12 @@ static int pwm_samsung_probe(struct platform_device *pdev) if (IS_ERR(our_chip->base)) return PTR_ERR(our_chip->base); - our_chip->base_clk = devm_clk_get(&pdev->dev, "timers"); + our_chip->base_clk = devm_clk_get_enabled(&pdev->dev, "timers"); if (IS_ERR(our_chip->base_clk)) { dev_err(dev, "failed to get timer base clk\n"); return PTR_ERR(our_chip->base_clk); } - ret = clk_prepare_enable(our_chip->base_clk); - if (ret < 0) { - dev_err(dev, "failed to enable base clock\n"); - return ret; - } - for (chan = 0; chan < SAMSUNG_PWM_NUM; ++chan) if (our_chip->variant.output_mask & BIT(chan)) pwm_samsung_set_invert(our_chip, chan, true); @@ -599,10 +593,9 @@ static int pwm_samsung_probe(struct platform_device *pdev) platform_set_drvdata(pdev, chip); - ret = pwmchip_add(chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) { dev_err(dev, "failed to register PWM chip\n"); - clk_disable_unprepare(our_chip->base_clk); return ret; } @@ -614,16 +607,6 @@ static int pwm_samsung_probe(struct platform_device *pdev) return 0; } -static void pwm_samsung_remove(struct platform_device *pdev) -{ - struct pwm_chip *chip = platform_get_drvdata(pdev); - struct samsung_pwm_chip *our_chip = to_samsung_pwm_chip(chip); - - pwmchip_remove(chip); - - clk_disable_unprepare(our_chip->base_clk); -} - static int pwm_samsung_resume(struct device *dev) { struct pwm_chip *chip = dev_get_drvdata(dev); @@ -666,7 +649,6 @@ static struct platform_driver pwm_samsung_driver = { .of_match_table = of_match_ptr(samsung_pwm_matches), }, .probe = pwm_samsung_probe, - .remove_new = pwm_samsung_remove, }; module_platform_driver(pwm_samsung_driver); From patchwork Wed Feb 14 09:32:27 2024 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: 13556176 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9B66AC48BC4 for ; Wed, 14 Feb 2024 09:39:31 +0000 (UTC) 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=VmxxEt2P16HKl2bLtgleyETD8pey44jE4O8ZdBmOmqo=; b=BCiy0+kFfe3sV3 Jf/9D9p2F0xzr9NlTnvypuWts1K3g2TmrFPee5272w+zciZ99loZy3SIkEspIGaAhMqI82cilkbD/ HOWvAi6defHbt5zqx7dLvnyPLov6kGh8Pc62t6WSdsYMJ5tg9VNbwJHMI0SmBuS/nHAw0U81wVyoL VTuLHYQcO/XRk4aHuYtELHckD0cw0hY6TR/tdXA+u1w3NAx+bperBMDpC+oagyJRbstTINCU+sGYf sZcbsftQGAwJih3MFqFT1I9xCuKinedhljh0lsGMPXGk3aeI2Zau8fpKHFjaCvCPwX31l5J/auSUF UeZDTImxND9cteNE4HTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBjX-0000000CNYa-02hZ; Wed, 14 Feb 2024 09:39:15 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfP-0000000CKkL-3cUq for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:34:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=RDFkRMbFbMpJimums6TUBPxNmUEcesgpLuxKVjPrY4s=; b=qqf947EusOzGCBZSUjlnSv/IVm 4pfR0k2kXdcuDefAFxPhhvUSdft6smCye9to7AncNYvn0rHrz4EMMd3/ze/SKSuUZo35ZjpnV1rbi O9ts09ETjyINNTuUbrcK4d23Jxoz+mWMNXQ8YYGWvFf6WSOqj9ZcgXF+fUm5ZvMcuVZ63mq1roDhj vjCvVzitj9bAVTWMZtiV3igjnEk0UIOQdIO4yZhnlA0pplt8cqnt+S4y6RO2xdy6/GFvtzu2er5H3 JmCKVT9IexTXQnqih98HTcoGKoAig4LDrQy8ZMJqEGnqHDpo0ysKyp8u4xK5LTpjSJ2vZtaGNQWN0 JVnHDnHw==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfE-0000000GAXL-22mN for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:58 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf3-0005W0-9f; Wed, 14 Feb 2024 10:34:37 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBez-000fEx-7y; Wed, 14 Feb 2024 10:34:33 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBez-004Y6R-0Y; Wed, 14 Feb 2024 10:34:33 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Krzysztof Kozlowski , linux-pwm@vger.kernel.org Cc: Alim Akhtar , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH v6 100/164] pwm: samsung: Simplify using dev_err_probe() Date: Wed, 14 Feb 2024 10:32:27 +0100 Message-ID: <27a55fc05eb13802c9eddc600d0460e279388999.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1964; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=mRVaVzxOuHc8/iADtJONL+ijTkKUJ56s+MALA1iYH+A=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIi+D0n05TAovcPWo0WShbw+vCNK1F8jTDUqD VLx1zSxmbiJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIvgAKCRCPgPtYfRL+ TpCFB/0WucM+81bYSS61dW50ExWjOJcYGSvOPnQh86vjDP2FsfAuR6/MnBbxOuWV1aQgw4UGKTO JhdTTmA3lyMwhIqjQhFy1j9XUmAYP2DA41As7r96QCRauDEZ4ZHvneHWID/YgNIhsYhKC5AiPWW HoxKRcFryR23chuKQ4KvbMx9oQE7KKbd6J97dhEwHn16DdHN+BgZEbNqnxMlxV7JHekTJFZBO0h B8MYZDYDFa86cQX8HkHIERN/2EKeFeF75yXmrEMSOSr5PKDx776N3D654B7j9fg8b2euxdPNMAD CoI/fmjmjjlQPJfX8Hyx5UyIJAJiG5XPqfXh72tvt046zXen X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093449_023450_953E0906 X-CRM114-Status: GOOD ( 12.73 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org dev_err_probe() simplifies and improves the idiom "emit error message + return error code". Apply it accordingly. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-samsung.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c index 81a2e66e927e..d3dc9b5b80d6 100644 --- a/drivers/pwm/pwm-samsung.c +++ b/drivers/pwm/pwm-samsung.c @@ -564,10 +564,9 @@ static int pwm_samsung_probe(struct platform_device *pdev) if (ret) return ret; } else { - if (!pdev->dev.platform_data) { - dev_err(&pdev->dev, "no platform data specified\n"); - return -EINVAL; - } + if (!pdev->dev.platform_data) + return dev_err_probe(&pdev->dev, -EINVAL, + "no platform data specified\n"); memcpy(&our_chip->variant, pdev->dev.platform_data, sizeof(our_chip->variant)); @@ -578,10 +577,9 @@ static int pwm_samsung_probe(struct platform_device *pdev) return PTR_ERR(our_chip->base); our_chip->base_clk = devm_clk_get_enabled(&pdev->dev, "timers"); - if (IS_ERR(our_chip->base_clk)) { - dev_err(dev, "failed to get timer base clk\n"); - return PTR_ERR(our_chip->base_clk); - } + if (IS_ERR(our_chip->base_clk)) + return dev_err_probe(dev, PTR_ERR(our_chip->base_clk), + "failed to get timer base clk\n"); for (chan = 0; chan < SAMSUNG_PWM_NUM; ++chan) if (our_chip->variant.output_mask & BIT(chan)) @@ -594,10 +592,8 @@ static int pwm_samsung_probe(struct platform_device *pdev) platform_set_drvdata(pdev, chip); ret = devm_pwmchip_add(&pdev->dev, chip); - if (ret < 0) { - dev_err(dev, "failed to register PWM chip\n"); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, "failed to register PWM chip\n"); dev_dbg(dev, "base_clk at %lu, tclk0 at %lu, tclk1 at %lu\n", clk_get_rate(our_chip->base_clk), From patchwork Wed Feb 14 09:32:28 2024 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: 13556197 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7511EC48BEB for ; Wed, 14 Feb 2024 09:39:51 +0000 (UTC) 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=ba8l98zKxUE4yuk0xWBID5D9soHUYx0Dvt8ijamq4rk=; b=WbJSppxqz/ERYR iSDkxnEVjrLzoo8WqDiSRJQGDBRztNGZA3MBRkzDO2JaiAMge15SJVAL3KCrWTkSN5A4lZyvIPiCy rK1vq+Q8qaih724spEmhOFpJh8DGmOYrK8tG4u3UnDimxoWi6HWd7l8rCLRgXArF8giYjFD8mGYtZ 4k1T/WubHeTh4Nxchdi6znF+NGDa2L7E5LLiV5Z2T7E3ILX/Hx4DVlBCqxcfo6szmMskDQETmt3xX D8ekiOsXRhTEzMaeVtteFGfiuQhGxu/l4mEQMDhE2sp4DbdatXb6ppMapGvGT2dbrf26GdZDXXVri Na8xC3vIMWdDKNObTNWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBjt-0000000CNvO-2Cbq; Wed, 14 Feb 2024 09:39:37 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfW-0000000CKuL-1kYK for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=4Y9wguz1rEYWXMAPI+RD8FD3INg1KWlyLC5Z+IETRHM=; b=g3FQFKs6e7fNd3+NeK8X+3zUv1 jr+sVPSpRVZ2B2y0PeJXH8J/mv1F9mGVBrxr+lrq9yHNJNIQBXRo7NFRF5j5KhdCsH4sxEW27U8RF /TmDtt6D9Y9elLrsaKcrws4rdyj0uzDPi7igiXoUwmf0YRm9Rj0kiKt42ka2L6ir2b8OFF4vIpSxm SVS+uZWlLB4DcgOYbIFXJKclaNskTUA3o08P1VwNAPDLXDBbq0p4snok+6+mBPO+KRnwqsaNEUHkU 0EMBIBYVu+Lqd9R25dOZrrGzGF+yW7Ra75eMR3bA6K6igLYepfcclcTaGsnDVwryUMUrnXEUdK0AR W7RcHHAA==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfD-0000000GAXB-3pkO for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:02 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf2-0005X3-Ha; Wed, 14 Feb 2024 10:34:36 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBez-000fF1-DI; Wed, 14 Feb 2024 10:34:33 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBez-004Y6f-14; Wed, 14 Feb 2024 10:34:33 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Krzysztof Kozlowski , linux-pwm@vger.kernel.org Cc: Alim Akhtar , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH v6 101/164] pwm: samsung: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:32:28 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2108; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=L2fP/40Abfd2uvbzxxaCl1aJUDUo3oBsL6xZcwUm+2w=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIi/e7UAi6YnGdZM63g1kB7xY5zzYA/9MCiLs qcEG9PGLFWJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIvwAKCRCPgPtYfRL+ Tt6uCACPyWp3rurpxUbYuN/g8JHDaC1Vl08KyFrb62bjxltlTf/39f706K/2jtSvH9JJmOWQY9s d/JbO2xwE/+kQgdAzHRq7cKgd35llxalGb9EnnjjF5uCVisi8lvyxDCoEh2u0gZLDZN1MyAC9mZ tdPWltTiSjjusA9CTvaqlifwLrbMYLFHYDY9r6fxa2EfuuYMKHEe5B3cSL6KJrxtyC4d1+YKg37 bJtZikaRpPZlgoOX9T1gL6SZ1sWJDgCMFwH0FJbn8zEADmgfyI1VpRnSRP8h+z6HBIhgW5tFKt5 OmKJ6Z+n8ySR2wSqYp0mElum6sud+xIHBMQE6/fqrog4XPo4 X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093448_555525_61BEE537 X-CRM114-Status: GOOD ( 14.33 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-samsung driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-samsung.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c index d3dc9b5b80d6..efb60c9f0cb3 100644 --- a/drivers/pwm/pwm-samsung.c +++ b/drivers/pwm/pwm-samsung.c @@ -69,7 +69,6 @@ struct samsung_pwm_channel { /** * struct samsung_pwm_chip - private data of PWM chip - * @chip: generic PWM chip * @variant: local copy of hardware variant data * @inverter_mask: inverter status for all channels - one bit per channel * @disabled_mask: disabled status for all channels - one bit per channel @@ -80,7 +79,6 @@ struct samsung_pwm_channel { * @channel: per channel driver data */ struct samsung_pwm_chip { - struct pwm_chip chip; struct samsung_pwm_variant variant; u8 inverter_mask; u8 disabled_mask; @@ -110,7 +108,7 @@ static DEFINE_SPINLOCK(samsung_pwm_lock); static inline struct samsung_pwm_chip *to_samsung_pwm_chip(struct pwm_chip *chip) { - return container_of(chip, struct samsung_pwm_chip, chip); + return pwmchip_get_drvdata(chip); } static inline unsigned int to_tcon_channel(unsigned int channel) @@ -549,14 +547,12 @@ static int pwm_samsung_probe(struct platform_device *pdev) unsigned int chan; int ret; - our_chip = devm_kzalloc(&pdev->dev, sizeof(*our_chip), GFP_KERNEL); - if (our_chip == NULL) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, SAMSUNG_PWM_NUM, sizeof(*our_chip)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + our_chip = to_samsung_pwm_chip(chip); - chip = &our_chip->chip; - chip->dev = &pdev->dev; chip->ops = &pwm_samsung_ops; - chip->npwm = SAMSUNG_PWM_NUM; our_chip->inverter_mask = BIT(SAMSUNG_PWM_NUM) - 1; if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) { From patchwork Wed Feb 14 09:32:40 2024 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: 13556209 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 82E6FC48BC4 for ; Wed, 14 Feb 2024 09:41:48 +0000 (UTC) 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=l+rzkrjWcxJWecwJjfJE3ZZFN1w/ZMxNcEPZeTFqRWM=; b=h9VsWUxNVd/5uE 1Gn9YfupH9EwDWKcx3RdK/qYt3gJVaTPNg5GufxgqSbQc0REgBJ7Lh6XSMHhl1DJIz4nwICTaOx9i prpyKTQJlIrZbK1IX9ye1wkHNDil4abUWhi6MtteczOCSmqg387C3aTRVmTbXEzZ8bDCPKn2gcQk8 /ZL6wpjibMiXn+vp/PZXLEcV8ZfZLTzcYGi/+ugfJ9hiM1P6KxfHIfDPLipNKnh5o+qon0wStxaSR 4Lxplgztd5PAU/Zxyud5viOY1QqTjGYuTkapEuWHsq4PQ+BYDps5qyL4PaGgpBEXY5PMsTEkyEFeh gT3ugXPMGB1VQ9Wbs2Lg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBlj-0000000CPQY-40nM; Wed, 14 Feb 2024 09:41:31 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfB-0000000CKVK-1tgj for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:51 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf5-0005ik-3n; Wed, 14 Feb 2024 10:34:39 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf1-000fFi-8S; Wed, 14 Feb 2024 10:34:35 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf1-004Y7R-0a; Wed, 14 Feb 2024 10:34:35 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Fabrice Gasnier , Maxime Coquelin , Alexandre Torgue , linux-pwm@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 113/164] pwm: stm32: Simplify code to determine the pwmchip's parent device Date: Wed, 14 Feb 2024 10:32:40 +0100 Message-ID: <54ace92a3c02d22f15a79c7ecf00c29f28386a33.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=872; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=bZTsW8lAwjzlND0LcwKPlCEPg8gdCtmlWf6i463Sq1k=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjN2bCo4elWQTi51iNbI+Kc+Jt2OcDstTYJh EROUhArW/6JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIzQAKCRCPgPtYfRL+ TtuFB/0VadLMWhIrTIg38YKPDtgTBx6Tn4VV33yfCIaelHzLHNHL6Cu3b76q6dbMT+sXHYNaOL9 IxrLgjvVR51f+/yumbGQesuyBlJ4wqZknMLGmdSiHcLlrKsprfrovyVcD8Ckf861FWYmNf8p+4D 3e+RNxtmM/3fAs+1dQxqyMi6tlUxJtt7ozjR/7GLp7+tpv4XD0cbxT9tUuHvV2zf+sObWcmV8jA vriK8BShqzzJs2zZW4LSq8wxMvh4b3VOhaSMsKUfI8HU+R3Pskjvw8Hz3cjPhxaw8PCJ2AHQV+S pPS1nsPMXGiwJ/EOgR2rLGzZvmKsRsQCFNKPjUqAIYFOj3Fh X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013445_864563_131C878B X-CRM114-Status: GOOD ( 13.40 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There is already a pointer to the pwmchip, make use of it directly instead of using the struct stm32_pwm *priv just obtained from it. This also has the advantage of not using struct stm32_pwm::chip any more which will be dropped soon. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-stm32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c index 5f10cba492ec..202114c00ad3 100644 --- a/drivers/pwm/pwm-stm32.c +++ b/drivers/pwm/pwm-stm32.c @@ -170,7 +170,7 @@ static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm, ret = clk_enable(priv->clk); if (ret) { - dev_err(priv->chip.dev, "failed to enable counter clock\n"); + dev_err(chip->dev, "failed to enable counter clock\n"); goto unlock; } From patchwork Wed Feb 14 09:32:41 2024 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: 13556169 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2440FC48BEC for ; Wed, 14 Feb 2024 09:39:20 +0000 (UTC) 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=OpEAbqIpXtR/9foHwEhpulXj1h1VS82t8JHXQvnznhI=; b=qEfHAVwMf8pIfB rOX4AAoK5bEoa38nmm3Cs8sa263BAGDZOORZ5KAywzaiAbTw7emiwzRD+ZAFaCBxyqm/FGevEAlN2 vfcmJN6UqOdbTG9OM7+aYkC7rhuL7IyStX/tF2xMhq3oNleLkKpQ+sX1t6pxgMT06pqu7QiCQFyEc uSrPyiWCNaqqCNKDxvr1DoFaFdl/skijPsG6Lhn1n2V10QbBFq+vnbrJr1Uql5rUXkdojMfX91k2y 7wJ+5KgtX5yP9sHU0Ii3lM78yOBdOAkpgOCCpL/hWTxl0hCvi1o3VUITL76xNaCxwhO0UZW102wNI G7tEfKVold6kUCgs9YJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBjQ-0000000CNTy-3znR; Wed, 14 Feb 2024 09:39:08 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfM-0000000CKhZ-2s5b for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:34:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=PqZePcoM/DDHqOJc9Du3h/04VGrW5erzkVV2Rmz14E4=; b=IZ+boRpW4GGLIGpvr2L9rcfa9k isPhVrLSWTGuSJtIvi1+nVE10ASxB7JmvffBfjzzh5hxJy3udIQce8LR9ouHRsV8v5GAPprclUtuv mi9MTOhuPvAp6vUAz/RnUmaukd3PUiThxPiJV3mCgJuX+MjJk3K16y872HtFfd6zdI6yJhZMUW+f+ T0U1X5wOU9jmrO3SqWcICU3ojgSSjhMztqcsKwqrcX8DvgEdS2Cl6cylqW2A7vrGWhTnEszjMRL4P Tfk6aOpPi4z8hOB0NcHNsIQdy5p2Q37TW/WwMORcD3kRYx+CZYjvSukU8KZebNMeD0rRiXNxDYAPO VpEQ9sAA==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfE-0000000GAXR-22jh for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:55 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf4-0005jX-9X; Wed, 14 Feb 2024 10:34:38 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf1-000fFl-Cn; Wed, 14 Feb 2024 10:34:35 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf1-004Y7U-11; Wed, 14 Feb 2024 10:34:35 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Fabrice Gasnier , Maxime Coquelin , Alexandre Torgue , linux-pwm@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 114/164] pwm: stm32: Change prototype of a helper to prepare further changes Date: Wed, 14 Feb 2024 10:32:41 +0100 Message-ID: <33790c64563cb0434d7156d96f189c6037b3eb0b.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2549; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=14MfV+FXrX/aTvW2MLXTLmHT0CglDRMiyFAOzxxibSU=; b=owGbwMvMwMXY3/A7olbonx/jabUkhtQzHecu1gXPzzUPOtNe/yIl7YvfP489k+6fn3urYYJ15 ESPbguGTkZjFgZGLgZZMUUW+8Y1mVZVcpGda/9dhhnEygQyhYGLUwAmUriJ/Z9N2r1LBXrmkyQM XoRdENM9Kjy188Bit1n3zZVObvRhm2/68MHk31tj926Qe9z0b6PvhpbIU1nqhUbKViveypS5sXc nTlLfuEN01hQNzrDl4Qa1TpI86v0Xc7YcaLnxqtZYcYuqzbTPsd7vLU6+kfx5LtW4qeRi2/kGQ6 dAoQg32yrpKdKcBzIfTSlPNOy/PYsvkE+2NE38FqdxTPMR5rO5JrMcFpQp9DtV/5aQf/XzRHxsK e9d67jy3++a37z9kj9zeofR+8eik+asVTTolJzX+ZLN9r5al1jTAUVfva/FhS4nWlLUJIPjmz/Z MFfERWwqeiAhto/hIWO1A9uE0P5nTPxv8v6VeVjyrD0NAA== X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093448_876299_30998A55 X-CRM114-Status: GOOD ( 13.41 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the driver for further changes that will make it harder to determine the pwm_chip from a given stm32_pwm. To just not have to do that, rework stm32_pwm_raw_capture() to take a pwm_chip. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-stm32.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c index 202114c00ad3..ec15bc51d930 100644 --- a/drivers/pwm/pwm-stm32.c +++ b/drivers/pwm/pwm-stm32.c @@ -90,11 +90,12 @@ static u32 active_channels(struct stm32_pwm *dev) * - Period = t2 - t0 * - Duty cycle = t1 - t0 */ -static int stm32_pwm_raw_capture(struct stm32_pwm *priv, struct pwm_device *pwm, +static int stm32_pwm_raw_capture(struct pwm_chip *chip, struct pwm_device *pwm, unsigned long tmo_ms, u32 *raw_prd, u32 *raw_dty) { - struct device *parent = priv->chip.dev->parent; + struct stm32_pwm *priv = to_stm32_pwm_dev(chip); + struct device *parent = pwmchip_parent(chip)->parent; enum stm32_timers_dmas dma_id; u32 ccen, ccr; int ret; @@ -170,7 +171,7 @@ static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm, ret = clk_enable(priv->clk); if (ret) { - dev_err(chip->dev, "failed to enable counter clock\n"); + dev_err(pwmchip_parent(chip), "failed to enable counter clock\n"); goto unlock; } @@ -208,7 +209,7 @@ static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm, TIM_CCER_CC12P : TIM_CCER_CC34P, pwm->hwpwm < 2 ? TIM_CCER_CC2P : TIM_CCER_CC4P); - ret = stm32_pwm_raw_capture(priv, pwm, tmo_ms, &raw_prd, &raw_dty); + ret = stm32_pwm_raw_capture(chip, pwm, tmo_ms, &raw_prd, &raw_dty); if (ret) goto stop; @@ -229,7 +230,7 @@ static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm, /* 2nd measure with new scale */ psc /= scale; regmap_write(priv->regmap, TIM_PSC, psc); - ret = stm32_pwm_raw_capture(priv, pwm, tmo_ms, &raw_prd, + ret = stm32_pwm_raw_capture(chip, pwm, tmo_ms, &raw_prd, &raw_dty); if (ret) goto stop; @@ -257,7 +258,7 @@ static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm, FIELD_PREP(TIM_CCMR_IC1PSC, icpsc) | FIELD_PREP(TIM_CCMR_IC2PSC, icpsc)); - ret = stm32_pwm_raw_capture(priv, pwm, tmo_ms, &raw_prd, &raw_dty); + ret = stm32_pwm_raw_capture(chip, pwm, tmo_ms, &raw_prd, &raw_dty); if (ret) goto stop; From patchwork Wed Feb 14 09:32:42 2024 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: 13556212 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 5719FC48BC4 for ; Wed, 14 Feb 2024 09:41:56 +0000 (UTC) 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=WgauqpzuUdYQaesTO71Z9HOJyPVTuWvkldYhhaZLEzg=; b=bayA7NRZl8f0iR jBjJOnXLw7Qb8LMqO1vUzL79gm31fo8mKcggq6GPLVPbbYcoXwmtEstnrMOZ24b6Y46BW1SaSVc2B 3qOKgeyDZ2hUYN8MI9E6DqnlvPTiIdsbfJkZWJ+x+g4AG+jPi5HYyBTsQamUV482Zakg3EwMGesMt aQNEO0gmaJbw9YHfH8B6KIvTQ+/UyNf+NcqDrcYsruE76+MuS9GtL3un6rOtdqvVd9cQE/s1Kv7hE O7VnLMPHmFo8iC5aMftorA2y2DjEzSd5ua2pz2zxtNday9nQ1zfrZSFa+huPCHUi0IUeg3QxzQ5bp VhImLS9Lz53869ReilpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBlr-0000000CPTw-2M7G; Wed, 14 Feb 2024 09:41:39 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfd-0000000CKyF-0OBD for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=pE41sGOmkufr+x+YNrOMJsY2syO5U8IpxRdCrMVyTtA=; b=euwj2DU6TG2q9gG8aygnhMhFpX CAOneNEH6LHlcQdP7J056Rgur7+5sa1+4h1aRPpLcYBQknNS1AUV0Ber8a1nExc9wqXBmY3vVYTw8 nqnQLpWY5JCerqSt0TYWb4nX7+keUIETZhW9MvsjUqJTbwB76SwoYna6YIdK9zy5PE/lRyL+sj5zA KNcCNpRfvDPDp+BCm6zeVgjNoGE1RHCeNEG7g9LsDgVf0kqen3faEh/IrNPNPow2ga9KH5flO2dv0 sGjI2wiOeKE14NDHK1DcPmizvnOnwQ0gPVGURCliexEIsccamGkOlQx6a/UQAk7Lae0UpRHzTfHsd 2Tb0TyRQ==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfT-0000000GDlB-03vW for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:12 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf4-0005kE-MU; Wed, 14 Feb 2024 10:34:38 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf1-000fFr-Hl; Wed, 14 Feb 2024 10:34:35 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf1-004Y7Z-1W; Wed, 14 Feb 2024 10:34:35 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Fabrice Gasnier , Maxime Coquelin , Alexandre Torgue , linux-pwm@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 115/164] pwm: stm32: Prepare removing pwm_chip from driver data Date: Wed, 14 Feb 2024 10:32:42 +0100 Message-ID: <3db96cd915d9d8fc350a7193c0d55dd109b1f035.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2861; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=eAn5zF3jZjX3+BIQYFdyKESVmjjGkTa7aWulVHapXqA=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjPJCfNH6vyPPPC9avsKPPfP5Ivo6fJsl5ri EkWkZwDeV6JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIzwAKCRCPgPtYfRL+ Ti8FB/49TDgXTFVxzSGv2wqrXOht+HhTFwO/+fq5SwdAa1NB0Vd+V2oRnUPUNqnvITBnGNZYUTc 50nI/TKddrey92Dw2XIPUXF+vDUSFz5Uo9sA9P/9caEPlNu9V6mSEPqeO1g+XytuZd7GJwFxsRi 7Ju6Jl3g++puBlegdyWdLeoByphzx33an6HLAn4kTPAxlU8R8r/wxXkHzdHwWiZvCmB1/8LdIig 3PyedNiS58IZ0D4d05fpEnk8dreVHah7ZIChpazCSfvdbVO6E/19LUUM4eiLl+49QEd6fWpn+gj JHgpaBITWpsN1J6c6HRLgpSW1G1KgbWoXoU0f9sa0GmYvSoj X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093504_486530_AB4704F2 X-CRM114-Status: GOOD ( 13.85 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the driver for further changes that will drop struct pwm_chip chip from struct stm32_pwm. Use the pwm_chip as driver data instead of the stm32_pwm to get access to the pwm_chip in stm32_pwm_suspend() without using priv->chip. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-stm32.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c index ec15bc51d930..4d12f3d849cd 100644 --- a/drivers/pwm/pwm-stm32.c +++ b/drivers/pwm/pwm-stm32.c @@ -630,6 +630,7 @@ static int stm32_pwm_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; struct stm32_timers *ddata = dev_get_drvdata(pdev->dev.parent); + struct pwm_chip *chip; struct stm32_pwm *priv; unsigned int num_enabled; unsigned int i; @@ -638,6 +639,7 @@ static int stm32_pwm_probe(struct platform_device *pdev) priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; + chip = &priv->chip; mutex_init(&priv->lock); priv->regmap = ddata->regmap; @@ -653,37 +655,38 @@ static int stm32_pwm_probe(struct platform_device *pdev) stm32_pwm_detect_complementary(priv); - priv->chip.dev = dev; - priv->chip.ops = &stm32pwm_ops; - priv->chip.npwm = stm32_pwm_detect_channels(priv, &num_enabled); + chip->dev = dev; + chip->ops = &stm32pwm_ops; + chip->npwm = stm32_pwm_detect_channels(priv, &num_enabled); /* Initialize clock refcount to number of enabled PWM channels. */ for (i = 0; i < num_enabled; i++) clk_enable(priv->clk); - ret = devm_pwmchip_add(dev, &priv->chip); + ret = devm_pwmchip_add(dev, chip); if (ret < 0) return ret; - platform_set_drvdata(pdev, priv); + platform_set_drvdata(pdev, chip); return 0; } static int stm32_pwm_suspend(struct device *dev) { - struct stm32_pwm *priv = dev_get_drvdata(dev); + struct pwm_chip *chip = dev_get_drvdata(dev); + struct stm32_pwm *priv = to_stm32_pwm_dev(chip); unsigned int i; u32 ccer, mask; /* Look for active channels */ ccer = active_channels(priv); - for (i = 0; i < priv->chip.npwm; i++) { + for (i = 0; i < chip->npwm; i++) { mask = TIM_CCER_CC1E << (i * 4); if (ccer & mask) { dev_err(dev, "PWM %u still in use by consumer %s\n", - i, priv->chip.pwms[i].label); + i, chip->pwms[i].label); return -EBUSY; } } @@ -693,7 +696,8 @@ static int stm32_pwm_suspend(struct device *dev) static int stm32_pwm_resume(struct device *dev) { - struct stm32_pwm *priv = dev_get_drvdata(dev); + struct pwm_chip *chip = dev_get_drvdata(dev); + struct stm32_pwm *priv = to_stm32_pwm_dev(chip); int ret; ret = pinctrl_pm_select_default_state(dev); From patchwork Wed Feb 14 09:32:43 2024 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: 13556166 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 16FC8C48BEC for ; Wed, 14 Feb 2024 09:39:18 +0000 (UTC) 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=UhDfcc0VdQ2zkc9VKVwOzcykbf0NOUb9/W9xmSeQqhU=; b=1MsqAARPx6bmW4 FRa4+1m1mnGroaxysGpELbJuxgo5kjdJASnU7FaaMqS1eclmMjegPD3Vzm2s/rPHRuq5FI3IJ0IR2 HcYLfQd39bLCXPWmJXbdnAvnGUnrR18NdctmP8pqYFcHF0DJGjUiW3B9oLCby5985R7Y/5lAtV6Dn xQ/ur2H6eZJwN8rq5bAvZkOwo1bdtMDpQwagQloFcY9uXdr9SQMYgsW90C1Cmd2aCzSOAzsyZwVzh 3QmqGuDETqBwR4mzEMoAaSBG9zDNstfu5Du8WijVlg7YjeXxBDy2zwftv00AhZTuHmltDFAS5Ce6S JNrqNguqBPOUHAURA58g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBjL-0000000CNRA-2xVb; Wed, 14 Feb 2024 09:39:03 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfB-0000000CKVW-2SuR for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:53 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf5-0005l0-Rd; Wed, 14 Feb 2024 10:34:39 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf1-000fFw-Mb; Wed, 14 Feb 2024 10:34:35 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf1-004Y7d-21; Wed, 14 Feb 2024 10:34:35 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Fabrice Gasnier , Maxime Coquelin , Alexandre Torgue , linux-pwm@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 116/164] pwm: stm32: Change prototype of helper that detects npwm to prepare further changes Date: Wed, 14 Feb 2024 10:32:43 +0100 Message-ID: <13d4d3e90a9ee1bcd04674dfdc16f242615b8320.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2044; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=Nqj6FSyujOBi7wIfnBl8B3HIO7dDpveM2SltQZnDbWY=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjQfHsVV8onHY9QV0koIOZtXKH407+kVXCpv bPYokUawpuJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI0AAKCRCPgPtYfRL+ TvlHB/sHWYVJuTH7ezXErU582vAbPrpDDl5W6dOrHDLFuwaT9xqM7asOC9r7Ovhq4CdW+sHPqoi 9rMYMaleFh0HISRlCUl4vjEaFuhCXC+B16ZwHsI4yK3rOM+VW5ipjS79p5o05XbKkJG+3f5jAXQ STpCrsfrAobJpKJxEjPSWq9WF77fqLKCe4i22O8TFlXQGyCqbt7hSxgTHPGVZrfzE6DXuK2/sDP uiBp6BRmmacs7EepJcxnrOMRXEFWX3CWB3ZNcd17IyclfLlN2XVCLN9eqDLt4urnqiqrxpKlqua wPl+tUxAwX+OELn9wXXDidzZ2JxCVv/DDZ90XcSHAltkbO+9 X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013445_981189_10599F36 X-CRM114-Status: GOOD ( 14.56 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When the stm32 pwm driver is converted to pwmchip_alloc(), the number of available PWM lines must be known before the driver private data can be allocated. So rework the helper function that determines this number to not take the driver private data struct as input parameter. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-stm32.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c index 4d12f3d849cd..1440b706ee57 100644 --- a/drivers/pwm/pwm-stm32.c +++ b/drivers/pwm/pwm-stm32.c @@ -606,7 +606,7 @@ static void stm32_pwm_detect_complementary(struct stm32_pwm *priv) priv->have_complementary_output = (ccer != 0); } -static unsigned int stm32_pwm_detect_channels(struct stm32_pwm *priv, +static unsigned int stm32_pwm_detect_channels(struct regmap *regmap, unsigned int *num_enabled) { u32 ccer, ccer_backup; @@ -615,10 +615,10 @@ static unsigned int stm32_pwm_detect_channels(struct stm32_pwm *priv, * If channels enable bits don't exist writing 1 will have no * effect so we can detect and count them. */ - regmap_read(priv->regmap, TIM_CCER, &ccer_backup); - regmap_set_bits(priv->regmap, TIM_CCER, TIM_CCER_CCXE); - regmap_read(priv->regmap, TIM_CCER, &ccer); - regmap_write(priv->regmap, TIM_CCER, ccer_backup); + regmap_read(regmap, TIM_CCER, &ccer_backup); + regmap_set_bits(regmap, TIM_CCER, TIM_CCER_CCXE); + regmap_read(regmap, TIM_CCER, &ccer); + regmap_write(regmap, TIM_CCER, ccer_backup); *num_enabled = hweight32(ccer_backup & TIM_CCER_CCXE); @@ -657,7 +657,7 @@ static int stm32_pwm_probe(struct platform_device *pdev) chip->dev = dev; chip->ops = &stm32pwm_ops; - chip->npwm = stm32_pwm_detect_channels(priv, &num_enabled); + chip->npwm = stm32_pwm_detect_channels(ddata->regmap, &num_enabled); /* Initialize clock refcount to number of enabled PWM channels. */ for (i = 0; i < num_enabled; i++) From patchwork Wed Feb 14 09:32:44 2024 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: 13556210 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7B719C48BEC for ; Wed, 14 Feb 2024 09:41:50 +0000 (UTC) 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=4sbVjWbRJrHfqlV6cjuGVdTv4Pvk470YcV+rnp+aDTE=; b=c5xjPO+e7hf/ew h5kMqEPiKot1Lc0KtZrsz57Q+E44zOzF/r30D3b+8ToamP0mqp9xoOP3zCfGz9wkUypeDqrurxhSe FOOI6zJRndqrXhflJey9AtCEX+RiNhHmzIDpgedds/jgzjhd3bermwhKAG8B1B/dQu5QK02V9gQP1 G7o+uIHfH6D/uBVziCFsZSDGxX0WcDxVYIi24Akk+x50p9KdkheyE7x19qcgGZ8xKvnbAFNv89unj gioIRu/kvVx7IM6WwNVvcqMmynJ6ewkIo/VKptFwOdIsi5OvrXpYbkg3pnlceDsM0dcGCceBQcn7B XB2mffKSsARyF7h/tY/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBlp-0000000CPT9-3qr4; Wed, 14 Feb 2024 09:41:37 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfc-0000000CKxf-1WXn for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=WMGtrrgp9CxLav1NK0/SfK+RJxkTjntNQJJwDIEQkUU=; b=E8vWUK8j865DkCPAF/rIy7t3i5 7NTyseo6u8OAdlpBDKLl9/+xJKH2nlgBpFWPCqxcub9j+WnDK7AqJ3v+nupuyfw1yu84JsNUjYZTJ 1zajFdmF/p5H336036Bo6icpIQy/njZg8q2cdQdB0e5E9sDeenpZvvqC5sIho9NrIVWxevQj0IeCQ C87O3DwDMciiTr4nSutkQRtEqB64caSQIv9jyru4jRVA/ChcrTUgjv0Ia8EZ8Ma+qzfrMHcPS0sTF 6LHSS4mAh1NbM4DnsGtVhqFPXZuxQpO0AU7lMItpL/DGIA7lZYYEtppeYSGHmu9rKKte6qEf5c2uV KVfBsDFA==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfS-0000000GDlE-43wi for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:11 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf5-0005mH-Id; Wed, 14 Feb 2024 10:34:39 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf1-000fFz-TE; Wed, 14 Feb 2024 10:34:35 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf1-004Y7h-2c; Wed, 14 Feb 2024 10:34:35 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Fabrice Gasnier , Maxime Coquelin , Alexandre Torgue , linux-pwm@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 117/164] pwm: stm32: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:32:44 +0100 Message-ID: <59e5dfff2b878cc8590e286572672e4f10e35380.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2070; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=T/U7wQnCa/nBPtaaTnKA2tY72R4dDiZtK4LWdIBSJd4=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjRsLdl8HTUa9tf6qIs+zvnxTpj//AqG0X++ ldOrCB7T1eJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI0QAKCRCPgPtYfRL+ Tu6/B/477D5/A7oJB9f/BCRHZQWbXLL6oXepDfsU47gcf24GXzWckRUa2n8Rqdd/N4URAzUpcng QoWNKG5EiIW/stnDW/Fr9WxNS+3kZw4quDzkWcw+aosSTnstAtrM8uI1gQdxfEy6aWOuhuQnS0S X1xBRUp9v2dVbkizu0+a0AAOrbtrVgh2rMLKXiDWhTYbKz6xHdZnlnNf3HLdCXkpxK96WQWJeJ/ ozDH2tVMAE52haznrJX5TZ6pbjP/ScQoKzLEl2AjJfNXu6U7ma8ohFQa2H/l9Eu0mjDCN3jpiV1 eOORhbGtaT96LiRrSk8FkgoUtiZWGOArvSlrqsow37mhdCpm X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093504_512972_F744201A X-CRM114-Status: GOOD ( 12.94 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-stm32 driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-stm32.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c index 1440b706ee57..0c028d17c075 100644 --- a/drivers/pwm/pwm-stm32.c +++ b/drivers/pwm/pwm-stm32.c @@ -27,7 +27,6 @@ struct stm32_breakinput { }; struct stm32_pwm { - struct pwm_chip chip; struct mutex lock; /* protect pwm config/enable */ struct clk *clk; struct regmap *regmap; @@ -40,7 +39,7 @@ struct stm32_pwm { static inline struct stm32_pwm *to_stm32_pwm_dev(struct pwm_chip *chip) { - return container_of(chip, struct stm32_pwm, chip); + return pwmchip_get_drvdata(chip); } static u32 active_channels(struct stm32_pwm *dev) @@ -632,14 +631,16 @@ static int stm32_pwm_probe(struct platform_device *pdev) struct stm32_timers *ddata = dev_get_drvdata(pdev->dev.parent); struct pwm_chip *chip; struct stm32_pwm *priv; - unsigned int num_enabled; + unsigned int npwm, num_enabled; unsigned int i; int ret; - priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - chip = &priv->chip; + npwm = stm32_pwm_detect_channels(ddata->regmap, &num_enabled); + + chip = devm_pwmchip_alloc(dev, npwm, sizeof(*priv)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + priv = to_stm32_pwm_dev(chip); mutex_init(&priv->lock); priv->regmap = ddata->regmap; @@ -655,9 +656,7 @@ static int stm32_pwm_probe(struct platform_device *pdev) stm32_pwm_detect_complementary(priv); - chip->dev = dev; chip->ops = &stm32pwm_ops; - chip->npwm = stm32_pwm_detect_channels(ddata->regmap, &num_enabled); /* Initialize clock refcount to number of enabled PWM channels. */ for (i = 0; i < num_enabled; i++) From patchwork Wed Feb 14 09:32:45 2024 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: 13556172 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1A674C48BEC for ; Wed, 14 Feb 2024 09:39:24 +0000 (UTC) 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=h6B5wBbMfLNjIqkepv0TnCKk4Tsb1UWMAVPvWkzgAWA=; b=zQDWoXZF79SLE2 3mPw+PBwbFnX5Ro36a3bH0N3RycPb3MQbboXgtWrXLADB5i2QY0A4k2jIeXxWH0iOYihw4vVQwon+ CnvBOKi09QqxMIlQztxQgGFIJLrUOTwOdV9Eip37SaKi6fUlSqpUKvbG+kCaSZ46OLU9RbmIorDjF Q3ukQfX/ZrBPq3pO1vKEwauqtHXDt4E/hIh9LfDIcDAEA1+GZjC1PsL10Kz048L2rrt2StfFW8OVh sbSsmHF/ohRYv8IIrdro+luptTAt2KB1dll/IGGUXiBGoGY3goxwhwQLG1nuw2odfYA5fVysYO+0F /EWS94lRD3aH1POlja9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBjQ-0000000CNTf-161X; Wed, 14 Feb 2024 09:39:08 +0000 Received: from metis.whiteo.stw.pengutronix.de ([185.203.201.7]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfE-0000000CKYc-0SBK for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:56 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf5-0005n0-7f; Wed, 14 Feb 2024 10:34:39 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf2-000fG3-14; Wed, 14 Feb 2024 10:34:36 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf1-004Y7l-35; Wed, 14 Feb 2024 10:34:35 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Fabrice Gasnier , Maxime Coquelin , Alexandre Torgue , linux-pwm@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 118/164] pwm: stm32-lp: Simplify code to determine the pwmchip's parent device Date: Wed, 14 Feb 2024 10:32:45 +0100 Message-ID: <9ad2399e1a683a6344b12d7f70498393b8f8b9de.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1729; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=p17FPEGdt5iTjNuLV9ceuEp0unNUnbj7ddT/qbdQK6A=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjSiFzVxGz5R9cEYI7bUJyRiPKUR9CFsjkaW i4NRo0cchuJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI0gAKCRCPgPtYfRL+ Tt5yCACxBKnzZgWU3h2X0Pssz520fC4vS5n8IvUil7omtHL+QdVa1HqAdbHiMTefUpOE/lbprks 9OXdbLyHyS+AP3rtkm9pf6NY9qiwCju+j8WxGHcuIE7pxjlGqG14SIelfDF1boJKg6l2ojCdehb zJ7IfYpisafyoF8FIChFk1gzc/ONNfnNtvM/6nXQff6eJCbBGCCJ6xr/cA8PIRekYefwuYn6TsR PAvFL1Eh8cnPZadlN2AadmF7XYfpkVIOMOAqbmwXXV8sR+LsV/JQiZaq6/aO4myzasrgrwTEZqF O3XYnL0Xd+toiysEZWSScpaBTuzdmy2sGr79orItPwV+hTkj X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013448_420552_D22FE086 X-CRM114-Status: GOOD ( 13.25 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There is already a pointer to the pwmchip, make use of it directly instead of using the struct stm32_pwm_lp *priv just obtained from it. This also has the advantage of not using struct stm32_pwm_lp::chip any more which will be dropped soon. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-stm32-lp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pwm/pwm-stm32-lp.c b/drivers/pwm/pwm-stm32-lp.c index 439068f3eca1..bbab6be314a8 100644 --- a/drivers/pwm/pwm-stm32-lp.c +++ b/drivers/pwm/pwm-stm32-lp.c @@ -61,7 +61,7 @@ static int stm32_pwm_lp_apply(struct pwm_chip *chip, struct pwm_device *pwm, do_div(div, NSEC_PER_SEC); if (!div) { /* Clock is too slow to achieve requested period. */ - dev_dbg(priv->chip.dev, "Can't reach %llu ns\n", state->period); + dev_dbg(chip->dev, "Can't reach %llu ns\n", state->period); return -EINVAL; } @@ -69,7 +69,7 @@ static int stm32_pwm_lp_apply(struct pwm_chip *chip, struct pwm_device *pwm, while (div > STM32_LPTIM_MAX_ARR) { presc++; if ((1 << presc) > STM32_LPTIM_MAX_PRESCALER) { - dev_err(priv->chip.dev, "max prescaler exceeded\n"); + dev_err(chip->dev, "max prescaler exceeded\n"); return -EINVAL; } div = prd >> presc; @@ -130,7 +130,7 @@ static int stm32_pwm_lp_apply(struct pwm_chip *chip, struct pwm_device *pwm, (val & STM32_LPTIM_CMPOK_ARROK) == STM32_LPTIM_CMPOK_ARROK, 100, 1000); if (ret) { - dev_err(priv->chip.dev, "ARR/CMP registers write issue\n"); + dev_err(chip->dev, "ARR/CMP registers write issue\n"); goto err; } ret = regmap_write(priv->regmap, STM32_LPTIM_ICR, From patchwork Wed Feb 14 09:32:46 2024 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: 13556165 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C31B4C48BEB for ; Wed, 14 Feb 2024 09:39:15 +0000 (UTC) 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=V+thkesXqI0dA5OOVXHlFtrR1OqzOAQP4wTRFnDxIts=; b=Mym+qW333tsRaZ A/GQq9kxCamDC7whSy/jq8PBEuFlOiaitEC6Wv1PL8s6oyrgH/YvAOTaoj3UA1tY6CTuyE6UEdosE 6rNIZv1NfcDH9zwPAkafXPa1Vot/dYetf7KPczONZ05aFup0IRbJ/hTZNs0y751EK/BHpx0C56M4A M33QHgD3LBz0f7UvD05suoVQ+9OKoOaCCb449pAasbqVHkqZklgJqOMLgBnfXsfTMI/mMG45WL/rA 3l7GzfiTcJ/uqaztNSI6lO+Gxyc94OJLw5yLDPskCzsWEEn2mVYNAUW5Wn+TG9i/f2mXwi8/oKgvH vsiEDkXd2Dr8gzeAqusw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBjM-0000000CNRk-2Wx8; Wed, 14 Feb 2024 09:39:04 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfC-0000000CKVu-0WTG for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:54 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf5-0005nZ-SR; Wed, 14 Feb 2024 10:34:39 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf2-000fG6-57; Wed, 14 Feb 2024 10:34:36 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf2-004Y7p-0H; Wed, 14 Feb 2024 10:34:36 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Fabrice Gasnier , Maxime Coquelin , Alexandre Torgue , linux-pwm@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 119/164] pwm: stm32-lp: Prepare removing pwm_chip from driver data Date: Wed, 14 Feb 2024 10:32:46 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1932; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=DhwVfYK3PSVBUzZ2FBq5DeLipOrGjyXL7mQwfO9Ate8=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjTLu8CxBTkFi4qgs8ztGE1w3A0T1K4W9gN1 Cf6LJm4zEqJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI0wAKCRCPgPtYfRL+ TqylCACvPMxKFHFT15Jn4qEunBjFxMOoreUu6c1bQn0YeYAJE92+RJJrGaq/H5m8Y0oJXkRh2ah 0+tWpqd9Xo6AjXK/turnQ8KpIxTiPKZ0zIJBhKDCuXZ118TeLWjZ08AAvpm4FbtCyA3ehpVcQCr kLW4ZH/C1bcX15IpZ/LLZuiR8l9qokNWcYjWsQe76+6QxYDScfEBhbg2+tfsxN6YF2YAr6grLSK 2oqEdkFkyO9R4cYl+h5cdgo5vwWfA7SpxOEMAPQCY/Fp5RWPrxcXxIw41dr4+2twuCUAKnQD/BH zp1n2M7sNTgMEJrpoDvsmd429z1jC8PkbYGENujrDOBBC/hN X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013446_443720_5C17C2BA X-CRM114-Status: GOOD ( 13.86 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the driver for further changes that will drop struct pwm_chip chip from struct stm32_pwm_lp. Use the pwm_chip as driver data instead of the stm32_pwm_lp to get access to the pwm_chip in stm32_pwm_lp_suspend() without using priv->chip. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-stm32-lp.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/pwm/pwm-stm32-lp.c b/drivers/pwm/pwm-stm32-lp.c index bbab6be314a8..b46d8193dd0f 100644 --- a/drivers/pwm/pwm-stm32-lp.c +++ b/drivers/pwm/pwm-stm32-lp.c @@ -197,6 +197,7 @@ static int stm32_pwm_lp_probe(struct platform_device *pdev) { struct stm32_lptimer *ddata = dev_get_drvdata(pdev->dev.parent); struct stm32_pwm_lp *priv; + struct pwm_chip *chip; int ret; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); @@ -205,28 +206,29 @@ static int stm32_pwm_lp_probe(struct platform_device *pdev) priv->regmap = ddata->regmap; priv->clk = ddata->clk; - priv->chip.dev = &pdev->dev; - priv->chip.ops = &stm32_pwm_lp_ops; - priv->chip.npwm = 1; + chip = &priv->chip; + chip->dev = &pdev->dev; + chip->ops = &stm32_pwm_lp_ops; + chip->npwm = 1; - ret = devm_pwmchip_add(&pdev->dev, &priv->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) return ret; - platform_set_drvdata(pdev, priv); + platform_set_drvdata(pdev, chip); return 0; } static int stm32_pwm_lp_suspend(struct device *dev) { - struct stm32_pwm_lp *priv = dev_get_drvdata(dev); + struct pwm_chip *chip = dev_get_drvdata(dev); struct pwm_state state; - pwm_get_state(&priv->chip.pwms[0], &state); + pwm_get_state(&chip->pwms[0], &state); if (state.enabled) { dev_err(dev, "The consumer didn't stop us (%s)\n", - priv->chip.pwms[0].label); + chip->pwms[0].label); return -EBUSY; } From patchwork Wed Feb 14 09:32:47 2024 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: 13556198 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 52BF8C48BEB for ; Wed, 14 Feb 2024 09:40:03 +0000 (UTC) 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=IupsgOMjmSoiti/nFXhdHr4t4fFtYgYT3YbojlI4HUc=; b=a4yoIMrqfCQ0HQ N/cVLYfQK3SwIW7B4VYl4gGSurXaMlHS+OhJgLynr3ZZu5iyMaf7qdtxahI0/EKhwuKSQ/d68VykO 0t/lKEpWQvnYF5m3VYIqLxCuhFQtKHFXhN/3U3BiFXpHfv1KLs0nbFhl1dBqSO4E+i26LLpva65x6 4fM6Y4RNseHDfWwiGveivHfpyS0ydlXn75y0h8X3hkLiJxJSA9sjRyLXmlTyczJnPkttWw06Lvhjq FRUTKZ7JERFOSe/mRaYWOqffqgGkiGWmzW2+Gmt3rLJEQSFBzeoQLkEc3+C2NSBVMnfSh1DZVZ5Fu k+z7ouNXAzgSOaau1Yag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBk0-0000000CO21-1c1F; Wed, 14 Feb 2024 09:39:44 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfW-0000000CKuI-1fX1 for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=I5Sa0Cp5EoWdxhPFTRXRjFz3Jt1oQ0BJ9dHShIue2Eg=; b=DOFmptIOdMgRip/UrHwlh0E5oA MPvhmMqEabmUendBl8PVzR5Nf4AymQOiBgsHuRVGDyQoWv39BcC7xDZheSCbgWK6ugZIyaeKTsctY cvywQrYdsLm0zo72V2xXgJY8bc/Onl5WW6sj1yohdGJ7t8ar+v4n8hvdg+UdFIPTCS8kCGmziS7aZ l7p1gjWkcvTs72zdUZGai6Fdue/Eg8iiHp28PN8pYRULo+Aka3Z3oS6EvJqUFZNwW74fmLzY/Pn8e Ut+Qx9G2ejlurJMoQDD+GwtoAve8H04zySE6GzpwIA+z5vliFEfgo/PxUn4PIcG/EJeh5m98W9Jhg cA2iRIPA==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfG-0000000GAbn-1Ywa for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:02 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf6-0005oV-DH; Wed, 14 Feb 2024 10:34:40 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf2-000fGA-A6; Wed, 14 Feb 2024 10:34:36 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf2-004Y7t-0k; Wed, 14 Feb 2024 10:34:36 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Fabrice Gasnier , Maxime Coquelin , Alexandre Torgue , linux-pwm@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 120/164] pwm: stm32-lp: Make use of pwmchip_parent() accessor Date: Wed, 14 Feb 2024 10:32:47 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1684; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=JuNIuFD3c6qnif44oMxmUb/F4xNQLrQPLEXkRb5EGmU=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjVynmgDVimgALzofCoefgRqxjoLBMzDm0q4 BFybHUdSlKJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI1QAKCRCPgPtYfRL+ Thj0B/9IxCbgrkAdV5rjSFQDUYgZsFWWSrgYuSRJhnVLmxRbQ5kyeQtq18sDsG3cnfT9QHycDcF lGalFo47OkBmtNJrP5nqjMJGQurX5ud2ENkNSCbf2t2+ESWKaMmmc9jJeo6pWKp6GAWxKrxdqjW NGNoMg2jNk28RQLI8AGd7Bs/3hq8AOFfaSpRJ3CgnhtrXf/s9dMg0EMfKSg802+WGy53TndqA5k ZeocdsiUev4PMGe9fgY6hmfmUpULm3y8Um/N1i/biuXseuAuf0Z58QNreroE+YVBpsUcXi/Jvak G4i0YCbZr0HFNWlHbxXW27TdMIpIMm8IA555DwzvoYUB/NG2 X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093450_870905_5E1BC122 X-CRM114-Status: GOOD ( 12.84 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org struct pwm_chip::dev is about to change. To not have to touch this driver in the same commit as struct pwm_chip::dev, use the accessor function provided for exactly this purpose. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-stm32-lp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pwm/pwm-stm32-lp.c b/drivers/pwm/pwm-stm32-lp.c index b46d8193dd0f..958043bc5c92 100644 --- a/drivers/pwm/pwm-stm32-lp.c +++ b/drivers/pwm/pwm-stm32-lp.c @@ -61,7 +61,7 @@ static int stm32_pwm_lp_apply(struct pwm_chip *chip, struct pwm_device *pwm, do_div(div, NSEC_PER_SEC); if (!div) { /* Clock is too slow to achieve requested period. */ - dev_dbg(chip->dev, "Can't reach %llu ns\n", state->period); + dev_dbg(pwmchip_parent(chip), "Can't reach %llu ns\n", state->period); return -EINVAL; } @@ -69,7 +69,7 @@ static int stm32_pwm_lp_apply(struct pwm_chip *chip, struct pwm_device *pwm, while (div > STM32_LPTIM_MAX_ARR) { presc++; if ((1 << presc) > STM32_LPTIM_MAX_PRESCALER) { - dev_err(chip->dev, "max prescaler exceeded\n"); + dev_err(pwmchip_parent(chip), "max prescaler exceeded\n"); return -EINVAL; } div = prd >> presc; @@ -130,7 +130,7 @@ static int stm32_pwm_lp_apply(struct pwm_chip *chip, struct pwm_device *pwm, (val & STM32_LPTIM_CMPOK_ARROK) == STM32_LPTIM_CMPOK_ARROK, 100, 1000); if (ret) { - dev_err(chip->dev, "ARR/CMP registers write issue\n"); + dev_err(pwmchip_parent(chip), "ARR/CMP registers write issue\n"); goto err; } ret = regmap_write(priv->regmap, STM32_LPTIM_ICR, From patchwork Wed Feb 14 09:32:48 2024 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: 13556211 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D02BAC48BC4 for ; Wed, 14 Feb 2024 09:41:51 +0000 (UTC) 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=S7qYl4gx1pcMF/KbglHMAhENNiR0E2olEFXv+QeqEjk=; b=T5ONo8LMrEaoUN CLnASp2lLOAQpwabtGP3Z0TSBXJPODJ0OGod3Sh1jFHDidGI+UU872Hv28vs7K4q58Fd24iYUy22g hWyL09mAOGUfBd3ERYP9S5N4UYheynxEbYvf7m3uZMlR1osa1hF1yyTVP7Lvrly7Y6u6MXtSBk7b0 UMvgCMkbLA27ppEObmG0ByEHCaNm7f6UnfdxHUFr1k3LBByQIkgQEfccFTAfoIe2zYYgHIah+m1zl P9Rx6I1NKY/PGxH8K8CvSWao9gab1HsaMrrRMq9TmCuj1GmGOqJDrYFcodSwDUQCvu/MFWRWWECMh hPvIjTDQoD35QmeVKAUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBln-0000000CPSZ-3i1E; Wed, 14 Feb 2024 09:41:35 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfb-0000000CKxN-3vU9 for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=yVaC3Jg7NQ8KN5ypsdJ/VqqLvTUSdRvrq6OP7vHxKoo=; b=Wbxiuc1HCqGD97HnTmi1y8WH8g jfAjz/xRbtFJgeyTJTSOPzpjL4DZm2wbfL+Nf3LfWXOUhgbv6Qd+6/hlagZWCmNfY6J+kahhgTNzi jxmiGZFoQ0dcw/F39WrdRH3t186X98PQFMNFZ21WTPWf4uOdotZzDk7ryQ6Q7rPueCWr9Y330KD8n vy+V77vZD4Hb/QzlerxrWXbQwHgShsCsHGyGdMeBRMAsN1t4ww3K5qORKJN52xjvammNjfHBOVewL rbNpgFG/QHcLq5fW8ykNdJXZV/quet3U7rXnb9JcdVy5oSIKSiV38o1E9dqLQi+Jjrts96Ag21GsG F8SRFaig==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfS-0000000GDl4-3s8K for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:10 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf5-0005pL-H8; Wed, 14 Feb 2024 10:34:39 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf2-000fGD-FG; Wed, 14 Feb 2024 10:34:36 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf2-004Y7x-1G; Wed, 14 Feb 2024 10:34:36 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Fabrice Gasnier , Maxime Coquelin , Alexandre Torgue , linux-pwm@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 121/164] pwm: stm32-lp: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:32:48 +0100 Message-ID: <04af7b3d00bc932dd025200a3bf74527c29ca47a.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1583; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=wTHot0rCpWKiBWRtIdmgUzbIiXlsK2MsHRkggFr4Eu0=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjWfsROWMer2NPaGM8yPEtjhSeNg1XRlolg8 AWibishgfCJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI1gAKCRCPgPtYfRL+ TgWUB/4y5vvEIFNjKDCx+K+e0lnQAquLBXIOyrCvlRTM8vqRsMv7KoBhHJvLFg8qouNbV+kYFf5 1UB3e+nPKQf26XZrNHZxD9C2PliRnTkH8SghTrdTQ6Ch/up7RgLTJBDgYZcFxJkX81Hpg68FpQY uVw981KCUCJUR6ZWuF/Yx2SmpJ/9lm/RL2n6pBYIzJdOh4dtn+7MmHWSP5Y+5WDw170r7feOlYG tLwXdqBrA7ehW28wQN6bGwBpLj3XJXMC2MPMzdqQ9Xm0SAIB++IE8rqaj7gyTtP/auOd764igOR 2Z/68WgrXM9Asoo/a3v7Q6DUTYAmq35xWNRqK54Msj0C0IdS X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093504_410632_5732588E X-CRM114-Status: GOOD ( 12.29 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-stm32-lp driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-stm32-lp.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/pwm/pwm-stm32-lp.c b/drivers/pwm/pwm-stm32-lp.c index 958043bc5c92..989731256f50 100644 --- a/drivers/pwm/pwm-stm32-lp.c +++ b/drivers/pwm/pwm-stm32-lp.c @@ -18,14 +18,13 @@ #include struct stm32_pwm_lp { - struct pwm_chip chip; struct clk *clk; struct regmap *regmap; }; static inline struct stm32_pwm_lp *to_stm32_pwm_lp(struct pwm_chip *chip) { - return container_of(chip, struct stm32_pwm_lp, chip); + return pwmchip_get_drvdata(chip); } /* STM32 Low-Power Timer is preceded by a configurable power-of-2 prescaler */ @@ -200,16 +199,14 @@ static int stm32_pwm_lp_probe(struct platform_device *pdev) struct pwm_chip *chip; int ret; - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*priv)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + priv = to_stm32_pwm_lp(chip); priv->regmap = ddata->regmap; priv->clk = ddata->clk; - chip = &priv->chip; - chip->dev = &pdev->dev; chip->ops = &stm32_pwm_lp_ops; - chip->npwm = 1; ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) From patchwork Wed Feb 14 09:32:49 2024 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: 13556170 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 80D01C48BEF for ; Wed, 14 Feb 2024 09:39:21 +0000 (UTC) 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=i9FGd4HKEDpHeHBdFmhhLewzJqD2R06qII2HkXSHV0Y=; b=TngoZMVQkUuqey GROxNDe3mjuJ3GXjMvjxx0dvhKzELHLomqm9tzmdQJ0zvr88+ErJAiOm6GchaEJ9n9m7gL6YXSTwo dZY+K9PNtc0NsP2jeX6aruF1ZCYoMJ3hD/hjXp5F9XEeoYf1Aq60QQZr3SBjar6XcYbs+CESPb1ok /9Iu3qtSHNSYOCgzVmb3rhO8nCAcbJRptY3s0s9KxJ7xb4EBcqvFnj4kK5o5eioXzJUKhqRYieCo8 tjhxV9feUpLS/lWh+jrgq1sFmf5u/hMxPEto5ixgmZKyGX6yN9rYLtbT+nwFORVB0sDdcpl4MyvIT e2sGkQJn99+DExcGkLjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBjN-0000000CNSE-1Paa; Wed, 14 Feb 2024 09:39:05 +0000 Received: from metis.whiteo.stw.pengutronix.de ([185.203.201.7]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfB-0000000CKVa-3Vcy for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:54 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf6-0005qZ-A2; Wed, 14 Feb 2024 10:34:40 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf2-000fGG-MA; Wed, 14 Feb 2024 10:34:36 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf2-004Y81-1w; Wed, 14 Feb 2024 10:34:36 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Maxime Coquelin , Alexandre Torgue , linux-pwm@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 122/164] pwm: stmpe: Make use of pwmchip_parent() accessor Date: Wed, 14 Feb 2024 10:32:49 +0100 Message-ID: <2136fbdf9b1e6bac479b935b439e2be73a003b97.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3985; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=cPJzXrxLwHXkWiFEE4aAAFggyf8jdNMceE3IMNWt3kk=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjXCJ9N00hJ5kHRel0KLZY2ALPZt/f5igpYs LtLH5gMjUqJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI1wAKCRCPgPtYfRL+ TnyhB/wKHZSSeekGr0UMvENfpbAnautZgsAo1BwQTNoMwX5vhhZck7PmI5tqWRrAhAcNu2DFwfG SBVE7drsAZth4qfqroLyvLBDx2RJlKiXRRkrbHYo50ckqXLYvXUPosyYtbybLQd1jfF9PzGlYlW 3UEe9qYEkrNHXB8JRXZRmWAX/YLhdyzw9fH1JBWlNTmEyjjyc2XJzBi0CtSBD0tR4EGCeLP0Qp+ pakt74PsmDhIFwj4c6KzEtCxVy7BL/wGJ5bfKyrKYVe3IXfnpGCeUKyjQHx1tzhbVCvKJzUC8ot COPrrmYUldWV9LS50nSmXE3nF4XF2DBEAC9B4iITVr/fh7jB X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013446_267053_DC50AFC5 X-CRM114-Status: GOOD ( 13.35 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org struct pwm_chip::dev is about to change. To not have to touch this driver in the same commit as struct pwm_chip::dev, use the accessor function provided for exactly this purpose. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-stmpe.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/pwm/pwm-stmpe.c b/drivers/pwm/pwm-stmpe.c index 19c0c0f39675..05f3f38031ee 100644 --- a/drivers/pwm/pwm-stmpe.c +++ b/drivers/pwm/pwm-stmpe.c @@ -44,7 +44,7 @@ static int stmpe_24xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) ret = stmpe_reg_read(stmpe_pwm->stmpe, STMPE24XX_PWMCS); if (ret < 0) { - dev_dbg(chip->dev, "error reading PWM#%u control\n", + dev_dbg(pwmchip_parent(chip), "error reading PWM#%u control\n", pwm->hwpwm); return ret; } @@ -53,7 +53,7 @@ static int stmpe_24xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) ret = stmpe_reg_write(stmpe_pwm->stmpe, STMPE24XX_PWMCS, value); if (ret) { - dev_dbg(chip->dev, "error writing PWM#%u control\n", + dev_dbg(pwmchip_parent(chip), "error writing PWM#%u control\n", pwm->hwpwm); return ret; } @@ -70,7 +70,7 @@ static int stmpe_24xx_pwm_disable(struct pwm_chip *chip, ret = stmpe_reg_read(stmpe_pwm->stmpe, STMPE24XX_PWMCS); if (ret < 0) { - dev_dbg(chip->dev, "error reading PWM#%u control\n", + dev_dbg(pwmchip_parent(chip), "error reading PWM#%u control\n", pwm->hwpwm); return ret; } @@ -79,7 +79,7 @@ static int stmpe_24xx_pwm_disable(struct pwm_chip *chip, ret = stmpe_reg_write(stmpe_pwm->stmpe, STMPE24XX_PWMCS, value); if (ret) - dev_dbg(chip->dev, "error writing PWM#%u control\n", + dev_dbg(pwmchip_parent(chip), "error writing PWM#%u control\n", pwm->hwpwm); return ret; } @@ -125,7 +125,7 @@ static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, ret = stmpe_set_altfunc(stmpe_pwm->stmpe, BIT(pin), STMPE_BLOCK_PWM); if (ret) { - dev_err(chip->dev, "unable to connect PWM#%u to pin\n", + dev_err(pwmchip_parent(chip), "unable to connect PWM#%u to pin\n", pwm->hwpwm); return ret; } @@ -150,7 +150,7 @@ static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, return -ENODEV; } - dev_dbg(chip->dev, "PWM#%u: config duty %d ns, period %d ns\n", + dev_dbg(pwmchip_parent(chip), "PWM#%u: config duty %d ns, period %d ns\n", pwm->hwpwm, duty_ns, period_ns); if (duty_ns == 0) { @@ -216,7 +216,7 @@ static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, program[1] = BRANCH; } - dev_dbg(chip->dev, + dev_dbg(pwmchip_parent(chip), "PWM#%u: value = %02x, last_duty = %02x, program=%04x,%04x,%04x\n", pwm->hwpwm, value, last, program[0], program[1], program[2]); @@ -233,7 +233,7 @@ static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, ret = stmpe_reg_write(stmpe_pwm->stmpe, offset, value); if (ret) { - dev_dbg(chip->dev, "error writing register %02x: %d\n", + dev_dbg(pwmchip_parent(chip), "error writing register %02x: %d\n", offset, ret); return ret; } @@ -242,7 +242,7 @@ static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, ret = stmpe_reg_write(stmpe_pwm->stmpe, offset, value); if (ret) { - dev_dbg(chip->dev, "error writing register %02x: %d\n", + dev_dbg(pwmchip_parent(chip), "error writing register %02x: %d\n", offset, ret); return ret; } @@ -255,7 +255,7 @@ static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, /* Sleep for 200ms so we're sure it will take effect */ msleep(200); - dev_dbg(chip->dev, "programmed PWM#%u, %u bytes\n", pwm->hwpwm, i); + dev_dbg(pwmchip_parent(chip), "programmed PWM#%u, %u bytes\n", pwm->hwpwm, i); return 0; } From patchwork Wed Feb 14 09:32:50 2024 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: 13556215 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 552CFC48BEB for ; Wed, 14 Feb 2024 09:42:15 +0000 (UTC) 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=WfHKmOY8NJ+UrMWHOw+AMN1G7K5OA0fJDutDxHeSMN0=; b=dxrR90NEuFJtoO l5wC293MPbJrHOB9XSUa3ErztJUHxnC9vVjx7uT2oTLrt97I1/n5bNHX/d5/M08v4VQSoOJqlmPvr BU8He+5tu2R/PAwubRY2tdIqcphUbW4SZnxPAwB1Dj/48PLUW9sGL0JyGYGNgqSgX6mD5h77KaNpa sJpmNsImghXezvDxZ+Jnmz0rX5QV58zKOcECgXVjK5deIMryMe5mhTHTn2t62Ycy8QgBjN2AqG3OV FYTTqGQSy/bVZZNC++xuCTz05ZgWaxvUWPTLsBiifp+meCdWYlyhEZ03/Kd5aZb3KFrPnN36wP6lj zSeFILOR2MgKrr5gDEgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBmE-0000000CPn7-2bBV; Wed, 14 Feb 2024 09:42:02 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfB-0000000CKVJ-1uNm for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:53 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf5-0005rI-Mh; Wed, 14 Feb 2024 10:34:39 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf2-000fGK-QI; Wed, 14 Feb 2024 10:34:36 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf2-004Y85-2N; Wed, 14 Feb 2024 10:34:36 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Maxime Coquelin , Alexandre Torgue , linux-pwm@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 123/164] pwm: stmpe: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:32:50 +0100 Message-ID: <7e3dbf3b70126038c0ba16331ca8c07cab575bd3.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2455; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=Bb8YBorqx+bVzwUkLBbdXoJMd39BE0M+Jl5c4roRp5w=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjYOMQ8tTWUOYAVYGSFAA+Yj0Hz+F/f4oxBl Rnfs+qAKOGJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI2AAKCRCPgPtYfRL+ Th1jB/0fMrZDxTfd7Yt+yAj4BDFhl1L44RtBqZZzcd1IUYVMTqIwcgf76dzxY1D879k4DWMYWnH 4Qm4c4MoBoAhwFS7b9es8RzCCxmNZqwHGYASw8WyyaWHsexjOTvI3n436eZzN6KOk5HVrUNfLU4 7CU4WRiFuAUiT8h4DMuJsdqAkFC7Eju+QqYLX4BDITHtibkh58JrxaYobxYvAADm3Q9oNs1V4gc Fb4TFuw69uGkZ4Pv43Z0BBebpEdEi++I9Vr92rIvhxG9UWPDoZ4la0/jkcJOpMA5dkdmE/djM9v xBq2hV0PAPuPFd06QXzl6mQeCCU8+n+7m6mvMjR3bozH6tlO X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013445_863158_D5AFE260 X-CRM114-Status: GOOD ( 15.69 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-stmpe driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-stmpe.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/pwm/pwm-stmpe.c b/drivers/pwm/pwm-stmpe.c index 05f3f38031ee..bb91062d5f1d 100644 --- a/drivers/pwm/pwm-stmpe.c +++ b/drivers/pwm/pwm-stmpe.c @@ -27,13 +27,12 @@ struct stmpe_pwm { struct stmpe *stmpe; - struct pwm_chip chip; u8 last_duty; }; static inline struct stmpe_pwm *to_stmpe_pwm(struct pwm_chip *chip) { - return container_of(chip, struct stmpe_pwm, chip); + return pwmchip_get_drvdata(chip); } static int stmpe_24xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) @@ -292,33 +291,36 @@ static const struct pwm_ops stmpe_24xx_pwm_ops = { static int __init stmpe_pwm_probe(struct platform_device *pdev) { struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); + struct pwm_chip *chip; struct stmpe_pwm *stmpe_pwm; int ret; - stmpe_pwm = devm_kzalloc(&pdev->dev, sizeof(*stmpe_pwm), GFP_KERNEL); - if (!stmpe_pwm) - return -ENOMEM; + switch (stmpe->partnum) { + case STMPE2401: + case STMPE2403: + break; + case STMPE1601: + return dev_err_probe(&pdev->dev, -ENODEV, + "STMPE1601 not yet supported\n"); + default: + return dev_err_probe(&pdev->dev, -ENODEV, + "Unknown STMPE PWM\n"); + } + + chip = devm_pwmchip_alloc(&pdev->dev, 3, sizeof(*stmpe_pwm)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + stmpe_pwm = to_stmpe_pwm(chip); stmpe_pwm->stmpe = stmpe; - stmpe_pwm->chip.dev = &pdev->dev; - if (stmpe->partnum == STMPE2401 || stmpe->partnum == STMPE2403) { - stmpe_pwm->chip.ops = &stmpe_24xx_pwm_ops; - stmpe_pwm->chip.npwm = 3; - } else { - if (stmpe->partnum == STMPE1601) - dev_err(&pdev->dev, "STMPE1601 not yet supported\n"); - else - dev_err(&pdev->dev, "Unknown STMPE PWM\n"); - - return -ENODEV; - } + chip->ops = &stmpe_24xx_pwm_ops; ret = stmpe_enable(stmpe, STMPE_BLOCK_PWM); if (ret) return ret; - ret = pwmchip_add(&stmpe_pwm->chip); + ret = pwmchip_add(chip); if (ret) { stmpe_disable(stmpe, STMPE_BLOCK_PWM); return ret; From patchwork Wed Feb 14 09:32:51 2024 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: 13556171 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7604FC48BEE for ; Wed, 14 Feb 2024 09:39:21 +0000 (UTC) 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=Cv9KJLH4OHPHLhtfFmurywigABWts0hSgrgPL2AOwfk=; b=dI6OMCv74Ghurg rPrNmXKrFjX4KlvulnE4Ay5oCUDIQSwaTyeJOeg8x3X/LEjnD9U6Mkb6cTtKen6vsoxj4W168aeno CIfUqB4VAbrU55Nq7uvTkwoX9RCvytOZSiQzt2OoF5645D9+TlQFgN2AOrk2hr4vn9eSjzQnSBfkp umonyBo8sfNMic1CNDc/tHJjHBXNjdj/xe+EvqXk8a2DuKMEW+RC7br/qF2rfGd0vWkMaEezYuaE3 maPdzoRDaMMW1N8+SvvNlqn0zi69ZFCHj8swwvb8vHYHBeq8jZskiroVMz1ctBOtq6Yqq6KUcgoqs Z/1b9EHuPdKSYmy0SXzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBjO-0000000CNT3-3WO5; Wed, 14 Feb 2024 09:39:06 +0000 Received: from metis.whiteo.stw.pengutronix.de ([185.203.201.7]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfD-0000000CKXc-0tV0 for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:55 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf6-0005rz-Cf; Wed, 14 Feb 2024 10:34:40 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf2-000fGP-Uu; Wed, 14 Feb 2024 10:34:36 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf2-004Y89-2q; Wed, 14 Feb 2024 10:34:36 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, kernel@pengutronix.de Subject: [PATCH v6 124/164] pwm: sun4i: Make use of pwmchip_parent() accessor Date: Wed, 14 Feb 2024 10:32:51 +0100 Message-ID: <3ddaec73f3abefb45625d0a469026fa8d13da8c0.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1280; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=3dVqSmhY8p5H+vr5Gl/jpAORwwjUu1lh7OQVl0sdU+s=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjZypwfClaOc9oFVyhz5spcDbeQ2oihX1A+s j7YGaJjb8mJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI2QAKCRCPgPtYfRL+ Tst6B/9ab8tf00wMOOj6CQrwM/ghrf+e8czin3fZ3LSlb8g0UCyvYthJlcVRsfrGN0DYiTOVB61 l0WLagICH4i0mF0CBmpJX2JBLMAsAEdTDX5X1npWQ4to/QNVXPu/QCL847a3XxFuTYAwau5pJyh usUbdxiWL5HGFq0m9KcZFglndGeebUVfJaVNcu3kRaYhZf0dIhxSRxLMgKIzT6EdMwJyC6IxRsH dWfYvIOTyMiAhEKbhH6493GDcjLh/7rY4bG5eUPjrgKn8csvGUPAS5o46sgxizlHUFj9qlgQ9xm iqHvvMgpCAXL0xfFITkns0xKrmRojp2HZEWMl9auqKtZt5Jj X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013447_501276_96CFC418 X-CRM114-Status: GOOD ( 13.30 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org struct pwm_chip::dev is about to change. To not have to touch this driver in the same commit as struct pwm_chip::dev, use the accessor function provided for exactly this purpose. Signed-off-by: Uwe Kleine-König Reviewed-by: Jernej Skrabec --- drivers/pwm/pwm-sun4i.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c index 1a439025540d..44edf1ce5739 100644 --- a/drivers/pwm/pwm-sun4i.c +++ b/drivers/pwm/pwm-sun4i.c @@ -245,7 +245,7 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, if (!cstate.enabled) { ret = clk_prepare_enable(sun4i_pwm->clk); if (ret) { - dev_err(chip->dev, "failed to enable PWM clock\n"); + dev_err(pwmchip_parent(chip), "failed to enable PWM clock\n"); return ret; } } @@ -253,7 +253,7 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, ret = sun4i_pwm_calculate(sun4i_pwm, state, &duty, &period, &prescaler, &bypass); if (ret) { - dev_err(chip->dev, "period exceeds the maximum value\n"); + dev_err(pwmchip_parent(chip), "period exceeds the maximum value\n"); if (!cstate.enabled) clk_disable_unprepare(sun4i_pwm->clk); return ret; From patchwork Wed Feb 14 09:32:52 2024 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: 13556206 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A86F9C48BEC for ; Wed, 14 Feb 2024 09:40:41 +0000 (UTC) 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=nLvr9nbQWt7Q2kihdKMCM/gMKMbxJhBzoB/NAukT1oc=; b=I9BjAc3lu87dFo omfthnjITvKs0U4GscHp8aASJTG8J+M9iJfImqth24us2Bws8gjlvUXdRtjLNF3PL6Rl7fFHxfW0Z MKF2YdtbIdM7KrIUuluOx1brne0BTWZt2qAkDsiQayltlVFzu1CWHN9CYTVpRMevTShzwejLubBbc AXlVHwpKvb81LfokT2DDDuvlp+DBMLodaZTMppGBVxeOZN9yVQT79EhHtZ4U3M1aQg5Uvw43MG0gT 9O6G3nJRBV0ka2eF2MlWCu8oS2LM+6f0UNT9TkgKnb2nDqRtrIlme9j4EPPuPfLyk8ihsDbGFMugX Do2AhRa8FLPPp+XWu7CQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBkf-0000000COYT-1675; Wed, 14 Feb 2024 09:40:25 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfd-0000000CKyS-2bCb for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=zgOKZ/SykLTdsPsKzcInfEDlQAdgI/56cAnEEkumn3k=; b=Ey5Pv4xb4GFfyRB8jaBg/OHoJd PrQ66cPPX4H6UNJZjzsCMNLVrmXeSLG2MDwArSQJ3JCzSYNzoWCS5GoAv+tk/MEpPHgva4cUadyQW GpBuMymZRRHhEsCA22h6Q84DafLx7G9rQWN+YheQzdaQ7OsfWwdTgxDuatIw4jC5u1MoFTjQqdyXN fJWFUwYvbtyHcPUR+RtTMFL8jkKEYL70Sw11e9fezZf8Epn+A15QkqT3PzWYOJpjVloGsRqbITmly MgOqvHbLVRDmZ6WdPnFeK7KL3kd8sHsn4k1sXS/lXiFvoChG/KzNIVHFZ8ERRoBP+V35Pp+FUvLAJ iWOKiuhw==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfT-0000000GDl5-0CW0 for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:12 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf5-0005st-Vy; Wed, 14 Feb 2024 10:34:40 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf3-000fGT-3o; Wed, 14 Feb 2024 10:34:37 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf3-004Y8D-08; Wed, 14 Feb 2024 10:34:37 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, kernel@pengutronix.de Subject: [PATCH v6 125/164] pwm: sun4i: Prepare removing pwm_chip from driver data Date: Wed, 14 Feb 2024 10:32:52 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2191; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=AueSBh20l+IvmTnMku/uAxXaCwl5AScvfIDtGYeyXxg=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjaRcrH/Di3kXiX+2H/62isgprTTbchcjoRV XNyA2Z72KSJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI2gAKCRCPgPtYfRL+ Tk7uCACQKU8wijfW5XTvrUoBIFZpXyJP4eFodXHJNx5MUXhZp+D7toClZKgb7XRdVgCsbAxnLdn CzEnmZTpm3beiNytFEAkZnC33LdIMo/sh7PWQ7Zeo1hmcL2/SOE926dzq+2vJWR7fTgHBziHF6x oGb80w8h9qONuV7o3QKZqL4eSsgw3jZs7ou3Yxo8QG3TYD8XJmAeNWN2QUyY78TrR0RCx3u9Ubm GIqlxCc409hLFN8CPQnVWqLnRGhCVU6AIDUkYN13tc0YB0yg0MKtZaUVvh5JfgVcbCjgTUWJQ1Z +UFDKwc14laD4XSymg32R/GWoUJidJ00KG4Tk3FQE3aW5P89 X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093504_537533_B6272474 X-CRM114-Status: GOOD ( 12.53 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the driver for further changes that will drop struct pwm_chip chip from struct sun4i_pwm_chip. Use the pwm_chip as driver data instead of the sun4i_pwm_chip to get access to the pwm_chip in sun4i_pwm_remove() without using sun4ichip->chip. Signed-off-by: Uwe Kleine-König Reviewed-by: Jernej Skrabec --- drivers/pwm/pwm-sun4i.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c index 44edf1ce5739..c2f579043915 100644 --- a/drivers/pwm/pwm-sun4i.c +++ b/drivers/pwm/pwm-sun4i.c @@ -384,12 +384,14 @@ MODULE_DEVICE_TABLE(of, sun4i_pwm_dt_ids); static int sun4i_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct sun4i_pwm_chip *sun4ichip; int ret; sun4ichip = devm_kzalloc(&pdev->dev, sizeof(*sun4ichip), GFP_KERNEL); if (!sun4ichip) return -ENOMEM; + chip = &sun4ichip->chip; sun4ichip->data = of_device_get_match_data(&pdev->dev); if (!sun4ichip->data) @@ -451,19 +453,19 @@ static int sun4i_pwm_probe(struct platform_device *pdev) goto err_bus; } - sun4ichip->chip.dev = &pdev->dev; - sun4ichip->chip.ops = &sun4i_pwm_ops; - sun4ichip->chip.npwm = sun4ichip->data->npwm; + chip->dev = &pdev->dev; + chip->ops = &sun4i_pwm_ops; + chip->npwm = sun4ichip->data->npwm; spin_lock_init(&sun4ichip->ctrl_lock); - ret = pwmchip_add(&sun4ichip->chip); + ret = pwmchip_add(chip); if (ret < 0) { dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret); goto err_pwm_add; } - platform_set_drvdata(pdev, sun4ichip); + platform_set_drvdata(pdev, chip); return 0; @@ -477,9 +479,10 @@ static int sun4i_pwm_probe(struct platform_device *pdev) static void sun4i_pwm_remove(struct platform_device *pdev) { - struct sun4i_pwm_chip *sun4ichip = platform_get_drvdata(pdev); + struct pwm_chip *chip = platform_get_drvdata(pdev); + struct sun4i_pwm_chip *sun4ichip = to_sun4i_pwm_chip(chip); - pwmchip_remove(&sun4ichip->chip); + pwmchip_remove(chip); clk_disable_unprepare(sun4ichip->bus_clk); reset_control_assert(sun4ichip->rst); From patchwork Wed Feb 14 09:32:53 2024 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: 13556203 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id F3FF4C48BC4 for ; Wed, 14 Feb 2024 09:40:31 +0000 (UTC) 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=2FrRpgg5o/SvsnR1/hzrzT9UAcXDmJRhvq6Q+2xRb4o=; b=T8btBj5ERCRumO xTyCbBjAUxJimsr3Svf2l97FtaMzD20PL06EyFfj3KVdkSmmn6TaWKEVBN4XfPojvF4SChW0gDQe9 +pj6t9ZwteHnPhgp1OQKRaMIDpdBw3DShWEQgDNajfmNpSLcB/1NodSXGWWIN2DFGrXKaS38QcZkC MoQ8VPkNUvQpagRCPBUuF+9Vq3QOxKT1spGgj1Q7lAEe7ysC7Fiemsfs0y9Mi0gHdAiiRp+qi1X/L GcqqMunne0yWG6iVIj9NUTZSufbbJLXpHDaBlsbwd6pdlEcH8atNFBJeknnMA3dEsmrAK31DbgLS9 ATYY28PcGiFoNJqM0duw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBkX-0000000COOI-29Cf; Wed, 14 Feb 2024 09:40:17 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfX-0000000CKvL-2PVz for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=NT0gB9kTiziT7BVIh0/miAvY9i/JxnR3oioD72vte58=; b=h6A4sPoSUjd21104cYmr1f6KoW BVqUjtppuFhqRn8vTvS5XBl0X6bitwGKqBpykgo3nt6KsaxMSfw81joG9d9l9t5P2ciRfRwLLv/4D 1ZGVZp1rrCeT4T69ar6LYNcNELpKGkI/35JVgeiTAF6+5MctJFtwsuEQ/a6YiMzI6Kg4YI2yypE28 4qkz6tTkTJWGIcmiFT8Q2zlszAeeb9Zgs+3rhcubgb8JBO3gJMXM4DS5i1BwLWiJ8u4TYIca5wsYA HaShxKAoJ34+3FrhhtOyNrPqH4SBE043JsEzz8V+ywOTVnl0nGjoQ2mhi9U2qFtRbieo5Ek9G0KmS 8wdhwpPA==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfS-0000000GDlA-2tTW for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:06 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf7-0005u1-Dd; Wed, 14 Feb 2024 10:34:41 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf3-000fGY-92; Wed, 14 Feb 2024 10:34:37 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf3-004Y8H-0d; Wed, 14 Feb 2024 10:34:37 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, kernel@pengutronix.de Subject: [PATCH v6 126/164] pwm: sun4i: Consistently name driver data sun4ichip Date: Wed, 14 Feb 2024 10:32:53 +0100 Message-ID: <705f54a13b59fff50eaa345d8b1e0c691345b996.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=8725; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=pYqhxukqqxjxaP+7jWY0dwzmWc6tQ3fdQHkzU6wvKgc=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjcFJDeGkGJiCtO/kFkd4CLnokzccSXKgqPX LlvGrwWM6qJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI3AAKCRCPgPtYfRL+ TqzCB/wO/LFmseKA69poXqCjxMiqvBOa7Xea8Y6B8KAQ/NRqLuEYt/ztn4WfSQABtY/wmbqha5C f38ihhHgQUVnW0vpHG1UJ5SzYP8zsWHUnLfncnN4rmAzxTccWP1+6ITqW345W3V5DGc36nCQkWc PegrIy9paz81m1oXjxchHqhXdp1k/gOFjf1dGb7hzYlxT4d8bCsksvepchLi8SovZcmeMzt/em2 oo0EkrcAWE5F8nsMYJTv2S5OAScfpp9twB3ucFPiiidbuIZqTwSgg0j1+PDLcnc3V2+djcHe+cT X4ZHx36LgIwt//2cCHSwAfK0Ppn8t51x52Ojw52il/Wu2W5T X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093504_288329_1A1B6FF2 X-CRM114-Status: GOOD ( 16.08 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The driver uses three different names for variables of type sun4i_pwm_chip: $ git grep 'struct sun4i_pwm_chip \*' v6.8-rc1 -- drivers/pwm/pwm-sun4i.c v6.8-rc1:drivers/pwm/pwm-sun4i.c:static inline struct sun4i_pwm_chip *to_sun4i_pwm_chip(struct pwm_chip *chip) v6.8-rc1:drivers/pwm/pwm-sun4i.c:static inline u32 sun4i_pwm_readl(struct sun4i_pwm_chip *chip, v6.8-rc1:drivers/pwm/pwm-sun4i.c:static inline void sun4i_pwm_writel(struct sun4i_pwm_chip *chip, v6.8-rc1:drivers/pwm/pwm-sun4i.c: struct sun4i_pwm_chip *sun4i_pwm = to_sun4i_pwm_chip(chip); v6.8-rc1:drivers/pwm/pwm-sun4i.c:static int sun4i_pwm_calculate(struct sun4i_pwm_chip *sun4i_pwm, v6.8-rc1:drivers/pwm/pwm-sun4i.c: struct sun4i_pwm_chip *sun4i_pwm = to_sun4i_pwm_chip(chip); v6.8-rc1:drivers/pwm/pwm-sun4i.c: struct sun4i_pwm_chip *sun4ichip; v6.8-rc1:drivers/pwm/pwm-sun4i.c: struct sun4i_pwm_chip *sun4ichip = platform_get_drvdata(pdev); "chip" is usually reserved for variables of type struct pwm_chip. So pick sun4ichip as common name which better matches the type name than sun4i_pwm. Signed-off-by: Uwe Kleine-König Acked-by: Jernej Skrabec --- drivers/pwm/pwm-sun4i.c | 64 ++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c index c2f579043915..2437e5961f5e 100644 --- a/drivers/pwm/pwm-sun4i.c +++ b/drivers/pwm/pwm-sun4i.c @@ -95,32 +95,32 @@ static inline struct sun4i_pwm_chip *to_sun4i_pwm_chip(struct pwm_chip *chip) return container_of(chip, struct sun4i_pwm_chip, chip); } -static inline u32 sun4i_pwm_readl(struct sun4i_pwm_chip *chip, +static inline u32 sun4i_pwm_readl(struct sun4i_pwm_chip *sun4ichip, unsigned long offset) { - return readl(chip->base + offset); + return readl(sun4ichip->base + offset); } -static inline void sun4i_pwm_writel(struct sun4i_pwm_chip *chip, +static inline void sun4i_pwm_writel(struct sun4i_pwm_chip *sun4ichip, u32 val, unsigned long offset) { - writel(val, chip->base + offset); + writel(val, sun4ichip->base + offset); } static int sun4i_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_state *state) { - struct sun4i_pwm_chip *sun4i_pwm = to_sun4i_pwm_chip(chip); + struct sun4i_pwm_chip *sun4ichip = to_sun4i_pwm_chip(chip); u64 clk_rate, tmp; u32 val; unsigned int prescaler; - clk_rate = clk_get_rate(sun4i_pwm->clk); + clk_rate = clk_get_rate(sun4ichip->clk); if (!clk_rate) return -EINVAL; - val = sun4i_pwm_readl(sun4i_pwm, PWM_CTRL_REG); + val = sun4i_pwm_readl(sun4ichip, PWM_CTRL_REG); /* * PWM chapter in H6 manual has a diagram which explains that if bypass @@ -128,7 +128,7 @@ static int sun4i_pwm_get_state(struct pwm_chip *chip, * proved that also enable bit is ignored in this case. */ if ((val & BIT_CH(PWM_BYPASS, pwm->hwpwm)) && - sun4i_pwm->data->has_direct_mod_clk_output) { + sun4ichip->data->has_direct_mod_clk_output) { state->period = DIV_ROUND_UP_ULL(NSEC_PER_SEC, clk_rate); state->duty_cycle = DIV_ROUND_UP_ULL(state->period, 2); state->polarity = PWM_POLARITY_NORMAL; @@ -137,7 +137,7 @@ static int sun4i_pwm_get_state(struct pwm_chip *chip, } if ((PWM_REG_PRESCAL(val, pwm->hwpwm) == PWM_PRESCAL_MASK) && - sun4i_pwm->data->has_prescaler_bypass) + sun4ichip->data->has_prescaler_bypass) prescaler = 1; else prescaler = prescaler_table[PWM_REG_PRESCAL(val, pwm->hwpwm)]; @@ -156,7 +156,7 @@ static int sun4i_pwm_get_state(struct pwm_chip *chip, else state->enabled = false; - val = sun4i_pwm_readl(sun4i_pwm, PWM_CH_PRD(pwm->hwpwm)); + val = sun4i_pwm_readl(sun4ichip, PWM_CH_PRD(pwm->hwpwm)); tmp = (u64)prescaler * NSEC_PER_SEC * PWM_REG_DTY(val); state->duty_cycle = DIV_ROUND_CLOSEST_ULL(tmp, clk_rate); @@ -167,7 +167,7 @@ static int sun4i_pwm_get_state(struct pwm_chip *chip, return 0; } -static int sun4i_pwm_calculate(struct sun4i_pwm_chip *sun4i_pwm, +static int sun4i_pwm_calculate(struct sun4i_pwm_chip *sun4ichip, const struct pwm_state *state, u32 *dty, u32 *prd, unsigned int *prsclr, bool *bypass) @@ -175,9 +175,9 @@ static int sun4i_pwm_calculate(struct sun4i_pwm_chip *sun4i_pwm, u64 clk_rate, div = 0; unsigned int prescaler = 0; - clk_rate = clk_get_rate(sun4i_pwm->clk); + clk_rate = clk_get_rate(sun4ichip->clk); - *bypass = sun4i_pwm->data->has_direct_mod_clk_output && + *bypass = sun4ichip->data->has_direct_mod_clk_output && state->enabled && (state->period * clk_rate >= NSEC_PER_SEC) && (state->period * clk_rate < 2 * NSEC_PER_SEC) && @@ -187,7 +187,7 @@ static int sun4i_pwm_calculate(struct sun4i_pwm_chip *sun4i_pwm, if (*bypass) return 0; - if (sun4i_pwm->data->has_prescaler_bypass) { + if (sun4ichip->data->has_prescaler_bypass) { /* First, test without any prescaler when available */ prescaler = PWM_PRESCAL_MASK; /* @@ -233,7 +233,7 @@ static int sun4i_pwm_calculate(struct sun4i_pwm_chip *sun4i_pwm, static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, const struct pwm_state *state) { - struct sun4i_pwm_chip *sun4i_pwm = to_sun4i_pwm_chip(chip); + struct sun4i_pwm_chip *sun4ichip = to_sun4i_pwm_chip(chip); struct pwm_state cstate; u32 ctrl, duty = 0, period = 0, val; int ret; @@ -243,31 +243,31 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, pwm_get_state(pwm, &cstate); if (!cstate.enabled) { - ret = clk_prepare_enable(sun4i_pwm->clk); + ret = clk_prepare_enable(sun4ichip->clk); if (ret) { dev_err(pwmchip_parent(chip), "failed to enable PWM clock\n"); return ret; } } - ret = sun4i_pwm_calculate(sun4i_pwm, state, &duty, &period, &prescaler, + ret = sun4i_pwm_calculate(sun4ichip, state, &duty, &period, &prescaler, &bypass); if (ret) { dev_err(pwmchip_parent(chip), "period exceeds the maximum value\n"); if (!cstate.enabled) - clk_disable_unprepare(sun4i_pwm->clk); + clk_disable_unprepare(sun4ichip->clk); return ret; } - spin_lock(&sun4i_pwm->ctrl_lock); - ctrl = sun4i_pwm_readl(sun4i_pwm, PWM_CTRL_REG); + spin_lock(&sun4ichip->ctrl_lock); + ctrl = sun4i_pwm_readl(sun4ichip, PWM_CTRL_REG); - if (sun4i_pwm->data->has_direct_mod_clk_output) { + if (sun4ichip->data->has_direct_mod_clk_output) { if (bypass) { ctrl |= BIT_CH(PWM_BYPASS, pwm->hwpwm); /* We can skip other parameter */ - sun4i_pwm_writel(sun4i_pwm, ctrl, PWM_CTRL_REG); - spin_unlock(&sun4i_pwm->ctrl_lock); + sun4i_pwm_writel(sun4ichip, ctrl, PWM_CTRL_REG); + spin_unlock(&sun4ichip->ctrl_lock); return 0; } @@ -277,14 +277,14 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, if (PWM_REG_PRESCAL(ctrl, pwm->hwpwm) != prescaler) { /* Prescaler changed, the clock has to be gated */ ctrl &= ~BIT_CH(PWM_CLK_GATING, pwm->hwpwm); - sun4i_pwm_writel(sun4i_pwm, ctrl, PWM_CTRL_REG); + sun4i_pwm_writel(sun4ichip, ctrl, PWM_CTRL_REG); ctrl &= ~BIT_CH(PWM_PRESCAL_MASK, pwm->hwpwm); ctrl |= BIT_CH(prescaler, pwm->hwpwm); } val = (duty & PWM_DTY_MASK) | PWM_PRD(period); - sun4i_pwm_writel(sun4i_pwm, val, PWM_CH_PRD(pwm->hwpwm)); + sun4i_pwm_writel(sun4ichip, val, PWM_CH_PRD(pwm->hwpwm)); if (state->polarity != PWM_POLARITY_NORMAL) ctrl &= ~BIT_CH(PWM_ACT_STATE, pwm->hwpwm); @@ -296,9 +296,9 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, if (state->enabled) ctrl |= BIT_CH(PWM_EN, pwm->hwpwm); - sun4i_pwm_writel(sun4i_pwm, ctrl, PWM_CTRL_REG); + sun4i_pwm_writel(sun4ichip, ctrl, PWM_CTRL_REG); - spin_unlock(&sun4i_pwm->ctrl_lock); + spin_unlock(&sun4ichip->ctrl_lock); if (state->enabled) return 0; @@ -310,14 +310,14 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, else usleep_range(delay_us, delay_us * 2); - spin_lock(&sun4i_pwm->ctrl_lock); - ctrl = sun4i_pwm_readl(sun4i_pwm, PWM_CTRL_REG); + spin_lock(&sun4ichip->ctrl_lock); + ctrl = sun4i_pwm_readl(sun4ichip, PWM_CTRL_REG); ctrl &= ~BIT_CH(PWM_CLK_GATING, pwm->hwpwm); ctrl &= ~BIT_CH(PWM_EN, pwm->hwpwm); - sun4i_pwm_writel(sun4i_pwm, ctrl, PWM_CTRL_REG); - spin_unlock(&sun4i_pwm->ctrl_lock); + sun4i_pwm_writel(sun4ichip, ctrl, PWM_CTRL_REG); + spin_unlock(&sun4ichip->ctrl_lock); - clk_disable_unprepare(sun4i_pwm->clk); + clk_disable_unprepare(sun4ichip->clk); return 0; } From patchwork Wed Feb 14 09:32:54 2024 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: 13556202 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C2009C48BEB for ; Wed, 14 Feb 2024 09:40:25 +0000 (UTC) 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=oDJJX6adaZ2sQokYKjb9BT+WC+hWCihErZxQ/8ZzShw=; b=CkW/mRqYqxeUPs MQ07NDShI4odB+ErRlhQWw/yTW2kosSAUIt0slNprLMwF8mENviN0eJybREKuxNe80iwqxMemHehm JdextOGK0IZw69JuSvZBGfsjg0yNdDNsVyIeuCVz2UiyNf847xGr8hoR21Uf6IZOcW+FKrCHL3dCU htpWtkYfIeLHXVQWTpJRrnhwbM1Gx22/UCtfLma70gMbB/MYs0YMwn5410z/5EBNxktwAkZlyZYfA KS22MrSBNHqWaxCDoAOXPj26WkzjFHYycVBGz0YrKKCTguC7tpi1E8ncHvyi3h00pSTjkp/CWNx1M yjExOziLgpNOKx2w0TwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBkO-0000000COL0-3ySJ; Wed, 14 Feb 2024 09:40:08 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfX-0000000CKvX-2PZg for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=haZuOvKd1ECeZAbsLg9a2Un9yW1uGt86GOF3EkoaPzI=; b=UZG5Zn6zw143yzvRYHT7pMEUN9 mk6IRSZUqfIfXys0H6lAlKju1kqezDiFxrM18xs9JZKuQAwuKLs59JH0wRul1pHFgl362+Jwowuml T0GBQDu+ZL/DIHGIPa4fcqQXGCzxUdblojS2jziW2YFQ9WcKaBOozaufuvdAqznLqGXLdYuMZS3fy zmEK8V7ihF7z82N2ylx1RiqAK39foFgI0nDi4Ujn1jPKBLkh0918aydqIQ6op8J7Lc4ykMDCI9BOA 0GhnFsQz3L8NQKZhw+ypDTSywFvpX2gaEtZzVmyPZWhYuNOYz2QrM7mvZIqwC2KaXOQs2KJ21lNQt KDl+K7gA==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfS-0000000GDl6-2iZ2 for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:06 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf6-0005v0-Cx; Wed, 14 Feb 2024 10:34:40 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf3-000fGb-Dp; Wed, 14 Feb 2024 10:34:37 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf3-004Y8L-17; Wed, 14 Feb 2024 10:34:37 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, kernel@pengutronix.de Subject: [PATCH v6 127/164] pwm: sun4i: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:32:54 +0100 Message-ID: <9d175b4e27878618cef2e75b6ecbf01ad5d18164.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2177; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=8grekMG/pnUPKM2MOLizyNA3Ftp35oinBr44kp2qzzM=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjdIZpyNN9xsJ/83vD9zGceZKDFjTgjS+vFw giGgyurR2mJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI3QAKCRCPgPtYfRL+ TpS0B/91FU88mXiefrP3J4rA4CGdSag6uBm5eO2sgfhRr4Y5m3b9MI4JyFbJ/WQ4h+3EVL+uS8U ktz9YZxmHu0X+OUlFsT8GxSVAvneu1cwDWIynXlXiHzFk2wz2ZJJ2mDjKLhHRTMPT3TDP8iPmqE t0h80+KjIv7S2CUVLjo4nv1oQ9xW6Am6bp437q2YT483DwnpYDhbnCXIl1604tOR/JmkRew28h3 k9QXL+nWjyNhQDXaMD7K3WMKigRZ+Vi0UJi8sfS/Q4nySkXxyqSUBPvL6g5w56XHRcQKP68IfKj VALUdkhZLAIwm79XrJwGdX3hEKtEiudv+4htab04pHWUZks/ X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093504_193403_4A77F63D X-CRM114-Status: GOOD ( 12.45 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-sun4i driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König Reviewed-by: Jernej Skrabec --- drivers/pwm/pwm-sun4i.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c index 2437e5961f5e..5c29590d1821 100644 --- a/drivers/pwm/pwm-sun4i.c +++ b/drivers/pwm/pwm-sun4i.c @@ -81,7 +81,6 @@ struct sun4i_pwm_data { }; struct sun4i_pwm_chip { - struct pwm_chip chip; struct clk *bus_clk; struct clk *clk; struct reset_control *rst; @@ -92,7 +91,7 @@ struct sun4i_pwm_chip { static inline struct sun4i_pwm_chip *to_sun4i_pwm_chip(struct pwm_chip *chip) { - return container_of(chip, struct sun4i_pwm_chip, chip); + return pwmchip_get_drvdata(chip); } static inline u32 sun4i_pwm_readl(struct sun4i_pwm_chip *sun4ichip, @@ -385,18 +384,20 @@ MODULE_DEVICE_TABLE(of, sun4i_pwm_dt_ids); static int sun4i_pwm_probe(struct platform_device *pdev) { struct pwm_chip *chip; + const struct sun4i_pwm_data *data; struct sun4i_pwm_chip *sun4ichip; int ret; - sun4ichip = devm_kzalloc(&pdev->dev, sizeof(*sun4ichip), GFP_KERNEL); - if (!sun4ichip) - return -ENOMEM; - chip = &sun4ichip->chip; - - sun4ichip->data = of_device_get_match_data(&pdev->dev); - if (!sun4ichip->data) + data = of_device_get_match_data(&pdev->dev); + if (!data) return -ENODEV; + chip = devm_pwmchip_alloc(&pdev->dev, data->npwm, sizeof(*sun4ichip)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + sun4ichip = to_sun4i_pwm_chip(chip); + + sun4ichip->data = data; sun4ichip->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(sun4ichip->base)) return PTR_ERR(sun4ichip->base); @@ -453,9 +454,7 @@ static int sun4i_pwm_probe(struct platform_device *pdev) goto err_bus; } - chip->dev = &pdev->dev; chip->ops = &sun4i_pwm_ops; - chip->npwm = sun4ichip->data->npwm; spin_lock_init(&sun4ichip->ctrl_lock); From patchwork Wed Feb 14 09:33:11 2024 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: 13556196 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 904D4C48BC4 for ; Wed, 14 Feb 2024 09:39:46 +0000 (UTC) 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=Um1KllIy84qlwet/MQd8H8SqVqqBOfrMizv5jcfY4/c=; b=JmtqgRSAavFC+x JOoCwGevlMCagsfWwvtze2fEJfxfc0Lzb6qY36L74+AVeHj6miUYVXf/YhW0gR3qzDPlPnzznRjr6 ZOC/3VAmPaagD586FDaMWF3/xikfk2DWcM4wqtKCXm0f30aat62a+PS1MhG/dxR+xxSfUuyy302Jr GnUXwvEMnCk0avhHgGe7Pv/iLSp3RuKWAtnSjXFpwwt/LNzHrIrUeyVErCNgIo+iM1HErALUlcqV2 fM29oWfyIfGTJ3HQQJyABh0qa9eoAdWyMXvq60OI6/45NJpTP1KLblkwZ0A5kOhqZ4VljKaD+2/tM 8PV/OizNRO3Bc2PIz3Cg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBjl-0000000CNmC-0exi; Wed, 14 Feb 2024 09:39:29 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfW-0000000CKuG-1pCY for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=h/cLOAWQ66J9qGAkXVYnfmLpuHjwIxxZ1jW7MNm8f5w=; b=ox5s4jSHS6udRzPDHt7A/v5BSa odyKzUtXtRwxw/e/cA6xYMVL4MHW0SEUoew5fjCgit6ENKbQJA/J7rjm0PL5H0oXtR1auRFif0y12 F4Pg7SuLjoesWdLG3a5aZLpI9KQp3//vIBgrSSwNp9AISlH9C5sQdVG5XIBajrowelNYvIQmGpZNr X5Vt2vBwFBNoAuvH43oOyRp61dXEjCwCbJ0vpX5ao3+J/OJdhAqcfmo6PqLBotJREl1LvhTBBxONM jnbfNdup4X5LnxvVSO79wVOpGOvIn43UnLw2L4Osy0XNY8xUM7Mc5CckpUY6w9F1bcn+3NLgCq878 b5JPNDhA==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfI-0000000GAcO-00Ax for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:04 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf9-00067p-BJ; Wed, 14 Feb 2024 10:34:43 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf5-000fHg-UO; Wed, 14 Feb 2024 10:34:39 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf5-004Y9b-2m; Wed, 14 Feb 2024 10:34:39 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Nobuhiro Iwamatsu , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 144/164] pwm: visconti: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:33:11 +0100 Message-ID: <24e779de69365686bb004742cd8f07cbda131212.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1937; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=CDg5DENx7fvJJUTQlX8qtwT+uKgrppGqalaIRu7TUN4=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjwdq4+uf6XzbzYVktvkHDMdzHqqDZa1hs6b eBpbuEABn2JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI8AAKCRCPgPtYfRL+ TlAJB/9vOvYOV3xw60esZZRMywJ09sW49Fc3wVXrxYVeA6Dr4wirit1dng8w6XBsrjRvzmXtds2 g/gckAYc+twR/4TMp3OJqJKka2KAu3aGRnU2hzBYydpDsTgAlYK2cOez4rTJYT3KaZ0Yhvu6UWA v2ciUH6cuSlt9B/xS3FVfrWLnLelGTJWr/Yr9YMuwGN4ZwSnyj81FiYsnZ+H+bt+TB2ouZXgteS XTH3je5v/T/w+fPg3vsbAGoJH7CAmCSDiQTtttcjYROZdNLzFwORqUJegBUx9wTrDrQkm+edHH6 bMRMvm4bhrHTYcVo2OtW+8twZZa3k3wKqiIkNx928kLpbbDe X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093452_218027_3954BE7E X-CRM114-Status: GOOD ( 15.33 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-visconti driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-visconti.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-visconti.c b/drivers/pwm/pwm-visconti.c index 8d736d558122..9e55380957be 100644 --- a/drivers/pwm/pwm-visconti.c +++ b/drivers/pwm/pwm-visconti.c @@ -34,13 +34,12 @@ #define PIPGM_PWMC_POLARITY_MASK GENMASK(5, 5) struct visconti_pwm_chip { - struct pwm_chip chip; void __iomem *base; }; static inline struct visconti_pwm_chip *visconti_pwm_from_chip(struct pwm_chip *chip) { - return container_of(chip, struct visconti_pwm_chip, chip); + return pwmchip_get_drvdata(chip); } static int visconti_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, @@ -134,22 +133,22 @@ static const struct pwm_ops visconti_pwm_ops = { static int visconti_pwm_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct pwm_chip *chip; struct visconti_pwm_chip *priv; int ret; - priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; + chip = devm_pwmchip_alloc(dev, 4, sizeof(*priv)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + priv = visconti_pwm_from_chip(chip); priv->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(priv->base)) return PTR_ERR(priv->base); - priv->chip.dev = dev; - priv->chip.ops = &visconti_pwm_ops; - priv->chip.npwm = 4; + chip->ops = &visconti_pwm_ops; - ret = devm_pwmchip_add(&pdev->dev, &priv->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) return dev_err_probe(&pdev->dev, ret, "Cannot register visconti PWM\n"); From patchwork Wed Feb 14 09:33:12 2024 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: 13556200 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 55865C48BEB for ; Wed, 14 Feb 2024 09:40:16 +0000 (UTC) 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=tgiCiorQ0r+qMpsyBt5vlJfKmUeUso4tCgCZcj2EkLo=; b=d4tQcO5V/bvON8 Kd0ow2mQZtWM3vs1j7FjDNTn8wf/3vs7SQ7T63ljX4vg6E1iPWHxb3a4AbDuE/bPuZiQVAxTW34VG TiLhM2nBWxa2Hp5Xx43cZGh4orf7zWgUiyxMu4i8iFmilp5sosybaOpxzdUE0PooIn+mri+BTC4TZ fuh6fows7Ex7g6tyFmwk85pheM3SE7d+dMwccbD7V0MMaZpEgyT5i7UBDEFUflLWDBC8tkSpEbuL/ bvz9xfogg/Z4IMXvMETCz88QWtw4ERl7hASbsrSVSisVllsNMAwJfpAxn7k2lZ2aTopnLceRJRtcB AAD41AsM/wu63z9RKt8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBkG-0000000COEG-0bxx; Wed, 14 Feb 2024 09:40:00 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfW-0000000CKu3-1CXK for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=U/SUTTJah+TJvWRze7+YZz5mllSNw8g8iuFJFC5JAuQ=; b=HwPnpVd2xvCZvpT8twY2kdHgEi i6eisdY7OMxUBbdf2CArNKY+9lGedCbvlbt5BMyOZaB0MBR5dxFt8kUB1LTidsmXq98ToZN7bdqFd wBPqJq2igaNASLf5xY1Sy3L48LLBhOaj6MEUJR0wSBWuv73IRoU7R+zoxEuc4e6SWGXrE4OU6aC4h 2FXbMMOMr3vqIqvNy/2Iss7u0v+kDtbZABf6etkiqAtsHBCKnYn/bsXdYkhMXxmJ14ZMeVRhgl5NQ J6k/jww8bAotP3zELyXv8Nc7bGVRE4o5RfRjmXXWToXEyV76w2v/dgsl3esafuTlwTLBnwxxHwGR4 GsxHQVJQ==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfE-0000000GAXS-2PL0 for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:00 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf8-00068V-P9; Wed, 14 Feb 2024 10:34:42 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf6-000fHl-38; Wed, 14 Feb 2024 10:34:40 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf6-004Y9f-04; Wed, 14 Feb 2024 10:34:40 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 145/164] pwm: vt8500: Change prototype of a helper to prepare further changes Date: Wed, 14 Feb 2024 10:33:12 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3462; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=1Qgr/NzRzqcCiFdlZZR2O2J75mlDqEJrmbF2tT3ET0s=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjxUgcU+qSMYlFq4YJ/hbepOuW6L4PO0vo5M 2f5XcOiJg2JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI8QAKCRCPgPtYfRL+ TsfxB/9aIwQ0hN7g5dbFuO0TtCnEGaE5DEh8kVjpcTADbHTb8mOCMuFbSdDt9jbelS65P9VhSag hTKQB5lrEL+2tn65hUEX7mGbkCnj4kZST+P8Eb6W9IwsEoGjO9HwaSCBfnQaIYQdAmhY0hGvRBq 01qLbZsxNwG9J9Y9buTYN4pWh74V2G4/pwuiD2TkQioEksY3Xg352LE5R7aN5mROwkx6mpn6TUG s79nyDhSiHSqp4yMNaYhiqBYaRp6CjuMr7PRvLwp3rxBdZfm+4bWcxRhSHdWu15Uoh1wmkU6XZE 8sHirgyajST+MUbz8FmSn+X8ZqX1TfB+0zEG3nDNkYtwcqmK X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093449_173747_5393C27B X-CRM114-Status: GOOD ( 12.32 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the driver for further changes that will make it harder to determine the pwm_chip from a given vt8500_chip. To just not have to do that, rework vt8500_pwm_busy_wait() to take a pwm_chip. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-vt8500.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-vt8500.c b/drivers/pwm/pwm-vt8500.c index 7bfeacee05d0..3646bd45b101 100644 --- a/drivers/pwm/pwm-vt8500.c +++ b/drivers/pwm/pwm-vt8500.c @@ -53,8 +53,9 @@ struct vt8500_chip { #define to_vt8500_chip(chip) container_of(chip, struct vt8500_chip, chip) #define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t) -static inline void vt8500_pwm_busy_wait(struct vt8500_chip *vt8500, int nr, u8 bitmask) +static inline void vt8500_pwm_busy_wait(struct pwm_chip *chip, int nr, u8 bitmask) { + struct vt8500_chip *vt8500 = to_vt8500_chip(chip); int loops = msecs_to_loops(10); u32 mask = bitmask << (nr << 8); @@ -62,7 +63,7 @@ static inline void vt8500_pwm_busy_wait(struct vt8500_chip *vt8500, int nr, u8 b cpu_relax(); if (unlikely(!loops)) - dev_warn(vt8500->chip.dev, "Waiting for status bits 0x%x to clear timed out\n", + dev_warn(chip->dev, "Waiting for status bits 0x%x to clear timed out\n", mask); } @@ -103,18 +104,18 @@ static int vt8500_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, dc = div64_u64(c, period_ns); writel(prescale, vt8500->base + REG_SCALAR(pwm->hwpwm)); - vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_SCALAR_UPDATE); + vt8500_pwm_busy_wait(chip, pwm->hwpwm, STATUS_SCALAR_UPDATE); writel(pv, vt8500->base + REG_PERIOD(pwm->hwpwm)); - vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_PERIOD_UPDATE); + vt8500_pwm_busy_wait(chip, pwm->hwpwm, STATUS_PERIOD_UPDATE); writel(dc, vt8500->base + REG_DUTY(pwm->hwpwm)); - vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_DUTY_UPDATE); + vt8500_pwm_busy_wait(chip, pwm->hwpwm, STATUS_DUTY_UPDATE); val = readl(vt8500->base + REG_CTRL(pwm->hwpwm)); val |= CTRL_AUTOLOAD; writel(val, vt8500->base + REG_CTRL(pwm->hwpwm)); - vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); + vt8500_pwm_busy_wait(chip, pwm->hwpwm, STATUS_CTRL_UPDATE); clk_disable(vt8500->clk); return 0; @@ -135,7 +136,7 @@ static int vt8500_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) val = readl(vt8500->base + REG_CTRL(pwm->hwpwm)); val |= CTRL_ENABLE; writel(val, vt8500->base + REG_CTRL(pwm->hwpwm)); - vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); + vt8500_pwm_busy_wait(chip, pwm->hwpwm, STATUS_CTRL_UPDATE); return 0; } @@ -148,7 +149,7 @@ static void vt8500_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) val = readl(vt8500->base + REG_CTRL(pwm->hwpwm)); val &= ~CTRL_ENABLE; writel(val, vt8500->base + REG_CTRL(pwm->hwpwm)); - vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); + vt8500_pwm_busy_wait(chip, pwm->hwpwm, STATUS_CTRL_UPDATE); clk_disable(vt8500->clk); } @@ -168,7 +169,7 @@ static int vt8500_pwm_set_polarity(struct pwm_chip *chip, val &= ~CTRL_INVERT; writel(val, vt8500->base + REG_CTRL(pwm->hwpwm)); - vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); + vt8500_pwm_busy_wait(chip, pwm->hwpwm, STATUS_CTRL_UPDATE); return 0; } From patchwork Wed Feb 14 09:33:13 2024 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: 13556205 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 81AC6C48BEE for ; Wed, 14 Feb 2024 09:40:35 +0000 (UTC) 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=xkTqiQ7iMOzwZs/pfYxe/BCch3SwzOMPns2Ub9c9KLo=; b=U3XkXx7MXGAEnm 7B09bIzoLbWqhZCmPTMcjejRdCe4Edx31k8IWQyBpPsObZkfWFwGjAW6KMsaj4O0BkXm7paLMXkME 1dZWE+YBbazJumsYNCf7A4WfCkgsqQPmlpabg97SOX4aJMTg/qujOzhBhmt/LPxhiPb2DAWt4zWft K0PAsumltpUplun7iUlCAQR8/v/gxOr8EbKcMvOlYP3xK1Tn8XCiqsrRCgEQEw1G5BpHiSn0+ufK+ sMnPLZR8BS85xXK+DLxlPKa/hHRLGlOy8S2rriASHs+nPAu4PGkvDTeBVFchjuCzZghJ8u8NxdI7B 2bxCfsIF7GbOXg98GxfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBkZ-0000000COTl-3BCG; Wed, 14 Feb 2024 09:40:19 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfb-0000000CKx3-124Z for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=ZRi/2XwxOTc+wbKbepRKmWxtHYD6a4n7CbpV1Hxbvdc=; b=aiVuyGaIHcrPpEZBz6cmzAbJLx Gs7PQ7e9OxmpeLXWT7nKm2y+zQjHZf2U87RgwiMzyvk6So+1sUFvRNYEfR8iFBBcpLAfnJeOVS+t+ yQY6CSagVyae4EzknPyTPuqW2SUF80NRrV/1qcAnb1K4Z/ap5LQlpKCFTEH2nD6YIyOTPdY6IOF3f 9VixiGCgrGla7T5OCZ3bfMdEBzpw2T7Dn2DZPLa4nQR+uSccSQgplSVvQlBwezBtBVB3Rw0K3vmjp 6QqFRIj42YwtcPnhklI05smH143BoSq5gSS3fHceEXTeVZifcwmzctHOH7Me9X+lRjemKYYip/mJL /RhjxvJQ==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfS-0000000GDl9-3dKt for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:10 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf9-00069W-8y; Wed, 14 Feb 2024 10:34:43 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf6-000fHp-8C; Wed, 14 Feb 2024 10:34:40 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf6-004Y9j-0Z; Wed, 14 Feb 2024 10:34:40 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 146/164] pwm: vt8500: Introduce a local pwm_chip variable in .probe() Date: Wed, 14 Feb 2024 10:33:13 +0100 Message-ID: <7d903b608609d46cf1ee1e06530f516f42af1ebb.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1522; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=j+ll1jcK/Tz1Xx6dt5wVgay2IUKDTlBkIX93unWwzRs=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjyE2JyHtqSobupAVUTnyaXx+U7SK81qJd0L aylHFyMJ4iJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI8gAKCRCPgPtYfRL+ TrTXCACKWdn+1TnbAzOS8B1SxWUnr0+CXxBrP3i56jQI3PdDuJWiigcFFng5yVkSlk61wZU+8AV aUHuWn2G80bz6dNDtjAELl+xwTPYfFcP/rpa0mkwL7C/6ny3vx411jVYJlXGPWX1i8fvpG26e8Z kwDRyJBkmzl2krZe5f1i5XRkhWrdLsx3UErxffVQ3avO0csNS5xYBS9SqGfmSu7o0fgQvj1CCC2 qFqmZyeJIHXuSEBvyfKxfs9sl8epBsB/Nm9CUcFcEXQ9S+j5CroCf9gGMwisljo7HAMkFZ4YNUU ibFOlvl3zfz1B15V4316wpfttWrQlkaw93/K7nDpBhIFLui9 X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093504_382043_3856215A X-CRM114-Status: GOOD ( 11.46 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This simplifies converting the driver to pwmchip_alloc() as there is only a single code line left that makes use of struct vt8500_chip::chip. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-vt8500.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/pwm/pwm-vt8500.c b/drivers/pwm/pwm-vt8500.c index 3646bd45b101..6da9b8f88afc 100644 --- a/drivers/pwm/pwm-vt8500.c +++ b/drivers/pwm/pwm-vt8500.c @@ -232,6 +232,7 @@ MODULE_DEVICE_TABLE(of, vt8500_pwm_dt_ids); static int vt8500_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct vt8500_chip *vt8500; struct device_node *np = pdev->dev.of_node; int ret; @@ -243,9 +244,10 @@ static int vt8500_pwm_probe(struct platform_device *pdev) if (vt8500 == NULL) return -ENOMEM; - vt8500->chip.dev = &pdev->dev; - vt8500->chip.ops = &vt8500_pwm_ops; - vt8500->chip.npwm = VT8500_NR_PWMS; + chip = &vt8500->chip; + chip->dev = &pdev->dev; + chip->ops = &vt8500_pwm_ops; + chip->npwm = VT8500_NR_PWMS; vt8500->clk = devm_clk_get_prepared(&pdev->dev, NULL); if (IS_ERR(vt8500->clk)) @@ -255,7 +257,7 @@ static int vt8500_pwm_probe(struct platform_device *pdev) if (IS_ERR(vt8500->base)) return PTR_ERR(vt8500->base); - ret = devm_pwmchip_add(&pdev->dev, &vt8500->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) return dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n"); From patchwork Wed Feb 14 09:33:14 2024 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: 13556204 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 96DB3C48BC4 for ; Wed, 14 Feb 2024 09:40:34 +0000 (UTC) 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=w1gosVQcgeqgr584nUCEmBcmDC/MtLw0N6IW0mm1/Zw=; b=HquPSvAodmTFkH wo2a+cHM925ivNPSpQxQVG4FqqG+LOBBE6jj2u5c85hPbivwALL6vJdSrqoQxKwsGqrKcvt9PjlcE J4tPvI+GSJc9fSyPiJ+Bbo+Z+nwJ2wClmkAx/3U4gKK9qe+VzviqxPo87bKnvnpkZCKh5rI7m5oPB Yt+CWLCzWmEafXN0cFC7j8Y6qOI3z2mEL6tPahYgP/ttbiNmZBD9tURdXLOLXx68qLmk3Ol//iHci UDR5JN03S6HzvWO+OcSTatx1LJ3sIg1wXzJYiwLoVsDXurm97C/S04dvPnj4MLhoa2x1+u7XcjZjF hSflJC4W3zWX80EvctpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBkb-0000000COVY-3oG0; Wed, 14 Feb 2024 09:40:21 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfb-0000000CKx7-25k9 for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=hijiZSmKK8/xensJkuR9JZMRjLjdWZ+PS+PEIaIhvfY=; b=WURsWrlM0nPfYw7MBmOASsD9Q4 NC3wv2Dcfjs5lPDdm9te86o35/Zm3e6Zm+Oxp46P1vSPM+n9yrg3/dcdRXVCL0xfPwsh6aw7c+qPh lJXnJ1LARs0vLZNenR20DlHGo+tm3CjQKu6+ZpF46Nl81bcYclzQScKj8KwT0o4YzIqVsVQ+eX12I Lh1bLcWbBOL17CynmoQFZtE06Q6GKBITKwLePituusmBYqESyR08d/VdTVI+fRaw9YP8oSS4FbyiU 1A13vime0CkbZqFItJFq8S2qH4ziSD1lDH/hbiSbG7ZbcWZVkOqWCEDvV4bj5UbXjVkK9UMS4Ao+V xmzLnsRQ==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfS-0000000GDl8-3NpS for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:10 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBfA-0006A1-G0; Wed, 14 Feb 2024 10:34:44 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf6-000fHs-DH; Wed, 14 Feb 2024 10:34:40 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf6-004Y9m-15; Wed, 14 Feb 2024 10:34:40 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 147/164] pwm: vt8500: Make use of pwmchip_parent() accessor Date: Wed, 14 Feb 2024 10:33:14 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1440; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=3B/r01Rwt+UpfKUdprpNwpdkLZbZZF74SsJaxMTgaIQ=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjzD/xlcSPQXypy6w9oOawV6+HN83LLUeSew mwiR7QytKOJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI8wAKCRCPgPtYfRL+ TunzB/0aK/XGscWyd87L1OKzi3lKLC4rIHujMBlVR5nG42obyi6agVhWVRHI9os/Gx8D6MZtOkB SzNwW6mA40v8ZnRLhieHRooWW8o6WMglcBTRnTtNK9zhc7vXpaINmljRAyKRHpK7BpjcKk7oVYk LUDet1UiPmGfwxsrkxD8pi4W95t0HJvlI+F690wQuA1oYhkdtOvEBqMHncZL57VugKKPb2Yonu6 uJzGuSEQ8NHHzESwObNmMJ8ghos7NNSzoc+/9tgjeEUMtC7U38RtZL6k73vcxku1cDgmvhKVpdV jS6rJVtmuw0OeApoaTQWwSWm62s4vHo7WF1NqI3zJP+wg3tu X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093504_310080_00A185C4 X-CRM114-Status: GOOD ( 11.22 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org struct pwm_chip::dev is about to change. To not have to touch this driver in the same commit as struct pwm_chip::dev, use the accessor function provided for exactly this purpose. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-vt8500.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pwm/pwm-vt8500.c b/drivers/pwm/pwm-vt8500.c index 6da9b8f88afc..fb4dbc88b0a3 100644 --- a/drivers/pwm/pwm-vt8500.c +++ b/drivers/pwm/pwm-vt8500.c @@ -63,7 +63,7 @@ static inline void vt8500_pwm_busy_wait(struct pwm_chip *chip, int nr, u8 bitmas cpu_relax(); if (unlikely(!loops)) - dev_warn(chip->dev, "Waiting for status bits 0x%x to clear timed out\n", + dev_warn(pwmchip_parent(chip), "Waiting for status bits 0x%x to clear timed out\n", mask); } @@ -78,7 +78,7 @@ static int vt8500_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, err = clk_enable(vt8500->clk); if (err < 0) { - dev_err(chip->dev, "failed to enable clock\n"); + dev_err(pwmchip_parent(chip), "failed to enable clock\n"); return err; } @@ -129,7 +129,7 @@ static int vt8500_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) err = clk_enable(vt8500->clk); if (err < 0) { - dev_err(chip->dev, "failed to enable clock\n"); + dev_err(pwmchip_parent(chip), "failed to enable clock\n"); return err; } From patchwork Wed Feb 14 09:33:15 2024 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: 13556167 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CCF20C48BED for ; Wed, 14 Feb 2024 09:39:18 +0000 (UTC) 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=YnLv+7w0SbyFzozKEC4RAng0OaxIwFtJ0Z7ibaDPX+U=; b=ZwUnaC9vLkw6Sa LgdH3lmvZSjn/tWstg4zCIbJ5orHIUBFjJz0gnfHrku5+tB2hQ+G9luKJ+qPBJbMQubEoUMhN1jnX tGdMZfvtEWo8SaLjJIhyOPxuBD0p4amcbm/+YcVooSAn2fcaMAEVpSuFyYDp1QYXShvnavVhykM7L tUhVXlz/r8+REuXr6iWkBE089Pwsimjsz2I8zOxFSPh70jywSRfRFaIuixbLwYTzEAZK4e7aGYmN0 0TZ+H4nDoam2R8SJkyDu+reb9QaSror50Lw43sPoDnXmSQ3GYUafwxm2kobwI4aGskA4QHwyxKi3B HPIJF4i0bomj9GNZpuHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBjP-0000000CNTO-2SUq; Wed, 14 Feb 2024 09:39:07 +0000 Received: from metis.whiteo.stw.pengutronix.de ([185.203.201.7]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfD-0000000CKYE-2uGC for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:55 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf9-0006Ah-7n; Wed, 14 Feb 2024 10:34:43 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf6-000fI0-ID; Wed, 14 Feb 2024 10:34:40 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf6-004Y9r-1Z; Wed, 14 Feb 2024 10:34:40 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 148/164] pwm: vt8500: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:33:15 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1811; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=rxI43Yujypy77xT768quBIuTIJlQXuHWwYYfj97S0uo=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIj02HTPmlqclJ16Q4aGRNjgVhgGhIukT5CBd BODoNDw2e6JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI9AAKCRCPgPtYfRL+ TviBB/48ZsIKp9OAnWE7ctCnSaJJ/kLw4UNBCKROpduCVBputp1yAxuewPUOsi6camFoBBMBJif PAnE5YLLv39F+OgeQD0cShjLxOtFqo6mZUQGJqnHW61Pu4FppZvPMMbe6TbNF3sS9pa/RvvamA4 cIxMytdCpzPGGXX+4gsjEvX1xUvt/Wr63SDkxBAUwWc26QNF7l9wlHygC9tyC5+9UdnWGYd+npd znFyou/c4eney24KX/35FhxSe02CNz/ycQxBAHK4B4Vhgo8Z3UvJEXoF++U59jr4nFihdDbsDeY VKk1+1aZkGNqvLns8M+3QeQYWiV2AmZqBvrxcNPnf72mguse X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013448_024576_A61C7346 X-CRM114-Status: GOOD ( 13.91 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-vt8500 driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Also convert the to_vt8500_chip() helper macro to a static inline to get some type safety. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-vt8500.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/pwm/pwm-vt8500.c b/drivers/pwm/pwm-vt8500.c index fb4dbc88b0a3..016c82d65527 100644 --- a/drivers/pwm/pwm-vt8500.c +++ b/drivers/pwm/pwm-vt8500.c @@ -45,12 +45,14 @@ #define STATUS_ALL_UPDATE 0x0F struct vt8500_chip { - struct pwm_chip chip; void __iomem *base; struct clk *clk; }; -#define to_vt8500_chip(chip) container_of(chip, struct vt8500_chip, chip) +static inline struct vt8500_chip *to_vt8500_chip(struct pwm_chip *chip) +{ + return pwmchip_get_drvdata(chip); +} #define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t) static inline void vt8500_pwm_busy_wait(struct pwm_chip *chip, int nr, u8 bitmask) @@ -240,14 +242,12 @@ static int vt8500_pwm_probe(struct platform_device *pdev) if (!np) return dev_err_probe(&pdev->dev, -EINVAL, "invalid devicetree node\n"); - vt8500 = devm_kzalloc(&pdev->dev, sizeof(*vt8500), GFP_KERNEL); - if (vt8500 == NULL) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, VT8500_NR_PWMS, sizeof(*vt8500)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + vt8500 = to_vt8500_chip(chip); - chip = &vt8500->chip; - chip->dev = &pdev->dev; chip->ops = &vt8500_pwm_ops; - chip->npwm = VT8500_NR_PWMS; vt8500->clk = devm_clk_get_prepared(&pdev->dev, NULL); if (IS_ERR(vt8500->clk)) From patchwork Wed Feb 14 09:33:16 2024 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: 13556174 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2A77AC48BEB for ; Wed, 14 Feb 2024 09:39:25 +0000 (UTC) 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=8wpyrhOZbqBXhKHDdTV2ZqltSgu3Q6Cacum7W5Efb2c=; b=aRXg5ICdKCu7z/ hQ1umZZAl4FOOkOimgJoOynBReJABYWHfPiCLbB5zMYgrdRrD2gXnGEre88G+wC8fryrPX9GSr0kq cEGmWqraTMfTwuF7qlvaENuJQi26wxux/8vg5NlpUGHIcMVJLIIbA9G93vv28z261YrpQEnx1BQ7d JEGIS/xMWyr047B1dsDjGCRmmAwoyqbsS4OeSBe2heCaqU14BKmRiM4dqLVcqfpA79lXjqdkdjNG7 aVAxkl9S7VXvP6WjU4q45hNPhLDc7A1fU1AryaKN7yUDPWRLrMGb422YB8cNkQvWjdrOaQBoXTF89 7tP+YN3n/PF9dsS6TgqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBjR-0000000CNUI-37kb; Wed, 14 Feb 2024 09:39:09 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfF-0000000CKb1-2Kv6 for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:57 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBfB-0006BN-5F; Wed, 14 Feb 2024 10:34:45 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf6-000fI3-Ma; Wed, 14 Feb 2024 10:34:40 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf6-004Y9v-1z; Wed, 14 Feb 2024 10:34:40 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Sean Anderson , Michal Simek , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 149/164] pwm: xilinx: Prepare removing pwm_chip from driver data Date: Wed, 14 Feb 2024 10:33:16 +0100 Message-ID: <738b9929c1d13bde64050f8bbc4ce8d85f58cc7a.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2515; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=0SYLkEACQ8T9AGYR57XhymGkN9/LFLhJpbaYpX97npw=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIj2a6DGhXDiU1Z6aUiYCWWWQW9gEgMV3inMX qS/8CiV40CJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI9gAKCRCPgPtYfRL+ Tn9BB/oCWEPoJqHqeucqUnA/H0dRS9PaYdQkNJvfa8bFh529CNuNG6EmxBMMDxr1vEH4TBW5OHv ae1T6JUTMThxqwufl7aTSCib+f4HO83gp5u23ZxkZGjmv9iuQ6BPFp4yF7MEIc0lrV2kRGt7btt 4kZM/IZF0Jc0+yxyGVsenhKA2zsKzvBxT9xV1yIVzOjMEJ0tSd9wyv/P8NTZiGyltL3fTSiDkn2 BDbG1dB272qKH4MekygiNmgE2jc8IheosgITEV6drW5YQ998xQ/TCmMv+X20iylqISHzP7yO3up 4yiuaFpqWSqbA5w5ql7M6ocKtTxF0W6jMQ3PgfFe2bncQADS X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013449_833306_A7589A83 X-CRM114-Status: GOOD ( 14.43 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the driver for further changes that will drop struct pwm_chip chip from struct xilinx_pwm_device. Use the pwm_chip as driver data instead of the xilinx_pwm_device to get access to the pwm_chip in xilinx_pwm_remove() without using xilinx_pwm->chip. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-xilinx.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-xilinx.c b/drivers/pwm/pwm-xilinx.c index 5f3c2a6fed11..0ca79fe8c105 100644 --- a/drivers/pwm/pwm-xilinx.c +++ b/drivers/pwm/pwm-xilinx.c @@ -214,6 +214,7 @@ static int xilinx_pwm_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; struct xilinx_timer_priv *priv; + struct pwm_chip *chip; struct xilinx_pwm_device *xilinx_pwm; u32 pwm_cells, one_timer, width; void __iomem *regs; @@ -228,8 +229,9 @@ static int xilinx_pwm_probe(struct platform_device *pdev) xilinx_pwm = devm_kzalloc(dev, sizeof(*xilinx_pwm), GFP_KERNEL); if (!xilinx_pwm) return -ENOMEM; - platform_set_drvdata(pdev, xilinx_pwm); priv = &xilinx_pwm->priv; + chip = &xilinx_pwm->chip; + platform_set_drvdata(pdev, chip); regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(regs)) @@ -278,10 +280,10 @@ static int xilinx_pwm_probe(struct platform_device *pdev) return dev_err_probe(dev, ret, "Clock enable failed\n"); clk_rate_exclusive_get(priv->clk); - xilinx_pwm->chip.dev = dev; - xilinx_pwm->chip.ops = &xilinx_pwm_ops; - xilinx_pwm->chip.npwm = 1; - ret = pwmchip_add(&xilinx_pwm->chip); + chip->dev = dev; + chip->ops = &xilinx_pwm_ops; + chip->npwm = 1; + ret = pwmchip_add(chip); if (ret) { clk_rate_exclusive_put(priv->clk); clk_disable_unprepare(priv->clk); @@ -293,11 +295,12 @@ static int xilinx_pwm_probe(struct platform_device *pdev) static void xilinx_pwm_remove(struct platform_device *pdev) { - struct xilinx_pwm_device *xilinx_pwm = platform_get_drvdata(pdev); + struct pwm_chip *chip = platform_get_drvdata(pdev); + struct xilinx_timer_priv *priv = xilinx_pwm_chip_to_priv(chip); - pwmchip_remove(&xilinx_pwm->chip); - clk_rate_exclusive_put(xilinx_pwm->priv.clk); - clk_disable_unprepare(xilinx_pwm->priv.clk); + pwmchip_remove(chip); + clk_rate_exclusive_put(priv->clk); + clk_disable_unprepare(priv->clk); } static const struct of_device_id xilinx_pwm_of_match[] = { From patchwork Wed Feb 14 09:33:17 2024 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: 13556173 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 39DC0C48BC4 for ; Wed, 14 Feb 2024 09:39:24 +0000 (UTC) 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=AzS8JUTm5F2+zx4uHpEqb/4IBDReuA4efEcNKCg+OS0=; b=4/+zGL+4wrPeJb of64TSQJDOvSmqKX+eeGzeXQ9D5sCLuwY4H5V5twH7Ir+oFnJsN/bP/JfZF4Q7QrusnecqBn1dIdo vPCN+oqbAYKIF0gtXGjyly1zE8I8ozTyraq/+KX7QNuYsaOQapOtvtKadqFsffHG/1RtxZJEVBBsB 5YCeDKb3BLv2+BieT0BqIUmIvgHIwxqA8qfwBE5+LfwRb56W5/b4o/dUfXgXA9Nad41HokStgsRvN Rjc9IZ7WFXjvA4Kb58ENVAZc+wocRTLemLWXK52WGG39lELxE4D9tkkZO6+m6DKn017fZC/4Cr6hg kswcVY6lLdUHbVLZFXsw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBjU-0000000CNWB-0Jos; Wed, 14 Feb 2024 09:39:12 +0000 Received: from metis.whiteo.stw.pengutronix.de ([185.203.201.7]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfF-0000000CKb5-26Vo for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:57 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf9-0006Bv-UK; Wed, 14 Feb 2024 10:34:43 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf6-000fI7-RH; Wed, 14 Feb 2024 10:34:40 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf6-004Y9z-2T; Wed, 14 Feb 2024 10:34:40 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Sean Anderson , Michal Simek , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 150/164] pwm: xilinx: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:33:17 +0100 Message-ID: <7cbc32771e94103b8c1c817cfdd613d7a2fc01b9.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2314; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=JwSksdiJKkUTA0XrBQphtQHWlG5cvgFNT9pJVNJ3gmQ=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIj3OiCxJq+FqmglVST//DPQ6+PrTwjBgJPA4 gSt5mi22ByJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI9wAKCRCPgPtYfRL+ TlQAB/9yGImmfJaZP5NL32Fv2T2P5dZmh+bVB+3++o/KOSLqtlEhk5NNCZ8hGzgX7IE2ksPQ8MH tj3Z0pBySlC6Aoi/aa2ZmCkMZ4cyatgeqafEtC2YZdT4xgAcFJ+Y1P9Ux0AAlj+HtI3q5p0aKdd 1vC67hcN+We44BMzY/Dequ4T/P4+ZHQlaCcAFDuFybnDpCWgKNHnzvHQKQKIlxgJpD0O0E2zipD sUB1215Z8evKttQuU5+L54zOI07GVIPU5N22pvPJJ7siyhMKriH7qdhjFJSCfRNTEKU8VAIjm7S ZnnpraI8plw3zlj3Ou/bHcb7I04I38bgoDOIMRJnpn/ShgNY X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_013449_914271_B457AC5E X-CRM114-Status: GOOD ( 13.83 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This prepares the pwm-xilinx driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-xilinx.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/pwm/pwm-xilinx.c b/drivers/pwm/pwm-xilinx.c index 0ca79fe8c105..3a7deebb0d0c 100644 --- a/drivers/pwm/pwm-xilinx.c +++ b/drivers/pwm/pwm-xilinx.c @@ -80,15 +80,10 @@ unsigned int xilinx_timer_get_period(struct xilinx_timer_priv *priv, #define TCSR_PWM_CLEAR (TCSR_MDT | TCSR_LOAD) #define TCSR_PWM_MASK (TCSR_PWM_SET | TCSR_PWM_CLEAR) -struct xilinx_pwm_device { - struct pwm_chip chip; - struct xilinx_timer_priv priv; -}; - static inline struct xilinx_timer_priv *xilinx_pwm_chip_to_priv(struct pwm_chip *chip) { - return &container_of(chip, struct xilinx_pwm_device, chip)->priv; + return pwmchip_get_drvdata(chip); } static bool xilinx_timer_pwm_enabled(u32 tcsr0, u32 tcsr1) @@ -215,7 +210,6 @@ static int xilinx_pwm_probe(struct platform_device *pdev) struct device_node *np = dev->of_node; struct xilinx_timer_priv *priv; struct pwm_chip *chip; - struct xilinx_pwm_device *xilinx_pwm; u32 pwm_cells, one_timer, width; void __iomem *regs; @@ -226,11 +220,10 @@ static int xilinx_pwm_probe(struct platform_device *pdev) if (ret) return dev_err_probe(dev, ret, "could not read #pwm-cells\n"); - xilinx_pwm = devm_kzalloc(dev, sizeof(*xilinx_pwm), GFP_KERNEL); - if (!xilinx_pwm) - return -ENOMEM; - priv = &xilinx_pwm->priv; - chip = &xilinx_pwm->chip; + chip = devm_pwmchip_alloc(dev, 1, sizeof(*priv)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + priv = xilinx_pwm_chip_to_priv(chip); platform_set_drvdata(pdev, chip); regs = devm_platform_ioremap_resource(pdev, 0); @@ -280,9 +273,7 @@ static int xilinx_pwm_probe(struct platform_device *pdev) return dev_err_probe(dev, ret, "Clock enable failed\n"); clk_rate_exclusive_get(priv->clk); - chip->dev = dev; chip->ops = &xilinx_pwm_ops; - chip->npwm = 1; ret = pwmchip_add(chip); if (ret) { clk_rate_exclusive_put(priv->clk);