From patchwork Tue Jun 7 15:26:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 9161649 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 92F5060801 for ; Tue, 7 Jun 2016 15:26:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 853DD264F4 for ; Tue, 7 Jun 2016 15:26:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79D6426E1A; Tue, 7 Jun 2016 15:26:49 +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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4429D27248 for ; Tue, 7 Jun 2016 15:26:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B8AC86E7DF; Tue, 7 Jun 2016 15:26:37 +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 52AE26E7DB; Tue, 7 Jun 2016 15:26:35 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id n184so25126358wmn.1; Tue, 07 Jun 2016 08:26:35 -0700 (PDT) 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=/hHR4TVypk/7Yhy2J+bkueMcRaznzouMt18bt+WJkWQ=; b=XDT2yP8APrm3WB1PXfRQFwUQP+XZ+Fy4xur546LkzEDoWjGGhhJ0JcCvRkGsUCHAS1 wJE2JZKzP+WkkJ52inV3aPp5fEEaSNdrPEUOZRWlQvUuZX1UI3kMXFKMWpIfWGhD/7Gs CkFdhG60p/Rr6Kc/EjH14Dg+LJIEEoXxMFEEKXDXQ+tajia49pNY6O+1nobuN72FLNnQ Do9b0Za2QJEtoZ5RTDgVxJA5fTJdpKUfPAVFh7EOl8Tbg59bTA++dj5QtzR2n11hukDp ZIeHdom+0hJNkR8uZf5ylH8iLVogdG+wJMoKECVULB784aOtzYnTeZbTbiYlvjfTpbKX HaWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/hHR4TVypk/7Yhy2J+bkueMcRaznzouMt18bt+WJkWQ=; b=ZcPZeQtwx89WVTGuxNzyEWJu/m4kUcv+7pOdkGxvrFO4FmozpE6b4sJ0274p77iLiS YcJd3R7pPJWvh2V+2gq9Qa8ej9s6Vg+Hdo54Y84VnWC7QNVHn8Hrv2RLQ3qYyk5HiQVo i6kiFRVfdcPcZ//ceaTCvOhUXBlvDANep6Lh8FTq1MghdBn2RSQRZEhULKbTmhOfRnyP h044n1JsqknPOvBkFHa9VgKVkCPRuScajbBzlshjqXPRC/1TpfX6/X0QsOKinReUmV9k Y2Shq2r+2W3WO/9q6JXqITOvnjj/llRkVjV0ccxEXCucYUgpr8LdFx4tZtB6CyHcX7FP if9Q== X-Gm-Message-State: ALyK8tKGfPDATfQixoXAdyrIipLhdvTdyy1SE9eOVGjzxmUGFt2rnY7b0YnsWfF/MeJVTw== X-Received: by 10.194.118.233 with SMTP id kp9mr15754573wjb.51.1465313193371; Tue, 07 Jun 2016 08:26:33 -0700 (PDT) Received: from localhost (port-9435.pppoe.wtnet.de. [84.46.36.255]) by smtp.gmail.com with ESMTPSA id dj4sm26002694wjc.13.2016.06.07.08.26.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jun 2016 08:26:32 -0700 (PDT) From: Thierry Reding To: Daniel Vetter Date: Tue, 7 Jun 2016 17:26:19 +0200 Message-Id: <20160607152625.9511-4-thierry.reding@gmail.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20160607152625.9511-1-thierry.reding@gmail.com> References: <20160607152625.9511-1-thierry.reding@gmail.com> Cc: Boris Brezillon , Joonyoung Shim , Xinliang Liu , Chen Feng , intel-gfx@lists.freedesktop.org, Seung-Woo Kim , Xinwei Kong , dri-devel@lists.freedesktop.org, Inki Dae , Kyungmin Park , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= Subject: [Intel-gfx] [PATCH v2 3/9] 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. Signed-off-by: Thierry Reding --- drivers/gpu/drm/drm_fb_helper.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 301644d12013..9afd4208596f 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -95,32 +95,38 @@ static LIST_HEAD(kernel_fb_helper_list); * mmap page writes. */ -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_reference(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);