From patchwork Sat Nov 27 14:11:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Fei X-Patchwork-Id: 12642257 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 00CDCC433F5 for ; Sat, 27 Nov 2021 14:16:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343843AbhK0OT1 (ORCPT ); Sat, 27 Nov 2021 09:19:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355255AbhK0OR1 (ORCPT ); Sat, 27 Nov 2021 09:17:27 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCAA2C0613D7 for ; Sat, 27 Nov 2021 06:11:28 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id q3so2334140wru.5 for ; Sat, 27 Nov 2021 06:11:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DU0NAGk/HARgZbacO/zBQEe/KDrwhSU3OnAthCrWpLo=; b=IO72eua2LtzV2gYO9JeclUgkQ1b6tcLbTRthI2maRBR9UjvnPrWs/+0h9F72YEmhIL OC4Wv3AlAqMC17QFNHhypybv/2mslEFi0FDoquxI1EbO5jx1RXh1HssO6veQLjPTREay a09iC48sta2AXJ6JDABvSek2vLLQn7XP2SeV94Z3J4M7W9rV9X4IPfdxjlGHSx4mYSZb r+KHGwvlvTRjVIGUOX6mof17qmtnkgrkt7G5d3Xw5zSp2ddHTQAbjjU9z8Li9zCE6AoI Qtg+NhvSmGsWHJwVboWQXFwMjKYqhLivoX8kxnT6UzspwGrvjLe4Pb18ebqF+duCuweh 2DVA== 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=DU0NAGk/HARgZbacO/zBQEe/KDrwhSU3OnAthCrWpLo=; b=adBFVjhUvyqkMdik8e68qh/pn0KjutFpxbHfb3HLflIFyBytO/KpnAHKGwVHx4oeMl ZtQ53wwYGXDYRbVUyIZ9bSNeDPXxKkDJAIjEPofUBrEj1fhavHrUXqPKjdYfo+GeQIaf 6LTRXexAx0Ed9rp4XlgHr0LHA9N/fKfykw/9qTUMYEPvtSfkAeqbeUdeLLJVA4LciKxN VBBlwiNWYG4+/RdEjTYKR+KvHLXl8k3lHT5w7CG8hVh/Hz/4G8QBeSZKcc1xldg9EjDF OyI2CbLle7PL1hxSLivTjTKmSS/9liKmURke0e6MHIGFvpqTxKhsJH+cMseCZfmEOzaA SCjw== X-Gm-Message-State: AOAM533+trJogWU//5zUVNuK+7RxwEQuVO8CLUXAi1kKf21Slgk9g4Df J0NUUeAYS33RCxq7OWfZG9U= X-Google-Smtp-Source: ABdhPJzUP45ypnoWx3yzVVmcfkNkzrrvxWaN8QwVzgYyvefbVTR2u3KC3o5Z7D4kyesbtuol7aIt1Q== X-Received: by 2002:a05:6000:1681:: with SMTP id y1mr20965337wrd.52.1638022287369; Sat, 27 Nov 2021 06:11:27 -0800 (PST) Received: from claire-ThinkPad-T470.localdomain (dynamic-2a01-0c22-7349-1000-d163-c2fa-698a-934f.c22.pool.telefonica.de. [2a01:c22:7349:1000:d163:c2fa:698a:934f]) by smtp.gmail.com with ESMTPSA id q26sm8754522wrc.39.2021.11.27.06.11.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Nov 2021 06:11:27 -0800 (PST) From: Fan Fei To: bjorn@helgaas.com Cc: Fan Fei , linux-pci@vger.kernel.org Subject: [PATCH 01/13] PCI: xilinx: Replace device * with platform_device * Date: Sat, 27 Nov 2021 15:11:09 +0100 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some PCI controller struct contain "device *", while others contain "platform_device *". Unify "device *dev" to "platform_device *pdev" in "struct xilinx_pcie", because PCI controllers interact with platform_device directly, not device, to enumerate the controlled device. Signed-off-by: Fan Fei --- drivers/pci/controller/pcie-xilinx.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c index 1e7928d81a05..9137e440b4d3 100644 --- a/drivers/pci/controller/pcie-xilinx.c +++ b/drivers/pci/controller/pcie-xilinx.c @@ -101,8 +101,8 @@ * @resources: Bus Resources */ struct xilinx_pcie { + struct platform_device *pdev; void __iomem *reg_base; - struct device *dev; unsigned long msi_map[BITS_TO_LONGS(XILINX_NUM_MSI_IRQS)]; struct mutex map_lock; struct irq_domain *msi_domain; @@ -132,7 +132,7 @@ static inline bool xilinx_pcie_link_up(struct xilinx_pcie *pcie) */ static void xilinx_pcie_clear_err_interrupts(struct xilinx_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; unsigned long val = pcie_read(pcie, XILINX_PCIE_REG_RPEFR); if (val & XILINX_PCIE_RPEFR_ERR_VALID) { @@ -277,20 +277,21 @@ static struct msi_domain_info xilinx_msi_info = { static int xilinx_allocate_msi_domains(struct xilinx_pcie *pcie) { - struct fwnode_handle *fwnode = dev_fwnode(pcie->dev); + struct device *dev = &pcie->pdev->dev; + struct fwnode_handle *fwnode = dev_fwnode(dev); struct irq_domain *parent; parent = irq_domain_create_linear(fwnode, XILINX_NUM_MSI_IRQS, &xilinx_msi_domain_ops, pcie); if (!parent) { - dev_err(pcie->dev, "failed to create IRQ domain\n"); + dev_err(dev, "failed to create IRQ domain\n"); return -ENOMEM; } irq_domain_update_bus_token(parent, DOMAIN_BUS_NEXUS); pcie->msi_domain = pci_msi_create_irq_domain(fwnode, &xilinx_msi_info, parent); if (!pcie->msi_domain) { - dev_err(pcie->dev, "failed to create MSI domain\n"); + dev_err(dev, "failed to create MSI domain\n"); irq_domain_remove(parent); return -ENOMEM; } @@ -343,7 +344,7 @@ static const struct irq_domain_ops intx_domain_ops = { static irqreturn_t xilinx_pcie_intr_handler(int irq, void *data) { struct xilinx_pcie *pcie = (struct xilinx_pcie *)data; - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; u32 val, mask, status; /* Read interrupt decode and mask registers */ @@ -455,7 +456,7 @@ static irqreturn_t xilinx_pcie_intr_handler(int irq, void *data) */ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct device_node *pcie_intc_node; int ret; @@ -496,7 +497,7 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie *pcie) */ static void xilinx_pcie_init_port(struct xilinx_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; if (xilinx_pcie_link_up(pcie)) dev_info(dev, "PCIe Link is UP\n"); @@ -529,7 +530,7 @@ static void xilinx_pcie_init_port(struct xilinx_pcie *pcie) */ static int xilinx_pcie_parse_dt(struct xilinx_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct device_node *node = dev->of_node; struct resource regs; unsigned int irq; @@ -579,7 +580,7 @@ static int xilinx_pcie_probe(struct platform_device *pdev) pcie = pci_host_bridge_priv(bridge); mutex_init(&pcie->map_lock); - pcie->dev = dev; + pcie->pdev = pdev; err = xilinx_pcie_parse_dt(pcie); if (err) { From patchwork Sat Nov 27 14:11:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Fei X-Patchwork-Id: 12642255 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 C9D71C433FE for ; Sat, 27 Nov 2021 14:16:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343494AbhK0OT1 (ORCPT ); Sat, 27 Nov 2021 09:19:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355256AbhK0OR1 (ORCPT ); Sat, 27 Nov 2021 09:17:27 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 943BDC0613DD for ; Sat, 27 Nov 2021 06:11:30 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id 133so10513099wme.0 for ; Sat, 27 Nov 2021 06:11:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LmWjHjdGbQoIJfyKhc/exaHghcRqYp973teYZWWGz8M=; b=XflV2PrRsGZW06woAOgpKprsZHn/64NG+PmhffRkptVWjQV/qYz+bMOUxVBEBPCDWU 7FToM+kbDiA0oG0IjGjp5ojZL3j1+5v7JhvqOV3FETlUIUV7NRIoLIvtUqocj9J1Lpw2 Dy59Kg7rj7fR6gNMDrOe/1y9KoJRxbJZtClJYXmHw/wF071EEGPkf8S5J4e+/RZstdXT 7GJDErzS/xUcYfebfFgSL526KWOUGoZdDz2YVNfBP+fMRLFB+lOYzUVn0wGj5c18za0S ysg+B+SLqzVWLnvv73KZh35nnclkne2/DgsNCGA19ov20YxRs5X/49sNxxjh4MF5ix6A vMpw== 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=LmWjHjdGbQoIJfyKhc/exaHghcRqYp973teYZWWGz8M=; b=oDKxR2VdJ5YItjSQlSfquEhWPK492qnG6b2KTo+Hx0OZ5Xhl6779erojSU6nUlCmZg oIyB6J1y7zYan5IVvXzYoSDzrwD0ojfnDeQPYMjcjOvaDp1CYu9A5UI1v79M/mWoQmqC ox2SVsKrLA3dCBR9A5To5aXsfgBeTOlfjU9TlSdqmvA/lPGQG+2jCfG4xiDyrXHitgxb iBo6Cebd/ymA+qSKV+Wv/AGSh3eXlla5T8UfmBal7elrbTt3VZeYlac7x265mFnfSOO3 fcPAZMUASG1QHciKkfJCIBt48PwSarK7RAxFeNwMXHsjHyly3GFXEQ9pFTgcDlzUzFCA DXYA== X-Gm-Message-State: AOAM531K5K9HA3z2u2ejGW1wdlYwx1rdPfS+/u6lQn7E2AzXSI2UFYZt VmdgcBai81RxSMeVSaHHPQ3IpPXE969kcQ== X-Google-Smtp-Source: ABdhPJyslNT+I+sJlkbEkCguIK7n7Vwea0YGiB9RpRvyv9lVWnQXa8gSwBiHYA4DaeK7Aq3hhF4lPg== X-Received: by 2002:a1c:9d48:: with SMTP id g69mr23642406wme.188.1638022289115; Sat, 27 Nov 2021 06:11:29 -0800 (PST) Received: from claire-ThinkPad-T470.localdomain (dynamic-2a01-0c22-7349-1000-d163-c2fa-698a-934f.c22.pool.telefonica.de. [2a01:c22:7349:1000:d163:c2fa:698a:934f]) by smtp.gmail.com with ESMTPSA id q26sm8754522wrc.39.2021.11.27.06.11.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Nov 2021 06:11:28 -0800 (PST) From: Fan Fei To: bjorn@helgaas.com Cc: Fan Fei , linux-pci@vger.kernel.org Subject: [PATCH 02/13] PCI: mediatek: Replace device * with platform_device * Date: Sat, 27 Nov 2021 15:11:10 +0100 Message-Id: <30848bb62fc3854bf5d800fba51bb60f8897dc79.1638022049.git.ffclaire1224@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some PCI controller struct contain "device *", while others contain "platform_device *". Unify "device *dev" to "platform_device *pdev" in struct mediatek_pcie, because PCI controllers interact with platform_device directly, not device, to enumerate the controlled device. Signed-off-by: Fan Fei --- drivers/pci/controller/pcie-mediatek.c | 31 +++++++++++++------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c index 2f3f974977a3..9e49d3ee9cff 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c @@ -216,7 +216,7 @@ struct mtk_pcie_port { * @soc: pointer to SoC-dependent operations */ struct mtk_pcie { - struct device *dev; + struct platform_device *pdev; void __iomem *base; struct regmap *cfg; struct clk *free_ck; @@ -227,7 +227,7 @@ struct mtk_pcie { static void mtk_pcie_subsys_powerdown(struct mtk_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; clk_disable_unprepare(pcie->free_ck); @@ -238,7 +238,7 @@ static void mtk_pcie_subsys_powerdown(struct mtk_pcie *pcie) static void mtk_pcie_port_free(struct mtk_pcie_port *port) { struct mtk_pcie *pcie = port->pcie; - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; devm_iounmap(dev, port->base); list_del(&port->list); @@ -410,7 +410,7 @@ static void mtk_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) msg->data = data->hwirq; - dev_dbg(port->pcie->dev, "msi#%d address_hi %#x address_lo %#x\n", + dev_dbg(&port->pcie->pdev->dev, "msi#%d address_hi %#x address_lo %#x\n", (int)data->hwirq, msg->address_hi, msg->address_lo); } @@ -470,7 +470,7 @@ static void mtk_pcie_irq_domain_free(struct irq_domain *domain, mutex_lock(&port->lock); if (!test_bit(d->hwirq, port->msi_irq_in_use)) - dev_err(port->pcie->dev, "trying to free unused MSI#%lu\n", + dev_err(&port->pcie->pdev->dev, "trying to free unused MSI#%lu\n", d->hwirq); else __clear_bit(d->hwirq, port->msi_irq_in_use); @@ -500,21 +500,22 @@ static struct msi_domain_info mtk_msi_domain_info = { static int mtk_pcie_allocate_msi_domains(struct mtk_pcie_port *port) { - struct fwnode_handle *fwnode = of_node_to_fwnode(port->pcie->dev->of_node); + struct device *dev = &port->pcie->pdev->dev; + struct fwnode_handle *fwnode = of_node_to_fwnode(dev->of_node); mutex_init(&port->lock); port->inner_domain = irq_domain_create_linear(fwnode, MTK_MSI_IRQS_NUM, &msi_domain_ops, port); if (!port->inner_domain) { - dev_err(port->pcie->dev, "failed to create IRQ domain\n"); + dev_err(dev, "failed to create IRQ domain\n"); return -ENOMEM; } port->msi_domain = pci_msi_create_irq_domain(fwnode, &mtk_msi_domain_info, port->inner_domain); if (!port->msi_domain) { - dev_err(port->pcie->dev, "failed to create MSI domain\n"); + dev_err(dev, "failed to create MSI domain\n"); irq_domain_remove(port->inner_domain); return -ENOMEM; } @@ -573,7 +574,7 @@ static const struct irq_domain_ops intx_domain_ops = { static int mtk_pcie_init_irq_domain(struct mtk_pcie_port *port, struct device_node *node) { - struct device *dev = port->pcie->dev; + struct device *dev = &port->pcie->pdev->dev; struct device_node *pcie_intc_node; int ret; @@ -640,7 +641,7 @@ static int mtk_pcie_setup_irq(struct mtk_pcie_port *port, struct device_node *node) { struct mtk_pcie *pcie = port->pcie; - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct platform_device *pdev = to_platform_device(dev); int err; @@ -830,7 +831,7 @@ static int mtk_pcie_startup_port(struct mtk_pcie_port *port) static void mtk_pcie_enable_port(struct mtk_pcie_port *port) { struct mtk_pcie *pcie = port->pcie; - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; int err; err = clk_prepare_enable(port->sys_ck); @@ -913,7 +914,7 @@ static int mtk_pcie_parse_port(struct mtk_pcie *pcie, int slot) { struct mtk_pcie_port *port; - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct platform_device *pdev = to_platform_device(dev); char name[10]; int err; @@ -990,7 +991,7 @@ static int mtk_pcie_parse_port(struct mtk_pcie *pcie, static int mtk_pcie_subsys_powerup(struct mtk_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct platform_device *pdev = to_platform_device(dev); struct resource *regs; struct device_node *cfg_node; @@ -1041,7 +1042,7 @@ static int mtk_pcie_subsys_powerup(struct mtk_pcie *pcie) static int mtk_pcie_setup(struct mtk_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct device_node *node = dev->of_node, *child; struct mtk_pcie_port *port, *tmp; int err, slot; @@ -1098,7 +1099,7 @@ static int mtk_pcie_probe(struct platform_device *pdev) pcie = pci_host_bridge_priv(host); - pcie->dev = dev; + pcie->pdev = pdev; pcie->soc = of_device_get_match_data(dev); platform_set_drvdata(pdev, pcie); INIT_LIST_HEAD(&pcie->ports); From patchwork Sat Nov 27 14:11:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Fei X-Patchwork-Id: 12642259 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 35407C433EF for ; Sat, 27 Nov 2021 14:16:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355185AbhK0OTs (ORCPT ); Sat, 27 Nov 2021 09:19:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235578AbhK0ORs (ORCPT ); Sat, 27 Nov 2021 09:17:48 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63585C0613E0 for ; Sat, 27 Nov 2021 06:11:32 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id d24so25242435wra.0 for ; Sat, 27 Nov 2021 06:11:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hal5HBf331WxcFEjxYYk3KDXF8ioOIwrN0pArUimBtk=; b=X4DmXatczhHdWgH3HfZvs2MgXJ/PLx7qFsCWXaJN2x5IOdyNCwOggPv8nroX+G3q1x h57Wjq6Orj5etbk/by9kII9pop5kw8piE2XXm22ghKk1pK+PCbnztMd7o3hnPxXDGr5Q EBI223qFmv5IobgTSM0JJ1KD+OOmw6AS5J/hIxkTVRgPQh8Wg9TSaBdTm+jR86ean0+/ AWMjhJz4m1NVPlQP6qm+Km10hDbi8EU0qTAs+YXB4HRXQFghfantSvSejrQsh8wnEXBg sB0qMnb6+yIoSqEUIOnE0CLDRKCmmH4tptk7SgGCJ6j2O+QCSBs1huJiBZ6OxOXcplxT JkTw== 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=Hal5HBf331WxcFEjxYYk3KDXF8ioOIwrN0pArUimBtk=; b=t+Ms+fGaGJhJ5dyVKUxBdz4d5f+MZfpwmOZx0rrjV++ETMEDYxwJIVd5SrmR6Vfs3U pWN5UJtFLAoKCB88JRi48kPMbmQMj78Dk6or4qYUDhSIRBJUbiv6g+EYNlf1xzPVJvoR NMQ4jylxIRd5fvXsfaAJ4LP7L1oVBE+kgAaUWPpUQRALCyKUAX/RMDMAs8tr5YopKjFi 9wr7l1zln0yIVSzH4HwUFNyDADM1+lcJ2IKmWyhSUr3Ls5MAuv7/pDkHT95X0EkKReJx jsCGIXZYfrpZX7jZtqsr/3rQxvuM0CXkerHOtNfDs47PUajCVKptY9XwCLlTvjYhT4mm bJYg== X-Gm-Message-State: AOAM532U3+H2gysRZKfGufovVUAi+Xyt2VMdVh/I+xr+DmL2ODg3yfRw QMJ4kNqE7oX04IPXoPwfemM= X-Google-Smtp-Source: ABdhPJyThSz9NmWJCNhb4T5bUBuCc+wBzEa0OzJ61QwBJzoIXbBIDLEoVu6jKBdfqDeOQte9JkVXig== X-Received: by 2002:a05:6000:1787:: with SMTP id e7mr20853247wrg.433.1638022290815; Sat, 27 Nov 2021 06:11:30 -0800 (PST) Received: from claire-ThinkPad-T470.localdomain (dynamic-2a01-0c22-7349-1000-d163-c2fa-698a-934f.c22.pool.telefonica.de. [2a01:c22:7349:1000:d163:c2fa:698a:934f]) by smtp.gmail.com with ESMTPSA id q26sm8754522wrc.39.2021.11.27.06.11.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Nov 2021 06:11:30 -0800 (PST) From: Fan Fei To: bjorn@helgaas.com Cc: Fan Fei , linux-pci@vger.kernel.org Subject: [PATCH 03/13] PCI: tegra: Replace device * with platform_device * Date: Sat, 27 Nov 2021 15:11:11 +0100 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some PCI controller struct contain "device *", while others contain "platform_device *". Unify "device *dev" to "platform_device *pdev" in struct tegra_pcie, because PCI controllers interact with platform_device directly, not device, to enumerate the controlled device. Signed-off-by: Fan Fei --- drivers/pci/controller/pci-tegra.c | 85 +++++++++++++++--------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c index cb0aa65d6934..0dce4c303db7 100644 --- a/drivers/pci/controller/pci-tegra.c +++ b/drivers/pci/controller/pci-tegra.c @@ -320,7 +320,7 @@ struct tegra_pcie_soc { }; struct tegra_pcie { - struct device *dev; + struct platform_device *pdev; void __iomem *pads; void __iomem *afi; @@ -714,7 +714,7 @@ static void tegra_pcie_port_disable(struct tegra_pcie_port *port) static void tegra_pcie_port_free(struct tegra_pcie_port *port) { struct tegra_pcie *pcie = port->pcie; - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; devm_iounmap(dev, port->base); devm_release_mem_region(dev, port->regs.start, @@ -777,7 +777,7 @@ static irqreturn_t tegra_pcie_isr(int irq, void *arg) "Peer2Peer error", }; struct tegra_pcie *pcie = arg; - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; u32 code, signature; code = afi_readl(pcie, AFI_INTR_CODE) & AFI_INTR_CODE_MASK; @@ -909,7 +909,7 @@ static int tegra_pcie_pll_wait(struct tegra_pcie *pcie, unsigned long timeout) static int tegra_pcie_phy_enable(struct tegra_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; const struct tegra_pcie_soc *soc = pcie->soc; u32 value; int err; @@ -990,7 +990,7 @@ static int tegra_pcie_phy_disable(struct tegra_pcie *pcie) static int tegra_pcie_port_phy_power_on(struct tegra_pcie_port *port) { - struct device *dev = port->pcie->dev; + struct device *dev = &port->pcie->pdev->dev; unsigned int i; int err; @@ -1007,7 +1007,7 @@ static int tegra_pcie_port_phy_power_on(struct tegra_pcie_port *port) static int tegra_pcie_port_phy_power_off(struct tegra_pcie_port *port) { - struct device *dev = port->pcie->dev; + struct device *dev = &port->pcie->pdev->dev; unsigned int i; int err; @@ -1025,7 +1025,7 @@ static int tegra_pcie_port_phy_power_off(struct tegra_pcie_port *port) static int tegra_pcie_phy_power_on(struct tegra_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct tegra_pcie_port *port; int err; @@ -1056,7 +1056,7 @@ static int tegra_pcie_phy_power_on(struct tegra_pcie *pcie) static int tegra_pcie_phy_power_off(struct tegra_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct tegra_pcie_port *port; int err; @@ -1151,7 +1151,7 @@ static void tegra_pcie_enable_controller(struct tegra_pcie *pcie) static void tegra_pcie_power_off(struct tegra_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; const struct tegra_pcie_soc *soc = pcie->soc; int err; @@ -1172,7 +1172,7 @@ static void tegra_pcie_power_off(struct tegra_pcie *pcie) static int tegra_pcie_power_on(struct tegra_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; const struct tegra_pcie_soc *soc = pcie->soc; int err; @@ -1252,7 +1252,7 @@ static void tegra_pcie_apply_pad_settings(struct tegra_pcie *pcie) static int tegra_pcie_clocks_get(struct tegra_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; const struct tegra_pcie_soc *soc = pcie->soc; pcie->pex_clk = devm_clk_get(dev, "pex"); @@ -1278,7 +1278,7 @@ static int tegra_pcie_clocks_get(struct tegra_pcie *pcie) static int tegra_pcie_resets_get(struct tegra_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; pcie->pex_rst = devm_reset_control_get_exclusive(dev, "pex"); if (IS_ERR(pcie->pex_rst)) @@ -1297,7 +1297,7 @@ static int tegra_pcie_resets_get(struct tegra_pcie *pcie) static int tegra_pcie_phys_get_legacy(struct tegra_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; int err; pcie->phy = devm_phy_optional_get(dev, "pcie"); @@ -1341,7 +1341,7 @@ static struct phy *devm_of_phy_optional_get_index(struct device *dev, static int tegra_pcie_port_get_phys(struct tegra_pcie_port *port) { - struct device *dev = port->pcie->dev; + struct device *dev = &port->pcie->pdev->dev; struct phy *phy; unsigned int i; int err; @@ -1374,7 +1374,7 @@ static int tegra_pcie_port_get_phys(struct tegra_pcie_port *port) static int tegra_pcie_phys_get(struct tegra_pcie *pcie) { const struct tegra_pcie_soc *soc = pcie->soc; - struct device_node *np = pcie->dev->of_node; + struct device_node *np = pcie->pdev->dev.of_node; struct tegra_pcie_port *port; int err; @@ -1393,7 +1393,7 @@ static int tegra_pcie_phys_get(struct tegra_pcie *pcie) static void tegra_pcie_phys_put(struct tegra_pcie *pcie) { struct tegra_pcie_port *port; - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; int err, i; if (pcie->legacy_phy) { @@ -1415,8 +1415,8 @@ static void tegra_pcie_phys_put(struct tegra_pcie *pcie) static int tegra_pcie_get_resources(struct tegra_pcie *pcie) { - struct device *dev = pcie->dev; - struct platform_device *pdev = to_platform_device(dev); + struct platform_device *pdev = pcie->pdev; + struct device *dev = &pdev->dev; struct resource *res; const struct tegra_pcie_soc *soc = pcie->soc; int err; @@ -1522,7 +1522,7 @@ static void tegra_pcie_pme_turnoff(struct tegra_pcie_port *port) err = readl_poll_timeout(pcie->afi + AFI_PCIE_PME, val, val & (0x1 << ack_bit), 1, PME_ACK_TIMEOUT); if (err) - dev_err(pcie->dev, "PME Ack is not received on port: %d\n", + dev_err(&pcie->pdev->dev, "PME Ack is not received on port: %d\n", port->index); usleep_range(10000, 11000); @@ -1537,7 +1537,7 @@ static void tegra_pcie_msi_irq(struct irq_desc *desc) struct tegra_pcie *pcie = irq_desc_get_handler_data(desc); struct irq_chip *chip = irq_desc_get_chip(desc); struct tegra_msi *msi = &pcie->msi; - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; unsigned int i; chained_irq_enter(chip, desc); @@ -1708,20 +1708,21 @@ static struct msi_domain_info tegra_msi_info = { static int tegra_allocate_domains(struct tegra_msi *msi) { struct tegra_pcie *pcie = msi_to_pcie(msi); - struct fwnode_handle *fwnode = dev_fwnode(pcie->dev); + struct device *dev = &pcie->pdev->dev; + struct fwnode_handle *fwnode = dev_fwnode(dev); struct irq_domain *parent; parent = irq_domain_create_linear(fwnode, INT_PCI_MSI_NR, &tegra_msi_domain_ops, msi); if (!parent) { - dev_err(pcie->dev, "failed to create IRQ domain\n"); + dev_err(dev, "failed to create IRQ domain\n"); return -ENOMEM; } irq_domain_update_bus_token(parent, DOMAIN_BUS_NEXUS); msi->domain = pci_msi_create_irq_domain(fwnode, &tegra_msi_info, parent); if (!msi->domain) { - dev_err(pcie->dev, "failed to create MSI domain\n"); + dev_err(dev, "failed to create MSI domain\n"); irq_domain_remove(parent); return -ENOMEM; } @@ -1739,9 +1740,9 @@ static void tegra_free_domains(struct tegra_msi *msi) static int tegra_pcie_msi_setup(struct tegra_pcie *pcie) { - struct platform_device *pdev = to_platform_device(pcie->dev); + struct platform_device *pdev = pcie->pdev; + struct device *dev = &pdev->dev; struct tegra_msi *msi = &pcie->msi; - struct device *dev = pcie->dev; int err; mutex_init(&msi->map_lock); @@ -1819,7 +1820,7 @@ static void tegra_pcie_msi_teardown(struct tegra_pcie *pcie) struct tegra_msi *msi = &pcie->msi; unsigned int i, irq; - dma_free_attrs(pcie->dev, PAGE_SIZE, msi->virt, msi->phys, + dma_free_attrs(&pcie->pdev->dev, PAGE_SIZE, msi->virt, msi->phys, DMA_ATTR_NO_KERNEL_MAPPING); for (i = 0; i < INT_PCI_MSI_NR; i++) { @@ -1858,7 +1859,7 @@ static void tegra_pcie_disable_interrupts(struct tegra_pcie *pcie) static int tegra_pcie_get_xbar_config(struct tegra_pcie *pcie, u32 lanes, u32 *xbar) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct device_node *np = dev->of_node; if (of_device_is_compatible(np, "nvidia,tegra186-pcie")) { @@ -1963,7 +1964,7 @@ static bool of_regulator_bulk_available(struct device_node *np, */ static int tegra_pcie_get_legacy_regulators(struct tegra_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct device_node *np = dev->of_node; if (of_device_is_compatible(np, "nvidia,tegra30-pcie")) @@ -2002,14 +2003,14 @@ static int tegra_pcie_get_legacy_regulators(struct tegra_pcie *pcie) */ static int tegra_pcie_get_regulators(struct tegra_pcie *pcie, u32 lane_mask) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct device_node *np = dev->of_node; unsigned int i = 0; if (of_device_is_compatible(np, "nvidia,tegra186-pcie")) { pcie->num_supplies = 4; - pcie->supplies = devm_kcalloc(pcie->dev, pcie->num_supplies, + pcie->supplies = devm_kcalloc(dev, pcie->num_supplies, sizeof(*pcie->supplies), GFP_KERNEL); if (!pcie->supplies) @@ -2022,7 +2023,7 @@ static int tegra_pcie_get_regulators(struct tegra_pcie *pcie, u32 lane_mask) } else if (of_device_is_compatible(np, "nvidia,tegra210-pcie")) { pcie->num_supplies = 3; - pcie->supplies = devm_kcalloc(pcie->dev, pcie->num_supplies, + pcie->supplies = devm_kcalloc(dev, pcie->num_supplies, sizeof(*pcie->supplies), GFP_KERNEL); if (!pcie->supplies) @@ -2114,7 +2115,7 @@ static int tegra_pcie_get_regulators(struct tegra_pcie *pcie, u32 lane_mask) static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct device_node *np = dev->of_node, *port; const struct tegra_pcie_soc *soc = pcie->soc; u32 lanes = 0, mask = 0; @@ -2245,7 +2246,7 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) #define TEGRA_PCIE_LINKUP_TIMEOUT 200 /* up to 1.2 seconds */ static bool tegra_pcie_port_check_link(struct tegra_pcie_port *port) { - struct device *dev = port->pcie->dev; + struct device *dev = &port->pcie->pdev->dev; unsigned int retries = 3; unsigned long value; @@ -2292,7 +2293,7 @@ static bool tegra_pcie_port_check_link(struct tegra_pcie_port *port) static void tegra_pcie_change_link_speed(struct tegra_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct tegra_pcie_port *port; ktime_t deadline; u32 value; @@ -2350,7 +2351,7 @@ static void tegra_pcie_change_link_speed(struct tegra_pcie *pcie) static void tegra_pcie_enable_ports(struct tegra_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct tegra_pcie_port *port, *tmp; list_for_each_entry_safe(port, tmp, &pcie->ports, list) { @@ -2634,7 +2635,7 @@ static int tegra_pcie_probe(struct platform_device *pdev) pcie->soc = of_device_get_match_data(dev); INIT_LIST_HEAD(&pcie->ports); - pcie->dev = dev; + pcie->pdev = pdev; err = tegra_pcie_parse_dt(pcie); if (err < 0) @@ -2652,8 +2653,8 @@ static int tegra_pcie_probe(struct platform_device *pdev) goto put_resources; } - pm_runtime_enable(pcie->dev); - err = pm_runtime_get_sync(pcie->dev); + pm_runtime_enable(&pcie->pdev->dev); + err = pm_runtime_get_sync(&pcie->pdev->dev); if (err < 0) { dev_err(dev, "fail to enable pcie controller: %d\n", err); goto pm_runtime_put; @@ -2674,8 +2675,8 @@ static int tegra_pcie_probe(struct platform_device *pdev) return 0; pm_runtime_put: - pm_runtime_put_sync(pcie->dev); - pm_runtime_disable(pcie->dev); + pm_runtime_put_sync(&pcie->pdev->dev); + pm_runtime_disable(&pcie->pdev->dev); tegra_pcie_msi_teardown(pcie); put_resources: tegra_pcie_put_resources(pcie); @@ -2693,8 +2694,8 @@ static int tegra_pcie_remove(struct platform_device *pdev) pci_stop_root_bus(host->bus); pci_remove_root_bus(host->bus); - pm_runtime_put_sync(pcie->dev); - pm_runtime_disable(pcie->dev); + pm_runtime_put_sync(&pcie->pdev->dev); + pm_runtime_disable(&pcie->pdev->dev); if (IS_ENABLED(CONFIG_PCI_MSI)) tegra_pcie_msi_teardown(pcie); From patchwork Sat Nov 27 14:11:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Fei X-Patchwork-Id: 12642261 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 83F10C433FE for ; Sat, 27 Nov 2021 14:16:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235578AbhK0OTt (ORCPT ); Sat, 27 Nov 2021 09:19:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233105AbhK0ORs (ORCPT ); Sat, 27 Nov 2021 09:17:48 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CAF7C0613E1 for ; Sat, 27 Nov 2021 06:11:34 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id q3so2334587wru.5 for ; Sat, 27 Nov 2021 06:11:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AEVHP1Z7SXziMrmDguErfOjl2Wgj4B31N+1BfgHsn/U=; b=pXpCZegAvrkl+3je5xwGq4D3det+7TlmeoHF7AjL0WKB0MlQ67TjbOo9ClwNo7zh3l JQu66pwZsoovlBH5Uqj+g49y3FrQAJnXGu/bk2ZILDNQovhcJmB9UPNHBFjMWSWnFOEY nIE5iHd8uFKqrDzzH2P4RgJHFBLcmNogKAVzRZi7hZNX8QuADZpYs1np3TbVNN59kilv +6tXiFC9EXG3IXZzCbK3Lg+Ubxr5wChUCcyWohu1NLs5oAiJDqqFqPS0lbhm/PA5PYGb qDIibNMLOowNrHzroFQ07izdB2PIPOYN4U0iQq3Mb76lwyOQmyEd7dutwMvk8idzrGX8 oa/g== 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=AEVHP1Z7SXziMrmDguErfOjl2Wgj4B31N+1BfgHsn/U=; b=sIZlG9V5lwCb2L29OdLcSC5x6lLqr/1RQmyzVCKHne48l9gwece2HqgEqgq2V5eKX1 e7rm8tgMP/Dzk7uwchkGqr1yVO0hcpeab65+qS3bWtFhWmDsDWACs+uGU1i8DBb6F+zY oEOPGZCfgL/akncM83qiG0NqU8mimrOyiSikUs20KHH4KrSCYbO6qNs6K8Co25qvWhSr 92idZNc69BdN6rrAFvEpyaVkZACrXlj82gzIorSruce3ttuV+89GIsjd9n84I5Uzwz3I SJI46ipckHhUHmtLJpEHLvIE/blnf3CdELQSnsMFOTdbbEXcOXyZqUSsHlW6rhVz1/xQ WUUQ== X-Gm-Message-State: AOAM532p8oM0roLD7sWU/gRVGKzrOrKaxUTT/ceMylwMAwMKEcOQtRkS j6zWavZlUXEzmnzc2K56u2w= X-Google-Smtp-Source: ABdhPJxNvYM+onzR5frLegIltIq3rRh0Qnli2Jj6QLVjbYniqGXXF+uKJn4C4+YQGBNZbjMnrPc1Dw== X-Received: by 2002:a5d:50c7:: with SMTP id f7mr20179386wrt.327.1638022292438; Sat, 27 Nov 2021 06:11:32 -0800 (PST) Received: from claire-ThinkPad-T470.localdomain (dynamic-2a01-0c22-7349-1000-d163-c2fa-698a-934f.c22.pool.telefonica.de. [2a01:c22:7349:1000:d163:c2fa:698a:934f]) by smtp.gmail.com with ESMTPSA id q26sm8754522wrc.39.2021.11.27.06.11.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Nov 2021 06:11:32 -0800 (PST) From: Fan Fei To: bjorn@helgaas.com Cc: Fan Fei , linux-pci@vger.kernel.org Subject: [PATCH 04/13] PCI: xegene: Replace device * with platform_device * Date: Sat, 27 Nov 2021 15:11:12 +0100 Message-Id: <273bcf128fa16901a51f4143ff291e52905d0703.1638022049.git.ffclaire1224@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some PCI controller struct contain "device *", while others contain "platform_device *". Unify "device *dev" to "platform_device *pdev" in struct xgene_pcie, because PCI controllers interact with platform_device directly, not device, to enumerate the controlled device. Signed-off-by: Fan Fei --- drivers/pci/controller/pci-xgene.c | 222 ++++++++++++++--------------- 1 file changed, 111 insertions(+), 111 deletions(-) diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c index ba11f369a1c9..f66abd60058b 100644 --- a/drivers/pci/controller/pci-xgene.c +++ b/drivers/pci/controller/pci-xgene.c @@ -61,8 +61,8 @@ #if defined(CONFIG_PCI_XGENE) || (defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS)) struct xgene_pcie { + struct platform_device *pdev; struct device_node *node; - struct device *dev; struct clk *clk; void __iomem *csr_base; void __iomem *cfg_base; @@ -71,14 +71,14 @@ struct xgene_pcie { u32 version; }; -static u32 xgene_pcie_readl(struct xgene_pcie *port, u32 reg) +static u32 xgene_pcie_readl(struct xgene_pcie *pcie, u32 reg) { - return readl(port->csr_base + reg); + return readl(pcie->csr_base + reg); } -static void xgene_pcie_writel(struct xgene_pcie *port, u32 reg, u32 val) +static void xgene_pcie_writel(struct xgene_pcie *pcie, u32 reg, u32 val) { - writel(val, port->csr_base + reg); + writel(val, pcie->csr_base + reg); } static inline u32 pcie_bar_low_val(u32 addr, u32 flags) @@ -103,12 +103,12 @@ static inline struct xgene_pcie *pcie_bus_to_port(struct pci_bus *bus) */ static void __iomem *xgene_pcie_get_cfg_base(struct pci_bus *bus) { - struct xgene_pcie *port = pcie_bus_to_port(bus); + struct xgene_pcie *pcie = pcie_bus_to_port(bus); if (bus->number >= (bus->primary + 1)) - return port->cfg_base + AXI_EP_CFG_ACCESS; + return pcie->cfg_base + AXI_EP_CFG_ACCESS; - return port->cfg_base; + return pcie->cfg_base; } /* @@ -117,7 +117,7 @@ static void __iomem *xgene_pcie_get_cfg_base(struct pci_bus *bus) */ static void xgene_pcie_set_rtdid_reg(struct pci_bus *bus, uint devfn) { - struct xgene_pcie *port = pcie_bus_to_port(bus); + struct xgene_pcie *pcie = pcie_bus_to_port(bus); unsigned int b, d, f; u32 rtdid_val = 0; @@ -128,9 +128,9 @@ static void xgene_pcie_set_rtdid_reg(struct pci_bus *bus, uint devfn) if (!pci_is_root_bus(bus)) rtdid_val = (b << 8) | (d << 3) | f; - xgene_pcie_writel(port, RTDID, rtdid_val); + xgene_pcie_writel(pcie, RTDID, rtdid_val); /* read the register back to ensure flush */ - xgene_pcie_readl(port, RTDID); + xgene_pcie_readl(pcie, RTDID); } /* @@ -164,7 +164,7 @@ static void __iomem *xgene_pcie_map_bus(struct pci_bus *bus, unsigned int devfn, static int xgene_pcie_config_read32(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val) { - struct xgene_pcie *port = pcie_bus_to_port(bus); + struct xgene_pcie *pcie = pcie_bus_to_port(bus); if (pci_generic_config_read32(bus, devfn, where & ~0x3, 4, val) != PCIBIOS_SUCCESSFUL) @@ -180,7 +180,7 @@ static int xgene_pcie_config_read32(struct pci_bus *bus, unsigned int devfn, * the read until it times out. Avoid this by not claiming to * support CRS SV. */ - if (pci_is_root_bus(bus) && (port->version == XGENE_PCIE_IP_VER_1) && + if (pci_is_root_bus(bus) && (pcie->version == XGENE_PCIE_IP_VER_1) && ((where & ~0x3) == XGENE_V1_PCI_EXP_CAP + PCI_EXP_RTCTL)) *val &= ~(PCI_EXP_RTCAP_CRSVIS << 16); @@ -227,12 +227,12 @@ static int xgene_pcie_ecam_init(struct pci_config_window *cfg, u32 ipversion) { struct device *dev = cfg->parent; struct acpi_device *adev = to_acpi_device(dev); - struct xgene_pcie *port; + struct xgene_pcie *pcie; struct resource csr; int ret; - port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL); - if (!port) + pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); + if (!pcie) return -ENOMEM; ret = xgene_get_csr_resource(adev, &csr); @@ -240,14 +240,14 @@ static int xgene_pcie_ecam_init(struct pci_config_window *cfg, u32 ipversion) dev_err(dev, "can't get CSR resource\n"); return ret; } - port->csr_base = devm_pci_remap_cfg_resource(dev, &csr); - if (IS_ERR(port->csr_base)) - return PTR_ERR(port->csr_base); + pcie->csr_base = devm_pci_remap_cfg_resource(dev, &csr); + if (IS_ERR(pcie->csr_base)) + return PTR_ERR(pcie->csr_base); - port->cfg_base = cfg->win; - port->version = ipversion; + pcie->cfg_base = cfg->win; + pcie->version = ipversion; - cfg->priv = port; + cfg->priv = pcie; return 0; } @@ -281,59 +281,59 @@ const struct pci_ecam_ops xgene_v2_pcie_ecam_ops = { #endif #if defined(CONFIG_PCI_XGENE) -static u64 xgene_pcie_set_ib_mask(struct xgene_pcie *port, u32 addr, +static u64 xgene_pcie_set_ib_mask(struct xgene_pcie *pcie, u32 addr, u32 flags, u64 size) { u64 mask = (~(size - 1) & PCI_BASE_ADDRESS_MEM_MASK) | flags; u32 val32 = 0; u32 val; - val32 = xgene_pcie_readl(port, addr); + val32 = xgene_pcie_readl(pcie, addr); val = (val32 & 0x0000ffff) | (lower_32_bits(mask) << 16); - xgene_pcie_writel(port, addr, val); + xgene_pcie_writel(pcie, addr, val); - val32 = xgene_pcie_readl(port, addr + 0x04); + val32 = xgene_pcie_readl(pcie, addr + 0x04); val = (val32 & 0xffff0000) | (lower_32_bits(mask) >> 16); - xgene_pcie_writel(port, addr + 0x04, val); + xgene_pcie_writel(pcie, addr + 0x04, val); - val32 = xgene_pcie_readl(port, addr + 0x04); + val32 = xgene_pcie_readl(pcie, addr + 0x04); val = (val32 & 0x0000ffff) | (upper_32_bits(mask) << 16); - xgene_pcie_writel(port, addr + 0x04, val); + xgene_pcie_writel(pcie, addr + 0x04, val); - val32 = xgene_pcie_readl(port, addr + 0x08); + val32 = xgene_pcie_readl(pcie, addr + 0x08); val = (val32 & 0xffff0000) | (upper_32_bits(mask) >> 16); - xgene_pcie_writel(port, addr + 0x08, val); + xgene_pcie_writel(pcie, addr + 0x08, val); return mask; } -static void xgene_pcie_linkup(struct xgene_pcie *port, +static void xgene_pcie_linkup(struct xgene_pcie *pcie, u32 *lanes, u32 *speed) { u32 val32; - port->link_up = false; - val32 = xgene_pcie_readl(port, PCIECORE_CTLANDSTATUS); + pcie->link_up = false; + val32 = xgene_pcie_readl(pcie, PCIECORE_CTLANDSTATUS); if (val32 & LINK_UP_MASK) { - port->link_up = true; + pcie->link_up = true; *speed = PIPE_PHY_RATE_RD(val32); - val32 = xgene_pcie_readl(port, BRIDGE_STATUS_0); + val32 = xgene_pcie_readl(pcie, BRIDGE_STATUS_0); *lanes = val32 >> 26; } } -static int xgene_pcie_init_port(struct xgene_pcie *port) +static int xgene_pcie_init_port(struct xgene_pcie *pcie) { - struct device *dev = port->dev; + struct device *dev = &pcie->pdev->dev; int rc; - port->clk = clk_get(dev, NULL); - if (IS_ERR(port->clk)) { + pcie->clk = clk_get(dev, NULL); + if (IS_ERR(pcie->clk)) { dev_err(dev, "clock not available\n"); return -ENODEV; } - rc = clk_prepare_enable(port->clk); + rc = clk_prepare_enable(pcie->clk); if (rc) { dev_err(dev, "clock enable failed\n"); return rc; @@ -342,31 +342,31 @@ static int xgene_pcie_init_port(struct xgene_pcie *port) return 0; } -static int xgene_pcie_map_reg(struct xgene_pcie *port, +static int xgene_pcie_map_reg(struct xgene_pcie *pcie, struct platform_device *pdev) { - struct device *dev = port->dev; + struct device *dev = &pdev->dev; struct resource *res; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "csr"); - port->csr_base = devm_pci_remap_cfg_resource(dev, res); - if (IS_ERR(port->csr_base)) - return PTR_ERR(port->csr_base); + pcie->csr_base = devm_pci_remap_cfg_resource(dev, res); + if (IS_ERR(pcie->csr_base)) + return PTR_ERR(pcie->csr_base); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg"); - port->cfg_base = devm_ioremap_resource(dev, res); - if (IS_ERR(port->cfg_base)) - return PTR_ERR(port->cfg_base); - port->cfg_addr = res->start; + pcie->cfg_base = devm_ioremap_resource(dev, res); + if (IS_ERR(pcie->cfg_base)) + return PTR_ERR(pcie->cfg_base); + pcie->cfg_addr = res->start; return 0; } -static void xgene_pcie_setup_ob_reg(struct xgene_pcie *port, +static void xgene_pcie_setup_ob_reg(struct xgene_pcie *pcie, struct resource *res, u32 offset, u64 cpu_addr, u64 pci_addr) { - struct device *dev = port->dev; + struct device *dev = &pcie->pdev->dev; resource_size_t size = resource_size(res); u64 restype = resource_type(res); u64 mask = 0; @@ -386,28 +386,28 @@ static void xgene_pcie_setup_ob_reg(struct xgene_pcie *port, dev_warn(dev, "res size 0x%llx less than minimum 0x%x\n", (u64)size, min_size); - xgene_pcie_writel(port, offset, lower_32_bits(cpu_addr)); - xgene_pcie_writel(port, offset + 0x04, upper_32_bits(cpu_addr)); - xgene_pcie_writel(port, offset + 0x08, lower_32_bits(mask)); - xgene_pcie_writel(port, offset + 0x0c, upper_32_bits(mask)); - xgene_pcie_writel(port, offset + 0x10, lower_32_bits(pci_addr)); - xgene_pcie_writel(port, offset + 0x14, upper_32_bits(pci_addr)); + xgene_pcie_writel(pcie, offset, lower_32_bits(cpu_addr)); + xgene_pcie_writel(pcie, offset + 0x04, upper_32_bits(cpu_addr)); + xgene_pcie_writel(pcie, offset + 0x08, lower_32_bits(mask)); + xgene_pcie_writel(pcie, offset + 0x0c, upper_32_bits(mask)); + xgene_pcie_writel(pcie, offset + 0x10, lower_32_bits(pci_addr)); + xgene_pcie_writel(pcie, offset + 0x14, upper_32_bits(pci_addr)); } -static void xgene_pcie_setup_cfg_reg(struct xgene_pcie *port) +static void xgene_pcie_setup_cfg_reg(struct xgene_pcie *pcie) { - u64 addr = port->cfg_addr; + u64 addr = pcie->cfg_addr; - xgene_pcie_writel(port, CFGBARL, lower_32_bits(addr)); - xgene_pcie_writel(port, CFGBARH, upper_32_bits(addr)); - xgene_pcie_writel(port, CFGCTL, EN_REG); + xgene_pcie_writel(pcie, CFGBARL, lower_32_bits(addr)); + xgene_pcie_writel(pcie, CFGBARH, upper_32_bits(addr)); + xgene_pcie_writel(pcie, CFGCTL, EN_REG); } -static int xgene_pcie_map_ranges(struct xgene_pcie *port) +static int xgene_pcie_map_ranges(struct xgene_pcie *pcie) { - struct pci_host_bridge *bridge = pci_host_bridge_from_priv(port); + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); struct resource_entry *window; - struct device *dev = port->dev; + struct device *dev = &pcie->pdev->dev; resource_list_for_each_entry(window, &bridge->windows) { struct resource *res = window->res; @@ -417,18 +417,18 @@ static int xgene_pcie_map_ranges(struct xgene_pcie *port) switch (restype) { case IORESOURCE_IO: - xgene_pcie_setup_ob_reg(port, res, OMR3BARL, + xgene_pcie_setup_ob_reg(pcie, res, OMR3BARL, pci_pio_to_address(res->start), res->start - window->offset); break; case IORESOURCE_MEM: if (res->flags & IORESOURCE_PREFETCH) - xgene_pcie_setup_ob_reg(port, res, OMR2BARL, + xgene_pcie_setup_ob_reg(pcie, res, OMR2BARL, res->start, res->start - window->offset); else - xgene_pcie_setup_ob_reg(port, res, OMR1BARL, + xgene_pcie_setup_ob_reg(pcie, res, OMR1BARL, res->start, res->start - window->offset); @@ -440,18 +440,18 @@ static int xgene_pcie_map_ranges(struct xgene_pcie *port) return -EINVAL; } } - xgene_pcie_setup_cfg_reg(port); + xgene_pcie_setup_cfg_reg(pcie); return 0; } -static void xgene_pcie_setup_pims(struct xgene_pcie *port, u32 pim_reg, +static void xgene_pcie_setup_pims(struct xgene_pcie *pcie, u32 pim_reg, u64 pim, u64 size) { - xgene_pcie_writel(port, pim_reg, lower_32_bits(pim)); - xgene_pcie_writel(port, pim_reg + 0x04, + xgene_pcie_writel(pcie, pim_reg, lower_32_bits(pim)); + xgene_pcie_writel(pcie, pim_reg + 0x04, upper_32_bits(pim) | EN_COHERENCY); - xgene_pcie_writel(port, pim_reg + 0x10, lower_32_bits(size)); - xgene_pcie_writel(port, pim_reg + 0x14, upper_32_bits(size)); + xgene_pcie_writel(pcie, pim_reg + 0x10, lower_32_bits(size)); + xgene_pcie_writel(pcie, pim_reg + 0x14, upper_32_bits(size)); } /* @@ -478,12 +478,12 @@ static int xgene_pcie_select_ib_reg(u8 *ib_reg_mask, u64 size) return -EINVAL; } -static void xgene_pcie_setup_ib_reg(struct xgene_pcie *port, +static void xgene_pcie_setup_ib_reg(struct xgene_pcie *pcie, struct resource_entry *entry, u8 *ib_reg_mask) { - void __iomem *cfg_base = port->cfg_base; - struct device *dev = port->dev; + void __iomem *cfg_base = pcie->cfg_base; + struct device *dev = &pcie->pdev->dev; void __iomem *bar_addr; u32 pim_reg; u64 cpu_addr = entry->res->start; @@ -506,72 +506,72 @@ static void xgene_pcie_setup_ib_reg(struct xgene_pcie *port, bar_low = pcie_bar_low_val((u32)cpu_addr, flags); switch (region) { case 0: - xgene_pcie_set_ib_mask(port, BRIDGE_CFG_4, flags, size); + xgene_pcie_set_ib_mask(pcie, BRIDGE_CFG_4, flags, size); bar_addr = cfg_base + PCI_BASE_ADDRESS_0; writel(bar_low, bar_addr); writel(upper_32_bits(cpu_addr), bar_addr + 0x4); pim_reg = PIM1_1L; break; case 1: - xgene_pcie_writel(port, IBAR2, bar_low); - xgene_pcie_writel(port, IR2MSK, lower_32_bits(mask)); + xgene_pcie_writel(pcie, IBAR2, bar_low); + xgene_pcie_writel(pcie, IR2MSK, lower_32_bits(mask)); pim_reg = PIM2_1L; break; case 2: - xgene_pcie_writel(port, IBAR3L, bar_low); - xgene_pcie_writel(port, IBAR3L + 0x4, upper_32_bits(cpu_addr)); - xgene_pcie_writel(port, IR3MSKL, lower_32_bits(mask)); - xgene_pcie_writel(port, IR3MSKL + 0x4, upper_32_bits(mask)); + xgene_pcie_writel(pcie, IBAR3L, bar_low); + xgene_pcie_writel(pcie, IBAR3L + 0x4, upper_32_bits(cpu_addr)); + xgene_pcie_writel(pcie, IR3MSKL, lower_32_bits(mask)); + xgene_pcie_writel(pcie, IR3MSKL + 0x4, upper_32_bits(mask)); pim_reg = PIM3_1L; break; } - xgene_pcie_setup_pims(port, pim_reg, pci_addr, ~(size - 1)); + xgene_pcie_setup_pims(pcie, pim_reg, pci_addr, ~(size - 1)); } -static int xgene_pcie_parse_map_dma_ranges(struct xgene_pcie *port) +static int xgene_pcie_parse_map_dma_ranges(struct xgene_pcie *pcie) { - struct pci_host_bridge *bridge = pci_host_bridge_from_priv(port); + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); struct resource_entry *entry; u8 ib_reg_mask = 0; resource_list_for_each_entry(entry, &bridge->dma_ranges) - xgene_pcie_setup_ib_reg(port, entry, &ib_reg_mask); + xgene_pcie_setup_ib_reg(pcie, entry, &ib_reg_mask); return 0; } /* clear BAR configuration which was done by firmware */ -static void xgene_pcie_clear_config(struct xgene_pcie *port) +static void xgene_pcie_clear_config(struct xgene_pcie *pcie) { int i; for (i = PIM1_1L; i <= CFGCTL; i += 4) - xgene_pcie_writel(port, i, 0); + xgene_pcie_writel(pcie, i, 0); } -static int xgene_pcie_setup(struct xgene_pcie *port) +static int xgene_pcie_setup(struct xgene_pcie *pcie) { - struct device *dev = port->dev; + struct device *dev = &pcie->pdev->dev; u32 val, lanes = 0, speed = 0; int ret; - xgene_pcie_clear_config(port); + xgene_pcie_clear_config(pcie); /* setup the vendor and device IDs correctly */ val = (XGENE_PCIE_DEVICEID << 16) | PCI_VENDOR_ID_AMCC; - xgene_pcie_writel(port, BRIDGE_CFG_0, val); + xgene_pcie_writel(pcie, BRIDGE_CFG_0, val); - ret = xgene_pcie_map_ranges(port); + ret = xgene_pcie_map_ranges(pcie); if (ret) return ret; - ret = xgene_pcie_parse_map_dma_ranges(port); + ret = xgene_pcie_parse_map_dma_ranges(pcie); if (ret) return ret; - xgene_pcie_linkup(port, &lanes, &speed); - if (!port->link_up) + xgene_pcie_linkup(pcie, &lanes, &speed); + if (!pcie->link_up) dev_info(dev, "(rc) link down\n"); else dev_info(dev, "(rc) x%d gen-%d link up\n", lanes, speed + 1); @@ -588,36 +588,36 @@ static int xgene_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *dn = dev->of_node; - struct xgene_pcie *port; + struct xgene_pcie *pcie; struct pci_host_bridge *bridge; int ret; - bridge = devm_pci_alloc_host_bridge(dev, sizeof(*port)); + bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie)); if (!bridge) return -ENOMEM; - port = pci_host_bridge_priv(bridge); + pcie = pci_host_bridge_priv(bridge); - port->node = of_node_get(dn); - port->dev = dev; + pcie->node = of_node_get(dn); + pcie->pdev = pdev; - port->version = XGENE_PCIE_IP_VER_UNKN; - if (of_device_is_compatible(port->node, "apm,xgene-pcie")) - port->version = XGENE_PCIE_IP_VER_1; + pcie->version = XGENE_PCIE_IP_VER_UNKN; + if (of_device_is_compatible(pcie->node, "apm,xgene-pcie")) + pcie->version = XGENE_PCIE_IP_VER_1; - ret = xgene_pcie_map_reg(port, pdev); + ret = xgene_pcie_map_reg(pcie, pdev); if (ret) return ret; - ret = xgene_pcie_init_port(port); + ret = xgene_pcie_init_port(pcie); if (ret) return ret; - ret = xgene_pcie_setup(port); + ret = xgene_pcie_setup(pcie); if (ret) return ret; - bridge->sysdata = port; + bridge->sysdata = pcie; bridge->ops = &xgene_pcie_ops; return pci_host_probe(bridge); From patchwork Sat Nov 27 14:11:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Fei X-Patchwork-Id: 12642263 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 0BA66C433F5 for ; Sat, 27 Nov 2021 14:16:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233105AbhK0OTt (ORCPT ); Sat, 27 Nov 2021 09:19:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235744AbhK0ORs (ORCPT ); Sat, 27 Nov 2021 09:17:48 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E0AAC0613ED for ; Sat, 27 Nov 2021 06:11:35 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id n33-20020a05600c502100b0032fb900951eso12792274wmr.4 for ; Sat, 27 Nov 2021 06:11:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XfPUljakp8BCPfOSBPOMugbLtY1riZZ9l3qqzRCJcvY=; b=FwvIoBqtoxl2vIPwkqxs6r86mmpOvx9ZChm6sS20fQObkP1MPpL+/YTTD4dlZVOgtJ ojOyApK8yB31habbl4rr2BZkT6eEN5AxkQNqt7I6BpVz8SiY7Le7jwygQcO6DHcU7Mut SJPOIvxfTlzYwq9+lhYaCHHQefXA6OMNiBpSzF+qygoKBsqqewmimKRkwIY63gRZujMQ xQR06JGuCVcOodwIrqgIO5cdfPfI3Th7MAqusC4UoQgP1gY4RLerHZAHwdqtn5eEIFQl gaT+IVreaMkwajeBnzOC+nzk09dMidFYnmLc8/xOd6sJL0M3sD0+DuKy/csQt6JXJBHM ragg== 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=XfPUljakp8BCPfOSBPOMugbLtY1riZZ9l3qqzRCJcvY=; b=Q/kR23yCKsyY9mNwzT3XMLWdT7tvMG8mJQx11bmJndssYuvHxno8zhZCPMwk5qVjOb AyuOWKcui4d5+kbVin4r/6NkBsBdc0AIKXpnV1oDB7MkVU3O+ZLsqap06q/kD3gmhkrd aOuVvCaqkennm1plb8YZlBwMTAcNJ/vNdz+g9F2h6Yi8y+DGT71UV8cJlvZ3tEATqTtm vEMScZBQCAcdStSp0dPAcSPDEQN2xYpl81dRXDqrB2zxHCIwp6ZFnw4Hf9SCyBMm8X7B vHaXugA2HLVwfm0WTG5H/zjTTRAO4VjFSXm7JXXf/jh4RzF+KHq+EnX+s+BIE8kPdb5g slLg== X-Gm-Message-State: AOAM533gZrlGyb/CJg+cfihg8nA++4DA+HKPfT1Dt10NmIfBUehXerFm fiilKTNjz2Z22mrj8fR8l3346vd1VjSGPg== X-Google-Smtp-Source: ABdhPJyx+UgMMKKuRuOZAcGh6gd+S54bg1M4zu6DmnDLrNhICwSxPzJJhiZbk8T41uFn/8OXKr0seA== X-Received: by 2002:a7b:c38d:: with SMTP id s13mr22851290wmj.12.1638022293892; Sat, 27 Nov 2021 06:11:33 -0800 (PST) Received: from claire-ThinkPad-T470.localdomain (dynamic-2a01-0c22-7349-1000-d163-c2fa-698a-934f.c22.pool.telefonica.de. [2a01:c22:7349:1000:d163:c2fa:698a:934f]) by smtp.gmail.com with ESMTPSA id q26sm8754522wrc.39.2021.11.27.06.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Nov 2021 06:11:33 -0800 (PST) From: Fan Fei To: bjorn@helgaas.com Cc: Fan Fei , linux-pci@vger.kernel.org Subject: [PATCH 05/13] PCI: microchip: Replace device * with platform_device * Date: Sat, 27 Nov 2021 15:11:13 +0100 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some PCI controller struct contain "device *", while others contain "platform_device *". Unify "device *dev" to "platform_device *pdev" in struct mc_port, because PCI controllers interact with platform_device directly, not device, to enumerate the controlled device. Signed-off-by: Fan Fei --- drivers/pci/controller/pcie-microchip-host.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/pci/controller/pcie-microchip-host.c b/drivers/pci/controller/pcie-microchip-host.c index 329f930d17aa..34616546e862 100644 --- a/drivers/pci/controller/pcie-microchip-host.c +++ b/drivers/pci/controller/pcie-microchip-host.c @@ -263,8 +263,8 @@ struct mc_msi { }; struct mc_port { + struct platform_device *pdev; void __iomem *axi_base_addr; - struct device *dev; struct irq_domain *intx_domain; struct irq_domain *event_domain; raw_spinlock_t lock; @@ -406,7 +406,7 @@ static void mc_pcie_enable_msi(struct mc_port *port, void __iomem *base) static void mc_handle_msi(struct irq_desc *desc) { struct mc_port *port = irq_desc_get_handler_data(desc); - struct device *dev = port->dev; + struct device *dev = &port->pdev->dev; struct mc_msi *msi = &port->msi; void __iomem *bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; @@ -450,7 +450,7 @@ static void mc_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) msg->address_hi = upper_32_bits(addr); msg->data = data->hwirq; - dev_dbg(port->dev, "msi#%x address_hi %#x address_lo %#x\n", + dev_dbg(&port->pdev->dev, "msi#%x address_hi %#x address_lo %#x\n", (int)data->hwirq, msg->address_hi, msg->address_lo); } @@ -511,7 +511,7 @@ static void mc_irq_msi_domain_free(struct irq_domain *domain, unsigned int virq, if (test_bit(d->hwirq, msi->used)) __clear_bit(d->hwirq, msi->used); else - dev_err(port->dev, "trying to free unused MSI%lu\n", d->hwirq); + dev_err(&port->pdev->dev, "trying to free unused MSI%lu\n", d->hwirq); mutex_unlock(&msi->lock); } @@ -536,7 +536,7 @@ static struct msi_domain_info mc_msi_domain_info = { static int mc_allocate_msi_domains(struct mc_port *port) { - struct device *dev = port->dev; + struct device *dev = &port->pdev->dev; struct fwnode_handle *fwnode = of_node_to_fwnode(dev->of_node); struct mc_msi *msi = &port->msi; @@ -563,7 +563,7 @@ static int mc_allocate_msi_domains(struct mc_port *port) static void mc_handle_intx(struct irq_desc *desc) { struct mc_port *port = irq_desc_get_handler_data(desc); - struct device *dev = port->dev; + struct device *dev = &port->pdev->dev; void __iomem *bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; unsigned long status; @@ -716,7 +716,7 @@ static u32 get_events(struct mc_port *port) static irqreturn_t mc_event_handler(int irq, void *dev_id) { struct mc_port *port = dev_id; - struct device *dev = port->dev; + struct device *dev = &port->pdev->dev; struct irq_data *data; data = irq_domain_get_irq_data(port->event_domain, irq); @@ -883,7 +883,7 @@ static int mc_pcie_init_clks(struct device *dev) static int mc_pcie_init_irq_domains(struct mc_port *port) { - struct device *dev = port->dev; + struct device *dev = &port->pdev->dev; struct device_node *node = dev->of_node; struct device_node *pcie_intc_node; @@ -995,7 +995,7 @@ static int mc_platform_init(struct pci_config_window *cfg) port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL); if (!port) return -ENOMEM; - port->dev = dev; + port->pdev = pdev; ret = mc_pcie_init_clks(dev); if (ret) { From patchwork Sat Nov 27 14:11:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Fei X-Patchwork-Id: 12642265 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 1FE37C4332F for ; Sat, 27 Nov 2021 14:16:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235744AbhK0OTt (ORCPT ); Sat, 27 Nov 2021 09:19:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235878AbhK0ORs (ORCPT ); Sat, 27 Nov 2021 09:17:48 -0500 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87127C0613F1 for ; Sat, 27 Nov 2021 06:11:37 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id c6-20020a05600c0ac600b0033c3aedd30aso8675851wmr.5 for ; Sat, 27 Nov 2021 06:11:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EZ/a1hLw4ib4u/sKDQg2z3YvvoSc0gXGQR3XWvJND3g=; b=oqhFJrPbWY79Vj5f5L0bx09G+WbgjAONBUVmiErfATsmYwQoMdhG8D9QdXevd+QSnW oFkYAPUvdbYBbcAoblBCypCHSrTtbmzWQi5BElfjXTLjJLYPb0mHfuyqacsZpmSuw8Mp jAGZTQe+ZNdkLFkKcBAFtXCR3432+ccFRYbrDfn1I4DLbmzLbsxNz6T4OAzfHd99Pz5j 3DLKpkXyksIKCVkE4Y96/poYPSA99CT+l5SlFt3CHzZigvG6hR0EIaJjRWwDUh5+t0PP JCSg/0EPPPpH+tOhY3xwheo1lSeQZ36ksmtPYPS3qs/vHDvoUVyZ3zGR0/lC9uDeRxTs Hp5A== 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=EZ/a1hLw4ib4u/sKDQg2z3YvvoSc0gXGQR3XWvJND3g=; b=qpwZHYiRX9r5a3bBH+krtjHcoq9fy0Nq+otLu7m+IKcvrfaCrtzO9HLy4PsK6alFhN VAg79NfY8AmRVa/H0uuXKx7byujbU7ogaM7C9UhO65Dii7vrqya6s1Y+NeXADVKqY9j3 HPMc9kx3pLvakBuSHgfQlrKKiPAqz6if/X2dsf0Oq3c3oA1+4b00ZWwNO40SH++umOmZ DppBv3DqWP16KRccrw04iPHOAvdudgxPmkj/rBM98ox1DbVybresxJX4w1djyhvrE8Ah ULmDS1JR62Db2bL6cvBB3lav5LrZk9xEGYFWfS2PuFloIiZx5wno7uhVxTCrr9WH4nG5 JuRw== X-Gm-Message-State: AOAM533vH7UpvBdgHitpmzARk+GH9W2prc3sOrz7sUKsbnRQCw+ZcXIM gTRAH6Jt90KBM5H/Uc0shmwnJ3BWG0Xk4Q== X-Google-Smtp-Source: ABdhPJwsQ8RBGmaR68eJc+uAbx2KvJIE4ouM9lYecwGOYm0nOmZ5Vt0dBnsmDhqgI1f4t7Ap4feSIw== X-Received: by 2002:a1c:7c19:: with SMTP id x25mr23192727wmc.42.1638022296061; Sat, 27 Nov 2021 06:11:36 -0800 (PST) Received: from claire-ThinkPad-T470.localdomain (dynamic-2a01-0c22-7349-1000-d163-c2fa-698a-934f.c22.pool.telefonica.de. [2a01:c22:7349:1000:d163:c2fa:698a:934f]) by smtp.gmail.com with ESMTPSA id q26sm8754522wrc.39.2021.11.27.06.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Nov 2021 06:11:35 -0800 (PST) From: Fan Fei To: bjorn@helgaas.com Cc: Fan Fei , linux-pci@vger.kernel.org Subject: [PATCH 06/13] PCI: brcmstb: Replace device * with platform_device * Date: Sat, 27 Nov 2021 15:11:14 +0100 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some PCI controller struct contain "device *", while others contain "platform_device *". Unify "device *dev" to "platform_device *pdev" in struct brcmstb_pcie, because PCI controllers interact with platform_device directly, not device, to enumerate the controlled device. Signed-off-by: Fan Fei --- drivers/pci/controller/pcie-brcmstb.c | 35 ++++++++++++++------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 1fc7bd49a7ad..e6f0c3e561b6 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -278,7 +278,7 @@ struct brcm_msi { /* Internal PCIe Host Controller Information.*/ struct brcm_pcie { - struct device *dev; + struct platform_device *pdev; void __iomem *base; struct clk *clk; struct device_node *np; @@ -641,7 +641,7 @@ static int brcm_pcie_enable_msi(struct brcm_pcie *pcie) { struct brcm_msi *msi; int irq, ret; - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; irq = irq_of_parse_and_map(dev->of_node, 1); if (irq <= 0) { @@ -780,7 +780,7 @@ static inline int brcm_pcie_get_rc_bar2_size_and_offset(struct brcm_pcie *pcie, { struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); struct resource_entry *entry; - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; u64 lowest_pcie_addr = ~(u64)0; int ret, i = 0; u64 size = 0; @@ -866,7 +866,7 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); u64 rc_bar2_offset, rc_bar2_size; void __iomem *base = pcie->base; - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct resource_entry *entry; bool ssc_good = false; struct resource *res; @@ -984,7 +984,7 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) continue; if (num_out_wins >= BRCM_NUM_PCIE_OUT_WINS) { - dev_err(pcie->dev, "too many outbound wins\n"); + dev_err(dev, "too many outbound wins\n"); return -EINVAL; } @@ -1067,7 +1067,7 @@ static void brcm_pcie_enter_l23(struct brcm_pcie *pcie) } if (!l23) - dev_err(pcie->dev, "failed to enter low-power link state\n"); + dev_err(&pcie->pdev->dev, "failed to enter low-power link state\n"); } static int brcm_phy_cntl(struct brcm_pcie *pcie, const int start) @@ -1101,7 +1101,7 @@ static int brcm_phy_cntl(struct brcm_pcie *pcie, const int start) ret = (tmp & combined_mask) == val ? 0 : -EIO; if (ret) - dev_err(pcie->dev, "failed to %s phy\n", (start ? "start" : "stop")); + dev_err(&pcie->pdev->dev, "failed to %s phy\n", (start ? "start" : "stop")); return ret; } @@ -1231,24 +1231,25 @@ static const struct of_device_id brcm_pcie_match[] = { static int brcm_pcie_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct device_node *np = pdev->dev.of_node, *msi_np; struct pci_host_bridge *bridge; const struct pcie_cfg_data *data; struct brcm_pcie *pcie; int ret; - bridge = devm_pci_alloc_host_bridge(&pdev->dev, sizeof(*pcie)); + bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie)); if (!bridge) return -ENOMEM; - data = of_device_get_match_data(&pdev->dev); + data = of_device_get_match_data(dev); if (!data) { pr_err("failed to look up compatible string\n"); return -EINVAL; } pcie = pci_host_bridge_priv(bridge); - pcie->dev = &pdev->dev; + pcie->pdev = pdev; pcie->np = np; pcie->reg_offsets = data->offsets; pcie->type = data->type; @@ -1259,7 +1260,7 @@ static int brcm_pcie_probe(struct platform_device *pdev) if (IS_ERR(pcie->base)) return PTR_ERR(pcie->base); - pcie->clk = devm_clk_get_optional(&pdev->dev, "sw_pcie"); + pcie->clk = devm_clk_get_optional(dev, "sw_pcie"); if (IS_ERR(pcie->clk)) return PTR_ERR(pcie->clk); @@ -1270,15 +1271,15 @@ static int brcm_pcie_probe(struct platform_device *pdev) ret = clk_prepare_enable(pcie->clk); if (ret) { - dev_err(&pdev->dev, "could not enable clock\n"); + dev_err(dev, "could not enable clock\n"); return ret; } - pcie->rescal = devm_reset_control_get_optional_shared(&pdev->dev, "rescal"); + pcie->rescal = devm_reset_control_get_optional_shared(dev, "rescal"); if (IS_ERR(pcie->rescal)) { clk_disable_unprepare(pcie->clk); return PTR_ERR(pcie->rescal); } - pcie->perst_reset = devm_reset_control_get_optional_exclusive(&pdev->dev, "perst"); + pcie->perst_reset = devm_reset_control_get_optional_exclusive(dev, "perst"); if (IS_ERR(pcie->perst_reset)) { clk_disable_unprepare(pcie->clk); return PTR_ERR(pcie->perst_reset); @@ -1286,7 +1287,7 @@ static int brcm_pcie_probe(struct platform_device *pdev) ret = reset_control_reset(pcie->rescal); if (ret) - dev_err(&pdev->dev, "failed to deassert 'rescal'\n"); + dev_err(dev, "failed to deassert 'rescal'\n"); ret = brcm_phy_start(pcie); if (ret) { @@ -1301,7 +1302,7 @@ static int brcm_pcie_probe(struct platform_device *pdev) pcie->hw_rev = readl(pcie->base + PCIE_MISC_REVISION); if (pcie->type == BCM4908 && pcie->hw_rev >= BRCM_PCIE_HW_REV_3_20) { - dev_err(pcie->dev, "hardware revision with unsupported PERST# setup\n"); + dev_err(dev, "hardware revision with unsupported PERST# setup\n"); ret = -ENODEV; goto fail; } @@ -1310,7 +1311,7 @@ static int brcm_pcie_probe(struct platform_device *pdev) if (pci_msi_enabled() && msi_np == pcie->np) { ret = brcm_pcie_enable_msi(pcie); if (ret) { - dev_err(pcie->dev, "probe of internal MSI failed"); + dev_err(dev, "probe of internal MSI failed"); goto fail; } } From patchwork Sat Nov 27 14:11:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Fei X-Patchwork-Id: 12642267 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 67025C43217 for ; Sat, 27 Nov 2021 14:16:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235878AbhK0OTv (ORCPT ); Sat, 27 Nov 2021 09:19:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243525AbhK0ORv (ORCPT ); Sat, 27 Nov 2021 09:17:51 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 527DBC0613F2 for ; Sat, 27 Nov 2021 06:11:39 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id 133so10513381wme.0 for ; Sat, 27 Nov 2021 06:11:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i++CnfQul7tulbjn5Ada0LDULJ8HgeGM/trVrGjJFJQ=; b=JDG2eaBM7xt7oDxiP7tHPrpYdroCV22/iciUUmf+Lv3t5ESc9DBiPzqtn0dNv3gr1r Xbow4y2zMJ22NpBMiOX8hnCuH4ljA2veSmU48qFq/AZjT4aTVu5kq6XpI5gIFqK1wLOT NXq2FeB7XTmdX8H+2n5lb1pqSF5tL4Rv00AgUJqgLs71BKSzJoJqSqenxGf7uoqeNCFG ZErojsOrvuRmscUaJiH3ImZiCW2wdpBSkm830IMTurNpRg0yG7zkkafE42yNlX9uRNUJ g2MKa657GTOSqDVDKWzrpnXGuhOv3hU2khxkYlAwT6dRr0z0mXjTPjzrgf505nCDVApd bZ4w== 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=i++CnfQul7tulbjn5Ada0LDULJ8HgeGM/trVrGjJFJQ=; b=rTIxcfg63Sf4jnw0zHkf66hRXU9iI+6FHv+rtXf3hD1P+xslTinqcWXu+8MzTaOSsG RHi1Kpe0d5RtMF1wN2DTypEQyr6CQXKygaBPjxP6Urh3vH7hVlC48dfT8mvCLniDKm/4 sdH4hyzZ2moKUg/qxf563L9i2lAqpq0qHJm4nvCr0lL6hbo2emjYKyB4I0AwWxLbOiu8 KCRZwOQEzrUlCLDv1pDzaYxMgGwQ92O0csy88pv7mV2PH/wQEXmjMNDDbRCKhSQaDRef /swo8xdlJhRiQt8swwFcg1/peUsNPstIPJNYHRrDU9wVZSosythaq13n2VzEhAPYqJXc ks/Q== X-Gm-Message-State: AOAM530nsXlK3meK6PQrtvAyoJac2KYWyehB0SZi7zRJ/KnjgjQOdWM8 G6dfpNyngqT8WckmcbaBZwHziBp3NHcHTA== X-Google-Smtp-Source: ABdhPJxnQfSJTSG39P3LAxqNbdYXXfrM26rfeDd0L9BJoklL7/7Xp+2+FrR4Rw+gcHo2e2wyWuGppQ== X-Received: by 2002:a05:600c:4303:: with SMTP id p3mr23333159wme.128.1638022297841; Sat, 27 Nov 2021 06:11:37 -0800 (PST) Received: from claire-ThinkPad-T470.localdomain (dynamic-2a01-0c22-7349-1000-d163-c2fa-698a-934f.c22.pool.telefonica.de. [2a01:c22:7349:1000:d163:c2fa:698a:934f]) by smtp.gmail.com with ESMTPSA id q26sm8754522wrc.39.2021.11.27.06.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Nov 2021 06:11:37 -0800 (PST) From: Fan Fei To: bjorn@helgaas.com Cc: Fan Fei , linux-pci@vger.kernel.org Subject: [PATCH 07/13] PCI: mediatek-gen3: Replace device * with platform_device * Date: Sat, 27 Nov 2021 15:11:15 +0100 Message-Id: <301c798d4799fd2a941b49b7acab119c484d0744.1638022049.git.ffclaire1224@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some PCI controller struct contain "device *", while others contain "platform_device *". Unify "device *dev" to "platform_device *pdev" in struct mtk_pcie, because PCI controllers interact with platform_device directly, not device, to enumerate the controlled device. Signed-off-by: Fan Fei --- drivers/pci/controller/pcie-mediatek-gen3.c | 36 ++++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c index 459fe88297b0..6e347be00b0d 100644 --- a/drivers/pci/controller/pcie-mediatek-gen3.c +++ b/drivers/pci/controller/pcie-mediatek-gen3.c @@ -130,7 +130,7 @@ struct mtk_msi_set { * @msi_irq_in_use: bit map for assigned MSI IRQ */ struct mtk_gen3_pcie { - struct device *dev; + struct platform_device *pdev; void __iomem *base; phys_addr_t reg_base; struct reset_control *mac_reset; @@ -213,11 +213,12 @@ static int mtk_pcie_set_trans_table(struct mtk_gen3_pcie *pcie, resource_size_t size, unsigned long type, int num) { + struct device *dev = &pcie->pdev->dev; void __iomem *table; u32 val; if (num >= PCIE_MAX_TRANS_TABLES) { - dev_err(pcie->dev, "not enough translate table for addr: %#llx, limited to [%d]\n", + dev_err(dev, "not enough translate table for addr: %#llx, limited to [%d]\n", (unsigned long long)cpu_addr, PCIE_MAX_TRANS_TABLES); return -ENODEV; } @@ -275,6 +276,7 @@ static void mtk_pcie_enable_msi(struct mtk_gen3_pcie *pcie) static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie) { + struct device *dev = &pcie->pdev->dev; struct resource_entry *entry; struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie); unsigned int table_index = 0; @@ -320,7 +322,7 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie) PCI_PM_D3COLD_WAIT * USEC_PER_MSEC); if (err) { val = readl_relaxed(pcie->base + PCIE_LTSSM_STATUS_REG); - dev_err(pcie->dev, "PCIe link down, ltssm reg val: %#x\n", val); + dev_err(dev, "PCIe link down, ltssm reg val: %#x\n", val); return err; } @@ -352,7 +354,7 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie) if (err) return err; - dev_dbg(pcie->dev, "set %s trans window[%d]: cpu_addr = %#llx, pci_addr = %#llx, size = %#llx\n", + dev_dbg(dev, "set %s trans window[%d]: cpu_addr = %#llx, pci_addr = %#llx, size = %#llx\n", range_type, table_index, (unsigned long long)cpu_addr, (unsigned long long)pci_addr, (unsigned long long)size); @@ -397,6 +399,7 @@ static void mtk_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) { struct mtk_msi_set *msi_set = irq_data_get_irq_chip_data(data); struct mtk_gen3_pcie *pcie = data->domain->host_data; + struct device *dev = &pcie->pdev->dev; unsigned long hwirq; hwirq = data->hwirq % PCIE_MSI_IRQS_PER_SET; @@ -404,7 +407,7 @@ static void mtk_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) msg->address_hi = upper_32_bits(msi_set->msg_addr); msg->address_lo = lower_32_bits(msi_set->msg_addr); msg->data = hwirq; - dev_dbg(pcie->dev, "msi#%#lx address_hi %#x address_lo %#x data %d\n", + dev_dbg(dev, "msi#%#lx address_hi %#x address_lo %#x data %d\n", hwirq, msg->address_hi, msg->address_lo, msg->data); } @@ -575,7 +578,7 @@ static const struct irq_domain_ops intx_domain_ops = { static int mtk_pcie_init_irq_domains(struct mtk_gen3_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct device_node *intc_node, *node = dev->of_node; int ret; @@ -691,8 +694,8 @@ static void mtk_pcie_irq_handler(struct irq_desc *desc) static int mtk_pcie_setup_irq(struct mtk_gen3_pcie *pcie) { - struct device *dev = pcie->dev; - struct platform_device *pdev = to_platform_device(dev); + struct platform_device *pdev = pcie->pdev; + struct device *dev = &pdev->dev; int err; err = mtk_pcie_init_irq_domains(pcie); @@ -710,8 +713,8 @@ static int mtk_pcie_setup_irq(struct mtk_gen3_pcie *pcie) static int mtk_pcie_parse_port(struct mtk_gen3_pcie *pcie) { - struct device *dev = pcie->dev; - struct platform_device *pdev = to_platform_device(dev); + struct platform_device *pdev = pcie->pdev; + struct device *dev = &pdev->dev; struct resource *regs; int ret; @@ -764,7 +767,7 @@ static int mtk_pcie_parse_port(struct mtk_gen3_pcie *pcie) static int mtk_pcie_power_up(struct mtk_gen3_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; int err; /* PHY power on and enable pipe clock */ @@ -811,10 +814,11 @@ static int mtk_pcie_power_up(struct mtk_gen3_pcie *pcie) static void mtk_pcie_power_down(struct mtk_gen3_pcie *pcie) { + struct device *dev = &pcie->pdev->dev; clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); - pm_runtime_put_sync(pcie->dev); - pm_runtime_disable(pcie->dev); + pm_runtime_put_sync(dev); + pm_runtime_disable(dev); reset_control_assert(pcie->mac_reset); phy_power_off(pcie->phy); @@ -865,7 +869,7 @@ static int mtk_pcie_probe(struct platform_device *pdev) pcie = pci_host_bridge_priv(host); - pcie->dev = dev; + pcie->pdev = pdev; platform_set_drvdata(pdev, pcie); err = mtk_pcie_setup(pcie); @@ -961,7 +965,7 @@ static int __maybe_unused mtk_pcie_suspend_noirq(struct device *dev) /* Trigger link to L2 state */ err = mtk_pcie_turn_off_link(pcie); if (err) { - dev_err(pcie->dev, "cannot enter L2 state\n"); + dev_err(dev, "cannot enter L2 state\n"); return err; } @@ -970,7 +974,7 @@ static int __maybe_unused mtk_pcie_suspend_noirq(struct device *dev) val |= PCIE_PE_RSTB; writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); - dev_dbg(pcie->dev, "entered L2 states successfully"); + dev_dbg(dev, "entered L2 states successfully"); mtk_pcie_irq_save(pcie); mtk_pcie_power_down(pcie); From patchwork Sat Nov 27 14:11:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Fei X-Patchwork-Id: 12642269 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 A3974C433EF for ; Sat, 27 Nov 2021 14:16:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355186AbhK0OTw (ORCPT ); Sat, 27 Nov 2021 09:19:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244740AbhK0ORv (ORCPT ); Sat, 27 Nov 2021 09:17:51 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5CCAC0613F3 for ; Sat, 27 Nov 2021 06:11:40 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id s13so25216406wrb.3 for ; Sat, 27 Nov 2021 06:11:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8nFR1D3sjPQN1xzd4WfJBHS1L8Y0eUshfiPdageUB7U=; b=eth2+FlBt7PAEaAzBLfDtk19omNBuPAFTeUldR5wJqNHbiGMvtzOrpPpdHFe6FfDSm CHSo+zLZN7gZcvS8Z3dldwFgbqZxKjo+xC9vZ7qhNcfB9ZGb7syuGQfQHG2JefdBlKPv 4YWc82vh98zI6aajCaM2w5lLAFXUyNZVQAAg5c/aIXUsR4SVy2u9kjD9HX86tBer7hdu UPoBaEx4/4PMe80v6pN6dFCt6QOYxDuJkLTYn1m6mP7JAdjquxxBtMkz+Chv1rjbOgXL SaMCC4QQwiZTD11ZICNbhYIPJltWvO8lmzQVI5Xt13Hhg92U8vMX8mPzwFB0obVztJ6s LawA== 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=8nFR1D3sjPQN1xzd4WfJBHS1L8Y0eUshfiPdageUB7U=; b=gC1YRNXtrMkKKGawWmerAViER7WlNUdwT2tW0pTPaztV1qPFHYPFECtqogSM1ZxK1K U8QsLKp9XCVidZEYL3cLqlar1RyveYjUK4iRJ5HhN8qqsT8tedpxTSJq7kfMaAhqnd7K x+4MuYquL7cvxroC3bJbsH3rxsjkpuIC017qGqLKntA5pVKPV+5kxTY1h/CtKsN2UB2p /ubuidDGX5HbhgTheO6ntm9DXuV+HfuyIcV5yl6qCboTcUy8jb/95woITIcV9/qehfwj ntp1e76n3JZ9Ce9n3UZx/ogQSIri7yxvtCfF+lXRCwYoLwa+WT3JALGslY97CZuVwOXD 2KCQ== X-Gm-Message-State: AOAM531xupN5nvyENVz9px5EzK9l86z1km0y79Ax3Sz5lUfivQG3Dz4L JrOeV9zA0mHdcrmqW0qIKuk= X-Google-Smtp-Source: ABdhPJz//yrYPQcKROeJv2eNeRPsn8Niq0vV4pio23vG1xrTJs8W+z9NU3zepUp2DtDyfyO/UIzQxg== X-Received: by 2002:a5d:64eb:: with SMTP id g11mr21324581wri.438.1638022299455; Sat, 27 Nov 2021 06:11:39 -0800 (PST) Received: from claire-ThinkPad-T470.localdomain (dynamic-2a01-0c22-7349-1000-d163-c2fa-698a-934f.c22.pool.telefonica.de. [2a01:c22:7349:1000:d163:c2fa:698a:934f]) by smtp.gmail.com with ESMTPSA id q26sm8754522wrc.39.2021.11.27.06.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Nov 2021 06:11:39 -0800 (PST) From: Fan Fei To: bjorn@helgaas.com Cc: Fan Fei , linux-pci@vger.kernel.org Subject: [PATCH 08/13] PCI: rcar-gen2: Replace device * with platform_device * Date: Sat, 27 Nov 2021 15:11:16 +0100 Message-Id: <758fc6c4dbd95b7bded954db3159fc8f962660c1.1638022049.git.ffclaire1224@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some PCI controller struct contain "device *", while others contain "platform_device *". Unify "device *dev" to "platform_device *pdev" in struct rcar_pci_priv, because PCI controllers interact with platform_device directly, not device, to enumerate the controlled device. Signed-off-by: Fan Fei --- drivers/pci/controller/pci-rcar-gen2.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/pci-rcar-gen2.c b/drivers/pci/controller/pci-rcar-gen2.c index afde4aa8f6dc..be24b08dfbaa 100644 --- a/drivers/pci/controller/pci-rcar-gen2.c +++ b/drivers/pci/controller/pci-rcar-gen2.c @@ -94,7 +94,7 @@ #define RCAR_PCI_UNIT_REV_REG (RCAR_AHBPCI_PCICOM_OFFSET + 0x48) struct rcar_pci_priv { - struct device *dev; + struct platform_device *pdev; void __iomem *reg; struct resource mem_res; struct resource *cfg_res; @@ -133,7 +133,7 @@ static void __iomem *rcar_pci_cfg_base(struct pci_bus *bus, unsigned int devfn, static irqreturn_t rcar_pci_err_irq(int irq, void *pw) { struct rcar_pci_priv *priv = pw; - struct device *dev = priv->dev; + struct device *dev = &priv->pdev->dev; u32 status = ioread32(priv->reg + RCAR_PCI_INT_STATUS_REG); if (status & RCAR_PCI_INT_ALLERRORS) { @@ -150,7 +150,7 @@ static irqreturn_t rcar_pci_err_irq(int irq, void *pw) static void rcar_pci_setup_errirq(struct rcar_pci_priv *priv) { - struct device *dev = priv->dev; + struct device *dev = &priv->pdev->dev; int ret; u32 val; @@ -173,7 +173,7 @@ static inline void rcar_pci_setup_errirq(struct rcar_pci_priv *priv) { } static void rcar_pci_setup(struct rcar_pci_priv *priv) { struct pci_host_bridge *bridge = pci_host_bridge_from_priv(priv); - struct device *dev = priv->dev; + struct device *dev = &priv->pdev->dev; void __iomem *reg = priv->reg; struct resource_entry *entry; unsigned long window_size; @@ -307,7 +307,7 @@ static int rcar_pci_probe(struct platform_device *pdev) priv->irq = platform_get_irq(pdev, 0); priv->reg = reg; - priv->dev = dev; + priv->pdev = pdev; if (priv->irq < 0) { dev_err(dev, "no valid irq found\n"); From patchwork Sat Nov 27 14:11:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Fei X-Patchwork-Id: 12642273 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 4E29EC433FE for ; Sat, 27 Nov 2021 14:16:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244976AbhK0OTw (ORCPT ); Sat, 27 Nov 2021 09:19:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244833AbhK0ORv (ORCPT ); Sat, 27 Nov 2021 09:17:51 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C709C0613F4 for ; Sat, 27 Nov 2021 06:11:42 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id d24so25243170wra.0 for ; Sat, 27 Nov 2021 06:11:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WH3xG1L5owcBHEeDadO3z6pf35kVBk/Y6uYjoG4FJf4=; b=ZSbtrDFXeuDOVTwsUKwLde8rWDPSgcemrF/FPu2b+CCojBiVm0uein5V8xzNiKQS1D Swgg5swMnTxeHQiS11xeAELJuLgiYiwFgXt0fj7WtFw6SrOhMJNnvG8WrpN32wb66DLH O3noccfLcdnFrac3RkwUgRHY/DZEuhAyhMRmBqzF3kzBqWAgz7wH7WvkB39VWdMiBfw3 NIdgs/WP3TlIFUMys6gzifIQY6fFO3DD3X4jBUIlwBimtYX+mm0MlQMH87piVsLk2KCM mvmo2cm8xeKYR4L2h9F4gLLOABsmD+GCfYIyy9Gur8KntUcpHCzFAIZ1CUnM1NNWHf/j Vp3A== 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=WH3xG1L5owcBHEeDadO3z6pf35kVBk/Y6uYjoG4FJf4=; b=vBEP3ekaYy3lDnanF0rl7muj+zjF4YpxYfDTI5T8pFJDqQDFzPnJD+Ol8kAE5oDD75 PPRPgtOFQDplS1etfO0axXVBQQy/TXdxyQtAONBb5uyPnidzMZgE8mksyTgigoNVP8Uk nOVDWPX/x2UgOePYzJ6Zkpk+VZAUAfIdj6SU2a5HXhiep6NnWugayeBpbuo4xdJmA4oR iCfJAUIuSQr976lJbgP7drzob26ntwpGqZZZQ29GBdFUYfNRxdCUvDNTHYbR6q4aEyhu XPPWfvLgHKNIm8sqU61fw3z/YMxA4x3tCJXjKkLa/mkNieb9C3leru5+6ihl3UTgmzQe x6iw== X-Gm-Message-State: AOAM5311LPgF2+767LpxSCffEy9KvYuWDV0ybFbiw+MOf0cp5mN9QeNn 7h1yp1noag9PAdf6MucnA4g= X-Google-Smtp-Source: ABdhPJw5HbbPHWHrKeGbFQjSVuKGXv56zXScrTA2TBlQF+inKybmp3jLx2vyXp8UirBOq3Bddqvyew== X-Received: by 2002:adf:e512:: with SMTP id j18mr21265037wrm.532.1638022300948; Sat, 27 Nov 2021 06:11:40 -0800 (PST) Received: from claire-ThinkPad-T470.localdomain (dynamic-2a01-0c22-7349-1000-d163-c2fa-698a-934f.c22.pool.telefonica.de. [2a01:c22:7349:1000:d163:c2fa:698a:934f]) by smtp.gmail.com with ESMTPSA id q26sm8754522wrc.39.2021.11.27.06.11.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Nov 2021 06:11:40 -0800 (PST) From: Fan Fei To: bjorn@helgaas.com Cc: Fan Fei , linux-pci@vger.kernel.org Subject: [PATCH 09/13] PCI: ftpci100: Replace device * with platform_device * Date: Sat, 27 Nov 2021 15:11:17 +0100 Message-Id: <0d49eb261d6cd7a69c98280a50f9db90e2e8fd75.1638022049.git.ffclaire1224@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some PCI controller struct contain "device *", while others contain "platform_device *". Unify "device *dev" to "platform_device *pdev" in struct faraday_pci, because PCI controllers interact with platform_device directly, not device, to enumerate the controlled device. Signed-off-by: Fan Fei --- drivers/pci/controller/pci-ftpci100.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/pci/controller/pci-ftpci100.c b/drivers/pci/controller/pci-ftpci100.c index 88980a44461d..64e4405ad0be 100644 --- a/drivers/pci/controller/pci-ftpci100.c +++ b/drivers/pci/controller/pci-ftpci100.c @@ -120,7 +120,7 @@ struct faraday_pci_variant { }; struct faraday_pci { - struct device *dev; + struct platform_device *pdev; void __iomem *base; struct irq_domain *irqdomain; struct pci_bus *bus; @@ -342,19 +342,20 @@ static const struct irq_domain_ops faraday_pci_irqdomain_ops = { static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p) { - struct device_node *intc = of_get_next_child(p->dev->of_node, NULL); + struct device *dev = &p->pdev->dev; + struct device_node *intc = of_get_next_child(dev->of_node, NULL); int irq; int i; if (!intc) { - dev_err(p->dev, "missing child interrupt-controller node\n"); + dev_err(dev, "missing child interrupt-controller node\n"); return -EINVAL; } /* All PCI IRQs cascade off this one */ irq = of_irq_get(intc, 0); if (irq <= 0) { - dev_err(p->dev, "failed to get parent IRQ\n"); + dev_err(dev, "failed to get parent IRQ\n"); of_node_put(intc); return irq ?: -EINVAL; } @@ -363,7 +364,7 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p) &faraday_pci_irqdomain_ops, p); of_node_put(intc); if (!p->irqdomain) { - dev_err(p->dev, "failed to create Gemini PCI IRQ domain\n"); + dev_err(dev, "failed to create Gemini PCI IRQ domain\n"); return -EINVAL; } @@ -377,7 +378,7 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p) static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p) { - struct device *dev = p->dev; + struct device *dev = &p->pdev->dev; struct pci_host_bridge *bridge = pci_host_bridge_from_priv(p); struct resource_entry *entry; u32 confreg[3] = { @@ -439,7 +440,7 @@ static int faraday_pci_probe(struct platform_device *pdev) host->ops = &faraday_pci_ops; p = pci_host_bridge_priv(host); host->sysdata = p; - p->dev = dev; + p->pdev = pdev; /* Retrieve and enable optional clocks */ clk = devm_clk_get(dev, "PCLK"); From patchwork Sat Nov 27 14:11:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Fei X-Patchwork-Id: 12642271 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 E5988C43219 for ; Sat, 27 Nov 2021 14:16:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244740AbhK0OTw (ORCPT ); Sat, 27 Nov 2021 09:19:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244976AbhK0ORv (ORCPT ); Sat, 27 Nov 2021 09:17:51 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0514FC0613F6 for ; Sat, 27 Nov 2021 06:11:44 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id d9so4283543wrw.4 for ; Sat, 27 Nov 2021 06:11:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=84sRKjOIcFLH6yEzmszwRjwTc0G3wDfY0PEvqFwFO18=; b=nWtf/e9B3LbshM6kF/N1B5iXbLnVLwodrIRSUG3BetQ2oWLPNoB+6z7k5BLonYuIFu 5LAeiyegX1fWfFC0voIqGZDZVRIWxnjIneWRFpZpeCSj5/BnX3FnHJp73bUQH2JXTBi7 t27N4FWBqfZ7C/2JZG6/0iQNuWWd+Uv4uTx6VKKLio9m5JEni9tv/4nPhXSVrlWbB7Qi 6ggOQ+igfNJw0jJFYzsfKyKnEZO7R38k8+6pOi5V3OFT6vUB94+8pRL2qdo51phrXptf 8TjLqF7oET91RQZGUjPfarHLijan6dtyyGMuKkBQfJmRZLlwYsdDnQsQxXE5RfVP1RDT GyLw== 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=84sRKjOIcFLH6yEzmszwRjwTc0G3wDfY0PEvqFwFO18=; b=umzyxYnBJTW9NncleocemOglgOpBDMmLaHIOqx2Dab3JAeRA+exn1im3yudn6Z26Sa kwg8XcoXQYhiOVBJ9z5ueWdGIGekKyoN5xCLiE5WqmfsSrqy5oAap67CaG/P328LUy0p gUt3M+bZMuMl2TRCqUfnxHNqwyGHUfHo+Ggr1cOj+8icbGyFVaEI/38Q7++8WvzOgUxb osnnSkSJNHzoZDNOkBOpv17N4/OtE7cLnhriJDx8MN5FCMg9VN0rn3PQYh1lc5BzElae UhD6rhWdRqS12NYmXBi3LndUTX0q9kyYaI58kB4A9lylAWWLku2G62V3Ytajoec9aqXk kwhw== X-Gm-Message-State: AOAM531wEVHPELT4TMAQ2MFPyfBss69THz9OHfW21nm5ucdmm52cBDjl oGK2683WNKw+XsPlXiNlap3L6hqF/k17tw== X-Google-Smtp-Source: ABdhPJwiTNCPDP5xYLP9PBXCTB6DVav9naFFAZZ8T0W/YgVbk98OPvlGPMfhB7nIhwLTsSWQsY6MWg== X-Received: by 2002:a05:6000:15c8:: with SMTP id y8mr21890085wry.55.1638022302516; Sat, 27 Nov 2021 06:11:42 -0800 (PST) Received: from claire-ThinkPad-T470.localdomain (dynamic-2a01-0c22-7349-1000-d163-c2fa-698a-934f.c22.pool.telefonica.de. [2a01:c22:7349:1000:d163:c2fa:698a:934f]) by smtp.gmail.com with ESMTPSA id q26sm8754522wrc.39.2021.11.27.06.11.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Nov 2021 06:11:42 -0800 (PST) From: Fan Fei To: bjorn@helgaas.com Cc: Fan Fei , linux-pci@vger.kernel.org Subject: [PATCH 10/13] PCI: v3-semi: Replace device * with platform_device * Date: Sat, 27 Nov 2021 15:11:18 +0100 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some PCI controller struct contain "device *", while others contain "platform_device *". Unify "device *dev" to "platform_device *pdev" in struct v3_pci, because PCI controllers interact with platform_device directly, not device, to enumerate the controlled device. Signed-off-by: Fan Fei --- drivers/pci/controller/pci-v3-semi.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/pci/controller/pci-v3-semi.c b/drivers/pci/controller/pci-v3-semi.c index 154a5398633c..96b486650667 100644 --- a/drivers/pci/controller/pci-v3-semi.c +++ b/drivers/pci/controller/pci-v3-semi.c @@ -236,7 +236,7 @@ #define INTEGRATOR_SC_LBFCODE_OFFSET 0x24 struct v3_pci { - struct device *dev; + struct platform_device *pdev; void __iomem *base; void __iomem *config_base; u32 config_mem; @@ -438,7 +438,7 @@ static struct pci_ops v3_pci_ops = { static irqreturn_t v3_irq(int irq, void *data) { struct v3_pci *v3 = data; - struct device *dev = v3->dev; + struct device *dev = &v3->pdev->dev; u32 status; status = readw(v3->base + V3_PCI_STAT); @@ -481,12 +481,13 @@ static irqreturn_t v3_irq(int irq, void *data) static int v3_integrator_init(struct v3_pci *v3) { + struct device *dev = &v3->pdev->dev; unsigned int val; v3->map = syscon_regmap_lookup_by_compatible("arm,integrator-ap-syscon"); if (IS_ERR(v3->map)) { - dev_err(v3->dev, "no syscon\n"); + dev_err(dev, "no syscon\n"); return -ENODEV; } @@ -511,7 +512,7 @@ static int v3_integrator_init(struct v3_pci *v3) readb(v3->base + V3_MAIL_DATA) != 0x55); } - dev_info(v3->dev, "initialized PCI V3 Integrator/AP integration\n"); + dev_info(dev, "initialized PCI V3 Integrator/AP integration\n"); return 0; } @@ -520,7 +521,7 @@ static int v3_pci_setup_resource(struct v3_pci *v3, struct pci_host_bridge *host, struct resource_entry *win) { - struct device *dev = v3->dev; + struct device *dev = &v3->pdev->dev; struct resource *mem; struct resource *io; @@ -598,7 +599,7 @@ static int v3_get_dma_range_config(struct v3_pci *v3, struct resource_entry *entry, u32 *pci_base, u32 *pci_map) { - struct device *dev = v3->dev; + struct device *dev = &v3->pdev->dev; u64 cpu_addr = entry->res->start; u64 cpu_end = entry->res->end; u64 pci_end = cpu_end - entry->offset; @@ -656,7 +657,7 @@ static int v3_get_dma_range_config(struct v3_pci *v3, val |= V3_LB_BASE_ADR_SIZE_2GB; break; default: - dev_err(v3->dev, "illegal dma memory chunk size\n"); + dev_err(dev, "illegal dma memory chunk size\n"); return -EINVAL; } val |= V3_PCI_MAP_M_REG_EN | V3_PCI_MAP_M_ENABLE; @@ -676,7 +677,7 @@ static int v3_pci_parse_map_dma_ranges(struct v3_pci *v3, struct device_node *np) { struct pci_host_bridge *bridge = pci_host_bridge_from_priv(v3); - struct device *dev = v3->dev; + struct device *dev = &v3->pdev->dev; struct resource_entry *entry; int i = 0; @@ -723,7 +724,7 @@ static int v3_pci_probe(struct platform_device *pdev) host->ops = &v3_pci_ops; v3 = pci_host_bridge_priv(host); host->sysdata = v3; - v3->dev = dev; + v3->pdev = pdev; /* Get and enable host clock */ clk = devm_clk_get(dev, NULL); From patchwork Sat Nov 27 14:11:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Fei X-Patchwork-Id: 12642279 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 B173AC433FE for ; Sat, 27 Nov 2021 14:16:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343515AbhK0OTz (ORCPT ); Sat, 27 Nov 2021 09:19:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229638AbhK0ORy (ORCPT ); Sat, 27 Nov 2021 09:17:54 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEA5EC0613F7 for ; Sat, 27 Nov 2021 06:11:45 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id i5so25195880wrb.2 for ; Sat, 27 Nov 2021 06:11:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zh+NOZs5/REqQNlTOGbjtnd3sstlb1c/9N9L5Mvs0xo=; b=iSa7TymEbRIAY/nBTYcK8bfUodICSovbII7PFzhJYFFwP8GyStW8H4dd5ZTTJQjZu5 h+U09OStS2PgXmgirf8pHQ1MnSYpcjI29CErUqEFWS7N24SafCn3s5lD8lwugywZC8Lf P5ET3U/DxqV72RlLmgmkLVWwvhSGweVZ8ZBjhzrRe4q87tHfUAAN/KvZfjzmUiyFJwq2 nn8Fj982yXcXDYUNf7A8lh2N5u+3jZLdjT00HayfyfnW0F4fT0dvVMZaiL6tkXuY30Ak 9kL8xkT0B6SmkGFuNEqwG4TM2twrtsyqERnpGorp+IslxzGTqnHGgyfA5QLJ/Jwu/Ep2 NUtg== 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=Zh+NOZs5/REqQNlTOGbjtnd3sstlb1c/9N9L5Mvs0xo=; b=EE1k/5mpH9o6gpZqIx4jPFAWCKVVwvKv25KZzO4zrEtHVwpxDGdHO3K3CgfXjUA6n6 QE58/J1okjP/79vTXWT1uap7bf5alRzfI06qEp62jBme60OK/z8jj5O41XLN+pO9Nvbk NDUoNLVyUXSrQAGtIsqP8E1Apw9NoFZUvwmjAPkME7XZ2wvMlDPgV/37/p3ex3kBy9ZS CUTiB/v3Q1DOY6Etmcpyr7GxWqH2BfDDYz0ovfIvwBPrfLTuPcF2+FfP720Ikbdu3eEe +aP808/MI0BHdiYBzntC8SO75U6tOmDDK+Y8SWQB/aN2Lqg9taiIaBwwt4bnlcczsIOJ c1iw== X-Gm-Message-State: AOAM531Y62a39nzJW8Tru8Hufo6ycAtZyfUsaVK9mwhY7FVh6AiE+yZy Ch6eLJXEMOlVPizeEN9rtFHTi+O91e3rHw== X-Google-Smtp-Source: ABdhPJwqTih8JFgAuF4pPRTH0BuNxSICRA5Stm/yqahpvLln2bIN8GHY5w+jy/XbE0i1wf9dDZ7A/g== X-Received: by 2002:adf:eb05:: with SMTP id s5mr19852681wrn.448.1638022304220; Sat, 27 Nov 2021 06:11:44 -0800 (PST) Received: from claire-ThinkPad-T470.localdomain (dynamic-2a01-0c22-7349-1000-d163-c2fa-698a-934f.c22.pool.telefonica.de. [2a01:c22:7349:1000:d163:c2fa:698a:934f]) by smtp.gmail.com with ESMTPSA id q26sm8754522wrc.39.2021.11.27.06.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Nov 2021 06:11:43 -0800 (PST) From: Fan Fei To: bjorn@helgaas.com Cc: Fan Fei , linux-pci@vger.kernel.org Subject: [PATCH 11/13] PCI: ixp4xx: Replace device * with platform_device * Date: Sat, 27 Nov 2021 15:11:19 +0100 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some PCI controller struct contain "device *", while others contain "platform_device *". Unify "device *dev" to "platform_device *pdev" in struct ixp4xx_pci, because PCI controllers interact with platform_device directly, not device, to enumerate the controlled device. Signed-off-by: Fan Fei --- drivers/pci/controller/pci-ixp4xx.c | 47 ++++++++++++++++------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/drivers/pci/controller/pci-ixp4xx.c b/drivers/pci/controller/pci-ixp4xx.c index 654ac4a82beb..13e8a4754f5b 100644 --- a/drivers/pci/controller/pci-ixp4xx.c +++ b/drivers/pci/controller/pci-ixp4xx.c @@ -101,7 +101,7 @@ #define IXP4XX_PCI_RTOTTO 0x40 struct ixp4xx_pci { - struct device *dev; + struct platform_device *pdev; void __iomem *base; bool errata_hammer; bool host_mode; @@ -138,7 +138,7 @@ static int ixp4xx_pci_check_master_abort(struct ixp4xx_pci *p) if (isr & IXP4XX_PCI_ISR_PFE) { /* Make sure the master abort bit is reset */ ixp4xx_writel(p, IXP4XX_PCI_ISR, IXP4XX_PCI_ISR_PFE); - dev_dbg(p->dev, "master abort detected\n"); + dev_dbg(&p->pdev->dev, "master abort detected\n"); return -EINVAL; } @@ -216,12 +216,13 @@ static u32 ixp4xx_crp_byte_lane_enable_bits(u32 n, int size) static int ixp4xx_crp_read_config(struct ixp4xx_pci *p, int where, int size, u32 *value) { + struct device *dev = &p->pdev->dev; u32 n, cmd, val; n = where % 4; cmd = where & ~3; - dev_dbg(p->dev, "%s from %d size %d cmd %08x\n", + dev_dbg(dev, "%s from %d size %d cmd %08x\n", __func__, where, size, cmd); ixp4xx_writel(p, IXP4XX_PCI_CRP_AD_CBE, cmd); @@ -231,19 +232,19 @@ static int ixp4xx_crp_read_config(struct ixp4xx_pci *p, int where, int size, switch (size) { case 1: val &= U8_MAX; - dev_dbg(p->dev, "%s read byte %02x\n", __func__, val); + dev_dbg(dev, "%s read byte %02x\n", __func__, val); break; case 2: val &= U16_MAX; - dev_dbg(p->dev, "%s read word %04x\n", __func__, val); + dev_dbg(dev, "%s read word %04x\n", __func__, val); break; case 4: val &= U32_MAX; - dev_dbg(p->dev, "%s read long %08x\n", __func__, val); + dev_dbg(dev, "%s read long %08x\n", __func__, val); break; default: /* Should not happen */ - dev_err(p->dev, "%s illegal size\n", __func__); + dev_err(dev, "%s illegal size\n", __func__); return PCIBIOS_DEVICE_NOT_FOUND; } *value = val; @@ -254,6 +255,7 @@ static int ixp4xx_crp_read_config(struct ixp4xx_pci *p, int where, int size, static int ixp4xx_crp_write_config(struct ixp4xx_pci *p, int where, int size, u32 value) { + struct device *dev = &p->pdev->dev; u32 n, cmd, val; n = where % 4; @@ -265,7 +267,7 @@ static int ixp4xx_crp_write_config(struct ixp4xx_pci *p, int where, int size, val = value << (8*n); - dev_dbg(p->dev, "%s to %d size %d cmd %08x val %08x\n", + dev_dbg(dev, "%s to %d size %d cmd %08x val %08x\n", __func__, where, size, cmd, val); ixp4xx_writel(p, IXP4XX_PCI_CRP_AD_CBE, cmd); @@ -293,6 +295,7 @@ static int ixp4xx_pci_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value) { struct ixp4xx_pci *p = bus->sysdata; + struct device *dev = &p->pdev->dev; u32 n, addr, val, cmd; u8 bus_num = bus->number; int ret; @@ -305,7 +308,7 @@ static int ixp4xx_pci_read_config(struct pci_bus *bus, unsigned int devfn, addr = ixp4xx_config_addr(bus_num, devfn, where); cmd |= NP_CMD_CONFIGREAD; - dev_dbg(p->dev, "read_config from %d size %d dev %d:%d:%d address: %08x cmd: %08x\n", + dev_dbg(dev, "read_config from %d size %d dev %d:%d:%d address: %08x cmd: %08x\n", where, size, bus_num, PCI_SLOT(devfn), PCI_FUNC(devfn), addr, cmd); ret = ixp4xx_pci_read_indirect(p, addr, cmd, &val); @@ -316,19 +319,19 @@ static int ixp4xx_pci_read_config(struct pci_bus *bus, unsigned int devfn, switch (size) { case 1: val &= U8_MAX; - dev_dbg(p->dev, "%s read byte %02x\n", __func__, val); + dev_dbg(dev, "%s read byte %02x\n", __func__, val); break; case 2: val &= U16_MAX; - dev_dbg(p->dev, "%s read word %04x\n", __func__, val); + dev_dbg(dev, "%s read word %04x\n", __func__, val); break; case 4: val &= U32_MAX; - dev_dbg(p->dev, "%s read long %08x\n", __func__, val); + dev_dbg(dev, "%s read long %08x\n", __func__, val); break; default: /* Should not happen */ - dev_err(p->dev, "%s illegal size\n", __func__); + dev_err(dev, "%s illegal size\n", __func__); return PCIBIOS_DEVICE_NOT_FOUND; } *value = val; @@ -340,6 +343,7 @@ static int ixp4xx_pci_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value) { struct ixp4xx_pci *p = bus->sysdata; + struct device *dev = &p->pdev->dev; u32 n, addr, val, cmd; u8 bus_num = bus->number; int ret; @@ -353,7 +357,7 @@ static int ixp4xx_pci_write_config(struct pci_bus *bus, unsigned int devfn, cmd |= NP_CMD_CONFIGWRITE; val = value << (8*n); - dev_dbg(p->dev, "write_config_byte %#x to %d size %d dev %d:%d:%d addr: %08x cmd %08x\n", + dev_dbg(dev, "write_config_byte %#x to %d size %d dev %d:%d:%d addr: %08x cmd %08x\n", value, where, size, bus_num, PCI_SLOT(devfn), PCI_FUNC(devfn), addr, cmd); ret = ixp4xx_pci_write_indirect(p, addr, cmd, val); @@ -379,7 +383,7 @@ static u32 ixp4xx_pci_addr_to_64mconf(phys_addr_t addr) static int ixp4xx_pci_parse_map_ranges(struct ixp4xx_pci *p) { - struct device *dev = p->dev; + struct device *dev = &p->pdev->dev; struct pci_host_bridge *bridge = pci_host_bridge_from_priv(p); struct resource_entry *win; struct resource *res; @@ -437,7 +441,7 @@ static int ixp4xx_pci_parse_map_ranges(struct ixp4xx_pci *p) static int ixp4xx_pci_parse_map_dma_ranges(struct ixp4xx_pci *p) { - struct device *dev = p->dev; + struct device *dev = &p->pdev->dev; struct pci_host_bridge *bridge = pci_host_bridge_from_priv(p); struct resource_entry *win; struct resource *res; @@ -476,17 +480,18 @@ static int ixp4xx_pci_abort_handler(unsigned long addr, unsigned int fsr, struct pt_regs *regs) { struct ixp4xx_pci *p = ixp4xx_pci_abort_singleton; + struct device *dev = &p->pdev->dev; u32 isr, status; int ret; isr = ixp4xx_readl(p, IXP4XX_PCI_ISR); ret = ixp4xx_crp_read_config(p, PCI_STATUS, 2, &status); if (ret) { - dev_err(p->dev, "unable to read abort status\n"); + dev_err(dev, "unable to read abort status\n"); return -EINVAL; } - dev_err(p->dev, + dev_err(dev, "PCI: abort_handler addr = %#lx, isr = %#x, status = %#x\n", addr, isr, status); @@ -495,14 +500,14 @@ static int ixp4xx_pci_abort_handler(unsigned long addr, unsigned int fsr, status |= PCI_STATUS_REC_MASTER_ABORT; ret = ixp4xx_crp_write_config(p, PCI_STATUS, 2, status); if (ret) - dev_err(p->dev, "unable to clear abort status bit\n"); + dev_err(dev, "unable to clear abort status bit\n"); /* * If it was an imprecise abort, then we need to correct the * return address to be _after_ the instruction. */ if (fsr & (1 << 10)) { - dev_err(p->dev, "imprecise abort\n"); + dev_err(dev, "imprecise abort\n"); regs->ARM_pc += 4; } @@ -533,7 +538,7 @@ static int __init ixp4xx_pci_probe(struct platform_device *pdev) host->ops = &ixp4xx_pci_ops; p = pci_host_bridge_priv(host); host->sysdata = p; - p->dev = dev; + p->pdev = pdev; dev_set_drvdata(dev, p); /* From patchwork Sat Nov 27 14:11:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Fei X-Patchwork-Id: 12642275 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 C5E62C433EF for ; Sat, 27 Nov 2021 14:16:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355192AbhK0OTz (ORCPT ); Sat, 27 Nov 2021 09:19:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245464AbhK0ORy (ORCPT ); Sat, 27 Nov 2021 09:17:54 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 642CEC0613F8 for ; Sat, 27 Nov 2021 06:11:47 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id o13so25094659wrs.12 for ; Sat, 27 Nov 2021 06:11:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RHywpbLnmqNH2SDUPxzDEczWXjY+h2wyoTkPOSA5iA0=; b=Sj9JlaYfs3Up3ii5b+IYCXappenSIjrHp9tQEO79CUJ3Ygn9A7RRFoc1IWUMCmO9Kj qtiBVuvz5AkE0JsnQIjeheCGHOFK4eZJiwmqxf78a4Q78kaIOzGIQD6hywRAmt/im+bP dtWfo+qfxdiup0Dz+2o5h8zTTjpWR5jO4LUw4hKouGXLNlY9N00xjRI0ybJON8sq0pUE lSvVGH+qZXeXtpWc6M0R8rufJFNzLbzcPkvvr9oKwXn7kOreiKyokvh3QYQyDNwXqZGW NflTOTeqICwr3VFs6kC6kbZTgbg073qxz8gkhqON0vbMpjFCAvPz8+/lgIzRTMUkECML SOfQ== 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=RHywpbLnmqNH2SDUPxzDEczWXjY+h2wyoTkPOSA5iA0=; b=rTnodWaBJTq05C+64OBiuQ4p5KiBEuWfW1b+AZq4nfIOgGutjTwOoUbRKs9Httfky6 ys8RD+egIc/sWoXSMzjXBpbbyJ+5YcNqxi7RtYJ4hhpNyqHxES4xveLKT45RnWxI3cpf kpLFI6b2CJNlOi8RJz0ZdgnQHHW2QbG5g9z1nju0sI1OGhV6qbFX441O1K/PxOcTVam8 dAkTpZDlGm3YOg1dnY4wvBWxkUo2L4qc7qM9fuZhAK4oBXFHOo2yP5rcyUHfyio2u1ym ZlHmWoCMOOR+kp9tNE0CQOnx9m7Ty/wKjmEyU1GnkDhrURVcHf3oxHoC44BYzs+Tinx3 zF7A== X-Gm-Message-State: AOAM530oX6Rr6RXgnfq4MT0vt3F1VG6QkUGDLblMBkfMeS3jGLxx6L2i MWYa9SJm6V3OO/nwyllaz98= X-Google-Smtp-Source: ABdhPJwIKpJDan/LACavqmOX1dGvhNrRrXmoP8KNTSQyAAzVtTIXuI+/LBMHBrEvVcjwCZOXFi5R6A== X-Received: by 2002:a5d:6902:: with SMTP id t2mr20636150wru.317.1638022305884; Sat, 27 Nov 2021 06:11:45 -0800 (PST) Received: from claire-ThinkPad-T470.localdomain (dynamic-2a01-0c22-7349-1000-d163-c2fa-698a-934f.c22.pool.telefonica.de. [2a01:c22:7349:1000:d163:c2fa:698a:934f]) by smtp.gmail.com with ESMTPSA id q26sm8754522wrc.39.2021.11.27.06.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Nov 2021 06:11:45 -0800 (PST) From: Fan Fei To: bjorn@helgaas.com Cc: Fan Fei , linux-pci@vger.kernel.org Subject: [PATCH 12/13] PCI: xilinx-nwl: Replace device * with platform_device * Date: Sat, 27 Nov 2021 15:11:20 +0100 Message-Id: <5e0d29625125ca307768749c055e76feb552b9c8.1638022049.git.ffclaire1224@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some PCI controller struct contain "device *", while others contain "platform_device *". Unify "device *dev" to "platform_device *pdev" in struct nwl_pcie, because PCI controllers interact with platform_device directly, not device, to enumerate the controlled device. Signed-off-by: Fan Fei --- drivers/pci/controller/pcie-xilinx-nwl.c | 28 ++++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/pci/controller/pcie-xilinx-nwl.c b/drivers/pci/controller/pcie-xilinx-nwl.c index a72b4f9a2b00..2e17fe41a9bd 100644 --- a/drivers/pci/controller/pcie-xilinx-nwl.c +++ b/drivers/pci/controller/pcie-xilinx-nwl.c @@ -154,7 +154,7 @@ struct nwl_msi { /* MSI information */ }; struct nwl_pcie { - struct device *dev; + struct platform_device *pdev; void __iomem *breg_base; void __iomem *pcireg_base; void __iomem *ecam_base; @@ -200,7 +200,7 @@ static bool nwl_phy_link_up(struct nwl_pcie *pcie) static int nwl_wait_for_link(struct nwl_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; int retries; /* check if the link is up or not */ @@ -260,7 +260,7 @@ static struct pci_ops nwl_pcie_ops = { static irqreturn_t nwl_pcie_misc_handler(int irq, void *data) { struct nwl_pcie *pcie = data; - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; u32 misc_stat; /* Checking for misc interrupts */ @@ -504,7 +504,7 @@ static const struct irq_domain_ops dev_msi_domain_ops = { static int nwl_pcie_init_msi_irq_domain(struct nwl_pcie *pcie) { #ifdef CONFIG_PCI_MSI - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct fwnode_handle *fwnode = of_node_to_fwnode(dev->of_node); struct nwl_msi *msi = &pcie->msi; @@ -528,7 +528,7 @@ static int nwl_pcie_init_msi_irq_domain(struct nwl_pcie *pcie) static int nwl_pcie_init_irq_domain(struct nwl_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct device_node *node = dev->of_node; struct device_node *legacy_intc_node; @@ -555,8 +555,8 @@ static int nwl_pcie_init_irq_domain(struct nwl_pcie *pcie) static int nwl_pcie_enable_msi(struct nwl_pcie *pcie) { - struct device *dev = pcie->dev; - struct platform_device *pdev = to_platform_device(dev); + struct platform_device *pdev = pcie->pdev; + struct device *dev = &pdev->dev; struct nwl_msi *msi = &pcie->msi; unsigned long base; int ret; @@ -640,8 +640,8 @@ static int nwl_pcie_enable_msi(struct nwl_pcie *pcie) static int nwl_pcie_bridge_init(struct nwl_pcie *pcie) { - struct device *dev = pcie->dev; - struct platform_device *pdev = to_platform_device(dev); + struct platform_device *pdev = pcie->pdev; + struct device *dev = &pdev->dev; u32 breg_val, ecam_val, first_busno = 0; int err; @@ -756,10 +756,10 @@ static int nwl_pcie_bridge_init(struct nwl_pcie *pcie) return 0; } -static int nwl_pcie_parse_dt(struct nwl_pcie *pcie, - struct platform_device *pdev) +static int nwl_pcie_parse_dt(struct nwl_pcie *pcie) { - struct device *dev = pcie->dev; + struct platform_device *pdev = pcie->pdev; + struct device *dev = &pdev->dev; struct resource *res; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "breg"); @@ -809,10 +809,10 @@ static int nwl_pcie_probe(struct platform_device *pdev) pcie = pci_host_bridge_priv(bridge); - pcie->dev = dev; + pcie->pdev = pdev; pcie->ecam_value = NWL_ECAM_VALUE_DEFAULT; - err = nwl_pcie_parse_dt(pcie, pdev); + err = nwl_pcie_parse_dt(pcie); if (err) { dev_err(dev, "Parsing DT failed\n"); return err; From patchwork Sat Nov 27 14:11:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Fei X-Patchwork-Id: 12642277 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 36243C433F5 for ; Sat, 27 Nov 2021 14:16:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245464AbhK0OTz (ORCPT ); Sat, 27 Nov 2021 09:19:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343515AbhK0ORy (ORCPT ); Sat, 27 Nov 2021 09:17:54 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8CE5C0613F9 for ; Sat, 27 Nov 2021 06:11:48 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id c4so25146745wrd.9 for ; Sat, 27 Nov 2021 06:11:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W1ucDj9vJAFoVvso9iUaodUIPODzZVXYrphoOb8WCVM=; b=ZLSoIpXw4N3OumU1Kq6UX6xp0lU7xYtBYtzzAXLlIXggkCuqy0sVz5DhodmrVofh86 qMGm0eVY+gFjZm4txnlLcmKJw082SeqOk8C8r2xwvZW0NovlgdyqpDzaVgz0POuJR4DR zFtNacAutj2d1WwMT4FClu+8TTfWoBvCceeh/RFGO2cNejdhBMznCbK82BsI3kuXpg8R 7rM6bLvT06OAhIxXQwyKMKAJVigJtu6ZI0b54TtWpZ7p0KXtYoLtNhlBJ+UkoIAkf1b1 6xAxq98jFuUXOKmWXrYUH2LQIyoWs14P7zjZ3CemTASrUE5LOU4aDW6M3n4/FU/efXmS lAYA== 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=W1ucDj9vJAFoVvso9iUaodUIPODzZVXYrphoOb8WCVM=; b=yMG/3c3GJG5UHr3bna+a9iIP+ApNyliWnmD1SOHD92ZtDIf2CaeIdjWj4fZuMCp6KU a/RUXYYvu6kE5cX41g+7i4AUjwPtMu2I3hi8C2CfmitCA1yqC5ByM/XoyaiZbqdhhdxR HWpiupxm4nuLcNWsoOlYXKGKRJ6Bx3CGzYrw+8IV/5JETku5p3ouWesVi5Rk3aXXat+5 QULvA9yKzJezODqY13eAQMk0Zs1nrLHMelN7fRCD6ZBatNWHGgMC8roLfp3e1rxxC65U JOeLodvjQ+W3jIMQjc+4/ysKd+ewqotTN2eF+N2MRUecuNwsgmYjv7ySED36z2XJJAQ1 HDaQ== X-Gm-Message-State: AOAM531h1de1ygksnMkLmSLfz1Zw4nP78wYGgeqsZg3pLJYUUrjoHWdY fDdATv4llpTNXDrh5zPwyzdz1wIuqu/q/Q== X-Google-Smtp-Source: ABdhPJxfpKdDx+ZQQUwFaTDpk2dmpJ9xfWw1bt/hUu7o3rWAWdVzzK/jOXOdRR54NRxGCv9Aqp/L4Q== X-Received: by 2002:a5d:5504:: with SMTP id b4mr20893188wrv.307.1638022307352; Sat, 27 Nov 2021 06:11:47 -0800 (PST) Received: from claire-ThinkPad-T470.localdomain (dynamic-2a01-0c22-7349-1000-d163-c2fa-698a-934f.c22.pool.telefonica.de. [2a01:c22:7349:1000:d163:c2fa:698a:934f]) by smtp.gmail.com with ESMTPSA id q26sm8754522wrc.39.2021.11.27.06.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Nov 2021 06:11:47 -0800 (PST) From: Fan Fei To: bjorn@helgaas.com Cc: Fan Fei , linux-pci@vger.kernel.org Subject: [PATCH 13/13] PCI: rcar: Replace device * with platform_device * Date: Sat, 27 Nov 2021 15:11:21 +0100 Message-Id: <7b7de38c0b3eb0b497f3eed2a3a62739b351d1e7.1638022050.git.ffclaire1224@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some PCI controller struct contain "device *", while others contain "platform_device *". Unify "device *dev" to "platform_device *pdev" in struct rcar_pcie, because PCI controllers interact with platform_device directly, not device, to enumerate the controlled device. Modify rcar host and endpoint file in this patch, because both struct include member rcar_pcie. Signed-off-by: Fan Fei --- drivers/pci/controller/pcie-rcar-ep.c | 40 ++++++++++++++----------- drivers/pci/controller/pcie-rcar-host.c | 27 +++++++++-------- drivers/pci/controller/pcie-rcar.h | 2 +- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/drivers/pci/controller/pcie-rcar-ep.c b/drivers/pci/controller/pcie-rcar-ep.c index f9682df1da61..1a471220f560 100644 --- a/drivers/pci/controller/pcie-rcar-ep.c +++ b/drivers/pci/controller/pcie-rcar-ep.c @@ -87,10 +87,11 @@ static int rcar_pcie_ep_get_window(struct rcar_pcie_endpoint *ep, return -EINVAL; } -static int rcar_pcie_parse_outbound_ranges(struct rcar_pcie_endpoint *ep, - struct platform_device *pdev) +static int rcar_pcie_parse_outbound_ranges(struct rcar_pcie_endpoint *ep) { struct rcar_pcie *pcie = &ep->pcie; + struct platform_device *pdev = pcie->pdev; + struct device *dev = &pdev->dev; char outbound_name[10]; struct resource *res; unsigned int i = 0; @@ -102,13 +103,13 @@ static int rcar_pcie_parse_outbound_ranges(struct rcar_pcie_endpoint *ep, IORESOURCE_MEM, outbound_name); if (!res) { - dev_err(pcie->dev, "missing outbound window %u\n", i); + dev_err(dev, "missing outbound window %u\n", i); return -EINVAL; } - if (!devm_request_mem_region(&pdev->dev, res->start, + if (!devm_request_mem_region(dev, res->start, resource_size(res), outbound_name)) { - dev_err(pcie->dev, "Cannot request memory region %s.\n", + dev_err(dev, "Cannot request memory region %s.\n", outbound_name); return -EIO; } @@ -125,12 +126,12 @@ static int rcar_pcie_parse_outbound_ranges(struct rcar_pcie_endpoint *ep, return 0; } -static int rcar_pcie_ep_get_pdata(struct rcar_pcie_endpoint *ep, - struct platform_device *pdev) +static int rcar_pcie_ep_get_pdata(struct rcar_pcie_endpoint *ep) { struct rcar_pcie *pcie = &ep->pcie; struct pci_epc_mem_window *window; - struct device *dev = pcie->dev; + struct platform_device *pdev = pcie->pdev; + struct device *dev = &pdev->dev; struct resource res; int err; @@ -146,7 +147,7 @@ static int rcar_pcie_ep_get_pdata(struct rcar_pcie_endpoint *ep, if (!ep->ob_window) return -ENOMEM; - rcar_pcie_parse_outbound_ranges(ep, pdev); + rcar_pcie_parse_outbound_ranges(ep); err = of_property_read_u8(dev->of_node, "max-functions", &ep->max_functions); @@ -201,13 +202,14 @@ static int rcar_pcie_ep_set_bar(struct pci_epc *epc, u8 func_no, u8 vfunc_no, dma_addr_t cpu_addr = epf_bar->phys_addr; enum pci_barno bar = epf_bar->barno; struct rcar_pcie *pcie = &ep->pcie; + struct device *dev = &pcie->pdev->dev; u32 mask; int idx; int err; idx = find_first_zero_bit(ep->ib_window_map, ep->num_ib_windows); if (idx >= ep->num_ib_windows) { - dev_err(pcie->dev, "no free inbound window\n"); + dev_err(dev, "no free inbound window\n"); return -EINVAL; } @@ -236,7 +238,7 @@ static int rcar_pcie_ep_set_bar(struct pci_epc *epc, u8 func_no, u8 vfunc_no, err = rcar_pcie_wait_for_phyrdy(pcie); if (err) { - dev_err(pcie->dev, "phy not ready\n"); + dev_err(dev, "phy not ready\n"); return -EINVAL; } @@ -288,6 +290,7 @@ static int rcar_pcie_ep_map_addr(struct pci_epc *epc, u8 fn, u8 vfn, { struct rcar_pcie_endpoint *ep = epc_get_drvdata(epc); struct rcar_pcie *pcie = &ep->pcie; + struct device *dev = &pcie->pdev->dev; struct resource_entry win; struct resource res; int window; @@ -296,13 +299,13 @@ static int rcar_pcie_ep_map_addr(struct pci_epc *epc, u8 fn, u8 vfn, /* check if we have a link. */ err = rcar_pcie_wait_for_dl(pcie); if (err) { - dev_err(pcie->dev, "link not up\n"); + dev_err(dev, "link not up\n"); return err; } window = rcar_pcie_ep_get_window(ep, addr); if (window < 0) { - dev_err(pcie->dev, "failed to get corresponding window\n"); + dev_err(dev, "failed to get corresponding window\n"); return -EINVAL; } @@ -347,23 +350,24 @@ static int rcar_pcie_ep_assert_intx(struct rcar_pcie_endpoint *ep, u8 fn, u8 intx) { struct rcar_pcie *pcie = &ep->pcie; + struct device *dev = &pcie->pdev->dev; u32 val; val = rcar_pci_read_reg(pcie, PCIEMSITXR); if ((val & PCI_MSI_FLAGS_ENABLE)) { - dev_err(pcie->dev, "MSI is enabled, cannot assert INTx\n"); + dev_err(dev, "MSI is enabled, cannot assert INTx\n"); return -EINVAL; } val = rcar_pci_read_reg(pcie, PCICONF(1)); if ((val & INTDIS)) { - dev_err(pcie->dev, "INTx message transmission is disabled\n"); + dev_err(dev, "INTx message transmission is disabled\n"); return -EINVAL; } val = rcar_pci_read_reg(pcie, PCIEINTXR); if ((val & ASTINTX)) { - dev_err(pcie->dev, "INTx is already asserted\n"); + dev_err(dev, "INTx is already asserted\n"); return -EINVAL; } @@ -487,7 +491,7 @@ static int rcar_pcie_ep_probe(struct platform_device *pdev) return -ENOMEM; pcie = &ep->pcie; - pcie->dev = dev; + pcie->pdev = pdev; pm_runtime_enable(dev); err = pm_runtime_resume_and_get(dev); @@ -496,7 +500,7 @@ static int rcar_pcie_ep_probe(struct platform_device *pdev) goto err_pm_disable; } - err = rcar_pcie_ep_get_pdata(ep, pdev); + err = rcar_pcie_ep_get_pdata(ep); if (err < 0) { dev_err(dev, "failed to request resources: %d\n", err); goto err_pm_put; diff --git a/drivers/pci/controller/pcie-rcar-host.c b/drivers/pci/controller/pcie-rcar-host.c index e12c2d8be05a..4984e4d0078d 100644 --- a/drivers/pci/controller/pcie-rcar-host.c +++ b/drivers/pci/controller/pcie-rcar-host.c @@ -216,7 +216,7 @@ static struct pci_ops rcar_pcie_ops = { static void rcar_pcie_force_speedup(struct rcar_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; unsigned int timeout = 1000; u32 macsr; @@ -312,7 +312,7 @@ static int rcar_pcie_enable(struct rcar_pcie_host *host) static int phy_wait_for_ack(struct rcar_pcie *pcie) { - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; unsigned int timeout = 100; while (timeout--) { @@ -490,7 +490,7 @@ static irqreturn_t rcar_pcie_msi_irq(int irq, void *data) struct rcar_pcie_host *host = data; struct rcar_pcie *pcie = &host->pcie; struct rcar_msi *msi = &host->msi; - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; unsigned long reg; reg = rcar_pci_read_reg(pcie, PCIEMSIFR); @@ -653,20 +653,21 @@ static struct msi_domain_info rcar_msi_info = { static int rcar_allocate_domains(struct rcar_msi *msi) { struct rcar_pcie *pcie = &msi_to_host(msi)->pcie; - struct fwnode_handle *fwnode = dev_fwnode(pcie->dev); + struct device *dev = &pcie->pdev->dev; + struct fwnode_handle *fwnode = dev_fwnode(dev); struct irq_domain *parent; parent = irq_domain_create_linear(fwnode, INT_PCI_MSI_NR, &rcar_msi_domain_ops, msi); if (!parent) { - dev_err(pcie->dev, "failed to create IRQ domain\n"); + dev_err(dev, "failed to create IRQ domain\n"); return -ENOMEM; } irq_domain_update_bus_token(parent, DOMAIN_BUS_NEXUS); msi->domain = pci_msi_create_irq_domain(fwnode, &rcar_msi_info, parent); if (!msi->domain) { - dev_err(pcie->dev, "failed to create MSI domain\n"); + dev_err(dev, "failed to create MSI domain\n"); irq_domain_remove(parent); return -ENOMEM; } @@ -685,7 +686,7 @@ static void rcar_free_domains(struct rcar_msi *msi) static int rcar_pcie_enable_msi(struct rcar_pcie_host *host) { struct rcar_pcie *pcie = &host->pcie; - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct rcar_msi *msi = &host->msi; struct resource res; int err; @@ -751,7 +752,7 @@ static void rcar_pcie_teardown_msi(struct rcar_pcie_host *host) static int rcar_pcie_get_resources(struct rcar_pcie_host *host) { struct rcar_pcie *pcie = &host->pcie; - struct device *dev = pcie->dev; + struct device *dev = &pcie->pdev->dev; struct resource res; int err, i; @@ -821,7 +822,7 @@ static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie, while (cpu_addr < cpu_end) { if (idx >= MAX_NR_INBOUND_MAPS - 1) { - dev_err(pcie->dev, "Failed to map inbound regions!\n"); + dev_err(&pcie->pdev->dev, "Failed to map inbound regions!\n"); return -EINVAL; } /* @@ -899,13 +900,13 @@ static int rcar_pcie_probe(struct platform_device *pdev) host = pci_host_bridge_priv(bridge); pcie = &host->pcie; - pcie->dev = dev; + pcie->pdev = pdev; platform_set_drvdata(pdev, host); - pm_runtime_enable(pcie->dev); - err = pm_runtime_get_sync(pcie->dev); + pm_runtime_enable(dev); + err = pm_runtime_get_sync(dev); if (err < 0) { - dev_err(pcie->dev, "pm_runtime_get_sync failed\n"); + dev_err(dev, "pm_runtime_get_sync failed\n"); goto err_pm_put; } diff --git a/drivers/pci/controller/pcie-rcar.h b/drivers/pci/controller/pcie-rcar.h index 9bb125db85c6..1f33ceb51b83 100644 --- a/drivers/pci/controller/pcie-rcar.h +++ b/drivers/pci/controller/pcie-rcar.h @@ -125,7 +125,7 @@ #define MAX_NR_INBOUND_MAPS 6 struct rcar_pcie { - struct device *dev; + struct platform_device *pdev; void __iomem *base; };