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
This commit is contained in:
Li-Ta Lo 2004-05-07 21:56:48 +00:00
parent 89666e4893
commit 75337f7500
1 changed files with 28 additions and 38 deletions

View File

@ -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 */
@ -195,34 +188,31 @@ static void get_resources(device_t dev, struct pnp_info *info)
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]);
}
}