Use -ENOSYS consistently
Subsystems (3)
cover Use -ENOSYS consistently
A few places use -ENOTSUPP when they should use -ENOSYS. In two cases both are used. This little series tidies this up.
Simon Glass (6):
usb: Return -ENOSYS when system call is not available
spi: Return -ENOSYS when system call is not available
tlv_eeprom: Return -ENOSYS when system call is not available
clk: Return -ENOSYS when system call is not available
simple-pm-bus: Use -ENOSYS for checking missing system call
pinctrl: Return -ENOSYS when system call is not available
drivers/clk/clk-composite.c | 8 ++++---- drivers/core/simple-pm-bus.c | 4 ++-- drivers/pinctrl/pinctrl-uclass.c | 10 ++++++---- drivers/usb/gadget/udc/udc-uclass.c | 2 +- include/spi-mem.h | 2 +- include/tlv_eeprom.h | 6 +++--- 6 files changed, 17 insertions(+), 15 deletions(-)
Signature · 1 line
2.31.0.rc2.261.g7f71774620-goog
PATCH 1/6 usb: Return -ENOSYS when system call is not available
Update usb_gadget_release() to use -ENOSYS, which is the correct error code for U-Boot.
---
drivers/usb/gadget/udc/udc-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/udc-uclass.c +1 -1
@@ -45,7 +45,7 @@ int usb_gadget_release(int index) dev_array[index] =NULL ;return ret;#else -return -ENOTSUPP ; +return -ENOSYS ;#endif }
Signature · 1 line
2.31.0.rc2.261.g7f71774620-goog
PATCH 1/6 usb: Return -ENOSYS when system call is not available
Quoted 2 lines · Simon Glass
Update
usb_gadget_release()to use-ENOSYS, which is the correct error code for U-Boot.
It would be good if you could explain _why_ this change is required. Why is ENOSYS the correct return value ? It is not clear from the patch description, sorry.
PATCH 1/6 usb: Return -ENOSYS when system call is not available
Hi Marek,
Quoted 8 lines · Marek Vasut
Quoted 2 lines · Simon Glass
Update
usb_gadget_release()to use-ENOSYS, which is the correct error code for U-Boot.It would be good if you could explain _why_ this change is required. Why is ENOSYS the correct return value ? It is not clear from the patch description, sorry.
That is the value used throughout driver model, so it is a convention. As per the cover letter and one on the patches, people are not sure which one to use, because -ENOTSUPP has crept in in a few places.
Regards,
Simon
PATCH 1/6 usb: Return -ENOSYS when system call is not available
Quoted 8 lines · Simon Glass
Hi Marek,
Quoted 5 lines · Marek Vasut
Quoted 2 lines · Simon Glass
Update
usb_gadget_release()to use-ENOSYS, which is the correct error code for U-Boot.
Quoted 7 lines
Quoted 3 lines
It would be good if you could explain _why_ this change is required. Why is ENOSYS the correct return value ? It is not clear from the patch description, sorry.
That is the value used throughout driver model, so it is a convention. As per the cover letter and one on the patches, people are not sure which one to use, because
-ENOTSUPPhas crept in in a few places.
I agree with Tom, this needs to be documented first, then the document should be agreed upon, and only then should these fixes follow.
PATCH 2/6 spi: Return -ENOSYS when system call is not available
In reply to Simon GlassUpdate spi_controller_dma_map_mem_op_data() to use -ENOSYS, which is the correct error code for U-Boot.
---
include/spi-mem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/spi-mem.h +1 -1
@@ -222,7 +222,7 @@ spi_controller_dma_map_mem_op_data(struct spi_controller *ctlr,const struct spi_mem_op *op, struct sg_table *sg) { - return -ENOTSUPP; + return -ENOSYS; } static inline void
Signature · 1 line
2.31.0.rc2.261.g7f71774620-goog
PATCH 3/6 tlv_eeprom: Return -ENOSYS when system call is not available
In reply to Simon GlassWhen CMD_TLV_EEPROM is not enabled, use -ENOSYS, which is the correct error code for U-Boot.
---
include/tlv_eeprom.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/tlv_eeprom.h +3 -3
@@ -114,19 +114,19 @@ int read_tlvinfo_tlv_eeprom(void *eeprom, struct tlvinfo_header **hdr,static inline int read_tlv_eeprom (void *eeprom,int offset,int len,int dev) { -return -ENOTSUPP ; +return -ENOSYS ; }static inline int write_tlv_eeprom (void *eeprom,int len) { -return -ENOTSUPP ; +return -ENOSYS ; }static inline int read_tlvinfo_tlv_eeprom (void *eeprom,struct tlvinfo_header **hdr,struct tlvinfo_tlv **first_entry,int dev) { -return -ENOTSUPP ; +return -ENOSYS ; }#endif /* CONFIG_IS_ENABLED(CMD_TLV_EEPROM) */
Signature · 1 line
2.31.0.rc2.261.g7f71774620-goog
PATCH 4/6 clk: Return -ENOSYS when system call is not available
In reply to Simon GlassUpdate clk_composite_set_parent() to use -ENOSYS, which is the correct error code for U-Boot. Also rearrange the code so that the error condition is clearly indicated and the function runs to the end in the normal case, since this is the common style in U-Boot.
---
drivers/clk/clk-composite.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clk/clk-composite.c +4 -4
@@ -37,10 +37,10 @@ static int clk_composite_set_parent(struct clk *clk, struct clk *parent)const struct clk_ops *mux_ops = composite->mux_ops;struct clk *mux = composite->mux; -if (mux && mux_ops) -return mux_ops->set_parent (mux, parent); -else -return -ENOTSUPP ; +if (!mux || !mux_ops) +return -ENOSYS ; + +return mux_ops->set_parent (mux, parent); }static unsigned long clk_composite_recalc_rate (struct clk *clk)
Signature · 1 line
2.31.0.rc2.261.g7f71774620-goog
PATCH 4/6 clk: Return -ENOSYS when system call is not available
Quoted 21 lines · Simon Glass
Update
clk_composite_set_parent()to use-ENOSYS, which is the correct error code for U-Boot. Also rearrange the code so that the error condition is clearly indicated and the function runs to the end in the normal case, since this is the common style in U-Boot.Signed-off-by Simon Glass <[email protected]>---
drivers/clk/clk-composite.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/clk/clk-composite.c +0
-1@@ -37,10 +37,10 @@ static int clk_composite_set_parent(struct clk *clk, struct clk *parent)const struct clk_ops *mux_ops = composite->mux_ops;struct clk *mux = composite->mux; -if (mux && mux_ops)
drivers/clk/clk-composite.c static int clk_composite_set_parent(struct clk *clk, struct clk *parent) · line 46
Quoted 10 lines
drivers/clk/clk-composite.c +4
-3-return mux_ops->set_parent (mux, parent); - else - return -ENOTSUPP; +if (!mux || !mux_ops) +return -ENOSYS ; + +return mux_ops->set_parent (mux, parent); }static unsigned long clk_composite_recalc_rate (struct clk *clk)
Will this be applied to the whole clock subsystem? From what I can tell, the clock subsystem returns ENOSYS in these situations, and drivers return ENOTSUPP. It would be great if we could unified all these so callers could check for one return value.
--Sean
PATCH 4/6 clk: Return -ENOSYS when system call is not available
Hi Seam,
Quoted 37 lines · Sean Anderson
Quoted 21 lines · Simon Glass
Update
clk_composite_set_parent()to use-ENOSYS, which is the correct error code for U-Boot. Also rearrange the code so that the error condition is clearly indicated and the function runs to the end in the normal case, since this is the common style in U-Boot.Signed-off-by Simon Glass <[email protected]>---
drivers/clk/clk-composite.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/clk/clk-composite.c +0
-1@@ -37,10 +37,10 @@ static int clk_composite_set_parent(struct clk *clk, struct clk *parent)const struct clk_ops *mux_ops = composite->mux_ops;struct clk *mux = composite->mux; -if (mux && mux_ops)drivers/clk/clk-composite.c static int clk_composite_set_parent(struct clk *clk, struct clk *parent) · line 46
Quoted 10 lines
drivers/clk/clk-composite.c +4
-3-return mux_ops->set_parent (mux, parent); - else - return -ENOTSUPP; +if (!mux || !mux_ops) +return -ENOSYS ; + +return mux_ops->set_parent (mux, parent); }static unsigned long clk_composite_recalc_rate (struct clk *clk)Reviewed-by Sean Anderson <[email protected]>
Quoted 4 lines
Will this be applied to the whole clock subsystem? From what I can tell, the clock subsystem returns ENOSYS in these situations, and drivers return ENOTSUPP. It would be great if we could unified all these so callers could check for one return value.
Most drivers use -EINVAL for an invalid / unknown clock, whereas -ENOSYS is for an unimplemented method or sub-method.
So I'll add a patch to use -EINVAL consistently.
Regards,
Simon
PATCH 5/6 simple-pm-bus: Use -ENOSYS for checking missing system call
In reply to Simon GlassWe don't need to check -ENOTSUPP since this is not used for this purpose in U-Boot. Update the code accordingly.
---
drivers/core/simple-pm-bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/core/simple-pm-bus.c +2 -2
@@ -21,7 +21,7 @@ static int simple_pm_bus_probe(struct udevice *dev)return ret; ret =clk_enable_bulk (bulk); -if (ret && ret != -ENOSYS && ret != -ENOTSUPP ) { +if (ret && ret != -ENOSYS ) {clk_release_bulk (bulk);return ret; }
@@ -34,7 +34,7 @@ static int simple_pm_bus_remove(struct udevice *dev)struct clk_bulk *bulk =dev_get_priv (dev); ret =clk_release_bulk (bulk); -if (ret && ret != -ENOSYS && ret != -ENOTSUPP ) +if (ret && ret != -ENOSYS )return ret;else return 0 ;
Signature · 1 line
2.31.0.rc2.261.g7f71774620-goog
PATCH 5/6 simple-pm-bus: Use -ENOSYS for checking missing system call
Quoted 24 lines · Simon Glass
We don't need to check
-ENOTSUPPsince this is not used for this purpose in U-Boot. Update the code accordingly.Signed-off-by Simon Glass <[email protected]>---
drivers/core/simple-pm-bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/core/simple-pm-bus.c +1
-1@@ -21,7 +21,7 @@ static int simple_pm_bus_probe(struct udevice *dev)return ret; ret =clk_enable_bulk (bulk); -if (ret && ret != -ENOSYS && ret != -ENOTSUPP ) { +if (ret && ret != -ENOSYS ) {clk_release_bulk (bulk);return ret; }
drivers/core/simple-pm-bus.c static int simple_pm_bus_remove(struct udevice *dev) · line 40
Quoted 8 lines
drivers/core/simple-pm-bus.c +1
-1@@ -34,7 +34,7 @@ static int simple_pm_bus_remove(struct udevice *dev)struct clk_bulk *bulk =dev_get_priv (dev); ret =clk_release_bulk (bulk); -if (ret && ret != -ENOSYS && ret != -ENOTSUPP ) +if (ret && ret != -ENOSYS )return ret;else return 0 ;
Nak. This cannot be removed until all drivers have been converted to use -ENOSYS.
--Sean
PATCH 6/6 pinctrl: Return -ENOSYS when system call is not available
In reply to Simon GlassUpdate the code to use -ENOSYS, which is the correct error code for an unimplemented system call in U-Boot.
Also we should not check for a missing operations array as this is not permitted. For now this can be covered by an assert().
---
drivers/pinctrl/pinctrl-uclass.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/pinctrl/pinctrl-uclass.c +6 -4
@@ -235,8 +235,9 @@ int pinctrl_gpio_request(struct udevice *dev, unsigned offset)return ret; ops =pinctrl_get_ops (pctldev); -if (!ops || !ops->gpio_request_enable) -return -ENOTSUPP ; +assert (ops); +if (!ops->gpio_request_enable) +return -ENOSYS ;return ops->gpio_request_enable (pctldev, pin_selector); }
@@ -261,8 +262,9 @@ int pinctrl_gpio_free(struct udevice *dev, unsigned offset)return ret; ops =pinctrl_get_ops (pctldev); -if (!ops || !ops->gpio_disable_free) -return -ENOTSUPP ; +assert (ops); +if (!ops->gpio_disable_free) +return -ENOSYS ;return ops->gpio_disable_free (pctldev, pin_selector); }
Signature · 1 line
2.31.0.rc2.261.g7f71774620-goog
cover Use -ENOSYS consistently
In reply to Simon GlassQuoted 12 lines · Simon Glass
A few places use
-ENOTSUPPwhen they should use-ENOSYS. In two cases both are used. This little series tidies this up.Simon Glass (6):
usb: Return-ENOSYSwhen system call is not available
spi: Return-ENOSYSwhen system call is not available
tlv_eeprom: Return-ENOSYSwhen system call is not available
clk: Return-ENOSYSwhen system call is not available
simple-pm-bus: Use-ENOSYSfor checking missing system call
pinctrl: Return-ENOSYSwhen system call is not available
Quoted 7 lines
drivers/clk/clk-composite.c | 8 ++++---- drivers/core/simple-pm-bus.c | 4 ++-- drivers/pinctrl/pinctrl-uclass.c | 10 ++++++---- drivers/usb/gadget/udc/udc-uclass.c | 2 +- include/spi-mem.h | 2 +- include/tlv_eeprom.h | 6 +++--- 6 files changed, 17 insertions(+), 15 deletions(-)
I think we need to start this series with a doc update that makes it
clear why this is correct and when it should be used. There's two
instances of "ENOSYS" in doc/driver-model/ today and neither explains why this series is correct (which I'm sure it is). Thanks.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210321/f063b944/attachment.sig>