* [dpdk-dev] [PATCH] bus/ifpga: remove useless driver cast
@ 2018-09-25 22:08 Thomas Monjalon
2018-09-26 0:25 ` Xu, Rosen
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Monjalon @ 2018-09-25 22:08 UTC (permalink / raw)
To: rosen.xu, tianfei.zhang; +Cc: dev
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.
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
drivers/bus/ifpga/ifpga_bus.c | 6 ++----
drivers/bus/ifpga/rte_bus_ifpga.h | 3 ---
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
index 207aea152..a10f54f7b 100644
--- a/drivers/bus/ifpga/ifpga_bus.c
+++ b/drivers/bus/ifpga/ifpga_bus.c
@@ -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
diff --git a/drivers/bus/ifpga/rte_bus_ifpga.h b/drivers/bus/ifpga/rte_bus_ifpga.h
index 51d5ae0d9..d53c0f483 100644
--- a/drivers/bus/ifpga/rte_bus_ifpga.h
+++ b/drivers/bus/ifpga/rte_bus_ifpga.h
@@ -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.
*/
--
2.19.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] bus/ifpga: remove useless driver cast
2018-09-25 22:08 [dpdk-dev] [PATCH] bus/ifpga: remove useless driver cast Thomas Monjalon
@ 2018-09-26 0:25 ` Xu, Rosen
2018-09-27 12:43 ` Thomas Monjalon
0 siblings, 1 reply; 3+ messages in thread
From: Xu, Rosen @ 2018-09-26 0:25 UTC (permalink / raw)
To: Thomas Monjalon, Zhang, Tianfei; +Cc: dev
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Wednesday, September 26, 2018 6:08
> To: Xu, Rosen <rosen.xu@intel.com>; Zhang, Tianfei
> <tianfei.zhang@intel.com>
> Cc: dev@dpdk.org
> 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.
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
> drivers/bus/ifpga/ifpga_bus.c | 6 ++----
> drivers/bus/ifpga/rte_bus_ifpga.h | 3 ---
> 2 files changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
> index 207aea152..a10f54f7b 100644
> --- a/drivers/bus/ifpga/ifpga_bus.c
> +++ b/drivers/bus/ifpga/ifpga_bus.c
> @@ -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
> diff --git a/drivers/bus/ifpga/rte_bus_ifpga.h
> b/drivers/bus/ifpga/rte_bus_ifpga.h
> index 51d5ae0d9..d53c0f483 100644
> --- a/drivers/bus/ifpga/rte_bus_ifpga.h
> +++ b/drivers/bus/ifpga/rte_bus_ifpga.h
> @@ -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.
> */
> --
> 2.19.0
Acked-by: Rosen Xu <rosen.xu@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] bus/ifpga: remove useless driver cast
2018-09-26 0:25 ` Xu, Rosen
@ 2018-09-27 12:43 ` Thomas Monjalon
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2018-09-27 12:43 UTC (permalink / raw)
To: Xu, Rosen; +Cc: dev, Zhang, Tianfei
> > 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.
> >
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
>
> Acked-by: Rosen Xu <rosen.xu@intel.com>
Applied
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-09-27 12:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-25 22:08 [dpdk-dev] [PATCH] bus/ifpga: remove useless driver cast Thomas Monjalon
2018-09-26 0:25 ` Xu, Rosen
2018-09-27 12:43 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).