From owner-svn-src-all@FreeBSD.ORG Thu Oct 11 19:57:12 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9D986256; Thu, 11 Oct 2012 19:57:12 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 85E3A8FC08; Thu, 11 Oct 2012 19:57:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q9BJvCqc077012; Thu, 11 Oct 2012 19:57:12 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9BJvCjC077008; Thu, 11 Oct 2012 19:57:12 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201210111957.q9BJvCjC077008@svn.freebsd.org> From: Alexander Motin Date: Thu, 11 Oct 2012 19:57:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r241455 - in head/sys/cam: . ata scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Oct 2012 19:57:12 -0000 Author: mav Date: Thu Oct 11 19:57:11 2012 New Revision: 241455 URL: http://svn.freebsd.org/changeset/base/241455 Log: Don't duplicate path/ccb allocation code, use existing functions. Modified: head/sys/cam/ata/ata_xpt.c head/sys/cam/cam_xpt.c head/sys/cam/scsi/scsi_xpt.c Modified: head/sys/cam/ata/ata_xpt.c ============================================================================== --- head/sys/cam/ata/ata_xpt.c Thu Oct 11 19:39:54 2012 (r241454) +++ head/sys/cam/ata/ata_xpt.c Thu Oct 11 19:57:11 2012 (r241455) @@ -1462,29 +1462,20 @@ ata_scan_lun(struct cam_periph *periph, } 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); @@ -1524,9 +1515,9 @@ ata_scan_lun(struct cam_periph *periph, 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: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Thu Oct 11 19:39:54 2012 (r241454) +++ head/sys/cam/cam_xpt.c Thu Oct 11 19:57:11 2012 (r241455) @@ -3857,12 +3857,6 @@ xpt_bus_register(struct cam_sim *sim, de /* 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 @@ xpt_bus_register(struct cam_sim *sim, de */ 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: head/sys/cam/scsi/scsi_xpt.c ============================================================================== --- head/sys/cam/scsi/scsi_xpt.c Thu Oct 11 19:39:54 2012 (r241454) +++ head/sys/cam/scsi/scsi_xpt.c Thu Oct 11 19:57:11 2012 (r241455) @@ -2243,29 +2243,20 @@ scsi_scan_lun(struct cam_periph *periph, } 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 @@ scsi_scan_lun(struct cam_periph *periph, 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 *