@@ -104,6 +104,11 @@ static inline struct rcar_du_device *to_rcar_du_device(struct drm_device *dev)
return container_of(dev, struct rcar_du_device, ddev);
}
+#define for_each_rcdu_group(__rcdu, __group, __i) \
+ for ((__i) = 0, (__group) = &(__rcdu)->groups[0]; \
+ (__i) < DIV_ROUND_UP((__rcdu)->num_crtcs, 2); \
+ __i++, __group++)
+
static inline bool rcar_du_has(struct rcar_du_device *rcdu,
unsigned int feature)
{
@@ -771,9 +771,9 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
struct drm_device *dev = &rcdu->ddev;
struct drm_encoder *encoder;
+ struct rcar_du_group *rgrp;
unsigned int dpad0_sources;
unsigned int num_encoders;
- unsigned int num_groups;
unsigned int swindex;
unsigned int hwindex;
unsigned int i;
@@ -820,11 +820,7 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
return ret;
/* Initialize the groups. */
- num_groups = DIV_ROUND_UP(rcdu->num_crtcs, 2);
-
- for (i = 0; i < num_groups; ++i) {
- struct rcar_du_group *rgrp = &rcdu->groups[i];
-
+ for_each_rcdu_group(rcdu, rgrp, i) {
mutex_init(&rgrp->lock);
rgrp->dev = rcdu;
@@ -866,8 +862,6 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
/* Create the CRTCs. */
for (swindex = 0, hwindex = 0; swindex < rcdu->num_crtcs; ++hwindex) {
- struct rcar_du_group *rgrp;
-
/* Skip unpopulated DU channels. */
if (!(rcdu->info->channels_mask & BIT(hwindex)))
continue;