From nobody Tue Nov 26 10:46:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1708936212; cv=none; d=zohomail.com; s=zohoarc; b=NBswWRSQ20fzJ85gAAYaK5di4THN7xffRVn1wIkxqrBPq3qvtO7ItZxHj2fnBVCwOTWRfOFyLDU2l1K3E6KzTjtzMHncGPDsGA5h6m7PunXcFqX5VhR8bIBi6utfJyQje4+FGGPV4GUcK52BCGz2J3jAfcZbKmlzthLrasQ7h0M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708936212; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=M1eDmbIANOn5GUFnwUNctW2wFwCkHAYHYCToWMrxESA=; b=bdZPnPrqC3nbx2mBUa+jdX/w79YplXLViRSt2zNp7G+yrwYRKGZ5NqoICNtxxh9F6psbEntLHVaHp7Y/457gecF26auLFh2NlCJ7d88tFM39exdUj3Hh3fHrms+u5AYuVsuwCrwV3Kk2QaCzjg7RkCH3lIWTQdbJbT27GSE5S10= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708936212765465.7380219718809; Mon, 26 Feb 2024 00:30:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1reWNA-00020T-6p; Mon, 26 Feb 2024 03:30:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1reWN2-0001zE-0x for qemu-devel@nongnu.org; Mon, 26 Feb 2024 03:29:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1reWN0-0005Pm-4t for qemu-devel@nongnu.org; Mon, 26 Feb 2024 03:29:55 -0500 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-403-LV2HJsL6PyKYlaCdauIpUA-1; Mon, 26 Feb 2024 03:29:48 -0500 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a431a294ebeso32232466b.0 for ; Mon, 26 Feb 2024 00:29:48 -0800 (PST) Received: from [192.168.10.118] ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id kx5-20020a170907774500b00a3d81b90ffcsm2162974ejc.218.2024.02.26.00.29.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 00:29:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708936193; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M1eDmbIANOn5GUFnwUNctW2wFwCkHAYHYCToWMrxESA=; b=CDvxwg7uiVtqq9Cw6yAFwnLBJfp0INFrYpO9dwl1Nz+LpD4mmjJHxH7HFcBuG4hCEoqQeT AGMElfQvGasS1zn6NkwCkpVw5MCIkm1bzNogEZuZ8Mtc4pQ+ee3PEkEfejHD6z6V4VuuCR am/srYuMxRl+gL50U/mTQNWOdoazkJQ= X-MC-Unique: LV2HJsL6PyKYlaCdauIpUA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708936187; x=1709540987; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M1eDmbIANOn5GUFnwUNctW2wFwCkHAYHYCToWMrxESA=; b=e+dPiZt2U1WvXr7KMp0SFhKX/k+z/0X46sICDDS3PPoIVSdEqI8HEAhL0aLZjBWdVz eSc5R7L/GQLlstlZeOoAPKBMMCsjgAwtLQA4vDj6L+U84V7Ib1GG/wMMktRWnIuyLsvx cyqsJs7PudZFkx/wHt82MYKnTalFPOdNnlTxuXzKo2KihOlMq46duwuR+H74NiZTX/p1 Pkf7wqet1UHW/XfbY9bPE29xFxBP2nFI3PC8PBU/7APKwJDNuyEdoStUW+Ivp3jtCQ6+ Y09eN3eSHz0+9isqoS8ax5jWh/vIA8+s9dBCnOmNeOB6Mhl3GQQx+CQu574HrGSagYi+ ggGg== X-Gm-Message-State: AOJu0YzcGkKv5yKHVe/l389c8fIxfde4RwQ9Vq69qXKEhdd62KVJuJqX sWiBqr4dujDJrN3GN7HJ8cOP9ezMW1mXyFIW4rnyNz6leBEQs1yFkUTgaPwND5WxjJ5iSeSgZiE w9WWoiXerNOGWiPoH6lj2N2Ja7HpgzbkuyvKyrwoMricCvhFH5fH1+eCFy9v1MQ3w2mXIYjuunr rJRBD/rqA5cwKoAY85Ca/qJd678gX4bdis/WhG X-Received: by 2002:a17:906:aed5:b0:a3f:ee60:4e15 with SMTP id me21-20020a170906aed500b00a3fee604e15mr4144270ejb.55.1708936187054; Mon, 26 Feb 2024 00:29:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdFpKpC7Ruhw9H/LpSIe8mncILi6Ijo6d8qGOe++uiDEGkhYUABuXwcZGXjGmbYEw3V7sl7A== X-Received: by 2002:a17:906:aed5:b0:a3f:ee60:4e15 with SMTP id me21-20020a170906aed500b00a3fee604e15mr4144254ejb.55.1708936186482; Mon, 26 Feb 2024 00:29:46 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 1/2] ide: collapse parameters to ide_init_drive Date: Mon, 26 Feb 2024 09:29:40 +0100 Message-ID: <20240226082941.90364-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240226082941.90364-1-pbonzini@redhat.com> References: <20240226082941.90364-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.097, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1708936214432100006 Content-Type: text/plain; charset="utf-8" All calls to ide_init_drive comes from ide_dev_initfn. Just pass down the IDEDevice (IDEState is kinda obsolete and should be merged into IDEDevice). Signed-off-by: Paolo Bonzini --- include/hw/ide/internal.h | 6 +----- hw/ide/core.c | 40 ++++++++++++++++++--------------------- hw/ide/qdev.c | 5 +---- 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h index 3bdcc75597d..0ad0d59d578 100644 --- a/include/hw/ide/internal.h +++ b/include/hw/ide/internal.h @@ -614,11 +614,7 @@ uint32_t ide_data_readw(void *opaque, uint32_t addr); void ide_data_writel(void *opaque, uint32_t addr, uint32_t val); uint32_t ide_data_readl(void *opaque, uint32_t addr); =20 -int ide_init_drive(IDEState *s, BlockBackend *blk, IDEDriveKind kind, - const char *version, const char *serial, const char *mo= del, - uint64_t wwn, - uint32_t cylinders, uint32_t heads, uint32_t secs, - int chs_trans, Error **errp); +int ide_init_drive(IDEState *s, IDEDevice *dev, IDEDriveKind kind, Error *= *errp); void ide_exit(IDEState *s); void ide_bus_init_output_irq(IDEBus *bus, qemu_irq irq_out); int ide_init_ioport(IDEBus *bus, ISADevice *isa, int iobase, int iobase2); diff --git a/hw/ide/core.c b/hw/ide/core.c index 9c4a8129028..3c42d72ac25 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2589,24 +2589,20 @@ static const BlockDevOps ide_hd_block_ops =3D { .resize_cb =3D ide_resize_cb, }; =20 -int ide_init_drive(IDEState *s, BlockBackend *blk, IDEDriveKind kind, - const char *version, const char *serial, const char *mo= del, - uint64_t wwn, - uint32_t cylinders, uint32_t heads, uint32_t secs, - int chs_trans, Error **errp) +int ide_init_drive(IDEState *s, IDEDevice *dev, IDEDriveKind kind, Error *= *errp) { uint64_t nb_sectors; =20 - s->blk =3D blk; + s->blk =3D dev->conf.blk; s->drive_kind =3D kind; =20 - blk_get_geometry(blk, &nb_sectors); - s->cylinders =3D cylinders; - s->heads =3D s->drive_heads =3D heads; - s->sectors =3D s->drive_sectors =3D secs; - s->chs_trans =3D chs_trans; + blk_get_geometry(s->blk, &nb_sectors); + s->cylinders =3D dev->conf.cyls; + s->heads =3D s->drive_heads =3D dev->conf.heads; + s->sectors =3D s->drive_sectors =3D dev->conf.secs; + s->chs_trans =3D dev->chs_trans; s->nb_sectors =3D nb_sectors; - s->wwn =3D wwn; + s->wwn =3D dev->wwn; /* The SMART values should be preserved across power cycles but they aren't. */ s->smart_enabled =3D 1; @@ -2614,26 +2610,26 @@ int ide_init_drive(IDEState *s, BlockBackend *blk, = IDEDriveKind kind, s->smart_errors =3D 0; s->smart_selftest_count =3D 0; if (kind =3D=3D IDE_CD) { - blk_set_dev_ops(blk, &ide_cd_block_ops, s); + blk_set_dev_ops(s->blk, &ide_cd_block_ops, s); } else { if (!blk_is_inserted(s->blk)) { error_setg(errp, "Device needs media, but drive is empty"); return -1; } - if (!blk_is_writable(blk)) { + if (!blk_is_writable(s->blk)) { error_setg(errp, "Can't use a read-only drive"); return -1; } - blk_set_dev_ops(blk, &ide_hd_block_ops, s); + blk_set_dev_ops(s->blk, &ide_hd_block_ops, s); } - if (serial) { - pstrcpy(s->drive_serial_str, sizeof(s->drive_serial_str), serial); + if (dev->serial) { + pstrcpy(s->drive_serial_str, sizeof(s->drive_serial_str), dev->ser= ial); } else { snprintf(s->drive_serial_str, sizeof(s->drive_serial_str), "QM%05d", s->drive_serial); } - if (model) { - pstrcpy(s->drive_model_str, sizeof(s->drive_model_str), model); + if (dev->model) { + pstrcpy(s->drive_model_str, sizeof(s->drive_model_str), dev->model= ); } else { switch (kind) { case IDE_CD: @@ -2648,14 +2644,14 @@ int ide_init_drive(IDEState *s, BlockBackend *blk, = IDEDriveKind kind, } } =20 - if (version) { - pstrcpy(s->version, sizeof(s->version), version); + if (dev->version) { + pstrcpy(s->version, sizeof(s->version), dev->version); } else { pstrcpy(s->version, sizeof(s->version), qemu_hw_version()); } =20 ide_reset(s); - blk_iostatus_enable(blk); + blk_iostatus_enable(s->blk); return 0; } =20 diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 1b3b4da01df..9244c5a0fdb 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -208,10 +208,7 @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKin= d kind, Error **errp) return; } =20 - if (ide_init_drive(s, dev->conf.blk, kind, - dev->version, dev->serial, dev->model, dev->wwn, - dev->conf.cyls, dev->conf.heads, dev->conf.secs, - dev->chs_trans, errp) < 0) { + if (ide_init_drive(s, dev, kind, errp) < 0) { return; } =20 --=20 2.43.2