From patchwork Thu Oct 20 20:42:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 6379 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp314304wrr; Thu, 20 Oct 2022 13:44:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5QkOykXSGEZuw14Ahp7hB9JLm8a/6duzzaW9Aq5ws7Njlt3qn2jzBwtonRv0nVH5Br/YPn X-Received: by 2002:a17:906:846b:b0:78d:f3b9:aadf with SMTP id hx11-20020a170906846b00b0078df3b9aadfmr12629483ejc.731.1666298644106; Thu, 20 Oct 2022 13:44:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666298644; cv=none; d=google.com; s=arc-20160816; b=DHNQkZucqY2/soMDICa+/w0aw45UCbZ331exDA0lgyOX74miGjHUX99ijXU87DLyZL bmrOpR8TnT5vcr7Fgs999UQUTiGAv9yV8JEJXuvTm6rkZLfGaArbkUPH5E75tZwH00y0 HFrpVJIDUJIJPENvWe2VzH9jbuErpguuINF2ZCE4VnSgUswaWABbzRcAuDftzGdsG73i WGg7q5hY4qOdHmc7vXNWBGCEtFlCipvrFCGbuJBI+8e0uuHzUI6nl41/Pt28+qFEIfOB u3t1wH8tluV7xLE1Rvdhcl3Gz11/c9rqKEmafWRDu9tTo7TUNd7vwpsN69dVeFr3dHXg Tpjw== 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=vbXOK0jQ3jFHRJvIZ2VofFJcCwQaYrNamaPN+cJ6Hx6jVKTNd6Fw2S3Gf/swntagoQ zJOC7krw6yecByhQCoKqNdLAzCp6mGaIBZX7IaF6KgHGM/w0sbn9pEqIJLC3zhDaTUrt w9hgqM6B9OuJRclpRNFz1692VS+9dcZ4SJwv2Wg/KQ+SkmigUq1ehtcIdJsFHKLZzlwr C3Vppq1qn9MZCrK0vbfwGB29li3DPbM6QMuxSRvyDuIXQOQEDaSisGNIjzNLg+RSr5/9 0swuwg2ogpvR53Cou0gZAn3JjFPaxwl2zQbHRjDBSXj56XDbs5GHHZejjdE04AeZhZ4i l+ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=lyOVSWyK; 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 t17-20020a056402021100b004599ae68f98si15214346edv.136.2022.10.20.13.43.39; Thu, 20 Oct 2022 13:44:04 -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=lyOVSWyK; 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 S229719AbiJTUnM (ORCPT + 99 others); Thu, 20 Oct 2022 16:43:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229489AbiJTUnK (ORCPT ); Thu, 20 Oct 2022 16:43:10 -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 776DC1F810A; 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 9AFB8660250A; 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=UP5o/tvjF82X745/6YwLJBWyLQY3SW00yYxIUB5+Do8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lyOVSWyKlZo3CKhTdjNO4jIL6KMkKJhWK2bhpQLW15YPV5+wGEJpJ3d5R0BP76Ihe /WNrklAWhUrXxJV44uwj3sX3KNEHYXXUmmgaH4FmqKtJnHML4tcg7ObEAT8uICLwvP 5a4AdXNTGFC8v/GGinsYweRC7mm9F2s3zInQqZetU0d0xrz8qrWx9cjif3bOfZOxwp qwI5Wi/ySVgqfYEEA9Bhi1knzOepvxpekeZ2vofyGQc9WemQub/2LJGk4B20HMy6aW 9i1EAnPDEXyTIo3PKWNWeJ7BhhEt0U/VhLZolFVrrSchlLeLpVzs5obXSrFiGPM5lC sUOmgmKeUpj2g== Received: by jupiter.universe (Postfix, from userid 1000) id 52567480897; 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 02/13] regulator: rk808: reduce 'struct rk808' usage Date: Thu, 20 Oct 2022 22:42:40 +0200 Message-Id: <20221020204251.108565-3-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?1747240767155278567?= X-GMAIL-MSGID: =?utf-8?q?1747240767155278567?= 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); }