[PATCH 4/4] mtd: remove R/O checking duplication

Shmulik Ladkani shmulik.ladkani at gmail.com
Sun Feb 5 03:33:21 EST 2012


On Fri,  3 Feb 2012 19:01:31 +0200 Artem Bityutskiy <dedekind1 at gmail.com> wrote:
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index 13bd4fa..78e1df6 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -754,7 +756,7 @@ int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
>  	      const u_char *buf)
>  {
>  	*retlen = 0;
> -	if (!mtd->_write)
> +	if (!mtd->_write || !(mtd->flags & MTD_WRITEABLE))
>  		return -EROFS;
>  	if (to < 0 || to > mtd->size || len > mtd->size - to)
>  		return -EINVAL;

(sorry for nit-picking)

Here you perform "writable" (EROFS) validation prior offset/length
validation (EINVAL) - however in other API funtions you had it
vice-versa.
Really not that important, but better if handling is consistent.

Regards,
Shmulik



More information about the linux-mtd mailing list