Commit e291d298 authored by Stefan Agner's avatar Stefan Agner

drm/fsl-dcu: remove regmap return value checks

It is not common to do regmap return value checks, especially not
for memory mapped device. We can rule out most error returns since
the conditions are static and we know they are ok (e.g. offset
aligned to register stride). Also without proper error handling
they are not really valuable for the user. Hence remove most of
them.

The check in the interrupt handler is worth keeping since a
volatile register won't be readable in case register caching is
still enabled.
Signed-off-by: default avatarStefan Agner <stefan@agner.ch>
parent efb8b491
...@@ -42,34 +42,24 @@ static void fsl_dcu_drm_disable_crtc(struct drm_crtc *crtc) ...@@ -42,34 +42,24 @@ static void fsl_dcu_drm_disable_crtc(struct drm_crtc *crtc)
{ {
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
int ret;
ret = regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE, regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
DCU_MODE_DCU_MODE_MASK, DCU_MODE_DCU_MODE_MASK,
DCU_MODE_DCU_MODE(DCU_MODE_OFF)); DCU_MODE_DCU_MODE(DCU_MODE_OFF));
if (ret) regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
dev_err(fsl_dev->dev, "Disable CRTC failed\n");
ret = regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
DCU_UPDATE_MODE_READREG); DCU_UPDATE_MODE_READREG);
if (ret)
dev_err(fsl_dev->dev, "Enable CRTC failed\n");
} }
static void fsl_dcu_drm_crtc_enable(struct drm_crtc *crtc) static void fsl_dcu_drm_crtc_enable(struct drm_crtc *crtc)
{ {
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
int ret;
ret = regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE, regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
DCU_MODE_DCU_MODE_MASK, DCU_MODE_DCU_MODE_MASK,
DCU_MODE_DCU_MODE(DCU_MODE_NORMAL)); DCU_MODE_DCU_MODE(DCU_MODE_NORMAL));
if (ret) regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
dev_err(fsl_dev->dev, "Enable CRTC failed\n");
ret = regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
DCU_UPDATE_MODE_READREG); DCU_UPDATE_MODE_READREG);
if (ret)
dev_err(fsl_dev->dev, "Enable CRTC failed\n");
} }
static bool fsl_dcu_drm_crtc_mode_fixup(struct drm_crtc *crtc, static bool fsl_dcu_drm_crtc_mode_fixup(struct drm_crtc *crtc,
...@@ -86,7 +76,6 @@ static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc *crtc) ...@@ -86,7 +76,6 @@ static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc *crtc)
struct drm_display_mode *mode = &crtc->state->mode; struct drm_display_mode *mode = &crtc->state->mode;
unsigned int hbp, hfp, hsw, vbp, vfp, vsw, div, index; unsigned int hbp, hfp, hsw, vbp, vfp, vsw, div, index;
unsigned long dcuclk; unsigned long dcuclk;
int ret;
index = drm_crtc_index(crtc); index = drm_crtc_index(crtc);
dcuclk = clk_get_rate(fsl_dev->clk); dcuclk = clk_get_rate(fsl_dev->clk);
...@@ -100,51 +89,31 @@ static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc *crtc) ...@@ -100,51 +89,31 @@ static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc *crtc)
vfp = mode->vsync_start - mode->vdisplay; vfp = mode->vsync_start - mode->vdisplay;
vsw = mode->vsync_end - mode->vsync_start; vsw = mode->vsync_end - mode->vsync_start;
ret = regmap_write(fsl_dev->regmap, DCU_HSYN_PARA, regmap_write(fsl_dev->regmap, DCU_HSYN_PARA,
DCU_HSYN_PARA_BP(hbp) | DCU_HSYN_PARA_BP(hbp) |
DCU_HSYN_PARA_PW(hsw) | DCU_HSYN_PARA_PW(hsw) |
DCU_HSYN_PARA_FP(hfp)); DCU_HSYN_PARA_FP(hfp));
if (ret) regmap_write(fsl_dev->regmap, DCU_VSYN_PARA,
goto set_failed;
ret = regmap_write(fsl_dev->regmap, DCU_VSYN_PARA,
DCU_VSYN_PARA_BP(vbp) | DCU_VSYN_PARA_BP(vbp) |
DCU_VSYN_PARA_PW(vsw) | DCU_VSYN_PARA_PW(vsw) |
DCU_VSYN_PARA_FP(vfp)); DCU_VSYN_PARA_FP(vfp));
if (ret) regmap_write(fsl_dev->regmap, DCU_DISP_SIZE,
goto set_failed;
ret = regmap_write(fsl_dev->regmap, DCU_DISP_SIZE,
DCU_DISP_SIZE_DELTA_Y(mode->vdisplay) | DCU_DISP_SIZE_DELTA_Y(mode->vdisplay) |
DCU_DISP_SIZE_DELTA_X(mode->hdisplay)); DCU_DISP_SIZE_DELTA_X(mode->hdisplay));
if (ret) regmap_write(fsl_dev->regmap, DCU_DIV_RATIO, div);
goto set_failed; regmap_write(fsl_dev->regmap, DCU_SYN_POL,
ret = regmap_write(fsl_dev->regmap, DCU_DIV_RATIO, div);
if (ret)
goto set_failed;
ret = regmap_write(fsl_dev->regmap, DCU_SYN_POL,
DCU_SYN_POL_INV_VS_LOW | DCU_SYN_POL_INV_HS_LOW); DCU_SYN_POL_INV_VS_LOW | DCU_SYN_POL_INV_HS_LOW);
if (ret) regmap_write(fsl_dev->regmap, DCU_BGND, DCU_BGND_R(0) |
goto set_failed;
ret = regmap_write(fsl_dev->regmap, DCU_BGND, DCU_BGND_R(0) |
DCU_BGND_G(0) | DCU_BGND_B(0)); DCU_BGND_G(0) | DCU_BGND_B(0));
if (ret) regmap_write(fsl_dev->regmap, DCU_DCU_MODE,
goto set_failed;
ret = regmap_write(fsl_dev->regmap, DCU_DCU_MODE,
DCU_MODE_BLEND_ITER(1) | DCU_MODE_RASTER_EN); DCU_MODE_BLEND_ITER(1) | DCU_MODE_RASTER_EN);
if (ret) regmap_write(fsl_dev->regmap, DCU_THRESHOLD,
goto set_failed;
ret = regmap_write(fsl_dev->regmap, DCU_THRESHOLD,
DCU_THRESHOLD_LS_BF_VS(BF_VS_VAL) | DCU_THRESHOLD_LS_BF_VS(BF_VS_VAL) |
DCU_THRESHOLD_OUT_BUF_HIGH(BUF_MAX_VAL) | DCU_THRESHOLD_OUT_BUF_HIGH(BUF_MAX_VAL) |
DCU_THRESHOLD_OUT_BUF_LOW(BUF_MIN_VAL)); DCU_THRESHOLD_OUT_BUF_LOW(BUF_MIN_VAL));
if (ret) regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
goto set_failed;
ret = regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
DCU_UPDATE_MODE_READREG); DCU_UPDATE_MODE_READREG);
if (ret)
goto set_failed;
return; return;
set_failed:
dev_err(dev->dev, "set DCU register failed\n");
} }
static const struct drm_crtc_helper_funcs fsl_dcu_drm_crtc_helper_funcs = { static const struct drm_crtc_helper_funcs fsl_dcu_drm_crtc_helper_funcs = {
...@@ -186,25 +155,14 @@ int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev) ...@@ -186,25 +155,14 @@ int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev)
else else
reg_num = VF610_LAYER_REG_NUM; reg_num = VF610_LAYER_REG_NUM;
for (i = 0; i <= fsl_dev->soc->total_layer; i++) { for (i = 0; i <= fsl_dev->soc->total_layer; i++) {
for (j = 0; j < reg_num; j++) { for (j = 0; j < reg_num; j++)
ret = regmap_write(fsl_dev->regmap, regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(i, j), 0);
DCU_CTRLDESCLN(i, j), 0);
if (ret)
goto init_failed;
} }
} regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
ret = regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
DCU_MODE_DCU_MODE_MASK, DCU_MODE_DCU_MODE_MASK,
DCU_MODE_DCU_MODE(DCU_MODE_OFF)); DCU_MODE_DCU_MODE(DCU_MODE_OFF));
if (ret) regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
goto init_failed;
ret = regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
DCU_UPDATE_MODE_READREG); DCU_UPDATE_MODE_READREG);
if (ret)
goto init_failed;
return 0; return 0;
init_failed:
dev_err(fsl_dev->dev, "init DCU register failed\n");
return ret;
} }
...@@ -55,20 +55,12 @@ static int fsl_dcu_drm_irq_init(struct drm_device *dev) ...@@ -55,20 +55,12 @@ static int fsl_dcu_drm_irq_init(struct drm_device *dev)
if (ret < 0) if (ret < 0)
dev_err(dev->dev, "failed to install IRQ handler\n"); dev_err(dev->dev, "failed to install IRQ handler\n");
ret = regmap_write(fsl_dev->regmap, DCU_INT_STATUS, 0); regmap_write(fsl_dev->regmap, DCU_INT_STATUS, 0);
if (ret) regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
dev_err(dev->dev, "set DCU_INT_STATUS failed\n");
ret = regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
if (ret)
dev_err(dev->dev, "read DCU_INT_MASK failed\n");
value &= DCU_INT_MASK_VBLANK; value &= DCU_INT_MASK_VBLANK;
ret = regmap_write(fsl_dev->regmap, DCU_INT_MASK, value); regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
if (ret) regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
dev_err(dev->dev, "set DCU_INT_MASK failed\n");
ret = regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
DCU_UPDATE_MODE_READREG); DCU_UPDATE_MODE_READREG);
if (ret)
dev_err(dev->dev, "set DCU_UPDATE_MODE failed\n");
return ret; return ret;
} }
...@@ -130,18 +122,17 @@ static irqreturn_t fsl_dcu_drm_irq(int irq, void *arg) ...@@ -130,18 +122,17 @@ static irqreturn_t fsl_dcu_drm_irq(int irq, void *arg)
int ret; int ret;
ret = regmap_read(fsl_dev->regmap, DCU_INT_STATUS, &int_status); ret = regmap_read(fsl_dev->regmap, DCU_INT_STATUS, &int_status);
if (ret) if (ret) {
dev_err(dev->dev, "set DCU_INT_STATUS failed\n"); dev_err(dev->dev, "read DCU_INT_STATUS failed\n");
return IRQ_NONE;
}
if (int_status & DCU_INT_STATUS_VBLANK) if (int_status & DCU_INT_STATUS_VBLANK)
drm_handle_vblank(dev, 0); drm_handle_vblank(dev, 0);
ret = regmap_write(fsl_dev->regmap, DCU_INT_STATUS, int_status); regmap_write(fsl_dev->regmap, DCU_INT_STATUS, int_status);
if (ret) regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
dev_err(dev->dev, "set DCU_INT_STATUS failed\n");
ret = regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
DCU_UPDATE_MODE_READREG); DCU_UPDATE_MODE_READREG);
if (ret)
dev_err(dev->dev, "set DCU_UPDATE_MODE failed\n");
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -150,15 +141,11 @@ static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, unsigned int pipe) ...@@ -150,15 +141,11 @@ static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, unsigned int pipe)
{ {
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
unsigned int value; unsigned int value;
int ret;
ret = regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value); regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
if (ret)
dev_err(dev->dev, "read DCU_INT_MASK failed\n");
value &= ~DCU_INT_MASK_VBLANK; value &= ~DCU_INT_MASK_VBLANK;
ret = regmap_write(fsl_dev->regmap, DCU_INT_MASK, value); regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
if (ret)
dev_err(dev->dev, "set DCU_INT_MASK failed\n");
return 0; return 0;
} }
...@@ -167,15 +154,10 @@ static void fsl_dcu_drm_disable_vblank(struct drm_device *dev, ...@@ -167,15 +154,10 @@ static void fsl_dcu_drm_disable_vblank(struct drm_device *dev,
{ {
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
unsigned int value; unsigned int value;
int ret;
ret = regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value); regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
if (ret)
dev_err(dev->dev, "read DCU_INT_MASK failed\n");
value |= DCU_INT_MASK_VBLANK; value |= DCU_INT_MASK_VBLANK;
ret = regmap_write(fsl_dev->regmap, DCU_INT_MASK, value); regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
if (ret)
dev_err(dev->dev, "set DCU_INT_MASK failed\n");
} }
static const struct file_operations fsl_dcu_drm_fops = { static const struct file_operations fsl_dcu_drm_fops = {
......
...@@ -62,19 +62,15 @@ static void fsl_dcu_drm_plane_atomic_disable(struct drm_plane *plane, ...@@ -62,19 +62,15 @@ static void fsl_dcu_drm_plane_atomic_disable(struct drm_plane *plane,
{ {
struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private; struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private;
unsigned int value; unsigned int value;
int index, ret; int index;
index = fsl_dcu_drm_plane_index(plane); index = fsl_dcu_drm_plane_index(plane);
if (index < 0) if (index < 0)
return; return;
ret = regmap_read(fsl_dev->regmap, DCU_CTRLDESCLN(index, 4), &value); regmap_read(fsl_dev->regmap, DCU_CTRLDESCLN(index, 4), &value);
if (ret)
dev_err(fsl_dev->dev, "read DCU_INT_MASK failed\n");
value &= ~DCU_LAYER_EN; value &= ~DCU_LAYER_EN;
ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 4), value); regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 4), value);
if (ret)
dev_err(fsl_dev->dev, "set DCU register failed\n");
} }
static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane, static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane,
...@@ -86,7 +82,7 @@ static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane, ...@@ -86,7 +82,7 @@ static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane,
struct drm_framebuffer *fb = plane->state->fb; struct drm_framebuffer *fb = plane->state->fb;
struct drm_gem_cma_object *gem; struct drm_gem_cma_object *gem;
unsigned int alpha, bpp; unsigned int alpha, bpp;
int index, ret; int index;
if (!fb) if (!fb)
return; return;
...@@ -126,70 +122,45 @@ static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane, ...@@ -126,70 +122,45 @@ static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane,
return; return;
} }
ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 1), regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 1),
DCU_LAYER_HEIGHT(state->crtc_h) | DCU_LAYER_HEIGHT(state->crtc_h) |
DCU_LAYER_WIDTH(state->crtc_w)); DCU_LAYER_WIDTH(state->crtc_w));
if (ret) regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 2),
goto set_failed;
ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 2),
DCU_LAYER_POSY(state->crtc_y) | DCU_LAYER_POSY(state->crtc_y) |
DCU_LAYER_POSX(state->crtc_x)); DCU_LAYER_POSX(state->crtc_x));
if (ret) regmap_write(fsl_dev->regmap,
goto set_failed;
ret = regmap_write(fsl_dev->regmap,
DCU_CTRLDESCLN(index, 3), gem->paddr); DCU_CTRLDESCLN(index, 3), gem->paddr);
if (ret) regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 4),
goto set_failed;
ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 4),
DCU_LAYER_EN | DCU_LAYER_EN |
DCU_LAYER_TRANS(alpha) | DCU_LAYER_TRANS(alpha) |
DCU_LAYER_BPP(bpp) | DCU_LAYER_BPP(bpp) |
DCU_LAYER_AB(0)); DCU_LAYER_AB(0));
if (ret) regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 5),
goto set_failed;
ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 5),
DCU_LAYER_CKMAX_R(0xFF) | DCU_LAYER_CKMAX_R(0xFF) |
DCU_LAYER_CKMAX_G(0xFF) | DCU_LAYER_CKMAX_G(0xFF) |
DCU_LAYER_CKMAX_B(0xFF)); DCU_LAYER_CKMAX_B(0xFF));
if (ret) regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 6),
goto set_failed;
ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 6),
DCU_LAYER_CKMIN_R(0) | DCU_LAYER_CKMIN_R(0) |
DCU_LAYER_CKMIN_G(0) | DCU_LAYER_CKMIN_G(0) |
DCU_LAYER_CKMIN_B(0)); DCU_LAYER_CKMIN_B(0));
if (ret) regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 7), 0);
goto set_failed; regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 8),
ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 7), 0);
if (ret)
goto set_failed;
ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 8),
DCU_LAYER_FG_FCOLOR(0)); DCU_LAYER_FG_FCOLOR(0));
if (ret) regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 9),
goto set_failed;
ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 9),
DCU_LAYER_BG_BCOLOR(0)); DCU_LAYER_BG_BCOLOR(0));
if (ret)
goto set_failed;
if (!strcmp(fsl_dev->soc->name, "ls1021a")) { if (!strcmp(fsl_dev->soc->name, "ls1021a")) {
ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 10), regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 10),
DCU_LAYER_POST_SKIP(0) | DCU_LAYER_POST_SKIP(0) |
DCU_LAYER_PRE_SKIP(0)); DCU_LAYER_PRE_SKIP(0));
if (ret)
goto set_failed;
} }
ret = regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE, regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
DCU_MODE_DCU_MODE_MASK, DCU_MODE_DCU_MODE_MASK,
DCU_MODE_DCU_MODE(DCU_MODE_NORMAL)); DCU_MODE_DCU_MODE(DCU_MODE_NORMAL));
if (ret) regmap_write(fsl_dev->regmap,
goto set_failed;
ret = regmap_write(fsl_dev->regmap,
DCU_UPDATE_MODE, DCU_UPDATE_MODE_READREG); DCU_UPDATE_MODE, DCU_UPDATE_MODE_READREG);
if (ret)
goto set_failed;
return;
set_failed: return;
dev_err(fsl_dev->dev, "set DCU register failed\n");
} }
static void static void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment