@@ -2398,18 +2398,18 @@ static int vop2_find_rgb_encoder(struct vop2 *vop2)
return -ENOENT;
}
-static int vop2_cluster_init(struct vop2_win *win)
+static int vop2_regmap_init(struct vop2_win *win, const struct reg_field *regs,
+ int nr_regs)
{
struct vop2 *vop2 = win->vop2;
int i;
- for (i = 0; i < vop2->data->nr_cluster_regs; i++) {
+ for (i = 0; i < nr_regs; i++) {
const struct reg_field field = {
- .reg = (vop2->data->cluster_reg[i].reg != 0xffffffff) ?
- vop2->data->cluster_reg[i].reg + win->offset :
- vop2->data->cluster_reg[i].reg,
- .lsb = vop2->data->cluster_reg[i].lsb,
- .msb = vop2->data->cluster_reg[i].msb
+ .reg = (regs[i].reg != 0xffffffff) ?
+ regs[i].reg + win->offset : regs[i].reg,
+ .lsb = regs[i].lsb,
+ .msb = regs[i].msb
};
win->reg[i] = devm_regmap_field_alloc(vop2->dev, vop2->map, field);
@@ -2420,28 +2420,6 @@ static int vop2_cluster_init(struct vop2_win *win)
return 0;
};
-static int vop2_esmart_init(struct vop2_win *win)
-{
- struct vop2 *vop2 = win->vop2;
- int i;
-
- for (i = 0; i < vop2->data->nr_smart_regs; i++) {
- const struct reg_field field = {
- .reg = (vop2->data->smart_reg[i].reg != 0xffffffff) ?
- vop2->data->smart_reg[i].reg + win->offset :
- vop2->data->smart_reg[i].reg,
- .lsb = vop2->data->smart_reg[i].lsb,
- .msb = vop2->data->smart_reg[i].msb
- };
-
- 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 0;
-}
-
static int vop2_win_init(struct vop2 *vop2)
{
const struct vop2_data *vop2_data = vop2->data;
@@ -2458,9 +2436,11 @@ static int vop2_win_init(struct vop2 *vop2)
win->win_id = i;
win->vop2 = vop2;
if (vop2_cluster_window(win))
- ret = vop2_cluster_init(win);
+ ret = vop2_regmap_init(win, vop2->data->cluster_reg,
+ vop2->data->nr_cluster_regs);
else
- ret = vop2_esmart_init(win);
+ ret = vop2_regmap_init(win, vop2->data->smart_reg,
+ vop2->data->nr_cluster_regs);
if (ret)
return ret;
}