[PATCH] ns16550: switch to resource

Antony Pavlov antonynpavlov at gmail.com
Sat Jul 30 08:07:30 EDT 2011


On 30/07/2011, Jean-Christophe PLAGNIOL-VILLARD <plagnioj at 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



More information about the barebox mailing list