From owner-svn-src-head@FreeBSD.ORG Tue Jul 1 04:33:38 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 623C82E7; Tue, 1 Jul 2014 04:33:38 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 43A6E29AD; Tue, 1 Jul 2014 04:33:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s614XcXd031272; Tue, 1 Jul 2014 04:33:38 GMT (envelope-from scottl@svn.freebsd.org) Received: (from scottl@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s614Xbwt031267; Tue, 1 Jul 2014 04:33:37 GMT (envelope-from scottl@svn.freebsd.org) Message-Id: <201407010433.s614Xbwt031267@svn.freebsd.org> From: Scott Long Date: Tue, 1 Jul 2014 04:33:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r268071 - head/sys/dev/mps X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Jul 2014 04:33:38 -0000 Author: scottl Date: Tue Jul 1 04:33:36 2014 New Revision: 268071 URL: http://svnweb.freebsd.org/changeset/base/268071 Log: Refactor some code in mps.c to reduce header pollution. Reviewed by: gibbs Obtained from: Netflix, Inc. MFC after: 2 days Modified: head/sys/dev/mps/mps.c head/sys/dev/mps/mps_sas.c head/sys/dev/mps/mps_sas.h head/sys/dev/mps/mps_user.c head/sys/dev/mps/mpsvar.h Modified: head/sys/dev/mps/mps.c ============================================================================== --- head/sys/dev/mps/mps.c Tue Jul 1 00:59:45 2014 (r268070) +++ head/sys/dev/mps/mps.c Tue Jul 1 04:33:36 2014 (r268071) @@ -75,7 +75,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include static int mps_diag_reset(struct mps_softc *sc, int sleep_flag); static int mps_init_queues(struct mps_softc *sc); @@ -328,11 +327,9 @@ mps_transition_operational(struct mps_so static int mps_iocfacts_allocate(struct mps_softc *sc, uint8_t attaching) { - int error, i; + int error; Mpi2IOCFactsReply_t saved_facts; uint8_t saved_mode, reallocating; - struct mpssas_lun *lun, *lun_tmp; - struct mpssas_target *targ; mps_dprint(sc, MPS_TRACE, "%s\n", __func__); @@ -489,27 +486,7 @@ mps_iocfacts_allocate(struct mps_softc * */ if (reallocating) { mps_iocfacts_free(sc); - - /* - * The number of targets is based on IOC Facts, so free all of - * the allocated LUNs for each target and then the target buffer - * itself. - */ - for (i=0; i< saved_facts.MaxTargets; i++) { - targ = &sc->sassc->targets[i]; - SLIST_FOREACH_SAFE(lun, &targ->luns, lun_link, - lun_tmp) { - free(lun, M_MPT2); - } - } - free(sc->sassc->targets, M_MPT2); - - sc->sassc->targets = malloc(sizeof(struct mpssas_target) * - sc->facts->MaxTargets, M_MPT2, M_WAITOK|M_ZERO); - if (!sc->sassc->targets) { - panic("%s failed to alloc targets with error %d\n", - __func__, ENOMEM); - } + mpssas_realloc_targets(sc, saved_facts.MaxTargets); } /* Modified: head/sys/dev/mps/mps_sas.c ============================================================================== --- head/sys/dev/mps/mps_sas.c Tue Jul 1 00:59:45 2014 (r268070) +++ head/sys/dev/mps/mps_sas.c Tue Jul 1 04:33:36 2014 (r268071) @@ -3591,3 +3591,33 @@ mpssas_check_id(struct mpssas_softc *sas return (0); } + +void +mpssas_realloc_targets(struct mps_softc *sc, int maxtargets) +{ + struct mpssas_softc *sassc; + struct mpssas_lun *lun, *lun_tmp; + struct mpssas_target *targ; + int i; + + sassc = sc->sassc; + /* + * The number of targets is based on IOC Facts, so free all of + * the allocated LUNs for each target and then the target buffer + * itself. + */ + for (i=0; i< maxtargets; i++) { + targ = &sassc->targets[i]; + SLIST_FOREACH_SAFE(lun, &targ->luns, lun_link, lun_tmp) { + free(lun, M_MPT2); + } + } + free(sassc->targets, M_MPT2); + + sassc->targets = malloc(sizeof(struct mpssas_target) * maxtargets, + M_MPT2, M_WAITOK|M_ZERO); + if (!sassc->targets) { + panic("%s failed to alloc targets with error %d\n", + __func__, ENOMEM); + } +} Modified: head/sys/dev/mps/mps_sas.h ============================================================================== --- head/sys/dev/mps/mps_sas.h Tue Jul 1 00:59:45 2014 (r268070) +++ head/sys/dev/mps/mps_sas.h Tue Jul 1 04:33:36 2014 (r268071) @@ -156,7 +156,5 @@ void mpssas_discovery_end(struct mpssas_ void mpssas_startup_increment(struct mpssas_softc *sassc); void mpssas_startup_decrement(struct mpssas_softc *sassc); -struct mps_command * mpssas_alloc_tm(struct mps_softc *sc); -void mpssas_free_tm(struct mps_softc *sc, struct mps_command *tm); void mpssas_firmware_event_work(void *arg, int pending); int mpssas_check_id(struct mpssas_softc *sassc, int id); Modified: head/sys/dev/mps/mps_user.c ============================================================================== --- head/sys/dev/mps/mps_user.c Tue Jul 1 00:59:45 2014 (r268070) +++ head/sys/dev/mps/mps_user.c Tue Jul 1 04:33:36 2014 (r268071) @@ -101,7 +101,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include Modified: head/sys/dev/mps/mpsvar.h ============================================================================== --- head/sys/dev/mps/mpsvar.h Tue Jul 1 00:59:45 2014 (r268070) +++ head/sys/dev/mps/mpsvar.h Tue Jul 1 04:33:36 2014 (r268071) @@ -756,6 +756,9 @@ void mpssas_prepare_remove(struct mpssas void mpssas_prepare_volume_remove(struct mpssas_softc *sassc, uint16_t handle); int mpssas_startup(struct mps_softc *sc); struct mpssas_target * mpssas_find_target_by_handle(struct mpssas_softc *, int, uint16_t); +void mpssas_realloc_targets(struct mps_softc *sc, int maxtargets); +struct mps_command * mpssas_alloc_tm(struct mps_softc *sc); +void mpssas_free_tm(struct mps_softc *sc, struct mps_command *tm); SYSCTL_DECL(_hw_mps);