Re: [PATCH 33/34] drivers: remove incorrect of_match_ptr/ACPI_PTR annotations

Peter Rosin
2024-04-23T09:53:01Z

Hi!

2024-04-03 at 10:06, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> When building with CONFIG_OF and/or CONFIG_ACPI disabled but W=1 extra
> warnings enabled, a lot of driver cause a warning about an unused
> ID table:
>
> drivers/char/tpm/tpm_ftpm_tee.c:356:34: error: unused variable 'of_ftpm_tee_ids' [-Werror,-Wunused-const-variable]
> drivers/dma/img-mdc-dma.c:863:34: error: unused variable 'mdc_dma_of_match' [-Werror,-Wunused-const-variable]
> drivers/fpga/versal-fpga.c:62:34: error: unused variable 'versal_fpga_of_match' [-Werror,-Wunused-const-variable]
> drivers/i2c/muxes/i2c-mux-ltc4306.c:200:34: error: unused variable 'ltc4306_of_match' [-Werror,-Wunused-const-variable]
> drivers/i2c/muxes/i2c-mux-reg.c:242:34: error: unused variable 'i2c_mux_reg_of_match' [-Werror,-Wunused-const-variable]
> drivers/memory/pl353-smc.c:62:34: error: unused variable 'pl353_smc_supported_children' [-Werror,-Wunused-const-variable]
> drivers/regulator/pbias-regulator.c:136:34: error: unused variable 'pbias_of_match' [-Werror,-Wunused-const-variable]
> drivers/regulator/twl-regulator.c:552:34: error: unused variable 'twl_of_match' [-Werror,-Wunused-const-variable]
> drivers/regulator/twl6030-regulator.c:645:34: error: unused variable 'twl_of_match' [-Werror,-Wunused-const-variable]
> drivers/scsi/hisi_sas/hisi_sas_v2_hw.c:3635:36: error: unused variable 'sas_v2_acpi_match' [-Werror,-Wunused-const-variable]
> drivers/staging/pi433/pi433_if.c:1359:34: error: unused variable 'pi433_dt_ids' [-Werror,-Wunused-const-variable]
> drivers/tty/serial/amba-pl011.c:2945:34: error: unused variable 'sbsa_uart_of_match' [-Werror,-Wunused-const-variable]
>
> The fix is always to just remove the of_match_ptr() and ACPI_PTR() wrappers
> that remove the reference, rather than adding another #ifdef just for build
> testing for a configuration that doesn't matter in practice.
>
> I considered splitting up the large patch into per subsystem patches, but since
> it's really just the same thing everywhere it feels better to do it all at once.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/char/ipmi/ipmb_dev_int.c | 2 +-
> drivers/char/tpm/tpm_ftpm_tee.c | 2 +-
> drivers/dma/img-mdc-dma.c | 2 +-
> drivers/fpga/versal-fpga.c | 2 +-
> drivers/hid/hid-google-hammer.c | 6 ++----
> drivers/i2c/muxes/i2c-mux-ltc4306.c | 2 +-
> drivers/i2c/muxes/i2c-mux-reg.c | 2 +-
> drivers/input/touchscreen/wdt87xx_i2c.c | 2 +-
> drivers/mux/adg792a.c | 2 +-
> drivers/net/ethernet/apm/xgene-v2/main.c | 2 +-
> drivers/net/ethernet/hisilicon/hns_mdio.c | 2 +-
> drivers/regulator/pbias-regulator.c | 2 +-
> drivers/regulator/twl-regulator.c | 2 +-
> drivers/regulator/twl6030-regulator.c | 2 +-
> drivers/rtc/rtc-fsl-ftm-alarm.c | 2 +-
> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 2 +-
> drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 2 +-
> drivers/staging/pi433/pi433_if.c | 2 +-
> drivers/tty/serial/amba-pl011.c | 6 +++---
> drivers/tty/serial/ma35d1_serial.c | 2 +-
> 20 files changed, 23 insertions(+), 25 deletions(-)

As far as I can tell, this triggers unconditional use of the
.of_match_table, and the compiler will have a harder time dropping
that data. However, the wasted data is negligible for the parts
touching "my" drivers:

drivers/i2c/muxes/i2c-mux-ltc4306.c
drivers/i2c/muxes/i2c-mux-reg.c
drivers/mux/adg729a.c

Acked-by: Peter Rosin <peda@axentia.se>

Cheers,
Peter