OSDN Git Service

hw/sd: Declare QOM types using DEFINE_TYPES() macro
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Tue, 31 Oct 2023 05:55:39 +0000 (06:55 +0100)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Tue, 7 Nov 2023 12:08:49 +0000 (13:08 +0100)
commit88d2198c0836871e5902da1e1340e3ba3cb5a71d
tree45bb7a8947f580418619f054cfc15346bab980df
parentff0511282d406150984de1aaaaad451da8ad3a1c
hw/sd: Declare QOM types using DEFINE_TYPES() macro

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é <philmd@linaro.org>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20231031080603.86889-2-philmd@linaro.org>
hw/sd/aspeed_sdhci.c
hw/sd/bcm2835_sdhost.c
hw/sd/cadence_sdhci.c
hw/sd/core.c
hw/sd/npcm7xx_sdhci.c
hw/sd/pl181.c
hw/sd/pxa2xx_mmci.c
hw/sd/sd.c
hw/sd/sdhci-pci.c
hw/sd/ssi-sd.c