Received: by 10.223.185.116 with SMTP id b49csp3948616wrg; Mon, 19 Feb 2018 08:31:57 -0800 (PST) X-Google-Smtp-Source: AH8x224+Bvrt6AJiiGVppOSlp3Lml1Lc3W+olr4/rRQ4hEmiS3NrvtPjK0e2JUaPHbmEgYV5/Vv+ X-Received: by 2002:a17:902:4906:: with SMTP id u6-v6mr14233651pld.92.1519057916976; Mon, 19 Feb 2018 08:31:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519057916; cv=none; d=google.com; s=arc-20160816; b=vPigN/78mZxY7HuONrtbmXN47pg4Jt5Xn0vLnZMPTPQw1jpP25Xk8Gaunbd25xiMOm hwAtpntuxOZ2wdQbzfRh7ejfYYDP97Z4do/UHkcLZEFz71egFvoe2ryfio4rxYgFsIAE ml8z3H7JjAZkoKLk4mGHts5ekmFvfFgb4d1wu6tJTOTE0df/qph3yRbpD+tevTCnSArF W/MnDtx7bp3oHcFYmQo/jHR6fAc1HMBokjsyRbXa7cFuD1nbQJOFUKLMt4I2jae7qg2a yHm9yYj5rOepgHoCzRnEoiiOtkMFO9nix/N7a1tOtxd+8qjdnsbepF7MICS/78goUbSA kSyQ== 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:arc-authentication-results; bh=UGfYG4tgVvGub0xjANIQiTPRG1SUhzB9QV9w4VaKiKs=; b=z9pfacEvXhnd+Ss1w5bdkE2BHJjEWDKM4StQ5NdtkO8al0hINDV2HIBk9Oz5wEXb4D k3DhL9ta75QIp2TMpM52mYHMk5MEagOm0mqb0ZmKk62VCXa4Lk4cmPFoZsBlCIw2P31m Jc7huaAzBKbkMf2A6zPxOE1k0ctcUif9LFVefw87wzieK+Ul89NeyzAF8oqNPZ3J/R+S ZILZTCBzZxQM2b8IlFcbTKGjMVAG+nzHUl2cMvcIA3olmaTcA97xE2jZztQ7R4KeisR4 2rpYg1alo4DNi7HPxQsAY59DT4i3Wlf+wK0mCgL0KFni+eCeQWiIVBSkN+nn/eCh7MHQ 1qWw== 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 w8si6649304pgo.616.2018.02.19.08.31.42; Mon, 19 Feb 2018 08:31:56 -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; 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 S1753219AbeBSQ3b (ORCPT + 99 others); Mon, 19 Feb 2018 11:29:31 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:33352 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752897AbeBSQ31 (ORCPT ); Mon, 19 Feb 2018 11:29:27 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EB81C1529; Mon, 19 Feb 2018 08:29:26 -0800 (PST) Received: from [10.1.210.88] (e110467-lin.cambridge.arm.com [10.1.210.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 565C83F318; Mon, 19 Feb 2018 08:29:22 -0800 (PST) Subject: Re: [PATCH 1/8] clk: Add clk_bulk_alloc functions To: Maciej Purski , linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org Cc: David Airlie , Michael Turquette , Kamil Debski , Andrzej Hajda , Sylwester Nawrocki , Marek Szyprowski , 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 , Stephen Boyd , 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> From: Robin Murphy Message-ID: Date: Mon, 19 Feb 2018 16:29:12 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1519055046-2399-2-git-send-email-m.purski@samsung.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Maciej, On 19/02/18 15:43, Maciej Purski wrote: > When a driver is going to use clk_bulk_get() function, it has to > initialize an array of clk_bulk_data, by filling its id fields. > > Add a new function to the core, which dynamically allocates > clk_bulk_data array and fills its id fields. Add clk_bulk_free() > function, which frees the array allocated by clk_bulk_alloc() function. > Add a managed version of clk_bulk_alloc(). 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. > Signed-off-by: Maciej Purski > --- > drivers/clk/clk-bulk.c | 16 ++++++++++++ > drivers/clk/clk-devres.c | 37 +++++++++++++++++++++++++--- > include/linux/clk.h | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 113 insertions(+), 4 deletions(-) > [...] > @@ -598,6 +645,23 @@ struct clk *clk_get_sys(const char *dev_id, const char *con_id); > > #else /* !CONFIG_HAVE_CLK */ > > +static inline struct clk_bulk_data *clk_bulk_alloc(int num_clks, > + const char **clk_ids) > +{ > + return NULL; Either way, is it intentional not returning an ERR_PTR() value in this case? Since NULL will pass an IS_ERR() check, it seems a bit fragile for an allocation call to apparently succeed when the whole API is configured out (and I believe introducing new uses of IS_ERR_OR_NULL() is in general strongly discouraged.) Robin. > +} > + > +static inline struct clk_bulk_data *devm_clk_bulk_alloc(struct device *dev, > + int num_clks, > + const char **clk_ids) > +{ > + return NULL; > +} > + > +static inline void clk_bulk_free(struct clk_bulk_data *clks) > +{ > +} > + > static inline struct clk *clk_get(struct device *dev, const char *id) > { > return NULL; >