[PATCH -next v2] drm/bridge: fix -Wunused-const-variable= warning

Arnd Bergmann arnd at arndb.de
Fri Jul 28 10:36:00 UTC 2023


On Fri, Jul 28, 2023, at 11:12, Zhu Wang wrote:
> When building with W=1, the following warning occurs.
>
> drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c:48:17: warning: 
> ‘anx781x_i2c_addresses’ defined but not used [-Wunused-const-variable=] 
>  static const u8 anx781x_i2c_addresses[] = {
>                  ^~~~~~~~~~~~~~~~~~~~~
> drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c:40:17: warning: 
> ‘anx7808_i2c_addresses’ defined but not used [-Wunused-const-variable=] 
>  static const u8 anx7808_i2c_addresses[] = {
>
> When CONFIG_IO is disabled, above two variables are not used,
> since the place where it is used is inclueded in the macro
> CONFIG_OF.
>
> The drivers under the directory drivers/gpu/drm/bridge depends
> on the macro CONFIG_OF, it is not necessary to use CONFIG_OF
> or of_match_ptr in related files in this directory, so we just
> remove them all.

Note that even for drivers that do not depend on CONFIG_OF,
it's almost always better to leave out the of_match_ptr(),
since the only thing it can possibly do is save a few bytes
of .text if a driver can be used both with and without it.

> Fixes: 0647e7dd3f7a ("drm/bridge: Add Analogix anx78xx support")
> Signed-off-by: Zhu Wang <wangzhu9 at huawei.com>

Reviewed-by: Arnd Bergmann <arnd at arndb.de>


More information about the dri-devel mailing list