stm32: Use DT_NUM_INST_STATUS_OKAY for num IRQ sources

Use DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) to determine
number of potential interrupt sources. This mitigates
the wasting of memory on devices with mutliple UCPD ports
but only one UCPD port is used.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
This commit is contained in:
Sam Hurst 2022-08-02 12:10:27 -07:00 committed by Anas Nashif
commit 050323f00f

View file

@ -1010,7 +1010,6 @@ static void ucpd_isr(const struct device *dev_inst[])
const struct tcpc_config *config; const struct tcpc_config *config;
struct tcpc_data *data; struct tcpc_data *data;
uint32_t sr; uint32_t sr;
uint32_t ucpd_base;
struct alert_info *info; struct alert_info *info;
uint32_t tx_done_mask = UCPD_SR_TXMSGSENT | uint32_t tx_done_mask = UCPD_SR_TXMSGSENT |
UCPD_SR_TXMSGABT | UCPD_SR_TXMSGABT |
@ -1018,7 +1017,13 @@ static void ucpd_isr(const struct device *dev_inst[])
UCPD_SR_HRSTSENT | UCPD_SR_HRSTSENT |
UCPD_SR_HRSTDISC; UCPD_SR_HRSTDISC;
if (IS_ENABLED(CONFIG_SOC_SERIES_STM32G0X)) { #if DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) > 1
/*
* Multiple UCPD ports are available
*/
uint32_t ucpd_base;
/* /*
* Since the UCPD peripherals share the same interrupt line, determine * Since the UCPD peripherals share the same interrupt line, determine
* which one generated the interrupt. * which one generated the interrupt.
@ -1045,11 +1050,14 @@ static void ucpd_isr(const struct device *dev_inst[])
break; break;
} }
} }
} else { #else
/* Only one port available */ /*
* Only one UCPD port available
*/
dev = dev_inst[0]; dev = dev_inst[0];
config = dev->config; config = dev->config;
} #endif /* Get the UCPD port that initiated that interrupt */
data = dev->data; data = dev->data;
info = &data->alert_info; info = &data->alert_info;