From patchwork Wed Mar 24 15:18:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 407863 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp501758jai; Wed, 24 Mar 2021 08:19:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzISe6lSFItmlLO2Q4Vhb0jKPIcq2HRfCCYuB+z6d7D14K9MI5qabZMruazyH3es/BYcc+H X-Received: by 2002:a63:5c07:: with SMTP id q7mr3503185pgb.52.1616599155478; Wed, 24 Mar 2021 08:19:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616599155; cv=none; d=google.com; s=arc-20160816; b=CZrdEBi75GPvfxikUhFefkig08iI9XjkJw0TfsuyCPW1u1t98LnNhFGE9XcFua+HAi DjMGuzvbTf/iKBDKUtoI4dUpKxpbvPm2hJhTEhp90gGDZ5pezV6sqx+D6sbneUw7qI5d ip5QhwOIEH0SD9GSVnW7mLG7FCZGWTYUPBTofkW/7V98emheeMs0d1IwXq6zQFPN3scp X3ZZLJHLtIvKSa/5XqfEjHTsE+9jhycFFizFu3hyDtyC3yYde7I7h/tUs5wxIrh7U6H+ O6USNV1pKSctciMs8AXbux+n+OOq7Pqt4G3Kj+CmziKQwPNrYjDl+7CMeua9UzKWZrUD Cy0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=wQ8NYoh4OeanBM+lZvbjPzUJjjnKSL+j7zH1d1u08L8=; b=yIk+LC337oNU0XvcU0BA/BQo4kH76nAPJtDVfsIxTjDJEy/fQ09Z23yeGleWqPmk4q 1okFt97523CQYOLS83fm4kMPGxd5Uix/8QZ55xzcJ4bct6lRRZ/4F27/Uq8wWMxs/Rmh VAN33o1Pb7nQgBNvOPE62qWCvGZoRJ2XM73TzchCa+yO1llYbK7c5+78m/bGMScbEaEy AIlr8YPCu7e5ZI/E45uhJPTrAJRF+EPDx5mIc86IgZFiqEztdmsBY/9N0eU6jdZlL3mQ tr4MpUOGqgMOCUBVmwkP+9SlFuftXhQBgywOsTQqy2wm5alm1ZIqyek5JFhy0PMpXBCq 4G3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="Ui/ozJrN"; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id w1si2360165pfi.270.2021.03.24.08.19.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 08:19:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="Ui/ozJrN"; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B24BD6EA39; Wed, 24 Mar 2021 15:19:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8959C6EA22 for ; Wed, 24 Mar 2021 15:19:10 +0000 (UTC) Received: by mail-lj1-x236.google.com with SMTP id a1so30713668ljp.2 for ; Wed, 24 Mar 2021 08:19:10 -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=fvhlkx4xo48Lrm5ulhQx7P9OeXo+UeYdR2FET2xIgts=; b=Ui/ozJrNvZxuonOcm0SDQcoC6WekUl443AjS6M5dIpQ2wT208WYxNbPs2Z/sk0PKBJ 112XOBtFRfuuJAD1WyN/Xkx8z7O46vaHkTLzmjzQW87nCupvS7zG/ELLfBff0qr6/F0b h45RZKolG+DtyEuiJyOgpPVz6zr/dGZFii9M9RONDjYSXDWxLbG0cu3hEs1FO6b9gr4S q6TRwksYAiGLGneTJj/D4yDiU6Bz9J4T9KgtbdEhknx7qiSGDL5QoH5DiNKCpkGL31gY PwtPpAb5BUbqEJanKcvKopJpiv7CN8e3yNF/AZ5+OOpoRMit68EDbdd2JYhziDx4opLx ce4A== 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=fvhlkx4xo48Lrm5ulhQx7P9OeXo+UeYdR2FET2xIgts=; b=UnxDg0+e4mb7bW0dwfXpQLWiGRKAnlFNSBfP0NHlg3nCy3hggJVhqJbt/gk+btyvv/ ZOJZWDpedV8dsanyPraAQDlka459Kf3j008zIEfk4k09fkde2CP2tW9G7AMZY1enEwc4 8tOpJfJJWPyeZxGErW5whehBHSK8SPQQfUXDuA18ZYoDdQuAwKEIvU8WyDVFx9lNNHzw kJQdATB9pmi5BpIzYfpLa6A2bQiytCfmCC2vGcIv3wXOg/3m6GpZg5mHRy1PR09jT9jt aCq3vRs5z5ILIK76slFn9F4XlkJwWfcVgy43kjgk7tV3kOPlvMPfnrGwBZ5Tq6aoGXHp 9LKw== X-Gm-Message-State: AOAM533FAN6nVJiX4DUkUCUGs0a/DWgrpFiRdxK7N0jBsEjubafTywhC 7wNnj/BK90ROTSidYmrNk4wmeg== X-Received: by 2002:a2e:581a:: with SMTP id m26mr2512908ljb.33.1616599149032; Wed, 24 Mar 2021 08:19:09 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id d22sm255199lfm.267.2021.03.24.08.19.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 08:19:08 -0700 (PDT) From: Dmitry Baryshkov To: Rob Clark , Sean Paul , Jonathan Marek , Michael Turquette Subject: [PATCH v2 02/28] clk: mux: provide devm_clk_hw_register_mux() Date: Wed, 24 Mar 2021 18:18:20 +0300 Message-Id: <20210324151846.2774204-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210324151846.2774204-1-dmitry.baryshkov@linaro.org> References: <20210324151846.2774204-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stephen Boyd , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, David Airlie , freedreno@lists.freedesktop.org, linux-clk@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add devm_clk_hw_register_mux() - devres-managed version of clk_hw_register_mux(). Signed-off-by: Dmitry Baryshkov --- drivers/clk/clk-mux.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/clk-provider.h | 13 +++++++++++++ 2 files changed, 48 insertions(+) -- 2.30.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel 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);