qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Liav Albani <liavalb@gmail.com>
To: Ani Sinha <ani@anisinha.ca>
Cc: imammedo@redhat.com, qemu-devel@nongnu.org, mst@redhat.com
Subject: Re: [PATCH v3 1/4] hw/isa: add function to check for existence of device by its type
Date: Sun, 27 Feb 2022 21:03:04 +0200	[thread overview]
Message-ID: <76ebfc46-444e-d145-7f6f-020e04dace9c@gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2202271254280.1249418@anisinha-lenovo>


On 2/27/22 09:27, Ani Sinha wrote:
>
> On Sat, 26 Feb 2022, Liav Albani wrote:
>
>> This function enumerates all attached ISA devices in the machine, and
>> tries to compare a given device type name to the enumerated devices.
>> For example, this can help other code to determine if a i8042 controller
>> exists in the machine.
>>
>> Signed-off-by: Liav Albani <liavalb@gmail.com>
>> ---
>>   hw/isa/isa-bus.c     | 23 +++++++++++++++++++++++
>>   include/hw/isa/isa.h |  1 +
>>   2 files changed, 24 insertions(+)
>>
>> diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c
>> index 6c31398dda..663aa36d29 100644
>> --- a/hw/isa/isa-bus.c
>> +++ b/hw/isa/isa-bus.c
>> @@ -222,6 +222,29 @@ void isa_build_aml(ISABus *bus, Aml *scope)
>>       }
>>   }
>>
>> +bool isa_check_device_existence(const char *typename)
>> +{
>> +    /*
>> +     * If there's no ISA bus, we know for sure that the checked ISA device type
>> +     * doesn't exist in the machine.
>> +     */
>> +    if (isabus == NULL) {
> nit: I would do if (!isabus) instead to keep uniformity with other parts
> of the code.
Hmm, OK, I'll change it because it seems really fine to do that this way 
too :)
>
>> +        return false;
>> +    }
>> +
>> +    BusChild *kid;
>> +    ISADevice *dev;
>> +
>> +    QTAILQ_FOREACH(kid, &isabus->parent_obj.children, sibling) {
>> +        dev = ISA_DEVICE(kid->child);
>> +        const char *object_type = object_get_typename(OBJECT(dev));
>> +        if (object_type && strcmp(object_type, typename) == 0) {
> nit: I would do !strcmp() instead.
>
Hmm, OK, I'll change it because it seems really fine to do that this way 
too :)
>> +            return true;
>> +        }
>> +    }
>> +    return false;
>> +}
>> +
>>   static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent)
>>   {
>>       ISADevice *d = ISA_DEVICE(dev);
>> diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
>> index d4417b34b6..65f0c7e28c 100644
>> --- a/include/hw/isa/isa.h
>> +++ b/include/hw/isa/isa.h
>> @@ -99,6 +99,7 @@ IsaDma *isa_get_dma(ISABus *bus, int nchan);
>>   MemoryRegion *isa_address_space(ISADevice *dev);
>>   MemoryRegion *isa_address_space_io(ISADevice *dev);
>>   ISADevice *isa_new(const char *name);
>> +bool isa_check_device_existence(const char *typename);
> Please provide documentation for this function in line with other
> functions like isa_register_ioport() and isa_register_portio_list()  in
> the same header.

Ah, I see what you mean - I'll write short descriptive documentation 
like what there's for other functions :)

Thanks for the suggestions!

Best regards,
Liav



  reply	other threads:[~2022-02-27 19:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-26  6:30 [PATCH v3 0/4] hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table Liav Albani
2022-02-26  6:30 ` [PATCH v3 1/4] hw/isa: add function to check for existence of device by its type Liav Albani
2022-02-27  7:27   ` Ani Sinha
2022-02-27 19:03     ` Liav Albani [this message]
2022-02-26  6:30 ` [PATCH v3 2/4] tests/acpi: i386: allow FACP acpi table changes Liav Albani
2022-02-27  6:57   ` Ani Sinha
2022-02-26  6:30 ` [PATCH v3 3/4] hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table Liav Albani
2022-02-27  6:56   ` Ani Sinha
2022-02-27 18:59     ` Liav Albani
2022-02-27 10:48   ` Bernhard Beschow
2022-02-27 18:58     ` Liav Albani
2022-02-27 21:33       ` Bernhard Beschow
2022-02-28  5:01         ` Ani Sinha
2022-02-28  6:56           ` Ani Sinha
2022-02-28  8:47             ` Ani Sinha
2022-02-26  6:30 ` [PATCH v3 4/4] tests/acpi: i386: update FACP table differences Liav Albani
2022-02-27  7:05   ` Ani Sinha

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=76ebfc46-444e-d145-7f6f-020e04dace9c@gmail.com \
    --to=liavalb@gmail.com \
    --cc=ani@anisinha.ca \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).