2 * Copyright 2009 Hauke Mehrtens <hauke@hauke-m.de>
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.
8 * Compatibility file for Linux wireless for kernels 2.6.33.
11 #include <linux/compat.h>
12 #include <linux/autoconf.h>
14 #if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE)
17 * pccard_loop_tuple() - loop over tuples in the CIS
18 * @s: the struct pcmcia_socket where the card is inserted
19 * @function: the device function we loop for
20 * @code: which CIS code shall we look for?
21 * @parse: buffer where the tuple shall be parsed (or NULL, if no parse)
22 * @priv_data: private data to be passed to the loop_tuple function.
23 * @loop_tuple: function to call for each CIS entry of type @function. IT
24 * gets passed the raw tuple, the paresed tuple (if @parse is
25 * set) and @priv_data.
27 * pccard_loop_tuple() loops over all CIS entries of type @function, and
28 * calls the @loop_tuple function for each entry. If the call to @loop_tuple
29 * returns 0, the loop exits. Returns 0 on success or errorcode otherwise.
31 int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function,
32 cisdata_t code, cisparse_t *parse, void *priv_data,
33 int (*loop_tuple) (tuple_t *tuple,
41 buf = kzalloc(256, GFP_KERNEL);
43 dev_printk(KERN_WARNING, &s->dev, "no memory to read tuple\n");
47 tuple.TupleData = buf;
48 tuple.TupleDataMax = 255;
49 tuple.TupleOffset = 0;
50 tuple.DesiredTuple = code;
53 ret = pccard_get_first_tuple(s, function, &tuple);
55 if (pccard_get_tuple_data(s, &tuple))
59 if (pcmcia_parse_tuple(&tuple, parse))
62 ret = loop_tuple(&tuple, parse, priv_data);
67 ret = pccard_get_next_tuple(s, function, &tuple);
73 EXPORT_SYMBOL(pccard_loop_tuple);
74 /* Source: drivers/pcmcia/cistpl.c */
76 #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
78 struct pcmcia_loop_mem {
79 struct pcmcia_device *p_dev;
81 int (*loop_tuple) (struct pcmcia_device *p_dev,
87 * pcmcia_do_loop_tuple() - internal helper for pcmcia_loop_config()
89 * pcmcia_do_loop_tuple() is the internal callback for the call from
90 * pcmcia_loop_tuple() to pccard_loop_tuple(). Data is transferred
91 * by a struct pcmcia_cfg_mem.
93 static int pcmcia_do_loop_tuple(tuple_t *tuple, cisparse_t *parse, void *priv)
95 struct pcmcia_loop_mem *loop = priv;
97 return loop->loop_tuple(loop->p_dev, tuple, loop->priv_data);
101 * pcmcia_loop_tuple() - loop over tuples in the CIS
102 * @p_dev: the struct pcmcia_device which we need to loop for.
103 * @code: which CIS code shall we look for?
104 * @priv_data: private data to be passed to the loop_tuple function.
105 * @loop_tuple: function to call for each CIS entry of type @function. IT
106 * gets passed the raw tuple and @priv_data.
108 * pcmcia_loop_tuple() loops over all CIS entries of type @function, and
109 * calls the @loop_tuple function for each entry. If the call to @loop_tuple
110 * returns 0, the loop exits. Returns 0 on success or errorcode otherwise.
112 int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code,
113 int (*loop_tuple) (struct pcmcia_device *p_dev,
118 struct pcmcia_loop_mem loop = {
120 .loop_tuple = loop_tuple,
121 .priv_data = priv_data};
123 return pccard_loop_tuple(p_dev->socket, p_dev->func, code, NULL,
124 &loop, pcmcia_do_loop_tuple);
126 EXPORT_SYMBOL(pcmcia_loop_tuple);
127 /* Source: drivers/pcmcia/pcmcia_resource.c */
129 #endif /* CONFIG_PCMCIA */
131 #endif /* CONFIG_PCCARD */