From patchwork Mon Oct 24 09:00:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 8259 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp335622wru; Mon, 24 Oct 2022 02:04:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM79LEkchZgZokmxJw4yPSPYxH1IgNb7S9azHagWH1e08cHz2zhLMd/nC4nWZzPftyRk2sUq X-Received: by 2002:a17:907:5c2:b0:77e:def7:65d8 with SMTP id wg2-20020a17090705c200b0077edef765d8mr26990379ejb.487.1666602295053; Mon, 24 Oct 2022 02:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666602295; cv=none; d=google.com; s=arc-20160816; b=DnFbOX5/+Dl3strYCucqcmQlOL4AlC/P/bwjGpJ3OqIpgcmWMB+g1LxLMOnso+4+iZ lAwPod33jjueutWFcPa5MTUBjbnRtmQtp6E/5RYQcfHtpXuqPWltiFzazxyO5LS4hmra jJWuXWla8azlqv44pKpfCrkuN7If/FD+uhQHbwdg5uvm+BkliTDKMHsM5vDIxksTLTDe zlHTvYlvN3eIgvV1mhKUEXEC6sGio+YdmCfGhUShVTLKR2Z7TzEsFnfxu0tIgAv0z83J /RX9FHCkoug0ENYjTr0pPFGJk5zhrBO8BxVN/PusWc+I2fX6Ixhbawxfhjj4xyTjhRnr QU2Q== 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=HhYGp3xj4fETUdoi6c4BpQ6p+BS7FEs9YxaRow5bRfw=; b=hqbiJldzNxPeYTFpWv76IxBhlDH0m8V6e5tlQAqdlZ4QEe48HSs0FpVm0UJYdMi4cV LapM3gTwzkB1syoTDyyI/OZCrOFKUI71UAbeBnBfsFNOdGOfDunl5DK1Z2uYOOWxcZYC wZq/HFWLML+KBs5BD2WNIRYcutTynYHRm6MpuyIBtOwT1OWt8xN2L3ZYS4V66CYEmqIp MyDX9PwDPaoBd4T28dcIyxdGeEqLcvo5Ld1tfcGfJqUjfPmo95Cy34UNE0n7jvI65XW7 TMzNpSFJZQx+uns2RLfaQTHWEHoy1chIzCGsiD2WKJPdc+LlofQvJaiFS0ij/MFx05/3 4erw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dvo6dhRO; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq8-20020a1709073f0800b0078c37681f89si33614774ejc.650.2022.10.24.02.04.30; Mon, 24 Oct 2022 02:04:55 -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=@kernel.org header.s=k20201202 header.b=dvo6dhRO; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229544AbiJXJCA (ORCPT + 99 others); Mon, 24 Oct 2022 05:02:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbiJXJBk (ORCPT ); Mon, 24 Oct 2022 05:01:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 622F94DB46; Mon, 24 Oct 2022 02:01:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E44DF61090; Mon, 24 Oct 2022 09:01:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CEA06C43147; Mon, 24 Oct 2022 09:01:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666602097; bh=kUu1wS6SClje+mygFdWFEMGHxt8IMZqWUdrDHplK5nY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dvo6dhROYScXXqv0k2xgGWLSEeqM6ukZdFGsRK4Z0Mnpr4aAidbU3mSDuKq3PFiwy 5NIJojb+xTo15iRn0PyhN0LCbzoNxFwxLOj1D5K9TQOOCjxhL+w/LoAHo8jg9adzq6 BJFssNvdQmcT1+Jv1JPEwVLiVkI5OGRWt1Z2p1BYJo9YKMpe8rf5fp1utslcyoQihs VQhyD+MiXbmkJPgb1mzskEj4hJhFheroEmiDdAiSAN+eZS3kXHkaf4LvA95ZZ96aQu cZglcLoumMk36/Zt3QcwhH7cqqgQ16XlrYFQu0KvaRG9Cyd/iaXxHmPTdluSOSNbC3 oZJkssKTDICEA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1omtKj-00056T-Ao; Mon, 24 Oct 2022 11:01:21 +0200 From: Johan Hovold To: Vinod Koul Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Dmitry Baryshkov , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 04/10] phy: qcom-qmp-ufs: clean up probe initialisation Date: Mon, 24 Oct 2022 11:00:35 +0200 Message-Id: <20221024090041.19574-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221024090041.19574-1-johan+linaro@kernel.org> References: <20221024090041.19574-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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?1747559168158006300?= X-GMAIL-MSGID: =?utf-8?q?1747559168158006300?= Stop abusing the driver data pointer and instead pass the driver state structure directly to the initialisation helpers during probe. Signed-off-by: Johan Hovold Reviewed-by: Dmitry Baryshkov --- drivers/phy/qualcomm/phy-qcom-qmp-ufs.c | 37 ++++++++++++------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c b/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c index 25744b3576f3..057f9a3fdd6d 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c @@ -945,9 +945,10 @@ static int qmp_ufs_disable(struct phy *phy) return qmp_ufs_exit(phy); } -static int qmp_ufs_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) +static int qmp_ufs_vreg_init(struct qmp_ufs *qmp) { - struct qmp_ufs *qmp = dev_get_drvdata(dev); + const struct qmp_phy_cfg *cfg = qmp->cfg; + struct device *dev = qmp->dev; int num = cfg->num_vregs; int i; @@ -961,9 +962,10 @@ static int qmp_ufs_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) return devm_regulator_bulk_get(dev, num, qmp->vregs); } -static int qmp_ufs_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg) +static int qmp_ufs_clk_init(struct qmp_ufs *qmp) { - struct qmp_ufs *qmp = dev_get_drvdata(dev); + const struct qmp_phy_cfg *cfg = qmp->cfg; + struct device *dev = qmp->dev; int num = cfg->num_clks; int i; @@ -983,15 +985,13 @@ static const struct phy_ops qcom_qmp_ufs_ops = { .owner = THIS_MODULE, }; -static int qmp_ufs_create(struct device *dev, struct device_node *np, - void __iomem *serdes, const struct qmp_phy_cfg *cfg) +static int qmp_ufs_create(struct qmp_ufs *qmp, struct device_node *np) { - struct qmp_ufs *qmp = dev_get_drvdata(dev); + const struct qmp_phy_cfg *cfg = qmp->cfg; + struct device *dev = qmp->dev; struct phy *generic_phy; int ret; - qmp->cfg = cfg; - qmp->serdes = serdes; /* * Get memory resources for the PHY: * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. @@ -1045,8 +1045,6 @@ static int qmp_ufs_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *child; struct phy_provider *phy_provider; - void __iomem *serdes; - const struct qmp_phy_cfg *cfg = NULL; struct qmp_ufs *qmp; int ret; @@ -1055,21 +1053,20 @@ static int qmp_ufs_probe(struct platform_device *pdev) return -ENOMEM; qmp->dev = dev; - dev_set_drvdata(dev, qmp); - cfg = of_device_get_match_data(dev); - if (!cfg) + qmp->cfg = of_device_get_match_data(dev); + if (!qmp->cfg) return -EINVAL; - serdes = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(serdes)) - return PTR_ERR(serdes); + qmp->serdes = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(qmp->serdes)) + return PTR_ERR(qmp->serdes); - ret = qmp_ufs_clk_init(dev, cfg); + ret = qmp_ufs_clk_init(qmp); if (ret) return ret; - ret = qmp_ufs_vreg_init(dev, cfg); + ret = qmp_ufs_vreg_init(qmp); if (ret) return ret; @@ -1077,7 +1074,7 @@ static int qmp_ufs_probe(struct platform_device *pdev) if (!child) return -EINVAL; - ret = qmp_ufs_create(dev, child, serdes, cfg); + ret = qmp_ufs_create(qmp, child); if (ret) goto err_node_put;