-/*======================================================================
-
- PCMCIA Card Information Structure parser
-
- cistpl.c 1.99 2002/10/24 06:11:48
-
- The contents of this file are subject to the Mozilla Public
- License Version 1.1 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of
- the License at http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS
- IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- implied. See the License for the specific language governing
- rights and limitations under the License.
-
- The initial developer of the original code is David A. Hinds
- <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
-
- Alternatively, the contents of this file may be used under the
- terms of the GNU General Public License version 2 (the "GPL"), in
- which case the provisions of the GPL are applicable instead of the
- above. If you wish to allow the use of your version of this file
- only under the terms of the GPL and not to allow others to use
- your version of this file under the MPL, indicate your decision
- by deleting the provisions above and replace them with the notice
- and other provisions required by the GPL. If you do not delete
- the provisions above, a recipient may use your version of this
- file under either the MPL or the GPL.
-
-======================================================================*/
+/*
+ * cistpl.c -- 16-bit PCMCIA Card Information Structure parser
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * The initial developer of the original code is David A. Hinds
+ * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
+ * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
+ *
+ * (C) 1999 David A. Hinds
+ */
#include <linux/config.h>
#include <linux/module.h>
s->cis_virt = NULL;
}
}
+EXPORT_SYMBOL(release_cis_mem);
/*
* Map the card memory at "card_offset" into virtual space.
{
pccard_mem_map *mem = &s->cis_mem;
if (!(s->features & SS_CAP_STATIC_MAP) && mem->res == NULL) {
- mem->res = find_mem_region(0, s->map_size, s->map_size, 0,
- "card services", s);
+ mem->res = find_mem_region(0, s->map_size, s->map_size, 0, s);
if (mem->res == NULL) {
printk(KERN_NOTICE "cs: unable to map card memory!\n");
return NULL;
list_del(&cis->node);
kfree(cis);
}
+
+ /*
+ * If there was a fake CIS, destroy that as well.
+ */
+ if (s->fake_cis) {
+ kfree(s->fake_cis);
+ s->fake_cis = NULL;
+ }
}
+EXPORT_SYMBOL(destroy_cis_cache);
/*======================================================================
======================================================================*/
-int pcmcia_replace_cis(client_handle_t handle, cisdump_t *cis)
+int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis)
{
- struct pcmcia_socket *s;
- if (CHECK_HANDLE(handle))
- return CS_BAD_HANDLE;
- s = SOCKET(handle);
if (s->fake_cis != NULL) {
kfree(s->fake_cis);
s->fake_cis = NULL;
#define MFC_FN(f) (((tuple_flags *)(&(f)))->mfc_fn)
#define SPACE(f) (((tuple_flags *)(&(f)))->space)
-int pcmcia_get_next_tuple(client_handle_t handle, tuple_t *tuple);
+int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int func, tuple_t *tuple);
-int pcmcia_get_first_tuple(client_handle_t handle, tuple_t *tuple)
+int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple)
{
- struct pcmcia_socket *s;
- if (CHECK_HANDLE(handle))
+ if (!s)
return CS_BAD_HANDLE;
- s = SOCKET(handle);
if (!(s->state & SOCKET_PRESENT))
return CS_NO_CARD;
tuple->TupleLink = tuple->Flags = 0;
!(tuple->Attributes & TUPLE_RETURN_COMMON)) {
cisdata_t req = tuple->DesiredTuple;
tuple->DesiredTuple = CISTPL_LONGLINK_MFC;
- if (pcmcia_get_next_tuple(handle, tuple) == CS_SUCCESS) {
+ if (pccard_get_next_tuple(s, function, tuple) == CS_SUCCESS) {
tuple->DesiredTuple = CISTPL_LINKTARGET;
- if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS)
+ if (pccard_get_next_tuple(s, function, tuple) != CS_SUCCESS)
return CS_NO_MORE_ITEMS;
} else
tuple->CISOffset = tuple->TupleLink = 0;
tuple->DesiredTuple = req;
}
- return pcmcia_get_next_tuple(handle, tuple);
+ return pccard_get_next_tuple(s, function, tuple);
}
+EXPORT_SYMBOL(pccard_get_first_tuple);
static int follow_link(struct pcmcia_socket *s, tuple_t *tuple)
{
return -1;
}
-int pcmcia_get_next_tuple(client_handle_t handle, tuple_t *tuple)
+int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple)
{
- struct pcmcia_socket *s;
u_char link[2], tmp;
int ofs, i, attr;
-
- if (CHECK_HANDLE(handle))
+
+ if (!s)
return CS_BAD_HANDLE;
- s = SOCKET(handle);
if (!(s->state & SOCKET_PRESENT))
return CS_NO_CARD;
case CISTPL_LONGLINK_MFC:
tuple->LinkOffset = ofs + 3;
LINK_SPACE(tuple->Flags) = attr;
- if (handle->Function == BIND_FN_ALL) {
+ if (function == BIND_FN_ALL) {
/* Follow all the MFC links */
read_cis_cache(s, attr, ofs+2, 1, &tmp);
MFC_FN(tuple->Flags) = tmp;
} else {
/* Follow exactly one of the links */
MFC_FN(tuple->Flags) = 1;
- tuple->LinkOffset += handle->Function * 5;
+ tuple->LinkOffset += function * 5;
}
break;
case CISTPL_NO_LINK:
tuple->CISOffset = ofs + 2;
return CS_SUCCESS;
}
+EXPORT_SYMBOL(pccard_get_next_tuple);
/*====================================================================*/
#define _MIN(a, b) (((a) < (b)) ? (a) : (b))
-int pcmcia_get_tuple_data(client_handle_t handle, tuple_t *tuple)
+int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple)
{
- struct pcmcia_socket *s;
u_int len;
-
- if (CHECK_HANDLE(handle))
- return CS_BAD_HANDLE;
- s = SOCKET(handle);
+ if (!s)
+ return CS_BAD_HANDLE;
if (tuple->TupleLink < tuple->TupleOffset)
return CS_NO_MORE_ITEMS;
_MIN(len, tuple->TupleDataMax), tuple->TupleData);
return CS_SUCCESS;
}
+EXPORT_SYMBOL(pccard_get_tuple_data);
+
/*======================================================================
/*====================================================================*/
-int pcmcia_parse_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
+int pccard_parse_tuple(tuple_t *tuple, cisparse_t *parse)
{
int ret = CS_SUCCESS;
}
return ret;
}
+EXPORT_SYMBOL(pccard_parse_tuple);
/*======================================================================
======================================================================*/
-int read_tuple(client_handle_t handle, cisdata_t code, void *parse)
+int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t code, void *parse)
{
tuple_t tuple;
cisdata_t *buf;
return CS_OUT_OF_RESOURCE;
tuple.DesiredTuple = code;
tuple.Attributes = TUPLE_RETURN_COMMON;
- ret = pcmcia_get_first_tuple(handle, &tuple);
+ ret = pccard_get_first_tuple(s, function, &tuple);
if (ret != CS_SUCCESS) goto done;
tuple.TupleData = buf;
tuple.TupleOffset = 0;
tuple.TupleDataMax = 255;
- ret = pcmcia_get_tuple_data(handle, &tuple);
+ ret = pccard_get_tuple_data(s, &tuple);
if (ret != CS_SUCCESS) goto done;
- ret = pcmcia_parse_tuple(handle, &tuple, parse);
+ ret = pccard_parse_tuple(&tuple, parse);
done:
kfree(buf);
return ret;
}
+EXPORT_SYMBOL(pccard_read_tuple);
/*======================================================================
======================================================================*/
-int pcmcia_validate_cis(client_handle_t handle, cisinfo_t *info)
+int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, cisinfo_t *info)
{
tuple_t *tuple;
cisparse_t *p;
int ret, reserved, dev_ok = 0, ident_ok = 0;
- if (CHECK_HANDLE(handle))
+ if (!s)
return CS_BAD_HANDLE;
+
tuple = kmalloc(sizeof(*tuple), GFP_KERNEL);
if (tuple == NULL)
return CS_OUT_OF_RESOURCE;
info->Chains = reserved = 0;
tuple->DesiredTuple = RETURN_FIRST_TUPLE;
tuple->Attributes = TUPLE_RETURN_COMMON;
- ret = pcmcia_get_first_tuple(handle, tuple);
+ ret = pccard_get_first_tuple(s, function, tuple);
if (ret != CS_SUCCESS)
goto done;
/* First tuple should be DEVICE; we should really have either that
or a CFTABLE_ENTRY of some sort */
if ((tuple->TupleCode == CISTPL_DEVICE) ||
- (read_tuple(handle, CISTPL_CFTABLE_ENTRY, p) == CS_SUCCESS) ||
- (read_tuple(handle, CISTPL_CFTABLE_ENTRY_CB, p) == CS_SUCCESS))
+ (pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY, p) == CS_SUCCESS) ||
+ (pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY_CB, p) == CS_SUCCESS))
dev_ok++;
/* All cards should have a MANFID tuple, and/or a VERS_1 or VERS_2
tuple, for card identification. Certain old D-Link and Linksys
cards have only a broken VERS_2 tuple; hence the bogus test. */
- if ((read_tuple(handle, CISTPL_MANFID, p) == CS_SUCCESS) ||
- (read_tuple(handle, CISTPL_VERS_1, p) == CS_SUCCESS) ||
- (read_tuple(handle, CISTPL_VERS_2, p) != CS_NO_MORE_ITEMS))
+ if ((pccard_read_tuple(s, function, CISTPL_MANFID, p) == CS_SUCCESS) ||
+ (pccard_read_tuple(s, function, CISTPL_VERS_1, p) == CS_SUCCESS) ||
+ (pccard_read_tuple(s, function, CISTPL_VERS_2, p) != CS_NO_MORE_ITEMS))
ident_ok++;
if (!dev_ok && !ident_ok)
goto done;
for (info->Chains = 1; info->Chains < MAX_TUPLES; info->Chains++) {
- ret = pcmcia_get_next_tuple(handle, tuple);
+ ret = pccard_get_next_tuple(s, function, tuple);
if (ret != CS_SUCCESS) break;
if (((tuple->TupleCode > 0x23) && (tuple->TupleCode < 0x40)) ||
((tuple->TupleCode > 0x47) && (tuple->TupleCode < 0x80)) ||
kfree(p);
return CS_SUCCESS;
}
-
+EXPORT_SYMBOL(pccard_validate_cis);