public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: "Linux ACPI" <linux-acpi@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Bjorn Helgaas" <helgaas@kernel.org>,
	"Zhang Rui" <rui.zhang@intel.com>,
	"Chen Yu" <yu.c.chen@intel.com>,
	"Mika Westerberg" <mika.westerberg@linux.intel.com>,
	"Linux PCI" <linux-pci@vger.kernel.org>,
	"Alex Hung" <alexhung@gmail.com>,
	"Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	platform-driver-x86@vger.kernel.org,
	"AceLan Kao" <acelan.kao@canonical.com>
Subject: Re: [PATCH v1 1/4] ACPI: PNP: Drop PNP0C01 and PNP0C02 from acpi_pnp_device_ids[]
Date: Mon, 29 Dec 2025 15:58:14 +0200	[thread overview]
Message-ID: <aVKI9lVAepGw4lVg@smile.fi.intel.com> (raw)
In-Reply-To: <CAJZ5v0h-uOs1Q3RXxsbw4AOxTvY5siGrnxSLfXfk+Ea-ZUz7bQ@mail.gmail.com>

On Mon, Dec 29, 2025 at 02:12:10PM +0100, Rafael J. Wysocki wrote:
> On Sun, Dec 28, 2025 at 8:11 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Mon, Dec 15, 2025 at 02:34:06PM +0100, Rafael J. Wysocki wrote:

...

> > > +     if (match_string(acpi_system_dev_ids, -1, acpi_device_hid(device)) >= 0) {
> >
> > Using -1 makes sense when we have no direct visibility of the mentioned array.
> > Here we have it visible and statically defined, hence the ARRAY_SIZE() is more
> > appropriate.
> 
> But as it stands it is more consistent with what happens elsewhere in this file.

It's not a big deal, especially if there is some consistency involved.

...

> > > +static void acpi_scan_claim_resources(struct acpi_device *adev)
> > > +{
> > > +     struct list_head resource_list = LIST_HEAD_INIT(resource_list);
> > > +     struct resource_entry *rentry;
> > > +     unsigned int count = 0;
> > > +     const char *regionid;
> >
> > > +     if (acpi_dev_get_resources(adev, &resource_list, NULL, NULL) <= 0)
> > > +             return;
> >
> > Strictly speaking the acpi_dev_free_resource_list() still needs to be called
> > on 0 return as it's called only for the error cases.
> 
> The return value of 0 means that the list is empty, so there's nothing to free.
> 
> > I think this is the first and the only time I see a combined comparison <= 0
> > for the acpi_dev_get_resources().
> 
> I don't see a problem here though.

There is no problem, the only minor thing is that the pattern I see seems only
here.

> > > +     regionid = kstrdup(dev_name(&adev->dev), GFP_KERNEL);
> > > +     if (!regionid)
> > > +             goto exit;
> > > +
> > > +     list_for_each_entry(rentry, &resource_list, node) {
> > > +             struct resource *res = rentry->res;
> > > +             struct resource *r;
> > > +
> > > +             /* Skip disabled and invalid resources. */
> > > +             if ((res->flags & IORESOURCE_DISABLED) || res->end < res->start)
> > > +                     continue;
> >
> > > +             if (res->flags & IORESOURCE_IO) {
> >
> > We have resource_type() helper.
> 
> I had considered using it, but then I couldn't convince myself that it
> would matter, so I went for simpler code.
> 
> > And I believe the direct comparison in this case is better.
> 
> You seem to be arguing that it matters after all, so why does it matter?

In the light of the resent findings of the resource_size() use on zeroed data
it also might be that in some cases the opposite happens, i.e. the resource had
initially a more bits of type assigned while checked for the certain one(s).
In such case the resource_type() == IORESOURCE_foo will fail on those.

I assume, nevertheless, that the code in question is quite unlikely exposed to
such mistakes.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-12-29 13:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-15 13:31 [PATCH v1 0/4] ACPI: scan: Handle generic system devices directly Rafael J. Wysocki
2025-12-15 13:34 ` [PATCH v1 1/4] ACPI: PNP: Drop PNP0C01 and PNP0C02 from acpi_pnp_device_ids[] Rafael J. Wysocki
2025-12-15 21:18   ` Mario Limonciello
2025-12-16 11:44     ` Rafael J. Wysocki
2025-12-28 19:11   ` Andy Shevchenko
2025-12-29 13:12     ` Rafael J. Wysocki
2025-12-29 13:58       ` Andy Shevchenko [this message]
2025-12-15 13:35 ` [PATCH v1 2/4] platform/x86/intel/hid: Stop creating a platform device Rafael J. Wysocki
2025-12-28 19:13   ` Andy Shevchenko
2025-12-29 13:07     ` Rafael J. Wysocki
2025-12-29 13:59       ` Andy Shevchenko
2025-12-15 13:35 ` [PATCH v1 3/4] platform/x86/intel/vbtn: " Rafael J. Wysocki
2025-12-28 19:14   ` Andy Shevchenko
2025-12-15 13:36 ` [PATCH v1 4/4] ACPI: PNP: Drop acpi_nonpnp_device_ids[] Rafael J. Wysocki
2025-12-16 14:03 ` [PATCH v1 0/4] ACPI: scan: Handle generic system devices directly Mario Limonciello

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=aVKI9lVAepGw4lVg@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=acelan.kao@canonical.com \
    --cc=alexhung@gmail.com \
    --cc=hansg@kernel.org \
    --cc=helgaas@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=yu.c.chen@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