Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/panel: sitronix-st7789v: avoid hardcoding mode info

Avoid hard-coding the default_mode and supply it from match data. One
additional layer of abstraction has been introduced, which will be
needed for specifying other panel information (e.g. bus flags) in the
next steps.

Reviewed-by: Michael Riesch <michael.riesch@wolfvision.net>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230714013756.1546769-9-sre@kernel.org

authored by

Sebastian Reichel and committed by
Neil Armstrong
9b4454fa bc2aa99b

+18 -6
+18 -6
drivers/gpu/drm/panel/panel-sitronix-st7789v.c
··· 108 108 return val; \ 109 109 } while (0) 110 110 111 + struct st7789_panel_info { 112 + const struct drm_display_mode *mode; 113 + }; 114 + 111 115 struct st7789v { 112 116 struct drm_panel panel; 117 + const struct st7789_panel_info *info; 113 118 struct spi_device *spi; 114 119 struct gpio_desc *reset; 115 120 struct regulator *power; ··· 165 160 .vtotal = 320 + 8 + 4 + 4, 166 161 }; 167 162 163 + static const struct st7789_panel_info default_panel = { 164 + .mode = &default_mode, 165 + }; 166 + 168 167 static int st7789v_get_modes(struct drm_panel *panel, 169 168 struct drm_connector *connector) 170 169 { 170 + struct st7789v *ctx = panel_to_st7789v(panel); 171 171 struct drm_display_mode *mode; 172 172 173 - mode = drm_mode_duplicate(connector->dev, &default_mode); 173 + mode = drm_mode_duplicate(connector->dev, ctx->info->mode); 174 174 if (!mode) { 175 - dev_err(panel->dev, "failed to add mode %ux%ux@%u\n", 176 - default_mode.hdisplay, default_mode.vdisplay, 177 - drm_mode_vrefresh(&default_mode)); 175 + dev_err(panel->dev, "failed to add mode %ux%u@%u\n", 176 + ctx->info->mode->hdisplay, ctx->info->mode->vdisplay, 177 + drm_mode_vrefresh(ctx->info->mode)); 178 178 return -ENOMEM; 179 179 } 180 180 ··· 369 359 spi_set_drvdata(spi, ctx); 370 360 ctx->spi = spi; 371 361 362 + ctx->info = device_get_match_data(&spi->dev); 363 + 372 364 drm_panel_init(&ctx->panel, dev, &st7789v_drm_funcs, 373 365 DRM_MODE_CONNECTOR_DPI); 374 366 ··· 401 389 } 402 390 403 391 static const struct spi_device_id st7789v_spi_id[] = { 404 - { "st7789v" }, 392 + { "st7789v", (unsigned long) &default_panel }, 405 393 { } 406 394 }; 407 395 MODULE_DEVICE_TABLE(spi, st7789v_spi_id); 408 396 409 397 static const struct of_device_id st7789v_of_match[] = { 410 - { .compatible = "sitronix,st7789v" }, 398 + { .compatible = "sitronix,st7789v", .data = &default_panel }, 411 399 { } 412 400 }; 413 401 MODULE_DEVICE_TABLE(of, st7789v_of_match);