From patchwork Tue Apr 19 08:12:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12817610 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D758DC433EF for ; Tue, 19 Apr 2022 08:13:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349733AbiDSIPp (ORCPT ); Tue, 19 Apr 2022 04:15:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241349AbiDSIPo (ORCPT ); Tue, 19 Apr 2022 04:15:44 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EBD52A70A for ; Tue, 19 Apr 2022 01:13:02 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d15so14669305pll.10 for ; Tue, 19 Apr 2022 01:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dbHuIMp6NqIKnY64hxaFgyNKsnlZfy6+G0wX97Ig5HA=; b=J2PrilvtBtshJTW6tcuSuriyrmWtLh1/U8UmkNn/ZRQrKqSR7IRRW7Qqld7f55Q3cf rrxhVkgpCFX/NIRsKoR5V/FWv6L94yV5dO9rMil1niuqDOA1a6a+EVEsXV5pYyj1XBE8 gzq+sQBOxYp86Ov71TzxfQDGnM28PMCBiuEHM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dbHuIMp6NqIKnY64hxaFgyNKsnlZfy6+G0wX97Ig5HA=; b=vhPTyg1NaZtf1lfgqq/gH9l0ZOLzYhDdMQM6ONlKqwvFSkTUGKlK7fXaus4ftostZU NkdCh3NzQqCKBIJESnuYzth/9tOgUloYnjYYfVDwsM/vToP18xOes0K4eMd9S3TMbBie gyxLn5k/vgEmCCFAJmyd7lSQMnrdBB2kNFDC7We3Egl/DW6AnkYPVekvMgWCOziBInzi VTRnTTwiiVbA3QndWOSgI9kP100JfgyKq0ogI8ZX1ESuY3fvvfaDaByrJ0/bOoMGfjee 0u7Wd3p2H8sM9kkyW08ovPt5A8RGD06IP17glvyTSOCFp0ONbzcfinVXNI2UGzi1XYUE h0SA== X-Gm-Message-State: AOAM530SA4M9HsTpJYs1V8sOpijw8uxXDcdgpeQmfV4Lm8XVwTbk7cRB 4dAXYSNUv2x+sGmpvX3IFbFuCA== X-Google-Smtp-Source: ABdhPJzdudJnBxIdIosCr5L+LmZy3jMnoSHD6sH5rSKWIoDdz3HtV2F81M6Us0l2M7ee5fHUZcO46w== X-Received: by 2002:a17:90a:ce0b:b0:1cd:6fff:8dbc with SMTP id f11-20020a17090ace0b00b001cd6fff8dbcmr17075458pju.212.1650355982018; Tue, 19 Apr 2022 01:13:02 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:33f6:f1e6:3e21:a253]) by smtp.gmail.com with ESMTPSA id n13-20020a654ccd000000b0039db6f73e9dsm15767448pgt.28.2022.04.19.01.13.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 01:13:01 -0700 (PDT) From: Chen-Yu Tsai To: Michael Turquette , Stephen Boyd , Chun-Jie Chen , Miles Chen , Rex-BC Chen Cc: Chen-Yu Tsai , Matthias Brugger , linux-clk@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/7] clk: mediatek: Make mtk_clk_register_composite() static Date: Tue, 19 Apr 2022 16:12:40 +0800 Message-Id: <20220419081246.2546159-2-wenst@chromium.org> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220419081246.2546159-1-wenst@chromium.org> References: <20220419081246.2546159-1-wenst@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org mtk_clk_register_composite() is not used anywhere outside of the file it is defined. Make it static. Fixes: 9741b1a68035 ("clk: mediatek: Add initial common clock support for Mediatek SoCs.") Signed-off-by: Chen-Yu Tsai Reviewed-by: AngeloGioacchino Del Regno --- drivers/clk/mediatek/clk-mtk.c | 2 +- drivers/clk/mediatek/clk-mtk.h | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index b4063261cf56..52bacce5dadd 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -183,7 +183,7 @@ void mtk_clk_unregister_factors(const struct mtk_fixed_factor *clks, int num, } EXPORT_SYMBOL_GPL(mtk_clk_unregister_factors); -struct clk *mtk_clk_register_composite(const struct mtk_composite *mc, +static struct clk *mtk_clk_register_composite(const struct mtk_composite *mc, void __iomem *base, spinlock_t *lock) { struct clk *clk; diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index bf6565aa7319..9577084790dc 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -147,9 +147,6 @@ struct mtk_composite { .flags = 0, \ } -struct clk *mtk_clk_register_composite(const struct mtk_composite *mc, - void __iomem *base, spinlock_t *lock); - int mtk_clk_register_composites(const struct mtk_composite *mcs, int num, void __iomem *base, spinlock_t *lock, struct clk_onecell_data *clk_data); From patchwork Tue Apr 19 08:12:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12817611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47A6EC433F5 for ; Tue, 19 Apr 2022 08:13:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239279AbiDSIPr (ORCPT ); Tue, 19 Apr 2022 04:15:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349742AbiDSIPq (ORCPT ); Tue, 19 Apr 2022 04:15:46 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A483B2981F for ; Tue, 19 Apr 2022 01:13:04 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id z16so7888741pfh.3 for ; Tue, 19 Apr 2022 01:13:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9UGfUGNG7X7pDsugCO6c2wWlLkIg3A+ba1SS8g2x2V8=; b=kE8h371r7KC1WaB3ptxODLKDwE0ME5VqByHNlLGRopQPgn2hRU94zG31+kIXMHFiWH sK2EgH2cU6NQzQ9myTtIxaTanQSuTrC4/Yt4PkcmH7iYRm8WPWkbhB9rxnHwSlUzi/Mh cTo1xx5oc5nXSEpwafQUqpsyUwugP+wJC5S2Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9UGfUGNG7X7pDsugCO6c2wWlLkIg3A+ba1SS8g2x2V8=; b=VxnUvZbu8HjXJY4p7WyOAmRCy27uG0zvtogXvSgUdTF8RJ5fQO3haf6TIT77ymy7eB 9yunSmMdpZT/KnP6R129gHqxbhboOKEDALPcU1I9SmCVkzEQpS/Hhkd5J4VIsd3yBBI2 r2stSg882CZlGFH1wAr+haL08Jugbnfovoli1baKrdUCzlSubOGoN/PyO9NCgTZXg3EF FBao4fzGZa3HzcGZUElpLdZm/I5YBZsQL+p4s2Emnr4twpfcBLiY9wlSFdOH0rHnn6vD C1004+ZFre+HVaqy+yG7X+ItJ4d6v09ugdyhxW49VEghUUIl8dc3FODg9rMASas2jFBa doIg== X-Gm-Message-State: AOAM531kDCxsww6wHUFc0KPB/QMkK7ZHtJSEKkv4DUcqQyMxvFgxpiSr rBP5rt0FfW+R0w7otXyrLxy/lB2Pf70XIA== X-Google-Smtp-Source: ABdhPJwFAqU0I4hg06PcLzrE0VtXM7yjQUzD3S0oIMtis8FukDJaRIF7kf/NYED/Wq9Kyzv6atT9sw== X-Received: by 2002:a05:6a00:cd2:b0:50a:7685:8055 with SMTP id b18-20020a056a000cd200b0050a76858055mr9021699pfv.37.1650355984158; Tue, 19 Apr 2022 01:13:04 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:33f6:f1e6:3e21:a253]) by smtp.gmail.com with ESMTPSA id n13-20020a654ccd000000b0039db6f73e9dsm15767448pgt.28.2022.04.19.01.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 01:13:03 -0700 (PDT) From: Chen-Yu Tsai To: Michael Turquette , Stephen Boyd , Chun-Jie Chen , Miles Chen , Rex-BC Chen Cc: Chen-Yu Tsai , Matthias Brugger , linux-clk@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/7] clk: mediatek: apmixed: Drop error message from clk_register() failure Date: Tue, 19 Apr 2022 16:12:41 +0800 Message-Id: <20220419081246.2546159-3-wenst@chromium.org> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220419081246.2546159-1-wenst@chromium.org> References: <20220419081246.2546159-1-wenst@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org mtk_clk_register_ref2usb_tx() prints an error message if clk_register() fails. It doesn't if kzalloc() fails though. The caller would then tack on its own error message to handle this. Also, All other clk registration functions in the MediaTek clk library leave the error message printing to the bulk registration functions, while the helpers that register individual clks just return error codes. Drop the error message that is printed when clk_register() fails in mtk_clk_register_ref2usb_tx() to make its behavior consistent both across its failure modes, and with the rest of the driver library. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-apmixed.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/clk/mediatek/clk-apmixed.c b/drivers/clk/mediatek/clk-apmixed.c index a29339cc26c4..06400c043fe7 100644 --- a/drivers/clk/mediatek/clk-apmixed.c +++ b/drivers/clk/mediatek/clk-apmixed.c @@ -91,10 +91,8 @@ struct clk * __init mtk_clk_register_ref2usb_tx(const char *name, clk = clk_register(NULL, &tx->hw); - if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %pe\n", name, clk); + if (IS_ERR(clk)) kfree(tx); - } return clk; } From patchwork Tue Apr 19 08:12:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12817612 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B91DBC433EF for ; Tue, 19 Apr 2022 08:13:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349756AbiDSIPv (ORCPT ); Tue, 19 Apr 2022 04:15:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349751AbiDSIPs (ORCPT ); Tue, 19 Apr 2022 04:15:48 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B95152A70A for ; Tue, 19 Apr 2022 01:13:06 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id l127so6152106pfl.6 for ; Tue, 19 Apr 2022 01:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aL1HiuRk5yYFz4xYpqYuYGNrqygVF3ZLXtA2aUqysL4=; b=LEXJrHEJYkHQYt3+NUC0A2RYl/pLHmHf8+SR4yudcy7lD64IgbmhmJrEGIl/XlRzy4 rFiaOBuVKdRUMLaZQ8MqVHwLjmsChzcrM5Fxza/aAWSZTJBU0uwdjPJiieKpuVt3zPQA jnvnNF57z7vm+bjvNPtYai0snAFLFOleiWlmU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aL1HiuRk5yYFz4xYpqYuYGNrqygVF3ZLXtA2aUqysL4=; b=sxxW1y74qm+/fFDmVSp+pgxSxdL0yE0LZyBb6/7V0cbEG7rPaGkgW7mkCyNuwOArC0 DSddMS4MrHs96l4rJ+javCjGJa8sraf0hNG6ifXIpJ6MpmjH3Nc6NHD9yEP6d5frGDeq +1ncDylK9HPIj6srK7A6DKhu7YfijzuPrDP4qP7cJMay6Yj6D6Ij6vPr6nI+HXZgPEu3 aF1bZcYQMcUFzC2LfgQXd1XZami8j9WnAQasBO8vQ909n5U5XC4NO3trTo22zeT5W61Q RCH58c0ycrkWOkz8+T+uIAUM41T0lwzXqnczYBc+g3J/DLG0n7F4MPE4QnRN1GUURb9f b/Yw== X-Gm-Message-State: AOAM531lCSpT/yBOGGaipzbiaBDRYYxhekQkfi1IEJiaDeHcHfsT8VK1 Zv1XpH5qDYF32TdHvRvotg2AmQ== X-Google-Smtp-Source: ABdhPJyIGDt6kZVVNhC1txAP0UdKWo807bFxbSvGZaHWUDQrzAwZFAQAwc4BPI5rullX3UT27dxnFA== X-Received: by 2002:a63:3841:0:b0:399:26da:29af with SMTP id h1-20020a633841000000b0039926da29afmr13364353pgn.489.1650355986330; Tue, 19 Apr 2022 01:13:06 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:33f6:f1e6:3e21:a253]) by smtp.gmail.com with ESMTPSA id n13-20020a654ccd000000b0039db6f73e9dsm15767448pgt.28.2022.04.19.01.13.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 01:13:06 -0700 (PDT) From: Chen-Yu Tsai To: Michael Turquette , Stephen Boyd , Chun-Jie Chen , Miles Chen , Rex-BC Chen Cc: Chen-Yu Tsai , Matthias Brugger , linux-clk@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 3/7] clk: mediatek: Convert mtk_{alloc,free}_clk_data to struct clk_hw Date: Tue, 19 Apr 2022 16:12:42 +0800 Message-Id: <20220419081246.2546159-4-wenst@chromium.org> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220419081246.2546159-1-wenst@chromium.org> References: <20220419081246.2546159-1-wenst@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org As part of the effort to improve the MediaTek clk drivers, the next step is to switch from the old 'struct clk' clk prodivder APIs to the new 'struct clk_hw' ones. Instead of adding new APIs to the MediaTek clk driver library mirroring the existing ones, moving all drivers to the new APIs, and then removing the old ones, just migrate everything at the same time. This involves replacing 'struct clk' with 'struct clk_hw', and 'struct clk_onecell_data' with 'struct clk_hw_onecell_data', and fixing up all usages. For now, the clk_register() and co. usage is retained, with __clk_get_hw() and (struct clk_hw *)->clk used to bridge the difference between the APIs. These will be replaced in subsequent patches. Fix up mtk_{alloc,free}_clk_data to use 'struct clk_hw' by hand. Fix up all other affected call sites with coccinelle scripts in the next patch. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mtk.c | 23 ++++++----------------- drivers/clk/mediatek/clk-mtk.h | 4 ++-- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 52bacce5dadd..554c6a128460 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -18,40 +18,29 @@ #include "clk-mtk.h" #include "clk-gate.h" -struct clk_onecell_data *mtk_alloc_clk_data(unsigned int clk_num) +struct clk_hw_onecell_data *mtk_alloc_clk_data(unsigned int clk_num) { int i; struct clk_onecell_data *clk_data; - clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL); + clk_data = kzalloc(struct_size(clk_data, hws, clk_num), GFP_KERNEL); if (!clk_data) return NULL; - clk_data->clks = kcalloc(clk_num, sizeof(*clk_data->clks), GFP_KERNEL); - if (!clk_data->clks) - goto err_out; - - clk_data->clk_num = clk_num; + clk_data->num = clk_num; for (i = 0; i < clk_num; i++) - clk_data->clks[i] = ERR_PTR(-ENOENT); + clk_data->hws[i] = ERR_PTR(-ENOENT); return clk_data; -err_out: - kfree(clk_data); - - return NULL; } EXPORT_SYMBOL_GPL(mtk_alloc_clk_data); -void mtk_free_clk_data(struct clk_onecell_data *clk_data) +void mtk_free_clk_data(struct clk_hw_onecell_data *clk_data) { - if (!clk_data) - return; - - kfree(clk_data->clks); kfree(clk_data); } +EXPORT_SYMBOL_GPL(mtk_free_clk_data); int mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num, struct clk_onecell_data *clk_data) diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index 9577084790dc..787fdeb1bd93 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -181,8 +181,8 @@ int mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num, void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, int num, struct clk_onecell_data *clk_data); -struct clk_onecell_data *mtk_alloc_clk_data(unsigned int clk_num); -void mtk_free_clk_data(struct clk_onecell_data *clk_data); +struct clk_hw_onecell_data *mtk_alloc_clk_data(unsigned int clk_num); +void mtk_free_clk_data(struct clk_hw_onecell_data *clk_data); struct clk *mtk_clk_register_ref2usb_tx(const char *name, const char *parent_name, void __iomem *reg); From patchwork Tue Apr 19 08:12:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12817613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4708FC433FE for ; Tue, 19 Apr 2022 08:13:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349741AbiDSIP7 (ORCPT ); Tue, 19 Apr 2022 04:15:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349769AbiDSIP5 (ORCPT ); Tue, 19 Apr 2022 04:15:57 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E84A32AC4F for ; Tue, 19 Apr 2022 01:13:11 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id c12so14685314plr.6 for ; Tue, 19 Apr 2022 01:13:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q5lOWLCy6mzo17nVc6OxwA2xfzBIDoO2WLHgDxNDHwU=; b=UIkT4REDZfPRsdJ11SR/ZdC2Do76WZNa+Va1eF95LfAaXajtYYA2tp/mzWSNUKuhYq RP4RnXGTaUUjv2hbrmEd9kto5zq6qWtX+NDMyjfEyL6Ao5wSQyVIJPPQnGYmaJCAdRiG +4oRwF6Wojcj7gAkFrtOe+PEZUcQgKdrddODU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q5lOWLCy6mzo17nVc6OxwA2xfzBIDoO2WLHgDxNDHwU=; b=BEISPydiG7ks5vUb00uDwAJRLpXM8P/eEWDQxkXbkcqlRi0O8nCVtixUYmXYsl5FcY iTUt36j4McjAmq6nupF066iPDBbl//ZL13uxOF65i1bb+ksItoI+rcc8ahjS7N42p3QD vU7ZIA9wuRlqcsxbbnA0ZlMoP8RRnNxUQs0a5VOIQxFhHNwkH4SVdpETzeVphMu3JzTn FC9jqi0cusdHb97aga4bGFFYKKHiTuzmU9oACfUmRPVCzicxKnAiz/lmPRm8suyt24q5 gfYMr5CZCDwJSrv6PPT2VnL70XkXOhKtKvzwXLkszhBCt4iSdTRk8Xlp0uE57fhL38x/ HLuw== X-Gm-Message-State: AOAM530wBe39utGqrmvL8m1aujfLD+tw3HA1JuK9w7noXyGomvNQGKOM eujbTP4P+euYDzDnbSQUdvKLzw== X-Google-Smtp-Source: ABdhPJxnEikCPYUPQ5n/sDV0npRozPxSDZMhD9eq3faczPA3+3E28AMme+Mesz7dtmLr6Hw23Cykcg== X-Received: by 2002:a17:902:edc5:b0:156:68e4:416 with SMTP id q5-20020a170902edc500b0015668e40416mr14357520plk.87.1650355991320; Tue, 19 Apr 2022 01:13:11 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:33f6:f1e6:3e21:a253]) by smtp.gmail.com with ESMTPSA id n13-20020a654ccd000000b0039db6f73e9dsm15767448pgt.28.2022.04.19.01.13.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 01:13:11 -0700 (PDT) From: Chen-Yu Tsai To: Michael Turquette , Stephen Boyd , Chun-Jie Chen , Miles Chen , Rex-BC Chen Cc: Chen-Yu Tsai , Matthias Brugger , linux-clk@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 5/7] clk: mediatek: Switch to clk_hw provider APIs Date: Tue, 19 Apr 2022 16:12:44 +0800 Message-Id: <20220419081246.2546159-6-wenst@chromium.org> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220419081246.2546159-1-wenst@chromium.org> References: <20220419081246.2546159-1-wenst@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org As part of the effort to improve the MediaTek clk drivers, the next step is to switch from the old 'struct clk' clk prodivder APIs to the new 'struct clk_hw' ones. In a previous patch, 'struct clk_onecell_data' was replaced with 'struct clk_hw_onecell_data', with (struct clk_hw *)->clk and __clk_get_hw() bridging the new data structures and old code. Now switch from the old 'clk_(un)?register*()' APIs to the new 'clk_hw_(un)?register*()' ones. This is done with the coccinelle script below. Unfortunately this also leaves clk-mt8173.c with a compile error that would need a coccinelle script longer than the actual diff to fix. This will be fixed up by hand in the next patch. // Fix prototypes @@ identifier F =~ "^mtk_clk_register_"; @@ - struct clk * + struct clk_hw * F(...); // Fix calls to mtk_clk_register_ @ reg @ identifier F =~ "^mtk_clk_register_"; identifier FS =~ "^mtk_clk_register_[a-z_]*s"; identifier I; expression clk_data; expression E; @@ FS(...) { ... - struct clk *I; + struct clk_hw *hw; ... for (...;...;...) { ... ( - I + hw = - clk_register_fixed_rate( + clk_hw_register_fixed_rate( ... ); | - I + hw = - clk_register_fixed_factor( + clk_hw_register_fixed_factor( ... ); | - I + hw = - clk_register_divider( + clk_hw_register_divider( ... ); | - I + hw = F(...); ) ... if ( - IS_ERR(I) + IS_ERR(hw) ) { pr_err(..., - I + hw ,...); ... } - clk_data->hws[E] = __clk_get_hw(I); + clk_data->hws[E] = hw; } ... } @ depends on reg @ identifier reg.I; @@ return PTR_ERR( - I + hw ); // Fix mtk_clk_register_composite to return clk_hw instead of clk @@ identifier I, R; expression E; @@ - struct clk * + struct clk_hw * mtk_clk_register_composite(...) { ... - struct clk *I; + struct clk_hw *hw; ... - I = clk_register_composite( + hw = clk_hw_register_composite( ...); if (IS_ERR( - I + hw )) { ... R = PTR_ERR( - I + hw ); ... } return - I + hw ; ... } // Fix other mtk_clk_register_ to return clk_hw instead of clk @@ identifier F =~ "^mtk_clk_register_"; identifier I, D, C; expression E; @@ - struct clk * + struct clk_hw * F(...) { ... - struct clk *I; + int ret; ... - I = clk_register(D, E); + ret = clk_hw_register(D, E); ... ( - if (IS_ERR(I)) + if (ret) { kfree(C); + return ERR_PTR(ret); + } | - if (IS_ERR(I)) + if (ret) { kfree(C); - return I; + return ERR_PTR(ret); } ) - return I; + return E; } // Fix mtk_clk_unregister_ to take clk_hw instead of clk @@ identifier F =~ "^mtk_clk_unregister_"; identifier I, I2; @@ static void F( - struct clk *I + struct clk_hw *I2 ) { ... - struct clk_hw *I2; ... - I2 = __clk_get_hw(I); ... ( - clk_unregister(I); + clk_hw_unregister(I2); | - clk_unregister_composite(I); + clk_hw_unregister_composite(I2); ) ... } // Fix calls to mtk_clk_unregister_*() @@ identifier F =~ "^mtk_clk_unregister_"; expression I; expression E; @@ - F(I->hws[E]->clk); + F(I->hws[E]); Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-apmixed.c | 12 +++-- drivers/clk/mediatek/clk-cpumux.c | 36 +++++++------- drivers/clk/mediatek/clk-gate.c | 36 +++++++------- drivers/clk/mediatek/clk-mtk.c | 76 +++++++++++++++--------------- drivers/clk/mediatek/clk-mtk.h | 2 +- drivers/clk/mediatek/clk-mux.c | 36 +++++++------- drivers/clk/mediatek/clk-pll.c | 35 +++++++------- 7 files changed, 118 insertions(+), 115 deletions(-) diff --git a/drivers/clk/mediatek/clk-apmixed.c b/drivers/clk/mediatek/clk-apmixed.c index 06400c043fe7..fc3d4146f482 100644 --- a/drivers/clk/mediatek/clk-apmixed.c +++ b/drivers/clk/mediatek/clk-apmixed.c @@ -70,12 +70,12 @@ static const struct clk_ops mtk_ref2usb_tx_ops = { .unprepare = mtk_ref2usb_tx_unprepare, }; -struct clk * __init mtk_clk_register_ref2usb_tx(const char *name, +struct clk_hw * __init mtk_clk_register_ref2usb_tx(const char *name, const char *parent_name, void __iomem *reg) { struct mtk_ref2usb_tx *tx; struct clk_init_data init = {}; - struct clk *clk; + int ret; tx = kzalloc(sizeof(*tx), GFP_KERNEL); if (!tx) @@ -89,12 +89,14 @@ struct clk * __init mtk_clk_register_ref2usb_tx(const char *name, init.parent_names = &parent_name; init.num_parents = 1; - clk = clk_register(NULL, &tx->hw); + ret = clk_hw_register(NULL, &tx->hw); - if (IS_ERR(clk)) + if (ret) { kfree(tx); + return ERR_PTR(ret); + } - return clk; + return &tx->hw; } MODULE_LICENSE("GPL"); diff --git a/drivers/clk/mediatek/clk-cpumux.c b/drivers/clk/mediatek/clk-cpumux.c index 8e80df43e356..2b5d48591738 100644 --- a/drivers/clk/mediatek/clk-cpumux.c +++ b/drivers/clk/mediatek/clk-cpumux.c @@ -57,12 +57,12 @@ static const struct clk_ops clk_cpumux_ops = { .set_parent = clk_cpumux_set_parent, }; -static struct clk * +static struct clk_hw * mtk_clk_register_cpumux(const struct mtk_composite *mux, struct regmap *regmap) { struct mtk_clk_cpumux *cpumux; - struct clk *clk; + int ret; struct clk_init_data init; cpumux = kzalloc(sizeof(*cpumux), GFP_KERNEL); @@ -81,25 +81,24 @@ mtk_clk_register_cpumux(const struct mtk_composite *mux, cpumux->regmap = regmap; cpumux->hw.init = &init; - clk = clk_register(NULL, &cpumux->hw); - if (IS_ERR(clk)) + ret = clk_hw_register(NULL, &cpumux->hw); + if (ret) { kfree(cpumux); + return ERR_PTR(ret); + } - return clk; + return &cpumux->hw; } -static void mtk_clk_unregister_cpumux(struct clk *clk) +static void mtk_clk_unregister_cpumux(struct clk_hw *hw) { struct mtk_clk_cpumux *cpumux; - struct clk_hw *hw; - - hw = __clk_get_hw(clk); if (!hw) return; cpumux = to_mtk_clk_cpumux(hw); - clk_unregister(clk); + clk_hw_unregister(hw); kfree(cpumux); } @@ -108,7 +107,7 @@ int mtk_clk_register_cpumuxes(struct device_node *node, struct clk_hw_onecell_data *clk_data) { int i; - struct clk *clk; + struct clk_hw *hw; struct regmap *regmap; regmap = device_node_to_regmap(node); @@ -126,13 +125,14 @@ int mtk_clk_register_cpumuxes(struct device_node *node, continue; } - clk = mtk_clk_register_cpumux(mux, regmap); - if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %pe\n", mux->name, clk); + hw = mtk_clk_register_cpumux(mux, regmap); + if (IS_ERR(hw)) { + pr_err("Failed to register clk %s: %pe\n", mux->name, + hw); goto err; } - clk_data->hws[mux->id] = __clk_get_hw(clk); + clk_data->hws[mux->id] = hw; } return 0; @@ -144,11 +144,11 @@ int mtk_clk_register_cpumuxes(struct device_node *node, if (IS_ERR_OR_NULL(clk_data->hws[mux->id])) continue; - mtk_clk_unregister_cpumux(clk_data->hws[mux->id]->clk); + mtk_clk_unregister_cpumux(clk_data->hws[mux->id]); clk_data->hws[mux->id] = ERR_PTR(-ENOENT); } - return PTR_ERR(clk); + return PTR_ERR(hw); } void mtk_clk_unregister_cpumuxes(const struct mtk_composite *clks, int num, @@ -162,7 +162,7 @@ void mtk_clk_unregister_cpumuxes(const struct mtk_composite *clks, int num, if (IS_ERR_OR_NULL(clk_data->hws[mux->id])) continue; - mtk_clk_unregister_cpumux(clk_data->hws[mux->id]->clk); + mtk_clk_unregister_cpumux(clk_data->hws[mux->id]); clk_data->hws[mux->id] = ERR_PTR(-ENOENT); } } diff --git a/drivers/clk/mediatek/clk-gate.c b/drivers/clk/mediatek/clk-gate.c index 0955cace5b1b..421806236228 100644 --- a/drivers/clk/mediatek/clk-gate.c +++ b/drivers/clk/mediatek/clk-gate.c @@ -152,7 +152,7 @@ const struct clk_ops mtk_clk_gate_ops_no_setclr_inv = { }; EXPORT_SYMBOL_GPL(mtk_clk_gate_ops_no_setclr_inv); -static struct clk *mtk_clk_register_gate(const char *name, +static struct clk_hw *mtk_clk_register_gate(const char *name, const char *parent_name, struct regmap *regmap, int set_ofs, int clr_ofs, int sta_ofs, u8 bit, @@ -160,7 +160,7 @@ static struct clk *mtk_clk_register_gate(const char *name, unsigned long flags, struct device *dev) { struct mtk_clk_gate *cg; - struct clk *clk; + int ret; struct clk_init_data init = {}; cg = kzalloc(sizeof(*cg), GFP_KERNEL); @@ -181,25 +181,24 @@ static struct clk *mtk_clk_register_gate(const char *name, cg->hw.init = &init; - clk = clk_register(dev, &cg->hw); - if (IS_ERR(clk)) + ret = clk_hw_register(dev, &cg->hw); + if (ret) { kfree(cg); + return ERR_PTR(ret); + } - return clk; + return &cg->hw; } -static void mtk_clk_unregister_gate(struct clk *clk) +static void mtk_clk_unregister_gate(struct clk_hw *hw) { struct mtk_clk_gate *cg; - struct clk_hw *hw; - - hw = __clk_get_hw(clk); if (!hw) return; cg = to_mtk_clk_gate(hw); - clk_unregister(clk); + clk_hw_unregister(hw); kfree(cg); } @@ -209,7 +208,7 @@ int mtk_clk_register_gates_with_dev(struct device_node *node, struct device *dev) { int i; - struct clk *clk; + struct clk_hw *hw; struct regmap *regmap; if (!clk_data) @@ -230,7 +229,7 @@ int mtk_clk_register_gates_with_dev(struct device_node *node, continue; } - clk = mtk_clk_register_gate(gate->name, gate->parent_name, + hw = mtk_clk_register_gate(gate->name, gate->parent_name, regmap, gate->regs->set_ofs, gate->regs->clr_ofs, @@ -238,12 +237,13 @@ int mtk_clk_register_gates_with_dev(struct device_node *node, gate->shift, gate->ops, gate->flags, dev); - if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %pe\n", gate->name, clk); + if (IS_ERR(hw)) { + pr_err("Failed to register clk %s: %pe\n", gate->name, + hw); goto err; } - clk_data->hws[gate->id] = __clk_get_hw(clk); + clk_data->hws[gate->id] = hw; } return 0; @@ -255,11 +255,11 @@ int mtk_clk_register_gates_with_dev(struct device_node *node, if (IS_ERR_OR_NULL(clk_data->hws[gate->id])) continue; - mtk_clk_unregister_gate(clk_data->hws[gate->id]->clk); + mtk_clk_unregister_gate(clk_data->hws[gate->id]); clk_data->hws[gate->id] = ERR_PTR(-ENOENT); } - return PTR_ERR(clk); + return PTR_ERR(hw); } int mtk_clk_register_gates(struct device_node *node, @@ -284,7 +284,7 @@ void mtk_clk_unregister_gates(const struct mtk_gate *clks, int num, if (IS_ERR_OR_NULL(clk_data->hws[gate->id])) continue; - mtk_clk_unregister_gate(clk_data->hws[gate->id]->clk); + mtk_clk_unregister_gate(clk_data->hws[gate->id]); clk_data->hws[gate->id] = ERR_PTR(-ENOENT); } } diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index cfcf740e4e68..b9188000ab3c 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -46,7 +46,7 @@ int mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num, struct clk_hw_onecell_data *clk_data) { int i; - struct clk *clk; + struct clk_hw *hw; if (!clk_data) return -ENOMEM; @@ -59,15 +59,16 @@ int mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num, continue; } - clk = clk_register_fixed_rate(NULL, rc->name, rc->parent, 0, + hw = clk_hw_register_fixed_rate(NULL, rc->name, rc->parent, 0, rc->rate); - if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %pe\n", rc->name, clk); + if (IS_ERR(hw)) { + pr_err("Failed to register clk %s: %pe\n", rc->name, + hw); goto err; } - clk_data->hws[rc->id] = __clk_get_hw(clk); + clk_data->hws[rc->id] = hw; } return 0; @@ -83,7 +84,7 @@ int mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num, clk_data->hws[rc->id] = ERR_PTR(-ENOENT); } - return PTR_ERR(clk); + return PTR_ERR(hw); } EXPORT_SYMBOL_GPL(mtk_clk_register_fixed_clks); @@ -111,7 +112,7 @@ int mtk_clk_register_factors(const struct mtk_fixed_factor *clks, int num, struct clk_hw_onecell_data *clk_data) { int i; - struct clk *clk; + struct clk_hw *hw; if (!clk_data) return -ENOMEM; @@ -124,15 +125,16 @@ int mtk_clk_register_factors(const struct mtk_fixed_factor *clks, int num, continue; } - clk = clk_register_fixed_factor(NULL, ff->name, ff->parent_name, + hw = clk_hw_register_fixed_factor(NULL, ff->name, ff->parent_name, CLK_SET_RATE_PARENT, ff->mult, ff->div); - if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %pe\n", ff->name, clk); + if (IS_ERR(hw)) { + pr_err("Failed to register clk %s: %pe\n", ff->name, + hw); goto err; } - clk_data->hws[ff->id] = __clk_get_hw(clk); + clk_data->hws[ff->id] = hw; } return 0; @@ -148,7 +150,7 @@ int mtk_clk_register_factors(const struct mtk_fixed_factor *clks, int num, clk_data->hws[ff->id] = ERR_PTR(-ENOENT); } - return PTR_ERR(clk); + return PTR_ERR(hw); } EXPORT_SYMBOL_GPL(mtk_clk_register_factors); @@ -172,10 +174,10 @@ void mtk_clk_unregister_factors(const struct mtk_fixed_factor *clks, int num, } EXPORT_SYMBOL_GPL(mtk_clk_unregister_factors); -static struct clk *mtk_clk_register_composite(const struct mtk_composite *mc, +static struct clk_hw *mtk_clk_register_composite(const struct mtk_composite *mc, void __iomem *base, spinlock_t *lock) { - struct clk *clk; + struct clk_hw *hw; struct clk_mux *mux = NULL; struct clk_gate *gate = NULL; struct clk_divider *div = NULL; @@ -239,18 +241,18 @@ static struct clk *mtk_clk_register_composite(const struct mtk_composite *mc, div_ops = &clk_divider_ops; } - clk = clk_register_composite(NULL, mc->name, parent_names, num_parents, + hw = clk_hw_register_composite(NULL, mc->name, parent_names, num_parents, mux_hw, mux_ops, div_hw, div_ops, gate_hw, gate_ops, mc->flags); - if (IS_ERR(clk)) { - ret = PTR_ERR(clk); + if (IS_ERR(hw)) { + ret = PTR_ERR(hw); goto err_out; } - return clk; + return hw; err_out: kfree(div); kfree(gate); @@ -259,15 +261,13 @@ static struct clk *mtk_clk_register_composite(const struct mtk_composite *mc, return ERR_PTR(ret); } -static void mtk_clk_unregister_composite(struct clk *clk) +static void mtk_clk_unregister_composite(struct clk_hw *hw) { - struct clk_hw *hw; struct clk_composite *composite; struct clk_mux *mux = NULL; struct clk_gate *gate = NULL; struct clk_divider *div = NULL; - hw = __clk_get_hw(clk); if (!hw) return; @@ -279,7 +279,7 @@ static void mtk_clk_unregister_composite(struct clk *clk) if (composite->rate_hw) div = to_clk_divider(composite->rate_hw); - clk_unregister_composite(clk); + clk_hw_unregister_composite(hw); kfree(div); kfree(gate); kfree(mux); @@ -289,7 +289,7 @@ int mtk_clk_register_composites(const struct mtk_composite *mcs, int num, void __iomem *base, spinlock_t *lock, struct clk_hw_onecell_data *clk_data) { - struct clk *clk; + struct clk_hw *hw; int i; if (!clk_data) @@ -304,14 +304,15 @@ int mtk_clk_register_composites(const struct mtk_composite *mcs, int num, continue; } - clk = mtk_clk_register_composite(mc, base, lock); + hw = mtk_clk_register_composite(mc, base, lock); - if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %pe\n", mc->name, clk); + if (IS_ERR(hw)) { + pr_err("Failed to register clk %s: %pe\n", mc->name, + hw); goto err; } - clk_data->hws[mc->id] = __clk_get_hw(clk); + clk_data->hws[mc->id] = hw; } return 0; @@ -323,11 +324,11 @@ int mtk_clk_register_composites(const struct mtk_composite *mcs, int num, if (IS_ERR_OR_NULL(clk_data->hws[mcs->id])) continue; - mtk_clk_unregister_composite(clk_data->hws[mc->id]->clk); + mtk_clk_unregister_composite(clk_data->hws[mc->id]); clk_data->hws[mc->id] = ERR_PTR(-ENOENT); } - return PTR_ERR(clk); + return PTR_ERR(hw); } EXPORT_SYMBOL_GPL(mtk_clk_register_composites); @@ -345,7 +346,7 @@ void mtk_clk_unregister_composites(const struct mtk_composite *mcs, int num, if (IS_ERR_OR_NULL(clk_data->hws[mc->id])) continue; - mtk_clk_unregister_composite(clk_data->hws[mc->id]->clk); + mtk_clk_unregister_composite(clk_data->hws[mc->id]); clk_data->hws[mc->id] = ERR_PTR(-ENOENT); } } @@ -355,7 +356,7 @@ int mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num, void __iomem *base, spinlock_t *lock, struct clk_hw_onecell_data *clk_data) { - struct clk *clk; + struct clk_hw *hw; int i; if (!clk_data) @@ -370,16 +371,17 @@ int mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num, continue; } - clk = clk_register_divider(NULL, mcd->name, mcd->parent_name, + hw = clk_hw_register_divider(NULL, mcd->name, mcd->parent_name, mcd->flags, base + mcd->div_reg, mcd->div_shift, mcd->div_width, mcd->clk_divider_flags, lock); - if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %pe\n", mcd->name, clk); + if (IS_ERR(hw)) { + pr_err("Failed to register clk %s: %pe\n", mcd->name, + hw); goto err; } - clk_data->hws[mcd->id] = __clk_get_hw(clk); + clk_data->hws[mcd->id] = hw; } return 0; @@ -391,11 +393,11 @@ int mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num, if (IS_ERR_OR_NULL(clk_data->hws[mcd->id])) continue; - mtk_clk_unregister_composite(clk_data->hws[mcd->id]->clk); + mtk_clk_unregister_composite(clk_data->hws[mcd->id]); clk_data->hws[mcd->id] = ERR_PTR(-ENOENT); } - return PTR_ERR(clk); + return PTR_ERR(hw); } void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, int num, diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index e736420170a2..adb1304d35d4 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -184,7 +184,7 @@ void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, int num, struct clk_hw_onecell_data *mtk_alloc_clk_data(unsigned int clk_num); void mtk_free_clk_data(struct clk_hw_onecell_data *clk_data); -struct clk *mtk_clk_register_ref2usb_tx(const char *name, +struct clk_hw *mtk_clk_register_ref2usb_tx(const char *name, const char *parent_name, void __iomem *reg); void mtk_register_reset_controller(struct device_node *np, diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c index 2f47e59cc528..cd5f9fd8cb98 100644 --- a/drivers/clk/mediatek/clk-mux.c +++ b/drivers/clk/mediatek/clk-mux.c @@ -143,13 +143,13 @@ const struct clk_ops mtk_mux_gate_clr_set_upd_ops = { }; EXPORT_SYMBOL_GPL(mtk_mux_gate_clr_set_upd_ops); -static struct clk *mtk_clk_register_mux(const struct mtk_mux *mux, +static struct clk_hw *mtk_clk_register_mux(const struct mtk_mux *mux, struct regmap *regmap, spinlock_t *lock) { struct mtk_clk_mux *clk_mux; struct clk_init_data init = {}; - struct clk *clk; + int ret; clk_mux = kzalloc(sizeof(*clk_mux), GFP_KERNEL); if (!clk_mux) @@ -166,27 +166,24 @@ static struct clk *mtk_clk_register_mux(const struct mtk_mux *mux, clk_mux->lock = lock; clk_mux->hw.init = &init; - clk = clk_register(NULL, &clk_mux->hw); - if (IS_ERR(clk)) { + ret = clk_hw_register(NULL, &clk_mux->hw); + if (ret) { kfree(clk_mux); - return clk; + return ERR_PTR(ret); } - return clk; + return &clk_mux->hw; } -static void mtk_clk_unregister_mux(struct clk *clk) +static void mtk_clk_unregister_mux(struct clk_hw *hw) { struct mtk_clk_mux *mux; - struct clk_hw *hw; - - hw = __clk_get_hw(clk); if (!hw) return; mux = to_mtk_clk_mux(hw); - clk_unregister(clk); + clk_hw_unregister(hw); kfree(mux); } @@ -196,7 +193,7 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, struct clk_hw_onecell_data *clk_data) { struct regmap *regmap; - struct clk *clk; + struct clk_hw *hw; int i; regmap = device_node_to_regmap(node); @@ -214,14 +211,15 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, continue; } - clk = mtk_clk_register_mux(mux, regmap, lock); + hw = mtk_clk_register_mux(mux, regmap, lock); - if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %pe\n", mux->name, clk); + if (IS_ERR(hw)) { + pr_err("Failed to register clk %s: %pe\n", mux->name, + hw); goto err; } - clk_data->hws[mux->id] = __clk_get_hw(clk); + clk_data->hws[mux->id] = hw; } return 0; @@ -233,11 +231,11 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, if (IS_ERR_OR_NULL(clk_data->hws[mux->id])) continue; - mtk_clk_unregister_mux(clk_data->hws[mux->id]->clk); + mtk_clk_unregister_mux(clk_data->hws[mux->id]); clk_data->hws[mux->id] = ERR_PTR(-ENOENT); } - return PTR_ERR(clk); + return PTR_ERR(hw); } EXPORT_SYMBOL_GPL(mtk_clk_register_muxes); @@ -255,7 +253,7 @@ void mtk_clk_unregister_muxes(const struct mtk_mux *muxes, int num, if (IS_ERR_OR_NULL(clk_data->hws[mux->id])) continue; - mtk_clk_unregister_mux(clk_data->hws[mux->id]->clk); + mtk_clk_unregister_mux(clk_data->hws[mux->id]); clk_data->hws[mux->id] = ERR_PTR(-ENOENT); } } diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c index 89350a1a158c..cabdf25a27f3 100644 --- a/drivers/clk/mediatek/clk-pll.c +++ b/drivers/clk/mediatek/clk-pll.c @@ -314,12 +314,12 @@ static const struct clk_ops mtk_pll_ops = { .set_rate = mtk_pll_set_rate, }; -static struct clk *mtk_clk_register_pll(const struct mtk_pll_data *data, +static struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data, void __iomem *base) { struct mtk_clk_pll *pll; struct clk_init_data init = {}; - struct clk *clk; + int ret; const char *parent_name = "clk26m"; pll = kzalloc(sizeof(*pll), GFP_KERNEL); @@ -354,26 +354,26 @@ static struct clk *mtk_clk_register_pll(const struct mtk_pll_data *data, init.parent_names = &parent_name; init.num_parents = 1; - clk = clk_register(NULL, &pll->hw); + ret = clk_hw_register(NULL, &pll->hw); - if (IS_ERR(clk)) + if (ret) { kfree(pll); + return ERR_PTR(ret); + } - return clk; + return &pll->hw; } -static void mtk_clk_unregister_pll(struct clk *clk) +static void mtk_clk_unregister_pll(struct clk_hw *hw) { - struct clk_hw *hw; struct mtk_clk_pll *pll; - hw = __clk_get_hw(clk); if (!hw) return; pll = to_mtk_clk_pll(hw); - clk_unregister(clk); + clk_hw_unregister(hw); kfree(pll); } @@ -383,7 +383,7 @@ int mtk_clk_register_plls(struct device_node *node, { void __iomem *base; int i; - struct clk *clk; + struct clk_hw *hw; base = of_iomap(node, 0); if (!base) { @@ -400,14 +400,15 @@ int mtk_clk_register_plls(struct device_node *node, continue; } - clk = mtk_clk_register_pll(pll, base); + hw = mtk_clk_register_pll(pll, base); - if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %pe\n", pll->name, clk); + if (IS_ERR(hw)) { + pr_err("Failed to register clk %s: %pe\n", pll->name, + hw); goto err; } - clk_data->hws[pll->id] = __clk_get_hw(clk); + clk_data->hws[pll->id] = hw; } return 0; @@ -416,13 +417,13 @@ int mtk_clk_register_plls(struct device_node *node, while (--i >= 0) { const struct mtk_pll_data *pll = &plls[i]; - mtk_clk_unregister_pll(clk_data->hws[pll->id]->clk); + mtk_clk_unregister_pll(clk_data->hws[pll->id]); clk_data->hws[pll->id] = ERR_PTR(-ENOENT); } iounmap(base); - return PTR_ERR(clk); + return PTR_ERR(hw); } EXPORT_SYMBOL_GPL(mtk_clk_register_plls); @@ -457,7 +458,7 @@ void mtk_clk_unregister_plls(const struct mtk_pll_data *plls, int num_plls, */ base = mtk_clk_pll_get_base(clk_data->hws[pll->id], pll); - mtk_clk_unregister_pll(clk_data->hws[pll->id]->clk); + mtk_clk_unregister_pll(clk_data->hws[pll->id]); clk_data->hws[pll->id] = ERR_PTR(-ENOENT); } From patchwork Tue Apr 19 08:12:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12817614 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB38BC433F5 for ; Tue, 19 Apr 2022 08:13:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349750AbiDSIQE (ORCPT ); Tue, 19 Apr 2022 04:16:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349781AbiDSIQD (ORCPT ); Tue, 19 Apr 2022 04:16:03 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E89202C122 for ; Tue, 19 Apr 2022 01:13:13 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id c12so14685461plr.6 for ; Tue, 19 Apr 2022 01:13:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Weku3tK3QsQmvTCERbGIwfFGvzqht9p9BZS1XmEvotY=; b=iRJI5ml7K6kAK/onoLxDchA/ArVyOYamxU90RxXYOx6Pzg5aap3PFpRYnG/cbfGJd6 /8vrlTiPABYe8GgWO2TOGciYVdjVpO0SLmFzLsJr3BBnNqQEkPxM1VOG9DPREEwn/MrS O3LSWUbVGUtObFi/zzy3ca9FJZ+wGXv0Cvj08= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Weku3tK3QsQmvTCERbGIwfFGvzqht9p9BZS1XmEvotY=; b=xzODFpcl9Mpphd5Cqmwm8sOWXdAespJWM7pKXWyWoNW41q3DsqhFrfpxy8jHw5oi6E SsGMCHcmguMXOzI8Vd4uw/4nao364zEMlDSWBJ7Yi58e/eh6E8CJamRmd9ZUAAsmEfvE BKOMZg7bMUEYeauodmFrx0gli6doKJHUCUrF07aX/X32b9vEvoJLjI9OPQuqxnv6Qg18 bQMl1NqAKa0QpMJd5XRTMQ3LgS0P9R2/5u7ro/kzNswf6dAfzLorpy9ikZxVdb/jzeOv M5iPlYeRjFd6+SHivyyGvUGNawqm8ayN1usAPZN6z7r9b5mb3+aPVZErWowFmqcGj6lz lkFw== X-Gm-Message-State: AOAM531SDwFqvsmyCMkf051BBT/MztgJI70N4gyri3+6yH7KoU0QRWvs Dc4KFRgPPbVI8av1Me3VT0W/UQ== X-Google-Smtp-Source: ABdhPJy2WKrXlaqCJkZtZm2wuCrjHhcU/3L6VkQg+6FopUOE3aGjPtuoWuBKFt+ExdfC73sGUt8/vg== X-Received: by 2002:a17:902:e74f:b0:158:e890:2ed4 with SMTP id p15-20020a170902e74f00b00158e8902ed4mr14598622plf.32.1650355993497; Tue, 19 Apr 2022 01:13:13 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:33f6:f1e6:3e21:a253]) by smtp.gmail.com with ESMTPSA id n13-20020a654ccd000000b0039db6f73e9dsm15767448pgt.28.2022.04.19.01.13.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 01:13:13 -0700 (PDT) From: Chen-Yu Tsai To: Michael Turquette , Stephen Boyd , Chun-Jie Chen , Miles Chen , Rex-BC Chen Cc: Chen-Yu Tsai , Matthias Brugger , linux-clk@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 6/7] clk: mediatek: mt8173: Fix usage of mtk_clk_register_ref2usb_tx() Date: Tue, 19 Apr 2022 16:12:45 +0800 Message-Id: <20220419081246.2546159-7-wenst@chromium.org> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220419081246.2546159-1-wenst@chromium.org> References: <20220419081246.2546159-1-wenst@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org As part of the effort to improve the MediaTek clk drivers, the next step is to switch from the old 'struct clk' clk prodivder APIs to the new 'struct clk_hw' ones. The apmixed clk library contains one special clk type that doesn't fit any of the generic clk types. This type is currently used only on the MT8173 SoC. The code for this clk type was converted by the coccinelle script from the previous patch, but the call site was not. Fix the return variable type for mtk_clk_register_ref2usb_tx() in the MT8173 clk driver. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mt8173.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/clk/mediatek/clk-mt8173.c b/drivers/clk/mediatek/clk-mt8173.c index 511b4da9e727..68d3a9749316 100644 --- a/drivers/clk/mediatek/clk-mt8173.c +++ b/drivers/clk/mediatek/clk-mt8173.c @@ -993,6 +993,7 @@ static void __init mtk_apmixedsys_init(struct device_node *node) { struct clk_hw_onecell_data *clk_data; void __iomem *base; + struct clk_hw *hw; struct clk *clk; int r, i; @@ -1013,16 +1014,13 @@ static void __init mtk_apmixedsys_init(struct device_node *node) for (i = 0; i < ARRAY_SIZE(apmixed_usb); i++) { const struct mtk_clk_usb *cku = &apmixed_usb[i]; - clk = mtk_clk_register_ref2usb_tx(cku->name, cku->parent, - base + cku->reg_ofs); - - if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", cku->name, - PTR_ERR(clk)); + hw = mtk_clk_register_ref2usb_tx(cku->name, cku->parent, base + cku->reg_ofs); + if (IS_ERR(hw)) { + pr_err("Failed to register clk %s: %ld\n", cku->name, PTR_ERR(hw)); continue; } - clk_data->hws[cku->id] = __clk_get_hw(clk); + clk_data->hws[cku->id] = hw; } clk = clk_register_divider(NULL, "hdmi_ref", "tvdpll_594m", 0, From patchwork Tue Apr 19 08:12:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 12817615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA4D0C433EF for ; Tue, 19 Apr 2022 08:13:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349785AbiDSIQI (ORCPT ); Tue, 19 Apr 2022 04:16:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349779AbiDSIQF (ORCPT ); Tue, 19 Apr 2022 04:16:05 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4301F2C12F for ; Tue, 19 Apr 2022 01:13:16 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id c23so14731581plo.0 for ; Tue, 19 Apr 2022 01:13:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ymcXL9mZkOXE1tvy2X8sRlDYOjiY7V/45QxE3N+k/bg=; b=d2lwlqxOipd23SNVAohwHf+gxo5amqNUclnUkRETxFfTTn1ZTq3HvQws+brlFkt85c Hfof9ZusLxWdVXKJ3l1Gg3TZenarfIXBwbKaK3la2n/LByuTNRdooFo/cte6FrHY39Eq 9ncMqc58sVmkJwKE9Skxnh51bHyEICko8Uspo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ymcXL9mZkOXE1tvy2X8sRlDYOjiY7V/45QxE3N+k/bg=; b=bYtJdANCxB9hq8dLB0yqtuH42WK57S6tkyWzBQz5/UnC+VsKMvGpfPxQZuhIMKCynt apCvRX1VqYIsi1g5eEMvGgrEPLRqxDm5s+6K1ASBQm0ORthyqg3Tbf+bpAfp2Ah03Lm5 cldFrztqk1FUc5vi64z7LugCHi1TD+oUu9T0S66VI9yYVuR1gLVZJDLFt9116gKYovoI WdoEIV5JjrrkodXTCjF3d/Y/EBvAsQg0sxeJs5XFQTugoNJGA9C1iraNopiozcN3pwIq 1SNQGP3tlXYlZiZJ/D1u6p955IG6UiYAZt0nt5ftq9EFiOSYF2e2Q9noOC27nealkET5 CtOQ== X-Gm-Message-State: AOAM533ZrD8JZ24ezEweZoLIFgw8K+SSmL2rgxh1Llt3PVQKSe45EPNG Xx1yV86AOOKiwt/pUBUi3HLCnw== X-Google-Smtp-Source: ABdhPJyPJGvPpTMNIeDwzlbJl89ma0IN1rYEVyRw7X+rYVNTUlAWEMm81vh00KrOJ1Q0dNCJ5surTw== X-Received: by 2002:a17:902:eb8c:b0:158:4cc9:6998 with SMTP id q12-20020a170902eb8c00b001584cc96998mr14826627plg.35.1650355995603; Tue, 19 Apr 2022 01:13:15 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:33f6:f1e6:3e21:a253]) by smtp.gmail.com with ESMTPSA id n13-20020a654ccd000000b0039db6f73e9dsm15767448pgt.28.2022.04.19.01.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 01:13:15 -0700 (PDT) From: Chen-Yu Tsai To: Michael Turquette , Stephen Boyd , Chun-Jie Chen , Miles Chen , Rex-BC Chen Cc: Chen-Yu Tsai , Matthias Brugger , linux-clk@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 7/7] clk: mediatek: mt8173: Switch to clk_hw provider APIs Date: Tue, 19 Apr 2022 16:12:46 +0800 Message-Id: <20220419081246.2546159-8-wenst@chromium.org> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220419081246.2546159-1-wenst@chromium.org> References: <20220419081246.2546159-1-wenst@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org As part of the effort to improve the MediaTek clk drivers, the next step is to switch from the old 'struct clk' clk prodivder APIs to the new 'struct clk_hw' ones. The MT8173 clk driver has one clk that is registered directly with the clk provider APIs, instead of going through the MediaTek clk library. Switch this instance to use the clk_hw provider API. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mt8173.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/clk/mediatek/clk-mt8173.c b/drivers/clk/mediatek/clk-mt8173.c index 68d3a9749316..d34b248c42ca 100644 --- a/drivers/clk/mediatek/clk-mt8173.c +++ b/drivers/clk/mediatek/clk-mt8173.c @@ -994,7 +994,6 @@ static void __init mtk_apmixedsys_init(struct device_node *node) struct clk_hw_onecell_data *clk_data; void __iomem *base; struct clk_hw *hw; - struct clk *clk; int r, i; base = of_iomap(node, 0); @@ -1023,10 +1022,10 @@ static void __init mtk_apmixedsys_init(struct device_node *node) clk_data->hws[cku->id] = hw; } - clk = clk_register_divider(NULL, "hdmi_ref", "tvdpll_594m", 0, - base + 0x40, 16, 3, CLK_DIVIDER_POWER_OF_TWO, - NULL); - clk_data->hws[CLK_APMIXED_HDMI_REF] = __clk_get_hw(clk); + hw = clk_hw_register_divider(NULL, "hdmi_ref", "tvdpll_594m", 0, + base + 0x40, 16, 3, CLK_DIVIDER_POWER_OF_TWO, + NULL); + clk_data->hws[CLK_APMIXED_HDMI_REF] = hw; r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); if (r)