From patchwork Fri May 12 10:58:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 9723945 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 38C87600CB for ; Fri, 12 May 2017 10:59:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 304F928807 for ; Fri, 12 May 2017 10:59:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24F682880A; Fri, 12 May 2017 10:59:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6A3528807 for ; Fri, 12 May 2017 10:59:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932306AbdELK67 (ORCPT ); Fri, 12 May 2017 06:58:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57208 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932217AbdELK6z (ORCPT ); Fri, 12 May 2017 06:58:55 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 64E2DC04B94E; Fri, 12 May 2017 10:58:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 64E2DC04B94E Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=david@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 64E2DC04B94E Received: from t460s.redhat.com (ovpn-116-140.ams2.redhat.com [10.36.116.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD4FC7D533; Fri, 12 May 2017 10:58:50 +0000 (UTC) From: David Hildenbrand To: kvm@vger.kernel.org Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Thomas Huth , david@redhat.com, Christian Borntraeger , Cornelia Huck Subject: [kvm-unit-tests PATCH v1 4/6] s390x: compile sclp-ascii.c Date: Fri, 12 May 2017 12:58:28 +0200 Message-Id: <20170512105830.10604-5-david@redhat.com> In-Reply-To: <20170512105830.10604-1-david@redhat.com> References: <20170512105830.10604-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 12 May 2017 10:58:55 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We can reuse strlen and memcpy. __pa(x) is already defined in page.h We don't have (and need) defines for error values and consuming sclp irqs is not required, as we won't be passing control to some other OS. Signed-off-by: David Hildenbrand --- lib/s390x/sclp-ascii.c | 28 +++++++--------------------- lib/s390x/sclp.h | 2 -- s390x/Makefile | 1 + 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/lib/s390x/sclp-ascii.c b/lib/s390x/sclp-ascii.c index dc1c3e4..dfb9e68 100644 --- a/lib/s390x/sclp-ascii.c +++ b/lib/s390x/sclp-ascii.c @@ -8,7 +8,9 @@ * directory. */ -#include "s390-ccw.h" +#include +#include +#include #include "sclp.h" static char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096))); @@ -24,11 +26,10 @@ static int sclp_service_call(unsigned int command, void *sccb) " srl %0,28" : "=&d" (cc) : "d" (command), "a" (__pa(sccb)) : "cc", "memory"); - consume_sclp_int(); if (cc == 3) - return -EIO; + return -1; if (cc == 2) - return -EBUSY; + return -1; return 0; } @@ -51,24 +52,9 @@ void sclp_setup(void) sclp_set_write_mask(); } -static int _strlen(const char *str) -{ - int i; - for (i = 0; *str; i++) - str++; - return i; -} - -static void _memcpy(char *dest, const char *src, int len) -{ - int i; - for (i = 0; i < len; i++) - dest[i] = src[i]; -} - void sclp_print(const char *str) { - int len = _strlen(str); + int len = strlen(str); WriteEventData *sccb = (void *)_sccb; sccb->h.length = sizeof(WriteEventData) + len; @@ -76,7 +62,7 @@ void sclp_print(const char *str) sccb->ebh.length = sizeof(EventBufferHeader) + len; sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA; sccb->ebh.flags = 0; - _memcpy(sccb->data, str, len); + memcpy(sccb->data, str, len); sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb); } diff --git a/lib/s390x/sclp.h b/lib/s390x/sclp.h index 3cbfb78..c48cc21 100644 --- a/lib/s390x/sclp.h +++ b/lib/s390x/sclp.h @@ -102,6 +102,4 @@ typedef struct ReadEventData { uint32_t mask; } __attribute__((packed)) ReadEventData; -#define __pa(x) (x) - #endif /* SCLP_H */ diff --git a/s390x/Makefile b/s390x/Makefile index 549c1c0..0f72c9e 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -20,6 +20,7 @@ cflatobjs += lib/util.o cflatobjs += lib/alloc.o cflatobjs += lib/s390x/io.o cflatobjs += lib/s390x/stack.o +cflatobjs += lib/s390x/sclp-ascii.o cstart.o = $(TEST_DIR)/cstart64.o