aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2008-08-03 04:22:47 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2008-08-22 20:29:40 -0400
commit1168386aa7d850ead2ae135d5a7949a592c6e9a0 (patch)
tree9b36c2220df778fa74af93befb641c0569a5e862 /drivers/pcmcia
parent5ff87db6792844ae24cc784512a95e0c94521b19 (diff)
pcmcia: deprecate CS_OUT_OF_RESOURCE
CS_OUT_OF_RESOURCE was almost only used to note -ENOMEM situations. Therefore, use -ENOMEM explicitely, and also print out warnings. CC: netdev@vger.kernel.org Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r--drivers/pcmcia/cistpl.c43
-rw-r--r--drivers/pcmcia/pcmcia_resource.c2
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c32
3 files changed, 47 insertions, 30 deletions
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index 1a513d9a8612..8d37768d0b46 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -352,7 +352,9 @@ int verify_cis_cache(struct pcmcia_socket *s)
352 352
353 buf = kmalloc(256, GFP_KERNEL); 353 buf = kmalloc(256, GFP_KERNEL);
354 if (buf == NULL) 354 if (buf == NULL)
355 return -1; 355 dev_printk(KERN_WARNING, &s->dev,
356 "no memory for verifying CIS\n");
357 return -ENOMEM;
356 list_for_each_entry(cis, &s->cis_cache, node) { 358 list_for_each_entry(cis, &s->cis_cache, node) {
357 int len = cis->len; 359 int len = cis->len;
358 360
@@ -384,15 +386,19 @@ int verify_cis_cache(struct pcmcia_socket *s)
384int pcmcia_replace_cis(struct pcmcia_socket *s, 386int pcmcia_replace_cis(struct pcmcia_socket *s,
385 const u8 *data, const size_t len) 387 const u8 *data, const size_t len)
386{ 388{
387 if (len > CISTPL_MAX_CIS_SIZE) 389 if (len > CISTPL_MAX_CIS_SIZE) {
388 return CS_BAD_SIZE; 390 dev_printk(KERN_WARNING, &s->dev, "replacement CIS too big\n");
389 kfree(s->fake_cis); 391 return -EINVAL;
390 s->fake_cis = kmalloc(len, GFP_KERNEL); 392 }
391 if (s->fake_cis == NULL) 393 kfree(s->fake_cis);
392 return CS_OUT_OF_RESOURCE; 394 s->fake_cis = kmalloc(len, GFP_KERNEL);
393 s->fake_cis_len = len; 395 if (s->fake_cis == NULL) {
394 memcpy(s->fake_cis, data, len); 396 dev_printk(KERN_WARNING, &s->dev, "no memory to replace CIS\n");
395 return 0; 397 return -ENOMEM;
398 }
399 s->fake_cis_len = len;
400 memcpy(s->fake_cis, data, len);
401 return 0;
396} 402}
397EXPORT_SYMBOL(pcmcia_replace_cis); 403EXPORT_SYMBOL(pcmcia_replace_cis);
398 404
@@ -1411,8 +1417,10 @@ int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t
1411 int ret; 1417 int ret;
1412 1418
1413 buf = kmalloc(256, GFP_KERNEL); 1419 buf = kmalloc(256, GFP_KERNEL);
1414 if (buf == NULL) 1420 if (buf == NULL) {
1415 return CS_OUT_OF_RESOURCE; 1421 dev_printk(KERN_WARNING, &s->dev, "no memory to read tuple\n");
1422 return -ENOMEM;
1423 }
1416 tuple.DesiredTuple = code; 1424 tuple.DesiredTuple = code;
1417 tuple.Attributes = TUPLE_RETURN_COMMON; 1425 tuple.Attributes = TUPLE_RETURN_COMMON;
1418 ret = pccard_get_first_tuple(s, function, &tuple); 1426 ret = pccard_get_first_tuple(s, function, &tuple);
@@ -1452,12 +1460,15 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned
1452 return CS_BAD_HANDLE; 1460 return CS_BAD_HANDLE;
1453 1461
1454 tuple = kmalloc(sizeof(*tuple), GFP_KERNEL); 1462 tuple = kmalloc(sizeof(*tuple), GFP_KERNEL);
1455 if (tuple == NULL) 1463 if (tuple == NULL) {
1456 return CS_OUT_OF_RESOURCE; 1464 dev_printk(KERN_WARNING, &s->dev, "no memory to validate CIS\n");
1465 return -ENOMEM;
1466 }
1457 p = kmalloc(sizeof(*p), GFP_KERNEL); 1467 p = kmalloc(sizeof(*p), GFP_KERNEL);
1458 if (p == NULL) { 1468 if (p == NULL) {
1459 kfree(tuple); 1469 kfree(tuple);
1460 return CS_OUT_OF_RESOURCE; 1470 dev_printk(KERN_WARNING, &s->dev, "no memory to validate CIS\n");
1471 return -ENOMEM;
1461 } 1472 }
1462 1473
1463 count = reserved = 0; 1474 count = reserved = 0;
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 48e168e8165b..69d87a7e0766 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -780,7 +780,7 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h
780 for (w = 0; w < MAX_WIN; w++) 780 for (w = 0; w < MAX_WIN; w++)
781 if (!(s->state & SOCKET_WIN_REQ(w))) break; 781 if (!(s->state & SOCKET_WIN_REQ(w))) break;
782 if (w == MAX_WIN) 782 if (w == MAX_WIN)
783 return CS_OUT_OF_RESOURCE; 783 return CS_IN_USE;
784 784
785 win = &s->win[w]; 785 win = &s->win[w];
786 win->magic = WINDOW_MAGIC; 786 win->magic = WINDOW_MAGIC;
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 9d04fb214ec2..0e4141bac7b1 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -122,19 +122,22 @@ static void free_region(struct resource *res)
122 122
123static int add_interval(struct resource_map *map, u_long base, u_long num) 123static int add_interval(struct resource_map *map, u_long base, u_long num)
124{ 124{
125 struct resource_map *p, *q; 125 struct resource_map *p, *q;
126 126
127 for (p = map; ; p = p->next) { 127 for (p = map; ; p = p->next) {
128 if ((p != map) && (p->base+p->num-1 >= base)) 128 if ((p != map) && (p->base+p->num-1 >= base))
129 return -1; 129 return -1;
130 if ((p->next == map) || (p->next->base > base+num-1)) 130 if ((p->next == map) || (p->next->base > base+num-1))
131 break; 131 break;
132 } 132 }
133 q = kmalloc(sizeof(struct resource_map), GFP_KERNEL); 133 q = kmalloc(sizeof(struct resource_map), GFP_KERNEL);
134 if (!q) return CS_OUT_OF_RESOURCE; 134 if (!q) {
135 q->base = base; q->num = num; 135 printk(KERN_WARNING "out of memory to update resources\n");
136 q->next = p->next; p->next = q; 136 return -ENOMEM;
137 return 0; 137 }
138 q->base = base; q->num = num;
139 q->next = p->next; p->next = q;
140 return 0;
138} 141}
139 142
140/*====================================================================*/ 143/*====================================================================*/
@@ -166,7 +169,10 @@ static int sub_interval(struct resource_map *map, u_long base, u_long num)
166 } else { 169 } else {
167 /* Split the block into two pieces */ 170 /* Split the block into two pieces */
168 p = kmalloc(sizeof(struct resource_map), GFP_KERNEL); 171 p = kmalloc(sizeof(struct resource_map), GFP_KERNEL);
169 if (!p) return CS_OUT_OF_RESOURCE; 172 if (!p) {
173 printk(KERN_WARNING "out of memory to update resources\n");
174 return -ENOMEM;
175 }
170 p->base = base+num; 176 p->base = base+num;
171 p->num = q->base+q->num - p->base; 177 p->num = q->base+q->num - p->base;
172 q->num = base - q->base; 178 q->num = base - q->base;