From patchwork Fri Jun 17 10:36:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9183399 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 3DA3F60573 for ; Fri, 17 Jun 2016 10:37:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A73127EE2 for ; Fri, 17 Jun 2016 10:37:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E70428399; Fri, 17 Jun 2016 10:37:44 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8B2B527EE2 for ; Fri, 17 Jun 2016 10:37:43 +0000 (UTC) Received: from localhost ([::1]:55555 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDr9i-00040N-Lq for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 Jun 2016 06:37:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDr99-0003tO-Bo for qemu-devel@nongnu.org; Fri, 17 Jun 2016 06:37:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDr94-0004V5-AD for qemu-devel@nongnu.org; Fri, 17 Jun 2016 06:37:06 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:34975) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDr93-0004Ut-SL for qemu-devel@nongnu.org; Fri, 17 Jun 2016 06:37:02 -0400 Received: by mail-wm0-x243.google.com with SMTP id k184so17631433wme.2 for ; Fri, 17 Jun 2016 03:37:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=WkgGeWx3Q/YwHHyPiSZ1oAMtXBEnezu52Pc51nVDC5Y=; b=thHQfI4AuUGbywNBT50tarn+5s85Il94NAjOOWTu6UZ5gjaBYkByuUHigJpZqRQjN7 dseNLnwiPqiOFJEO3Imq5qHJmdgbTiieLhHSOfBIgknzDYWuLqKgwncKLLwRmzzjERCy bR3XV+w/i92qObsa1F8clEbgyPQCszzMmKSotAGaDYIWEWe1s/x+HTrYQKgbqHYj0y19 yTyiNTs1bijf9l4oCzD8IgbaoArSVAvox89TECYdaxl3frH1Gg0MYRHKqMeOHpj6AKEU HcKqAG3sPq6SGQZu05BjGUnnMu9DldDDH4LSapxMyPckpQk/ovNspPDl2m9YH6IseCQb Hj/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=WkgGeWx3Q/YwHHyPiSZ1oAMtXBEnezu52Pc51nVDC5Y=; b=bhXgJ/7rUu80ngUxQC/WLRnQCx0Ynkc4po3XYc8Ur2Xopp18uBrTc3j01byn85fQsT 7yJm/9ilz7f/5x142pWTVHX8BTELvg+tjhvXP7H9zW7R1vpuowDws4KkY0Dqr3oyNiUJ oDVTIe0f262zF806uLZx44irWgeWv+BaJkoHOEsFpQs43X33d11RDW7BWvjBC1QybWFi gqf0Qw9TjfU5sQ3qoHQ/hDlILw3ER1LVWdrZZabE5WIQv1J05RuJiLxeorg41foSRiu2 UAH9ka0oWqMGSogHhXrPVSpoNaqVx+f1nwh65RgM9nJL6iEiXeMAS970R4Ht3wMpLlgI qqew== X-Gm-Message-State: ALyK8tJwOzx8jW9r7fjlRe4HeigxkwipDWMfpqxzF23VnMSGN0jFzSQREgvgVFmerDmT5g== X-Received: by 10.194.106.132 with SMTP id gu4mr1572449wjb.25.1466159821181; Fri, 17 Jun 2016 03:37:01 -0700 (PDT) Received: from donizetti.lan (94-39-188-118.adsl-ull.clienti.tiscali.it. [94.39.188.118]) by smtp.gmail.com with ESMTPSA id z5sm2476364wme.5.2016.06.17.03.36.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jun 2016 03:36:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 17 Jun 2016 12:36:56 +0200 Message-Id: <1466159816-28509-1-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 2.5.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PATCH] m25p80: qdev-ify drive property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, clg@kaod.org, armbru@redhat.com, crosthwaite.peter@gmail.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This allows specifying the property via -drive if=none and creating the flash device with -device. Signed-off-by: Paolo Bonzini --- Cedric, can you put it at the beginning of your ast2400 series and adjust aspeed_smc_init_flashes along these lines? It does not affect command line usage. hw/arm/xilinx_zynq.c | 8 +++++++- hw/arm/xlnx-ep108.c | 9 ++++++++- hw/block/m25p80.c | 10 ++-------- hw/microblaze/petalogix_ml605_mmu.c | 9 ++++++++- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c index aefebcf..b0cabe2 100644 --- a/hw/arm/xilinx_zynq.c +++ b/hw/arm/xilinx_zynq.c @@ -138,7 +138,13 @@ static inline void zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq, spi = (SSIBus *)qdev_get_child_bus(dev, bus_name); for (j = 0; j < num_ss; ++j) { - flash_dev = ssi_create_slave(spi, "n25q128"); + DriveInfo *dinfo = drive_get_next(IF_MTD); + flash_dev = ssi_create_slave_no_init(spi, "n25q128"); + if (dinfo) { + qdev_prop_set_drive(flash_dev, "drive", + blk_by_legacy_dinfo(dinfo), &error_fatal); + } + qdev_init_nofail(flash_dev); cs_line = qdev_get_gpio_in_named(flash_dev, SSI_GPIO_CS, 0); sysbus_connect_irq(busdev, i * num_ss + j + 1, cs_line); diff --git a/hw/arm/xlnx-ep108.c b/hw/arm/xlnx-ep108.c index 34b4641..4ec590a 100644 --- a/hw/arm/xlnx-ep108.c +++ b/hw/arm/xlnx-ep108.c @@ -88,12 +88,19 @@ static void xlnx_ep108_init(MachineState *machine) SSIBus *spi_bus; DeviceState *flash_dev; qemu_irq cs_line; + DriveInfo *dinfo = drive_get_next(IF_MTD); gchar *bus_name = g_strdup_printf("spi%d", i); spi_bus = (SSIBus *)qdev_get_child_bus(DEVICE(&s->soc), bus_name); g_free(bus_name); - flash_dev = ssi_create_slave(spi_bus, "sst25wf080"); + flash_dev = ssi_create_slave_no_init(spi_bus, "sst25wf080"); + if (dinfo) { + qdev_prop_set_drive(flash_dev, "drive", blk_by_legacy_dinfo(dinfo), + &error_fatal); + } + qdev_init_nofail(flash_dev); + cs_line = qdev_get_gpio_in_named(flash_dev, SSI_GPIO_CS, 0); sysbus_connect_irq(SYS_BUS_DEVICE(&s->soc.spi[i]), 1, cs_line); diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 51d8596..1a44b4c 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -880,7 +880,6 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx) static int m25p80_init(SSISlave *ss) { - DriveInfo *dinfo; Flash *s = M25P80(ss); M25P80Class *mc = M25P80_GET_CLASS(s); @@ -889,14 +888,8 @@ static int m25p80_init(SSISlave *ss) s->size = s->pi->sector_size * s->pi->n_sectors; s->dirty_page = -1; - /* FIXME use a qdev drive property instead of drive_get_next() */ - dinfo = drive_get_next(IF_MTD); - - if (dinfo) { + if (s->blk) { DB_PRINT_L(0, "Binding to IF_MTD drive\n"); - s->blk = blk_by_legacy_dinfo(dinfo); - blk_attach_dev_nofail(s->blk, s); - s->storage = blk_blockalign(s->blk, s->size); /* FIXME: Move to late init */ @@ -927,6 +920,7 @@ static void m25p80_pre_save(void *opaque) static Property m25p80_properties[] = { DEFINE_PROP_UINT32("nonvolatile-cfg", Flash, nonvolatile_cfg, 0x8FFF), + DEFINE_PROP_DRIVE("drive", Flash, blk), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c index 07527b6..4968bdb 100644 --- a/hw/microblaze/petalogix_ml605_mmu.c +++ b/hw/microblaze/petalogix_ml605_mmu.c @@ -191,9 +191,16 @@ petalogix_ml605_init(MachineState *machine) spi = (SSIBus *)qdev_get_child_bus(dev, "spi"); for (i = 0; i < NUM_SPI_FLASHES; i++) { + DriveInfo *dinfo = drive_get_next(IF_MTD); qemu_irq cs_line; - dev = ssi_create_slave(spi, "n25q128"); + dev = ssi_create_slave_no_init(spi, "n25q128"); + if (dinfo) { + qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(dinfo), + &error_fatal); + } + qdev_init_nofail(dev); + cs_line = qdev_get_gpio_in_named(dev, SSI_GPIO_CS, 0); sysbus_connect_irq(busdev, i+1, cs_line); }