From: Liav Albani <liavalb@gmail.com>
To: BALATON Zoltan <balaton@eik.bme.hu>
Cc: jsnow@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [PATCH 1/1] hw/ide: share bmdma read and write functions between piix.c and via.c
Date: Sat, 19 Feb 2022 15:05:10 +0200 [thread overview]
Message-ID: <ba8fb8ae-9af0-a740-6451-1e12dba14691@gmail.com> (raw)
In-Reply-To: <5b443413-5f5c-48f9-161-6573b79aa8e3@eik.bme.hu>
On 2/19/22 13:19, BALATON Zoltan wrote:
> On Sat, 19 Feb 2022, Liav Albani wrote:
>> Instead of letting each implementation to duplicate this code, we can
>> share these functions between IDE PIIX3/4 and VIA implementations.
>
> OK but there's a way to take this even further as cmd646 also uses
> similar functions just with more cases so you could remove the cases
> handled by these functions and only leave the difference and call the
> default function from the default case. E.g. (untested, just to show
> the idea):
>
> hw/ide/cmd646.c:
> static uint64_t bmdma_read(void *opaque, hwaddr addr,
> unsigned size)
> {
> BMDMAState *bm = opaque;
> PCIDevice *pci_dev = PCI_DEVICE(bm->pci_dev);
> uint32_t val;
>
> if (size != 1) {
> return ((uint64_t)1 << (size * 8)) - 1;
> }
>
> switch(addr & 3) {
> case 1:
> val = pci_dev->config[MRDMODE];
> break;
> case 3:
> if (bm == &bm->pci_dev->bmdma[0]) {
> val = pci_dev->config[UDIDETCR0];
> } else {
> val = pci_dev->config[UDIDETCR1];
> }
> break;
> default:
> val = bmdma_default_read(opaque, addr, size);
> break;
> }
>
> trace_bmdma_read_cmd646(addr, val);
> return val;
> }
>
Yeah, I see how I can do that for both bmdma write and read of cmd646.
I'll send a v2 right away with a fix.
>> Signed-off-by: Liav Albani <liavalb@gmail.com>
>> ---
>> hw/ide/pci.c | 47 ++++++++++++++++++++++++++++++++++++++++
>> hw/ide/piix.c | 50 ++-----------------------------------------
>> hw/ide/via.c | 51 ++------------------------------------------
>> include/hw/ide/pci.h | 4 ++++
>> 4 files changed, 55 insertions(+), 97 deletions(-)
>>
>> diff --git a/hw/ide/pci.c b/hw/ide/pci.c
>> index 84ba733548..c8b867659a 100644
>> --- a/hw/ide/pci.c
>> +++ b/hw/ide/pci.c
>> @@ -502,6 +502,53 @@ static const struct IDEDMAOps bmdma_ops = {
>> .reset = bmdma_reset,
>> };
>>
>> +uint64_t bmdma_default_read(void *opaque, hwaddr addr,
>> + unsigned size)
>
> Indentation off? Also everywhere else, usually we indent not with the
> parenthesis but with the list within. (Auto indent in most editors
> does that probably.)
>
I guess you mean that it should be:
+uint64_t bmdma_default_read(void *opaque, hwaddr addr,
+ unsigned size)
Like this?
I'm using Visual Studio Code, so I might not have the correct settings
for this editor with QEMU.
The checkpatch script doesn't complain on style issues, so what can I do
to make this correct?
Best regards,
Liav
> Regards,
> BALATON Zoltan
next prev parent reply other threads:[~2022-02-19 13:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-19 8:08 [PATCH 0/1] hw/ide: share bmdma read and write functions Liav Albani
2022-02-19 8:08 ` [PATCH 1/1] hw/ide: share bmdma read and write functions between piix.c and via.c Liav Albani
2022-02-19 11:19 ` BALATON Zoltan
2022-02-19 13:05 ` Liav Albani [this message]
2022-02-19 14:32 ` BALATON Zoltan
2022-02-19 15:57 ` BALATON Zoltan
2022-02-19 17:11 ` Liav Albani
2022-02-19 18:10 ` BALATON Zoltan
2022-09-06 14:26 ` [PATCH 0/1] hw/ide: share bmdma read and write functions Bernhard Beschow
2023-01-09 19:24 ` John Snow
2023-01-10 23:07 ` Bernhard Beschow
[not found] ` <7e7bf877-0300-7a2e-e0a4-f8db6eeae88b@gmail.com>
2023-01-16 20:29 ` John Snow
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=ba8fb8ae-9af0-a740-6451-1e12dba14691@gmail.com \
--to=liavalb@gmail.com \
--cc=balaton@eik.bme.hu \
--cc=jsnow@redhat.com \
--cc=qemu-block@nongnu.org \
--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).