UPSTREAM: mtd: Add a function to report when the MTD dev list has been updated
We need to parse mtdparts/mtids again everytime a device has been added/removed from the MTD list, but there's currently no way to know when such an update has been done. Add an ->updated field to the idr struct that we set to true every time a device is added/removed and expose a function returning the value of this field and resetting it to false. Change-Id: If7edb8fde01051087b43eb16683aca6b991daace Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Tested-by: Heiko Schocher <hs@denx.de> Signed-off-by: Jon Lin <jon.lin@rock-chips.com> (cherry picked from commit 4c47fd0b6bce62162e11b8a22e2eaf0d8f6673b1)
This commit is contained in:
parent
ce9c7df5f5
commit
90108c6c51
|
|
@ -88,14 +88,17 @@ struct idr_layer {
|
|||
|
||||
struct idr {
|
||||
struct idr_layer id[MAX_IDR_ID];
|
||||
bool updated;
|
||||
};
|
||||
|
||||
#define DEFINE_IDR(name) struct idr name;
|
||||
|
||||
void idr_remove(struct idr *idp, int id)
|
||||
{
|
||||
if (idp->id[id].used)
|
||||
if (idp->id[id].used) {
|
||||
idp->id[id].used = 0;
|
||||
idp->updated = true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -135,6 +138,7 @@ int idr_alloc(struct idr *idp, void *ptr, int start, int end, gfp_t gfp_mask)
|
|||
if (idl->used == 0) {
|
||||
idl->used = 1;
|
||||
idl->ptr = ptr;
|
||||
idp->updated = true;
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
|
|
@ -156,6 +160,16 @@ struct mtd_info *__mtd_next_device(int i)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(__mtd_next_device);
|
||||
|
||||
bool mtd_dev_list_updated(void)
|
||||
{
|
||||
if (mtd_idr.updated) {
|
||||
mtd_idr.updated = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifndef __UBOOT__
|
||||
static LIST_HEAD(mtd_notifiers);
|
||||
|
||||
|
|
|
|||
|
|
@ -610,6 +610,7 @@ int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off,
|
|||
void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,
|
||||
const uint64_t length, uint64_t *len_incl_bad,
|
||||
int *truncated);
|
||||
bool mtd_dev_list_updated(void);
|
||||
|
||||
/* drivers/mtd/mtd_uboot.c */
|
||||
int mtd_search_alternate_name(const char *mtdname, char *altname,
|
||||
|
|
|
|||
Loading…
Reference in New Issue