diff mbox series

soc: ti: pruss: Avoid cast to incompatible function type

Message ID 20230418-pruss-clk-cb-v1-1-549a7e7febe4@kernel.org (mailing list archive)
State New, archived
Headers show
Series soc: ti: pruss: Avoid cast to incompatible function type | expand

Commit Message

Simon Horman April 18, 2023, 11:41 a.m. UTC
Rather than casting clk_unregister_mux to an incompatible function
type provide a trivial wrapper with the correct signature for the
use-case.

Reported by clang-16 with W=1:

 drivers/soc/ti/pruss.c:158:38: error: cast from 'void (*)(struct clk *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
         ret = devm_add_action_or_reset(dev, (void(*)(void *))clk_unregister_mux,

No functional change intended.
Compile tested only.

Signed-off-by: Simon Horman <horms@kernel.org>
---
 drivers/soc/ti/pruss.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Nick Desaulniers April 18, 2023, 6:44 p.m. UTC | #1
On Tue, Apr 18, 2023 at 4:41 AM Simon Horman <horms@kernel.org> wrote:
>
> Rather than casting clk_unregister_mux to an incompatible function
> type provide a trivial wrapper with the correct signature for the
> use-case.
>
> Reported by clang-16 with W=1:
>
>  drivers/soc/ti/pruss.c:158:38: error: cast from 'void (*)(struct clk *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
>          ret = devm_add_action_or_reset(dev, (void(*)(void *))clk_unregister_mux,
>
> No functional change intended.
> Compile tested only.

Thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

Here's some more suspects to look at, if you have cycles:
drivers/base/devres.c:734:int __devm_add_action(struct device *dev,
void (*action)(void *), void *data, const char *name)
drivers/i2c/busses/i2c-mchp-pci1xxxx.c:1159: ret =
devm_add_action(dev, (void (*)(void *))pci1xxxx_i2c_shutdown, i2c);
drivers/soc/ti/pruss.c:96: ret = devm_add_action_or_reset(dev,
(void(*)(void *))clk_unregister_mux,
drivers/mmc/host/meson-mx-sdhc-mmc.c:791: ret =
devm_add_action_or_reset(dev, (void(*)(void *))mmc_free_host,
drivers/pci/controller/pcie-microchip-host.c:866:
devm_add_action_or_reset(dev, (void (*) (void
*))clk_disable_unprepare,

>
> Signed-off-by: Simon Horman <horms@kernel.org>
> ---
>  drivers/soc/ti/pruss.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/soc/ti/pruss.c b/drivers/soc/ti/pruss.c
> index 6882c86b3ce5..e68441bd7b30 100644
> --- a/drivers/soc/ti/pruss.c
> +++ b/drivers/soc/ti/pruss.c
> @@ -38,6 +38,11 @@ static void pruss_of_free_clk_provider(void *data)
>         of_node_put(clk_mux_np);
>  }
>
> +static void pruss_clk_unregister_mux(void *data)
> +{
> +       clk_unregister_mux(data);
> +}
> +
>  static int pruss_clk_mux_setup(struct pruss *pruss, struct clk *clk_mux,
>                                char *mux_name, struct device_node *clks_np)
>  {
> @@ -93,8 +98,7 @@ static int pruss_clk_mux_setup(struct pruss *pruss, struct clk *clk_mux,
>                 goto put_clk_mux_np;
>         }
>
> -       ret = devm_add_action_or_reset(dev, (void(*)(void *))clk_unregister_mux,
> -                                      clk_mux);
> +       ret = devm_add_action_or_reset(dev, pruss_clk_unregister_mux, clk_mux);
>         if (ret) {
>                 dev_err(dev, "failed to add clkmux unregister action %d", ret);
>                 goto put_clk_mux_np;
>
Nathan Chancellor April 18, 2023, 6:44 p.m. UTC | #2
On Tue, Apr 18, 2023 at 01:41:48PM +0200, Simon Horman wrote:
> Rather than casting clk_unregister_mux to an incompatible function
> type provide a trivial wrapper with the correct signature for the
> use-case.
> 
> Reported by clang-16 with W=1:
> 
>  drivers/soc/ti/pruss.c:158:38: error: cast from 'void (*)(struct clk *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
>          ret = devm_add_action_or_reset(dev, (void(*)(void *))clk_unregister_mux,
> 
> No functional change intended.
> Compile tested only.
> 
> Signed-off-by: Simon Horman <horms@kernel.org>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  drivers/soc/ti/pruss.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/soc/ti/pruss.c b/drivers/soc/ti/pruss.c
> index 6882c86b3ce5..e68441bd7b30 100644
> --- a/drivers/soc/ti/pruss.c
> +++ b/drivers/soc/ti/pruss.c
> @@ -38,6 +38,11 @@ static void pruss_of_free_clk_provider(void *data)
>  	of_node_put(clk_mux_np);
>  }
>  
> +static void pruss_clk_unregister_mux(void *data)
> +{
> +	clk_unregister_mux(data);
> +}
> +
>  static int pruss_clk_mux_setup(struct pruss *pruss, struct clk *clk_mux,
>  			       char *mux_name, struct device_node *clks_np)
>  {
> @@ -93,8 +98,7 @@ static int pruss_clk_mux_setup(struct pruss *pruss, struct clk *clk_mux,
>  		goto put_clk_mux_np;
>  	}
>  
> -	ret = devm_add_action_or_reset(dev, (void(*)(void *))clk_unregister_mux,
> -				       clk_mux);
> +	ret = devm_add_action_or_reset(dev, pruss_clk_unregister_mux, clk_mux);
>  	if (ret) {
>  		dev_err(dev, "failed to add clkmux unregister action %d", ret);
>  		goto put_clk_mux_np;
>
Simon Horman April 19, 2023, 5:45 a.m. UTC | #3
On Tue, Apr 18, 2023 at 11:44:28AM -0700, Nick Desaulniers wrote:
> On Tue, Apr 18, 2023 at 4:41 AM Simon Horman <horms@kernel.org> wrote:
> >
> > Rather than casting clk_unregister_mux to an incompatible function
> > type provide a trivial wrapper with the correct signature for the
> > use-case.
> >
> > Reported by clang-16 with W=1:
> >
> >  drivers/soc/ti/pruss.c:158:38: error: cast from 'void (*)(struct clk *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
> >          ret = devm_add_action_or_reset(dev, (void(*)(void *))clk_unregister_mux,
> >
> > No functional change intended.
> > Compile tested only.
> 
> Thanks for the patch!
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> 
> Here's some more suspects to look at, if you have cycles:
> drivers/base/devres.c:734:int __devm_add_action(struct device *dev,
> void (*action)(void *), void *data, const char *name)
> drivers/i2c/busses/i2c-mchp-pci1xxxx.c:1159: ret =
> devm_add_action(dev, (void (*)(void *))pci1xxxx_i2c_shutdown, i2c);
> drivers/soc/ti/pruss.c:96: ret = devm_add_action_or_reset(dev,
> (void(*)(void *))clk_unregister_mux,
> drivers/mmc/host/meson-mx-sdhc-mmc.c:791: ret =
> devm_add_action_or_reset(dev, (void(*)(void *))mmc_free_host,
> drivers/pci/controller/pcie-microchip-host.c:866:
> devm_add_action_or_reset(dev, (void (*) (void
> *))clk_disable_unprepare,

Thanks, I will take a look as a background task.
Let me know if there is any urgency on your side.

...
Anwar, Md Danish April 20, 2023, 5:49 a.m. UTC | #4
On 18/04/23 17:11, Simon Horman wrote:
> Rather than casting clk_unregister_mux to an incompatible function
> type provide a trivial wrapper with the correct signature for the
> use-case.
> 
> Reported by clang-16 with W=1:
> 
>  drivers/soc/ti/pruss.c:158:38: error: cast from 'void (*)(struct clk *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
>          ret = devm_add_action_or_reset(dev, (void(*)(void *))clk_unregister_mux,
> 
> No functional change intended.
> Compile tested only.
> 
> Signed-off-by: Simon Horman <horms@kernel.org>
> ---
>  drivers/soc/ti/pruss.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/soc/ti/pruss.c b/drivers/soc/ti/pruss.c
> index 6882c86b3ce5..e68441bd7b30 100644
> --- a/drivers/soc/ti/pruss.c
> +++ b/drivers/soc/ti/pruss.c
> @@ -38,6 +38,11 @@ static void pruss_of_free_clk_provider(void *data)
>  	of_node_put(clk_mux_np);
>  }
>  
> +static void pruss_clk_unregister_mux(void *data)
> +{
> +	clk_unregister_mux(data);
> +}
> +
>  static int pruss_clk_mux_setup(struct pruss *pruss, struct clk *clk_mux,
>  			       char *mux_name, struct device_node *clks_np)
>  {
> @@ -93,8 +98,7 @@ static int pruss_clk_mux_setup(struct pruss *pruss, struct clk *clk_mux,
>  		goto put_clk_mux_np;
>  	}
>  
> -	ret = devm_add_action_or_reset(dev, (void(*)(void *))clk_unregister_mux,
> -				       clk_mux);
> +	ret = devm_add_action_or_reset(dev, pruss_clk_unregister_mux, clk_mux);
>  	if (ret) {
>  		dev_err(dev, "failed to add clkmux unregister action %d", ret);
>  		goto put_clk_mux_np;
> 
> 
> From mboxrd@z Thu Jan  1 00:00:00 1970
> Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org>
> 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 91400C77B78
> 	for <linux-arm-kernel@archiver.kernel.org>; Tue, 18 Apr 2023 11:42: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:Cc:To:Message-Id:MIME-Version:Subject:
> 	Date:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:
> 	Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:
> 	List-Owner; bh=+CAO6uf34Wr1geK3ZRBtb0JAI43xTLZvVoAx3bYFR8o=; b=cuIUNZeFjlNWar
> 	n1qXrpSC2BWjTp1I6lb3nOHEvktz/aw4F5DEvvoNHxGvFGjKOkNVCOZ8kbNaPmbgN+kTATZka4FkF
> 	qQ/sW/CVCX/kWrwG1Wp/Q0rQfY1gO9+SaQEKNFvIM/RKK/G/9IP0kk2vQDjozKlCG52ka8uzTU5/Y
> 	mv5rKIYXf6KAsCH8KNxykQvIo5vCnaRzOIh/DGnFsuCdD0ShIuf1ymQBmFmg6rpXtTNBaiEU9asnR
> 	JbTngu0Ike23z2CkRSjpjDU7yULHoaUcp0FELF8NnkX5bbbKsPpjww949637SS7v9pEs11L7pNeDi
> 	lW4G7+LEEpL2z2yRkAPQ==;
> Received: from localhost ([::1] helo=bombadil.infradead.org)
> 	by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux))
> 	id 1pojif-001zZA-2v;
> 	Tue, 18 Apr 2023 11:41:57 +0000
> Received: from dfw.source.kernel.org ([139.178.84.217])
> 	by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux))
> 	id 1pojid-001zYi-0s
> 	for linux-arm-kernel@lists.infradead.org;
> 	Tue, 18 Apr 2023 11:41:56 +0000
> Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140])
> 	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
> 	(No client certificate requested)
> 	by dfw.source.kernel.org (Postfix) with ESMTPS id B371562AB8;
> 	Tue, 18 Apr 2023 11:41:54 +0000 (UTC)
> Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82D70C433EF;
> 	Tue, 18 Apr 2023 11:41:52 +0000 (UTC)
> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;
> 	s=k20201202; t=1681818114;
> 	bh=HDO76kSQTCd/EdXhW03QxEZMNUJlfvxdzP1GEo8IYVg=;
> 	h=From:Date:Subject:To:Cc:From;
> 	b=JZMzw7vBy3kF7tUHrf3heWahdw/+GlTfSbSfX4l8BXBY+xlpkYbzXBZF6yUtnZ6ei
> 	 X9heGXlXJ7Qjq+ln6+s1947UlK8OkkZ8GO5SvG5L6ek9ceYzedjuzvPZfxymikoQY+
> 	 e3xN7D2jgVVu7zVcX2rgraJ86iVq7G62fX9TnTnZ3cy6CQpj1mkPaQSTd0FJ09djlq
> 	 Ott8fvgXVB18h1Z2jWGiQOs3a4y7x0d+smz5RcKCOs2Qm6EWCicR19vJHHrpjqh3Yd
> 	 Wycn9PVVKILWspPmYdQLWAj2UTH539mJEdC3MrBHQG5XKAoYZ45uelHZwLuE+fL9gI
> 	 hj7mkdKhM7mmg==
> From: Simon Horman <horms@kernel.org>
> Date: Tue, 18 Apr 2023 13:41:48 +0200
> Subject: [PATCH] soc: ti: pruss: Avoid cast to incompatible function type
> MIME-Version: 1.0
> Message-Id: <20230418-pruss-clk-cb-v1-1-549a7e7febe4@kernel.org>
> X-B4-Tracking: v=1; b=H4sIAPuBPmQC/x2N0QqDMAwAf0XyvICtE8d+ZeyhjekMlk4SHAPx3
>  xf2eAfHHWCswgb37gDlj5i8m0O4dEBLai9GmZ0h9nHor+GGm+5mSHVFyljGkOfINA1jAU9yMsa
>  sqdHiUdtrdbkpF/n+H4/nef4A+lxSD3MAAAA=
> To: Nishanth Menon <nm@ti.com>, Santosh Shilimkar <ssantosh@kernel.org>
> Cc: Nathan Chancellor <nathan@kernel.org>, 
>  Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, 
>  linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, 
>  llvm@lists.linux.dev, Simon Horman <horms@kernel.org>
> X-Mailer: b4 0.12.2
> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 
> X-CRM114-CacheID: sfid-20230418_044155_365668_53307A20 
> X-CRM114-Status: GOOD (  11.38  )
> X-BeenThere: linux-arm-kernel@lists.infradead.org
> X-Mailman-Version: 2.1.34
> Precedence: list
> List-Id: <linux-arm-kernel.lists.infradead.org>
> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>,
>  <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>
> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/>
> List-Post: <mailto:linux-arm-kernel@lists.infradead.org>
> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>
> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,
>  <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>
> Content-Type: text/plain; charset="us-ascii"
> Content-Transfer-Encoding: 7bit
> Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org>
> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org
> 
> Rather than casting clk_unregister_mux to an incompatible function
> type provide a trivial wrapper with the correct signature for the
> use-case.
> 
> Reported by clang-16 with W=1:
> 
>  drivers/soc/ti/pruss.c:158:38: error: cast from 'void (*)(struct clk *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
>          ret = devm_add_action_or_reset(dev, (void(*)(void *))clk_unregister_mux,
> 
> No functional change intended.
> Compile tested only.
> 
> Signed-off-by: Simon Horman <horms@kernel.org>

Reviewed-by: MD Danish Anwar <danishanwar@ti.com>

> ---
>  drivers/soc/ti/pruss.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/soc/ti/pruss.c b/drivers/soc/ti/pruss.c
> index 6882c86b3ce5..e68441bd7b30 100644
> --- a/drivers/soc/ti/pruss.c
> +++ b/drivers/soc/ti/pruss.c
> @@ -38,6 +38,11 @@ static void pruss_of_free_clk_provider(void *data)
>  	of_node_put(clk_mux_np);
>  }
>  
> +static void pruss_clk_unregister_mux(void *data)
> +{
> +	clk_unregister_mux(data);
> +}
> +
>  static int pruss_clk_mux_setup(struct pruss *pruss, struct clk *clk_mux,
>  			       char *mux_name, struct device_node *clks_np)
>  {
> @@ -93,8 +98,7 @@ static int pruss_clk_mux_setup(struct pruss *pruss, struct clk *clk_mux,
>  		goto put_clk_mux_np;
>  	}
>  
> -	ret = devm_add_action_or_reset(dev, (void(*)(void *))clk_unregister_mux,
> -				       clk_mux);
> +	ret = devm_add_action_or_reset(dev, pruss_clk_unregister_mux, clk_mux);
>  	if (ret) {
>  		dev_err(dev, "failed to add clkmux unregister action %d", ret);
>  		goto put_clk_mux_np;
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
Nishanth Menon May 17, 2023, 5:55 p.m. UTC | #5
Hi Simon Horman,

On Tue, 18 Apr 2023 13:41:48 +0200, Simon Horman wrote:
> Rather than casting clk_unregister_mux to an incompatible function
> type provide a trivial wrapper with the correct signature for the
> use-case.
> 
> Reported by clang-16 with W=1:
> 
>  drivers/soc/ti/pruss.c:158:38: error: cast from 'void (*)(struct clk *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
>          ret = devm_add_action_or_reset(dev, (void(*)(void *))clk_unregister_mux,
> 
> [...]

I have applied the following to branch ti-drivers-soc-next on [1].
NOTE: I think this is trivial fixup, which I think is better off for
the next window.
Thank you!

[1/1] soc: ti: pruss: Avoid cast to incompatible function type
      commit: 413552b360e72604b8c0cf3f60f9e6f01c8ff963

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent up the chain during
the next merge window (or sooner if it is a relevant bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

[1] git://git.kernel.org/pub/scm/linux/kernel/git/ti/linux.git
diff mbox series

Patch

diff --git a/drivers/soc/ti/pruss.c b/drivers/soc/ti/pruss.c
index 6882c86b3ce5..e68441bd7b30 100644
--- a/drivers/soc/ti/pruss.c
+++ b/drivers/soc/ti/pruss.c
@@ -38,6 +38,11 @@  static void pruss_of_free_clk_provider(void *data)
 	of_node_put(clk_mux_np);
 }
 
+static void pruss_clk_unregister_mux(void *data)
+{
+	clk_unregister_mux(data);
+}
+
 static int pruss_clk_mux_setup(struct pruss *pruss, struct clk *clk_mux,
 			       char *mux_name, struct device_node *clks_np)
 {
@@ -93,8 +98,7 @@  static int pruss_clk_mux_setup(struct pruss *pruss, struct clk *clk_mux,
 		goto put_clk_mux_np;
 	}
 
-	ret = devm_add_action_or_reset(dev, (void(*)(void *))clk_unregister_mux,
-				       clk_mux);
+	ret = devm_add_action_or_reset(dev, pruss_clk_unregister_mux, clk_mux);
 	if (ret) {
 		dev_err(dev, "failed to add clkmux unregister action %d", ret);
 		goto put_clk_mux_np;