1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-30 08:19:09 +00:00

Revert a driver API change to xpt_alloc_ccb that isn't necessary. Fix a

couple of associated error checks.
This commit is contained in:
Scott Long 2007-04-18 04:58:53 +00:00
parent 8d36aa79ef
commit 8008a935a7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=168831
7 changed files with 35 additions and 24 deletions

View File

@ -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){

View File

@ -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);

View File

@ -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));

View File

@ -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,

View File

@ -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;

View File

@ -2148,7 +2148,7 @@ isp_make_here(ispsoftc_t *isp, int tgt)
* Allocate a CCB, create a wildcard path for this bus,
* and schedule a rescan.
*/
ccb = xpt_alloc_ccb_nowait(isp->isp_osinfo.sim);
ccb = xpt_alloc_ccb_nowait();
if (ccb == NULL) {
isp_prt(isp, ISP_LOGWARN, "unable to alloc CCB for rescan");
CAMLOCK_2_ISPLOCK(mpt);

View File

@ -2087,7 +2087,6 @@ mpt_cam_event(struct mpt_softc *mpt, request_t *req,
{
union ccb *ccb;
uint32_t pathid;
struct cam_sim *sim;
/*
* In general this means a device has been added to the loop.
*/
@ -2096,17 +2095,16 @@ mpt_cam_event(struct mpt_softc *mpt, request_t *req,
break;
}
if (mpt->phydisk_sim) {
sim = mpt->phydisk_sim;
pathid = cam_sim_path(mpt->phydisk_sim);
} else {
sim = mpt->sim;
pathid = cam_sim_path(mpt->sim);
}
pathid = cam_sim_path(sim);
MPTLOCK_2_CAMLOCK(mpt);
/*
* Allocate a CCB, create a wildcard path for this bus,
* and schedule a rescan.
*/
ccb = xpt_alloc_ccb_nowait(sim);
ccb = xpt_alloc_ccb_nowait();
if (ccb == NULL) {
mpt_prt(mpt, "unable to alloc CCB for rescan\n");
CAMLOCK_2_MPTLOCK(mpt);