Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb clean up ucom / ucom-parent interface slightly:
details: https://anonhg.NetBSD.org/src/rev/ab9714df77dc
branches: trunk
changeset: 451026:ab9714df77dc
user: mrg <mrg%NetBSD.org@localhost>
date: Sat May 04 08:04:13 2019 +0000
description:
clean up ucom / ucom-parent interface slightly:
- document what the ucom_methods{} callbacks argument are and that
they are all optional.
- remove almost all methods being assigned to NULL, as they are all
C99 initialisers and thus don't need NULL assignments.
- ucom_get_status() callback always has lsr/msr pointers as valid.
remove all tests for not NULL in these functions.
diffstat:
sys/dev/usb/moscom.c | 8 ++------
sys/dev/usb/u3g.c | 12 ++++--------
sys/dev/usb/uark.c | 15 ++++-----------
sys/dev/usb/ubsa.c | 7 ++-----
sys/dev/usb/ubsa_common.c | 10 ++++------
sys/dev/usb/uchcom.c | 7 ++-----
sys/dev/usb/ucomvar.h | 43 +++++++++++++++++++++++++++++++++++++++++--
sys/dev/usb/uftdi.c | 14 +++++---------
sys/dev/usb/ugensa.c | 11 ++---------
sys/dev/usb/uhmodem.c | 7 ++-----
sys/dev/usb/uipaq.c | 11 ++---------
sys/dev/usb/ukyopon.c | 6 ++----
sys/dev/usb/umct.c | 13 ++++---------
sys/dev/usb/umodem.c | 6 ++----
sys/dev/usb/umodem_common.c | 10 ++++------
sys/dev/usb/uplcom.c | 12 ++++--------
sys/dev/usb/uslsa.c | 21 +++++++--------------
sys/dev/usb/uvisor.c | 11 ++---------
sys/dev/usb/uvscom.c | 12 ++++--------
19 files changed, 99 insertions(+), 137 deletions(-)
diffs (truncated from 712 to 300 lines):
diff -r a9d142360316 -r ab9714df77dc sys/dev/usb/moscom.c
--- a/sys/dev/usb/moscom.c Sat May 04 07:28:18 2019 +0000
+++ b/sys/dev/usb/moscom.c Sat May 04 08:04:13 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: moscom.c,v 1.11 2017/06/26 20:36:01 is Exp $ */
+/* $NetBSD: moscom.c,v 1.12 2019/05/04 08:04:13 mrg Exp $ */
/* $OpenBSD: moscom.c,v 1.11 2007/10/11 18:33:14 deraadt Exp $ */
/*
@@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: moscom.c,v 1.11 2017/06/26 20:36:01 is Exp $");
+__KERNEL_RCSID(0, "$NetBSD: moscom.c,v 1.12 2019/05/04 08:04:13 mrg Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -156,14 +156,10 @@
int moscom_cmd(struct moscom_softc *, int, int);
struct ucom_methods moscom_methods = {
- .ucom_get_status = NULL,
.ucom_set = moscom_set,
.ucom_param = moscom_param,
- .ucom_ioctl = NULL,
.ucom_open = moscom_open,
.ucom_close = NULL,
- .ucom_read = NULL,
- .ucom_write = NULL,
};
static const struct usb_devno moscom_devs[] = {
diff -r a9d142360316 -r ab9714df77dc sys/dev/usb/u3g.c
--- a/sys/dev/usb/u3g.c Sat May 04 07:28:18 2019 +0000
+++ b/sys/dev/usb/u3g.c Sat May 04 08:04:13 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: u3g.c,v 1.35 2018/07/24 08:15:57 msaitoh Exp $ */
+/* $NetBSD: u3g.c,v 1.36 2019/05/04 08:04:13 mrg Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: u3g.c,v 1.35 2018/07/24 08:15:57 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: u3g.c,v 1.36 2019/05/04 08:04:13 mrg Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -166,8 +166,6 @@
struct ucom_methods u3g_methods = {
.ucom_get_status = u3g_get_status,
.ucom_set = u3g_set,
- .ucom_param = NULL,
- .ucom_ioctl = NULL,
.ucom_open = u3g_open,
.ucom_close = u3g_close,
.ucom_read = u3g_read,
@@ -542,10 +540,8 @@
{
struct u3g_softc *sc = arg;
- if (lsr != NULL)
- *lsr = 0; /* LSR isn't supported */
- if (msr != NULL)
- *msr = sc->sc_com[portno].c_msr;
+ *lsr = 0; /* LSR isn't supported */
+ *msr = sc->sc_com[portno].c_msr;
}
/*ARGSUSED*/
diff -r a9d142360316 -r ab9714df77dc sys/dev/usb/uark.c
--- a/sys/dev/usb/uark.c Sat May 04 07:28:18 2019 +0000
+++ b/sys/dev/usb/uark.c Sat May 04 08:04:13 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uark.c,v 1.12 2019/01/22 06:47:20 skrll Exp $ */
+/* $NetBSD: uark.c,v 1.13 2019/05/04 08:04:13 mrg Exp $ */
/* $OpenBSD: uark.c,v 1.13 2009/10/13 19:33:17 pirofti Exp $ */
/*
@@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uark.c,v 1.12 2019/01/22 06:47:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uark.c,v 1.13 2019/05/04 08:04:13 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -88,11 +88,6 @@
.ucom_get_status = uark_get_status,
.ucom_set = uark_set,
.ucom_param = uark_param,
- .ucom_ioctl = NULL,
- .ucom_open = NULL,
- .ucom_close = NULL,
- .ucom_read = NULL,
- .ucom_write = NULL,
};
static const struct usb_devno uark_devs[] = {
@@ -325,10 +320,8 @@
{
struct uark_softc *sc = vsc;
- if (msr != NULL)
- *msr = sc->sc_msr;
- if (lsr != NULL)
- *lsr = sc->sc_lsr;
+ *msr = sc->sc_msr;
+ *lsr = sc->sc_lsr;
}
void
diff -r a9d142360316 -r ab9714df77dc sys/dev/usb/ubsa.c
--- a/sys/dev/usb/ubsa.c Sat May 04 07:28:18 2019 +0000
+++ b/sys/dev/usb/ubsa.c Sat May 04 08:04:13 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ubsa.c,v 1.35 2019/01/22 06:47:20 skrll Exp $ */
+/* $NetBSD: ubsa.c,v 1.36 2019/05/04 08:04:13 mrg Exp $ */
/*-
* Copyright (c) 2002, Alexander Kabaev <kan.FreeBSD.org>.
* All rights reserved.
@@ -54,7 +54,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ubsa.c,v 1.35 2019/01/22 06:47:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubsa.c,v 1.36 2019/05/04 08:04:13 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -102,11 +102,8 @@
.ucom_get_status = ubsa_get_status,
.ucom_set = ubsa_set,
.ucom_param = ubsa_param,
- .ucom_ioctl = NULL,
.ucom_open = ubsa_open,
.ucom_close = ubsa_close,
- .ucom_read = NULL,
- .ucom_write = NULL
};
Static const struct usb_devno ubsa_devs[] = {
diff -r a9d142360316 -r ab9714df77dc sys/dev/usb/ubsa_common.c
--- a/sys/dev/usb/ubsa_common.c Sat May 04 07:28:18 2019 +0000
+++ b/sys/dev/usb/ubsa_common.c Sat May 04 08:04:13 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ubsa_common.c,v 1.10 2016/04/23 10:15:32 skrll Exp $ */
+/* $NetBSD: ubsa_common.c,v 1.11 2019/05/04 08:04:13 mrg Exp $ */
/*-
* Copyright (c) 2002, Alexander Kabaev <kan.FreeBSD.org>.
* All rights reserved.
@@ -54,7 +54,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ubsa_common.c,v 1.10 2016/04/23 10:15:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubsa_common.c,v 1.11 2019/05/04 08:04:13 mrg Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -436,9 +436,7 @@
DPRINTF(("ubsa_get_status\n"));
- if (lsr != NULL)
- *lsr = sc->sc_lsr;
- if (msr != NULL)
- *msr = sc->sc_msr;
+ *lsr = sc->sc_lsr;
+ *msr = sc->sc_msr;
}
diff -r a9d142360316 -r ab9714df77dc sys/dev/usb/uchcom.c
--- a/sys/dev/usb/uchcom.c Sat May 04 07:28:18 2019 +0000
+++ b/sys/dev/usb/uchcom.c Sat May 04 08:04:13 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uchcom.c,v 1.29 2019/04/27 01:23:26 mrg Exp $ */
+/* $NetBSD: uchcom.c,v 1.30 2019/05/04 08:04:13 mrg Exp $ */
/*
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uchcom.c,v 1.29 2019/04/27 01:23:26 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uchcom.c,v 1.30 2019/05/04 08:04:13 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -192,11 +192,8 @@
.ucom_get_status = uchcom_get_status,
.ucom_set = uchcom_set,
.ucom_param = uchcom_param,
- .ucom_ioctl = NULL,
.ucom_open = uchcom_open,
.ucom_close = uchcom_close,
- .ucom_read = NULL,
- .ucom_write = NULL,
};
int uchcom_match(device_t, cfdata_t, void *);
diff -r a9d142360316 -r ab9714df77dc sys/dev/usb/ucomvar.h
--- a/sys/dev/usb/ucomvar.h Sat May 04 07:28:18 2019 +0000
+++ b/sys/dev/usb/ucomvar.h Sat May 04 08:04:13 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ucomvar.h,v 1.21 2016/04/23 10:15:32 skrll Exp $ */
+/* $NetBSD: ucomvar.h,v 1.22 2019/05/04 08:04:13 mrg Exp $ */
/*
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -36,18 +36,51 @@
struct ucom_softc;
+/*
+ * The first argument to the ucom callbacks is the passed in ucaa_arg
+ * member of the attach args, typically the parent softc pointer.
+ *
+ * All of these are optional.
+ */
struct ucom_methods {
+ /*
+ * arg2: port number
+ * arg3: pointer to lsr (always non NULL)
+ * arg4: pointer to msr (always non NULL)
+ */
void (*ucom_get_status)(void *, int, u_char *, u_char *);
+ /*
+ * arg2: port number
+ * arg3: value to turn on or off (DTR, RTS, BREAK)
+ * arg4: onoff
+ */
void (*ucom_set)(void *, int, int, int);
#define UCOM_SET_DTR 1
#define UCOM_SET_RTS 2
#define UCOM_SET_BREAK 3
+ /*
+ * arg2: port number
+ * arg3: termios structure to set parameters from
+ */
int (*ucom_param)(void *, int, struct termios *);
+ /*
+ * arg2: port number
+ * arg3: ioctl command
+ * arg4: ioctl data
+ * arg5: ioctl flags
+ * arg6: process calling ioctl
+ */
int (*ucom_ioctl)(void *, int, u_long, void *, int, proc_t *);
+ /* arg2: port number */
int (*ucom_open)(void *, int);
+ /* arg2: port number */
void (*ucom_close)(void *, int);
/*
- * Note: The 'ptr' (2nd arg) and 'count' (3rd arg) pointers can be
+ * arg2: port number
+ * arg3: pointer to buffer pointer
+ * arg4: pointer to buffer count
+ *
+ * Note: The 'ptr' (3nd arg) and 'count' (4rd arg) pointers can be
* adjusted as follows:
*
* ptr: If consuming characters from the start of the buffer,
@@ -60,6 +93,12 @@
* If consuming all characters, set '*count' to zero.
*/
void (*ucom_read)(void *, int, u_char **, uint32_t *);
+ /*
+ * arg2: port number
+ * arg3: pointer to source buffer
+ * arg4: pointer to destination buffer
+ * arg5: pointer to buffer count
+ */
void (*ucom_write)(void *, int, u_char *, u_char *, uint32_t *);
};
diff -r a9d142360316 -r ab9714df77dc sys/dev/usb/uftdi.c
--- a/sys/dev/usb/uftdi.c Sat May 04 07:28:18 2019 +0000
+++ b/sys/dev/usb/uftdi.c Sat May 04 08:04:13 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uftdi.c,v 1.67 2018/02/20 15:48:37 ws Exp $ */
+/* $NetBSD: uftdi.c,v 1.68 2019/05/04 08:04:13 mrg Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uftdi.c,v 1.67 2018/02/20 15:48:37 ws Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uftdi.c,v 1.68 2019/05/04 08:04:13 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -104,15 +104,13 @@
Home |
Main Index |
Thread Index |
Old Index