Re: [PATCH] misc_register error return handling

From: Mikael Pettersson
Date: Mon Sep 25 2006 - 07:19:35 EST


On Mon, 25 Sep 2006 14:29:00 +0530, Amol Lad wrote:
> diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff linux-2.6.18-orig/arch/i386/kernel/apm.c linux-2.6.18/arch/i386/kernel/apm.c
> --- linux-2.6.18-orig/arch/i386/kernel/apm.c 2006-09-21 10:15:25.000000000 +0530
> +++ linux-2.6.18/arch/i386/kernel/apm.c 2006-09-25 13:59:53.000000000 +0530
> @@ -2246,6 +2246,12 @@ static int __init apm_init(void)
> return -ENODEV;
> }
>
> + ret = misc_register(&apm_device);
> + if (ret != 0) {
> + printk(KERN_ERR "apm: cannot register misc device.\n");
> + return ret;
> + }
> +
> if (allow_ints)
> apm_info.allow_ints = 1;
> if (broken_psr)
> @@ -2282,17 +2288,20 @@ static int __init apm_init(void)
>
> if (apm_info.disabled) {
> printk(KERN_NOTICE "apm: disabled on user request.\n");
> - return -ENODEV;
> + ret = -ENODEV;
> + goto out_misc;

etc

NAK on the APM changes. APM can do its work just fine even if
it failed to register a device file; it will just lack some
user interface/control bits.

> @@ -2348,8 +2358,6 @@ static int __init apm_init(void)
> return 0;
> }
>
> - misc_register(&apm_device);
> -

This should just print a warning (but not fail) if misc_register()
returned failure.

/Mikael
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/