pcmcia: move all pcmcia_resource_ops providers into one module
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
This commit is contained in:
Родитель
5c128e8432
Коммит
49b1153adf
|
@ -317,7 +317,7 @@ config ELECTRA_CF
|
|||
PA Semi Electra eval board.
|
||||
|
||||
config PCCARD_NONSTATIC
|
||||
tristate
|
||||
bool
|
||||
|
||||
config PCCARD_IODYN
|
||||
bool
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# Makefile for the kernel pcmcia subsystem (c/o David Hinds)
|
||||
#
|
||||
|
||||
pcmcia_core-y += cs.o rsrc_mgr.o socket_sysfs.o
|
||||
pcmcia_core-y += cs.o socket_sysfs.o
|
||||
pcmcia_core-$(CONFIG_CARDBUS) += cardbus.o
|
||||
obj-$(CONFIG_PCCARD) += pcmcia_core.o
|
||||
|
||||
|
@ -10,7 +10,10 @@ pcmcia-y += ds.o pcmcia_resource.o cistpl.o pcmcia_cis.o
|
|||
pcmcia-$(CONFIG_PCMCIA_IOCTL) += pcmcia_ioctl.o
|
||||
obj-$(CONFIG_PCMCIA) += pcmcia.o
|
||||
|
||||
obj-$(CONFIG_PCCARD_NONSTATIC) += rsrc_nonstatic.o
|
||||
pcmcia_rsrc-y += rsrc_mgr.o
|
||||
pcmcia_rsrc-$(CONFIG_PCCARD_NONSTATIC) += rsrc_nonstatic.o
|
||||
pcmcia_rsrc-$(CONFIG_PCCARD_IODYN) += rsrc_iodyn.o
|
||||
obj-$(CONFIG_PCCARD) += pcmcia_rsrc.o
|
||||
|
||||
|
||||
# socket drivers
|
||||
|
|
|
@ -88,6 +88,14 @@ struct pccard_resource_ops {
|
|||
#define SOCKET_CARDBUS_CONFIG 0x10000
|
||||
|
||||
|
||||
/*
|
||||
* Stuff internal to module "pcmcia_rsrc":
|
||||
*/
|
||||
extern int static_init(struct pcmcia_socket *s);
|
||||
extern struct resource *pcmcia_make_resource(unsigned long start,
|
||||
unsigned long end,
|
||||
int flags, const char *name);
|
||||
|
||||
/*
|
||||
* Stuff internal to module "pcmcia_core":
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* rsrc_iodyn.c -- Resource management routines for MEM-static sockets.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* The initial developer of the original code is David A. Hinds
|
||||
* <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
|
||||
* are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
|
||||
*
|
||||
* (C) 1999 David A. Hinds
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
#include <pcmcia/cs_types.h>
|
||||
#include <pcmcia/ss.h>
|
||||
#include <pcmcia/cs.h>
|
||||
#include <pcmcia/cistpl.h>
|
||||
#include "cs_internal.h"
|
||||
|
||||
|
||||
struct pcmcia_align_data {
|
||||
unsigned long mask;
|
||||
unsigned long offset;
|
||||
};
|
||||
|
||||
static resource_size_t pcmcia_align(void *align_data,
|
||||
const struct resource *res,
|
||||
resource_size_t size, resource_size_t align)
|
||||
{
|
||||
struct pcmcia_align_data *data = align_data;
|
||||
resource_size_t start;
|
||||
|
||||
start = (res->start & ~data->mask) + data->offset;
|
||||
if (start < res->start)
|
||||
start += data->mask + 1;
|
||||
|
||||
#ifdef CONFIG_X86
|
||||
if (res->flags & IORESOURCE_IO) {
|
||||
if (start & 0x300)
|
||||
start = (start + 0x3ff) & ~0x3ff;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_M68K
|
||||
if (res->flags & IORESOURCE_IO) {
|
||||
if ((res->start + size - 1) >= 1024)
|
||||
start = res->end;
|
||||
}
|
||||
#endif
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
|
||||
static int iodyn_adjust_io_region(struct resource *res, unsigned long r_start,
|
||||
unsigned long r_end, struct pcmcia_socket *s)
|
||||
{
|
||||
return adjust_resource(res, r_start, r_end - r_start + 1);
|
||||
}
|
||||
|
||||
|
||||
static struct resource *iodyn_find_io_region(unsigned long base, int num,
|
||||
unsigned long align, struct pcmcia_socket *s)
|
||||
{
|
||||
struct resource *res = pcmcia_make_resource(0, num, IORESOURCE_IO,
|
||||
dev_name(&s->dev));
|
||||
struct pcmcia_align_data data;
|
||||
unsigned long min = base;
|
||||
int ret;
|
||||
|
||||
if (align == 0)
|
||||
align = 0x10000;
|
||||
|
||||
data.mask = align - 1;
|
||||
data.offset = base & data.mask;
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
if (s->cb_dev) {
|
||||
ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, 1,
|
||||
min, 0, pcmcia_align, &data);
|
||||
} else
|
||||
#endif
|
||||
ret = allocate_resource(&ioport_resource, res, num, min, ~0UL,
|
||||
1, pcmcia_align, &data);
|
||||
|
||||
if (ret != 0) {
|
||||
kfree(res);
|
||||
res = NULL;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
struct pccard_resource_ops pccard_iodyn_ops = {
|
||||
.validate_mem = NULL,
|
||||
.adjust_io_region = iodyn_adjust_io_region,
|
||||
.find_io = iodyn_find_io_region,
|
||||
.find_mem = NULL,
|
||||
.add_io = NULL,
|
||||
.add_mem = NULL,
|
||||
.init = static_init,
|
||||
.exit = NULL,
|
||||
};
|
||||
EXPORT_SYMBOL(pccard_iodyn_ops);
|
|
@ -22,7 +22,7 @@
|
|||
#include <pcmcia/cistpl.h>
|
||||
#include "cs_internal.h"
|
||||
|
||||
static int static_init(struct pcmcia_socket *s)
|
||||
int static_init(struct pcmcia_socket *s)
|
||||
{
|
||||
/* the good thing about SS_CAP_STATIC_MAP sockets is
|
||||
* that they don't need a resource database */
|
||||
|
@ -32,6 +32,20 @@ static int static_init(struct pcmcia_socket *s)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct resource *pcmcia_make_resource(unsigned long start, unsigned long end,
|
||||
int flags, const char *name)
|
||||
{
|
||||
struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
|
||||
|
||||
if (res) {
|
||||
res->name = name;
|
||||
res->start = start;
|
||||
res->end = start + end - 1;
|
||||
res->flags = flags;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
struct pccard_resource_ops pccard_static_ops = {
|
||||
.validate_mem = NULL,
|
||||
|
@ -46,104 +60,6 @@ struct pccard_resource_ops pccard_static_ops = {
|
|||
EXPORT_SYMBOL(pccard_static_ops);
|
||||
|
||||
|
||||
#ifdef CONFIG_PCCARD_IODYN
|
||||
|
||||
static struct resource *
|
||||
make_resource(unsigned long b, unsigned long n, int flags, char *name)
|
||||
{
|
||||
struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
|
||||
|
||||
if (res) {
|
||||
res->name = name;
|
||||
res->start = b;
|
||||
res->end = b + n - 1;
|
||||
res->flags = flags;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
struct pcmcia_align_data {
|
||||
unsigned long mask;
|
||||
unsigned long offset;
|
||||
};
|
||||
|
||||
static resource_size_t pcmcia_align(void *align_data,
|
||||
const struct resource *res,
|
||||
resource_size_t size, resource_size_t align)
|
||||
{
|
||||
struct pcmcia_align_data *data = align_data;
|
||||
resource_size_t start;
|
||||
|
||||
start = (res->start & ~data->mask) + data->offset;
|
||||
if (start < res->start)
|
||||
start += data->mask + 1;
|
||||
|
||||
#ifdef CONFIG_X86
|
||||
if (res->flags & IORESOURCE_IO) {
|
||||
if (start & 0x300)
|
||||
start = (start + 0x3ff) & ~0x3ff;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_M68K
|
||||
if (res->flags & IORESOURCE_IO) {
|
||||
if ((res->start + size - 1) >= 1024)
|
||||
start = res->end;
|
||||
}
|
||||
#endif
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
|
||||
static int iodyn_adjust_io_region(struct resource *res, unsigned long r_start,
|
||||
unsigned long r_end, struct pcmcia_socket *s)
|
||||
{
|
||||
return adjust_resource(res, r_start, r_end - r_start + 1);
|
||||
}
|
||||
|
||||
|
||||
static struct resource *iodyn_find_io_region(unsigned long base, int num,
|
||||
unsigned long align, struct pcmcia_socket *s)
|
||||
{
|
||||
struct resource *res = make_resource(0, num, IORESOURCE_IO,
|
||||
dev_name(&s->dev));
|
||||
struct pcmcia_align_data data;
|
||||
unsigned long min = base;
|
||||
int ret;
|
||||
|
||||
if (align == 0)
|
||||
align = 0x10000;
|
||||
|
||||
data.mask = align - 1;
|
||||
data.offset = base & data.mask;
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
if (s->cb_dev) {
|
||||
ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, 1,
|
||||
min, 0, pcmcia_align, &data);
|
||||
} else
|
||||
#endif
|
||||
ret = allocate_resource(&ioport_resource, res, num, min, ~0UL,
|
||||
1, pcmcia_align, &data);
|
||||
|
||||
if (ret != 0) {
|
||||
kfree(res);
|
||||
res = NULL;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
struct pccard_resource_ops pccard_iodyn_ops = {
|
||||
.validate_mem = NULL,
|
||||
.adjust_io_region = iodyn_adjust_io_region,
|
||||
.find_io = iodyn_find_io_region,
|
||||
.find_mem = NULL,
|
||||
.add_io = NULL,
|
||||
.add_mem = NULL,
|
||||
.init = static_init,
|
||||
.exit = NULL,
|
||||
};
|
||||
EXPORT_SYMBOL(pccard_iodyn_ops);
|
||||
|
||||
#endif /* CONFIG_PCCARD_IODYN */
|
||||
MODULE_AUTHOR("David A. Hinds, Dominik Brodowski");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_ALIAS("rsrc_nonstatic");
|
||||
|
|
|
@ -34,8 +34,10 @@
|
|||
#include <pcmcia/cistpl.h>
|
||||
#include "cs_internal.h"
|
||||
|
||||
/* moved to rsrc_mgr.c
|
||||
MODULE_AUTHOR("David A. Hinds, Dominik Brodowski");
|
||||
MODULE_LICENSE("GPL");
|
||||
*/
|
||||
|
||||
/* Parameters that can be set with 'insmod' */
|
||||
|
||||
|
@ -69,20 +71,6 @@ struct socket_data {
|
|||
|
||||
======================================================================*/
|
||||
|
||||
static struct resource *
|
||||
make_resource(resource_size_t b, resource_size_t n, int flags, const char *name)
|
||||
{
|
||||
struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
|
||||
|
||||
if (res) {
|
||||
res->name = name;
|
||||
res->start = b;
|
||||
res->end = b + n - 1;
|
||||
res->flags = flags;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static struct resource *
|
||||
claim_region(struct pcmcia_socket *s, resource_size_t base,
|
||||
resource_size_t size, int type, char *name)
|
||||
|
@ -90,7 +78,7 @@ claim_region(struct pcmcia_socket *s, resource_size_t base,
|
|||
struct resource *res, *parent;
|
||||
|
||||
parent = type & IORESOURCE_MEM ? &iomem_resource : &ioport_resource;
|
||||
res = make_resource(base, size, type | IORESOURCE_BUSY, name);
|
||||
res = pcmcia_make_resource(base, size, type | IORESOURCE_BUSY, name);
|
||||
|
||||
if (res) {
|
||||
#ifdef CONFIG_PCI
|
||||
|
@ -698,7 +686,8 @@ static int nonstatic_adjust_io_region(struct resource *res, unsigned long r_star
|
|||
static struct resource *nonstatic_find_io_region(unsigned long base, int num,
|
||||
unsigned long align, struct pcmcia_socket *s)
|
||||
{
|
||||
struct resource *res = make_resource(0, num, IORESOURCE_IO, dev_name(&s->dev));
|
||||
struct resource *res = pcmcia_make_resource(0, num, IORESOURCE_IO,
|
||||
dev_name(&s->dev));
|
||||
struct socket_data *s_data = s->resource_data;
|
||||
struct pcmcia_align_data data;
|
||||
unsigned long min = base;
|
||||
|
@ -730,7 +719,8 @@ static struct resource *nonstatic_find_io_region(unsigned long base, int num,
|
|||
static struct resource *nonstatic_find_mem_region(u_long base, u_long num,
|
||||
u_long align, int low, struct pcmcia_socket *s)
|
||||
{
|
||||
struct resource *res = make_resource(0, num, IORESOURCE_MEM, dev_name(&s->dev));
|
||||
struct resource *res = pcmcia_make_resource(0, num, IORESOURCE_MEM,
|
||||
dev_name(&s->dev));
|
||||
struct socket_data *s_data = s->resource_data;
|
||||
struct pcmcia_align_data data;
|
||||
unsigned long min, max;
|
||||
|
|
Загрузка…
Ссылка в новой задаче