Skip to content

Commit

Permalink
Merge branch 'pnp-debug' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
Len Brown committed Oct 23, 2008
2 parents 5f50ef4 + ac88a8f commit 4dff4e7
Show file tree
Hide file tree
Showing 19 changed files with 121 additions and 125 deletions.
4 changes: 4 additions & 0 deletions Documentation/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,10 @@ and is between 256 and 4096 characters. It is defined in the file
Override pmtimer IOPort with a hex value.
e.g. pmtmr=0x508

pnp.debug [PNP]
Enable PNP debug messages. This depends on the
CONFIG_PNP_DEBUG_MESSAGES option.

pnpacpi= [ACPI]
{ off }

Expand Down
20 changes: 14 additions & 6 deletions drivers/pnp/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,21 @@ menuconfig PNP

If unsure, say Y.

if PNP

config PNP_DEBUG
bool "PnP Debug Messages"
config PNP_DEBUG_MESSAGES
default y
bool "PNP debugging messages"
depends on PNP
help
Say Y if you want the Plug and Play Layer to print debug messages.
This is useful if you are developing a PnP driver or troubleshooting.
Say Y here if you want the PNP layer to be able to produce debugging
messages if needed. The messages can be enabled at boot-time with
the pnp.debug kernel parameter.

This option allows you to save a bit of space if you do not want
the messages to even be built into the kernel.

If you have any doubts about this, say Y here.

if PNP

comment "Protocols"

Expand Down
4 changes: 0 additions & 4 deletions drivers/pnp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,3 @@ obj-y := core.o card.o driver.o resource.o manager.o support.o interface.o quir
obj-$(CONFIG_PNPACPI) += pnpacpi/
obj-$(CONFIG_PNPBIOS) += pnpbios/
obj-$(CONFIG_ISAPNP) += isapnp/

ifeq ($(CONFIG_PNP_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG
endif
10 changes: 10 additions & 0 deletions drivers/pnp/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,13 @@ struct pnp_resource *pnp_add_io_resource(struct pnp_dev *dev,
struct pnp_resource *pnp_add_mem_resource(struct pnp_dev *dev,
resource_size_t start,
resource_size_t end, int flags);

extern int pnp_debug;

#if defined(CONFIG_PNP_DEBUG_MESSAGES)
#define pnp_dbg(dev, format, arg...) \
({ if (pnp_debug) dev_printk(KERN_DEBUG, dev, format, ## arg); 0; })
#else
#define pnp_dbg(dev, format, arg...) \
({ if (0) dev_printk(KERN_DEBUG, dev, format, ## arg); 0; })
#endif
29 changes: 19 additions & 10 deletions drivers/pnp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ int __pnp_add_device(struct pnp_dev *dev)
int pnp_add_device(struct pnp_dev *dev)
{
int ret;
char buf[128];
int len = 0;
struct pnp_id *id;

if (dev->card)
return -EINVAL;
Expand All @@ -193,17 +196,12 @@ int pnp_add_device(struct pnp_dev *dev)
if (ret)
return ret;

#ifdef CONFIG_PNP_DEBUG
{
struct pnp_id *id;
buf[0] = '\0';
for (id = dev->id; id; id = id->next)
len += scnprintf(buf + len, sizeof(buf) - len, " %s", id->id);

dev_printk(KERN_DEBUG, &dev->dev, "%s device, IDs",
dev->protocol->name);
for (id = dev->id; id; id = id->next)
printk(" %s", id->id);
printk(" (%s)\n", dev->active ? "active" : "disabled");
}
#endif
pnp_dbg(&dev->dev, "%s device, IDs%s (%s)\n",
dev->protocol->name, buf, dev->active ? "active" : "disabled");
return 0;
}

Expand All @@ -223,3 +221,14 @@ static int __init pnp_init(void)
}

subsys_initcall(pnp_init);

int pnp_debug;

#if defined(CONFIG_PNP_DEBUG_MESSAGES)
static int __init pnp_debug_setup(char *__unused)
{
pnp_debug = 1;
return 1;
}
__setup("pnp.debug", pnp_debug_setup);
#endif
4 changes: 0 additions & 4 deletions drivers/pnp/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ static int pnp_device_probe(struct device *dev)
} else
goto fail;

dev_dbg(dev, "driver attached\n");
return error;

fail:
Expand Down Expand Up @@ -210,8 +209,6 @@ struct bus_type pnp_bus_type = {

int pnp_register_driver(struct pnp_driver *drv)
{
pnp_dbg("the driver '%s' has been registered", drv->name);

drv->driver.name = drv->name;
drv->driver.bus = &pnp_bus_type;

Expand All @@ -221,7 +218,6 @@ int pnp_register_driver(struct pnp_driver *drv)
void pnp_unregister_driver(struct pnp_driver *drv)
{
driver_unregister(&drv->driver);
pnp_dbg("the driver '%s' has been unregistered", drv->name);
}

/**
Expand Down
4 changes: 0 additions & 4 deletions drivers/pnp/isapnp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,3 @@
isapnp-proc-$(CONFIG_PROC_FS) = proc.o

obj-y := core.o compat.o $(isapnp-proc-y)

ifeq ($(CONFIG_PNP_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG
endif
12 changes: 6 additions & 6 deletions drivers/pnp/isapnp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ static int isapnp_get_resources(struct pnp_dev *dev)
{
int i, ret;

dev_dbg(&dev->dev, "get resources\n");
pnp_dbg(&dev->dev, "get resources\n");
pnp_init_resources(dev);
isapnp_cfg_begin(dev->card->number, dev->number);
dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE);
Expand Down Expand Up @@ -939,13 +939,13 @@ static int isapnp_set_resources(struct pnp_dev *dev)
struct resource *res;
int tmp;

dev_dbg(&dev->dev, "set resources\n");
pnp_dbg(&dev->dev, "set resources\n");
isapnp_cfg_begin(dev->card->number, dev->number);
dev->active = 1;
for (tmp = 0; tmp < ISAPNP_MAX_PORT; tmp++) {
res = pnp_get_resource(dev, IORESOURCE_IO, tmp);
if (pnp_resource_enabled(res)) {
dev_dbg(&dev->dev, " set io %d to %#llx\n",
pnp_dbg(&dev->dev, " set io %d to %#llx\n",
tmp, (unsigned long long) res->start);
isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1),
res->start);
Expand All @@ -957,22 +957,22 @@ static int isapnp_set_resources(struct pnp_dev *dev)
int irq = res->start;
if (irq == 2)
irq = 9;
dev_dbg(&dev->dev, " set irq %d to %d\n", tmp, irq);
pnp_dbg(&dev->dev, " set irq %d to %d\n", tmp, irq);
isapnp_write_byte(ISAPNP_CFG_IRQ + (tmp << 1), irq);
}
}
for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) {
res = pnp_get_resource(dev, IORESOURCE_DMA, tmp);
if (pnp_resource_enabled(res)) {
dev_dbg(&dev->dev, " set dma %d to %lld\n",
pnp_dbg(&dev->dev, " set dma %d to %lld\n",
tmp, (unsigned long long) res->start);
isapnp_write_byte(ISAPNP_CFG_DMA + tmp, res->start);
}
}
for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) {
res = pnp_get_resource(dev, IORESOURCE_MEM, tmp);
if (pnp_resource_enabled(res)) {
dev_dbg(&dev->dev, " set mem %d to %#llx\n",
pnp_dbg(&dev->dev, " set mem %d to %#llx\n",
tmp, (unsigned long long) res->start);
isapnp_write_word(ISAPNP_CFG_MEM + (tmp << 3),
(res->start >> 8) & 0xffff);
Expand Down
34 changes: 17 additions & 17 deletions drivers/pnp/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx)

res = pnp_get_resource(dev, IORESOURCE_IO, idx);
if (res) {
dev_dbg(&dev->dev, " io %d already set to %#llx-%#llx "
pnp_dbg(&dev->dev, " io %d already set to %#llx-%#llx "
"flags %#lx\n", idx, (unsigned long long) res->start,
(unsigned long long) res->end, res->flags);
return 0;
Expand All @@ -38,7 +38,7 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx)

if (!rule->size) {
res->flags |= IORESOURCE_DISABLED;
dev_dbg(&dev->dev, " io %d disabled\n", idx);
pnp_dbg(&dev->dev, " io %d disabled\n", idx);
goto __add;
}

Expand All @@ -49,7 +49,7 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx)
res->start += rule->align;
res->end = res->start + rule->size - 1;
if (res->start > rule->max || !rule->align) {
dev_dbg(&dev->dev, " couldn't assign io %d "
pnp_dbg(&dev->dev, " couldn't assign io %d "
"(min %#llx max %#llx)\n", idx,
(unsigned long long) rule->min,
(unsigned long long) rule->max);
Expand All @@ -68,7 +68,7 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx)

res = pnp_get_resource(dev, IORESOURCE_MEM, idx);
if (res) {
dev_dbg(&dev->dev, " mem %d already set to %#llx-%#llx "
pnp_dbg(&dev->dev, " mem %d already set to %#llx-%#llx "
"flags %#lx\n", idx, (unsigned long long) res->start,
(unsigned long long) res->end, res->flags);
return 0;
Expand All @@ -90,7 +90,7 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx)

if (!rule->size) {
res->flags |= IORESOURCE_DISABLED;
dev_dbg(&dev->dev, " mem %d disabled\n", idx);
pnp_dbg(&dev->dev, " mem %d disabled\n", idx);
goto __add;
}

Expand All @@ -101,7 +101,7 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx)
res->start += rule->align;
res->end = res->start + rule->size - 1;
if (res->start > rule->max || !rule->align) {
dev_dbg(&dev->dev, " couldn't assign mem %d "
pnp_dbg(&dev->dev, " couldn't assign mem %d "
"(min %#llx max %#llx)\n", idx,
(unsigned long long) rule->min,
(unsigned long long) rule->max);
Expand All @@ -126,7 +126,7 @@ static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx)

res = pnp_get_resource(dev, IORESOURCE_IRQ, idx);
if (res) {
dev_dbg(&dev->dev, " irq %d already set to %d flags %#lx\n",
pnp_dbg(&dev->dev, " irq %d already set to %d flags %#lx\n",
idx, (int) res->start, res->flags);
return 0;
}
Expand All @@ -138,7 +138,7 @@ static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx)

if (bitmap_empty(rule->map.bits, PNP_IRQ_NR)) {
res->flags |= IORESOURCE_DISABLED;
dev_dbg(&dev->dev, " irq %d disabled\n", idx);
pnp_dbg(&dev->dev, " irq %d disabled\n", idx);
goto __add;
}

Expand All @@ -160,11 +160,11 @@ static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx)
res->start = -1;
res->end = -1;
res->flags |= IORESOURCE_DISABLED;
dev_dbg(&dev->dev, " irq %d disabled (optional)\n", idx);
pnp_dbg(&dev->dev, " irq %d disabled (optional)\n", idx);
goto __add;
}

dev_dbg(&dev->dev, " couldn't assign irq %d\n", idx);
pnp_dbg(&dev->dev, " couldn't assign irq %d\n", idx);
return -EBUSY;

__add:
Expand All @@ -184,7 +184,7 @@ static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx)

res = pnp_get_resource(dev, IORESOURCE_DMA, idx);
if (res) {
dev_dbg(&dev->dev, " dma %d already set to %d flags %#lx\n",
pnp_dbg(&dev->dev, " dma %d already set to %d flags %#lx\n",
idx, (int) res->start, res->flags);
return 0;
}
Expand All @@ -205,7 +205,7 @@ static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx)
res->start = res->end = MAX_DMA_CHANNELS;
#endif
res->flags |= IORESOURCE_DISABLED;
dev_dbg(&dev->dev, " disable dma %d\n", idx);
pnp_dbg(&dev->dev, " disable dma %d\n", idx);

__add:
pnp_add_dma_resource(dev, res->start, res->flags);
Expand Down Expand Up @@ -238,7 +238,7 @@ static int pnp_assign_resources(struct pnp_dev *dev, int set)
int nport = 0, nmem = 0, nirq = 0, ndma = 0;
int ret = 0;

dev_dbg(&dev->dev, "pnp_assign_resources, try dependent set %d\n", set);
pnp_dbg(&dev->dev, "pnp_assign_resources, try dependent set %d\n", set);
mutex_lock(&pnp_res_mutex);
pnp_clean_resource_table(dev);

Expand Down Expand Up @@ -270,7 +270,7 @@ static int pnp_assign_resources(struct pnp_dev *dev, int set)

mutex_unlock(&pnp_res_mutex);
if (ret < 0) {
dev_dbg(&dev->dev, "pnp_assign_resources failed (%d)\n", ret);
pnp_dbg(&dev->dev, "pnp_assign_resources failed (%d)\n", ret);
pnp_clean_resource_table(dev);
} else
dbg_pnp_show_resources(dev, "pnp_assign_resources succeeded");
Expand All @@ -286,7 +286,7 @@ int pnp_auto_config_dev(struct pnp_dev *dev)
int i, ret;

if (!pnp_can_configure(dev)) {
dev_dbg(&dev->dev, "configuration not supported\n");
pnp_dbg(&dev->dev, "configuration not supported\n");
return -ENODEV;
}

Expand All @@ -313,7 +313,7 @@ int pnp_auto_config_dev(struct pnp_dev *dev)
int pnp_start_dev(struct pnp_dev *dev)
{
if (!pnp_can_write(dev)) {
dev_dbg(&dev->dev, "activation not supported\n");
pnp_dbg(&dev->dev, "activation not supported\n");
return -EINVAL;
}

Expand All @@ -336,7 +336,7 @@ int pnp_start_dev(struct pnp_dev *dev)
int pnp_stop_dev(struct pnp_dev *dev)
{
if (!pnp_can_disable(dev)) {
dev_dbg(&dev->dev, "disabling not supported\n");
pnp_dbg(&dev->dev, "disabling not supported\n");
return -EINVAL;
}
if (dev->protocol->disable(dev) < 0) {
Expand Down
4 changes: 0 additions & 4 deletions drivers/pnp/pnpacpi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,3 @@
#

obj-y := core.o rsparser.o

ifeq ($(CONFIG_PNP_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG
endif
10 changes: 5 additions & 5 deletions drivers/pnp/pnpacpi/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static int __init ispnpidacpi(char *id)

static int pnpacpi_get_resources(struct pnp_dev *dev)
{
dev_dbg(&dev->dev, "get resources\n");
pnp_dbg(&dev->dev, "get resources\n");
return pnpacpi_parse_allocated_resource(dev);
}

Expand All @@ -86,7 +86,7 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
int ret;
acpi_status status;

dev_dbg(&dev->dev, "set resources\n");
pnp_dbg(&dev->dev, "set resources\n");
ret = pnpacpi_build_resource_template(dev, &buffer);
if (ret)
return ret;
Expand Down Expand Up @@ -259,14 +259,14 @@ int pnpacpi_disabled __initdata;
static int __init pnpacpi_init(void)
{
if (acpi_disabled || pnpacpi_disabled) {
pnp_info("PnP ACPI: disabled");
printk(KERN_INFO "pnp: PnP ACPI: disabled\n");
return 0;
}
pnp_info("PnP ACPI init");
printk(KERN_INFO "pnp: PnP ACPI init\n");
pnp_register_protocol(&pnpacpi_protocol);
register_acpi_bus_type(&acpi_pnp_bus);
acpi_get_devices(NULL, pnpacpi_add_device_handler, NULL, NULL);
pnp_info("PnP ACPI: found %d devices", num);
printk(KERN_INFO "pnp: PnP ACPI: found %d devices\n", num);
unregister_acpi_bus_type(&acpi_pnp_bus);
pnp_platform_devices = 1;
return 0;
Expand Down
Loading

0 comments on commit 4dff4e7

Please sign in to comment.