From: Bjorn Helgaas <helgaas@kernel.org>
To: Bart Van Assche <bvanassche@acm.org>
Cc: "Martin K . Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org, Marco Elver <elver@google.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Nathan Chancellor <nathan@kernel.org>
Subject: Re: [PATCH v2 01/56] PCI: Convert to_pci_dev() into an inline function
Date: Thu, 30 Apr 2026 17:19:09 -0500 [thread overview]
Message-ID: <20260430221909.GA448587@bhelgaas> (raw)
In-Reply-To: <20260430182130.1978347-2-bvanassche@acm.org>
On Thu, Apr 30, 2026 at 11:19:31AM -0700, Bart Van Assche wrote:
> Clang's context analysis checker performs alias analysis on expressions
> passed to annotations like __acquires(). Clang's alias analysis does not
> support container_of(). Convert to_pci_dev() from a macro into an inline
> function such that Clang recognizes multiple to_pci_dev() expressions as
> identical if the 'dev' argument is the same.
>
> It is on purpose that to_pci_dev() accepts a const pointer and returns a
> pointer that is not const. Any other choice, e.g. accepting a non-const
> pointer or returning a const pointer, triggers compiler errors.
>
> While _Generic() could be used to support const and non-const struct
> device pointers in a more elegant way, Clang's alias analysis does not
> support _Generic().
>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
> include/linux/pci.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 2c4454583c11..f5989267a537 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -606,7 +606,10 @@ static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
>
> struct pci_dev *pci_alloc_dev(struct pci_bus *bus);
>
> -#define to_pci_dev(n) container_of(n, struct pci_dev, dev)
> +static inline struct pci_dev *to_pci_dev(const struct device *dev)
> +{
> + return container_of(dev, struct pci_dev, dev);
> +}
> #define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)
> #define for_each_pci_dev_reverse(d) \
> while ((d = pci_get_device_reverse(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)
next prev parent reply other threads:[~2026-04-30 22:19 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 18:19 [PATCH v2 00/56] Enable lock context analysis for the SCSI subsystem Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 01/56] PCI: Convert to_pci_dev() into an inline function Bart Van Assche
2026-04-30 22:19 ` Bjorn Helgaas [this message]
2026-04-30 18:19 ` [PATCH v2 02/56] scsi: scsi_debug: Prepare for enabling lock context analysis Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 03/56] scsi: sg: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 04/56] scsi: st: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 05/56] scsi: BusLogic: Introduce a local variable Bart Van Assche
2026-05-01 18:01 ` Khalid Aziz
2026-04-30 18:19 ` [PATCH v2 06/56] scsi: BusLogic: Prepare for enabling lock context analysis Bart Van Assche
2026-05-01 18:02 ` Khalid Aziz
2026-04-30 18:19 ` [PATCH v2 07/56] scsi: NCR5380: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 08/56] scsi: aacraid: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 09/56] scsi: aic7xxx: Enable " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 10/56] scsi: aha152x: Prepare for enabling " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 11/56] scsi: aic7xxx: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 12/56] scsi: aic94xx: Enable " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 13/56] scsi: arcmsr: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 14/56] scsi: arm: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 15/56] scsi: be2iscsi: Prepare for enabling " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 16/56] scsi: be2iscsi: Enable " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 17/56] scsi: cxgbi: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 18/56] scsi: bfa: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 19/56] scsi: bnx2fc: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 20/56] scsi: bnx2i: Introduce a local variable Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 21/56] scsi: bnx2i: Enable lock context analysis Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 22/56] scsi: csiostor: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 23/56] scsi: elx: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 24/56] scsi: esas2r: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 25/56] scsi: fcoe: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 26/56] scsi: fnic: " Bart Van Assche
2026-05-04 17:45 ` Karan Tilak Kumar (kartilak)
2026-04-30 18:19 ` [PATCH v2 27/56] scsi: hisi_sas: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 28/56] scsi: hpsa: Prepare for enabling " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 29/56] scsi: ibmvscsi: Enable " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 30/56] scsi: ibmvscsi_tgt: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 31/56] scsi: ipr: Prepare for enabling " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 32/56] scsi: ips: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 33/56] scsi: isci: Enable " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 34/56] scsi: libfc: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 35/56] scsi: libiscsi: Prepare for enabling " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 36/56] scsi: libsas: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 37/56] scsi: libsas: Enable " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 38/56] scsi: lpfc: Prepare for enabling " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 39/56] scsi: megaraid_sas: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 40/56] scsi: megaraid: Enable " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 41/56] scsi: mpt3sas: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 42/56] scsi: mvsas: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 43/56] scsi: pcmcia: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 44/56] scsi: pm8001: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 45/56] scsi: qedf: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 46/56] scsi: qedi: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 47/56] scsi: qla1280: Prepare for enabling " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 48/56] scsi: qla2xxx: Enable " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 49/56] scsi: qla4xxx: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 50/56] scsi: ufs: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 51/56] scsi: iSCSI transport: Prepare for enabling " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 52/56] scsi: smartpqi: Enable " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 53/56] scsi: snic: " Bart Van Assche
2026-05-01 19:08 ` Narsimhulu Musini (nmusini)
2026-04-30 18:20 ` [PATCH v2 54/56] scsi: sym53c8xx_2: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 55/56] scsi: core: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 56/56] scsi: core: Protect host state changes with the host lock Bart Van Assche
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=20260430221909.GA448587@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=bvanassche@acm.org \
--cc=elver@google.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=nathan@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