Make pwm channel numbers unsigned.
This commit is contained in:
parent
f8f8d87cd9
commit
6cdbe2bf20
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=349088
@ -226,7 +226,7 @@ aw_pwm_detach(device_t dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
aw_pwm_channel_count(device_t dev, int *nchannel)
|
aw_pwm_channel_count(device_t dev, u_int *nchannel)
|
||||||
{
|
{
|
||||||
|
|
||||||
*nchannel = 1;
|
*nchannel = 1;
|
||||||
@ -235,7 +235,7 @@ aw_pwm_channel_count(device_t dev, int *nchannel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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;
|
struct aw_pwm_softc *sc;
|
||||||
uint64_t period_freq, duty_freq;
|
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
|
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;
|
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
|
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;
|
struct aw_pwm_softc *sc;
|
||||||
uint32_t reg;
|
uint32_t reg;
|
||||||
@ -335,7 +335,7 @@ aw_pwm_channel_enable(device_t dev, int channel, bool enable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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;
|
struct aw_pwm_softc *sc;
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ struct pwmbus_softc {
|
|||||||
device_t dev;
|
device_t dev;
|
||||||
device_t parent;
|
device_t parent;
|
||||||
|
|
||||||
int nchannels;
|
u_int nchannels;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -103,43 +103,43 @@ pwmbus_detach(device_t dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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));
|
return (PWMBUS_CHANNEL_CONFIG(device_get_parent(dev), chan, period, duty));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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));
|
return (PWMBUS_CHANNEL_GET_CONFIG(device_get_parent(dev), chan, period, duty));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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));
|
return (PWMBUS_CHANNEL_GET_FLAGS(device_get_parent(dev), chan, flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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));
|
return (PWMBUS_CHANNEL_ENABLE(device_get_parent(dev), chan, enable));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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));
|
return (PWMBUS_CHANNEL_SET_FLAGS(device_get_parent(dev), chan, flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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));
|
return (PWMBUS_CHANNEL_IS_ENABLED(device_get_parent(dev), chan, enable));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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));
|
return (PWMBUS_CHANNEL_COUNT(device_get_parent(dev), nchannel));
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
struct pwm_channel {
|
struct pwm_channel {
|
||||||
device_t dev;
|
device_t dev;
|
||||||
int channel;
|
u_int channel;
|
||||||
uint64_t period;
|
uint64_t period;
|
||||||
uint64_t duty;
|
uint64_t duty;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
|
@ -33,14 +33,14 @@ INTERFACE pwmbus;
|
|||||||
|
|
||||||
CODE {
|
CODE {
|
||||||
static int
|
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);
|
return (EOPNOTSUPP);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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;
|
*flags = 0;
|
||||||
@ -54,7 +54,7 @@ CODE {
|
|||||||
#
|
#
|
||||||
METHOD int channel_config {
|
METHOD int channel_config {
|
||||||
device_t bus;
|
device_t bus;
|
||||||
int channel;
|
u_int channel;
|
||||||
unsigned int period;
|
unsigned int period;
|
||||||
unsigned int duty;
|
unsigned int duty;
|
||||||
};
|
};
|
||||||
@ -65,7 +65,7 @@ METHOD int channel_config {
|
|||||||
#
|
#
|
||||||
METHOD int channel_get_config {
|
METHOD int channel_get_config {
|
||||||
device_t bus;
|
device_t bus;
|
||||||
int channel;
|
u_int channel;
|
||||||
unsigned int *period;
|
unsigned int *period;
|
||||||
unsigned int *duty;
|
unsigned int *duty;
|
||||||
};
|
};
|
||||||
@ -75,7 +75,7 @@ METHOD int channel_get_config {
|
|||||||
#
|
#
|
||||||
METHOD int channel_set_flags {
|
METHOD int channel_set_flags {
|
||||||
device_t bus;
|
device_t bus;
|
||||||
int channel;
|
u_int channel;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
} DEFAULT pwm_default_set_flags;
|
} DEFAULT pwm_default_set_flags;
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ METHOD int channel_set_flags {
|
|||||||
#
|
#
|
||||||
METHOD int channel_get_flags {
|
METHOD int channel_get_flags {
|
||||||
device_t dev;
|
device_t dev;
|
||||||
int channel;
|
u_int channel;
|
||||||
uint32_t *flags;
|
uint32_t *flags;
|
||||||
} DEFAULT pwm_default_get_flags;
|
} DEFAULT pwm_default_get_flags;
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ METHOD int channel_get_flags {
|
|||||||
#
|
#
|
||||||
METHOD int channel_enable {
|
METHOD int channel_enable {
|
||||||
device_t bus;
|
device_t bus;
|
||||||
int channel;
|
u_int channel;
|
||||||
bool enable;
|
bool enable;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ METHOD int channel_enable {
|
|||||||
#
|
#
|
||||||
METHOD int channel_is_enabled {
|
METHOD int channel_is_enabled {
|
||||||
device_t bus;
|
device_t bus;
|
||||||
int channel;
|
u_int channel;
|
||||||
bool *enabled;
|
bool *enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -111,5 +111,5 @@ METHOD int channel_is_enabled {
|
|||||||
#
|
#
|
||||||
METHOD int channel_count {
|
METHOD int channel_count {
|
||||||
device_t bus;
|
device_t bus;
|
||||||
int *nchannel;
|
u_int *nchannel;
|
||||||
};
|
};
|
||||||
|
@ -54,7 +54,7 @@ pwm_ioctl(struct cdev *dev, u_long cmd, caddr_t data,
|
|||||||
struct pwmc_softc *sc;
|
struct pwmc_softc *sc;
|
||||||
struct pwm_state state;
|
struct pwm_state state;
|
||||||
device_t bus;
|
device_t bus;
|
||||||
int nchannel;
|
u_int nchannel;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
sc = dev->si_drv1;
|
sc = dev->si_drv1;
|
||||||
@ -62,7 +62,7 @@ pwm_ioctl(struct cdev *dev, u_long cmd, caddr_t data,
|
|||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case PWMMAXCHANNEL:
|
case PWMMAXCHANNEL:
|
||||||
nchannel = -1;
|
nchannel = 0;
|
||||||
rv = PWMBUS_CHANNEL_COUNT(bus, &nchannel);
|
rv = PWMBUS_CHANNEL_COUNT(bus, &nchannel);
|
||||||
bcopy(&nchannel, data, sizeof(nchannel));
|
bcopy(&nchannel, data, sizeof(nchannel));
|
||||||
break;
|
break;
|
||||||
|
@ -66,7 +66,7 @@ main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
struct pwm_state state;
|
struct pwm_state state;
|
||||||
int fd;
|
int fd;
|
||||||
int channel, nchannels;
|
u_int channel, nchannels;
|
||||||
int period, duty;
|
int period, duty;
|
||||||
int action, ch;
|
int action, ch;
|
||||||
cap_rights_t right_ioctl;
|
cap_rights_t right_ioctl;
|
||||||
@ -75,7 +75,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
action = 0;
|
action = 0;
|
||||||
fd = -1;
|
fd = -1;
|
||||||
channel = -1;
|
channel = -1u;
|
||||||
period = duty = -1;
|
period = duty = -1;
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "f:c:EDCp:d:")) != -1) {
|
while ((ch = getopt(argc, argv, "f:c:EDCp:d:")) != -1) {
|
||||||
@ -110,9 +110,9 @@ main(int argc, char *argv[])
|
|||||||
usage();
|
usage();
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
if (channel != -1)
|
if (channel != -1u)
|
||||||
usage();
|
usage();
|
||||||
channel = strtol(optarg, NULL, 10);
|
channel = strtoul(optarg, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
if ((fd = open(optarg, O_RDWR)) < 0) {
|
if ((fd = open(optarg, O_RDWR)) < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user