From patchwork Wed Mar 29 14:43:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 9651741 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 85151602BE for ; Wed, 29 Mar 2017 14:44:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AC5F284D0 for ; Wed, 29 Mar 2017 14:44:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FB0F284D4; Wed, 29 Mar 2017 14:44:48 +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 3837D284D0 for ; Wed, 29 Mar 2017 14:44:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F2FA66E770; Wed, 29 Mar 2017 14:44:23 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id D2CD16E749; Wed, 29 Mar 2017 14:44:07 +0000 (UTC) Received: by mail-wr0-x244.google.com with SMTP id w43so3620323wrb.1; Wed, 29 Mar 2017 07:44:07 -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=/6SCBmlMxSiPd7ge/mtFEndix0+9ACxlNi46dEtd9Vg=; b=WIhF2tUvaRHRmRSzP+nLCx6D4ujjZjR/qlhDFJfH3EmZjl2AbcldFsb315tJ6ijOS9 stIiN/44OAYvl/9zmWZKLjSAP9kv2ROIz72pNsgoCfDDeRARV4f6P1tdOoTCLrUDMiOe pwUxkSXZuay+6Lgcscj3+0Zsa7Lb1pJQxIMSmKRIta8U41xEOgFmUQ1qN6Fd6j8NKdte rxRK/MrxZTaG/mndwnkvIOi8IjQj2fGiozV3//nw+4RTIriPpcXfczRdiWwk3PL9LFDy oEIZ7SPB7OLMAcV2Xq+zLURITC/4OEa7Og62JFUAFeFZHv2g3Cgr/xKklzpdPEWgMTpJ Hv1w== 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=/6SCBmlMxSiPd7ge/mtFEndix0+9ACxlNi46dEtd9Vg=; b=Tte5EHclvwI7vl0FBrJn60t3nOPFT24vWpYK2yPSQJGZSnQTsoF0x/0SG+3j/1GijV hBogg4CyEhxeJbIm4//gguovccHEcNaHZWiE3prE/svmpxkmyZuX4yav+u55BnTUX8oG jKDg0j9eB4bRUjh//2M5ahh2Bk7ndHGFFp664o89IuRqe7TGMQ1DRR6cgj5brNZTcvgM L4k4UJzEmQXbNRprDut4/y6+cQ2ChNPHwFE+sgQEOR+oGJePoPabOuh0JOORuENNKFYC 0LM/je9ljqjESPYOmZSgt7QcfmTsClQ9qvU5mtJpHjZekRklfk08dOy0PTsMyBR4csgj GZyg== X-Gm-Message-State: AFeK/H0URz0VUO3e0AUpM8rSZ83I1AZ5SmU+dzG1xUqUYTMiCYDx2C/IIITVJW48NFbHxw== X-Received: by 10.223.138.200 with SMTP id z8mr863952wrz.49.1490798646275; Wed, 29 Mar 2017 07:44:06 -0700 (PDT) Received: from localhost (port-5852.pppoe.wtnet.de. [84.46.22.242]) by smtp.gmail.com with ESMTPSA id 82sm9504157wmg.0.2017.03.29.07.44.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 Mar 2017 07:44:05 -0700 (PDT) From: Thierry Reding To: Daniel Vetter Date: Wed, 29 Mar 2017 16:43:53 +0200 Message-Id: <20170329144401.1804-4-thierry.reding@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170329144401.1804-1-thierry.reding@gmail.com> References: <20170329144401.1804-1-thierry.reding@gmail.com> Cc: John Stultz , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH v4 03/11] 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 Reviewed-by: Daniel Vetter Signed-off-by: Thierry Reding --- 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 1581305c1053..673a47445d61 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 *fb_conn; struct drm_fb_helper_connector **temp; - struct drm_fb_helper_connector *fb_helper_connector; + 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(fb_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) + fb_conn = kzalloc(sizeof(*fb_conn), GFP_KERNEL); + if (!fb_conn) return -ENOMEM; drm_connector_get(connector); - fb_helper_connector->connector = connector; - fb_helper->connector_info[fb_helper->connector_count++] = fb_helper_connector; + fb_conn->connector = connector; + fb_helper->connector_info[fb_helper->connector_count++] = fb_conn; return 0; } EXPORT_SYMBOL(drm_fb_helper_add_one_connector);