jtag/adapter: retype adapter_gpio_config.{gpio,chip}_num
Previously, the gpio_num and chip_num members of adapter_gpio_config were typed as 'int' and a sentinel value of -1 was used to denote unconfigured values. Now, these members are typed as 'unsigned int' to better reflect their expected value range. The sentinel value now maps to UINT_MAX as all adapters either define an upper bound for these members or, in the case of bcm2835gpio, only operate on a specific chip, in which case the value doesn't matter. Format specifiers have been left as %d since, when configured, valid values are within the positive range of 'int'. This allows unconfigured values to display as a more readable value of -1 instead of UINT_MAX. Change-Id: Ieb20e5327b2e2e443a8e43d8689cb29538a5c9c1 Signed-off-by: Vincent Fazio <vfazio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8124 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
committed by
Tomas Vanek
parent
4593c75f0b
commit
0d3d4c981a
@@ -86,9 +86,7 @@ static const struct adapter_gpio_config *adapter_gpio_config;
|
||||
|
||||
static bool is_gpio_config_valid(const struct adapter_gpio_config *gpio_config)
|
||||
{
|
||||
return gpio_config->chip_num >= 0
|
||||
&& gpio_config->chip_num < AM335XGPIO_NUM_GPIO_CHIPS
|
||||
&& gpio_config->gpio_num >= 0
|
||||
return gpio_config->chip_num < AM335XGPIO_NUM_GPIO_CHIPS
|
||||
&& gpio_config->gpio_num < AM335XGPIO_NUM_GPIO_PER_CHIP;
|
||||
}
|
||||
|
||||
@@ -249,10 +247,13 @@ static int am335xgpio_reset(int trst, int srst)
|
||||
if (is_gpio_config_valid(&adapter_gpio_config[ADAPTER_GPIO_IDX_TRST]))
|
||||
set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_TRST], trst);
|
||||
|
||||
LOG_DEBUG("am335xgpio_reset(%d, %d), trst_gpio: %d %d, srst_gpio: %d %d",
|
||||
trst, srst,
|
||||
adapter_gpio_config[ADAPTER_GPIO_IDX_TRST].chip_num, adapter_gpio_config[ADAPTER_GPIO_IDX_TRST].gpio_num,
|
||||
adapter_gpio_config[ADAPTER_GPIO_IDX_SRST].chip_num, adapter_gpio_config[ADAPTER_GPIO_IDX_SRST].gpio_num);
|
||||
LOG_DEBUG("trst %d gpio: %d %d, srst %d gpio: %d %d",
|
||||
trst,
|
||||
(int)adapter_gpio_config[ADAPTER_GPIO_IDX_TRST].chip_num,
|
||||
(int)adapter_gpio_config[ADAPTER_GPIO_IDX_TRST].gpio_num,
|
||||
srst,
|
||||
(int)adapter_gpio_config[ADAPTER_GPIO_IDX_SRST].chip_num,
|
||||
(int)adapter_gpio_config[ADAPTER_GPIO_IDX_SRST].gpio_num);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,10 +84,7 @@ static inline void bcm2835_delay(void)
|
||||
static bool is_gpio_config_valid(enum adapter_gpio_config_index idx)
|
||||
{
|
||||
/* Only chip 0 is supported, accept unset value (-1) too */
|
||||
return adapter_gpio_config[idx].chip_num >= -1
|
||||
&& adapter_gpio_config[idx].chip_num <= 0
|
||||
&& adapter_gpio_config[idx].gpio_num >= 0
|
||||
&& adapter_gpio_config[idx].gpio_num <= 31;
|
||||
return adapter_gpio_config[idx].gpio_num <= 31;
|
||||
}
|
||||
|
||||
static void set_gpio_value(const struct adapter_gpio_config *gpio_config, int value)
|
||||
@@ -243,10 +240,13 @@ static int bcm2835gpio_reset(int trst, int srst)
|
||||
if (is_gpio_config_valid(ADAPTER_GPIO_IDX_TRST))
|
||||
set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_TRST], trst);
|
||||
|
||||
LOG_DEBUG("BCM2835 GPIO: bcm2835gpio_reset(%d, %d), trst_gpio: %d %d, srst_gpio: %d %d",
|
||||
trst, srst,
|
||||
adapter_gpio_config[ADAPTER_GPIO_IDX_TRST].chip_num, adapter_gpio_config[ADAPTER_GPIO_IDX_TRST].gpio_num,
|
||||
adapter_gpio_config[ADAPTER_GPIO_IDX_SRST].chip_num, adapter_gpio_config[ADAPTER_GPIO_IDX_SRST].gpio_num);
|
||||
LOG_DEBUG("trst %d gpio: %d %d, srst %d gpio: %d %d",
|
||||
trst,
|
||||
(int)adapter_gpio_config[ADAPTER_GPIO_IDX_TRST].chip_num,
|
||||
(int)adapter_gpio_config[ADAPTER_GPIO_IDX_TRST].gpio_num,
|
||||
srst,
|
||||
(int)adapter_gpio_config[ADAPTER_GPIO_IDX_SRST].chip_num,
|
||||
(int)adapter_gpio_config[ADAPTER_GPIO_IDX_SRST].gpio_num);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,9 +37,7 @@ static const struct adapter_gpio_config *adapter_gpio_config;
|
||||
*/
|
||||
static bool is_gpio_config_valid(enum adapter_gpio_config_index idx)
|
||||
{
|
||||
return adapter_gpio_config[idx].chip_num >= 0
|
||||
&& adapter_gpio_config[idx].chip_num < 1000
|
||||
&& adapter_gpio_config[idx].gpio_num >= 0
|
||||
return adapter_gpio_config[idx].chip_num < 1000
|
||||
&& adapter_gpio_config[idx].gpio_num < 10000;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user