Lines Matching full:bb
21 * @bb: the badblocks structure that holds all badblock information
53 int badblocks_check(struct badblocks *bb, sector_t s, int sectors, in badblocks_check() argument
58 u64 *p = bb->page; in badblocks_check()
63 if (bb->shift > 0) { in badblocks_check()
65 s >>= bb->shift; in badblocks_check()
66 target += (1<<bb->shift) - 1; in badblocks_check()
67 target >>= bb->shift; in badblocks_check()
73 seq = read_seqbegin(&bb->lock); in badblocks_check()
76 hi = bb->count; in badblocks_check()
121 if (read_seqretry(&bb->lock, seq)) in badblocks_check()
128 static void badblocks_update_acked(struct badblocks *bb) in badblocks_update_acked() argument
130 u64 *p = bb->page; in badblocks_update_acked()
134 if (!bb->unacked_exist) in badblocks_update_acked()
137 for (i = 0; i < bb->count ; i++) { in badblocks_update_acked()
145 bb->unacked_exist = 0; in badblocks_update_acked()
150 * @bb: the badblocks structure that holds all badblock information
163 int badblocks_set(struct badblocks *bb, sector_t s, int sectors, in badblocks_set() argument
171 if (bb->shift < 0) in badblocks_set()
175 if (bb->shift) { in badblocks_set()
179 s >>= bb->shift; in badblocks_set()
180 next += (1<<bb->shift) - 1; in badblocks_set()
181 next >>= bb->shift; in badblocks_set()
185 write_seqlock_irqsave(&bb->lock, flags); in badblocks_set()
187 p = bb->page; in badblocks_set()
189 hi = bb->count; in badblocks_set()
235 if (sectors && hi < bb->count) { in badblocks_set()
265 if (sectors == 0 && hi < bb->count) { in badblocks_set()
279 (bb->count - hi - 1) * 8); in badblocks_set()
280 bb->count--; in badblocks_set()
287 if (bb->count >= MAX_BADBLOCKS) { in badblocks_set()
295 (bb->count - hi) * 8); in badblocks_set()
296 bb->count++; in badblocks_set()
306 bb->changed = 1; in badblocks_set()
308 bb->unacked_exist = 1; in badblocks_set()
310 badblocks_update_acked(bb); in badblocks_set()
311 write_sequnlock_irqrestore(&bb->lock, flags); in badblocks_set()
319 * @bb: the badblocks structure that holds all badblock information
331 int badblocks_clear(struct badblocks *bb, sector_t s, int sectors) in badblocks_clear() argument
338 if (bb->shift > 0) { in badblocks_clear()
345 s += (1<<bb->shift) - 1; in badblocks_clear()
346 s >>= bb->shift; in badblocks_clear()
347 target >>= bb->shift; in badblocks_clear()
351 write_seqlock_irq(&bb->lock); in badblocks_clear()
353 p = bb->page; in badblocks_clear()
355 hi = bb->count; in badblocks_clear()
380 if (bb->count >= MAX_BADBLOCKS) { in badblocks_clear()
384 memmove(p+lo+1, p+lo, (bb->count - lo) * 8); in badblocks_clear()
385 bb->count++; in badblocks_clear()
413 memmove(p+lo+1, p+hi, (bb->count - hi) * 8); in badblocks_clear()
414 bb->count -= (hi - lo - 1); in badblocks_clear()
418 badblocks_update_acked(bb); in badblocks_clear()
419 bb->changed = 1; in badblocks_clear()
421 write_sequnlock_irq(&bb->lock); in badblocks_clear()
428 * @bb: the badblocks structure that holds all badblock information
433 void ack_all_badblocks(struct badblocks *bb) in ack_all_badblocks() argument
435 if (bb->page == NULL || bb->changed) in ack_all_badblocks()
438 write_seqlock_irq(&bb->lock); in ack_all_badblocks()
440 if (bb->changed == 0 && bb->unacked_exist) { in ack_all_badblocks()
441 u64 *p = bb->page; in ack_all_badblocks()
444 for (i = 0; i < bb->count ; i++) { in ack_all_badblocks()
452 bb->unacked_exist = 0; in ack_all_badblocks()
454 write_sequnlock_irq(&bb->lock); in ack_all_badblocks()
460 * @bb: the badblocks structure that holds all badblock information
467 ssize_t badblocks_show(struct badblocks *bb, char *page, int unack) in badblocks_show() argument
471 u64 *p = bb->page; in badblocks_show()
474 if (bb->shift < 0) in badblocks_show()
478 seq = read_seqbegin(&bb->lock); in badblocks_show()
483 while (len < PAGE_SIZE && i < bb->count) { in badblocks_show()
494 (unsigned long long)s << bb->shift, in badblocks_show()
495 length << bb->shift); in badblocks_show()
498 bb->unacked_exist = 0; in badblocks_show()
500 if (read_seqretry(&bb->lock, seq)) in badblocks_show()
509 * @bb: the badblocks structure that holds all badblock information
517 ssize_t badblocks_store(struct badblocks *bb, const char *page, size_t len, in badblocks_store() argument
537 if (badblocks_set(bb, sector, length, !unack)) in badblocks_store()
544 static int __badblocks_init(struct device *dev, struct badblocks *bb, in __badblocks_init() argument
547 bb->dev = dev; in __badblocks_init()
548 bb->count = 0; in __badblocks_init()
550 bb->shift = 0; in __badblocks_init()
552 bb->shift = -1; in __badblocks_init()
554 bb->page = devm_kzalloc(dev, PAGE_SIZE, GFP_KERNEL); in __badblocks_init()
556 bb->page = kzalloc(PAGE_SIZE, GFP_KERNEL); in __badblocks_init()
557 if (!bb->page) { in __badblocks_init()
558 bb->shift = -1; in __badblocks_init()
561 seqlock_init(&bb->lock); in __badblocks_init()
568 * @bb: the badblocks structure that holds all badblock information
575 int badblocks_init(struct badblocks *bb, int enable) in badblocks_init() argument
577 return __badblocks_init(NULL, bb, enable); in badblocks_init()
581 int devm_init_badblocks(struct device *dev, struct badblocks *bb) in devm_init_badblocks() argument
583 if (!bb) in devm_init_badblocks()
585 return __badblocks_init(dev, bb, 1); in devm_init_badblocks()
591 * @bb: the badblocks structure that holds all badblock information
593 void badblocks_exit(struct badblocks *bb) in badblocks_exit() argument
595 if (!bb) in badblocks_exit()
597 if (bb->dev) in badblocks_exit()
598 devm_kfree(bb->dev, bb->page); in badblocks_exit()
600 kfree(bb->page); in badblocks_exit()
601 bb->page = NULL; in badblocks_exit()