Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+60 -1
+3
drivers/mmc/core/bus.c
··· 187 187 188 188 sdio_free_common_cis(card); 189 189 190 + if (card->info) 191 + kfree(card->info); 192 + 190 193 kfree(card); 191 194 } 192 195
+3
drivers/mmc/core/sdio_bus.c
··· 211 211 212 212 sdio_free_func_cis(func); 213 213 214 + if (func->info) 215 + kfree(func->info); 216 + 214 217 kfree(func); 215 218 } 216 219
+49 -1
drivers/mmc/core/sdio_cis.c
··· 23 23 #include "sdio_cis.h" 24 24 #include "sdio_ops.h" 25 25 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 + 26 74 static int cistpl_manfid(struct mmc_card *card, struct sdio_func *func, 27 75 const unsigned char *buf, unsigned size) 28 76 { ··· 167 119 }; 168 120 169 121 static const struct cis_tpl cis_tpl_list[] = { 170 - { 0x15, 3, /* cistpl_vers_1 */ }, 122 + { 0x15, 3, cistpl_vers_1 }, 171 123 { 0x20, 4, cistpl_manfid }, 172 124 { 0x21, 2, /* cistpl_funcid */ }, 173 125 { 0x22, 0, cistpl_funce },
+2
include/linux/mmc/card.h
··· 108 108 struct sdio_cccr cccr; /* common card info */ 109 109 struct sdio_cis cis; /* common tuple info */ 110 110 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 */ 111 113 struct sdio_func_tuple *tuples; /* unknown common tuples */ 112 114 }; 113 115
+3
include/linux/mmc/sdio_func.h
··· 51 51 52 52 u8 tmpbuf[4]; /* DMA:able scratch buffer */ 53 53 54 + unsigned num_info; /* number of info strings */ 55 + const char **info; /* info strings */ 56 + 54 57 struct sdio_func_tuple *tuples; 55 58 }; 56 59