summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi-Ta Lo <ollie@lanl.gov>2004-05-07 21:56:48 +0000
committerLi-Ta Lo <ollie@lanl.gov>2004-05-07 21:56:48 +0000
commit75337f7500cbddc1bea2927573c8eadaa4455d7f (patch)
tree0482b833f3fc397401c3dd6f960277a79f140a88
parent89666e4893bf51eab4f20137f2f65a385d37ec09 (diff)
downloadcoreboot-75337f7500cbddc1bea2927573c8eadaa4455d7f.tar.xz
code reformat, fixed a bug in set/unset logical operation
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1551 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
-rw-r--r--src/devices/pnp_device.c66
1 files changed, 28 insertions, 38 deletions
diff --git a/src/devices/pnp_device.c b/src/devices/pnp_device.c
index 207e3db23f..9bee8e471f 100644
--- a/src/devices/pnp_device.c
+++ b/src/devices/pnp_device.c
@@ -70,41 +70,35 @@ void pnp_read_resources(device_t dev)
static void pnp_set_resource(device_t dev, struct resource *resource)
{
if (!(resource->flags & IORESOURCE_ASSIGNED)) {
-#if 1
printk_err("ERROR: %s %02x not allocated\n",
- dev_path(dev), resource->index);
-#endif
+ dev_path(dev), resource->index);
return;
}
+
/* Now store the resource */
resource->flags |= IORESOURCE_STORED;
if (resource->flags & IORESOURCE_IO) {
pnp_set_iobase(dev, resource->index, resource->base);
- }
- else if (resource->flags & IORESOURCE_DRQ) {
+ } else if (resource->flags & IORESOURCE_DRQ) {
pnp_set_drq(dev, resource->index, resource->base);
- }
- else if (resource->flags & IORESOURCE_IRQ) {
+ } else if (resource->flags & IORESOURCE_IRQ) {
pnp_set_irq(dev, resource->index, resource->base);
- }
- else {
+ } else {
/* Don't let me think I stored the resource */
- resource->flags &= IORESOURCE_STORED;
+ resource->flags &= ~IORESOURCE_STORED;
printk_err("ERROR: %s %02x unknown resource type\n",
- dev_path(dev), resource->index);
+ dev_path(dev), resource->index);
return;
}
- printk_debug(
- "%s %02x <- [0x%08lx - 0x%08lx] %s\n",
- dev_path(dev),
- resource->index,
- resource->base, resource->base + resource->size - 1,
- (resource->flags & IORESOURCE_IO)? "io":
- (resource->flags & IORESOURCE_DRQ)? "drq":
- (resource->flags & IORESOURCE_IRQ)? "irq":
- (resource->flags & IORESOURCE_MEM)? "mem":
- "???");
+ printk_debug("%s %02x <- [0x%08lx - 0x%08lx] %s\n", dev_path(dev),
+ resource->index, resource->base,
+ resource->base + resource->size - 1,
+ (resource->flags & IORESOURCE_IO)? "io":
+ (resource->flags & IORESOURCE_DRQ)? "drq":
+ (resource->flags & IORESOURCE_IRQ)? "irq":
+ (resource->flags & IORESOURCE_MEM)? "mem":
+ "???");
}
void pnp_set_resources(device_t dev)
@@ -115,23 +109,20 @@ void pnp_set_resources(device_t dev)
pnp_set_logical_device(dev);
/* Paranoia says I should disable the device here... */
- for(i = 0; i < dev->resources; i++) {
+ for (i = 0; i < dev->resources; i++) {
pnp_set_resource(dev, &dev->resource[i]);
}
-
}
void pnp_enable_resources(device_t dev)
{
pnp_set_logical_device(dev);
pnp_set_enable(dev, 1);
-
}
void pnp_enable(device_t dev)
{
-
- if (!dev->enabled) {
+ if (!dev->enabled) {
pnp_set_logical_device(dev);
pnp_set_enable(dev, 0);
}
@@ -146,10 +137,12 @@ struct device_operations pnp_ops = {
/* PNP chip opertations */
-static void pnp_get_ioresource(device_t dev, unsigned index, struct io_info *info)
+static void pnp_get_ioresource(device_t dev, unsigned index,
+ struct io_info *info)
{
struct resource *resource;
uint32_t size;
+
resource = get_resource(dev, index);
/* Initilize the resource */
@@ -194,35 +187,32 @@ static void get_resources(device_t dev, struct pnp_info *info)
resource = get_resource(dev, PNP_IDX_DRQ1);
resource->size = 1;
resource->flags |= IORESOURCE_DRQ;
- }
-
+ }
}
void pnp_enumerate(struct chip *chip, unsigned functions,
- struct device_operations *ops, struct pnp_info *info)
+ struct device_operations *ops, struct pnp_info *info)
{
struct device_path path;
device_t dev;
int i;
chip_enumerate(chip);
+
path.type = DEVICE_PATH_PNP;
path.u.pnp.port = chip->dev->path.u.pnp.port;
-
/* Setup the ops and resources on the newly allocated devices */
- for(i = 0; i < functions; i++) {
+ for (i = 0; i < functions; i++) {
path.u.pnp.device = info[i].function;
dev = alloc_find_dev(chip->bus, &path);
- if(info[i].ops == 0) { // BY LYH
- dev->ops = ops;
- }
- else {
- dev->ops = info[i].ops; // BY LYH
+ if (info[i].ops == 0) {
+ dev->ops = ops;
+ } else {
+ dev->ops = info[i].ops;
}
get_resources(dev, &info[i]);
-
}
}