Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4616395ybl; Wed, 22 Jan 2020 01:18:00 -0800 (PST) X-Google-Smtp-Source: APXvYqzbe9HQxis5acdSAvVTimNn8bTyx6HeyzppPkjPSxfLRiGGWO8SSvOCzyifWVZ0slbXJmx0 X-Received: by 2002:a9d:6e82:: with SMTP id a2mr6491169otr.336.1579684680179; Wed, 22 Jan 2020 01:18:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579684680; cv=none; d=google.com; s=arc-20160816; b=fdt6Y+Cf7xh7fXH9M9MVSEyfhuZobuSK7m6898hy2AyuCKvDyQ0V7aQD4+m/Pbl6GV EyWSLuHFeYCxKX2e4CegqgKNyQyAPtx6HGvroUVNCdcgphL51hlwD6kOVNB6IdagbTl1 Ka7ABcAVLafyfuSB9xRlJO7o/JPFLhbR4U1RWhIkfQGtF5ZGGWd140ijYwFP7yv2NfQD Yq1B4TY69H1j000f62ssz01rD/zSwPuf2ZZ10gmlwuCQenQn2pvq0Qk2tgzIUzbjY2Xf A7nLoVCv1oBNgR7ZvbjGd6lriivQHkiDmLlqlI7CD5Kot2bVGDSvT0OKyohxm9RQW9HL 1fXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=p6TXy9D8Jj5ZMAsUl92rse85KpLnXYI0D7il7xeObjo=; b=MrZOuIha9q7odGciaqRwrLRD3m+MF2HM3IsT2uAC1E4jo6DE5sAIGDofc8onbrr1+Y CVvidf7EX3Kc5EzqOHqQLh2GqqfhPpbFurW6uUDrWbVIEF0goIVZ+EyK/ta0BaAD+pA3 cOgohM7MBFMjAXxORPLOQX4QfceZWwycswtz8G9tkgg2OJkgQ21gM3LLJb4vuyGGqnFU qXXMPpC72SpwCpuSSp3qKIdjJW+0BAUngxgxd02P1uslmo9Ebq67fBvbtayA71kXdIy1 gtT36lQN2EdPUJmxItq6YmjuYBzVHPdl8zvkVZ3FgugzbeYMMO/zTBRvSGfymOnEyjCI S3mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=uBtieWXw; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q126si21343612oia.8.2020.01.22.01.17.48; Wed, 22 Jan 2020 01:18:00 -0800 (PST) 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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=uBtieWXw; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729143AbgAVJPp (ORCPT + 99 others); Wed, 22 Jan 2020 04:15:45 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:42224 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725911AbgAVJPo (ORCPT ); Wed, 22 Jan 2020 04:15:44 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 00M9FMLM122955; Wed, 22 Jan 2020 03:15:22 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1579684522; bh=p6TXy9D8Jj5ZMAsUl92rse85KpLnXYI0D7il7xeObjo=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=uBtieWXwbpXSnRK/R3juokz75ZF07c3mFcuNzH5xfgGKpgBJPYDmetcojC/2gI9gN 0VOEXTfL2++aG1uTJbYPyywW3QlkZZVZYsgZZaJUD4mknt6vWvHEYL0OY/TgmX2SW2 Ngi7YqDlsI0/rO0y0n5xfRIm29JqCAdjoS1cC6wk= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 00M9FM9x030906; Wed, 22 Jan 2020 03:15:22 -0600 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Wed, 22 Jan 2020 03:15:22 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Wed, 22 Jan 2020 03:15:22 -0600 Received: from [192.168.2.6] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 00M9FJa9046831; Wed, 22 Jan 2020 03:15:19 -0600 Subject: Re: [PATCH 2/2] drm/bridge: Add tc358768 driver To: Andrzej Hajda , , , , , CC: , , , , , , References: <20191217101506.18910-1-peter.ujfalusi@ti.com> <20191217101506.18910-3-peter.ujfalusi@ti.com> <35d664fe-8091-2744-abf2-69828ebf1148@samsung.com> <14306079-500d-09ca-df94-4cf72c43f858@ti.com> From: Peter Ujfalusi Message-ID: Date: Wed, 22 Jan 2020 11:16:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andrzej, On 22/01/2020 10.46, Andrzej Hajda wrote: >>>> +struct tc358768_priv { >>>> + struct device *dev; >>>> + struct regmap *regmap; >>>> + struct gpio_desc *reset_gpio; >>>> + struct regulator_bulk_data supplies[ARRAY_SIZE(tc358768_supplies)]; >>>> + struct clk *refclk; >>>> + >>>> + struct mipi_dsi_host dsi_host; >>>> + struct drm_bridge bridge; >>>> + struct tc358768_dsi_output output; >>> >>> Since tc358768_dsi_output is used only here, you can define it here as >>> well, up to you. >> I think I have done it like this to avoid thinking about prefixes for >> what is under the tc358768_dsi_output. >> I'll take a look if it will look better unpacked here. > > I though rather about in-place anonymous struct definition: > > +    struct tc358768_dsi_output { > +        struct mipi_dsi_device *dev; > +        struct drm_panel *panel; > +        struct drm_bridge *bridge; > +    } output; > > But, as I said - up to you. I see. I think I will keep how it was. They are in proximity, so easy to check. >>>> + >>>> + refclk = clk_get_rate(priv->refclk); >>>> + >>>> + best_diff = UINT_MAX; >>>> + best_pll = 0; >>>> + best_prd = 0; >>>> + best_fbd = 0; >>>> + >>>> + for (prd = 0; prd < 16; ++prd) { >>>> + u32 divisor = (prd + 1) * (1 << frs); >>>> + u32 fbd; >>>> + >>>> + for (fbd = 0; fbd < 512; ++fbd) { >>>> + u32 pll, diff; >>>> + >>>> + pll = (u32)div_u64((u64)refclk * (fbd + 1), divisor); >>>> + >>>> + if (pll >= max_pll || pll < min_pll) >>>> + continue; >>>> + >>>> + diff = max(pll, target_pll) - min(pll, target_pll); >>>> + >>>> + if (diff < best_diff) { >>>> + best_diff = diff; >>>> + best_pll = pll; >>>> + best_prd = prd; >>>> + best_fbd = fbd; >>>> + } >>>> + >>>> + if (best_diff == 0) >>>> + break; >>>> + } >>>> + >>>> + if (best_diff == 0) >>>> + break; >>> why another check here? >> To break out from the top for() loop also in case exact match has been >> found. > > > Ahh, OK. So maybe you should put "if (diff == 0) goto found" inside "if > (diff < best_diff)" block, in such case goto is not considered harmful > :), and is more readable. Exactly my thoughts ;) - Péter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki