Skip to contentSkip to conversation

bus/ifpga: remove useless driver cast

PATCH In review Thomas Monjalon 2 participants 3 messages Sep 25, 2018 – Sep 27, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bus/ifpga: remove useless driver cast

The rte_afu_driver is assigned to rte_afu_device.driver during probing. There is no need of accessing the rte_afu_driver via rte_device.driver and type casting to its container.

---
 drivers/bus/ifpga/ifpga_bus.c     | 6 ++----
 drivers/bus/ifpga/rte_bus_ifpga.h | 3 ---
 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +2 -4
index 207aea152..a10f54f7b 100644
@@ -349,16 +349,14 @@ static int
 ifpga_remove_driver(struct rte_afu_device *afu_dev)
 {
 	const char *name;
-	const struct rte_afu_driver *driver;
 
 	name = rte_ifpga_device_name(afu_dev);
-	if (!afu_dev->device.driver) {
+	if (afu_dev->driver == NULL) {
 		IFPGA_BUS_DEBUG("no driver attach to device %s\n", name);
 		return 1;
 	}
 
-	driver = RTE_DRV_TO_AFU_CONST(afu_dev->device.driver);
-	return driver->remove(afu_dev);
+	return afu_dev->driver->remove(afu_dev);
 }
 
 static int
drivers/bus/ifpga/rte_bus_ifpga.h +0 -3
index 51d5ae0d9..d53c0f483 100644
@@ -83,9 +83,6 @@ struct rte_afu_device {
 #define RTE_DEV_TO_AFU(ptr) \
 	container_of(ptr, struct rte_afu_device, device)
 
-#define RTE_DRV_TO_AFU_CONST(ptr) \
-	container_of(ptr, const struct rte_afu_driver, driver)
-
 /**
  * Initialization function for the driver called during FPGA BUS probing.
  */
Signature · 1 line
2.19.0
Acked-by on v1 1/1
#1 lore raw
Quoted 57 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, September 26, 2018 6:08
To: Xu, Rosen <[email protected]>; Zhang, Tianfei <[email protected]>
Cc: [email protected]
Subject: [PATCH] bus/ifpga: remove useless driver cast

The rte_afu_driver is assigned to rte_afu_device.driver during probing. There is no need of accessing the rte_afu_driver via rte_device.driver and type casting to its container.

---
 drivers/bus/ifpga/ifpga_bus.c     | 6 ++----
 drivers/bus/ifpga/rte_bus_ifpga.h | 3 ---
 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +2 -4
index 207aea152..a10f54f7b 100644
@@ -349,16 +349,14 @@ static int
 ifpga_remove_driver(struct rte_afu_device *afu_dev)  {
 	const char *name;
-	const struct rte_afu_driver *driver;
 
 	name = rte_ifpga_device_name(afu_dev);
-	if (!afu_dev->device.driver) {
+	if (afu_dev->driver == NULL) {
 		IFPGA_BUS_DEBUG("no driver attach to device %s\n", name);
 		return 1;
 	}
 
-	driver = RTE_DRV_TO_AFU_CONST(afu_dev->device.driver);
-	return driver->remove(afu_dev);
+	return afu_dev->driver->remove(afu_dev);
 }
 
 static int
drivers/bus/ifpga/rte_bus_ifpga.h +0 -4
index 51d5ae0d9..d53c0f483 100644
@@ -83,9 +83,6 @@ struct rte_afu_device {  #define RTE_DEV_TO_AFU(ptr)
 \
 	container_of(ptr, struct rte_afu_device, device)
 
-#define RTE_DRV_TO_AFU_CONST(ptr) \
-	container_of(ptr, const struct rte_afu_driver, driver)
-
 /**
  * Initialization function for the driver called during FPGA BUS probing.
  */
--
Quoted 1 line

2.19.0