ocelot->map             = felix->info->map;
        ocelot->stats_layout    = felix->info->stats_layout;
-       ocelot->num_stats       = felix->info->num_stats;
        ocelot->num_mact_rows   = felix->info->num_mact_rows;
        ocelot->vcap            = felix->info->vcap;
        ocelot->vcap_pol.base   = felix->info->vcap_pol_base;
 
        const u32                       *port_modes;
        int                             num_mact_rows;
        const struct ocelot_stat_layout *stats_layout;
-       unsigned int                    num_stats;
        int                             num_ports;
        int                             num_tx_queues;
        struct vcap_props               *vcap;
 
        { .offset = 0x10F,      .name = "drop_green_prio_5", },
        { .offset = 0x110,      .name = "drop_green_prio_6", },
        { .offset = 0x111,      .name = "drop_green_prio_7", },
+       OCELOT_STAT_END
 };
 
 static const struct vcap_field vsc9959_vcap_es0_keys[] = {
        .map                    = vsc9959_regmap,
        .ops                    = &vsc9959_ops,
        .stats_layout           = vsc9959_stats_layout,
-       .num_stats              = ARRAY_SIZE(vsc9959_stats_layout),
        .vcap                   = vsc9959_vcap_props,
        .vcap_pol_base          = VSC9959_VCAP_POLICER_BASE,
        .vcap_pol_max           = VSC9959_VCAP_POLICER_MAX,
 
        { .offset = 0x8F,       .name = "drop_green_prio_5", },
        { .offset = 0x90,       .name = "drop_green_prio_6", },
        { .offset = 0x91,       .name = "drop_green_prio_7", },
+       OCELOT_STAT_END
 };
 
 static const struct vcap_field vsc9953_vcap_es0_keys[] = {
        .map                    = vsc9953_regmap,
        .ops                    = &vsc9953_ops,
        .stats_layout           = vsc9953_stats_layout,
-       .num_stats              = ARRAY_SIZE(vsc9953_stats_layout),
        .vcap                   = vsc9953_vcap_props,
        .vcap_pol_base          = VSC9953_VCAP_POLICER_BASE,
        .vcap_pol_max           = VSC9953_VCAP_POLICER_MAX,
 
 
 int ocelot_init(struct ocelot *ocelot)
 {
+       const struct ocelot_stat_layout *stat;
        char queue_name[32];
        int i, ret;
        u32 port;
                }
        }
 
+       ocelot->num_stats = 0;
+       for_each_stat(ocelot, stat)
+               ocelot->num_stats++;
+
        ocelot->stats = devm_kcalloc(ocelot->dev,
                                     ocelot->num_phys_ports * ocelot->num_stats,
                                     sizeof(u64), GFP_KERNEL);
 
        { .name = "drop_green_prio_5", .offset = 0x8F, },
        { .name = "drop_green_prio_6", .offset = 0x90, },
        { .name = "drop_green_prio_7", .offset = 0x91, },
+       OCELOT_STAT_END
 };
 
 static void ocelot_pll5_init(struct ocelot *ocelot)
 
        ocelot->map = ocelot_regmap;
        ocelot->stats_layout = ocelot_stats_layout;
-       ocelot->num_stats = ARRAY_SIZE(ocelot_stats_layout);
        ocelot->num_mact_rows = 1024;
        ocelot->ops = ops;
 
 
 #define REG_RESERVED_ADDR              0xffffffff
 #define REG_RESERVED(reg)              REG(reg, REG_RESERVED_ADDR)
 
+#define OCELOT_STAT_FLAG_END           BIT(0)
+
+#define for_each_stat(ocelot, stat)                            \
+       for ((stat) = ocelot->stats_layout;                     \
+            !((stat)->flags & OCELOT_STAT_FLAG_END);           \
+            (stat)++)
+
 enum ocelot_target {
        ANA = 1,
        QS,
 
 struct ocelot_stat_layout {
        u32 offset;
+       u32 flags;
        char name[ETH_GSTRING_LEN];
 };
 
+#define OCELOT_STAT_END { .flags = OCELOT_STAT_FLAG_END }
+
 struct ocelot_stats_region {
        struct list_head node;
        u32 offset;