Misc cleanup from OpenBSD/luna88k.
- remove unused code - use proper prefix for structure members for readability
This commit is contained in:
parent
6e605f060f
commit
7f7c7f9b34
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: autoconf.c,v 1.8 2014/01/03 02:03:12 tsutsui Exp $ */
|
||||
/* $NetBSD: autoconf.c,v 1.9 2014/01/03 03:25:25 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 OMRON Corporation.
|
||||
|
@ -195,10 +195,7 @@ find_controller(struct hp_hw *hw)
|
|||
hc->hp_alive = 1;
|
||||
printf("%s%d", hc->hp_driver->d_name, hc->hp_unit);
|
||||
printf(" at %p,", hc->hp_addr);
|
||||
printf(" ipl %d", hc->hp_ipl);
|
||||
if (hc->hp_flags)
|
||||
printf(" flags 0x%x", hc->hp_flags);
|
||||
printf("\n");
|
||||
printf(" ipl %d\n", hc->hp_ipl);
|
||||
find_slaves(hc);
|
||||
} else
|
||||
hc->hp_addr = oaddr;
|
||||
|
@ -218,13 +215,13 @@ find_device(struct hp_hw *hw)
|
|||
hw->hw_name, hw->hw_sc, (u_int)hw->hw_addr, hw->hw_type);
|
||||
#endif
|
||||
match_d = NULL;
|
||||
for (hd = hp_dinit; hd->hp_driver; hd++) {
|
||||
if (hd->hp_alive)
|
||||
for (hd = hp_dinit; hd->hpd_driver; hd++) {
|
||||
if (hd->hpd_alive)
|
||||
continue;
|
||||
/* Must not be a slave */
|
||||
if (hd->hp_cdriver)
|
||||
if (hd->hpd_cdriver)
|
||||
continue;
|
||||
addr = hd->hp_addr;
|
||||
addr = hd->hpd_addr;
|
||||
/*
|
||||
* Exact match; all done.
|
||||
*/
|
||||
|
@ -243,8 +240,8 @@ find_device(struct hp_hw *hw)
|
|||
if (acdebug) {
|
||||
if (match_d)
|
||||
printf("found %s%d\n",
|
||||
match_d->hp_driver->d_name,
|
||||
match_d->hp_unit);
|
||||
match_d->hpd_driver->d_name,
|
||||
match_d->hpd_unit);
|
||||
else
|
||||
printf("not found\n");
|
||||
}
|
||||
|
@ -260,19 +257,14 @@ find_device(struct hp_hw *hw)
|
|||
* Note, we can still fail if HW won't initialize.
|
||||
*/
|
||||
hd = match_d;
|
||||
oaddr = hd->hp_addr;
|
||||
hd->hp_addr = hw->hw_addr;
|
||||
if ((*hd->hp_driver->d_init)(hd)) {
|
||||
hd->hp_alive = 1;
|
||||
printf("%s%d", hd->hp_driver->d_name, hd->hp_unit);
|
||||
printf(" at %p", hd->hp_addr);
|
||||
if (hd->hp_ipl)
|
||||
printf(", ipl %d", hd->hp_ipl);
|
||||
if (hd->hp_flags)
|
||||
printf(", flags 0x%x", hd->hp_flags);
|
||||
printf("\n");
|
||||
oaddr = hd->hpd_addr;
|
||||
hd->hpd_addr = hw->hw_addr;
|
||||
if ((*hd->hpd_driver->d_init)(hd)) {
|
||||
hd->hpd_alive = 1;
|
||||
printf("%s%d", hd->hpd_driver->d_name, hd->hpd_unit);
|
||||
printf(" at %p\n", hd->hpd_addr);
|
||||
} else
|
||||
hd->hp_addr = oaddr;
|
||||
hd->hpd_addr = oaddr;
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
@ -303,7 +295,7 @@ find_slaves(struct hp_ctlr *hc)
|
|||
for (s = 0; s < maxslaves; s++) {
|
||||
rescan = 1;
|
||||
match_s = NULL;
|
||||
for (hd = hp_dinit; hd->hp_driver; hd++) {
|
||||
for (hd = hp_dinit; hd->hpd_driver; hd++) {
|
||||
/*
|
||||
* Rule out the easy ones:
|
||||
* 1. slave already assigned or not a slave
|
||||
|
@ -311,13 +303,13 @@ find_slaves(struct hp_ctlr *hc)
|
|||
* 3. controller specified but not this one
|
||||
* 4. slave specified but not this one
|
||||
*/
|
||||
if (hd->hp_alive || hd->hp_cdriver == NULL)
|
||||
if (hd->hpd_alive || hd->hpd_cdriver == NULL)
|
||||
continue;
|
||||
if (!dr_type(hc->hp_driver, hd->hp_cdriver->d_name))
|
||||
if (!dr_type(hc->hp_driver, hd->hpd_cdriver->d_name))
|
||||
continue;
|
||||
if (hd->hp_ctlr >= 0 && hd->hp_ctlr != hc->hp_unit)
|
||||
if (hd->hpd_ctlr >= 0 && hd->hpd_ctlr != hc->hp_unit)
|
||||
continue;
|
||||
if (hd->hp_slave >= 0 && hd->hp_slave != s)
|
||||
if (hd->hpd_slave >= 0 && hd->hpd_slave != s)
|
||||
continue;
|
||||
/*
|
||||
* Case 0: first possible match.
|
||||
|
@ -336,7 +328,7 @@ find_slaves(struct hp_ctlr *hc)
|
|||
* "reserve" locations for dynamic addition of
|
||||
* disk/tape drives by fully qualifing the location.
|
||||
*/
|
||||
if (hd->hp_slave == s && hd->hp_ctlr == hc->hp_unit) {
|
||||
if (hd->hpd_slave == s && hd->hpd_ctlr == hc->hp_unit) {
|
||||
match_s = hd;
|
||||
rescan = 0;
|
||||
break;
|
||||
|
@ -345,8 +337,8 @@ find_slaves(struct hp_ctlr *hc)
|
|||
* Case 2: right controller, wildcarded slave.
|
||||
* Remember first and keep looking for an exact match.
|
||||
*/
|
||||
if (hd->hp_ctlr == hc->hp_unit &&
|
||||
match_s->hp_ctlr < 0) {
|
||||
if (hd->hpd_ctlr == hc->hp_unit &&
|
||||
match_s->hpd_ctlr < 0) {
|
||||
match_s = hd;
|
||||
new_s = s;
|
||||
continue;
|
||||
|
@ -355,8 +347,8 @@ find_slaves(struct hp_ctlr *hc)
|
|||
* Case 3: right slave, wildcarded controller.
|
||||
* Remember and keep looking for a better match.
|
||||
*/
|
||||
if (hd->hp_slave == s &&
|
||||
match_s->hp_ctlr < 0 && match_s->hp_slave < 0) {
|
||||
if (hd->hpd_slave == s &&
|
||||
match_s->hpd_ctlr < 0 && match_s->hpd_slave < 0) {
|
||||
match_s = hd;
|
||||
new_c = hc->hp_unit;
|
||||
continue;
|
||||
|
@ -376,85 +368,39 @@ find_slaves(struct hp_ctlr *hc)
|
|||
*/
|
||||
if (match_s) {
|
||||
hd = match_s;
|
||||
old_c = hd->hp_ctlr;
|
||||
old_s = hd->hp_slave;
|
||||
if (hd->hp_ctlr < 0)
|
||||
hd->hp_ctlr = new_c;
|
||||
if (hd->hp_slave < 0)
|
||||
hd->hp_slave = new_s;
|
||||
old_c = hd->hpd_ctlr;
|
||||
old_s = hd->hpd_slave;
|
||||
if (hd->hpd_ctlr < 0)
|
||||
hd->hpd_ctlr = new_c;
|
||||
if (hd->hpd_slave < 0)
|
||||
hd->hpd_slave = new_s;
|
||||
#ifdef DEBUG
|
||||
if (acdebug)
|
||||
printf("looking for %s%d at slave %d...",
|
||||
hd->hp_driver->d_name,
|
||||
hd->hp_unit, hd->hp_slave);
|
||||
hd->hpd_driver->d_name,
|
||||
hd->hpd_unit, hd->hpd_slave);
|
||||
#endif
|
||||
|
||||
if ((*hd->hp_driver->d_init)(hd)) {
|
||||
if ((*hd->hpd_driver->d_init)(hd)) {
|
||||
#ifdef DEBUG
|
||||
if (acdebug)
|
||||
printf("found\n");
|
||||
#endif
|
||||
printf("%s%d at %s%d, slave %d",
|
||||
hd->hp_driver->d_name, hd->hp_unit,
|
||||
hc->hp_driver->d_name, hd->hp_ctlr,
|
||||
hd->hp_slave);
|
||||
if (hd->hp_flags)
|
||||
printf(" flags 0x%x", hd->hp_flags);
|
||||
printf("\n");
|
||||
hd->hp_alive = 1;
|
||||
if (hd->hp_dk && dkn < DK_NDRIVE)
|
||||
hd->hp_dk = dkn++;
|
||||
else
|
||||
hd->hp_dk = -1;
|
||||
printf("%s%d at %s%d, slave %d\n",
|
||||
hd->hpd_driver->d_name, hd->hpd_unit,
|
||||
hc->hp_driver->d_name, hd->hpd_ctlr,
|
||||
hd->hpd_slave);
|
||||
hd->hpd_alive = 1;
|
||||
rescan = 1;
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
if (acdebug)
|
||||
printf("not found\n");
|
||||
#endif
|
||||
hd->hp_ctlr = old_c;
|
||||
hd->hp_slave = old_s;
|
||||
}
|
||||
/*
|
||||
* XXX: This should be handled better.
|
||||
* Re-scan a slave. There are two reasons to do this.
|
||||
* 1. It is possible to have both a tape and disk
|
||||
* (e.g. 7946) or two disks (e.g. 9122) at the
|
||||
* same slave address. Here we need to rescan
|
||||
* looking only at entries with a different
|
||||
* physical unit number (hp_flags).
|
||||
* 2. It is possible that an init failed because the
|
||||
* slave was there but of the wrong type. In this
|
||||
* case it may still be possible to match the slave
|
||||
* to another ioconf entry of a different type.
|
||||
* Here we need to rescan looking only at entries
|
||||
* of different types.
|
||||
* In both cases we avoid looking at undesirable
|
||||
* ioconf entries of the same type by setting their
|
||||
* alive fields to -1.
|
||||
*/
|
||||
if (rescan) {
|
||||
for (hd = hp_dinit; hd->hp_driver; hd++) {
|
||||
if (hd->hp_alive)
|
||||
continue;
|
||||
if (match_s->hp_alive == 1) { /* 1 */
|
||||
if (hd->hp_flags == match_s->hp_flags)
|
||||
hd->hp_alive = -1;
|
||||
} else { /* 2 */
|
||||
if (hd->hp_driver == match_s->hp_driver)
|
||||
hd->hp_alive = -1;
|
||||
}
|
||||
}
|
||||
s--;
|
||||
continue;
|
||||
hd->hpd_ctlr = old_c;
|
||||
hd->hpd_slave = old_s;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Reset bogon alive fields prior to attempting next slave
|
||||
*/
|
||||
for (hd = hp_dinit; hd->hp_driver; hd++)
|
||||
if (hd->hp_alive == -1)
|
||||
hd->hp_alive = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -465,10 +411,10 @@ same_hw_device(struct hp_hw *hw, struct hp_device *hd)
|
|||
|
||||
switch (hw->hw_type) {
|
||||
case NET:
|
||||
found = dr_type(hd->hp_driver, "le");
|
||||
found = dr_type(hd->hpd_driver, "le");
|
||||
break;
|
||||
case SCSI:
|
||||
found = dr_type(hd->hp_driver, "scsi");
|
||||
found = dr_type(hd->hpd_driver, "scsi");
|
||||
break;
|
||||
}
|
||||
return(found);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: device.h,v 1.6 2014/01/03 02:03:12 tsutsui Exp $ */
|
||||
/* $NetBSD: device.h,v 1.7 2014/01/03 03:25:25 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 OMRON Corporation.
|
||||
|
@ -86,16 +86,13 @@ struct hp_ctlr {
|
|||
};
|
||||
|
||||
struct hp_device {
|
||||
struct driver *hp_driver;
|
||||
struct driver *hp_cdriver;
|
||||
int hp_unit;
|
||||
int hp_ctlr;
|
||||
int hp_slave;
|
||||
uint8_t *hp_addr;
|
||||
int hp_dk;
|
||||
int hp_flags;
|
||||
int hp_alive;
|
||||
int hp_ipl;
|
||||
struct driver *hpd_driver;
|
||||
struct driver *hpd_cdriver;
|
||||
int hpd_unit;
|
||||
int hpd_ctlr;
|
||||
int hpd_slave;
|
||||
uint8_t *hpd_addr;
|
||||
int hpd_alive;
|
||||
};
|
||||
|
||||
struct hp_hw {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_le.c,v 1.3 2013/01/22 15:48:40 tsutsui Exp $ */
|
||||
/* $NetBSD: if_le.c,v 1.4 2014/01/03 03:25:25 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013 Izumi Tsutsui. All rights reserved.
|
||||
|
@ -121,19 +121,19 @@ leinit(void *arg)
|
|||
void *reg, *mem;
|
||||
uint8_t eaddr[6];
|
||||
|
||||
reg = hd->hp_addr;
|
||||
reg = hd->hpd_addr;
|
||||
mem = (void *)0x71010000; /* XXX */
|
||||
|
||||
myetheraddr(eaddr);
|
||||
|
||||
cookie = lance_attach(hd->hp_unit, reg, mem, eaddr);
|
||||
cookie = lance_attach(hd->hpd_unit, reg, mem, eaddr);
|
||||
if (cookie == NULL)
|
||||
return 0;
|
||||
|
||||
printf("%s%d: Am7990 LANCE Ethernet, mem at 0x%x\n",
|
||||
hd->hp_driver->d_name, hd->hp_unit, (uint32_t)mem);
|
||||
hd->hpd_driver->d_name, hd->hpd_unit, (uint32_t)mem);
|
||||
printf("%s%d: Ethernet address = %s\n",
|
||||
hd->hp_driver->d_name, hd->hp_unit,
|
||||
hd->hpd_driver->d_name, hd->hpd_unit,
|
||||
ether_sprintf(eaddr));
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ioconf.c,v 1.4 2014/01/03 02:03:12 tsutsui Exp $ */
|
||||
/* $NetBSD: ioconf.c,v 1.5 2014/01/03 03:25:25 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 OMRON Corporation.
|
||||
|
@ -87,14 +87,14 @@ struct hp_ctlr hp_cinit[] = {
|
|||
};
|
||||
|
||||
struct hp_device hp_dinit[] = {
|
||||
/*driver, cdriver, unit, ctlr, slave, addr, dk, flags*/
|
||||
{ &sddriver, &scdriver, 0, 0, 6, NULL, 1, 0x0 },
|
||||
{ &sddriver, &scdriver, 1, 0, 5, NULL, 1, 0x0 },
|
||||
{ &sddriver, &scdriver, 2, 1, 6, NULL, 1, 0x0 },
|
||||
{ &sddriver, &scdriver, 3, 1, 5, NULL, 1, 0x0 },
|
||||
{ &ledriver, NULL, 0, 0, 0, NULL, 0, 0x0 },
|
||||
/*driver, cdriver, unit, ctlr, slave */
|
||||
{ &sddriver, &scdriver, 0, 0, 6 },
|
||||
{ &sddriver, &scdriver, 1, 0, 5 },
|
||||
{ &sddriver, &scdriver, 2, 1, 6 },
|
||||
{ &sddriver, &scdriver, 3, 1, 5 },
|
||||
{ &ledriver, NULL, 0, 0, 0 },
|
||||
#ifdef notyet
|
||||
{ &stdriver, &scdriver, 0, 0, 4, NULL, 0, 0x0 },
|
||||
{ &stdriver, &scdriver, 0, 0, 4 },
|
||||
#endif
|
||||
{0}
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sd.c,v 1.6 2014/01/03 02:03:12 tsutsui Exp $ */
|
||||
/* $NetBSD: sd.c,v 1.7 2014/01/03 03:25:25 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 OMRON Corporation.
|
||||
|
@ -139,8 +139,8 @@ sdident(struct sd_softc *sc, struct hp_device *hd)
|
|||
int i;
|
||||
int tries = 10;
|
||||
|
||||
ctlr = hd->hp_ctlr;
|
||||
slave = hd->hp_slave;
|
||||
ctlr = hd->hpd_ctlr;
|
||||
slave = hd->hpd_slave;
|
||||
unit = sc->sc_punit;
|
||||
|
||||
/*
|
||||
|
@ -192,7 +192,7 @@ sdident(struct sd_softc *sc, struct hp_device *hd)
|
|||
if (idstr[i] != ' ')
|
||||
break;
|
||||
idstr[i+1] = 0;
|
||||
printf("sd%d: %s %s rev %s", hd->hp_unit, idstr, &idstr[8],
|
||||
printf("sd%d: %s %s rev %s", hd->hpd_unit, idstr, &idstr[8],
|
||||
&idstr[24]);
|
||||
|
||||
printf(", %d bytes/sect x %d sectors\n", sc->sc_blksize, sc->sc_blks);
|
||||
|
@ -213,14 +213,14 @@ int
|
|||
sdinit(void *arg)
|
||||
{
|
||||
struct hp_device *hd = arg;
|
||||
struct sd_softc *sc = &sd_softc[hd->hp_unit];
|
||||
struct sd_softc *sc = &sd_softc[hd->hpd_unit];
|
||||
struct disklabel *lp;
|
||||
char *msg;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("sdinit: hd->hp_unit = %d\n", hd->hp_unit);
|
||||
printf("sdinit: hd->hp_ctlr = %d, hd->hp_slave = %d\n",
|
||||
hd->hp_ctlr, hd->hp_slave);
|
||||
printf("sdinit: hd->hpd_unit = %d\n", hd->hpd_unit);
|
||||
printf("sdinit: hd->hpd_ctlr = %d, hd->hpd_slave = %d\n",
|
||||
hd->hpd_ctlr, hd->hpd_slave);
|
||||
#endif
|
||||
sc->sc_hd = hd;
|
||||
sc->sc_punit = 0; /* XXX no LUN support yet */
|
||||
|
@ -232,7 +232,7 @@ sdinit(void *arg)
|
|||
* Use the default sizes until we've read the label,
|
||||
* or longer if there isn't one there.
|
||||
*/
|
||||
lp = &sdlabel[hd->hp_unit];
|
||||
lp = &sdlabel[hd->hpd_unit];
|
||||
|
||||
if (lp->d_secpercyl == 0) {
|
||||
lp->d_secsize = DEV_BSIZE;
|
||||
|
@ -247,9 +247,9 @@ sdinit(void *arg)
|
|||
/*
|
||||
* read disklabel
|
||||
*/
|
||||
msg = readdisklabel(hd->hp_ctlr, hd->hp_slave, lp);
|
||||
msg = readdisklabel(hd->hpd_ctlr, hd->hpd_slave, lp);
|
||||
if (msg != NULL)
|
||||
printf("sd%d: %s\n", hd->hp_unit, msg);
|
||||
printf("sd%d: %s\n", hd->hpd_unit, msg);
|
||||
|
||||
sc->sc_flags = SDF_ALIVE;
|
||||
return(1);
|
||||
|
@ -323,8 +323,8 @@ sdstrategy(void *devdata, int func, daddr_t dblk, size_t size, void *v_buf,
|
|||
if (unit < 0 || unit >= NSD)
|
||||
return(-1);
|
||||
|
||||
ctlr = sc->sc_hd->hp_ctlr;
|
||||
slave = sc->sc_hd->hp_slave;
|
||||
ctlr = sc->sc_hd->hpd_ctlr;
|
||||
slave = sc->sc_hd->hpd_slave;
|
||||
|
||||
lp = &sdlabel[unit];
|
||||
blk = dblk + (lp->d_partitions[part].p_offset >> sc->sc_bshift);
|
||||
|
@ -355,55 +355,3 @@ sdstrategy(void *devdata, int func, daddr_t dblk, size_t size, void *v_buf,
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int
|
||||
sdread(dev_t dev, u_int blk, u_int nblk, u_char *buff, u_int len)
|
||||
{
|
||||
int unit = sdunit(dev);
|
||||
int part = sdpart(dev);
|
||||
struct sd_softc *sc = &sd_softc[unit];
|
||||
struct scsi_fmt_cdb *cdb;
|
||||
int stat, ctlr, slave;
|
||||
|
||||
ctlr = sc->sc_hd->hp_ctlr;
|
||||
slave = sc->sc_hd->hp_slave;
|
||||
|
||||
cdb = &cdb_read;
|
||||
|
||||
cdb->cdb[2] = (blk & 0xff000000) >> 24;
|
||||
cdb->cdb[3] = (blk & 0x00ff0000) >> 16;
|
||||
cdb->cdb[4] = (blk & 0x0000ff00) >> 8;
|
||||
cdb->cdb[5] = (blk & 0x000000ff);
|
||||
|
||||
cdb->cdb[7] = (nblk & 0xff00) >> 8;
|
||||
cdb->cdb[8] = (nblk & 0x00ff);
|
||||
|
||||
stat = scsi_immed_command(ctlr, slave, sc->sc_punit, cdb, buff, len);
|
||||
|
||||
if (stat == 0)
|
||||
return(1);
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
sdioctl(dev_t dev, u_long data[])
|
||||
{
|
||||
int unit = sdunit(dev);
|
||||
int part = sdpart(dev);
|
||||
struct disklabel *lp;
|
||||
|
||||
if (unit < 0 || unit >= NSD)
|
||||
return(0);
|
||||
|
||||
if (part < 0 || part >= MAXPARTITIONS)
|
||||
return(0);
|
||||
|
||||
lp = &sdlabel[unit];
|
||||
data[0] = lp->d_partitions[part].p_offset;
|
||||
data[1] = lp->d_partitions[part].p_size;
|
||||
|
||||
return(1);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue