diff --git a/system/i2c/i2c_common.c b/system/i2c/i2c_common.c index 514e50d72..a3b3fce23 100644 --- a/system/i2c/i2c_common.c +++ b/system/i2c/i2c_common.c @@ -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: