Lines Matching refs:bch
47 struct bchlib_s *bch = (struct bchlib_s *)handle; in bchlib_write() local
64 sector = offset / bch->sectsize; in bchlib_write()
65 sectoffset = offset - sector * bch->sectsize; in bchlib_write()
67 if (sector >= bch->nsectors) in bchlib_write()
79 ret = bchlib_readsector(bch, sector + bch->sectstart); in bchlib_write()
87 if (sectoffset + len > bch->sectsize) in bchlib_write()
89 nbytes = bch->sectsize - sectoffset; in bchlib_write()
96 ret = LOS_CopyToKernel(&bch->buffer[sectoffset], nbytes, buffer, nbytes); in bchlib_write()
102 bch->dirty = true; in bchlib_write()
108 if (sector >= bch->nsectors) in bchlib_write()
122 if (len >= bch->sectsize) in bchlib_write()
124 nsectors = len / bch->sectsize; in bchlib_write()
125 if (sector + nsectors > bch->nsectors) in bchlib_write()
127 nsectors = bch->nsectors - sector; in bchlib_write()
132 ret = los_disk_write(bch->disk->disk_id, (const void *)buffer, in bchlib_write()
133 sector + bch->sectstart, nsectors); in bchlib_write()
143 nbytes = nsectors * bch->sectsize; in bchlib_write()
146 if (sector >= bch->nsectors) in bchlib_write()
161 ret = bchlib_readsector(bch, sector + bch->sectstart); in bchlib_write()
169 ret = LOS_CopyToKernel(bch->buffer, len, buffer, len); in bchlib_write()
175 bch->dirty = true; in bchlib_write()
184 ret = bchlib_flushsector(bch); in bchlib_write()