I2C tool: Verify that the I2C bus driver exists when process the -b option
This commit is contained in:
parent
032e73f1eb
commit
83dc6a9b79
@ -43,30 +43,6 @@
|
|||||||
|
|
||||||
#include "i2ctool.h"
|
#include "i2ctool.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Types
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Function Prototypes
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -95,7 +71,7 @@ int common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg)
|
|||||||
goto out_of_range;
|
goto out_of_range;
|
||||||
}
|
}
|
||||||
|
|
||||||
i2ctool->addr = (uint8_t) value;
|
i2ctool->addr = (uint8_t)value;
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
@ -105,7 +81,12 @@ int common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg)
|
|||||||
goto out_of_range;
|
goto out_of_range;
|
||||||
}
|
}
|
||||||
|
|
||||||
i2ctool->bus = (uint8_t) value;
|
if (!i2cdev_exists((int)value))
|
||||||
|
{
|
||||||
|
goto invalid_argument;
|
||||||
|
}
|
||||||
|
|
||||||
|
i2ctool->bus = (uint8_t)value;
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
@ -137,7 +118,7 @@ int common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg)
|
|||||||
goto out_of_range;
|
goto out_of_range;
|
||||||
}
|
}
|
||||||
|
|
||||||
i2ctool->regaddr = (uint8_t) value;
|
i2ctool->regaddr = (uint8_t)value;
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
@ -151,7 +132,7 @@ int common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg)
|
|||||||
goto out_of_range;
|
goto out_of_range;
|
||||||
}
|
}
|
||||||
|
|
||||||
i2ctool->width = (uint8_t) value;
|
i2ctool->width = (uint8_t)value;
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user