Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1038675rdb; Fri, 16 Feb 2024 03:37:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVGIZmV8rTgV3Nyw3wjzHvvSyMk1UQJoMNuZ5jvGffWbi1ZnirPcstIFWIrXGP9sAx91OwCNc6j8O+C9tgN/byWFUD14ha8WhuWAOONiw== X-Google-Smtp-Source: AGHT+IG4yXaasfrPpTR6Pr4gps1qEawFshzibpXX/Nz/5JlLCbnDEXYm1CWqGpwfgx0XLpXnEN1e X-Received: by 2002:a17:902:a381:b0:1db:2d8d:914 with SMTP id x1-20020a170902a38100b001db2d8d0914mr4454232pla.53.1708083445151; Fri, 16 Feb 2024 03:37:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708083445; cv=pass; d=google.com; s=arc-20160816; b=yGYZFWJdQHOxFIKdQKIVsc2wf5IQDLjteJDwk+PN0GykM7T/uNBiVhS2BTvtbyn/9M sKr/7HKQ8DMQSjuSyi2a7lyXYjfx3pOC1mlCEoMDjV013/ShoXprBCVic/W6U3DM46T0 NmDPfHlGTjWPLeVQxdEDTwyyPrwVJ8b7luwTRh3uj02hYqnB7QH93K7WWsNUoA/2lrRq MR2OdxPYnLCWUdNmDHZS7STMWpQE5Bbls517xs77yGVsR6NqX8TT6+F3vC3L3FlCjzgP kM0GafDknkh64uNfJ/3Hha5uK5t111iOFTDHgYpSKTJ6J+wQFAeaOXkxCzuM8z1afhyp eCbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=yTLg2p9rvSPRXvNKR+Iv16WduzUd8WzxwmsQxSSHbjw=; fh=u6H1OQS3u+ymIfd0BsyY4OLOIQIuQoKx13XmoBosQgY=; b=KqUecmbOmjPOd0Zu2SRnI/HGiCb4kYMEcEHjbm9LvGe8vNCHeos4zt0ACwQlHEhgO6 IESEDdQYPKq4cjWkSq+oxQ9ZrKkeskNaeHJQU6/2QMeAjgtR9U9wpI6QciYqDPTA5MC+ TVIsIFxoTXOTifjSakLQ1UWJ8Gxp6K+ViCu4ismr/ibxwZT4WWfIrTRc5lgy6zKsH4jG cZzeM/KFoaZgFShmIrODvdWMRtHhC0u/IzBin/pXWN58cFMHDF/7oeHrg9VpFAy/2sYK CfOI+8rCcuHnJcxdplOdtN9UNiY/n8WmJKTHviTYARpHc7gEOgLChO9fb5F5Ra5Wt8Q9 y1/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K5Lv258E; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-68525-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68525-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c5-20020a170902d48500b001db29999242si2993731plg.251.2024.02.16.03.37.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 03:37:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68525-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K5Lv258E; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-68525-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68525-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 0E0D1B231B6 for ; Fri, 16 Feb 2024 11:32:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 461C177F22; Fri, 16 Feb 2024 11:31:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="K5Lv258E" Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5363477F04 for ; Fri, 16 Feb 2024 11:31:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708083118; cv=none; b=LQZKh3+Igl+9pGGVRciXS2iDxxeKvmpeNcpNwDwemyx5KWgECWuRllINueWbtudIv1Hsvg4WgBUf7oACJ6oNjGICd8zajEwobbHZy83pVz7RM86n0MbKLPxqoUeVvxv4MQtrdKzgQPUywH8e9UkWJu1OGB9I3pazG/vi5KOlQA8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708083118; c=relaxed/simple; bh=UwV6PP9Dy4l/PHEko/rhazRk7bZ5pWgavF2GNsY4jB4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lrtQkccBCvvxvZwL5GWY7gVUIpVVzoHDqSlKD99LiEHZKdyw8nRlgR/bngDvuVhHVP+4pqNYOxAyL3aoeOgJcyF4YhVYBT0l24aE+TzBH45X28YO+EGBZSD9b3610I+quTzAvlyCRNlGyhMZgg68kHDQ2/yHhDi7OYHKJFod5OE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=K5Lv258E; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1dbae7b8ff2so1677955ad.3 for ; Fri, 16 Feb 2024 03:31:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708083114; x=1708687914; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=yTLg2p9rvSPRXvNKR+Iv16WduzUd8WzxwmsQxSSHbjw=; b=K5Lv258EC7/0q9VDM7mhlj/jvCDy4xaOetbe37QlFvlSvzrmEK/llqd0ztiRn5LJ3p j2AMzYvUL7IYFASyPJqKPJhondmmaW4G9T2s1i+URB5EcaqOVV2wfRaGd8R+Mqf1S6MX jVA0wx2Gv/4milh3bC9wHZ6TjFkhAd0WvhOoBQdVPz0OQ7EgsFLlOzqchjk1VZF+K+8V Jo9yduEPMLBW9TL9/xprWd8uwTilLwALuOqmA/8zU9FwPstdohqSx1aJfxLbjWnkpyk4 FREpG5Fv/4B/XpbP3+pmjjRIIdbAuQMmNdjQ0koQ3e0R5edm8WbP/bDDjmjcVuUcRD8W lRgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708083114; x=1708687914; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yTLg2p9rvSPRXvNKR+Iv16WduzUd8WzxwmsQxSSHbjw=; b=Et3v0SCnxOlEV62XDUG456bdLkWVU73S1+GXt+XheO46plrGLySEt5rhQ0jhBq4ydH fBDOEyKv8JVJCoBmIUf6k51KIus+YL12/c0e72zSsGmuuIh0wy6kGtd3J774Ny2LGf2T K1UxnTGMDSPPDpxRKWkO6rVbtfnd9GUKriB6KZv77IEnr3KvVeSwItRZ4zH2sz0WR33d j19XFsnRQRgX8tdpvtaa7A8apL7QVNyo7GixRBVwISkQIh134Nt1ch2662EGEs7KUdpp uRKZCp7Uuv63pLgza9wazeRJHVYv7GETu3qWFVk/DuldqRdha+hGMsODaRQ8W3XGhfpx 2e3Q== X-Forwarded-Encrypted: i=1; AJvYcCX3QX+U/nwkM49cBdXA3vuHCS6UQ7U701gJ+fHXypfrXVyr2gxCHBOGq890ypFrlbZ/0b7glrXA7lPSqN9gdFRc5Ky9ALZByORdhaMZ X-Gm-Message-State: AOJu0YxFc/SIl32vBbR3Om7yj8g8gE31qu0Oc8UIuH8geqMheF/AFiO7 tQeZYSg7a44X7cZw96AOhHV7zoYyn2LVlfkPmKArHZNCL70t8gnun0WGedaRxQ== X-Received: by 2002:a17:902:e84e:b0:1da:2a3e:4c62 with SMTP id t14-20020a170902e84e00b001da2a3e4c62mr6071696plg.14.1708083114435; Fri, 16 Feb 2024 03:31:54 -0800 (PST) Received: from thinkpad ([120.138.12.48]) by smtp.gmail.com with ESMTPSA id r10-20020a170902c60a00b001db817b956bsm2811849plr.259.2024.02.16.03.31.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 03:31:54 -0800 (PST) Date: Fri, 16 Feb 2024 17:01:47 +0530 From: Manivannan Sadhasivam To: Shradha Todi Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, mturquette@baylibre.com, sboyd@kernel.org, jingoohan1@gmail.com, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, bhelgaas@google.com, krzysztof.kozlowski@linaro.org, alim.akhtar@samsung.com, linux@armlinux.org.uk, m.szyprowski@samsung.com, pankaj.dubey@samsung.com, gost.dev@samsung.com Subject: Re: [PATCH v5 1/2] clk: Provide managed helper to get and enable bulk clocks Message-ID: <20240216113147.GF2559@thinkpad> References: <20240213132751.46813-1-shradha.t@samsung.com> <20240213132751.46813-2-shradha.t@samsung.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240213132751.46813-2-shradha.t@samsung.com> On Tue, Feb 13, 2024 at 06:57:50PM +0530, Shradha Todi wrote: > Provide a managed devm_clk_bulk* wrapper to get and enable all > bulk clocks in order to simplify drivers that keeps all clocks > enabled for the time of driver operation. > > Suggested-by: Marek Szyprowski > Reviewed-by: Alim Akhtar > Signed-off-by: Shradha Todi Reviewed-by: Manivannan Sadhasivam - Mani > --- > drivers/clk/clk-devres.c | 40 ++++++++++++++++++++++++++++++++++++++++ > include/linux/clk.h | 23 +++++++++++++++++++++++ > 2 files changed, 63 insertions(+) > > diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c > index 4fb4fd4b06bd..cbbd2cc339c3 100644 > --- a/drivers/clk/clk-devres.c > +++ b/drivers/clk/clk-devres.c > @@ -182,6 +182,46 @@ int __must_check devm_clk_bulk_get_all(struct device *dev, > } > EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all); > > +static void devm_clk_bulk_release_all_enable(struct device *dev, void *res) > +{ > + struct clk_bulk_devres *devres = res; > + > + clk_bulk_disable_unprepare(devres->num_clks, devres->clks); > + clk_bulk_put_all(devres->num_clks, devres->clks); > +} > + > +int __must_check devm_clk_bulk_get_all_enable(struct device *dev, > + struct clk_bulk_data **clks) > +{ > + struct clk_bulk_devres *devres; > + int ret; > + > + devres = devres_alloc(devm_clk_bulk_release_all_enable, > + sizeof(*devres), GFP_KERNEL); > + if (!devres) > + return -ENOMEM; > + > + ret = clk_bulk_get_all(dev, &devres->clks); > + if (ret > 0) { > + *clks = devres->clks; > + devres->num_clks = ret; > + } else { > + devres_free(devres); > + return ret; > + } > + > + ret = clk_bulk_prepare_enable(devres->num_clks, *clks); > + if (!ret) { > + devres_add(dev, devres); > + } else { > + clk_bulk_put_all(devres->num_clks, devres->clks); > + devres_free(devres); > + } > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all_enable); > + > static int devm_clk_match(struct device *dev, void *res, void *data) > { > struct clk **c = res; > diff --git a/include/linux/clk.h b/include/linux/clk.h > index 1ef013324237..85a9330d5a5a 100644 > --- a/include/linux/clk.h > +++ b/include/linux/clk.h > @@ -438,6 +438,22 @@ int __must_check devm_clk_bulk_get_optional(struct device *dev, int num_clks, > int __must_check devm_clk_bulk_get_all(struct device *dev, > struct clk_bulk_data **clks); > > +/** > + * devm_clk_bulk_get_all_enable - Get and enable all clocks of the consumer (managed) > + * @dev: device for clock "consumer" > + * @clks: pointer to the clk_bulk_data table of consumer > + * > + * Returns success (0) or negative errno. > + * > + * This helper function allows drivers to get all clocks of the > + * consumer and enables them in one operation with management. > + * The clks will automatically be disabled and freed when the device > + * is unbound. > + */ > + > +int __must_check devm_clk_bulk_get_all_enable(struct device *dev, > + struct clk_bulk_data **clks); > + > /** > * devm_clk_get - lookup and obtain a managed reference to a clock producer. > * @dev: device for clock "consumer" > @@ -960,6 +976,13 @@ static inline int __must_check devm_clk_bulk_get_all(struct device *dev, > return 0; > } > > +static inline int __must_check devm_clk_bulk_get_all_enable(struct device *dev, > + struct clk_bulk_data **clks) > +{ > + > + return 0; > +} > + > static inline struct clk *devm_get_clk_from_child(struct device *dev, > struct device_node *np, const char *con_id) > { > -- > 2.17.1 > -- மணிவண்ணன் சதாசிவம்