mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: "Habil Eren Türker" <habilerenturker@hotmail.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Thomas Gleixner" <tglx@kernel.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"H . Peter Anvin" <hpa@zytor.com>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86/quirks: Cast PCI_D0 to u16 in apple_airport_reset()
Date: Thu, 19 Nov 2026 11:04:59 +0200	[thread overview]
Message-ID: <av67u5GSVL0KWolF@ashevche-desk.local> (raw)
In-Reply-To: <20261118181408.GA625801@bhelgaas>

On Wed, Nov 18, 2026 at 12:14:08PM -0600, Bjorn Helgaas wrote:
> [+cc Andy since he's fixed similar issues and may have better ideas]

Thanks! Yes, bitwise types in sparse are interesting thing, but since we want
to continue using them the easiest way out is to cast to pci_power_t.

> On Wed, Nov 18, 2026 at 04:16:03PM +0000, Habil Eren Türker wrote:
> > PCI_D0 is defined as pci_power_t, whereas pmcsr & PCI_PM_CTRL_STATE_MASK
> > evaluates to a u16 integer.
> > 
> > This causes Sparse (make C=1) to report:
> >         warning: restricted pci_power_t degrades to integer
> > 
> > Add (__force u16) casts on PCI_D0 to explicitly eliminate warnings.
> 
> We have a bunch of similar sparse warnings in drivers/pci, but I'm
> kind of hesitant to just throw in a cast at each one to avoid the
> warning.
> 
> About a third of the sparse warnings related to pci_power_t are
> similar to this, where we're extracting the power state using
> PCI_PM_CTRL_STATE_MASK and assigning to a pci_power_t variable or
> comparing for equality with PCI_D0.  I think we can fix these with an
> accessor something like this (better name ideas welcome):
> 
>   static inline pci_power_t pci_power_t_get(u32 csr)
>   {
>     return (pci_power_t __force) FIELD_GET(PCI_PM_CTRL_STATE_MASK, csr);
>   }
> 
> There are a few more we could fix with an analogous pci_power_t_set()
> or similar.  Most of the rest are arithmetic comparisons (>, <, >=,
> etc).

So, we basically need only two (the rest can be derived with negation.
_eq() [equal to] and _gt() [great than]. It may lead to have code in
a better shape from readability point of view.

-- 
With Best Regards,
Andy Shevchenko



      reply	other threads:[~2026-11-19  9:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 16:16 Habil Eren Türker
2026-11-18 18:14 ` Bjorn Helgaas
2026-11-19  9:04   ` 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=av67u5GSVL0KWolF@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=bhelgaas@google.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=habilerenturker@hotmail.com \
    --cc=helgaas@kernel.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@kernel.org \
    --cc=x86@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®