summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Yan <andy.yan@rock-chips.com>2025-02-18 19:27:28 +0800
committerHeiko Stuebner <heiko@sntech.de>2025-03-02 19:32:00 +0100
commitff0b6c031ed3ed31024618340c795523a86e6688 (patch)
tree2d16ad3ad28538a95faf46c123c249d9ff7d5ce4
parent2800028d5bdee8e9a3cda2fec782dadc32225d8d (diff)
downloadlinux-ff0b6c031ed3ed31024618340c795523a86e6688.tar.gz
linux-ff0b6c031ed3ed31024618340c795523a86e6688.zip
drm/rockchip: vop2: use devm_regmap_field_alloc for cluster-regs
Right now vop2_cluster_init() copies the base vop2_cluster_regs and adapts the reg value with the current window's offset before adding the fields to the regmap. This conflicts with the notion of reg_fields being const, see https://lore.kernel.org/all/20240706-regmap-const-structs-v1-1-d08c776da787@weissschuh.net/ for reference, which now causes checkpatch to actually warn about that. So instead of creating one big copy and changing it afterwards, add the reg_fields individually using devm_regmap_field_alloc(). Functional it is the same, just that the reg_field we're handling can stay const. Signed-off-by: Andy Yan <andy.yan@rock-chips.com> Signed-off-by: Heiko Stuebner <heiko@sntech.de> Link: https://patchwork.freedesktop.org/patch/msgid/20250218112744.34433-2-andyshrk@163.com
-rw-r--r--drivers/gpu/drm/rockchip/rockchip_drm_vop2.c66
1 files changed, 31 insertions, 35 deletions
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index 7b893b4447b6..b84e92a9a25a 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -3412,7 +3412,7 @@ static int vop2_find_rgb_encoder(struct vop2 *vop2)
return -ENOENT;
}
-static struct reg_field vop2_cluster_regs[VOP2_WIN_MAX_REG] = {
+static const struct reg_field vop2_cluster_regs[VOP2_WIN_MAX_REG] = {
[VOP2_WIN_ENABLE] = REG_FIELD(RK3568_CLUSTER_WIN_CTRL0, 0, 0),
[VOP2_WIN_FORMAT] = REG_FIELD(RK3568_CLUSTER_WIN_CTRL0, 1, 5),
[VOP2_WIN_RB_SWAP] = REG_FIELD(RK3568_CLUSTER_WIN_CTRL0, 14, 14),
@@ -3483,28 +3483,26 @@ static struct reg_field vop2_cluster_regs[VOP2_WIN_MAX_REG] = {
static int vop2_cluster_init(struct vop2_win *win)
{
struct vop2 *vop2 = win->vop2;
- struct reg_field *cluster_regs;
- int ret, i;
-
- cluster_regs = kmemdup(vop2_cluster_regs, sizeof(vop2_cluster_regs),
- GFP_KERNEL);
- if (!cluster_regs)
- return -ENOMEM;
-
- for (i = 0; i < ARRAY_SIZE(vop2_cluster_regs); i++)
- if (cluster_regs[i].reg != 0xffffffff)
- cluster_regs[i].reg += win->offset;
+ int i;
- ret = devm_regmap_field_bulk_alloc(vop2->dev, vop2->map, win->reg,
- cluster_regs,
- ARRAY_SIZE(vop2_cluster_regs));
+ for (i = 0; i < ARRAY_SIZE(vop2_cluster_regs); i++) {
+ const struct reg_field field = {
+ .reg = (vop2_cluster_regs[i].reg != 0xffffffff) ?
+ vop2_cluster_regs[i].reg + win->offset :
+ vop2_cluster_regs[i].reg,
+ .lsb = vop2_cluster_regs[i].lsb,
+ .msb = vop2_cluster_regs[i].msb
+ };
- kfree(cluster_regs);
+ win->reg[i] = devm_regmap_field_alloc(vop2->dev, vop2->map, field);
+ if (IS_ERR(win->reg[i]))
+ return PTR_ERR(win->reg[i]);
+ }
- return ret;
+ return 0;
};
-static struct reg_field vop2_esmart_regs[VOP2_WIN_MAX_REG] = {
+static const struct reg_field vop2_esmart_regs[VOP2_WIN_MAX_REG] = {
[VOP2_WIN_ENABLE] = REG_FIELD(RK3568_SMART_REGION0_CTRL, 0, 0),
[VOP2_WIN_FORMAT] = REG_FIELD(RK3568_SMART_REGION0_CTRL, 1, 5),
[VOP2_WIN_DITHER_UP] = REG_FIELD(RK3568_SMART_REGION0_CTRL, 12, 12),
@@ -3571,26 +3569,24 @@ static struct reg_field vop2_esmart_regs[VOP2_WIN_MAX_REG] = {
static int vop2_esmart_init(struct vop2_win *win)
{
struct vop2 *vop2 = win->vop2;
- struct reg_field *esmart_regs;
- int ret, i;
-
- esmart_regs = kmemdup(vop2_esmart_regs, sizeof(vop2_esmart_regs),
- GFP_KERNEL);
- if (!esmart_regs)
- return -ENOMEM;
-
- for (i = 0; i < ARRAY_SIZE(vop2_esmart_regs); i++)
- if (esmart_regs[i].reg != 0xffffffff)
- esmart_regs[i].reg += win->offset;
+ int i;
- ret = devm_regmap_field_bulk_alloc(vop2->dev, vop2->map, win->reg,
- esmart_regs,
- ARRAY_SIZE(vop2_esmart_regs));
+ for (i = 0; i < ARRAY_SIZE(vop2_esmart_regs); i++) {
+ const struct reg_field field = {
+ .reg = (vop2_esmart_regs[i].reg != 0xffffffff) ?
+ vop2_esmart_regs[i].reg + win->offset :
+ vop2_esmart_regs[i].reg,
+ .lsb = vop2_esmart_regs[i].lsb,
+ .msb = vop2_esmart_regs[i].msb
+ };
- kfree(esmart_regs);
+ win->reg[i] = devm_regmap_field_alloc(vop2->dev, vop2->map, field);
+ if (IS_ERR(win->reg[i]))
+ return PTR_ERR(win->reg[i]);
+ }
- return ret;
-};
+ return 0;
+}
static int vop2_win_init(struct vop2 *vop2)
{