Date: Tue, 1 Jul 2014 04:33:37 +0000 (UTC) From: Scott Long <scottl@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r268071 - head/sys/dev/mps Message-ID: <201407010433.s614Xbwt031267@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <dev/mps/mps_ioctl.h> #include <dev/mps/mpsvar.h> #include <dev/mps/mps_table.h> -#include <dev/mps/mps_sas.h> 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 <dev/mps/mps_ioctl.h> #include <dev/mps/mpsvar.h> #include <dev/mps/mps_table.h> -#include <dev/mps/mps_sas.h> #include <dev/pci/pcivar.h> #include <dev/pci/pcireg.h> 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201407010433.s614Xbwt031267>