From owner-svn-src-all@FreeBSD.ORG Fri Apr 27 18:05:25 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 117F81065670; Fri, 27 Apr 2012 18:05:25 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E74E78FC16; Fri, 27 Apr 2012 18:05:24 +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 q3RI5O0K017928; Fri, 27 Apr 2012 18:05:24 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3RI5OlY017926; Fri, 27 Apr 2012 18:05:24 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201204271805.q3RI5OlY017926@svn.freebsd.org> From: Dimitry Andric Date: Fri, 27 Apr 2012 18:05:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234734 - stable/9/sys/dev/asr X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Fri, 27 Apr 2012 18:05:25 -0000 Author: dim Date: Fri Apr 27 18:05:24 2012 New Revision: 234734 URL: http://svn.freebsd.org/changeset/base/234734 Log: MFC r234503: 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 Modified: stable/9/sys/dev/asr/asr.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/dev/asr/asr.c ============================================================================== --- stable/9/sys/dev/asr/asr.c Fri Apr 27 17:25:13 2012 (r234733) +++ stable/9/sys/dev/asr/asr.c Fri Apr 27 18:05:24 2012 (r234734) @@ -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 */