From patchwork Wed Aug 9 21:25:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Stitt X-Patchwork-Id: 13348529 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 4A34CC04A94 for ; Wed, 9 Aug 2023 21:26: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:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=7KUhwX4IrO6hlrbFbxpxGGgjNI1EIGK3r026hlyBiH4=; b=wvYrsXwfkS0pJIHlWOXMoZizb0 +Dg20OIdLDPQKxmWBmH6IWsTyVcsWIMdlX+iqRelKVMKl8Yrf2v+lx4xuBWCG/2qvOY3oypQv1o0b XGe0wAUnwZPaA3b03gO86FBnxFxHmvZhez8+gOzwE8xi5TOpIb2vsr567pWJ9QSrcca0Q9T28QUun Fq+o8zBRW1gQL0ZBmZ8ZxAsFqpF1ru5vBh3a0iK4M+SScsq07HMomoFk2d0K0J0pM9FCxIDOUvdLj fmE//iQqcG3oSxfTYkX2XeE82XbMapTaQ6Lf1USfiPM4qfSr30hZXEeXt5tnCXaZgYu2ioHArid+a EYv53cIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qTqgj-005t4p-1N; Wed, 09 Aug 2023 21:25:53 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qTqgd-005t2i-1Q for linux-arm-kernel@lists.infradead.org; Wed, 09 Aug 2023 21:25:48 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5897d05e878so4211787b3.3 for ; Wed, 09 Aug 2023 14:25:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691616345; x=1692221145; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xDx0Hy/g05LsgjXJunLNKRIVZ1PiGzjJ3aP3yYS1SPs=; b=q95v/fDBA425ZRj8HB8knec/n4Wh3vXc8UbBeQ9+7ttjuOkZDgYRPpnfEmLqXf/K0c 9vUIwMzhWqcCXcQ3ORw3unREK+rNDPA94GFJB3geeKvjgleAH2TJzWdB4aiD1AgfKkI9 Z/bn4LDdalSqacEfSDlGVSB+SrKHJq+8AHxcNmoUPLE2evR/gffiSsW98OvDz7w+3DyV T8HJ4BVxsFz1/VC2CZS3v9TY2Ew85MTPbGOCkMlUSQk0LvyVWCWPQ6Q0CKtwX4rYn4Mz Bzrx5iddUJRYh3HidSo+HrZFmOUe4x5eekX/x5QVelGZKMWymoP1yjh830Hf898C+unA TkHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691616345; x=1692221145; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xDx0Hy/g05LsgjXJunLNKRIVZ1PiGzjJ3aP3yYS1SPs=; b=jknxsCEVTzuzYxeo9lkQrsabcrHR6e+g+motimFPTF4d7PsWdCRyb4GTicKocxOsUU /ypn4E0GD8lSOGtEUoDL1QmJfZo5/wCYOERENjge+TWutRwq5KFGPuo2OlTDA6lP4XS+ MMbFtuykz08UzRn33yclAsNLUreSyneppvP+gD4e+O5jWEvwyl/FC4IAw2i8f1dd3YPR SLIDavyI8XlBIqOL3Ydwc5IW9hAo49M8c86HLeUE0VjJZ2Yiq3TFamn+U9+uo1B/ol+x ga7Cgn+scKdz/sMixuu9zRpLUrAuEwY0L5ckrvzpdUB2DDnvTYeX91oaQAhLhcEwzVca TFww== X-Gm-Message-State: AOJu0YyzzsX5MPoyDJyMhy6kfav1jxAtmUA7USpXBpgtUtnEwqUv+jaU wofFeWgArXg3bXrIr/Z2sAYiXI2YxmGLDRVSzQ== X-Google-Smtp-Source: AGHT+IEsmlDYpjMBJObJR5jz4UIcD43JE1pStIMxSDRZxpyCeyJHub91Vaates1u0eDPesF/KIhjvHlbNAFHmDDJvQ== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a81:b718:0:b0:576:f61f:adbc with SMTP id v24-20020a81b718000000b00576f61fadbcmr8718ywh.1.1691616345223; Wed, 09 Aug 2023 14:25:45 -0700 (PDT) Date: Wed, 09 Aug 2023 21:25:35 +0000 In-Reply-To: <20230809-cbl-1903-v1-0-df9d66a3ba3e@google.com> Mime-Version: 1.0 References: <20230809-cbl-1903-v1-0-df9d66a3ba3e@google.com> X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1691616343; l=1671; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=1jpubBEYs5G/kONM8KXG1tjVjaf45XD96u1TgLGh88c=; b=HD13U7Lf7gLBUJgdxnwIDWUS5iUmJBBrEtQkf3kdA3nIJwjjfZ/thVFMV1IjFQZf6I2y84s5B 9rseL9CjIuVBaaF60aQ2gvWP/yFSYM2Erz2oCmo8XTvy/PYDz3u5bej X-Mailer: b4 0.12.3 Message-ID: <20230809-cbl-1903-v1-1-df9d66a3ba3e@google.com> Subject: [PATCH 1/2] i2c: i2c-bcm-iproc: fix -Wvoid-pointer-to-enum-cast warning From: Justin Stitt To: Andi Shyti , Ray Jui , Scott Branden , Broadcom internal kernel review list Cc: linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Nathan Chancellor , Justin Stitt X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230809_142547_494619_6FED719E 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 When building with W=1 we see the following warning: | drivers/i2c/busses/i2c-bcm-iproc.c:1039:3: error: cast to smaller \ | integer type 'enum bcm_iproc_i2c_type' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast] | 1039 | (enum bcm_iproc_i2c_type)of_device_get_match_data(&pdev->dev); | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is due to the fact that the `bcm_iproc_i2c_type` enum members are int-width and a cast from pointer-width down to int will cause truncation and possible data loss. Although in this case `bcm_iproc_i2c_type` has only a few enumerated fields and thus there is likely no data loss occurring. Nonetheless, this patch is necessary to the goal of promoting this warning out of W=1. Link: https://github.com/ClangBuiltLinux/linux/issues/1903 Signed-off-by: Justin Stitt --- drivers/i2c/busses/i2c-bcm-iproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c b/drivers/i2c/busses/i2c-bcm-iproc.c index 2d8342fdc25d..3464f3a376a5 100644 --- a/drivers/i2c/busses/i2c-bcm-iproc.c +++ b/drivers/i2c/busses/i2c-bcm-iproc.c @@ -1036,7 +1036,7 @@ static int bcm_iproc_i2c_probe(struct platform_device *pdev) platform_set_drvdata(pdev, iproc_i2c); iproc_i2c->device = &pdev->dev; iproc_i2c->type = - (enum bcm_iproc_i2c_type)of_device_get_match_data(&pdev->dev); + (unsigned long) of_device_get_match_data(&pdev->dev); init_completion(&iproc_i2c->done); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);