Received: by 10.213.65.68 with SMTP id h4csp38605imn; Thu, 15 Mar 2018 15:57:22 -0700 (PDT) X-Google-Smtp-Source: AG47ELsFVH1bEafO/7YPCBMgbSj0ULyj8LLOPUJZy/QyaCkqSzDJdcQX3w1O62FcPeHTjimZUd0b X-Received: by 2002:a17:902:7088:: with SMTP id z8-v6mr9945848plk.174.1521154641999; Thu, 15 Mar 2018 15:57:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521154641; cv=none; d=google.com; s=arc-20160816; b=1HZ2ONJ6NyW+CuLPsDuNcY1k2qbFxhCWrOUt80ciraQV6AZqQ5ITFcEtJZvjnhfGla OYi4GMpOXQ3btVUYnnam3L6QNpX8XP6HsHkKHHswvfblsJo2D2dPqXOILiYvPWb7osTY oy9VBatfbQx/48F7zZK9vVwyUDV9TqqAlgug3rB62KZtqFWlF12BhQjUl7P1rxSiSINu 5RQRAyTLonnMQQBd3apvJpLkJFnRpS1JGUZQnB+p+GHO2fg9Ezdb3GCPaRytSg2J+xZK 0J6JxBIOH4cjRoUva8Gyt8c3XsOiDMGNWhLjXEU1Mseu3Sh+N5gfZyyEgq8J5nQ/d/hr 86Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:dmarc-filter:arc-authentication-results; bh=/hpFdg4P7ql3/eMubOX6DO2D8TORiL8Yj3dB2xqBmBI=; b=pMiiT7JVYb3BlcPYQ6e3io6eMv5JoxMGtCArBrrD2F6yd32skJylwhy9b4UBw2tF6j 1MXvsm3rJBPnk0R6dXi9H7shnWcNM8m+sszhRS3adwnm/Sy0eTItLhcHasR3ASqL9RkQ fv3pe7auXbME8XGDFyHD+fBvC7EoVtUPSMm56M1AyXD8Ws+LL+qPURHhPE3qO6Yr0DIj cScnVAFizdMfmP/18iPdIdZkHDzemrmup5DYRgadnln1nWawdEEzDfhUolU7FgyECaAq 3JDGZuK6p94TPzUm8RPIhE9vHKT+afveZHv6PW66Y9g2FwufuChwqr7EbCw5EzLz6trL +/tA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u10-v6si4845999plu.362.2018.03.15.15.57.08; Thu, 15 Mar 2018 15:57:21 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932858AbeCOWzN convert rfc822-to-8bit (ORCPT + 99 others); Thu, 15 Mar 2018 18:55:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:37692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752810AbeCOWzL (ORCPT ); Thu, 15 Mar 2018 18:55:11 -0400 Received: from localhost (unknown [104.132.1.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 70D3320685; Thu, 15 Mar 2018 22:55:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70D3320685 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=sboyd@kernel.org Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Maciej Purski , Marek Szyprowski , Robin Murphy , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org From: Stephen Boyd In-Reply-To: Cc: David Airlie , Michael Turquette , Kamil Debski , Andrzej Hajda , Sylwester Nawrocki , Thibault Saunier , Joonyoung Shim , Russell King , Krzysztof Kozlowski , Javier Martinez Canillas , Kukjin Kim , Hoegeun Kwon , Bartlomiej Zolnierkiewicz , Inki Dae , Jeongtae Park , Jacek Anaszewski , Andrzej Pietrasiewicz , Mauro Carvalho Chehab , Seung-Woo Kim , Hans Verkuil , Kyungmin Park References: <1519055046-2399-1-git-send-email-m.purski@samsung.com> <1519055046-2399-2-git-send-email-m.purski@samsung.com> Message-ID: <152115450981.111154.2342657732967302796@swboyd.mtv.corp.google.com> User-Agent: alot/0.7 Subject: Re: [PATCH 1/8] clk: Add clk_bulk_alloc functions Date: Thu, 15 Mar 2018 15:55:09 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Marek Szyprowski (2018-02-20 01:36:03) > Hi Robin, > > On 2018-02-19 17:29, Robin Murphy wrote: > > > > Seeing how every subsequent patch ends up with the roughly this same > > stanza: > > > >     x = devm_clk_bulk_alloc(dev, num, names); > >     if (IS_ERR(x) > >         return PTR_ERR(x); > >     ret = devm_clk_bulk_get(dev, x, num); > > > > I wonder if it might be better to simply implement: > > > >     int devm_clk_bulk_alloc_get(dev, &x, num, names) > > > > that does the whole lot in one go, and let drivers that want to do > > more fiddly things continue to open-code the allocation. > > > > But perhaps that's an abstraction too far... I'm not all that familiar > > with the lie of the land here. > > Hmmm. This patchset clearly shows, that it would be much simpler if we > get rid of clk_bulk_data structure at all and let clk_bulk_* functions > to operate on struct clk *array[]. Typically the list of clock names > is already in some kind of array (taken from driver data or statically > embedded into driver), so there is little benefit from duplicating it > in clk_bulk_data. Sadly, I missed clk_bulk_* api discussion and maybe > there are other benefits from this approach. > > If not, I suggest simplifying clk_bulk_* api by dropping clk_bulk_data > structure and switching to clock ptr array: > > int clk_bulk_get(struct device *dev, int num_clock, struct clk *clocks[], >                  const char *clk_names[]); > int clk_bulk_prepare(int num_clks, struct clk *clks[]); > int clk_bulk_enable(int num_clks, struct clk *clks[]); > ... > If you have an array of pointers to names of clks then we can put the struct clk pointers adjacent to them at the same time. I suppose the problem there is that some drivers want to mark that array of pointers to names as const. And then we can't update the clk pointers next to them. This is the same design that regulators has done so that's why it's written like this for clks. Honestly, we're talking about a handful of pointers here so I'm not sure it really matters much. Just duplicate the pointer and be done if you want to mark the array of names as const or have your const 'setup' structure point to the bulk_data array that you define statically non-const somewhere globally.