Message ID | 20210426132632.10221-1-linux.amoon@gmail.com |
---|---|
State | Changes Requested |
Delegated to: | Kever Yang |
Headers | show |
Series | [1/3] pci: pcie_dw_rockchip: Fixed the below compilation error | expand |
Am Mon, Apr 26, 2021 at 01:26:30PM +0000 schrieb Anand Moon: > Use the Error values that may be returned by PCI functions > Added the error macro from linux/include/linux/pci.h > > drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_read': > drivers/pci/pcie_dw_rockchip.c:70:10: error: 'PCIBIOS_UNSUPPORTED' > undeclared (first use in this function) > 70 | return PCIBIOS_UNSUPPORTED; > | ^~~~~~~~~~~~~~~~~~~ > drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_write': > drivers/pci/pcie_dw_rockchip.c:90:10: error: 'PCIBIOS_UNSUPPORTED' > undeclared (first use in this function) > 90 | return PCIBIOS_UNSUPPORTED; > | ^~~~~~~~~~~~~~~~~~~ > > Cc: Neil Armstrong <narmstrong@baylibre.com> > Cc: Kever Yang <kever.yang@rock-chips.com> > Signed-off-by: Anand Moon <linux.amoon@gmail.com> > --- > drivers/pci/pcie_dw_common.h | 9 +++++++++ > drivers/pci/pcie_dw_rockchip.c | 4 ++-- > 2 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/pcie_dw_common.h b/drivers/pci/pcie_dw_common.h > index 6b701645af..ba5feb5b51 100644 > --- a/drivers/pci/pcie_dw_common.h > +++ b/drivers/pci/pcie_dw_common.h > @@ -90,6 +90,15 @@ > #define PCIE_MISC_CONTROL_1_OFF 0x8bc > #define PCIE_DBI_RO_WR_EN BIT(0) > > +/* Error values that may be returned by PCI functions */ > +#define PCIBIOS_SUCCESSFUL 0x00 > +#define PCIBIOS_FUNC_NOT_SUPPORTED 0x81 > +#define PCIBIOS_BAD_VENDOR_ID 0x83 > +#define PCIBIOS_DEVICE_NOT_FOUND 0x86 > +#define PCIBIOS_BAD_REGISTER_NUMBER 0x87 > +#define PCIBIOS_SET_FAILED 0x88 > +#define PCIBIOS_BUFFER_TOO_SMALL 0x89 > + > /* Parameters for the waiting for iATU enabled routine */ > #define LINK_WAIT_MAX_IATU_RETRIES 5 > #define LINK_WAIT_IATU 10000 > diff --git a/drivers/pci/pcie_dw_rockchip.c b/drivers/pci/pcie_dw_rockchip.c > index bc22af4230..9702b40019 100644 > --- a/drivers/pci/pcie_dw_rockchip.c > +++ b/drivers/pci/pcie_dw_rockchip.c > @@ -67,7 +67,7 @@ static int rk_pcie_read(void __iomem *addr, int size, u32 *val) > { > if ((uintptr_t)addr & (size - 1)) { > *val = 0; > - return PCIBIOS_UNSUPPORTED; > + return PCIBIOS_BAD_REGISTER_NUMBER; Since this function seems to return normal error code, why not use -EINVAL? Or even better -EOPNOTSUP? The callers only check for != 0 anyway. > } > > if (size == 4) { > @@ -87,7 +87,7 @@ static int rk_pcie_read(void __iomem *addr, int size, u32 *val) > static int rk_pcie_write(void __iomem *addr, int size, u32 val) > { > if ((uintptr_t)addr & (size - 1)) > - return PCIBIOS_UNSUPPORTED; > + return PCIBIOS_BAD_REGISTER_NUMBER; > > if (size == 4) > writel(val, addr); > -- > 2.31.1 >
Hi Patrick, On Tue, 27 Apr 2021 at 01:40, Patrick Wildt <patrick@blueri.se> wrote: > > Am Mon, Apr 26, 2021 at 01:26:30PM +0000 schrieb Anand Moon: > > Use the Error values that may be returned by PCI functions > > Added the error macro from linux/include/linux/pci.h > > > > drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_read': > > drivers/pci/pcie_dw_rockchip.c:70:10: error: 'PCIBIOS_UNSUPPORTED' > > undeclared (first use in this function) > > 70 | return PCIBIOS_UNSUPPORTED; > > | ^~~~~~~~~~~~~~~~~~~ > > drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_write': > > drivers/pci/pcie_dw_rockchip.c:90:10: error: 'PCIBIOS_UNSUPPORTED' > > undeclared (first use in this function) > > 90 | return PCIBIOS_UNSUPPORTED; > > | ^~~~~~~~~~~~~~~~~~~ > > > > Cc: Neil Armstrong <narmstrong@baylibre.com> > > Cc: Kever Yang <kever.yang@rock-chips.com> > > Signed-off-by: Anand Moon <linux.amoon@gmail.com> > > --- > > drivers/pci/pcie_dw_common.h | 9 +++++++++ > > drivers/pci/pcie_dw_rockchip.c | 4 ++-- > > 2 files changed, 11 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/pci/pcie_dw_common.h b/drivers/pci/pcie_dw_common.h > > index 6b701645af..ba5feb5b51 100644 > > --- a/drivers/pci/pcie_dw_common.h > > +++ b/drivers/pci/pcie_dw_common.h > > @@ -90,6 +90,15 @@ > > #define PCIE_MISC_CONTROL_1_OFF 0x8bc > > #define PCIE_DBI_RO_WR_EN BIT(0) > > > > +/* Error values that may be returned by PCI functions */ > > +#define PCIBIOS_SUCCESSFUL 0x00 > > +#define PCIBIOS_FUNC_NOT_SUPPORTED 0x81 > > +#define PCIBIOS_BAD_VENDOR_ID 0x83 > > +#define PCIBIOS_DEVICE_NOT_FOUND 0x86 > > +#define PCIBIOS_BAD_REGISTER_NUMBER 0x87 > > +#define PCIBIOS_SET_FAILED 0x88 > > +#define PCIBIOS_BUFFER_TOO_SMALL 0x89 > > + > > /* Parameters for the waiting for iATU enabled routine */ > > #define LINK_WAIT_MAX_IATU_RETRIES 5 > > #define LINK_WAIT_IATU 10000 > > diff --git a/drivers/pci/pcie_dw_rockchip.c b/drivers/pci/pcie_dw_rockchip.c > > index bc22af4230..9702b40019 100644 > > --- a/drivers/pci/pcie_dw_rockchip.c > > +++ b/drivers/pci/pcie_dw_rockchip.c > > @@ -67,7 +67,7 @@ static int rk_pcie_read(void __iomem *addr, int size, u32 *val) > > { > > if ((uintptr_t)addr & (size - 1)) { > > *val = 0; > > - return PCIBIOS_UNSUPPORTED; > > + return PCIBIOS_BAD_REGISTER_NUMBER; > > Since this function seems to return normal error code, why not use > -EINVAL? Or even better -EOPNOTSUP? The callers only check for != 0 > anyway. > Thanks for your review comments. -EOPNOTSUPP It seems to be the correct return code over here. -Anand
On 2021/4/26 下午9:26, Anand Moon wrote: > Use the Error values that may be returned by PCI functions > Added the error macro from linux/include/linux/pci.h > > drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_read': > drivers/pci/pcie_dw_rockchip.c:70:10: error: 'PCIBIOS_UNSUPPORTED' > undeclared (first use in this function) > 70 | return PCIBIOS_UNSUPPORTED; > | ^~~~~~~~~~~~~~~~~~~ > drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_write': > drivers/pci/pcie_dw_rockchip.c:90:10: error: 'PCIBIOS_UNSUPPORTED' > undeclared (first use in this function) > 90 | return PCIBIOS_UNSUPPORTED; > | ^~~~~~~~~~~~~~~~~~~ > > Cc: Neil Armstrong <narmstrong@baylibre.com> > Cc: Kever Yang <kever.yang@rock-chips.com> > Signed-off-by: Anand Moon <linux.amoon@gmail.com> Reviewed-by: Kever Yang <kever.yang@rock-chips.com> Thanks, - Kever > --- > drivers/pci/pcie_dw_common.h | 9 +++++++++ > drivers/pci/pcie_dw_rockchip.c | 4 ++-- > 2 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/pcie_dw_common.h b/drivers/pci/pcie_dw_common.h > index 6b701645af..ba5feb5b51 100644 > --- a/drivers/pci/pcie_dw_common.h > +++ b/drivers/pci/pcie_dw_common.h > @@ -90,6 +90,15 @@ > #define PCIE_MISC_CONTROL_1_OFF 0x8bc > #define PCIE_DBI_RO_WR_EN BIT(0) > > +/* Error values that may be returned by PCI functions */ > +#define PCIBIOS_SUCCESSFUL 0x00 > +#define PCIBIOS_FUNC_NOT_SUPPORTED 0x81 > +#define PCIBIOS_BAD_VENDOR_ID 0x83 > +#define PCIBIOS_DEVICE_NOT_FOUND 0x86 > +#define PCIBIOS_BAD_REGISTER_NUMBER 0x87 > +#define PCIBIOS_SET_FAILED 0x88 > +#define PCIBIOS_BUFFER_TOO_SMALL 0x89 > + > /* Parameters for the waiting for iATU enabled routine */ > #define LINK_WAIT_MAX_IATU_RETRIES 5 > #define LINK_WAIT_IATU 10000 > diff --git a/drivers/pci/pcie_dw_rockchip.c b/drivers/pci/pcie_dw_rockchip.c > index bc22af4230..9702b40019 100644 > --- a/drivers/pci/pcie_dw_rockchip.c > +++ b/drivers/pci/pcie_dw_rockchip.c > @@ -67,7 +67,7 @@ static int rk_pcie_read(void __iomem *addr, int size, u32 *val) > { > if ((uintptr_t)addr & (size - 1)) { > *val = 0; > - return PCIBIOS_UNSUPPORTED; > + return PCIBIOS_BAD_REGISTER_NUMBER; > } > > if (size == 4) { > @@ -87,7 +87,7 @@ static int rk_pcie_read(void __iomem *addr, int size, u32 *val) > static int rk_pcie_write(void __iomem *addr, int size, u32 val) > { > if ((uintptr_t)addr & (size - 1)) > - return PCIBIOS_UNSUPPORTED; > + return PCIBIOS_BAD_REGISTER_NUMBER; > > if (size == 4) > writel(val, addr);
H Kever, On Fri, 21 May 2021 at 18:51, Kever Yang <kever.yang@rock-chips.com> wrote: > > > On 2021/4/26 下午9:26, Anand Moon wrote: > > Use the Error values that may be returned by PCI functions > > Added the error macro from linux/include/linux/pci.h > > > > drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_read': > > drivers/pci/pcie_dw_rockchip.c:70:10: error: 'PCIBIOS_UNSUPPORTED' > > undeclared (first use in this function) > > 70 | return PCIBIOS_UNSUPPORTED; > > | ^~~~~~~~~~~~~~~~~~~ > > drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_write': > > drivers/pci/pcie_dw_rockchip.c:90:10: error: 'PCIBIOS_UNSUPPORTED' > > undeclared (first use in this function) > > 90 | return PCIBIOS_UNSUPPORTED; > > | ^~~~~~~~~~~~~~~~~~~ > > > > Cc: Neil Armstrong <narmstrong@baylibre.com> > > Cc: Kever Yang <kever.yang@rock-chips.com> > > Signed-off-by: Anand Moon <linux.amoon@gmail.com> > > > Reviewed-by: Kever Yang <kever.yang@rock-chips.com> > Oops, I forgot to send the revised version of these patches. > Thanks, > > - Kever
diff --git a/drivers/pci/pcie_dw_common.h b/drivers/pci/pcie_dw_common.h index 6b701645af..ba5feb5b51 100644 --- a/drivers/pci/pcie_dw_common.h +++ b/drivers/pci/pcie_dw_common.h @@ -90,6 +90,15 @@ #define PCIE_MISC_CONTROL_1_OFF 0x8bc #define PCIE_DBI_RO_WR_EN BIT(0) +/* Error values that may be returned by PCI functions */ +#define PCIBIOS_SUCCESSFUL 0x00 +#define PCIBIOS_FUNC_NOT_SUPPORTED 0x81 +#define PCIBIOS_BAD_VENDOR_ID 0x83 +#define PCIBIOS_DEVICE_NOT_FOUND 0x86 +#define PCIBIOS_BAD_REGISTER_NUMBER 0x87 +#define PCIBIOS_SET_FAILED 0x88 +#define PCIBIOS_BUFFER_TOO_SMALL 0x89 + /* Parameters for the waiting for iATU enabled routine */ #define LINK_WAIT_MAX_IATU_RETRIES 5 #define LINK_WAIT_IATU 10000 diff --git a/drivers/pci/pcie_dw_rockchip.c b/drivers/pci/pcie_dw_rockchip.c index bc22af4230..9702b40019 100644 --- a/drivers/pci/pcie_dw_rockchip.c +++ b/drivers/pci/pcie_dw_rockchip.c @@ -67,7 +67,7 @@ static int rk_pcie_read(void __iomem *addr, int size, u32 *val) { if ((uintptr_t)addr & (size - 1)) { *val = 0; - return PCIBIOS_UNSUPPORTED; + return PCIBIOS_BAD_REGISTER_NUMBER; } if (size == 4) { @@ -87,7 +87,7 @@ static int rk_pcie_read(void __iomem *addr, int size, u32 *val) static int rk_pcie_write(void __iomem *addr, int size, u32 val) { if ((uintptr_t)addr & (size - 1)) - return PCIBIOS_UNSUPPORTED; + return PCIBIOS_BAD_REGISTER_NUMBER; if (size == 4) writel(val, addr);
Use the Error values that may be returned by PCI functions Added the error macro from linux/include/linux/pci.h drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_read': drivers/pci/pcie_dw_rockchip.c:70:10: error: 'PCIBIOS_UNSUPPORTED' undeclared (first use in this function) 70 | return PCIBIOS_UNSUPPORTED; | ^~~~~~~~~~~~~~~~~~~ drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_write': drivers/pci/pcie_dw_rockchip.c:90:10: error: 'PCIBIOS_UNSUPPORTED' undeclared (first use in this function) 90 | return PCIBIOS_UNSUPPORTED; | ^~~~~~~~~~~~~~~~~~~ Cc: Neil Armstrong <narmstrong@baylibre.com> Cc: Kever Yang <kever.yang@rock-chips.com> Signed-off-by: Anand Moon <linux.amoon@gmail.com> --- drivers/pci/pcie_dw_common.h | 9 +++++++++ drivers/pci/pcie_dw_rockchip.c | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-)