DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, stephen@networkplumber.org,
	bruce.richardson@intel.com, Parav Pandit <parav@nvidia.com>,
	Xueming Li <xuemingl@nvidia.com>, Rosen Xu <rosen.xu@altera.com>,
	Tomasz Duszynski <tduszynski@marvell.com>
Subject: [PATCH 05/23] drivers/bus: remove device and driver checks in plug
Date: Wed, 29 Apr 2026 13:44:38 +0200	[thread overview]
Message-ID: <20260429114503.932575-6-david.marchand@redhat.com> (raw)
In-Reply-To: <20260429114503.932575-1-david.marchand@redhat.com>

The bus-specific device conversion macros all use container_of()
to convert from a generic rte_device pointer to a bus-specific
device structure.

A key property of container_of() is that it does NOT return NULL when
given a NULL pointer as input. Instead, it returns (NULL - offset),
which is a small non-NULL pointer value. This means NULL checks on
container_of() results cannot work as intended.

The device parameter passed to bus probe or plug operations cannot be NULL
as the caller already dereferenced the bus structure to invoke these
operations. Remove redundant NULL checks on the device parameter and
derived device pointers.

The driver reference in the bus-specific device cannot be NULL since
calling the .plug op is done after dereferencing this pointer.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/bus/auxiliary/auxiliary_common.c | 6 ------
 drivers/bus/ifpga/ifpga_bus.c            | 3 ---
 drivers/bus/platform/platform.c          | 8 +-------
 3 files changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/bus/auxiliary/auxiliary_common.c b/drivers/bus/auxiliary/auxiliary_common.c
index 1fe0cb4d78..314361643c 100644
--- a/drivers/bus/auxiliary/auxiliary_common.c
+++ b/drivers/bus/auxiliary/auxiliary_common.c
@@ -81,9 +81,6 @@ rte_auxiliary_probe_one_driver(struct rte_auxiliary_driver *drv,
 	enum rte_iova_mode iova_mode;
 	int ret;
 
-	if (drv == NULL || dev == NULL)
-		return -EINVAL;
-
 	/* Check if driver supports it. */
 	if (!auxiliary_match(drv, dev))
 		/* Match of device and driver failed */
@@ -174,9 +171,6 @@ auxiliary_probe_all_drivers(struct rte_auxiliary_device *dev)
 	struct rte_auxiliary_driver *drv;
 	int rc;
 
-	if (dev == NULL)
-		return -EINVAL;
-
 	FOREACH_DRIVER_ON_AUXILIARY_BUS(drv) {
 		if (!drv->match(dev->name))
 			continue;
diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
index fc5308b6f4..0f331fa6dd 100644
--- a/drivers/bus/ifpga/ifpga_bus.c
+++ b/drivers/bus/ifpga/ifpga_bus.c
@@ -302,9 +302,6 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)
 	struct rte_afu_driver *drv = NULL;
 	int ret = 0;
 
-	if (afu_dev == NULL)
-		return -1;
-
 	/* Check if a driver is already loaded */
 	if (rte_dev_is_probed(&afu_dev->device)) {
 		IFPGA_BUS_DEBUG("Device %s is already probed",
diff --git a/drivers/bus/platform/platform.c b/drivers/bus/platform/platform.c
index 0345f1daf7..5cc0d69209 100644
--- a/drivers/bus/platform/platform.c
+++ b/drivers/bus/platform/platform.c
@@ -458,19 +458,13 @@ platform_bus_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, cons
 static int
 platform_bus_plug(struct rte_device *dev)
 {
-	struct rte_platform_device *pdev;
-
 	if (rte_bus_device_is_ignored(&platform_bus.bus, dev->name))
 		return -EPERM;
 
 	if (!dev_is_bound_vfio_platform(dev->name))
 		return -EPERM;
 
-	pdev = RTE_DEV_TO_PLATFORM_DEV(dev);
-	if (pdev == NULL)
-		return -EINVAL;
-
-	return device_attach(pdev);
+	return device_attach(RTE_DEV_TO_PLATFORM_DEV(dev));
 }
 
 static void
-- 
2.53.0


  parent reply	other threads:[~2026-04-29 11:45 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-29 11:44 [PATCH 00/23] Consolidate bus driver infrastructure David Marchand
2026-04-29 11:44 ` [PATCH 01/23] bus/ifpga: remove unused AFU lookup helper David Marchand
2026-04-29 11:44 ` [PATCH 02/23] crypto/octeontx: remove check on driver in remove David Marchand
2026-04-29 11:59   ` [EXTERNAL] " Anoob Joseph
2026-04-29 11:44 ` [PATCH 03/23] bus: remove device and driver checks in DMA map/unmap David Marchand
2026-04-29 11:44 ` [PATCH 04/23] drivers/bus: remove device and driver checks in unplug David Marchand
2026-04-29 11:44 ` David Marchand [this message]
2026-04-29 11:44 ` [PATCH 06/23] bus: add bus conversion macros David Marchand
2026-04-29 11:44 ` [PATCH 07/23] bus: factorize driver list David Marchand
2026-04-29 11:44 ` [PATCH 08/23] bus: factorize device list David Marchand
2026-04-29 11:44 ` [PATCH 09/23] bus: consolidate device lookup David Marchand
2026-04-29 11:44 ` [PATCH 10/23] bus: consolidate device iteration David Marchand
2026-04-29 11:44 ` [PATCH 11/23] bus: factorize driver lookup David Marchand
2026-04-29 11:44 ` [PATCH 12/23] bus: refactor device probe David Marchand
2026-04-29 11:44 ` [PATCH 13/23] bus: support multiple probe David Marchand
2026-04-29 11:44 ` [PATCH 14/23] drivers/bus: initialize NXP bus specifics in scan David Marchand
2026-04-29 11:44 ` [PATCH 15/23] bus: implement probe in EAL David Marchand
2026-04-29 11:44 ` [PATCH 16/23] bus: factorize driver reference David Marchand
2026-04-29 11:44 ` [PATCH 17/23] drivers: rely on generic driver David Marchand
2026-04-29 11:44 ` [PATCH 18/23] drivers/bus: remove bus-specific driver references David Marchand
2026-04-29 11:44 ` [PATCH 19/23] dma/idxd: remove specific bus type David Marchand
2026-04-29 11:44 ` [PATCH 20/23] drivers/bus: separate specific bus metadata for NXP drivers David Marchand
2026-04-29 11:44 ` [PATCH 21/23] drivers/bus: remove specific bus types David Marchand
2026-04-29 11:44 ` [PATCH 22/23] eventdev: rename dev field to device David Marchand
2026-04-29 11:44 ` [PATCH 23/23] bus: add class device conversion macro David Marchand
2026-05-06 15:51 ` [PATCH v2 00/23] Consolidate bus driver infrastructure David Marchand
2026-05-06 15:51   ` [PATCH v2 01/23] bus/ifpga: remove unused AFU lookup helper David Marchand
2026-05-06 15:51   ` [PATCH v2 02/23] crypto/octeontx: remove check on driver in remove David Marchand
2026-05-06 15:51   ` [PATCH v2 03/23] bus: remove device and driver checks in DMA map/unmap David Marchand
2026-05-06 15:51   ` [PATCH v2 04/23] drivers/bus: remove device and driver checks in unplug David Marchand
2026-05-06 15:51   ` [PATCH v2 05/23] drivers/bus: remove device and driver checks in plug David Marchand
2026-05-06 15:51   ` [PATCH v2 06/23] bus: add bus conversion macros David Marchand
2026-05-06 15:51   ` [PATCH v2 07/23] bus: factorize driver list David Marchand
2026-05-06 15:51   ` [PATCH v2 08/23] bus: factorize device list David Marchand
2026-05-06 15:51   ` [PATCH v2 09/23] bus: consolidate device lookup David Marchand
2026-05-06 15:51   ` [PATCH v2 10/23] bus: consolidate device iteration David Marchand
2026-05-06 15:51   ` [PATCH v2 11/23] bus: factorize driver lookup David Marchand
2026-05-06 15:51   ` [PATCH v2 12/23] bus: refactor device probe David Marchand
2026-05-06 15:51   ` [PATCH v2 13/23] bus: support multiple probe David Marchand
2026-05-06 15:51   ` [PATCH v2 14/23] drivers/bus: initialize NXP bus specifics in scan David Marchand
2026-05-06 15:51   ` [PATCH v2 15/23] bus: implement probe in EAL David Marchand
2026-05-06 15:51   ` [PATCH v2 16/23] bus: factorize driver reference David Marchand
2026-05-06 15:51   ` [PATCH v2 17/23] drivers: rely on generic driver David Marchand
2026-05-06 15:51   ` [PATCH v2 18/23] drivers/bus: remove bus-specific driver references David Marchand
2026-05-06 15:51   ` [PATCH v2 19/23] dma/idxd: remove specific bus type David Marchand
2026-05-06 15:51   ` [PATCH v2 20/23] drivers/bus: separate specific bus metadata for NXP drivers David Marchand
2026-05-06 15:51   ` [PATCH v2 21/23] drivers/bus: remove specific bus types David Marchand
2026-05-06 15:51   ` [PATCH v2 22/23] eventdev: rename dev field to device David Marchand
2026-05-06 15:51   ` [PATCH v2 23/23] bus: add class device conversion macro David Marchand

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=20260429114503.932575-6-david.marchand@redhat.com \
    --to=david.marchand@redhat.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=parav@nvidia.com \
    --cc=rosen.xu@altera.com \
    --cc=stephen@networkplumber.org \
    --cc=tduszynski@marvell.com \
    --cc=thomas@monjalon.net \
    --cc=xuemingl@nvidia.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