[PATCH] arm: imx: add u-boot-nand.imx to boot from NAND without SPL

2023-03-10 Thread Luca Ceresoli
U-Boot can be booted from NAND without SPL by prepending the DCD header to
the actual U-Boot binary. However this requires prepending 1024 bytes to
u-boot.imx (DCD + u-boot.bin).

There is already a similar target to build spl/u-boot-nand-spl.imx, add the
same option for no-SPL boot.

Tested on i.MX6ULL.

The resulting layout of u-boot-nand.imx is:

 - Offset 0x (0 KiB): padding
 - Offset 0x0400 (1 KiB): DCD header
 - Offset 0x1000 (4 KiB): u-boot.bin

Signed-off-by: Luca Ceresoli 
---
 Makefile   | 3 +++
 arch/arm/mach-imx/Makefile | 6 ++
 2 files changed, 9 insertions(+)

diff --git a/Makefile b/Makefile
index e760bacf9451..db124476d6e6 100644
--- a/Makefile
+++ b/Makefile
@@ -1522,6 +1522,9 @@ endif
 u-boot.uim: u-boot.bin FORCE
$(Q)$(MAKE) $(build)=arch/arm/mach-imx $@
 
+u-boot-nand.imx: u-boot.imx FORCE
+   $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@
+
 u-boot-with-spl.imx u-boot-with-nand-spl.imx: SPL $(if 
$(CONFIG_OF_SEPARATE),u-boot.img,u-boot.uim) FORCE
$(Q)$(MAKE) $(build)=arch/arm/mach-imx $@
 
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 4dfc60eedc43..c386132dacd1 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -132,6 +132,12 @@ u-boot.imx: MKIMAGEOUTPUT = u-boot.imx.log
 u-boot.imx: u-boot.bin u-boot.cfgout $(PLUGIN).bin FORCE
$(call if_changed,mkimage)
 
+quiet_cmd_u-boot-nand_imx = GEN $@
+cmd_u-boot-nand_imx = (dd bs=1024 count=1 if=/dev/zero 2>/dev/null) | cat - $< 
> $@
+
+u-boot-nand.imx: u-boot.imx FORCE
+   $(call if_changed,u-boot-nand_imx)
+
 ifeq ($(CONFIG_MULTI_DTB_FIT),y)
 MKIMAGEFLAGS_u-boot-dtb.imx = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
-T $(IMAGE_TYPE) -e $(CONFIG_TEXT_BASE)
-- 
2.34.1



Re: [PATCH v9 14/14] treewide: Disable USE_SPL_FIT_GENERATOR by default

2023-01-09 Thread Luca Ceresoli
Hello Tom, Simon, Michal,

On Sun, 8 Jan 2023 12:36:15 -0700
Simon Glass  wrote:

> Hi Tom,
> 
> On Sun, 8 Jan 2023 at 09:24, Tom Rini  wrote:
> >
> > On Sun, Jan 08, 2023 at 09:20:09AM -0700, Simon Glass wrote:  
> > > Hi Tom,
> > >
> > > On Sun, 8 Jan 2023 at 09:06, Tom Rini  wrote:  
> > > >
> > > > On Sun, Jan 08, 2023 at 08:48:37AM -0700, Simon Glass wrote:  
> > > > > Hi Tom,
> > > > >
> > > > > On Sun, 8 Jan 2023 at 06:41, Tom Rini  wrote:  
> > > > > >
> > > > > > On Sat, Jan 07, 2023 at 02:07:21PM -0700, Simon Glass wrote:
> > > > > >  
> > > > > > > This option is deprecated and only used by two boards. Enable it 
> > > > > > > for just
> > > > > > > those two boards, so others don't accidentally enable it.
> > > > > > >
> > > > > > > Signed-off-by: Simon Glass   
> > > > > > [snip]  
> > > > > > > diff --git a/boot/Kconfig b/boot/Kconfig
> > > > > > > index 55f06761ef8..7ab0dd14211 100644
> > > > > > > --- a/boot/Kconfig
> > > > > > > +++ b/boot/Kconfig
> > > > > > > @@ -282,12 +282,13 @@ config SPL_FIT_SOURCE
> > > > > > >  config USE_SPL_FIT_GENERATOR
> > > > > > >   bool "Use a script to generate the .its script"
> > > > > > >   depends on SPL_FIT
> > > > > > > - default y if SPL_FIT && ARCH_ZYNQMP
> > > > > > > + help
> > > > > > > +   This is deprecated. Please do not use it. Use binman 
> > > > > > > instead.  
> > > > > >
> > > > > > Lets remove the text around bool so it can't be enabled, and move to
> > > > > > select'ing it from the two boards that need it. Michal, Luca, what's
> > > > > > needed to move your two platforms
> > > > > > (avnet_ultrazedev_cc_v1_0_ultrazedev_som_v1_0 and 
> > > > > > xilinx_zynqmp_virt off
> > > > > > of this very legacy option, given that other xilinx platforms have
> > > > > > already migrated to binman ?  

Unfortunately I lost access to that board, and since the vendor does
not appear interested in supporting it I think the best options would
be to either remove the defconfig or to keep legacy support.

Which one would you prefer?

Regards,
-- 
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


[PATCH] arm64: zynqmp: remove Avnet UltraZed-EV Starter Kit

2023-01-09 Thread Luca Ceresoli
Nobody seems interested and able to keep this board supported, and
xilinx_zynqmp_virt_defconfig is supposed to be enough for any zynqmp board.

See the discussion at: 
https://lore.kernel.org/u-boot/CAPnjgZ3hHbyiFf=_Lp-Wz_XOWBkV-3vK4Q3xp=7bcerw-sp...@mail.gmail.com/T/#m76d726f1ab3f7074c8105c9a2af2110ac7d18708

Signed-off-by: Luca Ceresoli 
---
 arch/arm/dts/Makefile |  1 -
 ...ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts | 59 -
 arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi   | 56 -
 board/xilinx/zynqmp/MAINTAINERS   |  6 --
 ...edev_cc_v1_0_ultrazedev_som_v1_0_defconfig | 83 ---
 5 files changed, 205 deletions(-)
 delete mode 100644 
arch/arm/dts/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts
 delete mode 100644 arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi
 delete mode 100644 
configs/avnet_ultrazedev_cc_v1_0_ultrazedev_som_v1_0_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index b3baaf482908..79bec315a2a5 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -336,7 +336,6 @@ dtb-$(CONFIG_ARCH_ZYNQ) += \
zynq-zybo-z7.dtb
 dtb-$(CONFIG_ARCH_ZYNQMP) += \
avnet-ultra96-rev1.dtb  \
-   avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dtb\
zynqmp-a2197-revA.dtb   \
zynqmp-dlc21-revA.dtb   \
zynqmp-e-a2197-00-revA.dtb  \
diff --git a/arch/arm/dts/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts 
b/arch/arm/dts/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts
deleted file mode 100644
index 6d1448e8697a..
--- a/arch/arm/dts/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts
+++ /dev/null
@@ -1,59 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+ OR X11
-
-/*
- * UltraZed-EV Carrier Card v1 (based on the UltraZed-EV SoM)
- * http://ultrazed.org/product/ultrazed-ev-carrier-card
- */
-
-/dts-v1/;
-
-#include "avnet-ultrazedev-som-v1.0.dtsi"
-
-/ {
-   model = "Avnet UltraZed EV Carrier Card v1.0";
-   compatible = "avnet,ultrazedev-cc-v1.0-ultrazedev-som-v1.0",
-"xlnx,zynqmp";
-   chosen {
-   stdout-path = "serial0:115200n8";
-   };
-   aliases {
-   ethernet0 = &gem3;
-   nvmem0 = &eeprom;
-   serial0 = &uart0;
-   };
-};
-
-&uart0 {
-   device_type = "serial";
-   status = "okay";
-};
-
-&i2c_cc {
-   /* Microchip 24AA025E48T-I/OT: 2K I2C Serial EEPROM with EUI-48 */
-   eeprom: eeprom@51 {
-   compatible = "atmel,24c02";
-   reg = <0x51>;
-   };
-
-   /* IDT Versa Clock 5P49V5935B */
-   vc5: clock-generator@6a {
-   compatible = "idt,5p49v5935";
-   reg = <0x6a>;
-   #clock-cells = <1>;
-   };
-};
-
-/* Ethernet RJ-45 */
-&gem3 {
-   status = "okay";
-};
-
-/* microSD card slot */
-&sdhci1 {
-   status = "okay";
-   xlnx,mio-bank = <1>;
-   clock-frequency = <18000>;
-   max-frequency = <5000>;
-   no-1-8-v;
-   disable-wp;
-};
diff --git a/arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi 
b/arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi
deleted file mode 100644
index cbcb290a5c83..
--- a/arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi
+++ /dev/null
@@ -1,56 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+ OR X11
-
-/*
- * UltraZed-EV SoM v1
- * http://ultrazed.org/product/ultrazed-ev
- */
-
-/dts-v1/;
-
-#include "zynqmp.dtsi"
-#include "zynqmp-clk-ccf.dtsi"
-
-/ {
-   model = "Avnet UltraZed EV SoM v1.0";
-   compatible = "avnet,ultrazedev-som-v1.0", "xlnx,zynqmp";
-   memory {
-   device_type = "memory";
-   reg = <0x0 0x0 0x0 0x8000>, /* 2 GB @ offset 0 */
- <0x8 0x0 0x0 0x8000>; /* 2 GB @ offset 32GB */
-   };
-};
-
-&i2c1 {
-   clock-frequency = <40>;
-   status = "okay";
-
-   i2cswitch@70 {
-   compatible = "nxp,pca9543";
-   #address-cells = <1>;
-   #size-cells = <0>;
-   reg = <0x70>;
-
-   /* I2C connected to Carrier Card via JX3A1/JX3C1 */
-   i2c_cc: i2c@0 {
-   reg = <0>;
-   #address-cells = <1>;
-   #size-cells = <0>;
-   };
-   };
-};
-
-/* Marvell 88E1512-A0-NNP2I000 Ethernet PHY */
-&gem3 {
-   phy-mode = "rgmii-id";
-   phy-handle = <&gem3phy>;
-   gem3phy: ethernet-phy@0 {
-   reg = <0>;
-   };
-};
-
-/* Micron MTFC8GAKAJCN-4M 8 GB eMMC */
-&sdhci0 {
- 

[PATCH v2] arm64: zynqmp: remove Avnet UltraZed-EV Starter Kit

2023-01-11 Thread Luca Ceresoli
Nobody seems interested and able to keep this board supported, and
xilinx_zynqmp_virt_defconfig is supposed to be enough for any zynqmp board.

See the discussion at: 
https://lore.kernel.org/u-boot/CAPnjgZ3hHbyiFf=_Lp-Wz_XOWBkV-3vK4Q3xp=7bcerw-sp...@mail.gmail.com/T/#m76d726f1ab3f7074c8105c9a2af2110ac7d18708

Signed-off-by: Luca Ceresoli 

---

Changed in v2:
 - also remove board/xilinx/zynqmp/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0/
   (reported by Michal)
---
 arch/arm/dts/Makefile |   1 -
 ...ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts |  59 --
 arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi   |  56 --
 board/xilinx/zynqmp/MAINTAINERS   |   6 -
 .../psu_init_gpl.c| 655 --
 ...edev_cc_v1_0_ultrazedev_som_v1_0_defconfig |  83 ---
 6 files changed, 860 deletions(-)
 delete mode 100644 
arch/arm/dts/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts
 delete mode 100644 arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi
 delete mode 100644 
board/xilinx/zynqmp/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0/psu_init_gpl.c
 delete mode 100644 
configs/avnet_ultrazedev_cc_v1_0_ultrazedev_som_v1_0_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index b3baaf482908..79bec315a2a5 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -336,7 +336,6 @@ dtb-$(CONFIG_ARCH_ZYNQ) += \
zynq-zybo-z7.dtb
 dtb-$(CONFIG_ARCH_ZYNQMP) += \
avnet-ultra96-rev1.dtb  \
-   avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dtb\
zynqmp-a2197-revA.dtb   \
zynqmp-dlc21-revA.dtb   \
zynqmp-e-a2197-00-revA.dtb  \
diff --git a/arch/arm/dts/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts 
b/arch/arm/dts/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts
deleted file mode 100644
index 6d1448e8697a..
--- a/arch/arm/dts/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts
+++ /dev/null
@@ -1,59 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+ OR X11
-
-/*
- * UltraZed-EV Carrier Card v1 (based on the UltraZed-EV SoM)
- * http://ultrazed.org/product/ultrazed-ev-carrier-card
- */
-
-/dts-v1/;
-
-#include "avnet-ultrazedev-som-v1.0.dtsi"
-
-/ {
-   model = "Avnet UltraZed EV Carrier Card v1.0";
-   compatible = "avnet,ultrazedev-cc-v1.0-ultrazedev-som-v1.0",
-"xlnx,zynqmp";
-   chosen {
-   stdout-path = "serial0:115200n8";
-   };
-   aliases {
-   ethernet0 = &gem3;
-   nvmem0 = &eeprom;
-   serial0 = &uart0;
-   };
-};
-
-&uart0 {
-   device_type = "serial";
-   status = "okay";
-};
-
-&i2c_cc {
-   /* Microchip 24AA025E48T-I/OT: 2K I2C Serial EEPROM with EUI-48 */
-   eeprom: eeprom@51 {
-   compatible = "atmel,24c02";
-   reg = <0x51>;
-   };
-
-   /* IDT Versa Clock 5P49V5935B */
-   vc5: clock-generator@6a {
-   compatible = "idt,5p49v5935";
-   reg = <0x6a>;
-   #clock-cells = <1>;
-   };
-};
-
-/* Ethernet RJ-45 */
-&gem3 {
-   status = "okay";
-};
-
-/* microSD card slot */
-&sdhci1 {
-   status = "okay";
-   xlnx,mio-bank = <1>;
-   clock-frequency = <18000>;
-   max-frequency = <5000>;
-   no-1-8-v;
-   disable-wp;
-};
diff --git a/arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi 
b/arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi
deleted file mode 100644
index cbcb290a5c83..
--- a/arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi
+++ /dev/null
@@ -1,56 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+ OR X11
-
-/*
- * UltraZed-EV SoM v1
- * http://ultrazed.org/product/ultrazed-ev
- */
-
-/dts-v1/;
-
-#include "zynqmp.dtsi"
-#include "zynqmp-clk-ccf.dtsi"
-
-/ {
-   model = "Avnet UltraZed EV SoM v1.0";
-   compatible = "avnet,ultrazedev-som-v1.0", "xlnx,zynqmp";
-   memory {
-   device_type = "memory";
-   reg = <0x0 0x0 0x0 0x8000>, /* 2 GB @ offset 0 */
- <0x8 0x0 0x0 0x8000>; /* 2 GB @ offset 32GB */
-   };
-};
-
-&i2c1 {
-   clock-frequency = <40>;
-   status = "okay";
-
-   i2cswitch@70 {
-   compatible = "nxp,pca9543";
-   #address-cells = <1>;
-   #size-cells = <0>;
-   reg = <0x70>;
-
-   /* I2C connected to Carrier Card via JX3A1/JX3C1 */
-   i2c_cc: i2c@0 {
-   reg = <0>;
-   #address-cells = <1>;
-   #size-cells = <0>;
-   };
-   };
-};
-
-/* Marvell 88E1512-A0-NNP2I

Re: [PATCH] firmware: zynqmp: Change panic logic in zynqmp_pmufw_load_config_object()

2020-05-12 Thread Luca Ceresoli
Hi Michal,

On 12/05/20 08:25, Michal Simek wrote:
> There is no need to panic all the time when pmufw config object loading
> failed. The patch improves function logic to report permission deny case
> and also panic only for SPL case.
> 
> Signed-off-by: Michal Simek 

Looks good to me.

Reviewed-by: Luca Ceresoli 

-- 
Luca


Re: [PATCH] i2c: muxes: pca954x: add PCA9546 variant

2020-04-02 Thread Luca Ceresoli
Hi Chris,

On 01/04/20 04:55, Chris Packham wrote:
> This adds the PCA9546 4-channel i2c bus switch.
> 
> Signed-off-by: Chris Packham 

Reviewed-by: Luca Ceresoli 

-- 
Luca


Re: [PATCH] clk: clk_versaclock: Add support for versaclock driver

2021-06-03 Thread Luca Ceresoli
On 24/05/21 19:53, Adam Ford wrote:
> The driver is based on the Versaclock driver from the Linux code, but
> do differences in the clock API between them, some pieces had to change.

s/do/due to/ ?
s/had to change/had to be changed/

> This driver creates a mux, pfd, pll, and a series of fod ouputs.
>  Rate   Usecnt  Name
> --
>  2500 0`-- x304-clock
>  2500 0`-- clock-control...@6a.mux
>  2500 0|-- clock-control...@6a.pfd
>  28   0|   `-- clock-control...@6a.pll
>   0|   |-- clock-controller@6a.fod0
>   0|   |   `-- 
> clock-controller@6a.out1
>   0|   |-- clock-controller@6a.fod1
>   0|   |   `-- 
> clock-controller@6a.out2
>  5000 0|   |-- clock-controller@6a.fod2
>  5000 0|   |   `-- 
> clock-controller@6a.out3
>  125000|   `-- clock-controller@6a.fod3
>  125000|   `-- 
> clock-controller@6a.out4
>  2500 0`-- clock-controller@6a.out0_sel_i2cb
> 
> A translation function is added so the references to <&versaclock X> get 
> routed
> to the corresponding clock-control...@6a.outx.
> 
> Signed-off-by: Adam Ford 

I've been reviewing this patch and it looks mostly OK to me except for a
few notes below, mostly minor ones. However my knowledge of the U-Boot
driver model is minimal, thus I couldn't go in depth in the most
interesting and critical part of Adam's work, i.e. the adaptations for
the U-Boot codebase. I'm afraid I cannot do more.

> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> index 645709b855..2a9ebec860 100644
> --- a/drivers/clk/Makefile
> +++ b/drivers/clk/Makefile
> @@ -51,3 +51,4 @@ obj-$(CONFIG_SANDBOX_CLK_CCF) += clk_sandbox_ccf.o
>  obj-$(CONFIG_STM32H7) += clk_stm32h7.o
>  obj-$(CONFIG_CLK_VERSAL) += clk_versal.o
>  obj-$(CONFIG_CLK_CDCE9XX) += clk-cdce9xx.o
> +obj-$(CONFIG_CLK_VERSACLOCK) +=clk_versaclock.o

Nit: space after '+='.

> diff --git a/drivers/clk/clk_versaclock.c b/drivers/clk/clk_versaclock.c
> new file mode 100644
> index 00..30e49fad31
> --- /dev/null
> +++ b/drivers/clk/clk_versaclock.c
> @@ -0,0 +1,1025 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Driver for IDT Versaclock 5/6
> + *
> + * Derived from code Copyright (C) 2017 Marek Vasut 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 

Missing file?

> +
> +/* VersaClock5 registers */
> +#define VC5_OTP_CONTROL  0x00
> +
> +/* Factory-reserved register block */
> +#define VC5_RSVD_DEVICE_ID   0x01
> +#define VC5_RSVD_ADC_GAIN_7_00x02
> +#define VC5_RSVD_ADC_GAIN_15_8   0x03
> +#define VC5_RSVD_ADC_OFFSET_7_0  0x04
> +#define VC5_RSVD_ADC_OFFSET_15_8 0x05
> +#define VC5_RSVD_TEMPY   0x06
> +#define VC5_RSVD_OFFSET_TBIN 0x07
> +#define VC5_RSVD_GAIN0x08
> +#define VC5_RSVD_TEST_NP 0x09
> +#define VC5_RSVD_UNUSED  0x0a
> +#define VC5_RSVD_BANDGAP_TRIM_UP 0x0b
> +#define VC5_RSVD_BANDGAP_TRIM_DN 0x0c
> +#define VC5_RSVD_CLK_R_12_CLK_AMP_4  0x0d
> +#define VC5_RSVD_CLK_R_34_CLK_AMP_4  0x0e
> +#define VC5_RSVD_CLK_AMP_123 0x0f

I wonder whether it really makes sense to define so many registers that
are not used in the driver. But it's done the same way in the Linux
driver, and it doesn't hurt much, so I'll be fine with or without them.

[...]

> +static const struct udevice_id versaclock_ids[] = {
> + { .compatible = "idt,5p49v5923", .data = (ulong)&idt_5p49v5923_info },
> + { .compatible = "idt,5p49v5925", .data = (ulong)&idt_5p49v5925_info },
> + { .compatible = "idt,5p49v5933", .data = (ulong)&idt_5p49v5933_info },
> + { .compatible = "idt,5p49v5935", .data = (ulong)&idt_5p49v5935_info },
> + { .compatible = "idt,5p49v6901", .data = (ulong)&idt_5p49v6901_info },
> + { .compatible = "idt,5p49v6965", .data = (ulong)&idt_5p49v6965_info },
> + {},
> +};

Why not putting this array below, right before the U_BOOT_DRIVER() call
where it is used, similarly to the Linux driver?

-- 
Luca


Re: [PATCH] clk: clk_versaclock: Add support for versaclock driver

2021-06-03 Thread Luca Ceresoli
Hi Adam,

On 03/06/21 14:06, Adam Ford wrote:
> On Thu, Jun 3, 2021 at 3:34 AM Luca Ceresoli  wrote:
>>
>> On 24/05/21 19:53, Adam Ford wrote:
>>> The driver is based on the Versaclock driver from the Linux code, but
>>> do differences in the clock API between them, some pieces had to change.
>>
>> s/do/due to/ ?
>> s/had to change/had to be changed/
> 
> I am usually more careful about grammar.  I must have been tired.  :-)
> 
>>
>>> This driver creates a mux, pfd, pll, and a series of fod ouputs.
>>>  Rate   Usecnt  Name
>>> --
>>>  2500 0`-- x304-clock
>>>  2500 0`-- clock-control...@6a.mux
>>>  2500 0|-- clock-control...@6a.pfd
>>>  28   0|   `-- clock-control...@6a.pll
>>>   0|   |-- clock-controller@6a.fod0
>>>   0|   |   `-- 
>>> clock-controller@6a.out1
>>>   0|   |-- clock-controller@6a.fod1
>>>   0|   |   `-- 
>>> clock-controller@6a.out2
>>>  5000 0|   |-- clock-controller@6a.fod2
>>>  5000 0|   |   `-- 
>>> clock-controller@6a.out3
>>>  125000|   `-- clock-controller@6a.fod3
>>>  125000|   `-- 
>>> clock-controller@6a.out4
>>>  2500 0`-- clock-controller@6a.out0_sel_i2cb
>>>
>>> A translation function is added so the references to <&versaclock X> get 
>>> routed
>>> to the corresponding clock-control...@6a.outx.
>>>
>>> Signed-off-by: Adam Ford 
>>
>> I've been reviewing this patch and it looks mostly OK to me except for a
>> few notes below, mostly minor ones. However my knowledge of the U-Boot
>> driver model is minimal, thus I couldn't go in depth in the most
>> interesting and critical part of Adam's work, i.e. the adaptations for
>> the U-Boot codebase. I'm afraid I cannot do more.
>>
>>> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
>>> index 645709b855..2a9ebec860 100644
>>> --- a/drivers/clk/Makefile
>>> +++ b/drivers/clk/Makefile
>>> @@ -51,3 +51,4 @@ obj-$(CONFIG_SANDBOX_CLK_CCF) += clk_sandbox_ccf.o
>>>  obj-$(CONFIG_STM32H7) += clk_stm32h7.o
>>>  obj-$(CONFIG_CLK_VERSAL) += clk_versal.o
>>>  obj-$(CONFIG_CLK_CDCE9XX) += clk-cdce9xx.o
>>> +obj-$(CONFIG_CLK_VERSACLOCK) +=clk_versaclock.o
>>
>> Nit: space after '+='.
> 
> make sense.
> 
>>
>>> diff --git a/drivers/clk/clk_versaclock.c b/drivers/clk/clk_versaclock.c
>>> new file mode 100644
>>> index 00..30e49fad31
>>> --- /dev/null
>>> +++ b/drivers/clk/clk_versaclock.c
>>> @@ -0,0 +1,1025 @@
>>> +// SPDX-License-Identifier: GPL-2.0-or-later
>>> +/*
>>> + * Driver for IDT Versaclock 5/6
>>> + *
>>> + * Derived from code Copyright (C) 2017 Marek Vasut 
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#include 
>>
>> Missing file?
> 
> This was included a while ago in order to allow the device trees to build.

Apologies, I was on an old commit and didn't realize.

-- 
Luca


Re: [PATCH 28/30] spi: Enable missing CONFIG_SPL_DM_SPI support

2020-06-12 Thread Luca Ceresoli
Hi Tom,

On 10/06/20 22:16, Tom Rini wrote:
> Due to how the Makefile logic is we currently get DM_SPI support in SPL
> enabled by having DM_SPI enabled for full U-Boot but not having
> CONFIG_SPL_DM_SPI set.  Add this missing option to boards that were
> inadvertently making use of it.
> 
> Cc: Adam Ford 
> Cc: Akash Gajjar 
> Cc: Anatolij Gustschin 
> Cc: Andy Yan 
> Cc: Anup Patel 
> Cc: Atish Patra 
> Cc: Bin Meng 
> Cc: Chee Hong Ang 
> Cc: Chin-Liang See 
> Cc: Dalon Westergreen 
> Cc: Dinh Nguyen 
> Cc: Eugen Hristev 
> Cc: Hannes Schmelzer 
> Cc: Heiko Schocher 
> Cc: Jagan Teki 
> Cc: Klaus Goger 
> Cc: Levin Du 
> Cc: Ley Foon Tan 
> Cc: Lokesh Vutla 
> Cc: Luca Ceresoli 
> Cc: Marek Vasut 
> Cc: Michal Simek 
> Cc: Mike Looijmans 
> Cc: Nicolas Ferre 
> Cc: Nikita Kiryanov 
> Cc: Palmer Dabbelt 
> Cc: Patrick Delaunay 
> Cc: Paul Walmsley 
> Cc: Pavel Machek 
> Cc: Peter Robinson 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: Suniel Mahesh 
> Cc: Wolfgang Grandegger 
> Signed-off-by: Tom Rini 

For the Avnet Ultrazed:
>  configs/avnet_ultrazedev_cc_v1_0_ultrazedev_som_v1_0_defconfig | 1 +

Reviewed-by: Luca Ceresoli 

-- 
Luca


Re: [PATCHv2 29/31] spi: Enable missing CONFIG_SPL_DM_SPI support

2020-06-17 Thread Luca Ceresoli
Hi,

On 17/06/20 01:06, Tom Rini wrote:
> Due to how the Makefile logic is we currently get DM_SPI support in SPL
> enabled by having DM_SPI enabled for full U-Boot but not having
> CONFIG_SPL_DM_SPI set.  Add this missing option to boards that were
> inadvertently making use of it.

[...]

For the Avnet Ultrazed:

>  configs/avnet_ultrazedev_cc_v1_0_ultrazedev_som_v1_0_defconfig | 1 +

Reviewed-by: Luca Ceresoli 

-- 
Luca


Re: [PATCH] arm64: zynqmp: Support converting pm_cfg_obj.c

2020-06-23 Thread Luca Ceresoli
Hi Brandon,

On 22/06/20 22:45, Brandon Maier wrote:
> To use CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE, a developer must pull down the
> U-Boot source and run ./tools/zynqmp_pm_cfg_obj_convert.py to convert
> their pm_cfg_obj.c into U-Boot's PMU loader format, then feed that file
> back to U-Boot during build.
>
> Instead, by doing the conversion in U-Boot during the build, we can
> simplify the developer's build system. And it ensures that if
> zynqmp_pm_cfg_obj_convert.py is updated, the pm_cfg_obj will stay in
> sync with U-Boot.

In the workflows I have used so far U-Boot tools are extracted in a
different step w.r.t. U-Boot cross-compilation, so I never felt the need
for this feature. But I understand this feature can be handy.

The code looks OK too.

Reviewed-by: Luca Ceresoli 

-- 
Luca


Re: [PATCH] arm64: zynqmp: Support converting pm_cfg_obj.c

2020-06-23 Thread Luca Ceresoli
Hi Brandon,

On 23/06/20 19:08, Brandon Maier wrote:
> On Tue, Jun 23, 2020 at 10:18 AM Luca Ceresoli  wrote:
>>
>> Hi Brandon,
>>
>> On 22/06/20 22:45, Brandon Maier wrote:
>>> To use CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE, a developer must pull down the
>>> U-Boot source and run ./tools/zynqmp_pm_cfg_obj_convert.py to convert
>>> their pm_cfg_obj.c into U-Boot's PMU loader format, then feed that file
>>> back to U-Boot during build.
>>>
>>> Instead, by doing the conversion in U-Boot during the build, we can
>>> simplify the developer's build system. And it ensures that if
>>> zynqmp_pm_cfg_obj_convert.py is updated, the pm_cfg_obj will stay in
>>> sync with U-Boot.
>>
>> In the workflows I have used so far U-Boot tools are extracted in a
>> different step w.r.t. U-Boot cross-compilation, so I never felt the need
>> for this feature. But I understand this feature can be handy.
> 
> I'm trying to get it to work with Buildroot. Buildroot does have a
> package for uboot-tools, so I could use that to run it. I'd have to
> move the config and build commands into Buildroot's uboot package.
> Since the script belongs to U-Boot anyway, it seemed cleaner to
> integrate it directly into U-Boot so it could be used by other build
> systems too.

I understand. But I also understand Michal's concern: the U-Boot
makefiles are quite complex already, and this feature is a relatively
minor improvement.

Probably having the conversion in Buildroot could be even simpler as you
can support _only_ the C format there and do the conversion
unconditionally. Only one workflow, no ifs, simpler code. Don't forget
to Cc: me if you send a patch for that, I'll be glad to review it.

-- 
Luca


Re: [PATCH] arm64: zynqmp: Support converting pm_cfg_obj.c

2020-06-23 Thread Luca Ceresoli
Hi,

On 23/06/20 23:23, Luca Ceresoli wrote:
> Hi Brandon,
> 
> On 23/06/20 19:08, Brandon Maier wrote:
>> On Tue, Jun 23, 2020 at 10:18 AM Luca Ceresoli  wrote:
>>>
>>> Hi Brandon,
>>>
>>> On 22/06/20 22:45, Brandon Maier wrote:
>>>> To use CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE, a developer must pull down the
>>>> U-Boot source and run ./tools/zynqmp_pm_cfg_obj_convert.py to convert
>>>> their pm_cfg_obj.c into U-Boot's PMU loader format, then feed that file
>>>> back to U-Boot during build.
>>>>
>>>> Instead, by doing the conversion in U-Boot during the build, we can
>>>> simplify the developer's build system. And it ensures that if
>>>> zynqmp_pm_cfg_obj_convert.py is updated, the pm_cfg_obj will stay in
>>>> sync with U-Boot.
>>>
>>> In the workflows I have used so far U-Boot tools are extracted in a
>>> different step w.r.t. U-Boot cross-compilation, so I never felt the need
>>> for this feature. But I understand this feature can be handy.
>>
>> I'm trying to get it to work with Buildroot. Buildroot does have a
>> package for uboot-tools, so I could use that to run it. I'd have to
>> move the config and build commands into Buildroot's uboot package.
>> Since the script belongs to U-Boot anyway, it seemed cleaner to
>> integrate it directly into U-Boot so it could be used by other build
>> systems too.
> 
> I understand. But I also understand Michal's concern: the U-Boot
> makefiles are quite complex already, and this feature is a relatively
> minor improvement.
> 
> Probably having the conversion in Buildroot could be even simpler as you
> can support _only_ the C format there and do the conversion
> unconditionally. Only one workflow, no ifs, simpler code. Don't forget
> to Cc: me if you send a patch for that, I'll be glad to review it.

I almost forgot: I wrote some notes on how this could be implemented in
yocto a while back. The principles are pretty much the same so you might
be interested in reading them:

https://www.yoctoproject.org/pipermail/meta-xilinx/2019-November/004578.html


-- 
Luca


Re: [PATCH] arm64: zynqmp: Do not include psu_init to U-Boot by default

2022-12-03 Thread Luca Ceresoli
Hello Michal,

Il 02/12/22 09:18, Michal Simek ha scritto:
> The commit ed35de617013 ("Convert CONFIG_ZYNQMP_PSU_INIT_ENABLED to
> Kconfig") converted CONFIG_ZYNQMP_PSU_INIT_ENABLED symbol and enabled it by
> default which is not correct configuration.
> Intention of this config was to have it enabled by default for SPL and
> provide an option to users to also do low level initialization directly
> from U-Boot.
> That's why it is necessary to define second symbol with SPL marking in it
> and properly use symbols depends on usage in Makefile.
> Also disable ZYNQMP_PSU_INIT_ENABLED from boards which enables it by
> default. CONFIG_SPL_ZYNQMP_PSU_INIT_ENABLED is enabled by default when SPL
> is enabled.
> 
> Reported-by: Venkatesh Yadav Abbarapu 
> Signed-off-by: Michal Simek 

After checking ed35de617013 I can see the problem, and this seems like a
correct fix:

Reviewed-by: Luca Ceresoli 

-- 
Luca



[PATCH] board/xilinx/zynqmp/MAINTAINERS: change e-mail address for Luca Ceresoli

2022-12-03 Thread Luca Ceresoli
My Bootlin address is the preferred one now.

Signed-off-by: Luca Ceresoli 
Signed-off-by: Luca Ceresoli 
---
 board/xilinx/zynqmp/MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/xilinx/zynqmp/MAINTAINERS b/board/xilinx/zynqmp/MAINTAINERS
index 17a2766413c6..07b91b81c95b 100644
--- a/board/xilinx/zynqmp/MAINTAINERS
+++ b/board/xilinx/zynqmp/MAINTAINERS
@@ -11,7 +11,7 @@ F:configs/xilinx_zynqmp*
 F: configs/avnet_ultra96_rev1_defconfig
 
 ARM ZYNQMP AVNET ULTRAZED EV BOARD
-M: Luca Ceresoli 
+M: Luca Ceresoli 
 S: Maintained
 F: arch/arm/dts/avnet-ultrazedev-*
 F: configs/avnet_ultrazedev_cc_v1_0_ultrazedev_som_v1_0_defconfig
-- 
2.34.1



Re: [PATCH v2] tools: zynqmp: Fix regex expression around XPm_ConfigObject.

2020-11-24 Thread Luca Ceresoli
Hi,

On 24/11/20 16:13, Adrian Fiergolski wrote:
> The XPm_ConfigObject array definition generated by Vitis 2020.1 differs from 
> previous Vivado versions (before 2019.2).
> 
> -const u32 XPm_ConfigObject[] __attribute__((used, section(".sys_cfg_data"))) 
> = {
> +const u32 XPm_ConfigObject[] __attribute__((used, section(".sys_cfg_data"))) 
> =
> +#elif defined (__ICCARM__)
> +#pragma location = ".sys_cfg_data"
> +__root const u32 XPm_ConfigObject[] =
> +#endif
> +{
> 
> Change the matching regex to handle both cases.
> 
> Signed-off-by: Adrian Fiergolski 
> ---
> Changes in v2:
> Fix the patch tile.
> 
>  tools/zynqmp_pm_cfg_obj_convert.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/zynqmp_pm_cfg_obj_convert.py 
> b/tools/zynqmp_pm_cfg_obj_convert.py
> index dd27f47921..0a44710e1e 100755
> --- a/tools/zynqmp_pm_cfg_obj_convert.py
> +++ b/tools/zynqmp_pm_cfg_obj_convert.py
> @@ -289,7 +289,7 @@ code = in_file.read()
>  code = re.sub('//.*?\n|/\*.*?\*/', '', code, flags=re.DOTALL)
>  
>  # remove everything outside the XPm_ConfigObject array definition
> -code = re.search('const u32 XPm_ConfigObject.*= {\n(.*)};',
> +code = re.search('const u32 XPm_ConfigObject.*=.*{\n(.*)};',
>   code, flags=re.DOTALL).group(1)

Looks good, thanks.

Reviewed-by: Luca Ceresoli 

-- 
Luca


Re: [U-Boot] [PATCHv3 1/3] ARM: OMAP3: Remove unused define CONFIG_OMAP3430

2011-11-28 Thread Luca Ceresoli

Thomas Weber wrote:

This patch removes the CONFIG_OMAP3430, because it is unused.

Acked-by: Enric Balletbo i Serra
Acked-by: Tom Rini
Acked-by: Igor Grinberg
Signed-off-by: Thomas Weber


Acked-by: Luca Ceresoli 

But please check my name spelling in Cc:, as I received only one of your 
v3 patches. Thanks.


Luca
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCHv3 2/3] ARM: OMAP3: Remove unused define SDRC_R_C_B

2011-11-28 Thread Luca Ceresoli

Thomas Weber wrote:

This patch removes the unused definition of SDRC_R_C_B
from the config files.

Acked-by: Enric Balletbo i Serra
Acked-by: Igor Grinberg
Signed-off-by: Thomas Weber



Acked-by: Luca Ceresoli 

Luca
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCHv3 3/3] ARM: OMAP: Remove STACKSIZE for IRQ and FIQ if unused

2011-11-28 Thread Luca Ceresoli

Thomas Weber wrote:

This patch removes the definition of stack sizes for
irq and fiq if the CONFIG_USE_IRQ is undefined before.

Acked-by: Enric Balletbo i Serra
Acked-by: Tom Rini
Acked-by: Igor Grinberg
Signed-off-by: Thomas Weber


This does not touch the board I maintain, but since I was in Cc:, and
I successfully tested the whole series on my board:

Acked-by: Luca Ceresoli 

Luca
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] OMAP3: Remove unused define CONFIG_OMAP3_*_DDR

2011-12-19 Thread Luca Ceresoli

Thomas Weber wrote:

This patch removes the unused definitions:
CONFIG_OMAP3_MICRON_DDR
CONFIG_OMAP3_NUMONYX_DDR
CONFIG_OMAP3_INFINEON_DDR

Signed-off-by: Thomas Weber


Acked-by: Luca Ceresoli 

Luca
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/9] OMAP3: DIG297: Use generic MMC driver

2011-08-24 Thread Luca Ceresoli
Tom Rini wrote:
> Switch from the legacy omap3 mmc driver to the new generic omap hsmmc
> driver.  This patch is based on the work done for Beagle, etc.
>
> Signed-off-by: Tom Rini

Again, please Cc: the board maintainers in the future, thanks.

> ---
>   board/comelit/dig297/dig297.c |9 +
>   include/configs/dig297.h  |5 +++--
>   2 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/board/comelit/dig297/dig297.c b/board/comelit/dig297/dig297.c
> index 0062f12..a7071cd 100644
> --- a/board/comelit/dig297/dig297.c
> +++ b/board/comelit/dig297/dig297.c
> @@ -37,6 +37,7 @@
>   #include
>   #include
>   #include
> +#include
>   #include
>   #include
>   #include
> @@ -145,6 +146,14 @@ void set_muxconf_regs(void)
>   MUX_DIG297();
>   }
>
> +#ifdef CONFIG_GENERIC_MMC
> +int board_mmc_init(bd_t *bis)
> +{
> + omap_mmc_init(0);
> + return 0;
> +}
> +#endif
> +
>   #ifdef CONFIG_CMD_NET
>   /*
>* Routine: setup_net_chip
> diff --git a/include/configs/dig297.h b/include/configs/dig297.h
> index b68f073..0e05df3 100644
> --- a/include/configs/dig297.h
> +++ b/include/configs/dig297.h
> @@ -97,8 +97,9 @@
>   #define CONFIG_BAUDRATE 115200
>   #define CONFIG_SYS_BAUDRATE_TABLE   {4800, 9600, 19200, 38400, 57600,\
>   115200}
> -#define CONFIG_MMC
> -#define CONFIG_OMAP3_MMC
> +#define CONFIG_GENERIC_MMC   1
> +#define CONFIG_MMC   1
> +#define CONFIG_OMAP_HSMMC1

IIRC the coding style says you should define the y/n constants without
a value, e.g.:
   #define CONFIG_GENERIC_MMC
not:
   #define CONFIG_GENERIC_MMC 1

Apart for this:
Tested-by: Luca Ceresoli 

Luca
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC 0/3] omap: gpio: User generic (instead of custom) API

2011-09-01 Thread Luca Ceresoli
Hi Sanjeev,

Sanjeev Premi wrote:
> The OMAP boards use a custom api for GPIO operations. While
> it works, it doesn't help when when we don't know existence
> of the customization.
>
> I earlier encountered the problem when looking for GPIO
> related changes when submitting prev set of patches. Since
> the search for gpio_request() in omap sources returned empty,
> I had assumed that it isn't supported.
>
> This patchset attempts to adapt the current implementation
> to use generic API.
>
> Since, the changes impact all OMAP boards, and I wouldn't be
> able to test on all, I decided to submit changes as RFC.
> Unless any major issue is found, I will be able to submit
> as formal patch by end of this week.

Tested and working on the dig297 board, on top of the master
branch in the u-boot-ti repository.

I also tried to merge your work on the u-boot-arm repo, but it
conflicts with the GPIO work recently committed there. You might
want to rebase and resubmit when the -ti repo will be in line with
the -arm one.

Anyway, for the current version:
Tested-by: Luca Ceresoli 

Luca
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 0/3] omap: gpio: Use generic API (instead of custom)

2011-09-07 Thread Luca Ceresoli
Hi Sanjeev,

Sanjeev Premi wrote:
> The OMAP boards use a custom api for GPIO operations. While
> it works, it doesn't help when when we don't know existence
> of the customization.
...
> Changes since RFC[1]:
>   1) While the original RFC was based against the master of
>  u-boot.git. This series is based against master of
>  u-boot-arm.git

This patchset does not apply on top of current -arm master:

   commit 1052ea04d60de953f8355eab0e39336974283304
   Author: Sanjeev Premi 
   Date:   Mon Sep 5 00:25:53 2011 +

 omap3: beagle: Fix build warning

With this message:

   Applying: omap: gpio: Use generic API
   error: patch failed: arch/arm/cpu/armv7/omap-common/gpio.c:151
   error: arch/arm/cpu/armv7/omap-common/gpio.c: patch does not apply
   error: patch failed: arch/arm/include/asm/omap_gpio.h:49
   error: arch/arm/include/asm/omap_gpio.h: patch does not apply
   Patch failed at 0001 omap: gpio: Use generic API

I'm afraid think you need another rebase.

Luca
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 0/3] omap: gpio: Use generic API (instead of custom)

2011-09-08 Thread Luca Ceresoli
Premi, Sanjeev wrote:
> [sp] Actually, I realized that PATCH 1 in the series depends upon:
>   http://marc.info/?l=u-boot&m=131515805732292&w=2
>
>   I had mentioned 2 patches in the cover letter. Of the two,
>   one is already included in u-boot-arm/master. This one is
>   still not.
>
>   Can you apply this patch and then try to apply this series?

That did work. Compiled and tested on the dig297 board.

Tested-by: Luca Ceresoli 

Luca
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] Bricked when trying to attach UBI

2012-12-19 Thread Luca Ceresoli

Hi all,

I am facing a problem with some boards that do not boot after some
weeks or months of normal usage, being unable to attach UBI. They do
not boot anymore event after a power cycle, in other words they are
totally bricked.
I don't know exactly what problem UBI has, but it is recoverable by
Linux, but apparently not by U-Boot.

The boards are DIG297 (dig297 board in mainline U-Boot), based on
OMAP3530 and equipped with a NAND flash (Micron MT29F2G16ABBEAHC) as
their unique permanent storage.

U-Boot v2012.04.01 starts correctly. The bootcmd tries to load the
kernel from UBI, starting with the following commands:

echo Booting from nand ...
setenv bootargs console=ttyO2,115200n8 
mtdparts=omap2-nand.0:768k(uboot),128k(reserved),128k(uboot-env),-(ubi) 
ubi.mtd=3 root=ubi0:rootfs ro rootfstype=ubifs ip=

ubi part nand0,3
...

On "bricked" devices the output of the "ubi part nand0,3" command is:

Creating 1 MTD partitions on "nand0":
0x0010-0x1000 : "mtd=3"
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:129024 bytes
UBI: smallest flash I/O unit:2048
UBI: sub-page size:  512
UBI: VID header offset:  512 (aligned 512)
UBI: data offset:2048
UBI error: ubi_wl_init_scan: no enough physical eraseblocks (0, need 1)

Now the device is totally blocked, and power cycling does not change
the result.

The interesting thing is that if I load Linux (2.6.37 + OMAP patches +
board support patches) via TFTP and boot it with bootm, it correctly
attaches UBI (fixing any problem it may have) and boots correctly.
After that the board is unbricked: U-Boot can boot again normally from
NAND.

Without the ambition of understanding all UBI internals, I tried to
visually inspect the UBI code around the line where the error is
produced and compare it to the corresponding Linux sources. They looked
extremely similar, so I haven't and obvious hint of why U-Boot and
Linux produce different results.

I also tried with an updated U-Boot master, but the error is still
there.

Obviously I have changed nothing in the UBI and MTD code, both in
U-Boot and in Linux.

Can you suggest a proper way to track the root of the problem, or to
bypass it?

Big thanks in advance,

Luca
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Bricked when trying to attach UBI

2012-12-19 Thread Luca Ceresoli

Hi Andreas,

Andreas Bießmann wrote:
...

Creating 1 MTD partitions on "nand0":
0x0010-0x1000 : "mtd=3"
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:129024 bytes
UBI: smallest flash I/O unit:2048
UBI: sub-page size:  512
UBI: VID header offset:  512 (aligned 512)
UBI: data offset:2048
UBI error: ubi_wl_init_scan: no enough physical eraseblocks (0, need 1)

Now the device is totally blocked, and power cycling does not change
the result.


have you tried to increase the malloc arena in u-boot
(CONIG_SYS_MALLOC_LEN)?
We had errors like this before [1],[2] and [3], maybe others -
apparently with another error message, but please give it a try. We know
ubi recovery needs some ram and 1MiB may be not enough.


Thanks for your suggestion.

Unfortunately this does not seem to be the cause of my problem: I tried
increasing my CONFIG_SYS_MALLOC_LEN in include/configs/dig297.h from
(1024 << 10) to both (1024 << 12) and (1024 << 14), but without any
difference.

Luca

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Bricked when trying to attach UBI

2012-12-19 Thread Luca Ceresoli

Hi Andreas,

Andreas Bießmann wrote:

Hi Luca,

On 19.12.2012 16:56, Luca Ceresoli wrote:

Hi Andreas,

Andreas Bießmann wrote:
...

Creating 1 MTD partitions on "nand0":
0x0010-0x1000 : "mtd=3"
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:129024 bytes
UBI: smallest flash I/O unit:2048
UBI: sub-page size:  512
UBI: VID header offset:  512 (aligned 512)
UBI: data offset:2048
UBI error: ubi_wl_init_scan: no enough physical eraseblocks (0, need 1)

Now the device is totally blocked, and power cycling does not change
the result.


have you tried to increase the malloc arena in u-boot
(CONIG_SYS_MALLOC_LEN)?
We had errors like this before [1],[2] and [3], maybe others -
apparently with another error message, but please give it a try. We know
ubi recovery needs some ram and 1MiB may be not enough.


Thanks for your suggestion.

Unfortunately this does not seem to be the cause of my problem: I tried
increasing my CONFIG_SYS_MALLOC_LEN in include/configs/dig297.h from
(1024 << 10) to both (1024 << 12) and (1024 << 14), but without any
difference.


Well, ok ... Malloc arena is always my first thought if I read about
problems with ubi in u-boot.
Have you looked up the differences in drivers/mtd/ubi/ in your u-boot
and linux tree? Maybe you can see something obviously different in the
ubi_wl_init_scan()?


I had some days ago, but I double-checked now as you suggested. Indeed
there is an important difference: attach_by_scanning() (build.c) calls
ubi_wl_init_scan() and ubi_eba_init_scan() just like Linux does, but in
a swapped order!

This swap dates back to:

commit d63894654df72b010de2abb4b3f07d0d755f65b6
Author: Holger Brunck 
Date:   Mon Oct 10 13:08:19 2011 +0200

UBI: init eba tables before wl when attaching a device

This fixes that u-boot gets stuck when a bitflip was detected
during "ubi part ". If a bitflip was detected UBI tries
to copy the PEB to a different place. This needs that the eba table
are initialized, but this was done after the wear levelling worker
detects the bitflip. So changes the initialisation of these two
tasks in u-boot.

This is a u-boot specific patch and not needed in the linux layer,
because due to commit 1b1f9a9d00447d
UBI: Ensure that "background thread" operations are really executed
we schedule these tasks in place and not as in linux after the inital
task which schedule this new task is finished.

Signed-off-by: Holger Brunck 
cc: Stefan Roese 
Signed-off-by: Stefan Roese 

I tried reverting that commit and... surprise! U-Boot can now attach UBI
and boot properly!

But the cited commit actually fixed a bug that bite our board a few
months back, so it should not be reverted without thinking twice. Now
it apparently introduced another bug. :-(

I'm Cc:ing the commit author for comments.

Nonetheless, I have evidence of a different behaviour between U-Boot
and Linux even before the two swapped functions are called.

What attach_by_scanning() does in Linux is (abbreviated):

static int attach_by_scanning(struct ubi_device *ubi)
{
si = ubi_scan(ubi);
...fill ubi->some_fields...;
err = ubi_read_volume_table(ubi, si);
/* MARK */
err = ubi_eba_init_scan(ubi, si); /* swapped in U-Boot */
err = ubi_wl_init_scan(ubi, si);  /* swapped in U-Boot */
ubi_scan_destroy_si(si);
return 0;
}

See the two swapped calls.

At MARK, I printed some of the peb counters in *ubi, and I got
different results for ubi->avail_pebs between U-Boot and Linux:
U-Boot: UBI: POST_TBL: rsvd=2018, avail=21, beb_rsvd_{pebs,level}=0,0
Linux:  UBI: POST_TBL: rsvd=2018, avail=22, beb_rsvd_{pebs,level}=0,0

The printed values were equal before calling ubi_read_volume_table().
I have no idea about where this difference comes from, nor if this
difference can cause my troubles.
I will better investigate tomorrow looking into ubi_read_volume_table().

Luca

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Bricked when trying to attach UBI

2012-12-20 Thread Luca Ceresoli

Hi,

I'm Cc'ing the linux-mtd list as well as the authors of the Linux
commits cited below.

For these new readers: I reported a problem with U-Boot 2012.04.01 not
being able to attach an UBI partition in NAND, while Linux (2.6.37) can
attach and repair it.

It looks like an U-Boot bug, but I discovered strange things around the
chip->badblockbits variable (in the NAND code) by comparing the
relevant code in U-Boot and Linux.

Sorry for Cc'ing so many people, but following this issue I was lead
from one subsystem to another (and from U-Boot to Linux).

Previous discussion is here:
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/149624

Luca Ceresoli wrote:

Hi Andreas,

Andreas Bießmann wrote:

Hi Luca,

On 19.12.2012 16:56, Luca Ceresoli wrote:

Hi Andreas,

Andreas Bießmann wrote:
...

Creating 1 MTD partitions on "nand0":
0x0010-0x1000 : "mtd=3"
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:129024 bytes
UBI: smallest flash I/O unit:2048
UBI: sub-page size:  512
UBI: VID header offset:  512 (aligned 512)
UBI: data offset:2048
UBI error: ubi_wl_init_scan: no enough physical eraseblocks (0,
need 1)

Now the device is totally blocked, and power cycling does not change
the result.


have you tried to increase the malloc arena in u-boot
(CONIG_SYS_MALLOC_LEN)?
We had errors like this before [1],[2] and [3], maybe others -
apparently with another error message, but please give it a try. We
know
ubi recovery needs some ram and 1MiB may be not enough.


Thanks for your suggestion.

Unfortunately this does not seem to be the cause of my problem: I tried
increasing my CONFIG_SYS_MALLOC_LEN in include/configs/dig297.h from
(1024 << 10) to both (1024 << 12) and (1024 << 14), but without any
difference.


Well, ok ... Malloc arena is always my first thought if I read about
problems with ubi in u-boot.
Have you looked up the differences in drivers/mtd/ubi/ in your u-boot
and linux tree? Maybe you can see something obviously different in the
ubi_wl_init_scan()?


I had some days ago, but I double-checked now as you suggested. Indeed
there is an important difference: attach_by_scanning() (build.c) calls
ubi_wl_init_scan() and ubi_eba_init_scan() just like Linux does, but in
a swapped order!

This swap dates back to:

commit d63894654df72b010de2abb4b3f07d0d755f65b6
Author: Holger Brunck 
Date:   Mon Oct 10 13:08:19 2011 +0200

 UBI: init eba tables before wl when attaching a device

 This fixes that u-boot gets stuck when a bitflip was detected
 during "ubi part ". If a bitflip was detected UBI tries
 to copy the PEB to a different place. This needs that the eba table
 are initialized, but this was done after the wear levelling worker
 detects the bitflip. So changes the initialisation of these two
 tasks in u-boot.

 This is a u-boot specific patch and not needed in the linux layer,
 because due to commit 1b1f9a9d00447d
 UBI: Ensure that "background thread" operations are really executed
 we schedule these tasks in place and not as in linux after the inital
 task which schedule this new task is finished.

 Signed-off-by: Holger Brunck 
 cc: Stefan Roese 
 Signed-off-by: Stefan Roese 

I tried reverting that commit and... surprise! U-Boot can now attach UBI
and boot properly!

But the cited commit actually fixed a bug that bite our board a few
months back, so it should not be reverted without thinking twice. Now
it apparently introduced another bug. :-(

I'm Cc:ing the commit author for comments.

Nonetheless, I have evidence of a different behaviour between U-Boot
and Linux even before the two swapped functions are called.

What attach_by_scanning() does in Linux is (abbreviated):

static int attach_by_scanning(struct ubi_device *ubi)
{
 si = ubi_scan(ubi);
 ...fill ubi->some_fields...;
 err = ubi_read_volume_table(ubi, si);
 /* MARK */
 err = ubi_eba_init_scan(ubi, si); /* swapped in U-Boot */
 err = ubi_wl_init_scan(ubi, si);  /* swapped in U-Boot */
 ubi_scan_destroy_si(si);
 return 0;
}

See the two swapped calls.

At MARK, I printed some of the peb counters in *ubi, and I got
different results for ubi->avail_pebs between U-Boot and Linux:
U-Boot: UBI: POST_TBL: rsvd=2018, avail=21, beb_rsvd_{pebs,level}=0,0
Linux:  UBI: POST_TBL: rsvd=2018, avail=22, beb_rsvd_{pebs,level}=0,0

The printed values were equal before calling ubi_read_volume_table().
I have no idea about where this difference comes from, nor if this
difference can cause my troubles.
I will better investigate tomorrow looking into ubi_read_volume_table().


After half a day of debugging and an insane amount of printk()s added to
both U-Boot and Linux, I have some more hints to understand the problem.

The two differ

Re: [U-Boot] Bricked when trying to attach UBI

2013-01-02 Thread Luca Ceresoli

Luca Ceresoli wrote:

Hi,

I'm Cc'ing the linux-mtd list as well as the authors of the Linux
commits cited below.

For these new readers: I reported a problem with U-Boot 2012.04.01 not
being able to attach an UBI partition in NAND, while Linux (2.6.37) can
attach and repair it.

It looks like an U-Boot bug, but I discovered strange things around the
chip->badblockbits variable (in the NAND code) by comparing the
relevant code in U-Boot and Linux.

Sorry for Cc'ing so many people, but following this issue I was lead
from one subsystem to another (and from U-Boot to Linux).

Previous discussion is here:
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/149624

Luca Ceresoli wrote:

Hi Andreas,

Andreas Bießmann wrote:

Hi Luca,

On 19.12.2012 16:56, Luca Ceresoli wrote:

Hi Andreas,

Andreas Bießmann wrote:
...

Creating 1 MTD partitions on "nand0":
0x0010-0x1000 : "mtd=3"
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:129024 bytes
UBI: smallest flash I/O unit:2048
UBI: sub-page size:  512
UBI: VID header offset:  512 (aligned 512)
UBI: data offset:2048
UBI error: ubi_wl_init_scan: no enough physical eraseblocks (0,
need 1)

Now the device is totally blocked, and power cycling does not change
the result.


have you tried to increase the malloc arena in u-boot
(CONIG_SYS_MALLOC_LEN)?
We had errors like this before [1],[2] and [3], maybe others -
apparently with another error message, but please give it a try. We
know
ubi recovery needs some ram and 1MiB may be not enough.


Thanks for your suggestion.

Unfortunately this does not seem to be the cause of my problem: I 
tried

increasing my CONFIG_SYS_MALLOC_LEN in include/configs/dig297.h from
(1024 << 10) to both (1024 << 12) and (1024 << 14), but without any
difference.


Well, ok ... Malloc arena is always my first thought if I read about
problems with ubi in u-boot.
Have you looked up the differences in drivers/mtd/ubi/ in your u-boot
and linux tree? Maybe you can see something obviously different in the
ubi_wl_init_scan()?


I had some days ago, but I double-checked now as you suggested. Indeed
there is an important difference: attach_by_scanning() (build.c) calls
ubi_wl_init_scan() and ubi_eba_init_scan() just like Linux does, but in
a swapped order!

This swap dates back to:

commit d63894654df72b010de2abb4b3f07d0d755f65b6
Author: Holger Brunck 
Date:   Mon Oct 10 13:08:19 2011 +0200

 UBI: init eba tables before wl when attaching a device

 This fixes that u-boot gets stuck when a bitflip was detected
 during "ubi part ". If a bitflip was detected UBI tries
 to copy the PEB to a different place. This needs that the eba table
 are initialized, but this was done after the wear levelling worker
 detects the bitflip. So changes the initialisation of these two
 tasks in u-boot.

 This is a u-boot specific patch and not needed in the linux layer,
 because due to commit 1b1f9a9d00447d
 UBI: Ensure that "background thread" operations are really executed
 we schedule these tasks in place and not as in linux after the 
inital

 task which schedule this new task is finished.

 Signed-off-by: Holger Brunck 
 cc: Stefan Roese 
 Signed-off-by: Stefan Roese 

I tried reverting that commit and... surprise! U-Boot can now attach UBI
and boot properly!

But the cited commit actually fixed a bug that bite our board a few
months back, so it should not be reverted without thinking twice. Now
it apparently introduced another bug. :-(

I'm Cc:ing the commit author for comments.

Nonetheless, I have evidence of a different behaviour between U-Boot
and Linux even before the two swapped functions are called.

What attach_by_scanning() does in Linux is (abbreviated):

static int attach_by_scanning(struct ubi_device *ubi)
{
 si = ubi_scan(ubi);
 ...fill ubi->some_fields...;
 err = ubi_read_volume_table(ubi, si);
 /* MARK */
 err = ubi_eba_init_scan(ubi, si); /* swapped in U-Boot */
 err = ubi_wl_init_scan(ubi, si);  /* swapped in U-Boot */
 ubi_scan_destroy_si(si);
 return 0;
}

See the two swapped calls.

At MARK, I printed some of the peb counters in *ubi, and I got
different results for ubi->avail_pebs between U-Boot and Linux:
U-Boot: UBI: POST_TBL: rsvd=2018, avail=21, beb_rsvd_{pebs,level}=0,0
Linux:  UBI: POST_TBL: rsvd=2018, avail=22, beb_rsvd_{pebs,level}=0,0

The printed values were equal before calling ubi_read_volume_table().
I have no idea about where this difference comes from, nor if this
difference can cause my troubles.
I will better investigate tomorrow looking into ubi_read_volume_table().


After half a day of debugging and an insane amount of printk()s added to
both U-Boot and Linux, I have some more hints to understand the

[U-Boot] [RFC] Act as a TFTP server

2011-04-13 Thread Luca Ceresoli
Hi,

I am going to implement in U-Boot the ability to receive a file via TFTP acting
as a server, not a client. I've sketched up a way to implement it, and I would
appreciate any comments about it.

This is useful to solve the firewall issues that a Management Station can face
when sending files to a U-Boot device. These issues are only partially solved
using CONFIG_TFTP_PORT for '"punching through" the (Windows XP) firewall' (see
the README).

My implementation would be very basic (keep it simple):
- receive only (accept WRQ from remote client, not RRQ);
- the Filename in the WRQ is ignored: the destination is always a user-provided
   memory location;
- binary transfers only: the Mode in the WRQ is ignored; this is allowed by
   RFC1350 (section 5);
- no TFTP Option Extensions (RFC2347);
- no TFTP multicast.

After a preliminary analysis, I think the current TFTP clien implementation can
be mostly reused without code duplication, hence the amount of new code would
be pretty limited.

Even better, it would not increase binary size when the feature is disabled,
as I don't see any need to extend the existing code in a way that cannot be
easily put under appropriate #ifdefs.

 From the user point of view, I would implement a new command, activated only
when CONFIG_CMD_TFTPSRV is defined:

   Usage:tftpsrv []

This would be used almost like tftpboot, except no file name is specified on
the commandline.
  would default to the environment variable.

Here's a tentative implementation roadmap. It is presented in a roughly
top-down order, from user interface down to low level.
Many steps, except for those in net/tftp.c, are pretty trivial.

- add CONFIG_CMD_TFTPSRV config option;
- include/net.h: add TFTPSRV to proto_t, *as if it were a different protocol*;
   this may look dirty but I believe it makes implementation cleaner;
   - alternative: reuse TFTP protocol, but save in some flag (where?) whether
 the user wants a client or server transfer;
- common/cmd_net.c: add a tftpsrv command and do_tftpsrv() function;
   just like do_tftpb() simply calls netboot_common(TFTP, ...),
   do_tftpsrv() would simply call netboot_common(TFTPSRV, ...);
- common/cmd_net.c: netboot_common() should not need change, except maybe
   for the argv parsing: tftpsrv does not take a "hostaddr:filename" argument;
   to make it simpler, it could accept (but ignore) it if passed;
- net/net.c: change net_check_prereq() as needed: it should not check for
   NetServerIP when protocol==TFTPSRV;
- net/net.c: extend NetLoop() to handle the new protocol: call
   TftpStartServer() (not TftpStart()) when protocol==TFTPSRV;
- net/tftp.c: add TftpStartServer() with a role similar to TftpStart();
   - alternative: extend TftpStart() to handle both client and server mode;
 probably not worth doing as the actions to do are mostly different;
- net/tftp.c: extend the TFTP state machine (TftpHandler() and TftpStart())
   a new STATE_WAITING state (it should be enough);
   - the state machine would be different in the session setup: in
 STATE_WAITING handle WRQ packets and select a new UDP port;
   - after the setup phase, the state machine would converge on the
 currently-implemented STATE_DATA for normal DATA/ACK management.

Do you think my approach is correct?
Would this feature be considered for mainline inclusion?

Thanks in advance,
Luca


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC] Act as a TFTP server

2011-04-13 Thread Luca Ceresoli
Wolfgang,
thanks for the feedback.

Wolfgang Denk wrote:

> ...
>>From the user point of view, I would implement a new command, activated 
>> only
>> when CONFIG_CMD_TFTPSRV is defined:
>>
>> Usage:tftpsrv []
>>
>> This would be used almost like tftpboot, except no file name is specified on
>> the commandline.
>>would default to the environment variable.
> I see some user interface issues here:
> - When and how do you terminate this command?  After a successful
>download, ok.  But how long do we wait for that?  Forever? Or do we
>time out?
The TFTP client tries sending a RRQ packet TIMEOUT_COUNT times (default 10),
spaced TIMEOUT msecs (default 5000) from each other. 50 seconds total by 
default.

I would keep the same scheme for the server, except it would obviously not send
anything after each timeout. This would allow to print something every 5 
seconds,
for user feedback.

> - It would be nice if the user could terminate the command using ^C.
Sure. The main loop in NetLoop() would be unchanged, so I expect ctrlc() to work
for free in the same way it does for the TFTP client.

Luca


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC] Act as a TFTP server

2011-04-14 Thread Luca Ceresoli
Luca Ceresoli wrote:

> - net/tftp.c: extend the TFTP state machine (TftpHandler() and TftpStart())
> a new STATE_WAITING state (it should be enough);
> - the state machine would be different in the session setup: in
>   STATE_WAITING handle WRQ packets and select a new UDP port;
> - after the setup phase, the state machine would converge on the
>   currently-implemented STATE_DATA for normal DATA/ACK management.
Right now the TFTP server is working here, but before submitting patches I
have a question about the TftpHandler() callback function.

TftpHandler() is of type:

include/net.h:80: typedef void rxhand_f(uchar *, unsigned, unsigned, unsigned);

The 4 parameters are: packet pointer, UDP source port, UDP destination
port and packet length.

Upon reception of a Write Request packet, the TFTP server needs to know the
remote (client) IP address, or it won't be able to send any packet back.

This is different from currently implemented network file transfer modes,
which are always initiated by U-Boot in client mode, and thus the remote
(server) IP address is known a priori.

I plan to add a new parameter to the rxhand_t, and change accordingly all
handlers to have the new (unused) parameter:

- typedef void rxhand_f(uchar *, unsigned, unsigned, unsigned);
+ typedef void rxhand_f(uchar *pkt, unsigned dest_port,
 IPaddr_t src_ip, unsigned src_port,
 unsigned len);

Is this ok, or do you foresee any issues with the function footprint or
anything else?

Thanks,
Luca


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 0/6] TFTP server

2011-04-14 Thread Luca Ceresoli
This patch series adds to U-Boot the ability to receive a file via TFTP acting
as a server, not a client.

The implementation is kept simple:
- receive only (accept WRQ from remote client, not RRQ);
- the Filename in the WRQ is ignored: the destination is always a user-provided
  memory location;
- binary transfers only: the Mode in the WRQ is ignored; this is allowed by
  RFC1350 (section 5);
- no TFTP Option Extensions (RFC2347);
- no TFTP multicast.

The implementation is discussed here:
http://lists.denx.de/pipermail/u-boot/2011-April/090405.html

Once it has started, the server is stopped like the client is: on a complete
file reception, Ctrl-C and after waiting 5 seconds for 10 times.

The first four patches are preliminary cleanups and extensions to the current
code. Most important, the second patch adds to incoming packet handlers an
argument containing the source IP address, and has impact in many places in
the networking code.

The fifth patch implements the core TFTP server.

The last patch adds a user command to launch the server.

A note about checkpatch.pl.
Some of these patches do have checkpatch errors and/or warnings. These are all
issues that were already present in the pre-existing code.
An example from patch 2:

 static void
-PingHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
+PingHandler (uchar * pkt, unsigned dest, IPaddr_t sip, unsigned src,
+unsigned len)
 {

Raises:
* ERROR: "foo * bar" should be "foo *bar"
* WARNING: space prohibited between function name and open parenthesis '('

As I didn't touch the pointer parameters nor the stuff before the '(' (but I
changed the line somewhere else), should I also fix the checkpatch issues?
And in case, should it be a separate patch to make it cleaner?

Also please take a look at the note in patch number 5.

Luca

Luca Ceresoli (6):
  README: remove spurious line
  NET: pass source IP address to packet handlers
  TFTP: rename "server" to "remote"
  TFTP: rename STATE_RRQ to STATE_SEND_RRQ
  TFTP: net/tftp.c: add server mode receive
  TFTP: add tftpsrv command

 README   |2 +-
 common/cmd_net.c |   14 ++
 drivers/net/netconsole.c |5 +-
 include/net.h|   18 +---
 net/bootp.c  |9 +++-
 net/dns.c|2 +-
 net/net.c|   35 +--
 net/nfs.c|2 +-
 net/rarp.c   |3 +-
 net/sntp.c   |3 +-
 net/tftp.c   |  109 -
 net/tftp.h   |6 +++
 12 files changed, 157 insertions(+), 51 deletions(-)

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/6] README: remove spurious line

2011-04-14 Thread Luca Ceresoli
Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
 README |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/README b/README
index 4917e26..b9b0fcb 100644
--- a/README
+++ b/README
@@ -1299,7 +1299,6 @@ The following options need to be configured:
driver in use must provide a function: mcast() to join/leave a
multicast group.
 
-   CONFIG_BOOTP_RANDOM_DELAY
 - BOOTP Recovery Mode:
CONFIG_BOOTP_RANDOM_DELAY
 
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/6] NET: pass source IP address to packet handlers

2011-04-14 Thread Luca Ceresoli
This is needed for the upcoming TFTP server implementation.

This also simplifies PingHandler() and fixes rxhand_f documentation.

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
 drivers/net/netconsole.c |5 +++--
 include/net.h|   15 ++-
 net/bootp.c  |9 ++---
 net/dns.c|2 +-
 net/net.c|   25 ++---
 net/nfs.c|2 +-
 net/rarp.c   |3 ++-
 net/sntp.c   |3 ++-
 net/tftp.c   |3 ++-
 9 files changed, 41 insertions(+), 26 deletions(-)

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index e27bb3e..ed753d1 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -40,13 +40,14 @@ static short nc_port;   /* 
source/target port */
 static const char *output_packet;  /* used by first send udp */
 static int output_packet_len = 0;
 
-static void nc_wait_arp_handler (uchar * pkt, unsigned dest, unsigned src,
+static void nc_wait_arp_handler (uchar * pkt, unsigned dest,
+IPaddr_t sip, unsigned src,
 unsigned len)
 {
NetState = NETLOOP_SUCCESS; /* got arp reply - quit net loop */
 }
 
-static void nc_handler (uchar * pkt, unsigned dest, unsigned src,
+static void nc_handler (uchar * pkt, unsigned dest, IPaddr_t sip, unsigned src,
unsigned len)
 {
if (input_size)
diff --git a/include/net.h b/include/net.h
index 95ef8ab..01f7159 100644
--- a/include/net.h
+++ b/include/net.h
@@ -72,12 +72,17 @@
 typedef ulong  IPaddr_t;
 
 
-/*
- * The current receive packet handler.  Called with a pointer to the
- * application packet, and a protocol type (PORT_BOOTPC or PORT_TFTP).
- * All other packets are dealt with without calling the handler.
+/**
+ * An incoming packet handler.
+ * @param pktpointer to the application packet
+ * @param dport  destination UDP port
+ * @param sipsource IP address
+ * @param sport  source UDP port
+ * @param lenpacket length
  */
-typedef void   rxhand_f(uchar *, unsigned, unsigned, unsigned);
+typedef void rxhand_f(uchar *pkt, unsigned dport,
+ IPaddr_t sip, unsigned sport,
+ unsigned len);
 
 /*
  * A timeout handler.  Called after time interval has expired.
diff --git a/net/bootp.c b/net/bootp.c
index 87b027e..eafaae2 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -44,7 +44,8 @@ ulong seed1, seed2;
 dhcp_state_t dhcp_state = INIT;
 unsigned long dhcp_leasetime = 0;
 IPaddr_t NetDHCPServerIP = 0;
-static void DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned 
len);
+static void DhcpHandler(uchar * pkt, unsigned dest, IPaddr_t sip, unsigned src,
+   unsigned len);
 
 /* For Debug */
 #if 0
@@ -282,7 +283,8 @@ static void BootpVendorProcess (u8 * ext, int size)
  * Handle a BOOTP received packet.
  */
 static void
-BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+BootpHandler(uchar * pkt, unsigned dest, IPaddr_t sip, unsigned src,
+unsigned len)
 {
Bootp_t *bp;
char*s;
@@ -858,7 +860,8 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
  * Handle DHCP received packets.
  */
 static void
-DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+DhcpHandler(uchar * pkt, unsigned dest, IPaddr_t sip, unsigned src,
+   unsigned len)
 {
Bootp_t *bp = (Bootp_t *)pkt;
 
diff --git a/net/dns.c b/net/dns.c
index bb3e3f5..b51d1bd 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -101,7 +101,7 @@ DnsTimeout(void)
 }
 
 static void
-DnsHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len)
+DnsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)
 {
struct header *header;
const unsigned char *p, *e, *s;
diff --git a/net/net.c b/net/net.c
index a609632..79afd8b 100644
--- a/net/net.c
+++ b/net/net.c
@@ -555,7 +555,8 @@ startAgainTimeout(void)
 }
 
 static void
-startAgainHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+startAgainHandler(uchar * pkt, unsigned dest, IPaddr_t sip,
+ unsigned src, unsigned len)
 {
/* Totally ignore the packet */
 }
@@ -752,13 +753,10 @@ PingTimeout (void)
 }
 
 static void
-PingHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
+PingHandler (uchar * pkt, unsigned dest, IPaddr_t sip, unsigned src,
+unsigned len)
 {
-   IPaddr_t tmp;
-   volatile IP_t *ip = (volatile IP_t *)pkt;
-
-   tmp = NetReadIP((void *)&ip->ip_src);
-   if (tmp != NetPingIP)
+   if (sip != NetPingIP)
return;
 
NetState = NETLOOP_SUCCESS;
@@ -990,7 +988,8 @@ CDPTimeout (void)
 }
 
 static void
-CDPDummyHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
+CDPDummyHandler (uchar * pkt, unsigned dest, IPaddr_t sip, unsig

[U-Boot] [PATCH 3/6] TFTP: rename "server" to "remote"

2011-04-14 Thread Luca Ceresoli
With the upcoming TFTP server implementation, the remote node can be
either a client or a server, so avoid ambiguities.

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
 net/tftp.c |   28 ++--
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/net/tftp.c b/net/tftp.c
index 8e6df0a..42469e7 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -55,8 +55,8 @@ enum {
TFTP_ERR_FILE_ALREADY_EXISTS = 6,
 };
 
-static IPaddr_t TftpServerIP;
-static int TftpServerPort; /* The UDP port at their end
*/
+static IPaddr_t TftpRemoteIP;
+static int TftpRemotePort; /* The UDP port at their end
*/
 static int TftpOurPort;/* The UDP port at our end  
*/
 static int TftpTimeoutCount;
 static ulong   TftpBlock;  /* packet sequence number   
*/
@@ -273,7 +273,8 @@ TftpSend (void)
break;
}
 
-   NetSendUDPPacket(NetServerEther, TftpServerIP, TftpServerPort, 
TftpOurPort, len);
+   NetSendUDPPacket(NetServerEther, TftpRemoteIP, TftpRemotePort,
+TftpOurPort, len);
 }
 
 
@@ -292,9 +293,8 @@ TftpHandler (uchar * pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
 #endif
return;
}
-   if (TftpState != STATE_RRQ && src != TftpServerPort) {
+   if (TftpState != STATE_RRQ && src != TftpRemotePort)
return;
-   }
 
if (len < 2) {
return;
@@ -318,7 +318,7 @@ TftpHandler (uchar * pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
pkt,
pkt + strlen((char *)pkt) + 1);
TftpState = STATE_OACK;
-   TftpServerPort = src;
+   TftpRemotePort = src;
/*
 * Check for 'blksize' option.
 * Careful: "i" is signed, "len" is unsigned, thus
@@ -386,7 +386,7 @@ TftpHandler (uchar * pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
if (TftpState == STATE_RRQ || TftpState == STATE_OACK) {
/* first block received */
TftpState = STATE_DATA;
-   TftpServerPort = src;
+   TftpRemotePort = src;
TftpLastBlock = 0;
TftpBlockWrap = 0;
TftpBlockWrapOffset = 0;
@@ -421,7 +421,7 @@ TftpHandler (uchar * pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
 
/*
 *  Acknoledge the block just received, which will prompt
-*  the server for the next one.
+*  the remote for the next one.
 */
 #ifdef CONFIG_MCAST_TFTP
/* if I am the MasterClient, actively calculate what my next
@@ -548,7 +548,7 @@ TftpStart (void)
debug("TFTP blocksize = %i, timeout = %ld ms\n",
TftpBlkSizeOption, TftpTimeoutMSecs);
 
-   TftpServerIP = NetServerIP;
+   TftpRemoteIP = NetServerIP;
if (BootFile[0] == '\0') {
sprintf(default_filename, "%02lX%02lX%02lX%02lX.img",
NetOurIP & 0xFF,
@@ -568,7 +568,7 @@ TftpStart (void)
strncpy(tftp_filename, BootFile, MAX_LEN);
tftp_filename[MAX_LEN-1] = 0;
} else {
-   TftpServerIP = string_to_ip (BootFile);
+   TftpRemoteIP = string_to_ip(BootFile);
strncpy(tftp_filename, p + 1, MAX_LEN);
tftp_filename[MAX_LEN-1] = 0;
}
@@ -578,12 +578,12 @@ TftpStart (void)
printf ("Using %s device\n", eth_get_name());
 #endif
printf("TFTP from server %pI4"
-   "; our IP address is %pI4", &TftpServerIP, &NetOurIP);
+   "; our IP address is %pI4", &TftpRemoteIP, &NetOurIP);
 
/* Check if we need to send across this subnet */
if (NetOurGatewayIP && NetOurSubnetMask) {
IPaddr_t OurNet = NetOurIP& NetOurSubnetMask;
-   IPaddr_t ServerNet  = TftpServerIP & NetOurSubnetMask;
+   IPaddr_t ServerNet  = TftpRemoteIP & NetOurSubnetMask;
 
if (OurNet != ServerNet)
printf("; sending through gateway %pI4", &NetOurGatewayIP);
@@ -608,7 +608,7 @@ TftpStart (void)
NetSetTimeout (TftpTimeoutMSecs, TftpTimeout);
NetSetHandler (TftpHandler);
 
-   TftpServerPort = WELL_KNOWN_PORT;
+   TftpRemotePort = WELL_KNOWN_PORT;
TftpTimeoutCount = 0;
TftpState = STATE_RRQ;
/* Use a pseudo-random port unless a specific port is set */
@@ -616,7 +616,7 @@ TftpStart (void)
 
 #ifdef CONFIG_TFTP_PORT
if ((ep = getenv("tftpdstp")) != NULL

[U-Boot] [PATCH 4/6] TFTP: rename STATE_RRQ to STATE_SEND_RRQ

2011-04-14 Thread Luca Ceresoli
With the upcoming TFTP server implementation, requests can be either
outgoing or incoming, so avoid ambiguities.

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
 net/tftp.c |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/tftp.c b/net/tftp.c
index 42469e7..2c96358 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -69,7 +69,7 @@ static intTftpTsize;  /* The file size 
reported by the server */
 static short   TftpNumchars;   /* The number of hashes we printed  
*/
 #endif
 
-#define STATE_RRQ  1
+#define STATE_SEND_RRQ 1
 #define STATE_DATA 2
 #define STATE_TOO_LARGE3
 #define STATE_BAD_MAGIC4
@@ -200,7 +200,7 @@ TftpSend (void)
 
switch (TftpState) {
 
-   case STATE_RRQ:
+   case STATE_SEND_RRQ:
xp = pkt;
s = (ushort *)pkt;
*s++ = htons(TFTP_RRQ);
@@ -293,7 +293,7 @@ TftpHandler (uchar * pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
 #endif
return;
}
-   if (TftpState != STATE_RRQ && src != TftpRemotePort)
+   if (TftpState != STATE_SEND_RRQ && src != TftpRemotePort)
return;
 
if (len < 2) {
@@ -380,10 +380,10 @@ TftpHandler (uchar * pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
}
}
 
-   if (TftpState == STATE_RRQ)
+   if (TftpState == STATE_SEND_RRQ)
debug("Server did not acknowledge timeout option!\n");
 
-   if (TftpState == STATE_RRQ || TftpState == STATE_OACK) {
+   if (TftpState == STATE_SEND_RRQ || TftpState == STATE_OACK) {
/* first block received */
TftpState = STATE_DATA;
TftpRemotePort = src;
@@ -610,7 +610,7 @@ TftpStart (void)
 
TftpRemotePort = WELL_KNOWN_PORT;
TftpTimeoutCount = 0;
-   TftpState = STATE_RRQ;
+   TftpState = STATE_SEND_RRQ;
/* Use a pseudo-random port unless a specific port is set */
TftpOurPort = 1024 + (get_timer(0) % 3072);
 
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 5/6] TFTP: net/tftp.c: add server mode receive

2011-04-14 Thread Luca Ceresoli
Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---

A note on the style of this patch.
There are many hunks like this:

> - if (TftpState != STATE_SEND_RRQ && src != TftpRemotePort)
> + if (TftpState != STATE_SEND_RRQ &&
> +#ifdef CONFIG_CMD_TFTPSRV
> + TftpState != STATE_RECV_WRQ &&
> +#endif
> + src != TftpRemotePort)

where I put a comparison between TftpState and STATE_RECV_WRQ in #ifdefs.

The #ifdef is not necessary, as both TftpState and STATE_RECV_WRQ are defined
even when CONFIG_CMD_TFTPSRV is off. Simply, TftpState can never be equal to
STATE_RECV_WRQ.

I've put the #ifdefs with the intention of optimizing the code as much as
possible, avoiding a comparison that would be always true (or always false).
I understand that this makes the code a lot more difficult to read.

Should I instead remote the #ifdefs and make the code more readable (but less
optimized)?

Thanks,
Luca


 net/tftp.c |   72 ---
 net/tftp.h |6 +
 2 files changed, 74 insertions(+), 4 deletions(-)

diff --git a/net/tftp.c b/net/tftp.c
index 2c96358..c586a9f 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -2,6 +2,8 @@
  * Copyright 1994, 1995, 2000 Neil Russell.
  * (See License)
  * Copyright 2000, 2001 DENX Software Engineering, Wolfgang Denk, 
w...@denx.de
+ * Copyright 2011 Comelit Group SpA,
+ *Luca Ceresoli 
  */
 
 #include 
@@ -74,6 +76,7 @@ static short  TftpNumchars;   /* The number of hashes 
we printed  */
 #define STATE_TOO_LARGE3
 #define STATE_BAD_MAGIC4
 #define STATE_OACK 5
+#define STATE_RECV_WRQ 6
 
 #define TFTP_BLOCK_SIZE512 /* default TFTP 
block size  */
 #define TFTP_SEQUENCE_SIZE ((ulong)(1<<16))/* sequence number is 16 
bit */
@@ -241,6 +244,10 @@ TftpSend (void)
TftpBlock=ext2_find_next_zero_bit(Bitmap,(Mapsize*8),0);
/*..falling..*/
 #endif
+
+#ifdef CONFIG_CMD_TFTPSRV
+   case STATE_RECV_WRQ:
+#endif
case STATE_DATA:
xp = pkt;
s = (ushort *)pkt;
@@ -293,7 +300,11 @@ TftpHandler (uchar * pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
 #endif
return;
}
-   if (TftpState != STATE_SEND_RRQ && src != TftpRemotePort)
+   if (TftpState != STATE_SEND_RRQ &&
+#ifdef CONFIG_CMD_TFTPSRV
+   TftpState != STATE_RECV_WRQ &&
+#endif
+   src != TftpRemotePort)
return;
 
if (len < 2) {
@@ -307,12 +318,24 @@ TftpHandler (uchar * pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
switch (ntohs(proto)) {
 
case TFTP_RRQ:
-   case TFTP_WRQ:
case TFTP_ACK:
break;
default:
break;
 
+#ifdef CONFIG_CMD_TFTPSRV
+   case TFTP_WRQ:
+   debug("Got WRQ\n");
+   TftpRemoteIP = sip;
+   TftpRemotePort = src;
+   TftpOurPort = 1024 + (get_timer(0) % 3072);
+   TftpLastBlock = 0;
+   TftpBlockWrap = 0;
+   TftpBlockWrapOffset = 0;
+   TftpSend(); /* Send ACK(0) */
+   break;
+#endif
+
case TFTP_OACK:
debug("Got OACK: %s %s\n",
pkt,
@@ -383,7 +406,11 @@ TftpHandler (uchar * pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
if (TftpState == STATE_SEND_RRQ)
debug("Server did not acknowledge timeout option!\n");
 
-   if (TftpState == STATE_SEND_RRQ || TftpState == STATE_OACK) {
+   if (TftpState == STATE_SEND_RRQ ||
+#ifdef CONFIG_CMD_TFTPSRV
+   TftpState == STATE_RECV_WRQ ||
+#endif
+   TftpState == STATE_OACK) {
/* first block received */
TftpState = STATE_DATA;
TftpRemotePort = src;
@@ -518,7 +545,10 @@ TftpTimeout (void)
} else {
puts ("T ");
NetSetTimeout (TftpTimeoutMSecs, TftpTimeout);
-   TftpSend ();
+#ifdef CONFIG_CMD_TFTPSRV
+   if (TftpState != STATE_RECV_WRQ)
+#endif
+   TftpSend();
}
 }
 
@@ -639,6 +669,40 @@ TftpStart (void)
TftpSend ();
 }
 
+#ifdef CONFIG_CMD_TFTPSRV
+void
+TftpStartServer(void)
+{
+   tftp_filename[0] = 0;
+
+#if defined(CONFIG_NET_MULTI)
+   printf("Using %s device\n", eth_get_name());
+#endif
+   printf("Listening for TFTP transfer on %pI4\n", &NetOurIP);
+   printf("Load address: 0x%lx\n", load_addr);
+
+   puts("Loading: *\b");
+
+   TftpTimeoutCountMax = TIMEOUT_COUNT;
+   TftpTimeoutCount = 0;
+   TftpTimeoutMSecs = TIMEOUT;
+   NetSetTimeout(TftpTimeoutMSecs, Tft

[U-Boot] [PATCH 6/6] TFTP: add tftpsrv command

2011-04-14 Thread Luca Ceresoli
Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
 README   |1 +
 common/cmd_net.c |   14 ++
 include/net.h|3 ++-
 net/net.c|   10 --
 4 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/README b/README
index b9b0fcb..83dcb2a 100644
--- a/README
+++ b/README
@@ -685,6 +685,7 @@ The following options need to be configured:
  (requires CONFIG_CMD_MEMORY)
CONFIG_CMD_SOURCE "source" command Support
CONFIG_CMD_SPI  * SPI serial bus support
+   CONFIG_CMD_TFTPSRV  * TFTP transfer in server mode
CONFIG_CMD_USB  * USB support
CONFIG_CMD_VFD  * VFD support (TRAB)
CONFIG_CMD_CDP  * Cisco Discover Protocol support
diff --git a/common/cmd_net.c b/common/cmd_net.c
index 8c6f5c8..053162a 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -52,6 +52,20 @@ U_BOOT_CMD(
"[loadAddress] [[hostIPaddr:]bootfilename]"
 );
 
+#ifdef CONFIG_CMD_TFTPSRV
+int do_tftpsrv(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+   return netboot_common(TFTPSRV, cmdtp, argc, argv);
+}
+
+U_BOOT_CMD(
+   tftpsrv,2,  1,  do_tftpsrv,
+   "boot image via network acting as a TFTP server",
+   "[loadAddress]"
+);
+#endif
+
+
 #ifdef CONFIG_CMD_RARP
 int do_rarpb (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
diff --git a/include/net.h b/include/net.h
index 01f7159..018a744 100644
--- a/include/net.h
+++ b/include/net.h
@@ -364,7 +364,8 @@ extern int  NetState;   /* Network loop 
state   */
 extern int NetRestartWrap; /* Tried all network devices
*/
 #endif
 
-typedef enum { BOOTP, RARP, ARP, TFTP, DHCP, PING, DNS, NFS, CDP, NETCONS, 
SNTP } proto_t;
+typedef enum { BOOTP, RARP, ARP, TFTP, DHCP, PING, DNS, NFS, CDP, NETCONS, 
SNTP,
+  TFTPSRV } proto_t;
 
 /* from net/net.c */
 extern charBootFile[128];  /* Boot File name   
*/
diff --git a/net/net.c b/net/net.c
index 79afd8b..a9a2f8b 100644
--- a/net/net.c
+++ b/net/net.c
@@ -388,7 +388,11 @@ restart:
/* always use ARP to get server ethernet address */
TftpStart();
break;
-
+#ifdef CONFIG_CMD_TFTPSRV
+   case TFTPSRV:
+   TftpStartServer();
+   break;
+#endif
 #if defined(CONFIG_CMD_DHCP)
case DHCP:
BootpTry = 0;
@@ -1730,7 +1734,9 @@ static int net_check_prereq (proto_t protocol)
 #if defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP)
 common:
 #endif
-
+#ifdef CONFIG_CMD_TFTPSRV
+   case TFTPSRV:
+#endif
if (NetOurIP == 0) {
puts ("*** ERROR: `ipaddr' not set\n");
return (1);
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 0/4] Add DIG297 board and OMAP3 fixes

2011-04-15 Thread Luca Ceresoli
Hi all,

this patch series cleans up some OMAP3 stuff and adds DIG297 board support.

New in v4:
 - patch 2 gets rid of some ugly extern variables in mem.c;
 - patch 3 creates a new file for register definitions (inspired by the pxa and
   imx code base), and defines GPMC_CONFIGx register values.

Luca

Luca Ceresoli (4):
  ARMV7: OMAP3: Fix preprocessor check for CONFIG_OMAP34XX
  ARMV7: OMAP3: Cleanup extern variables in mem.c
  ARMV7: OMAP3: Add GPMC_CONFIGx register value definitions
  ARMV7: OMAP3: Add support for Comelit DIG297 board

 MAINTAINERS  |4 +
 MAKEALL  |1 +
 arch/arm/cpu/armv7/omap3/mem.c   |   32 ---
 arch/arm/cpu/armv7/start.S   |2 +-
 arch/arm/include/asm/arch-omap3/omap3-regs.h |   95 +++
 board/comelit/dig297/Makefile|   49 
 board/comelit/dig297/dig297.c|  187 +
 board/comelit/dig297/dig297.h|  383 ++
 boards.cfg   |1 +
 include/configs/am3517_evm.h |   18 +-
 include/configs/cm_t35.h |   16 +-
 include/configs/devkit8000.h |   10 +-
 include/configs/dig297.h |  311 +
 include/configs/omap3_beagle.h   |   16 +-
 include/configs/omap3_evm.h  |   26 +-
 include/configs/omap3_overo.h|   16 +-
 include/configs/omap3_pandora.h  |   16 +-
 include/configs/omap3_sdp3430.h  |   10 -
 include/configs/omap3_zoom1.h|   16 +-
 include/configs/omap3_zoom2.h|   16 +-
 20 files changed, 1081 insertions(+), 144 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-omap3/omap3-regs.h
 create mode 100644 board/comelit/dig297/Makefile
 create mode 100644 board/comelit/dig297/dig297.c
 create mode 100644 board/comelit/dig297/dig297.h
 create mode 100644 include/configs/dig297.h

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/4] ARMV7: OMAP3: Fix preprocessor check for CONFIG_OMAP34XX

2011-04-15 Thread Luca Ceresoli
CONFIG_OMAP34XX must be checked for existence, not value.

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Albert Aribaud 
Cc: Sandeep Paulraj 
---
Changes in v2:
 - this patch is new in v2.

Changes in v3: none.

Changes in v4: none.

 arch/arm/cpu/armv7/start.S |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
index d83d501..6387b8b 100644
--- a/arch/arm/cpu/armv7/start.S
+++ b/arch/arm/cpu/armv7/start.S
@@ -115,7 +115,7 @@ reset:
orr r0, r0, #0xd3
msr cpsr,r0
 
-#if (CONFIG_OMAP34XX)
+#if defined(CONFIG_OMAP34XX)
/* Copy vectors to mask ROM indirect addr */
adr r0, _start  @ r0 <- current position of code
add r0, r0, #4  @ skip reset vector
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/4] ARMV7: OMAP3: Cleanup extern variables in mem.c

2011-04-15 Thread Luca Ceresoli
Removed boot_flash_* extern variables.
boot_flash_type was totally unused. The other ones were actually constants, so
they have been replaced with #defines in the board config files.

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Albert Aribaud 
Cc: Sandeep Paulraj 
---
Changes in v4:
 - this patch is new in v4.

 arch/arm/cpu/armv7/omap3/mem.c  |   32 
 include/configs/am3517_evm.h|   18 ++
 include/configs/cm_t35.h|   16 +---
 include/configs/devkit8000.h|   10 +-
 include/configs/omap3_beagle.h  |   16 +---
 include/configs/omap3_evm.h |   26 --
 include/configs/omap3_overo.h   |   16 +---
 include/configs/omap3_pandora.h |   16 +---
 include/configs/omap3_sdp3430.h |   10 --
 include/configs/omap3_zoom1.h   |   16 +---
 include/configs/omap3_zoom2.h   |   16 +---
 11 files changed, 49 insertions(+), 143 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap3/mem.c b/arch/arm/cpu/armv7/omap3/mem.c
index bd914b0..a01c303 100644
--- a/arch/arm/cpu/armv7/omap3/mem.c
+++ b/arch/arm/cpu/armv7/omap3/mem.c
@@ -31,16 +31,6 @@
 #include 
 #include 
 
-/*
- * Only One NAND allowed on board at a time.
- * The GPMC CS Base for the same
- */
-unsigned int boot_flash_base;
-unsigned int boot_flash_off;
-unsigned int boot_flash_sec;
-unsigned int boot_flash_type;
-volatile unsigned int boot_flash_env_addr;
-
 struct gpmc *gpmc_cfg;
 
 #if defined(CONFIG_CMD_NAND)
@@ -134,10 +124,6 @@ void gpmc_init(void)
const u32 *gpmc_config = NULL;
u32 base = 0;
u32 size = 0;
-#if defined(CONFIG_ENV_IS_IN_NAND) || defined(CONFIG_ENV_IS_IN_ONENAND)
-   u32 f_off = CONFIG_SYS_MONITOR_LEN;
-   u32 f_sec = 0;
-#endif
 #endif
u32 config = 0;
 
@@ -162,15 +148,6 @@ void gpmc_init(void)
base = PISMO1_NAND_BASE;
size = PISMO1_NAND_SIZE;
enable_gpmc_cs_config(gpmc_config, &gpmc_cfg->cs[0], base, size);
-#if defined(CONFIG_ENV_IS_IN_NAND)
-   f_off = SMNAND_ENV_OFFSET;
-   f_sec = (128 << 10);/* 128 KiB */
-   /* env setup */
-   boot_flash_base = base;
-   boot_flash_off = f_off;
-   boot_flash_sec = f_sec;
-   boot_flash_env_addr = f_off;
-#endif
 #endif
 
 #if defined(CONFIG_CMD_ONENAND)
@@ -178,14 +155,5 @@ void gpmc_init(void)
base = PISMO1_ONEN_BASE;
size = PISMO1_ONEN_SIZE;
enable_gpmc_cs_config(gpmc_config, &gpmc_cfg->cs[0], base, size);
-#if defined(CONFIG_ENV_IS_IN_ONENAND)
-   f_off = ONENAND_ENV_OFFSET;
-   f_sec = (128 << 10);/* 128 KiB */
-   /* env setup */
-   boot_flash_base = base;
-   boot_flash_off = f_off;
-   boot_flash_sec = f_sec;
-   boot_flash_env_addr = f_off;
-#endif
 #endif
 }
diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
index 70e8f07..f5d5821 100644
--- a/include/configs/am3517_evm.h
+++ b/include/configs/am3517_evm.h
@@ -294,7 +294,9 @@
 #define CONFIG_SYS_MAX_FLASH_BANKS 2   /* max number of flash banks */
 #define CONFIG_SYS_MONITOR_LEN (256 << 10) /* Reserve 2 sectors */
 
-#define CONFIG_SYS_FLASH_BASE  boot_flash_base
+#if defined(CONFIG_CMD_NAND)
+#define CONFIG_SYS_FLASH_BASE  PISMO1_NAND_BASE
+#endif
 
 /* Monitor at start of flash */
 #define CONFIG_SYS_MONITOR_BASECONFIG_SYS_FLASH_BASE
@@ -304,9 +306,9 @@
 #define CONFIG_ENV_IS_IN_NAND  1
 #define SMNAND_ENV_OFFSET  0x26 /* environment starts here */
 
-#define CONFIG_SYS_ENV_SECT_SIZE   boot_flash_sec
-#define CONFIG_ENV_OFFSET  boot_flash_off
-#define CONFIG_ENV_ADDRboot_flash_env_addr
+#define CONFIG_SYS_ENV_SECT_SIZE   (128 << 10) /* 128 KiB */
+#define CONFIG_ENV_OFFSET  SMNAND_ENV_OFFSET
+#define CONFIG_ENV_ADDRSMNAND_ENV_OFFSET
 
 /*---
  * CFI FLASH driver setup
@@ -323,14 +325,6 @@
 #define CONFIG_SYS_JFFS2_FIRST_BANKCONFIG_SYS_MAX_FLASH_BANKS
 #define CONFIG_SYS_JFFS2_NUM_BANKS 1
 
-#ifndef __ASSEMBLY__
-extern unsigned int boot_flash_base;
-extern volatile unsigned int boot_flash_env_addr;
-extern unsigned int boot_flash_off;
-extern unsigned int boot_flash_sec;
-extern unsigned int boot_flash_type;
-#endif
-
 #define CONFIG_SYS_SDRAM_BASE  PHYS_SDRAM_1
 #define CONFIG_SYS_INIT_RAM_ADDR   0x4020f800
 #define CONFIG_SYS_INIT_RAM_SIZE   0x800
diff --git a/include/configs/cm_t35.h b/include/configs/cm_t35.h
index 510c6d4..ee9175d 100644
--- a/include/configs/cm_t35.h
+++ b/include/configs/cm_t35.h
@@ -310,7 +310,9 @@
 
 #define CONFIG_SYS_MONITOR_LEN (256 << 10) /* Reserve 2 sectors */
 
-#define CONFIG_SYS_FLASH_BASE  boot_flash_base
+#if defined(CONFIG_CMD_NAND)
+#define CON

[U-Boot] [PATCH 3/4] ARMV7: OMAP3: Add GPMC_CONFIGx register value definitions

2011-04-15 Thread Luca Ceresoli
Signed-off-by: Luca Ceresoli 
---
Changes in v4:
 - this patch is new in v4.

 arch/arm/include/asm/arch-omap3/omap3-regs.h |   95 ++
 1 files changed, 95 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-omap3/omap3-regs.h

diff --git a/arch/arm/include/asm/arch-omap3/omap3-regs.h 
b/arch/arm/include/asm/arch-omap3/omap3-regs.h
new file mode 100644
index 000..818214f
--- /dev/null
+++ b/arch/arm/include/asm/arch-omap3/omap3-regs.h
@@ -0,0 +1,95 @@
+/*
+ * (c) 2011 Comelit Group SpA, Luca Ceresoli 
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _OMAP3_REGS_H
+#define _OMAP3_REGS_H
+
+/*
+ * Register definitions for OMAP3 processors.
+ */
+
+/*
+ * GPMC_CONFIG1 - GPMC_CONFIG7
+ */
+
+/* Values for GPMC_CONFIG1 - signal control parameters */
+#define WRAPBURST (1 << 31)
+#define READMULTIPLE  (1 << 30)
+#define READTYPE  (1 << 29)
+#define WRITEMULTIPLE (1 << 28)
+#define WRITETYPE (1 << 27)
+#define CLKACTIVATIONTIME(x)  (((x) & 3) << 25)
+#define ATTACHEDDEVICEPAGELENGTH(x)   (((x) & 3) << 23)
+#define WAITREADMONITORING(1 << 22)
+#define WAITWRITEMONITORING   (1 << 21)
+#define WAITMONITORINGTIME(x) (((x) & 3) << 18)
+#define WAITPINSELECT(x)  (((x) & 3) << 16)
+#define DEVICESIZE(x) (((x) & 3) << 12)
+#define DEVICESIZE_8BIT   DEVICESIZE(0)
+#define DEVICESIZE_16BIT  DEVICESIZE(1)
+#define DEVICETYPE(x) (((x) & 3) << 10)
+#define DEVICETYPE_NORDEVICETYPE(0)
+#define DEVICETYPE_NAND   DEVICETYPE(2)
+#define MUXADDDATA(1 << 9)
+#define TIMEPARAGRANULARITY   (1 << 4)
+#define GPMCFCLKDIVIDER(x)(((x) & 3) << 0)
+
+/* Values for GPMC_CONFIG2 - CS timing */
+#define CSWROFFTIME(x)   (((x) & 0x1f) << 16)
+#define CSRDOFFTIME(x)   (((x) & 0x1f) <<  8)
+#define CSEXTRADELAY (1 << 7)
+#define CSONTIME(x)  (((x) &  0xf) <<  0)
+
+/* Values for GPMC_CONFIG3 - nADV timing */
+#define ADVWROFFTIME(x)  (((x) & 0x1f) << 16)
+#define ADVRDOFFTIME(x)  (((x) & 0x1f) <<  8)
+#define ADVEXTRADELAY(1 << 7)
+#define ADVONTIME(x) (((x) &  0xf) <<  0)
+
+/* Values for GPMC_CONFIG4 - nWE and nOE timing */
+#define WEOFFTIME(x) (((x) & 0x1f) << 24)
+#define WEEXTRADELAY (1 << 23)
+#define WEONTIME(x)  (((x) &  0xf) << 16)
+#define OEOFFTIME(x) (((x) & 0x1f) <<  8)
+#define OEEXTRADELAY (1 << 7)
+#define OEONTIME(x)  (((x) &  0xf) <<  0)
+
+/* Values for GPMC_CONFIG5 - RdAccessTime and CycleTime timing */
+#define PAGEBURSTACCESSTIME(x)  (((x) &  0xf) << 24)
+#define RDACCESSTIME(x) (((x) & 0x1f) << 16)
+#define WRCYCLETIME(x)  (((x) & 0x1f) <<  8)
+#define RDCYCLETIME(x)  (((x) & 0x1f) <<  0)
+
+/* Values for GPMC_CONFIG6 - misc timings */
+#define WRACCESSTIME(x)(((x) & 0x1f) << 24)
+#define WRDATAONADMUXBUS(x)(((x) &  0xf) << 16)
+#define CYCLE2CYCLEDELAY(x)(((x) &  0xf) <<  8)
+#define CYCLE2CYCLESAMECSEN(1 << 7)
+#define CYCLE2CYCLEDIFFCSEN(1 << 6)
+#define BUSTURNAROUND(x)   (((x) &  0xf) <<  0)
+
+/* Values for GPMC_CONFIG7 - CS address mapping configuration */
+#define MASKADDRESS(x) (((x) &  0xf) <<  8)
+#define CSVALID(1 << 6)
+#define BASEADDRESS(x) (((x) & 0x3f) <<  0)
+
+#endif /* _OMAP3_REGS_H */
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 1/4] ARMV7: OMAP3: Fix preprocessor check for CONFIG_OMAP34XX

2011-04-15 Thread Luca Ceresoli
CONFIG_OMAP34XX must be checked for existence, not value.

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Albert Aribaud 
Cc: Sandeep Paulraj 
---
Changes in v2:
 - this patch is new in v2.

Changes in v3: none.

Changes in v4: none.

 arch/arm/cpu/armv7/start.S |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
index d83d501..6387b8b 100644
--- a/arch/arm/cpu/armv7/start.S
+++ b/arch/arm/cpu/armv7/start.S
@@ -115,7 +115,7 @@ reset:
orr r0, r0, #0xd3
msr cpsr,r0
 
-#if (CONFIG_OMAP34XX)
+#if defined(CONFIG_OMAP34XX)
/* Copy vectors to mask ROM indirect addr */
adr r0, _start  @ r0 <- current position of code
add r0, r0, #4  @ skip reset vector
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 0/4] Add DIG297 board and OMAP3 fixes

2011-04-15 Thread Luca Ceresoli
Hi all,

this patch series cleans up some OMAP3 stuff and adds DIG297 board support.

New in v4:
 - patch 2 gets rid of some ugly extern variables in mem.c;
 - patch 3 creates a new file for register definitions (inspired by the pxa and
   imx code base), and defines GPMC_CONFIGx register values.

Luca

Luca Ceresoli (4):
  ARMV7: OMAP3: Fix preprocessor check for CONFIG_OMAP34XX
  ARMV7: OMAP3: Cleanup extern variables in mem.c
  ARMV7: OMAP3: Add GPMC_CONFIGx register value definitions
  ARMV7: OMAP3: Add support for Comelit DIG297 board

 MAINTAINERS  |4 +
 MAKEALL  |1 +
 arch/arm/cpu/armv7/omap3/mem.c   |   32 ---
 arch/arm/cpu/armv7/start.S   |2 +-
 arch/arm/include/asm/arch-omap3/omap3-regs.h |   95 +++
 board/comelit/dig297/Makefile|   49 
 board/comelit/dig297/dig297.c|  187 +
 board/comelit/dig297/dig297.h|  383 ++
 boards.cfg   |1 +
 include/configs/am3517_evm.h |   18 +-
 include/configs/cm_t35.h |   16 +-
 include/configs/devkit8000.h |   10 +-
 include/configs/dig297.h |  311 +
 include/configs/omap3_beagle.h   |   16 +-
 include/configs/omap3_evm.h  |   26 +-
 include/configs/omap3_overo.h|   16 +-
 include/configs/omap3_pandora.h  |   16 +-
 include/configs/omap3_sdp3430.h  |   10 -
 include/configs/omap3_zoom1.h|   16 +-
 include/configs/omap3_zoom2.h|   16 +-
 20 files changed, 1081 insertions(+), 144 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-omap3/omap3-regs.h
 create mode 100644 board/comelit/dig297/Makefile
 create mode 100644 board/comelit/dig297/dig297.c
 create mode 100644 board/comelit/dig297/dig297.h
 create mode 100644 include/configs/dig297.h

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 4/4] ARMV7: OMAP3: Add support for Comelit DIG297 board

2011-04-15 Thread Luca Ceresoli
Board support for the DIG297 board manufactured by Comelit Group SpA.
It is a custom board based on the BeagleBoard <http://beagleboard.org/> by
Texas Instruments.

The board support is based on the BeagleBoard implementation.

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Albert Aribaud 
Cc: Sandeep Paulraj 
---
Changes in v2:
 - renamed board from CPS to DIG297;
 - fixed all (relevant) issues raised by checkpatch.pl;
 - removed config.mk from board dir;
 - fixed coding style;
 - minor cleanups.

Changes in v3: none.

Changes in v4:
 - MAKEALL: keep it sorted alphabetically;
 - Fixed multiline comments;
 - Use enable_gpmc_cs_config() to initialize GPMC for the LAN chip;
 - Remove useless #ifdef CONFIG_SMC911X;
 - Fixed english translation;
 - Removed "ro" flag from mtdparts;
 - Updated prompt to board name ("DIG297# ").

 MAINTAINERS   |4 +
 MAKEALL   |1 +
 board/comelit/dig297/Makefile |   49 ++
 board/comelit/dig297/dig297.c |  187 
 board/comelit/dig297/dig297.h |  383 +
 boards.cfg|1 +
 include/configs/dig297.h  |  311 +
 7 files changed, 936 insertions(+), 0 deletions(-)
 create mode 100644 board/comelit/dig297/Makefile
 create mode 100644 board/comelit/dig297/dig297.c
 create mode 100644 board/comelit/dig297/dig297.h
 create mode 100644 include/configs/dig297.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 1299cbb..5feb6de 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -599,6 +599,10 @@ Rick Bronson 
 
AT91RM9200DKat91rm9200
 
+Luca Ceresoli 
+
+   dig297  ARM ARMV7 (OMAP3530 SoC)
+
 Po-Yu Chuang 
 
a320evb FA526 (ARM920T-like) (a320 SoC)
diff --git a/MAKEALL b/MAKEALL
index 6acece7..088b6bc 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -421,6 +421,7 @@ LIST_ARMV7="\
am3517_evm  \
ca9x4_ct_vxp\
devkit8000  \
+   dig297  \
igep0020\
igep0030\
mx51evk \
diff --git a/board/comelit/dig297/Makefile b/board/comelit/dig297/Makefile
new file mode 100644
index 000..8dffedd
--- /dev/null
+++ b/board/comelit/dig297/Makefile
@@ -0,0 +1,49 @@
+#
+# (C) Copyright 2000, 2001, 2002
+# Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)lib$(BOARD).o
+
+COBJS  := dig297.o
+
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+$(LIB):$(obj).depend $(OBJS)
+   $(call cmd_link_o_target, $(OBJS))
+
+clean:
+   rm -f $(OBJS)
+
+distclean: clean
+   rm -f $(LIB) core *.bak $(obj).depend
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/board/comelit/dig297/dig297.c b/board/comelit/dig297/dig297.c
new file mode 100644
index 000..0062f12
--- /dev/null
+++ b/board/comelit/dig297/dig297.c
@@ -0,0 +1,187 @@
+/*
+ * (C) Copyright 2011 Comelit Group SpA
+ * Luca Ceresoli 
+ *
+ * Based on board/ti/beagle/beagle.c:
+ * (C) Copyright 2004-2008
+ * Texas Instruments, 
+ *
+ * Author :
+ * Sunil Kumar 
+ * Shashi Ranjan 
+ *
+ * Derived from Beagle Board and 3430 SDP code by
+ * Richard Woodruff 
+ * Syed Mohammed Khasim 
+ *
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should 

[U-Boot] [PATCH v4 4/4] ARMV7: OMAP3: Add support for Comelit DIG297 board

2011-04-15 Thread Luca Ceresoli
Board support for the DIG297 board manufactured by Comelit Group SpA.
It is a custom board based on the BeagleBoard <http://beagleboard.org/> by
Texas Instruments.

The board support is based on the BeagleBoard implementation.

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Albert Aribaud 
Cc: Sandeep Paulraj 
---
Changes in v2:
 - renamed board from CPS to DIG297;
 - fixed all (relevant) issues raised by checkpatch.pl;
 - removed config.mk from board dir;
 - fixed coding style;
 - minor cleanups.

Changes in v3: none.

Changes in v4:
 - MAKEALL: keep it sorted alphabetically;
 - Fixed multiline comments;
 - Use enable_gpmc_cs_config() to initialize GPMC for the LAN chip;
 - Remove useless #ifdef CONFIG_SMC911X;
 - Fixed english translation;
 - Removed "ro" flag from mtdparts;
 - Updated prompt to board name ("DIG297# ").

 MAINTAINERS   |4 +
 MAKEALL   |1 +
 board/comelit/dig297/Makefile |   49 ++
 board/comelit/dig297/dig297.c |  187 
 board/comelit/dig297/dig297.h |  383 +
 boards.cfg|1 +
 include/configs/dig297.h  |  311 +
 7 files changed, 936 insertions(+), 0 deletions(-)
 create mode 100644 board/comelit/dig297/Makefile
 create mode 100644 board/comelit/dig297/dig297.c
 create mode 100644 board/comelit/dig297/dig297.h
 create mode 100644 include/configs/dig297.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 1299cbb..5feb6de 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -599,6 +599,10 @@ Rick Bronson 
 
AT91RM9200DKat91rm9200
 
+Luca Ceresoli 
+
+   dig297  ARM ARMV7 (OMAP3530 SoC)
+
 Po-Yu Chuang 
 
a320evb FA526 (ARM920T-like) (a320 SoC)
diff --git a/MAKEALL b/MAKEALL
index 6acece7..088b6bc 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -421,6 +421,7 @@ LIST_ARMV7="\
am3517_evm  \
ca9x4_ct_vxp\
devkit8000  \
+   dig297  \
igep0020\
igep0030\
mx51evk \
diff --git a/board/comelit/dig297/Makefile b/board/comelit/dig297/Makefile
new file mode 100644
index 000..8dffedd
--- /dev/null
+++ b/board/comelit/dig297/Makefile
@@ -0,0 +1,49 @@
+#
+# (C) Copyright 2000, 2001, 2002
+# Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)lib$(BOARD).o
+
+COBJS  := dig297.o
+
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+$(LIB):$(obj).depend $(OBJS)
+   $(call cmd_link_o_target, $(OBJS))
+
+clean:
+   rm -f $(OBJS)
+
+distclean: clean
+   rm -f $(LIB) core *.bak $(obj).depend
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/board/comelit/dig297/dig297.c b/board/comelit/dig297/dig297.c
new file mode 100644
index 000..0062f12
--- /dev/null
+++ b/board/comelit/dig297/dig297.c
@@ -0,0 +1,187 @@
+/*
+ * (C) Copyright 2011 Comelit Group SpA
+ * Luca Ceresoli 
+ *
+ * Based on board/ti/beagle/beagle.c:
+ * (C) Copyright 2004-2008
+ * Texas Instruments, 
+ *
+ * Author :
+ * Sunil Kumar 
+ * Shashi Ranjan 
+ *
+ * Derived from Beagle Board and 3430 SDP code by
+ * Richard Woodruff 
+ * Syed Mohammed Khasim 
+ *
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should 

[U-Boot] [PATCH v4 3/4] ARMV7: OMAP3: Add GPMC_CONFIGx register value definitions

2011-04-15 Thread Luca Ceresoli
Signed-off-by: Luca Ceresoli 
---
Changes in v4:
 - this patch is new in v4.

 arch/arm/include/asm/arch-omap3/omap3-regs.h |   95 ++
 1 files changed, 95 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-omap3/omap3-regs.h

diff --git a/arch/arm/include/asm/arch-omap3/omap3-regs.h 
b/arch/arm/include/asm/arch-omap3/omap3-regs.h
new file mode 100644
index 000..818214f
--- /dev/null
+++ b/arch/arm/include/asm/arch-omap3/omap3-regs.h
@@ -0,0 +1,95 @@
+/*
+ * (c) 2011 Comelit Group SpA, Luca Ceresoli 
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _OMAP3_REGS_H
+#define _OMAP3_REGS_H
+
+/*
+ * Register definitions for OMAP3 processors.
+ */
+
+/*
+ * GPMC_CONFIG1 - GPMC_CONFIG7
+ */
+
+/* Values for GPMC_CONFIG1 - signal control parameters */
+#define WRAPBURST (1 << 31)
+#define READMULTIPLE  (1 << 30)
+#define READTYPE  (1 << 29)
+#define WRITEMULTIPLE (1 << 28)
+#define WRITETYPE (1 << 27)
+#define CLKACTIVATIONTIME(x)  (((x) & 3) << 25)
+#define ATTACHEDDEVICEPAGELENGTH(x)   (((x) & 3) << 23)
+#define WAITREADMONITORING(1 << 22)
+#define WAITWRITEMONITORING   (1 << 21)
+#define WAITMONITORINGTIME(x) (((x) & 3) << 18)
+#define WAITPINSELECT(x)  (((x) & 3) << 16)
+#define DEVICESIZE(x) (((x) & 3) << 12)
+#define DEVICESIZE_8BIT   DEVICESIZE(0)
+#define DEVICESIZE_16BIT  DEVICESIZE(1)
+#define DEVICETYPE(x) (((x) & 3) << 10)
+#define DEVICETYPE_NORDEVICETYPE(0)
+#define DEVICETYPE_NAND   DEVICETYPE(2)
+#define MUXADDDATA(1 << 9)
+#define TIMEPARAGRANULARITY   (1 << 4)
+#define GPMCFCLKDIVIDER(x)(((x) & 3) << 0)
+
+/* Values for GPMC_CONFIG2 - CS timing */
+#define CSWROFFTIME(x)   (((x) & 0x1f) << 16)
+#define CSRDOFFTIME(x)   (((x) & 0x1f) <<  8)
+#define CSEXTRADELAY (1 << 7)
+#define CSONTIME(x)  (((x) &  0xf) <<  0)
+
+/* Values for GPMC_CONFIG3 - nADV timing */
+#define ADVWROFFTIME(x)  (((x) & 0x1f) << 16)
+#define ADVRDOFFTIME(x)  (((x) & 0x1f) <<  8)
+#define ADVEXTRADELAY(1 << 7)
+#define ADVONTIME(x) (((x) &  0xf) <<  0)
+
+/* Values for GPMC_CONFIG4 - nWE and nOE timing */
+#define WEOFFTIME(x) (((x) & 0x1f) << 24)
+#define WEEXTRADELAY (1 << 23)
+#define WEONTIME(x)  (((x) &  0xf) << 16)
+#define OEOFFTIME(x) (((x) & 0x1f) <<  8)
+#define OEEXTRADELAY (1 << 7)
+#define OEONTIME(x)  (((x) &  0xf) <<  0)
+
+/* Values for GPMC_CONFIG5 - RdAccessTime and CycleTime timing */
+#define PAGEBURSTACCESSTIME(x)  (((x) &  0xf) << 24)
+#define RDACCESSTIME(x) (((x) & 0x1f) << 16)
+#define WRCYCLETIME(x)  (((x) & 0x1f) <<  8)
+#define RDCYCLETIME(x)  (((x) & 0x1f) <<  0)
+
+/* Values for GPMC_CONFIG6 - misc timings */
+#define WRACCESSTIME(x)(((x) & 0x1f) << 24)
+#define WRDATAONADMUXBUS(x)(((x) &  0xf) << 16)
+#define CYCLE2CYCLEDELAY(x)(((x) &  0xf) <<  8)
+#define CYCLE2CYCLESAMECSEN(1 << 7)
+#define CYCLE2CYCLEDIFFCSEN(1 << 6)
+#define BUSTURNAROUND(x)   (((x) &  0xf) <<  0)
+
+/* Values for GPMC_CONFIG7 - CS address mapping configuration */
+#define MASKADDRESS(x) (((x) &  0xf) <<  8)
+#define CSVALID(1 << 6)
+#define BASEADDRESS(x) (((x) & 0x3f) <<  0)
+
+#endif /* _OMAP3_REGS_H */
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 2/4] ARMV7: OMAP3: Cleanup extern variables in mem.c

2011-04-15 Thread Luca Ceresoli
Removed boot_flash_* extern variables.
boot_flash_type was totally unused. The other ones were actually constants, so
they have been replaced with #defines in the board config files.

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Albert Aribaud 
Cc: Sandeep Paulraj 
---
Changes in v4:
 - this patch is new in v4.

 arch/arm/cpu/armv7/omap3/mem.c  |   32 
 include/configs/am3517_evm.h|   18 ++
 include/configs/cm_t35.h|   16 +---
 include/configs/devkit8000.h|   10 +-
 include/configs/omap3_beagle.h  |   16 +---
 include/configs/omap3_evm.h |   26 --
 include/configs/omap3_overo.h   |   16 +---
 include/configs/omap3_pandora.h |   16 +---
 include/configs/omap3_sdp3430.h |   10 --
 include/configs/omap3_zoom1.h   |   16 +---
 include/configs/omap3_zoom2.h   |   16 +---
 11 files changed, 49 insertions(+), 143 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap3/mem.c b/arch/arm/cpu/armv7/omap3/mem.c
index bd914b0..a01c303 100644
--- a/arch/arm/cpu/armv7/omap3/mem.c
+++ b/arch/arm/cpu/armv7/omap3/mem.c
@@ -31,16 +31,6 @@
 #include 
 #include 
 
-/*
- * Only One NAND allowed on board at a time.
- * The GPMC CS Base for the same
- */
-unsigned int boot_flash_base;
-unsigned int boot_flash_off;
-unsigned int boot_flash_sec;
-unsigned int boot_flash_type;
-volatile unsigned int boot_flash_env_addr;
-
 struct gpmc *gpmc_cfg;
 
 #if defined(CONFIG_CMD_NAND)
@@ -134,10 +124,6 @@ void gpmc_init(void)
const u32 *gpmc_config = NULL;
u32 base = 0;
u32 size = 0;
-#if defined(CONFIG_ENV_IS_IN_NAND) || defined(CONFIG_ENV_IS_IN_ONENAND)
-   u32 f_off = CONFIG_SYS_MONITOR_LEN;
-   u32 f_sec = 0;
-#endif
 #endif
u32 config = 0;
 
@@ -162,15 +148,6 @@ void gpmc_init(void)
base = PISMO1_NAND_BASE;
size = PISMO1_NAND_SIZE;
enable_gpmc_cs_config(gpmc_config, &gpmc_cfg->cs[0], base, size);
-#if defined(CONFIG_ENV_IS_IN_NAND)
-   f_off = SMNAND_ENV_OFFSET;
-   f_sec = (128 << 10);/* 128 KiB */
-   /* env setup */
-   boot_flash_base = base;
-   boot_flash_off = f_off;
-   boot_flash_sec = f_sec;
-   boot_flash_env_addr = f_off;
-#endif
 #endif
 
 #if defined(CONFIG_CMD_ONENAND)
@@ -178,14 +155,5 @@ void gpmc_init(void)
base = PISMO1_ONEN_BASE;
size = PISMO1_ONEN_SIZE;
enable_gpmc_cs_config(gpmc_config, &gpmc_cfg->cs[0], base, size);
-#if defined(CONFIG_ENV_IS_IN_ONENAND)
-   f_off = ONENAND_ENV_OFFSET;
-   f_sec = (128 << 10);/* 128 KiB */
-   /* env setup */
-   boot_flash_base = base;
-   boot_flash_off = f_off;
-   boot_flash_sec = f_sec;
-   boot_flash_env_addr = f_off;
-#endif
 #endif
 }
diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
index 70e8f07..f5d5821 100644
--- a/include/configs/am3517_evm.h
+++ b/include/configs/am3517_evm.h
@@ -294,7 +294,9 @@
 #define CONFIG_SYS_MAX_FLASH_BANKS 2   /* max number of flash banks */
 #define CONFIG_SYS_MONITOR_LEN (256 << 10) /* Reserve 2 sectors */
 
-#define CONFIG_SYS_FLASH_BASE  boot_flash_base
+#if defined(CONFIG_CMD_NAND)
+#define CONFIG_SYS_FLASH_BASE  PISMO1_NAND_BASE
+#endif
 
 /* Monitor at start of flash */
 #define CONFIG_SYS_MONITOR_BASECONFIG_SYS_FLASH_BASE
@@ -304,9 +306,9 @@
 #define CONFIG_ENV_IS_IN_NAND  1
 #define SMNAND_ENV_OFFSET  0x26 /* environment starts here */
 
-#define CONFIG_SYS_ENV_SECT_SIZE   boot_flash_sec
-#define CONFIG_ENV_OFFSET  boot_flash_off
-#define CONFIG_ENV_ADDRboot_flash_env_addr
+#define CONFIG_SYS_ENV_SECT_SIZE   (128 << 10) /* 128 KiB */
+#define CONFIG_ENV_OFFSET  SMNAND_ENV_OFFSET
+#define CONFIG_ENV_ADDRSMNAND_ENV_OFFSET
 
 /*---
  * CFI FLASH driver setup
@@ -323,14 +325,6 @@
 #define CONFIG_SYS_JFFS2_FIRST_BANKCONFIG_SYS_MAX_FLASH_BANKS
 #define CONFIG_SYS_JFFS2_NUM_BANKS 1
 
-#ifndef __ASSEMBLY__
-extern unsigned int boot_flash_base;
-extern volatile unsigned int boot_flash_env_addr;
-extern unsigned int boot_flash_off;
-extern unsigned int boot_flash_sec;
-extern unsigned int boot_flash_type;
-#endif
-
 #define CONFIG_SYS_SDRAM_BASE  PHYS_SDRAM_1
 #define CONFIG_SYS_INIT_RAM_ADDR   0x4020f800
 #define CONFIG_SYS_INIT_RAM_SIZE   0x800
diff --git a/include/configs/cm_t35.h b/include/configs/cm_t35.h
index 510c6d4..ee9175d 100644
--- a/include/configs/cm_t35.h
+++ b/include/configs/cm_t35.h
@@ -310,7 +310,9 @@
 
 #define CONFIG_SYS_MONITOR_LEN (256 << 10) /* Reserve 2 sectors */
 
-#define CONFIG_SYS_FLASH_BASE  boot_flash_base
+#if defined(CONFIG_CMD_NAND)
+#define CON

[U-Boot] [PATCH v2 0/6] TFTP server

2011-04-18 Thread Luca Ceresoli
Hi,
here's the tftpsrv patch series, with checkpatch warnings fixed.
Only patches 2 and 3 are actually changed. Patch 1 is unchanged and patches 4-6
have been simply rebased.

There are still a few checkpatch issues (!), though, that I think can be ignored
and I'm not going to fix unless there's a specific request.

Here they are:

> WARNING: consider using kstrto* in preference to simple_strtol
> #125: FILE: net/tftp.c:619:
> + TftpRemotePort = simple_strtol(ep, NULL, 10);
Which is Linux-only

> WARNING: do not add new typedefs
> #61: FILE: include/net.h:367:
> +typedef enum { BOOTP, RARP, ARP, TFTP, DHCP, PING, DNS, NFS, CDP, NETCONS, 
> SNTP,
Is a typedef *enum* considered bad in U-Boot?

Luca

Luca Ceresoli (6):
  README: remove spurious line
  NET: pass source IP address to packet handlers
  TFTP: rename "server" to "remote"
  TFTP: rename STATE_RRQ to STATE_SEND_RRQ
  TFTP: net/tftp.c: add server mode receive
  TFTP: add tftpsrv command

 README   |2 +-
 common/cmd_net.c |   14 +
 drivers/net/netconsole.c |5 +-
 include/net.h|   18 +--
 net/bootp.c  |9 ++-
 net/dns.c|2 +-
 net/net.c|   40 +--
 net/nfs.c|2 +-
 net/rarp.c   |3 +-
 net/sntp.c   |3 +-
 net/tftp.c   |  123 +++---
 net/tftp.h   |6 ++
 12 files changed, 167 insertions(+), 60 deletions(-)

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/6] README: remove spurious line

2011-04-18 Thread Luca Ceresoli
Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
Changes in v2: none.

 README |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/README b/README
index 4917e26..b9b0fcb 100644
--- a/README
+++ b/README
@@ -1299,7 +1299,6 @@ The following options need to be configured:
driver in use must provide a function: mcast() to join/leave a
multicast group.
 
-   CONFIG_BOOTP_RANDOM_DELAY
 - BOOTP Recovery Mode:
CONFIG_BOOTP_RANDOM_DELAY
 
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 2/6] NET: pass source IP address to packet handlers

2011-04-18 Thread Luca Ceresoli
This is needed for the upcoming TFTP server implementation.

This also simplifies PingHandler() and fixes rxhand_f documentation.

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
Changes in v2:
 - fixed checkpatch issues.

 drivers/net/netconsole.c |5 +++--
 include/net.h|   15 ++-
 net/bootp.c  |9 ++---
 net/dns.c|2 +-
 net/net.c|   30 +-
 net/nfs.c|2 +-
 net/rarp.c   |3 ++-
 net/sntp.c   |3 ++-
 net/tftp.c   |3 ++-
 9 files changed, 44 insertions(+), 28 deletions(-)

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index e27bb3e..e40efb8 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -40,13 +40,14 @@ static short nc_port;   /* 
source/target port */
 static const char *output_packet;  /* used by first send udp */
 static int output_packet_len = 0;
 
-static void nc_wait_arp_handler (uchar * pkt, unsigned dest, unsigned src,
+static void nc_wait_arp_handler(uchar *pkt, unsigned dest,
+IPaddr_t sip, unsigned src,
 unsigned len)
 {
NetState = NETLOOP_SUCCESS; /* got arp reply - quit net loop */
 }
 
-static void nc_handler (uchar * pkt, unsigned dest, unsigned src,
+static void nc_handler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
unsigned len)
 {
if (input_size)
diff --git a/include/net.h b/include/net.h
index 95ef8ab..01f7159 100644
--- a/include/net.h
+++ b/include/net.h
@@ -72,12 +72,17 @@
 typedef ulong  IPaddr_t;
 
 
-/*
- * The current receive packet handler.  Called with a pointer to the
- * application packet, and a protocol type (PORT_BOOTPC or PORT_TFTP).
- * All other packets are dealt with without calling the handler.
+/**
+ * An incoming packet handler.
+ * @param pktpointer to the application packet
+ * @param dport  destination UDP port
+ * @param sipsource IP address
+ * @param sport  source UDP port
+ * @param lenpacket length
  */
-typedef void   rxhand_f(uchar *, unsigned, unsigned, unsigned);
+typedef void rxhand_f(uchar *pkt, unsigned dport,
+ IPaddr_t sip, unsigned sport,
+ unsigned len);
 
 /*
  * A timeout handler.  Called after time interval has expired.
diff --git a/net/bootp.c b/net/bootp.c
index 87b027e..4db63cb 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -44,7 +44,8 @@ ulong seed1, seed2;
 dhcp_state_t dhcp_state = INIT;
 unsigned long dhcp_leasetime = 0;
 IPaddr_t NetDHCPServerIP = 0;
-static void DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned 
len);
+static void DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
+   unsigned len);
 
 /* For Debug */
 #if 0
@@ -282,7 +283,8 @@ static void BootpVendorProcess (u8 * ext, int size)
  * Handle a BOOTP received packet.
  */
 static void
-BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+BootpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
+unsigned len)
 {
Bootp_t *bp;
char*s;
@@ -858,7 +860,8 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
  * Handle DHCP received packets.
  */
 static void
-DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
+   unsigned len)
 {
Bootp_t *bp = (Bootp_t *)pkt;
 
diff --git a/net/dns.c b/net/dns.c
index bb3e3f5..b51d1bd 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -101,7 +101,7 @@ DnsTimeout(void)
 }
 
 static void
-DnsHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len)
+DnsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)
 {
struct header *header;
const unsigned char *p, *e, *s;
diff --git a/net/net.c b/net/net.c
index a609632..132f99b 100644
--- a/net/net.c
+++ b/net/net.c
@@ -555,7 +555,8 @@ startAgainTimeout(void)
 }
 
 static void
-startAgainHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+startAgainHandler(uchar *pkt, unsigned dest, IPaddr_t sip,
+ unsigned src, unsigned len)
 {
/* Totally ignore the packet */
 }
@@ -752,13 +753,10 @@ PingTimeout (void)
 }
 
 static void
-PingHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
+PingHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
+   unsigned len)
 {
-   IPaddr_t tmp;
-   volatile IP_t *ip = (volatile IP_t *)pkt;
-
-   tmp = NetReadIP((void *)&ip->ip_src);
-   if (tmp != NetPingIP)
+   if (sip != NetPingIP)
return;
 
NetState = NETLOOP_SUCCESS;
@@ -990,7 +988,8 @@ CDPTimeout (void)
 }
 
 static void
-CDPDummyHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
+CDPDummyHandler(uchar *pkt, unsign

[U-Boot] [PATCH v2 3/6] TFTP: rename "server" to "remote"

2011-04-18 Thread Luca Ceresoli
With the upcoming TFTP server implementation, the remote node can be
either a client or a server, so avoid ambiguities.

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
Changes in v2:
 - fixed checkpatch issues.

 net/tftp.c |   42 +-
 1 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/net/tftp.c b/net/tftp.c
index 00abec3..da545c6 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -55,18 +55,18 @@ enum {
TFTP_ERR_FILE_ALREADY_EXISTS = 6,
 };
 
-static IPaddr_t TftpServerIP;
-static int TftpServerPort; /* The UDP port at their end
*/
-static int TftpOurPort;/* The UDP port at our end  
*/
+static IPaddr_t TftpRemoteIP;
+static int TftpRemotePort; /* The UDP port at their end*/
+static int TftpOurPort;/* The UDP port at our end  */
 static int TftpTimeoutCount;
-static ulong   TftpBlock;  /* packet sequence number   
*/
-static ulong   TftpLastBlock;  /* last packet sequence number received 
*/
-static ulong   TftpBlockWrap;  /* count of sequence number wraparounds 
*/
-static ulong   TftpBlockWrapOffset;/* memory offset due to wrapping
*/
+static ulong   TftpBlock;  /* packet sequence number   */
+static ulong   TftpLastBlock;  /* last packet sequence number received */
+static ulong   TftpBlockWrap;  /* count of sequence number wraparounds */
+static ulong   TftpBlockWrapOffset; /* memory offset due to wrapping   */
 static int TftpState;
 #ifdef CONFIG_TFTP_TSIZE
-static int TftpTsize;  /* The file size reported by the server 
*/
-static short   TftpNumchars;   /* The number of hashes we printed  
*/
+static int TftpTsize;  /* The file size reported by the server */
+static short   TftpNumchars;   /* The number of hashes we printed  */
 #endif
 
 #define STATE_RRQ  1
@@ -273,7 +273,8 @@ TftpSend (void)
break;
}
 
-   NetSendUDPPacket(NetServerEther, TftpServerIP, TftpServerPort, 
TftpOurPort, len);
+   NetSendUDPPacket(NetServerEther, TftpRemoteIP, TftpRemotePort,
+TftpOurPort, len);
 }
 
 
@@ -292,9 +293,8 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
 #endif
return;
}
-   if (TftpState != STATE_RRQ && src != TftpServerPort) {
+   if (TftpState != STATE_RRQ && src != TftpRemotePort)
return;
-   }
 
if (len < 2) {
return;
@@ -318,7 +318,7 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
pkt,
pkt + strlen((char *)pkt) + 1);
TftpState = STATE_OACK;
-   TftpServerPort = src;
+   TftpRemotePort = src;
/*
 * Check for 'blksize' option.
 * Careful: "i" is signed, "len" is unsigned, thus
@@ -386,7 +386,7 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
if (TftpState == STATE_RRQ || TftpState == STATE_OACK) {
/* first block received */
TftpState = STATE_DATA;
-   TftpServerPort = src;
+   TftpRemotePort = src;
TftpLastBlock = 0;
TftpBlockWrap = 0;
TftpBlockWrapOffset = 0;
@@ -421,7 +421,7 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
 
/*
 *  Acknoledge the block just received, which will prompt
-*  the server for the next one.
+*  the remote for the next one.
 */
 #ifdef CONFIG_MCAST_TFTP
/* if I am the MasterClient, actively calculate what my next
@@ -548,7 +548,7 @@ TftpStart (void)
debug("TFTP blocksize = %i, timeout = %ld ms\n",
TftpBlkSizeOption, TftpTimeoutMSecs);
 
-   TftpServerIP = NetServerIP;
+   TftpRemoteIP = NetServerIP;
if (BootFile[0] == '\0') {
sprintf(default_filename, "%02lX%02lX%02lX%02lX.img",
NetOurIP & 0xFF,
@@ -568,7 +568,7 @@ TftpStart (void)
strncpy(tftp_filename, BootFile, MAX_LEN);
tftp_filename[MAX_LEN-1] = 0;
} else {
-   TftpServerIP = string_to_ip (BootFile);
+   TftpRemoteIP = string_to_ip(BootFile);
strncpy(tftp_filename, p + 1, MAX_LEN);
tftp_filename[MAX_LEN-1] = 0;
}
@@ -578,12 +578,12 @@ TftpStart (void)
printf ("Using %s device\n", eth_get_name());
 #endif
printf("TFTP from server %pI4"
-   "; o

[U-Boot] [PATCH v2 4/6] TFTP: rename STATE_RRQ to STATE_SEND_RRQ

2011-04-18 Thread Luca Ceresoli
With the upcoming TFTP server implementation, requests can be either
outgoing or incoming, so avoid ambiguities.

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
Changes in v2: none.

 net/tftp.c |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/tftp.c b/net/tftp.c
index da545c6..e166a63 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -69,7 +69,7 @@ static intTftpTsize;  /* The file size reported by 
the server */
 static short   TftpNumchars;   /* The number of hashes we printed  */
 #endif
 
-#define STATE_RRQ  1
+#define STATE_SEND_RRQ 1
 #define STATE_DATA 2
 #define STATE_TOO_LARGE3
 #define STATE_BAD_MAGIC4
@@ -200,7 +200,7 @@ TftpSend (void)
 
switch (TftpState) {
 
-   case STATE_RRQ:
+   case STATE_SEND_RRQ:
xp = pkt;
s = (ushort *)pkt;
*s++ = htons(TFTP_RRQ);
@@ -293,7 +293,7 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
 #endif
return;
}
-   if (TftpState != STATE_RRQ && src != TftpRemotePort)
+   if (TftpState != STATE_SEND_RRQ && src != TftpRemotePort)
return;
 
if (len < 2) {
@@ -380,10 +380,10 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
}
}
 
-   if (TftpState == STATE_RRQ)
+   if (TftpState == STATE_SEND_RRQ)
debug("Server did not acknowledge timeout option!\n");
 
-   if (TftpState == STATE_RRQ || TftpState == STATE_OACK) {
+   if (TftpState == STATE_SEND_RRQ || TftpState == STATE_OACK) {
/* first block received */
TftpState = STATE_DATA;
TftpRemotePort = src;
@@ -610,7 +610,7 @@ TftpStart (void)
 
TftpRemotePort = WELL_KNOWN_PORT;
TftpTimeoutCount = 0;
-   TftpState = STATE_RRQ;
+   TftpState = STATE_SEND_RRQ;
/* Use a pseudo-random port unless a specific port is set */
TftpOurPort = 1024 + (get_timer(0) % 3072);
 
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 6/6] TFTP: add tftpsrv command

2011-04-18 Thread Luca Ceresoli
Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
Changes in v2: none.

 README   |1 +
 common/cmd_net.c |   14 ++
 include/net.h|3 ++-
 net/net.c|   10 --
 4 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/README b/README
index b9b0fcb..83dcb2a 100644
--- a/README
+++ b/README
@@ -685,6 +685,7 @@ The following options need to be configured:
  (requires CONFIG_CMD_MEMORY)
CONFIG_CMD_SOURCE "source" command Support
CONFIG_CMD_SPI  * SPI serial bus support
+   CONFIG_CMD_TFTPSRV  * TFTP transfer in server mode
CONFIG_CMD_USB  * USB support
CONFIG_CMD_VFD  * VFD support (TRAB)
CONFIG_CMD_CDP  * Cisco Discover Protocol support
diff --git a/common/cmd_net.c b/common/cmd_net.c
index 8c6f5c8..053162a 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -52,6 +52,20 @@ U_BOOT_CMD(
"[loadAddress] [[hostIPaddr:]bootfilename]"
 );
 
+#ifdef CONFIG_CMD_TFTPSRV
+int do_tftpsrv(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+   return netboot_common(TFTPSRV, cmdtp, argc, argv);
+}
+
+U_BOOT_CMD(
+   tftpsrv,2,  1,  do_tftpsrv,
+   "boot image via network acting as a TFTP server",
+   "[loadAddress]"
+);
+#endif
+
+
 #ifdef CONFIG_CMD_RARP
 int do_rarpb (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
diff --git a/include/net.h b/include/net.h
index 01f7159..018a744 100644
--- a/include/net.h
+++ b/include/net.h
@@ -364,7 +364,8 @@ extern int  NetState;   /* Network loop 
state   */
 extern int NetRestartWrap; /* Tried all network devices
*/
 #endif
 
-typedef enum { BOOTP, RARP, ARP, TFTP, DHCP, PING, DNS, NFS, CDP, NETCONS, 
SNTP } proto_t;
+typedef enum { BOOTP, RARP, ARP, TFTP, DHCP, PING, DNS, NFS, CDP, NETCONS, 
SNTP,
+  TFTPSRV } proto_t;
 
 /* from net/net.c */
 extern charBootFile[128];  /* Boot File name   
*/
diff --git a/net/net.c b/net/net.c
index 132f99b..17eb06f 100644
--- a/net/net.c
+++ b/net/net.c
@@ -388,7 +388,11 @@ restart:
/* always use ARP to get server ethernet address */
TftpStart();
break;
-
+#ifdef CONFIG_CMD_TFTPSRV
+   case TFTPSRV:
+   TftpStartServer();
+   break;
+#endif
 #if defined(CONFIG_CMD_DHCP)
case DHCP:
BootpTry = 0;
@@ -1731,7 +1735,9 @@ static int net_check_prereq (proto_t protocol)
 #if defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP)
 common:
 #endif
-
+#ifdef CONFIG_CMD_TFTPSRV
+   case TFTPSRV:
+#endif
if (NetOurIP == 0) {
puts ("*** ERROR: `ipaddr' not set\n");
return (1);
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 5/6] TFTP: net/tftp.c: add server mode receive

2011-04-18 Thread Luca Ceresoli
Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
Changes in v2: none.

 net/tftp.c |   72 ---
 net/tftp.h |6 +
 2 files changed, 74 insertions(+), 4 deletions(-)

diff --git a/net/tftp.c b/net/tftp.c
index e166a63..87eb0b8 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -2,6 +2,8 @@
  * Copyright 1994, 1995, 2000 Neil Russell.
  * (See License)
  * Copyright 2000, 2001 DENX Software Engineering, Wolfgang Denk, 
w...@denx.de
+ * Copyright 2011 Comelit Group SpA,
+ *Luca Ceresoli 
  */
 
 #include 
@@ -74,6 +76,7 @@ static short  TftpNumchars;   /* The number of hashes we 
printed  */
 #define STATE_TOO_LARGE3
 #define STATE_BAD_MAGIC4
 #define STATE_OACK 5
+#define STATE_RECV_WRQ 6
 
 #define TFTP_BLOCK_SIZE512 /* default TFTP 
block size  */
 #define TFTP_SEQUENCE_SIZE ((ulong)(1<<16))/* sequence number is 16 
bit */
@@ -241,6 +244,10 @@ TftpSend (void)
TftpBlock=ext2_find_next_zero_bit(Bitmap,(Mapsize*8),0);
/*..falling..*/
 #endif
+
+#ifdef CONFIG_CMD_TFTPSRV
+   case STATE_RECV_WRQ:
+#endif
case STATE_DATA:
xp = pkt;
s = (ushort *)pkt;
@@ -293,7 +300,11 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
 #endif
return;
}
-   if (TftpState != STATE_SEND_RRQ && src != TftpRemotePort)
+   if (TftpState != STATE_SEND_RRQ &&
+#ifdef CONFIG_CMD_TFTPSRV
+   TftpState != STATE_RECV_WRQ &&
+#endif
+   src != TftpRemotePort)
return;
 
if (len < 2) {
@@ -307,12 +318,24 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
switch (ntohs(proto)) {
 
case TFTP_RRQ:
-   case TFTP_WRQ:
case TFTP_ACK:
break;
default:
break;
 
+#ifdef CONFIG_CMD_TFTPSRV
+   case TFTP_WRQ:
+   debug("Got WRQ\n");
+   TftpRemoteIP = sip;
+   TftpRemotePort = src;
+   TftpOurPort = 1024 + (get_timer(0) % 3072);
+   TftpLastBlock = 0;
+   TftpBlockWrap = 0;
+   TftpBlockWrapOffset = 0;
+   TftpSend(); /* Send ACK(0) */
+   break;
+#endif
+
case TFTP_OACK:
debug("Got OACK: %s %s\n",
pkt,
@@ -383,7 +406,11 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
if (TftpState == STATE_SEND_RRQ)
debug("Server did not acknowledge timeout option!\n");
 
-   if (TftpState == STATE_SEND_RRQ || TftpState == STATE_OACK) {
+   if (TftpState == STATE_SEND_RRQ ||
+#ifdef CONFIG_CMD_TFTPSRV
+   TftpState == STATE_RECV_WRQ ||
+#endif
+   TftpState == STATE_OACK) {
/* first block received */
TftpState = STATE_DATA;
TftpRemotePort = src;
@@ -518,7 +545,10 @@ TftpTimeout (void)
} else {
puts ("T ");
NetSetTimeout (TftpTimeoutMSecs, TftpTimeout);
-   TftpSend ();
+#ifdef CONFIG_CMD_TFTPSRV
+   if (TftpState != STATE_RECV_WRQ)
+#endif
+   TftpSend();
}
 }
 
@@ -639,6 +669,40 @@ TftpStart (void)
TftpSend ();
 }
 
+#ifdef CONFIG_CMD_TFTPSRV
+void
+TftpStartServer(void)
+{
+   tftp_filename[0] = 0;
+
+#if defined(CONFIG_NET_MULTI)
+   printf("Using %s device\n", eth_get_name());
+#endif
+   printf("Listening for TFTP transfer on %pI4\n", &NetOurIP);
+   printf("Load address: 0x%lx\n", load_addr);
+
+   puts("Loading: *\b");
+
+   TftpTimeoutCountMax = TIMEOUT_COUNT;
+   TftpTimeoutCount = 0;
+   TftpTimeoutMSecs = TIMEOUT;
+   NetSetTimeout(TftpTimeoutMSecs, TftpTimeout);
+
+   /* Revert TftpBlkSize to dflt */
+   TftpBlkSize = TFTP_BLOCK_SIZE;
+   TftpBlock = 0;
+   TftpOurPort = WELL_KNOWN_PORT;
+
+#ifdef CONFIG_TFTP_TSIZE
+   TftpTsize = 0;
+   TftpNumchars = 0;
+#endif
+
+   TftpState = STATE_RECV_WRQ;
+   NetSetHandler(TftpHandler);
+}
+#endif /* CONFIG_CMD_TFTPSRV */
+
 #ifdef CONFIG_MCAST_TFTP
 /* Credits: atftp project.
  */
diff --git a/net/tftp.h b/net/tftp.h
index e3dfb26..3abdf7b 100644
--- a/net/tftp.h
+++ b/net/tftp.h
@@ -2,6 +2,8 @@
  * LiMon - BOOTP/TFTP.
  *
  * Copyright 1994, 1995, 2000 Neil Russell.
+ * Copyright 2011 Comelit Group SpA
+ *Luca Ceresoli 
  * (See License)
  */
 
@@ -16,6 +18,10 @@
 /* tftp.c */
 extern voidTftpStart (void);   /* Begin TFTP get */
 
+#ifdef CONFIG_CMD_TFTPSRV
+extern voidTftpStartServer(void);  /* Wait for incoming TFTP put */
+#e

Re: [U-Boot] [PATCH v4 4/4] ARMV7: OMAP3: Add support for Comelit DIG297 board

2011-04-19 Thread Luca Ceresoli
Paulraj, Sandeep wrote:

>> Board support for the DIG297 board manufactured by Comelit Group SpA.
>> It is a custom board based on the BeagleBoard  by
>> Texas Instruments.
>> ...
>
> I'll apply this after you resend the patch
>
> ARMV7: OMAP3: Cleanup extern variables in mem.c
>
> --Sandeep
Ok, but while rebasing these two patches, I'll have to re-add 
MACH_TYPE_OMAP3_CPS to
mach-types.h, as it has just been removed.

Luca


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/6] NET: pass source IP address to packet handlers

2011-04-19 Thread Luca Ceresoli
Il 19/04/2011 16:15, Detlev Zundel ha scritto:
> Hi Luca,
>
>> This is needed for the upcoming TFTP server implementation.
>>
>> This also simplifies PingHandler() and fixes rxhand_f documentation.
>>
>> Signed-off-by: Luca Ceresoli
>> Cc: Wolfgang Denk
>> ---
>> Changes in v2:
>>   - fixed checkpatch issues.
>>
>>   drivers/net/netconsole.c |5 +++--
>>   include/net.h|   15 ++-
>>   net/bootp.c  |9 ++---
>>   net/dns.c|2 +-
>>   net/net.c|   30 +-
>>   net/nfs.c|2 +-
>>   net/rarp.c   |3 ++-
>>   net/sntp.c   |3 ++-
>>   net/tftp.c   |3 ++-
>>   9 files changed, 44 insertions(+), 28 deletions(-)
>>
> [...]
>
>> diff --git a/net/net.c b/net/net.c
>> index a609632..132f99b 100644
>> --- a/net/net.c
>> +++ b/net/net.c
> [...]
>
>> @@ -1596,11 +1598,12 @@ NetReceive(volatile uchar * inpkt, int len)
>>   *  IP header OK.  Pass the packet to the 
>> current handler.
>>   */
>>  /* XXX point to ip packet */
>> -(*packetHandler)((uchar *)ip, 0, 0, 0);
>> +(*packetHandler)((uchar *)ip, 0, src_ip, 0, 0);
>>  return;
>>  case ICMP_ECHO_REQUEST:
>> -debug("Got ICMP ECHO REQUEST, return %d bytes 
>> \n",
>> -ETHER_HDR_SIZE + len);
>> +debug("Got ICMP ECHO REQUEST, "
>> +  "return %d bytes\n",
>> +  ETHER_HDR_SIZE + len);
>>
>>  memcpy (&et->et_dest[0],&et->et_src[0], 6);
>>  memcpy (&et->et_src[ 0], NetOurEther, 6);
> This second hunk is not related to the patch at hand, so strictly
> speaking it should not be in here.  It's not enough to NAK the patch
> however, just something to look out for in the future.

Yep, but it's needed for checkpatch compliance.

Luca


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 3/6] TFTP: rename "server" to "remote"

2011-04-19 Thread Luca Ceresoli
Il 19/04/2011 16:18, Detlev Zundel ha scritto:
> Hi Luca,
>
>> With the upcoming TFTP server implementation, the remote node can be
>> either a client or a server, so avoid ambiguities.
>>
>> Signed-off-by: Luca Ceresoli
>> Cc: Wolfgang Denk
>> ---
>> Changes in v2:
>>   - fixed checkpatch issues.
>>
>>   net/tftp.c |   42 +-
>>   1 files changed, 21 insertions(+), 21 deletions(-)
>>
>> diff --git a/net/tftp.c b/net/tftp.c
>> index 00abec3..da545c6 100644
>> --- a/net/tftp.c
>> +++ b/net/tftp.c
>> @@ -55,18 +55,18 @@ enum {
>>  TFTP_ERR_FILE_ALREADY_EXISTS = 6,
>>   };
>>
>> -static IPaddr_t TftpServerIP;
>> -static int  TftpServerPort; /* The UDP port at their end
>> */
>> -static int  TftpOurPort;/* The UDP port at our end  
>> */
>> +static IPaddr_t TftpRemoteIP;
>> +static int  TftpRemotePort; /* The UDP port at their end*/
>> +static int  TftpOurPort;/* The UDP port at our end  */
>>   static int TftpTimeoutCount;
>> -static ulongTftpBlock;  /* packet sequence number   
>> */
>> -static ulongTftpLastBlock;  /* last packet sequence number 
>> received */
>> -static ulongTftpBlockWrap;  /* count of sequence number 
>> wraparounds */
>> -static ulongTftpBlockWrapOffset;/* memory offset due to 
>> wrapping*/
>> +static ulongTftpBlock;  /* packet sequence number   
>> */
>> +static ulongTftpLastBlock;  /* last packet sequence number received 
>> */
>> +static ulongTftpBlockWrap;  /* count of sequence number wraparounds 
>> */
>> +static ulongTftpBlockWrapOffset; /* memory offset due to wrapping   
>> */
> These changes are indentation only changes, so they should be in a
> separate patch.

It's needed for checkpatch compliance.


>>   static int TftpState;
>>   #ifdef CONFIG_TFTP_TSIZE
>> -static int  TftpTsize;  /* The file size reported by the server 
>> */
>> -static shortTftpNumchars;   /* The number of hashes we 
>> printed  */
>> +static int  TftpTsize;  /* The file size reported by the server */
>> +static shortTftpNumchars;   /* The number of hashes we printed  
>> */
> dito.
>
> [...]
>
>> @@ -421,7 +421,7 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
>> unsigned src,
>>
>>  /*
>>   *  Acknoledge the block just received, which will prompt
>> - *  the server for the next one.
>> + *  the remote for the next one.
> Hey, while you're at it, please fix the "Acknoledge" typo ;)

Will do.

> [...]
>
>> @@ -568,7 +568,7 @@ TftpStart (void)
>>  strncpy(tftp_filename, BootFile, MAX_LEN);
>>  tftp_filename[MAX_LEN-1] = 0;
>>  } else {
>> -TftpServerIP = string_to_ip (BootFile);
>> +TftpRemoteIP = string_to_ip(BootFile);
> Whitespace fix.

checkpatch again.

Luca

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 3/6] TFTP: rename "server" to "remote"

2011-04-19 Thread Luca Ceresoli
Hi,

just a few e-mails ago along this thread Albert Aribaud wrote:

>  My opinion is that you should make sure that at least the code you touch
>  is checkpatch-clean, so yes, you should fix that; but there is no need
>  to submit 'checkpatch-compliance' patches. Just fix the line here so
>  that checkpatch does not complain.


So I proceeded along that way.

Now Detlev Zundel wrote:
> ...
> Hm, I see.  Still, can we have one commit (with "cosmetic" in the
> changelog) that silences checkpatch but does not have any functional
> changes?  We really try hard to separate cosmetic from functional
> changes.  This makes reviewing (and debugging) so much easier.

While I appreciate the careful review of my patches, I cannot hide
that it is discouraging for new contributors to be requested for
contradictory modifications.

There should be one precise policy, and that should be clearly documented.

http://www.denx.de/wiki/U-Boot/CodingStyle is the place where I would
expect to find it.

Luca

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 3/6] TFTP: rename "server" to "remote"

2011-04-20 Thread Luca Ceresoli
Detlev Zundel wrote:
> Hi Luca,
>
>> Il 19/04/2011 16:18, Detlev Zundel ha scritto:
>>> Hi Luca,
>>>
>>>> With the upcoming TFTP server implementation, the remote node can be
>>>> either a client or a server, so avoid ambiguities.
>>>>
>>>> Signed-off-by: Luca Ceresoli
>>>> Cc: Wolfgang Denk
>>>> ---
>>>> Changes in v2:
>>>>- fixed checkpatch issues.
>>>>
>>>>net/tftp.c |   42 +-
>>>>1 files changed, 21 insertions(+), 21 deletions(-)
>>>>
>>>> diff --git a/net/tftp.c b/net/tftp.c
>>>> index 00abec3..da545c6 100644
>>>> --- a/net/tftp.c
>>>> +++ b/net/tftp.c
>>>> @@ -55,18 +55,18 @@ enum {
>>>>TFTP_ERR_FILE_ALREADY_EXISTS = 6,
>>>>};
>>>>
>>>> -static IPaddr_t TftpServerIP;
>>>> -static intTftpServerPort; /* The UDP port at their end
>>>> */
>>>> -static intTftpOurPort;/* The UDP port at our end  
>>>> */
>>>> +static IPaddr_t TftpRemoteIP;
>>>> +static intTftpRemotePort; /* The UDP port at their end
>>>> */
>>>> +static intTftpOurPort;/* The UDP port at our end  
>>>> */
>>>>static int  TftpTimeoutCount;
>>>> -static ulong  TftpBlock;  /* packet sequence number   
>>>> */
>>>> -static ulong  TftpLastBlock;  /* last packet sequence number 
>>>> received */
>>>> -static ulong  TftpBlockWrap;  /* count of sequence number 
>>>> wraparounds */
>>>> -static ulong  TftpBlockWrapOffset;/* memory offset due to 
>>>> wrapping*/
>>>> +static ulong  TftpBlock;  /* packet sequence number   
>>>> */
>>>> +static ulong  TftpLastBlock;  /* last packet sequence number received 
>>>> */
>>>> +static ulong  TftpBlockWrap;  /* count of sequence number wraparounds 
>>>> */
>>>> +static ulong  TftpBlockWrapOffset; /* memory offset due to wrapping   
>>>> */
>>> These changes are indentation only changes, so they should be in a
>>> separate patch.
>> It's needed for checkpatch compliance.
> I'm trying to understand the problems involved, but looking at this
> again, it is not clear to me what you say here.  When I run your version
> 1 of the patches (where you only do the rename) through checkpatch, I
> get:
>
>WARNING: line over 80 characters
>#116: FILE: net/tftp.c:59:
>+static intTftpRemotePort; /* The UDP port at their end
> */
>
>WARNING: consider using kstrto* in preference to simple_strtol
>#215: FILE: net/tftp.c:619:
>+  TftpRemotePort = simple_strtol(ep, NULL, 10);
>
>total: 0 errors, 2 warnings, 99 lines checked
>
>/home/dzu/transfer/p2 has style problems, please review.  If any of these 
> errors
>are false positives report them to the maintainer, see
>CHECKPATCH in MAINTAINERS.
>
> So I'm not sure why you say that the other changes are needed for
> checkpatch.  What exactly do you mean by this?

All the comments were nicely columned before my patchset. Reducing the
length of a line would have broken this.

I chose to change all of them in order to preserve the pre-existing 
coding style.

Luca

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 0/2] Add DIG297 board and OMAP3 fixes

2011-04-20 Thread Luca Ceresoli
Hi all,

this patch series cleans up some OMAP3 stuff and adds DIG297 board support.

New in v5:
 - rebased against u-boot-ti master (007965dbe4dae12);
 - updated to support the new am3517 crane board;
 - removed two patches that have already been pushed to u-boot-ti master.

Luca

Luca Ceresoli (2):
  ARMV7: OMAP3: Cleanup extern variables in mem.c
  ARMV7: OMAP3: Add support for Comelit DIG297 board

 MAINTAINERS |4 +
 MAKEALL |1 +
 arch/arm/cpu/armv7/omap3/mem.c  |   32 
 board/comelit/dig297/Makefile   |   49 +
 board/comelit/dig297/dig297.c   |  187 +++
 board/comelit/dig297/dig297.h   |  383 +++
 boards.cfg  |1 +
 include/configs/am3517_crane.h  |   16 +--
 include/configs/am3517_evm.h|   18 +--
 include/configs/cm_t35.h|   16 +-
 include/configs/devkit8000.h|   10 +-
 include/configs/dig297.h|  311 +++
 include/configs/omap3_beagle.h  |   16 +-
 include/configs/omap3_evm.h |   26 ++--
 include/configs/omap3_overo.h   |   16 +-
 include/configs/omap3_pandora.h |   16 +-
 include/configs/omap3_sdp3430.h |   10 -
 include/configs/omap3_zoom1.h   |   16 +-
 include/configs/omap3_zoom2.h   |   16 +-
 19 files changed, 989 insertions(+), 155 deletions(-)
 create mode 100644 board/comelit/dig297/Makefile
 create mode 100644 board/comelit/dig297/dig297.c
 create mode 100644 board/comelit/dig297/dig297.h
 create mode 100644 include/configs/dig297.h

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 1/2] ARMV7: OMAP3: Cleanup extern variables in mem.c

2011-04-20 Thread Luca Ceresoli
Removed boot_flash_* extern variables.
boot_flash_type was totally unused. The other ones were actually constants, so
they have been replaced with #defines in the board config files.

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Albert Aribaud 
Cc: Sandeep Paulraj 
---
Changes in v4:
 - this patch is new in v4.

Changes in v5:
 - extended to crane board.

 arch/arm/cpu/armv7/omap3/mem.c  |   32 
 include/configs/am3517_crane.h  |   16 
 include/configs/am3517_evm.h|   18 ++
 include/configs/cm_t35.h|   16 +---
 include/configs/devkit8000.h|   10 +-
 include/configs/omap3_beagle.h  |   16 +---
 include/configs/omap3_evm.h |   26 --
 include/configs/omap3_overo.h   |   16 +---
 include/configs/omap3_pandora.h |   16 +---
 include/configs/omap3_sdp3430.h |   10 --
 include/configs/omap3_zoom1.h   |   16 +---
 include/configs/omap3_zoom2.h   |   16 +---
 12 files changed, 53 insertions(+), 155 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap3/mem.c b/arch/arm/cpu/armv7/omap3/mem.c
index bd914b0..a01c303 100644
--- a/arch/arm/cpu/armv7/omap3/mem.c
+++ b/arch/arm/cpu/armv7/omap3/mem.c
@@ -31,16 +31,6 @@
 #include 
 #include 
 
-/*
- * Only One NAND allowed on board at a time.
- * The GPMC CS Base for the same
- */
-unsigned int boot_flash_base;
-unsigned int boot_flash_off;
-unsigned int boot_flash_sec;
-unsigned int boot_flash_type;
-volatile unsigned int boot_flash_env_addr;
-
 struct gpmc *gpmc_cfg;
 
 #if defined(CONFIG_CMD_NAND)
@@ -134,10 +124,6 @@ void gpmc_init(void)
const u32 *gpmc_config = NULL;
u32 base = 0;
u32 size = 0;
-#if defined(CONFIG_ENV_IS_IN_NAND) || defined(CONFIG_ENV_IS_IN_ONENAND)
-   u32 f_off = CONFIG_SYS_MONITOR_LEN;
-   u32 f_sec = 0;
-#endif
 #endif
u32 config = 0;
 
@@ -162,15 +148,6 @@ void gpmc_init(void)
base = PISMO1_NAND_BASE;
size = PISMO1_NAND_SIZE;
enable_gpmc_cs_config(gpmc_config, &gpmc_cfg->cs[0], base, size);
-#if defined(CONFIG_ENV_IS_IN_NAND)
-   f_off = SMNAND_ENV_OFFSET;
-   f_sec = (128 << 10);/* 128 KiB */
-   /* env setup */
-   boot_flash_base = base;
-   boot_flash_off = f_off;
-   boot_flash_sec = f_sec;
-   boot_flash_env_addr = f_off;
-#endif
 #endif
 
 #if defined(CONFIG_CMD_ONENAND)
@@ -178,14 +155,5 @@ void gpmc_init(void)
base = PISMO1_ONEN_BASE;
size = PISMO1_ONEN_SIZE;
enable_gpmc_cs_config(gpmc_config, &gpmc_cfg->cs[0], base, size);
-#if defined(CONFIG_ENV_IS_IN_ONENAND)
-   f_off = ONENAND_ENV_OFFSET;
-   f_sec = (128 << 10);/* 128 KiB */
-   /* env setup */
-   boot_flash_base = base;
-   boot_flash_off = f_off;
-   boot_flash_sec = f_sec;
-   boot_flash_env_addr = f_off;
-#endif
 #endif
 }
diff --git a/include/configs/am3517_crane.h b/include/configs/am3517_crane.h
index ef0c0a1..09cb951 100644
--- a/include/configs/am3517_crane.h
+++ b/include/configs/am3517_crane.h
@@ -294,7 +294,7 @@
 #define CONFIG_SYS_MAX_FLASH_BANKS 2   /* max number of flash banks */
 #define CONFIG_SYS_MONITOR_LEN (256 << 10) /* Reserve 2 sectors */
 
-#define CONFIG_SYS_FLASH_BASE  boot_flash_base
+#define CONFIG_SYS_FLASH_BASE  PISMO1_NAND_BASE
 
 /* Monitor at start of flash */
 #define CONFIG_SYS_MONITOR_BASECONFIG_SYS_FLASH_BASE
@@ -304,9 +304,9 @@
 #define CONFIG_ENV_IS_IN_NAND  1
 #define SMNAND_ENV_OFFSET  0x26 /* environment starts here */
 
-#define CONFIG_SYS_ENV_SECT_SIZE   boot_flash_sec
-#define CONFIG_ENV_OFFSET  boot_flash_off
-#define CONFIG_ENV_ADDRboot_flash_env_addr
+#define CONFIG_SYS_ENV_SECT_SIZE   (128 << 10) /* 128 KiB sector */
+#define CONFIG_ENV_OFFSET  SMNAND_ENV_OFFSET
+#define CONFIG_ENV_ADDRSMNAND_ENV_OFFSET
 
 /*---
  * CFI FLASH driver setup
@@ -323,14 +323,6 @@
 #define CONFIG_SYS_JFFS2_FIRST_BANKCONFIG_SYS_MAX_FLASH_BANKS
 #define CONFIG_SYS_JFFS2_NUM_BANKS 1
 
-#ifndef __ASSEMBLY__
-extern unsigned int boot_flash_base;
-extern volatile unsigned int boot_flash_env_addr;
-extern unsigned int boot_flash_off;
-extern unsigned int boot_flash_sec;
-extern unsigned int boot_flash_type;
-#endif
-
 #define CONFIG_SYS_SDRAM_BASE  PHYS_SDRAM_1
 #define CONFIG_SYS_INIT_RAM_ADDR   0x4020f800
 #define CONFIG_SYS_INIT_RAM_SIZE   0x800
diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
index 70e8f07..f5d5821 100644
--- a/include/configs/am3517_evm.h
+++ b/include/configs/am3517_evm.h
@@ -294,7 +294,9 @@
 #define CONFIG_SYS_MAX_FLASH_BANKS 2   /* max number of flash banks */
 #define CON

[U-Boot] [PATCH v5 2/2] ARMV7: OMAP3: Add support for Comelit DIG297 board

2011-04-20 Thread Luca Ceresoli
Board support for the DIG297 board manufactured by Comelit Group SpA.
It is a custom board based on the BeagleBoard <http://beagleboard.org/> by
Texas Instruments.

The board support is based on the BeagleBoard implementation.

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Albert Aribaud 
Cc: Sandeep Paulraj 
---
Changes in v4:
 - this patch is new in v4.

Changes in v5: none.

 MAINTAINERS   |4 +
 MAKEALL   |1 +
 board/comelit/dig297/Makefile |   49 ++
 board/comelit/dig297/dig297.c |  187 
 board/comelit/dig297/dig297.h |  383 +
 boards.cfg|1 +
 include/configs/dig297.h  |  311 +
 7 files changed, 936 insertions(+), 0 deletions(-)
 create mode 100644 board/comelit/dig297/Makefile
 create mode 100644 board/comelit/dig297/dig297.c
 create mode 100644 board/comelit/dig297/dig297.h
 create mode 100644 include/configs/dig297.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 91e7cd9..fc793f5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -600,6 +600,10 @@ Rick Bronson 
 
AT91RM9200DKat91rm9200
 
+Luca Ceresoli 
+
+   dig297  ARM ARMV7 (OMAP3530 SoC)
+
 Po-Yu Chuang 
 
a320evb FA526 (ARM920T-like) (a320 SoC)
diff --git a/MAKEALL b/MAKEALL
index fdc1aca..c3df657 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -422,6 +422,7 @@ LIST_ARMV7="\
am3517_evm  \
ca9x4_ct_vxp\
devkit8000  \
+   dig297  \
igep0020\
igep0030\
mx51evk \
diff --git a/board/comelit/dig297/Makefile b/board/comelit/dig297/Makefile
new file mode 100644
index 000..8dffedd
--- /dev/null
+++ b/board/comelit/dig297/Makefile
@@ -0,0 +1,49 @@
+#
+# (C) Copyright 2000, 2001, 2002
+# Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)lib$(BOARD).o
+
+COBJS  := dig297.o
+
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+$(LIB):$(obj).depend $(OBJS)
+   $(call cmd_link_o_target, $(OBJS))
+
+clean:
+   rm -f $(OBJS)
+
+distclean: clean
+   rm -f $(LIB) core *.bak $(obj).depend
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/board/comelit/dig297/dig297.c b/board/comelit/dig297/dig297.c
new file mode 100644
index 000..0062f12
--- /dev/null
+++ b/board/comelit/dig297/dig297.c
@@ -0,0 +1,187 @@
+/*
+ * (C) Copyright 2011 Comelit Group SpA
+ * Luca Ceresoli 
+ *
+ * Based on board/ti/beagle/beagle.c:
+ * (C) Copyright 2004-2008
+ * Texas Instruments, 
+ *
+ * Author :
+ * Sunil Kumar 
+ * Shashi Ranjan 
+ *
+ * Derived from Beagle Board and 3430 SDP code by
+ * Richard Woodruff 
+ * Syed Mohammed Khasim 
+ *
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "dig297.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifdef CONFIG_CMD_NET
+static void setup_net_chip(void);
+
+#define NET_LAN9221_RESET_GPIO 12
+
+/* GPMC

Re: [U-Boot] [PATCH 2/6] NET: pass source IP address to packet handlers

2011-05-03 Thread Luca Ceresoli
Hi Wolfgang,

Wolfgang Denk wrote:

> Dear Luca Ceresoli,
>
> In message<1302796377-3321-3-git-send-email-luca.ceres...@comelit.it>  you 
> wrote:
>> This is needed for the upcoming TFTP server implementation.
>>
>> This also simplifies PingHandler() and fixes rxhand_f documentation.
>>
>> Signed-off-by: Luca Ceresoli
>> Cc: Wolfgang Denk
> Undone this and previous one as there is a V2 version of this patch.
>
> I wish you would thread yout postings!
I'm sorry for your wasted time, but it's not clear (to me at least...) how
postings should be threaded in the U-Boot ml.

The Wiki says:

>  Make sure that your mailer adds or keeps correct
>  |"In-reply-to:"|  and|"References:"|  headers, so threading of
>  messages is working and everybody can see that the new message
>  refers to some older posting of the same topic.
>
>  Uncommented and un-threaded repostings are extremely annoying and
>  time-consuming, as we have to try to remember if anything similar has
>  been posted before, look up the old threads, and then manually
>  compare if anything has been changed, or what.

'correct|"In-reply-to:"|  and|"References:"|' can have many interpretations.

On the ML I see varying ones, and I even see submissions with NO THREADING
AT ALL: the first submit is in a thread, v2 starts a new thread, v3 yet
another one etc.

MY humble interpretation of the Wiki wording is this:

- [PATCH 0/2]
   |
   +->  [PATCH 1/2]
   +->  [PATCH 2/2]
   |   +->  Re: [PATCH 2/2] reviewers comments to patch 2/2
   |   +->  Re: [PATCH 2/2] more reviewers comments to patch 2/2
   |
   +->  Re: [PATCH 0/2] reviewers comments to the patchset (0/2)
   |   +->  Re: [PATCH 0/2] discussion...
   |
   +->  [PATCH v2 0/2] resubmit (In-Reply-To: the first submit)
   |
   +->  [PATCH v2 1/2]
   +->  [PATCH v2 2/2]
   |   ... more discussion - not shown...
   |
   +->  [PATCH v3 0/2] resubmit (In-Reply-To: the first submit)
   |
   +->  [PATCH v3 1/2]
   +->  [PATCH v3 2/2]

What's wrong with this?
Please state in absolutely unambiguous detail what the correct threading is,
and please docuemnt it in the wiki for everybody.

My postings look correctly threaded according to the above interpretation,
as you can see for example on the Gmane threaded interface.

Luca


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC] Act as a TFTP server

2011-05-03 Thread Luca Ceresoli
Il 30/04/2011 21:53, Wolfgang Denk ha scritto:
> Dear Luca Ceresoli,
>
> In message<4da59b5e.5000...@comelit.it>  you wrote:
>>>>  Usage:tftpsrv []
>>>>
>>>> This would be used almost like tftpboot, except no file name is specified 
>>>> on
>>>> the commandline.
>>>> would default to the environment variable.
>>> I see some user interface issues here:
>>> - When and how do you terminate this command?  After a successful
>>> download, ok.  But how long do we wait for that?  Forever? Or do we
>>> time out?
>> The TFTP client tries sending a RRQ packet TIMEOUT_COUNT times (default 10),
>> spaced TIMEOUT msecs (default 5000) from each other. 50 seconds total by 
>> default.
> Well - this requires that there actually _is_ a TFTP client which
> attempts to connect.  But there is no guarantee that any such client
> is running at all, or that it can connect through firewalls, routers,
> etc.
>
> So assuming we never see any incoming packets - how long will we wait?

Once it has started, the server is stopped like the client is:
- on a complete file reception
- pressing Ctrl-C
- after waiting 5 seconds for 10 times.

Luca


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 3/6] TFTP: rename "server" to "remote"

2011-05-04 Thread Luca Ceresoli
Detlev Zundel wrote:
>
> I'll start a new thread to discuss this.  Hopefully we then come up with
> a policy to stick into that wiki page.
>

Now that the checkpatch policy is much more clear, I started to clean up
the networking stuff, on top of which the TFTP server sits.

net/net.c alone counts 76 errors and 197 warnings. In terms of modified
lines, it's going to be a big job, so I am doing it in separate patches, one
per each category of errors/warnings (whitespace issues, lines >80 chars,
parentheses issues etc).
Is this choice ok?

Also, it's going to be a bigger job than the TFTP server itself, so I'll 
send a
separate patchset for the cleanup work, and hold the TFTP server until the
cleanup is worked out.

Luca

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 0/8] net/net.c: clenups for checkpatch compliance

2011-05-04 Thread Luca Ceresoli
Hi,

net/net.c currently raises a lot of checkpatch issues: 76 errors, 197 warnings.
This patchset fixes most of them, leaving 0 errors and 25 warnings.

Since the changes are quite massive I split them in separate patches, one
per each category of errors/warning.

The 25 warnings still present are of the following types:
 - WARNING: consider using kstrto* in preference to simple_strtoul
   which is Linux-specific;
 - WARNING: externs should be avoided in .c files
   these are due to loop-dependencies between net/net.c and other files;
 - WARNING: line over 80 characters
   described in the commit message for patch 1;
 - WARNING: Use of volatile is usually wrong [...]
   I've had a quick look at these, but I don't know in detail how the
   networking code and Ethernet drivers (and maybe DMA?) interact, so I cannot
   remove them being sure that things will continue working.

Luca Ceresoli (8):
  net/net.c: cosmetic: fix lines over 80 characters
  net/net.c: cosmetic: variable initializations
  net/net.c: cosmetic: fix whitespace issues
  net/net.c: cosmetic: fix brace issues
  net/net.c: cosmetic: fix pointer syntax issues
  net/net.c: cosmetic: parentheses not required for return
  net/net.c: cosmetic: fix indentation
  net/net.c: cosmetic: do not use assignment in if condition

 net/net.c |  600 ++---
 1 files changed, 333 insertions(+), 267 deletions(-)

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/8] net/net.c: cosmetic: variable initializations

2011-05-04 Thread Luca Ceresoli
This removes the following checkpatch errors:
 - ERROR: do not initialise globals to 0 or NULL
 - ERROR: spaces required around that '=' (ctx:VxV)
 - ERROR: that open brace { should be on the previous line

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Ben Warren 
---
 net/net.c |   42 --
 1 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/net/net.c b/net/net.c
index 90312eb..e89e118 100644
--- a/net/net.c
+++ b/net/net.c
@@ -117,23 +117,23 @@ DECLARE_GLOBAL_DATA_PTR;
 /** BOOTP EXTENTIONS **/
 
 /* Our subnet mask (0=unknown) */
-IPaddr_t   NetOurSubnetMask=0;
+IPaddr_t   NetOurSubnetMask;
 /* Our gateways IP address */
-IPaddr_t   NetOurGatewayIP=0;
+IPaddr_t   NetOurGatewayIP;
 /* Our DNS IP address */
-IPaddr_t   NetOurDNSIP=0;
+IPaddr_t   NetOurDNSIP;
 #if defined(CONFIG_BOOTP_DNS2)
 /* Our 2nd DNS IP address */
-IPaddr_t   NetOurDNS2IP=0;
+IPaddr_t   NetOurDNS2IP;
 #endif
 /* Our NIS domain */
-char   NetOurNISDomain[32]={0,};
+char   NetOurNISDomain[32] = {0,};
 /* Our hostname */
-char   NetOurHostName[32]={0,};
+char   NetOurHostName[32] = {0,};
 /* Our bootpath */
-char   NetOurRootPath[64]={0,};
+char   NetOurRootPath[64] = {0,};
 /* Our bootfile size in blocks */
-ushort NetBootFileSize=0;
+ushort NetBootFileSize;
 
 #ifdef CONFIG_MCAST_TFTP   /* Multicast TFTP */
 IPaddr_t Mcast_addr;
@@ -146,8 +146,7 @@ ulong   NetBootFileXferSize;
 /* Our ethernet address */
 uchar  NetOurEther[6];
 /* Boot server enet address */
-uchar  NetServerEther[6] =
-   { 0, 0, 0, 0, 0, 0 };
+uchar  NetServerEther[6];
 /* Our IP addr (0 = unknown) */
 IPaddr_t   NetOurIP;
 /* Server IP addr (0 = unknown) */
@@ -159,27 +158,26 @@ int   NetRxPacketLen;
 /* IP packet ID */
 unsigned   NetIPID;
 /* Ethernet bcast address */
-uchar  NetBcastAddr[6] =
-   { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-uchar  NetEtherNullAddr[6] =
-   { 0, 0, 0, 0, 0, 0 };
+uchar  NetBcastAddr[6] = {
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+uchar  NetEtherNullAddr[6];
 #ifdef CONFIG_API
 void   (*push_packet)(volatile void *, int len) = 0;
 #endif
 #if defined(CONFIG_CMD_CDP)
 /* Ethernet bcast address */
-uchar  NetCDPAddr[6] =
-   { 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
+uchar  NetCDPAddr[6] = {
+   0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
 #endif
 /* Network loop state */
 intNetState;
 #ifdef CONFIG_NET_MULTI
 /* Tried all network devices */
-intNetRestartWrap = 0;
+intNetRestartWrap;
 /* Network loop restarted */
-static int NetRestarted = 0;
+static int NetRestarted;
 /* At least one device configured */
-static int NetDevExists = 0;
+static int NetDevExists;
 #endif
 
 /* XXX in both little & big endian machines 0x == ntohs(-1) */
@@ -206,7 +204,7 @@ static void CDPStart(void);
 /* NTP server IP address */
 IPaddr_t   NetNtpServerIP;
 /* offset time from UTC */
-intNetTimeOffset=0;
+intNetTimeOffset;
 #endif
 
 #ifdef CONFIG_NETCONSOLE
@@ -228,7 +226,7 @@ static ulongtimeStart;
 /* Current timeout value */
 static ulong   timeDelta;
 /* THE transmit packet */
-volatile uchar *NetTxPacket = 0;
+volatile uchar *NetTxPacket;
 
 static int net_check_prereq (proto_t protocol);
 
@@ -319,7 +317,7 @@ void ArpTimeoutCheck(void)
 static void
 NetInitLoop(proto_t protocol)
 {
-   static int env_changed_id = 0;
+   static int env_changed_id;
bd_t *bd = gd->bd;
int env_id = get_env_id ();
 
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/8] net/net.c: cosmetic: fix lines over 80 characters

2011-05-04 Thread Luca Ceresoli
This removes the following checkpatch warning:
 - WARNING: line over 80 characters

There is still one such warning that is hard to fix with cosmetic-only
changes without compromising code readability, so I', leaving it as it
is for now:
  WARNING: line over 80 characters
  #1537: FILE: net.c:1537:
  + [4 tabs] memcpy(((Ethernet_t *)NetArpWaitTxPacket)->et_dest, ...

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Ben Warren 
---
 net/net.c |  238 +
 1 files changed, 159 insertions(+), 79 deletions(-)

diff --git a/net/net.c b/net/net.c
index e50bdf1..90312eb 100644
--- a/net/net.c
+++ b/net/net.c
@@ -101,7 +101,8 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifndefCONFIG_ARP_TIMEOUT
-# define ARP_TIMEOUT   5000UL  /* Milliseconds before trying ARP again 
*/
+/* Milliseconds before trying ARP again */
+# define ARP_TIMEOUT   5000UL
 #else
 # define ARP_TIMEOUT   CONFIG_ARP_TIMEOUT
 #endif
@@ -115,16 +116,24 @@ DECLARE_GLOBAL_DATA_PTR;
 
 /** BOOTP EXTENTIONS **/
 
-IPaddr_t   NetOurSubnetMask=0; /* Our subnet mask (0=unknown)  
*/
-IPaddr_t   NetOurGatewayIP=0;  /* Our gateways IP address  
*/
-IPaddr_t   NetOurDNSIP=0;  /* Our DNS IP address   
*/
+/* Our subnet mask (0=unknown) */
+IPaddr_t   NetOurSubnetMask=0;
+/* Our gateways IP address */
+IPaddr_t   NetOurGatewayIP=0;
+/* Our DNS IP address */
+IPaddr_t   NetOurDNSIP=0;
 #if defined(CONFIG_BOOTP_DNS2)
-IPaddr_t   NetOurDNS2IP=0; /* Our 2nd DNS IP address   
*/
-#endif
-char   NetOurNISDomain[32]={0,};   /* Our NIS domain   
*/
-char   NetOurHostName[32]={0,};/* Our hostname 
*/
-char   NetOurRootPath[64]={0,};/* Our bootpath 
*/
-ushort NetBootFileSize=0;  /* Our bootfile size in blocks  
*/
+/* Our 2nd DNS IP address */
+IPaddr_t   NetOurDNS2IP=0;
+#endif
+/* Our NIS domain */
+char   NetOurNISDomain[32]={0,};
+/* Our hostname */
+char   NetOurHostName[32]={0,};
+/* Our bootpath */
+char   NetOurRootPath[64]={0,};
+/* Our bootfile size in blocks */
+ushort NetBootFileSize=0;
 
 #ifdef CONFIG_MCAST_TFTP   /* Multicast TFTP */
 IPaddr_t Mcast_addr;
@@ -132,16 +141,25 @@ IPaddr_t Mcast_addr;
 
 /** END OF BOOTP EXTENTIONS **/
 
-ulong  NetBootFileXferSize;/* The actual transferred size of the 
bootfile (in bytes) */
-uchar  NetOurEther[6]; /* Our ethernet address 
*/
-uchar  NetServerEther[6] = /* Boot server enet address 
*/
+/* The actual transferred size of the bootfile (in bytes) */
+ulong  NetBootFileXferSize;
+/* Our ethernet address */
+uchar  NetOurEther[6];
+/* Boot server enet address */
+uchar  NetServerEther[6] =
{ 0, 0, 0, 0, 0, 0 };
-IPaddr_t   NetOurIP;   /* Our IP addr (0 = unknown)
*/
-IPaddr_t   NetServerIP;/* Server IP addr (0 = unknown) 
*/
-volatile uchar *NetRxPacket;   /* Current receive packet   
*/
-intNetRxPacketLen; /* Current rx packet length 
*/
-unsigned   NetIPID;/* IP packet ID 
*/
-uchar  NetBcastAddr[6] =   /* Ethernet bcast address   
*/
+/* Our IP addr (0 = unknown) */
+IPaddr_t   NetOurIP;
+/* Server IP addr (0 = unknown) */
+IPaddr_t   NetServerIP;
+/* Current receive packet */
+volatile uchar *NetRxPacket;
+/* Current rx packet length */
+intNetRxPacketLen;
+/* IP packet ID */
+unsigned   NetIPID;
+/* Ethernet bcast address */
+uchar  NetBcastAddr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
 uchar  NetEtherNullAddr[6] =
{ 0, 0, 0, 0, 0, 0 };
@@ -149,24 +167,33 @@ uchar NetEtherNullAddr[6] =
 void   (*push_packet)(volatile void *, int len) = 0;
 #endif
 #if defined(CONFIG_CMD_CDP)
-uchar  NetCDPAddr[6] = /* Ethernet bcast address   
*/
+/* Ethernet bcast address */
+uchar  NetCDPAddr[6] =
{ 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
 #endif
-intNetState;   /* Network loop state   
*/
+/* Network loop state */
+intNetState;
 #ifdef CONFIG_NET_MULTI
-intNetRestartWrap = 0; /* Tried all network devices
*/
-static int NetRestarted = 0;   /* Network loop restarted   
*/
-static int NetDevExists = 0;   /* At least one device configured   
*/
+/* Tried all network devices */
+intNetRestartWrap = 0;
+/* Network loop restarted */
+static int NetRestarted = 0;
+/* At least one device configured */
+static int NetD

[U-Boot] [PATCH 3/8] net/net.c: cosmetic: fix whitespace issues

2011-05-04 Thread Luca Ceresoli
This removes the following checkpatch issues:
 - ERROR: space prohibited after that open parenthesis '('
 - ERROR: space prohibited before that close parenthesis ')'
 - ERROR: space prohibited after that open square bracket '['
 - ERROR: space prohibited after that '&' (ctx:WxW)
 - ERROR: spaces required around that '=' (ctx:VxW)
 - ERROR: space required before the open parenthesis '('
 - ERROR: space required after that ',' (ctx:VxV)
 - ERROR: need consistent spacing around '+' (ctx:WxV)
 - WARNING: unnecessary whitespace before a quoted newline
 - WARNING: please, no spaces at the start of a line
 - WARNING: space prohibited between function name and open
   parenthesis '('

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Ben Warren 
---
 net/net.c |  192 ++--
 1 files changed, 96 insertions(+), 96 deletions(-)

diff --git a/net/net.c b/net/net.c
index e89e118..630aeee 100644
--- a/net/net.c
+++ b/net/net.c
@@ -228,7 +228,7 @@ static ulongtimeDelta;
 /* THE transmit packet */
 volatile uchar *NetTxPacket;
 
-static int net_check_prereq (proto_t protocol);
+static int net_check_prereq(proto_t protocol);
 
 static int NetTryCount;
 
@@ -245,7 +245,7 @@ uchar   NetArpWaitPacketBuf[PKTSIZE_ALIGN + 
PKTALIGN];
 ulong  NetArpWaitTimerStart;
 intNetArpWaitTry;
 
-void ArpRequest (void)
+void ArpRequest(void)
 {
int i;
volatile uchar *pkt;
@@ -255,20 +255,20 @@ void ArpRequest (void)
 
pkt = NetTxPacket;
 
-   pkt += NetSetEther (pkt, NetBcastAddr, PROT_ARP);
+   pkt += NetSetEther(pkt, NetBcastAddr, PROT_ARP);
 
arp = (ARP_t *) pkt;
 
-   arp->ar_hrd = htons (ARP_ETHER);
-   arp->ar_pro = htons (PROT_IP);
+   arp->ar_hrd = htons(ARP_ETHER);
+   arp->ar_pro = htons(PROT_IP);
arp->ar_hln = 6;
arp->ar_pln = 4;
-   arp->ar_op = htons (ARPOP_REQUEST);
+   arp->ar_op = htons(ARPOP_REQUEST);
 
/* source ET addr */
-   memcpy (&arp->ar_data[0], NetOurEther, 6);
+   memcpy(&arp->ar_data[0], NetOurEther, 6);
/* source IP addr */
-   NetWriteIP ((uchar *) & arp->ar_data[6], NetOurIP);
+   NetWriteIP((uchar *) &arp->ar_data[6], NetOurIP);
for (i = 10; i < 16; ++i) {
/* dest ET addr = 0 */
arp->ar_data[i] = 0;
@@ -277,7 +277,7 @@ void ArpRequest (void)
if ((NetArpWaitPacketIP & NetOurSubnetMask) !=
(NetOurIP & NetOurSubnetMask)) {
if (NetOurGatewayIP == 0) {
-   puts ("## Warning: gatewayip needed but not set\n");
+   puts("## Warning: gatewayip needed but not set\n");
NetArpWaitReplyIP = NetArpWaitPacketIP;
} else {
NetArpWaitReplyIP = NetOurGatewayIP;
@@ -286,8 +286,8 @@ void ArpRequest (void)
NetArpWaitReplyIP = NetArpWaitPacketIP;
}
 
-   NetWriteIP ((uchar *) & arp->ar_data[16], NetArpWaitReplyIP);
-   (void) eth_send (NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);
+   NetWriteIP((uchar *) &arp->ar_data[16], NetArpWaitReplyIP);
+   (void) eth_send(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);
 }
 
 void ArpTimeoutCheck(void)
@@ -304,7 +304,7 @@ void ArpTimeoutCheck(void)
NetArpWaitTry++;
 
if (NetArpWaitTry >= ARP_TIMEOUT_COUNT) {
-   puts ("\nARP Retry count exceeded; starting again\n");
+   puts("\nARP Retry count exceeded; starting again\n");
NetArpWaitTry = 0;
NetStartAgain();
} else {
@@ -319,14 +319,14 @@ NetInitLoop(proto_t protocol)
 {
static int env_changed_id;
bd_t *bd = gd->bd;
-   int env_id = get_env_id ();
+   int env_id = get_env_id();
 
/* update only when the environment has changed */
if (env_changed_id != env_id) {
NetCopyIP(&NetOurIP, &bd->bi_ip_addr);
-   NetOurGatewayIP = getenv_IPaddr ("gatewayip");
-   NetOurSubnetMask= getenv_IPaddr ("netmask");
-   NetServerIP = getenv_IPaddr ("serverip");
+   NetOurGatewayIP = getenv_IPaddr("gatewayip");
+   NetOurSubnetMask = getenv_IPaddr("netmask");
+   NetServerIP = getenv_IPaddr("serverip");
NetOurNativeVLAN = getenv_VLAN("nvlan");
NetOurVLAN = getenv_VLAN("vlan");
 #if defined(CONFIG_CMD_DNS)
@@ -391,7 +391,7 @@ NetLoop(proto_t protocol)
 
 restart:
 #ifdef CONFIG_NET_MULTI
-   memcpy (NetOurEther, eth_get_dev()->enet

[U-Boot] [PATCH 4/8] net/net.c: cosmetic: fix brace issues

2011-05-04 Thread Luca Ceresoli
This removes the following checkpatch issues:
 - WARNING: braces {} are not necessary for single statement blocks
 - WARNING: braces {} are not necessary for any arm of this statement

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Ben Warren 
---
 net/net.c |   38 +-
 1 files changed, 13 insertions(+), 25 deletions(-)

diff --git a/net/net.c b/net/net.c
index 630aeee..14dc65a 100644
--- a/net/net.c
+++ b/net/net.c
@@ -369,9 +369,8 @@ NetLoop(proto_t protocol)
 */
NetTxPacket = &PktBuf[0] + (PKTALIGN - 1);
NetTxPacket -= (ulong)NetTxPacket % PKTALIGN;
-   for (i = 0; i < PKTBUFSRX; i++) {
+   for (i = 0; i < PKTBUFSRX; i++)
NetRxPackets[i] = NetTxPacket + (i+1)*PKTSIZE_ALIGN;
-   }
}
 
if (!NetArpWaitTxPacket) {
@@ -493,11 +492,10 @@ restart:
/*
 * Echo the inverted link state to the fault LED.
 */
-   if (miiphy_link(eth_get_dev()->name, CONFIG_SYS_FAULT_MII_ADDR)) {
+   if (miiphy_link(eth_get_dev()->name, CONFIG_SYS_FAULT_MII_ADDR))
status_led_set(STATUS_LED_RED, STATUS_LED_OFF);
-   } else {
+   else
status_led_set(STATUS_LED_RED, STATUS_LED_ON);
-   }
 #endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */
 #endif /* CONFIG_MII, ... */
 
@@ -1098,9 +1096,8 @@ CDPHandler(const uchar * pkt, unsigned len)
ss = (const ushort *)pkt;
type = ntohs(ss[0]);
tlen = ntohs(ss[1]);
-   if (tlen > len) {
+   if (tlen > len)
goto pkt_short;
-   }
 
pkt += tlen;
len -= tlen;
@@ -1479,26 +1476,20 @@ NetReceive(volatile uchar * inpkt, int len)
printf("bad length %d < %d\n", len, ARP_HDR_SIZE);
return;
}
-   if (ntohs(arp->ar_hrd) != ARP_ETHER) {
+   if (ntohs(arp->ar_hrd) != ARP_ETHER)
return;
-   }
-   if (ntohs(arp->ar_pro) != PROT_IP) {
+   if (ntohs(arp->ar_pro) != PROT_IP)
return;
-   }
-   if (arp->ar_hln != 6) {
+   if (arp->ar_hln != 6)
return;
-   }
-   if (arp->ar_pln != 4) {
+   if (arp->ar_pln != 4)
return;
-   }
 
-   if (NetOurIP == 0) {
+   if (NetOurIP == 0)
return;
-   }
 
-   if (NetReadIP(&arp->ar_data[16]) != NetOurIP) {
+   if (NetReadIP(&arp->ar_data[16]) != NetOurIP)
return;
-   }
 
switch (ntohs(arp->ar_op)) {
case ARPOP_REQUEST:
@@ -1603,13 +1594,11 @@ NetReceive(volatile uchar * inpkt, int len)
debug("len=%d, v=%02x\n", len, ip->ip_hl_v & 0xff);
 
/* Can't deal with anything except IPv4 */
-   if ((ip->ip_hl_v & 0xf0) != 0x40) {
+   if ((ip->ip_hl_v & 0xf0) != 0x40)
return;
-   }
/* Can't deal with IP options (headers != 20 bytes) */
-   if ((ip->ip_hl_v & 0x0f) > 0x05) {
+   if ((ip->ip_hl_v & 0x0f) > 0x05)
return;
-   }
/* Check the Checksum of the header */
if (!NetCksumOk((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2)) {
puts("checksum bad\n");
@@ -1949,9 +1938,8 @@ void copy_filename(char *dst, const char *src, int size)
--size;
}
 
-   while ((--size > 0) && *src && (*src != '"')) {
+   while ((--size > 0) && *src && (*src != '"'))
*dst++ = *src++;
-   }
*dst = '\0';
 }
 
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 5/8] net/net.c: cosmetic: fix pointer syntax issues

2011-05-04 Thread Luca Ceresoli
This removes the following checkpatch issues:
 - ERROR: "foo * bar" should be "foo *bar"
 - ERROR: "(foo*)" should be "(foo *)"

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Ben Warren 
---
 net/net.c |   36 ++--
 1 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/net/net.c b/net/net.c
index 14dc65a..0e13fb2 100644
--- a/net/net.c
+++ b/net/net.c
@@ -594,7 +594,7 @@ startAgainTimeout(void)
 }
 
 static void
-startAgainHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+startAgainHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len)
 {
/* Totally ignore the packet */
 }
@@ -655,14 +655,14 @@ void NetStartAgain(void)
  */
 
 void
-NetSetHandler(rxhand_f * f)
+NetSetHandler(rxhand_f *f)
 {
packetHandler = f;
 }
 
 
 void
-NetSetTimeout(ulong iv, thand_f * f)
+NetSetTimeout(ulong iv, thand_f *f)
 {
if (iv == 0) {
timeHandler = (thand_f *)0;
@@ -675,7 +675,7 @@ NetSetTimeout(ulong iv, thand_f * f)
 
 
 void
-NetSendPacket(volatile uchar * pkt, int len)
+NetSendPacket(volatile uchar *pkt, int len)
 {
(void) eth_send(pkt, len);
 }
@@ -770,9 +770,9 @@ int PingSend(void)
ip->ip_p = 0x01;/* ICMP */
ip->ip_sum   = 0;
/* already in network byte order */
-   NetCopyIP((void*)&ip->ip_src, &NetOurIP);
+   NetCopyIP((void *)&ip->ip_src, &NetOurIP);
/* - "" - */
-   NetCopyIP((void*)&ip->ip_dst, &NetPingIP);
+   NetCopyIP((void *)&ip->ip_dst, &NetPingIP);
ip->ip_sum   = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2);
 
s = &ip->udp_src;   /* XXX ICMP starts here */
@@ -801,7 +801,7 @@ PingTimeout(void)
 }
 
 static void
-PingHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+PingHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len)
 {
IPaddr_t tmp;
volatile IP_t *ip = (volatile IP_t *)pkt;
@@ -1044,13 +1044,13 @@ CDPTimeout(void)
 }
 
 static void
-CDPDummyHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+CDPDummyHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len)
 {
/* nothing */
 }
 
 static void
-CDPHandler(const uchar * pkt, unsigned len)
+CDPHandler(const uchar *pkt, unsigned len)
 {
const uchar *t;
const ushort *ss;
@@ -1356,7 +1356,7 @@ static inline IP_t *NetDefragment(IP_t *ip, int *lenp)
 #endif
 
 void
-NetReceive(volatile uchar * inpkt, int len)
+NetReceive(volatile uchar *inpkt, int len)
 {
Ethernet_t *et;
IP_t*ip;
@@ -1665,8 +1665,8 @@ NetReceive(volatile uchar * inpkt, int len)
 
ip->ip_sum = 0;
ip->ip_off = 0;
-   NetCopyIP((void*)&ip->ip_dst, &ip->ip_src);
-   NetCopyIP((void*)&ip->ip_src, &NetOurIP);
+   NetCopyIP((void *)&ip->ip_dst, &ip->ip_src);
+   NetCopyIP((void *)&ip->ip_src, &NetOurIP);
ip->ip_sum = ~NetCksum((uchar *)ip,
   IP_HDR_SIZE_NO_UDP >> 1);
 
@@ -1836,14 +1836,14 @@ static int net_check_prereq(proto_t protocol)
 /**/
 
 int
-NetCksumOk(uchar * ptr, int len)
+NetCksumOk(uchar *ptr, int len)
 {
return !((NetCksum(ptr, len) + 1) & 0xfffe);
 }
 
 
 unsigned
-NetCksum(uchar * ptr, int len)
+NetCksum(uchar *ptr, int len)
 {
ulong   xsum;
ushort *p = (ushort *)ptr;
@@ -1870,7 +1870,7 @@ NetEthHdrSize(void)
 }
 
 int
-NetSetEther(volatile uchar * xet, uchar * addr, uint prot)
+NetSetEther(volatile uchar *xet, uchar * addr, uint prot)
 {
Ethernet_t *et = (Ethernet_t *)xet;
ushort myvlanid;
@@ -1895,7 +1895,7 @@ NetSetEther(volatile uchar * xet, uchar * addr, uint prot)
 }
 
 void
-NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
+NetSetIP(volatile uchar *xip, IPaddr_t dest, int dport, int sport, int len)
 {
IP_t *ip = (IP_t *)xip;
 
@@ -1921,9 +1921,9 @@ NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, 
int sport, int len)
ip->ip_p = 17;  /* UDP */
ip->ip_sum   = 0;
/* already in network byte order */
-   NetCopyIP((void*)&ip->ip_src, &NetOurIP);
+   NetCopyIP((void *)&ip->ip_src, &NetOurIP);
/* - "" - */
-   NetCopyIP((void*)&ip->ip_dst, &dest);
+   NetCopyIP((void *)&ip->ip_dst, &dest);
ip->udp_src  = htons(sport);
ip->udp_dst  = htons(dport);
ip->udp_len  = htons(8 + len);
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 7/8] net/net.c: cosmetic: fix indentation

2011-05-04 Thread Luca Ceresoli
This removes the following checkpatch issues:
 - ERROR: switch and case should be at the same indent
 - WARNING: suspect code indent for conditional statements
 - WARNING: labels should not be indented

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Ben Warren 
---
 net/net.c |   85 ++---
 1 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/net/net.c b/net/net.c
index 2bffc5b..13efa67 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1106,51 +1106,50 @@ CDPHandler(const uchar *pkt, unsigned len)
tlen -= 4;
 
switch (type) {
-   case CDP_DEVICE_ID_TLV:
-   break;
-   case CDP_ADDRESS_TLV:
-   break;
-   case CDP_PORT_ID_TLV:
-   break;
-   case CDP_CAPABILITIES_TLV:
-   break;
-   case CDP_VERSION_TLV:
-   break;
-   case CDP_PLATFORM_TLV:
-   break;
-   case CDP_NATIVE_VLAN_TLV:
-   nvlan = *ss;
-   break;
-   case CDP_APPLIANCE_VLAN_TLV:
-   t = (const uchar *)ss;
-   while (tlen > 0) {
-   if (tlen < 3)
-   goto pkt_short;
+   case CDP_DEVICE_ID_TLV:
+   break;
+   case CDP_ADDRESS_TLV:
+   break;
+   case CDP_PORT_ID_TLV:
+   break;
+   case CDP_CAPABILITIES_TLV:
+   break;
+   case CDP_VERSION_TLV:
+   break;
+   case CDP_PLATFORM_TLV:
+   break;
+   case CDP_NATIVE_VLAN_TLV:
+   nvlan = *ss;
+   break;
+   case CDP_APPLIANCE_VLAN_TLV:
+   t = (const uchar *)ss;
+   while (tlen > 0) {
+   if (tlen < 3)
+   goto pkt_short;
 
-   applid = t[0];
-   ss = (const ushort *)(t + 1);
+   applid = t[0];
+   ss = (const ushort *)(t + 1);
 
 #ifdef CONFIG_CDP_APPLIANCE_VLAN_TYPE
-   if (applid ==
-   CONFIG_CDP_APPLIANCE_VLAN_TYPE)
-   vlan = *ss;
+   if (applid == CONFIG_CDP_APPLIANCE_VLAN_TYPE)
+   vlan = *ss;
 #else
-   /* XXX will this work; dunno */
-   vlan = ntohs(*ss);
+   /* XXX will this work; dunno */
+   vlan = ntohs(*ss);
 #endif
-   t += 3; tlen -= 3;
-   }
-   break;
-   case CDP_TRIGGER_TLV:
-   break;
-   case CDP_POWER_CONSUMPTION_TLV:
-   break;
-   case CDP_SYSNAME_TLV:
-   break;
-   case CDP_SYSOBJECT_TLV:
-   break;
-   case CDP_MANAGEMENT_ADDRESS_TLV:
-   break;
+   t += 3; tlen -= 3;
+   }
+   break;
+   case CDP_TRIGGER_TLV:
+   break;
+   case CDP_POWER_CONSUMPTION_TLV:
+   break;
+   case CDP_SYSNAME_TLV:
+   break;
+   case CDP_SYSOBJECT_TLV:
+   break;
+   case CDP_MANAGEMENT_ADDRESS_TLV:
+   break;
}
}
 
@@ -1610,7 +1609,7 @@ NetReceive(volatile uchar *inpkt, int len)
 #ifdef CONFIG_MCAST_TFTP
if (Mcast_addr != tmp)
 #endif
-   return;
+   return;
}
/*
 * The function returns the unchanged packet if it's not
@@ -1787,7 +1786,7 @@ static int net_check_prereq(proto_t protocol)
}
 #ifdefined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
defined(CONFIG_CMD_DNS)
-common:
+common:
 #endif
 
if (NetOurIP == 0) {
@@ -1882,7 +1881,7 @@ NetSetEther(volatile uchar *xet, uchar * addr, uint prot)
memcpy(et->et_dest, addr, 6);
 

[U-Boot] [PATCH 8/8] net/net.c: cosmetic: do not use assignment in if condition

2011-05-04 Thread Luca Ceresoli
This removes the following checkpatch issue:
 - ERROR: do not use assignment in if condition

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Ben Warren 
---
 net/net.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/net.c b/net/net.c
index 13efa67..c17d071 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1616,7 +1616,8 @@ NetReceive(volatile uchar *inpkt, int len)
 * a fragment, and either the complete packet or NULL if
 * it is a fragment (if !CONFIG_IP_DEFRAG, it returns NULL)
 */
-   if (!(ip = NetDefragment(ip, &len)))
+   ip = NetDefragment(ip, &len);
+   if (!ip)
return;
/*
 * watch for ICMP host redirects
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 6/8] net/net.c: cosmetic: parentheses not required for return

2011-05-04 Thread Luca Ceresoli
This removes the following checkpatch issue:
 - ERROR: return is not a function, parentheses are not required

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Ben Warren 
---
 net/net.c |   30 +++---
 1 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/net/net.c b/net/net.c
index 0e13fb2..2bffc5b 100644
--- a/net/net.c
+++ b/net/net.c
@@ -385,7 +385,7 @@ NetLoop(proto_t protocol)
 #endif
if (eth_init(bd) < 0) {
eth_halt();
-   return(-1);
+   return -1;
}
 
 restart:
@@ -408,7 +408,7 @@ restart:
case 1:
/* network not configured */
eth_halt();
-   return (-1);
+   return -1;
 
 #ifdef CONFIG_NET_MULTI
case 2:
@@ -523,7 +523,7 @@ restart:
if (ctrlc()) {
eth_halt();
puts("\nAbort\n");
-   return (-1);
+   return -1;
}
 
ArpTimeoutCheck();
@@ -580,7 +580,7 @@ restart:
return NetBootFileXferSize;
 
case NETLOOP_FAIL:
-   return (-1);
+   return -1;
}
}
 }
@@ -1756,7 +1756,7 @@ static int net_check_prereq(proto_t protocol)
case PING:
if (NetPingIP == 0) {
puts("*** ERROR: ping address not given\n");
-   return (1);
+   return 1;
}
goto common;
 #endif
@@ -1764,7 +1764,7 @@ static int net_check_prereq(proto_t protocol)
case SNTP:
if (NetNtpServerIP == 0) {
puts("*** ERROR: NTP server address not given\n");
-   return (1);
+   return 1;
}
goto common;
 #endif
@@ -1783,7 +1783,7 @@ static int net_check_prereq(proto_t protocol)
case TFTP:
if (NetServerIP == 0) {
puts("*** ERROR: `serverip' not set\n");
-   return (1);
+   return 1;
}
 #ifdefined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
defined(CONFIG_CMD_DNS)
@@ -1792,7 +1792,7 @@ static int net_check_prereq(proto_t protocol)
 
if (NetOurIP == 0) {
puts("*** ERROR: `ipaddr' not set\n");
-   return (1);
+   return 1;
}
/* Fall through */
 
@@ -1810,7 +1810,7 @@ static int net_check_prereq(proto_t protocol)
switch (num) {
case -1:
puts("*** ERROR: No ethernet found.\n");
-   return (1);
+   return 1;
case 0:
puts("*** ERROR: `ethaddr' not set\n");
break;
@@ -1821,17 +1821,17 @@ static int net_check_prereq(proto_t protocol)
}
 
NetStartAgain();
-   return (2);
+   return 2;
 #else
puts("*** ERROR: `ethaddr' not set\n");
-   return (1);
+   return 1;
 #endif
}
/* Fall through */
default:
-   return (0);
+   return 0;
}
-   return (0); /* OK */
+   return 0;   /* OK */
 }
 /**/
 
@@ -1853,7 +1853,7 @@ NetCksum(uchar *ptr, int len)
xsum += *p++;
xsum = (xsum & 0x) + (xsum >> 16);
xsum = (xsum & 0x) + (xsum >> 16);
-   return (xsum & 0x);
+   return xsum & 0x;
 }
 
 int
@@ -1997,5 +1997,5 @@ ushort string_to_VLAN(const char *s)
 
 ushort getenv_VLAN(char *var)
 {
-   return (string_to_VLAN(getenv(var)));
+   return string_to_VLAN(getenv(var));
 }
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/8] net/net.c: cosmetic: variable initializations

2011-05-04 Thread Luca Ceresoli
Mike Frysinger wrote:
> On Wed, May 4, 2011 at 08:40, Luca Ceresoli wrote:
>>   - ERROR: that open brace { should be on the previous line
>> ...
>> -uchar  NetCDPAddr[6] =
>> -   { 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
>> +uchar  NetCDPAddr[6] = {
>> +   0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
>> ...
> your fix here is worse than the original.  just leave them be.

Damn, you're right!

I think a one-line solution would be even better (and much simpler):

uchar   NetCDPAddr[6] = {0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc};

BTW, this is the original checkpatch message:
   ERROR: that open brace { should be on the previous line
   #172: FILE: net.c:172:
   +uchar  NetCDPAddr[6] =
   +   { 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };

So either we choose the one-line solution above, or we have the first
checkpatch message that should be disabled in the U-Boot version, when it
will exist.

Your opinion?

Luca


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/8] net/net.c: cosmetic: fix lines over 80 characters

2011-05-10 Thread Luca Ceresoli
Hi Mike,

Mike Frysinger wrote:
> On Wednesday, May 04, 2011 08:40:40 Luca Ceresoli wrote:
>> -debug("Got ICMP ECHO REQUEST, return %d bytes 
>> \n",
>> -ETHER_HDR_SIZE + len);
>> +debug("Got ICMP ECHO REQUEST, "
>> +  "return %d bytes \n",
>> +  ETHER_HDR_SIZE + len);
> please do not split string literals

What do you suggest as an alternative? Leave the line more than
80 characters long?

I think the best thing would be to split the NetReceive() function that
contains that line, which is currently ~400 lines long. This would reduce
the amount of tabs in front of the deeply nested lines (such as this).

So I would agree to leave the line as is, waiting for NetReceive() to be
split in a future cleanup work.

Luca

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 0/8] net/net.c: cleanups for checkpatch compliance

2011-05-11 Thread Luca Ceresoli
Hi,

this is an update to the net/net.c cleanup, incorporating Mike's suggestions
to patches 1 and 2. Thanks Mike.

net/net.c currently raises a lot of checkpatch issues: 76 errors, 197 warnings.
This patchset fixes most of them, leaving 0 errors and 27 warnings.

Since the changes are quite massive I split them in separate patches, one
per each category of errors/warning.

The warnings that are still present are of the following types:
 - WARNING: consider using kstrto* in preference to simple_strtoul
   which is Linux-specific;
 - WARNING: externs should be avoided in .c files
   these are due to loop-dependencies between net/net.c and other files;
 - WARNING: line over 80 characters
   described in the commit message for patch 1;
 - WARNING: Use of volatile is usually wrong [...]
   I've had a quick look at these, but I don't know in detail how the
   networking code and Ethernet drivers (and maybe DMA?) interact, so I cannot
   remove them being sure that things will continue working.

Luca


Luca Ceresoli (8):
  net/net.c: cosmetic: fix lines over 80 characters
  net/net.c: cosmetic: variable initializations
  net/net.c: cosmetic: fix whitespace issues
  net/net.c: cosmetic: fix brace issues
  net/net.c: cosmetic: fix pointer syntax issues
  net/net.c: cosmetic: parentheses not required for return
  net/net.c: cosmetic: fix indentation
  net/net.c: cosmetic: do not use assignment in if condition

 net/net.c |  593 ++---
 1 files changed, 328 insertions(+), 265 deletions(-)

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/8] net/net.c: cosmetic: fix lines over 80 characters

2011-05-11 Thread Luca Ceresoli
This removes the following checkpatch warning:
 - WARNING: line over 80 characters

There are three such warnings left.

The first is hard to fix with cosmetic-only changes without compromising code
readability, so I'm leaving it as it is for now:
  WARNING: line over 80 characters
  #1537: FILE: net.c:1537:
  + [4 tabs] memcpy(((Ethernet_t *)NetArpWaitTxPacket)->et_dest, ...

The other two cannot be fixed without splitting string literals, so it is
preferred to keep them longer than 80 characters.

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Ben Warren 
Cc: Mike Frysinger 

---
Changes since v1:
 - do not split string literals (even though this means leaving the line
   longer than 80 characters).

 net/net.c |  231 +
 1 files changed, 155 insertions(+), 76 deletions(-)

diff --git a/net/net.c b/net/net.c
index e50bdf1..6e3af5b 100644
--- a/net/net.c
+++ b/net/net.c
@@ -101,7 +101,8 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifndefCONFIG_ARP_TIMEOUT
-# define ARP_TIMEOUT   5000UL  /* Milliseconds before trying ARP again 
*/
+/* Milliseconds before trying ARP again */
+# define ARP_TIMEOUT   5000UL
 #else
 # define ARP_TIMEOUT   CONFIG_ARP_TIMEOUT
 #endif
@@ -115,16 +116,24 @@ DECLARE_GLOBAL_DATA_PTR;
 
 /** BOOTP EXTENTIONS **/
 
-IPaddr_t   NetOurSubnetMask=0; /* Our subnet mask (0=unknown)  
*/
-IPaddr_t   NetOurGatewayIP=0;  /* Our gateways IP address  
*/
-IPaddr_t   NetOurDNSIP=0;  /* Our DNS IP address   
*/
+/* Our subnet mask (0=unknown) */
+IPaddr_t   NetOurSubnetMask=0;
+/* Our gateways IP address */
+IPaddr_t   NetOurGatewayIP=0;
+/* Our DNS IP address */
+IPaddr_t   NetOurDNSIP=0;
 #if defined(CONFIG_BOOTP_DNS2)
-IPaddr_t   NetOurDNS2IP=0; /* Our 2nd DNS IP address   
*/
-#endif
-char   NetOurNISDomain[32]={0,};   /* Our NIS domain   
*/
-char   NetOurHostName[32]={0,};/* Our hostname 
*/
-char   NetOurRootPath[64]={0,};/* Our bootpath 
*/
-ushort NetBootFileSize=0;  /* Our bootfile size in blocks  
*/
+/* Our 2nd DNS IP address */
+IPaddr_t   NetOurDNS2IP=0;
+#endif
+/* Our NIS domain */
+char   NetOurNISDomain[32]={0,};
+/* Our hostname */
+char   NetOurHostName[32]={0,};
+/* Our bootpath */
+char   NetOurRootPath[64]={0,};
+/* Our bootfile size in blocks */
+ushort NetBootFileSize=0;
 
 #ifdef CONFIG_MCAST_TFTP   /* Multicast TFTP */
 IPaddr_t Mcast_addr;
@@ -132,16 +141,25 @@ IPaddr_t Mcast_addr;
 
 /** END OF BOOTP EXTENTIONS **/
 
-ulong  NetBootFileXferSize;/* The actual transferred size of the 
bootfile (in bytes) */
-uchar  NetOurEther[6]; /* Our ethernet address 
*/
-uchar  NetServerEther[6] = /* Boot server enet address 
*/
+/* The actual transferred size of the bootfile (in bytes) */
+ulong  NetBootFileXferSize;
+/* Our ethernet address */
+uchar  NetOurEther[6];
+/* Boot server enet address */
+uchar  NetServerEther[6] =
{ 0, 0, 0, 0, 0, 0 };
-IPaddr_t   NetOurIP;   /* Our IP addr (0 = unknown)
*/
-IPaddr_t   NetServerIP;/* Server IP addr (0 = unknown) 
*/
-volatile uchar *NetRxPacket;   /* Current receive packet   
*/
-intNetRxPacketLen; /* Current rx packet length 
*/
-unsigned   NetIPID;/* IP packet ID 
*/
-uchar  NetBcastAddr[6] =   /* Ethernet bcast address   
*/
+/* Our IP addr (0 = unknown) */
+IPaddr_t   NetOurIP;
+/* Server IP addr (0 = unknown) */
+IPaddr_t   NetServerIP;
+/* Current receive packet */
+volatile uchar *NetRxPacket;
+/* Current rx packet length */
+intNetRxPacketLen;
+/* IP packet ID */
+unsigned   NetIPID;
+/* Ethernet bcast address */
+uchar  NetBcastAddr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
 uchar  NetEtherNullAddr[6] =
{ 0, 0, 0, 0, 0, 0 };
@@ -149,24 +167,33 @@ uchar NetEtherNullAddr[6] =
 void   (*push_packet)(volatile void *, int len) = 0;
 #endif
 #if defined(CONFIG_CMD_CDP)
-uchar  NetCDPAddr[6] = /* Ethernet bcast address   
*/
+/* Ethernet bcast address */
+uchar  NetCDPAddr[6] =
{ 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
 #endif
-intNetState;   /* Network loop state   
*/
+/* Network loop state */
+intNetState;
 #ifdef CONFIG_NET_MULTI
-intNetRestartWrap = 0; /* Tried all network devices
*/
-static int NetRestarted = 0;   /* Network loop restarted   
*/

[U-Boot] [PATCH v2 2/8] net/net.c: cosmetic: variable initializations

2011-05-11 Thread Luca Ceresoli
This removes the following checkpatch errors:
 - ERROR: do not initialise globals to 0 or NULL
 - ERROR: spaces required around that '=' (ctx:VxV)
 - ERROR: that open brace { should be on the previous line

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Ben Warren 
Cc: Mike Frysinger 

---
Changes since v1:
 - re-fix array initializations (the fix in v1 was worse than the original).

 net/net.c |   40 ++--
 1 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/net/net.c b/net/net.c
index 6e3af5b..4715699 100644
--- a/net/net.c
+++ b/net/net.c
@@ -117,23 +117,23 @@ DECLARE_GLOBAL_DATA_PTR;
 /** BOOTP EXTENTIONS **/
 
 /* Our subnet mask (0=unknown) */
-IPaddr_t   NetOurSubnetMask=0;
+IPaddr_t   NetOurSubnetMask;
 /* Our gateways IP address */
-IPaddr_t   NetOurGatewayIP=0;
+IPaddr_t   NetOurGatewayIP;
 /* Our DNS IP address */
-IPaddr_t   NetOurDNSIP=0;
+IPaddr_t   NetOurDNSIP;
 #if defined(CONFIG_BOOTP_DNS2)
 /* Our 2nd DNS IP address */
-IPaddr_t   NetOurDNS2IP=0;
+IPaddr_t   NetOurDNS2IP;
 #endif
 /* Our NIS domain */
-char   NetOurNISDomain[32]={0,};
+char   NetOurNISDomain[32] = {0,};
 /* Our hostname */
-char   NetOurHostName[32]={0,};
+char   NetOurHostName[32] = {0,};
 /* Our bootpath */
-char   NetOurRootPath[64]={0,};
+char   NetOurRootPath[64] = {0,};
 /* Our bootfile size in blocks */
-ushort NetBootFileSize=0;
+ushort NetBootFileSize;
 
 #ifdef CONFIG_MCAST_TFTP   /* Multicast TFTP */
 IPaddr_t Mcast_addr;
@@ -146,8 +146,7 @@ ulong   NetBootFileXferSize;
 /* Our ethernet address */
 uchar  NetOurEther[6];
 /* Boot server enet address */
-uchar  NetServerEther[6] =
-   { 0, 0, 0, 0, 0, 0 };
+uchar  NetServerEther[6];
 /* Our IP addr (0 = unknown) */
 IPaddr_t   NetOurIP;
 /* Server IP addr (0 = unknown) */
@@ -159,27 +158,24 @@ int   NetRxPacketLen;
 /* IP packet ID */
 unsigned   NetIPID;
 /* Ethernet bcast address */
-uchar  NetBcastAddr[6] =
-   { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-uchar  NetEtherNullAddr[6] =
-   { 0, 0, 0, 0, 0, 0 };
+uchar  NetBcastAddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+uchar  NetEtherNullAddr[6];
 #ifdef CONFIG_API
 void   (*push_packet)(volatile void *, int len) = 0;
 #endif
 #if defined(CONFIG_CMD_CDP)
 /* Ethernet bcast address */
-uchar  NetCDPAddr[6] =
-   { 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
+uchar  NetCDPAddr[6] = { 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
 #endif
 /* Network loop state */
 intNetState;
 #ifdef CONFIG_NET_MULTI
 /* Tried all network devices */
-intNetRestartWrap = 0;
+intNetRestartWrap;
 /* Network loop restarted */
-static int NetRestarted = 0;
+static int NetRestarted;
 /* At least one device configured */
-static int NetDevExists = 0;
+static int NetDevExists;
 #endif
 
 /* XXX in both little & big endian machines 0x == ntohs(-1) */
@@ -206,7 +202,7 @@ static void CDPStart(void);
 /* NTP server IP address */
 IPaddr_t   NetNtpServerIP;
 /* offset time from UTC */
-intNetTimeOffset=0;
+intNetTimeOffset;
 #endif
 
 #ifdef CONFIG_NETCONSOLE
@@ -228,7 +224,7 @@ static ulongtimeStart;
 /* Current timeout value */
 static ulong   timeDelta;
 /* THE transmit packet */
-volatile uchar *NetTxPacket = 0;
+volatile uchar *NetTxPacket;
 
 static int net_check_prereq (proto_t protocol);
 
@@ -319,7 +315,7 @@ void ArpTimeoutCheck(void)
 static void
 NetInitLoop(proto_t protocol)
 {
-   static int env_changed_id = 0;
+   static int env_changed_id;
bd_t *bd = gd->bd;
int env_id = get_env_id ();
 
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 4/8] net/net.c: cosmetic: fix brace issues

2011-05-11 Thread Luca Ceresoli
This removes the following checkpatch issues:
 - WARNING: braces {} are not necessary for single statement blocks
 - WARNING: braces {} are not necessary for any arm of this statement

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Ben Warren 
Cc: Mike Frysinger 

---
Changes since v1: none.

 net/net.c |   38 +-
 1 files changed, 13 insertions(+), 25 deletions(-)

diff --git a/net/net.c b/net/net.c
index 172f4d5..c22da5f 100644
--- a/net/net.c
+++ b/net/net.c
@@ -367,9 +367,8 @@ NetLoop(proto_t protocol)
 */
NetTxPacket = &PktBuf[0] + (PKTALIGN - 1);
NetTxPacket -= (ulong)NetTxPacket % PKTALIGN;
-   for (i = 0; i < PKTBUFSRX; i++) {
+   for (i = 0; i < PKTBUFSRX; i++)
NetRxPackets[i] = NetTxPacket + (i+1)*PKTSIZE_ALIGN;
-   }
}
 
if (!NetArpWaitTxPacket) {
@@ -491,11 +490,10 @@ restart:
/*
 * Echo the inverted link state to the fault LED.
 */
-   if (miiphy_link(eth_get_dev()->name, CONFIG_SYS_FAULT_MII_ADDR)) {
+   if (miiphy_link(eth_get_dev()->name, CONFIG_SYS_FAULT_MII_ADDR))
status_led_set(STATUS_LED_RED, STATUS_LED_OFF);
-   } else {
+   else
status_led_set(STATUS_LED_RED, STATUS_LED_ON);
-   }
 #endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */
 #endif /* CONFIG_MII, ... */
 
@@ -1096,9 +1094,8 @@ CDPHandler(const uchar * pkt, unsigned len)
ss = (const ushort *)pkt;
type = ntohs(ss[0]);
tlen = ntohs(ss[1]);
-   if (tlen > len) {
+   if (tlen > len)
goto pkt_short;
-   }
 
pkt += tlen;
len -= tlen;
@@ -1477,26 +1474,20 @@ NetReceive(volatile uchar * inpkt, int len)
printf("bad length %d < %d\n", len, ARP_HDR_SIZE);
return;
}
-   if (ntohs(arp->ar_hrd) != ARP_ETHER) {
+   if (ntohs(arp->ar_hrd) != ARP_ETHER)
return;
-   }
-   if (ntohs(arp->ar_pro) != PROT_IP) {
+   if (ntohs(arp->ar_pro) != PROT_IP)
return;
-   }
-   if (arp->ar_hln != 6) {
+   if (arp->ar_hln != 6)
return;
-   }
-   if (arp->ar_pln != 4) {
+   if (arp->ar_pln != 4)
return;
-   }
 
-   if (NetOurIP == 0) {
+   if (NetOurIP == 0)
return;
-   }
 
-   if (NetReadIP(&arp->ar_data[16]) != NetOurIP) {
+   if (NetReadIP(&arp->ar_data[16]) != NetOurIP)
return;
-   }
 
switch (ntohs(arp->ar_op)) {
case ARPOP_REQUEST:
@@ -1601,13 +1592,11 @@ NetReceive(volatile uchar * inpkt, int len)
debug("len=%d, v=%02x\n", len, ip->ip_hl_v & 0xff);
 
/* Can't deal with anything except IPv4 */
-   if ((ip->ip_hl_v & 0xf0) != 0x40) {
+   if ((ip->ip_hl_v & 0xf0) != 0x40)
return;
-   }
/* Can't deal with IP options (headers != 20 bytes) */
-   if ((ip->ip_hl_v & 0x0f) > 0x05) {
+   if ((ip->ip_hl_v & 0x0f) > 0x05)
return;
-   }
/* Check the Checksum of the header */
if (!NetCksumOk((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2)) {
puts("checksum bad\n");
@@ -1946,9 +1935,8 @@ void copy_filename(char *dst, const char *src, int size)
--size;
}
 
-   while ((--size > 0) && *src && (*src != '"')) {
+   while ((--size > 0) && *src && (*src != '"'))
*dst++ = *src++;
-   }
*dst = '\0';
 }
 
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 3/8] net/net.c: cosmetic: fix whitespace issues

2011-05-11 Thread Luca Ceresoli
This removes the following checkpatch issues:
 - ERROR: space prohibited after that open parenthesis '('
 - ERROR: space prohibited before that close parenthesis ')'
 - ERROR: space prohibited after that open square bracket '['
 - ERROR: space prohibited after that '&' (ctx:WxW)
 - ERROR: spaces required around that '=' (ctx:VxW)
 - ERROR: space required before the open parenthesis '('
 - ERROR: space required after that ',' (ctx:VxV)
 - ERROR: need consistent spacing around '+' (ctx:WxV)
 - WARNING: unnecessary whitespace before a quoted newline
 - WARNING: please, no spaces at the start of a line
 - WARNING: space prohibited between function name and open
   parenthesis '('

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Ben Warren 
Cc: Mike Frysinger 

---
Changes since v1: none.

 net/net.c |  192 ++--
 1 files changed, 96 insertions(+), 96 deletions(-)

diff --git a/net/net.c b/net/net.c
index 4715699..172f4d5 100644
--- a/net/net.c
+++ b/net/net.c
@@ -226,7 +226,7 @@ static ulongtimeDelta;
 /* THE transmit packet */
 volatile uchar *NetTxPacket;
 
-static int net_check_prereq (proto_t protocol);
+static int net_check_prereq(proto_t protocol);
 
 static int NetTryCount;
 
@@ -243,7 +243,7 @@ uchar   NetArpWaitPacketBuf[PKTSIZE_ALIGN + 
PKTALIGN];
 ulong  NetArpWaitTimerStart;
 intNetArpWaitTry;
 
-void ArpRequest (void)
+void ArpRequest(void)
 {
int i;
volatile uchar *pkt;
@@ -253,20 +253,20 @@ void ArpRequest (void)
 
pkt = NetTxPacket;
 
-   pkt += NetSetEther (pkt, NetBcastAddr, PROT_ARP);
+   pkt += NetSetEther(pkt, NetBcastAddr, PROT_ARP);
 
arp = (ARP_t *) pkt;
 
-   arp->ar_hrd = htons (ARP_ETHER);
-   arp->ar_pro = htons (PROT_IP);
+   arp->ar_hrd = htons(ARP_ETHER);
+   arp->ar_pro = htons(PROT_IP);
arp->ar_hln = 6;
arp->ar_pln = 4;
-   arp->ar_op = htons (ARPOP_REQUEST);
+   arp->ar_op = htons(ARPOP_REQUEST);
 
/* source ET addr */
-   memcpy (&arp->ar_data[0], NetOurEther, 6);
+   memcpy(&arp->ar_data[0], NetOurEther, 6);
/* source IP addr */
-   NetWriteIP ((uchar *) & arp->ar_data[6], NetOurIP);
+   NetWriteIP((uchar *) &arp->ar_data[6], NetOurIP);
for (i = 10; i < 16; ++i) {
/* dest ET addr = 0 */
arp->ar_data[i] = 0;
@@ -275,7 +275,7 @@ void ArpRequest (void)
if ((NetArpWaitPacketIP & NetOurSubnetMask) !=
(NetOurIP & NetOurSubnetMask)) {
if (NetOurGatewayIP == 0) {
-   puts ("## Warning: gatewayip needed but not set\n");
+   puts("## Warning: gatewayip needed but not set\n");
NetArpWaitReplyIP = NetArpWaitPacketIP;
} else {
NetArpWaitReplyIP = NetOurGatewayIP;
@@ -284,8 +284,8 @@ void ArpRequest (void)
NetArpWaitReplyIP = NetArpWaitPacketIP;
}
 
-   NetWriteIP ((uchar *) & arp->ar_data[16], NetArpWaitReplyIP);
-   (void) eth_send (NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);
+   NetWriteIP((uchar *) &arp->ar_data[16], NetArpWaitReplyIP);
+   (void) eth_send(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);
 }
 
 void ArpTimeoutCheck(void)
@@ -302,7 +302,7 @@ void ArpTimeoutCheck(void)
NetArpWaitTry++;
 
if (NetArpWaitTry >= ARP_TIMEOUT_COUNT) {
-   puts ("\nARP Retry count exceeded; starting again\n");
+   puts("\nARP Retry count exceeded; starting again\n");
NetArpWaitTry = 0;
NetStartAgain();
} else {
@@ -317,14 +317,14 @@ NetInitLoop(proto_t protocol)
 {
static int env_changed_id;
bd_t *bd = gd->bd;
-   int env_id = get_env_id ();
+   int env_id = get_env_id();
 
/* update only when the environment has changed */
if (env_changed_id != env_id) {
NetCopyIP(&NetOurIP, &bd->bi_ip_addr);
-   NetOurGatewayIP = getenv_IPaddr ("gatewayip");
-   NetOurSubnetMask= getenv_IPaddr ("netmask");
-   NetServerIP = getenv_IPaddr ("serverip");
+   NetOurGatewayIP = getenv_IPaddr("gatewayip");
+   NetOurSubnetMask = getenv_IPaddr("netmask");
+   NetServerIP = getenv_IPaddr("serverip");
NetOurNativeVLAN = getenv_VLAN("nvlan");
NetOurVLAN = getenv_VLAN("vlan");
 #if defined(CONFIG_CMD_DNS)
@@ -389,7 +389,7 @@ NetLoop(proto_t protocol)
 
 restart:
 #ifdef CONFI

[U-Boot] [PATCH v2 5/8] net/net.c: cosmetic: fix pointer syntax issues

2011-05-11 Thread Luca Ceresoli
This removes the following checkpatch issues:
 - ERROR: "foo * bar" should be "foo *bar"
 - ERROR: "(foo*)" should be "(foo *)"

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Ben Warren 
Cc: Mike Frysinger 

---
Changes since v1: none.

 net/net.c |   36 ++--
 1 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/net/net.c b/net/net.c
index c22da5f..f8c852d 100644
--- a/net/net.c
+++ b/net/net.c
@@ -592,7 +592,7 @@ startAgainTimeout(void)
 }
 
 static void
-startAgainHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+startAgainHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len)
 {
/* Totally ignore the packet */
 }
@@ -653,14 +653,14 @@ void NetStartAgain(void)
  */
 
 void
-NetSetHandler(rxhand_f * f)
+NetSetHandler(rxhand_f *f)
 {
packetHandler = f;
 }
 
 
 void
-NetSetTimeout(ulong iv, thand_f * f)
+NetSetTimeout(ulong iv, thand_f *f)
 {
if (iv == 0) {
timeHandler = (thand_f *)0;
@@ -673,7 +673,7 @@ NetSetTimeout(ulong iv, thand_f * f)
 
 
 void
-NetSendPacket(volatile uchar * pkt, int len)
+NetSendPacket(volatile uchar *pkt, int len)
 {
(void) eth_send(pkt, len);
 }
@@ -768,9 +768,9 @@ int PingSend(void)
ip->ip_p = 0x01;/* ICMP */
ip->ip_sum   = 0;
/* already in network byte order */
-   NetCopyIP((void*)&ip->ip_src, &NetOurIP);
+   NetCopyIP((void *)&ip->ip_src, &NetOurIP);
/* - "" - */
-   NetCopyIP((void*)&ip->ip_dst, &NetPingIP);
+   NetCopyIP((void *)&ip->ip_dst, &NetPingIP);
ip->ip_sum   = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2);
 
s = &ip->udp_src;   /* XXX ICMP starts here */
@@ -799,7 +799,7 @@ PingTimeout(void)
 }
 
 static void
-PingHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+PingHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len)
 {
IPaddr_t tmp;
volatile IP_t *ip = (volatile IP_t *)pkt;
@@ -1042,13 +1042,13 @@ CDPTimeout(void)
 }
 
 static void
-CDPDummyHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+CDPDummyHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len)
 {
/* nothing */
 }
 
 static void
-CDPHandler(const uchar * pkt, unsigned len)
+CDPHandler(const uchar *pkt, unsigned len)
 {
const uchar *t;
const ushort *ss;
@@ -1354,7 +1354,7 @@ static inline IP_t *NetDefragment(IP_t *ip, int *lenp)
 #endif
 
 void
-NetReceive(volatile uchar * inpkt, int len)
+NetReceive(volatile uchar *inpkt, int len)
 {
Ethernet_t *et;
IP_t*ip;
@@ -1662,8 +1662,8 @@ NetReceive(volatile uchar * inpkt, int len)
 
ip->ip_sum = 0;
ip->ip_off = 0;
-   NetCopyIP((void*)&ip->ip_dst, &ip->ip_src);
-   NetCopyIP((void*)&ip->ip_src, &NetOurIP);
+   NetCopyIP((void *)&ip->ip_dst, &ip->ip_src);
+   NetCopyIP((void *)&ip->ip_src, &NetOurIP);
ip->ip_sum = ~NetCksum((uchar *)ip,
   IP_HDR_SIZE_NO_UDP >> 1);
 
@@ -1833,14 +1833,14 @@ static int net_check_prereq(proto_t protocol)
 /**/
 
 int
-NetCksumOk(uchar * ptr, int len)
+NetCksumOk(uchar *ptr, int len)
 {
return !((NetCksum(ptr, len) + 1) & 0xfffe);
 }
 
 
 unsigned
-NetCksum(uchar * ptr, int len)
+NetCksum(uchar *ptr, int len)
 {
ulong   xsum;
ushort *p = (ushort *)ptr;
@@ -1867,7 +1867,7 @@ NetEthHdrSize(void)
 }
 
 int
-NetSetEther(volatile uchar * xet, uchar * addr, uint prot)
+NetSetEther(volatile uchar *xet, uchar * addr, uint prot)
 {
Ethernet_t *et = (Ethernet_t *)xet;
ushort myvlanid;
@@ -1892,7 +1892,7 @@ NetSetEther(volatile uchar * xet, uchar * addr, uint prot)
 }
 
 void
-NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
+NetSetIP(volatile uchar *xip, IPaddr_t dest, int dport, int sport, int len)
 {
IP_t *ip = (IP_t *)xip;
 
@@ -1918,9 +1918,9 @@ NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, 
int sport, int len)
ip->ip_p = 17;  /* UDP */
ip->ip_sum   = 0;
/* already in network byte order */
-   NetCopyIP((void*)&ip->ip_src, &NetOurIP);
+   NetCopyIP((void *)&ip->ip_src, &NetOurIP);
/* - "" - */
-   NetCopyIP((void*)&ip->ip_dst, &dest);
+   NetCopyIP((void *)&ip->ip_dst, &dest);
ip->udp_src  = htons(sport);
ip->udp_dst  = htons(dport);
ip->udp_len  = htons(8 + len);
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 7/8] net/net.c: cosmetic: fix indentation

2011-05-11 Thread Luca Ceresoli
This removes the following checkpatch issues:
 - ERROR: switch and case should be at the same indent
 - WARNING: suspect code indent for conditional statements
 - WARNING: labels should not be indented

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Ben Warren 
Cc: Mike Frysinger 

---
Changes since v1: none.

 net/net.c |   85 ++---
 1 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/net/net.c b/net/net.c
index 63fc60a..8b4d28e 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1104,51 +1104,50 @@ CDPHandler(const uchar *pkt, unsigned len)
tlen -= 4;
 
switch (type) {
-   case CDP_DEVICE_ID_TLV:
-   break;
-   case CDP_ADDRESS_TLV:
-   break;
-   case CDP_PORT_ID_TLV:
-   break;
-   case CDP_CAPABILITIES_TLV:
-   break;
-   case CDP_VERSION_TLV:
-   break;
-   case CDP_PLATFORM_TLV:
-   break;
-   case CDP_NATIVE_VLAN_TLV:
-   nvlan = *ss;
-   break;
-   case CDP_APPLIANCE_VLAN_TLV:
-   t = (const uchar *)ss;
-   while (tlen > 0) {
-   if (tlen < 3)
-   goto pkt_short;
+   case CDP_DEVICE_ID_TLV:
+   break;
+   case CDP_ADDRESS_TLV:
+   break;
+   case CDP_PORT_ID_TLV:
+   break;
+   case CDP_CAPABILITIES_TLV:
+   break;
+   case CDP_VERSION_TLV:
+   break;
+   case CDP_PLATFORM_TLV:
+   break;
+   case CDP_NATIVE_VLAN_TLV:
+   nvlan = *ss;
+   break;
+   case CDP_APPLIANCE_VLAN_TLV:
+   t = (const uchar *)ss;
+   while (tlen > 0) {
+   if (tlen < 3)
+   goto pkt_short;
 
-   applid = t[0];
-   ss = (const ushort *)(t + 1);
+   applid = t[0];
+   ss = (const ushort *)(t + 1);
 
 #ifdef CONFIG_CDP_APPLIANCE_VLAN_TYPE
-   if (applid ==
-   CONFIG_CDP_APPLIANCE_VLAN_TYPE)
-   vlan = *ss;
+   if (applid == CONFIG_CDP_APPLIANCE_VLAN_TYPE)
+   vlan = *ss;
 #else
-   /* XXX will this work; dunno */
-   vlan = ntohs(*ss);
+   /* XXX will this work; dunno */
+   vlan = ntohs(*ss);
 #endif
-   t += 3; tlen -= 3;
-   }
-   break;
-   case CDP_TRIGGER_TLV:
-   break;
-   case CDP_POWER_CONSUMPTION_TLV:
-   break;
-   case CDP_SYSNAME_TLV:
-   break;
-   case CDP_SYSOBJECT_TLV:
-   break;
-   case CDP_MANAGEMENT_ADDRESS_TLV:
-   break;
+   t += 3; tlen -= 3;
+   }
+   break;
+   case CDP_TRIGGER_TLV:
+   break;
+   case CDP_POWER_CONSUMPTION_TLV:
+   break;
+   case CDP_SYSNAME_TLV:
+   break;
+   case CDP_SYSOBJECT_TLV:
+   break;
+   case CDP_MANAGEMENT_ADDRESS_TLV:
+   break;
}
}
 
@@ -1608,7 +1607,7 @@ NetReceive(volatile uchar *inpkt, int len)
 #ifdef CONFIG_MCAST_TFTP
if (Mcast_addr != tmp)
 #endif
-   return;
+   return;
}
/*
 * The function returns the unchanged packet if it's not
@@ -1784,7 +1783,7 @@ static int net_check_prereq(proto_t protocol)
}
 #ifdefined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
defined(CONFIG_CMD_DNS)
-common:
+common:
 #endif
 
if (NetOurIP == 0) {
@@ -1879,7 +1878,7 @@ NetSetEther(volatile uchar *xet, uchar * addr, uint prot)

[U-Boot] [PATCH v2 6/8] net/net.c: cosmetic: parentheses not required for return

2011-05-11 Thread Luca Ceresoli
This removes the following checkpatch issue:
 - ERROR: return is not a function, parentheses are not required

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Ben Warren 
Cc: Mike Frysinger 

---
Changes since v1: none.

 net/net.c |   30 +++---
 1 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/net/net.c b/net/net.c
index f8c852d..63fc60a 100644
--- a/net/net.c
+++ b/net/net.c
@@ -383,7 +383,7 @@ NetLoop(proto_t protocol)
 #endif
if (eth_init(bd) < 0) {
eth_halt();
-   return(-1);
+   return -1;
}
 
 restart:
@@ -406,7 +406,7 @@ restart:
case 1:
/* network not configured */
eth_halt();
-   return (-1);
+   return -1;
 
 #ifdef CONFIG_NET_MULTI
case 2:
@@ -521,7 +521,7 @@ restart:
if (ctrlc()) {
eth_halt();
puts("\nAbort\n");
-   return (-1);
+   return -1;
}
 
ArpTimeoutCheck();
@@ -578,7 +578,7 @@ restart:
return NetBootFileXferSize;
 
case NETLOOP_FAIL:
-   return (-1);
+   return -1;
}
}
 }
@@ -1753,7 +1753,7 @@ static int net_check_prereq(proto_t protocol)
case PING:
if (NetPingIP == 0) {
puts("*** ERROR: ping address not given\n");
-   return (1);
+   return 1;
}
goto common;
 #endif
@@ -1761,7 +1761,7 @@ static int net_check_prereq(proto_t protocol)
case SNTP:
if (NetNtpServerIP == 0) {
puts("*** ERROR: NTP server address not given\n");
-   return (1);
+   return 1;
}
goto common;
 #endif
@@ -1780,7 +1780,7 @@ static int net_check_prereq(proto_t protocol)
case TFTP:
if (NetServerIP == 0) {
puts("*** ERROR: `serverip' not set\n");
-   return (1);
+   return 1;
}
 #ifdefined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
defined(CONFIG_CMD_DNS)
@@ -1789,7 +1789,7 @@ static int net_check_prereq(proto_t protocol)
 
if (NetOurIP == 0) {
puts("*** ERROR: `ipaddr' not set\n");
-   return (1);
+   return 1;
}
/* Fall through */
 
@@ -1807,7 +1807,7 @@ static int net_check_prereq(proto_t protocol)
switch (num) {
case -1:
puts("*** ERROR: No ethernet found.\n");
-   return (1);
+   return 1;
case 0:
puts("*** ERROR: `ethaddr' not set\n");
break;
@@ -1818,17 +1818,17 @@ static int net_check_prereq(proto_t protocol)
}
 
NetStartAgain();
-   return (2);
+   return 2;
 #else
puts("*** ERROR: `ethaddr' not set\n");
-   return (1);
+   return 1;
 #endif
}
/* Fall through */
default:
-   return (0);
+   return 0;
}
-   return (0); /* OK */
+   return 0;   /* OK */
 }
 /**/
 
@@ -1850,7 +1850,7 @@ NetCksum(uchar *ptr, int len)
xsum += *p++;
xsum = (xsum & 0x) + (xsum >> 16);
xsum = (xsum & 0x) + (xsum >> 16);
-   return (xsum & 0x);
+   return xsum & 0x;
 }
 
 int
@@ -1994,5 +1994,5 @@ ushort string_to_VLAN(const char *s)
 
 ushort getenv_VLAN(char *var)
 {
-   return (string_to_VLAN(getenv(var)));
+   return string_to_VLAN(getenv(var));
 }
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 8/8] net/net.c: cosmetic: do not use assignment in if condition

2011-05-11 Thread Luca Ceresoli
This removes the following checkpatch issue:
 - ERROR: do not use assignment in if condition

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
Cc: Ben Warren 
Cc: Mike Frysinger 

---
Changes since v1: none.

 net/net.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/net.c b/net/net.c
index 8b4d28e..1c4c982 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1614,7 +1614,8 @@ NetReceive(volatile uchar *inpkt, int len)
 * a fragment, and either the complete packet or NULL if
 * it is a fragment (if !CONFIG_IP_DEFRAG, it returns NULL)
 */
-   if (!(ip = NetDefragment(ip, &len)))
+   ip = NetDefragment(ip, &len);
+   if (!ip)
return;
/*
 * watch for ICMP host redirects
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 3/6] TFTP: rename "server" to "remote"

2011-05-13 Thread Luca Ceresoli
Hi Wolfgang,

Wolfgang Denk wrote:
> Dear Luca Ceresoli,
>
> In message<1303143594-5345-4-git-send-email-luca.ceres...@comelit.it>  you 
> wrote:
>> With the upcoming TFTP server implementation, the remote node can be
>> either a client or a server, so avoid ambiguities.
>>
>> Signed-off-by: Luca Ceresoli
>> Cc: Wolfgang Denk
>> ---
>> Changes in v2:
>>   - fixed checkpatch issues.
>>
>>   net/tftp.c |   42 +-
>>   1 files changed, 21 insertions(+), 21 deletions(-)
> How do we proceed now?  I've applied paches 1 + 2 of this series,
> but for patch 3 we had changes requested, and the following patche
> sdepend on it.
>
> I understand you are now waiting for the "net/net.c: cosmetic:"
> patches to go in?  Normally these would be stuff for the next
> branch...
>
> I'd even be willing to pull these in now, if you then would re-post
> the remaining patches of the tftpserver code soon?

I see you've committed the net/net.c cleanup into master.
I'll rebase the TFTP server work (only patches 3 and 4) and resend them
as soon as possible for inclusion in master, perhaps today or tomorrow.

Luca

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 0/8] net/tftp.c: clenups for checkpatch compliance

2011-05-14 Thread Luca Ceresoli
Hi,

net/tftp.c currently raises 82 errors and 99 warnings.
This patchset fixes most of them, leaving 3 errors and 14 warnings.

Since the changes are quite massive I split them in separate patches, one
per each category of errors/warning.

These issues are still present:
 - ERROR: else should follow close brace '}'
   these are due to the presence of an #ifdef right after or before the else
   (to compile an entire branch conditionally), and cannot be removed easily
   without compromising readability;
 - WARNING: consider using kstrto* in preference to simple_*
   which are Linux-specific;
 - WARNING: externs should be avoided in .c files
   these are due to loop-dependencies with other files;
 - WARNING: Use of volatile is usually wrong [...]
   I've had a quick look at these, but I don't know in detail how the
   networking code and Ethernet drivers (and maybe DMA?) interact, so I cannot
   remove them being sure that things will continue working;
 - WARNING: plain inline is preferred over __inline__
   as I see many "__inline__"s in the current source and don't know what the
   U-Boot policy is.

Luca Ceresoli (8):
  net/tftp.c: cosmetic: fix lines over 80 characters
  net/tftp.c: cosmetic: fix whitespace issues
  net/tftp.c: cosmetic: fix pointer syntax issues
  net/tftp.c: cosmetic: do not use assignment in if condition
  net/tftp.c: cosmetic: fix brace issues
  net/tftp.c: cosmetic: trailing statements should be on next line
  net/tftp.c: cosmetic: fix indentation
  net/tftp.c: cosmetic: do not initialise statics to 0 or NULL

 net/tftp.c |  309 
 1 files changed, 167 insertions(+), 142 deletions(-)

Luca
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 7/8] net/tftp.c: cosmetic: fix indentation

2011-05-14 Thread Luca Ceresoli
This removes the following checkpatch issue:
 - WARNING: suspect code indent for conditional statements

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
 net/tftp.c |   11 ++-
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/net/tftp.c b/net/tftp.c
index f83c0d6..a52f54c 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -307,7 +307,7 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
if (Multicast
 && (!Mcast_port || (dest != Mcast_port)))
 #endif
-   return;
+   return;
}
if (TftpState != STATE_RRQ && src != TftpServerPort)
return;
@@ -603,11 +603,12 @@ TftpStart(void)
 
/* Check if we need to send across this subnet */
if (NetOurGatewayIP && NetOurSubnetMask) {
-   IPaddr_t OurNet = NetOurIP& NetOurSubnetMask;
-   IPaddr_t ServerNet  = TftpServerIP & NetOurSubnetMask;
+   IPaddr_t OurNet = NetOurIP& NetOurSubnetMask;
+   IPaddr_t ServerNet  = TftpServerIP & NetOurSubnetMask;
 
-   if (OurNet != ServerNet)
-   printf("; sending through gateway %pI4", &NetOurGatewayIP);
+   if (OurNet != ServerNet)
+   printf("; sending through gateway %pI4",
+  &NetOurGatewayIP);
}
putc('\n');
 
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/8] net/tftp.c: cosmetic: fix lines over 80 characters

2011-05-14 Thread Luca Ceresoli
Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
 net/tftp.c |   66 ++-
 1 files changed, 42 insertions(+), 24 deletions(-)

diff --git a/net/tftp.c b/net/tftp.c
index 00abec3..2eace3d 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -1,7 +1,7 @@
 /*
- * Copyright 1994, 1995, 2000 Neil Russell.
- * (See License)
- * Copyright 2000, 2001 DENX Software Engineering, Wolfgang Denk, 
w...@denx.de
+ * Copyright 1994, 1995, 2000 Neil Russell.
+ * (See License)
+ * Copyright 2000, 2001 DENX Software Engineering, Wolfgang Denk, w...@denx.de
  */
 
 #include 
@@ -10,15 +10,18 @@
 #include "tftp.h"
 #include "bootp.h"
 
-#define WELL_KNOWN_PORT69  /* Well known TFTP port #   
*/
-#define TIMEOUT5000UL  /* Millisecs to timeout for 
lost pkt */
+/* Well known TFTP port # */
+#define WELL_KNOWN_PORT69
+/* Millisecs to timeout for lost pkt */
+#define TIMEOUT5000UL
 #ifndefCONFIG_NET_RETRY_COUNT
-# define TIMEOUT_COUNT 10  /* # of timeouts before giving up  */
+/* # of timeouts before giving up */
+# define TIMEOUT_COUNT 10
 #else
 # define TIMEOUT_COUNT  (CONFIG_NET_RETRY_COUNT * 2)
 #endif
-   /* (for checking the image size)
*/
-#define HASHES_PER_LINE65  /* Number of "loading" hashes 
per line  */
+/* Number of "loading" hashes per line (for checking the image size) */
+#define HASHES_PER_LINE65
 
 /*
  * TFTP operations.
@@ -56,17 +59,25 @@ enum {
 };
 
 static IPaddr_t TftpServerIP;
-static int TftpServerPort; /* The UDP port at their end
*/
-static int TftpOurPort;/* The UDP port at our end  
*/
+/* The UDP port at their end */
+static int TftpServerPort;
+/* The UDP port at our end */
+static int TftpOurPort;
 static int TftpTimeoutCount;
-static ulong   TftpBlock;  /* packet sequence number   
*/
-static ulong   TftpLastBlock;  /* last packet sequence number received 
*/
-static ulong   TftpBlockWrap;  /* count of sequence number wraparounds 
*/
-static ulong   TftpBlockWrapOffset;/* memory offset due to wrapping
*/
+/* packet sequence number */
+static ulong   TftpBlock;
+/* last packet sequence number received */
+static ulong   TftpLastBlock;
+/* count of sequence number wraparounds */
+static ulong   TftpBlockWrap;
+/* memory offset due to wrapping */
+static ulong   TftpBlockWrapOffset;
 static int TftpState;
 #ifdef CONFIG_TFTP_TSIZE
-static int TftpTsize;  /* The file size reported by the server 
*/
-static short   TftpNumchars;   /* The number of hashes we printed  
*/
+/* The file size reported by the server */
+static int TftpTsize;
+/* The number of hashes we printed */
+static short   TftpNumchars;
 #endif
 
 #define STATE_RRQ  1
@@ -75,8 +86,10 @@ static short TftpNumchars;   /* The number of hashes 
we printed  */
 #define STATE_BAD_MAGIC4
 #define STATE_OACK 5
 
-#define TFTP_BLOCK_SIZE512 /* default TFTP 
block size  */
-#define TFTP_SEQUENCE_SIZE ((ulong)(1<<16))/* sequence number is 16 
bit */
+/* default TFTP block size */
+#define TFTP_BLOCK_SIZE512
+/* sequence number is 16 bit */
+#define TFTP_SEQUENCE_SIZE ((ulong)(1<<16))
 
 #define DEFAULT_NAME_LEN   (8 + 4 + 1)
 static char default_filename[DEFAULT_NAME_LEN];
@@ -273,7 +286,8 @@ TftpSend (void)
break;
}
 
-   NetSendUDPPacket(NetServerEther, TftpServerIP, TftpServerPort, 
TftpOurPort, len);
+   NetSendUDPPacket(NetServerEther, TftpServerIP, TftpServerPort,
+TftpOurPort, len);
 }
 
 
@@ -333,7 +347,8 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
}
 #ifdef CONFIG_TFTP_TSIZE
if (strcmp ((char*)pkt+i,"tsize") == 0) {
-   TftpTsize = 
simple_strtoul((char*)pkt+i+6,NULL,10);
+   TftpTsize = simple_strtoul((char*)pkt+i+6,
+  NULL, 10);
debug("size = %s, %d\n",
 (char*)pkt+i+6, TftpTsize);
}
@@ -361,12 +376,15 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
 */
if (TftpBlock == 0) {
TftpBlockWrap++;
-   TftpBlockWrapOffset += TftpBlkSize * TFTP_SEQUENCE_SIZE;
-   printf ("\n\t %lu MB received\n\t ", 
TftpBlockWrapOffset>>20);
+   TftpBlockWrapOffset +=
+   Tft

[U-Boot] [PATCH 8/8] net/tftp.c: cosmetic: do not initialise statics to 0 or NULL

2011-05-14 Thread Luca Ceresoli
This removes the following checkpatch issue:
 - ERROR: do not initialise statics to 0 or NULL

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
 net/tftp.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/tftp.c b/net/tftp.c
index a52f54c..0f74e6b 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -125,8 +125,8 @@ static unsigned short TftpBlkSizeOption = 
TFTP_MTU_BLOCKSIZE;
 #define MTFTP_BITMAPSIZE   0x1000
 static unsigned *Bitmap;
 static int PrevBitmapHole, Mapsize = MTFTP_BITMAPSIZE;
-static uchar ProhibitMcast = 0, MasterClient = 0;
-static uchar Multicast = 0;
+static uchar ProhibitMcast, MasterClient;
+static uchar Multicast;
 extern IPaddr_t Mcast_addr;
 static int Mcast_port;
 static ulong TftpEndingBlock; /* can get 'last' block before done..*/
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 6/8] net/tftp.c: cosmetic: trailing statements should be on next line

2011-05-14 Thread Luca Ceresoli
This removes the following checkpatch issue:
 - ERROR: trailing statements should be on next line

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
 net/tftp.c |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/net/tftp.c b/net/tftp.c
index eacd529..f83c0d6 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -136,8 +136,10 @@ static void parse_multicast_oack(char *pkt, int len);
 static void
 mcast_cleanup(void)
 {
-   if (Mcast_addr) eth_mcast_join(Mcast_addr, 0);
-   if (Bitmap) free(Bitmap);
+   if (Mcast_addr)
+   eth_mcast_join(Mcast_addr, 0);
+   if (Bitmap)
+   free(Bitmap);
Bitmap = NULL;
Mcast_addr = Multicast = Mcast_port = 0;
TftpEndingBlock = -1;
@@ -703,7 +705,8 @@ static void parse_multicast_oack(char *pkt, int len)
}
}
}
-   if (!port || !mc_adr || !mc) return;
+   if (!port || !mc_adr || !mc)
+   return;
if (Multicast && MasterClient) {
printf("I got a OACK as master Client, WRONG!\n");
return;
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 5/8] net/tftp.c: cosmetic: fix brace issues

2011-05-14 Thread Luca Ceresoli
This removes the following checkpatch issues:
 - WARNING: braces {} are not necessary for single statement blocks
 - WARNING: braces {} are not necessary for any arm of this statement

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
 net/tftp.c |   17 ++---
 1 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/net/tftp.c b/net/tftp.c
index 81b7aa5..eacd529 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -307,13 +307,11 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
 #endif
return;
}
-   if (TftpState != STATE_RRQ && src != TftpServerPort) {
+   if (TftpState != STATE_RRQ && src != TftpServerPort)
return;
-   }
 
-   if (len < 2) {
+   if (len < 2)
return;
-   }
len -= 2;
/* warning: don't use increment (++) in ntohs() macros!! */
s = (ushort *)pkt;
@@ -393,11 +391,10 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
}
 #endif
else {
-   if (((TftpBlock - 1) % 10) == 0) {
+   if (((TftpBlock - 1) % 10) == 0)
putc('#');
-   } else if ((TftpBlock % (10 * HASHES_PER_LINE)) == 0) {
+   else if ((TftpBlock % (10 * HASHES_PER_LINE)) == 0)
puts("\n\t ");
-   }
}
 
if (TftpState == STATE_RRQ)
@@ -638,13 +635,11 @@ TftpStart(void)
 
 #ifdef CONFIG_TFTP_PORT
ep = getenv("tftpdstp");
-   if (ep != NULL) {
+   if (ep != NULL)
TftpServerPort = simple_strtol(ep, NULL, 10);
-   }
ep = getenv("tftpsrcp");
-   if (ep != NULL) {
+   if (ep != NULL)
TftpOurPort = simple_strtol(ep, NULL, 10);
-   }
 #endif
TftpBlock = 0;
 
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 4/8] net/tftp.c: cosmetic: do not use assignment in if condition

2011-05-14 Thread Luca Ceresoli
This removes the following checkpatch issue:
 - ERROR: do not use assignment in if condition.

There is one such error left:

  ERROR: do not use assignment in if condition
  #239: FILE: tftp.c:239:
  + if (!ProhibitMcast
  +  && (Bitmap = malloc(Mapsize))
  +  && eth_get_dev()->mcast) {

which would require an additional nested if to be fixed, resulting in longer
and less readable code.

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
 net/tftp.c |   18 --
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/net/tftp.c b/net/tftp.c
index 4c05266..81b7aa5 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -552,10 +552,12 @@ TftpStart(void)
 * Allow the user to choose TFTP blocksize and timeout.
 * TFTP protocol has a minimal timeout of 1 second.
 */
-   if ((ep = getenv("tftpblocksize")) != NULL)
+   ep = getenv("tftpblocksize");
+   if (ep != NULL)
TftpBlkSizeOption = simple_strtol(ep, NULL, 10);
 
-   if ((ep = getenv("tftptimeout")) != NULL)
+   ep = getenv("tftptimeout");
+   if (ep != NULL)
TftpTimeoutMSecs = simple_strtol(ep, NULL, 10);
 
if (TftpTimeoutMSecs < 1000) {
@@ -635,10 +637,12 @@ TftpStart(void)
TftpOurPort = 1024 + (get_timer(0) % 3072);
 
 #ifdef CONFIG_TFTP_PORT
-   if ((ep = getenv("tftpdstp")) != NULL) {
+   ep = getenv("tftpdstp");
+   if (ep != NULL) {
TftpServerPort = simple_strtol(ep, NULL, 10);
}
-   if ((ep = getenv("tftpsrcp")) != NULL) {
+   ep = getenv("tftpsrcp");
+   if (ep != NULL) {
TftpOurPort = simple_strtol(ep, NULL, 10);
}
 #endif
@@ -721,7 +725,8 @@ static void parse_multicast_oack(char *pkt, int len)
/* I malloc instead of pre-declare; so that if the file ends
 * up being too big for this bitmap I can retry
 */
-   if (!(Bitmap = malloc(Mapsize))) {
+   Bitmap = malloc(Mapsize);
+   if (!Bitmap) {
printf("No Bitmap, no multicast. Sorry.\n");
ProhibitMcast = 1;
return;
@@ -734,7 +739,8 @@ static void parse_multicast_oack(char *pkt, int len)
if (Mcast_addr != addr) {
if (Mcast_addr)
eth_mcast_join(Mcast_addr, 0);
-   if (eth_mcast_join(Mcast_addr = addr, 1)) {
+   Mcast_addr = addr;
+   if (eth_mcast_join(Mcast_addr, 1)) {
printf("Fail to set mcast, revert to TFTP\n");
ProhibitMcast = 1;
mcast_cleanup();
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 3/8] net/tftp.c: cosmetic: fix pointer syntax issues

2011-05-14 Thread Luca Ceresoli
This removes the following checkpatch issues:
 - ERROR: "foo * bar" should be "foo *bar"
 - ERROR: "(foo*)" should be "(foo *)"

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
 net/tftp.c |   20 ++--
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/net/tftp.c b/net/tftp.c
index c0342a8..4c05266 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -146,7 +146,7 @@ mcast_cleanup(void)
 #endif /* CONFIG_MCAST_TFTP */
 
 static __inline__ void
-store_block(unsigned block, uchar * src, unsigned len)
+store_block(unsigned block, uchar *src, unsigned len)
 {
ulong offset = block * TftpBlkSize + TftpBlockWrapOffset;
ulong newsize = offset + len;
@@ -193,9 +193,9 @@ static void TftpTimeout(void);
 static void
 TftpSend(void)
 {
-   volatile uchar *pkt;
-   volatile uchar *xp;
-   int len = 0;
+   volatile uchar *pkt;
+   volatile uchar *xp;
+   int len = 0;
volatile ushort *s;
 
 #ifdef CONFIG_MCAST_TFTP
@@ -340,19 +340,19 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
 * something like "len-8" may give a *huge* number
 */
for (i = 0; i+8 < len; i++) {
-   if (strcmp((char*)pkt+i, "blksize") == 0) {
+   if (strcmp((char *)pkt+i, "blksize") == 0) {
TftpBlkSize = (unsigned short)
-   simple_strtoul((char*)pkt+i+8, NULL,
+   simple_strtoul((char *)pkt+i+8, NULL,
   10);
debug("Blocksize ack: %s, %d\n",
-   (char*)pkt+i+8, TftpBlkSize);
+   (char *)pkt+i+8, TftpBlkSize);
}
 #ifdef CONFIG_TFTP_TSIZE
-   if (strcmp((char*)pkt+i, "tsize") == 0) {
-   TftpTsize = simple_strtoul((char*)pkt+i+6,
+   if (strcmp((char *)pkt+i, "tsize") == 0) {
+   TftpTsize = simple_strtoul((char *)pkt+i+6,
   NULL, 10);
debug("size = %s, %d\n",
-(char*)pkt+i+6, TftpTsize);
+(char *)pkt+i+6, TftpTsize);
}
 #endif
}
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/8] net/tftp.c: cosmetic: fix whitespace issues

2011-05-14 Thread Luca Ceresoli
This removes the following checkpatch issues:
 - ERROR: space prohibited before that close parenthesis ')'
 - ERROR: space required after that ';' (ctx:BxV)
 - ERROR: space required after that ',' (ctx:VxV)
 - ERROR: space required after that ';' (ctx:VxV)
 - ERROR: spaces required around that '<<=' (ctx:VxV)
 - ERROR: spaces required around that '<' (ctx:VxV)
 - ERROR: spaces required around that '=' (ctx:VxV)
 - ERROR: spaces required around that '+=' (ctx:VxV)
 - ERROR: spaces required around that '=' (ctx:VxW)
 - WARNING: please, no spaces at the start of a line
 - WARNING: space prohibited between function name and open parenthesis '('

Signed-off-by: Luca Ceresoli 
Cc: Wolfgang Denk 
---
 net/tftp.c |  192 ++--
 1 files changed, 97 insertions(+), 95 deletions(-)

diff --git a/net/tftp.c b/net/tftp.c
index 2eace3d..c0342a8 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -117,28 +117,28 @@ extern flash_info_t flash_info[];
 #define TFTP_MTU_BLOCKSIZE 1468
 #endif
 
-static unsigned short TftpBlkSize=TFTP_BLOCK_SIZE;
-static unsigned short TftpBlkSizeOption=TFTP_MTU_BLOCKSIZE;
+static unsigned short TftpBlkSize = TFTP_BLOCK_SIZE;
+static unsigned short TftpBlkSizeOption = TFTP_MTU_BLOCKSIZE;
 
 #ifdef CONFIG_MCAST_TFTP
 #include 
 #define MTFTP_BITMAPSIZE   0x1000
 static unsigned *Bitmap;
-static int PrevBitmapHole,Mapsize=MTFTP_BITMAPSIZE;
-static uchar ProhibitMcast=0, MasterClient=0;
-static uchar Multicast=0;
+static int PrevBitmapHole, Mapsize = MTFTP_BITMAPSIZE;
+static uchar ProhibitMcast = 0, MasterClient = 0;
+static uchar Multicast = 0;
 extern IPaddr_t Mcast_addr;
 static int Mcast_port;
 static ulong TftpEndingBlock; /* can get 'last' block before done..*/
 
-static void parse_multicast_oack(char *pkt,int len);
+static void parse_multicast_oack(char *pkt, int len);
 
 static void
 mcast_cleanup(void)
 {
if (Mcast_addr) eth_mcast_join(Mcast_addr, 0);
if (Bitmap) free(Bitmap);
-   Bitmap=NULL;
+   Bitmap = NULL;
Mcast_addr = Multicast = Mcast_port = 0;
TftpEndingBlock = -1;
 }
@@ -146,14 +146,14 @@ mcast_cleanup(void)
 #endif /* CONFIG_MCAST_TFTP */
 
 static __inline__ void
-store_block (unsigned block, uchar * src, unsigned len)
+store_block(unsigned block, uchar * src, unsigned len)
 {
ulong offset = block * TftpBlkSize + TftpBlockWrapOffset;
ulong newsize = offset + len;
 #ifdef CONFIG_SYS_DIRECT_FLASH_TFTP
int i, rc = 0;
 
-   for (i=0; imcast) {
free(Bitmap);
-   Bitmap=NULL;
-   pkt += sprintf((char *)pkt,"multicast%c%c",0,0);
+   Bitmap = NULL;
+   pkt += sprintf((char *)pkt, "multicast%c%c", 0, 0);
}
 #endif /* CONFIG_MCAST_TFTP */
len = pkt - xp;
@@ -251,7 +251,8 @@ TftpSend (void)
 #ifdef CONFIG_MCAST_TFTP
/* My turn!  Start at where I need blocks I missed.*/
if (Multicast)
-   TftpBlock=ext2_find_next_zero_bit(Bitmap,(Mapsize*8),0);
+   TftpBlock = ext2_find_next_zero_bit(Bitmap,
+   (Mapsize*8), 0);
/*..falling..*/
 #endif
case STATE_DATA:
@@ -269,7 +270,7 @@ TftpSend (void)
*s++ = htons(TFTP_ERROR);
*s++ = htons(3);
pkt = (uchar *)s;
-   strcpy ((char *)pkt, "File too large");
+   strcpy((char *)pkt, "File too large");
pkt += 14 /*strlen("File too large")*/ + 1;
len = pkt - xp;
break;
@@ -280,7 +281,7 @@ TftpSend (void)
*s++ = htons(TFTP_ERROR);
*s++ = htons(2);
pkt = (uchar *)s;
-   strcpy ((char *)pkt, "File has bad magic");
+   strcpy((char *)pkt, "File has bad magic");
pkt += 18 /*strlen("File has bad magic")*/ + 1;
len = pkt - xp;
break;
@@ -338,15 +339,16 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
 * Careful: "i" is signed, "len" is unsigned, thus
 * something like "len-8" may give a *huge* number
 */
-   for (i=0; i+8>20);
}
 #ifdef CONFIG_TFTP_TSIZE
@@ -392,9 +394,9 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, 
unsigned src,
 #endif
else {
if (((TftpBlock - 1) % 10) == 0) {
-   putc ('#');
+   putc('#');
} else if ((TftpBlock % (10 * HAS

Re: [U-Boot] [PATCH v2 3/6] TFTP: rename "server" to "remote"

2011-05-14 Thread Luca Ceresoli
Luca Ceresoli wrote:
> Hi Wolfgang,
>
> Wolfgang Denk wrote:
>> Dear Luca Ceresoli,
>>
>> In 
>> message<1303143594-5345-4-git-send-email-luca.ceres...@comelit.it>  
>> you wrote:
>>> With the upcoming TFTP server implementation, the remote node can be
>>> either a client or a server, so avoid ambiguities.
>>>
>>> Signed-off-by: Luca Ceresoli
>>> Cc: Wolfgang Denk
>>> ---
>>> Changes in v2:
>>>   - fixed checkpatch issues.
>>>
>>>   net/tftp.c |   42 +-
>>>   1 files changed, 21 insertions(+), 21 deletions(-)
>> How do we proceed now?  I've applied paches 1 + 2 of this series,
>> but for patch 3 we had changes requested, and the following patche
>> sdepend on it.
>>
>> I understand you are now waiting for the "net/net.c: cosmetic:"
>> patches to go in?  Normally these would be stuff for the next
>> branch...
>>
>> I'd even be willing to pull these in now, if you then would re-post
>> the remaining patches of the tftpserver code soon?
>
> I see you've committed the net/net.c cleanup into master.
> I'll rebase the TFTP server work (only patches 3 and 4) and resend them
> as soon as possible for inclusion in master, perhaps today or tomorrow.
>

Damn. While rebasing, I hit many checkpatch issues. The cleanup soon became
larger that the TFTP server work, so I took a breath, and started a new 
branch
out of master to fully cleanup net/tftp.c.

I submitted right now a lengthy patch series just for that cleanup.
Since it's very similar to my net/net.c cleanup that has just been 
merged, I think
this will be merged also without a great need of discussion.

I'll take some time ASAP to rebase the TFTP server on top of this cleanup,
but alas not today nor tomorrow (I spent all the time with checkpatch...).

Luca

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 3/6] TFTP: rename "server" to "remote"

2011-05-16 Thread Luca Ceresoli
Mike Frysinger wrote:
> On Monday, April 18, 2011 12:19:51 Luca Ceresoli wrote:
>> With the upcoming TFTP server implementation, the remote node can be
>> either a client or a server, so avoid ambiguities.
> the summary made me worried because i thought you were going to rename the env
> var "server" to "remote".  could you tweak the summary to avoid this ambiguity
> in what you're actually doing ?  how about:
>   TFTP: use "remote" in local variable names instead of "server"

Improved commit message in v3.

>> -IPaddr_t ServerNet  = TftpServerIP&  NetOurSubnetMask;
>> +IPaddr_t ServerNet  = TftpRemoteIP&  NetOurSubnetMask;
> shouldnt that now be RemoteNet ?

Done for v3.

Luca

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 3/6] TFTP: rename "server" to "remote"

2011-05-16 Thread Luca Ceresoli
Luca Ceresoli wrote:
> Il 19/04/2011 16:18, Detlev Zundel ha scritto:
>> Hi Luca,
>>
>>> With the upcoming TFTP server implementation, the remote node can be
>>> either a client or a server, so avoid ambiguities.
>>>
>>> Signed-off-by: Luca Ceresoli
>>> Cc: Wolfgang Denk
>>> ---
>>> Changes in v2:
>>>   - fixed checkpatch issues.
>>>
>>>   net/tftp.c |   42 +-
>>>   1 files changed, 21 insertions(+), 21 deletions(-)
>>>
>>> diff --git a/net/tftp.c b/net/tftp.c
>>> index 00abec3..da545c6 100644
>>> --- a/net/tftp.c
>>> +++ b/net/tftp.c
>>> @@ -55,18 +55,18 @@ enum {
>>>   TFTP_ERR_FILE_ALREADY_EXISTS = 6,
>>>   };
>>>
>>> -static IPaddr_t TftpServerIP;
>>> -static intTftpServerPort;/* The UDP port at their 
>>> end*/
>>> -static intTftpOurPort;/* The UDP port at our end*/
>>> +static IPaddr_t TftpRemoteIP;
>>> +static intTftpRemotePort;/* The UDP port at their 
>>> end*/
>>> +static intTftpOurPort;/* The UDP port at our end*/
>>>   static intTftpTimeoutCount;
>>> -static ulongTftpBlock;/* packet sequence number*/
>>> -static ulongTftpLastBlock;/* last packet sequence 
>>> number received */
>>> -static ulongTftpBlockWrap;/* count of sequence number 
>>> wraparounds */
>>> -static ulongTftpBlockWrapOffset;/* memory offset due to 
>>> wrapping*/
>>> +static ulongTftpBlock;/* packet sequence number*/
>>> +static ulongTftpLastBlock;/* last packet sequence number 
>>> received */
>>> +static ulongTftpBlockWrap;/* count of sequence number 
>>> wraparounds */
>>> +static ulongTftpBlockWrapOffset; /* memory offset due to 
>>> wrapping*/
>> These changes are indentation only changes, so they should be in a
>> separate patch.
>
> It's needed for checkpatch compliance.
>
>
>>>   static intTftpState;
>>>   #ifdef CONFIG_TFTP_TSIZE
>>> -static intTftpTsize;/* The file size reported by the 
>>> server */
>>> -static shortTftpNumchars;/* The number of hashes we 
>>> printed  */
>>> +static intTftpTsize;/* The file size reported by the server */
>>> +static shortTftpNumchars;/* The number of hashes we 
>>> printed  */
>> dito.
>>
>> [...]
>>
>>> @@ -421,7 +421,7 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t 
>>> sip, unsigned src,
>>>
>>>   /*
>>>*Acknoledge the block just received, which will prompt
>>> - *the server for the next one.
>>> + *the remote for the next one.
>> Hey, while you're at it, please fix the "Acknoledge" typo ;)
>
> Will do.

Done for v3.

I removed the checkpatch-related changes: they are now on the tftp 
cleanup patch series that I submitted on saturday, and on top of which 
v3 of the TFTP server will be based.

Luca

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


  1   2   3   >