[PATCH 0/3] Clarify standalone application support

While looking into the support for u-boot standalone applications I noticed that there was some mis-alignment between the license exception and the files which needed to be included to get a functioning application. I also noticed that the set of SPI access functions defined in the jump table was missing a key function and did not match the set of prototypes defined in the exports header. These patches should rectify the issues I found.
Paul Barker (3): Licenses: Clarify exceptions for standalone apps examples: hello_world: Drop inclusion of common header exports: Fix export of SPI access functions
Licenses/Exceptions | 12 ++++++++---- examples/standalone/hello_world.c | 1 - include/_exports.h | 4 ++++ include/exports.h | 15 ++++++++++++++- 4 files changed, 26 insertions(+), 6 deletions(-)

On 2010-01-27, an email [1] was sent to the mailing list by Wolfgang Denk which clarified the intended licensing exceptions for standalone applications. As the "export.h" header and the "stubs.c" source files are required to implement a standalone application, the intention was that these files be covered by the licensing exception. This is made clear in the following quotes from that email:
"exports.h" should be added to the "allowed" file list; there should be no need to include "common.h". Eventually this needs fixing. Patches are welcome.
"examples/standalone/stubs.c" should be added to the "allowed" file list (the ppc_*jmp.S files are LGPLed).
There should be no doubts - the intention is clear, the current state may need improvement. Help (read: patches) welcome.
[1]: https://lists.denx.de/pipermail/u-boot/2010-January/067174.html
Signed-off-by: Paul Barker paul.barker@sancloud.com Cc: Wolfgang Denk wd@denx.de --- Licenses/Exceptions | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/Licenses/Exceptions b/Licenses/Exceptions index c9b3cd981f51..4f241f4aff29 100644 --- a/Licenses/Exceptions +++ b/Licenses/Exceptions @@ -7,9 +7,13 @@ use U-Boot services by means of the jump table provided by U-Boot exactly for this purpose - this is merely considered normal use of U-Boot, and does *not* fall under the heading of "derived work".
- The header files "include/image.h" and "arch/*/include/asm/u-boot.h" -define interfaces to U-Boot. Including these (unmodified) header -files in another file is considered normal use of U-Boot, and does -*not* fall under the heading of "derived work". +The following files define interfaces to U-Boot: + * include/image.h + * include/export.h + * arch/*/include/asm/u-boot.h + * examples/standalone/stubs.c + +Including these (unmodified) files in another file is considered normal +use of U-Boot, and does *not* fall under the heading of "derived work". -- Wolfgang Denk

On Thu, May 05, 2022 at 03:32:40PM +0000, Paul Barker wrote:
On 2010-01-27, an email [1] was sent to the mailing list by Wolfgang Denk which clarified the intended licensing exceptions for standalone applications. As the "export.h" header and the "stubs.c" source files are required to implement a standalone application, the intention was that these files be covered by the licensing exception. This is made clear in the following quotes from that email:
"exports.h" should be added to the "allowed" file list; there should be no need to include "common.h". Eventually this needs fixing. Patches are welcome.
"examples/standalone/stubs.c" should be added to the "allowed" file list (the ppc_*jmp.S files are LGPLed).
There should be no doubts - the intention is clear, the current state may need improvement. Help (read: patches) welcome.
Signed-off-by: Paul Barker paul.barker@sancloud.com Cc: Wolfgang Denk wd@denx.de
Licenses/Exceptions | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/Licenses/Exceptions b/Licenses/Exceptions index c9b3cd981f51..4f241f4aff29 100644 --- a/Licenses/Exceptions +++ b/Licenses/Exceptions @@ -7,9 +7,13 @@ use U-Boot services by means of the jump table provided by U-Boot exactly for this purpose - this is merely considered normal use of U-Boot, and does *not* fall under the heading of "derived work".
- The header files "include/image.h" and "arch/*/include/asm/u-boot.h"
-define interfaces to U-Boot. Including these (unmodified) header -files in another file is considered normal use of U-Boot, and does -*not* fall under the heading of "derived work". +The following files define interfaces to U-Boot:
- include/image.h
- include/export.h
- arch/*/include/asm/u-boot.h
- examples/standalone/stubs.c
+Including these (unmodified) files in another file is considered normal +use of U-Boot, and does *not* fall under the heading of "derived work". -- Wolfgang Denk
Wolfgang?

Dear Paul Barker,
In message 20220505153242.1598807-2-paul.barker@sancloud.com you wrote:
On 2010-01-27, an email [1] was sent to the mailing list by Wolfgang Denk which clarified the intended licensing exceptions for standalone applications. As the "export.h" header and the "stubs.c" source files are required to implement a standalone application, the intention was that these files be covered by the licensing exception. This is made clear in the following quotes from that email:
"exports.h" should be added to the "allowed" file list; there should be no need to include "common.h". Eventually this needs fixing. Patches are welcome.
"examples/standalone/stubs.c" should be added to the "allowed" file list (the ppc_*jmp.S files are LGPLed).
There should be no doubts - the intention is clear, the current state may need improvement. Help (read: patches) welcome.
Signed-off-by: Paul Barker paul.barker@sancloud.com Cc: Wolfgang Denk wd@denx.de
Acked-by: Wolfgang Denk wd@denx.de
Best regards,
Wolfgang Denk

On Thu, May 05, 2022 at 03:32:40PM +0000, Paul Barker wrote:
On 2010-01-27, an email [1] was sent to the mailing list by Wolfgang Denk which clarified the intended licensing exceptions for standalone applications. As the "export.h" header and the "stubs.c" source files are required to implement a standalone application, the intention was that these files be covered by the licensing exception. This is made clear in the following quotes from that email:
"exports.h" should be added to the "allowed" file list; there should be no need to include "common.h". Eventually this needs fixing. Patches are welcome.
"examples/standalone/stubs.c" should be added to the "allowed" file list (the ppc_*jmp.S files are LGPLed).
There should be no doubts - the intention is clear, the current state may need improvement. Help (read: patches) welcome.
Signed-off-by: Paul Barker paul.barker@sancloud.com Cc: Wolfgang Denk wd@denx.de Acked-by: Wolfgang Denk wd@denx.de
Applied to u-boot/master, thanks!

The "common.h" header is not covered by the licensing exception for standalone applications. Let's drop inclusion of this header from the hello_world example to prove that a standalone app can be built without it.
Signed-off-by: Paul Barker paul.barker@sancloud.com --- examples/standalone/hello_world.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/examples/standalone/hello_world.c b/examples/standalone/hello_world.c index 263cd9ca079d..27ec3793155d 100644 --- a/examples/standalone/hello_world.c +++ b/examples/standalone/hello_world.c @@ -4,7 +4,6 @@ * Wolfgang Denk, DENX Software Engineering, wd@denx.de. */
-#include <common.h> #include <exports.h>
int hello_world(int argc, char *const argv[])

On Thu, May 05, 2022 at 03:32:41PM +0000, Paul Barker wrote:
The "common.h" header is not covered by the licensing exception for standalone applications. Let's drop inclusion of this header from the hello_world example to prove that a standalone app can be built without it.
Signed-off-by: Paul Barker paul.barker@sancloud.com
Reviewed-by: Tom Rini trini@konsulko.com

Dear Paul,
In message 20220505153242.1598807-3-paul.barker@sancloud.com you wrote:
The "common.h" header is not covered by the licensing exception for standalone applications. Let's drop inclusion of this header from the hello_world example to prove that a standalone app can be built without it.
Signed-off-by: Paul Barker paul.barker@sancloud.com
examples/standalone/hello_world.c | 1 - 1 file changed, 1 deletion(-)
Acked-off-by: Wolfgang Denk wd@denx.de
Best regards,
Wolfgang Denk

On Thu, May 05, 2022 at 03:32:41PM +0000, Paul Barker wrote:
The "common.h" header is not covered by the licensing exception for standalone applications. Let's drop inclusion of this header from the hello_world example to prove that a standalone app can be built without it.
Signed-off-by: Paul Barker paul.barker@sancloud.com Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot/master, thanks!

* With CONFIG_DM_SPI defined, spi_get_bus_and_cs needs to be used instead of spi_setup_slave to configure a SPI bus. As spi_setup_slave is already present in the export list it is reasonable to also export spi_get_bus_and_cs.
* For the functions listed in the jump table to be callable they must also be defined in the "exports.h" header. Define the various exported SPI functions so that they can be used.
Signed-off-by: Paul Barker paul.barker@sancloud.com --- include/_exports.h | 4 ++++ include/exports.h | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/include/_exports.h b/include/_exports.h index f6df8b610734..3457a92c95ad 100644 --- a/include/_exports.h +++ b/include/_exports.h @@ -60,11 +60,15 @@ EXPORT_FUNC(dummy, void, spi_claim_bus, void) EXPORT_FUNC(dummy, void, spi_release_bus, void) EXPORT_FUNC(dummy, void, spi_xfer, void) + EXPORT_FUNC(dummy, void, spi_get_bus_and_cs, void) #else EXPORT_FUNC(spi_claim_bus, int, spi_claim_bus, struct spi_slave *) EXPORT_FUNC(spi_release_bus, void, spi_release_bus, struct spi_slave *) EXPORT_FUNC(spi_xfer, int, spi_xfer, struct spi_slave *, unsigned int, const void *, void *, unsigned long) + EXPORT_FUNC(spi_get_bus_and_cs, int, spi_get_bus_and_cs, int, int, int, + int, const char *, const char *, struct udevice **, + struct spi_slave **) #endif EXPORT_FUNC(ustrtoul, unsigned long, ustrtoul, const char *, char **, unsigned int) diff --git a/include/exports.h b/include/exports.h index 6f8c9cf4517e..93110d63a235 100644 --- a/include/exports.h +++ b/include/exports.h @@ -53,6 +53,19 @@ unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base); int i2c_write (uchar, uint, int , uchar* , int); int i2c_read (uchar, uint, int , uchar* , int); #endif +#ifdef CONFIG_CMD_SPI +#ifndef CONFIG_DM_SPI +struct spi_slave * spi_setup_slave(unsigned int, unsigned int, + unsigned int, unsigned int); +void spi_free_slave(struct spi_slave *); +#endif +int spi_claim_bus(struct spi_slave *); +void spi_release_bus(struct spi_slave *); +int spi_xfer(struct spi_slave *, unsigned int, const void *, void *, + unsigned long); +int spi_get_bus_and_cs(int, int, int, int, const char *, const char *, + struct udevice **, struct spi_slave **); +#endif #ifdef CONFIG_PHY_AQUANTIA struct mii_dev *mdio_get_current_dev(void); struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask); @@ -71,7 +84,7 @@ struct jt_funcs { };
-#define XF_VERSION 9 +#define XF_VERSION 10
#if defined(CONFIG_X86) extern gd_t *global_data;

On Thu, May 05, 2022 at 03:32:42PM +0000, Paul Barker wrote:
- With CONFIG_DM_SPI defined, spi_get_bus_and_cs needs to be used
instead of spi_setup_slave to configure a SPI bus. As spi_setup_slave is already present in the export list it is reasonable to also export spi_get_bus_and_cs.
- For the functions listed in the jump table to be callable they must
also be defined in the "exports.h" header. Define the various exported SPI functions so that they can be used.
Signed-off-by: Paul Barker paul.barker@sancloud.com
Reviewed-by: Tom Rini trini@konsulko.com

Dear Paul,
In message 20220505153242.1598807-4-paul.barker@sancloud.com you wrote:
- With CONFIG_DM_SPI defined, spi_get_bus_and_cs needs to be used
instead of spi_setup_slave to configure a SPI bus. As spi_setup_slave is already present in the export list it is reasonable to also export spi_get_bus_and_cs.
- For the functions listed in the jump table to be callable they must
also be defined in the "exports.h" header. Define the various exported SPI functions so that they can be used.
Signed-off-by: Paul Barker paul.barker@sancloud.com
include/_exports.h | 4 ++++ include/exports.h | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-)
Sorry, but I disagree here. The SPI functions should have never been part of the export interface. As far as I can see now, they have been added by commit bedd8403f7
export SPI functions to standalone apps
While we're here, fix the broken #ifdef handling in _exports.h.
Signed-off-by: Mike Frysinger vapier@gentoo.org
in 2009. Actually I must even have seen them, as I complained about incorrect comment style :-(
But no, SPI support should not be inclluded. I2C was there because it was needed for reading the environment from an EEPROM, but then the interface was frozen ano no more new interfices / drivers should be allowed.
Viele Grüße,
Wolfgang Denk
participants (3)
-
Paul Barker
-
Tom Rini
-
Wolfgang Denk