Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp60953rdb; Mon, 14 Aug 2023 09:27:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjr3872lFP1c4zN7HtQjcxMGCxPnxPejrQcT9Lrry03Cg2Z3VDpomaihGWcMO/uflL37OT X-Received: by 2002:a05:6a20:1016:b0:13d:ee19:7723 with SMTP id gs22-20020a056a20101600b0013dee197723mr8766220pzc.35.1692030445498; Mon, 14 Aug 2023 09:27:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692030445; cv=none; d=google.com; s=arc-20160816; b=zkc0/33A5htocyIJr87hnaPqN9ObpJxiWIc6NdwDi/WJTeb3FafnAuhvDCp6l7f3TR BdwSSqweMIfKQxHHqZiQxrfEsOimvRdBplRrsSK4NZORbl3ePcDTkyMBTHpzRFpa3uOL pmxb2d28iiY3bqjOBkpt+5jNrKtsJKwXrWdF7MnTKJzYvTI/JAZHZ6JyplosY88kJsrM /ycUEHlgCsxihlUE7D3eg6c4bvJNQUNVsBcjG+9jj/iOgX7tUrG7YtixnzGBYHT4GEpc LqIWbgnWiDC18u2dbx5Jg5dY7rtfYIsKl39btNAxVXem9gu+/4Gz41K0yqpo3sHibHyv YXIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fWc7M7rsFUhmHwIybCG1OOdHDkD1+lzeaDcxxigieJg=; fh=cJx4phrPhSHvIYS4k4YZawujsfe9moQlieqLVLZ7vaw=; b=Y5cYI7x/qk0P280VU1ywKODAZFSMT3LLjejg4acdmf4+3gHVRbiczTEMVrHEAWFxyv YdDLJbP7gOx40WF9hW1Mbqg4gMrlclCSJh6CGCYzOPctSHtXneiFL/tFaUD7jXsJaceM bmpo5HjZGz8MP64ROAYcGSwpu4n19tzjgcyqUV2YeAC7ZIxUgUugHu9XY9O4oN4i5z1M OVipCYDJ29M/l4xNidAxyA9x0VhDStDaUzM5KDfX50CbHunYYpO90fGtZTDl8YwWyKsN jkfY57aUzvqzFhZ2Cua/bOVD1FvxPTcvvBluL5fsk/Ny8mI8mYK/e3Oxp2srM/bvxwbH DkWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="1E6/EL1Q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a21-20020a656415000000b0056554d5dc32si8457250pgv.844.2023.08.14.09.26.49; Mon, 14 Aug 2023 09:27:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="1E6/EL1Q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231226AbjHNQE5 (ORCPT + 99 others); Mon, 14 Aug 2023 12:04:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbjHNQE0 (ORCPT ); Mon, 14 Aug 2023 12:04:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CE76115; Mon, 14 Aug 2023 09:04:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1EC0E63B8C; Mon, 14 Aug 2023 16:04:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDD2FC433C7; Mon, 14 Aug 2023 16:04:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1692029064; bh=pRpAJLUc7dGKoDe04Q0MY/DgnG2HzORkQMrUx8SAsjA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=1E6/EL1QiurAq9zYumlRoJMXAWrk2rLzxtFB8WZ9f8aS5k/5XOl5pfwVt0W/YQgKV +Vb7ZKusuHLXkDPyZ2p1tBfALidALwe23Dji3AWx2DGkHf5LDMbCy/w/FfnVL7wCY4 ThgECuSap/+Q56BzT5WqQMBDnbGGaB746qcoz2PU= Date: Mon, 14 Aug 2023 18:04:21 +0200 From: Greg Kroah-Hartman To: Krzysztof Kozlowski Cc: Nathan Chancellor , Jiri Slaby , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Andi Shyti Subject: Re: [PATCH] serial: mxs-uart: fix Wvoid-pointer-to-enum-cast warning Message-ID: <2023081413-simmering-snap-bb8e@gregkh> References: <20230810085042.39252-1-krzysztof.kozlowski@linaro.org> <2023081004-lapped-handbag-0324@gregkh> <66cbafc5-f490-511c-df9b-02c2e5e40811@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <66cbafc5-f490-511c-df9b-02c2e5e40811@linaro.org> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 14, 2023 at 08:58:34AM +0200, Krzysztof Kozlowski wrote: > On 10/08/2023 17:44, Greg Kroah-Hartman wrote: > > On Thu, Aug 10, 2023 at 10:50:42AM +0200, Krzysztof Kozlowski wrote: > >> `devtype` is enum, thus cast of pointer on 64-bit compile test with W=1 > >> causes: > >> > >> mxs-auart.c:1598:15: error: cast to smaller integer type 'enum mxs_auart_type' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast] > >> > >> Cc: Andi Shyti > >> Signed-off-by: Krzysztof Kozlowski > >> --- > >> drivers/tty/serial/mxs-auart.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c > >> index 8eeecf8ad359..a9b32722b049 100644 > >> --- a/drivers/tty/serial/mxs-auart.c > >> +++ b/drivers/tty/serial/mxs-auart.c > >> @@ -1595,7 +1595,7 @@ static int mxs_auart_probe(struct platform_device *pdev) > >> return -EINVAL; > >> } > >> > >> - s->devtype = (enum mxs_auart_type)of_device_get_match_data(&pdev->dev); > >> + s->devtype = (uintptr_t)of_device_get_match_data(&pdev->dev); > > > > This feels like a compiler issue as devtype is a enum mxs_auart_type > > variable, so the cast shoudl be correct. > > While the cast is obviously safe here, the warning in general is > reasonable - people were make too many mistakes by assuming pointers are > integers... But this isn't a pointer, it's an enumerated type thrown into a void *, so cast it properly (void * == unsigned long). > Just for the record (not saying that others doing is proof of correctness): > > https://lore.kernel.org/lkml/20230809-cbl-1903-v1-1-df9d66a3ba3e@google.com/T/ > > But maybe Nathan can share his thoughts whether we should just disable > this warning for kernel? I thought that Linus had some objection to the compilers doing something foolish here as well, but I can't find it in my archives at the moment (am traveling). > > And if not, unitptr_t isn't a valid kernel type, so that's not a good > > It is in include/linux/types.h, so do you mean that it is not > recommended for in-kernel usage? I can go with kernel_ulong_t - which is > a kernel type - if the cast is agreed. not recommended for in-kernel usage. thanks, greg k-h