All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Ayman Bagabas <ayman.bagabas@gmail.com>
Cc: Darren Hart <dvhart@infradead.org>,
	Andy Shevchenko <andy@infradead.org>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Kailang Yang <kailang@realtek.com>,
	Hui Wang <hui.wang@canonical.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Platform Driver <platform-driver-x86@vger.kernel.org>,
	ALSA Development Mailing List <alsa-devel@alsa-project.org>
Subject: Re: [PATCH v3 1/3] x86: add support for Huawei WMI hotkeys.
Date: Thu, 8 Nov 2018 21:58:44 +0200	[thread overview]
Message-ID: <CAHp75Vev_0ObO=KLHfON8JAco=a9MURycH9uk-a+h1JqrSSQFA@mail.gmail.com> (raw)
In-Reply-To: <20181108171701.4444-2-ayman.bagabas@gmail.com>

On Thu, Nov 8, 2018 at 7:17 PM Ayman Bagabas <ayman.bagabas@gmail.com> wrote:
>
> This driver adds support for missing hotkeys on some Huawei laptops.
> Currently, only Huawei Matebook X and Matebook X Pro is supported.
>

Thanks for an update, my comments below.


> +config HUAWEI_LAPTOP
> +       tristate "Huawei WMI hotkeys driver"

> +       depends on ACPI

Do you need an ACPI dependency be explicit here?

> +       depends on ACPI_WMI
> +       depends on INPUT
> +       select INPUT_SPARSEKMAP
> +       help
> +         This driver provides support for Huawei WMI hotkeys.
> +         It enables the missing keys and adds support to the micmute
> +         LED found on some of these laptops.


> +/*
> + *  Huawei WMI hotkeys
> + *
> + *  Copyright (C) 2018       Ayman Bagabas <ayman.bagabas@gmail.com>

> + *
> + *  This program is free software: you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation, either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
> + *

Please, replace this boilerplate text with appropriate SPDX identifier.

> + */

> +#include <linux/init.h>
> +#include <linux/module.h>

One of them should be chosen.

> +static char *event_guid;
> +static struct input_dev *inputdev;

> +int huawei_wmi_micmute_led_set(bool on)
> +{
> +       acpi_handle handle = ACPI_HANDLE(&inputdev->dev);
> +       char *method;
> +       union acpi_object args[3];

> +       args[0].type = args[1].type = args[2].type = ACPI_TYPE_INTEGER;
> +       args[1].integer.value = 0x04;

Please, don't mix definitions and code.

> +       struct acpi_object_list arg_list = {
> +               .pointer = args,
> +               .count = ARRAY_SIZE(args),
> +       };
> +
> +       if (acpi_has_method(handle, method = "\\_SB.PCI0.LPCB.EC0.SPIN")) {
> +               args[0].integer.value = 0;
> +               args[2].integer.value = on ? 1 : 0;
> +       } else if (acpi_has_method(handle, method = "\\_SB.PCI0.LPCB.EC0.WPIN")) {
> +               args[0].integer.value = 1;
> +               args[2].integer.value = on ? 0 : 1;
> +       } else {
> +               pr_err("Unable to find ACPI method\n");

dev_err() here.

> +               return -1;

Return appropriate error code.

> +       }
> +
> +       acpi_evaluate_object(handle, method, &arg_list, NULL);
> +
> +       return 0;
> +}
> +EXPORT_SYMBOL_GPL(huawei_wmi_micmute_led_set);
> +
> +static void huawei_wmi_process_key(struct input_dev *inputdev, int code)
> +{

> +               acpi_status status;
> +               unsigned long long result;
> +               const char *method = "\\WMI0.WQ00";
> +               union acpi_object args[] = {
> +                               { .type = ACPI_TYPE_INTEGER  },
> +               };

> +               args[0].integer.value = 0;

Don't mix definitions and code.

> +               struct acpi_object_list arg_list = {
> +                       .pointer = args,
> +                       .count = ARRAY_SIZE(args),
> +               };

> +       if ((key->sw.code == KEY_BRIGHTNESSUP
> +                       || key->sw.code == KEY_BRIGHTNESSDOWN)

I believe this can fit one line.

> +                       && strcmp(event_guid, MBXP_EVENT_GUID) == 0)
> +               return;
> +
> +       sparse_keymap_report_entry(inputdev, key, 1, true);
> +}

> +static int __init huawei_wmi_init(void)
> +{
> +       int err;
> +
> +       if (wmi_has_guid(MBX_EVENT_GUID)) {
> +               event_guid = MBX_EVENT_GUID;
> +       } else if (wmi_has_guid(MBXP_EVENT_GUID)) {
> +               event_guid = MBXP_EVENT_GUID;
> +       } else {

> +               pr_warn("No known WMI GUID found\n");

Simple "Compatible WMI GUID not found\n".

> +               return -ENODEV;
> +       }
> +

> +       err = huawei_wmi_input_init();
> +       if (err) {

> +               pr_err("Failed to setup input device\n");

Noise.

> +               return err;
> +       }
> +
> +       return 0;

...just do

return huawei_wmi_input_init();

> +}

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2018-11-08 19:58 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-08 17:16 [PATCH v3 0/3] Huawei laptops Ayman Bagabas
2018-11-08 17:16 ` [PATCH v3 1/3] x86: add support for Huawei WMI hotkeys Ayman Bagabas
2018-11-08 19:58   ` Andy Shevchenko [this message]
2018-11-09  3:52     ` ayman.bagabas
2018-11-09 10:40       ` Andy Shevchenko
2018-11-08 17:16 ` [PATCH v3 2/3] ALSA: hda: fix front speakers on Huawei MBXP Ayman Bagabas
2018-11-09  8:55   ` Takashi Iwai
2018-11-09  8:55     ` Takashi Iwai
2018-11-08 17:16 ` [PATCH v3 3/3] ALSA: hda: add support for Huawei WMI micmute LED Ayman Bagabas
2018-11-09  9:01   ` Takashi Iwai
2018-11-09  9:01     ` Takashi Iwai
2018-11-09 13:20     ` Ayman Bagabas
2018-11-09 13:28       ` Takashi Iwai
2018-11-19 23:57   ` Pavel Machek
2018-11-20  7:07     ` Takashi Iwai
2018-11-20  7:07       ` Takashi Iwai
2018-11-20  9:10       ` Pavel Machek
2018-11-20  9:23         ` Takashi Iwai
2018-11-20  9:36           ` Pavel Machek
2018-11-20  9:36             ` Pavel Machek
2018-11-20  9:49             ` Takashi Iwai
2018-11-20 11:51               ` Pavel Machek
2018-11-20 12:19                 ` Takashi Iwai
2018-11-22 11:36                   ` Andy Shevchenko
2018-11-22 13:18                     ` Pavel Machek
2018-11-22 13:43                       ` Takashi Iwai
2018-11-23 22:05                         ` Pavel Machek
2018-11-23 22:05                           ` Pavel Machek
2018-11-23 23:33                         ` Pavel Machek
2018-11-23 23:33                           ` Pavel Machek
2018-11-24  8:10                           ` Takashi Iwai
2018-11-24  8:10                             ` Takashi Iwai
2018-11-24 10:41                             ` Pavel Machek
2018-11-22 13:12                   ` Pavel Machek
2018-11-22 13:14                     ` Takashi Iwai
2018-11-08 19:59 ` [PATCH v3 0/3] Huawei laptops Andy Shevchenko
2018-11-09  3:38   ` ayman.bagabas
2018-11-09  7:41   ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHp75Vev_0ObO=KLHfON8JAco=a9MURycH9uk-a+h1JqrSSQFA@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=andy@infradead.org \
    --cc=ayman.bagabas@gmail.com \
    --cc=dvhart@infradead.org \
    --cc=hui.wang@canonical.com \
    --cc=kailang@realtek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.