Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp368297rwn; Wed, 7 Sep 2022 18:32:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR47HTV7cBpRbUtPijVHfMQgDYWi+AQWc8GNVuR3zt6uwJ7msXkLzV22HNA/yA9g9uETY4fi X-Received: by 2002:aa7:cd05:0:b0:44f:2776:2ff with SMTP id b5-20020aa7cd05000000b0044f277602ffmr2853695edw.49.1662600778249; Wed, 07 Sep 2022 18:32:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662600778; cv=none; d=google.com; s=arc-20160816; b=CYo0CY9PI/Wsf1Bp8Q6+rJ6yVpQTxPQ3WNOTacGjmRWDvZ+x68F9iqvbDQl8JDyl7W HXcE5sbJdYFVTbUK6uqX88d4aRltyEoELFl18IT4hGE+LQjCDt1yHfD6fMQXgkWuNtXg l98Hk+ed/UXVy6vLnPRBfCsOA969iRBILozT8o5O/bEGMkFmWBBMYztk4HiI3FjxQ2Ay Pg6qUeNJ5scb02gS/XM99MmAdj3JA49v2wge1OvcBII1SyjFxvZOQPvuhErF/pkDU0+9 EYXpVxtWgEFBkpsw3thTqKhD/vTnwlXmpsDWte/DMQb/YHNzaxB2JyLJ4ZkPNRc9KY1L FCBw== 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=XOp/iG3CLyS0BXjgrF8FfBg3GGrX7n3WSw4onAJG5z0=; b=KOzpsYRcKRZm5mgBTQrTZ4iaqAkkePk0EXh/VNogV8ZH/3G6V/Zq0gUn05qEfyHlNq 6/blYpBCC1Wo4xofOF2upGotudt5UxYgfwqfi82G2+jy/lyNuDKG4FXDPdpK5lyf3NoC bypWvmmCfSiMZDnNjeveeyUPzFj10zUck9xy4NJnrBxpGH6oGavYhogrSydwzAwbnA74 OLiSLExmJYwYfjZlxCHwqL/34jfEYN215962IOLFAsJdEV2BnuqkNhbbmtrtih9s0x/9 eUHXBuZopRdiAXzJdCdnksLdOn9tS/l+nNgHkUvKm0Ypxq6ZVZlq0T8uCWIUh5ZO968C FSFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=jJSS896B; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m9-20020a056402510900b00446408c0fb7si16556481edd.211.2022.09.07.18.32.34; Wed, 07 Sep 2022 18:32:58 -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=jJSS896B; 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 S230337AbiIHAbd (ORCPT + 99 others); Wed, 7 Sep 2022 20:31:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230131AbiIHAbQ (ORCPT ); Wed, 7 Sep 2022 20:31:16 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DB8686FC9; Wed, 7 Sep 2022 17:31:14 -0700 (PDT) Received: from jupiter.universe (dyndsl-095-033-158-249.ewe-ip-backbone.de [95.33.158.249]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: sre) by madras.collabora.co.uk (Postfix) with ESMTPSA id 3E5F66601F75; Thu, 8 Sep 2022 01:31:12 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1662597072; bh=UP5o/tvjF82X745/6YwLJBWyLQY3SW00yYxIUB5+Do8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jJSS896BXO4FDEElQMVgUjiT6SDgTcI1lqsQEdHl2+opxTprfy1HYaFtkUyhPjacl p4oPfFLvtrCRcY6A2NJWotwQId/gKTIuoX3wwr9nlQ6qgztU29ZvDNOJvPp1vII3DZ cUxTCuwOZaJspp7cO5akg/2YyCQlBhTWfkQF1k7Ht3n6iEq1GjeqeFUQ82gL+Ze2Hu UzRteGejvTHhzmNklpTmZkMrOiUJxQBZdqpq/ZEm1zrQ23ySqTqU5wr4lTl+kNGub/ qjGTipub8fwWUEjQ00Mi6qG9hVmVJDQj4xIUTraWI+7Q1cCqAaP1vqlhvSqeIipTkx AXmEfseIPZvIQ== Received: by jupiter.universe (Postfix, from userid 1000) id 642E54805BE; Thu, 8 Sep 2022 02:31:09 +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: [PATCHv2 04/13] regulator: rk808: reduce 'struct rk808' usage Date: Thu, 8 Sep 2022 02:30:58 +0200 Message-Id: <20220908003107.220143-5-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220908003107.220143-1-sebastian.reichel@collabora.com> References: <20220908003107.220143-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, T_SCC_BODY_TEXT_LINE 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 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. Acked-by: Mark Brown Signed-off-by: Sebastian Reichel --- drivers/regulator/rk808-regulator.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c index 127dc2e2e690..ce9c64cadeba 100644 --- a/drivers/regulator/rk808-regulator.c +++ b/drivers/regulator/rk808-regulator.c @@ -14,7 +14,6 @@ #include #include -#include #include #include #include @@ -1286,19 +1285,23 @@ static int rk808_regulator_dt_parse_pdata(struct device *dev, static int rk808_regulator_probe(struct platform_device *pdev) { struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent); - struct i2c_client *client = rk808->i2c; struct regulator_config config = {}; struct regulator_dev *rk808_rdev; struct rk808_regulator_data *pdata; const struct regulator_desc *regulators; + struct regmap *regmap; int ret, i, nregulators; + regmap = dev_get_regmap(pdev->dev.parent, NULL); + if (!regmap) + return -ENODEV; + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return -ENOMEM; - ret = rk808_regulator_dt_parse_pdata(&pdev->dev, &client->dev, - rk808->regmap, pdata); + ret = rk808_regulator_dt_parse_pdata(&pdev->dev, pdev->dev.parent, + regmap, pdata); if (ret < 0) return ret; @@ -1326,21 +1329,22 @@ static int rk808_regulator_probe(struct platform_device *pdev) nregulators = RK818_NUM_REGULATORS; break; default: - dev_err(&client->dev, "unsupported RK8XX ID %lu\n", + dev_err(&pdev->dev, "unsupported RK8XX ID %lu\n", rk808->variant); return -EINVAL; } - config.dev = &client->dev; + config.dev = &pdev->dev; + config.dev->of_node = pdev->dev.parent->of_node; config.driver_data = pdata; - config.regmap = rk808->regmap; + config.regmap = regmap; /* Instantiate the regulators */ for (i = 0; i < nregulators; i++) { rk808_rdev = devm_regulator_register(&pdev->dev, ®ulators[i], &config); if (IS_ERR(rk808_rdev)) { - dev_err(&client->dev, + dev_err(&pdev->dev, "failed to register %d regulator\n", i); return PTR_ERR(rk808_rdev); } -- 2.35.1