diff mbox series

[RFC,3/6] fpga: dfl: add an API to get the base device for dfl device

Message ID 1603442745-13085-4-git-send-email-yilun.xu@intel.com (mailing list archive)
State RFC
Headers show
Series None | expand

Commit Message

Xu Yilun Oct. 23, 2020, 8:45 a.m. UTC
This patch adds an API for dfl devices to find which physical device
owns the DFL.

This patch makes preparation for supporting DFL Ether Group private
feature driver. It uses this information to determine which retimer
device physically connects to which ether group.

Signed-off-by: Xu Yilun <yilun.xu@intel.com>
---
 drivers/fpga/dfl.c  | 9 +++++++++
 include/linux/dfl.h | 1 +
 2 files changed, 10 insertions(+)

Comments

Tom Rix Oct. 24, 2020, 2:39 p.m. UTC | #1
On 10/23/20 1:45 AM, Xu Yilun wrote:
> This patch adds an API for dfl devices to find which physical device
> owns the DFL.
>
> This patch makes preparation for supporting DFL Ether Group private
> feature driver. It uses this information to determine which retimer
> device physically connects to which ether group.
device is physically
>
> Signed-off-by: Xu Yilun <yilun.xu@intel.com>
> ---
>  drivers/fpga/dfl.c  | 9 +++++++++
>  include/linux/dfl.h | 1 +
>  2 files changed, 10 insertions(+)
>
> diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
> index ca3c678..52d18e6 100644
> --- a/drivers/fpga/dfl.c
> +++ b/drivers/fpga/dfl.c
> @@ -558,6 +558,15 @@ int dfl_dev_get_vendor_net_cfg(struct dfl_device *dfl_dev)
>  }
>  EXPORT_SYMBOL_GPL(dfl_dev_get_vendor_net_cfg);
>  
> +struct device *dfl_dev_get_base_dev(struct dfl_device *dfl_dev)
> +{
> +	if (!dfl_dev || !dfl_dev->cdev)
> +		return NULL;
> +
> +	return dfl_dev->cdev->parent;
> +}
> +EXPORT_SYMBOL_GPL(dfl_dev_get_base_dev);

This name is awkward. maybe

dfl_dev_parent() or dfl_dev_base()


> +
>  #define is_header_feature(feature) ((feature)->id == FEATURE_ID_FIU_HEADER)
>  
>  /**
> diff --git a/include/linux/dfl.h b/include/linux/dfl.h
> index 5ee2b1e..dd313f2 100644
> --- a/include/linux/dfl.h
> +++ b/include/linux/dfl.h
> @@ -68,6 +68,7 @@ struct dfl_driver {
>  #define to_dfl_drv(d) container_of(d, struct dfl_driver, drv)
>  
>  int dfl_dev_get_vendor_net_cfg(struct dfl_device *dfl_dev);
> +struct device *dfl_dev_get_base_dev(struct dfl_device *dfl_dev);

Because this is an external interface these should have comments

This is another generic change and should be split out of the patchset.

I believe the generic changes would have an easier time being accepted and could be done in parallel as the harder part of the private features is worked out.

Tom

>  
>  /*
>   * use a macro to avoid include chaining to get THIS_MODULE.
Wu, Hao Oct. 26, 2020, 3:42 a.m. UTC | #2
> Subject: [RFC PATCH 3/6] fpga: dfl: add an API to get the base device for dfl
> device
> 
> This patch adds an API for dfl devices to find which physical device
> owns the DFL.
> 
> This patch makes preparation for supporting DFL Ether Group private
> feature driver. It uses this information to determine which retimer
> device physically connects to which ether group.
> 
> Signed-off-by: Xu Yilun <yilun.xu@intel.com>
> ---
>  drivers/fpga/dfl.c  | 9 +++++++++
>  include/linux/dfl.h | 1 +
>  2 files changed, 10 insertions(+)
> 
> diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
> index ca3c678..52d18e6 100644
> --- a/drivers/fpga/dfl.c
> +++ b/drivers/fpga/dfl.c
> @@ -558,6 +558,15 @@ int dfl_dev_get_vendor_net_cfg(struct dfl_device
> *dfl_dev)
>  }
>  EXPORT_SYMBOL_GPL(dfl_dev_get_vendor_net_cfg);
> 
> +struct device *dfl_dev_get_base_dev(struct dfl_device *dfl_dev)
> +{
> +	if (!dfl_dev || !dfl_dev->cdev)
> +		return NULL;
> +
> +	return dfl_dev->cdev->parent;
> +}
> +EXPORT_SYMBOL_GPL(dfl_dev_get_base_dev);

It may confuse people that this get doesn't require a put operation on
the base device. could we avoid this by using a different name?

And why it needs to know the physical device here? DFL hides the
physical device for upper layer drivers, so this is not the same case?
or cdev can be used instead here?

Thanks
Hao

> +
>  #define is_header_feature(feature) ((feature)->id ==
> FEATURE_ID_FIU_HEADER)
> 
>  /**
> diff --git a/include/linux/dfl.h b/include/linux/dfl.h
> index 5ee2b1e..dd313f2 100644
> --- a/include/linux/dfl.h
> +++ b/include/linux/dfl.h
> @@ -68,6 +68,7 @@ struct dfl_driver {
>  #define to_dfl_drv(d) container_of(d, struct dfl_driver, drv)
> 
>  int dfl_dev_get_vendor_net_cfg(struct dfl_device *dfl_dev);
> +struct device *dfl_dev_get_base_dev(struct dfl_device *dfl_dev);
> 
>  /*
>   * use a macro to avoid include chaining to get THIS_MODULE.
> --
> 2.7.4
diff mbox series

Patch

diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index ca3c678..52d18e6 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -558,6 +558,15 @@  int dfl_dev_get_vendor_net_cfg(struct dfl_device *dfl_dev)
 }
 EXPORT_SYMBOL_GPL(dfl_dev_get_vendor_net_cfg);
 
+struct device *dfl_dev_get_base_dev(struct dfl_device *dfl_dev)
+{
+	if (!dfl_dev || !dfl_dev->cdev)
+		return NULL;
+
+	return dfl_dev->cdev->parent;
+}
+EXPORT_SYMBOL_GPL(dfl_dev_get_base_dev);
+
 #define is_header_feature(feature) ((feature)->id == FEATURE_ID_FIU_HEADER)
 
 /**
diff --git a/include/linux/dfl.h b/include/linux/dfl.h
index 5ee2b1e..dd313f2 100644
--- a/include/linux/dfl.h
+++ b/include/linux/dfl.h
@@ -68,6 +68,7 @@  struct dfl_driver {
 #define to_dfl_drv(d) container_of(d, struct dfl_driver, drv)
 
 int dfl_dev_get_vendor_net_cfg(struct dfl_device *dfl_dev);
+struct device *dfl_dev_get_base_dev(struct dfl_device *dfl_dev);
 
 /*
  * use a macro to avoid include chaining to get THIS_MODULE.