* [IDE] meaningless #ifndef?
@ 2001-02-19 21:57 Pozsar Balazs
2001-02-19 22:31 ` Andre Hedrick
2001-02-20 9:47 ` Andrzej Krzysztofowicz
0 siblings, 2 replies; 10+ messages in thread
From: Pozsar Balazs @ 2001-02-19 21:57 UTC (permalink / raw)
To: linux-kernel
from drivers/ide/ide-features.c:
/*
* All hosts that use the 80c ribbon mus use!
*/
byte eighty_ninty_three (ide_drive_t *drive)
{
return ((byte) ((HWIF(drive)->udma_four) &&
#ifndef CONFIG_IDEDMA_IVB
(drive->id->hw_config & 0x4000) &&
#endif /* CONFIG_IDEDMA_IVB */
(drive->id->hw_config & 0x6000)) ? 1 : 0);
}
If i see well, then this is always same whether CONFIG_IDEDMA_IVB is
defined or not.
What's the clue?
--
pozsy.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [IDE] meaningless #ifndef?
2001-02-19 21:57 Pozsar Balazs
@ 2001-02-19 22:31 ` Andre Hedrick
2001-02-19 23:31 ` Bill Wendling
2001-02-20 9:47 ` Andrzej Krzysztofowicz
1 sibling, 1 reply; 10+ messages in thread
From: Andre Hedrick @ 2001-02-19 22:31 UTC (permalink / raw)
To: Pozsar Balazs; +Cc: linux-kernel
On Mon, 19 Feb 2001, Pozsar Balazs wrote:
> from drivers/ide/ide-features.c:
>
> /*
> * All hosts that use the 80c ribbon mus use!
> */
> byte eighty_ninty_three (ide_drive_t *drive)
> {
> return ((byte) ((HWIF(drive)->udma_four) &&
> #ifndef CONFIG_IDEDMA_IVB
> (drive->id->hw_config & 0x4000) &&
> #endif /* CONFIG_IDEDMA_IVB */
> (drive->id->hw_config & 0x6000)) ? 1 : 0);
> }
>
> If i see well, then this is always same whether CONFIG_IDEDMA_IVB is
> defined or not.
> What's the clue?
(drive->id->hw_config & 0x4000)
mask off 0x4000 for presence.
(drive->id->hw_config & 0x6000)
mask off 0x2000 ot 0x4000 for presence.
The first is true only if bit 14 is set.
The second is true if either bit 13 or 14 is set.
Togather they test for two bits.
The first test is exclusive to bit 14
The second test is inclusive of bits 13 and 14.
Because some older drives set only bit 13 for the device side cable-detect,
then newer drives than these did a supported mode bit 14 and no bits 13,
then others do both.
So in order to have a test that supports ATA-4/5/6 you have to allow
users the option to disable the newer sense code that is only valid for
ATA-5/6. It will get messier still.
Andre Hedrick
Linux ATA Development
ASL Kernel Development
-----------------------------------------------------------------------------
ASL, Inc. Toll free: 1-877-ASL-3535
1757 Houret Court Fax: 1-408-941-2071
Milpitas, CA 95035 Web: www.aslab.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [IDE] meaningless #ifndef?
2001-02-19 22:31 ` Andre Hedrick
@ 2001-02-19 23:31 ` Bill Wendling
2001-02-19 23:34 ` Andre Hedrick
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Bill Wendling @ 2001-02-19 23:31 UTC (permalink / raw)
To: Andre Hedrick; +Cc: Pozsar Balazs, linux-kernel
Also sprach Andre Hedrick:
} On Mon, 19 Feb 2001, Pozsar Balazs wrote:
}
} > from drivers/ide/ide-features.c:
} >
} > /*
} > * All hosts that use the 80c ribbon mus use!
} > */
} > byte eighty_ninty_three (ide_drive_t *drive)
} > {
} > return ((byte) ((HWIF(drive)->udma_four) &&
} > #ifndef CONFIG_IDEDMA_IVB
} > (drive->id->hw_config & 0x4000) &&
} > #endif /* CONFIG_IDEDMA_IVB */
} > (drive->id->hw_config & 0x6000)) ? 1 : 0);
} > }
} >
} > If i see well, then this is always same whether CONFIG_IDEDMA_IVB is
} > defined or not.
} > What's the clue?
}
[snip...]
The use of the ternary operator is superfluous, though...and makes the
code look ugly IMNSHO :).
--
|| Bill Wendling wendling@ganymede.isdn.uiuc.edu
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [IDE] meaningless #ifndef?
2001-02-19 23:31 ` Bill Wendling
@ 2001-02-19 23:34 ` Andre Hedrick
2001-02-20 4:45 ` Tom Leete
2001-02-20 5:10 ` Tom Leete
2 siblings, 0 replies; 10+ messages in thread
From: Andre Hedrick @ 2001-02-19 23:34 UTC (permalink / raw)
To: Bill Wendling; +Cc: Pozsar Balazs, linux-kernel
On Mon, 19 Feb 2001, Bill Wendling wrote:
> The use of the ternary operator is superfluous, though...and makes the
> code look ugly IMNSHO :).
What is ugly is that the commitee can not decide if there is going to be
host-side only, device-side only or both-side.
Cheers,
Andre Hedrick
Linux ATA Development
ASL Kernel Development
-----------------------------------------------------------------------------
ASL, Inc. Toll free: 1-877-ASL-3535
1757 Houret Court Fax: 1-408-941-2071
Milpitas, CA 95035 Web: www.aslab.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [IDE] meaningless #ifndef?
2001-02-19 23:31 ` Bill Wendling
2001-02-19 23:34 ` Andre Hedrick
@ 2001-02-20 4:45 ` Tom Leete
2001-02-20 5:10 ` Tom Leete
2 siblings, 0 replies; 10+ messages in thread
From: Tom Leete @ 2001-02-20 4:45 UTC (permalink / raw)
To: Bill Wendling; +Cc: Andre Hedrick, Pozsar Balazs, linux-kernel
Bill Wendling wrote:
>
> Also sprach Andre Hedrick:
> } On Mon, 19 Feb 2001, Pozsar Balazs wrote:
> }
> } > from drivers/ide/ide-features.c:
> } >
> } > /*
> } > * All hosts that use the 80c ribbon mus use!
> } > */
> } > byte eighty_ninty_three (ide_drive_t *drive)
> } > {
> } > return ((byte) ((HWIF(drive)->udma_four) &&
> } > #ifndef CONFIG_IDEDMA_IVB
> } > (drive->id->hw_config & 0x4000) &&
> } > #endif /* CONFIG_IDEDMA_IVB */
> } > (drive->id->hw_config & 0x6000)) ? 1 : 0);
> } > }
> } >
> } > If i see well, then this is always same whether CONFIG_IDEDMA_IVB is
> } > defined or not.
> } > What's the clue?
> }
> [snip...]
>
> The use of the ternary operator is superfluous, though...and makes the
> code look ugly IMNSHO :).
>
Check return type. 0 == ((byte) 0x6000).
Tom
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [IDE] meaningless #ifndef?
2001-02-19 23:31 ` Bill Wendling
2001-02-19 23:34 ` Andre Hedrick
2001-02-20 4:45 ` Tom Leete
@ 2001-02-20 5:10 ` Tom Leete
2 siblings, 0 replies; 10+ messages in thread
From: Tom Leete @ 2001-02-20 5:10 UTC (permalink / raw)
To: Bill Wendling; +Cc: Andre Hedrick, Pozsar Balazs, linux-kernel
Bill Wendling wrote:
>
> The use of the ternary operator is superfluous, though...and makes the
> code look ugly IMNSHO :).
>
You are correct. Please ignore my thinko.
Tom
--
The Daemons lurk and are dumb. -- Emerson
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [IDE] meaningless #ifndef?
2001-02-19 21:57 Pozsar Balazs
2001-02-19 22:31 ` Andre Hedrick
@ 2001-02-20 9:47 ` Andrzej Krzysztofowicz
1 sibling, 0 replies; 10+ messages in thread
From: Andrzej Krzysztofowicz @ 2001-02-20 9:47 UTC (permalink / raw)
To: Pozsar Balazs; +Cc: linux-kernel
"Pozsar Balazs wrote:"
> from drivers/ide/ide-features.c:
>
> /*
> * All hosts that use the 80c ribbon mus use!
> */
> byte eighty_ninty_three (ide_drive_t *drive)
> {
> return ((byte) ((HWIF(drive)->udma_four) &&
> #ifndef CONFIG_IDEDMA_IVB
> (drive->id->hw_config & 0x4000) &&
> #endif /* CONFIG_IDEDMA_IVB */
> (drive->id->hw_config & 0x6000)) ? 1 : 0);
> }
>
> If i see well, then this is always same whether CONFIG_IDEDMA_IVB is
> defined or not.
No, it is not the same. But it duplicates the test when CONFIG_IDEDMA_IVB
is not set. If both tests are done and the first is true, the second also
must be true. If the first is false, the second is meaningless.
Maybe the above code should be:
return ((byte) ((HWIF(drive)->udma_four) &&
#ifndef CONFIG_IDEDMA_IVB
(drive->id->hw_config & 0x4000)
#else
(drive->id->hw_config & 0x6000)
#endif /* CONFIG_IDEDMA_IVB */
) ? 1 : 0);
Just my 0.03 PLN...
--
=======================================================================
Andrzej M. Krzysztofowicz ankry@mif.pg.gda.pl
phone (48)(58) 347 14 61
Faculty of Applied Phys. & Math., Technical University of Gdansk
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [IDE] meaningless #ifndef?
[not found] <Pine.LNX.4.21.0102201705280.11260-100000@alloc>
@ 2001-02-20 17:45 ` Hugh Dickins
2001-02-20 18:20 ` Vojtech Pavlik
0 siblings, 1 reply; 10+ messages in thread
From: Hugh Dickins @ 2001-02-20 17:45 UTC (permalink / raw)
To: Andre Hedrick; +Cc: Pozsar Balazs, linux-kernel
On Mon, 19 Feb 2001, Andre Hedrick wrote:
> On Mon, 19 Feb 2001, Pozsar Balazs wrote:
>
> > from drivers/ide/ide-features.c:
> >
> > /*
> > * All hosts that use the 80c ribbon mus use!
> > */
> > byte eighty_ninty_three (ide_drive_t *drive)
> > {
> > return ((byte) ((HWIF(drive)->udma_four) &&
> > #ifndef CONFIG_IDEDMA_IVB
> > (drive->id->hw_config & 0x4000) &&
> > #endif /* CONFIG_IDEDMA_IVB */
> > (drive->id->hw_config & 0x6000)) ? 1 : 0);
> > }
> >
> > If i see well, then this is always same whether CONFIG_IDEDMA_IVB is
> > defined or not.
> > What's the clue?
>
> (drive->id->hw_config & 0x4000)
> mask off 0x4000 for presence.
> (drive->id->hw_config & 0x6000)
> mask off 0x2000 ot 0x4000 for presence.
>
> The first is true only if bit 14 is set.
> The second is true if either bit 13 or 14 is set.
>
> Togather they test for two bits.
> The first test is exclusive to bit 14
> The second test is inclusive of bits 13 and 14.
>
> Because some older drives set only bit 13 for the device side cable-detect,
> then newer drives than these did a supported mode bit 14 and no bits 13,
> then others do both.
>
> So in order to have a test that supports ATA-4/5/6 you have to allow
> users the option to disable the newer sense code that is only valid for
> ATA-5/6. It will get messier still.
Andre, please read through that code again, and through your reply.
It seems to me that Poszar is absolutely right, and your reply is
(once again) just saying "there's lots of confusion out there, so
my code has to be confused too". Or do your &s and &&s behave
differently from ours?
Hugh
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [IDE] meaningless #ifndef?
2001-02-20 17:45 ` [IDE] meaningless #ifndef? Hugh Dickins
@ 2001-02-20 18:20 ` Vojtech Pavlik
2001-02-20 19:08 ` Hugh Dickins
0 siblings, 1 reply; 10+ messages in thread
From: Vojtech Pavlik @ 2001-02-20 18:20 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Andre Hedrick, Pozsar Balazs, linux-kernel
On Tue, Feb 20, 2001 at 05:45:52PM +0000, Hugh Dickins wrote:
> >
> > > from drivers/ide/ide-features.c:
> > >
> > > /*
> > > * All hosts that use the 80c ribbon mus use!
> > > */
> > > byte eighty_ninty_three (ide_drive_t *drive)
> > > {
> > > return ((byte) ((HWIF(drive)->udma_four) &&
> > > #ifndef CONFIG_IDEDMA_IVB
> > > (drive->id->hw_config & 0x4000) &&
> > > #endif /* CONFIG_IDEDMA_IVB */
> > > (drive->id->hw_config & 0x6000)) ? 1 : 0);
> > > }
> > >
> > > If i see well, then this is always same whether CONFIG_IDEDMA_IVB is
> > > defined or not.
> > > What's the clue?
> > The first is true only if bit 14 is set.
> > The second is true if either bit 13 or 14 is set.
> >
> > Togather they test for two bits.
> > The first test is exclusive to bit 14
> > The second test is inclusive of bits 13 and 14.
> Andre, please read through that code again, and through your reply.
> It seems to me that Poszar is absolutely right, and your reply is
> (once again) just saying "there's lots of confusion out there, so
> my code has to be confused too". Or do your &s and &&s behave
> differently from ours?
Well, the code looks weird. However, it doesn't behave the same when
CONFIG_IDEDMA_IVB is enabled or not. If it is not, normal case, it's
just:
(drive->id->hw_config & 0x6000)
If CONFIG_IDEDMA_IVB is enabled, it boils down to:
(drive->id->hw_config & 0x4000)
because the second bit test includes the earlier test already only
loosening it. Because of that, it's superfluous. And the code relies on
the compiler to optimize it out.
If written like:
#ifndef CONFIG_IDEDMA_IVB
#define IDE_UDMA_MASK 0x4000
#else
#define IDE_UDMA_MASK 0x6000
#endif /* CONFIG_IDEDMA_IVB */
byte eighty_ninty_three (ide_drive_t *drive)
{
return HWIF(drive)->udma_four &&
(drive->id->hw_config & IDE_UDMA_MASK);
}
it'd be probably somewhat clearer.
--
Vojtech Pavlik
SuSE Labs
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [IDE] meaningless #ifndef?
2001-02-20 18:20 ` Vojtech Pavlik
@ 2001-02-20 19:08 ` Hugh Dickins
0 siblings, 0 replies; 10+ messages in thread
From: Hugh Dickins @ 2001-02-20 19:08 UTC (permalink / raw)
To: Vojtech Pavlik; +Cc: Andre Hedrick, Pozsar Balazs, linux-kernel
On Tue, 20 Feb 2001, Vojtech Pavlik wrote:
> On Tue, Feb 20, 2001 at 05:45:52PM +0000, Hugh Dickins wrote:
> > > > byte eighty_ninty_three (ide_drive_t *drive)
> > > > {
> > > > return ((byte) ((HWIF(drive)->udma_four) &&
> > > > #ifndef CONFIG_IDEDMA_IVB
> > > > (drive->id->hw_config & 0x4000) &&
> > > > #endif /* CONFIG_IDEDMA_IVB */
> > > > (drive->id->hw_config & 0x6000)) ? 1 : 0);
> > > > }
>
> Well, the code looks weird. However, it doesn't behave the same when
> CONFIG_IDEDMA_IVB is enabled or not. If it is not, normal case, it's
> just:
>
> (drive->id->hw_config & 0x6000)
>
> If CONFIG_IDEDMA_IVB is enabled, it boils down to:
>
> (drive->id->hw_config & 0x4000)
>
> because the second bit test includes the earlier test already only
> loosening it. Because of that, it's superfluous. And the code relies on
> the compiler to optimize it out.
Thank you for re-explaining this to me.
Yes, you are right, I was wrong, I now
admit my &s and &&s behave like yours,
and I apologize to Andre!
> If written like:
>
> #ifndef CONFIG_IDEDMA_IVB
> #define IDE_UDMA_MASK 0x4000
> #else
> #define IDE_UDMA_MASK 0x6000
> #endif /* CONFIG_IDEDMA_IVB */
>
> byte eighty_ninty_three (ide_drive_t *drive)
> {
> return HWIF(drive)->udma_four &&
> (drive->id->hw_config & IDE_UDMA_MASK);
> }
>
> it'd be probably somewhat clearer.
That would certainly have helped us!
Hugh
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2001-02-20 19:09 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <Pine.LNX.4.21.0102201705280.11260-100000@alloc>
2001-02-20 17:45 ` [IDE] meaningless #ifndef? Hugh Dickins
2001-02-20 18:20 ` Vojtech Pavlik
2001-02-20 19:08 ` Hugh Dickins
2001-02-19 21:57 Pozsar Balazs
2001-02-19 22:31 ` Andre Hedrick
2001-02-19 23:31 ` Bill Wendling
2001-02-19 23:34 ` Andre Hedrick
2001-02-20 4:45 ` Tom Leete
2001-02-20 5:10 ` Tom Leete
2001-02-20 9:47 ` Andrzej Krzysztofowicz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox