Refactor some code in mps.c to reduce header pollution.
Reviewed by: gibbs Obtained from: Netflix, Inc. MFC after: 2 days
This commit is contained in:
parent
ccbb7b5e19
commit
b7f7712702
@ -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_softc *sc)
|
||||
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 *sc, uint8_t attaching)
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3591,3 +3591,33 @@ mpssas_check_id(struct mpssas_softc *sassc, int id)
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,5 @@ void mpssas_discovery_end(struct mpssas_softc *sassc);
|
||||
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);
|
||||
|
@ -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>
|
||||
|
||||
|
@ -756,6 +756,9 @@ void mpssas_prepare_remove(struct mpssas_softc *sassc, uint16_t handle);
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user