static ssize_t store_mem_db(struct class_device *class_dev, const char *buf, size_t count) { struct pcmcia_socket *s = class_get_devdata(class_dev); unsigned long start_addr, end_addr; unsigned int add = ADD_MANAGED_RESOURCE; ssize_t ret = 0; ret = sscanf (buf, "+ 0x%lx - 0x%lx", &start_addr, &end_addr); if (ret != 2) { ret = sscanf (buf, "- 0x%lx - 0x%lx", &start_addr, &end_addr); add = REMOVE_MANAGED_RESOURCE; if (ret != 2) { ret = sscanf (buf, "0x%lx - 0x%lx", &start_addr, &end_addr); add = ADD_MANAGED_RESOURCE; if (ret != 2) return -EINVAL; } } if (end_addr < start_addr) return -EINVAL; ret = adjust_memory(s, add, start_addr, end_addr); if (!ret) s->resource_setup_new = 1; return ret ? ret : count; }
static int nonstatic_autoadd_resources(struct pcmcia_socket *s) { struct resource *res; int i, done = 0; if (!s->cb_dev || !s->cb_dev->bus) return -ENODEV; #if defined(CONFIG_X86) /* If this is the root bus, the risk of hitting * some strange system devices which aren't protected * by either ACPI resource tables or properly requested * resources is too big. Therefore, don't do auto-adding * of resources at the moment. */ if (s->cb_dev->bus->number == 0) return -EINVAL; #endif for (i=0; i < PCI_BUS_NUM_RESOURCES; i++) { res = s->cb_dev->bus->resource[i]; if (!res) continue; if (res->flags & IORESOURCE_IO) { if (res == &ioport_resource) continue; dev_printk(KERN_INFO, &s->cb_dev->dev, "pcmcia: parent PCI bridge I/O " "window: 0x%llx - 0x%llx\n", (unsigned long long)res->start, (unsigned long long)res->end); if (!adjust_io(s, ADD_MANAGED_RESOURCE, res->start, res->end)) done |= IORESOURCE_IO; } if (res->flags & IORESOURCE_MEM) { if (res == &iomem_resource) continue; dev_printk(KERN_INFO, &s->cb_dev->dev, "pcmcia: parent PCI bridge Memory " "window: 0x%llx - 0x%llx\n", (unsigned long long)res->start, (unsigned long long)res->end); if (!adjust_memory(s, ADD_MANAGED_RESOURCE, res->start, res->end)) done |= IORESOURCE_MEM; } } /* if we got at least one of IO, and one of MEM, we can be glad and * activate the PCMCIA subsystem */ if (done == (IORESOURCE_MEM | IORESOURCE_IO)) s->resource_setup_done = 1; return 0; }
static int nonstatic_adjust_resource_info(struct pcmcia_socket *s, adjust_t *adj) { unsigned long end; switch (adj->Resource) { case RES_MEMORY_RANGE: end = adj->resource.memory.Base + adj->resource.memory.Size - 1; return adjust_memory(s, adj->Action, adj->resource.memory.Base, end); case RES_IO_RANGE: end = adj->resource.io.BasePort + adj->resource.io.NumPorts - 1; return adjust_io(s, adj->Action, adj->resource.io.BasePort, end); } return CS_UNSUPPORTED_FUNCTION; }