From: Michael Schmitz <schmitzmic@gmail.com>
To: Damien Le Moal <dlemoal@kernel.org>,
Sergey Shtylyov <s.shtylyov@omp.ru>,
linux-ide@vger.kernel.org, linux-m68k@vger.kernel.org
Cc: will@sowerbutts.com, rz@linux-m68k.org, geert@linux-m68k.org,
Finn Thain <fthain@linux-m68k.org>
Subject: Re: [PATCH v4 2/2] ata: pata_falcon: add data_swab option to byte-swap disk data
Date: Thu, 24 Aug 2023 13:49:50 +1200 [thread overview]
Message-ID: <4f3d3973-cec5-803e-9588-d5d7c20a41f8@gmail.com> (raw)
In-Reply-To: <35b28bcb-13ba-fafc-a30b-d84eb3b6bbea@kernel.org>
Hi Damien,
On 24/08/23 11:03, Damien Le Moal wrote:
> On 8/24/23 01:35, Sergey Shtylyov wrote:
>> On 8/23/23 1:13 AM, Michael Schmitz wrote:
>>
>>> Some users of pata_falcon on Q40 have IDE disks in default
>>> IDE little endian byte order, whereas legacy disks use
>>> host-native big-endian byte order as on the Atari Falcon.
>>>
>>> Add module parameter 'data_swab' to allow connecting drives
>>> with non-native data byte order. Drives selected by the
>>> data_swap bit mask will have their user data byte-swapped to
>>> host byte order, i.e. 'pata_falcon.data_swab=2' will byte-swap
>>> all user data on drive B, leaving data on drive A in native
>>> byte order. On Q40, drives on a second IDE interface may be
>>> added to the bit mask as bits 2 and 3.
>>>
>>> Default setting is no byte swapping, i.e. compatibility with
>>> the native Falcon or Q40 operating system disk format.
>>>
>>> Cc: William R Sowerbutts <will@sowerbutts.com>
>>> Cc: Finn Thain <fthain@linux-m68k.org>
>>> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
>>> Tested-by: William R Sowerbutts <will@sowerbutts.com>
>>> Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
>> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
>>
>> [...]
>>
>>> diff --git a/drivers/ata/pata_falcon.c b/drivers/ata/pata_falcon.c
>>> index 3841ea200bcb..7cf15bd9764a 100644
>>> --- a/drivers/ata/pata_falcon.c
>>> +++ b/drivers/ata/pata_falcon.c
>> [...]
>>> @@ -194,6 +199,9 @@ static int __init pata_falcon_init_one(struct platform_device *pdev)
>>> ata_port_desc(ap, "cmd %px ctl %px data %pa",
>>> base, ctl_base, &ap->ioaddr.data_addr);
>>>
>>> + ap->private_data = (void *)(uintptr_t)(pdev->id > 0 ?
>>> + pata_falcon_swap_mask >> 2 : pata_falcon_swap_mask);
>> How about:
>>
>> ap->private_data = (void *)(uintptr_t)(pata_falcon_swap_mask >>
>> (pdev->id > 0 ? 2 : 0));
> This is so hard to decode... Let's please spell this out.
> Something like:
>
> int shift;
>
> if (pdev->id)
Atari Falcon has pdev->id==-1, so this must be 'if (pdev->id > 0)' here.
(Testing for pdev->id nonzero did work in earlier versions of my patch
because patch 3 changed the platform device ID on Atari. That patch had
the potential to confuse user space so I dropped it from v3 on.)
> shift = 2;
> else
> shift = 0;
No need for the 'else' if we initialize shift above (as is done for irq,
io_offset and reg_shift).
> ap->private_data = (uintptr_t)(pata_falcon_swap_mask >> shift);
>
> This is initialization, so no need to try to optimize and rather privilege clear
> code.
Hmm - or maybe I'll leave that spelled out as you suggest.
Cheers,
Michael
>
>> [...]
>>
>> MBR, Sergey
prev parent reply other threads:[~2023-08-24 1:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-22 22:13 [PATCH v4 0/2] Q40 IDE fixes Michael Schmitz
2023-08-22 22:13 ` [PATCH v4 1/2] ata: pata_falcon: fix IO base selection for Q40 Michael Schmitz
2023-08-23 9:05 ` Geert Uytterhoeven
2023-08-24 1:54 ` Michael Schmitz
2023-08-23 16:05 ` Sergey Shtylyov
2023-08-24 1:56 ` Michael Schmitz
2023-08-24 10:00 ` Sergey Shtylyov
2023-08-25 1:07 ` Michael Schmitz
2023-08-22 22:13 ` [PATCH v4 2/2] ata: pata_falcon: add data_swab option to byte-swap disk data Michael Schmitz
2023-08-23 9:10 ` Geert Uytterhoeven
2023-08-23 9:10 ` Geert Uytterhoeven
2023-08-24 1:57 ` Michael Schmitz
2023-08-23 16:35 ` Sergey Shtylyov
2023-08-23 23:03 ` Damien Le Moal
2023-08-24 1:49 ` Michael Schmitz [this message]
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=4f3d3973-cec5-803e-9588-d5d7c20a41f8@gmail.com \
--to=schmitzmic@gmail.com \
--cc=dlemoal@kernel.org \
--cc=fthain@linux-m68k.org \
--cc=geert@linux-m68k.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-m68k@vger.kernel.org \
--cc=rz@linux-m68k.org \
--cc=s.shtylyov@omp.ru \
--cc=will@sowerbutts.com \
/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