Remove usage of cam_extend.c, replace with dev->si_drv1

PR:		kern/39809
Approved by:	gibbs
This commit is contained in:
njl 2002-08-15 20:54:03 +00:00
parent 62a0b60a38
commit 54a3d67ad2
10 changed files with 74 additions and 244 deletions

View File

@ -62,7 +62,6 @@
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_extend.h>
#include <cam/cam_periph.h>
#include <cam/cam_xpt_periph.h>
#include <cam/cam_queue.h>
@ -267,7 +266,6 @@ static struct cdevsw cd_cdevsw = {
};
static struct cdevsw cddisk_cdevsw;
static struct extend_array *cdperiphs;
static int num_changers;
#ifndef CHANGER_MIN_BUSY_SECONDS
@ -309,15 +307,6 @@ cdinit(void)
cam_status status;
struct cam_path *path;
/*
* Create our extend array for storing the devices we attach to.
*/
cdperiphs = cam_extend_new();
if (cdperiphs == NULL) {
printf("cd: Failed to alloc extend array!\n");
return;
}
/*
* Install a global async callback. This callback will
* receive async callbacks like "new device found".
@ -481,7 +470,6 @@ cdcleanup(struct cam_periph *periph)
num_changers--;
}
devstat_remove_entry(&softc->device_stats);
cam_extend_release(cdperiphs, periph->unit_number);
if (softc->disk.d_dev) {
disk_destroy(softc->disk.d_dev);
}
@ -560,6 +548,7 @@ cdregister(struct cam_periph *periph, void *arg)
struct ccb_setasync csa;
struct ccb_getdev *cgd;
caddr_t match;
dev_t disk_dev;
cgd = (struct ccb_getdev *)arg;
if (periph == NULL) {
@ -591,8 +580,6 @@ cdregister(struct cam_periph *periph, void *arg)
periph->softc = softc;
softc->periph = periph;
cam_extend_set(cdperiphs, periph->unit_number, periph);
/*
* See if this device has any quirks.
*/
@ -623,9 +610,10 @@ cdregister(struct cam_periph *periph, void *arg)
DEVSTAT_BS_UNAVAILABLE,
DEVSTAT_TYPE_CDROM | DEVSTAT_TYPE_IF_SCSI,
DEVSTAT_PRIORITY_CD);
disk_create(periph->unit_number, &softc->disk,
disk_dev = disk_create(periph->unit_number, &softc->disk,
DSO_ONESLICE | DSO_COMPATLABEL,
&cd_cdevsw, &cddisk_cdevsw);
disk_dev->si_drv1 = periph;
/*
* Add an async callback so that we get
@ -875,12 +863,10 @@ cdopen(dev_t dev, int flags, int fmt, struct thread *td)
struct cd_softc *softc;
struct ccb_getdev cgd;
u_int32_t size;
int unit, error;
int error;
int s;
unit = dkunit(dev);
periph = cam_extend_get(cdperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);
@ -984,10 +970,9 @@ cdclose(dev_t dev, int flag, int fmt, struct thread *td)
{
struct cam_periph *periph;
struct cd_softc *softc;
int unit, error;
int error;
unit = dkunit(dev);
periph = cam_extend_get(cdperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);
@ -1359,12 +1344,9 @@ cdstrategy(struct bio *bp)
{
struct cam_periph *periph;
struct cd_softc *softc;
u_int unit, part;
int s;
unit = dkunit(bp->bio_dev);
part = dkpart(bp->bio_dev);
periph = cam_extend_get(cdperiphs, unit);
periph = (struct cam_periph *)bp->bio_dev->si_drv1;
if (periph == NULL) {
biofinish(bp, NULL, ENXIO);
return;
@ -1804,11 +1786,9 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
struct cam_periph *periph;
struct cd_softc *softc;
int error, unit;
int error;
unit = dkunit(dev);
periph = cam_extend_get(cdperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return(ENXIO);
@ -2510,8 +2490,7 @@ cdsize(dev_t dev, u_int32_t *size)
struct scsi_read_capacity_data *rcap_buf;
int error;
periph = cam_extend_get(cdperiphs, dkunit(dev));
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);

View File

@ -82,7 +82,6 @@
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_extend.h>
#include <cam/cam_periph.h>
#include <cam/cam_xpt_periph.h>
#include <cam/cam_debug.h>
@ -227,23 +226,12 @@ static struct cdevsw ch_cdevsw = {
/* flags */ 0,
};
static struct extend_array *chperiphs;
void
chinit(void)
{
cam_status status;
struct cam_path *path;
/*
* Create our extend array for storing the devices we attach to.
*/
chperiphs = cam_extend_new();
if (chperiphs == NULL) {
printf("ch: Failed to alloc extend array!\n");
return;
}
/*
* Install a global async callback. This callback will
* receive async callbacks like "new device found".
@ -305,7 +293,6 @@ chcleanup(struct cam_periph *periph)
devstat_remove_entry(&softc->device_stats);
destroy_dev(softc->dev);
cam_extend_release(chperiphs, periph->unit_number);
xpt_print_path(periph->path);
printf("removing device entry\n");
free(softc, M_DEVBUF);
@ -384,7 +371,6 @@ chregister(struct cam_periph *periph, void *arg)
bzero(softc, sizeof(*softc));
softc->state = CH_STATE_PROBE;
periph->softc = softc;
cam_extend_set(chperiphs, periph->unit_number, periph);
softc->quirks = CH_Q_NONE;
/*
@ -401,6 +387,7 @@ chregister(struct cam_periph *periph, void *arg)
softc->dev = make_dev(&ch_cdevsw, periph->unit_number, UID_ROOT,
GID_OPERATOR, 0600, "%s%d", periph->periph_name,
periph->unit_number);
softc->dev->si_drv1 = periph;
/*
* Add an async callback so that we get
@ -428,12 +415,10 @@ chopen(dev_t dev, int flags, int fmt, struct thread *td)
{
struct cam_periph *periph;
struct ch_softc *softc;
int unit, error;
int error;
int s;
unit = CHUNIT(dev);
periph = cam_extend_get(chperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return(ENXIO);
@ -478,12 +463,11 @@ chclose(dev_t dev, int flag, int fmt, struct thread *td)
{
struct cam_periph *periph;
struct ch_softc *softc;
int unit, error;
int error;
error = 0;
unit = CHUNIT(dev);
periph = cam_extend_get(chperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return(ENXIO);
@ -728,12 +712,9 @@ chioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
{
struct cam_periph *periph;
struct ch_softc *softc;
u_int8_t unit;
int error;
unit = CHUNIT(dev);
periph = cam_extend_get(chperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return(ENXIO);

View File

@ -60,7 +60,6 @@
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_extend.h>
#include <cam/cam_periph.h>
#include <cam/cam_xpt_periph.h>
@ -491,7 +490,6 @@ static struct cdevsw da_cdevsw = {
static struct cdevsw dadisk_cdevsw;
static SLIST_HEAD(,da_softc) softc_list;
static struct extend_array *daperiphs;
static int
daopen(dev_t dev, int flags __unused, int fmt __unused, struct thread *td __unused)
@ -509,7 +507,7 @@ daopen(dev_t dev, int flags __unused, int fmt __unused, struct thread *td __unus
unit = dkunit(dev);
part = dkpart(dev);
s = splsoftcam();
periph = cam_extend_get(daperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL) {
splx(s);
return (ENXIO);
@ -621,11 +619,9 @@ daclose(dev_t dev, int flag __unused, int fmt __unused, struct thread *td __unus
{
struct cam_periph *periph;
struct da_softc *softc;
int unit;
int error;
unit = dkunit(dev);
periph = cam_extend_get(daperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);
@ -711,13 +707,9 @@ dastrategy(struct bio *bp)
{
struct cam_periph *periph;
struct da_softc *softc;
u_int unit;
u_int part;
int s;
unit = dkunit(bp->bio_dev);
part = dkpart(bp->bio_dev);
periph = cam_extend_get(daperiphs, unit);
periph = (struct cam_periph *)bp->bio_dev->si_drv1;
if (periph == NULL) {
biofinish(bp, NULL, ENXIO);
return;
@ -771,11 +763,9 @@ daioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
{
struct cam_periph *periph;
struct da_softc *softc;
int unit;
int error;
unit = dkunit(dev);
periph = cam_extend_get(daperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);
@ -799,14 +789,10 @@ dadump(dev_t dev, void *virtual, vm_offset_t physical, off_t offset, size_t leng
{
struct cam_periph *periph;
struct da_softc *softc;
u_int unit;
u_int part;
u_int secsize;
struct ccb_scsiio csio;
unit = dkunit(dev);
part = dkpart(dev);
periph = cam_extend_get(daperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);
softc = (struct da_softc *)periph->softc;
@ -892,15 +878,7 @@ dainit(void)
cam_status status;
struct cam_path *path;
/*
* Create our extend array for storing the devices we attach to.
*/
daperiphs = cam_extend_new();
SLIST_INIT(&softc_list);
if (daperiphs == NULL) {
printf("da: Failed to alloc extend array!\n");
return;
}
/*
* Install a global async callback. This callback will
@ -997,7 +975,6 @@ dacleanup(struct cam_periph *periph)
softc = (struct da_softc *)periph->softc;
devstat_remove_entry(&softc->device_stats);
cam_extend_release(daperiphs, periph->unit_number);
xpt_print_path(periph->path);
printf("removing device entry\n");
if (softc->dev) {
@ -1109,8 +1086,6 @@ daregister(struct cam_periph *periph, void *arg)
periph->softc = softc;
cam_extend_set(daperiphs, periph->unit_number, periph);
/*
* See if this device has any quirks.
*/
@ -1156,6 +1131,7 @@ daregister(struct cam_periph *periph, void *arg)
*/
softc->dev = disk_create(periph->unit_number, &softc->disk, 0,
&da_cdevsw, &dadisk_cdevsw);
softc->dev->si_drv1 = periph;
/*
* Add async callbacks for bus reset and

View File

@ -41,7 +41,6 @@
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_extend.h>
#include <cam/cam_periph.h>
#include <cam/cam_queue.h>
#include <cam/cam_xpt_periph.h>
@ -125,23 +124,12 @@ static struct cdevsw pass_cdevsw = {
/* flags */ 0,
};
static struct extend_array *passperiphs;
static void
passinit(void)
{
cam_status status;
struct cam_path *path;
/*
* Create our extend array for storing the devices we attach to.
*/
passperiphs = cam_extend_new();
if (passperiphs == NULL) {
printf("passm: Failed to alloc extend array!\n");
return;
}
/*
* Install a global async callback. This callback will
* receive async callbacks like "new device found".
@ -214,8 +202,6 @@ passcleanup(struct cam_periph *periph)
destroy_dev(softc->dev);
cam_extend_release(passperiphs, periph->unit_number);
if (bootverbose) {
xpt_print_path(periph->path);
printf("removing device entry\n");
@ -303,7 +289,6 @@ passregister(struct cam_periph *periph, void *arg)
softc->pd_type = SID_TYPE(&cgd->inq_data);
periph->softc = softc;
cam_extend_set(passperiphs, periph->unit_number, periph);
/*
* We pass in 0 for a blocksize, since we don't
@ -323,6 +308,7 @@ passregister(struct cam_periph *periph, void *arg)
softc->dev = make_dev(&pass_cdevsw, periph->unit_number, UID_ROOT,
GID_OPERATOR, 0600, "%s%d", periph->periph_name,
periph->unit_number);
softc->dev->si_drv1 = periph;
/*
* Add an async callback so that we get
@ -346,17 +332,12 @@ passopen(dev_t dev, int flags, int fmt, struct thread *td)
{
struct cam_periph *periph;
struct pass_softc *softc;
int unit, error;
int error;
int s;
error = 0; /* default to no error */
/* unit = dkunit(dev); */
/* XXX KDM fix this */
unit = minor(dev) & 0xff;
periph = cam_extend_get(passperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);
@ -418,13 +399,9 @@ passclose(dev_t dev, int flag, int fmt, struct thread *td)
{
struct cam_periph *periph;
struct pass_softc *softc;
int unit, error;
int error;
/* unit = dkunit(dev); */
/* XXX KDM fix this */
unit = minor(dev) & 0xff;
periph = cam_extend_get(passperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);
@ -482,18 +459,11 @@ passdone(struct cam_periph *periph, union ccb *done_ccb)
static int
passioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
{
struct cam_periph *periph;
struct cam_periph *periph;
struct pass_softc *softc;
u_int8_t unit;
int error;
/* unit = dkunit(dev); */
/* XXX KDM fix this */
unit = minor(dev) & 0xff;
periph = cam_extend_get(passperiphs, unit);
int error;
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return(ENXIO);

View File

@ -41,7 +41,6 @@
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_extend.h>
#include <cam/cam_periph.h>
#include <cam/cam_xpt_periph.h>
#include <cam/cam_debug.h>
@ -134,8 +133,6 @@ static struct cdevsw pt_cdevsw = {
/* flags */ 0,
};
static struct extend_array *ptperiphs;
#ifndef SCSI_PT_DEFAULT_TIMEOUT
#define SCSI_PT_DEFAULT_TIMEOUT 60
#endif
@ -150,7 +147,7 @@ ptopen(dev_t dev, int flags, int fmt, struct thread *td)
int s;
unit = minor(dev);
periph = cam_extend_get(ptperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);
@ -189,11 +186,9 @@ ptclose(dev_t dev, int flag, int fmt, struct thread *td)
{
struct cam_periph *periph;
struct pt_softc *softc;
int unit;
int error;
unit = minor(dev);
periph = cam_extend_get(ptperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);
@ -218,11 +213,9 @@ ptstrategy(struct bio *bp)
{
struct cam_periph *periph;
struct pt_softc *softc;
u_int unit;
int s;
unit = minor(bp->bio_dev);
periph = cam_extend_get(ptperiphs, unit);
periph = (struct cam_periph *)bp->bio_dev->si_drv1;
bp->bio_resid = bp->bio_bcount;
if (periph == NULL) {
biofinish(bp, NULL, ENXIO);
@ -267,15 +260,6 @@ ptinit(void)
cam_status status;
struct cam_path *path;
/*
* Create our extend array for storing the devices we attach to.
*/
ptperiphs = cam_extend_new();
if (ptperiphs == NULL) {
printf("pt: Failed to alloc extend array!\n");
return;
}
/*
* Install a global async callback. This callback will
* receive async callbacks like "new device found".
@ -337,8 +321,6 @@ ptctor(struct cam_periph *periph, void *arg)
periph->softc = softc;
cam_extend_set(ptperiphs, periph->unit_number, periph);
devstat_add_entry(&softc->device_stats, "pt",
periph->unit_number, 0,
DEVSTAT_NO_BLOCKSIZE,
@ -348,6 +330,8 @@ ptctor(struct cam_periph *periph, void *arg)
softc->dev = make_dev(&pt_cdevsw, periph->unit_number, UID_ROOT,
GID_OPERATOR, 0600, "%s%d", periph->periph_name,
periph->unit_number);
softc->dev->si_drv1 = periph;
/*
* Add async callbacks for bus reset and
* bus device reset calls. I don't bother
@ -427,7 +411,6 @@ ptdtor(struct cam_periph *periph)
destroy_dev(softc->dev);
cam_extend_release(ptperiphs, periph->unit_number);
xpt_print_path(periph->path);
printf("removing device entry\n");
free(softc, M_DEVBUF);
@ -682,12 +665,9 @@ ptioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
{
struct cam_periph *periph;
struct pt_softc *softc;
int unit;
int error;
unit = minor(dev);
periph = cam_extend_get(ptperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return(ENXIO);

View File

@ -52,7 +52,6 @@
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_extend.h>
#include <cam/cam_periph.h>
#include <cam/cam_xpt_periph.h>
#include <cam/cam_debug.h>
@ -437,8 +436,6 @@ static struct cdevsw sa_cdevsw = {
/* flags */ D_TAPE,
};
static struct extend_array *saperiphs;
static int
saopen(dev_t dev, int flags, int fmt, struct thread *td)
{
@ -455,7 +452,7 @@ saopen(dev_t dev, int flags, int fmt, struct thread *td)
density = SADENSITY(dev);
s = splsoftcam();
periph = cam_extend_get(saperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL) {
(void) splx(s);
return (ENXIO);
@ -513,7 +510,7 @@ saclose(dev_t dev, int flag, int fmt, struct thread *td)
unit = SAUNIT(dev);
mode = SAMODE(dev);
periph = cam_extend_get(saperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);
@ -659,7 +656,6 @@ sastrategy(struct bio *bp)
{
struct cam_periph *periph;
struct sa_softc *softc;
u_int unit;
int s;
bp->bio_resid = bp->bio_bcount;
@ -667,8 +663,7 @@ sastrategy(struct bio *bp)
biofinish(bp, NULL, EINVAL);
return;
}
unit = SAUNIT(bp->bio_dev);
periph = cam_extend_get(saperiphs, unit);
periph = (struct cam_periph *)bp->bio_dev->si_drv1;
if (periph == NULL) {
biofinish(bp, NULL, ENXIO);
return;
@ -779,7 +774,7 @@ saioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *td)
error = 0; /* shut up gcc */
spaceop = 0; /* shut up gcc */
periph = cam_extend_get(saperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);
@ -1253,15 +1248,6 @@ sainit(void)
cam_status status;
struct cam_path *path;
/*
* Create our extend array for storing the devices we attach to.
*/
saperiphs = cam_extend_new();
if (saperiphs == NULL) {
printf("sa: Failed to alloc extend array!\n");
return;
}
/*
* Install a global async callback.
*/
@ -1356,7 +1342,6 @@ sacleanup(struct cam_periph *periph)
destroy_dev(softc->devs.mode_devs[i].er_dev);
}
cam_extend_release(saperiphs, periph->unit_number);
xpt_print_path(periph->path);
printf("removing device entry\n");
free(softc, M_DEVBUF);
@ -1438,7 +1423,6 @@ saregister(struct cam_periph *periph, void *arg)
bioq_init(&softc->bio_queue);
periph->softc = softc;
cam_extend_set(saperiphs, periph->unit_number, periph);
/*
* See if this device has any quirks.
@ -1472,6 +1456,7 @@ saregister(struct cam_periph *periph, void *arg)
softc->devs.ctl_dev = make_dev(&sa_cdevsw, SAMINOR(SA_CTLDEV,
periph->unit_number, 0, SA_ATYPE_R), UID_ROOT, GID_OPERATOR,
0660, "%s%d.ctl", periph->periph_name, periph->unit_number);
softc->devs.ctl_dev->si_drv1 = periph;
for (i = 0; i < SA_NUM_MODES; i++) {
@ -1479,28 +1464,35 @@ saregister(struct cam_periph *periph, void *arg)
SAMINOR(SA_NOT_CTLDEV, periph->unit_number, i, SA_ATYPE_R),
UID_ROOT, GID_OPERATOR, 0660, "%s%d.%d",
periph->periph_name, periph->unit_number, i);
softc->devs.mode_devs[i].r_dev->si_drv1 = periph;
softc->devs.mode_devs[i].nr_dev = make_dev(&sa_cdevsw,
SAMINOR(SA_NOT_CTLDEV, periph->unit_number, i, SA_ATYPE_NR),
UID_ROOT, GID_OPERATOR, 0660, "n%s%d.%d",
periph->periph_name, periph->unit_number, i);
softc->devs.mode_devs[i].nr_dev->si_drv1 = periph;
softc->devs.mode_devs[i].er_dev = make_dev(&sa_cdevsw,
SAMINOR(SA_NOT_CTLDEV, periph->unit_number, i, SA_ATYPE_ER),
UID_ROOT, GID_OPERATOR, 0660, "e%s%d.%d",
periph->periph_name, periph->unit_number, i);
softc->devs.mode_devs[i].er_dev->si_drv1 = periph;
/*
* Make the (well known) aliases for the first mode.
*/
if (i == 0) {
make_dev_alias(softc->devs.mode_devs[i].r_dev,
dev_t alias;
alias = make_dev_alias(softc->devs.mode_devs[i].r_dev,
"%s%d", periph->periph_name, periph->unit_number);
make_dev_alias(softc->devs.mode_devs[i].nr_dev,
alias->si_drv1 = periph;
alias = make_dev_alias(softc->devs.mode_devs[i].nr_dev,
"n%s%d", periph->periph_name, periph->unit_number);
make_dev_alias(softc->devs.mode_devs[i].er_dev,
alias->si_drv1 = periph;
alias = make_dev_alias(softc->devs.mode_devs[i].er_dev,
"e%s%d", periph->periph_name, periph->unit_number);
alias->si_drv1 = periph;
}
}

View File

@ -39,7 +39,6 @@
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_extend.h>
#include <cam/cam_periph.h>
#include <cam/cam_xpt_periph.h>
#include <cam/cam_debug.h>
@ -191,7 +190,6 @@ static struct cdevsw ses_cdevsw =
/* psize */ nopsize,
/* flags */ 0,
};
static struct extend_array *sesperiphs;
void
sesinit(void)
@ -199,15 +197,6 @@ sesinit(void)
cam_status status;
struct cam_path *path;
/*
* Create our extend array for storing the devices we attach to.
*/
sesperiphs = cam_extend_new();
if (sesperiphs == NULL) {
printf("ses: Failed to alloc extend array!\n");
return;
}
/*
* Install a global async callback. This callback will
* receive async callbacks like "new device found".
@ -267,7 +256,6 @@ sescleanup(struct cam_periph *periph)
destroy_dev(softc->ses_dev);
cam_extend_release(sesperiphs, periph->unit_number);
xpt_print_path(periph->path);
printf("removing device entry\n");
free(softc, M_DEVBUF);
@ -383,11 +371,10 @@ sesregister(struct cam_periph *periph, void *arg)
return (CAM_REQ_CMP_ERR);
}
cam_extend_set(sesperiphs, periph->unit_number, periph);
softc->ses_dev = make_dev(&ses_cdevsw, periph->unit_number,
UID_ROOT, GID_OPERATOR, 0600, "%s%d",
periph->periph_name, periph->unit_number);
softc->ses_dev->si_drv1 = periph;
/*
* Add an async callback so that we get
@ -433,7 +420,7 @@ sesopen(dev_t dev, int flags, int fmt, struct thread *td)
int error, s;
s = splsoftcam();
periph = cam_extend_get(sesperiphs, SESUNIT(dev));
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL) {
splx(s);
return (ENXIO);
@ -486,12 +473,11 @@ sesclose(dev_t dev, int flag, int fmt, struct thread *td)
{
struct cam_periph *periph;
struct ses_softc *softc;
int unit, error;
int error;
error = 0;
unit = SESUNIT(dev);
periph = cam_extend_get(sesperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);
@ -555,7 +541,7 @@ sesioctl(dev_t dev, u_long cmd, caddr_t arg_addr, int flag, struct thread *td)
else
addr = NULL;
periph = cam_extend_get(sesperiphs, SESUNIT(dev));
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);

View File

@ -41,7 +41,6 @@
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_extend.h>
#include <cam/cam_periph.h>
#include <cam/cam_queue.h>
#include <cam/cam_xpt_periph.h>

View File

@ -43,7 +43,6 @@
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_extend.h>
#include <cam/cam_periph.h>
#include <cam/cam_queue.h>
#include <cam/cam_xpt_periph.h>
@ -82,7 +81,7 @@ typedef enum {
#define MIN(a, b) ((a > b) ? b : a)
#define TARG_CONTROL_UNIT 0xffff00ff
#define TARG_IS_CONTROL_DEV(unit) ((unit) == TARG_CONTROL_UNIT)
#define TARG_IS_CONTROL_DEV(d) (minor((d)) == TARG_CONTROL_UNIT)
#define TARG_TAG_WILDCARD ((u_int)~0)
@ -236,20 +235,11 @@ static struct periph_driver targdriver =
PERIPHDRIVER_DECLARE(targ, targdriver);
static struct extend_array *targperiphs;
static dev_t targ_ctl_dev;
static void
targinit(void)
{
/*
* Create our extend array for storing the devices we attach to.
*/
targperiphs = cam_extend_new();
if (targperiphs == NULL) {
printf("targ: Failed to alloc extend array!\n");
return;
}
targ_ctl_dev = make_dev(&targ_cdevsw, TARG_CONTROL_UNIT, UID_ROOT,
GID_OPERATOR, 0600, "%s.ctl", "targ");
if (targ_ctl_dev == (dev_t) 0) {
@ -470,8 +460,6 @@ targctor(struct cam_periph *periph, void *arg)
periph->softc = softc;
softc->init_level++;
cam_extend_set(targperiphs, periph->unit_number, periph);
/*
* We start out life with a UA to indicate power-on/reset.
*/
@ -517,6 +505,7 @@ targctor(struct cam_periph *periph, void *arg)
softc->targ_dev = make_dev(&targ_cdevsw, periph->unit_number, UID_ROOT,
GID_OPERATOR, 0600, "%s%d",
periph->periph_name, periph->unit_number);
softc->targ_dev->si_drv1 = periph;
softc->init_level++;
return (CAM_REQ_CMP);
@ -533,8 +522,6 @@ targdtor(struct cam_periph *periph)
targdislun(periph);
cam_extend_release(targperiphs, periph->unit_number);
switch (softc->init_level) {
default:
/* FALLTHROUGH */
@ -555,19 +542,16 @@ targopen(dev_t dev, int flags, int fmt, struct thread *td)
{
struct cam_periph *periph;
struct targ_softc *softc;
u_int unit;
cam_status status;
int error;
int s;
unit = minor(dev);
/* An open of the control device always succeeds */
if (TARG_IS_CONTROL_DEV(unit))
if (TARG_IS_CONTROL_DEV(dev))
return 0;
s = splsoftcam();
periph = cam_extend_get(targperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL) {
splx(s);
return (ENXIO);
@ -614,18 +598,15 @@ targclose(dev_t dev, int flag, int fmt, struct thread *td)
{
struct cam_periph *periph;
struct targ_softc *softc;
u_int unit;
int s;
int error;
unit = minor(dev);
/* A close of the control device always succeeds */
if (TARG_IS_CONTROL_DEV(unit))
if (TARG_IS_CONTROL_DEV(dev))
return 0;
s = splsoftcam();
periph = cam_extend_get(targperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL) {
splx(s);
return (ENXIO);
@ -811,12 +792,10 @@ targioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
{
struct cam_periph *periph;
struct targ_softc *softc;
u_int unit;
int error;
unit = minor(dev);
error = 0;
if (TARG_IS_CONTROL_DEV(unit)) {
if (TARG_IS_CONTROL_DEV(dev)) {
switch (cmd) {
case OTARGCTLIOALLOCUNIT:
case TARGCTLIOALLOCUNIT:
@ -838,7 +817,7 @@ targioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
return (error);
}
periph = cam_extend_get(targperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);
softc = (struct targ_softc *)periph->softc;
@ -1084,17 +1063,14 @@ targpoll(dev_t dev, int poll_events, struct thread *td)
{
struct cam_periph *periph;
struct targ_softc *softc;
u_int unit;
int revents;
int s;
unit = minor(dev);
/* ioctl is the only supported operation of the control device */
if (TARG_IS_CONTROL_DEV(unit))
if (TARG_IS_CONTROL_DEV(dev))
return EINVAL;
periph = cam_extend_get(targperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);
softc = (struct targ_softc *)periph->softc;
@ -1128,11 +1104,8 @@ targpoll(dev_t dev, int poll_events, struct thread *td)
static int
targread(dev_t dev, struct uio *uio, int ioflag)
{
u_int unit;
unit = minor(dev);
/* ioctl is the only supported operation of the control device */
if (TARG_IS_CONTROL_DEV(unit))
if (TARG_IS_CONTROL_DEV(dev))
return EINVAL;
if (uio->uio_iovcnt == 0
@ -1143,7 +1116,7 @@ targread(dev_t dev, struct uio *uio, int ioflag)
int s;
s = splcam();
periph = cam_extend_get(targperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);
softc = (struct targ_softc *)periph->softc;
@ -1158,11 +1131,8 @@ targread(dev_t dev, struct uio *uio, int ioflag)
static int
targwrite(dev_t dev, struct uio *uio, int ioflag)
{
u_int unit;
unit = minor(dev);
/* ioctl is the only supported operation of the control device */
if (TARG_IS_CONTROL_DEV(unit))
if (TARG_IS_CONTROL_DEV(dev))
return EINVAL;
if (uio->uio_iovcnt == 0
@ -1173,7 +1143,7 @@ targwrite(dev_t dev, struct uio *uio, int ioflag)
int s;
s = splcam();
periph = cam_extend_get(targperiphs, unit);
periph = (struct cam_periph *)dev->si_drv1;
if (periph == NULL)
return (ENXIO);
softc = (struct targ_softc *)periph->softc;
@ -1195,19 +1165,17 @@ targstrategy(struct bio *bp)
{
struct cam_periph *periph;
struct targ_softc *softc;
u_int unit;
int s;
unit = minor(bp->bio_dev);
bp->bio_resid = bp->bio_bcount;
/* ioctl is the only supported operation of the control device */
if (TARG_IS_CONTROL_DEV(unit)) {
if (TARG_IS_CONTROL_DEV(bp->bio_dev)) {
biofinish(bp, NULL, EINVAL);
return;
}
periph = cam_extend_get(targperiphs, unit);
periph = (struct cam_periph *)bp->bio_dev->si_drv1;
if (periph == NULL) {
biofinish(bp, NULL, ENXIO);
return;

View File

@ -24,7 +24,6 @@ kern/bus_if.m standard
kern/clock_if.m optional genclock
kern/linker_if.m standard
cam/cam.c optional scbus
cam/cam_extend.c optional scbus
cam/cam_periph.c optional scbus
cam/cam_queue.c optional scbus
cam/cam_sim.c optional scbus