aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pcmcia/ds.c50
-rw-r--r--include/pcmcia/ds.h13
2 files changed, 30 insertions, 33 deletions
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 55a46af33ca4..e0624a8fb6e3 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -69,8 +69,8 @@ spinlock_t pcmcia_dev_list_lock;
69/* String tables for error messages */ 69/* String tables for error messages */
70 70
71typedef struct lookup_t { 71typedef struct lookup_t {
72 int key; 72 const int key;
73 char *msg; 73 const char *msg;
74} lookup_t; 74} lookup_t;
75 75
76static const lookup_t error_table[] = { 76static const lookup_t error_table[] = {
@@ -137,46 +137,32 @@ static const lookup_t service_table[] = {
137 { ReplaceCIS, "ReplaceCIS" } 137 { ReplaceCIS, "ReplaceCIS" }
138}; 138};
139 139
140 140const char *pcmcia_error_func(int func)
141static int pcmcia_report_error(struct pcmcia_device *p_dev, error_info_t *err)
142{ 141{
143 int i; 142 int i;
144 char *serv;
145
146 if (!p_dev)
147 printk(KERN_NOTICE);
148 else
149 printk(KERN_NOTICE "%s: ", p_dev->dev.bus_id);
150 143
151 for (i = 0; i < ARRAY_SIZE(service_table); i++) 144 for (i = 0; i < ARRAY_SIZE(service_table); i++)
152 if (service_table[i].key == err->func) 145 if (service_table[i].key == func)
153 break; 146 return service_table[i].msg;
154 if (i < ARRAY_SIZE(service_table))
155 serv = service_table[i].msg;
156 else
157 serv = "Unknown service number";
158 147
159 for (i = 0; i < ARRAY_SIZE(error_table); i++) 148 return "Unknown service number";
160 if (error_table[i].key == err->retcode) 149}
161 break; 150EXPORT_SYMBOL(pcmcia_error_func);
162 if (i < ARRAY_SIZE(error_table))
163 printk("%s: %s\n", serv, error_table[i].msg);
164 else
165 printk("%s: Unknown error code %#x\n", serv, err->retcode);
166 151
167 return 0; 152const char *pcmcia_error_ret(int ret)
168} /* report_error */ 153{
154 int i;
155
156 for (i = 0; i < ARRAY_SIZE(error_table); i++)
157 if (error_table[i].key == ret)
158 return error_table[i].msg;
169 159
170/* end of code which was in cs.c before */ 160 return "unknown";
161}
162EXPORT_SYMBOL(pcmcia_error_ret);
171 163
172/*======================================================================*/ 164/*======================================================================*/
173 165
174void cs_error(struct pcmcia_device *p_dev, int func, int ret)
175{
176 error_info_t err = { func, ret };
177 pcmcia_report_error(p_dev, &err);
178}
179EXPORT_SYMBOL(cs_error);
180 166
181 167
182static void pcmcia_check_driver(struct pcmcia_driver *p_drv) 168static void pcmcia_check_driver(struct pcmcia_driver *p_drv)
diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h
index 9ff9de9ec3f0..a98bbf42023a 100644
--- a/include/pcmcia/ds.h
+++ b/include/pcmcia/ds.h
@@ -249,7 +249,18 @@ struct pcmcia_device {
249#define handle_to_dev(handle) (handle->dev) 249#define handle_to_dev(handle) (handle->dev)
250 250
251/* error reporting */ 251/* error reporting */
252void cs_error(struct pcmcia_device *handle, int func, int ret); 252
253const char *pcmcia_error_func(int func);
254const char *pcmcia_error_ret(int ret);
255
256#define cs_error(p_dev, func, ret) \
257 { \
258 dev_printk(KERN_NOTICE, &p_dev->dev, \
259 "%s : %s\n", \
260 pcmcia_error_func(func), \
261 pcmcia_error_ret(ret)); \
262 }
263
253 264
254#endif /* __KERNEL__ */ 265#endif /* __KERNEL__ */
255#endif /* _LINUX_DS_H */ 266#endif /* _LINUX_DS_H */