From patchwork Tue Mar 21 08:13:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 9636175 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5D348602CC for ; Tue, 21 Mar 2017 08:14:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D1321FF8F for ; Tue, 21 Mar 2017 08:14:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41E7927F07; Tue, 21 Mar 2017 08:14:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D35801FF8F for ; Tue, 21 Mar 2017 08:14:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 787AB6E22C; Tue, 21 Mar 2017 08:14:10 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0DE426E1E3; Tue, 21 Mar 2017 08:14:05 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id u132so1489053wmg.1; Tue, 21 Mar 2017 01:14:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OkEYKG1hx5rEus1XYsLBwc2F+v/feYK9qZreH9ONuKk=; b=dTKzBODOhxLu6cOxTN2YeF1lPlgXu/QNQxQFbahWAVYsf8pPEN8VxwvX2MJcv8eMy1 zF6G7Z87FrRxrpikFaxGQ+Na1np240eA1b8zmoRN+f0SU5wOPHK61mxM+KhCuYXbd96C iDwRmqaBUpiVqPDg/HB1g9dFJdM0o1k/8uLnVWBwlc9l6P9Qt/zxOozhTWY314BXGdd3 klkIEvni3/2WxRzqgfFNDnFcY0otPM+o1wHZke7FC5onB37kFAwYrwG4zvfY7hVyY0tf vi7Lhp70IUlREMOjzhnZO5FfGjd7EI8yGAJiWg+p5JHTzSeO13d3qAf84Fw0um3rXZHX khaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OkEYKG1hx5rEus1XYsLBwc2F+v/feYK9qZreH9ONuKk=; b=qVFdhLWfvxYAbuExMevgxSVHv2bQdp1DcU9lDzAsI48SKjpWKsBemiu43EWcjGb8mI C8SWjY7dcodQuDIf/v7P26eOD7b68xDfU9k/JFphvMZPB3v5maaXdWZh8GVMBs3Qy25F QfmLcDnW7ug+wgZbh0B5RAkeXPD/0f+i6ikNsW3cnRDoT0GUIFhSZ/LGYiT+BMcZ+jn/ uRKGcC87tSsfnlNVMwJ4/A52xV9vkSnZ1u81tGShkzaIBXQ/T22cUHr3XUKtF0SQrO9w 6ORl91S40JvPJ3oRrmWRXnJoqwKWfsGu/T2CIzwnRFtG/hClmYNR+swsxX34QMYnDQI+ bBOA== X-Gm-Message-State: AFeK/H2QwoQtMqPkZx9byjdtazRDUtsGHV3BpwX8tox3E+OjKcLmAQm0fI1py2PdQrzE9g== X-Received: by 10.28.52.84 with SMTP id b81mr1574557wma.30.1490084043571; Tue, 21 Mar 2017 01:14:03 -0700 (PDT) Received: from localhost (port-52488.pppoe.wtnet.de. [46.59.205.174]) by smtp.gmail.com with ESMTPSA id y43sm23861064wrd.0.2017.03.21.01.14.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Mar 2017 01:14:02 -0700 (PDT) From: Thierry Reding To: Daniel Vetter Date: Tue, 21 Mar 2017 09:13:51 +0100 Message-Id: <20170321081358.27237-4-thierry.reding@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170321081358.27237-1-thierry.reding@gmail.com> References: <20170321081358.27237-1-thierry.reding@gmail.com> Cc: John Stultz , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH v3 03/10] drm/fb-helper: Improve code readability X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding Add a couple of temporary variables and use shorter names for existing variables in drm_fb_helper_add_one_connector() for better readability. Tested-by: John Stultz Signed-off-by: Thierry Reding Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_fb_helper.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 875a49048222..17fd98fe4a1f 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -109,31 +109,38 @@ static DEFINE_MUTEX(kernel_fb_helper_lock); for (({ lockdep_assert_held(&(fbh)->dev->mode_config.mutex); }), \ i__ = 0; i__ < (fbh)->connector_count; i__++) -int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct drm_connector *connector) +int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, + struct drm_connector *connector) { struct drm_fb_helper_connector **temp; - struct drm_fb_helper_connector *fb_helper_connector; + struct drm_fb_helper_connector *conn; + unsigned int count; if (!drm_fbdev_emulation) return 0; WARN_ON(!mutex_is_locked(&fb_helper->dev->mode_config.mutex)); - if (fb_helper->connector_count + 1 > fb_helper->connector_info_alloc_count) { - temp = krealloc(fb_helper->connector_info, sizeof(struct drm_fb_helper_connector *) * (fb_helper->connector_count + 1), GFP_KERNEL); + + count = fb_helper->connector_count + 1; + + if (count > fb_helper->connector_info_alloc_count) { + size_t size = count * sizeof(conn); + + temp = krealloc(fb_helper->connector_info, size, GFP_KERNEL); if (!temp) return -ENOMEM; - fb_helper->connector_info_alloc_count = fb_helper->connector_count + 1; + fb_helper->connector_info_alloc_count = count; fb_helper->connector_info = temp; } - fb_helper_connector = kzalloc(sizeof(struct drm_fb_helper_connector), GFP_KERNEL); - if (!fb_helper_connector) + conn = kzalloc(sizeof(*conn), GFP_KERNEL); + if (!conn) return -ENOMEM; drm_connector_get(connector); - fb_helper_connector->connector = connector; - fb_helper->connector_info[fb_helper->connector_count++] = fb_helper_connector; + conn->connector = connector; + fb_helper->connector_info[fb_helper->connector_count++] = conn; return 0; } EXPORT_SYMBOL(drm_fb_helper_add_one_connector);