From: Andrew Boyer Date: Fri, 29 Jan 2021 22:44:33 +0000 (-0800) Subject: net/ionic: use existing array size macro X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=76276d716b2ce6eb9dbef584cec4b67b4e364b21;p=dpdk.git net/ionic: use existing array size macro Using the RTE_DIM() macro makes the code clearer. Signed-off-by: Andrew Boyer --- diff --git a/drivers/net/ionic/ionic_dev.c b/drivers/net/ionic/ionic_dev.c index aba1713fbc..a9f9e2faf9 100644 --- a/drivers/net/ionic/ionic_dev.c +++ b/drivers/net/ionic/ionic_dev.c @@ -87,9 +87,8 @@ void ionic_dev_cmd_comp(struct ionic_dev *idev, void *mem) { union ionic_dev_cmd_comp *comp = mem; - unsigned int i; - uint32_t comp_size = sizeof(comp->words) / - sizeof(comp->words[0]); + uint32_t comp_size = RTE_DIM(comp->words); + uint32_t i; for (i = 0; i < comp_size; i++) comp->words[i] = ioread32(&idev->dev_cmd->comp.words[i]); @@ -98,9 +97,8 @@ ionic_dev_cmd_comp(struct ionic_dev *idev, void *mem) void ionic_dev_cmd_go(struct ionic_dev *idev, union ionic_dev_cmd *cmd) { - unsigned int i; - uint32_t cmd_size = sizeof(cmd->words) / - sizeof(cmd->words[0]); + uint32_t cmd_size = RTE_DIM(cmd->words); + uint32_t i; IONIC_PRINT(DEBUG, "Sending %s (%d) via dev_cmd", ionic_opcode_to_str(cmd->cmd.opcode), cmd->cmd.opcode); diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c index 9a319df6ec..67f38cd3f4 100644 --- a/drivers/net/ionic/ionic_ethdev.c +++ b/drivers/net/ionic/ionic_ethdev.c @@ -207,8 +207,7 @@ static const struct rte_ionic_xstats_name_off rte_ionic_xstats_strings[] = { tx_desc_data_error)}, }; -#define IONIC_NB_HW_STATS (sizeof(rte_ionic_xstats_strings) / \ - sizeof(rte_ionic_xstats_strings[0])) +#define IONIC_NB_HW_STATS RTE_DIM(rte_ionic_xstats_strings) static int ionic_dev_fw_version_get(struct rte_eth_dev *eth_dev, diff --git a/drivers/net/ionic/ionic_lif.c b/drivers/net/ionic/ionic_lif.c index a8768b6a31..3d4e155328 100644 --- a/drivers/net/ionic/ionic_lif.c +++ b/drivers/net/ionic/ionic_lif.c @@ -1824,13 +1824,10 @@ ionic_lif_identify(struct ionic_adapter *adapter) struct ionic_dev *idev = &adapter->idev; struct ionic_identity *ident = &adapter->ident; union ionic_lif_config *cfg = &ident->lif.eth.config; + uint32_t lif_words = RTE_DIM(ident->lif.words); + uint32_t cmd_words = RTE_DIM(idev->dev_cmd->data); + uint32_t i, nwords; int err; - unsigned int i; - unsigned int lif_words = sizeof(ident->lif.words) / - sizeof(ident->lif.words[0]); - unsigned int cmd_words = sizeof(idev->dev_cmd->data) / - sizeof(idev->dev_cmd->data[0]); - unsigned int nwords; ionic_dev_cmd_lif_identify(idev, IONIC_LIF_TYPE_CLASSIC, IONIC_IDENTITY_VERSION_1); diff --git a/drivers/net/ionic/ionic_main.c b/drivers/net/ionic/ionic_main.c index 3f15a6f2f2..3f1a764888 100644 --- a/drivers/net/ionic/ionic_main.c +++ b/drivers/net/ionic/ionic_main.c @@ -263,15 +263,11 @@ ionic_identify(struct ionic_adapter *adapter) { struct ionic_dev *idev = &adapter->idev; struct ionic_identity *ident = &adapter->ident; - int err = 0; - uint32_t i; - unsigned int nwords; - uint32_t drv_size = sizeof(ident->drv.words) / - sizeof(ident->drv.words[0]); - uint32_t cmd_size = sizeof(idev->dev_cmd->data) / - sizeof(idev->dev_cmd->data[0]); - uint32_t dev_size = sizeof(ident->dev.words) / - sizeof(ident->dev.words[0]); + uint32_t drv_size = RTE_DIM(ident->drv.words); + uint32_t cmd_size = RTE_DIM(idev->dev_cmd->data); + uint32_t dev_size = RTE_DIM(ident->dev.words); + uint32_t i, nwords; + int err; memset(ident, 0, sizeof(*ident)); @@ -323,12 +319,9 @@ ionic_port_identify(struct ionic_adapter *adapter) { struct ionic_dev *idev = &adapter->idev; struct ionic_identity *ident = &adapter->ident; - unsigned int port_words = sizeof(ident->port.words) / - sizeof(ident->port.words[0]); - unsigned int cmd_words = sizeof(idev->dev_cmd->data) / - sizeof(idev->dev_cmd->data[0]); - unsigned int i; - unsigned int nwords; + uint32_t port_words = RTE_DIM(ident->port.words); + uint32_t cmd_words = RTE_DIM(idev->dev_cmd->data); + uint32_t i, nwords; int err; ionic_dev_cmd_port_identify(idev); @@ -374,12 +367,9 @@ ionic_port_init(struct ionic_adapter *adapter) struct ionic_dev *idev = &adapter->idev; struct ionic_identity *ident = &adapter->ident; char z_name[RTE_MEMZONE_NAMESIZE]; - unsigned int config_words = sizeof(ident->port.config.words) / - sizeof(ident->port.config.words[0]); - unsigned int cmd_words = sizeof(idev->dev_cmd->data) / - sizeof(idev->dev_cmd->data[0]); - unsigned int nwords; - unsigned int i; + uint32_t config_words = RTE_DIM(ident->port.config.words); + uint32_t cmd_words = RTE_DIM(idev->dev_cmd->data); + uint32_t i, nwords; int err; if (idev->port_info)