mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/4] param: dev_add_param_fixed: constify argument
@ 2014-02-28 10:24 Sascha Hauer
  2014-02-28 10:24 ` [PATCH 2/4] fs: ubifs: Fix unused function warning Sascha Hauer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-02-28 10:24 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 include/param.h | 2 +-
 lib/parameter.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/param.h b/include/param.h
index 7830f6f..e8458b5 100644
--- a/include/param.h
+++ b/include/param.h
@@ -54,7 +54,7 @@ struct param_d *dev_add_param_ip(struct device_d *dev, const char *name,
 		int (*get)(struct param_d *p, void *priv),
 		IPaddr_t *ip, void *priv);
 
-int dev_add_param_fixed(struct device_d *dev, char *name, char *value);
+int dev_add_param_fixed(struct device_d *dev, char *name, const char *value);
 
 void dev_remove_param(struct param_d *p);
 
diff --git a/lib/parameter.c b/lib/parameter.c
index c5c6426..de11819 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -184,7 +184,7 @@ int dev_add_param(struct device_d *dev, const char *name,
  * @param name	The name of the parameter
  * @param value	The value of the parameter
  */
-int dev_add_param_fixed(struct device_d *dev, char *name, char *value)
+int dev_add_param_fixed(struct device_d *dev, char *name, const char *value)
 {
 	struct param_d *param;
 	int ret;
-- 
1.8.5.3


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/4] fs: ubifs: Fix unused function warning
  2014-02-28 10:24 [PATCH 1/4] param: dev_add_param_fixed: constify argument Sascha Hauer
@ 2014-02-28 10:24 ` Sascha Hauer
  2014-02-28 10:24 ` [PATCH 3/4] mtd: ubi: rework logging Sascha Hauer
  2014-02-28 10:24 ` [PATCH 4/4] fs: ubifs: " Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-02-28 10:24 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/ubifs/ubifs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index e2f9593..44a9e97 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -49,11 +49,13 @@ struct z_stream_s ubifs_zlib_stream;
 
 /* compress.c */
 
+#ifdef CONFIG_ZLIB
 static int ubifs_deflate_decompress(const u8 *src, unsigned int slen, u8 *dst,
 		unsigned int *dlen)
 {
 	return deflate_decompress(&ubifs_zlib_stream, src, slen, dst, dlen);
 }
+#endif
 
 /* All UBIFS compressors */
 struct ubifs_compressor ubifs_compressors[UBIFS_COMPR_TYPES_CNT] = {
-- 
1.8.5.3


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/4] mtd: ubi: rework logging
  2014-02-28 10:24 [PATCH 1/4] param: dev_add_param_fixed: constify argument Sascha Hauer
  2014-02-28 10:24 ` [PATCH 2/4] fs: ubifs: Fix unused function warning Sascha Hauer
@ 2014-02-28 10:24 ` Sascha Hauer
  2014-02-28 10:24 ` [PATCH 4/4] fs: ubifs: " Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-02-28 10:24 UTC (permalink / raw)
  To: barebox

By default UBI is very verbose. Decrease the verbosity, turn
printf messages into ubi_ messages and add device parameters
for the values which are not printed anymore.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/ubi/build.c   | 30 +++++++++++++++++++++---------
 drivers/mtd/ubi/cdev.c    | 18 +++++++++---------
 drivers/mtd/ubi/fastmap.c |  4 ++--
 drivers/mtd/ubi/ubi.h     |  1 +
 4 files changed, 33 insertions(+), 20 deletions(-)

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 202b046..093f703 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -578,8 +578,8 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
 		ubi->fm_disabled = 1;
 	}
 
-	ubi_msg("default fastmap pool size: %d", ubi->fm_pool.max_size);
-	ubi_msg("default fastmap WL pool size: %d", ubi->fm_wl_pool.max_size);
+	ubi_debug("default fastmap pool size: %d", ubi->fm_pool.max_size);
+	ubi_debug("default fastmap WL pool size: %d", ubi->fm_wl_pool.max_size);
 #else
 	ubi->fm_disabled = 1;
 #endif
@@ -619,23 +619,35 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
 
 	ubi_msg("attached mtd%d (name \"%s\", size %llu MiB) to ubi%d",
 		mtd->index, mtd->name, ubi->flash_size >> 20, ubi_num);
-	ubi_msg("PEB size: %d bytes (%d KiB), LEB size: %d bytes",
+	ubi_debug("PEB size: %d bytes (%d KiB), LEB size: %d bytes",
 		ubi->peb_size, ubi->peb_size >> 10, ubi->leb_size);
-	ubi_msg("min./max. I/O unit sizes: %d/%d, sub-page size %d",
+	ubi_debug("min./max. I/O unit sizes: %d/%d, sub-page size %d",
 		ubi->min_io_size, ubi->max_write_size, ubi->hdrs_min_io_size);
-	ubi_msg("VID header offset: %d (aligned %d), data offset: %d",
+	ubi_debug("VID header offset: %d (aligned %d), data offset: %d",
 		ubi->vid_hdr_offset, ubi->vid_hdr_aloffset, ubi->leb_start);
-	ubi_msg("good PEBs: %d, bad PEBs: %d, corrupted PEBs: %d",
+	ubi_debug("good PEBs: %d, bad PEBs: %d, corrupted PEBs: %d",
 		ubi->good_peb_count, ubi->bad_peb_count, ubi->corr_peb_count);
-	ubi_msg("user volume: %d, internal volumes: %d, max. volumes count: %d",
+	ubi_debug("user volume: %d, internal volumes: %d, max. volumes count: %d",
 		ubi->vol_count - UBI_INT_VOL_COUNT, UBI_INT_VOL_COUNT,
 		ubi->vtbl_slots);
-	ubi_msg("max/mean erase counter: %d/%d, WL threshold: %d, image sequence number: %u",
+	ubi_debug("max/mean erase counter: %d/%d, WL threshold: %d, image sequence number: %u",
 		ubi->max_ec, ubi->mean_ec, CONFIG_MTD_UBI_WL_THRESHOLD,
 		ubi->image_seq);
-	ubi_msg("available PEBs: %d, total reserved PEBs: %d, PEBs reserved for bad PEB handling: %d",
+	ubi_debug("available PEBs: %d, total reserved PEBs: %d, PEBs reserved for bad PEB handling: %d",
 		ubi->avail_pebs, ubi->rsvd_pebs, ubi->beb_rsvd_pebs);
 
+	dev_add_param_int_ro(&ubi->dev, "peb_size", ubi->peb_size, "%d");
+	dev_add_param_int_ro(&ubi->dev, "leb_size", ubi->leb_size, "%d");
+	dev_add_param_int_ro(&ubi->dev, "vid_header_offset", ubi->vid_hdr_offset, "%d");
+	dev_add_param_int_ro(&ubi->dev, "min_io_size", ubi->min_io_size, "%d");
+	dev_add_param_int_ro(&ubi->dev, "sub_page_size", ubi->hdrs_min_io_size, "%d");
+	dev_add_param_int_ro(&ubi->dev, "good_peb_count", ubi->good_peb_count, "%d");
+	dev_add_param_int_ro(&ubi->dev, "bad_peb_count", ubi->bad_peb_count, "%d");
+	dev_add_param_int_ro(&ubi->dev, "max_erase_counter", ubi->max_ec, "%d");
+	dev_add_param_int_ro(&ubi->dev, "mean_erase_counter", ubi->mean_ec, "%d");
+	dev_add_param_int_ro(&ubi->dev, "available_pebs", ubi->avail_pebs, "%d");
+	dev_add_param_int_ro(&ubi->dev, "reserved_pebs", ubi->rsvd_pebs, "%d");
+
 	/*
 	 * The below lock makes sure we do not race with 'ubi_thread()' which
 	 * checks @ubi->thread_enabled. Otherwise we may fail to wake it up.
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 129f2e2..d64e6cf 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -25,7 +25,7 @@ static ssize_t ubi_volume_cdev_read(struct cdev *cdev, void *buf, size_t size,
 	loff_t offp = offset;
 	int usable_leb_size = vol->usable_leb_size;
 
-	debug("%s: %zd @ 0x%08llx\n", __func__, size, offset);
+	ubi_debug("%s: %zd @ 0x%08llx\n", __func__, size, offset);
 
 	len = size > usable_leb_size ? usable_leb_size : size;
 
@@ -38,7 +38,7 @@ static ssize_t ubi_volume_cdev_read(struct cdev *cdev, void *buf, size_t size,
 
 		err = ubi_eba_read_leb(ubi, vol, lnum, buf, off, len, 0);
 		if (err) {
-			printf("read err %x\n", err);
+			ubi_err("read error: %s\n", strerror(-err));
 			break;
 		}
 		off += len;
@@ -68,14 +68,14 @@ static ssize_t ubi_volume_cdev_write(struct cdev* cdev, const void *buf,
 	if (!priv->written) {
 		err = ubi_start_update(ubi, vol, vol->used_bytes);
 		if (err < 0) {
-			printf("Cannot start volume update\n");
+			ubi_err("Cannot start volume update\n");
 			return err;
 		}
 	}
 
 	err = ubi_more_update_data(ubi, vol, buf, size);
 	if (err < 0) {
-		printf("Couldnt or partially wrote data \n");
+		ubi_err("Couldnt or partially wrote data \n");
 		return err;
 	}
 
@@ -117,7 +117,7 @@ static int ubi_volume_cdev_close(struct cdev *cdev)
 			kfree(buf);
 
 			if (err < 0) {
-				printf("Couldnt or partially wrote data \n");
+				ubi_err("Couldnt or partially wrote data \n");
 				return err;
 			}
 		}
@@ -128,7 +128,7 @@ static int ubi_volume_cdev_close(struct cdev *cdev)
 
 		err = ubi_check_volume(ubi, vol->vol_id);
 		if (err < 0) {
-			printf("check failed: %s\n", strerror(err));
+			ubi_err("ubi volume check failed: %s\n", strerror(err));
 			return err;
 		}
 
@@ -179,7 +179,7 @@ int ubi_volume_cdev_add(struct ubi_device *ubi, struct ubi_volume *vol)
 	cdev->name = asprintf("ubi%d.%s", ubi->ubi_num, vol->name);
 	cdev->priv = priv;
 	cdev->size = vol->used_bytes;
-	printf("registering %s as /dev/%s\n", vol->name, cdev->name);
+	ubi_msg("registering %s as /dev/%s\n", vol->name, cdev->name);
 	ret = devfs_create(cdev);
 	if (ret) {
 		kfree(priv);
@@ -241,7 +241,7 @@ int ubi_cdev_add(struct ubi_device *ubi)
 	cdev->priv = ubi;
 	cdev->size = 0;
 
-	printf("registering /dev/%s\n", cdev->name);
+	ubi_msg("registering /dev/%s", cdev->name);
 	ret = devfs_create(cdev);
 	if (ret)
 		kfree(cdev->name);
@@ -253,7 +253,7 @@ void ubi_cdev_remove(struct ubi_device *ubi)
 {
 	struct cdev *cdev = &ubi->cdev;
 
-	printf("removing %s\n", cdev->name);
+	ubi_msg("removing %s", cdev->name);
 
 	devfs_remove(cdev);
 	kfree(cdev->name);
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index 1ba1571..de68c32 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -1054,8 +1054,8 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
 	ubi->fm_pool.max_size = ubi->fm->max_pool_size;
 	ubi->fm_wl_pool.max_size = ubi->fm->max_wl_pool_size;
 	ubi_msg("attached by fastmap");
-	ubi_msg("fastmap pool size: %d", ubi->fm_pool.max_size);
-	ubi_msg("fastmap WL pool size: %d", ubi->fm_wl_pool.max_size);
+	ubi_debug("fastmap pool size: %d", ubi->fm_pool.max_size);
+	ubi_debug("fastmap WL pool size: %d", ubi->fm_wl_pool.max_size);
 	ubi->fm_disabled = 0;
 
 	ubi_free_vid_hdr(ubi, vh);
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index aa2cf02..a3bb704 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -39,6 +39,7 @@
 /* UBI name used for character devices, sysfs, etc */
 #define UBI_NAME_STR "ubi"
 
+#define ubi_debug(fmt, ...) pr_debug("UBI: " fmt "\n", ##__VA_ARGS__)
 /* Normal UBI messages */
 #define ubi_msg(fmt, ...) pr_info("UBI: " fmt "\n", ##__VA_ARGS__)
 /* UBI warning messages */
-- 
1.8.5.3


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 4/4] fs: ubifs: rework logging
  2014-02-28 10:24 [PATCH 1/4] param: dev_add_param_fixed: constify argument Sascha Hauer
  2014-02-28 10:24 ` [PATCH 2/4] fs: ubifs: Fix unused function warning Sascha Hauer
  2014-02-28 10:24 ` [PATCH 3/4] mtd: ubi: rework logging Sascha Hauer
@ 2014-02-28 10:24 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-02-28 10:24 UTC (permalink / raw)
  To: barebox

By default UBIFS is very verbose. Decrease the verbosity, turn
printf messages into ubifs_ messages and add device parameters
for the values which are not printed anymore.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/ubifs/super.c | 30 +++++++++++++++++++++---------
 fs/ubifs/ubifs.c |  2 +-
 fs/ubifs/ubifs.h | 11 +++++------
 3 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index e8e2cbe..075b258 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -257,12 +257,12 @@ static int init_constants_early(struct ubifs_info *c)
 	}
 
 	if (c->di.ro_mode) {
-		ubifs_msg("read-only UBI device");
+		dbg_msg("read-only UBI device");
 		c->ro_media = 1;
 	}
 
 	if (c->vi.vol_type == UBI_STATIC_VOLUME) {
-		ubifs_msg("static UBI volume - read-only mode");
+		dbg_msg("static UBI volume - read-only mode");
 		c->ro_media = 1;
 	}
 
@@ -540,6 +540,7 @@ static int mount_ubifs(struct ubifs_info *c)
 	int err, mounted_read_only = ubifs_readonly(c);
 	long long x;
 	size_t sz;
+	char str[128];
 
 	err = init_constants_early(c);
 	if (err)
@@ -676,18 +677,19 @@ static int mount_ubifs(struct ubifs_info *c)
 	ubifs_msg("mounted UBI device %d, volume %d, name \"%s\"",
 		  c->vi.ubi_num, c->vi.vol_id, c->vi.name);
 	if (mounted_read_only)
-		ubifs_msg("mounted read-only");
+		dbg_msg("mounted read-only");
 	x = (long long)c->main_lebs * c->leb_size;
-	ubifs_msg("file system size:   %lld bytes (%lld KiB, %lld MiB, %d "
+	c->fs_size_mb = x >> 20;
+	dbg_msg("file system size:   %lld bytes (%lld KiB, %lld MiB, %d "
 		  "LEBs)", x, x >> 10, x >> 20, c->main_lebs);
 	x = (long long)c->log_lebs * c->leb_size + c->max_bud_bytes;
-	ubifs_msg("journal size:       %lld bytes (%lld KiB, %lld MiB, %d "
+	dbg_msg("journal size:       %lld bytes (%lld KiB, %lld MiB, %d "
 		  "LEBs)", x, x >> 10, x >> 20, c->log_lebs + c->max_bud_cnt);
-	ubifs_msg("media format:       w%d/r%d (latest is w%d/r%d)",
+	dbg_msg("media format:       w%d/r%d (latest is w%d/r%d)",
 		  c->fmt_version, c->ro_compat_version,
 		  UBIFS_FORMAT_VERSION, UBIFS_RO_COMPAT_VERSION);
-	ubifs_msg("default compressor: %s", ubifs_compr_name(c->default_compr));
-	ubifs_msg("reserved for root:  %llu bytes (%llu KiB)",
+	dbg_msg("default compressor: %s", ubifs_compr_name(c->default_compr));
+	dbg_msg("reserved for root:  %llu bytes (%llu KiB)",
 		c->report_rp_size, c->report_rp_size >> 10);
 
 	dbg_msg("compiled on:         " __DATE__ " at " __TIME__);
@@ -696,6 +698,14 @@ static int mount_ubifs(struct ubifs_info *c)
 		c->leb_size, c->leb_size >> 10);
 	dbg_msg("data journal heads:  %d",
 		c->jhead_cnt - NONDATA_JHEADS_CNT);
+
+	dev_add_param_int_ro(c->dev, "filesystem_size_mb", c->fs_size_mb, "%d");
+	dev_add_param_fixed(c->dev, "default_compressor", ubifs_compr_name(c->default_compr));
+	sprintf(str, "w%d/r%d", c->fmt_version, c->ro_compat_version);
+	dev_add_param_fixed(c->dev, "media_format", str);
+	sprintf(str, "w%d/r%d", UBIFS_FORMAT_VERSION, UBIFS_RO_COMPAT_VERSION);
+	dev_add_param_fixed(c->dev, "media_format_latest", str);
+
 	dbg_msg("UUID:                %02X%02X%02X%02X-%02X%02X"
 	       "-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
 	       c->uuid[0], c->uuid[1], c->uuid[2], c->uuid[3],
@@ -804,7 +814,7 @@ void ubifs_umount(struct ubifs_info *c)
 	ubifs_debugging_exit(c);
 }
 
-struct super_block *ubifs_get_super(struct ubi_volume_desc *ubi, int silent)
+struct super_block *ubifs_get_super(struct device_d *dev, struct ubi_volume_desc *ubi, int silent)
 {
 	struct super_block *sb;
 	struct ubifs_info *c;
@@ -814,6 +824,8 @@ struct super_block *ubifs_get_super(struct ubi_volume_desc *ubi, int silent)
 	sb = xzalloc(sizeof(*sb));
 	c = xzalloc(sizeof(struct ubifs_info));
 
+	c->dev = dev;
+
 	spin_lock_init(&c->cnt_lock);
 	spin_lock_init(&c->cs_lock);
 	spin_lock_init(&c->buds_lock);
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 44a9e97..35923a9 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -610,7 +610,7 @@ static int ubifs_probe(struct device_d *dev)
 		goto err_free;
 	}
 
-	priv->sb = ubifs_get_super(priv->ubi, 0);
+	priv->sb = ubifs_get_super(dev, priv->ubi, 0);
 	if (IS_ERR(priv->sb)) {
 		ret = PTR_ERR(priv->sb);
 		goto err;
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index fea1584..b4a9d76 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -470,12 +470,8 @@ static inline ino_t parent_ino(struct dentry *dentry)
 #define UBIFS_VERSION 1
 
 /* Normal UBIFS messages */
-#ifdef CONFIG_UBIFS_SILENCE_MSG
-#define ubifs_msg(fmt, ...)
-#else
 #define ubifs_msg(fmt, ...) \
-		pr_notice("UBIFS: " fmt "\n", ##__VA_ARGS__)
-#endif
+		pr_info("UBIFS: " fmt "\n", ##__VA_ARGS__)
 /* UBIFS error messages */
 #define ubifs_err(fmt, ...)                                                  \
 	pr_err("UBIFS error (pid %d): %s: " fmt "\n", 0, \
@@ -1824,6 +1820,9 @@ struct ubifs_info {
 	int always_chk_crc;
 	struct ubifs_mount_opts mount_opts;
 
+	unsigned int fs_size_mb;
+	struct device_d *dev;
+
 #ifdef CONFIG_UBIFS_FS_DEBUG
 	struct ubifs_debug_info *dbg;
 #endif
@@ -2140,7 +2139,7 @@ long ubifs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 #include "misc.h"
 #include "key.h"
 
-struct super_block *ubifs_get_super(struct ubi_volume_desc *ubi, int silent);
+struct super_block *ubifs_get_super(struct device_d *dev, struct ubi_volume_desc *ubi, int silent);
 void ubifs_umount(struct ubifs_info *);
 
 static inline int ubifs_readonly(struct ubifs_info *c)
-- 
1.8.5.3


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-02-28 10:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-28 10:24 [PATCH 1/4] param: dev_add_param_fixed: constify argument Sascha Hauer
2014-02-28 10:24 ` [PATCH 2/4] fs: ubifs: Fix unused function warning Sascha Hauer
2014-02-28 10:24 ` [PATCH 3/4] mtd: ubi: rework logging Sascha Hauer
2014-02-28 10:24 ` [PATCH 4/4] fs: ubifs: " Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox