Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a1c06609 authored by Joe Perches's avatar Joe Perches Committed by David Woodhouse
Browse files

mtd: Convert logging messages



Use a more current logging style.

Convert homegrown ERROR/INFO macros to pr_<level>.
Convert homegrown parse_err macros to pr_err and
expand hidden flow control.

Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 4b6ff7af
Loading
Loading
Loading
Loading
+31 −27
Original line number Original line Diff line number Diff line
@@ -6,6 +6,9 @@
 *
 *
 * Licence: GPL
 * Licence: GPL
 */
 */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/module.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/fs.h>
#include <linux/blkdev.h>
#include <linux/blkdev.h>
@@ -18,10 +21,6 @@
#include <linux/mount.h>
#include <linux/mount.h>
#include <linux/slab.h>
#include <linux/slab.h>


#define ERROR(fmt, args...) printk(KERN_ERR "block2mtd: " fmt "\n" , ## args)
#define INFO(fmt, args...) printk(KERN_INFO "block2mtd: " fmt "\n" , ## args)


/* Info for the block device */
/* Info for the block device */
struct block2mtd_dev {
struct block2mtd_dev {
	struct list_head list;
	struct list_head list;
@@ -84,7 +83,7 @@ static int block2mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
	err = _block2mtd_erase(dev, from, len);
	err = _block2mtd_erase(dev, from, len);
	mutex_unlock(&dev->write_mutex);
	mutex_unlock(&dev->write_mutex);
	if (err) {
	if (err) {
		ERROR("erase failed err = %d", err);
		pr_err("erase failed err = %d\n", err);
		instr->state = MTD_ERASE_FAILED;
		instr->state = MTD_ERASE_FAILED;
	} else
	} else
		instr->state = MTD_ERASE_DONE;
		instr->state = MTD_ERASE_DONE;
@@ -239,13 +238,13 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
#endif
#endif


	if (IS_ERR(bdev)) {
	if (IS_ERR(bdev)) {
		ERROR("error: cannot open device %s", devname);
		pr_err("error: cannot open device %s\n", devname);
		goto devinit_err;
		goto devinit_err;
	}
	}
	dev->blkdev = bdev;
	dev->blkdev = bdev;


	if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) {
	if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) {
		ERROR("attempting to use an MTD device as a block device");
		pr_err("attempting to use an MTD device as a block device\n");
		goto devinit_err;
		goto devinit_err;
	}
	}


@@ -277,7 +276,8 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
		goto devinit_err;
		goto devinit_err;
	}
	}
	list_add(&dev->list, &blkmtd_device_list);
	list_add(&dev->list, &blkmtd_device_list);
	INFO("mtd%d: [%s] erase_size = %dKiB [%d]", dev->mtd.index,
	pr_info("mtd%d: [%s] erase_size = %dKiB [%d]\n",
		dev->mtd.index,
		dev->mtd.name + strlen("block2mtd: "),
		dev->mtd.name + strlen("block2mtd: "),
		dev->mtd.erasesize >> 10, dev->mtd.erasesize);
		dev->mtd.erasesize >> 10, dev->mtd.erasesize);
	return dev;
	return dev;
@@ -339,17 +339,11 @@ static inline void kill_final_newline(char *str)
}
}




#define parse_err(fmt, args...) do {	\
	ERROR(fmt, ## args);		\
	return 0;			\
} while (0)

#ifndef MODULE
#ifndef MODULE
static int block2mtd_init_called = 0;
static int block2mtd_init_called = 0;
static char block2mtd_paramline[80 + 12]; /* 80 for device, 12 for erase size */
static char block2mtd_paramline[80 + 12]; /* 80 for device, 12 for erase size */
#endif
#endif



static int block2mtd_setup2(const char *val)
static int block2mtd_setup2(const char *val)
{
{
	char buf[80 + 12]; /* 80 for device, 12 for erase size */
	char buf[80 + 12]; /* 80 for device, 12 for erase size */
@@ -359,8 +353,10 @@ static int block2mtd_setup2(const char *val)
	size_t erase_size = PAGE_SIZE;
	size_t erase_size = PAGE_SIZE;
	int i, ret;
	int i, ret;


	if (strnlen(val, sizeof(buf)) >= sizeof(buf))
	if (strnlen(val, sizeof(buf)) >= sizeof(buf)) {
		parse_err("parameter too long");
		pr_err("parameter too long\n");
		return 0;
	}


	strcpy(str, val);
	strcpy(str, val);
	kill_final_newline(str);
	kill_final_newline(str);
@@ -368,20 +364,27 @@ static int block2mtd_setup2(const char *val)
	for (i = 0; i < 2; i++)
	for (i = 0; i < 2; i++)
		token[i] = strsep(&str, ",");
		token[i] = strsep(&str, ",");


	if (str)
	if (str) {
		parse_err("too many arguments");
		pr_err("too many arguments\n");
		return 0;
	}


	if (!token[0])
	if (!token[0]) {
		parse_err("no argument");
		pr_err("no argument\n");
		return 0;
	}


	name = token[0];
	name = token[0];
	if (strlen(name) + 1 > 80)
	if (strlen(name) + 1 > 80) {
		parse_err("device name too long");
		pr_err("device name too long\n");
		return 0;
	}


	if (token[1]) {
	if (token[1]) {
		ret = parse_num(&erase_size, token[1]);
		ret = parse_num(&erase_size, token[1]);
		if (ret) {
		if (ret) {
			parse_err("illegal erase size");
			pr_err("illegal erase size\n");
			return 0;
		}
		}
	}
	}


@@ -444,7 +447,8 @@ static void block2mtd_exit(void)
		struct block2mtd_dev *dev = list_entry(pos, typeof(*dev), list);
		struct block2mtd_dev *dev = list_entry(pos, typeof(*dev), list);
		block2mtd_sync(&dev->mtd);
		block2mtd_sync(&dev->mtd);
		mtd_device_unregister(&dev->mtd);
		mtd_device_unregister(&dev->mtd);
		INFO("mtd%d: [%s] removed", dev->mtd.index,
		pr_info("mtd%d: [%s] removed\n",
			dev->mtd.index,
			dev->mtd.name + strlen("block2mtd: "));
			dev->mtd.name + strlen("block2mtd: "));
		list_del(&dev->list);
		list_del(&dev->list);
		block2mtd_free_device(dev);
		block2mtd_free_device(dev);