blob: 252893216e508e54deb26fae97feb20cb22f49b1 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * rsrc_mgr.c -- Resource management routines and/or wrappers
4 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * The initial developer of the original code is David A. Hinds
6 * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
7 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
8 *
9 * (C) 1999 David A. Hinds
10 */
11
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090012#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/module.h>
14#include <linux/kernel.h>
15
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <pcmcia/ss.h>
Dominik Brodowski91284222009-10-18 23:32:33 +020017#include <pcmcia/cistpl.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include "cs_internal.h"
19
Dominik Brodowski49b11532010-03-07 16:41:57 +010020int static_init(struct pcmcia_socket *s)
Linus Torvalds1da177e2005-04-16 15:20:36 -070021{
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 /* the good thing about SS_CAP_STATIC_MAP sockets is
23 * that they don't need a resource database */
24
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 s->resource_setup_done = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
27 return 0;
28}
29
Alan Coxa6c61932014-12-10 15:05:38 +000030struct resource *pcmcia_make_resource(resource_size_t start,
31 resource_size_t end,
32 unsigned long flags, const char *name)
Dominik Brodowski49b11532010-03-07 16:41:57 +010033{
34 struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
35
36 if (res) {
37 res->name = name;
38 res->start = start;
39 res->end = start + end - 1;
40 res->flags = flags;
41 }
42 return res;
43}
44
Dominik Brodowskib19a7272010-03-20 13:10:47 +010045static int static_find_io(struct pcmcia_socket *s, unsigned int attr,
46 unsigned int *base, unsigned int num,
Dominik Brodowskiad0c7be2010-07-25 13:10:22 +020047 unsigned int align, struct resource **parent)
Dominik Brodowskib19a7272010-03-20 13:10:47 +010048{
49 if (!s->io_offset)
50 return -EINVAL;
51 *base = s->io_offset | (*base & 0x0fff);
Dominik Brodowskiad0c7be2010-07-25 13:10:22 +020052 *parent = NULL;
Dominik Brodowskib19a7272010-03-20 13:10:47 +010053
54 return 0;
55}
56
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58struct pccard_resource_ops pccard_static_ops = {
59 .validate_mem = NULL,
Dominik Brodowskib19a7272010-03-20 13:10:47 +010060 .find_io = static_find_io,
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 .find_mem = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 .init = static_init,
63 .exit = NULL,
64};
65EXPORT_SYMBOL(pccard_static_ops);
Dominik Brodowski3b27e942005-12-07 12:32:20 +010066
67
Dominik Brodowski49b11532010-03-07 16:41:57 +010068MODULE_AUTHOR("David A. Hinds, Dominik Brodowski");
69MODULE_LICENSE("GPL");
70MODULE_ALIAS("rsrc_nonstatic");