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.
This commit is contained in:
Ian Lepore 2019-06-18 00:11:00 +00:00
parent e68fcc8875
commit 780c3de886
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=349164
4 changed files with 13 additions and 44 deletions

View File

@ -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,

View File

@ -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_ */

View File

@ -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,

View File

@ -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;