/* This helper function allocates and initializes UBIFS write-buffers. Returns zero in case of success and %-ENOMEM in case of failure.  */
static int alloc_wbufs(struct ubifs_info *c)
/* This helper function allocates and initializes UBIFS write-buffers. Returns zero in case of success and %-ENOMEM in case of failure.  */
static int alloc_wbufs(struct ubifs_info *c)
{
	int i, err;
	c->jheads = kcalloc(c->jhead_cnt, sizeof(struct ubifs_jhead),
			    GFP_KERNEL);
	if (!c->jheads)
		return -ENOMEM;
	for (i = 0; i < c->jhead_cnt; i++) {
		INIT_LIST_HEAD(&c->jheads[i].buds_list);
		err = ubifs_wbuf_init(c, &c->jheads[i].wbuf);
		if (err)
			return err;
		c->jheads[i].wbuf.sync_callback = &bud_wbuf_callback;
		c->jheads[i].wbuf.jhead = i;
		c->jheads[i].grouped = 1;
	}
	c->jheads[GCHD].wbuf.no_timer = 1;
	c->jheads[GCHD].grouped = 0;
	return 0;
}