From patchwork Thu Jan 23 12:50:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 3528571 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0B191C02DC for ; Thu, 23 Jan 2014 12:50:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1523B20115 for ; Thu, 23 Jan 2014 12:50:42 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7AFD620108 for ; Thu, 23 Jan 2014 12:50:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 62489FAA8F; Thu, 23 Jan 2014 04:50:35 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by gabe.freedesktop.org (Postfix) with ESMTP id DC7C9FAA8F for ; Thu, 23 Jan 2014 04:50:32 -0800 (PST) Received: by mail-we0-f182.google.com with SMTP id w62so1102088wes.27 for ; Thu, 23 Jan 2014 04:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iUDvW5I5H4p+tnohSThAsQATIuAM9ytCFmna0hlWR7I=; b=guOHshLjyADERfeC1OZlPPybZ8FUJREgck/JIMCLpEfW+Gbe7+rds7JPoRkvin4GuP kwkW/XzgHNr+5X8vrX9HrL6FxLAMz+328e3gJo9BwJB/QhzeSvi21ttO+H1slV1KaNdd dA5veejKsthZWpoevBRfju0C8FN+ZOGbynk5DqgpmEKSkJHcN+eBe2y+fxHNJC9+A+m+ iHJuZandjSDgWqBH0AwzxpzR42iZpwAtQRinsMe2/Yn7SAQX3VpBW0vYeZzBomhrBmRN nYfcv2EOA+BMGw/SUXn4T2FlTLEizGDdZADV5Pz5wIwMOOT4mF63WFQAKZi5yX+GSfcy onsw== X-Received: by 10.180.149.175 with SMTP id ub15mr7854240wib.10.1390481430528; Thu, 23 Jan 2014 04:50:30 -0800 (PST) Received: from david-ub.localdomain (stgt-5f71be19.pool.mediaWays.net. [95.113.190.25]) by mx.google.com with ESMTPSA id 5sm22093976wjw.17.2014.01.23.04.50.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Jan 2014 04:50:29 -0800 (PST) From: David Herrmann To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/6] drm/udl: fix Bpp calculation in dumb_create() Date: Thu, 23 Jan 2014 13:50:21 +0100 Message-Id: <1390481421-471-1-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1390245989-13280-2-git-send-email-dh.herrmann@gmail.com> References: <1390245989-13280-2-git-send-email-dh.herrmann@gmail.com> Cc: Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Probably a typo.. we obviously need "(bpp + 7) / 8" instead of "(bpp + 1) / 8". Unlikely to be hit in any sane code, but lets be safe. Use DIV_ROUND_UP() to avoid the problem entirely and make the core more readable. Reviewed-by: Daniel Vetter Signed-off-by: David Herrmann --- drivers/gpu/drm/udl/udl_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c index 8d67b94..be4fcd0 100644 --- a/drivers/gpu/drm/udl/udl_gem.c +++ b/drivers/gpu/drm/udl/udl_gem.c @@ -60,7 +60,7 @@ int udl_dumb_create(struct drm_file *file, struct drm_device *dev, struct drm_mode_create_dumb *args) { - args->pitch = args->width * ((args->bpp + 1) / 8); + args->pitch = args->width * DIV_ROUND_UP(args->bpp, 8); args->size = args->pitch * args->height; return udl_gem_create(file, dev, args->size, &args->handle);