Message ID | 20230312132624.352703-1-krzysztof.kozlowski@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp719503wrd; Sun, 12 Mar 2023 06:36:13 -0700 (PDT) X-Google-Smtp-Source: AK7set+I2SYSERw2eW+hwsNoYiP95yvGnAzbl324HreHMyCKE6OFmG3dVCTYvpFiBtU+k57fdMJ1 X-Received: by 2002:a05:6a20:728c:b0:d4:686:4a92 with SMTP id o12-20020a056a20728c00b000d406864a92mr2144762pzk.34.1678628172839; Sun, 12 Mar 2023 06:36:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678628172; cv=none; d=google.com; s=arc-20160816; b=WHxamLKvE67fRJ0Nf8XdeaLVzNM/W5Ejf2i46ekierund0GrVZKyFHYri1T2oBFQFw DQm5N387IjtkAUmZdb0SBUfxxniVsg3Mu4WNBQQ2Zg6K85ZfWq98VYtbRIGntl2b5Uav 9/fXVHYnnFiTKW2SViQZM6BpTF5hMSv9yFtErRKG9BcJjwRIMXjc/zX83mj83+gIJu9G pvLPCziz7jawaOMS62Kpn4w3tjyOAC2mKfl2bDuv0rQAxkFkVqV6BtB5u9EH8UQvBmFi FVfN37pRPRU4PYBoc/jo4XpSp/UUAuTUrah9Op5Vd3wO/++RhDxHtSu0i1YPXsYcx5yP DJqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Bh0gYoy5qUPCzAnHJW2JcAjlXQZm3YAviGSJNEQBYZQ=; b=Hl55KtVG1Pl5PCGpCm9Tl+2PHhscC6ZyRPqHjsp9yfE0bNrGc3LekMWsy3fNV4JLEZ rkdCgQh/bJ2BFc4rDdUGrGQ8tcdfVvIRCG2MPmeW4N03ZH8yXOJf5PA/SYx5c6JG9atV AmoaV0SXybY3eXOTWg4p4Pk7BtkK/qyFebcJCsM0dPWxF4+GRBteKdjXg/v5eWIrHskC F51fctdGqp0vKL5SvQY0Wx7QelN0c1uMAhc7L5cFaKvsPhFzky0nKuLsLUfqvhJMMTPY XO8JTSLMCp52JkspZiRl4C3fzc3HEZr0jJ71NcytiCDKRtsP6ZVdE4j9cD9ymRVKM3v7 J9lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AE8WXyIs; 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=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v13-20020a63464d000000b005007daa08b3si3355470pgk.278.2023.03.12.06.35.39; Sun, 12 Mar 2023 06:36:11 -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=@linaro.org header.s=google header.b=AE8WXyIs; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230290AbjCLN0x (ORCPT <rfc822;realc9580@gmail.com> + 99 others); Sun, 12 Mar 2023 09:26:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229946AbjCLN0p (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 12 Mar 2023 09:26:45 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF58D1D904 for <linux-kernel@vger.kernel.org>; Sun, 12 Mar 2023 06:26:27 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id cn21so8389222edb.0 for <linux-kernel@vger.kernel.org>; Sun, 12 Mar 2023 06:26:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678627586; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Bh0gYoy5qUPCzAnHJW2JcAjlXQZm3YAviGSJNEQBYZQ=; b=AE8WXyIsIJt5ke8dzRYox1xQcFkZ28l6Zo3mfMVVqmNUwbxVROLa6c3pvO9qmeljqY E/xYtw9DqE/iUiHlJOWrNNSzyI9DZIxk4tpHawu+sAulRGiTwI4A/XHXd5qzS7DSr4HF dK4L7LyAgFSjAvBF+MNFJaIlTdxSuokRbi8yq7tfreZChgXQUvgt2357t1NfHHxHKIM+ xmzG0KxIU32mWu9HAmCV2csig/JBVVwqg/+RWgv6iZHh0ch/qkq4A2ri5oZT3BkJFnUJ msFNMLX1BQjXfxOFoVFU69JDipyDcxPwegz+7vqtIf6/mMId5fS3dlNaRGzvT8Cd87Vo Ja9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678627586; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Bh0gYoy5qUPCzAnHJW2JcAjlXQZm3YAviGSJNEQBYZQ=; b=GgkDrJQXqKPdKaOjORjVpztJSs6jiGP/3nzbWv0dP7MvhOAOwETRWrIS8MmOiGXhOa ufWTwQ5UeBvpDEIZbbyURIIZdK8ZM+bIvgoXCQfRPTQxiCR67e9eThotmP6HlkojSd0V aIv6uGC+YaBFHi6pxc88QvMwcpB7ePR3ZYEyM/0uRZiXRqeikCP0KU00UBqPv/uLbSxQ kNqcKm942Aaw+b9D5SxHqv5MUHP4zZo7PB01xgIOV/XpGbMjduxLaytU6qWGyCRNeDhQ UyPhZ8hsn2wFQ0R0cqeNxRRn7bTOX4D+YSrFAmkbChheKxMj8OfvTwyfc0FsF6zm9Wjm B00Q== X-Gm-Message-State: AO0yUKV5asN9au2c3ogEiBVXrxXD1rEMdAlVAuW8HxH0/AtSa3RgOPAv tMhUe8Rn3AnZnTUr2kLmqAy4Hhk2pq5WmfrBHSQ= X-Received: by 2002:a17:906:8506:b0:920:38f:b6ce with SMTP id i6-20020a170906850600b00920038fb6cemr4461649ejx.33.1678627586208; Sun, 12 Mar 2023 06:26:26 -0700 (PDT) Received: from krzk-bin.. ([2a02:810d:15c0:828:d9f6:3e61:beeb:295a]) by smtp.gmail.com with ESMTPSA id xc14-20020a170907074e00b008b904cb2bcdsm2262530ejb.11.2023.03.12.06.26.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Mar 2023 06:26:25 -0700 (PDT) From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> To: Hans de Goede <hdegoede@redhat.com>, Mark Gross <markgross@kernel.org>, Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>, Daniel Oliveira Nascimento <don@syst.com.br>, Mattia Dongili <malattia@linux.it>, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Subject: [PATCH 1/3] platform: olpc: mark SPI related data as maybe unused Date: Sun, 12 Mar 2023 14:26:22 +0100 Message-Id: <20230312132624.352703-1-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760169213724100450?= X-GMAIL-MSGID: =?utf-8?q?1760169213724100450?= |
Series |
[1/3] platform: olpc: mark SPI related data as maybe unused
|
|
Commit Message
Krzysztof Kozlowski
March 12, 2023, 1:26 p.m. UTC
The driver can be compile tested as built-in making certain data unused:
drivers/platform/olpc/olpc-xo175-ec.c:737:35: error: ‘olpc_xo175_ec_id_table’ defined but not used [-Werror=unused-const-variable=]
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/platform/olpc/olpc-xo175-ec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hi Krzysztof, On 3/12/23 14:26, Krzysztof Kozlowski wrote: > The driver can be compile tested as built-in making certain data unused: > > drivers/platform/olpc/olpc-xo175-ec.c:737:35: error: ‘olpc_xo175_ec_id_table’ defined but not used [-Werror=unused-const-variable=] > > Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> > --- > drivers/platform/olpc/olpc-xo175-ec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/platform/olpc/olpc-xo175-ec.c b/drivers/platform/olpc/olpc-xo175-ec.c > index 4823bd2819f6..04573495ef5a 100644 > --- a/drivers/platform/olpc/olpc-xo175-ec.c > +++ b/drivers/platform/olpc/olpc-xo175-ec.c > @@ -734,7 +734,7 @@ static const struct of_device_id olpc_xo175_ec_of_match[] = { > }; > MODULE_DEVICE_TABLE(of, olpc_xo175_ec_of_match); > > -static const struct spi_device_id olpc_xo175_ec_id_table[] = { > +static const struct spi_device_id olpc_xo175_ec_id_table[] __maybe_unused = { > { "xo1.75-ec", 0 }, > {} > }; > MODULE_DEVICE_TABLE(spi, olpc_xo175_ec_id_table); The whole presence of the olpc_xo175_ec_id_table[] seems to make little sense. This should be referenced by: static struct spi_driver olpc_xo175_ec_spi_driver = { Like this: .probe = olpc_xo175_ec_probe, .remove = olpc_xo175_ec_remove, + .id_table = olpc_xo175_ec_id_table, Otherwise those ids cannot be used to load the driver the non DT/of way. Since the driver assumingly does actually bind already this means that it is only used the DT/of way and it seems to me that the whole olpc_xo175_ec_id_table[] can be removed entirely. Exposing modaliases for a non supported way of binding the driver does not really seem useful ? Patches 2/3 and 3/3 do make sense, I'll merge those soonish. Regards, Hans
On 16/03/2023 13:50, Hans de Goede wrote: > Hi Krzysztof, > > On 3/12/23 14:26, Krzysztof Kozlowski wrote: >> The driver can be compile tested as built-in making certain data unused: >> >> drivers/platform/olpc/olpc-xo175-ec.c:737:35: error: ‘olpc_xo175_ec_id_table’ defined but not used [-Werror=unused-const-variable=] >> >> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> >> --- >> drivers/platform/olpc/olpc-xo175-ec.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/platform/olpc/olpc-xo175-ec.c b/drivers/platform/olpc/olpc-xo175-ec.c >> index 4823bd2819f6..04573495ef5a 100644 >> --- a/drivers/platform/olpc/olpc-xo175-ec.c >> +++ b/drivers/platform/olpc/olpc-xo175-ec.c >> @@ -734,7 +734,7 @@ static const struct of_device_id olpc_xo175_ec_of_match[] = { >> }; >> MODULE_DEVICE_TABLE(of, olpc_xo175_ec_of_match); >> >> -static const struct spi_device_id olpc_xo175_ec_id_table[] = { >> +static const struct spi_device_id olpc_xo175_ec_id_table[] __maybe_unused = { >> { "xo1.75-ec", 0 }, >> {} >> }; >> MODULE_DEVICE_TABLE(spi, olpc_xo175_ec_id_table); > > The whole presence of the olpc_xo175_ec_id_table[] seems to make little sense. > > This should be referenced by: > > static struct spi_driver olpc_xo175_ec_spi_driver = { > > Like this: > > .probe = olpc_xo175_ec_probe, > .remove = olpc_xo175_ec_remove, > + .id_table = olpc_xo175_ec_id_table, Yes, it should. > > Otherwise those ids cannot be used to load the driver the non DT/of way. Since the driver assumingly does actually bind already this means that it is only used the DT/of way and it seems to me that the whole olpc_xo175_ec_id_table[] can be removed entirely. > > Exposing modaliases for a non supported way of binding the driver does not really seem useful ? However binding the device and module loading (uevent) uses sometimes different pieces. Maybe something changed in kernel, but sometime ago certain buses where sending uevent for module loading with one ID (e.g. platform or spi bus) but device matching would be according to OF. Thus if you did not have entries in spi_device_id, the module would not autoload. It was exactly the case for example here: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c46ed2281bbe4b84e6f3d4bdfb0e4e9ab813fa9d&context=30&ignorews=0&dt=0 You needed spi_device_id for proper module autoloading. Unless something change in between in the kernel? (+CC Javier, author of that commit) Best regards, Krzysztof
Hi, On 3/16/23 15:07, Krzysztof Kozlowski wrote: > On 16/03/2023 13:50, Hans de Goede wrote: >> Hi Krzysztof, >> >> On 3/12/23 14:26, Krzysztof Kozlowski wrote: >>> The driver can be compile tested as built-in making certain data unused: >>> >>> drivers/platform/olpc/olpc-xo175-ec.c:737:35: error: ‘olpc_xo175_ec_id_table’ defined but not used [-Werror=unused-const-variable=] >>> >>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> >>> --- >>> drivers/platform/olpc/olpc-xo175-ec.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/platform/olpc/olpc-xo175-ec.c b/drivers/platform/olpc/olpc-xo175-ec.c >>> index 4823bd2819f6..04573495ef5a 100644 >>> --- a/drivers/platform/olpc/olpc-xo175-ec.c >>> +++ b/drivers/platform/olpc/olpc-xo175-ec.c >>> @@ -734,7 +734,7 @@ static const struct of_device_id olpc_xo175_ec_of_match[] = { >>> }; >>> MODULE_DEVICE_TABLE(of, olpc_xo175_ec_of_match); >>> >>> -static const struct spi_device_id olpc_xo175_ec_id_table[] = { >>> +static const struct spi_device_id olpc_xo175_ec_id_table[] __maybe_unused = { >>> { "xo1.75-ec", 0 }, >>> {} >>> }; >>> MODULE_DEVICE_TABLE(spi, olpc_xo175_ec_id_table); >> >> The whole presence of the olpc_xo175_ec_id_table[] seems to make little sense. >> >> This should be referenced by: >> >> static struct spi_driver olpc_xo175_ec_spi_driver = { >> >> Like this: >> >> .probe = olpc_xo175_ec_probe, >> .remove = olpc_xo175_ec_remove, >> + .id_table = olpc_xo175_ec_id_table, > > Yes, it should. > >> >> Otherwise those ids cannot be used to load the driver the non DT/of way. Since the driver assumingly does actually bind already this means that it is only used the DT/of way and it seems to me that the whole olpc_xo175_ec_id_table[] can be removed entirely. >> >> Exposing modaliases for a non supported way of binding the driver does not really seem useful ? > > However binding the device and module loading (uevent) uses sometimes > different pieces. Maybe something changed in kernel, but sometime ago > certain buses where sending uevent for module loading with one ID (e.g. > platform or spi bus) but device matching would be according to OF. Thus > if you did not have entries in spi_device_id, the module would not autoload. > > It was exactly the case for example here: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c46ed2281bbe4b84e6f3d4bdfb0e4e9ab813fa9d&context=30&ignorews=0&dt=0 > > You needed spi_device_id for proper module autoloading. > > Unless something change in between in the kernel? Looks like your right, the spi_uevent() code always emits "spi:xxxxxxx" style modalias even for dt/of enumerated devices: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/spi/spi.c#n398 So the table needs to stay. Can you do a v2 (of just this patch) adding an id_table entry to olpc_xo175_ec_spi_driver rather then using __maybe_unused ? Regards, Hans
On 16/03/2023 15:13, Hans de Goede wrote: > > Looks like your right, the spi_uevent() code always emits "spi:xxxxxxx" style modalias even for dt/of enumerated devices: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/spi/spi.c#n398 > > So the table needs to stay. > > Can you do a v2 (of just this patch) adding an id_table entry to olpc_xo175_ec_spi_driver rather then using __maybe_unused ? Yes, sure. Best regards, Krzysztof
Hans de Goede <hdegoede@redhat.com> writes: [...] >>> Exposing modaliases for a non supported way of binding the driver does not really seem useful ? >> >> However binding the device and module loading (uevent) uses sometimes >> different pieces. Maybe something changed in kernel, but sometime ago >> certain buses where sending uevent for module loading with one ID (e.g. >> platform or spi bus) but device matching would be according to OF. Thus >> if you did not have entries in spi_device_id, the module would not autoload. >> >> It was exactly the case for example here: >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c46ed2281bbe4b84e6f3d4bdfb0e4e9ab813fa9d&context=30&ignorews=0&dt=0 >> >> You needed spi_device_id for proper module autoloading. >> >> Unless something change in between in the kernel? > > Looks like your right, the spi_uevent() code always emits "spi:xxxxxxx" style modalias even for dt/of enumerated devices: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/spi/spi.c#n398 > > So the table needs to stay. > Yeah, and in fact dropping the spi_device_id table will cause the kernel to warn that an spi_device_id entry doesn't exist for a given of_device_id entry since commit 5fa6863ba692 ("spi: Check we have a spi_device_id for each DT compatible"). Fixing that is not trivial because a lot of drivers are rely on current behaviour of the SPI core always returning a spi:<dev> modalias. So don't even have an OF table, even when the SPI devices are instantiated by DT.
diff --git a/drivers/platform/olpc/olpc-xo175-ec.c b/drivers/platform/olpc/olpc-xo175-ec.c index 4823bd2819f6..04573495ef5a 100644 --- a/drivers/platform/olpc/olpc-xo175-ec.c +++ b/drivers/platform/olpc/olpc-xo175-ec.c @@ -734,7 +734,7 @@ static const struct of_device_id olpc_xo175_ec_of_match[] = { }; MODULE_DEVICE_TABLE(of, olpc_xo175_ec_of_match); -static const struct spi_device_id olpc_xo175_ec_id_table[] = { +static const struct spi_device_id olpc_xo175_ec_id_table[] __maybe_unused = { { "xo1.75-ec", 0 }, {} };