From: Nathan Chancellor <nathan@kernel.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: kernel test robot <lkp@intel.com>,
Jakob Hauser <jahau@rocketmail.com>,
Jonathan Cameron <jic23@kernel.org>,
llvm@lists.linux.dev, kbuild-all@lists.01.org,
Lars-Peter Clausen <lars@metafoo.de>,
Linus Walleij <linus.walleij@linaro.org>,
Hans de Goede <hdegoede@redhat.com>,
linux-iio <linux-iio@vger.kernel.org>,
devicetree <devicetree@vger.kernel.org>,
phone-devel@vger.kernel.org,
~postmarketos/upstreaming@lists.sr.ht
Subject: Re: [PATCH v5 09/14] iio: magnetometer: yas530: Introduce "chip_info" structure
Date: Mon, 8 Aug 2022 12:48:59 -0700 [thread overview]
Message-ID: <YvFoq9C00GRZVeZR@dev-arch.thelio-3990X> (raw)
In-Reply-To: <CAHp75VePJ2iKDx0Sj5SErW4nfpx-9KrN3c5yRFyfwgpfnMCkEg@mail.gmail.com>
On Mon, Aug 08, 2022 at 08:04:20PM +0200, Andy Shevchenko wrote:
> On Mon, Aug 8, 2022 at 5:59 PM Nathan Chancellor <nathan@kernel.org> wrote:
> > On Mon, Aug 08, 2022 at 01:18:06PM, +0200, Andy Shevchenko wrote:
> > > On Mon, Aug 8, 2022 at 7:40 AM kernel test robot <lkp@intel.com> wrote:
> > >
> > > ...
> > >
> > > > All errors (new ones prefixed by >>):
> > > >
> > > > >> drivers/iio/magnetometer/yamaha-yas530.c:933:19: error: initializer element is not a compile-time constant
> > > > .product_name = yas5xx_product_name[yas530],
> > > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > > 1 error generated.
> > >
> > > What?!
> > >
> > > The yas530 is a part of the enum, how come that compiler can't see
> > > this? Looks like a Clang bug.
> >
> > That is not what clang is complaining about here, you'll see the same
> > error even if you used '0', '1', or '2' here:
> >
> > drivers/iio/magnetometer/yamaha-yas530.c:933:19: error: initializer element is not a compile-time constant
> > .product_name = yas5xx_product_name[0],
> > ^~~~~~~~~~~~~~~~~~~~~~
> > 1 error generated.
> >
> > It is complaining that the initializer element
> > ('yas5xx_product_name[yas530]', rather than just 'yas530') is not
> > constant, which is a true complaint if I am reading C11 standard 6.6.7
> > correctly.
> >
> > GCC 8+ has chosen to accept const structures as constant expressions in
> > designated initializers, which it is allowed to do per 6.6.10. Nick did
> > have a patch to try and match this behavior in clang but the work that
> > was requested doesn't seem to be trivial so it was never finalized:
> > https://reviews.llvm.org/D76096
> >
> > You'll see the same error with GCC 7:
> >
> > drivers/iio/magnetometer/yamaha-yas530.c:933:19: error: initializer element is not constant
> > .product_name = yas5xx_product_name[yas530],
> > ^~~~~~~~~~~~~~~~~~~
> > drivers/iio/magnetometer/yamaha-yas530.c:933:19: note: (near initialization for ‘yas5xx_chip_info_tbl[0].product_name’)
> > drivers/iio/magnetometer/yamaha-yas530.c:938:19: error: initializer element is not constant
> > .product_name = yas5xx_product_name[yas532],
> > ^~~~~~~~~~~~~~~~~~~
> > drivers/iio/magnetometer/yamaha-yas530.c:938:19: note: (near initialization for ‘yas5xx_chip_info_tbl[1].product_name’)
> > drivers/iio/magnetometer/yamaha-yas530.c:943:19: error: initializer element is not constant
> > .product_name = yas5xx_product_name[yas533],
> > ^~~~~~~~~~~~~~~~~~~
> > drivers/iio/magnetometer/yamaha-yas530.c:943:19: note: (near initialization for ‘yas5xx_chip_info_tbl[2].product_name’)
>
> > > > 930 static const struct yas5xx_chip_info yas5xx_chip_info_tbl[] = {
> > > > 931 [yas530] = {
> > > > 932 .devid = YAS530_DEVICE_ID,
> > > > > 933 .product_name = yas5xx_product_name[yas530],
> > > > 934 .version_name = yas5xx_version_names[yas530],
>
> Would then
>
> .product_name = "YAS530 MS-3E",
> .version_names = { "A", "B" },
>
> work?
I haven't tested it but there is no reason that shouldn't work.
> Jakob, note 's' in the field name as well.
>
> > > > 935 },
> > > > 936 [yas532] = {
> > > > 937 .devid = YAS532_DEVICE_ID,
> > > > 938 .product_name = yas5xx_product_name[yas532],
> > > > 939 .version_name = yas5xx_version_names[yas532],
> > > > 940 },
> > > > 941 [yas533] = {
> > > > 942 .devid = YAS532_DEVICE_ID,
> > > > 943 .product_name = yas5xx_product_name[yas533],
> > > > 944 .version_name = yas5xx_version_names[yas533],
> > > > 945 },
> > > > 946 };
>
> --
> With Best Regards,
> Andy Shevchenko
next prev parent reply other threads:[~2022-08-08 19:49 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1659909060.git.jahau.ref@rocketmail.com>
2022-08-07 23:02 ` [PATCH v5 00/14] Add support for magnetometer Yamaha YAS537 Jakob Hauser
2022-08-07 23:02 ` [PATCH v5 01/14] iio: magnetometer: yas530: Change data type of hard_offsets to signed Jakob Hauser
2022-08-07 23:02 ` [PATCH v5 02/14] iio: magnetometer: yas530: Change range of data in volatile register Jakob Hauser
2022-08-07 23:02 ` [PATCH v5 03/14] iio: magnetometer: yas530: Correct scaling of magnetic axes Jakob Hauser
2022-08-07 23:02 ` [PATCH v5 04/14] iio: magnetometer: yas530: Correct temperature handling Jakob Hauser
2022-08-07 23:02 ` [PATCH v5 05/14] iio: magnetometer: yas530: Change data type of calibration coefficients Jakob Hauser
2022-08-07 23:02 ` [PATCH v5 06/14] iio: magnetometer: yas530: Rename functions and registers Jakob Hauser
2022-08-08 11:08 ` Andy Shevchenko
2022-08-09 23:23 ` Jakob Hauser
2022-08-07 23:06 ` [PATCH v5 07/14] iio: magnetometer: yas530: Move printk %*ph parameters out from stack Jakob Hauser
2022-08-08 11:10 ` Andy Shevchenko
2022-08-09 23:24 ` Jakob Hauser
2022-08-07 23:06 ` [PATCH v5 08/14] iio: magnetometer: yas530: Apply documentation and style fixes Jakob Hauser
2022-08-07 23:06 ` [PATCH v5 09/14] iio: magnetometer: yas530: Introduce "chip_info" structure Jakob Hauser
2022-08-08 5:39 ` kernel test robot
2022-08-08 11:18 ` Andy Shevchenko
2022-08-08 11:24 ` Andy Shevchenko
2022-08-08 15:59 ` Nathan Chancellor
2022-08-08 18:04 ` Andy Shevchenko
2022-08-08 19:48 ` Nathan Chancellor [this message]
2022-08-09 23:26 ` Jakob Hauser
2022-08-08 11:22 ` Andy Shevchenko
2022-08-09 23:29 ` Jakob Hauser
2022-08-08 11:32 ` Andy Shevchenko
2022-08-09 23:32 ` Jakob Hauser
2022-08-07 23:06 ` [PATCH v5 10/14] iio: magnetometer: yas530: Add volatile registers to "chip_info" Jakob Hauser
2022-08-08 11:33 ` Andy Shevchenko
2022-08-07 23:06 ` [PATCH v5 11/14] iio: magnetometer: yas530: Add IIO scaling " Jakob Hauser
2022-08-08 11:33 ` Andy Shevchenko
2022-08-07 23:06 ` [PATCH v5 12/14] iio: magnetometer: yas530: Add temperature calculation " Jakob Hauser
2022-08-08 11:36 ` Andy Shevchenko
2022-08-09 23:36 ` Jakob Hauser
2022-08-07 23:06 ` [PATCH v5 13/14] iio: magnetometer: yas530: Add function pointers " Jakob Hauser
2022-08-08 11:37 ` Andy Shevchenko
2022-08-09 23:38 ` Jakob Hauser
2022-08-07 23:12 ` [PATCH v5 14/14] iio: magnetometer: yas530: Add YAS537 variant Jakob Hauser
2022-08-08 11:47 ` Andy Shevchenko
2022-08-09 23:41 ` Jakob Hauser
2022-08-12 21:43 ` Linus Walleij
2022-08-12 21:49 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YvFoq9C00GRZVeZR@dev-arch.thelio-3990X \
--to=nathan@kernel.org \
--cc=andy.shevchenko@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=hdegoede@redhat.com \
--cc=jahau@rocketmail.com \
--cc=jic23@kernel.org \
--cc=kbuild-all@lists.01.org \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
--cc=phone-devel@vger.kernel.org \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox