aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/kapi.c
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2014-11-24 16:30:09 -0500
committerRichard Weinberger <richard@nod.at>2015-01-28 09:57:04 -0500
commitfafdd2bf2638157670f28462b641150d16dbaeca (patch)
tree717b6e07e8018eec9e6ac3e5ead6dedffbf4799c /drivers/mtd/ubi/kapi.c
parent346be9bc802ddbaf7ce2ad35145d1ddfba376594 (diff)
UBI: Implement UBI_METAONLY
UBI_METAONLY is a new open mode for UBI volumes, it indicates that only meta data is being changed. Meta data in terms of UBI volumes means data which is stored in the UBI volume table but not on the volume itself. While it does not interfere with UBI_READONLY and UBI_READWRITE it is not allowed to use UBI_METAONLY together with UBI_EXCLUSIVE. Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Cc: Andrew Murray <amurray@embedded-bits.co.uk> Signed-off-by: Richard Weinberger <richard@nod.at> Tested-by: Guido Martínez <guido@vanguardiasur.com.ar> Reviewed-by: Guido Martínez <guido@vanguardiasur.com.ar> Tested-by: Christoph Fritz <chf.fritz@googlemail.com> Tested-by: Andrew Murray <amurray@embedded-bits.co.uk>
Diffstat (limited to 'drivers/mtd/ubi/kapi.c')
-rw-r--r--drivers/mtd/ubi/kapi.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index f3bab669f6bb..589c423fac2d 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -137,7 +137,7 @@ struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode)
137 return ERR_PTR(-EINVAL); 137 return ERR_PTR(-EINVAL);
138 138
139 if (mode != UBI_READONLY && mode != UBI_READWRITE && 139 if (mode != UBI_READONLY && mode != UBI_READWRITE &&
140 mode != UBI_EXCLUSIVE) 140 mode != UBI_EXCLUSIVE && mode != UBI_METAONLY)
141 return ERR_PTR(-EINVAL); 141 return ERR_PTR(-EINVAL);
142 142
143 /* 143 /*
@@ -182,10 +182,17 @@ struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode)
182 break; 182 break;
183 183
184 case UBI_EXCLUSIVE: 184 case UBI_EXCLUSIVE:
185 if (vol->exclusive || vol->writers || vol->readers) 185 if (vol->exclusive || vol->writers || vol->readers ||
186 vol->metaonly)
186 goto out_unlock; 187 goto out_unlock;
187 vol->exclusive = 1; 188 vol->exclusive = 1;
188 break; 189 break;
190
191 case UBI_METAONLY:
192 if (vol->metaonly || vol->exclusive)
193 goto out_unlock;
194 vol->metaonly = 1;
195 break;
189 } 196 }
190 get_device(&vol->dev); 197 get_device(&vol->dev);
191 vol->ref_count += 1; 198 vol->ref_count += 1;
@@ -343,6 +350,10 @@ void ubi_close_volume(struct ubi_volume_desc *desc)
343 break; 350 break;
344 case UBI_EXCLUSIVE: 351 case UBI_EXCLUSIVE:
345 vol->exclusive = 0; 352 vol->exclusive = 0;
353 break;
354 case UBI_METAONLY:
355 vol->metaonly = 0;
356 break;
346 } 357 }
347 vol->ref_count -= 1; 358 vol->ref_count -= 1;
348 spin_unlock(&ubi->volumes_lock); 359 spin_unlock(&ubi->volumes_lock);