Deleted Added
full compact
sbp_targ.c (168752) sbp_targ.c (169130)
1/*-
2 * Copyright (C) 2003
3 * Hidetoshi Shimokawa. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
1/*-
2 * Copyright (C) 2003
3 * Hidetoshi Shimokawa. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * $FreeBSD: head/sys/dev/firewire/sbp_targ.c 168752 2007-04-15 08:49:19Z scottl $
34 * $FreeBSD: head/sys/dev/firewire/sbp_targ.c 169130 2007-04-30 13:41:40Z simokawa $
35 */
36
37#include <sys/param.h>
38#include <sys/kernel.h>
39#include <sys/systm.h>
40#include <sys/sysctl.h>
41#include <sys/types.h>
42#include <sys/conf.h>

--- 1562 unchanged lines hidden (view full) ---

1605 splx(s);
1606}
1607
1608static int
1609sbp_targ_attach(device_t dev)
1610{
1611 struct sbp_targ_softc *sc;
1612 struct cam_devq *devq;
35 */
36
37#include <sys/param.h>
38#include <sys/kernel.h>
39#include <sys/systm.h>
40#include <sys/sysctl.h>
41#include <sys/types.h>
42#include <sys/conf.h>

--- 1562 unchanged lines hidden (view full) ---

1605 splx(s);
1606}
1607
1608static int
1609sbp_targ_attach(device_t dev)
1610{
1611 struct sbp_targ_softc *sc;
1612 struct cam_devq *devq;
1613 struct fw_xfer *xfer;
1614 int i;
1615
1616 sc = (struct sbp_targ_softc *) device_get_softc(dev);
1617 bzero((void *)sc, sizeof(struct sbp_targ_softc));
1618
1619 sc->fd.fc = device_get_ivars(dev);
1620 sc->fd.dev = dev;
1621 sc->fd.post_explore = (void *) sbp_targ_post_explore;
1622 sc->fd.post_busreset = (void *) sbp_targ_post_busreset;

--- 16 unchanged lines hidden (view full) ---

1639 if (xpt_create_path(&sc->path, /*periph*/ NULL, cam_sim_path(sc->sim),
1640 CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
1641 xpt_bus_deregister(cam_sim_path(sc->sim));
1642 goto fail;
1643 }
1644
1645 sc->fwb.start = SBP_TARG_BIND_START;
1646 sc->fwb.end = SBP_TARG_BIND_END;
1613
1614 sc = (struct sbp_targ_softc *) device_get_softc(dev);
1615 bzero((void *)sc, sizeof(struct sbp_targ_softc));
1616
1617 sc->fd.fc = device_get_ivars(dev);
1618 sc->fd.dev = dev;
1619 sc->fd.post_explore = (void *) sbp_targ_post_explore;
1620 sc->fd.post_busreset = (void *) sbp_targ_post_busreset;

--- 16 unchanged lines hidden (view full) ---

1637 if (xpt_create_path(&sc->path, /*periph*/ NULL, cam_sim_path(sc->sim),
1638 CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
1639 xpt_bus_deregister(cam_sim_path(sc->sim));
1640 goto fail;
1641 }
1642
1643 sc->fwb.start = SBP_TARG_BIND_START;
1644 sc->fwb.end = SBP_TARG_BIND_END;
1647 sc->fwb.act_type = FWACT_XFER;
1648
1649 /* pre-allocate xfer */
1650 STAILQ_INIT(&sc->fwb.xferlist);
1645
1646 /* pre-allocate xfer */
1647 STAILQ_INIT(&sc->fwb.xferlist);
1651 for (i = 0; i < MAX_LUN /* XXX */; i ++) {
1652 xfer = fw_xfer_alloc_buf(M_SBP_TARG,
1653 /* send */ 0,
1654 /* recv */ SBP_TARG_RECV_LEN);
1655 xfer->hand = sbp_targ_recv;
1656 xfer->fc = sc->fd.fc;
1657 xfer->sc = (caddr_t)sc;
1658 STAILQ_INSERT_TAIL(&sc->fwb.xferlist, xfer, link);
1659 }
1648 fw_xferlist_add(&sc->fwb.xferlist, M_SBP_TARG,
1649 /*send*/ 0, /*recv*/ SBP_TARG_RECV_LEN, MAX_LUN /* XXX */,
1650 sc->fd.fc, (void *)sc, sbp_targ_recv);
1660 fw_bindadd(sc->fd.fc, &sc->fwb);
1661 return 0;
1662
1663fail:
1664 cam_sim_free(sc->sim, /*free_devq*/TRUE);
1665 return (ENXIO);
1666}
1667
1668static int
1669sbp_targ_detach(device_t dev)
1670{
1671 struct sbp_targ_softc *sc;
1672 struct sbp_targ_lstate *lstate;
1651 fw_bindadd(sc->fd.fc, &sc->fwb);
1652 return 0;
1653
1654fail:
1655 cam_sim_free(sc->sim, /*free_devq*/TRUE);
1656 return (ENXIO);
1657}
1658
1659static int
1660sbp_targ_detach(device_t dev)
1661{
1662 struct sbp_targ_softc *sc;
1663 struct sbp_targ_lstate *lstate;
1673 struct fw_xfer *xfer, *next;
1674 int i;
1675
1676 sc = (struct sbp_targ_softc *)device_get_softc(dev);
1677 sc->fd.post_busreset = NULL;
1678
1679 xpt_free_path(sc->path);
1680 xpt_bus_deregister(cam_sim_path(sc->sim));
1681 cam_sim_free(sc->sim, /*free_devq*/TRUE);

--- 5 unchanged lines hidden (view full) ---

1687 free(lstate, M_SBP_TARG);
1688 }
1689 }
1690 if (sc->black_hole != NULL) {
1691 xpt_free_path(sc->black_hole->path);
1692 free(sc->black_hole, M_SBP_TARG);
1693 }
1694
1664 int i;
1665
1666 sc = (struct sbp_targ_softc *)device_get_softc(dev);
1667 sc->fd.post_busreset = NULL;
1668
1669 xpt_free_path(sc->path);
1670 xpt_bus_deregister(cam_sim_path(sc->sim));
1671 cam_sim_free(sc->sim, /*free_devq*/TRUE);

--- 5 unchanged lines hidden (view full) ---

1677 free(lstate, M_SBP_TARG);
1678 }
1679 }
1680 if (sc->black_hole != NULL) {
1681 xpt_free_path(sc->black_hole->path);
1682 free(sc->black_hole, M_SBP_TARG);
1683 }
1684
1695 for (xfer = STAILQ_FIRST(&sc->fwb.xferlist);
1696 xfer != NULL; xfer = next) {
1697 next = STAILQ_NEXT(xfer, link);
1698 fw_xfer_free_buf(xfer);
1699 }
1700 STAILQ_INIT(&sc->fwb.xferlist);
1701 fw_bindremove(sc->fd.fc, &sc->fwb);
1685 fw_bindremove(sc->fd.fc, &sc->fwb);
1686 fw_xferlist_remove(&sc->fwb.xferlist);
1702
1703 return 0;
1704}
1705
1706static devclass_t sbp_targ_devclass;
1707
1708static device_method_t sbp_targ_methods[] = {
1709 /* device interface */

--- 17 unchanged lines hidden ---
1687
1688 return 0;
1689}
1690
1691static devclass_t sbp_targ_devclass;
1692
1693static device_method_t sbp_targ_methods[] = {
1694 /* device interface */

--- 17 unchanged lines hidden ---