[PATCH] paride_register(): shuffle return values

paride_register() returns 1 on success, 0 on failure and module init
code looks like

	static int __init foo_init(void)
	{
		return paride_register(&foo) - 1;
	}

which is not what one get used to. Converted to usual 0/-E convention.

In case of kbic driver, unwind registration. It was just

	return (paride_register(&k951)||paride_register(&k971))-1;

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Alexey Dobriyan 2006-12-06 20:36:21 -08:00 committed by Linus Torvalds
parent f4330002d1
commit b4178ab58a
16 changed files with 26 additions and 18 deletions

View File

@ -149,7 +149,7 @@ static struct pi_protocol aten = {
static int __init aten_init(void) static int __init aten_init(void)
{ {
return paride_register(&aten)-1; return paride_register(&aten);
} }
static void __exit aten_exit(void) static void __exit aten_exit(void)

View File

@ -464,7 +464,7 @@ static struct pi_protocol bpck = {
static int __init bpck_init(void) static int __init bpck_init(void)
{ {
return paride_register(&bpck)-1; return paride_register(&bpck);
} }
static void __exit bpck_exit(void) static void __exit bpck_exit(void)

View File

@ -265,7 +265,7 @@ static int __init bpck6_init(void)
printk(KERN_INFO "bpck6: Copyright 2001 by Micro Solutions, Inc., DeKalb IL. USA\n"); printk(KERN_INFO "bpck6: Copyright 2001 by Micro Solutions, Inc., DeKalb IL. USA\n");
if(verbose) if(verbose)
printk(KERN_DEBUG "bpck6: verbose debug enabled.\n"); printk(KERN_DEBUG "bpck6: verbose debug enabled.\n");
return paride_register(&bpck6) - 1; return paride_register(&bpck6);
} }
static void __exit bpck6_exit(void) static void __exit bpck6_exit(void)

View File

@ -205,7 +205,7 @@ static struct pi_protocol comm = {
static int __init comm_init(void) static int __init comm_init(void)
{ {
return paride_register(&comm)-1; return paride_register(&comm);
} }
static void __exit comm_exit(void) static void __exit comm_exit(void)

View File

@ -220,7 +220,7 @@ static struct pi_protocol dstr = {
static int __init dstr_init(void) static int __init dstr_init(void)
{ {
return paride_register(&dstr)-1; return paride_register(&dstr);
} }
static void __exit dstr_exit(void) static void __exit dstr_exit(void)

View File

@ -327,7 +327,7 @@ static int __init epat_init(void)
#ifdef CONFIG_PARIDE_EPATC8 #ifdef CONFIG_PARIDE_EPATC8
epatc8 = 1; epatc8 = 1;
#endif #endif
return paride_register(&epat)-1; return paride_register(&epat);
} }
static void __exit epat_exit(void) static void __exit epat_exit(void)

View File

@ -303,7 +303,7 @@ static struct pi_protocol epia = {
static int __init epia_init(void) static int __init epia_init(void)
{ {
return paride_register(&epia)-1; return paride_register(&epia);
} }
static void __exit epia_exit(void) static void __exit epia_exit(void)

View File

@ -138,7 +138,7 @@ static struct pi_protocol fit2 = {
static int __init fit2_init(void) static int __init fit2_init(void)
{ {
return paride_register(&fit2)-1; return paride_register(&fit2);
} }
static void __exit fit2_exit(void) static void __exit fit2_exit(void)

View File

@ -198,7 +198,7 @@ static struct pi_protocol fit3 = {
static int __init fit3_init(void) static int __init fit3_init(void)
{ {
return paride_register(&fit3)-1; return paride_register(&fit3);
} }
static void __exit fit3_exit(void) static void __exit fit3_exit(void)

View File

@ -263,7 +263,7 @@ static struct pi_protocol friq = {
static int __init friq_init(void) static int __init friq_init(void)
{ {
return paride_register(&friq)-1; return paride_register(&friq);
} }
static void __exit friq_exit(void) static void __exit friq_exit(void)

View File

@ -300,7 +300,7 @@ static struct pi_protocol frpw = {
static int __init frpw_init(void) static int __init frpw_init(void)
{ {
return paride_register(&frpw)-1; return paride_register(&frpw);
} }
static void __exit frpw_exit(void) static void __exit frpw_exit(void)

View File

@ -283,7 +283,15 @@ static struct pi_protocol k971 = {
static int __init kbic_init(void) static int __init kbic_init(void)
{ {
return (paride_register(&k951)||paride_register(&k971))-1; int rv;
rv = paride_register(&k951);
if (rv < 0)
return rv;
rv = paride_register(&k971);
if (rv < 0)
paride_unregister(&k951);
return rv;
} }
static void __exit kbic_exit(void) static void __exit kbic_exit(void)

View File

@ -115,7 +115,7 @@ static struct pi_protocol ktti = {
static int __init ktti_init(void) static int __init ktti_init(void)
{ {
return paride_register(&ktti)-1; return paride_register(&ktti);
} }
static void __exit ktti_exit(void) static void __exit ktti_exit(void)

View File

@ -140,7 +140,7 @@ static struct pi_protocol on20 = {
static int __init on20_init(void) static int __init on20_init(void)
{ {
return paride_register(&on20)-1; return paride_register(&on20);
} }
static void __exit on20_exit(void) static void __exit on20_exit(void)

View File

@ -306,7 +306,7 @@ static struct pi_protocol on26 = {
static int __init on26_init(void) static int __init on26_init(void)
{ {
return paride_register(&on26)-1; return paride_register(&on26);
} }
static void __exit on26_exit(void) static void __exit on26_exit(void)

View File

@ -237,19 +237,19 @@ int paride_register(PIP * pr)
if (protocols[k] && !strcmp(pr->name, protocols[k]->name)) { if (protocols[k] && !strcmp(pr->name, protocols[k]->name)) {
printk("paride: %s protocol already registered\n", printk("paride: %s protocol already registered\n",
pr->name); pr->name);
return 0; return -1;
} }
k = 0; k = 0;
while ((k < MAX_PROTOS) && (protocols[k])) while ((k < MAX_PROTOS) && (protocols[k]))
k++; k++;
if (k == MAX_PROTOS) { if (k == MAX_PROTOS) {
printk("paride: protocol table full\n"); printk("paride: protocol table full\n");
return 0; return -1;
} }
protocols[k] = pr; protocols[k] = pr;
pr->index = k; pr->index = k;
printk("paride: %s registered as protocol %d\n", pr->name, k); printk("paride: %s registered as protocol %d\n", pr->name, k);
return 1; return 0;
} }
EXPORT_SYMBOL(paride_register); EXPORT_SYMBOL(paride_register);