mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] ns16550: switch to resource
Date: Sat, 30 Jul 2011 16:07:30 +0400	[thread overview]
Message-ID: <CAA4bVAHVAbNCHcXY7_3Pp1hHZNRdh7rv7p5AHs7V4yUUnaP6+w@mail.gmail.com> (raw)
In-Reply-To: <1312004257-7009-1-git-send-email-plagnioj@jcrosoft.com>

On 30/07/2011, Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote:

> +static uint32_t ns16550_read(struct console_device *cdev, uint32_t off)
> +{
> +	struct device_d *dev = cdev->dev;
> +	struct NS16550_plat *plat = (struct NS16550_plat *)dev->platform_data;
> +	int width = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
> +	
> +	off <<= plat->shift;
> +
> +	if (plat->reg_read)
> +		return plat->reg_read((unsigned long)dev->priv, off);
>

So, this code __always__ make swap before calling platform-dependent
reg_read (if any).
And platform-dependent reg_read must assume the presence of the shift.

I propose this variant:
---------------------------
if (plat->reg_read)
	return plat->reg_read((unsigned long)dev->priv, off);

off <<= plat->shift;
---------------------------

> +static void ns16550_write(struct console_device *cdev, uint32_t val,
> +			  uint32_t off)
> +{
> +	struct device_d *dev = cdev->dev;
> +	struct NS16550_plat *plat = (struct NS16550_plat *)dev->platform_data;
> +	int width = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
> +
> +	off <<= plat->shift;
> +
> +	if (plat->reg_write) {
> +		plat->reg_write(val, (unsigned long)dev->priv, off);
> +		return;
> +	}

Near the same code.

-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2011-07-30 12:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-30  5:37 Jean-Christophe PLAGNIOL-VILLARD
2011-07-30 12:07 ` Antony Pavlov [this message]
2011-07-30 12:10   ` Jean-Christophe PLAGNIOL-VILLARD
2011-07-30 12:42     ` Antony Pavlov

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=CAA4bVAHVAbNCHcXY7_3Pp1hHZNRdh7rv7p5AHs7V4yUUnaP6+w@mail.gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=plagnioj@jcrosoft.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