Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Jun 2019 00:11:01 +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: r349164 - in head: sys/dev/pwm usr.sbin/pwm
Message-ID:  <201906180011.x5I0B1hp027657@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Tue Jun 18 00:11:00 2019
New Revision: 349164
URL: https://svnweb.freebsd.org/changeset/base/349164

Log:
  Remove everything related to channels from the pwmc public interface, now
  that there is a pwmc(4) instance per channel and the channel number is
  maintained as a driver ivar rather than being passed in from userland.

Modified:
  head/sys/dev/pwm/pwmc.c
  head/sys/dev/pwm/pwmc.h
  head/usr.sbin/pwm/pwm.8
  head/usr.sbin/pwm/pwm.c

Modified: head/sys/dev/pwm/pwmc.c
==============================================================================
--- head/sys/dev/pwm/pwmc.c	Tue Jun 18 00:08:02 2019	(r349163)
+++ head/sys/dev/pwm/pwmc.c	Tue Jun 18 00:11:00 2019	(r349164)
@@ -71,18 +71,12 @@ pwm_ioctl(struct cdev *dev, u_long cmd, caddr_t data,
 	struct pwmc_softc *sc;
 	struct pwm_state state;
 	device_t bus;
-	u_int nchannel;
 	int rv = 0;
 
 	sc = dev->si_drv1;
 	bus = device_get_parent(sc->dev);
 
 	switch (cmd) {
-	case PWMMAXCHANNEL:
-		nchannel = 0;
-		rv = PWMBUS_CHANNEL_COUNT(bus, &nchannel);
-		bcopy(&nchannel, data, sizeof(nchannel));
-		break;
 	case PWMSETSTATE:
 		bcopy(data, &state, sizeof(state));
 		rv = PWMBUS_CHANNEL_CONFIG(bus, sc->chan,

Modified: head/sys/dev/pwm/pwmc.h
==============================================================================
--- head/sys/dev/pwm/pwmc.h	Tue Jun 18 00:08:02 2019	(r349163)
+++ head/sys/dev/pwm/pwmc.h	Tue Jun 18 00:11:00 2019	(r349164)
@@ -34,7 +34,6 @@
 #define	PWM_POLARITY_INVERTED	(1 << 0)
 
 struct pwm_state {
-	u_int		channel;
 	u_int		period;
 	u_int		duty;
 	uint32_t	flags;
@@ -45,9 +44,8 @@ struct pwm_state {
  * ioctls
  */
 
-#define	PWMMAXCHANNEL	_IOWR('G', 0, int)
-#define	PWMGETSTATE	_IOWR('G', 1, struct pwm_state)
-#define	PWMSETSTATE	_IOWR('G', 2, struct pwm_state)
+#define	PWMGETSTATE	_IOWR('G', 0, struct pwm_state)
+#define	PWMSETSTATE	_IOWR('G', 1, struct pwm_state)
 
 
 #endif /* _PWM_H_ */

Modified: head/usr.sbin/pwm/pwm.8
==============================================================================
--- head/usr.sbin/pwm/pwm.8	Tue Jun 18 00:08:02 2019	(r349163)
+++ head/usr.sbin/pwm/pwm.8	Tue Jun 18 00:11:00 2019	(r349164)
@@ -31,23 +31,18 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl f Ar device
-.Fl c Ar channel
 .Fl E
 .Nm
 .Op Fl f Ar device
-.Fl c Ar channel
 .Fl D
 .Nm
 .Op Fl f Ar device
-.Fl c Ar channel
 .Fl C
 .Nm
 .Op Fl f Ar device
-.Fl c Ar channel
 .Fl p Ar period
 .Nm
 .Op Fl f Ar device
-.Fl c Ar channel
 .Fl d Ar duty
 .Sh DESCRIPTION
 The
@@ -55,9 +50,7 @@ The
 utility can be used to configure pwm controllers.
 .Pp
 The options are as follow:
-.Bl -tag -width "-c channel"
-.It Fl c Ar channel
-Channel number to operate on.
+.Bl -tag -width "-f device"
 .It Fl f Ar device
 Device to operate on.
 If not specified,

Modified: head/usr.sbin/pwm/pwm.c
==============================================================================
--- head/usr.sbin/pwm/pwm.c	Tue Jun 18 00:08:02 2019	(r349163)
+++ head/usr.sbin/pwm/pwm.c	Tue Jun 18 00:11:00 2019	(r349164)
@@ -66,11 +66,11 @@ static void
 usage(void)
 {
 	fprintf(stderr, "Usage:\n");
-	fprintf(stderr, "\tpwm [-f dev] -c channel -E\n");
-	fprintf(stderr, "\tpwm [-f dev] -c channel -D\n");
-	fprintf(stderr, "\tpwm [-f dev] -c channel -C\n");
-	fprintf(stderr, "\tpwm [-f dev] -c channel -p period\n");
-	fprintf(stderr, "\tpwm [-f dev] -c channel -d duty\n");
+	fprintf(stderr, "\tpwm [-f dev] -E\n");
+	fprintf(stderr, "\tpwm [-f dev] -D\n");
+	fprintf(stderr, "\tpwm [-f dev] -C\n");
+	fprintf(stderr, "\tpwm [-f dev] -p period\n");
+	fprintf(stderr, "\tpwm [-f dev] -d duty\n");
 	exit(1);
 }
 
@@ -79,21 +79,19 @@ main(int argc, char *argv[])
 {
 	struct pwm_state state;
 	int fd;
-	u_int channel, nchannels;
 	int period, duty;
 	int action, ch;
 	cap_rights_t right_ioctl;
-	const unsigned long pwm_ioctls[] = {PWMGETSTATE, PWMSETSTATE, PWMMAXCHANNEL};
+	const unsigned long pwm_ioctls[] = {PWMGETSTATE, PWMSETSTATE};
 	char *percent;
 	bool setname;
 
 	action = 0;
 	setname = false;
 	fd = -1;
-	channel = -1u;
 	period = duty = -1;
 
-	while ((ch = getopt(argc, argv, "f:c:EDCp:d:")) != -1) {
+	while ((ch = getopt(argc, argv, "f:EDCp:d:")) != -1) {
 		switch (ch) {
 		case 'E':
 			if (action)
@@ -124,15 +122,13 @@ main(int argc, char *argv[])
 			if (*percent != '\0' && *percent != '%')
 				usage();
 			break;
-		case 'c':
-			if (channel != -1u)
-				usage();
-			channel = strtoul(optarg, NULL, 10);
-			break;
 		case 'f':
 			setname = true;
 			set_device_name(optarg);
 			break;
+		case '?':
+			usage();
+			break;
 		}
 	}
 
@@ -167,19 +163,7 @@ main(int argc, char *argv[])
 		goto fail;
 	}
 
-	/* Check if the channel is correct */
-	if (ioctl(fd, PWMMAXCHANNEL, &nchannels) == -1) {
-		fprintf(stderr, "ioctl: %s\n", strerror(errno));
-		goto fail;
-	}
-	if (channel > nchannels) {
-		fprintf(stderr, "pwm controller only support %d channels\n",
-		    nchannels);
-		goto fail;
-	}
-
 	/* Fill the common args */
-	state.channel = channel;
 	if (ioctl(fd, PWMGETSTATE, &state) == -1) {
 		fprintf(stderr, "Cannot get current state of the pwm controller\n");
 		goto fail;



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