[02/14] bus/pci: add const to some experimental API
Checks
Commit Message
Those functions are fine with a const on the device pointer.
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
drivers/bus/pci/pci_common.c | 4 ++--
drivers/bus/pci/rte_bus_pci.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
Comments
On Thu, Aug 03, 2023 at 09:50:25AM +0200, David Marchand wrote:
> Those functions are fine with a const on the device pointer.
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> drivers/bus/pci/pci_common.c | 4 ++--
> drivers/bus/pci/rte_bus_pci.h | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
> index 52404ab0fe..382b0b8946 100644
> --- a/drivers/bus/pci/pci_common.c
> +++ b/drivers/bus/pci/pci_common.c
> @@ -814,7 +814,7 @@ rte_pci_get_iommu_class(void)
> }
>
> off_t
> -rte_pci_find_ext_capability(struct rte_pci_device *dev, uint32_t cap)
> +rte_pci_find_ext_capability(const struct rte_pci_device *dev, uint32_t cap)
> {
> off_t offset = RTE_PCI_CFG_SPACE_SIZE;
> uint32_t header;
> @@ -857,7 +857,7 @@ rte_pci_find_ext_capability(struct rte_pci_device *dev, uint32_t cap)
> }
>
> int
> -rte_pci_set_bus_master(struct rte_pci_device *dev, bool enable)
> +rte_pci_set_bus_master(const struct rte_pci_device *dev, bool enable)
> {
> uint16_t old_cmd, cmd;
>
While generally I'm a big fan of using const everywhere we can, I wonder if
this is confusing here, since you are changing a setting, i.e. it's not
a read-only function.
That said, since const works, I have no strong objection to going with it.
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
On Thu, Aug 3, 2023 at 11:47 AM Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> On Thu, Aug 03, 2023 at 09:50:25AM +0200, David Marchand wrote:
> > Those functions are fine with a const on the device pointer.
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > ---
> > drivers/bus/pci/pci_common.c | 4 ++--
> > drivers/bus/pci/rte_bus_pci.h | 4 ++--
> > 2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
> > index 52404ab0fe..382b0b8946 100644
> > --- a/drivers/bus/pci/pci_common.c
> > +++ b/drivers/bus/pci/pci_common.c
> > @@ -814,7 +814,7 @@ rte_pci_get_iommu_class(void)
> > }
> >
> > off_t
> > -rte_pci_find_ext_capability(struct rte_pci_device *dev, uint32_t cap)
> > +rte_pci_find_ext_capability(const struct rte_pci_device *dev, uint32_t cap)
> > {
> > off_t offset = RTE_PCI_CFG_SPACE_SIZE;
> > uint32_t header;
> > @@ -857,7 +857,7 @@ rte_pci_find_ext_capability(struct rte_pci_device *dev, uint32_t cap)
> > }
> >
> > int
> > -rte_pci_set_bus_master(struct rte_pci_device *dev, bool enable)
> > +rte_pci_set_bus_master(const struct rte_pci_device *dev, bool enable)
> > {
> > uint16_t old_cmd, cmd;
> >
>
> While generally I'm a big fan of using const everywhere we can, I wonder if
> this is confusing here, since you are changing a setting, i.e. it's not
> a read-only function.
Changing a setting in the underlying hardware, yes, but the C object
is left untouched.
@@ -814,7 +814,7 @@ rte_pci_get_iommu_class(void)
}
off_t
-rte_pci_find_ext_capability(struct rte_pci_device *dev, uint32_t cap)
+rte_pci_find_ext_capability(const struct rte_pci_device *dev, uint32_t cap)
{
off_t offset = RTE_PCI_CFG_SPACE_SIZE;
uint32_t header;
@@ -857,7 +857,7 @@ rte_pci_find_ext_capability(struct rte_pci_device *dev, uint32_t cap)
}
int
-rte_pci_set_bus_master(struct rte_pci_device *dev, bool enable)
+rte_pci_set_bus_master(const struct rte_pci_device *dev, bool enable)
{
uint16_t old_cmd, cmd;
@@ -85,7 +85,7 @@ void rte_pci_dump(FILE *f);
* = 0: Device does not support it.
*/
__rte_experimental
-off_t rte_pci_find_ext_capability(struct rte_pci_device *dev, uint32_t cap);
+off_t rte_pci_find_ext_capability(const struct rte_pci_device *dev, uint32_t cap);
/**
* Enables/Disables Bus Master for device's PCI command register.
@@ -99,7 +99,7 @@ off_t rte_pci_find_ext_capability(struct rte_pci_device *dev, uint32_t cap);
* 0 on success, -1 on error in PCI config space read/write.
*/
__rte_experimental
-int rte_pci_set_bus_master(struct rte_pci_device *dev, bool enable);
+int rte_pci_set_bus_master(const struct rte_pci_device *dev, bool enable);
/**
* Read PCI config space.