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=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 4A026C433B4 for ; Wed, 19 May 2021 12:33:54 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 CF6C26108B for ; Wed, 19 May 2021 12:33:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CF6C26108B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Date:Message-ID:In-reply-to:Subject:Cc: To:From:References:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SYKBAGvraAFAU8D2KlsnA0ZSo0+qoXkCa7b3fSwjZt4=; b=IiH5Bx7ZsL36+OTWkn3UTpOcu J30QFr1rTeay6eu4ibMB+bVzJC2YRTJ/n8tA0CmoYwZZ942WxB3hh/o+CSRZtAbLMp4W0QkeS3dJu yjpuIzdquo6McZaCaiALO+yuAY7vG/dM07cjd7NrdCRlRgo/ga4SQEgIedVFvJYRjU6Fana26rPH/ ZIuw6zT8m5iGzvb/FaJUrOaiV81G77Az67ZTlp+BzffVJO+tYt4Ds6W6AQtwVWPCQ0XDK8LeIj4CH gRbl/F/CKpFilyctKxMyUFOHslfgORaJygMgn3+kyLQplzUC6fSxxc0th0jy7XFax3aX+7mpREUz2 dQAvt2wSA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ljLMi-003uXG-FR; Wed, 19 May 2021 12:31:56 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljLMa-003uUa-60 for linux-arm-kernel@desiato.infradead.org; Wed, 19 May 2021 12:31:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:MIME-Version:Date: Message-ID:In-reply-to:Subject:Cc:To:From:References:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=bAo7Ei/TUi10dkjUS5XYUKLdKDhp8o5GDEEhLvW8E/8=; b=q3hAjQlL9zQgbuBVcjQm5clIT5 Ak5oipbre0TxgdI/eG8T1ucgvS4EuJ29eP9UbJL3uCRmLS2bQNMl0M3J9ZYnjfFxmTqHrvKktnkkb OlC+vHRcOEDkUik5NHQNrOxr4rB6hizP8HqVSnHg56ZrvrIOqG3oIwJ7DNRK/bNIuikxSxIbIAxUy +juqzDzqWlmrOSkkJcSxWziEszJ3bQCFxpsvkesqgsuzDl9f3hEAdngkQwaqlz12Qx6pOmBpHcQ3t MEuO6dz9RB6WziAQs4NV29cZP4zl/9Z0oGX4GLSJOhJLrAfkp3nTEgU0pIPZYqsvuOk9rxfGpPegj c4cQ3Krg==; Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljLMW-00FSAz-Tc for linux-arm-kernel@lists.infradead.org; Wed, 19 May 2021 12:31:46 +0000 Received: by mail-wm1-x332.google.com with SMTP id z19-20020a7bc7d30000b029017521c1fb75so3358957wmk.0 for ; Wed, 19 May 2021 05:31:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=references:user-agent:from:to:cc:subject:in-reply-to:message-id :date:mime-version; bh=bAo7Ei/TUi10dkjUS5XYUKLdKDhp8o5GDEEhLvW8E/8=; b=oL1E6C3sCn5SHZuQHZQ4qSR511zUkj1ReiFbYY7jMF3nHEXzAwrJBxV5BlKQfH5J4o RP7yi+L6XxHJn7+zxVHoPJa0rOXsTP3b/bODa1ijp9XrcLFVIs8L0JGMjxcSSswU0LeS jybN7+Bw8gTm3Ru3oTvtzkLVn1YlrM0zMXUv0+mNX5NrcAFh9+W+stJKmRHzv/7xAqr+ fmTYrsF+ZlDhafMfvFJTkjDOTLrYgCGMcCqASE96TXMJbuP7/CsJPZM07Tt889kaAskz QUctp0dN9NOVjtNLssocI3ukWFH6O/rSqk7dKPcnuProg7E/pu0p9okkQ4i2uXvEkUqv qJtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:message-id:date:mime-version; bh=bAo7Ei/TUi10dkjUS5XYUKLdKDhp8o5GDEEhLvW8E/8=; b=J0GfYqRCvUKrN2qv2d0YhsTbyt2w5VRg17/jN/57EvE0VSKgVFogO9zmJEoRhv3oIP UOh61+HOUT0Lf51myktYaCfEt7kPl2QcXxS3mu+ATBxZBuh1fu+UO87+HC1PyLxk9czA /btKP6PWcXtIZ/hOYW5a8/XB7EGEifbwouGap3P1MSZnTX4ikv6I217mlSWJbzLPdqYa PMy4A06v49AnHtbLMYdDbl4NQ5aUu1UYOg7ibRIKyAhaJLK2L86iip/nSdXVGmJXeIm+ S7ImUnZRVLOcxWdADw+7r88FlndG5L/feB+a8GJIxia7ilVLYKxc54lNrm0c0xmd8lu8 viNw== X-Gm-Message-State: AOAM532qJ1HVmc3sLy/pytASn1wQHTteFtsG3LMDz1u/IAhew8OlHcrI dbQwJ5mMwpZKsbMWZ+FlnpfdGA== X-Google-Smtp-Source: ABdhPJxuxG5efFOAKNN/YpLS+nSoJ6UYkSczlvIdgyrB9oZNqJ9617YPnFDTyRH3uyrAmV13niYQGQ== X-Received: by 2002:a05:600c:19cb:: with SMTP id u11mr11538782wmq.185.1621427502264; Wed, 19 May 2021 05:31:42 -0700 (PDT) Received: from localhost (82-65-169-74.subs.proxad.net. [82.65.169.74]) by smtp.gmail.com with ESMTPSA id u19sm1185904wmq.7.2021.05.19.05.31.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 May 2021 05:31:41 -0700 (PDT) References: <20210517203724.1006254-1-martin.blumenstingl@googlemail.com> <20210517203724.1006254-2-martin.blumenstingl@googlemail.com> <1jtun01o5p.fsf@starbuckisacylon.baylibre.com> User-agent: mu4e 1.4.15; emacs 27.1 From: Jerome Brunet To: Martin Blumenstingl Cc: mturquette@baylibre.com, sboyd@kernel.org, Neil Armstrong , linux-clk@vger.kernel.org, khilman@baylibre.com, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH RFC v1 1/3] clk: divider: Add re-usable determine_rate implementations In-reply-to: Message-ID: <1jv97eaor6.fsf@starbuckisacylon.baylibre.com> Date: Wed, 19 May 2021 14:31:41 +0200 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210519_053145_047369_5BAC9365 X-CRM114-Status: GOOD ( 22.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue 18 May 2021 at 22:33, Martin Blumenstingl wrote: > Hi Jerome, > > On Tue, May 18, 2021 at 9:44 AM Jerome Brunet wrote: > [...] >> > +int divider_ro_determine_rate(struct clk_hw *hw, struct clk_rate_request *req, >> > + const struct clk_div_table *table, u8 width, >> > + unsigned long flags, unsigned int val) >> > +{ >> > + int div; >> > + >> > + div = _get_div(table, val, flags, width); >> > + >> > + /* Even a read-only clock can propagate a rate change */ >> > + if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) { >> > + if (!req->best_parent_hw) >> > + return -EINVAL; >> > + >> > + req->best_parent_rate = clk_hw_round_rate(req->best_parent_hw, >> > + req->rate * div); >> > + } >> > + >> > + req->rate = DIV_ROUND_UP_ULL((u64)req->best_parent_rate, div); >> > + >> > + return 0; >> > +} >> > +EXPORT_SYMBOL_GPL(divider_ro_determine_rate); >> >> For a final version, could you factorize the code with the .round_rate() >> variant ? It would remove a bit of duplication. > my first idea was to basically let the new _determine_rate code just > forward all relevant parameters to _round_rate > however, I discarded that as it turned out to be less understandable > for me as parameters need to be mapped in both ways > > while writing this mail I noticed that the opposite direction > (meaning: _round_rate forwards to _determine_rate) will probably work. > I'll give it a try in the next days > if you had anything else in mind then please let me know Yep, the idea would be to use the determine_rate() part as the common implementation. AFAICT, all you need is to build req_rate structure in the round_rate() part. > >> Maybe determine_rate() can also replace round_rate() in the generic >> divider ops ? > sure, I'll add that as a separate patch in this series > note to myself: testing can be done with the MMC drivers as we're > using the generic clk_divider_ops there > > > Best regards, > Martin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel