提交 79ba6757 编写于 作者: D Dominik Brodowski

pcmcia: use dev_printk for cs_error()

Use dev_printk() in cs_error()-based error reporting. While this
function-turned-macro will hopefully go away soon, using dev_printk
simplifies the code much.
Signed-off-by: NDominik Brodowski <linux@dominikbrodowski.net>
上级 9c8b7965
...@@ -69,8 +69,8 @@ spinlock_t pcmcia_dev_list_lock; ...@@ -69,8 +69,8 @@ spinlock_t pcmcia_dev_list_lock;
/* String tables for error messages */ /* String tables for error messages */
typedef struct lookup_t { typedef struct lookup_t {
int key; const int key;
char *msg; const char *msg;
} lookup_t; } lookup_t;
static const lookup_t error_table[] = { static const lookup_t error_table[] = {
...@@ -137,46 +137,32 @@ static const lookup_t service_table[] = { ...@@ -137,46 +137,32 @@ static const lookup_t service_table[] = {
{ ReplaceCIS, "ReplaceCIS" } { ReplaceCIS, "ReplaceCIS" }
}; };
const char *pcmcia_error_func(int func)
static int pcmcia_report_error(struct pcmcia_device *p_dev, error_info_t *err)
{ {
int i; int i;
char *serv;
if (!p_dev)
printk(KERN_NOTICE);
else
printk(KERN_NOTICE "%s: ", p_dev->dev.bus_id);
for (i = 0; i < ARRAY_SIZE(service_table); i++) for (i = 0; i < ARRAY_SIZE(service_table); i++)
if (service_table[i].key == err->func) if (service_table[i].key == func)
break; return service_table[i].msg;
if (i < ARRAY_SIZE(service_table))
serv = service_table[i].msg;
else
serv = "Unknown service number";
for (i = 0; i < ARRAY_SIZE(error_table); i++) return "Unknown service number";
if (error_table[i].key == err->retcode) }
break; EXPORT_SYMBOL(pcmcia_error_func);
if (i < ARRAY_SIZE(error_table))
printk("%s: %s\n", serv, error_table[i].msg);
else
printk("%s: Unknown error code %#x\n", serv, err->retcode);
return 0; const char *pcmcia_error_ret(int ret)
} /* report_error */ {
int i;
for (i = 0; i < ARRAY_SIZE(error_table); i++)
if (error_table[i].key == ret)
return error_table[i].msg;
/* end of code which was in cs.c before */ return "unknown";
}
EXPORT_SYMBOL(pcmcia_error_ret);
/*======================================================================*/ /*======================================================================*/
void cs_error(struct pcmcia_device *p_dev, int func, int ret)
{
error_info_t err = { func, ret };
pcmcia_report_error(p_dev, &err);
}
EXPORT_SYMBOL(cs_error);
static void pcmcia_check_driver(struct pcmcia_driver *p_drv) static void pcmcia_check_driver(struct pcmcia_driver *p_drv)
......
...@@ -249,7 +249,18 @@ struct pcmcia_device { ...@@ -249,7 +249,18 @@ struct pcmcia_device {
#define handle_to_dev(handle) (handle->dev) #define handle_to_dev(handle) (handle->dev)
/* error reporting */ /* error reporting */
void cs_error(struct pcmcia_device *handle, int func, int ret);
const char *pcmcia_error_func(int func);
const char *pcmcia_error_ret(int ret);
#define cs_error(p_dev, func, ret) \
{ \
dev_printk(KERN_NOTICE, &p_dev->dev, \
"%s : %s\n", \
pcmcia_error_func(func), \
pcmcia_error_ret(ret)); \
}
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* _LINUX_DS_H */ #endif /* _LINUX_DS_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册