Skip to contentSkip to conversation

Basic Unsorted Block Image (UBI) support (part 1)

PATCH New Kyungmin Park 3 participants 5 messages Oct 21, 2008 – Oct 22, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Basic Unsorted Block Image (UBI) support (part 1)

Now it can use UBI support on U-Boot

---
 Makefile                       |    1 +
 drivers/mtd/Makefile           |    1 +
 drivers/mtd/mtdcore.c          |  142 ++++
 drivers/mtd/mtdpart.c          |  531 +++++++++++++
 drivers/mtd/ubi/Makefile       |   48 ++
 drivers/mtd/ubi/build.c        | 1182 ++++++++++++++++++++++++++++
 drivers/mtd/ubi/crc32.c        |  514 ++++++++++++
 drivers/mtd/ubi/crc32defs.h    |   32 +
 drivers/mtd/ubi/crc32table.h   |  136 ++++
 drivers/mtd/ubi/debug.c        |  192 +++++
 drivers/mtd/ubi/debug.h        |  152 ++++
 drivers/mtd/ubi/eba.c          | 1256 ++++++++++++++++++++++++++++++
 drivers/mtd/ubi/io.c           | 1274 ++++++++++++++++++++++++++++++
 drivers/mtd/ubi/kapi.c         |  638 +++++++++++++++
 drivers/mtd/ubi/misc.c         |  106 +++
 drivers/mtd/ubi/scan.c         | 1361 ++++++++++++++++++++++++++++++++
 drivers/mtd/ubi/scan.h         |  165 ++++
 drivers/mtd/ubi/ubi-media.h    |  372 +++++++++
 drivers/mtd/ubi/ubi.h          |  641 +++++++++++++++
 drivers/mtd/ubi/upd.c          |  441 +++++++++++
 drivers/mtd/ubi/vmt.c          |  862 +++++++++++++++++++++
 drivers/mtd/ubi/vtbl.c         |  837 ++++++++++++++++++++
 drivers/mtd/ubi/wl.c           | 1670 ++++++++++++++++++++++++++++++++++++++++
 include/linux/crc32.h          |   27 +
 include/linux/mtd/mtd.h        |    1 +
 include/linux/mtd/partitions.h |   84 ++
 include/linux/mtd/ubi.h        |  186 +++++
 include/linux/types.h          |   24 +
 include/mtd/ubi-header.h       |  372 +++++++++
 include/mtd/ubi-user.h         |  268 +++++++
 include/ubi_uboot.h            |  209 +++++
 31 files changed, 13725 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/mtdcore.c
 create mode 100644 drivers/mtd/mtdpart.c
 create mode 100644 drivers/mtd/ubi/Makefile
 create mode 100644 drivers/mtd/ubi/build.c
 create mode 100644 drivers/mtd/ubi/crc32.c
 create mode 100644 drivers/mtd/ubi/crc32defs.h
 create mode 100644 drivers/mtd/ubi/crc32table.h
 create mode 100644 drivers/mtd/ubi/debug.c
 create mode 100644 drivers/mtd/ubi/debug.h
 create mode 100644 drivers/mtd/ubi/eba.c
 create mode 100644 drivers/mtd/ubi/io.c
 create mode 100644 drivers/mtd/ubi/kapi.c
 create mode 100644 drivers/mtd/ubi/misc.c
 create mode 100644 drivers/mtd/ubi/scan.c
 create mode 100644 drivers/mtd/ubi/scan.h
 create mode 100644 drivers/mtd/ubi/ubi-media.h
 create mode 100644 drivers/mtd/ubi/ubi.h
 create mode 100644 drivers/mtd/ubi/upd.c
 create mode 100644 drivers/mtd/ubi/vmt.c
 create mode 100644 drivers/mtd/ubi/vtbl.c
 create mode 100644 drivers/mtd/ubi/wl.c
 create mode 100644 include/linux/crc32.h
 create mode 100644 include/linux/mtd/partitions.h
 create mode 100644 include/linux/mtd/ubi.h
 create mode 100644 include/mtd/ubi-header.h
 create mode 100644 include/mtd/ubi-user.h
 create mode 100644 include/ubi_uboot.h
Makefile +1 -0
index 9a132f7..93759e4 100644
@@ -230,6 +230,7 @@ LIBS += drivers/mtd/libmtd.a
 LIBS += drivers/mtd/nand/libnand.a
 LIBS += drivers/mtd/nand_legacy/libnand_legacy.a
 LIBS += drivers/mtd/onenand/libonenand.a
+LIBS += drivers/mtd/ubi/libubi.a
 LIBS += drivers/mtd/spi/libspi_flash.a
 LIBS += drivers/net/libnet.a
 LIBS += drivers/net/phy/libphy.a
drivers/mtd/Makefile +1 -0
index 6538f7a..d225a68 100644
@@ -25,6 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	:= $(obj)libmtd.a
 
+COBJS-$(CONFIG_CMD_UBI) += mtdcore.o mtdpart.o
 COBJS-$(CONFIG_HAS_DATAFLASH) += at45.o
 COBJS-$(CONFIG_FLASH_CFI_DRIVER) += cfi_flash.o
 COBJS-$(CONFIG_HAS_DATAFLASH) += dataflash.o
drivers/mtd/mtdcore.c new file +142 -0

142 lines not on this page · raw message

drivers/mtd/mtdpart.c new file +531 -0

531 lines not on this page · raw message

drivers/mtd/ubi/Makefile new file +48 -0

48 lines not on this page · raw message

drivers/mtd/ubi/build.c new file +1182 -0

1,182 lines not on this page · raw message

drivers/mtd/ubi/crc32.c new file +514 -0

514 lines not on this page · raw message

drivers/mtd/ubi/crc32defs.h new file +32 -0
new file mode 100644
index 0000000..9b6773d
@@ -0,0 +1,32 @@
+/*
+ * There are multiple 16-bit CRC polynomials in common use, but this is
+ * *the* standard CRC-32 polynomial, first popularized by Ethernet.
+ * x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0
+ */
+#define CRCPOLY_LE 0xedb88320
+#define CRCPOLY_BE 0x04c11db7
+
+/* How many bits@a time to use.  Requires a table of 4<<CRC_xx_BITS bytes. */
+/* For less performance-sensitive, use 4 */
+#ifndef CRC_LE_BITS 
+# define CRC_LE_BITS 8
+#endif
+#ifndef CRC_BE_BITS
+# define CRC_BE_BITS 8
+#endif
+
+/*
+ * Little-endian CRC computation.  Used with serial bit streams sent
+ * lsbit-first.  Be sure to use cpu_to_le32() to append the computed CRC.
+ */
+#if CRC_LE_BITS > 8 || CRC_LE_BITS < 1 || CRC_LE_BITS & CRC_LE_BITS-1
+# error CRC_LE_BITS must be a power of 2 between 1 and 8
+#endif
+
+/*
+ * Big-endian CRC computation.  Used with serial bit streams sent
+ * msbit-first.  Be sure to use cpu_to_be32() to append the computed CRC.
+ */
+#if CRC_BE_BITS > 8 || CRC_BE_BITS < 1 || CRC_BE_BITS & CRC_BE_BITS-1
+# error CRC_BE_BITS must be a power of 2 between 1 and 8
+#endif
drivers/mtd/ubi/crc32table.h new file +136 -0

136 lines not on this page · raw message

drivers/mtd/ubi/debug.c new file +192 -0

192 lines not on this page · raw message

drivers/mtd/ubi/debug.h new file +152 -0

152 lines not on this page · raw message

drivers/mtd/ubi/eba.c new file +1256 -0

57 lines not on this page · raw message

drivers/mtd/ubi/io.c new file +1274 -0

1,274 lines not on this page · raw message

drivers/mtd/ubi/kapi.c new file +638 -0

638 lines not on this page · raw message

drivers/mtd/ubi/misc.c new file +106 -0

106 lines not on this page · raw message

drivers/mtd/ubi/scan.c new file +1361 -0

1,361 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#1 lore raw

PATCH 1/1 Basic Unsorted Block Image (UBI) support (part 1)

Dear Kyungmin Park,

Quoted 5 lines · In message <20081021091839.GA29297@july> you wrote:

Tm93IGl0IGNhbiB1c2UgVUJJIHN1cHBvcnQgb24gVS1Cb290CgpTaWduZWQtb2ZmLWJ5OiBLeXVu Z21pbiBQYXJrIDxreXVuZ21pbi5wYXJrQHNhbXN1bmcuY29tPgotLS0KIE1ha2VmaWxlICAgICAg ICAgICAgICAgICAgICAgICB8ICAgIDEgKwogZHJpdmVycy9tdGQvTWFrZWZpbGUgICAgICAgICAg IHwgICAgMSArCiBkcml2ZXJzL210ZC9tdGRjb3JlLmMgICAgICAgICAgfCAgMTQyICsrKysKIGRy aXZlcnMvbXRkL210ZHBhcnQuYyAgICAgICAgICB8ICA1MzEgKysrKysrKysrKysrKwogZHJpdmVy

...

Please post patches as PLAIN TEXT, not with base64 encoding!!!

There are lots of coding style violations: trailing white space, using spaces instead of TABs for indentation and for vertical alignment, using C++ comments, etc.

Quoted 1 line

Now it can use UBI support on U-Boot

That's not really a good commit message, it seems.

drivers/mtd/mtdcore.c line 2

Quoted 6 lines

index 0000000..a9f494a

drivers/mtd/mtdcore.c new file +2 -0
@@ -0,0 +1,142 @@
+/*
+ * $Id: mtdcore.c,v 1.47 2005/11/07 11:14:20 gleixner Exp $

Please do not include versioninformation in files. We use git for this.

drivers/mtd/mtdcore.c line 6

Quoted 3 lines
drivers/mtd/mtdcore.c new file +3 -0
+ * Core registration and callback routines for MTD
+ * drivers and users.
+ */

GPL header missing - here and in many other files.

drivers/mtd/mtdcore.c line 18

Quoted 5 lines
drivers/mtd/mtdcore.c new file +5 -0
+int add_mtd_device(struct mtd_info *mtd)
+{
+	int i;
+
+	BUG_ON(mtd->writesize == 0);

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

What's that?

drivers/mtd/mtdcore.c line 20

Quoted 1 line
drivers/mtd/mtdcore.c new file +1 -0
+	for (i=0; i < MAX_MTD_DEVICES; i++)

Need "{...}" for multi-line statements.

Quoted 10 lines
drivers/mtd/mtdcore.c new file +10 -0
+		if (!mtd_table[i]) {
+			mtd_table[i] = mtd;
+			mtd->index = i;
+			mtd->usecount = 0;
+
+			printf("mtd: Giving out device %d to %s\n",i, mtd->name);
+			/* No need to get a refcount on the module containing
+			   the notifier, since we hold the mtd_table_mutex */
+
+			/* We _know_ we aren't being removed, because

drivers/mtd/mtdcore.c line 40

Quoted 10 lines
drivers/mtd/mtdcore.c new file +10 -0
+			   our caller is still holding us here. So none
+			   of this try_ nonsense, and no bitching about it
+			   either. :) */
+			return 0;
+		}
+
+	return 1;
+}
+
+/**

Please use plain "/*" as start of multiline comments. Here and everywhere.

drivers/mtd/mtdpart.c line 2

Quoted 8 lines
drivers/mtd/mtdpart.c new file +2 -0
new file mode 100644
index 0000000..113516a
@@ -0,0 +1,531 @@
+/*
+ * Simple MTD partitioning layer

Hm... We were talking about UBI support.

Do we really have to pull in the whole MTD layer from Linux for this?

I'm not exactly happy about this.

...

drivers/mtd/mtdpart.c line 72

Quoted 12 lines
drivers/mtd/mtdpart.c new file +12 -0
+#if 0
+	if (unlikely(res)) {
+		if (res == -EUCLEAN)
+			mtd->ecc_stats.corrected++;
+		if (res == -EBADMSG)
+			mtd->ecc_stats.failed++;
+	}
+#endif
+	return res;
+}
+
+#if 0

...

Please do not add dead code.

Quoted 39 lines

index 0000000..bf8a19f

drivers/mtd/ubi/build.c new file +35 -0
@@ -0,0 +1,1182 @@
+/*
+ * Copyright (c) International Business Machines Corp., 2006
+ * Copyright (c) Nokia Corporation, 2007
+ *
+ * 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
+ *
+ * Author: Artem Bityutskiy (???????????????? ??????????),
+ *         Frank Haverkamp
+ */
+
+/*
+ * This file includes UBI initialization and building of UBI devices.
+ *
+ * When UBI is initialized, it attaches all the MTD devices specified as the
+ * module load parameters or the kernel boot parameters. If MTD devices were
+ * specified, UBI does not attach any MTD device, but it is possible to do
+ * later using the "UBI control device".
+ *
+ * At the moment we only attach UBI devices by scanning, which will become a
+ * bottleneck when flashes reach certain large size. Then one may improve UBI
+ * and add other methods, although it does not seem to be easy to do.
+ */
+

drivers/mtd/ubi/build.c line 45

Quoted 10 lines
drivers/mtd/ubi/build.c new file +10 -0
+#if 0
+#include <linux/err.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/stringify.h>
+#include <linux/stat.h>
+#include <linux/miscdevice.h>
+#include <linux/log2.h>
+#include <linux/kthread.h>
+#endif

Please do not add dead code - here and everywhere.

Quoted 16 lines
drivers/mtd/ubi/build.c new file +16 -0
+
+/**
+ * ubi_major2num - get UBI device number by character device major number.
+ * @major: major number
+ *
+ * This function searches UBI device number object by its major number. If UBI
+ * device was not found, this function returns -ENODEV, otherwise the UBI device
+ * number is returned.
+ */
+int ubi_major2num(int major)
+{
+	int i, ubi_num = -ENODEV;
+
+	spin_lock(&ubi_devices_lock);
+	for (i = 0; i < UBI_MAX_DEVICES; i++) {
+		struct ubi_device *ubi = ubi_devices[i];

drivers/mtd/ubi/build.c line 222

Quoted 10 lines
drivers/mtd/ubi/build.c new file +10 -0
+
+		if (ubi && MAJOR(ubi->cdev.dev) == major) {
+			ubi_num = ubi->ubi_num;
+			break;
+		}
+	}
+	spin_unlock(&ubi_devices_lock);
+
+	return ubi_num;
+}

Hm... it does not make sense to me to pull in the whole Linux OS unfiltered.

Should we not try and restrict the code to the functions that are really needed and used in U-Boot?

We do not have any such stuff like major or minor device numbers here. And no permissions and al the othe rstuff.

drivers/mtd/ubi/build.c line 227

Quoted 4 lines
drivers/mtd/ubi/build.c new file +4 -0
+#if 0
+/* "Show" method for files in '/<sysfs>/class/ubi/ubiX/' */
+static ssize_t dev_attribute_show(struct device *dev,
+				  struct device_attribute *attr, char *buf)

Argh... Again tons of dead code.

I stop reviewing here. It makes no sense.

Can you pelase discuss with Stefan internally how to reduce the amount of code you are importing?

It definitely makes no sense to me to import the whole Linux OS here. If we think we want to run this code, then we should boot Linux instead :-(

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"A complex system that works is invariably found to have evolved from
a simple system that worked."             - John Gall, _Systemantics_
#2 lore raw

PATCH 1/1 Basic Unsorted Block Image (UBI) support (part 1)

Hi Wolfgang & Kyungmin,

Wolfgang, thanks for the internal discussion about this. I now know that you have no general concerns about the Linux "code cloning". But please find my original comments (written before the internal discussion) below.

Quoted 3 lines · Wolfgang Denk
Quoted 1 line

Now it can use UBI support on U-Boot

That's not really a good commit message, it seems.

Ack.

Quoted 9 lines

drivers/mtd/mtdcore.c line 2

Quoted 6 lines

index 0000000..a9f494a

drivers/mtd/mtdcore.c new file +2 -0
@@ -0,0 +1,142 @@
+/*
+ * $Id: mtdcore.c,v 1.47 2005/11/07 11:14:20 gleixner Exp $

Please do not include versioninformation in files. We use git for this.

That's directly imported from the Linux source. Most of your comments below also deal with this Linux code copying. I personally think it is a good idea to clone the code from Linux instead of writing a U-Boot specific UBI driver. We have done this before on other occasions and it makes perfect sense here too from my point of view. It makes porting easier and faster and less error prone and even more important, it makes porting of new versions, fixes etc easier.

Quoted 14 lines

drivers/mtd/mtdcore.c line 6

Quoted 3 lines
drivers/mtd/mtdcore.c new file +3 -0
+ * Core registration and callback routines for MTD
+ * drivers and users.
+ */

GPL header missing - here and in many other files.

drivers/mtd/mtdcore.c line 18

Quoted 5 lines
drivers/mtd/mtdcore.c new file +5 -0
+int add_mtd_device(struct mtd_info *mtd)
+{
+	int i;
+
+	BUG_ON(mtd->writesize == 0);

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Quoted 1 line

What's that?

It's handled in the UBI Linux->U-Boot porting "layer" (include/ubi_uboot.h):

#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))

Again this has been done before:

[stefan at kubuntu u-boot (master)]$ git grep BUG_ON include/ include/common.h:#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
include/linux/mtd/compat.h:#define BUG_ON(condition) do { if (condition) BUG(); } while(0)

Quoted 3 lines

drivers/mtd/mtdcore.c line 20

Quoted 1 line
drivers/mtd/mtdcore.c new file +1 -0
+	for (i=0; i < MAX_MTD_DEVICES; i++)

Need "{...}" for multi-line statements.

Again from the Linux original source. When we start changing this code because of coding-style issue, it will get very hard to compare those versions and add fixes in the future. So I vote for keeping the code as is. It's not that ugly, at least from my understanding.

Quoted 15 lines
Quoted 15 lines
drivers/mtd/mtdcore.c new file +15 -0
+		if (!mtd_table[i]) {
+			mtd_table[i] = mtd;
+			mtd->index = i;
+			mtd->usecount = 0;
+
+			printf("mtd: Giving out device %d to %s\n",i, mtd->name);
+			/* No need to get a refcount on the module containing
+			   the notifier, since we hold the mtd_table_mutex */
+
+			/* We _know_ we aren't being removed, because
+			   our caller is still holding us here. So none
+			   of this try_ nonsense, and no bitching about it
+			   either. :) */
+			return 0;
+		}
Quoted 8 lines

drivers/mtd/mtdcore.c line 40

Quoted 5 lines
drivers/mtd/mtdcore.c new file +5 -0
+
+	return 1;
+}
+
+/**

Please use plain "/*" as start of multiline comments. Here and everywhere.

Again I vote for not changing it.

Quoted 32 lines

drivers/mtd/mtdpart.c line 2

Quoted 8 lines
drivers/mtd/mtdpart.c new file +2 -0
new file mode 100644
index 0000000..113516a
@@ -0,0 +1,531 @@
+/*
+ * Simple MTD partitioning layer

Hm... We were talking about UBI support.

Do we really have to pull in the whole MTD layer from Linux for this?

I'm not exactly happy about this.

...

Quoted 12 lines
drivers/mtd/mtdpart.c new file +12 -0
+#if 0
+	if (unlikely(res)) {
+		if (res == -EUCLEAN)
+			mtd->ecc_stats.corrected++;
+		if (res == -EBADMSG)
+			mtd->ecc_stats.failed++;
+	}
+#endif
+	return res;
+}
+
+#if 0

...

Quoted 1 line

Please do not add dead code.

Here I'm not sure which version I prefer. The one Kyungmin used, disabling the not needed code via #if 0 (or something else, like #if UBI_LINUX), or completely removing it. Both has some advantages. But again for comparison with the original Linux source it's perhaps better to just disable the code. An "#if UBI_LINIX" is probably better than on "#if 0" though.

Quoted 82 lines
Quoted 39 lines

index 0000000..bf8a19f

drivers/mtd/ubi/build.c new file +17 -0
@@ -0,0 +1,1182 @@
+/*
+ * Copyright (c) International Business Machines Corp., 2006
+ * Copyright (c) Nokia Corporation, 2007
+ *
+ * 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 + *
+ * Author: Artem Bityutskiy (???????????????? ??????????),
+ * Frank Haverkamp
+ */

drivers/mtd/ubi/build.c new file +5 -0
+
+/*
+ * This file includes UBI initialization and building of UBI devices.
+ *
+ * When UBI is initialized, it attaches all the MTD devices specified as

the + * module load parameters or the kernel boot parameters. If MTD devices were + * specified, UBI does not attach any MTD device, but it is possible to do + * later using the "UBI control device".
+ *
+ * At the moment we only attach UBI devices by scanning, which will become a + * bottleneck when flashes reach certain large size. Then one may improve UBI + * and add other methods, although it does not seem to be easy to do. + */

drivers/mtd/ubi/build.c new file +1 -0
+

drivers/mtd/ubi/build.c line 45

Quoted 10 lines
drivers/mtd/ubi/build.c new file +10 -0
+#if 0
+#include <linux/err.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/stringify.h>
+#include <linux/stat.h>
+#include <linux/miscdevice.h>
+#include <linux/log2.h>
+#include <linux/kthread.h>
+#endif

Please do not add dead code - here and everywhere.

Quoted 16 lines
drivers/mtd/ubi/build.c new file +3 -0
+
+/**
+ * ubi_major2num - get UBI device number by character device major

number. + * @major: major number
+ *
+ * This function searches UBI device number object by its major number. If UBI + * device was not found, this function returns -ENODEV, otherwise the UBI device + * number is returned.
+ */

drivers/mtd/ubi/build.c new file +7 -0
+int ubi_major2num(int major)
+{
+	int i, ubi_num = -ENODEV;
+
+	spin_lock(&ubi_devices_lock);
+	for (i = 0; i < UBI_MAX_DEVICES; i++) {
+		struct ubi_device *ubi = ubi_devices[i];

drivers/mtd/ubi/build.c line 222

Quoted 10 lines
drivers/mtd/ubi/build.c new file +10 -0
+
+		if (ubi && MAJOR(ubi->cdev.dev) == major) {
+			ubi_num = ubi->ubi_num;
+			break;
+		}
+	}
+	spin_unlock(&ubi_devices_lock);
+
+	return ubi_num;
+}

Hm... it does not make sense to me to pull in the whole Linux OS unfiltered.

Quoted 5 lines

Should we not try and restrict the code to the functions that are really needed and used in U-Boot?

We do not have any such stuff like major or minor device numbers here. And no permissions and al the othe rstuff.

Of course we haven't. But it's hard to draw the line *if* you decide to include the Linux source. Most OS functions (like spin_lock()...) are defined to no-ops in ubi_uboot.h. So it doesn't really increase the code size for U-Boot. It just keeps the source in-line with the Linux version.

Quoted 9 lines

drivers/mtd/ubi/build.c line 227

Quoted 4 lines
drivers/mtd/ubi/build.c new file +4 -0
+#if 0
+/* "Show" method for files in '/<sysfs>/class/ubi/ubiX/' */
+static ssize_t dev_attribute_show(struct device *dev,
+				  struct device_attribute *attr, char *buf)

Argh... Again tons of dead code.

Quoted 4 lines

I stop reviewing here. It makes no sense.

Can you pelase discuss with Stefan internally how to reduce the amount of code you are importing?

Kyungmin, do you have any ideas on parts of this code that can be removed/dropped completely? Other than the "#if 0" parts?

Thanks.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================

#3 lore raw

PATCH 1/1 Basic Unsorted Block Image (UBI) support (part 1)

Dear Stefan Roese,

Quoted 8 lines · In message <[email protected]> you wrote:

That's directly imported from the Linux source. Most of your comments below also deal with this Linux code copying. I personally think it is a good idea to clone the code from Linux instead of writing a U-Boot specific UBI driver. We have done this before on other occasions and it makes perfect sense here too from my point of view. It makes porting easier and faster and less error prone and even more important, it makes porting of new versions, fixes etc easier.

We agree on that. So maybe we should send coding style cleanup patches for the Linux kenrel?

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

+ * Core registration and callback routines for MTD
+ * drivers and users.
+ */

GPL header missing - here and in many other files.

This *is* a serious issue. And I don;t care wether the code comes from Linux or not, but I will not accept any code without absolutley clear licensing conditions.

Quoted 6 lines
Quoted 1 line

Need "{...}" for multi-line statements.

Again from the Linux original source. When we start changing this code because of coding-style issue, it will get very hard to compare those versions and add fixes in the future. So I vote for keeping the code as is. It's not that ugly, at least from my understanding.

It is a clear violation of Linux Coding Style requirements.

If we don;t want to fix it here, I suggest to fixit at the origin, i.e. in Linux.

Quoted 8 lines
Quoted 8 lines

drivers/mtd/mtdpart.c line 2

Quoted 4 lines

+++ b/drivers/mtd/mtdpart.c

drivers/mtd/mtdpart.c new file +2 -0
@@ -0,0 +1,531 @@
+/*
+ * Simple MTD partitioning layer

Hm... We were talking about UBI support.

Do we really have to pull in the whole MTD layer from Linux for this?

...

Quoted 7 lines
Quoted 1 line

Please do not add dead code.

Here I'm not sure which version I prefer. The one Kyungmin used, disabling > the not needed code via #if 0 (or something else, like #if UBI_LINUX), or completely removing it. Both has some advantages. But again for comparison> with the original Linux source it's perhaps better to just disable the code> . An "#if UBI_LINIX" is probably better than on "#if 0" though.

There is two things I am concerned about:

1) Do we really need all these files?
2) Do we really need all of this code?

Lots of the code that was left in was obviously dealing with features we don;t have in U-Boot, and will not have: concepts like user IDs, file permissions, major and minor numbers, etc.

Quoted 4 lines

Of course we haven't. But it's hard to draw the line *if* you decide to include the Linux source. Most OS functions (like spin_lock()...) are defin> ed to no-ops in ubi_uboot.h. So it doesn't really increase the code size for U-Boot. It just keeps the source in-line with the Linux version.

On the other hand it makes it semi-impossible to review the code in U-Boot context, or even to get an understanding of flow of control etc.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Why should we subsidize intellectual curiosity?" - Ronald Reagan
#4 lore raw

PATCH 1/1 Basic Unsorted Block Image (UBI) support (part 1)

Dear Wolfgang and Stefan,

Quoted 12 lines · Wolfgang Denk

Dear Stefan Roese,

Quoted 8 lines · In message <[email protected]> you wrote:

That's directly imported from the Linux source. Most of your comments below also deal with this Linux code copying. I personally think it is a good idea to clone the code from Linux instead of writing a U-Boot specific UBI driver. We have done this before on other occasions and it makes perfect sense here too from my point of view. It makes porting easier and faster and less error prone and even more important, it makes porting of new versions, fixes etc easier.

Quoted 9 lines

We agree on that. So maybe we should send coding style cleanup patches for the Linux kenrel?

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

+ * Core registration and callback routines for MTD
+ * drivers and users.
+ */

GPL header missing - here and in many other files.

I added the GPL.

Quoted 24 lines

This *is* a serious issue. And I don;t care wether the code comes from Linux or not, but I will not accept any code without absolutley clear licensing conditions.

Quoted 6 lines
Quoted 1 line

Need "{...}" for multi-line statements.

Again from the Linux original source. When we start changing this code because of coding-style issue, it will get very hard to compare those versions and add fixes in the future. So I vote for keeping the code as is. It's not that ugly, at least from my understanding.

It is a clear violation of Linux Coding Style requirements.

If we don;t want to fix it here, I suggest to fixit at the origin, i.e. in Linux.

Quoted 7 lines
Quoted 7 lines

drivers/mtd/mtdpart.c line 2

Quoted 4 lines

+++ b/drivers/mtd/mtdpart.c

drivers/mtd/mtdpart.c new file +2 -0
@@ -0,0 +1,531 @@
+/*
+ * Simple MTD partitioning layer

Hm... We were talking about UBI support.

Quoted 4 lines
Quoted 1 line
Quoted 1 line

Do we really have to pull in the whole MTD layer from Linux for this?

...

Quoted 1 line
Quoted 1 line

Please do not add dead code.

It's needed. almost flash related code except the NOR, are based on MTD and uses.
Event though it's only compiled UBI command, it will be changed. Now partition codes use own implementation at u-boot, I think it's better MTD partition code.

Quoted 6 lines
Quoted 6 lines

Here I'm not sure which version I prefer. The one Kyungmin used, disabling > the not needed code via #if 0 (or something else, like #if UBI_LINUX), or completely removing it. Both has some advantages. But again for comparison> with the original Linux source it's perhaps better to just disable the code> . An "#if UBI_LINIX" is probably better than on "#if 0" though.

I change to use UBI_LINUX instead of if 0.

Quoted 10 lines

There is two things I am concerned about:

1) Do we really need all these files?
2) Do we really need all of this code?

Lots of the code that was left in was obviously dealing with features we don;t have in U-Boot, and will not have: concepts like user IDs, file permissions, major and minor numbers, etc.

Quoted 9 lines
Quoted 4 lines

Of course we haven't. But it's hard to draw the line *if* you decide to include the Linux source. Most OS functions (like spin_lock()...) are defin> ed to no-ops in ubi_uboot.h. So it doesn't really increase the code size for U-Boot. It just keeps the source in-line with the Linux version.

On the other hand it makes it semi-impossible to review the code in U-Boot context, or even to get an understanding of flow of control etc.

Basically I think if we use the imported code. we don't modify code itself. Instead we give some adaptation layer or wrapper. In this case I use the latter. ubi_uboot.h wrapped the UBI kernel code and can run it on u-boot. Of course it disables the some linux specific kernel if can't wrap.

Meanwhile who is the main users of this modules? It's linux kernel. It means users can familiar with kernel UBI code and they can use it more easily. They don't need to understand the UBI code at u-boot.

Thank you,
Kyungmin Park