Misc cleanup from OpenBSD/luna88k.

- remove unused code
- use proper prefix for structure members for readability
This commit is contained in:
tsutsui 2014-01-03 03:25:25 +00:00
parent 6e605f060f
commit 7f7c7f9b34
5 changed files with 77 additions and 186 deletions

View File

@ -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. * Copyright (c) 1992 OMRON Corporation.
@ -195,10 +195,7 @@ find_controller(struct hp_hw *hw)
hc->hp_alive = 1; hc->hp_alive = 1;
printf("%s%d", hc->hp_driver->d_name, hc->hp_unit); printf("%s%d", hc->hp_driver->d_name, hc->hp_unit);
printf(" at %p,", hc->hp_addr); printf(" at %p,", hc->hp_addr);
printf(" ipl %d", hc->hp_ipl); printf(" ipl %d\n", hc->hp_ipl);
if (hc->hp_flags)
printf(" flags 0x%x", hc->hp_flags);
printf("\n");
find_slaves(hc); find_slaves(hc);
} else } else
hc->hp_addr = oaddr; 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); hw->hw_name, hw->hw_sc, (u_int)hw->hw_addr, hw->hw_type);
#endif #endif
match_d = NULL; match_d = NULL;
for (hd = hp_dinit; hd->hp_driver; hd++) { for (hd = hp_dinit; hd->hpd_driver; hd++) {
if (hd->hp_alive) if (hd->hpd_alive)
continue; continue;
/* Must not be a slave */ /* Must not be a slave */
if (hd->hp_cdriver) if (hd->hpd_cdriver)
continue; continue;
addr = hd->hp_addr; addr = hd->hpd_addr;
/* /*
* Exact match; all done. * Exact match; all done.
*/ */
@ -243,8 +240,8 @@ find_device(struct hp_hw *hw)
if (acdebug) { if (acdebug) {
if (match_d) if (match_d)
printf("found %s%d\n", printf("found %s%d\n",
match_d->hp_driver->d_name, match_d->hpd_driver->d_name,
match_d->hp_unit); match_d->hpd_unit);
else else
printf("not found\n"); printf("not found\n");
} }
@ -260,19 +257,14 @@ find_device(struct hp_hw *hw)
* Note, we can still fail if HW won't initialize. * Note, we can still fail if HW won't initialize.
*/ */
hd = match_d; hd = match_d;
oaddr = hd->hp_addr; oaddr = hd->hpd_addr;
hd->hp_addr = hw->hw_addr; hd->hpd_addr = hw->hw_addr;
if ((*hd->hp_driver->d_init)(hd)) { if ((*hd->hpd_driver->d_init)(hd)) {
hd->hp_alive = 1; hd->hpd_alive = 1;
printf("%s%d", hd->hp_driver->d_name, hd->hp_unit); printf("%s%d", hd->hpd_driver->d_name, hd->hpd_unit);
printf(" at %p", hd->hp_addr); printf(" at %p\n", hd->hpd_addr);
if (hd->hp_ipl)
printf(", ipl %d", hd->hp_ipl);
if (hd->hp_flags)
printf(", flags 0x%x", hd->hp_flags);
printf("\n");
} else } else
hd->hp_addr = oaddr; hd->hpd_addr = oaddr;
return(1); return(1);
} }
@ -303,7 +295,7 @@ find_slaves(struct hp_ctlr *hc)
for (s = 0; s < maxslaves; s++) { for (s = 0; s < maxslaves; s++) {
rescan = 1; rescan = 1;
match_s = NULL; match_s = NULL;
for (hd = hp_dinit; hd->hp_driver; hd++) { for (hd = hp_dinit; hd->hpd_driver; hd++) {
/* /*
* Rule out the easy ones: * Rule out the easy ones:
* 1. slave already assigned or not a slave * 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 * 3. controller specified but not this one
* 4. slave 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; continue;
if (!dr_type(hc->hp_driver, hd->hp_cdriver->d_name)) if (!dr_type(hc->hp_driver, hd->hpd_cdriver->d_name))
continue; continue;
if (hd->hp_ctlr >= 0 && hd->hp_ctlr != hc->hp_unit) if (hd->hpd_ctlr >= 0 && hd->hpd_ctlr != hc->hp_unit)
continue; continue;
if (hd->hp_slave >= 0 && hd->hp_slave != s) if (hd->hpd_slave >= 0 && hd->hpd_slave != s)
continue; continue;
/* /*
* Case 0: first possible match. * Case 0: first possible match.
@ -336,7 +328,7 @@ find_slaves(struct hp_ctlr *hc)
* "reserve" locations for dynamic addition of * "reserve" locations for dynamic addition of
* disk/tape drives by fully qualifing the location. * 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; match_s = hd;
rescan = 0; rescan = 0;
break; break;
@ -345,8 +337,8 @@ find_slaves(struct hp_ctlr *hc)
* Case 2: right controller, wildcarded slave. * Case 2: right controller, wildcarded slave.
* Remember first and keep looking for an exact match. * Remember first and keep looking for an exact match.
*/ */
if (hd->hp_ctlr == hc->hp_unit && if (hd->hpd_ctlr == hc->hp_unit &&
match_s->hp_ctlr < 0) { match_s->hpd_ctlr < 0) {
match_s = hd; match_s = hd;
new_s = s; new_s = s;
continue; continue;
@ -355,8 +347,8 @@ find_slaves(struct hp_ctlr *hc)
* Case 3: right slave, wildcarded controller. * Case 3: right slave, wildcarded controller.
* Remember and keep looking for a better match. * Remember and keep looking for a better match.
*/ */
if (hd->hp_slave == s && if (hd->hpd_slave == s &&
match_s->hp_ctlr < 0 && match_s->hp_slave < 0) { match_s->hpd_ctlr < 0 && match_s->hpd_slave < 0) {
match_s = hd; match_s = hd;
new_c = hc->hp_unit; new_c = hc->hp_unit;
continue; continue;
@ -376,85 +368,39 @@ find_slaves(struct hp_ctlr *hc)
*/ */
if (match_s) { if (match_s) {
hd = match_s; hd = match_s;
old_c = hd->hp_ctlr; old_c = hd->hpd_ctlr;
old_s = hd->hp_slave; old_s = hd->hpd_slave;
if (hd->hp_ctlr < 0) if (hd->hpd_ctlr < 0)
hd->hp_ctlr = new_c; hd->hpd_ctlr = new_c;
if (hd->hp_slave < 0) if (hd->hpd_slave < 0)
hd->hp_slave = new_s; hd->hpd_slave = new_s;
#ifdef DEBUG #ifdef DEBUG
if (acdebug) if (acdebug)
printf("looking for %s%d at slave %d...", printf("looking for %s%d at slave %d...",
hd->hp_driver->d_name, hd->hpd_driver->d_name,
hd->hp_unit, hd->hp_slave); hd->hpd_unit, hd->hpd_slave);
#endif #endif
if ((*hd->hp_driver->d_init)(hd)) { if ((*hd->hpd_driver->d_init)(hd)) {
#ifdef DEBUG #ifdef DEBUG
if (acdebug) if (acdebug)
printf("found\n"); printf("found\n");
#endif #endif
printf("%s%d at %s%d, slave %d", printf("%s%d at %s%d, slave %d\n",
hd->hp_driver->d_name, hd->hp_unit, hd->hpd_driver->d_name, hd->hpd_unit,
hc->hp_driver->d_name, hd->hp_ctlr, hc->hp_driver->d_name, hd->hpd_ctlr,
hd->hp_slave); hd->hpd_slave);
if (hd->hp_flags) hd->hpd_alive = 1;
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;
rescan = 1; rescan = 1;
} else { } else {
#ifdef DEBUG #ifdef DEBUG
if (acdebug) if (acdebug)
printf("not found\n"); printf("not found\n");
#endif #endif
hd->hp_ctlr = old_c; hd->hpd_ctlr = old_c;
hd->hp_slave = old_s; hd->hpd_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;
} }
} }
/*
* 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) { switch (hw->hw_type) {
case NET: case NET:
found = dr_type(hd->hp_driver, "le"); found = dr_type(hd->hpd_driver, "le");
break; break;
case SCSI: case SCSI:
found = dr_type(hd->hp_driver, "scsi"); found = dr_type(hd->hpd_driver, "scsi");
break; break;
} }
return(found); return(found);

View File

@ -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. * Copyright (c) 1992 OMRON Corporation.
@ -86,16 +86,13 @@ struct hp_ctlr {
}; };
struct hp_device { struct hp_device {
struct driver *hp_driver; struct driver *hpd_driver;
struct driver *hp_cdriver; struct driver *hpd_cdriver;
int hp_unit; int hpd_unit;
int hp_ctlr; int hpd_ctlr;
int hp_slave; int hpd_slave;
uint8_t *hp_addr; uint8_t *hpd_addr;
int hp_dk; int hpd_alive;
int hp_flags;
int hp_alive;
int hp_ipl;
}; };
struct hp_hw { struct hp_hw {

View File

@ -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. * Copyright (c) 2013 Izumi Tsutsui. All rights reserved.
@ -121,19 +121,19 @@ leinit(void *arg)
void *reg, *mem; void *reg, *mem;
uint8_t eaddr[6]; uint8_t eaddr[6];
reg = hd->hp_addr; reg = hd->hpd_addr;
mem = (void *)0x71010000; /* XXX */ mem = (void *)0x71010000; /* XXX */
myetheraddr(eaddr); myetheraddr(eaddr);
cookie = lance_attach(hd->hp_unit, reg, mem, eaddr); cookie = lance_attach(hd->hpd_unit, reg, mem, eaddr);
if (cookie == NULL) if (cookie == NULL)
return 0; return 0;
printf("%s%d: Am7990 LANCE Ethernet, mem at 0x%x\n", 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", 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)); ether_sprintf(eaddr));
return 1; return 1;

View File

@ -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. * Copyright (c) 1992 OMRON Corporation.
@ -87,14 +87,14 @@ struct hp_ctlr hp_cinit[] = {
}; };
struct hp_device hp_dinit[] = { struct hp_device hp_dinit[] = {
/*driver, cdriver, unit, ctlr, slave, addr, dk, flags*/ /*driver, cdriver, unit, ctlr, slave */
{ &sddriver, &scdriver, 0, 0, 6, NULL, 1, 0x0 }, { &sddriver, &scdriver, 0, 0, 6 },
{ &sddriver, &scdriver, 1, 0, 5, NULL, 1, 0x0 }, { &sddriver, &scdriver, 1, 0, 5 },
{ &sddriver, &scdriver, 2, 1, 6, NULL, 1, 0x0 }, { &sddriver, &scdriver, 2, 1, 6 },
{ &sddriver, &scdriver, 3, 1, 5, NULL, 1, 0x0 }, { &sddriver, &scdriver, 3, 1, 5 },
{ &ledriver, NULL, 0, 0, 0, NULL, 0, 0x0 }, { &ledriver, NULL, 0, 0, 0 },
#ifdef notyet #ifdef notyet
{ &stdriver, &scdriver, 0, 0, 4, NULL, 0, 0x0 }, { &stdriver, &scdriver, 0, 0, 4 },
#endif #endif
{0} {0}
}; };

View File

@ -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. * Copyright (c) 1992 OMRON Corporation.
@ -139,8 +139,8 @@ sdident(struct sd_softc *sc, struct hp_device *hd)
int i; int i;
int tries = 10; int tries = 10;
ctlr = hd->hp_ctlr; ctlr = hd->hpd_ctlr;
slave = hd->hp_slave; slave = hd->hpd_slave;
unit = sc->sc_punit; unit = sc->sc_punit;
/* /*
@ -192,7 +192,7 @@ sdident(struct sd_softc *sc, struct hp_device *hd)
if (idstr[i] != ' ') if (idstr[i] != ' ')
break; break;
idstr[i+1] = 0; 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]); &idstr[24]);
printf(", %d bytes/sect x %d sectors\n", sc->sc_blksize, sc->sc_blks); printf(", %d bytes/sect x %d sectors\n", sc->sc_blksize, sc->sc_blks);
@ -213,14 +213,14 @@ int
sdinit(void *arg) sdinit(void *arg)
{ {
struct hp_device *hd = 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; struct disklabel *lp;
char *msg; char *msg;
#ifdef DEBUG #ifdef DEBUG
printf("sdinit: hd->hp_unit = %d\n", hd->hp_unit); printf("sdinit: hd->hpd_unit = %d\n", hd->hpd_unit);
printf("sdinit: hd->hp_ctlr = %d, hd->hp_slave = %d\n", printf("sdinit: hd->hpd_ctlr = %d, hd->hpd_slave = %d\n",
hd->hp_ctlr, hd->hp_slave); hd->hpd_ctlr, hd->hpd_slave);
#endif #endif
sc->sc_hd = hd; sc->sc_hd = hd;
sc->sc_punit = 0; /* XXX no LUN support yet */ 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, * Use the default sizes until we've read the label,
* or longer if there isn't one there. * or longer if there isn't one there.
*/ */
lp = &sdlabel[hd->hp_unit]; lp = &sdlabel[hd->hpd_unit];
if (lp->d_secpercyl == 0) { if (lp->d_secpercyl == 0) {
lp->d_secsize = DEV_BSIZE; lp->d_secsize = DEV_BSIZE;
@ -247,9 +247,9 @@ sdinit(void *arg)
/* /*
* read disklabel * read disklabel
*/ */
msg = readdisklabel(hd->hp_ctlr, hd->hp_slave, lp); msg = readdisklabel(hd->hpd_ctlr, hd->hpd_slave, lp);
if (msg != NULL) 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; sc->sc_flags = SDF_ALIVE;
return(1); 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) if (unit < 0 || unit >= NSD)
return(-1); return(-1);
ctlr = sc->sc_hd->hp_ctlr; ctlr = sc->sc_hd->hpd_ctlr;
slave = sc->sc_hd->hp_slave; slave = sc->sc_hd->hpd_slave;
lp = &sdlabel[unit]; lp = &sdlabel[unit];
blk = dblk + (lp->d_partitions[part].p_offset >> sc->sc_bshift); 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; 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