Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp176143ybx; Wed, 6 Nov 2019 15:11:27 -0800 (PST) X-Google-Smtp-Source: APXvYqxD+8wpziV6rAwyzQki2jCaIIG78N/Tv9XXMine6vws+CbTByUQHBD3ZXHCQvO1RcRW5KfG X-Received: by 2002:a05:6402:382:: with SMTP id o2mr292336edv.61.1573081887775; Wed, 06 Nov 2019 15:11:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573081887; cv=none; d=google.com; s=arc-20160816; b=nA4Y+1NxE+E9OcVasXHu7SLHyNUvBJPD7PvRy0uimRxWFAqUQ0JHA9JXG+UYLtXa98 XRn20klxK7WdrGLV4r90NJEdcTQWuf0qVSd7R/SKWFBlARCWICfRwY8cshQP3Ps6f3WA KWa1AIvcnjkKX16Cwqbu89mOa+I4DUWiD4oOYJqIQBEKw0NHnfhiz6W+HBB7XMHQGwqW AFjy61Lu8RPPUINMPAbBT7fP1kmWuN9UA8GFOFeUIClA6kd1/5ylzE7NpvzjazhQDGqY ncvwe0TAxuXctBIgOZWDbk8MPL76Xc4bOKIQZXtmqEug+9+kmd4qQAxFM4pKYEd5b3vu uTrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:user-agent:cc:to:from :subject:references:in-reply-to:content-transfer-encoding :mime-version:dkim-signature; bh=lKcqjJF2a3j9rqWVfIKXu6Sp9nc6hO2Dkc4HMTWUARo=; b=XdJl0R3Iiwa++JkrdN7SUbGRmGQohO3WNJM7qFQFf/HBlWK4XksBAjPTDkNZsap5XB i1EZDAfz25OuLK/hRD3mK+v00A4CWau1rBMQ8PzLHob+YXzOwJiHcYEKY6TWgIlaCCt2 n8Z+3eYFSQ8JHNJdS5dQOF9vnRfWBjdRagUEfGB9NrnXLy4Zpa8/hqbSbqPnJPtfDIRM ToIynYYF2wVVEcmDoj9TSlxpJ2eWJ02567PtZwXasHKj99DkdgSLHHNG3cVWtiyu8h0L n5wmLEkVW+KMj4LOdZAwSfJ+mcVW0porgAuNTRpI0M5FHXmF1XYQ14ylSsemHIjWWZ/8 jtKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ujuxe6X1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e24si54601ede.392.2019.11.06.15.11.04; Wed, 06 Nov 2019 15:11:27 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Ujuxe6X1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732847AbfKFXKH (ORCPT + 99 others); Wed, 6 Nov 2019 18:10:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:34466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727228AbfKFXKH (ORCPT ); Wed, 6 Nov 2019 18:10:07 -0500 Received: from kernel.org (unknown [104.132.0.74]) (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 F2CD820869; Wed, 6 Nov 2019 23:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573081806; bh=phPqrB8jdcQhMXpI7PNcLtByNjzRwAfdzJcKYVWr13E=; h=In-Reply-To:References:Subject:From:To:Cc:Date:From; b=Ujuxe6X1kCsRkxtdQYgSWiR0mYrSc9nQP1ygJUr45CCctRkVEX2Jf9Wnp4kkOvTVm GBOqu/HNFeA6cJMT7QS6PMnl2OKfLo3pUAUZ0MAZ1yEG1+KPhxkjhqPb0cTze2UIjW qce2kBf6A/GX0fvsfQmdvN+ylBBREGi5gRasWjRE= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <1565984527-5272-8-git-send-email-skomatineni@nvidia.com> References: <1565984527-5272-1-git-send-email-skomatineni@nvidia.com> <1565984527-5272-8-git-send-email-skomatineni@nvidia.com> Subject: Re: [PATCH v9 07/22] clk: Add API to get index of the clock parent From: Stephen Boyd To: Sowjanya Komatineni , jason@lakedaemon.net, jonathanh@nvidia.com, linus.walleij@linaro.org, marc.zyngier@arm.com, mark.rutland@arm.com, stefan@agner.ch, tglx@linutronix.de, thierry.reding@gmail.com Cc: pdeschrijver@nvidia.com, pgaikwad@nvidia.com, linux-clk@vger.kernel.org, linux-gpio@vger.kernel.org, jckuo@nvidia.com, josephl@nvidia.com, talho@nvidia.com, skomatineni@nvidia.com, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, mperttunen@nvidia.com, spatra@nvidia.com, robh+dt@kernel.org, digetx@gmail.com, devicetree@vger.kernel.org, rjw@rjwysocki.net, viresh.kumar@linaro.org, linux-pm@vger.kernel.org User-Agent: alot/0.8.1 Date: Wed, 06 Nov 2019 15:10:05 -0800 Message-Id: <20191106231005.F2CD820869@mail.kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Sowjanya Komatineni (2019-08-16 12:41:52) > This patch adds an API clk_hw_get_parent_index to get index of the > clock parent to use during the clock restore operations on system > resume. Is there a reason we can't save the clk hw index at suspend time by reading the hardware to understand the current parent? The parent index typically doesn't matter unless we're trying to communicate something from the framework to the provider driver. Put another way, I would think the provider driver can figure out the index itself without having to go through the framework to do so. >=20 > Reviewed-by: Thierry Reding > Reviewed-by: Dmitry Osipenko > Signed-off-by: Sowjanya Komatineni > > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c > index cbcc333aec84..12ad0e9b8591 100644 > --- a/drivers/clk/clk.c > +++ b/drivers/clk/clk.c > @@ -1645,6 +1645,23 @@ static int clk_fetch_parent_index(struct clk_core = *core, > return i; > } > =20 > +/** > + * clk_hw_get_parent_index - return the index of parent clock > + * @hw: clk_hw associated with the clk being consumed > + * @parent_hw: clk_hw associated with the parent of clk > + * > + * Fetches and returns the index of parent clock. > + * If hw or parent_hw is NULL, returns -EINVAL. > + */ > +int clk_hw_get_parent_index(struct clk_hw *hw, struct clk_hw *parent_hw) > +{ > + if (!hw || !parent_hw) > + return -EINVAL; The caller should be ashamed if they call this with NULL arguments. I'd prefer we skip this check and we get an oops. > + > + return clk_fetch_parent_index(hw->core, parent_hw->core); > +} > +EXPORT_SYMBOL_GPL(clk_hw_get_parent_index); > + > /* > * Update the orphan status of @core and all its children. > */