From patchwork Fri Dec 6 08:59:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 11275815 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01EC0109A for ; Fri, 6 Dec 2019 09:00:20 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DE92420659 for ; Fri, 6 Dec 2019 09:00:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE92420659 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 178D36F980; Fri, 6 Dec 2019 09:00:08 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id CBEB56F977 for ; Fri, 6 Dec 2019 09:00:00 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 91FE1B1B0; Fri, 6 Dec 2019 08:59:58 +0000 (UTC) From: Thomas Zimmermann To: airlied@redhat.com, daniel@ffwll.ch, sam@ravnborg.org, kraxel@redhat.com, emil.velikov@collabora.com, noralf@tronnes.org, zboszor@pr.hu Subject: [PATCH v2 5/7] drm/udl: Move log-cpp code out of udl_damage_handler() Date: Fri, 6 Dec 2019 09:59:52 +0100 Message-Id: <20191206085954.9697-6-tzimmermann@suse.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191206085954.9697-1-tzimmermann@suse.de> References: <20191206085954.9697-1-tzimmermann@suse.de> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Computing the cpp value's logarithm in a separate helper function makes the damage-handler code more readable. Signed-off-by: Thomas Zimmermann Reviewed-by: Emil Velikov Acked-by: Gerd Hoffmann --- drivers/gpu/drm/udl/udl_fb.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c index cc2a09a995b8..482786eeea6c 100644 --- a/drivers/gpu/drm/udl/udl_fb.c +++ b/drivers/gpu/drm/udl/udl_fb.c @@ -58,6 +58,13 @@ static uint16_t rgb16(uint32_t col) } #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, int width, int height) { @@ -92,11 +99,6 @@ int udl_handle_damage(struct drm_framebuffer *fb, int x, int y, int log_bpp; 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); if (udl->active_fb_16 != fb) { 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); + 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); if (ret) return ret;