blob: 4e80421fd9084d02433aea7f1c0561edcd2c6192 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * rsrc_mgr.c -- Resource management routines and/or wrappers
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * The initial developer of the original code is David A. Hinds
9 * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
10 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
11 *
12 * (C) 1999 David A. Hinds
13 */
14
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090015#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/module.h>
17#include <linux/kernel.h>
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <pcmcia/ss.h>
20#include <pcmcia/cs.h>
Dominik Brodowski91284222009-10-18 23:32:33 +020021#include <pcmcia/cistpl.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include "cs_internal.h"
23
Dominik Brodowski49b11532010-03-07 16:41:57 +010024int static_init(struct pcmcia_socket *s)
Linus Torvalds1da177e2005-04-16 15:20:36 -070025{
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 /* the good thing about SS_CAP_STATIC_MAP sockets is
27 * that they don't need a resource database */
28
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 s->resource_setup_done = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31 return 0;
32}
33
Dominik Brodowski49b11532010-03-07 16:41:57 +010034struct resource *pcmcia_make_resource(unsigned long start, unsigned long end,
35 int flags, const char *name)
36{
37 struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
38
39 if (res) {
40 res->name = name;
41 res->start = start;
42 res->end = start + end - 1;
43 res->flags = flags;
44 }
45 return res;
46}
47
Dominik Brodowskib19a7272010-03-20 13:10:47 +010048static int static_find_io(struct pcmcia_socket *s, unsigned int attr,
49 unsigned int *base, unsigned int num,
Dominik Brodowskiad0c7be2010-07-25 13:10:22 +020050 unsigned int align, struct resource **parent)
Dominik Brodowskib19a7272010-03-20 13:10:47 +010051{
52 if (!s->io_offset)
53 return -EINVAL;
54 *base = s->io_offset | (*base & 0x0fff);
Dominik Brodowskiad0c7be2010-07-25 13:10:22 +020055 *parent = NULL;
Dominik Brodowskib19a7272010-03-20 13:10:47 +010056
57 return 0;
58}
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61struct pccard_resource_ops pccard_static_ops = {
62 .validate_mem = NULL,
Dominik Brodowskib19a7272010-03-20 13:10:47 +010063 .find_io = static_find_io,
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 .find_mem = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 .init = static_init,
66 .exit = NULL,
67};
68EXPORT_SYMBOL(pccard_static_ops);
Dominik Brodowski3b27e942005-12-07 12:32:20 +010069
70
Dominik Brodowski49b11532010-03-07 16:41:57 +010071MODULE_AUTHOR("David A. Hinds, Dominik Brodowski");
72MODULE_LICENSE("GPL");
73MODULE_ALIAS("rsrc_nonstatic");