MFD fixes for v5.12
Good afternoon Linus,
The following changes since commit a38fd8748464831584a19438cbb3082b5a2dab15:
Linux 5.12-rc2 (2021-03-05 17:33:41 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git tags/mfd-fixes-5.12
for you to fetch changes up to a61f4661fba404418a7c77e86586dc52a58a93c6:
mfd: intel_quark_i2c_gpio: Revert "Constify static struct resources" (2021-03-23 09:14:12 +0000)
----------------------------------------------------------------
- Bug Fixes
- Unconstify editable placeholder structures
----------------------------------------------------------------
Andy Shevchenko (1):
mfd: intel_quark_i2c_gpio: Revert "Constify static struct resources"
drivers/mfd/intel_quark_i2c_gpio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Quoted 2 lines · Lee Jones
- 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
Quoted 27 lines · Linus Torvalds
Quoted 2 lines · Lee Jones
- 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.
Quoted 8 lines
This broken pattern shows up for both
intel_quark_i2c_setup()andintel_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).
Thanks for pointing this out! I'll take it in my TODO list.
Hmm... I missed the above b/c I have seen the pattern of supplying non-const data structures via .driver_data field and thought that here is something similar without looking into the actual approach.
Signature · 2 lines
With Best Regards, Andy Shevchenko
The pull request you sent on Thu, 25 Mar 2021 16:33:58 +0000:
The pull request you sent on Thu, 25 Mar 2021 16:33:58 +0000:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.gittags/mfd-fixes-5.12
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/58e4b9de9d98599d539ad71c7c31f53c0d1f5aba
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html