Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Sep 2017 22:58:13 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r323691 - in head/sys: dev/iicbus modules/i2c modules/i2c/icee
Message-ID:  <201709172258.v8HMwDgn000805@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Sun Sep 17 22:58:13 2017
New Revision: 323691
URL: https://svnweb.freebsd.org/changeset/base/323691

Log:
  Give icee(4) a detach() method so it can be used as a module.  Add a
  module makefile for it.

Added:
  head/sys/modules/i2c/icee/
  head/sys/modules/i2c/icee/Makefile   (contents, props changed)
Modified:
  head/sys/dev/iicbus/icee.c
  head/sys/modules/i2c/Makefile

Modified: head/sys/dev/iicbus/icee.c
==============================================================================
--- head/sys/dev/iicbus/icee.c	Sun Sep 17 22:58:13 2017	(r323690)
+++ head/sys/dev/iicbus/icee.c	Sun Sep 17 22:58:13 2017	(r323691)
@@ -206,17 +206,34 @@ icee_attach(device_t dev)
 	return (0);
 }
 
+static int
+icee_detach(device_t dev)
+{
+	struct icee_softc *sc = device_get_softc(dev);
+
+	destroy_dev(sc->cdev);
+	return (0);
+}
+
 static int 
 icee_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
 {
+	struct icee_softc *sc;
 
+	sc = CDEV2SOFTC(dev);
+	if (device_get_state(sc->dev) < DS_BUSY)
+		device_busy(sc->dev);
+
 	return (0);
 }
 
 static int
 icee_close(struct cdev *dev, int fflag, int devtype, struct thread *td)
 {
+	struct icee_softc *sc;
 
+	sc = CDEV2SOFTC(dev);
+	device_unbusy(sc->dev);
 	return (0);
 }
 
@@ -345,6 +362,7 @@ icee_write(struct cdev *dev, struct uio *uio, int iofl
 static device_method_t icee_methods[] = {
 	DEVMETHOD(device_probe,		icee_probe),
 	DEVMETHOD(device_attach,	icee_attach),
+	DEVMETHOD(device_detach,	icee_detach),
 
 	DEVMETHOD_END
 };

Modified: head/sys/modules/i2c/Makefile
==============================================================================
--- head/sys/modules/i2c/Makefile	Sun Sep 17 22:58:13 2017	(r323690)
+++ head/sys/modules/i2c/Makefile	Sun Sep 17 22:58:13 2017	(r323691)
@@ -6,6 +6,7 @@ SUBDIR = \
 	ds1307 \
 	ds13rtc \
 	ds3231 \
+	icee \
 	if_ic \
 	iic \
 	iicbb \

Added: head/sys/modules/i2c/icee/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/modules/i2c/icee/Makefile	Sun Sep 17 22:58:13 2017	(r323691)
@@ -0,0 +1,14 @@
+# $FreeBSD$
+
+.PATH:	${SRCTOP}/sys/dev/iicbus
+KMOD=	icee
+SRCS=	icee.c
+
+SRCS+=	\
+	bus_if.h \
+	device_if.h \
+	iicbus_if.h \
+	ofw_bus_if.h \
+	opt_platform.h \
+
+.include <bsd.kmod.mk>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709172258.v8HMwDgn000805>