All of lore.kernel.org
 help / color / mirror / Atom feed
From: BALATON Zoltan via <qemu-devel@nongnu.org>
To: qemu-devel@nongnu.org
Cc: Huacai Chen <chenhuacai@kernel.org>, f4bug@amsat.org
Subject: [PATCH 06/12] audio/via-ac97: Simplify code and set user_creatable to false
Date: Sun, 27 Dec 2020 02:10:06 +0100	[thread overview]
Message-ID: <717bd2ed67a42476fdb4c6132d7c351eb9f54282.1609031406.git.balaton@eik.bme.hu> (raw)
In-Reply-To: <cover.1609031406.git.balaton@eik.bme.hu>

Remove some unneded, empty code and set user_creatable to false
(besides being not implemented yet, so does nothing anyway) it's also
normally part of VIA south bridge chips so no need to confuse users
showing them these devices.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 hw/audio/via-ac97.c | 51 +++++++++++++++++----------------------------
 1 file changed, 19 insertions(+), 32 deletions(-)

diff --git a/hw/audio/via-ac97.c b/hw/audio/via-ac97.c
index e617416ff7..6d556f74fc 100644
--- a/hw/audio/via-ac97.c
+++ b/hw/audio/via-ac97.c
@@ -13,27 +13,13 @@
 #include "hw/isa/vt82c686.h"
 #include "hw/pci/pci.h"
 
-struct VIAAC97State {
-    PCIDevice dev;
-};
-
-struct VIAMC97State {
-    PCIDevice dev;
-};
-
-OBJECT_DECLARE_SIMPLE_TYPE(VIAAC97State, VIA_AC97)
-OBJECT_DECLARE_SIMPLE_TYPE(VIAMC97State, VIA_MC97)
-
-static void via_ac97_realize(PCIDevice *dev, Error **errp)
+static void via_ac97_realize(PCIDevice *pci_dev, Error **errp)
 {
-    VIAAC97State *s = VIA_AC97(dev);
-    uint8_t *pci_conf = s->dev.config;
-
-    pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
-                 PCI_COMMAND_PARITY);
-    pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_CAP_LIST |
-                 PCI_STATUS_DEVSEL_MEDIUM);
-    pci_set_long(pci_conf + PCI_INTERRUPT_PIN, 0x03);
+    pci_set_word(pci_dev->config + PCI_COMMAND,
+                 PCI_COMMAND_INVALIDATE | PCI_COMMAND_PARITY);
+    pci_set_word(pci_dev->config + PCI_STATUS,
+                 PCI_STATUS_CAP_LIST | PCI_STATUS_DEVSEL_MEDIUM);
+    pci_set_long(pci_dev->config + PCI_INTERRUPT_PIN, 0x03);
 }
 
 static void via_ac97_class_init(ObjectClass *klass, void *data)
@@ -47,13 +33,15 @@ static void via_ac97_class_init(ObjectClass *klass, void *data)
     k->revision = 0x50;
     k->class_id = PCI_CLASS_MULTIMEDIA_AUDIO;
     set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
-    dc->desc = "AC97";
+    dc->desc = "VIA AC97";
+    /* Reason: Part of a south bridge chip */
+    dc->user_creatable = false;
 }
 
 static const TypeInfo via_ac97_info = {
     .name          = TYPE_VIA_AC97,
     .parent        = TYPE_PCI_DEVICE,
-    .instance_size = sizeof(VIAAC97State),
+    .instance_size = sizeof(PCIDevice),
     .class_init    = via_ac97_class_init,
     .interfaces = (InterfaceInfo[]) {
         { INTERFACE_CONVENTIONAL_PCI_DEVICE },
@@ -61,15 +49,12 @@ static const TypeInfo via_ac97_info = {
     },
 };
 
-static void via_mc97_realize(PCIDevice *dev, Error **errp)
+static void via_mc97_realize(PCIDevice *pci_dev, Error **errp)
 {
-    VIAMC97State *s = VIA_MC97(dev);
-    uint8_t *pci_conf = s->dev.config;
-
-    pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
-                 PCI_COMMAND_VGA_PALETTE);
-    pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM);
-    pci_set_long(pci_conf + PCI_INTERRUPT_PIN, 0x03);
+    pci_set_word(pci_dev->config + PCI_COMMAND,
+                 PCI_COMMAND_INVALIDATE | PCI_COMMAND_VGA_PALETTE);
+    pci_set_word(pci_dev->config + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM);
+    pci_set_long(pci_dev->config + PCI_INTERRUPT_PIN, 0x03);
 }
 
 static void via_mc97_class_init(ObjectClass *klass, void *data)
@@ -83,13 +68,15 @@ static void via_mc97_class_init(ObjectClass *klass, void *data)
     k->class_id = PCI_CLASS_COMMUNICATION_OTHER;
     k->revision = 0x30;
     set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
-    dc->desc = "MC97";
+    dc->desc = "VIA MC97";
+    /* Reason: Part of a south bridge chip */
+    dc->user_creatable = false;
 }
 
 static const TypeInfo via_mc97_info = {
     .name          = TYPE_VIA_MC97,
     .parent        = TYPE_PCI_DEVICE,
-    .instance_size = sizeof(VIAMC97State),
+    .instance_size = sizeof(PCIDevice),
     .class_init    = via_mc97_class_init,
     .interfaces = (InterfaceInfo[]) {
         { INTERFACE_CONVENTIONAL_PCI_DEVICE },
-- 
2.21.3



  parent reply	other threads:[~2020-12-27  1:27 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-27  1:10 [PATCH 00/12] Misc vt82c686b clean ups BALATON Zoltan via
2020-12-27  1:10 ` [PATCH 12/12] vt82c686: Do not add floppy BALATON Zoltan via
2020-12-27  1:10 ` [PATCH 07/12] vt82c686: Remove vt82c686b_isa_init() function BALATON Zoltan via
2020-12-27 14:36   ` Philippe Mathieu-Daudé
2020-12-27 16:52     ` BALATON Zoltan via
2020-12-27  1:10 ` [PATCH 02/12] vt82c686: Rename AC97/MC97 parts from VT82C686B to VIA BALATON Zoltan via
2020-12-27 15:04   ` Philippe Mathieu-Daudé
2020-12-27  1:10 ` [PATCH 08/12] vt82c686: Remove vt82c686b_pm_init() function BALATON Zoltan via
2020-12-27 14:39   ` Philippe Mathieu-Daudé
2020-12-27  1:10 ` [PATCH 01/12] vt82c686: Add APM and ACPI dependencies for VT82C686 BALATON Zoltan via
2020-12-28  0:35   ` Huacai Chen
2020-12-28  1:41     ` BALATON Zoltan via
2020-12-28  2:03       ` chen huacai
2020-12-27  1:10 ` BALATON Zoltan via [this message]
2020-12-27 14:56   ` [PATCH 06/12] audio/via-ac97: Simplify code and set user_creatable to false Philippe Mathieu-Daudé
2020-12-27 16:47     ` BALATON Zoltan via
2020-12-27  1:10 ` [PATCH 04/12] vt82c686: Remove vt82c686b_[am]c97_init() functions BALATON Zoltan via
2021-01-01 21:07   ` Philippe Mathieu-Daudé
2020-12-27  1:10 ` [PATCH 03/12] vt82c686: Remove unnecessary _DEVICE suffix from type macros BALATON Zoltan via
2020-12-27 14:29   ` Philippe Mathieu-Daudé
2020-12-27 14:33   ` Philippe Mathieu-Daudé
2020-12-27 16:49     ` BALATON Zoltan via
2020-12-27  1:10 ` [PATCH 11/12] vt82c686: Rename some functions to better show where they belong BALATON Zoltan via
2020-12-27 14:25   ` Philippe Mathieu-Daudé
2020-12-27  1:10 ` [PATCH 10/12] vt82c686: Remove unneeded includes and defines BALATON Zoltan via
2020-12-27 14:51   ` Philippe Mathieu-Daudé
2020-12-27  1:10 ` [PATCH 05/12] vt82c686: Split off via-[am]c97 into separate file in hw/audio BALATON Zoltan via
2020-12-27 15:03   ` Philippe Mathieu-Daudé
2020-12-27  1:10 ` [PATCH 09/12] vt82c686: Convert debug printf to trace points BALATON Zoltan via
2020-12-27 15:08   ` Philippe Mathieu-Daudé
2020-12-27 16:42     ` BALATON Zoltan via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=717bd2ed67a42476fdb4c6132d7c351eb9f54282.1609031406.git.balaton@eik.bme.hu \
    --to=qemu-devel@nongnu.org \
    --cc=balaton@eik.bme.hu \
    --cc=chenhuacai@kernel.org \
    --cc=f4bug@amsat.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.