From patchwork Wed Mar 31 10:57:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 412847 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp383143jai; Wed, 31 Mar 2021 03:57:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPEgoMY7WqCMdaEguxOWYDBxk3YpLp19bjdE/VC+PzmRB3gnYMWH3G7y9JmvUHctbyzjcQ X-Received: by 2002:a65:538f:: with SMTP id x15mr2755752pgq.429.1617188270816; Wed, 31 Mar 2021 03:57:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617188270; cv=none; d=google.com; s=arc-20160816; b=TkaLTHwg1RysEwOigN5pADZSpPkYabmFNRFc5erpYku7UUKKnK/AnqHMJDyKgTi1SN uVukeKGLMTAImybYIHwWqSy8ToTXRwmPOqUHPhzDYVY+/TVmTArQXBBDlfxGIqkfiBX+ p3lbnunoxJloMQYz5h7pytd9X3DwlJQdJvkKJFb8MJfSihpqH55q689WvDP92emFz6x6 2M/D/FNoxCwIaaaW5CdgA8AyGRRj+rn3gIxYSEIFlsxDh1KZ2ONa06Mq8e7II5j8zApC i2+RvsKj4hEP31Daev5oC3pa/8vFNiKCd5AEfXveiAbpkePoPkUv5PTNMYWOtcMcHdDt iuWA== 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=dEjDQfRBN4FbER/cHrHTkbD743iJ8vGGR89hiuONz2Q=; b=Ep+G3oEjMIlGf1QzH58waP+VhJyrLy/jEe1MpZqnwWIFJ5nLjwL8lg89XDt8cdEYLH NWT0ZjKOzeQjBHHcjZL2ovVTZf9OieN/OwSlvjgoiS6JkQjSsruz7DT/KYhvZUb+CNUT DgYUc1sj+ks0BHP49UujsvmUoYVhV4gkSqvhkATYVE6QR3E2im6C6Dc/yZk5lxpHLDwW Bgi3vaqPVMH5W10AHaUd46LCg6UH7HYh5pFA1Ytr3t1PK3lfT2EOj5bTH4CneBh5zV2Y kuIhdka1BKGbplh3kE7YahyxquVNfrugv1Mz/dtNSOmXYzFnY20Rbas8+T7d2EK4D2cM fYlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=K6LTjhre; 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 u66si1962050pgu.175.2021.03.31.03.57.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Mar 2021 03:57:50 -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=K6LTjhre; 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 715216EA52; Wed, 31 Mar 2021 10:57:43 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0381B6E1A3 for ; Wed, 31 Mar 2021 10:57:39 +0000 (UTC) Received: by mail-lf1-x12a.google.com with SMTP id o10so28471505lfb.9 for ; Wed, 31 Mar 2021 03:57:38 -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=Y1u3qI91niStgKbW+WBtzClbJFp3L1syvepMyAqokcs=; b=K6LTjhrenDqyIdIUPPp1YHKyaN4YhM1dbepoy7YLo0scME9jbZ+wQlMhx+dRGbtyIb rn7jp2woz9YglWY/x3BpkmoGS7UcXAXHCCTEIBTtDzpVZYQmKwL38+al3kzNTagV4yjh Uuz8+DzOt6VY9axa9x0wN4CkUD0vBmroUiqm5Jaok3t8eFJ6iySpXyKxHDMPPtJtje1L FtnZfNCWUlahfgd89f4IuXuvyjIzcSqH5lTD9fR5GxYJeeNv2r+9oNDm3q6ZaVjwF+si paXskREcH2t+lSSLP5MobghwphANhKhhZM1NorG9GkonDiAN604k0oVynfOCQP2dH6/F +fww== 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=Y1u3qI91niStgKbW+WBtzClbJFp3L1syvepMyAqokcs=; b=VEzytrVv7b0puX8u4ONU0ct0TNdZeWEvvpD4PmdQb+8FqsKynF2G/jc/oGGV5sfrye O9Qlv9BU+DjAHOlY6UdQBDz0eWPvCNTpl7mKdfk+rpGFAKjpe9REJLGGN9kO+rKRuvU/ B5hkB82pJLiIKnuiKr2d7bL89uEdTTbwK+JQfJoNBaY/PeKuBKc6Fo7Tt1JxOGYaiMXG lknW8w3JEpvyr7u28/0X5Gg9HM7FvbzSD4w8/Gh7eHnhq5FR+rAR17M21jj/Xbp1diio pZPGv44D+uF7E0tLk3ASjaWLLwhqZoMldnzDHfuijJmLYl0lhvOrGINLgOpiRhSZWF1B vBwA== X-Gm-Message-State: AOAM530L3sOn/2Cv+ZBUiK/Js5/MzpcV5ZBsaDK/go0hVM7PCIKz8Dn2 JLp+6EVLSkvRCu6hiFEUf9UJjbU+DpdHkw== X-Received: by 2002:a05:6512:a82:: with SMTP id m2mr1920945lfu.259.1617188257411; Wed, 31 Mar 2021 03:57:37 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id h3sm184359ljc.67.2021.03.31.03.57.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Mar 2021 03:57:37 -0700 (PDT) From: Dmitry Baryshkov To: Rob Clark , Sean Paul , Abhinav Kumar , Jonathan Marek , Michael Turquette Subject: [PATCH v4 01/24] clk: mux: provide devm_clk_hw_register_mux() Date: Wed, 31 Mar 2021 13:57:12 +0300 Message-Id: <20210331105735.3690009-2-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210331105735.3690009-1-dmitry.baryshkov@linaro.org> References: <20210331105735.3690009-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 Reviewed-by: Abhinav Kumar Acked-by: Stephen Boyd --- 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 e4316890661a..9cf7ecc62f7c 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);