Re: [PATCH 05/44 take 2] [UBI] internal common header

Christoph Hellwig
2007-02-19T10:54:47Z

On Sat, Feb 17, 2007 at 06:54:49PM +0200, Artem Bityutskiy wrote:
> +#ifndef __UBI_UBI_H__
> +#define __UBI_UBI_H__
> +
> +#include <linux/mtd/ubi.h>
> +
> +/* Version of this UBI implementation */
> +#define UBI_VERSION 1

We shouldn't have versions for inkernel interfaces.

> +/* UBI messages printk level */
> +#define UBI_MSG_LEVEL KERN_INFO
> +#define UBI_WARN_LEVEL KERN_WARNING
> +#define UBI_ERR_LEVEL KERN_ERR

Please use the KERN_ macros directly.

> +/* Normal UBI messages */
> +#define ubi_msg(fmt, ...) \
> + printk(UBI_MSG_LEVEL UBI_MSG_PREF " " fmt "\n", ##__VA_ARGS__)
> +/* UBI warning messages */
> +#define ubi_warn(fmt, ...) \
> + printk(UBI_WARN_LEVEL UBI_WARN_PREF " %s: " fmt "\n", __FUNCTION__, \
> + ##__VA_ARGS__)
> +/* UBI error messages */
> +#define ubi_err(fmt, ...) \
> + printk(UBI_ERR_LEVEL UBI_ERR_PREF " %s " fmt "\n", __FUNCTION__, \
> + ##__VA_ARGS__)

you should probably use dev_printk and the wrappers around it in most
places.

> +extern int ubis_num;
> +extern struct ubi_info *ubis[UBI_MAX_INSTANCES];

Having this kind of global information directly exposed is a very
bad idea. In general you only want to access it through more
specific information and avoid allocating the global array at all.