I2C tool: Verify that the I2C bus driver exists when process the -b option

This commit is contained in:
Gregory Nutt 2016-02-05 10:49:27 -06:00
parent 032e73f1eb
commit 83dc6a9b79

View File

@ -43,30 +43,6 @@
#include "i2ctool.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -95,7 +71,7 @@ int common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg)
goto out_of_range;
}
i2ctool->addr = (uint8_t) value;
i2ctool->addr = (uint8_t)value;
return ret;
case 'b':
@ -105,7 +81,12 @@ int common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg)
goto out_of_range;
}
i2ctool->bus = (uint8_t) value;
if (!i2cdev_exists((int)value))
{
goto invalid_argument;
}
i2ctool->bus = (uint8_t)value;
return ret;
case 'f':
@ -137,7 +118,7 @@ int common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg)
goto out_of_range;
}
i2ctool->regaddr = (uint8_t) value;
i2ctool->regaddr = (uint8_t)value;
return ret;
case 's':
@ -151,7 +132,7 @@ int common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg)
goto out_of_range;
}
i2ctool->width = (uint8_t) value;
i2ctool->width = (uint8_t)value;
return ret;
default: