Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751913AbeAPT6T (ORCPT + 1 other); Tue, 16 Jan 2018 14:58:19 -0500 Received: from mail-qk0-f193.google.com ([209.85.220.193]:41130 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751438AbeAPT6R (ORCPT ); Tue, 16 Jan 2018 14:58:17 -0500 X-Google-Smtp-Source: ACJfBovHy6I1rR6EMGrDnboIvXO6EHugcsIRp1gECIrxKGiohReh9uRFI21Fd5VltXwc6BWX6oOugA== Message-ID: <1516132695.18904.13.camel@redhat.com> Subject: Re: [06/12] watchdog: sp5100_tco: Match PCI device early From: Lyude Paul To: Guenter Roeck , Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, =?ISO-8859-1?Q?Zolt=E1n_B=F6sz=F6rm=E9nyi?= Date: Tue, 16 Jan 2018 14:58:15 -0500 In-Reply-To: <1514149457-20273-7-git-send-email-linux@roeck-us.net> References: <1514149457-20273-7-git-send-email-linux@roeck-us.net> Organization: Red Hat Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.3 (3.26.3-1.fc27) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Reviewed-by: Lyude Paul On Sun, 2017-12-24 at 13:04 -0800, Guenter Roeck wrote: > Match PCI device in module init function, not in the probe function. > It is pointless trying to probe if we can determine early that the device > is not supported. > > Cc: Zoltán Böszörményi > Signed-off-by: Guenter Roeck > --- > drivers/watchdog/sp5100_tco.c | 66 ++++++++++++++++++++------------------ > ----- > 1 file changed, 31 insertions(+), 35 deletions(-) > > diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c > index 5a13ab483c50..5868c6b6bf17 100644 > --- a/drivers/watchdog/sp5100_tco.c > +++ b/drivers/watchdog/sp5100_tco.c > @@ -312,25 +312,6 @@ static struct miscdevice sp5100_tco_miscdev = { > .fops = &sp5100_tco_fops, > }; > > -/* > - * Data for PCI driver interface > - * > - * This data only exists for exporting the supported > - * PCI ids via MODULE_DEVICE_TABLE. We do not actually > - * register a pci_driver, because someone else might > - * want to register another driver on the same PCI id. > - */ > -static const struct pci_device_id sp5100_tco_pci_tbl[] = { > - { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS, PCI_ANY_ID, > - PCI_ANY_ID, }, > - { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SMBUS, PCI_ANY_ID, > - PCI_ANY_ID, }, > - { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_KERNCZ_SMBUS, PCI_ANY_ID, > - PCI_ANY_ID, }, > - { 0, }, /* End of list */ > -}; > -MODULE_DEVICE_TABLE(pci, sp5100_tco_pci_tbl); > - > static u8 sp5100_tco_read_pm_reg32(u8 index) > { > u32 val = 0; > @@ -347,27 +328,11 @@ static u8 sp5100_tco_read_pm_reg32(u8 index) > */ > static int sp5100_tco_setupdevice(void) > { > - struct pci_dev *dev = NULL; > const char *dev_name = NULL; > u32 val; > u8 base_addr; > int ret; > > - /* Match the PCI device */ > - for_each_pci_dev(dev) { > - if (pci_match_id(sp5100_tco_pci_tbl, dev) != NULL) { > - sp5100_tco_pci = dev; > - break; > - } > - } > - > - if (!sp5100_tco_pci) > - return -ENODEV; > - > - pr_info("PCI Vendor ID: 0x%x, Device ID: 0x%x, Revision ID: > 0x%x\n", > - sp5100_tco_pci->vendor, sp5100_tco_pci->device, > - sp5100_tco_pci->revision); > - > /* > * Determine type of southbridge chipset. > */ > @@ -557,10 +522,41 @@ static struct platform_driver sp5100_tco_driver = { > }, > }; > > +/* > + * Data for PCI driver interface > + * > + * This data only exists for exporting the supported > + * PCI ids via MODULE_DEVICE_TABLE. We do not actually > + * register a pci_driver, because someone else might > + * want to register another driver on the same PCI id. > + */ > +static const struct pci_device_id sp5100_tco_pci_tbl[] = { > + { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS, PCI_ANY_ID, > + PCI_ANY_ID, }, > + { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SMBUS, PCI_ANY_ID, > + PCI_ANY_ID, }, > + { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_KERNCZ_SMBUS, PCI_ANY_ID, > + PCI_ANY_ID, }, > + { 0, }, /* End of list */ > +}; > +MODULE_DEVICE_TABLE(pci, sp5100_tco_pci_tbl); > + > static int __init sp5100_tco_init_module(void) > { > + struct pci_dev *dev = NULL; > int err; > > + /* Match the PCI device */ > + for_each_pci_dev(dev) { > + if (pci_match_id(sp5100_tco_pci_tbl, dev) != NULL) { > + sp5100_tco_pci = dev; > + break; > + } > + } > + > + if (!sp5100_tco_pci) > + return -ENODEV; > + > pr_info("SP5100/SB800 TCO WatchDog Timer Driver v%s\n", > TCO_VERSION); > > err = platform_driver_register(&sp5100_tco_driver); -- Cheers, Lyude Paul