Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/nick-nhusb]: src/sys/dev/usb Provide and use a MOTG_PIPE2MPIPE helper macro
details: https://anonhg.NetBSD.org/src/rev/30c2099a70a4
branches: nick-nhusb
changeset: 334335:30c2099a70a4
user: skrll <skrll%NetBSD.org@localhost>
date: Sat Dec 19 09:55:07 2015 +0000
description:
Provide and use a MOTG_PIPE2MPIPE helper macro
diffstat:
sys/dev/usb/motg.c | 40 ++++++++++++++++++++--------------------
sys/dev/usb/motgvar.h | 5 +++--
2 files changed, 23 insertions(+), 22 deletions(-)
diffs (201 lines):
diff -r b785735217e7 -r 30c2099a70a4 sys/dev/usb/motg.c
--- a/sys/dev/usb/motg.c Sat Dec 19 09:47:57 2015 +0000
+++ b/sys/dev/usb/motg.c Sat Dec 19 09:55:07 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: motg.c,v 1.12.2.22 2015/12/19 09:47:57 skrll Exp $ */
+/* $NetBSD: motg.c,v 1.12.2.23 2015/12/19 09:55:07 skrll Exp $ */
/*
* Copyright (c) 1998, 2004, 2011, 2012, 2014 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
#include "opt_motg.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.12.2.22 2015/12/19 09:47:57 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.12.2.23 2015/12/19 09:55:07 skrll Exp $");
#include <sys/param.h>
@@ -481,7 +481,7 @@
static int
motg_select_ep(struct motg_softc *sc, struct usbd_pipe *pipe)
{
- struct motg_pipe *otgpipe = (struct motg_pipe *)pipe;
+ struct motg_pipe *otgpipe = MOTG_PIPE2MPIPE(pipe);
usb_endpoint_descriptor_t *ed = pipe->up_endpoint->ue_edesc;
struct motg_hw_ep *ep;
int i, size;
@@ -522,7 +522,7 @@
motg_open(struct usbd_pipe *pipe)
{
struct motg_softc *sc = MOTG_PIPE2SC(pipe);
- struct motg_pipe *otgpipe = (struct motg_pipe *)pipe;
+ struct motg_pipe *otgpipe = MOTG_PIPE2MPIPE(pipe);
usb_endpoint_descriptor_t *ed = pipe->up_endpoint->ue_edesc;
uint8_t rhaddr = pipe->up_dev->ud_bus->ub_rhaddr;
@@ -1159,7 +1159,7 @@
motg_setup_endpoint_tx(struct usbd_xfer *xfer)
{
struct motg_softc *sc = MOTG_XFER2SC(xfer);
- struct motg_pipe *otgpipe = (struct motg_pipe *)xfer->ux_pipe;
+ struct motg_pipe *otgpipe = MOTG_PIPE2MPIPE(xfer->ux_pipe);
struct usbd_device *dev = otgpipe->pipe.up_dev;
int epnumber = otgpipe->hw_ep->ep_number;
@@ -1209,7 +1209,7 @@
{
struct motg_softc *sc = MOTG_XFER2SC(xfer);
struct usbd_device *dev = xfer->ux_pipe->up_dev;
- struct motg_pipe *otgpipe = (struct motg_pipe *)xfer->ux_pipe;
+ struct motg_pipe *otgpipe = MOTG_PIPE2MPIPE(xfer->ux_pipe);
int epnumber = otgpipe->hw_ep->ep_number;
UWRITE1(sc, MUSB2_REG_RXFADDR(epnumber), dev->ud_addr);
@@ -1330,7 +1330,7 @@
goto end;
}
xfer->ux_status = USBD_IN_PROGRESS;
- KASSERT(otgpipe == (struct motg_pipe *)xfer->ux_pipe);
+ KASSERT(otgpipe == MOTG_PIPE2MPIPE(xfer->ux_pipe));
KASSERT(otgpipe->hw_ep == ep);
#ifdef DIAGNOSTIC
if (!(xfer->ux_rqflags & URQ_REQUEST))
@@ -1385,7 +1385,7 @@
motg_device_ctrl_read(struct usbd_xfer *xfer)
{
struct motg_softc *sc = MOTG_XFER2SC(xfer);
- struct motg_pipe *otgpipe = (struct motg_pipe *)xfer->ux_pipe;
+ struct motg_pipe *otgpipe = MOTG_PIPE2MPIPE(xfer->ux_pipe);
/* assume endpoint already selected */
motg_setup_endpoint_rx(xfer);
/* start transaction */
@@ -1664,7 +1664,7 @@
motg_device_ctrl_close(struct usbd_pipe *pipe)
{
struct motg_softc *sc __diagused = MOTG_PIPE2SC(pipe);
- struct motg_pipe *otgpipe = (struct motg_pipe *)pipe;
+ struct motg_pipe *otgpipe = MOTG_PIPE2MPIPE(pipe);
struct motg_pipe *otgpipeiter;
MOTGHIST_FUNC(); MOTGHIST_CALLED();
@@ -1689,7 +1689,7 @@
void
motg_device_ctrl_done(struct usbd_xfer *xfer)
{
- struct motg_pipe *otgpipe __diagused = (struct motg_pipe *)xfer->ux_pipe;
+ struct motg_pipe *otgpipe __diagused = MOTG_PIPE2MPIPE(xfer->ux_pipe);
MOTGHIST_FUNC(); MOTGHIST_CALLED();
KASSERT(otgpipe->hw_ep->xfer != xfer);
@@ -1723,7 +1723,7 @@
motg_device_data_start(struct usbd_xfer *xfer)
{
struct motg_softc *sc = MOTG_XFER2SC(xfer);
- struct motg_pipe *otgpipe = (struct motg_pipe *)xfer->ux_pipe;
+ struct motg_pipe *otgpipe = MOTG_PIPE2MPIPE(xfer->ux_pipe);
usbd_status err;
MOTGHIST_FUNC(); MOTGHIST_CALLED();
@@ -1779,7 +1779,7 @@
goto end;
}
xfer->ux_status = USBD_IN_PROGRESS;
- KASSERT(otgpipe == (struct motg_pipe *)xfer->ux_pipe);
+ KASSERT(otgpipe == MOTG_PIPE2MPIPE(xfer->ux_pipe));
KASSERT(otgpipe->hw_ep == ep);
#ifdef DIAGNOSTIC
if (xfer->ux_rqflags & URQ_REQUEST)
@@ -1830,7 +1830,7 @@
motg_device_data_read(struct usbd_xfer *xfer)
{
struct motg_softc *sc = MOTG_XFER2SC(xfer);
- struct motg_pipe *otgpipe = (struct motg_pipe *)xfer->ux_pipe;
+ struct motg_pipe *otgpipe = MOTG_PIPE2MPIPE(xfer->ux_pipe);
uint32_t val;
MOTGHIST_FUNC(); MOTGHIST_CALLED();
@@ -1861,7 +1861,7 @@
motg_device_data_write(struct usbd_xfer *xfer)
{
struct motg_softc *sc = MOTG_XFER2SC(xfer);
- struct motg_pipe *otgpipe = (struct motg_pipe *)xfer->ux_pipe;
+ struct motg_pipe *otgpipe = MOTG_PIPE2MPIPE(xfer->ux_pipe);
struct motg_hw_ep *ep = otgpipe->hw_ep;
int datalen;
char *data;
@@ -1971,7 +1971,7 @@
goto complete;
}
- struct motg_pipe *otgpipe = (struct motg_pipe *)xfer->ux_pipe;
+ struct motg_pipe *otgpipe = MOTG_PIPE2MPIPE(xfer->ux_pipe);
otgpipe->nexttoggle = otgpipe->nexttoggle ^ 1;
datalen = UREAD2(sc, MUSB2_REG_RXCOUNT);
@@ -2090,7 +2090,7 @@
panic("motg_device_intr_tx: bad phase %d", ep->phase);
#endif
- otgpipe = (struct motg_pipe *)xfer->ux_pipe;
+ otgpipe = MOTG_PIPE2MPIPE(xfer->ux_pipe);
otgpipe->nexttoggle = otgpipe->nexttoggle ^ 1;
if (ep->datalen == 0) {
@@ -2141,7 +2141,7 @@
motg_device_data_close(struct usbd_pipe *pipe)
{
struct motg_softc *sc __diagused = MOTG_PIPE2SC(pipe);
- struct motg_pipe *otgpipe = (struct motg_pipe *)pipe;
+ struct motg_pipe *otgpipe = MOTG_PIPE2MPIPE(pipe);
struct motg_pipe *otgpipeiter;
MOTGHIST_FUNC(); MOTGHIST_CALLED();
@@ -2167,7 +2167,7 @@
void
motg_device_data_done(struct usbd_xfer *xfer)
{
- struct motg_pipe *otgpipe __diagused = (struct motg_pipe *)xfer->ux_pipe;
+ struct motg_pipe *otgpipe __diagused = MOTG_PIPE2MPIPE(xfer->ux_pipe);
MOTGHIST_FUNC(); MOTGHIST_CALLED();
KASSERT(otgpipe->hw_ep->xfer != xfer);
@@ -2212,7 +2212,7 @@
void
motg_device_clear_toggle(struct usbd_pipe *pipe)
{
- struct motg_pipe *otgpipe = (struct motg_pipe *)pipe;
+ struct motg_pipe *otgpipe = MOTG_PIPE2MPIPE(pipe);
otgpipe->nexttoggle = 0;
}
@@ -2223,7 +2223,7 @@
int wake;
uint8_t csr;
struct motg_softc *sc = MOTG_XFER2SC(xfer);
- struct motg_pipe *otgpipe = (struct motg_pipe *)xfer->ux_pipe;
+ struct motg_pipe *otgpipe = MOTG_PIPE2MPIPE(xfer->ux_pipe);
KASSERT(mutex_owned(&sc->sc_lock));
MOTGHIST_FUNC(); MOTGHIST_CALLED();
diff -r b785735217e7 -r 30c2099a70a4 sys/dev/usb/motgvar.h
--- a/sys/dev/usb/motgvar.h Sat Dec 19 09:47:57 2015 +0000
+++ b/sys/dev/usb/motgvar.h Sat Dec 19 09:55:07 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: motgvar.h,v 1.4.2.8 2015/10/22 11:15:42 skrll Exp $ */
+/* $NetBSD: motgvar.h,v 1.4.2.9 2015/12/19 09:55:07 skrll Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -116,9 +116,10 @@
#define MOTG_BUS2SC(bus) ((bus)->ub_hcpriv)
#define MOTG_PIPE2SC(pipe) MOTG_BUS2SC((pipe)->up_dev->ud_bus)
#define MOTG_XFER2SC(xfer) MOTG_BUS2SC((xfer)->ux_bus)
-#define MOTG_OTGPIPE2SC(mpipe) MOTG_BUS2SC((mpipe)->pipe.up_dev->ud_bus)
+#define MOTG_MPIPE2SC(mpipe) MOTG_BUS2SC((mpipe)->pipe.up_dev->ud_bus)
#define MOTG_XFER2MXFER(xfer) ((struct motg_xfer *)(xfer))
+#define MOTG_PIPE2MPIPE(pipe) ((struct motg_pipe *)(pipe))
int motg_init(struct motg_softc *);
int motg_intr(struct motg_softc *, uint16_t, uint16_t, uint8_t);
Home |
Main Index |
Thread Index |
Old Index