Fix badblock checking

Replace flash_addr_t with flash_off_t and use it to address flash everywhere
This commit is contained in:
ahoka 2011-04-04 14:25:09 +00:00
parent 3d869de066
commit 6adb739d5e
7 changed files with 81 additions and 83 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: flash.c,v 1.2 2011/03/30 14:34:26 uebayasi Exp $ */ /* $NetBSD: flash.c,v 1.3 2011/04/04 14:25:09 ahoka Exp $ */
/*- /*-
* Copyright (c) 2011 Department of Software Engineering, * Copyright (c) 2011 Department of Software Engineering,
@ -37,7 +37,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: flash.c,v 1.2 2011/03/30 14:34:26 uebayasi Exp $"); __KERNEL_RCSID(0, "$NetBSD: flash.c,v 1.3 2011/04/04 14:25:09 ahoka Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/types.h> #include <sys/types.h>
@ -88,7 +88,7 @@ bool flash_shutdown(device_t dev, int how);
int flash_nsectors(struct buf *bp); int flash_nsectors(struct buf *bp);
int flash_sector(struct buf *bp); int flash_sector(struct buf *bp);
static inline off_t flash_get_part_offset(struct flash_softc *fl, static inline flash_off_t flash_get_part_offset(struct flash_softc *fl,
size_t poffset); size_t poffset);
int flash_match(device_t parent, cfdata_t match, void *aux); int flash_match(device_t parent, cfdata_t match, void *aux);
@ -405,7 +405,8 @@ flashioctl(dev_t dev, u_long command, void *data, int flags, struct lwp *l)
struct flash_softc *sc; struct flash_softc *sc;
int unit, err; int unit, err;
size_t retlen; size_t retlen;
flash_addr_t offset; flash_off_t offset;
bool bad;
unit = minor(dev); unit = minor(dev);
if ((sc = device_lookup_private(&flash_cd, unit)) == NULL) if ((sc = device_lookup_private(&flash_cd, unit)) == NULL)
@ -441,15 +442,11 @@ flashioctl(dev_t dev, u_long command, void *data, int flags, struct lwp *l)
*/ */
bbp = data; bbp = data;
err = flash_block_isbad(sc->sc_dev, bbp->bbp_addr); err = flash_block_isbad(sc->sc_dev, bbp->bbp_addr, &bad);
if (err == EIO) { if (err) {
bbp->bbp_isbad = true;
err = 0;
} else if (err) {
return err; return err;
} else {
bbp->bbp_isbad = false;
} }
bbp->bbp_isbad = bad;
break; break;
case FLASH_BLOCK_MARKBAD: case FLASH_BLOCK_MARKBAD:
@ -548,7 +545,7 @@ flash_get_device(dev_t dev)
return sc->sc_dev; return sc->sc_dev;
} }
static inline off_t static inline flash_off_t
flash_get_part_offset(struct flash_softc *fl, size_t poffset) flash_get_part_offset(struct flash_softc *fl, size_t poffset)
{ {
return fl->flash_if->partition.part_offset + poffset; return fl->flash_if->partition.part_offset + poffset;
@ -577,7 +574,7 @@ flash_erase(device_t self, struct flash_erase_instruction *ei)
int int
flash_read(device_t self, flash_read(device_t self,
off_t offset, size_t len, size_t *retlen, uint8_t *buf) flash_off_t offset, size_t len, size_t *retlen, uint8_t *buf)
{ {
struct flash_softc *sc = device_private(self); struct flash_softc *sc = device_private(self);
@ -593,7 +590,7 @@ flash_read(device_t self,
int int
flash_write(device_t self, flash_write(device_t self,
off_t offset, size_t len, size_t *retlen, const uint8_t *buf) flash_off_t offset, size_t len, size_t *retlen, const uint8_t *buf)
{ {
struct flash_softc *sc = device_private(self); struct flash_softc *sc = device_private(self);
@ -611,7 +608,7 @@ flash_write(device_t self,
} }
int int
flash_block_markbad(device_t self, uint64_t offset) flash_block_markbad(device_t self, flash_off_t offset)
{ {
struct flash_softc *sc = device_private(self); struct flash_softc *sc = device_private(self);
@ -629,7 +626,7 @@ flash_block_markbad(device_t self, uint64_t offset)
} }
int int
flash_block_isbad(device_t self, uint64_t offset) flash_block_isbad(device_t self, flash_off_t offset, bool *bad)
{ {
struct flash_softc *sc = device_private(self); struct flash_softc *sc = device_private(self);
@ -640,7 +637,7 @@ flash_block_isbad(device_t self, uint64_t offset)
sc->flash_if->partition.part_offset) sc->flash_if->partition.part_offset)
return EINVAL; return EINVAL;
return sc->flash_if->block_isbad(device_parent(self), offset); return sc->flash_if->block_isbad(device_parent(self), offset, bad);
} }
int int

View File

@ -1,4 +1,4 @@
/* $NetBSD: flash.h,v 1.2 2011/03/30 14:34:26 uebayasi Exp $ */ /* $NetBSD: flash.h,v 1.3 2011/04/04 14:25:09 ahoka Exp $ */
/*- /*-
* Copyright (c) 2011 Department of Software Engineering, * Copyright (c) 2011 Department of Software Engineering,
@ -73,8 +73,8 @@ device_t flash_get_device(dev_t);
* @state: the erase operation's result * @state: the erase operation's result
*/ */
struct flash_erase_instruction { struct flash_erase_instruction {
flash_addr_t ei_addr; flash_off_t ei_addr;
flash_addr_t ei_len; flash_off_t ei_len;
void (*ei_callback)(struct flash_erase_instruction *); void (*ei_callback)(struct flash_erase_instruction *);
u_long ei_priv; u_long ei_priv;
u_char ei_state; u_char ei_state;
@ -86,8 +86,8 @@ enum {
}; };
struct flash_partition { struct flash_partition {
flash_addr_t part_offset; flash_off_t part_offset;
flash_addr_t part_size; flash_off_t part_size;
int part_flags; int part_flags;
}; };
@ -107,10 +107,10 @@ struct flash_partition {
*/ */
struct flash_interface { struct flash_interface {
int (*erase)(device_t, struct flash_erase_instruction *); int (*erase)(device_t, struct flash_erase_instruction *);
int (*read)(device_t, off_t, size_t, size_t *, uint8_t *); int (*read)(device_t, flash_off_t, size_t, size_t *, uint8_t *);
int (*write)(device_t, off_t, size_t, size_t *, const uint8_t *); int (*write)(device_t, flash_off_t, size_t, size_t *, const uint8_t *);
int (*block_markbad)(device_t, uint64_t); int (*block_markbad)(device_t, flash_off_t);
int (*block_isbad)(device_t, uint64_t); int (*block_isbad)(device_t, flash_off_t, bool *);
int (*sync)(device_t); int (*sync)(device_t);
int (*submit)(device_t, struct buf *); int (*submit)(device_t, struct buf *);
@ -119,7 +119,7 @@ struct flash_interface {
struct flash_partition partition; struct flash_partition partition;
/* total size of mtd */ /* total size of mtd */
flash_addr_t size; flash_size_t size;
uint32_t page_size; uint32_t page_size;
uint32_t erasesize; uint32_t erasesize;
uint32_t writesize; uint32_t writesize;
@ -132,16 +132,16 @@ struct flash_interface {
*/ */
struct flash_cache { struct flash_cache {
size_t fc_len; size_t fc_len;
flash_addr_t fc_block; flash_off_t fc_block;
uint8_t *fc_data; uint8_t *fc_data;
}; };
/* flash operations should be used through these */ /* flash operations should be used through these */
int flash_erase(device_t, struct flash_erase_instruction *); int flash_erase(device_t, struct flash_erase_instruction *);
int flash_read(device_t, off_t, size_t, size_t *, uint8_t *); int flash_read(device_t, flash_off_t, size_t, size_t *, uint8_t *);
int flash_write(device_t, off_t, size_t, size_t *, const uint8_t *); int flash_write(device_t, flash_off_t, size_t, size_t *, const uint8_t *);
int flash_block_markbad(device_t, uint64_t); int flash_block_markbad(device_t, flash_off_t);
int flash_block_isbad(device_t, uint64_t); int flash_block_isbad(device_t, flash_off_t, bool *);
int flash_sync(device_t); int flash_sync(device_t);
/* /*

View File

@ -1,4 +1,4 @@
/* $NetBSD: nand.c,v 1.6 2011/03/27 13:33:04 ahoka Exp $ */ /* $NetBSD: nand.c,v 1.7 2011/04/04 14:25:10 ahoka Exp $ */
/*- /*-
* Copyright (c) 2010 Department of Software Engineering, * Copyright (c) 2010 Department of Software Engineering,
@ -34,7 +34,7 @@
/* Common driver for NAND chips implementing the ONFI 2.2 specification */ /* Common driver for NAND chips implementing the ONFI 2.2 specification */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nand.c,v 1.6 2011/03/27 13:33:04 ahoka Exp $"); __KERNEL_RCSID(0, "$NetBSD: nand.c,v 1.7 2011/04/04 14:25:10 ahoka Exp $");
#include "locators.h" #include "locators.h"
@ -615,7 +615,7 @@ nand_address_row(device_t self, size_t row)
{ {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
struct nand_chip *chip = &sc->sc_chip; struct nand_chip *chip = &sc->sc_chip;
off_t i; int i;
/* XXX TODO */ /* XXX TODO */
row >>= chip->nc_page_shift; row >>= chip->nc_page_shift;
@ -647,7 +647,7 @@ nand_check_wp(device_t self)
} }
static void static void
nand_prepare_read(device_t self, flash_addr_t row, flash_addr_t column) nand_prepare_read(device_t self, flash_off_t row, flash_off_t column)
{ {
nand_command(self, ONFI_READ); nand_command(self, ONFI_READ);
nand_address_column(self, row, column); nand_address_column(self, row, column);
@ -865,9 +865,9 @@ nand_markbad(device_t self, size_t offset)
{ {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
struct nand_chip *chip = &sc->sc_chip; struct nand_chip *chip = &sc->sc_chip;
flash_addr_t blockoffset, marker; flash_off_t blockoffset, marker;
#ifdef NAND_BBT #ifdef NAND_BBT
flash_addr_t block; flash_off_t block;
block = offset / chip->nc_block_size; block = offset / chip->nc_block_size;
@ -889,11 +889,11 @@ nand_markbad(device_t self, size_t offset)
} }
bool bool
nand_isfactorybad(device_t self, flash_addr_t offset) nand_isfactorybad(device_t self, flash_off_t offset)
{ {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
struct nand_chip *chip = &sc->sc_chip; struct nand_chip *chip = &sc->sc_chip;
flash_addr_t block, first_page, last_page, page; flash_off_t block, first_page, last_page, page;
int i; int i;
/* Check for factory bad blocks first /* Check for factory bad blocks first
@ -926,11 +926,11 @@ nand_isfactorybad(device_t self, flash_addr_t offset)
} }
bool bool
nand_iswornoutbad(device_t self, flash_addr_t offset) nand_iswornoutbad(device_t self, flash_off_t offset)
{ {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
struct nand_chip *chip = &sc->sc_chip; struct nand_chip *chip = &sc->sc_chip;
flash_addr_t block; flash_off_t block;
/* we inspect the first page of the block */ /* we inspect the first page of the block */
block = offset & chip->nc_block_mask; block = offset & chip->nc_block_mask;
@ -963,12 +963,12 @@ nand_iswornoutbad(device_t self, flash_addr_t offset)
} }
bool bool
nand_isbad(device_t self, flash_addr_t offset) nand_isbad(device_t self, flash_off_t offset)
{ {
#ifdef NAND_BBT #ifdef NAND_BBT
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
struct nand_chip *chip = &sc->sc_chip; struct nand_chip *chip = &sc->sc_chip;
flash_addr_t block; flash_off_t block;
block = offset / chip->nc_block_size; block = offset / chip->nc_block_size;
@ -1041,14 +1041,14 @@ nand_default_select(device_t self, bool enable)
* handle (page) unaligned write to nand * handle (page) unaligned write to nand
*/ */
static int static int
nand_flash_write_unaligned(device_t self, off_t offset, size_t len, nand_flash_write_unaligned(device_t self, flash_off_t offset, size_t len,
size_t *retlen, const uint8_t *buf) size_t *retlen, const uint8_t *buf)
{ {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
struct nand_chip *chip = &sc->sc_chip; struct nand_chip *chip = &sc->sc_chip;
flash_addr_t first, last, firstoff; flash_off_t first, last, firstoff;
const uint8_t *bufp; const uint8_t *bufp;
flash_addr_t addr; flash_off_t addr;
size_t left, count; size_t left, count;
int error, i; int error, i;
@ -1155,7 +1155,7 @@ nand_flash_write_unaligned(device_t self, off_t offset, size_t len,
} }
int int
nand_flash_write(device_t self, off_t offset, size_t len, size_t *retlen, nand_flash_write(device_t self, flash_off_t offset, size_t len, size_t *retlen,
const uint8_t *buf) const uint8_t *buf)
{ {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
@ -1287,7 +1287,7 @@ out:
} }
int int
nand_flash_read(device_t self, off_t offset, size_t len, size_t *retlen, nand_flash_read(device_t self, flash_off_t offset, size_t len, size_t *retlen,
uint8_t *buf) uint8_t *buf)
{ {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
@ -1354,7 +1354,7 @@ out:
} }
int int
nand_flash_isbad(device_t self, uint64_t ofs) nand_flash_isbad(device_t self, flash_off_t ofs, bool *isbad)
{ {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
struct nand_chip *chip = &sc->sc_chip; struct nand_chip *chip = &sc->sc_chip;
@ -1368,22 +1368,23 @@ nand_flash_isbad(device_t self, uint64_t ofs)
} }
if (ofs % chip->nc_block_size != 0) { if (ofs % chip->nc_block_size != 0) {
panic("offset (0x%jx) is not the multiple of block size (%ju)", DPRINTF(("offset (0x%jx) is not the multiple of block size "
(uintmax_t)ofs, (uintmax_t)chip->nc_block_size); "(%ju)",
(uintmax_t)ofs, (uintmax_t)chip->nc_block_size));
return EINVAL;
} }
mutex_enter(&sc->sc_device_lock); mutex_enter(&sc->sc_device_lock);
result = nand_isbad(self, ofs); result = nand_isbad(self, ofs);
mutex_exit(&sc->sc_device_lock); mutex_exit(&sc->sc_device_lock);
if (result) *isbad = result;
return 1;
else return 0;
return 0;
} }
int int
nand_flash_markbad(device_t self, uint64_t ofs) nand_flash_markbad(device_t self, flash_off_t ofs)
{ {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
struct nand_chip *chip = &sc->sc_chip; struct nand_chip *chip = &sc->sc_chip;
@ -1413,7 +1414,7 @@ nand_flash_erase(device_t self,
{ {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
struct nand_chip *chip = &sc->sc_chip; struct nand_chip *chip = &sc->sc_chip;
flash_addr_t addr; flash_off_t addr;
int error; int error;
if (ei->ei_addr < 0 || ei->ei_len < chip->nc_block_size) if (ei->ei_addr < 0 || ei->ei_len < chip->nc_block_size)

View File

@ -1,4 +1,4 @@
/* $NetBSD: nand.h,v 1.4 2011/03/27 13:33:04 ahoka Exp $ */ /* $NetBSD: nand.h,v 1.5 2011/04/04 14:25:10 ahoka Exp $ */
/*- /*-
* Copyright (c) 2010 Department of Software Engineering, * Copyright (c) 2010 Department of Software Engineering,
@ -401,7 +401,7 @@ nand_read_page(device_t self, size_t offset, uint8_t *data)
#if 0 #if 0
static inline bool static inline bool
nand_block_isbad(device_t self, off_t block) nand_block_isbad(device_t self, flash_off_t block)
{ {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
@ -455,10 +455,10 @@ nand_dump_data(const char *name, void *data, size_t len)
} }
/* flash interface implementation */ /* flash interface implementation */
int nand_flash_isbad(device_t, uint64_t); int nand_flash_isbad(device_t, flash_off_t, bool *);
int nand_flash_markbad(device_t, uint64_t); int nand_flash_markbad(device_t, flash_off_t);
int nand_flash_write(device_t, off_t, size_t, size_t *, const u_char *); int nand_flash_write(device_t, flash_off_t, size_t, size_t *, const u_char *);
int nand_flash_read(device_t, off_t, size_t, size_t *, uint8_t *); int nand_flash_read(device_t, flash_off_t, size_t, size_t *, uint8_t *);
int nand_flash_erase(device_t, struct flash_erase_instruction *); int nand_flash_erase(device_t, struct flash_erase_instruction *);
/* nand specific functions */ /* nand specific functions */
@ -469,9 +469,9 @@ void nand_sync_thread(void *);
int nand_sync_thread_start(device_t); int nand_sync_thread_start(device_t);
void nand_sync_thread_stop(device_t); void nand_sync_thread_stop(device_t);
bool nand_isfactorybad(device_t, flash_addr_t); bool nand_isfactorybad(device_t, flash_off_t);
bool nand_iswornoutbad(device_t, flash_addr_t); bool nand_iswornoutbad(device_t, flash_off_t);
bool nand_isbad(device_t, flash_addr_t); bool nand_isbad(device_t, flash_off_t);
void nand_markbad(device_t, size_t); void nand_markbad(device_t, size_t);
//int nand_read_page(device_t, size_t, uint8_t *); //int nand_read_page(device_t, size_t, uint8_t *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nand_bbt.c,v 1.1 2011/02/26 18:07:31 ahoka Exp $ */ /* $NetBSD: nand_bbt.c,v 1.2 2011/04/04 14:25:10 ahoka Exp $ */
/*- /*-
* Copyright (c) 2011 Department of Software Engineering, * Copyright (c) 2011 Department of Software Engineering,
@ -68,7 +68,7 @@ nand_bbt_scan(device_t self)
{ {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
struct nand_chip *chip = &sc->sc_chip; struct nand_chip *chip = &sc->sc_chip;
flash_addr_t i, blocks, addr; flash_off_t i, blocks, addr;
blocks = chip->nc_size / chip->nc_block_size; blocks = chip->nc_size / chip->nc_block_size;
@ -93,7 +93,7 @@ nand_bbt_update(device_t self)
} }
static bool static bool
nand_bbt_page_has_bbt(device_t self, flash_addr_t addr) { nand_bbt_page_has_bbt(device_t self, flash_off_t addr) {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
struct nand_chip *chip = &sc->sc_chip; struct nand_chip *chip = &sc->sc_chip;
uint8_t *oob = chip->nc_oob_cache; uint8_t *oob = chip->nc_oob_cache;
@ -110,7 +110,7 @@ nand_bbt_page_has_bbt(device_t self, flash_addr_t addr) {
} }
static bool static bool
nand_bbt_get_bbt_from_page(device_t self, flash_addr_t addr) nand_bbt_get_bbt_from_page(device_t self, flash_off_t addr)
{ {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
struct nand_chip *chip = &sc->sc_chip; struct nand_chip *chip = &sc->sc_chip;
@ -156,7 +156,7 @@ nand_bbt_load(device_t self)
{ {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
struct nand_chip *chip = &sc->sc_chip; struct nand_chip *chip = &sc->sc_chip;
flash_addr_t blockaddr; flash_off_t blockaddr;
int n; int n;
blockaddr = chip->nc_size - chip->nc_block_size; blockaddr = chip->nc_size - chip->nc_block_size;
@ -173,7 +173,7 @@ nand_bbt_load(device_t self)
} }
void void
nand_bbt_block_markbad(device_t self, flash_addr_t block) nand_bbt_block_markbad(device_t self, flash_off_t block)
{ {
if (nand_bbt_block_isbad(self, block)) { if (nand_bbt_block_isbad(self, block)) {
aprint_error_dev(self, aprint_error_dev(self,
@ -184,7 +184,7 @@ nand_bbt_block_markbad(device_t self, flash_addr_t block)
} }
void void
nand_bbt_block_markfactorybad(device_t self, flash_addr_t block) nand_bbt_block_markfactorybad(device_t self, flash_off_t block)
{ {
if (nand_bbt_block_isbad(self, block)) { if (nand_bbt_block_isbad(self, block)) {
aprint_error_dev(self, aprint_error_dev(self,
@ -195,7 +195,7 @@ nand_bbt_block_markfactorybad(device_t self, flash_addr_t block)
} }
void void
nand_bbt_block_mark(device_t self, flash_addr_t block, uint8_t marker) nand_bbt_block_mark(device_t self, flash_off_t block, uint8_t marker)
{ {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC
@ -215,7 +215,7 @@ nand_bbt_block_mark(device_t self, flash_addr_t block, uint8_t marker)
} }
bool bool
nand_bbt_block_isbad(device_t self, flash_addr_t block) nand_bbt_block_isbad(device_t self, flash_off_t block)
{ {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC

View File

@ -1,4 +1,4 @@
/* $NetBSD: nand_bbt.h,v 1.1 2011/02/26 18:07:31 ahoka Exp $ */ /* $NetBSD: nand_bbt.h,v 1.2 2011/04/04 14:25:10 ahoka Exp $ */
/*- /*-
* Copyright (c) 2010 Department of Software Engineering, * Copyright (c) 2010 Department of Software Engineering,
@ -50,9 +50,9 @@ void nand_bbt_detach(device_t);
void nand_bbt_scan(device_t); void nand_bbt_scan(device_t);
bool nand_bbt_update(device_t); bool nand_bbt_update(device_t);
bool nand_bbt_load(device_t); bool nand_bbt_load(device_t);
void nand_bbt_block_mark(device_t, flash_addr_t, uint8_t); void nand_bbt_block_mark(device_t, flash_off_t, uint8_t);
void nand_bbt_block_markbad(device_t, flash_addr_t); void nand_bbt_block_markbad(device_t, flash_off_t);
void nand_bbt_block_markfactorybad(device_t, flash_addr_t); void nand_bbt_block_markfactorybad(device_t, flash_off_t);
bool nand_bbt_block_isbad(device_t, flash_addr_t); bool nand_bbt_block_isbad(device_t, flash_off_t);
#endif #endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: nand_io.c,v 1.1 2011/02/26 18:07:31 ahoka Exp $ */ /* $NetBSD: nand_io.c,v 1.2 2011/04/04 14:25:10 ahoka Exp $ */
/*- /*-
* Copyright (c) 2011 Department of Software Engineering, * Copyright (c) 2011 Department of Software Engineering,
@ -72,7 +72,7 @@ nand_io_getblock(device_t self, struct buf *bp)
{ {
struct nand_softc *sc = device_private(self); struct nand_softc *sc = device_private(self);
struct nand_chip *chip = &sc->sc_chip; struct nand_chip *chip = &sc->sc_chip;
flash_addr_t block, last; flash_off_t block, last;
/* get block number of first byte */ /* get block number of first byte */
block = bp->b_rawblkno * DEV_BSIZE / chip->nc_block_size; block = bp->b_rawblkno * DEV_BSIZE / chip->nc_block_size;