diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-07-28 13:44:05 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-08-02 12:56:49 -0400 |
commit | 53efec9513cfb1acff602c7ebdd945d677808e9e (patch) | |
tree | 6bf9d0475d0be0829348096442d505001c027017 /drivers/pcmcia/cistpl.c | |
parent | 6e86841d05f371b5b9b86ce76c02aaee83352298 (diff) |
pcmcia: only copy CIS override data once
Instead of copying CIS override data in socket_sysfs.c or ds.c, and then again
in cistpl.c, only do so once. Also, cisdump_t is now only used by the
deprecated ioctl.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia/cistpl.c')
-rw-r--r-- | drivers/pcmcia/cistpl.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index 65129b54eb09..11c473c865a5 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c | |||
@@ -265,13 +265,13 @@ EXPORT_SYMBOL(pcmcia_write_cis_mem); | |||
265 | ======================================================================*/ | 265 | ======================================================================*/ |
266 | 266 | ||
267 | static void read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr, | 267 | static void read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr, |
268 | u_int len, void *ptr) | 268 | size_t len, void *ptr) |
269 | { | 269 | { |
270 | struct cis_cache_entry *cis; | 270 | struct cis_cache_entry *cis; |
271 | int ret; | 271 | int ret; |
272 | 272 | ||
273 | if (s->fake_cis) { | 273 | if (s->fake_cis) { |
274 | if (s->fake_cis_len > addr+len) | 274 | if (s->fake_cis_len >= addr+len) |
275 | memcpy(ptr, s->fake_cis+addr, len); | 275 | memcpy(ptr, s->fake_cis+addr, len); |
276 | else | 276 | else |
277 | memset(ptr, 0xff, len); | 277 | memset(ptr, 0xff, len); |
@@ -380,17 +380,17 @@ int verify_cis_cache(struct pcmcia_socket *s) | |||
380 | 380 | ||
381 | ======================================================================*/ | 381 | ======================================================================*/ |
382 | 382 | ||
383 | int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis) | 383 | int pcmcia_replace_cis(struct pcmcia_socket *s, |
384 | const u8 *data, const size_t len) | ||
384 | { | 385 | { |
385 | kfree(s->fake_cis); | 386 | if (len > CISTPL_MAX_CIS_SIZE) |
386 | s->fake_cis = NULL; | ||
387 | if (cis->Length > CISTPL_MAX_CIS_SIZE) | ||
388 | return CS_BAD_SIZE; | 387 | return CS_BAD_SIZE; |
389 | s->fake_cis = kmalloc(cis->Length, GFP_KERNEL); | 388 | kfree(s->fake_cis); |
389 | s->fake_cis = kmalloc(len, GFP_KERNEL); | ||
390 | if (s->fake_cis == NULL) | 390 | if (s->fake_cis == NULL) |
391 | return CS_OUT_OF_RESOURCE; | 391 | return CS_OUT_OF_RESOURCE; |
392 | s->fake_cis_len = cis->Length; | 392 | s->fake_cis_len = len; |
393 | memcpy(s->fake_cis, cis->Data, cis->Length); | 393 | memcpy(s->fake_cis, data, len); |
394 | return CS_SUCCESS; | 394 | return CS_SUCCESS; |
395 | } | 395 | } |
396 | EXPORT_SYMBOL(pcmcia_replace_cis); | 396 | EXPORT_SYMBOL(pcmcia_replace_cis); |