diff mbox

[5/6] hw/char: QOM'ify sclpconsole-lm.c

Message ID 1458206430-21917-6-git-send-email-zxq_yx_007@163.com (mailing list archive)
State New, archived
Headers show

Commit Message

zhao xiao qiang March 17, 2016, 9:20 a.m. UTC
Drop the DO_UPCAST macro

Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
---
 hw/char/sclpconsole-lm.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

Comments

Cornelia Huck March 17, 2016, 10:08 a.m. UTC | #1
On Thu, 17 Mar 2016 17:20:29 +0800
xiaoqiang zhao <zxq_yx_007@163.com> wrote:

> Drop the DO_UPCAST macro
> 
> Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
> ---
>  hw/char/sclpconsole-lm.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c
> index 7d4ff81..3dcc5a5 100644
> --- a/hw/char/sclpconsole-lm.c
> +++ b/hw/char/sclpconsole-lm.c
> @@ -44,6 +44,10 @@ typedef struct SCLPConsoleLM {
>      uint8_t buf[SIZE_CONSOLE_BUFFER];
>  } SCLPConsoleLM;
> 
> +#define TYPE_SCLP_LM_CONSOLE "sclplmconsole"
> +#define SCLP_LM_CONSOLE(obj) \
> +    OBJECT_CHECK(SCLPConsoleLM, (obj), TYPE_SCLP_LM_CONSOLE)

I'd prefer SCLPLM over SCLP_LM (don't know, but the 'LM' looks a bit
lonely ;)
zhao xiao qiang March 17, 2016, 10:38 a.m. UTC | #2
At 2016-03-17 18:08:52, "Cornelia Huck" <cornelia.huck@de.ibm.com> wrote:
>On Thu, 17 Mar 2016 17:20:29 +0800
>xiaoqiang zhao <zxq_yx_007@163.com> wrote:
>
>> Drop the DO_UPCAST macro
>> 
>> Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
>> ---
>>  hw/char/sclpconsole-lm.c | 14 +++++++++-----
>>  1 file changed, 9 insertions(+), 5 deletions(-)
>> 
>> diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c
>> index 7d4ff81..3dcc5a5 100644
>> --- a/hw/char/sclpconsole-lm.c
>> +++ b/hw/char/sclpconsole-lm.c
>> @@ -44,6 +44,10 @@ typedef struct SCLPConsoleLM {
>>      uint8_t buf[SIZE_CONSOLE_BUFFER];
>>  } SCLPConsoleLM;
>> 
>> +#define TYPE_SCLP_LM_CONSOLE "sclplmconsole"
>> +#define SCLP_LM_CONSOLE(obj) \
>> +    OBJECT_CHECK(SCLPConsoleLM, (obj), TYPE_SCLP_LM_CONSOLE)
>
>I'd prefer SCLPLM over SCLP_LM (don't know, but the 'LM' looks a bit
>lonely ;)
>

>
Maybe better!
diff mbox

Patch

diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c
index 7d4ff81..3dcc5a5 100644
--- a/hw/char/sclpconsole-lm.c
+++ b/hw/char/sclpconsole-lm.c
@@ -44,6 +44,10 @@  typedef struct SCLPConsoleLM {
     uint8_t buf[SIZE_CONSOLE_BUFFER];
 } SCLPConsoleLM;
 
+#define TYPE_SCLP_LM_CONSOLE "sclplmconsole"
+#define SCLP_LM_CONSOLE(obj) \
+    OBJECT_CHECK(SCLPConsoleLM, (obj), TYPE_SCLP_LM_CONSOLE)
+
 /*
 *  Character layer call-back functions
  *
@@ -116,7 +120,7 @@  static int get_console_data(SCLPEvent *event, uint8_t *buf, size_t *size,
 {
     int len;
 
-    SCLPConsoleLM *cons = DO_UPCAST(SCLPConsoleLM, event, event);
+    SCLPConsoleLM *cons = SCLP_LM_CONSOLE(event);
 
     len = cons->length;
     /* data need to fit into provided SCLP buffer */
@@ -190,7 +194,7 @@  static int write_console_data(SCLPEvent *event, const uint8_t *buf, int len)
     int ret = 0;
     const uint8_t *buf_offset;
 
-    SCLPConsoleLM *scon = DO_UPCAST(SCLPConsoleLM, event, event);
+    SCLPConsoleLM *scon = SCLP_LM_CONSOLE(event);
 
     if (!scon->chr) {
         /* If there's no backend, we can just say we consumed all data. */
@@ -244,7 +248,7 @@  static int write_event_data(SCLPEvent *event, EventBufferHeader *ebh)
     int errors = 0;
     MDBO *mdbo;
     SclpMsg *data = (SclpMsg *) ebh;
-    SCLPConsoleLM *scon = DO_UPCAST(SCLPConsoleLM, event, event);
+    SCLPConsoleLM *scon = SCLP_LM_CONSOLE(event);
 
     len = be16_to_cpu(data->mdb.header.length);
     if (len < sizeof(data->mdb.header)) {
@@ -313,7 +317,7 @@  static int console_init(SCLPEvent *event)
 {
     static bool console_available;
 
-    SCLPConsoleLM *scon = DO_UPCAST(SCLPConsoleLM, event, event);
+    SCLPConsoleLM *scon = SCLP_LM_CONSOLE(event);
 
     if (console_available) {
         error_report("Multiple line-mode operator consoles are not supported");
@@ -336,7 +340,7 @@  static int console_exit(SCLPEvent *event)
 static void console_reset(DeviceState *dev)
 {
    SCLPEvent *event = SCLP_EVENT(dev);
-   SCLPConsoleLM *scon = DO_UPCAST(SCLPConsoleLM, event, event);
+   SCLPConsoleLM *scon = SCLP_LM_CONSOLE(event);
 
    event->event_pending = false;
    scon->length = 0;