Commit bc2aa99b authored by Sebastian Reichel's avatar Sebastian Reichel Committed by Neil Armstrong
Browse files

drm/panel: sitronix-st7789v: improve error handling



Improve error handling in the probe routine, so that probe
defer errors are captured in /sys/kernel/debug/devices_deferred

Reviewed-by: default avatarMichael Riesch <michael.riesch@wolfvision.net>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
Signed-off-by: default avatarNeil Armstrong <neil.armstrong@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230714013756.1546769-8-sre@kernel.org
parent fbad26dc
Loading
Loading
Loading
Loading
+12 −11
Original line number Original line Diff line number Diff line
@@ -348,32 +348,33 @@ static const struct drm_panel_funcs st7789v_drm_funcs = {


static int st7789v_probe(struct spi_device *spi)
static int st7789v_probe(struct spi_device *spi)
{
{
	struct device *dev = &spi->dev;
	struct st7789v *ctx;
	struct st7789v *ctx;
	int ret;
	int ret;


	ctx = devm_kzalloc(&spi->dev, sizeof(*ctx), GFP_KERNEL);
	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
	if (!ctx)
	if (!ctx)
		return -ENOMEM;
		return -ENOMEM;


	spi_set_drvdata(spi, ctx);
	spi_set_drvdata(spi, ctx);
	ctx->spi = spi;
	ctx->spi = spi;


	drm_panel_init(&ctx->panel, &spi->dev, &st7789v_drm_funcs,
	drm_panel_init(&ctx->panel, dev, &st7789v_drm_funcs,
		       DRM_MODE_CONNECTOR_DPI);
		       DRM_MODE_CONNECTOR_DPI);


	ctx->power = devm_regulator_get(&spi->dev, "power");
	ctx->power = devm_regulator_get(dev, "power");
	if (IS_ERR(ctx->power))
	ret = PTR_ERR_OR_ZERO(ctx->power);
		return PTR_ERR(ctx->power);
	if (ret)
		return dev_err_probe(dev, ret, "Failed to get regulator\n");


	ctx->reset = devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_LOW);
	ctx->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
	if (IS_ERR(ctx->reset)) {
	ret = PTR_ERR_OR_ZERO(ctx->reset);
		dev_err(&spi->dev, "Couldn't get our reset line\n");
	if (ret)
		return PTR_ERR(ctx->reset);
		return dev_err_probe(dev, ret, "Failed to get reset line\n");
	}


	ret = drm_panel_of_backlight(&ctx->panel);
	ret = drm_panel_of_backlight(&ctx->panel);
	if (ret)
	if (ret)
		return ret;
		return dev_err_probe(dev, ret, "Failed to get backlight\n");


	drm_panel_add(&ctx->panel);
	drm_panel_add(&ctx->panel);