[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1410991612.4290.10.camel@joe-AO725>
Date: Wed, 17 Sep 2014 15:06:52 -0700
From: Joe Perches <joe@...ches.com>
To: Frans Klaver <fransklaver@...il.com>
Cc: Darren Hart <dvhart@...radead.org>,
Corentin Chary <corentin.chary@...il.com>,
Rafael Wysocki <rafael.j.wysocki@...el.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
acpi4asus-user@...ts.sourceforge.net,
platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/9] eeepc-laptop: clean up coding style
On Wed, 2014-09-17 at 23:47 +0200, Frans Klaver wrote:
> Correct indentation and brace usage to comply with
> Documentation/CodingStyle.
>
> Signed-off-by: Frans Klaver <fransklaver@...il.com>
> ---
> drivers/platform/x86/eeepc-laptop.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
> index 3095d38..653999e 100644
> --- a/drivers/platform/x86/eeepc-laptop.c
> +++ b/drivers/platform/x86/eeepc-laptop.c
> @@ -544,7 +544,7 @@ static int eeepc_led_init(struct eeepc_laptop *eeepc)
> eeepc->tpd_led.name = "eeepc::touchpad";
> eeepc->tpd_led.brightness_set = tpd_led_set;
> if (get_acpi(eeepc, CM_ASL_TPD) >= 0) /* if method is available */
> - eeepc->tpd_led.brightness_get = tpd_led_get;
> + eeepc->tpd_led.brightness_get = tpd_led_get;
> eeepc->tpd_led.max_brightness = 1;
>
> rv = led_classdev_register(&eeepc->platform_device->dev,
> @@ -692,8 +692,9 @@ static int eeepc_register_rfkill_notifier(struct eeepc_laptop *eeepc,
> * changed during setup.
> */
> eeepc_rfkill_hotplug(eeepc, handle);
> - } else
> + } else {
> return -ENODEV;
> + }
>
> return 0;
> }
This sort of code:
if (foo) {
[ do_something ]
} else
return -ERRVAL;
is generally better rewritten as:
if (!foo)
return -ERRVAL;
[ do_something ]
This gives immediacy to the error handler and
as well reduces unnecessary indentation.
So instead of:
static int eeepc_register_rfkill_notifier(struct eeepc_laptop *eeepc,
char *node)
{
acpi_status status;
acpi_handle handle;
status = acpi_get_handle(NULL, node, &handle);
if (ACPI_SUCCESS(status)) {
status = acpi_install_notify_handler(handle,
ACPI_SYSTEM_NOTIFY,
eeepc_rfkill_notify,
eeepc);
if (ACPI_FAILURE(status))
pr_warn("Failed to register notify on %s\n", node);
/*
* Refresh pci hotplug in case the rfkill state was
* changed during setup.
*/
eeepc_rfkill_hotplug(eeepc, handle);
} else
return -ENODEV;
return 0;
}
try something like:
static int eeepc_register_rfkill_notifier(struct eeepc_laptop *eeepc,
char *node)
{
acpi_handle handle;
acpi_status status = acpi_get_handle(NULL, node, &handle);
if (!ACPI_SUCCESS(status))
return -ENODEV;
status = acpi_install_notify_handler(handle,
ACPI_SYSTEM_NOTIFY,
eeepc_rfkill_notify,
eeepc);
if (ACPI_FAILURE(status))
pr_warn("Failed to register notify on %s\n", node);
/*
* Refresh pci hotplug in case the rfkill state was
* changed during setup.
*/
eeepc_rfkill_hotplug(eeepc, handle);
return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists