On 31/10/23 09:31, Cédric Le Goater wrote:
On 10/31/23 09:06, Philippe Mathieu-Daudé wrote:
When multiple QOM types are registered in the same file,
it is simpler to use the the DEFINE_TYPES() macro. In
particular because type array declared with such macro
are easier to review.

Mechanical transformation using the following comby script:

   [pattern-x1]
   match='''
   static const TypeInfo :[i1~.*_info] = {
       :[body]
   };
   static void :[rt1~.*_register_type.](void)
   {
       type_register_static(&:[i2~.*_info]);
   }
   type_init(:[rt2~.*_register_type.])
   '''
   rewrite='''
   static const TypeInfo :[i1][] = {
       {
       :[body]
       },
   };

   DEFINE_TYPES(:[i1])
   '''
   rule='where :[i1] == :[i2], :[rt1] == :[rt2]'

   [pattern-x2]
   match='''
   static const TypeInfo :[i1a~.*_info] = {
       :[body1]
   };
   ...
   static const TypeInfo :[i2a~.*_info] = {
       :[body2]
   };
   static void :[rt1~.*_register_type.](void)
   {
       type_register_static(&:[i1b~.*_info]);
       type_register_static(&:[i2b~.*_info]);
   }
   type_init(:[rt2~.*_register_type.])
   '''
   rewrite='''
   static const TypeInfo :[i1a][] = {
       {
       :[body1]
       },
       {
       :[body2]
       },
   };

   DEFINE_TYPES(:[i1a])
   '''
   rule='''
   where
   :[i1a] == :[i1b],
   :[i2a] == :[i2b],
   :[rt1] == :[rt2]
   '''

and re-indented manually.

Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org>

I checked the aspeed part.

Reviewed-by: Cédric Le Goater <c...@kaod.org>

In the absence of other reviews, I'm queueing this patch via my cpu/misc tree, thanks!

---
  hw/sd/aspeed_sdhci.c   | 19 ++++++++-----------
  hw/sd/bcm2835_sdhost.c | 33 ++++++++++++++-------------------
  hw/sd/cadence_sdhci.c  | 21 +++++++++------------
  hw/sd/core.c           | 19 ++++++++-----------
  hw/sd/npcm7xx_sdhci.c  | 21 +++++++++------------
  hw/sd/pl181.c          | 35 +++++++++++++++--------------------
  hw/sd/pxa2xx_mmci.c    | 35 +++++++++++++++--------------------
  hw/sd/sd.c             | 37 ++++++++++++++++---------------------
  hw/sd/sdhci-pci.c      | 25 +++++++++++--------------
  hw/sd/ssi-sd.c         | 19 ++++++++-----------
  10 files changed, 113 insertions(+), 151 deletions(-)


Reply via email to