2019-05-27 14:55:01 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2007-06-16 14:04:16 +08:00
|
|
|
/*
|
|
|
|
* linux/drivers/mmc/core/sdio_cis.c
|
|
|
|
*
|
|
|
|
* Author: Nicolas Pitre
|
|
|
|
* Created: June 11, 2007
|
|
|
|
* Copyright: MontaVista Software Inc.
|
|
|
|
*
|
2007-06-16 14:06:47 +08:00
|
|
|
* Copyright 2007 Pierre Ossman
|
2007-06-16 14:04:16 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2007-06-16 14:04:16 +08:00
|
|
|
|
|
|
|
#include <linux/mmc/host.h>
|
2007-07-30 21:15:30 +08:00
|
|
|
#include <linux/mmc/card.h>
|
2007-06-16 14:04:16 +08:00
|
|
|
#include <linux/mmc/sdio.h>
|
|
|
|
#include <linux/mmc/sdio_func.h>
|
|
|
|
|
|
|
|
#include "sdio_cis.h"
|
|
|
|
#include "sdio_ops.h"
|
|
|
|
|
2007-09-20 00:42:16 +08:00
|
|
|
static int cistpl_vers_1(struct mmc_card *card, struct sdio_func *func,
|
|
|
|
const unsigned char *buf, unsigned size)
|
|
|
|
{
|
|
|
|
unsigned i, nr_strings;
|
|
|
|
char **buffer, *string;
|
|
|
|
|
2009-10-08 07:32:33 +08:00
|
|
|
/* Find all null-terminated (including zero length) strings in
|
|
|
|
the TPLLV1_INFO field. Trailing garbage is ignored. */
|
2007-09-20 00:42:16 +08:00
|
|
|
buf += 2;
|
|
|
|
size -= 2;
|
|
|
|
|
|
|
|
nr_strings = 0;
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
if (buf[i] == 0xff)
|
|
|
|
break;
|
|
|
|
if (buf[i] == 0)
|
|
|
|
nr_strings++;
|
|
|
|
}
|
2009-10-08 07:32:33 +08:00
|
|
|
if (nr_strings == 0)
|
2007-09-20 00:42:16 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
size = i;
|
|
|
|
|
|
|
|
buffer = kzalloc(sizeof(char*) * nr_strings + size, GFP_KERNEL);
|
|
|
|
if (!buffer)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
string = (char*)(buffer + nr_strings);
|
|
|
|
|
|
|
|
for (i = 0; i < nr_strings; i++) {
|
|
|
|
buffer[i] = string;
|
|
|
|
strcpy(string, buf);
|
|
|
|
string += strlen(string) + 1;
|
|
|
|
buf += strlen(buf) + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (func) {
|
|
|
|
func->num_info = nr_strings;
|
|
|
|
func->info = (const char**)buffer;
|
|
|
|
} else {
|
|
|
|
card->num_info = nr_strings;
|
|
|
|
card->info = (const char**)buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-07-30 21:15:30 +08:00
|
|
|
static int cistpl_manfid(struct mmc_card *card, struct sdio_func *func,
|
|
|
|
const unsigned char *buf, unsigned size)
|
2007-06-16 14:04:16 +08:00
|
|
|
{
|
2007-07-30 21:15:30 +08:00
|
|
|
unsigned int vendor, device;
|
|
|
|
|
2007-06-16 14:04:16 +08:00
|
|
|
/* TPLMID_MANF */
|
2007-07-30 21:15:30 +08:00
|
|
|
vendor = buf[0] | (buf[1] << 8);
|
2007-06-16 14:04:16 +08:00
|
|
|
|
|
|
|
/* TPLMID_CARD */
|
2007-07-30 21:15:30 +08:00
|
|
|
device = buf[2] | (buf[3] << 8);
|
|
|
|
|
|
|
|
if (func) {
|
|
|
|
func->vendor = vendor;
|
|
|
|
func->device = device;
|
|
|
|
} else {
|
|
|
|
card->cis.vendor = vendor;
|
|
|
|
card->cis.device = device;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const unsigned char speed_val[16] =
|
|
|
|
{ 0, 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80 };
|
|
|
|
static const unsigned int speed_unit[8] =
|
|
|
|
{ 10000, 100000, 1000000, 10000000, 0, 0, 0, 0 };
|
|
|
|
|
2009-12-15 10:01:19 +08:00
|
|
|
|
|
|
|
typedef int (tpl_parse_t)(struct mmc_card *, struct sdio_func *,
|
|
|
|
const unsigned char *, unsigned);
|
|
|
|
|
|
|
|
struct cis_tpl {
|
|
|
|
unsigned char code;
|
|
|
|
unsigned char min_size;
|
|
|
|
tpl_parse_t *parse;
|
2009-10-02 06:44:05 +08:00
|
|
|
};
|
|
|
|
|
2009-12-15 10:01:19 +08:00
|
|
|
static int cis_tpl_parse(struct mmc_card *card, struct sdio_func *func,
|
|
|
|
const char *tpl_descr,
|
|
|
|
const struct cis_tpl *tpl, int tpl_count,
|
|
|
|
unsigned char code,
|
|
|
|
const unsigned char *buf, unsigned size)
|
2009-10-02 06:44:05 +08:00
|
|
|
{
|
2009-12-15 10:01:19 +08:00
|
|
|
int i, ret;
|
2009-10-02 06:44:05 +08:00
|
|
|
|
2009-12-15 10:01:19 +08:00
|
|
|
/* look for a matching code in the table */
|
|
|
|
for (i = 0; i < tpl_count; i++, tpl++) {
|
|
|
|
if (tpl->code == code)
|
|
|
|
break;
|
2009-10-02 06:44:05 +08:00
|
|
|
}
|
2009-12-15 10:01:19 +08:00
|
|
|
if (i < tpl_count) {
|
|
|
|
if (size >= tpl->min_size) {
|
|
|
|
if (tpl->parse)
|
|
|
|
ret = tpl->parse(card, func, buf, size);
|
|
|
|
else
|
|
|
|
ret = -EILSEQ; /* known tuple, not parsed */
|
|
|
|
} else {
|
|
|
|
/* invalid tuple */
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
if (ret && ret != -EILSEQ && ret != -ENOENT) {
|
2011-10-11 14:14:09 +08:00
|
|
|
pr_err("%s: bad %s tuple 0x%02x (%u bytes)\n",
|
2009-12-15 10:01:19 +08:00
|
|
|
mmc_hostname(card->host), tpl_descr, code, size);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* unknown tuple */
|
|
|
|
ret = -ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2009-10-02 06:44:05 +08:00
|
|
|
}
|
|
|
|
|
2009-12-15 10:01:19 +08:00
|
|
|
static int cistpl_funce_common(struct mmc_card *card, struct sdio_func *func,
|
2007-07-30 21:15:30 +08:00
|
|
|
const unsigned char *buf, unsigned size)
|
|
|
|
{
|
2009-12-15 10:01:19 +08:00
|
|
|
/* Only valid for the common CIS (function 0) */
|
|
|
|
if (func)
|
2007-07-30 21:15:30 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* TPLFE_FN0_BLK_SIZE */
|
|
|
|
card->cis.blksize = buf[1] | (buf[2] << 8);
|
|
|
|
|
|
|
|
/* TPLFE_MAX_TRAN_SPEED */
|
|
|
|
card->cis.max_dtr = speed_val[(buf[3] >> 3) & 15] *
|
|
|
|
speed_unit[buf[3] & 7];
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-12-15 10:01:19 +08:00
|
|
|
static int cistpl_funce_func(struct mmc_card *card, struct sdio_func *func,
|
2007-07-30 21:15:30 +08:00
|
|
|
const unsigned char *buf, unsigned size)
|
|
|
|
{
|
|
|
|
unsigned vsn;
|
|
|
|
unsigned min_size;
|
|
|
|
|
2009-12-15 10:01:19 +08:00
|
|
|
/* Only valid for the individual function's CIS (1-7) */
|
|
|
|
if (!func)
|
|
|
|
return -EINVAL;
|
2009-10-02 06:44:05 +08:00
|
|
|
|
2009-12-15 10:01:19 +08:00
|
|
|
/*
|
|
|
|
* This tuple has a different length depending on the SDIO spec
|
|
|
|
* version.
|
|
|
|
*/
|
2007-07-30 21:15:30 +08:00
|
|
|
vsn = func->card->cccr.sdio_vsn;
|
|
|
|
min_size = (vsn == SDIO_SDIO_REV_1_00) ? 28 : 42;
|
|
|
|
|
2016-05-09 15:59:59 +08:00
|
|
|
if (size == 28 && vsn == SDIO_SDIO_REV_1_10) {
|
|
|
|
pr_warn("%s: card has broken SDIO 1.1 CIS, forcing SDIO 1.0\n",
|
|
|
|
mmc_hostname(card->host));
|
|
|
|
vsn = SDIO_SDIO_REV_1_00;
|
|
|
|
} else if (size < min_size) {
|
2007-07-30 21:15:30 +08:00
|
|
|
return -EINVAL;
|
2016-05-09 15:59:59 +08:00
|
|
|
}
|
2007-07-30 21:15:30 +08:00
|
|
|
|
|
|
|
/* TPLFE_MAX_BLK_SIZE */
|
2007-08-08 21:23:48 +08:00
|
|
|
func->max_blksize = buf[12] | (buf[13] << 8);
|
2007-06-16 14:04:16 +08:00
|
|
|
|
2008-07-10 07:41:43 +08:00
|
|
|
/* TPLFE_ENABLE_TIMEOUT_VAL, present in ver 1.1 and above */
|
|
|
|
if (vsn > SDIO_SDIO_REV_1_00)
|
|
|
|
func->enable_timeout = (buf[28] | (buf[29] << 8)) * 10;
|
|
|
|
else
|
|
|
|
func->enable_timeout = jiffies_to_msecs(HZ);
|
|
|
|
|
2007-06-16 14:04:16 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-12-15 10:01:19 +08:00
|
|
|
/*
|
|
|
|
* Known TPLFE_TYPEs table for CISTPL_FUNCE tuples.
|
|
|
|
*
|
|
|
|
* Note that, unlike PCMCIA, CISTPL_FUNCE tuples are not parsed depending
|
|
|
|
* on the TPLFID_FUNCTION value of the previous CISTPL_FUNCID as on SDIO
|
|
|
|
* TPLFID_FUNCTION is always hardcoded to 0x0C.
|
|
|
|
*/
|
|
|
|
static const struct cis_tpl cis_tpl_funce_list[] = {
|
|
|
|
{ 0x00, 4, cistpl_funce_common },
|
|
|
|
{ 0x01, 0, cistpl_funce_func },
|
|
|
|
{ 0x04, 1+1+6, /* CISTPL_FUNCE_LAN_NODE_ID */ },
|
|
|
|
};
|
|
|
|
|
2007-07-30 21:15:30 +08:00
|
|
|
static int cistpl_funce(struct mmc_card *card, struct sdio_func *func,
|
|
|
|
const unsigned char *buf, unsigned size)
|
|
|
|
{
|
2009-12-15 10:01:19 +08:00
|
|
|
if (size < 1)
|
|
|
|
return -EINVAL;
|
2007-07-30 21:15:30 +08:00
|
|
|
|
2009-12-15 10:01:19 +08:00
|
|
|
return cis_tpl_parse(card, func, "CISTPL_FUNCE",
|
|
|
|
cis_tpl_funce_list,
|
|
|
|
ARRAY_SIZE(cis_tpl_funce_list),
|
|
|
|
buf[0], buf, size);
|
2007-07-30 21:15:30 +08:00
|
|
|
}
|
|
|
|
|
2009-12-15 10:01:19 +08:00
|
|
|
/* Known TPL_CODEs table for CIS tuples */
|
2007-06-16 14:04:16 +08:00
|
|
|
static const struct cis_tpl cis_tpl_list[] = {
|
2007-09-20 00:42:16 +08:00
|
|
|
{ 0x15, 3, cistpl_vers_1 },
|
2007-06-16 14:04:16 +08:00
|
|
|
{ 0x20, 4, cistpl_manfid },
|
|
|
|
{ 0x21, 2, /* cistpl_funcid */ },
|
2007-07-30 21:15:30 +08:00
|
|
|
{ 0x22, 0, cistpl_funce },
|
2016-01-20 16:17:04 +08:00
|
|
|
{ 0x91, 2, /* cistpl_sdio_std */ },
|
2007-06-16 14:04:16 +08:00
|
|
|
};
|
|
|
|
|
2007-07-30 21:15:30 +08:00
|
|
|
static int sdio_read_cis(struct mmc_card *card, struct sdio_func *func)
|
2007-06-16 14:04:16 +08:00
|
|
|
{
|
|
|
|
int ret;
|
2007-06-16 14:06:47 +08:00
|
|
|
struct sdio_func_tuple *this, **prev;
|
2007-06-16 14:04:16 +08:00
|
|
|
unsigned i, ptr = 0;
|
|
|
|
|
2007-07-30 21:15:30 +08:00
|
|
|
/*
|
|
|
|
* Note that this works for the common CIS (function number 0) as
|
|
|
|
* well as a function's CIS * since SDIO_CCCR_CIS and SDIO_FBR_CIS
|
|
|
|
* have the same offset.
|
|
|
|
*/
|
2007-06-16 14:04:16 +08:00
|
|
|
for (i = 0; i < 3; i++) {
|
2007-07-30 21:15:30 +08:00
|
|
|
unsigned char x, fn;
|
|
|
|
|
|
|
|
if (func)
|
|
|
|
fn = func->num;
|
|
|
|
else
|
|
|
|
fn = 0;
|
|
|
|
|
|
|
|
ret = mmc_io_rw_direct(card, 0, 0,
|
2007-08-08 21:23:05 +08:00
|
|
|
SDIO_FBR_BASE(fn) + SDIO_FBR_CIS + i, 0, &x);
|
2007-06-16 14:04:16 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
ptr |= x << (i * 8);
|
|
|
|
}
|
|
|
|
|
2007-07-30 21:15:30 +08:00
|
|
|
if (func)
|
|
|
|
prev = &func->tuples;
|
|
|
|
else
|
|
|
|
prev = &card->tuples;
|
|
|
|
|
2016-11-02 15:24:00 +08:00
|
|
|
if (*prev)
|
|
|
|
return -EINVAL;
|
2007-06-16 14:04:16 +08:00
|
|
|
|
|
|
|
do {
|
|
|
|
unsigned char tpl_code, tpl_link;
|
|
|
|
|
2007-07-30 21:15:30 +08:00
|
|
|
ret = mmc_io_rw_direct(card, 0, 0, ptr++, 0, &tpl_code);
|
2007-06-16 14:04:16 +08:00
|
|
|
if (ret)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* 0xff means we're done */
|
|
|
|
if (tpl_code == 0xff)
|
|
|
|
break;
|
|
|
|
|
2009-03-06 02:38:38 +08:00
|
|
|
/* null entries have no link field or data */
|
|
|
|
if (tpl_code == 0x00)
|
|
|
|
continue;
|
|
|
|
|
2007-07-30 21:15:30 +08:00
|
|
|
ret = mmc_io_rw_direct(card, 0, 0, ptr++, 0, &tpl_link);
|
2007-06-16 14:04:16 +08:00
|
|
|
if (ret)
|
|
|
|
break;
|
|
|
|
|
2009-03-06 02:37:28 +08:00
|
|
|
/* a size of 0xff also means we're done */
|
|
|
|
if (tpl_link == 0xff)
|
|
|
|
break;
|
|
|
|
|
2007-06-16 14:06:47 +08:00
|
|
|
this = kmalloc(sizeof(*this) + tpl_link, GFP_KERNEL);
|
|
|
|
if (!this)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
for (i = 0; i < tpl_link; i++) {
|
2007-07-30 21:15:30 +08:00
|
|
|
ret = mmc_io_rw_direct(card, 0, 0,
|
2007-06-16 14:06:47 +08:00
|
|
|
ptr + i, 0, &this->data[i]);
|
|
|
|
if (ret)
|
2007-06-16 14:04:16 +08:00
|
|
|
break;
|
|
|
|
}
|
2007-06-16 14:06:47 +08:00
|
|
|
if (ret) {
|
|
|
|
kfree(this);
|
2007-06-16 14:04:16 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-12-15 10:01:19 +08:00
|
|
|
/* Try to parse the CIS tuple */
|
|
|
|
ret = cis_tpl_parse(card, func, "CIS",
|
|
|
|
cis_tpl_list, ARRAY_SIZE(cis_tpl_list),
|
|
|
|
tpl_code, this->data, tpl_link);
|
|
|
|
if (ret == -EILSEQ || ret == -ENOENT) {
|
2009-10-02 06:44:05 +08:00
|
|
|
/*
|
2009-12-15 10:01:19 +08:00
|
|
|
* The tuple is unknown or known but not parsed.
|
|
|
|
* Queue the tuple for the function driver.
|
2009-10-02 06:44:05 +08:00
|
|
|
*/
|
|
|
|
this->next = NULL;
|
|
|
|
this->code = tpl_code;
|
|
|
|
this->size = tpl_link;
|
|
|
|
*prev = this;
|
|
|
|
prev = &this->next;
|
2009-12-15 10:01:19 +08:00
|
|
|
|
|
|
|
if (ret == -ENOENT) {
|
|
|
|
/* warn about unknown tuples */
|
2012-07-09 18:26:42 +08:00
|
|
|
pr_warn_ratelimited("%s: queuing unknown"
|
2009-12-15 10:01:19 +08:00
|
|
|
" CIS tuple 0x%02x (%u bytes)\n",
|
|
|
|
mmc_hostname(card->host),
|
|
|
|
tpl_code, tpl_link);
|
|
|
|
}
|
|
|
|
|
2009-10-02 06:44:05 +08:00
|
|
|
/* keep on analyzing tuples */
|
|
|
|
ret = 0;
|
2009-12-15 10:01:19 +08:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* We don't need the tuple anymore if it was
|
|
|
|
* successfully parsed by the SDIO core or if it is
|
|
|
|
* not going to be queued for a driver.
|
|
|
|
*/
|
|
|
|
kfree(this);
|
2007-06-16 14:04:16 +08:00
|
|
|
}
|
|
|
|
|
2007-06-16 14:06:47 +08:00
|
|
|
ptr += tpl_link;
|
2007-06-16 14:04:16 +08:00
|
|
|
} while (!ret);
|
|
|
|
|
2007-07-30 21:15:30 +08:00
|
|
|
/*
|
|
|
|
* Link in all unknown tuples found in the common CIS so that
|
|
|
|
* drivers don't have to go digging in two places.
|
|
|
|
*/
|
|
|
|
if (func)
|
|
|
|
*prev = card->tuples;
|
|
|
|
|
2007-06-16 14:04:16 +08:00
|
|
|
return ret;
|
|
|
|
}
|
2007-06-16 14:06:47 +08:00
|
|
|
|
2007-07-30 21:15:30 +08:00
|
|
|
int sdio_read_common_cis(struct mmc_card *card)
|
|
|
|
{
|
|
|
|
return sdio_read_cis(card, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sdio_free_common_cis(struct mmc_card *card)
|
2007-06-16 14:06:47 +08:00
|
|
|
{
|
|
|
|
struct sdio_func_tuple *tuple, *victim;
|
|
|
|
|
2007-07-30 21:15:30 +08:00
|
|
|
tuple = card->tuples;
|
2007-06-16 14:06:47 +08:00
|
|
|
|
|
|
|
while (tuple) {
|
|
|
|
victim = tuple;
|
|
|
|
tuple = tuple->next;
|
|
|
|
kfree(victim);
|
|
|
|
}
|
|
|
|
|
2007-07-30 21:15:30 +08:00
|
|
|
card->tuples = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int sdio_read_func_cis(struct sdio_func *func)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = sdio_read_cis(func->card, func);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since we've linked to tuples in the card structure,
|
|
|
|
* we must make sure we have a reference to it.
|
|
|
|
*/
|
|
|
|
get_device(&func->card->dev);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Vendor/device id is optional for function CIS, so
|
|
|
|
* copy it from the card structure as needed.
|
|
|
|
*/
|
|
|
|
if (func->vendor == 0) {
|
|
|
|
func->vendor = func->card->cis.vendor;
|
|
|
|
func->device = func->card->cis.device;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sdio_free_func_cis(struct sdio_func *func)
|
|
|
|
{
|
|
|
|
struct sdio_func_tuple *tuple, *victim;
|
|
|
|
|
|
|
|
tuple = func->tuples;
|
|
|
|
|
|
|
|
while (tuple && tuple != func->card->tuples) {
|
|
|
|
victim = tuple;
|
|
|
|
tuple = tuple->next;
|
|
|
|
kfree(victim);
|
|
|
|
}
|
|
|
|
|
2007-06-16 14:06:47 +08:00
|
|
|
func->tuples = NULL;
|
2007-07-30 21:15:30 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We have now removed the link to the tuples in the
|
|
|
|
* card structure, so remove the reference.
|
|
|
|
*/
|
|
|
|
put_device(&func->card->dev);
|
2007-06-16 14:06:47 +08:00
|
|
|
}
|
|
|
|
|