Skip to contentSkip to conversation

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

PATCH In review Simon Horman 5 participants 8 messages Apr 18, 2023 – May 17, 2023 TI Keystone multicore navigator drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soc: ti: pruss: Avoid cast to incompatible function type

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.

---
 drivers/soc/ti/pruss.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/soc/ti/pruss.c +6 -2
index 6882c86b3ce5..e68441bd7b30 100644
@@ -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;
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Simon Horman

Rather than casting clk_unregister_mux to an incompatible function type provide a trivial wrapper with the correct signature for the use-case.

Quoted 7 lines

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!

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,

Quoted 33 lines
---
 drivers/soc/ti/pruss.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/soc/ti/pruss.c +6 -2
index 6882c86b3ce5..e68441bd7b30 100644
@@ -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;
Signature · 2 lines
Thanks,
~Nick Desaulniers
#2 lore raw
Quoted 17 lines · Nick Desaulniers
Quoted 5 lines · Simon Horman

Rather than casting clk_unregister_mux to an incompatible function type provide a trivial wrapper with the correct signature for the use-case.

Quoted 7 lines

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!

Quoted 12 lines

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.

...

#3 lore raw
Quoted 32 lines · Simon Horman
Quoted 17 lines · Nick Desaulniers
Quoted 5 lines · Simon Horman

Rather than casting clk_unregister_mux to an incompatible function type provide a trivial wrapper with the correct signature for the use-case.

Quoted 7 lines

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!

Quoted 12 lines

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,

Quoted 2 lines

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

No urgency on W=1 warnings. They are good cleanups to do. I meant to invite you to our meeting today (but forgot):
https://clangbuiltlinux.github.io/ has links to more info under "Bi-weekly video meeting".

We could use your help if there's anything in our issue tracker that looks tractable: https://github.com/ClangBuiltLinux/linux/issues

Thanks for the patches.

Signature · 2 lines
Thanks,
~Nick Desaulniers
Reviewed-by on v1 1/1
#4 lore raw
In reply to Simon Horman
Quoted 6 lines · Simon Horman

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:

Quoted 7 lines

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.

Quoted 31 lines
---
 drivers/soc/ti/pruss.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/soc/ti/pruss.c +6 -2
index 6882c86b3ce5..e68441bd7b30 100644
@@ -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;
Reviewed-by on v1 1/1
#5 lore raw
In reply to Simon Horman
Quoted 131 lines · Simon Horman

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.

---
 drivers/soc/ti/pruss.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/soc/ti/pruss.c +6 -2
index 6882c86b3ce5..e68441bd7b30 100644
@@ -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 <[email protected]>; 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 [email protected];
	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 <[email protected]>
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: <[email protected]>
X-B4-Tracking: v=1; b=H4sIAPuBPmQC/x2N0QqDMAwAf0XyvICtE8d+ZeyhjekMlk4SHAPx3
xf2eAfHHWCswgb37gDlj5i8m0O4dEBLai9GmZ0h9nHor+GGm+5mSHVFyljGkOfINA1jAU9yMsa sqdHiUdtrdbkpF/n+H4/nef4A+lxSD3MAAAA=
To: Nishanth Menon <[email protected]>, Santosh Shilimkar <[email protected]>
Cc: Nathan Chancellor <[email protected]>,
Nick Desaulniers <[email protected]>, Tom Rix <[email protected]>, [email protected], [email protected], [email protected], Simon Horman <[email protected]>
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: [email protected]
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:[email protected]?subject=unsubscribe>
List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/>
List-Post: <mailto:[email protected]>
List-Help: <mailto:[email protected]?subject=help>
List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,
<mailto:[email protected]?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: "linux-arm-kernel" <[email protected]>
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:

Quoted 7 lines

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.

Quoted 37 lines
---
 drivers/soc/ti/pruss.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/soc/ti/pruss.c +6 -2
index 6882c86b3ce5..e68441bd7b30 100644
@@ -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
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Signature · 2 lines
Thanks and Regards,
Danish.
#6 lore raw
Quoted 1 line · Md Danish Anwar

On 18/04/23 17:11, Simon Horman wrote:

...

Quoted 9 lines
Quoted 9 lines

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,

Quoted 6 lines
Quoted 4 lines

No functional change intended.
Compile tested only.

Hi,

I'm wondering what the path of this patch to Linus's tree might be. Perhaps naively, I expected it to show up in v6.4-rc1.

maintainer
#7 lore raw
In reply to Simon Horman

Hi Simon Horman,

Quoted 10 lines · Simon Horman

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

Signature · 3 lines
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D