From patchwork Thu Oct 20 20:42:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 6380 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp314421wrr; Thu, 20 Oct 2022 13:44:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5gLkVXYVCWoTsISxJjf434NBGhWeVsyIat68835wSWuo6YeoaNhdpx6IdQ1hbpIX68E2LT X-Received: by 2002:a63:d709:0:b0:461:be56:507e with SMTP id d9-20020a63d709000000b00461be56507emr13834449pgg.597.1666298666105; Thu, 20 Oct 2022 13:44:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666298666; cv=none; d=google.com; s=arc-20160816; b=bC72Es1zwJzal3DCvPZQgpT90oJAAPtxT887xdWD8lammtWanecp/iaYgHv0iwQ1Kg Nei+T9lfQpPH+yEEgM9AFkKTiC+5Z6JloTjahEK0NQ7loxz5piu0YrgYY2uGPOzAcCpy Cnh8NUlW7r0dB77ZJ/rjYNMwnAa960Gz5VtPVuQiOr5coz2e9/M8SS6j6FvJbq0z10BD gWXLTsJqvljdCCOQ2SFlG8+it3U7HKBe38FwKcBbhfrC3OsLGqgoI0tKhHCXI9DRaKE9 27PK8+0cC7/enN5X3yqKBiM2NyzaYgpj9Yk4K0CjZmL3omo8LXNKBQDX5+Mj815ILtj8 e4QA== 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=At7T9JVVRQuzhl0biqY+OaZou6wXAyCclRkFgaFnBdA=; b=wj5+I4xNsJp4chFDbcS+B9Nxx9ANucxW3yz8DBCg0K38vHhZrf0iXwrfCVJSWV4aFs vUOYft4uYArEV//VB5K4MKYSgOKdmRuw+N8FaKfJP+kVGpIjcRVBrZRDPwI0t1Zo5P7c /Lj5iTAt9hcU3ipKQoLW2mgA98WB39Vcg012M+Cgi0DPxoa7Ms2/Q+fxj6vVVbBLeByU FELyY/iFwXAz8/v5afgDN4fclo88J+Aju/Uj2mfEvfqKaVE39YY1Wj95JbQ4aXAjPRq3 DXw7gzfcbobMKn57gEbToGJJIVmA54jmmEnBGiLDP4YVDUK/t/gyuYoBrW++QFobuaRZ 1rkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=oU13qj5D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o18-20020a63f152000000b00434e297a5ccsi22914339pgk.142.2022.10.20.13.44.11; Thu, 20 Oct 2022 13:44:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=oU13qj5D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229755AbiJTUnX (ORCPT + 99 others); Thu, 20 Oct 2022 16:43:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbiJTUnL (ORCPT ); Thu, 20 Oct 2022 16:43:11 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 777FF1FB79C; Thu, 20 Oct 2022 13:42:56 -0700 (PDT) Received: from jupiter.universe (dyndsl-091-096-059-009.ewe-ip-backbone.de [91.96.59.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sre) by madras.collabora.co.uk (Postfix) with ESMTPSA id 8BA8A66024E8; Thu, 20 Oct 2022 21:42:54 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1666298574; bh=s6um36bR3kLKecIG+7jDV13ngBnOF98lUyD4ZvCww6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oU13qj5DC0Wiuj19fSfuFOYcdSJAPIxrIiFXqAOBPXsySh3cRojkQwBLOaNA7G0QG wrTQVn+LZSoZMP7NSIL4vls7I85vn0f9mMYQjYGVGJ5TTuntGHuo3zvJ1m4xilqV9J hCOayxd5eLSjVCRnosi0ASWJvZvmqhDm4JWErZ6Y27o9jIKSfDOM3JvsgUfFpe09yf aV7kN5nc6DZfAyhKNlDq6uCvqNWr2prb11wuKRv6u38tAGcMiBm+498spARmOHYl1B v8tyqmuew8CW7/gLUIe94+jxgfO1nKTu1WHO2WceM1dcvm0BVIJ96boG4kac/oECxg +bcfBWSuTPEWA== Received: by jupiter.universe (Postfix, from userid 1000) id 50001480896; Thu, 20 Oct 2022 22:42:52 +0200 (CEST) From: Sebastian Reichel To: Heiko Stuebner , Rob Herring , Krzysztof Kozlowski , Lee Jones Cc: Michael Turquette , Stephen Boyd , Linus Walleij , Mark Brown , Liam Girdwood , Alexandre Belloni , Alessandro Zummo , linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel , kernel@collabora.com Subject: [PATCHv4 01/13] clk: RK808: reduce 'struct rk808' usage Date: Thu, 20 Oct 2022 22:42:39 +0200 Message-Id: <20221020204251.108565-2-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221020204251.108565-1-sebastian.reichel@collabora.com> References: <20221020204251.108565-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747240790452059523?= X-GMAIL-MSGID: =?utf-8?q?1747240790452059523?= Reduce usage of 'struct rk808' (driver data of the parent MFD), so that only the chip variant field is still being accessed directly. This allows restructuring the MFD driver to support SPI based PMICs. Signed-off-by: Sebastian Reichel --- drivers/clk/clk-rk808.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/clk/clk-rk808.c b/drivers/clk/clk-rk808.c index 32f833d732ed..f7412b137e5e 100644 --- a/drivers/clk/clk-rk808.c +++ b/drivers/clk/clk-rk808.c @@ -12,10 +12,9 @@ #include #include #include -#include struct rk808_clkout { - struct rk808 *rk808; + struct regmap *regmap; struct clk_hw clkout1_hw; struct clk_hw clkout2_hw; }; @@ -31,9 +30,8 @@ static int rk808_clkout2_enable(struct clk_hw *hw, bool enable) struct rk808_clkout *rk808_clkout = container_of(hw, struct rk808_clkout, clkout2_hw); - struct rk808 *rk808 = rk808_clkout->rk808; - return regmap_update_bits(rk808->regmap, RK808_CLK32OUT_REG, + return regmap_update_bits(rk808_clkout->regmap, RK808_CLK32OUT_REG, CLK32KOUT2_EN, enable ? CLK32KOUT2_EN : 0); } @@ -52,10 +50,9 @@ static int rk808_clkout2_is_prepared(struct clk_hw *hw) struct rk808_clkout *rk808_clkout = container_of(hw, struct rk808_clkout, clkout2_hw); - struct rk808 *rk808 = rk808_clkout->rk808; uint32_t val; - int ret = regmap_read(rk808->regmap, RK808_CLK32OUT_REG, &val); + int ret = regmap_read(rk808_clkout->regmap, RK808_CLK32OUT_REG, &val); if (ret < 0) return ret; @@ -93,9 +90,8 @@ static int rk817_clkout2_enable(struct clk_hw *hw, bool enable) struct rk808_clkout *rk808_clkout = container_of(hw, struct rk808_clkout, clkout2_hw); - struct rk808 *rk808 = rk808_clkout->rk808; - return regmap_update_bits(rk808->regmap, RK817_SYS_CFG(1), + return regmap_update_bits(rk808_clkout->regmap, RK817_SYS_CFG(1), RK817_CLK32KOUT2_EN, enable ? RK817_CLK32KOUT2_EN : 0); } @@ -115,10 +111,9 @@ static int rk817_clkout2_is_prepared(struct clk_hw *hw) struct rk808_clkout *rk808_clkout = container_of(hw, struct rk808_clkout, clkout2_hw); - struct rk808 *rk808 = rk808_clkout->rk808; unsigned int val; - int ret = regmap_read(rk808->regmap, RK817_SYS_CFG(1), &val); + int ret = regmap_read(rk808_clkout->regmap, RK817_SYS_CFG(1), &val); if (ret < 0) return 0; @@ -153,18 +148,21 @@ static const struct clk_ops *rkpmic_get_ops(long variant) static int rk808_clkout_probe(struct platform_device *pdev) { struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent); - struct i2c_client *client = rk808->i2c; - struct device_node *node = client->dev.of_node; + struct device *dev = &pdev->dev; struct clk_init_data init = {}; struct rk808_clkout *rk808_clkout; int ret; - rk808_clkout = devm_kzalloc(&client->dev, + dev->of_node = pdev->dev.parent->of_node; + + rk808_clkout = devm_kzalloc(dev, sizeof(*rk808_clkout), GFP_KERNEL); if (!rk808_clkout) return -ENOMEM; - rk808_clkout->rk808 = rk808; + rk808_clkout->regmap = dev_get_regmap(pdev->dev.parent, NULL); + if (!rk808_clkout->regmap) + return -ENODEV; init.parent_names = NULL; init.num_parents = 0; @@ -173,10 +171,10 @@ static int rk808_clkout_probe(struct platform_device *pdev) rk808_clkout->clkout1_hw.init = &init; /* optional override of the clockname */ - of_property_read_string_index(node, "clock-output-names", + of_property_read_string_index(dev->of_node, "clock-output-names", 0, &init.name); - ret = devm_clk_hw_register(&client->dev, &rk808_clkout->clkout1_hw); + ret = devm_clk_hw_register(dev, &rk808_clkout->clkout1_hw); if (ret) return ret; @@ -185,10 +183,10 @@ static int rk808_clkout_probe(struct platform_device *pdev) rk808_clkout->clkout2_hw.init = &init; /* optional override of the clockname */ - of_property_read_string_index(node, "clock-output-names", + of_property_read_string_index(dev->of_node, "clock-output-names", 1, &init.name); - ret = devm_clk_hw_register(&client->dev, &rk808_clkout->clkout2_hw); + ret = devm_clk_hw_register(dev, &rk808_clkout->clkout2_hw); if (ret) return ret;