mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-26 16:18:31 +00:00
Don't duplicate path/ccb allocation code, use existing functions.
This commit is contained in:
parent
f0c51ba5c7
commit
32aa80a6bd
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=241455
@ -1462,29 +1462,20 @@ ata_scan_lun(struct cam_periph *periph, struct cam_path *path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (request_ccb == NULL) {
|
if (request_ccb == NULL) {
|
||||||
request_ccb = malloc(sizeof(union ccb), M_CAMXPT, M_NOWAIT);
|
request_ccb = xpt_alloc_ccb_nowait();
|
||||||
if (request_ccb == NULL) {
|
if (request_ccb == NULL) {
|
||||||
xpt_print(path, "xpt_scan_lun: can't allocate CCB, "
|
xpt_print(path, "xpt_scan_lun: can't allocate CCB, "
|
||||||
"can't continue\n");
|
"can't continue\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new_path = malloc(sizeof(*new_path), M_CAMXPT, M_NOWAIT);
|
status = xpt_create_path(&new_path, xpt_periph,
|
||||||
if (new_path == NULL) {
|
|
||||||
xpt_print(path, "xpt_scan_lun: can't allocate path, "
|
|
||||||
"can't continue\n");
|
|
||||||
free(request_ccb, M_CAMXPT);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
status = xpt_compile_path(new_path, xpt_periph,
|
|
||||||
path->bus->path_id,
|
path->bus->path_id,
|
||||||
path->target->target_id,
|
path->target->target_id,
|
||||||
path->device->lun_id);
|
path->device->lun_id);
|
||||||
|
|
||||||
if (status != CAM_REQ_CMP) {
|
if (status != CAM_REQ_CMP) {
|
||||||
xpt_print(path, "xpt_scan_lun: can't compile path, "
|
xpt_print(path, "xpt_scan_lun: can't create path, "
|
||||||
"can't continue\n");
|
"can't continue\n");
|
||||||
free(request_ccb, M_CAMXPT);
|
xpt_free_ccb(request_ccb);
|
||||||
free(new_path, M_CAMXPT);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
xpt_setup_ccb(&request_ccb->ccb_h, new_path, CAM_PRIORITY_XPT);
|
xpt_setup_ccb(&request_ccb->ccb_h, new_path, CAM_PRIORITY_XPT);
|
||||||
@ -1524,9 +1515,9 @@ ata_scan_lun(struct cam_periph *periph, struct cam_path *path,
|
|||||||
static void
|
static void
|
||||||
xptscandone(struct cam_periph *periph, union ccb *done_ccb)
|
xptscandone(struct cam_periph *periph, union ccb *done_ccb)
|
||||||
{
|
{
|
||||||
xpt_release_path(done_ccb->ccb_h.path);
|
|
||||||
free(done_ccb->ccb_h.path, M_CAMXPT);
|
xpt_free_path(done_ccb->ccb_h.path);
|
||||||
free(done_ccb, M_CAMXPT);
|
xpt_free_ccb(done_ccb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cam_ed *
|
static struct cam_ed *
|
||||||
|
@ -3857,12 +3857,6 @@ xpt_bus_register(struct cam_sim *sim, device_t parent, u_int32_t bus)
|
|||||||
/* Couldn't satisfy request */
|
/* Couldn't satisfy request */
|
||||||
return (CAM_RESRC_UNAVAIL);
|
return (CAM_RESRC_UNAVAIL);
|
||||||
}
|
}
|
||||||
path = (struct cam_path *)malloc(sizeof(*path), M_CAMXPT, M_NOWAIT);
|
|
||||||
if (path == NULL) {
|
|
||||||
free(new_bus, M_CAMXPT);
|
|
||||||
return (CAM_RESRC_UNAVAIL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(sim->sim_name, "xpt") != 0) {
|
if (strcmp(sim->sim_name, "xpt") != 0) {
|
||||||
sim->path_id =
|
sim->path_id =
|
||||||
xptpathid(sim->sim_name, sim->unit_number, sim->bus_id);
|
xptpathid(sim->sim_name, sim->unit_number, sim->bus_id);
|
||||||
@ -3896,7 +3890,7 @@ xpt_bus_register(struct cam_sim *sim, device_t parent, u_int32_t bus)
|
|||||||
*/
|
*/
|
||||||
new_bus->xport = &xport_default;
|
new_bus->xport = &xport_default;
|
||||||
|
|
||||||
status = xpt_compile_path(path, /*periph*/NULL, sim->path_id,
|
status = xpt_create_path(&path, /*periph*/NULL, sim->path_id,
|
||||||
CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD);
|
CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD);
|
||||||
if (status != CAM_REQ_CMP) {
|
if (status != CAM_REQ_CMP) {
|
||||||
xpt_release_bus(new_bus);
|
xpt_release_bus(new_bus);
|
||||||
|
@ -2243,29 +2243,20 @@ scsi_scan_lun(struct cam_periph *periph, struct cam_path *path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (request_ccb == NULL) {
|
if (request_ccb == NULL) {
|
||||||
request_ccb = malloc(sizeof(union ccb), M_CAMXPT, M_NOWAIT);
|
request_ccb = xpt_alloc_ccb_nowait();
|
||||||
if (request_ccb == NULL) {
|
if (request_ccb == NULL) {
|
||||||
xpt_print(path, "scsi_scan_lun: can't allocate CCB, "
|
xpt_print(path, "scsi_scan_lun: can't allocate CCB, "
|
||||||
"can't continue\n");
|
"can't continue\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new_path = malloc(sizeof(*new_path), M_CAMXPT, M_NOWAIT);
|
status = xpt_create_path(&new_path, xpt_periph,
|
||||||
if (new_path == NULL) {
|
|
||||||
xpt_print(path, "scsi_scan_lun: can't allocate path, "
|
|
||||||
"can't continue\n");
|
|
||||||
free(request_ccb, M_CAMXPT);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
status = xpt_compile_path(new_path, xpt_periph,
|
|
||||||
path->bus->path_id,
|
path->bus->path_id,
|
||||||
path->target->target_id,
|
path->target->target_id,
|
||||||
path->device->lun_id);
|
path->device->lun_id);
|
||||||
|
|
||||||
if (status != CAM_REQ_CMP) {
|
if (status != CAM_REQ_CMP) {
|
||||||
xpt_print(path, "scsi_scan_lun: can't compile path, "
|
xpt_print(path, "scsi_scan_lun: can't create path, "
|
||||||
"can't continue\n");
|
"can't continue\n");
|
||||||
free(request_ccb, M_CAMXPT);
|
xpt_free_ccb(request_ccb);
|
||||||
free(new_path, M_CAMXPT);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
xpt_setup_ccb(&request_ccb->ccb_h, new_path, CAM_PRIORITY_XPT);
|
xpt_setup_ccb(&request_ccb->ccb_h, new_path, CAM_PRIORITY_XPT);
|
||||||
@ -2304,9 +2295,9 @@ scsi_scan_lun(struct cam_periph *periph, struct cam_path *path,
|
|||||||
static void
|
static void
|
||||||
xptscandone(struct cam_periph *periph, union ccb *done_ccb)
|
xptscandone(struct cam_periph *periph, union ccb *done_ccb)
|
||||||
{
|
{
|
||||||
xpt_release_path(done_ccb->ccb_h.path);
|
|
||||||
free(done_ccb->ccb_h.path, M_CAMXPT);
|
xpt_free_path(done_ccb->ccb_h.path);
|
||||||
free(done_ccb, M_CAMXPT);
|
xpt_free_ccb(done_ccb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cam_ed *
|
static struct cam_ed *
|
||||||
|
Loading…
Reference in New Issue
Block a user