[Midnightbsd-cvs] src [8244] trunk/sys/cam: dont duplicate code
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Sep 17 17:32:52 EDT 2016
Revision: 8244
http://svnweb.midnightbsd.org/src/?rev=8244
Author: laffer1
Date: 2016-09-17 17:32:52 -0400 (Sat, 17 Sep 2016)
Log Message:
-----------
dont duplicate code
Modified Paths:
--------------
trunk/sys/cam/ata/ata_xpt.c
trunk/sys/cam/cam_xpt.c
trunk/sys/cam/scsi/scsi_xpt.c
Modified: trunk/sys/cam/ata/ata_xpt.c
===================================================================
--- trunk/sys/cam/ata/ata_xpt.c 2016-09-17 21:32:34 UTC (rev 8243)
+++ trunk/sys/cam/ata/ata_xpt.c 2016-09-17 21:32:52 UTC (rev 8244)
@@ -1458,29 +1458,20 @@
}
if (request_ccb == NULL) {
- request_ccb = malloc(sizeof(union ccb), M_CAMXPT, M_NOWAIT);
+ request_ccb = xpt_alloc_ccb_nowait();
if (request_ccb == NULL) {
xpt_print(path, "xpt_scan_lun: can't allocate CCB, "
"can't continue\n");
return;
}
- new_path = malloc(sizeof(*new_path), M_CAMXPT, M_NOWAIT);
- 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,
+ status = xpt_create_path(&new_path, xpt_periph,
path->bus->path_id,
path->target->target_id,
path->device->lun_id);
-
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");
- free(request_ccb, M_CAMXPT);
- free(new_path, M_CAMXPT);
+ xpt_free_ccb(request_ccb);
return;
}
xpt_setup_ccb(&request_ccb->ccb_h, new_path, CAM_PRIORITY_XPT);
@@ -1520,9 +1511,9 @@
static void
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);
- free(done_ccb, M_CAMXPT);
+
+ xpt_free_path(done_ccb->ccb_h.path);
+ xpt_free_ccb(done_ccb);
}
static struct cam_ed *
Modified: trunk/sys/cam/cam_xpt.c
===================================================================
--- trunk/sys/cam/cam_xpt.c 2016-09-17 21:32:34 UTC (rev 8243)
+++ trunk/sys/cam/cam_xpt.c 2016-09-17 21:32:52 UTC (rev 8244)
@@ -3857,12 +3857,6 @@
/* Couldn't satisfy request */
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) {
sim->path_id =
xptpathid(sim->sim_name, sim->unit_number, sim->bus_id);
@@ -3896,7 +3890,7 @@
*/
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);
if (status != CAM_REQ_CMP) {
xpt_release_bus(new_bus);
Modified: trunk/sys/cam/scsi/scsi_xpt.c
===================================================================
--- trunk/sys/cam/scsi/scsi_xpt.c 2016-09-17 21:32:34 UTC (rev 8243)
+++ trunk/sys/cam/scsi/scsi_xpt.c 2016-09-17 21:32:52 UTC (rev 8244)
@@ -2243,29 +2243,20 @@
}
if (request_ccb == NULL) {
- request_ccb = malloc(sizeof(union ccb), M_CAMXPT, M_NOWAIT);
+ request_ccb = xpt_alloc_ccb_nowait();
if (request_ccb == NULL) {
xpt_print(path, "scsi_scan_lun: can't allocate CCB, "
"can't continue\n");
return;
}
- new_path = malloc(sizeof(*new_path), M_CAMXPT, M_NOWAIT);
- 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,
+ status = xpt_create_path(&new_path, xpt_periph,
path->bus->path_id,
path->target->target_id,
path->device->lun_id);
-
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");
- free(request_ccb, M_CAMXPT);
- free(new_path, M_CAMXPT);
+ xpt_free_ccb(request_ccb);
return;
}
xpt_setup_ccb(&request_ccb->ccb_h, new_path, CAM_PRIORITY_XPT);
@@ -2304,9 +2295,9 @@
static void
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);
- free(done_ccb, M_CAMXPT);
+
+ xpt_free_path(done_ccb->ccb_h.path);
+ xpt_free_ccb(done_ccb);
}
static struct cam_ed *
More information about the Midnightbsd-cvs
mailing list