From patchwork Fri Feb 21 13:25:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1242137 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BhZCArZE; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48PCCy5lSLz9sRl for ; Sat, 22 Feb 2020 00:36:30 +1100 (AEDT) Received: from localhost ([::1]:57882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j58Tk-0000VT-Fd for incoming@patchwork.ozlabs.org; Fri, 21 Feb 2020 08:36:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33024) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j58Jk-00032F-4S for qemu-devel@nongnu.org; Fri, 21 Feb 2020 08:26:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j58Jj-0007RH-5i for qemu-devel@nongnu.org; Fri, 21 Feb 2020 08:26:08 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:35685 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j58Jj-0007Oa-0x for qemu-devel@nongnu.org; Fri, 21 Feb 2020 08:26:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582291559; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=paBsMW5zAXDjF5puyoeLRSe8b4xNuuGDm59bJb4U3bc=; b=BhZCArZELnxL5NNxFJykcCsDTgONQZW+nHj79P/LNy4vqxcgDQmYyM8eshdJWpz3x4CeQu xnsYobzHj90eD9q42aGvNQ94Dr+EjlWPFBFGT6NUvxyvPKopgIy1EYBvx6WMf5jIdDai3r Z++CXNtaQwU1Jxg+YRRtLKBuIMPcFHs= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-402-h-SMVGyhNY2VKFwkOT-6jg-1; Fri, 21 Feb 2020 08:25:55 -0500 X-MC-Unique: h-SMVGyhNY2VKFwkOT-6jg-1 Received: by mail-wr1-f70.google.com with SMTP id t6so1025459wru.3 for ; Fri, 21 Feb 2020 05:25:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6JNTk73NjeTv3OroNAfG3ztm3tllZwoLmRJFD7uZjK0=; b=r42kOHdwy7uHgp20YeLoB4tk16GbGNCF8Xaqp5gr8fuMJnZLb2WFKCYznOlNGkTg9O PSMDlEfAT6YwNCqlLc8ZmNWwKG/RSMVCTAz0b0DZvMuX1IQrvl3CqW5sVl1T5rHjKcYw pWTedDGSoj0xzOldSJvY4r5CjOwURpewTcFyeBV1cYYaXZlakgNgeLZmvhr0WwqYRpgv leXeD8rk/swUf9s20FdmTMH9O5z3kUpkokzqGJs4qLaguZCzC0PMA0XvX30mrUHQqByT Iu08/7tzP8B1k1m6mhPcP31p9gwQVgAH9buYHby6IFHGIbEFNMTLWdSBd48OuiXoyMGy uaag== X-Gm-Message-State: APjAAAUb/9rDq5a0ssfoIhI94Ist1xekZ1NSN7izWYNav9+977Q9D8Ri ds8PckWgjR/lmUrArs29UYM+PnBPFaG5hdFKmLgjEsTn8370RwmtlfKMTADLYT94+MdzDh2bZ2A 5021zhJBfBpwOc/o= X-Received: by 2002:a1c:1d13:: with SMTP id d19mr4054148wmd.163.1582291553724; Fri, 21 Feb 2020 05:25:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzPjY8oFbGxLJLxgcK4v5NODWlpzzhdcwfRsmRXufRcVp1f1WdUGi5RdTT5vnCn6cmusuzFaA== X-Received: by 2002:a1c:1d13:: with SMTP id d19mr4054114wmd.163.1582291553379; Fri, 21 Feb 2020 05:25:53 -0800 (PST) Received: from x1w.redhat.com (78.red-88-21-202.staticip.rima-tde.net. [88.21.202.78]) by smtp.gmail.com with ESMTPSA id t13sm3947679wrw.19.2020.02.21.05.25.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2020 05:25:52 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/3] hw/dma/sparc32_dma: Make espdma_memory_[read/write] static Date: Fri, 21 Feb 2020 14:25:48 +0100 Message-Id: <20200221132550.22156-2-philmd@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200221132550.22156-1-philmd@redhat.com> References: <20200221132550.22156-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Jason Wang , Mark Cave-Ayland , Laurent Vivier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" No code use the espdma_memory_[read/write] functions outside of hw/dma/sparc32_dma.c, make them static. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell --- include/hw/sparc/sparc32_dma.h | 2 -- hw/dma/sparc32_dma.c | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/hw/sparc/sparc32_dma.h b/include/hw/sparc/sparc32_dma.h index ab42c5421b..b3811b617d 100644 --- a/include/hw/sparc/sparc32_dma.h +++ b/include/hw/sparc/sparc32_dma.h @@ -61,7 +61,5 @@ void ledma_memory_read(void *opaque, hwaddr addr, uint8_t *buf, int len, int do_bswap); void ledma_memory_write(void *opaque, hwaddr addr, uint8_t *buf, int len, int do_bswap); -void espdma_memory_read(void *opaque, uint8_t *buf, int len); -void espdma_memory_write(void *opaque, uint8_t *buf, int len); #endif diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c index 3e4da0c47f..c9e313938c 100644 --- a/hw/dma/sparc32_dma.c +++ b/hw/dma/sparc32_dma.c @@ -142,7 +142,7 @@ static void dma_set_irq(void *opaque, int irq, int level) } } -void espdma_memory_read(void *opaque, uint8_t *buf, int len) +static void espdma_memory_read(void *opaque, uint8_t *buf, int len) { DMADeviceState *s = opaque; IOMMUState *is = (IOMMUState *)s->iommu; @@ -152,7 +152,7 @@ void espdma_memory_read(void *opaque, uint8_t *buf, int len) s->dmaregs[1] += len; } -void espdma_memory_write(void *opaque, uint8_t *buf, int len) +static void espdma_memory_write(void *opaque, uint8_t *buf, int len) { DMADeviceState *s = opaque; IOMMUState *is = (IOMMUState *)s->iommu; From patchwork Fri Feb 21 13:25:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1242150 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NsS9t5eS; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48PCNY27Mrz9sRG for ; Sat, 22 Feb 2020 00:43:57 +1100 (AEDT) Received: from localhost ([::1]:58074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j58ax-0005dM-5h for incoming@patchwork.ozlabs.org; Fri, 21 Feb 2020 08:43:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33030) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j58Jm-00032H-BM for qemu-devel@nongnu.org; Fri, 21 Feb 2020 08:26:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j58Jj-0007Ra-6d for qemu-devel@nongnu.org; Fri, 21 Feb 2020 08:26:08 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:36135 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j58Jj-0007Og-2Q for qemu-devel@nongnu.org; Fri, 21 Feb 2020 08:26:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582291560; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=knm7izTn3QMDeqGkdlsTr7WEWsDthOUVCNGPYSj8q90=; b=NsS9t5eStfytKrs/RU3KxSl9FKLEAtVvNpG4QHATDbDQ3EVM/wO2wqKPApyta+4oeO06Or nFfbOFlzyWMu4etxSfxu+7yskexLYrPqD3yP0r3c5hyRzuzDKdbXvIy1bfS7HF7AT6xjs0 vJWU476KRhLXNS+dcz+m/M5KuO8yXNs= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-153-YqpKcDUDPIW-g4P1ZVooCQ-1; Fri, 21 Feb 2020 08:25:56 -0500 X-MC-Unique: YqpKcDUDPIW-g4P1ZVooCQ-1 Received: by mail-wm1-f70.google.com with SMTP id p26so607904wmg.5 for ; Fri, 21 Feb 2020 05:25:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i4tc3X06KlldR4fgJ2DnHVlEIqgio/XYk4CRiPLhiQE=; b=gR5CdJGedQ4sPtC6OWhRBNDYAoL/qMtNUtjZzmzDJsshX258PoINMqg1axsSB9RpY7 QHBuJVGTizkmLEAWY41NwVdeZ3UlI777JmoVqBcn2Z5K+KbkO3BWSh4gHq2f263fNMzr gwHLvTfxK+Se9lUakLtfB1MLSoHPhuI4pBW9QF1udbAa5kw3fb/t2J3ui48jt/xj05q7 2Gjy7FD8XNBqGu0fePwY3m5fntrpOBa8LUTv3blOLxGXhmNeZnYR8J1DOYUEg+95eec0 rvUkCJPNwjAdBkHhbMF68gDYa7O8T28pXWl/eCWvJPS7tCjBoZuxcY+Vr30RzmtuK6Qa d1Hg== X-Gm-Message-State: APjAAAWSwUeVnR0t91x5EYqkPp2q45fCO7NLKm1/j8b520PM4j84Y6es pMSa+rmFN2EBzYbE9A9zmYY6RMJLLJerq0T5QIsX8qho+d8DZjtaT8gQfjN+RgnmQfkyW84DX+v heg3jIS0Vsj+ygV8= X-Received: by 2002:a5d:62c8:: with SMTP id o8mr47793227wrv.316.1582291555172; Fri, 21 Feb 2020 05:25:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwBkWPDof7tB9gbioJ+go7V27Hj14HlPsHFiHSeDJLh2zDSwQS68e2jbTp1o8eVzNT4n3wk7w== X-Received: by 2002:a5d:62c8:: with SMTP id o8mr47793197wrv.316.1582291554961; Fri, 21 Feb 2020 05:25:54 -0800 (PST) Received: from x1w.redhat.com (78.red-88-21-202.staticip.rima-tde.net. [88.21.202.78]) by smtp.gmail.com with ESMTPSA id t13sm3947679wrw.19.2020.02.21.05.25.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2020 05:25:54 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 2/3] hw/scsi/esp: Let ESPDMAMemoryReadWriteFunc take void pointer and size_t Date: Fri, 21 Feb 2020 14:25:49 +0100 Message-Id: <20200221132550.22156-3-philmd@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200221132550.22156-1-philmd@redhat.com> References: <20200221132550.22156-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Jason Wang , Mark Cave-Ayland , Laurent Vivier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The ESPDMAMemoryReadWriteFunc handlers end calling dma_memory_read/write, which both take void pointers (since introduced in commit d86a77f8). The ESPDMAMemoryReadWriteFunc handlers can take a void pointer too. All calls to these handlers in hw/scsi/esp.c use an unsigned length. Use size_t type. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/scsi/esp.h | 2 +- hw/dma/sparc32_dma.c | 4 ++-- hw/scsi/esp-pci.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index 6ba47dac41..fff0ebc4d4 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -6,7 +6,7 @@ /* esp.c */ #define ESP_MAX_DEVS 7 -typedef void (*ESPDMAMemoryReadWriteFunc)(void *opaque, uint8_t *buf, int len); +typedef void (*ESPDMAMemoryReadWriteFunc)(void *opaque, void *buf, size_t len); #define ESP_REGS 16 #define TI_BUFSZ 16 diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c index c9e313938c..fbe58b8fea 100644 --- a/hw/dma/sparc32_dma.c +++ b/hw/dma/sparc32_dma.c @@ -142,7 +142,7 @@ static void dma_set_irq(void *opaque, int irq, int level) } } -static void espdma_memory_read(void *opaque, uint8_t *buf, int len) +static void espdma_memory_read(void *opaque, void *buf, size_t len) { DMADeviceState *s = opaque; IOMMUState *is = (IOMMUState *)s->iommu; @@ -152,7 +152,7 @@ static void espdma_memory_read(void *opaque, uint8_t *buf, int len) s->dmaregs[1] += len; } -static void espdma_memory_write(void *opaque, uint8_t *buf, int len) +static void espdma_memory_write(void *opaque, void *buf, size_t len) { DMADeviceState *s = opaque; IOMMUState *is = (IOMMUState *)s->iommu; diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c index d5a1f9e017..8f11c4a2d2 100644 --- a/hw/scsi/esp-pci.c +++ b/hw/scsi/esp-pci.c @@ -242,7 +242,7 @@ static uint64_t esp_pci_io_read(void *opaque, hwaddr addr, return ret; } -static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len, +static void esp_pci_dma_memory_rw(PCIESPState *pci, void *buf, size_t len, DMADirection dir) { dma_addr_t addr; @@ -278,13 +278,13 @@ static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len, } } -static void esp_pci_dma_memory_read(void *opaque, uint8_t *buf, int len) +static void esp_pci_dma_memory_read(void *opaque, void *buf, size_t len) { PCIESPState *pci = opaque; esp_pci_dma_memory_rw(pci, buf, len, DMA_DIRECTION_TO_DEVICE); } -static void esp_pci_dma_memory_write(void *opaque, uint8_t *buf, int len) +static void esp_pci_dma_memory_write(void *opaque, void *buf, size_t len) { PCIESPState *pci = opaque; esp_pci_dma_memory_rw(pci, buf, len, DMA_DIRECTION_FROM_DEVICE); From patchwork Fri Feb 21 13:25:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1242140 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CDGCXH60; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48PCFg6smcz9sP7 for ; Sat, 22 Feb 2020 00:37:59 +1100 (AEDT) Received: from localhost ([::1]:57924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j58VB-0003Jt-TH for incoming@patchwork.ozlabs.org; Fri, 21 Feb 2020 08:37:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33035) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j58Jk-00032r-Lk for qemu-devel@nongnu.org; Fri, 21 Feb 2020 08:26:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j58Jj-0007RA-5J for qemu-devel@nongnu.org; Fri, 21 Feb 2020 08:26:08 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:24507 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j58Jj-0007Oi-0R for qemu-devel@nongnu.org; Fri, 21 Feb 2020 08:26:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582291560; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cMOXko/4H0FB0S7u3dYzICgeqoNZW5DiwbZ8PiLJoXI=; b=CDGCXH604QY7wRTvtKgJiPnNmS6hgCSdAEmsS5J4EEiPmn2c4VmiYHoPsGcdohT9OOobR0 XnyCi8jIBgggeKFSg1m18Xa86FYcTDv6Xpp0LbtmMvVeQhCRMcPza9i33SOcQNOpgtY4bf HnqNZ3xJpNoV2bUOWvUmULHD49I9ALA= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-301-N3A-jZskOpi5RdEk2JQk_A-1; Fri, 21 Feb 2020 08:25:58 -0500 X-MC-Unique: N3A-jZskOpi5RdEk2JQk_A-1 Received: by mail-wm1-f70.google.com with SMTP id q125so571169wme.1 for ; Fri, 21 Feb 2020 05:25:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hcg1mTPNvTqu5kw0kpHNtRAtcOajm8vfSJTKD9bWkbM=; b=P08dPs+cqYM0TQd2gLLTluIZx5W+983qBCx1bQUP9LUkPTHIWuz+o9Cygc2LmIhphW L8T0PVza/usMLArJz0V/4kDETyI0/r0SYcrv7ONMw24MZ7FuZDYzQUam+eRRJ5FnW4Te v03H1wepEAlgNzmcFAxczjGg6O0Lv6cflSwatrwwSmPKBMgACOjJ8rJexJ6f/Lo4KO7c LFA1S/3Nufb4pF0ZA1LbFztAJ2DbrFZSS4E7uMa13dbKouoJNiEQAeNP4a12anzvWYVp e9V03yexY9pntsX3JOqEbfkmnvD3eywX6ke4IpRbeewx3k/NUyrp4l8UdPAOaN0qdTdY b7yQ== X-Gm-Message-State: APjAAAXDCEh0qOrss6f4ZfifsGZuuwaI3+LEfexu9CC9FXNy98Fz4KoW LLpKk6mXTDRevKeVBqwoe5rX6uA2hSlmkCNkFPBBzYOllZ8XJEQ9YxsaqWf+hEZhN6bI8Y+b7nI IDXSVJV8aGcDWRuc= X-Received: by 2002:adf:f80c:: with SMTP id s12mr49130629wrp.1.1582291557231; Fri, 21 Feb 2020 05:25:57 -0800 (PST) X-Google-Smtp-Source: APXvYqyZ8zRwQjRSOapQpvHA7eWW8PLfsp1CYzT1rJ38J4VZUnRLds4ZKYRE30wnQupHSJYRW3+npQ== X-Received: by 2002:adf:f80c:: with SMTP id s12mr49130596wrp.1.1582291556925; Fri, 21 Feb 2020 05:25:56 -0800 (PST) Received: from x1w.redhat.com (78.red-88-21-202.staticip.rima-tde.net. [88.21.202.78]) by smtp.gmail.com with ESMTPSA id t13sm3947679wrw.19.2020.02.21.05.25.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2020 05:25:55 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 3/3] hw/net/pcnet: Let phys_mem_read/write take void pointer and boolean Date: Fri, 21 Feb 2020 14:25:50 +0100 Message-Id: <20200221132550.22156-4-philmd@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200221132550.22156-1-philmd@redhat.com> References: <20200221132550.22156-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Jason Wang , Mark Cave-Ayland , Laurent Vivier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Both PCNetState::phys_mem_read/write handlers end calling dma_memory_read/write, which both take void pointers (since introduced in commit d86a77f8). The PCNetState phys_mem_read/write handlers can take a void pointer too. As the length is always a sizeof(), use a size_t type. The 'do_bswap' is used as a boolean argument. Use an explicit boolean type. The changes in hw/net/pcnet.c are produced using the following Coccinelle script: @@ expression E1, E2, E3, E4; @@ ( - s->phys_mem_read(E1, E2, (void *)(E3), E4, 0); + s->phys_mem_read(E1, E2, E3, E4, false); | - s->phys_mem_write(E1, E2, (void *)(E3), E4, 0); + s->phys_mem_write(E1, E2, E3, E4, false); | - s->phys_mem_read(E1, E2, (void *)(E3), E4, 1); + s->phys_mem_read(E1, E2, E3, E4, true); | - s->phys_mem_write(E1, E2, (void *)(E3), E4, 1); + s->phys_mem_write(E1, E2, E3, E4, true); ) Signed-off-by: Philippe Mathieu-Daudé --- hw/net/pcnet.h | 4 ++-- include/hw/sparc/sparc32_dma.h | 4 ++-- hw/dma/sparc32_dma.c | 4 ++-- hw/net/pcnet-pci.c | 5 +++-- hw/net/pcnet.c | 16 ++++++++-------- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/hw/net/pcnet.h b/hw/net/pcnet.h index f49b213c57..3f15e6f065 100644 --- a/hw/net/pcnet.h +++ b/hw/net/pcnet.h @@ -47,9 +47,9 @@ struct PCNetState_st { uint8_t buffer[4096]; qemu_irq irq; void (*phys_mem_read)(void *dma_opaque, hwaddr addr, - uint8_t *buf, int len, int do_bswap); + void *buf, size_t len, bool do_bswap); void (*phys_mem_write)(void *dma_opaque, hwaddr addr, - uint8_t *buf, int len, int do_bswap); + const void *buf, size_t len, bool do_bswap); DeviceState *dma_opaque; int tx_busy; int looptest; diff --git a/include/hw/sparc/sparc32_dma.h b/include/hw/sparc/sparc32_dma.h index b3811b617d..db42f7440d 100644 --- a/include/hw/sparc/sparc32_dma.h +++ b/include/hw/sparc/sparc32_dma.h @@ -58,8 +58,8 @@ typedef struct SPARC32DMAState { /* sparc32_dma.c */ void ledma_memory_read(void *opaque, hwaddr addr, - uint8_t *buf, int len, int do_bswap); + void *buf, size_t len, bool do_bswap); void ledma_memory_write(void *opaque, hwaddr addr, - uint8_t *buf, int len, int do_bswap); + const void *buf, size_t len, bool do_bswap); #endif diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c index fbe58b8fea..629f9830f7 100644 --- a/hw/dma/sparc32_dma.c +++ b/hw/dma/sparc32_dma.c @@ -72,7 +72,7 @@ enum { /* Note: on sparc, the lance 16 bit bus is swapped */ void ledma_memory_read(void *opaque, hwaddr addr, - uint8_t *buf, int len, int do_bswap) + void *buf, size_t len, bool do_bswap) { DMADeviceState *s = opaque; IOMMUState *is = (IOMMUState *)s->iommu; @@ -93,7 +93,7 @@ void ledma_memory_read(void *opaque, hwaddr addr, } void ledma_memory_write(void *opaque, hwaddr addr, - uint8_t *buf, int len, int do_bswap) + const void *buf, size_t len, bool do_bswap) { DMADeviceState *s = opaque; IOMMUState *is = (IOMMUState *)s->iommu; diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c index d1f31e0272..4e4d60b046 100644 --- a/hw/net/pcnet-pci.c +++ b/hw/net/pcnet-pci.c @@ -167,13 +167,14 @@ static const MemoryRegionOps pcnet_mmio_ops = { }; static void pci_physical_memory_write(void *dma_opaque, hwaddr addr, - uint8_t *buf, int len, int do_bswap) + const void *buf, size_t len, + bool do_bswap) { pci_dma_write(dma_opaque, addr, buf, len); } static void pci_physical_memory_read(void *dma_opaque, hwaddr addr, - uint8_t *buf, int len, int do_bswap) + void *buf, size_t len, bool do_bswap) { pci_dma_read(dma_opaque, addr, buf, len); } diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c index f3f18d8598..d669ca2aa3 100644 --- a/hw/net/pcnet.c +++ b/hw/net/pcnet.c @@ -305,14 +305,14 @@ static inline void pcnet_tmd_load(PCNetState *s, struct pcnet_TMD *tmd, int16_t length; int16_t status; } xda; - s->phys_mem_read(s->dma_opaque, addr, (void *)&xda, sizeof(xda), 0); + s->phys_mem_read(s->dma_opaque, addr, &xda, sizeof(xda), false); tmd->tbadr = le32_to_cpu(xda.tbadr) & 0xffffff; tmd->length = le16_to_cpu(xda.length); tmd->status = (le32_to_cpu(xda.tbadr) >> 16) & 0xff00; tmd->misc = le16_to_cpu(xda.status) << 16; tmd->res = 0; } else { - s->phys_mem_read(s->dma_opaque, addr, (void *)tmd, sizeof(*tmd), 0); + s->phys_mem_read(s->dma_opaque, addr, tmd, sizeof(*tmd), false); le32_to_cpus(&tmd->tbadr); le16_to_cpus((uint16_t *)&tmd->length); le16_to_cpus((uint16_t *)&tmd->status); @@ -339,7 +339,7 @@ static inline void pcnet_tmd_store(PCNetState *s, const struct pcnet_TMD *tmd, ((tmd->status & 0xff00) << 16)); xda.length = cpu_to_le16(tmd->length); xda.status = cpu_to_le16(tmd->misc >> 16); - s->phys_mem_write(s->dma_opaque, addr, (void *)&xda, sizeof(xda), 0); + s->phys_mem_write(s->dma_opaque, addr, &xda, sizeof(xda), false); } else { struct { uint32_t tbadr; @@ -358,7 +358,7 @@ static inline void pcnet_tmd_store(PCNetState *s, const struct pcnet_TMD *tmd, xda.tbadr = xda.misc; xda.misc = tmp; } - s->phys_mem_write(s->dma_opaque, addr, (void *)&xda, sizeof(xda), 0); + s->phys_mem_write(s->dma_opaque, addr, &xda, sizeof(xda), false); } } @@ -371,14 +371,14 @@ static inline void pcnet_rmd_load(PCNetState *s, struct pcnet_RMD *rmd, int16_t buf_length; int16_t msg_length; } rda; - s->phys_mem_read(s->dma_opaque, addr, (void *)&rda, sizeof(rda), 0); + s->phys_mem_read(s->dma_opaque, addr, &rda, sizeof(rda), false); rmd->rbadr = le32_to_cpu(rda.rbadr) & 0xffffff; rmd->buf_length = le16_to_cpu(rda.buf_length); rmd->status = (le32_to_cpu(rda.rbadr) >> 16) & 0xff00; rmd->msg_length = le16_to_cpu(rda.msg_length); rmd->res = 0; } else { - s->phys_mem_read(s->dma_opaque, addr, (void *)rmd, sizeof(*rmd), 0); + s->phys_mem_read(s->dma_opaque, addr, rmd, sizeof(*rmd), false); le32_to_cpus(&rmd->rbadr); le16_to_cpus((uint16_t *)&rmd->buf_length); le16_to_cpus((uint16_t *)&rmd->status); @@ -405,7 +405,7 @@ static inline void pcnet_rmd_store(PCNetState *s, struct pcnet_RMD *rmd, ((rmd->status & 0xff00) << 16)); rda.buf_length = cpu_to_le16(rmd->buf_length); rda.msg_length = cpu_to_le16(rmd->msg_length); - s->phys_mem_write(s->dma_opaque, addr, (void *)&rda, sizeof(rda), 0); + s->phys_mem_write(s->dma_opaque, addr, &rda, sizeof(rda), false); } else { struct { uint32_t rbadr; @@ -424,7 +424,7 @@ static inline void pcnet_rmd_store(PCNetState *s, struct pcnet_RMD *rmd, rda.rbadr = rda.msg_length; rda.msg_length = tmp; } - s->phys_mem_write(s->dma_opaque, addr, (void *)&rda, sizeof(rda), 0); + s->phys_mem_write(s->dma_opaque, addr, &rda, sizeof(rda), false); } }