Re: [PATCH 0/9] MIPS: xburst: add JZ4780 SoC and MIPS Creator CI20 board support

2014-09-11 Thread Sascha Hauer
On Wed, Sep 10, 2014 at 11:42:17AM +0400, Antony Pavlov wrote:
 The MIPS Creator CI20 board is a high performance, fully featured
 Linux and Android development platform.
 
 The Creator CI20 is supplied free of charge to certain approved projects
 under Imagination's ecosystem.
 
 Please see http://store.imgtec.com/product/mips-creator-ci20/ for details.
 
 Barebox CI20-related changes are available on github:
   https://github.com/frantony/barebox/tree/next.ci20.20140910
 
 
 Antony Pavlov (9):
   common.h: use special IOMEM() for MIPS
   MIPS: dts: use physical addresses (as Linux does)
   MIPS: xburst: add JZ4780 SoC support
   MIPS: add (another) Ingenic vendor ID
   MIPS: xburst: debug_ll: rework common code, add JZ4780 support
   MIPS: dts: add jz4780.dtsi
   MIPS: add MIPS Creator CI20 board support
   MIPS: add img-ci20_defconfig
   Documentation: add MIPS Creator CI20 board mini-howto

Applied all, thanks

Sascha


-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] net: dm9k: fix copy-paste typo

2014-09-11 Thread Sascha Hauer
On Wed, Sep 10, 2014 at 11:49:52AM +0400, Antony Pavlov wrote:
 Signed-off-by: Antony Pavlov antonynpav...@gmail.com
 ---
  drivers/net/dm9k.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks

Sascha

 
 diff --git a/drivers/net/dm9k.c b/drivers/net/dm9k.c
 index 950bdb3..e525a84 100644
 --- a/drivers/net/dm9k.c
 +++ b/drivers/net/dm9k.c
 @@ -775,7 +775,7 @@ static int dm9k_probe(struct device_d *dev)
   break;
   case 2:
   dev_dbg(dev, 8 bit data bus\n);
 - if (priv-buswidth != IORESOURCE_MEM_32BIT)
 + if (priv-buswidth != IORESOURCE_MEM_8BIT)
   dev_err(dev,
   Wrong databus width defined at compile time\n);
   break;
 -- 
 2.1.0
 
 
 ___
 barebox mailing list
 barebox@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/barebox
 

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] net: dm9k: show only one phy on miibus

2014-09-11 Thread Sascha Hauer
On Wed, Sep 10, 2014 at 11:51:12AM +0400, Antony Pavlov wrote:
 Signed-off-by: Antony Pavlov antonynpav...@gmail.com
 ---
  drivers/net/dm9k.c | 9 +
  1 file changed, 9 insertions(+)
 
 diff --git a/drivers/net/dm9k.c b/drivers/net/dm9k.c
 index 3a4c6aa..950bdb3 100644
 --- a/drivers/net/dm9k.c
 +++ b/drivers/net/dm9k.c
 @@ -359,6 +359,11 @@ static int dm9k_phy_read(struct mii_bus *bus, int addr, 
 int reg)
   struct dm9k *priv = bus-priv;
   struct device_d *dev = bus-dev;
  
 + /* Show only one phy on miibus */
 + if (addr != 0) {
 + return 0x;
 + }

In the datasheet I can see that the dm9000 has an internal phy but also
supports an external phy. The above seems true for the internal, but
what about the external? Is support for this missing anyway since I
can't find any references in the code?

Sascha


-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [RFC] net: dm9k: add device tree support

2014-09-11 Thread Sascha Hauer
On Wed, Sep 10, 2014 at 11:53:48AM +0400, Antony Pavlov wrote:
 Signed-off-by: Antony Pavlov antonynpav...@gmail.com
 ---
  drivers/net/dm9k.c | 46 +++---
  1 file changed, 39 insertions(+), 7 deletions(-)
 
 diff --git a/drivers/net/dm9k.c b/drivers/net/dm9k.c
 index e525a84..9e7b415 100644
 --- a/drivers/net/dm9k.c
 +++ b/drivers/net/dm9k.c
 @@ -707,16 +707,30 @@ static int dm9k_init_dev(struct eth_device *edev)
   return 0;
  }
  
 +static struct dm9000_platform_data *dm9000_parse_dt(struct device_d *dev)
 +{
 + struct dm9000_platform_data *pdata;
 + struct device_node *np = dev-device_node;
 +
 + if (!IS_ENABLED(CONFIG_OF) || !np)
 + return NULL;
 +
 + pdata = xzalloc(sizeof(*pdata));
 +
 + pdata-srom = 0;

Please don't allocate platform_data for the device tree case. Instead,
add a srom variable to struct dm9k and set it either from platform_data
or device tree.

 - priv-buswidth = dev-resource[0].flags  IORESOURCE_MEM_TYPE_MASK;
 + switch (resource_size(dev-resource[0])) {
 + case 1:
 + priv-buswidth = IORESOURCE_MEM_8BIT;
 + break;
 + case 2:
 + priv-buswidth = IORESOURCE_MEM_16BIT;
 + break;
 + case 4:
 + priv-buswidth = IORESOURCE_MEM_32BIT;
 + break;
 + default:
 + dev_err(dev, Wrong io resource size\n);
 + priv-buswidth = 0;
 + }

Does this work for device tree?

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] checkpatch.pl: check for the FSF mailing address

2014-09-11 Thread Antony Pavlov
This check code is imported from Linux v3.16 checkpatch.pl.

Signed-off-by: Antony Pavlov antonynpav...@gmail.com
---
 scripts/checkpatch.pl | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 153af8d..419436d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1425,6 +1425,16 @@ sub process {
$rpt_cleaners = 1;
}
 
+# Check for FSF mailing addresses.
+   if ($rawline =~ /\bwrite to the Free/i ||
+   $rawline =~ /\b59\s+Temple\s+Pl/i ||
+   $rawline =~ /\b51\s+Franklin\s+St/i) {
+   my $herevet = $here\n . cat_vet($rawline) . \n;
+   my $msg_type = \ERROR;
+   $msg_type = \CHK if ($file);
+   {$msg_type}(Do not include the paragraph about 
writing to the Free Software Foundation's mailing address from the sample GPL 
notice. The FSF has changed addresses in the past, and may do so again. barebox 
already includes a copy of the GPL.\n . $herevet)
+   }
+
 # check for Kconfig help text having a real description
 # Only applies when adding the entry originally, after that we do not have
 # sufficient context to determine whether it is indeed long enough.
-- 
2.1.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[RFC] net: dm9k: fix reset routine

2014-09-11 Thread Antony Pavlov
Based on Linux's commit:

commit 09ee9f87d02e779e4fc3f5c29212c733d6d6e349
Author: Michael Abbott michael.abb...@diamond.ac.uk
Date:   Wed Oct 16 11:41:33 2013 +0300

dm9000: Implement full reset of DM9000 network device

A Davicom application note for the DM9000 network device recommends
performing software reset twice to correctly initialise the device.
Without this reset some devices fail to initialise correctly on
system startup.

N.B. DM9000B on MIPS Creator CI20 board needs additional workaround
(see the 'Make all GPIO pins outputs' and 'Power internal PHY' lines).

This workaround was taken from this U-boot's commit:

commit fbcb7ece0ea1e364180f1cf963e0fa0ce7f6560d
Author: Remy Bohmer li...@bohmer.net
Date:   Tue Jun 3 15:26:24 2008 +0200

DM9000: Improve eth_reset() routine

According to the application notes of the DM9000 v1.22 chapter 5.2 
bullet 2, the
reset procedure must be done twice to properly reset the DM9000 by 
means of software.
This errata is not needed anymore for the DM9000A, but it does not 
bother it.

This change has been tested with DM9000A, DM9000E, DM9000EP.

Signed-off-by: Antony Pavlov antonynpav...@gmail.com
---
 drivers/net/dm9k.c | 25 +++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dm9k.c b/drivers/net/dm9k.c
index 9e7b415..b407f19 100644
--- a/drivers/net/dm9k.c
+++ b/drivers/net/dm9k.c
@@ -48,6 +48,7 @@
 # define NCR_FCOL  (1  4)
 # define NCR_FDX   (1  3)
 # define NCR_LBK   (3  1)
+# define NCR_MAC_LBK   (1  1)
 # define NCR_RST   (1  0)
 
 #define DM9K_NSR   0x01
@@ -471,8 +472,28 @@ static void dm9k_reset(struct dm9k *priv)
struct device_d *dev = priv-miibus.parent;
 
dev_dbg(dev, %s\n, __func__);
-   dm9k_iow(priv, DM9K_NCR, NCR_RST);
-   udelay(1000);   /* delay 1ms */
+
+   /* Reset DM9000, see DM9000 Application Notes V1.22 Jun 11, 2004 page 29
+* The essential point is that we have to do a double reset, and the
+* instruction is to set LBK into MAC internal loopback mode.
+*/
+
+   /* Make all GPIO pins outputs */
+   dm9k_iow(priv, DM9K_GPCR, 0x0F);
+   /* Power internal PHY by writing 0 to GPIO0 pin */
+   dm9k_iow(priv, DM9K_GPR, 0);
+
+   dm9k_iow(priv, DM9K_NCR, NCR_RST | NCR_MAC_LBK);
+   udelay(100); /* Application note says at least 20 us */
+   if (dm9k_ior(priv, DM9K_NCR)  NCR_RST)
+   dev_err(dev, dm9000 did not respond to first reset\n);
+
+   dm9k_iow(priv, DM9K_NCR, 0);
+   dm9k_iow(priv, DM9K_NCR, NCR_RST | NCR_MAC_LBK);
+   udelay(100);
+
+   if (dm9k_ior(priv, DM9K_NCR)  NCR_RST)
+   dev_err(dev, dm9000 did not respond to second reset\n);
 }
 
 static int dm9k_eth_open(struct eth_device *edev)
-- 
2.1.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] commands: of_dump: Fix return value

2014-09-11 Thread Teresa Gámez
In an error case the return value is set nicely
but 0 is always beeing returned.

Signed-off-by: Teresa Gámez t.ga...@phytec.de
---
 commands/of_dump.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/commands/of_dump.c b/commands/of_dump.c
index 1222ebf..513a4b8 100644
--- a/commands/of_dump.c
+++ b/commands/of_dump.c
@@ -34,7 +34,7 @@
 static int do_of_dump(int argc, char *argv[])
 {
int opt;
-   int ret;
+   int ret = 0;
int fix = 0;
struct device_node *root = NULL, *node, *of_free = NULL;
char *dtbfile = NULL;
@@ -117,7 +117,7 @@ out:
if (of_free)
of_delete_node(of_free);
 
-   return 0;
+   return ret;
 }
 
 BAREBOX_CMD_HELP_START(of_dump)
-- 
1.7.0.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 10/10] UBI: bugfix in ubi_wl_flush()

2014-09-11 Thread Sascha Hauer
From: Richard Weinberger rich...@nod.at

Use the _safe variant because we're iterating over a list where items get
deleted and freed.

Signed-off-by: Richard Weinberger rich...@nod.at
Signed-off-by: Artem Bityutskiy artem.bityuts...@linux.intel.com
---
 drivers/mtd/ubi/wl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index e52910f..4c20e90 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1617,10 +1617,10 @@ int ubi_wl_flush(struct ubi_device *ubi, int vol_id, 
int lnum)
   vol_id, lnum, ubi-works_count);
 
while (found) {
-   struct ubi_work *wrk;
+   struct ubi_work *wrk, *tmp;
found = 0;
 
-   list_for_each_entry(wrk, ubi-works, list) {
+   list_for_each_entry_safe(wrk, tmp, ubi-works, list) {
if ((vol_id == UBI_ALL || wrk-vol_id == vol_id) 
(lnum == UBI_ALL || wrk-lnum == lnum)) {
list_del(wrk-list);
-- 
2.1.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 07/10] UBI: fix the volumes tree sorting criteria

2014-09-11 Thread Sascha Hauer
From: Heiko Schocher h...@denx.de

Commig 604b592 UBI: fix rb_tree node comparison in add_map
broke fastmap backward compatibility and older fastmap images
cannot be mounted anymore. The reason is that it changes the
volumes RB-tree sorting criteria. This patch fixes the problem.

Artem: re-write the commit message

Signed-off-by: Heiko Schocher h...@denx.de
Acked-by: Richard Weinberger rich...@nod.at
Signed-off-by: Artem Bityutskiy artem.bityuts...@linux.intel.com
---
 drivers/mtd/ubi/fastmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index 3aa7aa8..21b7f07 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -125,7 +125,7 @@ static struct ubi_ainf_volume *add_vol(struct 
ubi_attach_info *ai, int vol_id,
parent = *p;
av = rb_entry(parent, struct ubi_ainf_volume, rb);
 
-   if (vol_id  av-vol_id)
+   if (vol_id  av-vol_id)
p = (*p)-rb_left;
else
p = (*p)-rb_right;
-- 
2.1.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 01/10] UBI: fix error return code

2014-09-11 Thread Sascha Hauer
From: Julia Lawall julia.law...@lip6.fr

Set the return variable to an error code as done elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
(
if@p1 (\(ret  0\|ret != 0\))
 { ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
when != ret
*if(...)
{
  ... when != ret = e2
  when forall
 return ret;
}

// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr
Reviewed-by: Richard Weinberger rich...@nod.at
---
 drivers/mtd/ubi/attach.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c
index 5412974..d6fe43b 100644
--- a/drivers/mtd/ubi/attach.c
+++ b/drivers/mtd/ubi/attach.c
@@ -1429,8 +1429,10 @@ int ubi_attach(struct ubi_device *ubi, int force_scan)
struct ubi_attach_info *scan_ai;
 
scan_ai = alloc_ai(ubi_ckh_aeb_slab_cache);
-   if (!scan_ai)
+   if (!scan_ai) {
+   err = -ENOMEM;
goto out_wl;
+   }
 
err = scan_all(ubi, scan_ai, 0);
if (err) {
-- 
2.1.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 08/10] UBI: fastmap: do not miss bit-flips

2014-09-11 Thread Sascha Hauer
From: Brian Norris computersforpe...@gmail.com

The return value from 'ubi_io_read_ec_hdr()' was stored in 'err', not in 'ret'.
This fix makes sure Fastmap-enabled UBI does not miss bit-flip while reading EC
headers, events and scrubs the affected PEBs.

This issue was reported by Coverity Scan.

Artem: improved the commit message.

Signed-off-by: Brian Norris computersforpe...@gmail.com
Acked-by: Richard Weinberger rich...@nod.at
Signed-off-by: Artem Bityutskiy artem.bityuts...@linux.intel.com
---
 drivers/mtd/ubi/fastmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index 21b7f07..8f29430 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -422,7 +422,7 @@ static int scan_pool(struct ubi_device *ubi, struct 
ubi_attach_info *ai,
pnum, err);
ret = err  0 ? UBI_BAD_FASTMAP : err;
goto out;
-   } else if (ret == UBI_IO_BITFLIPS)
+   } else if (err == UBI_IO_BITFLIPS)
scrub = 1;
 
/*
-- 
2.1.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 02/10] UBI: avoid program operation on NOR flash after erasure interrupted

2014-09-11 Thread Sascha Hauer
From: Qi Wang 王起 (qiwang) qiw...@micron.com

nor_erase_prepare() will be called before erase a NOR flash, it will program '0'
into a block to mark this block. But program data into a erasure interrupted 
block
can cause program timtout(several minutes at most) error, could impact other
operation on NOR flash. So UBIFS can read this block first to avoid unneeded
program operation.

This patch try to put read operation at head of write operation in
nor_erase_prepare(), read out the data.
If the data is already corrupt, then no need to program any data into this 
block,
just go to erase this block.

This patch is validated on Micron NOR flash, part number is:JS28F512M29EWHA

Signed-off-by: Qi Wang qiw...@micron.com
Signed-off-by: Artem Bityutskiy artem.bityuts...@linux.intel.com
---
 drivers/mtd/ubi/io.c | 54 +---
 1 file changed, 22 insertions(+), 32 deletions(-)

diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index f9f9738..e55dfc5 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -473,10 +473,12 @@ out:
  */
 static int nor_erase_prepare(struct ubi_device *ubi, int pnum)
 {
-   int err, err1;
+   int err;
size_t written;
loff_t addr;
uint32_t data = 0;
+   struct ubi_ec_hdr ec_hdr;
+
/*
 * Note, we cannot generally define VID header buffers on stack,
 * because of the way we deal with these buffers (see the header
@@ -487,50 +489,38 @@ static int nor_erase_prepare(struct ubi_device *ubi, int 
pnum)
struct ubi_vid_hdr vid_hdr;
 
/*
+* If VID or EC is valid, we have to corrupt them before erasing.
 * It is important to first invalidate the EC header, and then the VID
 * header. Otherwise a power cut may lead to valid EC header and
 * invalid VID header, in which case UBI will treat this PEB as
 * corrupted and will try to preserve it, and print scary warnings.
 */
addr = (loff_t)pnum * ubi-peb_size;
-   err = mtd_write(ubi-mtd, addr, 4, written, (void *)data);
-   if (!err) {
-   addr += ubi-vid_hdr_aloffset;
+   err = ubi_io_read_ec_hdr(ubi, pnum, ec_hdr, 0);
+   if (err != UBI_IO_BAD_HDR_EBADMSG  err != UBI_IO_BAD_HDR 
+   err != UBI_IO_FF){
err = mtd_write(ubi-mtd, addr, 4, written, (void *)data);
-   if (!err)
-   return 0;
+   if(err)
+   goto error;
}
 
-   /*
-* We failed to write to the media. This was observed with Spansion
-* S29GL512N NOR flash. Most probably the previously eraseblock erasure
-* was interrupted at a very inappropriate moment, so it became
-* unwritable. In this case we probably anyway have garbage in this
-* PEB.
-*/
-   err1 = ubi_io_read_vid_hdr(ubi, pnum, vid_hdr, 0);
-   if (err1 == UBI_IO_BAD_HDR_EBADMSG || err1 == UBI_IO_BAD_HDR ||
-   err1 == UBI_IO_FF) {
-   struct ubi_ec_hdr ec_hdr;
-
-   err1 = ubi_io_read_ec_hdr(ubi, pnum, ec_hdr, 0);
-   if (err1 == UBI_IO_BAD_HDR_EBADMSG || err1 == UBI_IO_BAD_HDR ||
-   err1 == UBI_IO_FF)
-   /*
-* Both VID and EC headers are corrupted, so we can
-* safely erase this PEB and not afraid that it will be
-* treated as a valid PEB in case of an unclean reboot.
-*/
-   return 0;
+   err = ubi_io_read_vid_hdr(ubi, pnum, vid_hdr, 0);
+   if (err != UBI_IO_BAD_HDR_EBADMSG  err != UBI_IO_BAD_HDR 
+   err != UBI_IO_FF){
+   addr += ubi-vid_hdr_aloffset;
+   err = mtd_write(ubi-mtd, addr, 4, written, (void *)data);
+   if (err)
+   goto error;
}
+   return 0;
 
+error:
/*
-* The PEB contains a valid VID header, but we cannot invalidate it.
-* Supposedly the flash media or the driver is screwed up, so return an
-* error.
+* The PEB contains a valid VID or EC header, but we cannot invalidate
+* it. Supposedly the flash media or the driver is screwed up, so
+* return an error.
 */
-   ubi_err(cannot invalidate PEB %d, write returned %d read returned %d,
-   pnum, err, err1);
+   ubi_err(cannot invalidate PEB %d, write returned %d, pnum, err);
ubi_dump_flash(ubi, pnum, 0, ubi-peb_size);
return -EIO;
 }
-- 
2.1.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 06/10] UBI: fix rb_tree node comparison in add_map

2014-09-11 Thread Sascha Hauer
From: Mike Snitzer snit...@redhat.com

The comparisons used in add_vol() shouldn't be identical.  Pretty sure
the following is correct but it is completely untested.

Signed-off-by: Mike Snitzer snit...@redhat.com
Acked-by: Richard Weinberger rich...@nod.at
Signed-off-by: Artem Bityutskiy artem.bityuts...@linux.intel.com
---
 drivers/mtd/ubi/fastmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index 50db661..3aa7aa8 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -125,9 +125,9 @@ static struct ubi_ainf_volume *add_vol(struct 
ubi_attach_info *ai, int vol_id,
parent = *p;
av = rb_entry(parent, struct ubi_ainf_volume, rb);
 
-   if (vol_id  av-vol_id)
+   if (vol_id  av-vol_id)
p = (*p)-rb_left;
-   else if (vol_id  av-vol_id)
+   else
p = (*p)-rb_right;
}
 
-- 
2.1.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 04/10] UBI: fix error path in __wl_get_peb

2014-09-11 Thread Sascha Hauer
From: Tanya Brokhman tlin...@codeaurora.org

In case of an error (if there are not free PEB's for example),
__wl_get_peb will return a negative value. In order to prevent access
violation we need to test the returned value prior to using it later on.

Signed-off-by: Tatyana Brokhman tlin...@codeaurora.org
Reviewed-by: Dolev Raviv dra...@codeaurora.org
Acked-by: Richard Weinberger rich...@nod.at
Signed-off-by: Artem Bityutskiy artem.bityuts...@linux.intel.com
---
 drivers/mtd/ubi/wl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index c083cac..4ecbe18 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -646,6 +646,9 @@ int ubi_wl_get_peb(struct ubi_device *ubi)
 
peb = __wl_get_peb(ubi);
 
+   if (peb  0)
+   return peb;
+
err = ubi_self_check_all_ff(ubi, peb, ubi-vid_hdr_aloffset,
ubi-peb_size - ubi-vid_hdr_aloffset);
if (err) {
-- 
2.1.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


UBI patches

2014-09-11 Thread Sascha Hauer
The following are the UBI fixes ported from the Kernel. This updates
UBI corresponding to Linux-3.17-rc4.

Sascha


Brian Norris (1):
  UBI: fastmap: do not miss bit-flips

Dan Carpenter (1):
  UBI: fix some use after free bugs

Heiko Schocher (1):
  UBI: fix the volumes tree sorting criteria

Julia Lawall (1):
  UBI: fix error return code

Mike Snitzer (1):
  UBI: fix rb_tree node comparison in add_map

Qi Wang 王起 (qiwang) (1):
  UBI: avoid program operation on NOR flash after erasure interrupted

Richard Weinberger (2):
  UBI: init_volumes: Ignore volumes with no LEBs
  UBI: bugfix in ubi_wl_flush()

Tanya Brokhman (2):
  UBI: fix error path in __wl_get_peb
  UBI: fix ubi free PEBs count calculation

 drivers/mtd/ubi/attach.c  |  4 +++-
 drivers/mtd/ubi/fastmap.c | 12 +--
 drivers/mtd/ubi/io.c  | 54 +++
 drivers/mtd/ubi/vtbl.c|  2 +-
 drivers/mtd/ubi/wl.c  | 10 +++--
 5 files changed, 40 insertions(+), 42 deletions(-)

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 05/10] UBI: fix ubi free PEBs count calculation

2014-09-11 Thread Sascha Hauer
From: Tanya Brokhman tlin...@codeaurora.org

The ubi-free_count should be updated with every insert/remove to/from
the ubi-free list.

Signed-off-by: Tanya Brokhman tlin...@codeaurora.org
Reviewed-by: Dolev Raviv dra...@codeaurora.org
Acked-by: Richard Weinberger rich...@nod.at
Signed-off-by: Artem Bityutskiy artem.bityuts...@linux.intel.com
---
 drivers/mtd/ubi/wl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 4ecbe18..e52910f 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -635,6 +635,8 @@ static struct ubi_wl_entry *get_peb_for_wl(struct 
ubi_device *ubi)
 
e = find_wl_entry(ubi, ubi-free, WL_FREE_MAX_DIFF);
self_check_in_wl_tree(ubi, e, ubi-free);
+   ubi-free_count--;
+   ubi_assert(ubi-free_count = 0);
rb_erase(e-u.rb, ubi-free);
 
return e;
@@ -1018,6 +1020,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, 
struct ubi_work *wrk,
 
/* Give the unused PEB back */
wl_tree_add(e2, ubi-free);
+   ubi-free_count++;
goto out_cancel;
}
self_check_in_wl_tree(ubi, e1, ubi-used);
-- 
2.1.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 09/10] UBI: init_volumes: Ignore volumes with no LEBs

2014-09-11 Thread Sascha Hauer
From: Richard Weinberger rich...@nod.at

UBI assumes that ubi_attach_info will only contain ubi_ainf_volume
structures for volumes with at least one LEB.
In scanning mode this is true because UBI can nicely create a ubi_ainf_volume
on demand while creating the EBA table.

For fastmap this is not true, the fastmap on-flash structure has a list of
all volumes, the ubi_ainf_volume structures are created from this list.
So it can happen that an empty volume ends up in init_volumes().

We can easely deal with that by looking into -leb_count too.

Signed-off-by: Richard Weinberger rich...@nod.at
Signed-off-by: Artem Bityutskiy artem.bityuts...@linux.intel.com
---
 drivers/mtd/ubi/vtbl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 48b2915..c15809a 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -580,7 +580,7 @@ static int init_volumes(struct ubi_device *ubi,
 
/* Static volumes only */
av = ubi_find_av(ai, i);
-   if (!av) {
+   if (!av || !av-leb_count) {
/*
 * No eraseblocks belonging to this volume found. We
 * don't actually know whether this static volume is
-- 
2.1.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 03/10] UBI: fix some use after free bugs

2014-09-11 Thread Sascha Hauer
From: Dan Carpenter dan.carpen...@oracle.com

Move the kmem_cache_free() calls down a couple lines.

Signed-off-by: Dan Carpenter dan.carpen...@oracle.com
Signed-off-by: Artem Bityutskiy artem.bityuts...@linux.intel.com
---
 drivers/mtd/ubi/fastmap.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index de68c32..50db661 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -462,8 +462,8 @@ static int scan_pool(struct ubi_device *ubi, struct 
ubi_attach_info *ai,
}
}
if (found_orphan) {
-   kfree(tmp_aeb);
list_del(tmp_aeb-u.list);
+   kfree(tmp_aeb);
}
 
new_aeb = kzalloc(sizeof(*new_aeb), GFP_KERNEL);
@@ -835,16 +835,16 @@ fail_bad:
ret = UBI_BAD_FASTMAP;
 fail:
list_for_each_entry_safe(tmp_aeb, _tmp_aeb, used, u.list) {
-   free(tmp_aeb);
list_del(tmp_aeb-u.list);
+   free(tmp_aeb);
}
list_for_each_entry_safe(tmp_aeb, _tmp_aeb, eba_orphans, u.list) {
-   free(tmp_aeb);
list_del(tmp_aeb-u.list);
+   free(tmp_aeb);
}
list_for_each_entry_safe(tmp_aeb, _tmp_aeb, lfree, u.list) {
-   free(tmp_aeb);
list_del(tmp_aeb-u.list);
+   free(tmp_aeb);
}
 
return ret;
-- 
2.1.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] checkpatch.pl: check for the FSF mailing address

2014-09-11 Thread Sascha Hauer
On Thu, Sep 11, 2014 at 01:49:51PM +0400, Antony Pavlov wrote:
 This check code is imported from Linux v3.16 checkpatch.pl.
 
 Signed-off-by: Antony Pavlov antonynpav...@gmail.com

Ah good move. I hope this helps not getting the address back into the
tree every now and then.

Applied, thanks.

Sascha

 ---
  scripts/checkpatch.pl | 10 ++
  1 file changed, 10 insertions(+)
 
 diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
 index 153af8d..419436d 100755
 --- a/scripts/checkpatch.pl
 +++ b/scripts/checkpatch.pl
 @@ -1425,6 +1425,16 @@ sub process {
   $rpt_cleaners = 1;
   }
  
 +# Check for FSF mailing addresses.
 + if ($rawline =~ /\bwrite to the Free/i ||
 + $rawline =~ /\b59\s+Temple\s+Pl/i ||
 + $rawline =~ /\b51\s+Franklin\s+St/i) {
 + my $herevet = $here\n . cat_vet($rawline) . \n;
 + my $msg_type = \ERROR;
 + $msg_type = \CHK if ($file);
 + {$msg_type}(Do not include the paragraph about 
 writing to the Free Software Foundation's mailing address from the sample GPL 
 notice. The FSF has changed addresses in the past, and may do so again. 
 barebox already includes a copy of the GPL.\n . $herevet)
 + }
 +
  # check for Kconfig help text having a real description
  # Only applies when adding the entry originally, after that we do not have
  # sufficient context to determine whether it is indeed long enough.
 -- 
 2.1.0
 
 
 ___
 barebox mailing list
 barebox@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/barebox
 

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [RFC] net: dm9k: fix reset routine

2014-09-11 Thread Sascha Hauer
On Thu, Sep 11, 2014 at 03:20:01PM +0400, Antony Pavlov wrote:
 Based on Linux's commit:
 
 commit 09ee9f87d02e779e4fc3f5c29212c733d6d6e349
 Author: Michael Abbott michael.abb...@diamond.ac.uk
 Date:   Wed Oct 16 11:41:33 2013 +0300
 
 dm9000: Implement full reset of DM9000 network device
 
 A Davicom application note for the DM9000 network device recommends
 performing software reset twice to correctly initialise the device.
 Without this reset some devices fail to initialise correctly on
 system startup.
 
  # define NCR_FDX (1  3)
  # define NCR_LBK (3  1)
 +# define NCR_MAC_LBK (1  1)
  # define NCR_RST (1  0)
  
  #define DM9K_NSR 0x01
 @@ -471,8 +472,28 @@ static void dm9k_reset(struct dm9k *priv)
   struct device_d *dev = priv-miibus.parent;
  
   dev_dbg(dev, %s\n, __func__);
 - dm9k_iow(priv, DM9K_NCR, NCR_RST);
 - udelay(1000);   /* delay 1ms */
 +
 + /* Reset DM9000, see DM9000 Application Notes V1.22 Jun 11, 2004 page 29
 +  * The essential point is that we have to do a double reset, and the
 +  * instruction is to set LBK into MAC internal loopback mode.
 +  */
 +
 + /* Make all GPIO pins outputs */
 + dm9k_iow(priv, DM9K_GPCR, 0x0F);
 + /* Power internal PHY by writing 0 to GPIO0 pin */
 + dm9k_iow(priv, DM9K_GPR, 0);
 +
 + dm9k_iow(priv, DM9K_NCR, NCR_RST | NCR_MAC_LBK);
 + udelay(100); /* Application note says at least 20 us */
 + if (dm9k_ior(priv, DM9K_NCR)  NCR_RST)
 + dev_err(dev, dm9000 did not respond to first reset\n);
 +
 + dm9k_iow(priv, DM9K_NCR, 0);
 + dm9k_iow(priv, DM9K_NCR, NCR_RST | NCR_MAC_LBK);
 + udelay(100);
 +
 + if (dm9k_ior(priv, DM9K_NCR)  NCR_RST)
 + dev_err(dev, dm9000 did not respond to second reset\n);

How about using a loop to save a few bytes? Otherwise fine with me.

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox