| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
 | 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 Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 15 | #include <linux/slab.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/module.h> | 
 | 17 | #include <linux/kernel.h> | 
 | 18 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <pcmcia/ss.h> | 
| Dominik Brodowski | 9128422 | 2009-10-18 23:32:33 +0200 | [diff] [blame] | 20 | #include <pcmcia/cistpl.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include "cs_internal.h" | 
 | 22 |  | 
| Dominik Brodowski | 49b1153 | 2010-03-07 16:41:57 +0100 | [diff] [blame] | 23 | int static_init(struct pcmcia_socket *s) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | 	/* the good thing about SS_CAP_STATIC_MAP sockets is | 
 | 26 | 	 * that they don't need a resource database */ | 
 | 27 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | 	s->resource_setup_done = 1; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 |  | 
 | 30 | 	return 0; | 
 | 31 | } | 
 | 32 |  | 
| Dominik Brodowski | 49b1153 | 2010-03-07 16:41:57 +0100 | [diff] [blame] | 33 | struct resource *pcmcia_make_resource(unsigned long start, unsigned long end, | 
 | 34 | 				int flags, const char *name) | 
 | 35 | { | 
 | 36 | 	struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL); | 
 | 37 |  | 
 | 38 | 	if (res) { | 
 | 39 | 		res->name = name; | 
 | 40 | 		res->start = start; | 
 | 41 | 		res->end = start + end - 1; | 
 | 42 | 		res->flags = flags; | 
 | 43 | 	} | 
 | 44 | 	return res; | 
 | 45 | } | 
 | 46 |  | 
| Dominik Brodowski | b19a727 | 2010-03-20 13:10:47 +0100 | [diff] [blame] | 47 | static int static_find_io(struct pcmcia_socket *s, unsigned int attr, | 
 | 48 | 			unsigned int *base, unsigned int num, | 
| Dominik Brodowski | ad0c7be | 2010-07-25 13:10:22 +0200 | [diff] [blame] | 49 | 			unsigned int align, struct resource **parent) | 
| Dominik Brodowski | b19a727 | 2010-03-20 13:10:47 +0100 | [diff] [blame] | 50 | { | 
 | 51 | 	if (!s->io_offset) | 
 | 52 | 		return -EINVAL; | 
 | 53 | 	*base = s->io_offset | (*base & 0x0fff); | 
| Dominik Brodowski | ad0c7be | 2010-07-25 13:10:22 +0200 | [diff] [blame] | 54 | 	*parent = NULL; | 
| Dominik Brodowski | b19a727 | 2010-03-20 13:10:47 +0100 | [diff] [blame] | 55 |  | 
 | 56 | 	return 0; | 
 | 57 | } | 
 | 58 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 |  | 
 | 60 | struct pccard_resource_ops pccard_static_ops = { | 
 | 61 | 	.validate_mem = NULL, | 
| Dominik Brodowski | b19a727 | 2010-03-20 13:10:47 +0100 | [diff] [blame] | 62 | 	.find_io = static_find_io, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | 	.find_mem = NULL, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | 	.init = static_init, | 
 | 65 | 	.exit = NULL, | 
 | 66 | }; | 
 | 67 | EXPORT_SYMBOL(pccard_static_ops); | 
| Dominik Brodowski | 3b27e94 | 2005-12-07 12:32:20 +0100 | [diff] [blame] | 68 |  | 
 | 69 |  | 
| Dominik Brodowski | 49b1153 | 2010-03-07 16:41:57 +0100 | [diff] [blame] | 70 | MODULE_AUTHOR("David A. Hinds, Dominik Brodowski"); | 
 | 71 | MODULE_LICENSE("GPL"); | 
 | 72 | MODULE_ALIAS("rsrc_nonstatic"); |