diff mbox

[v5,04/15] ssi: Added create_slave_no_init()

Message ID 14d6a00223a609ba4ba0c15682d997519ede7864.1344218410.git.peter.crosthwaite@petalogix.com
State New
Headers show

Commit Message

Peter A. G. Crosthwaite Aug. 6, 2012, 2:16 a.m. UTC
Slave creation function that can be used to create an SSI slave without
qdev_init() being called. This give machine models a change to set properties.

Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
---
 hw/ssi.c |    9 +++++++--
 hw/ssi.h |    1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

Comments

Peter Maydell Aug. 6, 2012, 9:29 a.m. UTC | #1
On 6 August 2012 03:16, Peter A. G. Crosthwaite
<peter.crosthwaite@petalogix.com> wrote:
> Slave creation function that can be used to create an SSI slave without
> qdev_init() being called. This give machine models a change to set properties.

Not convinced about this one -- I think that if machine models need to
do more complicated things with the qdev device then they should just
call qdev_create/set properties/qdev_init themselves.

-- PMM

> Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
> ---
>  hw/ssi.c |    9 +++++++--
>  hw/ssi.h |    1 +
>  2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/hw/ssi.c b/hw/ssi.c
> index 2e4f2fe..c47419d 100644
> --- a/hw/ssi.c
> +++ b/hw/ssi.c
> @@ -86,10 +86,15 @@ static TypeInfo ssi_slave_info = {
>      .abstract = true,
>  };
>
> +DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name)
> +{
> +    return qdev_create(&bus->qbus, name);
> +}
> +
>  DeviceState *ssi_create_slave(SSIBus *bus, const char *name)
>  {
> -    DeviceState *dev;
> -    dev = qdev_create(&bus->qbus, name);
> +    DeviceState *dev = ssi_create_slave_no_init(bus, name);
> +
>      qdev_init_nofail(dev);
>      return dev;
>  }
> diff --git a/hw/ssi.h b/hw/ssi.h
> index 5b69a3b..80b9664 100644
> --- a/hw/ssi.h
> +++ b/hw/ssi.h
> @@ -76,6 +76,7 @@ extern const VMStateDescription vmstate_ssi_slave;
>  }
>
>  DeviceState *ssi_create_slave(SSIBus *bus, const char *name);
> +DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name);
>
>  /* Master interface.  */
>  SSIBus *ssi_create_bus(DeviceState *parent, const char *name);
> --
> 1.7.0.4
>
Peter A. G. Crosthwaite Aug. 7, 2012, 12:04 a.m. UTC | #2
On Mon, Aug 6, 2012 at 7:29 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 6 August 2012 03:16, Peter A. G. Crosthwaite
> <peter.crosthwaite@petalogix.com> wrote:
>> Slave creation function that can be used to create an SSI slave without
>> qdev_init() being called. This give machine models a change to set properties.
>
> Not convinced about this one -- I think that if machine models need to
> do more complicated things with the qdev device then they should just
> call qdev_create/set properties/qdev_init themselves.
>

Yeh I tried that didnt work. See comment below.

> -- PMM
>
>> Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
>> ---
>>  hw/ssi.c |    9 +++++++--
>>  hw/ssi.h |    1 +
>>  2 files changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/ssi.c b/hw/ssi.c
>> index 2e4f2fe..c47419d 100644
>> --- a/hw/ssi.c
>> +++ b/hw/ssi.c
>> @@ -86,10 +86,15 @@ static TypeInfo ssi_slave_info = {
>>      .abstract = true,
>>  };
>>
>> +DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name)
>> +{
>> +    return qdev_create(&bus->qbus, name);

bus->qbus accesses requires the definition of struct SSIBus which is
private to ssi.c. Machine models cant access the qbus field which they
need for qdev_create().

Regards,
Peter

>> +}
>> +
>>  DeviceState *ssi_create_slave(SSIBus *bus, const char *name)
>>  {
>> -    DeviceState *dev;
>> -    dev = qdev_create(&bus->qbus, name);
>> +    DeviceState *dev = ssi_create_slave_no_init(bus, name);
>> +
>>      qdev_init_nofail(dev);
>>      return dev;
>>  }
>> diff --git a/hw/ssi.h b/hw/ssi.h
>> index 5b69a3b..80b9664 100644
>> --- a/hw/ssi.h
>> +++ b/hw/ssi.h
>> @@ -76,6 +76,7 @@ extern const VMStateDescription vmstate_ssi_slave;
>>  }
>>
>>  DeviceState *ssi_create_slave(SSIBus *bus, const char *name);
>> +DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name);
>>
>>  /* Master interface.  */
>>  SSIBus *ssi_create_bus(DeviceState *parent, const char *name);
>> --
>> 1.7.0.4
>>
diff mbox

Patch

diff --git a/hw/ssi.c b/hw/ssi.c
index 2e4f2fe..c47419d 100644
--- a/hw/ssi.c
+++ b/hw/ssi.c
@@ -86,10 +86,15 @@  static TypeInfo ssi_slave_info = {
     .abstract = true,
 };
 
+DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name)
+{
+    return qdev_create(&bus->qbus, name);
+}
+
 DeviceState *ssi_create_slave(SSIBus *bus, const char *name)
 {
-    DeviceState *dev;
-    dev = qdev_create(&bus->qbus, name);
+    DeviceState *dev = ssi_create_slave_no_init(bus, name);
+
     qdev_init_nofail(dev);
     return dev;
 }
diff --git a/hw/ssi.h b/hw/ssi.h
index 5b69a3b..80b9664 100644
--- a/hw/ssi.h
+++ b/hw/ssi.h
@@ -76,6 +76,7 @@  extern const VMStateDescription vmstate_ssi_slave;
 }
 
 DeviceState *ssi_create_slave(SSIBus *bus, const char *name);
+DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name);
 
 /* Master interface.  */
 SSIBus *ssi_create_bus(DeviceState *parent, const char *name);