Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 May 2014 06:56:59 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r265633 - in stable/9: sbin/camcontrol sys/cam sys/cam/scsi
Message-ID:  <201405080656.s486uxmi045532@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Thu May  8 06:56:59 2014
New Revision: 265633
URL: http://svnweb.freebsd.org/changeset/base/265633

Log:
  MFC r260509:
  Replace several instances of -1 with appropriate CAM_*_WILDCARD and types.
  
  It was equal before r259397, but for good or bad, not any more for LUNs.
  
  This change fixes at least CAM debugging.

Modified:
  stable/9/sbin/camcontrol/camcontrol.c
  stable/9/sys/cam/cam_debug.h
  stable/9/sys/cam/cam_xpt.c
  stable/9/sys/cam/scsi/scsi_low.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/sbin/   (props changed)
  stable/9/sbin/camcontrol/   (props changed)
  stable/9/sys/   (props changed)

Modified: stable/9/sbin/camcontrol/camcontrol.c
==============================================================================
--- stable/9/sbin/camcontrol/camcontrol.c	Thu May  8 06:55:48 2014	(r265632)
+++ stable/9/sbin/camcontrol/camcontrol.c	Thu May  8 06:56:59 2014	(r265633)
@@ -264,11 +264,12 @@ static int scsiinquiry(struct cam_device
 static int scsiserial(struct cam_device *device, int retry_count, int timeout);
 static int camxferrate(struct cam_device *device);
 #endif /* MINIMALISTIC */
-static int parse_btl(char *tstr, int *bus, int *target, int *lun,
-		     cam_argmask *arglst);
+static int parse_btl(char *tstr, path_id_t *bus, target_id_t *target,
+		     lun_id_t *lun, cam_argmask *arglst);
 static int dorescan_or_reset(int argc, char **argv, int rescan);
-static int rescan_or_reset_bus(int bus, int rescan);
-static int scanlun_or_reset_dev(int bus, int target, int lun, int scan);
+static int rescan_or_reset_bus(path_id_t bus, int rescan);
+static int scanlun_or_reset_dev(path_id_t bus, target_id_t target,
+    lun_id_t lun, int scan);
 #ifndef MINIMALISTIC
 static int readdefects(struct cam_device *device, int argc, char **argv,
 		       char *combinedopt, int retry_count, int timeout);
@@ -3001,7 +3002,8 @@ atasecurity(struct cam_device *device, i
  * Returns the number of parsed components, or 0.
  */
 static int
-parse_btl(char *tstr, int *bus, int *target, int *lun, cam_argmask *arglst)
+parse_btl(char *tstr, path_id_t *bus, target_id_t *target, lun_id_t *lun,
+    cam_argmask *arglst)
 {
 	char *tmpstr;
 	int convs = 0;
@@ -3037,7 +3039,9 @@ dorescan_or_reset(int argc, char **argv,
 	static const char must[] =
 		"you must specify \"all\", a bus, or a bus:target:lun to %s";
 	int rv, error = 0;
-	int bus = -1, target = -1, lun = -1;
+	path_id_t bus = CAM_BUS_WILDCARD;
+	target_id_t target = CAM_TARGET_WILDCARD;
+	lun_id_t lun = CAM_LUN_WILDCARD;
 	char *tstr;
 
 	if (argc < 3) {
@@ -3069,7 +3073,7 @@ dorescan_or_reset(int argc, char **argv,
 }
 
 static int
-rescan_or_reset_bus(int bus, int rescan)
+rescan_or_reset_bus(path_id_t bus, int rescan)
 {
 	union ccb ccb, matchccb;
 	int fd, retval;
@@ -3083,7 +3087,7 @@ rescan_or_reset_bus(int bus, int rescan)
 		return(1);
 	}
 
-	if (bus != -1) {
+	if (bus != CAM_BUS_WILDCARD) {
 		ccb.ccb_h.func_code = rescan ? XPT_SCAN_BUS : XPT_RESET_BUS;
 		ccb.ccb_h.path_id = bus;
 		ccb.ccb_h.target_id = CAM_TARGET_WILDCARD;
@@ -3183,7 +3187,7 @@ rescan_or_reset_bus(int bus, int rescan)
 			 * We don't want to rescan or reset the xpt bus.
 			 * See above.
 			 */
-			if ((int)bus_result->path_id == -1)
+			if (bus_result->path_id == CAM_XPT_PATH_ID)
 				continue;
 
 			ccb.ccb_h.func_code = rescan ? XPT_SCAN_BUS :
@@ -3236,7 +3240,7 @@ bailout:
 }
 
 static int
-scanlun_or_reset_dev(int bus, int target, int lun, int scan)
+scanlun_or_reset_dev(path_id_t bus, target_id_t target, lun_id_t lun, int scan)
 {
 	union ccb ccb;
 	struct cam_device *device;
@@ -3244,18 +3248,18 @@ scanlun_or_reset_dev(int bus, int target
 
 	device = NULL;
 
-	if (bus < 0) {
+	if (bus == CAM_BUS_WILDCARD) {
 		warnx("invalid bus number %d", bus);
 		return(1);
 	}
 
-	if (target < 0) {
+	if (target == CAM_TARGET_WILDCARD) {
 		warnx("invalid target number %d", target);
 		return(1);
 	}
 
-	if (lun < 0) {
-		warnx("invalid lun number %d", lun);
+	if (lun == CAM_LUN_WILDCARD) {
+		warnx("invalid lun number %jx", (uintmax_t)lun);
 		return(1);
 	}
 
@@ -3313,12 +3317,12 @@ scanlun_or_reset_dev(int bus, int target
 	if (((ccb.ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)
 	 || ((!scan)
 	  && ((ccb.ccb_h.status & CAM_STATUS_MASK) == CAM_BDR_SENT))) {
-		fprintf(stdout, "%s of %d:%d:%d was successful\n",
-		    scan? "Re-scan" : "Reset", bus, target, lun);
+		fprintf(stdout, "%s of %d:%d:%jx was successful\n",
+		    scan? "Re-scan" : "Reset", bus, target, (uintmax_t)lun);
 		return(0);
 	} else {
-		fprintf(stdout, "%s of %d:%d:%d returned error %#x\n",
-		    scan? "Re-scan" : "Reset", bus, target, lun,
+		fprintf(stdout, "%s of %d:%d:%jx returned error %#x\n",
+		    scan? "Re-scan" : "Reset", bus, target, (uintmax_t)lun,
 		    ccb.ccb_h.status & CAM_STATUS_MASK);
 		return(1);
 	}
@@ -4200,7 +4204,9 @@ static int
 camdebug(int argc, char **argv, char *combinedopt)
 {
 	int c, fd;
-	int bus = -1, target = -1, lun = -1;
+	path_id_t bus = CAM_BUS_WILDCARD;
+	target_id_t target = CAM_TARGET_WILDCARD;
+	lun_id_t lun = CAM_LUN_WILDCARD;
 	char *tstr, *tmpstr = NULL;
 	union ccb ccb;
 	int error = 0;
@@ -4320,8 +4326,8 @@ camdebug(int argc, char **argv, char *co
 				} else {
 					fprintf(stderr,
 						"Debugging enabled for "
-						"%d:%d:%d\n",
-						bus, target, lun);
+						"%d:%d:%jx\n",
+						bus, target, (uintmax_t)lun);
 				}
 			}
 		}
@@ -7967,7 +7973,9 @@ main(int argc, char **argv)
 	int error = 0, optstart = 2;
 	int devopen = 1;
 #ifndef MINIMALISTIC
-	int bus, target, lun;
+	path_id_t bus;
+	target_id_t target;
+	lun_id_t lun;
 #endif /* MINIMALISTIC */
 
 	cmdlist = CAM_CMD_NONE;

Modified: stable/9/sys/cam/cam_debug.h
==============================================================================
--- stable/9/sys/cam/cam_debug.h	Thu May  8 06:55:48 2014	(r265632)
+++ stable/9/sys/cam/cam_debug.h	Thu May  8 06:56:59 2014	(r265633)
@@ -61,13 +61,13 @@ typedef enum {
 #endif
 
 #ifndef CAM_DEBUG_BUS
-#define CAM_DEBUG_BUS		(-1)
+#define CAM_DEBUG_BUS		CAM_BUS_WILDCARD
 #endif
 #ifndef CAM_DEBUG_TARGET
-#define CAM_DEBUG_TARGET	(-1)
+#define CAM_DEBUG_TARGET	CAM_TARGET_WILDCARD
 #endif
 #ifndef CAM_DEBUG_LUN
-#define CAM_DEBUG_LUN		(-1)
+#define CAM_DEBUG_LUN		CAM_LUN_WILDCARD
 #endif
 
 #ifndef CAM_DEBUG_DELAY

Modified: stable/9/sys/cam/cam_xpt.c
==============================================================================
--- stable/9/sys/cam/cam_xpt.c	Thu May  8 06:55:48 2014	(r265632)
+++ stable/9/sys/cam/cam_xpt.c	Thu May  8 06:56:59 2014	(r265633)
@@ -2006,13 +2006,15 @@ xptplistperiphfunc(struct cam_periph *pe
 			cdm->matches[j].result.periph_result.target_id =
 				periph->path->target->target_id;
 		else
-			cdm->matches[j].result.periph_result.target_id = -1;
+			cdm->matches[j].result.periph_result.target_id =
+				CAM_TARGET_WILDCARD;
 
 		if (periph->path->device)
 			cdm->matches[j].result.periph_result.target_lun =
 				periph->path->device->lun_id;
 		else
-			cdm->matches[j].result.periph_result.target_lun = -1;
+			cdm->matches[j].result.periph_result.target_lun =
+				CAM_LUN_WILDCARD;
 
 		cdm->matches[j].result.periph_result.unit_number =
 			periph->unit_number;

Modified: stable/9/sys/cam/scsi/scsi_low.c
==============================================================================
--- stable/9/sys/cam/scsi/scsi_low.c	Thu May  8 06:55:48 2014	(r265632)
+++ stable/9/sys/cam/scsi/scsi_low.c	Thu May  8 06:56:59 2014	(r265633)
@@ -4762,7 +4762,7 @@ scsi_low_print(slp, ti)
 	if (ti != NULL)
 	{
 		u_int flags = 0, maxnqio = 0, nqio = 0;
-		int lun = -1;
+		int lun = CAM_LUN_WILDCARD;
 
 		if (li != NULL)
 		{



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405080656.s486uxmi045532>