aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2017-12-24 16:04:11 -0500
committerWim Van Sebroeck <wim@iguana.be>2018-01-21 06:56:35 -0500
commita34834435f46225d9371b77599f44e3ec2e43b08 (patch)
tree90c65159fa7e23d54046052f507b506ae479d562
parente189410cbef1374ec29d42b72df0d58d5c7e193c (diff)
watchdog: sp5100_tco: Match PCI device early
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 <zboszor@pr.hu> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
-rw-r--r--drivers/watchdog/sp5100_tco.c66
1 files 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 = {
312 .fops = &sp5100_tco_fops, 312 .fops = &sp5100_tco_fops,
313}; 313};
314 314
315/*
316 * Data for PCI driver interface
317 *
318 * This data only exists for exporting the supported
319 * PCI ids via MODULE_DEVICE_TABLE. We do not actually
320 * register a pci_driver, because someone else might
321 * want to register another driver on the same PCI id.
322 */
323static const struct pci_device_id sp5100_tco_pci_tbl[] = {
324 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS, PCI_ANY_ID,
325 PCI_ANY_ID, },
326 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SMBUS, PCI_ANY_ID,
327 PCI_ANY_ID, },
328 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_KERNCZ_SMBUS, PCI_ANY_ID,
329 PCI_ANY_ID, },
330 { 0, }, /* End of list */
331};
332MODULE_DEVICE_TABLE(pci, sp5100_tco_pci_tbl);
333
334static u8 sp5100_tco_read_pm_reg32(u8 index) 315static u8 sp5100_tco_read_pm_reg32(u8 index)
335{ 316{
336 u32 val = 0; 317 u32 val = 0;
@@ -347,27 +328,11 @@ static u8 sp5100_tco_read_pm_reg32(u8 index)
347 */ 328 */
348static int sp5100_tco_setupdevice(void) 329static int sp5100_tco_setupdevice(void)
349{ 330{
350 struct pci_dev *dev = NULL;
351 const char *dev_name = NULL; 331 const char *dev_name = NULL;
352 u32 val; 332 u32 val;
353 u8 base_addr; 333 u8 base_addr;
354 int ret; 334 int ret;
355 335
356 /* Match the PCI device */
357 for_each_pci_dev(dev) {
358 if (pci_match_id(sp5100_tco_pci_tbl, dev) != NULL) {
359 sp5100_tco_pci = dev;
360 break;
361 }
362 }
363
364 if (!sp5100_tco_pci)
365 return -ENODEV;
366
367 pr_info("PCI Vendor ID: 0x%x, Device ID: 0x%x, Revision ID: 0x%x\n",
368 sp5100_tco_pci->vendor, sp5100_tco_pci->device,
369 sp5100_tco_pci->revision);
370
371 /* 336 /*
372 * Determine type of southbridge chipset. 337 * Determine type of southbridge chipset.
373 */ 338 */
@@ -557,10 +522,41 @@ static struct platform_driver sp5100_tco_driver = {
557 }, 522 },
558}; 523};
559 524
525/*
526 * Data for PCI driver interface
527 *
528 * This data only exists for exporting the supported
529 * PCI ids via MODULE_DEVICE_TABLE. We do not actually
530 * register a pci_driver, because someone else might
531 * want to register another driver on the same PCI id.
532 */
533static const struct pci_device_id sp5100_tco_pci_tbl[] = {
534 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS, PCI_ANY_ID,
535 PCI_ANY_ID, },
536 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SMBUS, PCI_ANY_ID,
537 PCI_ANY_ID, },
538 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_KERNCZ_SMBUS, PCI_ANY_ID,
539 PCI_ANY_ID, },
540 { 0, }, /* End of list */
541};
542MODULE_DEVICE_TABLE(pci, sp5100_tco_pci_tbl);
543
560static int __init sp5100_tco_init_module(void) 544static int __init sp5100_tco_init_module(void)
561{ 545{
546 struct pci_dev *dev = NULL;
562 int err; 547 int err;
563 548
549 /* Match the PCI device */
550 for_each_pci_dev(dev) {
551 if (pci_match_id(sp5100_tco_pci_tbl, dev) != NULL) {
552 sp5100_tco_pci = dev;
553 break;
554 }
555 }
556
557 if (!sp5100_tco_pci)
558 return -ENODEV;
559
564 pr_info("SP5100/SB800 TCO WatchDog Timer Driver v%s\n", TCO_VERSION); 560 pr_info("SP5100/SB800 TCO WatchDog Timer Driver v%s\n", TCO_VERSION);
565 561
566 err = platform_driver_register(&sp5100_tco_driver); 562 err = platform_driver_register(&sp5100_tco_driver);