From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41668C43381 for ; Tue, 19 Mar 2019 09:25:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0351A20857 for ; Tue, 19 Mar 2019 09:25:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="aRPUZsWp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0351A20857 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gC7HAAeljuvEanBrndRq5M5YJyx6hZDZbKR9in4zea8=; b=aRPUZsWp2MjzrG JBnin7mxLyqUtzo1V4Av0G4AV0XJtgwrx6ujKH0faooZKdxeKzfsBr7igslBEeDxugu1M2y4KX7aK RSlRuU4hWIV+jVQvp015xKvaqK2mmtxnhovhQVERSoBgvrMDtJIUvuVpn27tV8uBl97fO7cyqNY8J kLvn7Nq8aLTwSE5V13UEHSutlm4xXWoPCtDgJ34rzL//RfJUjuAAIMVpqaDHPvb1R0MuUZX/XDlZD NIsCy9BphGfAmqFkNVho1qgP9KAiYGtG7AidyCU9F3WXS407DCPI1qV002coM116tHi9lzXgKCmPh cdD4OGDYU9Fj8U3iOsFA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6AzP-0004MD-Aa; Tue, 19 Mar 2019 09:24:55 +0000 Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6AzM-0004LR-Bq for linux-arm-kernel@lists.infradead.org; Tue, 19 Mar 2019 09:24:54 +0000 X-Originating-IP: 182.72.246.220 Received: from localhost (unknown [182.72.246.220]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 060C440003; Tue, 19 Mar 2019 09:24:43 +0000 (UTC) Date: Tue, 19 Mar 2019 10:24:38 +0100 From: Alexandre Belloni To: Nicolas.Ferre@microchip.com Subject: Re: [PATCH v2] clk: at91: fix programmable clock for sama5d2 Message-ID: <20190319092438.GC29054@piout.net> References: <20190318105045.26943-1-nicolas.ferre@microchip.com> <155293884206.20095.9858756917267939797@swboyd.mtv.corp.google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190319_022452_550712_4B01C645 X-CRM114-Status: GOOD ( 15.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sboyd@kernel.org, mturquette@baylibre.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Claudiu.Beznea@microchip.com, matthias.wieloch@few-bauer.de, Ludovic.Desroches@microchip.com, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 19/03/2019 08:28:40+0000, Nicolas Ferre wrote: > > Ok. I can apply this clk-fixes. I presume that things are real bad and > > it can't wait until v5.2? > > To be perfectly clear, it's not a regression. > But as we're at the very beginning of the '-rc' phase and as it's a bug, > I was thinking about adding it now. But you to choose, no problem either > way. > > >> @@ -60,10 +68,18 @@ static int clk_programmable_determine_rate(struct clk_hw *hw, > >> continue; > >> > >> parent_rate = clk_hw_get_rate(parent); > >> - for (shift = 0; shift < PROG_PRES_MASK; shift++) { > >> - tmp_rate = parent_rate >> shift; > >> - if (tmp_rate <= req->rate) > >> - break; > >> + if (layout->is_pres_direct) { > >> + for (shift = 0; shift <= layout->pres_mask; shift++) { > >> + tmp_rate = parent_rate / (shift + 1); > >> + if (tmp_rate <= req->rate) > >> + break; > >> + } > >> + } else { > >> + for (shift = 0; shift < layout->pres_mask; shift++) { > >> + tmp_rate = parent_rate >> shift; > >> + if (tmp_rate <= req->rate) > >> + break; > >> + } > > > > This looks like a lot of copy paste when the if statement could have been > > pulled into the for loop instead of duplicating the loops and > > surrounding if condition check for tmp_rate. > > Stop condition of loops not being the same made me separate them instead > of adding artificial test conditions for shift == layout->pres_mask. I'm > not sure the other way around is more obvious then... > I also tried different ways (e.g. setting up a different determine_rate for the sama5d2) but this ended up being the more concise one. -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel