summaryrefslogtreecommitdiffstats
path: root/sys/cam
diff options
context:
space:
mode:
authorscottl <scottl@FreeBSD.org>2007-04-18 04:58:53 +0000
committerscottl <scottl@FreeBSD.org>2007-04-18 04:58:53 +0000
commita40b57339d0ae20db108ee7c13ef670039d1f2c7 (patch)
tree7a504d9115e85179155d0fb6137bd3588944fe08 /sys/cam
parent4db8f3e0cc218ebbc69857ffdd274e67b815cd31 (diff)
downloadFreeBSD-src-a40b57339d0ae20db108ee7c13ef670039d1f2c7.zip
FreeBSD-src-a40b57339d0ae20db108ee7c13ef670039d1f2c7.tar.gz
Revert a driver API change to xpt_alloc_ccb that isn't necessary. Fix a
couple of associated error checks.
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/cam_xpt.c39
-rw-r--r--sys/cam/cam_xpt_periph.h4
-rw-r--r--sys/cam/scsi/scsi_low.c2
-rw-r--r--sys/cam/scsi/scsi_pass.c2
-rw-r--r--sys/cam/scsi/scsi_sg.c2
5 files changed, 31 insertions, 18 deletions
diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c
index a34b343..86e5344 100644
--- a/sys/cam/cam_xpt.c
+++ b/sys/cam/cam_xpt.c
@@ -1072,7 +1072,7 @@ xptioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td
case XPT_ENG_INQ:
case XPT_SCAN_LUN:
- ccb = xpt_alloc_ccb(bus->sim);
+ ccb = xpt_alloc_ccb();
CAM_SIM_LOCK(bus->sim);
@@ -4979,26 +4979,20 @@ xpt_done(union ccb *done_ccb)
}
union ccb *
-xpt_alloc_ccb(struct cam_sim *sim)
+xpt_alloc_ccb()
{
union ccb *new_ccb;
new_ccb = malloc(sizeof(*new_ccb), M_CAMXPT, M_WAITOK);
- if ((sim != NULL) && ((sim->flags & CAM_SIM_MPSAFE) == 0)) {
- callout_handle_init(&new_ccb->ccb_h.timeout_ch);
- }
return (new_ccb);
}
union ccb *
-xpt_alloc_ccb_nowait(struct cam_sim *sim)
+xpt_alloc_ccb_nowait()
{
union ccb *new_ccb;
new_ccb = malloc(sizeof(*new_ccb), M_CAMXPT, M_NOWAIT);
- if ((sim != NULL) && ((sim->flags & CAM_SIM_MPSAFE) == 0)) {
- callout_handle_init(&new_ccb->ccb_h.timeout_ch);
- }
return (new_ccb);
}
@@ -5029,11 +5023,13 @@ xpt_get_ccb(struct cam_ed *device)
s = splsoftcam();
sim = device->sim;
if ((new_ccb = (union ccb *)SLIST_FIRST(&sim->ccb_freeq)) == NULL) {
- new_ccb = xpt_alloc_ccb_nowait(sim);
+ new_ccb = xpt_alloc_ccb_nowait();
if (new_ccb == NULL) {
splx(s);
return (NULL);
}
+ if ((sim->flags & CAM_SIM_MPSAFE) == 0)
+ callout_handle_init(&new_ccb->ccb_h.timeout_ch);
SLIST_INSERT_HEAD(&sim->ccb_freeq, &new_ccb->ccb_h,
xpt_links.sle);
sim->ccb_count++;
@@ -5353,7 +5349,12 @@ xpt_scan_bus(struct cam_periph *periph, union ccb *request_ccb)
u_int initiator_id;
/* Find out the characteristics of the bus */
- work_ccb = xpt_alloc_ccb_nowait(periph->sim);
+ work_ccb = xpt_alloc_ccb_nowait();
+ if (work_ccb == NULL) {
+ request_ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
+ xpt_done(request_ccb);
+ return;
+ }
xpt_setup_ccb(&work_ccb->ccb_h, request_ccb->ccb_h.path,
request_ccb->ccb_h.pinfo.priority);
work_ccb->ccb_h.func_code = XPT_PATH_INQ;
@@ -5418,7 +5419,14 @@ xpt_scan_bus(struct cam_periph *periph, union ccb *request_ccb)
xpt_done(request_ccb);
break;
}
- work_ccb = xpt_alloc_ccb_nowait(periph->sim);
+ work_ccb = xpt_alloc_ccb_nowait();
+ if (work_ccb == NULL) {
+ free(scan_info, M_TEMP);
+ xpt_free_path(path);
+ request_ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
+ xpt_done(request_ccb);
+ break;
+ }
xpt_setup_ccb(&work_ccb->ccb_h, path,
request_ccb->ccb_h.pinfo.priority);
work_ccb->ccb_h.func_code = XPT_SCAN_LUN;
@@ -6970,7 +6978,12 @@ xptconfigfunc(struct cam_eb *bus, void *arg)
cam_status status;
int can_negotiate;
- work_ccb = xpt_alloc_ccb_nowait(bus->sim);
+ work_ccb = xpt_alloc_ccb_nowait();
+ if (work_ccb == NULL) {
+ busses_to_config--;
+ xpt_finishconfig(xpt_periph, NULL);
+ return(0);
+ }
if ((status = xpt_create_path(&path, xpt_periph, bus->path_id,
CAM_TARGET_WILDCARD,
CAM_LUN_WILDCARD)) !=CAM_REQ_CMP){
diff --git a/sys/cam/cam_xpt_periph.h b/sys/cam/cam_xpt_periph.h
index 9c4a3bb..c6b8cc2 100644
--- a/sys/cam/cam_xpt_periph.h
+++ b/sys/cam/cam_xpt_periph.h
@@ -38,8 +38,8 @@
/* Functions accessed by the peripheral drivers */
#ifdef _KERNEL
void xpt_polled_action(union ccb *ccb);
-union ccb *xpt_alloc_ccb(struct cam_sim *sim);
-union ccb *xpt_alloc_ccb_nowait(struct cam_sim *sim);
+union ccb *xpt_alloc_ccb(void);
+union ccb *xpt_alloc_ccb_nowait(void);
void xpt_free_ccb(union ccb *free_ccb);
void xpt_release_ccb(union ccb *released_ccb);
void xpt_schedule(struct cam_periph *perph, u_int32_t new_priority);
diff --git a/sys/cam/scsi/scsi_low.c b/sys/cam/scsi/scsi_low.c
index 296af9b..695815c 100644
--- a/sys/cam/scsi/scsi_low.c
+++ b/sys/cam/scsi/scsi_low.c
@@ -966,7 +966,7 @@ scsi_low_rescan_bus_cam(slp)
struct scsi_low_softc *slp;
{
struct cam_path *path;
- union ccb *ccb = xpt_alloc_ccb(NULL);
+ union ccb *ccb = xpt_alloc_ccb();
cam_status status;
bzero(ccb, sizeof(union ccb));
diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c
index 62aaccf..5617ef0 100644
--- a/sys/cam/scsi/scsi_pass.c
+++ b/sys/cam/scsi/scsi_pass.c
@@ -490,7 +490,7 @@ passioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *t
inccb->ccb_h.pinfo.priority);
ccb_malloced = 0;
} else {
- ccb = xpt_alloc_ccb_nowait(periph->sim);
+ ccb = xpt_alloc_ccb_nowait();
if (ccb != NULL)
xpt_setup_ccb(&ccb->ccb_h, periph->path,
diff --git a/sys/cam/scsi/scsi_sg.c b/sys/cam/scsi/scsi_sg.c
index 9084654..402d4b4 100644
--- a/sys/cam/scsi/scsi_sg.c
+++ b/sys/cam/scsi/scsi_sg.c
@@ -699,7 +699,7 @@ sgwrite(struct cdev *dev, struct uio *uio, int ioflag)
if (error)
goto out_hdr;
- ccb = xpt_alloc_ccb(periph->sim);
+ ccb = xpt_alloc_ccb();
if (ccb == NULL) {
error = ENOMEM;
goto out_hdr;
OpenPOWER on IntegriCloud