Re: [PATCH] soc: ti: pruss: Avoid cast to incompatible function type

From: Md Danish Anwar
Date: Thu Apr 20 2023 - 01:50:29 EST


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@xxxxxxxxxx>
> ---
> 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@xxxxxxxxxxxxxxxxxxx>
> 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@xxxxxxxxxxxxxxxxxxx>; 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@xxxxxxxxxxxxxxxxxxx;
> 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@xxxxxxxxxx>
> 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@xxxxxxxxxx>
> X-B4-Tracking: v=1; b=H4sIAPuBPmQC/x2N0QqDMAwAf0XyvICtE8d+ZeyhjekMlk4SHAPx3
> xf2eAfHHWCswgb37gDlj5i8m0O4dEBLai9GmZ0h9nHor+GGm+5mSHVFyljGkOfINA1jAU9yMsa
> sqdHiUdtrdbkpF/n+H4/nef4A+lxSD3MAAAA=
> To: Nishanth Menon <nm@xxxxxx>, Santosh Shilimkar <ssantosh@xxxxxxxxxx>
> Cc: Nathan Chancellor <nathan@xxxxxxxxxx>,
> Nick Desaulniers <ndesaulniers@xxxxxxxxxx>, Tom Rix <trix@xxxxxxxxxx>,
> linux-kernel@xxxxxxxxxxxxxxx, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx,
> llvm@xxxxxxxxxxxxxxx, Simon Horman <horms@xxxxxxxxxx>
> 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@xxxxxxxxxxxxxxxxxxx
> 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@xxxxxxxxxxxxxxxxxxx?subject=unsubscribe>
> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/>
> List-Post: <mailto:linux-arm-kernel@xxxxxxxxxxxxxxxxxxx>
> List-Help: <mailto:linux-arm-kernel-request@xxxxxxxxxxxxxxxxxxx?subject=help>
> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,
> <mailto:linux-arm-kernel-request@xxxxxxxxxxxxxxxxxxx?subject=subscribe>
> Content-Type: text/plain; charset="us-ascii"
> Content-Transfer-Encoding: 7bit
> Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@xxxxxxxxxxxxxxxxxxx>
> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@xxxxxxxxxxxxxxxxxxx
>
> 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@xxxxxxxxxx>

Reviewed-by: MD Danish Anwar <danishanwar@xxxxxx>

> ---
> 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@xxxxxxxxxxxxxxxxxxx
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

--
Thanks and Regards,
Danish.