From 4cf9f24db3954ac5802de24c826b7ebed27760c4 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 15 Apr 2013 14:33:42 -0600 Subject: EISA: Use dev_printk() when possible Use dev_printk() when possible to make messages more useful. Signed-off-by: Bjorn Helgaas --- drivers/eisa/eisa-bus.c | 63 ++++++++++++++++++++++--------------------------- drivers/eisa/pci_eisa.c | 5 ++-- 2 files changed, 30 insertions(+), 38 deletions(-) (limited to 'drivers/eisa') diff --git a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c index 806c77bfd434..0b06df44ed54 100644 --- a/drivers/eisa/eisa-bus.c +++ b/drivers/eisa/eisa-bus.c @@ -314,22 +314,22 @@ static int __init eisa_probe(struct eisa_root_device *root) { int i, c; struct eisa_device *edev; + char *enabled_str; - printk(KERN_INFO "EISA: Probing bus %d at %s\n", - root->bus_nr, dev_name(root->dev)); + dev_info(root->dev, "Probing EISA bus %d\n", root->bus_nr); /* First try to get hold of slot 0. If there is no device * here, simply fail, unless root->force_probe is set. */ edev = kzalloc(sizeof(*edev), GFP_KERNEL); if (!edev) { - printk(KERN_ERR "EISA: Couldn't allocate mainboard slot\n"); + dev_err(root->dev, "EISA: Couldn't allocate mainboard slot\n"); return -ENOMEM; } if (eisa_request_resources(root, edev, 0)) { - printk(KERN_WARNING \ - "EISA: Cannot allocate resource for mainboard\n"); + dev_warn(root->dev, + "EISA: Cannot allocate resource for mainboard\n"); kfree(edev); if (!root->force_probe) return -EBUSY; @@ -344,11 +344,11 @@ static int __init eisa_probe(struct eisa_root_device *root) goto force_probe; } - printk(KERN_INFO "EISA: Mainboard %s detected.\n", edev->id.sig); + dev_info(&edev->dev, "EISA: Mainboard %s detected\n", edev->id.sig); if (eisa_register_device(edev)) { - printk(KERN_ERR "EISA: Failed to register %s\n", - edev->id.sig); + dev_err(&edev->dev, "EISA: Failed to register %s\n", + edev->id.sig); eisa_release_resources(edev); kfree(edev); } @@ -358,14 +358,15 @@ static int __init eisa_probe(struct eisa_root_device *root) for (c = 0, i = 1; i <= root->slots; i++) { edev = kzalloc(sizeof(*edev), GFP_KERNEL); if (!edev) { - printk(KERN_ERR "EISA: Out of memory for slot %d\n", i); + dev_err(root->dev, "EISA: Out of memory for slot %d\n", + i); continue; } if (eisa_request_resources(root, edev, i)) { - printk(KERN_WARNING \ - "Cannot allocate resource for EISA slot %d\n", - i); + dev_warn(root->dev, + "Cannot allocate resource for EISA slot %d\n", + i); kfree(edev); continue; } @@ -375,38 +376,30 @@ static int __init eisa_probe(struct eisa_root_device *root) kfree(edev); continue; } - - printk(KERN_INFO "EISA: slot %d : %s detected", - i, edev->id.sig); - - switch (edev->state) { - case EISA_CONFIG_ENABLED | EISA_CONFIG_FORCED: - printk(" (forced enabled)"); - break; - - case EISA_CONFIG_FORCED: - printk(" (forced disabled)"); - break; - - case 0: - printk(" (disabled)"); - break; - } - - printk (".\n"); + + if (edev->state == (EISA_CONFIG_ENABLED | EISA_CONFIG_FORCED)) + enabled_str = " (forced enabled)"; + else if (edev->state == EISA_CONFIG_FORCED) + enabled_str = " (forced disabled)"; + else if (edev->state == 0) + enabled_str = " (disabled)"; + else + enabled_str = ""; + + dev_info(&edev->dev, "EISA: slot %d: %s detected%s\n", i, + edev->id.sig, enabled_str); c++; if (eisa_register_device(edev)) { - printk(KERN_ERR "EISA: Failed to register %s\n", - edev->id.sig); + dev_err(&edev->dev, "EISA: Failed to register %s\n", + edev->id.sig); eisa_release_resources(edev); kfree(edev); } } - printk(KERN_INFO "EISA: Detected %d card%s.\n", c, c == 1 ? "" : "s"); - + dev_info(root->dev, "EISA: Detected %d card%s\n", c, c == 1 ? "" : "s"); return 0; } diff --git a/drivers/eisa/pci_eisa.c b/drivers/eisa/pci_eisa.c index cdae207028a7..0d42ea791060 100644 --- a/drivers/eisa/pci_eisa.c +++ b/drivers/eisa/pci_eisa.c @@ -25,8 +25,7 @@ static int __init pci_eisa_init(struct pci_dev *pdev, int rc; if ((rc = pci_enable_device (pdev))) { - printk (KERN_ERR "pci_eisa : Could not enable device %s\n", - pci_name(pdev)); + dev_err(&pdev->dev, "Could not enable device\n"); return rc; } @@ -38,7 +37,7 @@ static int __init pci_eisa_init(struct pci_dev *pdev, dev_set_drvdata(pci_eisa_root.dev, &pci_eisa_root); if (eisa_root_register (&pci_eisa_root)) { - printk (KERN_ERR "pci_eisa : Could not register EISA root\n"); + dev_err(&pdev->dev, "Could not register EISA root\n"); return -1; } -- cgit v1.2.3-70-g09d2 From 76668257b26957ce2ca815da9e7d7fc740164123 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 15 Apr 2013 14:33:56 -0600 Subject: EISA: Mark vendor ID resource as I/O port space Previously we marked this as merely IORESOURCE_BUSY without indicating the type. Setting the type makes %pR on the resource work better. Signed-off-by: Bjorn Helgaas --- drivers/eisa/eisa-bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/eisa') diff --git a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c index 0b06df44ed54..bf30dcb77bcb 100644 --- a/drivers/eisa/eisa-bus.c +++ b/drivers/eisa/eisa-bus.c @@ -285,7 +285,7 @@ static int __init eisa_request_resources(struct eisa_root_device *root, edev->res[i].start = SLOT_ADDRESS(root, slot) + EISA_VENDOR_ID_OFFSET; edev->res[i].end = edev->res[i].start + 3; - edev->res[i].flags = IORESOURCE_BUSY; + edev->res[i].flags = IORESOURCE_IO | IORESOURCE_BUSY; } if (request_resource(root->res, &edev->res[i])) -- cgit v1.2.3-70-g09d2 From 26abfeed4341872364386c6a52b9acef8c81a81a Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 15 Apr 2013 14:34:02 -0600 Subject: EISA: Initialize device before its resources Move eisa_init_device() before eisa_request_resources() so the device name is set before we set up its resources. That way we can print better messages. Previously edev->res[i].name was set to NULL in eisa_request_resources(), then filled in by eisa_init_device(). Now it is filled in by eisa_init_device() first, and we don't want to clear it out later in eisa_request_resources(). Signed-off-by: Bjorn Helgaas --- drivers/eisa/eisa-bus.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'drivers/eisa') diff --git a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c index bf30dcb77bcb..d0c50b477d0b 100644 --- a/drivers/eisa/eisa-bus.c +++ b/drivers/eisa/eisa-bus.c @@ -275,13 +275,11 @@ static int __init eisa_request_resources(struct eisa_root_device *root, } if (slot) { - edev->res[i].name = NULL; edev->res[i].start = SLOT_ADDRESS(root, slot) + (i * 0x400); edev->res[i].end = edev->res[i].start + 0xff; edev->res[i].flags = IORESOURCE_IO; } else { - edev->res[i].name = NULL; edev->res[i].start = SLOT_ADDRESS(root, slot) + EISA_VENDOR_ID_OFFSET; edev->res[i].end = edev->res[i].start + 3; @@ -327,20 +325,19 @@ static int __init eisa_probe(struct eisa_root_device *root) return -ENOMEM; } - if (eisa_request_resources(root, edev, 0)) { - dev_warn(root->dev, - "EISA: Cannot allocate resource for mainboard\n"); + if (eisa_init_device(root, edev, 0)) { kfree(edev); if (!root->force_probe) - return -EBUSY; + return -ENODEV; goto force_probe; } - if (eisa_init_device(root, edev, 0)) { - eisa_release_resources(edev); + if (eisa_request_resources(root, edev, 0)) { + dev_warn(root->dev, + "EISA: Cannot allocate resource for mainboard\n"); kfree(edev); if (!root->force_probe) - return -ENODEV; + return -EBUSY; goto force_probe; } @@ -363,16 +360,15 @@ static int __init eisa_probe(struct eisa_root_device *root) continue; } - if (eisa_request_resources(root, edev, i)) { - dev_warn(root->dev, - "Cannot allocate resource for EISA slot %d\n", - i); + if (eisa_init_device(root, edev, i)) { kfree(edev); continue; } - if (eisa_init_device(root, edev, i)) { - eisa_release_resources(edev); + if (eisa_request_resources(root, edev, i)) { + dev_warn(root->dev, + "Cannot allocate resource for EISA slot %d\n", + i); kfree(edev); continue; } -- cgit v1.2.3-70-g09d2 From a2080d0c561c546d73cb8b296d4b7ca414e6860b Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 15 Apr 2013 14:34:07 -0600 Subject: EISA: Log device resources in dmesg Note the resources consumed by EISA devices in dmesg, similar to what we already do for PCI and PNP devices. Signed-off-by: Bjorn Helgaas --- drivers/eisa/eisa-bus.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/eisa') diff --git a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c index d0c50b477d0b..272a3ec35957 100644 --- a/drivers/eisa/eisa-bus.c +++ b/drivers/eisa/eisa-bus.c @@ -286,6 +286,7 @@ static int __init eisa_request_resources(struct eisa_root_device *root, edev->res[i].flags = IORESOURCE_IO | IORESOURCE_BUSY; } + dev_printk(KERN_DEBUG, &edev->dev, "%pR\n", &edev->res[i]); if (request_resource(root->res, &edev->res[i])) goto failed; } -- cgit v1.2.3-70-g09d2