mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Hao Wei Tee <angelsl@angelsl.xyz>
Cc: Platform Driver <platform-driver-x86@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Andy Shevchenko <andy@infradead.org>,
	Darren Hart <dvhart@infradead.org>,
	Ike Panhc <ike.pan@canonical.com>
Subject: Re: [PATCH] platform/x86: ideapad-laptop: Expose conservation mode switch
Date: Sun, 13 Aug 2017 15:15:28 +0300	[thread overview]
Message-ID: <CAHp75Vc6SeP6bF7U_bdvy=DBSx8G78B7LWnwGR8Tg7-1O2NK8Q@mail.gmail.com> (raw)
In-Reply-To: <b667a2be-8021-93a0-d87a-e6fa6b2aa633@angelsl.xyz>

On Sat, May 27, 2017 at 10:31 AM, Hao Wei Tee <angelsl@angelsl.xyz> wrote:
> This exposes the battery conservation mode present on some (?) IdeaPads.
> The mode is set by calling ACPI method SBMC with argument 3 (on) or
> 5 (off). Status is reported in bit 5 of the return value of ACPI method
> GBMD.
>
> This patch was written based on an IdeaPad U430p. I'm not sure if the ACPI
> methods are the same across all IdeaPads, so it would be great if this got more
> testing across other models before it's merged.

Okay, since there is no reply from Ideapad maintainer I'm going to
accept v2 of this. (Sorry it took so long)

Why v2? See my comments below.

> +#define GBMD_CONSERVATION_BIT (5)

Please separate this line, it's not in CFG_ namespace AFAIU.

>  #define CFG_BT_BIT     (16)
>  #define CFG_3G_BIT     (17)
>  #define CFG_WIFI_BIT   (18)

>  enum {
> +       VPCCMD_CONSERVATION_ON = 3,
> +       VPCCMD_CONSERVATION_OFF = 5,

This should be separate enum. Below related to EC commands, you do
something else.

>         VPCCMD_R_VPC1 = 0x10,
>         VPCCMD_R_BL_MAX,
>         VPCCMD_R_BL,

> +static int conservation_mode_status(acpi_handle handle, bool *ret)

Should be called method_gbmd(). And please use unsigned long as return value.

> +{
> +       acpi_status status;
> +       unsigned long long result;
> +
> +       status = acpi_evaluate_integer(handle, "GBMD", NULL, &result);
> +       if (ACPI_FAILURE(status))
> +               return -1;

You may use read_method_int() helper.

> +
> +       *ret = (result & (1 << GBMD_CONSERVATION_BIT)) != 0;

"("  and "!= 0)" will gone with change of returned value type.

> +       return 0;
> +}

> +       bool boolval;

Reuse value instead.

>
>         if (!priv)
>                 return -EINVAL;
> @@ -250,6 +275,12 @@ static int debugfs_status_show(struct seq_file *s, void *data)
>         if (!read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &value))
>                 seq_printf(s, "Camera status:\t%s(%lu)\n",
>                            value ? "On" : "Off", value);
> +       seq_puts(s, "=====================\n");
> +
> +       if (!conservation_mode_status(priv->adev->handle, &boolval)) {

Ditto.

> +               seq_printf(s, "Conservation mode:\t%s(%u)\n",
> +                          boolval ? "On" : "Off", boolval);
> +       }

-- 
With Best Regards,
Andy Shevchenko

      parent reply	other threads:[~2017-08-13 12:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-27  7:31 Hao Wei Tee
2017-05-28 13:47 ` Hao Wei Tee
2017-05-30 13:22   ` Andy Shevchenko
2017-05-30 14:05     ` Hao Wei Tee
2017-06-11  5:07       ` Hao Wei Tee
2017-08-05 15:18     ` Hao Wei Tee
2017-08-06 18:35       ` Andy Shevchenko
2017-08-07 13:20         ` Hao Wei Tee
2017-08-13 12:15 ` Andy Shevchenko [this message]

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='CAHp75Vc6SeP6bF7U_bdvy=DBSx8G78B7LWnwGR8Tg7-1O2NK8Q@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=andy@infradead.org \
    --cc=angelsl@angelsl.xyz \
    --cc=dvhart@infradead.org \
    --cc=ike.pan@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®