public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Frank <mail@dmitryfrank.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Zhang Rui <rui.zhang@intel.com>,
	"Rafael J . Wysocki" <rjw@rjwysocki.net>,
	Len Brown <lenb@kernel.org>,
	Felipe Contreras <felipe.contreras@gmail.com>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>
Subject: Re: [PATCH] acpi: video: get rid of magic numbers and use enum instead
Date: Wed, 19 Apr 2017 13:12:06 +0300	[thread overview]
Message-ID: <20170419101205.GC13803@dimon-t520> (raw)
In-Reply-To: <CAJZ5v0jRJhhZehYFzb6LtaheGsgXUb6OCZvoCHraFgwx2M_GVQ@mail.gmail.com>

Hi Rafael,

Thanks for the review.

On 04/19, Rafael J. Wysocki wrote:
> Hi,
> 
> On Tue, Apr 18, 2017 at 2:35 PM, Dmitry Frank <mail@dmitryfrank.com> wrote:
> > The first two items in the _BCL method response are special:
> >
> >   - Level when machine has full power
> >   - Level when machine is on batteries
> >   - .... actual supported levels go there ....
> >
> > So this commits adds an enum and uses its descriptive elements
> > throughout the code, instead of magic numbers.
> >
> > Some subtle cases are commented additionally (the comment for
> > acpi_video_bqc_quirk is by Felipe Contreras, CCed)
> 
> So that should be a separate patch.  Please split.
> 

Sure, done; please see the "v2" patchset. (It contains one more change:
renaming of the global flag device_id_scheme, since the old name is
misleading)

> >
> > Signed-off-by: Dmitry Frank <mail@dmitryfrank.com>
> > ---
> >  drivers/acpi/acpi_video.c | 134 ++++++++++++++++++++++++++++++----------------
> >  1 file changed, 89 insertions(+), 45 deletions(-)
> >
> > diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
> > index d00bc0ef87a6..856694e5f325 100644
> > --- a/drivers/acpi/acpi_video.c
> > +++ b/drivers/acpi/acpi_video.c
> > @@ -88,6 +88,18 @@ static int acpi_video_bus_remove(struct acpi_device *device);
> >  static void acpi_video_bus_notify(struct acpi_device *device, u32 event);
> >  void acpi_video_detect_exit(void);
> >
> > +/*
> > + * Indices in the _BCL method response: the first two items are special,
> > + * the rest are all supported levels.
> > + *
> > + * See page 575 of the ACPI spec 3.0
> > + */
> > +enum lvl_idx {
> > +       LVL_IDX_AC,             /* level when machine has full power */
> > +       LVL_IDX_BATTERY,        /* level when machine is on batteries */
> > +       LVL_IDX_FIRST,          /* actual supported levels begin here */
> 
> What about using different symbol names, like ACPI_VIDEO_AC_LEVEL,
> ACPI_VIDEO_BATTERY_LEVEL and ACPI_VIDEO_FIRST_LEVEL, respectively?
> 

Honestly, I find ACPI_VIDEO_..._LEVEL a bit misleading, because these
values are not levels, they are indices of levels. So I'd probably
prefer ..._LEVEL_INDEX, or ..._LEVEL_IDX, but it probably gets too long,
so...

Anyway, the patchset v2 contains the names you proposed; if you agree
that LEVEL_INDEX or LEVEL_IDX would be better, please let me know, and
I'll be happy to craft v3. Otherwise, I'm fine with these names too.

> > +};
> > +
> >  static const struct acpi_device_id video_device_ids[] = {
> >         {ACPI_VIDEO_HID, 0},
> >         {"", 0},
> > @@ -132,7 +144,7 @@ struct acpi_video_device_attrib {
> >                                    the VGA device. */
> >         u32 pipe_id:3;          /* For VGA multiple-head devices. */
> >         u32 reserved:10;        /* Must be 0 */
> > -       u32 device_id_scheme:1; /* Device ID Scheme */
> > +       u32 device_id_scheme:1; /* Whether the device ID follows this scheme above */
> 
> That still is not particularly clear (although admittedly it is better
> than what we have).
> 

Ok, I added a descriptive comment above the field.

Thanks,
Dmitry

  parent reply	other threads:[~2017-04-19 10:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-18 12:35 [PATCH] acpi: video: get rid of magic numbers and use enum instead Dmitry Frank
2017-04-19  0:42 ` Rafael J. Wysocki
2017-04-19  9:58   ` Dmitry Frank
2017-04-19 10:12   ` Dmitry Frank [this message]
2017-04-19  9:48 ` [PATCH v2 0/3] ACPI: video: get rid of magic numbers, do other refactoring Dmitry Frank
2017-04-19  9:48   ` [PATCH v2 1/3] ACPI: video: get rid of magic numbers and use enum instead Dmitry Frank
2017-04-19  9:48   ` [PATCH v2 2/3] ACPI: video: rename the global flag device_id_scheme Dmitry Frank
2017-04-19 10:23     ` Rafael J. Wysocki
2017-04-19 10:40       ` Dmitry Frank
2017-04-19  9:48   ` [PATCH v2 3/3] ACPI: video: add comments about subtle cases Dmitry Frank
2017-04-19 10:36 ` [PATCH v3 0/2] ACPI: video: get rid of magic numbers, do other refactoring Dmitry Frank
2017-04-19 10:36   ` [PATCH v3 1/2] ACPI: video: get rid of magic numbers and use enum instead Dmitry Frank
2017-04-19 19:36     ` Rafael J. Wysocki
2017-04-19 19:44       ` Dmitry Frank
2017-04-19 20:15         ` Rafael J. Wysocki
2017-04-20 10:40           ` Rafael J. Wysocki
2017-04-20 10:46             ` Dmitry Frank
2017-04-19 10:36   ` [PATCH v3 2/2] ACPI: video: add comments about subtle cases Dmitry Frank

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=20170419101205.GC13803@dimon-t520 \
    --to=mail@dmitryfrank.com \
    --cc=felipe.contreras@gmail.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=rui.zhang@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox