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>
13 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
15 #include <linux/autoconf.h>
17 #if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE)
20 * pccard_loop_tuple() - loop over tuples in the CIS
21 * @s: the struct pcmcia_socket where the card is inserted
22 * @function: the device function we loop for
23 * @code: which CIS code shall we look for?
24 * @parse: buffer where the tuple shall be parsed (or NULL, if no parse)
25 * @priv_data: private data to be passed to the loop_tuple function.
26 * @loop_tuple: function to call for each CIS entry of type @function. IT
27 * gets passed the raw tuple, the paresed tuple (if @parse is
28 * set) and @priv_data.
30 * pccard_loop_tuple() loops over all CIS entries of type @function, and
31 * calls the @loop_tuple function for each entry. If the call to @loop_tuple
32 * returns 0, the loop exits. Returns 0 on success or errorcode otherwise.
34 int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function,
35 cisdata_t code, cisparse_t *parse, void *priv_data,
36 int (*loop_tuple) (tuple_t *tuple,
44 buf = kzalloc(256, GFP_KERNEL);
46 dev_printk(KERN_WARNING, &s->dev, "no memory to read tuple\n");
50 tuple.TupleData = buf;
51 tuple.TupleDataMax = 255;
52 tuple.TupleOffset = 0;
53 tuple.DesiredTuple = code;
56 ret = pccard_get_first_tuple(s, function, &tuple);
58 if (pccard_get_tuple_data(s, &tuple))
62 if (pcmcia_parse_tuple(&tuple, parse))
65 ret = loop_tuple(&tuple, parse, priv_data);
70 ret = pccard_get_next_tuple(s, function, &tuple);
76 EXPORT_SYMBOL(pccard_loop_tuple);
77 /* Source: drivers/pcmcia/cistpl.c */
79 #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
81 struct pcmcia_loop_mem {
82 struct pcmcia_device *p_dev;
84 int (*loop_tuple) (struct pcmcia_device *p_dev,
90 * pcmcia_do_loop_tuple() - internal helper for pcmcia_loop_config()
92 * pcmcia_do_loop_tuple() is the internal callback for the call from
93 * pcmcia_loop_tuple() to pccard_loop_tuple(). Data is transferred
94 * by a struct pcmcia_cfg_mem.
96 static int pcmcia_do_loop_tuple(tuple_t *tuple, cisparse_t *parse, void *priv)
98 struct pcmcia_loop_mem *loop = priv;
100 return loop->loop_tuple(loop->p_dev, tuple, loop->priv_data);
104 * pcmcia_loop_tuple() - loop over tuples in the CIS
105 * @p_dev: the struct pcmcia_device which we need to loop for.
106 * @code: which CIS code shall we look for?
107 * @priv_data: private data to be passed to the loop_tuple function.
108 * @loop_tuple: function to call for each CIS entry of type @function. IT
109 * gets passed the raw tuple and @priv_data.
111 * pcmcia_loop_tuple() loops over all CIS entries of type @function, and
112 * calls the @loop_tuple function for each entry. If the call to @loop_tuple
113 * returns 0, the loop exits. Returns 0 on success or errorcode otherwise.
115 int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code,
116 int (*loop_tuple) (struct pcmcia_device *p_dev,
121 struct pcmcia_loop_mem loop = {
123 .loop_tuple = loop_tuple,
124 .priv_data = priv_data};
126 return pccard_loop_tuple(p_dev->socket, p_dev->func, code, NULL,
127 &loop, pcmcia_do_loop_tuple);
129 EXPORT_SYMBOL(pcmcia_loop_tuple);
130 /* Source: drivers/pcmcia/pcmcia_resource.c */
132 #endif /* CONFIG_PCMCIA */
134 #endif /* CONFIG_PCCARD */
136 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */