Skip to content

Commit 759bdc7

Browse files
author
Pierre Ossman
committed
sdio: store vendor strings
Store vendor strings found in CISTPL_VERS_1 so that function drivers can access them. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
1 parent f9996ae commit 759bdc7

File tree

5 files changed

+60
-1
lines changed

5 files changed

+60
-1
lines changed

drivers/mmc/core/bus.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ static void mmc_release_card(struct device *dev)
187187

188188
sdio_free_common_cis(card);
189189

190+
if (card->info)
191+
kfree(card->info);
192+
190193
kfree(card);
191194
}
192195

drivers/mmc/core/sdio_bus.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ static void sdio_release_func(struct device *dev)
211211

212212
sdio_free_func_cis(func);
213213

214+
if (func->info)
215+
kfree(func->info);
216+
214217
kfree(func);
215218
}
216219

drivers/mmc/core/sdio_cis.c

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,54 @@
2323
#include "sdio_cis.h"
2424
#include "sdio_ops.h"
2525

26+
static int cistpl_vers_1(struct mmc_card *card, struct sdio_func *func,
27+
const unsigned char *buf, unsigned size)
28+
{
29+
unsigned i, nr_strings;
30+
char **buffer, *string;
31+
32+
buf += 2;
33+
size -= 2;
34+
35+
nr_strings = 0;
36+
for (i = 0; i < size; i++) {
37+
if (buf[i] == 0xff)
38+
break;
39+
if (buf[i] == 0)
40+
nr_strings++;
41+
}
42+
43+
if (buf[i-1] != '\0') {
44+
printk(KERN_WARNING "SDIO: ignoring broken CISTPL_VERS_1\n");
45+
return 0;
46+
}
47+
48+
size = i;
49+
50+
buffer = kzalloc(sizeof(char*) * nr_strings + size, GFP_KERNEL);
51+
if (!buffer)
52+
return -ENOMEM;
53+
54+
string = (char*)(buffer + nr_strings);
55+
56+
for (i = 0; i < nr_strings; i++) {
57+
buffer[i] = string;
58+
strcpy(string, buf);
59+
string += strlen(string) + 1;
60+
buf += strlen(buf) + 1;
61+
}
62+
63+
if (func) {
64+
func->num_info = nr_strings;
65+
func->info = (const char**)buffer;
66+
} else {
67+
card->num_info = nr_strings;
68+
card->info = (const char**)buffer;
69+
}
70+
71+
return 0;
72+
}
73+
2674
static int cistpl_manfid(struct mmc_card *card, struct sdio_func *func,
2775
const unsigned char *buf, unsigned size)
2876
{
@@ -119,7 +167,7 @@ struct cis_tpl {
119167
};
120168

121169
static const struct cis_tpl cis_tpl_list[] = {
122-
{ 0x15, 3, /* cistpl_vers_1 */ },
170+
{ 0x15, 3, cistpl_vers_1 },
123171
{ 0x20, 4, cistpl_manfid },
124172
{ 0x21, 2, /* cistpl_funcid */ },
125173
{ 0x22, 0, cistpl_funce },

include/linux/mmc/card.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ struct mmc_card {
108108
struct sdio_cccr cccr; /* common card info */
109109
struct sdio_cis cis; /* common tuple info */
110110
struct sdio_func *sdio_func[SDIO_MAX_FUNCS]; /* SDIO functions (devices) */
111+
unsigned num_info; /* number of info strings */
112+
const char **info; /* info strings */
111113
struct sdio_func_tuple *tuples; /* unknown common tuples */
112114
};
113115

include/linux/mmc/sdio_func.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ struct sdio_func {
5151

5252
u8 tmpbuf[4]; /* DMA:able scratch buffer */
5353

54+
unsigned num_info; /* number of info strings */
55+
const char **info; /* info strings */
56+
5457
struct sdio_func_tuple *tuples;
5558
};
5659

0 commit comments

Comments
 (0)