Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp400134imm; Fri, 3 Aug 2018 05:28:46 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeICzyN5PoSgBQuSOK7WcjRq0jB72YbShNpasHARBvf58OaRZ8kJ2XaCRQh+KEW4DgtAdQl X-Received: by 2002:a63:175b:: with SMTP id 27-v6mr3554933pgx.31.1533299326020; Fri, 03 Aug 2018 05:28:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533299325; cv=none; d=google.com; s=arc-20160816; b=Gn88REJ5F0DndaITxxwi2iwoPpu3tNNqLchDMO9aRW3H/CJsmm1EZt1hlT7YRy562w soFjw0N/ijnuze0wX127KZwrRIaXYRqQpus8jAcs62OsiNAXT5J6WWs0jejWVuM6OeyE Dll9Wd/bmCNdrOWoxnIYBGiK9C9O24vuzJ9se938QZk+7h0otA0FdSgEjFKTAJQ7TQ2v l14CsgrepQcQPkmXhnnS83JpNwa5t8YHUS6Vezej1G//7nAY7etV6Uq8aor2pIfjyyxF uKOLbcUytKqpk7K+GxWo/AKd6qZyVRusRI7PR67P1GZHqfPZv1furrFMAzETzExnAgp9 zEdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=CPcITFdw7hRbw0aSdTLg5RsVpQ3sDb/85fvxk43NR54=; b=smFvKdxV/innIRDrszSyjR6XqvMg+sT+HaKG+UboMpqyzX1KlS7b/MQkY71dBW555T DyJYGIeYLvjZ3sv9i2yLlTubG0IYHMaVuJi9ZCLhW6K/oQIhcGqIcfmjUqn8eKfUs1DK HGPPPBtMDTkOBd4Zr6fEvups2kXXnJYym9FKgPsHByWYKXgPBsaS+qLjqxxkZDg4Bxtz Qt8MBe0y1DXnyRlmSZcefAmHb05KQeihIXkg4210eKCXS6k/bBMusJOqh97tvYW9kCFe 6saDyNURAbYICDg88lh/6p1TEtrtpZtWSuiGjMGbhEB9jhbsqDgrl5XnCtw2/fDnvLwI VZhg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h29-v6si4744714pgb.53.2018.08.03.05.28.30; Fri, 03 Aug 2018 05:28:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729859AbeHCOV6 (ORCPT + 99 others); Fri, 3 Aug 2018 10:21:58 -0400 Received: from mga14.intel.com ([192.55.52.115]:63356 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727116AbeHCOV6 (ORCPT ); Fri, 3 Aug 2018 10:21:58 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Aug 2018 05:25:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,438,1526367600"; d="scan'208";a="61818894" Received: from chanse1-mobl.ger.corp.intel.com (HELO [10.252.51.109]) ([10.252.51.109]) by orsmga007.jf.intel.com with ESMTP; 03 Aug 2018 05:24:26 -0700 Subject: Re: [PATCH v1] drm/kms/crtc: Improving the func drm_mode_setcrtc To: Satendra Singh Thakur , Gustavo Padovan , Sean Paul , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: vineet.j@samsung.com, hemanshu.s@samsung.com, sst2005@gmail.com References: <66ead941-3c64-45e4-7835-949360e2b01f@linux.intel.com> <20180803114404epcas5p1c5aaec7ca27e520b5cba52b0d7f09124~HXSyqLTJ81698916989epcas5p1G@epcas5p1.samsung.com> From: Maarten Lankhorst Message-ID: <419670d5-bba9-d5e3-9ad6-f7b3324099c5@linux.intel.com> Date: Fri, 3 Aug 2018 14:24:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180803114404epcas5p1c5aaec7ca27e520b5cba52b0d7f09124~HXSyqLTJ81698916989epcas5p1G@epcas5p1.samsung.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Op 03-08-18 om 13:43 schreef Satendra Singh Thakur: > Following changes are done to this func: > 1. The declaration of plane and it's assignment plane = crtc->primary > are only used when mode_valid is set. Therefore, moved it inside > the if(mode_valid) statement. > > 2. The declaration of connector and set_connectors_ptr and out_id > are moved inside the for loop, as their scope is limited within > that block. > > 3. Currently, there are 3 checks on count_connectors > and 4 checks on mode related params (mode_valid, mode, fb). > if (crtc_req->mode_valid) { > if (crtc_req->count_connectors == 0 && mode) { > if (crtc_req->count_connectors > 0 && (!mode || !fb)) { > if (crtc_req->count_connectors > 0) { > > In the modified code, there are just 1 check on mode_valid and > 2 checks count_connectors. > Checks on mode and fb are not needed as these variables will > be non-NULL by the end of if(mode_valid) statement if mode_valid is set. > If mode_valid is clear, mode and fb will be NULL. > Therefore, we just check mode_valid and NOT mode or fb. > > 4. Moved kfree inside if statement > > Signed-off-by: Satendra Singh Thakur > > --- > > v1: Hi Mr Maarten, Thanks for the comments. > I have fixed some of them and done more modifications to the patch. > Please review. Could you read the suggestions on https://patchwork.freedesktop.org/patch/241508/ ? I'm not saying this code is incorrect, I think that if you want to improve drm then you should tackle something bigger than just function readability. :) Cheers, ~Maarten