drm/udl: Move log-cpp code out of udl_damage_handler()
Computing the cpp value's logarithm in a separate helper function makes the damage-handler code more readable. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Emil Velikov <emil.velikov@collabora.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20191206085954.9697-6-tzimmermann@suse.de
This commit is contained in:
@@ -58,6 +58,13 @@ static uint16_t rgb16(uint32_t col)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static long udl_log_cpp(unsigned int cpp)
|
||||||
|
{
|
||||||
|
if (WARN_ON(!is_power_of_2(cpp)))
|
||||||
|
return -EINVAL;
|
||||||
|
return __ffs(cpp);
|
||||||
|
}
|
||||||
|
|
||||||
static int udl_aligned_damage_clip(struct drm_rect *clip, int x, int y,
|
static int udl_aligned_damage_clip(struct drm_rect *clip, int x, int y,
|
||||||
int width, int height)
|
int width, int height)
|
||||||
{
|
{
|
||||||
@@ -92,11 +99,6 @@ int udl_handle_damage(struct drm_framebuffer *fb, int x, int y,
|
|||||||
int log_bpp;
|
int log_bpp;
|
||||||
void *vaddr;
|
void *vaddr;
|
||||||
|
|
||||||
if (WARN_ON(!is_power_of_2(fb->format->cpp[0])))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
log_bpp = __ffs(fb->format->cpp[0]);
|
|
||||||
|
|
||||||
spin_lock(&udl->active_fb_16_lock);
|
spin_lock(&udl->active_fb_16_lock);
|
||||||
if (udl->active_fb_16 != fb) {
|
if (udl->active_fb_16 != fb) {
|
||||||
spin_unlock(&udl->active_fb_16_lock);
|
spin_unlock(&udl->active_fb_16_lock);
|
||||||
@@ -104,6 +106,11 @@ int udl_handle_damage(struct drm_framebuffer *fb, int x, int y,
|
|||||||
}
|
}
|
||||||
spin_unlock(&udl->active_fb_16_lock);
|
spin_unlock(&udl->active_fb_16_lock);
|
||||||
|
|
||||||
|
ret = udl_log_cpp(fb->format->cpp[0]);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
log_bpp = ret;
|
||||||
|
|
||||||
ret = udl_aligned_damage_clip(&clip, x, y, width, height);
|
ret = udl_aligned_damage_clip(&clip, x, y, width, height);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user