Make pwm channel numbers unsigned.

This commit is contained in:
Ian Lepore 2019-06-15 23:02:09 +00:00
parent f8f8d87cd9
commit 6cdbe2bf20
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=349088
6 changed files with 29 additions and 29 deletions

View File

@ -226,7 +226,7 @@ aw_pwm_detach(device_t dev)
}
static int
aw_pwm_channel_count(device_t dev, int *nchannel)
aw_pwm_channel_count(device_t dev, u_int *nchannel)
{
*nchannel = 1;
@ -235,7 +235,7 @@ aw_pwm_channel_count(device_t dev, int *nchannel)
}
static int
aw_pwm_channel_config(device_t dev, int channel, unsigned int period, unsigned int duty)
aw_pwm_channel_config(device_t dev, u_int channel, u_int period, u_int duty)
{
struct aw_pwm_softc *sc;
uint64_t period_freq, duty_freq;
@ -298,7 +298,7 @@ aw_pwm_channel_config(device_t dev, int channel, unsigned int period, unsigned i
}
static int
aw_pwm_channel_get_config(device_t dev, int channel, unsigned int *period, unsigned int *duty)
aw_pwm_channel_get_config(device_t dev, u_int channel, u_int *period, u_int *duty)
{
struct aw_pwm_softc *sc;
@ -311,7 +311,7 @@ aw_pwm_channel_get_config(device_t dev, int channel, unsigned int *period, unsig
}
static int
aw_pwm_channel_enable(device_t dev, int channel, bool enable)
aw_pwm_channel_enable(device_t dev, u_int channel, bool enable)
{
struct aw_pwm_softc *sc;
uint32_t reg;
@ -335,7 +335,7 @@ aw_pwm_channel_enable(device_t dev, int channel, bool enable)
}
static int
aw_pwm_channel_is_enabled(device_t dev, int channel, bool *enabled)
aw_pwm_channel_is_enabled(device_t dev, u_int channel, bool *enabled)
{
struct aw_pwm_softc *sc;

View File

@ -57,7 +57,7 @@ struct pwmbus_softc {
device_t dev;
device_t parent;
int nchannels;
u_int nchannels;
};
static int
@ -103,43 +103,43 @@ pwmbus_detach(device_t dev)
}
static int
pwmbus_channel_config(device_t dev, int chan, u_int period, u_int duty)
pwmbus_channel_config(device_t dev, u_int chan, u_int period, u_int duty)
{
return (PWMBUS_CHANNEL_CONFIG(device_get_parent(dev), chan, period, duty));
}
static int
pwmbus_channel_get_config(device_t dev, int chan, u_int *period, u_int *duty)
pwmbus_channel_get_config(device_t dev, u_int chan, u_int *period, u_int *duty)
{
return (PWMBUS_CHANNEL_GET_CONFIG(device_get_parent(dev), chan, period, duty));
}
static int
pwmbus_channel_get_flags(device_t dev, int chan, uint32_t *flags)
pwmbus_channel_get_flags(device_t dev, u_int chan, uint32_t *flags)
{
return (PWMBUS_CHANNEL_GET_FLAGS(device_get_parent(dev), chan, flags));
}
static int
pwmbus_channel_enable(device_t dev, int chan, bool enable)
pwmbus_channel_enable(device_t dev, u_int chan, bool enable)
{
return (PWMBUS_CHANNEL_ENABLE(device_get_parent(dev), chan, enable));
}
static int
pwmbus_channel_set_flags(device_t dev, int chan, uint32_t flags)
pwmbus_channel_set_flags(device_t dev, u_int chan, uint32_t flags)
{
return (PWMBUS_CHANNEL_SET_FLAGS(device_get_parent(dev), chan, flags));
}
static int
pwmbus_channel_is_enabled(device_t dev, int chan, bool *enable)
pwmbus_channel_is_enabled(device_t dev, u_int chan, bool *enable)
{
return (PWMBUS_CHANNEL_IS_ENABLED(device_get_parent(dev), chan, enable));
}
static int
pwmbus_channel_count(device_t dev, int *nchannel)
pwmbus_channel_count(device_t dev, u_int *nchannel)
{
return (PWMBUS_CHANNEL_COUNT(device_get_parent(dev), nchannel));
}

View File

@ -34,7 +34,7 @@
struct pwm_channel {
device_t dev;
int channel;
u_int channel;
uint64_t period;
uint64_t duty;
uint32_t flags;

View File

@ -33,14 +33,14 @@ INTERFACE pwmbus;
CODE {
static int
pwm_default_set_flags(device_t dev, int channel, uint32_t flags)
pwm_default_set_flags(device_t dev, u_int channel, uint32_t flags)
{
return (EOPNOTSUPP);
}
static int
pwm_default_get_flags(device_t dev, int channel, uint32_t *flags)
pwm_default_get_flags(device_t dev, u_int channel, uint32_t *flags)
{
*flags = 0;
@ -54,7 +54,7 @@ CODE {
#
METHOD int channel_config {
device_t bus;
int channel;
u_int channel;
unsigned int period;
unsigned int duty;
};
@ -65,7 +65,7 @@ METHOD int channel_config {
#
METHOD int channel_get_config {
device_t bus;
int channel;
u_int channel;
unsigned int *period;
unsigned int *duty;
};
@ -75,7 +75,7 @@ METHOD int channel_get_config {
#
METHOD int channel_set_flags {
device_t bus;
int channel;
u_int channel;
uint32_t flags;
} DEFAULT pwm_default_set_flags;
@ -84,7 +84,7 @@ METHOD int channel_set_flags {
#
METHOD int channel_get_flags {
device_t dev;
int channel;
u_int channel;
uint32_t *flags;
} DEFAULT pwm_default_get_flags;
@ -93,7 +93,7 @@ METHOD int channel_get_flags {
#
METHOD int channel_enable {
device_t bus;
int channel;
u_int channel;
bool enable;
};
@ -102,7 +102,7 @@ METHOD int channel_enable {
#
METHOD int channel_is_enabled {
device_t bus;
int channel;
u_int channel;
bool *enabled;
};
@ -111,5 +111,5 @@ METHOD int channel_is_enabled {
#
METHOD int channel_count {
device_t bus;
int *nchannel;
u_int *nchannel;
};

View File

@ -54,7 +54,7 @@ pwm_ioctl(struct cdev *dev, u_long cmd, caddr_t data,
struct pwmc_softc *sc;
struct pwm_state state;
device_t bus;
int nchannel;
u_int nchannel;
int rv = 0;
sc = dev->si_drv1;
@ -62,7 +62,7 @@ pwm_ioctl(struct cdev *dev, u_long cmd, caddr_t data,
switch (cmd) {
case PWMMAXCHANNEL:
nchannel = -1;
nchannel = 0;
rv = PWMBUS_CHANNEL_COUNT(bus, &nchannel);
bcopy(&nchannel, data, sizeof(nchannel));
break;

View File

@ -66,7 +66,7 @@ main(int argc, char *argv[])
{
struct pwm_state state;
int fd;
int channel, nchannels;
u_int channel, nchannels;
int period, duty;
int action, ch;
cap_rights_t right_ioctl;
@ -75,7 +75,7 @@ main(int argc, char *argv[])
action = 0;
fd = -1;
channel = -1;
channel = -1u;
period = duty = -1;
while ((ch = getopt(argc, argv, "f:c:EDCp:d:")) != -1) {
@ -110,9 +110,9 @@ main(int argc, char *argv[])
usage();
break;
case 'c':
if (channel != -1)
if (channel != -1u)
usage();
channel = strtol(optarg, NULL, 10);
channel = strtoul(optarg, NULL, 10);
break;
case 'f':
if ((fd = open(optarg, O_RDWR)) < 0) {