diff options
| author | Nate Lawson <njl@FreeBSD.org> | 2004-05-24 07:02:25 +0000 |
|---|---|---|
| committer | Nate Lawson <njl@FreeBSD.org> | 2004-05-24 07:02:25 +0000 |
| commit | 51e23558827dd60a32ce321dd69032a2f4ac2ef1 (patch) | |
| tree | 98d7ca75febb72f045bd84f9fa945072084c8cc1 /sys/dev/isp/isp_inline.h | |
| parent | 2aeec2960a5702c54b4b48fe2cb26545e231c3e4 (diff) | |
Notes
Diffstat (limited to 'sys/dev/isp/isp_inline.h')
| -rw-r--r-- | sys/dev/isp/isp_inline.h | 65 |
1 files changed, 61 insertions, 4 deletions
diff --git a/sys/dev/isp/isp_inline.h b/sys/dev/isp/isp_inline.h index 17ac1d05d581..6bc54fbf08e7 100644 --- a/sys/dev/isp/isp_inline.h +++ b/sys/dev/isp/isp_inline.h @@ -43,8 +43,8 @@ static INLINE int isp_save_xs(struct ispsoftc *, XS_T *, u_int16_t *); static INLINE XS_T *isp_find_xs(struct ispsoftc *, u_int16_t); static INLINE u_int16_t isp_find_handle(struct ispsoftc *, XS_T *); static INLINE int isp_handle_index(u_int16_t); +static INLINE u_int16_t isp_index_handle(int); static INLINE void isp_destroy_handle(struct ispsoftc *, u_int16_t); -static INLINE void isp_remove_handle(struct ispsoftc *, XS_T *); static INLINE int isp_save_xs(struct ispsoftc *isp, XS_T *xs, u_int16_t *handlep) @@ -100,19 +100,76 @@ isp_handle_index(u_int16_t handle) return (handle-1); } +static INLINE u_int16_t +isp_index_handle(int index) +{ + return (index+1); +} + static INLINE void isp_destroy_handle(struct ispsoftc *isp, u_int16_t handle) { if (handle > 0 && handle <= (u_int16_t) isp->isp_maxcmds) { - isp->isp_xflist[isp_handle_index(handle)] = NULL; + isp->isp_xflist[handle - 1] = NULL; + } +} + +#ifdef ISP_TARGET_MODE +static INLINE int isp_save_xs_tgt(struct ispsoftc *, void *, u_int16_t *); +static INLINE void *isp_find_xs_tgt(struct ispsoftc *, u_int16_t); +static INLINE void isp_destroy_tgt_handle(struct ispsoftc *, u_int16_t); + +static INLINE int +isp_save_xs_tgt(struct ispsoftc *isp, void *xs, u_int16_t *handlep) +{ + int i; + + for (i = 0; i < (int) isp->isp_maxcmds; i++) { + if (isp->isp_tgtlist[i] == NULL) { + break; + } + } + if (i == isp->isp_maxcmds) { + return (-1); + } + isp->isp_tgtlist[i] = xs; + *handlep = i+1; + return (0); +} + +static INLINE void * +isp_find_xs_tgt(struct ispsoftc *isp, u_int16_t handle) +{ + if (handle < 1 || handle > (u_int16_t) isp->isp_maxcmds) { + return (NULL); + } else { + return (isp->isp_tgtlist[handle - 1]); } } +static INLINE u_int16_t +isp_find_tgt_handle(struct ispsoftc *isp, void *xs) +{ + int i; + if (xs != NULL) { + for (i = 0; i < isp->isp_maxcmds; i++) { + if (isp->isp_tgtlist[i] == xs) { + return ((u_int16_t) i+1); + } + } + } + return (0); +} + static INLINE void -isp_remove_handle(struct ispsoftc *isp, XS_T *xs) +isp_destroy_tgt_handle(struct ispsoftc *isp, u_int16_t handle) { - isp_destroy_handle(isp, isp_find_handle(isp, xs)); + if (handle > 0 && handle <= (u_int16_t) isp->isp_maxcmds) { + isp->isp_tgtlist[handle - 1] = NULL; + } } +#endif + static INLINE int isp_getrqentry(struct ispsoftc *, u_int16_t *, u_int16_t *, void **); |
