From patchwork Mon Oct 4 12:59:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 12533887 X-Patchwork-Delegate: bhelgaas@google.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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02562C433EF for ; Mon, 4 Oct 2021 13:34:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD14E611C7 for ; Mon, 4 Oct 2021 13:34:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237582AbhJDNge (ORCPT ); Mon, 4 Oct 2021 09:36:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237461AbhJDNek (ORCPT ); Mon, 4 Oct 2021 09:34:40 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD43FC02B751 for ; Mon, 4 Oct 2021 05:59:44 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXNZH-00054d-0u; Mon, 04 Oct 2021 14:59:43 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1mXNZF-0000Kv-5T; Mon, 04 Oct 2021 14:59:41 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1mXNZF-0000b1-4g; Mon, 04 Oct 2021 14:59:41 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, kernel@pengutronix.de, Christoph Hellwig Subject: [PATCH v6 01/11] PCI: Simplify pci_device_remove() Date: Mon, 4 Oct 2021 14:59:25 +0200 Message-Id: <20211004125935.2300113-2-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> References: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=hj/Mv0oBl1Lf1uSz5IdbQVlj1aJs3W94rdH7QDuEpg8=; m=3MjO1JqLy12b20qOWv/Fp9tjcaX0qdsgbDBjSqzg3lQ=; p=u/IlHXlFxyd9VYnelQTUuUgSTqRFKk2si+oT8j90cMA=; g=17cd0bf2a324e8b42bc1759f29e7dd1d484c24ad X-Patch-Sig: m=pgp; i=u.kleine-koenig@pengutronix.de; s=0x0D2511F322BFAB1C1580266BE2DCDD9132669BD6; b=iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmFa+n0ACgkQwfwUeK3K7Ana9gf+OfV qUrWXfk6u7XxukdAGMkhlCImiETp7WbAaJtx4ucc9Eqi14ECyf//4VLm6chZkV/FCt3hk2NLuS9+g Ow40dXPPTMeapRfZE8F/rCwW4c5oRnLA1JJ3lHn/PzFBhFuAQCmHiW72yGhRa8mIywBse5aPOHhjK qGufI36txI/o/G9mBWL/NX9kXwN4aURNNJDpMV0KqpXkDInx3cwx0WNdZbQ/IuvIM+GbsrimXCUtu 2+TE+K96WwPk3tOUHsShIu2h4VgYMPHQa/BYSn0wTtmawkBpngcndm6EIzrzlk4o9l3RhVWM+whAd Pomcid8gom4pevc6FkV3xHpQv0tH1eQ== X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-pci@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org When the driver core calls pci_device_remove() there is a driver that bound the device and so pci_dev->driver is never NULL. Reviewed-by: Christoph Hellwig Signed-off-by: Uwe Kleine-König --- drivers/pci/pci-driver.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 2761ab86490d..8fb6418c93e8 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -459,16 +459,14 @@ static void pci_device_remove(struct device *dev) struct pci_dev *pci_dev = to_pci_dev(dev); struct pci_driver *drv = pci_dev->driver; - if (drv) { - if (drv->remove) { - pm_runtime_get_sync(dev); - drv->remove(pci_dev); - pm_runtime_put_noidle(dev); - } - pcibios_free_irq(pci_dev); - pci_dev->driver = NULL; - pci_iov_remove(pci_dev); + if (drv->remove) { + pm_runtime_get_sync(dev); + drv->remove(pci_dev); + pm_runtime_put_noidle(dev); } + pcibios_free_irq(pci_dev); + pci_dev->driver = NULL; + pci_iov_remove(pci_dev); /* Undo the runtime PM settings in local_pci_probe() */ pm_runtime_put_sync(dev); From patchwork Mon Oct 4 12:59:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 12533889 X-Patchwork-Delegate: bhelgaas@google.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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80F74C433EF for ; Mon, 4 Oct 2021 13:34:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 673E3611C7 for ; Mon, 4 Oct 2021 13:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237588AbhJDNgf (ORCPT ); Mon, 4 Oct 2021 09:36:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237653AbhJDNem (ORCPT ); Mon, 4 Oct 2021 09:34:42 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDDB1C02B752 for ; Mon, 4 Oct 2021 05:59:44 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXNZH-00054f-0u; Mon, 04 Oct 2021 14:59:43 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1mXNZF-0000Kz-Ay; Mon, 04 Oct 2021 14:59:41 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1mXNZF-0000cE-AE; Mon, 04 Oct 2021 14:59:41 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, kernel@pengutronix.de, Christoph Hellwig Subject: [PATCH v6 02/11] PCI: Drop useless check from pci_device_probe() Date: Mon, 4 Oct 2021 14:59:26 +0200 Message-Id: <20211004125935.2300113-3-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> References: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=DxD2f+xPNtLjHiGujpupqv/4IuiZwGoM96HIM+GP4wQ=; m=brxsOJEmtbcToFhdbpQjJIJkUf3JUm4RRkRbChGXUkY=; p=mHFEUbsSOr1Fwea+VtNTtvy2knf9bNjYTh9sfkoxZLA=; g=4751c79fba41d79e9c1c5a83a7197e81fb2ff22e X-Patch-Sig: m=pgp; i=u.kleine-koenig@pengutronix.de; s=0x0D2511F322BFAB1C1580266BE2DCDD9132669BD6; b=iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmFa+oQACgkQwfwUeK3K7AlnfQf5ATx oht8EnKwvAkY5xfhyk77k/n/C2e1mA0Exso8SW5its2RzZULsKqfSaaEPK6XAcEmVWHFUMjrOrP0w RaKA3EuVPdKx5yU5gtErILfcAZTJ/OSyHgnIErbR+yuEeXBsXVEV+lzvz2bgmlSH5N0G3VeO2/QWQ PrHxQAEutgRdvjZtdxCXUG7oxPWXjIUENjoa8s5J6s2C29+QHKfxi/QBX78HwyoqpBPnWlu13uC8e E15Bnwo+h5BFLYMgJMzbXn7W9GK9SyzbSgA/90zHGCn/jdZhLSI/zQL5EjJ/Fqt1Pz9rjJ4GxNImC h5kaZ6qaL3DSRazhm4WFd2YbbfjVT+g== X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-pci@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org When the device core calls the probe callback for a device the device is never bound and so !pci_dev->driver is always true. Reviewed-by: Christoph Hellwig Signed-off-by: Uwe Kleine-König --- drivers/pci/pci-driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 8fb6418c93e8..50449ec622a3 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -397,7 +397,7 @@ static int __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev) const struct pci_device_id *id; int error = 0; - if (!pci_dev->driver && drv->probe) { + if (drv->probe) { error = -ENODEV; id = pci_match_device(drv, pci_dev); From patchwork Mon Oct 4 12:59:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 12533891 X-Patchwork-Delegate: bhelgaas@google.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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7318AC433F5 for ; Mon, 4 Oct 2021 13:34:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A7DD611F0 for ; Mon, 4 Oct 2021 13:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237616AbhJDNgf (ORCPT ); Mon, 4 Oct 2021 09:36:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237279AbhJDNen (ORCPT ); Mon, 4 Oct 2021 09:34:43 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBBEDC02B753 for ; Mon, 4 Oct 2021 05:59:44 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXNZH-00054g-5h; Mon, 04 Oct 2021 14:59:43 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1mXNZF-0000L2-HD; Mon, 04 Oct 2021 14:59:41 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1mXNZF-0000cM-GA; Mon, 04 Oct 2021 14:59:41 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Bjorn Helgaas , Boris Ostrovsky , Juergen Gross Cc: linux-pci@vger.kernel.org, kernel@pengutronix.de, Stefano Stabellini , Konrad Rzeszutek Wilk , xen-devel@lists.xenproject.org, Christoph Hellwig Subject: [PATCH v6 03/11] xen/pci: Drop some checks that are always true Date: Mon, 4 Oct 2021 14:59:27 +0200 Message-Id: <20211004125935.2300113-4-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> References: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=7QOFRnoxyPrPqaGt2Yf8oJvx3xwgCvlMdm130sPrxr8=; m=Ixh7t2kv5MnS1JaJxFtVrqNhjBtz3xQyoCGo2anqbI0=; p=dOfuuSLv1l/M9DCuxyIBdCuX9kCH+yUzno229EZfUDs=; g=9e481f95a51887868b05f8a86c3e5a9f8aff47c6 X-Patch-Sig: m=pgp; i=u.kleine-koenig@pengutronix.de; s=0x0D2511F322BFAB1C1580266BE2DCDD9132669BD6; b=iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmFa+ocACgkQwfwUeK3K7Amivgf+JL3 VuSxNpZrDO5AQClHSuKBtHBaW7oTZrnAnrcEOp1mfJQ0APZDzc4FyTrDOrUqKGOTJKFHVWuxJGT5k TV31y+QhV/acV/nGCdglSS0qVvPZWqpehJx1tUmYnbE+pljLQXJM1iULrwC6v1Wx0B879pKQ1o4P3 7f+xl1YwNv+uOF52e0xNSTJ/PkPZucaNDdq6UtbfOtxHrPBrNmTp1KOgxWymujpRDxvtiNbBz7uGk XG1wfHDNRrB/TpXbkJVRPm842O3/GnSCKiV5BAgsFqeYcUc1vBOZ9afXqseT1w7tG3/4uovlnIqKZ 0yDw0Ltrn/A3l39G2RtzPL+eLsre9Pg== X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-pci@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org pcifront_common_process() has a check at the start that exits early if pcidev or pdidev->driver are NULL. So simplify the following code by not checking these two again. Reviewed-by: Boris Ostrovsky Reviewed-by: Christoph Hellwig Signed-off-by: Uwe Kleine-König --- drivers/pci/xen-pcifront.c | 57 +++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c index 2156c632524d..f2d7f70a7a10 100644 --- a/drivers/pci/xen-pcifront.c +++ b/drivers/pci/xen-pcifront.c @@ -594,7 +594,6 @@ static pci_ers_result_t pcifront_common_process(int cmd, int devfn = pdev->sh_info->aer_op.devfn; int domain = pdev->sh_info->aer_op.domain; struct pci_dev *pcidev; - int flag = 0; dev_dbg(&pdev->xdev->dev, "pcifront AER process: cmd %x (bus:%x, devfn%x)", @@ -609,40 +608,34 @@ static pci_ers_result_t pcifront_common_process(int cmd, } pdrv = pcidev->driver; - if (pdrv) { - if (pdrv->err_handler && pdrv->err_handler->error_detected) { - pci_dbg(pcidev, "trying to call AER service\n"); - if (pcidev) { - flag = 1; - switch (cmd) { - case XEN_PCI_OP_aer_detected: - result = pdrv->err_handler-> - error_detected(pcidev, state); - break; - case XEN_PCI_OP_aer_mmio: - result = pdrv->err_handler-> - mmio_enabled(pcidev); - break; - case XEN_PCI_OP_aer_slotreset: - result = pdrv->err_handler-> - slot_reset(pcidev); - break; - case XEN_PCI_OP_aer_resume: - pdrv->err_handler->resume(pcidev); - break; - default: - dev_err(&pdev->xdev->dev, - "bad request in aer recovery " - "operation!\n"); - - } - } + if (pdrv->err_handler && pdrv->err_handler->error_detected) { + pci_dbg(pcidev, "trying to call AER service\n"); + switch (cmd) { + case XEN_PCI_OP_aer_detected: + result = pdrv->err_handler-> + error_detected(pcidev, state); + break; + case XEN_PCI_OP_aer_mmio: + result = pdrv->err_handler-> + mmio_enabled(pcidev); + break; + case XEN_PCI_OP_aer_slotreset: + result = pdrv->err_handler-> + slot_reset(pcidev); + break; + case XEN_PCI_OP_aer_resume: + pdrv->err_handler->resume(pcidev); + break; + default: + dev_err(&pdev->xdev->dev, + "bad request in aer recovery " + "operation!\n"); } + + return result; } - if (!flag) - result = PCI_ERS_RESULT_NONE; - return result; + return PCI_ERS_RESULT_NONE; } From patchwork Mon Oct 4 12:59:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 12533893 X-Patchwork-Delegate: bhelgaas@google.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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E822EC433FE for ; Mon, 4 Oct 2021 13:34:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D4EE66124D for ; Mon, 4 Oct 2021 13:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237279AbhJDNgf (ORCPT ); Mon, 4 Oct 2021 09:36:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237661AbhJDNeo (ORCPT ); Mon, 4 Oct 2021 09:34:44 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44742C02B754 for ; Mon, 4 Oct 2021 05:59:45 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXNZH-00054h-0t; Mon, 04 Oct 2021 14:59:43 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1mXNZF-0000L5-Mc; Mon, 04 Oct 2021 14:59:41 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1mXNZF-0000cZ-Lj; Mon, 04 Oct 2021 14:59:41 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Bjorn Helgaas , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Cc: linux-pci@vger.kernel.org, kernel@pengutronix.de, linux-wireless@vger.kernel.org Subject: [PATCH v6 04/11] bcma: simplify reference to the driver's name Date: Mon, 4 Oct 2021 14:59:28 +0200 Message-Id: <20211004125935.2300113-5-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> References: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=xSP+K0RSyQAwniF6A6kkbjiE0JBr+Cc60dr1a6KF2Cc=; m=9WMNRZUkbhy3cqoI0SdJ4z32UI6gOxRm4XsLfBOiMFc=; p=ynQzBWvQpvfCsznbo0TKCTlX0o4FNuUIlPzqKHsY1yI=; g=7b3a3bd10c36e651f6578f5837b227bfa43b045b X-Patch-Sig: m=pgp; i=u.kleine-koenig@pengutronix.de; s=0x0D2511F322BFAB1C1580266BE2DCDD9132669BD6; b=iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmFa+o8ACgkQwfwUeK3K7AnLewf8Dlz c2/6eRydXEQMGM0rSOh9Fyr9miaBUlNu5AanNfHSYWpPnz/8LfSEN3LEWiFHFi3IHz4ywopnBAxgy 9CSeG1Bt0MjLrywAD0AMje5hqtxD9LXfT8ZeJ+JyWKhkfsnIt46KOFywtD4Vd4oBviqwJUHglRhhA eeOVAeZMeh6WZWMymRQ/Z0E2zp1iBJr9iTdnDyDnRlLW5h3Zm5mM9Rp+8zu99/9Yik/8UokGkHPnS 2P913K6YlytVjhHbbwKJWaHMOEtoAj21nkmMJuNuL2xKLVIAtXoN5SepWwDoJ4rAu8HP5EsI+mLYK XGAgENRcZxksEfj65Ez1JRZ/wYFgftA== X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-pci@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org When bcma_host_pci_probe() is called the pci driver core already assigned the device's driver in local_pci_probe(). So dev->driver is always true and here it points to bcma_pci_bridge_driver which has .name set to "bcma-pci-bridge". Simplify accordingly. Signed-off-by: Uwe Kleine-König --- drivers/bcma/host_pci.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c index 69c10a7b7c61..960632197b05 100644 --- a/drivers/bcma/host_pci.c +++ b/drivers/bcma/host_pci.c @@ -162,7 +162,6 @@ static int bcma_host_pci_probe(struct pci_dev *dev, { struct bcma_bus *bus; int err = -ENOMEM; - const char *name; u32 val; /* Alloc */ @@ -175,10 +174,7 @@ static int bcma_host_pci_probe(struct pci_dev *dev, if (err) goto err_kfree_bus; - name = dev_name(&dev->dev); - if (dev->driver && dev->driver->name) - name = dev->driver->name; - err = pci_request_regions(dev, name); + err = pci_request_regions(dev, "bcma-pci-bridge"); if (err) goto err_pci_disable; pci_set_master(dev); From patchwork Mon Oct 4 12:59:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 12533899 X-Patchwork-Delegate: bhelgaas@google.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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79F5DC433FE for ; Mon, 4 Oct 2021 13:35:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6364B611CB for ; Mon, 4 Oct 2021 13:35:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238203AbhJDNhc (ORCPT ); Mon, 4 Oct 2021 09:37:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237966AbhJDNfc (ORCPT ); Mon, 4 Oct 2021 09:35:32 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5891C02B76C for ; Mon, 4 Oct 2021 05:59:52 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXNZN-0005K3-Lr; Mon, 04 Oct 2021 14:59:49 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1mXNZN-0000MV-3l; Mon, 04 Oct 2021 14:59:49 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1mXNZF-0000ci-Qr; Mon, 04 Oct 2021 14:59:41 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Bjorn Helgaas , Michael Ellerman Cc: linux-pci@vger.kernel.org, kernel@pengutronix.de, Benjamin Herrenschmidt , Paul Mackerras , Russell Currey , "Oliver O'Halloran" , linuxppc-dev@lists.ozlabs.org Subject: [PATCH v6 05/11] powerpc/eeh: Don't use driver member of struct pci_dev and further cleanups Date: Mon, 4 Oct 2021 14:59:29 +0200 Message-Id: <20211004125935.2300113-6-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> References: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=Zpj0MfNpdqb/t0RctaGob3+oRuWP4Yx6JOoywu4XRsI=; m=qLVHAb7UOiGrqQuPN/p5loiFStoGSa1I5N8zuOAmNU8=; p=0U5IO+Yv/dUfU3ayUE/9KpmDUjFv5zoIY+LRFqJ9Pw0=; g=70976583fe04d220fe4cb7c498cea58f830f1545 X-Patch-Sig: m=pgp; i=u.kleine-koenig@pengutronix.de; s=0x0D2511F322BFAB1C1580266BE2DCDD9132669BD6; b=iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmFa+pMACgkQwfwUeK3K7An2DQf7BwJ +5mTDkIUqy7dufqTCmfUL/PuOO3mdLaN1UMkgI+kPHMqsXVfWtUV44UIB4C931RElHQkQMHbdzind MaO/mCm0chUWdShL8e7yyolxTjG9jIOFeJ8djp7717jyeRduuYev+tzQHfZtVlzf+gZ0fUhDceib9 zbLjwW63K/k14aNwXGpoaQjI8l98vZkZJdvXd8thLuKZt3md1tCPZmB47YRaA/kALD/jXtqmM2geN dp6ooS4aElGr+AodCUYLzzzx+Agh0Zj5+KJ21gckCg7UtotQIwH78aOEpP/C1QIVQUXpwxBWhNHZm Whg67TxzuSne0ilvaKGdceDZvjcEUhg== X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-pci@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The driver member of struct pci_dev is to be removed as it tracks information already present by tracking of the driver core. So replace pdev->driver->name by dev_driver_string() for the corresponding struct device. Also move the function nearer to its only user and instead of the ?: operator use a normal if which is more readable. Signed-off-by: Uwe Kleine-König --- arch/powerpc/include/asm/ppc-pci.h | 5 ----- arch/powerpc/kernel/eeh.c | 8 ++++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/ppc-pci.h b/arch/powerpc/include/asm/ppc-pci.h index 2b9edbf6e929..f6cf0159024e 100644 --- a/arch/powerpc/include/asm/ppc-pci.h +++ b/arch/powerpc/include/asm/ppc-pci.h @@ -55,11 +55,6 @@ void eeh_pe_dev_mode_mark(struct eeh_pe *pe, int mode); void eeh_sysfs_add_device(struct pci_dev *pdev); void eeh_sysfs_remove_device(struct pci_dev *pdev); -static inline const char *eeh_driver_name(struct pci_dev *pdev) -{ - return (pdev && pdev->driver) ? pdev->driver->name : ""; -} - #endif /* CONFIG_EEH */ #define PCI_BUSNO(bdfn) ((bdfn >> 8) & 0xff) diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c index e9b597ed423c..4b08881c4a1e 100644 --- a/arch/powerpc/kernel/eeh.c +++ b/arch/powerpc/kernel/eeh.c @@ -399,6 +399,14 @@ static int eeh_phb_check_failure(struct eeh_pe *pe) return ret; } +static inline const char *eeh_driver_name(struct pci_dev *pdev) +{ + if (pdev) + return dev_driver_string(&pdev->dev); + + return ""; +} + /** * eeh_dev_check_failure - Check if all 1's data is due to EEH slot freeze * @edev: eeh device From patchwork Mon Oct 4 12:59:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 12533897 X-Patchwork-Delegate: bhelgaas@google.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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C97E1C4332F for ; Mon, 4 Oct 2021 13:34:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B21A7611C7 for ; Mon, 4 Oct 2021 13:34:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237692AbhJDNgm (ORCPT ); Mon, 4 Oct 2021 09:36:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237779AbhJDNe5 (ORCPT ); Mon, 4 Oct 2021 09:34:57 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE74FC02B757 for ; Mon, 4 Oct 2021 05:59:46 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXNZH-00054i-0u; Mon, 04 Oct 2021 14:59:43 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1mXNZG-0000L8-1K; Mon, 04 Oct 2021 14:59:42 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1mXNZG-0000cl-0D; Mon, 04 Oct 2021 14:59:42 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Bjorn Helgaas , =?utf-8?q?Michael_B=C3=BCsch?= Cc: linux-pci@vger.kernel.org, kernel@pengutronix.de, linux-wireless@vger.kernel.org Subject: [PATCH v6 06/11] ssb: Simplify determination of driver name Date: Mon, 4 Oct 2021 14:59:30 +0200 Message-Id: <20211004125935.2300113-7-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> References: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=98LA6DtO6x3YHoo9xrdF6tAQFUIynO6p1dMjF9yjRwA=; m=EiK7a8Op8GQPl3dHtg7E9V4Vg7092+Ak3Ee+tNDA8iU=; p=Pkc23pm1s8AeZXLg9vN/Ugj7OZ/vul9MFPqunUCTCFQ=; g=a63fc551b59edb3ff3251a4c4f7afaada4cebafa X-Patch-Sig: m=pgp; i=u.kleine-koenig@pengutronix.de; s=0x0D2511F322BFAB1C1580266BE2DCDD9132669BD6; b=iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmFa+pYACgkQwfwUeK3K7Akfvgf9FY7 2+JNv8HHXv8Hr9ZkoIjx84PVX7Snb2Ho4mRX6/ivHJuJ6wznEDeGAvyXy8e8WGz5WCOgI5g0McS7N rWQtfyqNERgoZzVqQHcOQs54jNp1A/8tqRC4o1RPS91Dj43LipxunVCwuWK0ujonrBMBAo+JU0B+K uW91LgsHz/UBzn+nAl/NZaPrWumJk9eDwmNK5pr8133twT+OQ+so2Ks7vHBu6pYAhbxjznfCXnPlv ChbnA4usKuakP6XgchG02Pf/a2aL+tdfwo0xzm41nDULLM03YwS/5SYOH0xh+80Qg7dTcRqNFr5xW xbRBbEivsTHMZfiycHa6NilMQ3qBeCQ== X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-pci@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org For all drivers that make use of ssb_pcihost_probe() (i.e. b43_pci_bridge_driver and b44_pci_driver) the driver name is set. As at the time for the function is called __pci_register_driver() already assigned drv->driver.name to hold the same value, use dev_driver_string() with the same result. This has the upside of not requiring the driver member of struct pci_dev which is about to be removed and being simpler. Acked-by: Michael Büsch Signed-off-by: Uwe Kleine-König --- drivers/ssb/pcihost_wrapper.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/ssb/pcihost_wrapper.c b/drivers/ssb/pcihost_wrapper.c index 410215c16920..dd70fd41c77d 100644 --- a/drivers/ssb/pcihost_wrapper.c +++ b/drivers/ssb/pcihost_wrapper.c @@ -69,7 +69,6 @@ static int ssb_pcihost_probe(struct pci_dev *dev, { struct ssb_bus *ssb; int err = -ENOMEM; - const char *name; u32 val; ssb = kzalloc(sizeof(*ssb), GFP_KERNEL); @@ -78,10 +77,7 @@ static int ssb_pcihost_probe(struct pci_dev *dev, err = pci_enable_device(dev); if (err) goto err_kfree_ssb; - name = dev_name(&dev->dev); - if (dev->driver && dev->driver->name) - name = dev->driver->name; - err = pci_request_regions(dev, name); + err = pci_request_regions(dev, dev_driver_string(&dev->dev)); if (err) goto err_pci_disable; pci_set_master(dev); From patchwork Mon Oct 4 12:59:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 12533921 X-Patchwork-Delegate: bhelgaas@google.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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C76DCC433EF for ; Mon, 4 Oct 2021 13:39:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95AC8611C0 for ; Mon, 4 Oct 2021 13:39:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236888AbhJDNlL (ORCPT ); Mon, 4 Oct 2021 09:41:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236894AbhJDNjJ (ORCPT ); Mon, 4 Oct 2021 09:39:09 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50B20C029807 for ; Mon, 4 Oct 2021 06:00:25 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXNZO-0005B6-5Z; Mon, 04 Oct 2021 14:59:50 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1mXNZJ-0000Lr-Cz; Mon, 04 Oct 2021 14:59:45 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1mXNZG-0000cu-9R; Mon, 04 Oct 2021 14:59:42 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, kernel@pengutronix.de, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Zhou Wang , Herbert Xu , "David S. Miller" , Yisen Zhuang , Salil Mehta , Jakub Kicinski , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , Simon Horman , Michael Buesch , "Oliver O'Halloran" , Jesse Brandeburg , Alexander Duyck , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-crypto@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@corigine.com Subject: [PATCH v6 07/11] PCI: Replace pci_dev::driver usage that gets the driver name Date: Mon, 4 Oct 2021 14:59:31 +0200 Message-Id: <20211004125935.2300113-8-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> References: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=x5Y9j5QPtBpKPfcAJK/OT7BRgKvI7pSChd5/rmmq6Xw=; m=nEqg0QrmbDfsrPkKSQiKF1eTL+0Rkaib5pkx/JtL0jE=; p=P030KPvGBgn0wACiWmlhwa6Q6u7mafsHSYpCChEQFbg=; g=d855fa8a2569029e17368da8c0bf9fc2e6496586 X-Patch-Sig: m=pgp; i=u.kleine-koenig@pengutronix.de; s=0x0D2511F322BFAB1C1580266BE2DCDD9132669BD6; b=iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmFa+p8ACgkQwfwUeK3K7Akgawf/Xx3 8d1n/PRIuyXwavQQ5ZVCnDnLvAZf8+W7tgrZMDmQqmxTiRWDEtMW9LEabr1RZmRaiCb+iYFFZVNEL jDL5v6WZi1ZzNdk66VUUJjjCglQ8U9tTPobkm/evwZTZCDkfhr7UoYSUZqL8LIbHsvtW5onQJdi+y d7dmNzs7w6Zc9mvpoxyA76r98YmB/hgU413bLQ5g9Jhw2orQ8bQkguQZNIEhu9xR8q+Yco7Q8f0IG QRXdirMMHXks9FkjFqHywZfNwjh72LrULqxY9Difn0Wsbov5UijaUM1BzClFn9RQMu+d7iWK6T4E9 796RuLTiXS0J78uftSGRmBl7z6UHyQg== X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-pci@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org struct pci_dev::driver holds (apart from a constant offset) the same data as struct pci_dev::dev->driver. With the goal to remove struct pci_dev::driver to get rid of data duplication replace getting the driver name by dev_driver_string() which implicitly makes use of struct pci_dev::dev->driver. Acked-by: Simon Horman (for NFP) Signed-off-by: Uwe Kleine-König Reviewed-by: Ido Schimmel Tested-by: Ido Schimmel --- drivers/crypto/hisilicon/qm.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 2 +- drivers/net/ethernet/marvell/prestera/prestera_pci.c | 2 +- drivers/net/ethernet/mellanox/mlxsw/pci.c | 2 +- drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c | 3 ++- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 369562d34d66..8f361e54e524 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -3085,7 +3085,7 @@ static int qm_alloc_uacce(struct hisi_qm *qm) }; int ret; - ret = strscpy(interface.name, pdev->driver->name, + ret = strscpy(interface.name, dev_driver_string(&pdev->dev), sizeof(interface.name)); if (ret < 0) return -ENAMETOOLONG; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 7ea511d59e91..f279edfce3f1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -606,7 +606,7 @@ static void hns3_get_drvinfo(struct net_device *netdev, return; } - strncpy(drvinfo->driver, h->pdev->driver->name, + strncpy(drvinfo->driver, dev_driver_string(&h->pdev->dev), sizeof(drvinfo->driver)); drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0'; diff --git a/drivers/net/ethernet/marvell/prestera/prestera_pci.c b/drivers/net/ethernet/marvell/prestera/prestera_pci.c index a250d394da38..a8f007f6dad2 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_pci.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_pci.c @@ -720,7 +720,7 @@ static int prestera_fw_load(struct prestera_fw *fw) static int prestera_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { - const char *driver_name = pdev->driver->name; + const char *driver_name = dev_driver_string(&pdev->dev); struct prestera_fw *fw; int err; diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c index 13b0259f7ea6..8f306364f7bf 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/pci.c +++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c @@ -1876,7 +1876,7 @@ static void mlxsw_pci_cmd_fini(struct mlxsw_pci *mlxsw_pci) static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { - const char *driver_name = pdev->driver->name; + const char *driver_name = dev_driver_string(&pdev->dev); struct mlxsw_pci *mlxsw_pci; int err; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c index 0685ece1f155..1de076f55740 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c @@ -202,7 +202,8 @@ nfp_get_drvinfo(struct nfp_app *app, struct pci_dev *pdev, { char nsp_version[ETHTOOL_FWVERS_LEN] = {}; - strlcpy(drvinfo->driver, pdev->driver->name, sizeof(drvinfo->driver)); + strlcpy(drvinfo->driver, dev_driver_string(&pdev->dev), + sizeof(drvinfo->driver)); nfp_net_get_nspinfo(app, nsp_version); snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "%s %s %s %s", vnic_version, nsp_version, From patchwork Mon Oct 4 12:59:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 12533901 X-Patchwork-Delegate: bhelgaas@google.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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 964A6C433FE for ; Mon, 4 Oct 2021 13:36:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F4F5611CB for ; Mon, 4 Oct 2021 13:36:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237852AbhJDNh5 (ORCPT ); Mon, 4 Oct 2021 09:37:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235673AbhJDNf5 (ORCPT ); Mon, 4 Oct 2021 09:35:57 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 472B5C02B76D for ; Mon, 4 Oct 2021 05:59:54 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXNZO-0005Kb-Nf; Mon, 04 Oct 2021 14:59:50 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1mXNZN-0000Mn-KM; Mon, 04 Oct 2021 14:59:49 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1mXNZG-0000cx-FR; Mon, 04 Oct 2021 14:59:42 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, kernel@pengutronix.de, Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, "Martin K . Petersen" , Christoph Hellwig Subject: [PATCH v6 08/11] scsi: message: fusion: Remove unused parameter of mpt_pci driver's probe() Date: Mon, 4 Oct 2021 14:59:32 +0200 Message-Id: <20211004125935.2300113-9-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> References: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=Qw3P/Tfw3H2aE9nuVn1p4NHDqaHGErEmfJmO6L2HF80=; m=oP54miBWrkCU6D5dir8+ZifQgR+cn/3uLfRD8ejXKkU=; p=swgwO0gHobGOw9bvcebWnvhUeGHl0wdD920V7Jm9gyE=; g=2a2dbd5e6a461e2ef057dc0c5df0fe68c3d03bd6 X-Patch-Sig: m=pgp; i=u.kleine-koenig@pengutronix.de; s=0x0D2511F322BFAB1C1580266BE2DCDD9132669BD6; b=iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmFa+qIACgkQwfwUeK3K7AlgIQgAkSE 2UVcsvbX+K9t/SIp3vxn8+uHdWW4NOTduI3SOuDeFxA/CtD1BeFDUhquMKungE0lYQNeg0ZW+FXiX D/x8kXK1iK22apWyzZGBJxnVfeujKytUEmZzlPARZr0v737TEvvWJFE9vojHpWFYmsHnw83J+G522 GBtgWRHJ+NcphlXAQj/YOpNqZObuuUFT1uHnYjJMvsk1HxIZmayM6gpz3e8l2xA6XHgNyxqHan0fI 2G14+wH1E0KtcgAqyTKesQ3oZ2UUkFO7p7IPgQrO6wbcOhyEjLVzPZ4Z1PzBdXN7WCTymDQ+CT3nD 79rrvaUTlRqVSuz39kuSjVzh7DntGrw== X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-pci@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The only two drivers don't make use of the id parameter, so drop it. This removes a usage of struct pci_dev::driver which is planned to be removed as it tracks duplicate data. Acked-by: Martin K. Petersen Reviewed-by: Christoph Hellwig Signed-off-by: Uwe Kleine-König --- drivers/message/fusion/mptbase.c | 7 ++----- drivers/message/fusion/mptbase.h | 2 +- drivers/message/fusion/mptctl.c | 4 ++-- drivers/message/fusion/mptlan.c | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c index 7f7abc9069f7..b94d5e4fdc23 100644 --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c @@ -829,7 +829,6 @@ int mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, u8 cb_idx) { MPT_ADAPTER *ioc; - const struct pci_device_id *id; if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) return -EINVAL; @@ -838,10 +837,8 @@ mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, u8 cb_idx) /* call per pci device probe entry point */ list_for_each_entry(ioc, &ioc_list, list) { - id = ioc->pcidev->driver ? - ioc->pcidev->driver->id_table : NULL; if (dd_cbfunc->probe) - dd_cbfunc->probe(ioc->pcidev, id); + dd_cbfunc->probe(ioc->pcidev); } return 0; @@ -2032,7 +2029,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) for(cb_idx = 0; cb_idx < MPT_MAX_PROTOCOL_DRIVERS; cb_idx++) { if(MptDeviceDriverHandlers[cb_idx] && MptDeviceDriverHandlers[cb_idx]->probe) { - MptDeviceDriverHandlers[cb_idx]->probe(pdev,id); + MptDeviceDriverHandlers[cb_idx]->probe(pdev); } } diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h index b9e0376be723..4bd0682c65d3 100644 --- a/drivers/message/fusion/mptbase.h +++ b/drivers/message/fusion/mptbase.h @@ -257,7 +257,7 @@ typedef enum { } MPT_DRIVER_CLASS; struct mpt_pci_driver{ - int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); + int (*probe) (struct pci_dev *dev); void (*remove) (struct pci_dev *dev); }; diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index 72025996cd70..ae433c150b37 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c @@ -114,7 +114,7 @@ static int mptctl_do_reset(MPT_ADAPTER *iocp, unsigned long arg); static int mptctl_hp_hostinfo(MPT_ADAPTER *iocp, unsigned long arg, unsigned int cmd); static int mptctl_hp_targetinfo(MPT_ADAPTER *iocp, unsigned long arg); -static int mptctl_probe(struct pci_dev *, const struct pci_device_id *); +static int mptctl_probe(struct pci_dev *); static void mptctl_remove(struct pci_dev *); #ifdef CONFIG_COMPAT @@ -2838,7 +2838,7 @@ static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long a */ static int -mptctl_probe(struct pci_dev *pdev, const struct pci_device_id *id) +mptctl_probe(struct pci_dev *pdev) { MPT_ADAPTER *ioc = pci_get_drvdata(pdev); diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c index 3261cac762de..7c1af5e6eb0b 100644 --- a/drivers/message/fusion/mptlan.c +++ b/drivers/message/fusion/mptlan.c @@ -1377,7 +1377,7 @@ mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum) } static int -mptlan_probe(struct pci_dev *pdev, const struct pci_device_id *id) +mptlan_probe(struct pci_dev *pdev) { MPT_ADAPTER *ioc = pci_get_drvdata(pdev); struct net_device *dev; From patchwork Mon Oct 4 12:59:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 12533903 X-Patchwork-Delegate: bhelgaas@google.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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10A63C4332F for ; Mon, 4 Oct 2021 13:37:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E705D61164 for ; Mon, 4 Oct 2021 13:37:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237632AbhJDNiy (ORCPT ); Mon, 4 Oct 2021 09:38:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237226AbhJDNhC (ORCPT ); Mon, 4 Oct 2021 09:37:02 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C901C061369 for ; Mon, 4 Oct 2021 06:00:04 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXNZN-0005EB-5a; Mon, 04 Oct 2021 14:59:49 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1mXNZK-0000Lu-1h; Mon, 04 Oct 2021 14:59:46 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1mXNZG-0000d0-Vc; Mon, 04 Oct 2021 14:59:42 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, kernel@pengutronix.de, Giovanni Cabiddu , Herbert Xu , "David S. Miller" , Tomaszx Kowalik , Fiona Trahe , Marco Chiappero , Andy Shevchenko , Wojciech Ziemba , Jack Xu , qat-linux@intel.com, linux-crypto@vger.kernel.org Subject: [PATCH v6 09/11] crypto: qat - simplify adf_enable_aer() Date: Mon, 4 Oct 2021 14:59:33 +0200 Message-Id: <20211004125935.2300113-10-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> References: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=woJ+XG24qLZpRfQYIhuIjBJ10HF9ai4yZDNEgvzBdKs=; m=43Bwh4bgNofseZy3pN98J/xw6T54xBXYb8+EgplqK/c=; p=e0ubWRxaTOxpVVmYaiPGXfH9Fp+aEsg5i7cfFIxLb4w=; g=75d910e3cf936fc2161d0c2f4f099378e2733742 X-Patch-Sig: m=pgp; i=u.kleine-koenig@pengutronix.de; s=0x0D2511F322BFAB1C1580266BE2DCDD9132669BD6; b=iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmFa+qUACgkQwfwUeK3K7AnPogf/eah oJ3UrQN2jf+An7FP3zNu4rS7El07kskIfjiMK5JSBfg28Bxw4A1QVJIiPy31kIxUq10JjMh7qLBvM chciHIPpHlZcTPksJ7F54CPO9sh2xH9BxQaieCa87eOSbkm39O6ht/t5+lG51xpCiBdapbO7Pv+WD qlcJjJXuR5FFT4M6ftq9OBDSQ58U0uOCMuKyONUa/xJt8ZZj58d59LapLofNSEpgGai3CJMFuaUHm l8y2UWlkTg9qR3i0ZnPhw4E6QQI8BiQETNpt2WuMvk1JBCLZzY097UDpPIuDEeAATRVF74Screawk is7yOrtCIY4jVCRN66+/oPUSsSv+S/g== X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-pci@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org A struct pci_driver is supposed to be constant and assigning .err_handler once per bound device isn't really sensible. Also as the function returns zero unconditionally let it return no value instead and simplify the callers accordingly. As a side effect this removes one user of struct pci_dev::driver. This member is planned to be removed. Signed-off-by: Uwe Kleine-König --- drivers/crypto/qat/qat_4xxx/adf_drv.c | 7 ++----- drivers/crypto/qat/qat_c3xxx/adf_drv.c | 7 ++----- drivers/crypto/qat/qat_c62x/adf_drv.c | 7 ++----- drivers/crypto/qat/qat_common/adf_aer.c | 10 +++------- drivers/crypto/qat/qat_common/adf_common_drv.h | 3 ++- drivers/crypto/qat/qat_dh895xcc/adf_drv.c | 7 ++----- 6 files changed, 13 insertions(+), 28 deletions(-) diff --git a/drivers/crypto/qat/qat_4xxx/adf_drv.c b/drivers/crypto/qat/qat_4xxx/adf_drv.c index 359fb7989dfb..71ef065914b2 100644 --- a/drivers/crypto/qat/qat_4xxx/adf_drv.c +++ b/drivers/crypto/qat/qat_4xxx/adf_drv.c @@ -247,11 +247,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_set_master(pdev); - if (adf_enable_aer(accel_dev)) { - dev_err(&pdev->dev, "Failed to enable aer.\n"); - ret = -EFAULT; - goto out_err; - } + adf_enable_aer(accel_dev); if (pci_save_state(pdev)) { dev_err(&pdev->dev, "Failed to save pci state.\n"); @@ -304,6 +300,7 @@ static struct pci_driver adf_driver = { .probe = adf_probe, .remove = adf_remove, .sriov_configure = adf_sriov_configure, + .err_handler = &adf_err_handler, }; module_pci_driver(adf_driver); diff --git a/drivers/crypto/qat/qat_c3xxx/adf_drv.c b/drivers/crypto/qat/qat_c3xxx/adf_drv.c index cc6e75dc60de..2aef0bb791df 100644 --- a/drivers/crypto/qat/qat_c3xxx/adf_drv.c +++ b/drivers/crypto/qat/qat_c3xxx/adf_drv.c @@ -33,6 +33,7 @@ static struct pci_driver adf_driver = { .probe = adf_probe, .remove = adf_remove, .sriov_configure = adf_sriov_configure, + .err_handler = &adf_err_handler, }; static void adf_cleanup_pci_dev(struct adf_accel_dev *accel_dev) @@ -192,11 +193,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } pci_set_master(pdev); - if (adf_enable_aer(accel_dev)) { - dev_err(&pdev->dev, "Failed to enable aer\n"); - ret = -EFAULT; - goto out_err_free_reg; - } + adf_enable_aer(accel_dev); if (pci_save_state(pdev)) { dev_err(&pdev->dev, "Failed to save pci state\n"); diff --git a/drivers/crypto/qat/qat_c62x/adf_drv.c b/drivers/crypto/qat/qat_c62x/adf_drv.c index bf251dfe74b3..56163083f161 100644 --- a/drivers/crypto/qat/qat_c62x/adf_drv.c +++ b/drivers/crypto/qat/qat_c62x/adf_drv.c @@ -33,6 +33,7 @@ static struct pci_driver adf_driver = { .probe = adf_probe, .remove = adf_remove, .sriov_configure = adf_sriov_configure, + .err_handler = &adf_err_handler, }; static void adf_cleanup_pci_dev(struct adf_accel_dev *accel_dev) @@ -192,11 +193,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } pci_set_master(pdev); - if (adf_enable_aer(accel_dev)) { - dev_err(&pdev->dev, "Failed to enable aer\n"); - ret = -EFAULT; - goto out_err_free_reg; - } + adf_enable_aer(accel_dev); if (pci_save_state(pdev)) { dev_err(&pdev->dev, "Failed to save pci state\n"); diff --git a/drivers/crypto/qat/qat_common/adf_aer.c b/drivers/crypto/qat/qat_common/adf_aer.c index ed3e40bc56eb..fe9bb2f3536a 100644 --- a/drivers/crypto/qat/qat_common/adf_aer.c +++ b/drivers/crypto/qat/qat_common/adf_aer.c @@ -166,11 +166,12 @@ static void adf_resume(struct pci_dev *pdev) dev_info(&pdev->dev, "Device is up and running\n"); } -static const struct pci_error_handlers adf_err_handler = { +const struct pci_error_handlers adf_err_handler = { .error_detected = adf_error_detected, .slot_reset = adf_slot_reset, .resume = adf_resume, }; +EXPORT_SYMBOL_GPL(adf_err_handler); /** * adf_enable_aer() - Enable Advance Error Reporting for acceleration device @@ -179,17 +180,12 @@ static const struct pci_error_handlers adf_err_handler = { * Function enables PCI Advance Error Reporting for the * QAT acceleration device accel_dev. * To be used by QAT device specific drivers. - * - * Return: 0 on success, error code otherwise. */ -int adf_enable_aer(struct adf_accel_dev *accel_dev) +void adf_enable_aer(struct adf_accel_dev *accel_dev) { struct pci_dev *pdev = accel_to_pci_dev(accel_dev); - struct pci_driver *pdrv = pdev->driver; - pdrv->err_handler = &adf_err_handler; pci_enable_pcie_error_reporting(pdev); - return 0; } EXPORT_SYMBOL_GPL(adf_enable_aer); diff --git a/drivers/crypto/qat/qat_common/adf_common_drv.h b/drivers/crypto/qat/qat_common/adf_common_drv.h index 4261749fae8d..e4c24be212ff 100644 --- a/drivers/crypto/qat/qat_common/adf_common_drv.h +++ b/drivers/crypto/qat/qat_common/adf_common_drv.h @@ -95,7 +95,8 @@ void adf_ae_fw_release(struct adf_accel_dev *accel_dev); int adf_ae_start(struct adf_accel_dev *accel_dev); int adf_ae_stop(struct adf_accel_dev *accel_dev); -int adf_enable_aer(struct adf_accel_dev *accel_dev); +extern const struct pci_error_handlers adf_err_handler; +void adf_enable_aer(struct adf_accel_dev *accel_dev); void adf_disable_aer(struct adf_accel_dev *accel_dev); void adf_reset_sbr(struct adf_accel_dev *accel_dev); void adf_reset_flr(struct adf_accel_dev *accel_dev); diff --git a/drivers/crypto/qat/qat_dh895xcc/adf_drv.c b/drivers/crypto/qat/qat_dh895xcc/adf_drv.c index 3976a81bd99b..acca56752aa0 100644 --- a/drivers/crypto/qat/qat_dh895xcc/adf_drv.c +++ b/drivers/crypto/qat/qat_dh895xcc/adf_drv.c @@ -33,6 +33,7 @@ static struct pci_driver adf_driver = { .probe = adf_probe, .remove = adf_remove, .sriov_configure = adf_sriov_configure, + .err_handler = &adf_err_handler, }; static void adf_cleanup_pci_dev(struct adf_accel_dev *accel_dev) @@ -192,11 +193,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } pci_set_master(pdev); - if (adf_enable_aer(accel_dev)) { - dev_err(&pdev->dev, "Failed to enable aer\n"); - ret = -EFAULT; - goto out_err_free_reg; - } + adf_enable_aer(accel_dev); if (pci_save_state(pdev)) { dev_err(&pdev->dev, "Failed to save pci state\n"); From patchwork Mon Oct 4 12:59:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 12533923 X-Patchwork-Delegate: bhelgaas@google.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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D8BFC433EF for ; Mon, 4 Oct 2021 13:40:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D2F1613AD for ; Mon, 4 Oct 2021 13:40:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238338AbhJDNmD (ORCPT ); Mon, 4 Oct 2021 09:42:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238372AbhJDNkW (ORCPT ); Mon, 4 Oct 2021 09:40:22 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48950C06136E for ; Mon, 4 Oct 2021 06:00:38 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXNZL-00055S-Ir; Mon, 04 Oct 2021 14:59:47 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1mXNZH-0000LX-AH; Mon, 04 Oct 2021 14:59:43 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1mXNZH-0000d3-7t; Mon, 04 Oct 2021 14:59:43 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, kernel@pengutronix.de, Russell Currey , "Oliver O'Halloran" , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Frederic Barrat , Andrew Donnellan , Arnd Bergmann , Greg Kroah-Hartman , Bjorn Helgaas , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Konrad Rzeszutek Wilk , Mathias Nyman , linuxppc-dev@lists.ozlabs.org, linux-perf-users@vger.kernel.org, xen-devel@lists.xenproject.org, linux-usb@vger.kernel.org Subject: [PATCH v6 10/11] PCI: Replace pci_dev::driver usage by pci_dev::dev.driver Date: Mon, 4 Oct 2021 14:59:34 +0200 Message-Id: <20211004125935.2300113-11-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> References: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=/pZgVMb346xYWFyKXoYzQiwqLbFb4Qw5wqFIqjkKa+4=; m=FyMqGYUG+9Ut7bWwCBeeUgHOxoK/KbMAjt+cyx+MULA=; p=Av5qfMnrDTtNxfRgMp26LOqOMV4xtxFiJlRkPzujoa8=; g=83869c2c7c1ddaa0f90cc111fab61100dab63d9d X-Patch-Sig: m=pgp; i=u.kleine-koenig@pengutronix.de; s=0x0D2511F322BFAB1C1580266BE2DCDD9132669BD6; b=iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmFa+qgACgkQwfwUeK3K7AldKwf/cPy CnIgfE0NaztkicLWjXoy3/B+C9RMJD0L7z5jWhMxqk13IoI6/sBomAxA2l+x3fMXkjYrXON8De6P8 LKG9sUd7VSMFEAWwQmnEdgVrniKWDgQEWOm8LIC/IOHVJe3vvWlMAb8Lp+ZlCqfga5N5OeAWq2RGp zK+W9FzcN+QvmZmKRRLwSDNE9LHV8cxSe702ZABCWlpLr/2wUmzMkLluchD+GSX60P92lk6Y1vDS1 rhqVcpO2/o39jIUBb1Ek3p3oHAUlq66h5s5z2lVvpdo8MAtSPK3y/hsHsPNuePaCJHRzbEsaM3nox QoZR2AME45/sUgeaNeMYg+wotfusCpg== X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-pci@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org struct pci_dev::driver contains (apart from a constant offset) the same data as struct pci_dev::dev->driver. Replace all remaining users of the former pointer by the latter to allow removing the former. Reviewed-by: Boris Ostrovsky Signed-off-by: Uwe Kleine-König --- arch/powerpc/kernel/eeh_driver.c | 10 ++--- arch/x86/events/intel/uncore.c | 2 +- arch/x86/kernel/probe_roms.c | 10 +++-- drivers/misc/cxl/guest.c | 24 +++++----- drivers/misc/cxl/pci.c | 30 ++++++++----- drivers/pci/iov.c | 33 ++++++++++---- drivers/pci/pci-driver.c | 76 +++++++++++++++++++------------- drivers/pci/pci.c | 4 +- drivers/pci/pcie/err.c | 36 ++++++++------- drivers/pci/xen-pcifront.c | 4 +- drivers/usb/host/xhci-pci.c | 2 +- 11 files changed, 140 insertions(+), 91 deletions(-) diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c index 3eff6a4888e7..350dab18e137 100644 --- a/arch/powerpc/kernel/eeh_driver.c +++ b/arch/powerpc/kernel/eeh_driver.c @@ -104,13 +104,13 @@ static bool eeh_edev_actionable(struct eeh_dev *edev) */ static inline struct pci_driver *eeh_pcid_get(struct pci_dev *pdev) { - if (!pdev || !pdev->driver) + if (!pdev || !pdev->dev.driver) return NULL; - if (!try_module_get(pdev->driver->driver.owner)) + if (!try_module_get(pdev->dev.driver->owner)) return NULL; - return pdev->driver; + return to_pci_driver(pdev->dev.driver); } /** @@ -122,10 +122,10 @@ static inline struct pci_driver *eeh_pcid_get(struct pci_dev *pdev) */ static inline void eeh_pcid_put(struct pci_dev *pdev) { - if (!pdev || !pdev->driver) + if (!pdev || !pdev->dev.driver) return; - module_put(pdev->driver->driver.owner); + module_put(pdev->dev.driver->owner); } /** diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index c72e368dd164..f1ba6ab2e97e 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -1187,7 +1187,7 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id * PCI slot and func to indicate the uncore box. */ if (id->driver_data & ~0xffff) { - struct pci_driver *pci_drv = pdev->driver; + struct pci_driver *pci_drv = to_pci_driver(pdev->dev.driver); pmu = uncore_pci_find_dev_pmu(pdev, pci_drv->id_table); if (pmu == NULL) diff --git a/arch/x86/kernel/probe_roms.c b/arch/x86/kernel/probe_roms.c index 9e1def3744f2..deaaef6efe34 100644 --- a/arch/x86/kernel/probe_roms.c +++ b/arch/x86/kernel/probe_roms.c @@ -80,15 +80,17 @@ static struct resource video_rom_resource = { */ static bool match_id(struct pci_dev *pdev, unsigned short vendor, unsigned short device) { - struct pci_driver *drv = pdev->driver; const struct pci_device_id *id; if (pdev->vendor == vendor && pdev->device == device) return true; - for (id = drv ? drv->id_table : NULL; id && id->vendor; id++) - if (id->vendor == vendor && id->device == device) - break; + if (pdev->dev.driver) { + struct pci_driver *drv = to_pci_driver(pdev->dev.driver); + for (id = drv->id_table; id && id->vendor; id++) + if (id->vendor == vendor && id->device == device) + break; + } return id && id->vendor; } diff --git a/drivers/misc/cxl/guest.c b/drivers/misc/cxl/guest.c index 186308f1f8eb..d997c9c3ebb5 100644 --- a/drivers/misc/cxl/guest.c +++ b/drivers/misc/cxl/guest.c @@ -25,28 +25,32 @@ static void pci_error_handlers(struct cxl_afu *afu, return; list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) { - if (!afu_dev->driver) + struct pci_driver *afu_drv; + + if (!afu_dev->dev.driver) continue; + afu_drv = to_pci_driver(afu_dev->dev.driver); + switch (bus_error_event) { case CXL_ERROR_DETECTED_EVENT: afu_dev->error_state = state; - if (afu_dev->driver->err_handler && - afu_dev->driver->err_handler->error_detected) - afu_dev->driver->err_handler->error_detected(afu_dev, state); + if (afu_drv->err_handler && + afu_drv->err_handler->error_detected) + afu_drv->err_handler->error_detected(afu_dev, state); break; case CXL_SLOT_RESET_EVENT: afu_dev->error_state = state; - if (afu_dev->driver->err_handler && - afu_dev->driver->err_handler->slot_reset) - afu_dev->driver->err_handler->slot_reset(afu_dev); + if (afu_drv->err_handler && + afu_drv->err_handler->slot_reset) + afu_drv->err_handler->slot_reset(afu_dev); break; case CXL_RESUME_EVENT: - if (afu_dev->driver->err_handler && - afu_dev->driver->err_handler->resume) - afu_dev->driver->err_handler->resume(afu_dev); + if (afu_drv->err_handler && + afu_drv->err_handler->resume) + afu_drv->err_handler->resume(afu_dev); break; } } diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c index 2ba899f5659f..7e7545d01e27 100644 --- a/drivers/misc/cxl/pci.c +++ b/drivers/misc/cxl/pci.c @@ -1805,14 +1805,16 @@ static pci_ers_result_t cxl_vphb_error_detected(struct cxl_afu *afu, return result; list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) { - if (!afu_dev->driver) + struct pci_driver *afu_drv; + if (!afu_dev->dev.driver) continue; + afu_drv = to_pci_driver(afu_dev->dev.driver); + afu_dev->error_state = state; - if (afu_dev->driver->err_handler) - afu_result = afu_dev->driver->err_handler->error_detected(afu_dev, - state); + if (afu_drv->err_handler) + afu_result = afu_drv->err_handler->error_detected(afu_dev, state); /* Disconnect trumps all, NONE trumps NEED_RESET */ if (afu_result == PCI_ERS_RESULT_DISCONNECT) result = PCI_ERS_RESULT_DISCONNECT; @@ -2003,6 +2005,8 @@ static pci_ers_result_t cxl_pci_slot_reset(struct pci_dev *pdev) continue; list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) { + struct pci_driver *afu_drv; + /* Reset the device context. * TODO: make this less disruptive */ @@ -2028,12 +2032,14 @@ static pci_ers_result_t cxl_pci_slot_reset(struct pci_dev *pdev) * shouldn't start new work until we call * their resume function. */ - if (!afu_dev->driver) + if (!afu_dev->dev.driver) continue; - if (afu_dev->driver->err_handler && - afu_dev->driver->err_handler->slot_reset) - afu_result = afu_dev->driver->err_handler->slot_reset(afu_dev); + afu_drv = to_pci_driver(afu_dev->dev.driver); + + if (afu_drv->err_handler && + afu_drv->err_handler->slot_reset) + afu_result = afu_drv->err_handler->slot_reset(afu_dev); if (afu_result == PCI_ERS_RESULT_DISCONNECT) result = PCI_ERS_RESULT_DISCONNECT; @@ -2074,9 +2080,11 @@ static void cxl_pci_resume(struct pci_dev *pdev) continue; list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) { - if (afu_dev->driver && afu_dev->driver->err_handler && - afu_dev->driver->err_handler->resume) - afu_dev->driver->err_handler->resume(afu_dev); + struct pci_driver *afu_drv; + if (afu_dev->dev.driver && + (afu_drv = to_pci_driver(afu_dev->dev.driver))->err_handler && + afu_drv->err_handler->resume) + afu_drv->err_handler->resume(afu_dev); } } spin_unlock(&adapter->afu_list_lock); diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index dafdc652fcd0..0d0a34347868 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -164,13 +164,18 @@ static ssize_t sriov_vf_total_msix_show(struct device *dev, char *buf) { struct pci_dev *pdev = to_pci_dev(dev); + struct pci_driver *pdrv; u32 vf_total_msix = 0; device_lock(dev); - if (!pdev->driver || !pdev->driver->sriov_get_vf_total_msix) + if (!dev->driver) goto unlock; - vf_total_msix = pdev->driver->sriov_get_vf_total_msix(pdev); + pdrv = to_pci_driver(dev->driver); + if (!pdrv->sriov_get_vf_total_msix) + goto unlock; + + vf_total_msix = pdrv->sriov_get_vf_total_msix(pdev); unlock: device_unlock(dev); return sysfs_emit(buf, "%u\n", vf_total_msix); @@ -183,6 +188,7 @@ static ssize_t sriov_vf_msix_count_store(struct device *dev, { struct pci_dev *vf_dev = to_pci_dev(dev); struct pci_dev *pdev = pci_physfn(vf_dev); + struct pci_driver *pdrv; int val, ret; ret = kstrtoint(buf, 0, &val); @@ -193,13 +199,19 @@ static ssize_t sriov_vf_msix_count_store(struct device *dev, return -EINVAL; device_lock(&pdev->dev); - if (!pdev->driver || !pdev->driver->sriov_set_msix_vec_count) { + if (!pdev->dev.driver) { + ret = -EOPNOTSUPP; + goto err_pdev; + } + + pdrv = to_pci_driver(pdev->dev.driver); + if (!pdrv->sriov_set_msix_vec_count) { ret = -EOPNOTSUPP; goto err_pdev; } device_lock(&vf_dev->dev); - if (vf_dev->driver) { + if (vf_dev->dev.driver) { /* * A driver is already attached to this VF and has configured * itself based on the current MSI-X vector count. Changing @@ -209,7 +221,7 @@ static ssize_t sriov_vf_msix_count_store(struct device *dev, goto err_dev; } - ret = pdev->driver->sriov_set_msix_vec_count(vf_dev, val); + ret = pdrv->sriov_set_msix_vec_count(vf_dev, val); err_dev: device_unlock(&vf_dev->dev); @@ -376,6 +388,7 @@ static ssize_t sriov_numvfs_store(struct device *dev, const char *buf, size_t count) { struct pci_dev *pdev = to_pci_dev(dev); + struct pci_driver *pdrv; int ret; u16 num_vfs; @@ -392,14 +405,16 @@ static ssize_t sriov_numvfs_store(struct device *dev, goto exit; /* is PF driver loaded */ - if (!pdev->driver) { + if (!pdev->dev.driver) { pci_info(pdev, "no driver bound to device; cannot configure SR-IOV\n"); ret = -ENOENT; goto exit; } + pdrv = to_pci_driver(pdev->dev.driver); + /* is PF driver loaded w/callback */ - if (!pdev->driver->sriov_configure) { + if (!pdrv->sriov_configure) { pci_info(pdev, "driver does not support SR-IOV configuration via sysfs\n"); ret = -ENOENT; goto exit; @@ -407,7 +422,7 @@ static ssize_t sriov_numvfs_store(struct device *dev, if (num_vfs == 0) { /* disable VFs */ - ret = pdev->driver->sriov_configure(pdev, 0); + ret = pdrv->sriov_configure(pdev, 0); goto exit; } @@ -419,7 +434,7 @@ static ssize_t sriov_numvfs_store(struct device *dev, goto exit; } - ret = pdev->driver->sriov_configure(pdev, num_vfs); + ret = pdrv->sriov_configure(pdev, num_vfs); if (ret < 0) goto exit; diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 50449ec622a3..8654fe70cd66 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -457,7 +457,7 @@ static int pci_device_probe(struct device *dev) static void pci_device_remove(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); - struct pci_driver *drv = pci_dev->driver; + struct pci_driver *drv = to_pci_driver(pci_dev->dev.driver); if (drv->remove) { pm_runtime_get_sync(dev); @@ -493,12 +493,15 @@ static void pci_device_remove(struct device *dev) static void pci_device_shutdown(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); - struct pci_driver *drv = pci_dev->driver; pm_runtime_resume(dev); - if (drv && drv->shutdown) - drv->shutdown(pci_dev); + if (pci_dev->dev.driver) { + struct pci_driver *drv = to_pci_driver(pci_dev->dev.driver); + + if (drv->shutdown) + drv->shutdown(pci_dev); + } /* * If this is a kexec reboot, turn off Bus Master bit on the @@ -589,22 +592,25 @@ static int pci_pm_reenable_device(struct pci_dev *pci_dev) static int pci_legacy_suspend(struct device *dev, pm_message_t state) { struct pci_dev *pci_dev = to_pci_dev(dev); - struct pci_driver *drv = pci_dev->driver; - if (drv && drv->suspend) { - pci_power_t prev = pci_dev->current_state; - int error; + if (dev->driver) { + struct pci_driver *drv = to_pci_driver(dev->driver); - error = drv->suspend(pci_dev, state); - suspend_report_result(drv->suspend, error); - if (error) - return error; + if (drv->suspend) { + pci_power_t prev = pci_dev->current_state; + int error; - if (!pci_dev->state_saved && pci_dev->current_state != PCI_D0 - && pci_dev->current_state != PCI_UNKNOWN) { - pci_WARN_ONCE(pci_dev, pci_dev->current_state != prev, - "PCI PM: Device state not saved by %pS\n", - drv->suspend); + error = drv->suspend(pci_dev, state); + suspend_report_result(drv->suspend, error); + if (error) + return error; + + if (!pci_dev->state_saved && pci_dev->current_state != PCI_D0 + && pci_dev->current_state != PCI_UNKNOWN) { + pci_WARN_ONCE(pci_dev, pci_dev->current_state != prev, + "PCI PM: Device state not saved by %pS\n", + drv->suspend); + } } } @@ -630,12 +636,17 @@ static int pci_legacy_suspend_late(struct device *dev, pm_message_t state) static int pci_legacy_resume(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); - struct pci_driver *drv = pci_dev->driver; pci_fixup_device(pci_fixup_resume, pci_dev); - return drv && drv->resume ? - drv->resume(pci_dev) : pci_pm_reenable_device(pci_dev); + if (pci_dev->dev.driver) { + struct pci_driver *drv = to_pci_driver(pci_dev->dev.driver); + + if (drv->resume) + return drv->resume(pci_dev); + } + + return pci_pm_reenable_device(pci_dev); } /* Auxiliary functions used by the new power management framework */ @@ -649,8 +660,14 @@ static void pci_pm_default_suspend(struct pci_dev *pci_dev) static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev) { - struct pci_driver *drv = pci_dev->driver; - bool ret = drv && (drv->suspend || drv->resume); + struct pci_driver *drv; + bool ret; + + if (!pci_dev->dev.driver) + return false; + + drv = to_pci_driver(pci_dev->dev.driver); + ret = drv && (drv->suspend || drv->resume); /* * Legacy PM support is used by default, so warn if the new framework is @@ -1242,11 +1259,11 @@ static int pci_pm_runtime_suspend(struct device *dev) int error; /* - * If pci_dev->driver is not set (unbound), we leave the device in D0, + * If pci_dev->dev.driver is not set (unbound), we leave the device in D0, * but it may go to D3cold when the bridge above it runtime suspends. * Save its config space in case that happens. */ - if (!pci_dev->driver) { + if (!pci_dev->dev.driver) { pci_save_state(pci_dev); return 0; } @@ -1303,7 +1320,7 @@ static int pci_pm_runtime_resume(struct device *dev) */ pci_restore_standard_config(pci_dev); - if (!pci_dev->driver) + if (!dev->driver) return 0; pci_fixup_device(pci_fixup_resume_early, pci_dev); @@ -1322,14 +1339,13 @@ static int pci_pm_runtime_resume(struct device *dev) static int pci_pm_runtime_idle(struct device *dev) { - struct pci_dev *pci_dev = to_pci_dev(dev); const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; /* - * If pci_dev->driver is not set (unbound), the device should + * If dev->driver is not set (unbound), the device should * always remain in D0 regardless of the runtime PM status */ - if (!pci_dev->driver) + if (!dev->driver) return 0; if (!pm) @@ -1436,8 +1452,8 @@ static struct pci_driver pci_compat_driver = { */ struct pci_driver *pci_dev_driver(const struct pci_dev *dev) { - if (dev->driver) - return dev->driver; + if (dev->dev.driver) + return to_pci_driver(dev->dev.driver); else { int i; for (i = 0; i <= PCI_ROM_RESOURCE; i++) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index ce2ab62b64cf..ccecf740de59 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -5089,7 +5089,7 @@ EXPORT_SYMBOL_GPL(pci_dev_unlock); static void pci_dev_save_and_disable(struct pci_dev *dev) { const struct pci_error_handlers *err_handler = - dev->driver ? dev->driver->err_handler : NULL; + dev->dev.driver ? to_pci_driver(dev->dev.driver)->err_handler : NULL; /* * dev->driver->err_handler->reset_prepare() is protected against @@ -5120,7 +5120,7 @@ static void pci_dev_save_and_disable(struct pci_dev *dev) static void pci_dev_restore(struct pci_dev *dev) { const struct pci_error_handlers *err_handler = - dev->driver ? dev->driver->err_handler : NULL; + dev->dev.driver ? to_pci_driver(dev->dev.driver)->err_handler : NULL; pci_restore_state(dev); diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index b576aa890c76..b314b54f7821 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c @@ -49,14 +49,15 @@ static int report_error_detected(struct pci_dev *dev, pci_channel_state_t state, enum pci_ers_result *result) { + struct pci_driver *pdrv; pci_ers_result_t vote; const struct pci_error_handlers *err_handler; device_lock(&dev->dev); if (!pci_dev_set_io_state(dev, state) || - !dev->driver || - !dev->driver->err_handler || - !dev->driver->err_handler->error_detected) { + !dev->dev.driver || + !(pdrv = to_pci_driver(dev->dev.driver))->err_handler || + !pdrv->err_handler->error_detected) { /* * If any device in the subtree does not have an error_detected * callback, PCI_ERS_RESULT_NO_AER_DRIVER prevents subsequent @@ -70,7 +71,7 @@ static int report_error_detected(struct pci_dev *dev, vote = PCI_ERS_RESULT_NONE; } } else { - err_handler = dev->driver->err_handler; + err_handler = pdrv->err_handler; vote = err_handler->error_detected(dev, state); } pci_uevent_ers(dev, vote); @@ -92,15 +93,16 @@ static int report_normal_detected(struct pci_dev *dev, void *data) static int report_mmio_enabled(struct pci_dev *dev, void *data) { pci_ers_result_t vote, *result = data; + struct pci_driver *pdrv; const struct pci_error_handlers *err_handler; device_lock(&dev->dev); - if (!dev->driver || - !dev->driver->err_handler || - !dev->driver->err_handler->mmio_enabled) + if (!dev->dev.driver || + !(pdrv = to_pci_driver(dev->dev.driver))->err_handler || + !pdrv->err_handler->mmio_enabled) goto out; - err_handler = dev->driver->err_handler; + err_handler = pdrv->err_handler; vote = err_handler->mmio_enabled(dev); *result = merge_result(*result, vote); out: @@ -112,14 +114,15 @@ static int report_slot_reset(struct pci_dev *dev, void *data) { pci_ers_result_t vote, *result = data; const struct pci_error_handlers *err_handler; + struct pci_driver *pdrv; device_lock(&dev->dev); - if (!dev->driver || - !dev->driver->err_handler || - !dev->driver->err_handler->slot_reset) + if (!dev->dev.driver || + !(pdrv = to_pci_driver(dev->dev.driver))->err_handler || + !pdrv->err_handler->slot_reset) goto out; - err_handler = dev->driver->err_handler; + err_handler = pdrv->err_handler; vote = err_handler->slot_reset(dev); *result = merge_result(*result, vote); out: @@ -130,15 +133,16 @@ static int report_slot_reset(struct pci_dev *dev, void *data) static int report_resume(struct pci_dev *dev, void *data) { const struct pci_error_handlers *err_handler; + struct pci_driver *pdrv; device_lock(&dev->dev); if (!pci_dev_set_io_state(dev, pci_channel_io_normal) || - !dev->driver || - !dev->driver->err_handler || - !dev->driver->err_handler->resume) + !dev->dev.driver || + !(pdrv = to_pci_driver(dev->dev.driver))->err_handler || + !pdrv->err_handler->resume) goto out; - err_handler = dev->driver->err_handler; + err_handler = pdrv->err_handler; err_handler->resume(dev); out: pci_uevent_ers(dev, PCI_ERS_RESULT_RECOVERED); diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c index f2d7f70a7a10..73831fb87a1e 100644 --- a/drivers/pci/xen-pcifront.c +++ b/drivers/pci/xen-pcifront.c @@ -601,12 +601,12 @@ static pci_ers_result_t pcifront_common_process(int cmd, result = PCI_ERS_RESULT_NONE; pcidev = pci_get_domain_bus_and_slot(domain, bus, devfn); - if (!pcidev || !pcidev->driver) { + if (!pcidev || !pcidev->dev.driver) { dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n"); pci_dev_put(pcidev); return result; } - pdrv = pcidev->driver; + pdrv = to_pci_driver(pcidev->dev.driver); if (pdrv->err_handler && pdrv->err_handler->error_detected) { pci_dbg(pcidev, "trying to call AER service\n"); diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 2c9f25ca8edd..2f4729f4f1e0 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -103,7 +103,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) struct xhci_driver_data *driver_data; const struct pci_device_id *id; - id = pci_match_id(pdev->driver->id_table, pdev); + id = pci_match_id(to_pci_driver(pdev->dev.driver)->id_table, pdev); if (id && id->driver_data) { driver_data = (struct xhci_driver_data *)id->driver_data; From patchwork Mon Oct 4 12:59:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 12533895 X-Patchwork-Delegate: bhelgaas@google.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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7C15C433EF for ; Mon, 4 Oct 2021 13:34:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C3361611C7 for ; Mon, 4 Oct 2021 13:34:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237656AbhJDNgm (ORCPT ); Mon, 4 Oct 2021 09:36:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236918AbhJDNe5 (ORCPT ); Mon, 4 Oct 2021 09:34:57 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0AA5C02B758 for ; Mon, 4 Oct 2021 05:59:46 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXNZJ-00055e-5S; Mon, 04 Oct 2021 14:59:45 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1mXNZI-0000Lk-F7; Mon, 04 Oct 2021 14:59:44 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1mXNZH-0000de-DX; Mon, 04 Oct 2021 14:59:43 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH v6 11/11] PCI: Drop duplicated tracking of a pci_dev's bound driver Date: Mon, 4 Oct 2021 14:59:35 +0200 Message-Id: <20211004125935.2300113-12-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> References: <20211004125935.2300113-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=yGEodBYjARp1eJPqP9/n/KpfKo6ALJzXr+t0LDtBUZM=; m=JRVTmu6nPliiiBslnXnYAnMTr94GnCwSSGQey1Vdrcw=; p=YrUjfzbJ8WQwmXnl18oyuAlJX7HKhKEbscb1cCroxfY=; g=f3b7d22ed7c914b1939595bea1dcb198b436a8ca X-Patch-Sig: m=pgp; i=u.kleine-koenig@pengutronix.de; s=0x0D2511F322BFAB1C1580266BE2DCDD9132669BD6; b=iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmFa+qsACgkQwfwUeK3K7AmXNwgAjCZ hmGRQqql0lefiNl4D6Aed53arbX2fxfwPG1elBx+HAwEWg/rYaf+02dYgiruzW72mgLQjQFebgNcT c2Q6LNyLdp7OG9TZ+j2J2ax+B8MalTO6uOuoqsD9GbmwrBYI/z8CAJdjlcF3luTpZ8z7AnDOcpWK9 jABUy74jvJJLMJT4YrpdzRS3mroGUPb03PWHtolF/FSb9i1O0Fvk/GiM4oVLUGeHChFCcrnoMGpj+ YFbQGvgu4jLWq6qWSSs58wklabo7u5t3jmBiffCbvErbxD6ug6zOCrCJYluNUTegJY/7RZmPRvq2N PcYrF7Ztecr42ha/YWT1KDfwQS2PjvA== X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-pci@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Currently it's tracked twice which driver is bound to a given pci device. Now that all users of the pci specific one (struct pci_dev::driver) are updated to use an access macro (pci_driver_of_dev()), change the macro to use the information from the driver core and remove the driver member from struct pci_dev. Signed-off-by: Uwe Kleine-König --- drivers/pci/pci-driver.c | 4 ---- include/linux/pci.h | 1 - 2 files changed, 5 deletions(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 8654fe70cd66..e94aa338bab4 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -319,12 +319,10 @@ static long local_pci_probe(void *_ddi) * its remove routine. */ pm_runtime_get_sync(dev); - pci_dev->driver = pci_drv; rc = pci_drv->probe(pci_dev, ddi->id); if (!rc) return rc; if (rc < 0) { - pci_dev->driver = NULL; pm_runtime_put_sync(dev); return rc; } @@ -390,7 +388,6 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev, * @pci_dev: PCI device being probed * * returns 0 on success, else error. - * side-effect: pci_dev->driver is set to drv when drv claims pci_dev. */ static int __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev) { @@ -465,7 +462,6 @@ static void pci_device_remove(struct device *dev) pm_runtime_put_noidle(dev); } pcibios_free_irq(pci_dev); - pci_dev->driver = NULL; pci_iov_remove(pci_dev); /* Undo the runtime PM settings in local_pci_probe() */ diff --git a/include/linux/pci.h b/include/linux/pci.h index cd8aa6fce204..7c1ceb39035c 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -342,7 +342,6 @@ struct pci_dev { u16 pcie_flags_reg; /* Cached PCIe Capabilities Register */ unsigned long *dma_alias_mask;/* Mask of enabled devfn aliases */ - struct pci_driver *driver; /* Driver bound to this device */ u64 dma_mask; /* Mask of the bits of bus address this device implements. Normally this is 0xffffffff. You only need to change