[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wjJxziChniE2zmkbFxEpizYFg=XaKyq_O_Rfh_Lr_idkw@mail.gmail.com>
Date: Thu, 25 Mar 2021 11:23:06 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Lee Jones <lee.jones@...aro.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [GIT PULL] MFD fixes for v5.12
On Thu, Mar 25, 2021 at 9:34 AM Lee Jones <lee.jones@...aro.org> wrote:
>
> - Unconstify editable placeholder structures
Hmm. This does show a real issue with that gpio driver.
It does garbage things:
static int intel_quark_gpio_setup(struct pci_dev *pdev, struct mfd_cell *cell)
{
struct dwapb_platform_data *pdata;
struct resource *res = (struct resource *)cell->resources;
where that cast is exactly because "cell->resources" _is_ const, and
the driver violates that.
This horrible mis-use of a const pointer is why the original patch
that got reverted didn't cause build-time warnings.
Honestly, I think the right thing to do is to get rid of that cast, and do
struct resource *res = intel_quark_mfd_cells;
instead, so that you clearly edit somethign that isn't const, and so
that the compiler would have warned about the whole constification in
the first place.
This broken pattern shows up for both intel_quark_i2c_setup() and
intel_quark_gpio_setup().
I've pulled this, but I really want this kind of "take a const pointer
and violate it" crap removed. It is *only* correct if you know exactly
which pointer it is, and then you should just have used that original
pointer in the first place (ie use that intel_quark_mfd_cells[]
directly like suggested above).
Linus
Powered by blists - more mailing lists