From patchwork Sat Mar 27 11:02:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 410131 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2160436jai; Sat, 27 Mar 2021 04:03:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxV2pB4ENeXARmbNgTgPujMYOVcGztkR4WqYBNazSCkNtxHXWED6RAQVnqVhph9iWbpai1b X-Received: by 2002:a17:906:cb18:: with SMTP id lk24mr19090923ejb.70.1616842998099; Sat, 27 Mar 2021 04:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616842998; cv=none; d=google.com; s=arc-20160816; b=APsSJS2jHl9t8R7nfFyQ+7klP5epI5FNOrxFNgsUi1Zs73QTZBEu0v4etAUnRWb0E0 HhOPuKq1C7WnsIhEnp1AlXEVgou54JBTqAhomue4RNMuRJzuldmuRGyQf4DPSBy8rW6f qEi5ulEuSnDevmvkVsTRQ61fkRhpoIe+O8FTkopQehJmKv4jVNLlSYhqH7M+pm3fpo0q zchuudArMCOeF575atKeB3HWzW5nbia5e4KFLLdKsCQNoDsQFXeb6IsxXF0f0KN0Tvt+ wR3u4W+yFtFC5aY2j+LGxLkoCCTWOrvnMSpj3RQTLRQEX18slBAfJAP/iKDO3Zv1T63l dOkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9T3V1Iuh/pWUZcOYqOHZd87B2nHY2V8k/rzwsRWGTYg=; b=kP7Iq+cPmkjCcPQrY/eaxGBpowqKc4ePzr72DeKI75NTIYgKmsv6mIHjtIb4HdoXZp z8Rj24Ap5+e4ZanzuTJ9h8Tyabac8srpIEq2G61pPnNY+Z7y89Sniq9/qHlgfx/75yMY PHShKmQraIVSK0SuWXGtk0HSjsJiIRU8T47+Z+lf+z5IsfpAlns5MWri1Pz+ygQA4ivD r0A7ZWqwXZU4aQyyIQ2FMLnC8LMsd/b/leOuXJJcjhf0hnRC7CsM6UCHwvPCWng1cy0y qSyp2ycdA1al1tuhkzl/FMPFxkUNZ41MQ+lgQNp8hRaQvhxkFTcFO8ZvmIctN6m96ZpC ddOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=apuB+DXG; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c17si9600445edr.46.2021.03.27.04.03.17; Sat, 27 Mar 2021 04:03:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=apuB+DXG; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230415AbhC0LDP (ORCPT + 17 others); Sat, 27 Mar 2021 07:03:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230350AbhC0LDO (ORCPT ); Sat, 27 Mar 2021 07:03:14 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E280C0613B1 for ; Sat, 27 Mar 2021 04:03:14 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id 12so1127777lfq.13 for ; Sat, 27 Mar 2021 04:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9T3V1Iuh/pWUZcOYqOHZd87B2nHY2V8k/rzwsRWGTYg=; b=apuB+DXG4PiOIq/SciIJCGwhZYrYIdKcqJDY8/b0wFZeuf5oxptyUYQfqnb76j1Lkf Mj4srTMtdgtQFEX/zPD4+dfENsGeEc3WArddcjjmLFdwysgeQK4zS9S/Kt8hVV/uN5zz lR93teqcoR/I0dvApRhBtTpvNa3jKY8tmOALcBFthnfTsNzfYdipzWHMxh6RxQwDF0Ts MN8UkMO8qacgeyuuF1Klq6AXs650onYTXDEKazDedmG+P5q5MOoZ4NTeiNaXMsDrc7Ei hW1jETROjoCDLUkrE+/EDNlcy1DEN3asMNLkN79OeVtrzthpN7yJDnQL3oW9NpzLwtmy cIqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9T3V1Iuh/pWUZcOYqOHZd87B2nHY2V8k/rzwsRWGTYg=; b=NnmvclGwLKFcMqco7CGKTrREYzT2dxZPJ/kEijxcNvbSrEZhz1v6zTfs52Crd4DhNq 4FUXoOAcKBkZRop8lfuEPYKXrGkT+Jb/BWo6KQ084NiPqVMKINzjwCgQpO2Yaq2nIRYn af8YFDfkvRCT5GEtY97H92VNPoHwH+/k3su5qXQc++6faKdGdl25iNWLyHqrCG4CtXUo kuYnvqirpV8UbTwwB71GlDabMp8nVXF/1IOwxzgOMX4Yf1rJVsTQ0eO6PGKN2P3vIsb/ 6f5GCdqZNWDPF7FEKPp0x7lcFSPC0rCLwdKvMky4p0OdGm5prhrqfq9oQpqGisq/7aQT ze0g== X-Gm-Message-State: AOAM531Mw6u786uJhXzrdWkrBw+ji5k3AWd5DmMY49IKYmTSB+ZdrWap 9VeeyOwCzws422nvof1db6uo9Q== X-Received: by 2002:a05:6512:3b9a:: with SMTP id g26mr10992553lfv.560.1616842992707; Sat, 27 Mar 2021 04:03:12 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id a8sm1513801ljn.96.2021.03.27.04.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Mar 2021 04:03:12 -0700 (PDT) From: Dmitry Baryshkov To: Rob Clark , Sean Paul , Abhinav Kumar , Jonathan Marek , Michael Turquette Cc: Stephen Boyd , David Airlie , Daniel Vetter , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-clk@vger.kernel.org Subject: [PATCH v3 02/25] clk: mux: provide devm_clk_hw_register_mux() Date: Sat, 27 Mar 2021 14:02:42 +0300 Message-Id: <20210327110305.3289784-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210327110305.3289784-1-dmitry.baryshkov@linaro.org> References: <20210327110305.3289784-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add devm_clk_hw_register_mux() - devres-managed version of clk_hw_register_mux(). Signed-off-by: Dmitry Baryshkov Reviewed-by: Abhinav Kumar --- drivers/clk/clk-mux.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/clk-provider.h | 13 +++++++++++++ 2 files changed, 48 insertions(+) -- 2.30.2 diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c index e54e79714818..20582aae7a35 100644 --- a/drivers/clk/clk-mux.c +++ b/drivers/clk/clk-mux.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -206,6 +207,40 @@ struct clk_hw *__clk_hw_register_mux(struct device *dev, struct device_node *np, } EXPORT_SYMBOL_GPL(__clk_hw_register_mux); +static void devm_clk_hw_release_mux(struct device *dev, void *res) +{ + clk_hw_unregister_mux(*(struct clk_hw **)res); +} + +struct clk_hw *__devm_clk_hw_register_mux(struct device *dev, struct device_node *np, + const char *name, u8 num_parents, + const char * const *parent_names, + const struct clk_hw **parent_hws, + const struct clk_parent_data *parent_data, + unsigned long flags, void __iomem *reg, u8 shift, u32 mask, + u8 clk_mux_flags, u32 *table, spinlock_t *lock) +{ + struct clk_hw **ptr, *hw; + + ptr = devres_alloc(devm_clk_hw_release_mux, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + hw = __clk_hw_register_mux(dev, np, name, num_parents, parent_names, parent_hws, + parent_data, flags, reg, shift, mask, + clk_mux_flags, table, lock); + + if (!IS_ERR(hw)) { + *ptr = hw; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return hw; +} +EXPORT_SYMBOL_GPL(__devm_clk_hw_register_mux); + struct clk *clk_register_mux_table(struct device *dev, const char *name, const char * const *parent_names, u8 num_parents, unsigned long flags, void __iomem *reg, u8 shift, u32 mask, diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 58f6fe866ae9..3eb15e0262f5 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -868,6 +868,13 @@ struct clk_hw *__clk_hw_register_mux(struct device *dev, struct device_node *np, const struct clk_parent_data *parent_data, unsigned long flags, void __iomem *reg, u8 shift, u32 mask, u8 clk_mux_flags, u32 *table, spinlock_t *lock); +struct clk_hw *__devm_clk_hw_register_mux(struct device *dev, struct device_node *np, + const char *name, u8 num_parents, + const char * const *parent_names, + const struct clk_hw **parent_hws, + const struct clk_parent_data *parent_data, + unsigned long flags, void __iomem *reg, u8 shift, u32 mask, + u8 clk_mux_flags, u32 *table, spinlock_t *lock); struct clk *clk_register_mux_table(struct device *dev, const char *name, const char * const *parent_names, u8 num_parents, unsigned long flags, void __iomem *reg, u8 shift, u32 mask, @@ -902,6 +909,12 @@ struct clk *clk_register_mux_table(struct device *dev, const char *name, __clk_hw_register_mux((dev), NULL, (name), (num_parents), NULL, NULL, \ (parent_data), (flags), (reg), (shift), \ BIT((width)) - 1, (clk_mux_flags), NULL, (lock)) +#define devm_clk_hw_register_mux(dev, name, parent_names, num_parents, flags, reg, \ + shift, width, clk_mux_flags, lock) \ + __devm_clk_hw_register_mux((dev), NULL, (name), (num_parents), \ + (parent_names), NULL, NULL, (flags), (reg), \ + (shift), BIT((width)) - 1, (clk_mux_flags), \ + NULL, (lock)) int clk_mux_val_to_index(struct clk_hw *hw, u32 *table, unsigned int flags, unsigned int val);