Re: [PATCH v3 2/2] asus-laptop: cleanup is_visible

From: Darren Hart
Date: Mon Jan 26 2015 - 22:11:56 EST


On Fri, Jan 23, 2015 at 09:01:11AM -0500, Vivien Didelot wrote:
> Get rid of the "normal" label, use one if-statement per attribute for
> maintainability and change s/supported/ret/ and s/asus->handle/handle/
> to fix a coding style issue (lines with 80+ chars).
>
> Signed-off-by: Vivien Didelot <vivien.didelot@xxxxxxxxxxxxxxxxxxxx>
> ---
> drivers/platform/x86/asus-laptop.c | 61 ++++++++++++++------------------------
> 1 file changed, 22 insertions(+), 39 deletions(-)
>
> diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
> index 46b2746..37a3a1f 100644
> --- a/drivers/platform/x86/asus-laptop.c
> +++ b/drivers/platform/x86/asus-laptop.c
> @@ -1602,55 +1602,38 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
> struct platform_device *pdev = to_platform_device(dev);
> struct asus_laptop *asus = platform_get_drvdata(pdev);
> acpi_handle handle = asus->handle;
> - bool supported;
> + bool ret = true;

Very odd to have ret be a bool...

>
> - if (asus->is_pega_lucid) {
> - /* no ls_level interface on the Lucid */
> - if (attr == &dev_attr_ls_switch.attr)
> - supported = true;
> - else if (attr == &dev_attr_ls_level.attr)
> - supported = false;
> - else
> - goto normal;
> -
> - return supported ? attr->mode : 0;
> - }
> -
> -normal:
> if (attr == &dev_attr_wlan.attr) {
> - supported = !acpi_check_handle(handle, METHOD_WLAN, NULL);
> -
> + ret = !acpi_check_handle(handle, METHOD_WLAN, NULL);

acpi_check_handle returns an int, you should be able to just use that.
...

> } else if (attr == &dev_attr_ls_value.attr) {
> - supported = asus->is_pega_lucid;
> + ret = asus->is_pega_lucid;

This should promote to an int without a problem.
...

--
Darren Hart
Intel Open Source Technology Center
--
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/