Skip to content

Commit 5d40d4f

Browse files
drm/ssd130x: Set SPI .id_table to prevent an SPI core warning
The only reason for the ssd130x-spi driver to have an spi_device_id table is that the SPI core always reports an "spi:" MODALIAS, even when the SPI device has been registered via a Device Tree Blob. Without spi_device_id table information in the module's metadata, module autoloading would not work because there won't be an alias that matches the MODALIAS reported by the SPI core. This spi_device_id table is not needed for device matching though, since the of_device_id table is always used in this case. For this reason, the struct spi_driver .id_table member is currently not set in the SPI driver. Because the spi_device_id table is always required for module autoloading, the SPI core checks during driver registration that both an of_device_id table and a spi_device_id table are present and that they contain the same entries for all the SPI devices. Not setting the .id_table member in the driver then confuses the core and leads to the following warning when the ssd130x-spi driver is registered: [ 41.091198] SPI driver ssd130x-spi has no spi_device_id for sinowealth,sh1106 [ 41.098614] SPI driver ssd130x-spi has no spi_device_id for solomon,ssd1305 [ 41.105862] SPI driver ssd130x-spi has no spi_device_id for solomon,ssd1306 [ 41.113062] SPI driver ssd130x-spi has no spi_device_id for solomon,ssd1307 [ 41.120247] SPI driver ssd130x-spi has no spi_device_id for solomon,ssd1309 [ 41.127449] SPI driver ssd130x-spi has no spi_device_id for solomon,ssd1322 [ 41.134627] SPI driver ssd130x-spi has no spi_device_id for solomon,ssd1325 [ 41.141784] SPI driver ssd130x-spi has no spi_device_id for solomon,ssd1327 [ 41.149021] SPI driver ssd130x-spi has no spi_device_id for solomon,ssd1331 To prevent the warning, set the .id_table even though it's not necessary. Since the check is done even for built-in drivers, drop the condition to only define the ID table when the driver is built as a module. Finally, rename the variable to use the "_spi_id" convention used for ID tables. Fixes: 7437397 ("drm/solomon: Add SSD130x OLED displays SPI support") Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://patchwork.freedesktop.org/patch/msgid/20241231114516.2063201-1-javierm@redhat.com Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
1 parent 88849f2 commit 5d40d4f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/gpu/drm/solomon/ssd130x-spi.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ static const struct of_device_id ssd130x_of_match[] = {
151151
};
152152
MODULE_DEVICE_TABLE(of, ssd130x_of_match);
153153

154-
#if IS_MODULE(CONFIG_DRM_SSD130X_SPI)
155154
/*
156155
* The SPI core always reports a MODALIAS uevent of the form "spi:<dev>", even
157156
* if the device was registered via OF. This means that the module will not be
@@ -160,7 +159,7 @@ MODULE_DEVICE_TABLE(of, ssd130x_of_match);
160159
* To workaround this issue, add a SPI device ID table. Even when this should
161160
* not be needed for this driver to match the registered SPI devices.
162161
*/
163-
static const struct spi_device_id ssd130x_spi_table[] = {
162+
static const struct spi_device_id ssd130x_spi_id[] = {
164163
/* ssd130x family */
165164
{ "sh1106", SH1106_ID },
166165
{ "ssd1305", SSD1305_ID },
@@ -175,14 +174,14 @@ static const struct spi_device_id ssd130x_spi_table[] = {
175174
{ "ssd1331", SSD1331_ID },
176175
{ /* sentinel */ }
177176
};
178-
MODULE_DEVICE_TABLE(spi, ssd130x_spi_table);
179-
#endif
177+
MODULE_DEVICE_TABLE(spi, ssd130x_spi_id);
180178

181179
static struct spi_driver ssd130x_spi_driver = {
182180
.driver = {
183181
.name = DRIVER_NAME,
184182
.of_match_table = ssd130x_of_match,
185183
},
184+
.id_table = ssd130x_spi_id,
186185
.probe = ssd130x_spi_probe,
187186
.remove = ssd130x_spi_remove,
188187
.shutdown = ssd130x_spi_shutdown,

0 commit comments

Comments
 (0)