1.优化设备命令。

This commit is contained in:
MacRsh
2023-12-20 16:04:33 +08:00
parent 36d2737548
commit b1b1fb3602
10 changed files with 28 additions and 93 deletions

View File

@@ -104,7 +104,7 @@ static int mr_adc_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
switch (cmd)
{
case MR_CTL_ADC_SET_CONFIG:
case MR_CTL_ADC_SET_CHANNEL_STATE:
{
if (args != MR_NULL)
{
@@ -114,18 +114,8 @@ static int mr_adc_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
}
return MR_EINVAL;
}
case MR_CTL_ADC_SET_CHANNEL_STATE:
{
if (args != MR_NULL)
{
int state = *((int *)args);
return adc_channel_set_state(adc, off, state);
}
return MR_EINVAL;
}
case MR_CTL_ADC_GET_CONFIG:
case MR_CTL_ADC_GET_CHANNEL_STATE:
{
if (args != MR_NULL)
{
@@ -140,22 +130,6 @@ static int mr_adc_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
return MR_EOK;
}
}
case MR_CTL_ADC_GET_CHANNEL_STATE:
{
if (args != MR_NULL)
{
int *state = (int *)args;
int ret = adc_channel_get_state(adc, off);
if (ret < 0)
{
return ret;
}
*state = ret;
return MR_EOK;
}
return MR_EINVAL;
}
default:
{

View File

@@ -104,7 +104,7 @@ static int mr_dac_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
switch (cmd)
{
case MR_CTL_DAC_SET_CONFIG:
case MR_CTL_DAC_SET_CHANNEL_STATE:
{
if (args != MR_NULL)
{
@@ -114,32 +114,6 @@ static int mr_dac_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
}
return MR_EINVAL;
}
case MR_CTL_DAC_SET_CHANNEL_STATE:
{
if (args != MR_NULL)
{
int state = *((int *)args);
return dac_channel_set_state(dac, off, state);
}
return MR_EINVAL;
}
case MR_CTL_DAC_GET_CONFIG:
{
if (args != MR_NULL)
{
struct mr_dac_config *config = (struct mr_dac_config *)args;
int ret = dac_channel_get_state(dac, off);
if (ret < 0)
{
return ret;
}
config->channel_state = ret;
return MR_EOK;
}
}
case MR_CTL_DAC_GET_CHANNEL_STATE:
{
if (args != MR_NULL)

View File

@@ -121,7 +121,7 @@ static int mr_pin_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
switch (cmd)
{
case MR_CTL_PIN_SET_CONFIG:
case MR_CTL_PIN_SET_MODE:
{
if (args != MR_NULL)
{
@@ -131,16 +131,6 @@ static int mr_pin_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
}
return MR_EINVAL;
}
case MR_CTL_PIN_SET_MODE:
{
if (args != MR_NULL)
{
int mode = *((int *)args);
return pin_set_mode(pin, off, mode);
}
return MR_EINVAL;
}
default:
{

View File

@@ -186,7 +186,7 @@ static int mr_serial_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
}
case MR_CTL_SERIAL_GET_RD_DATASZ:
{
if (args!= MR_NULL)
if (args != MR_NULL)
{
size_t *datasz = (size_t *)args;
@@ -197,7 +197,7 @@ static int mr_serial_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
}
case MR_CTL_SERIAL_GET_WR_DATASZ:
{
if (args!= MR_NULL)
if (args != MR_NULL)
{
size_t *datasz = (size_t *)args;

View File

@@ -183,7 +183,7 @@ static int mr_timer_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
switch (cmd)
{
case MR_CTL_TIMER_SET_CONFIG:
case MR_CTL_TIMER_SET_MODE:
{
if (args != MR_NULL)
{
@@ -195,7 +195,7 @@ static int mr_timer_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
return MR_EINVAL;
}
case MR_CTL_TIMER_GET_CONFIG:
case MR_CTL_TIMER_GET_MODE:
{
if (args != MR_NULL)
{