All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stanislaw Gruszka <stf_xl@wp.pl>
To: Igor Plyatov <plyatov@gmail.com>
Cc: Jeff Garzik <jgarzik@pobox.com>, Tejun Heo <tj@kernel.org>,
	linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pata_at91: SMC settings calculation bugfixes, support for t6z and IORDY
Date: Fri, 13 May 2011 09:13:00 +0200	[thread overview]
Message-ID: <20110513071300.GA2584@localhost.localdomain> (raw)
In-Reply-To: <1305224151-11557-1-git-send-email-plyatov@gmail.com>

Hello

On Thu, May 12, 2011 at 10:15:51PM +0400, Igor Plyatov wrote:
> * New code correctly calculates SMC registers values, adjusts calculated
>   to admissible ranges, enlarges cycles when required and converts values
>   into SMC's format.
> * Support for TDF cycles (ATA t6z) and IORDY line added.
> * Eliminate need in the initial_timing structure.
> * Code cleanup.

Generally looks good for me, some remarks below.

> +		int *setup, int *pulse, int *cycle, int *cs_pulse)
> +{
> +	int ret_val;
> +	int err = 0;
> +	struct smc_range range_setup[] = {	/* SMC_SETUP valid values */
> +		{.min = 0,	.max = 31},	/* first  range */
> +		{.min = 128,	.max = 159}	/* second range */
> +	};
> +	struct smc_range range_pulse[] = {	/* SMC_PULSE valid values */
> +		{.min = 0,	.max = 63},	/* first  range */
> +		{.min = 256,	.max = 319}	/* second range */
> +	};
> +	struct smc_range range_cycle[] = {	/* SMC_CYCLE valid values */
> +		{.min = 0,	.max = 127},	/* first  range */
> +		{.min = 256,	.max = 383},	/* second range */
> +		{.min = 512,	.max = 639},	/* third  range */
> +		{.min = 768,	.max = 895}	/* fourth range */
> +	};

These /* ... rage */ comments are useless.

> +	*cs_pulse = *cycle;
> +	if (*cs_pulse > CS_PULSE_MAXIMUM) {
> +		dev_err(dev, "unable to calculate valid SMC settings\n");
> +		return -ER_SMC_CALC;
> +	}
> +
> +	ret_val = adjust_smc_value(cs_pulse, range_pulse,
> +					ARRAY_SIZE(range_pulse));
> +	if (ret_val < 0) {
> +		dev_warn(dev, "maximal SMC CS Pulse value\n");
> +	} else if (ret_val != 0) {
> +		*cycle = *cs_pulse;

cs_pulse and cycle will always have the same value here, so perhaps only
one variable can be used instead of two.

> + * to_smc_format - convert values into SMC format
> + * @setup: SETUP value of SMC Setup Register
> + * @pulse: PULSE value of SMC Pulse Register
> + * @cycle: CYCLE value of SMC Cycle Register
> + * @cs_pulse: NCS_PULSE value of SMC Pulse Register
> + */
> +static void to_smc_format(int *setup, int *pulse, int *cycle, int *cs_pulse)
> +{
> +	*setup = (*setup & 0x1f) | ((*setup & 0x80) >> 2);
> +	*pulse = (*pulse & 0x3f) | ((*pulse & 0x100) >> 2);
> +	*cycle = (*cycle & 0x7f) | ((*cycle & 0x300) >> 1);
> +	*cs_pulse = (*cs_pulse & 0x3f) | ((*cs_pulse & 0x100) >> 2);

Ok, here is the difference, but in previous functions cs_pulse seems
to be unneeded.

> +	do {
> +		ret = calc_smc_vals(dev, &setup, &pulse, &cycle, &cs_pulse);
> +	} while (ret == -ER_SMC_RECALC);

I do not quite understand why we have to recalculate, could you
add a short comment or explain?

Thanks
Stanislaw

      reply	other threads:[~2011-05-13  7:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-12 18:15 [PATCH] pata_at91: SMC settings calculation bugfixes, support for t6z and IORDY Igor Plyatov
2011-05-13  7:13 ` Stanislaw Gruszka [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=20110513071300.GA2584@localhost.localdomain \
    --to=stf_xl@wp.pl \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=plyatov@gmail.com \
    --cc=tj@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.