https://github.com/torvalds/linux
Revision 6f5a0f7c955d3567f800fa36f978758cb5b99aa2 authored by mikem on 18 November 2005, 21:05:36 UTC, committed by Jens Axboe on 18 November 2005, 21:05:36 UTC
Jeff Garzik pointed me to his code to see how to remove a disk from
the system _properly_. Well, here it is...
Every place we remove disks we are now testing before calling del_gendisk
or blk_cleanup_queue and then call put_disk.

Signed-off-by: Mike Miller <mike.miller@hp.com>
Signed-off-by: Jens Axboe <axboe@suse.de>
1 parent 15534d3
Raw File
Tip revision: 6f5a0f7c955d3567f800fa36f978758cb5b99aa2 authored by mikem on 18 November 2005, 21:05:36 UTC
[PATCH 3/3] cciss: add put_disk into cleanup routines
Tip revision: 6f5a0f7
find_next_bit.c
/* find_next_bit.c: fallback find next bit implementation
 *
 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
 * Written by David Howells (dhowells@redhat.com)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 */

#include <linux/bitops.h>

int find_next_bit(const unsigned long *addr, int size, int offset)
{
	const unsigned long *base;
	const int NBITS = sizeof(*addr) * 8;
	unsigned long tmp;

	base = addr;
	if (offset) {
		int suboffset;

		addr += offset / NBITS;

		suboffset = offset % NBITS;
		if (suboffset) {
			tmp = *addr;
			tmp >>= suboffset;
			if (tmp)
				goto finish;
		}

		addr++;
	}

	while ((tmp = *addr) == 0)
		addr++;

	offset = (addr - base) * NBITS;

 finish:
	/* count the remaining bits without using __ffs() since that takes a 32-bit arg */
	while (!(tmp & 0xff)) {
		offset += 8;
		tmp >>= 8;
	}

	while (!(tmp & 1)) {
		offset++;
		tmp >>= 1;
	}

	return offset;
}
back to top