linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kristoffer Nyborg Gregertsen <gregerts@stud.ntnu.no>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Kristoffer Nyborg Gregertsen <kngregertsen@norway.atmel.com>,
	linux-ide@vger.kernel.org, gregerts@stud.ntnu.no
Subject: Re: [PATCH 1/1] AVR32 PATA driver
Date: Tue, 7 Aug 2007 19:39:34 +0200	[thread overview]
Message-ID: <200708071939.34266.gregerts@stud.ntnu.no> (raw)
In-Reply-To: <20070807165409.4c2a4451@the-village.bc.nu>

On Tuesday 07 August 2007 17:54:09 Alan Cox wrote:
>  +static int pata_at32_get_pio_mask(void)
>
> > +{
> > +	switch (max_pio) {
> > +	case 0:
> > +		return 0x01;
> > +	case 1:
> > +		return 0x03;
> > +	case 2:
> > +		return 0x07;
> > +	case 3:
> > +		return 0x0f;
> > +	case 4:
> > +		return 0x1f;
> > +	default:
> > +		return 0x01;
>
> What is wrong with just using  (1 << max_pio) - 1 as the range is only
> 0-4 anyway.

Since max_pio is a module argument it may be invalid. Perhaps:

if (0 <= max_pio && max_pio <= 4)
	return (1 << max_pio) - 1;
else
	return 0x01;

Or is it common to trust the module arguments to be sane?

> > +static void pata_at32_data_xfer(struct ata_device *adev, unsigned char
> > *buf, +				unsigned int buflen, int write_data)
> > +{
> > +	struct at32_ide_info *info = adev->ap->host->private_data;
> > +
> > +	/* Set SMC to data transfer speed */
> > +	if (info->smc_pio_mode < 3)
> > +		smc_restore_registers(info->cs, &info->smc_16.reg);
> > +
> > +	/* Transfer data */
> > +	ata_data_xfer(adev, buf, buflen, write_data);
> > +
> > +	/* Set SMC back to register transfer speed */
> > +	if (info->smc_pio_mode < 3)
> > +		smc_restore_registers(info->cs, &info->smc_8.reg);
>
> Should be safe currently for IRQ driven behaviour, might be for polled but
> remember that without locking you could end up reading the status before
> you switch the clock back  so I'm not 100% sure.

I now see that things can get messed up. I can alter the hardware so that a 
seperate SMC memory space for data and register transfer can be used, each 
with their respective timing set at all times. This will cost one extra chip 
select pin and an AND port on the adaptor, but it might be worth it?

-- 
With kind regards

Kristoffer Nyborg Gregertsen

Student, Department of Engineering Cybernetics
Norwegian University of Science and Technology
Trondheim, Norway

  reply	other threads:[~2007-08-07 18:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-07  9:26 [PATCH 0/1] AVR32 PATA driver Kristoffer Nyborg Gregertsen
2007-08-07  9:27 ` [PATCH 1/1] " Kristoffer Nyborg Gregertsen
2007-08-07 15:54   ` Alan Cox
2007-08-07 17:39     ` Kristoffer Nyborg Gregertsen [this message]
2007-08-07 18:14       ` Jeff Garzik
2007-08-07 18:26         ` Kristoffer Nyborg Gregertsen
2007-08-08 14:57     ` Kristoffer Nyborg Gregertsen
2007-08-31  9:38       ` Jeff Garzik
2007-08-07 15:58 ` [PATCH 0/1] " Alan Cox
2007-08-07 18:18   ` Kristoffer Nyborg Gregertsen
2007-08-14  6:41 ` [PATCH 1/1] " Kristoffer Nyborg Gregertsen
2007-08-14  6:53   ` Kristoffer Nyborg Gregertsen
2007-08-15  8:44     ` Kristoffer Nyborg Gregertsen

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=200708071939.34266.gregerts@stud.ntnu.no \
    --to=gregerts@stud.ntnu.no \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=kngregertsen@norway.atmel.com \
    --cc=linux-ide@vger.kernel.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).