Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Apr 2012 21:17:33 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r234503 - head/sys/dev/asr
Message-ID:  <201204202117.q3KLHXke055845@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Fri Apr 20 21:17:33 2012
New Revision: 234503
URL: http://svn.freebsd.org/changeset/base/234503

Log:
  Replace homegrown list implementation in sys/dev/asr/asr.c with
  STAILQ().  While here, fix another clang warning about a switch which
  tests an enum type for a regular integer value.
  
  Submitted by:	jhb
  MFC after:	1 week

Modified:
  head/sys/dev/asr/asr.c

Modified: head/sys/dev/asr/asr.c
==============================================================================
--- head/sys/dev/asr/asr.c	Fri Apr 20 21:00:39 2012	(r234502)
+++ head/sys/dev/asr/asr.c	Fri Apr 20 21:17:33 2012	(r234503)
@@ -378,11 +378,12 @@ typedef struct Asr_softc {
 	u_int16_t		ha_Msgs_Count;
 
 	/* Links into other parents and HBAs */
-	struct Asr_softc      * ha_next;       /* HBA list */
+	STAILQ_ENTRY(Asr_softc) ha_next;       /* HBA list */
 	struct cdev *ha_devt;
 } Asr_softc_t;
 
-static Asr_softc_t *Asr_softc_list;
+static STAILQ_HEAD(, Asr_softc) Asr_softc_list =
+	STAILQ_HEAD_INITIALIZER(Asr_softc_list);
 
 /*
  *	Prototypes of the routines we have in this object.
@@ -1959,7 +1960,7 @@ ASR_setSysTab(Asr_softc_t *sc)
 {
 	PI2O_EXEC_SYS_TAB_SET_MESSAGE Message_Ptr;
 	PI2O_SET_SYSTAB_HEADER	      SystemTable;
-	Asr_softc_t		    * ha;
+	Asr_softc_t		    * ha, *next;
 	PI2O_SGE_SIMPLE_ELEMENT	      sg;
 	int			      retVal;
 
@@ -1967,7 +1968,7 @@ ASR_setSysTab(Asr_softc_t *sc)
 	  sizeof(I2O_SET_SYSTAB_HEADER), M_TEMP, M_WAITOK | M_ZERO)) == NULL) {
 		return (ENOMEM);
 	}
-	for (ha = Asr_softc_list; ha; ha = ha->ha_next) {
+	STAILQ_FOREACH(ha, &Asr_softc_list, ha_next) {
 		++SystemTable->NumberEntries;
 	}
 	if ((Message_Ptr = (PI2O_EXEC_SYS_TAB_SET_MESSAGE)malloc (
@@ -1998,9 +1999,9 @@ ASR_setSysTab(Asr_softc_t *sc)
 	      &(Message_Ptr->StdMessageFrame)) & 0xF0) >> 2));
 	SG(sg, 0, I2O_SGL_FLAGS_DIR, SystemTable, sizeof(I2O_SET_SYSTAB_HEADER));
 	++sg;
-	for (ha = Asr_softc_list; ha; ha = ha->ha_next) {
+	STAILQ_FOREACH_SAFE(ha, &Asr_softc_list, ha_next, next) {
 		SG(sg, 0,
-		  ((ha->ha_next)
+		  ((next)
 		    ? (I2O_SGL_FLAGS_DIR)
 		    : (I2O_SGL_FLAGS_DIR | I2O_SGL_FLAGS_END_OF_BUFFER)),
 		  &(ha->ha_SystemTable), sizeof(ha->ha_SystemTable));
@@ -2396,7 +2397,7 @@ asr_attach(device_t dev)
 {
 	PI2O_EXEC_STATUS_GET_REPLY status;
 	PI2O_LCT_ENTRY		 Device;
-	Asr_softc_t		 *sc, **ha;
+	Asr_softc_t		 *sc;
 	struct scsi_inquiry_data *iq;
 	int			 bus, size, unit;
 	int			 error;
@@ -2405,7 +2406,7 @@ asr_attach(device_t dev)
 	unit = device_get_unit(dev);
 	sc->ha_dev = dev;
 
-	if (Asr_softc_list == NULL) {
+	if (STAILQ_EMPTY(&Asr_softc_list)) {
 		/*
 		 *	Fixup the OS revision as saved in the dptsig for the
 		 *	engine (dptioctl.h) to pick up.
@@ -2417,8 +2418,7 @@ asr_attach(device_t dev)
 	 */
 	LIST_INIT(&(sc->ha_ccb));
 	/* Link us into the HA list */
-	for (ha = &Asr_softc_list; *ha; ha = &((*ha)->ha_next));
-		*(ha) = sc;
+	STAILQ_INSERT_TAIL(&Asr_softc_list, sc, ha_next);
 
 	/*
 	 *	This is the real McCoy!
@@ -2700,7 +2700,7 @@ asr_action(struct cam_sim *sim, union cc
 
 	ccb->ccb_h.spriv_ptr0 = sc = (struct Asr_softc *)cam_sim_softc(sim);
 
-	switch (ccb->ccb_h.func_code) {
+	switch ((int)ccb->ccb_h.func_code) {
 
 	/* Common cases first */
 	case XPT_SCSI_IO:	/* Execute the requested I/O operation */



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