Re: [PATCH 2/2] serial: Add support for Fintek F81216A LPC to 4 UART

From: One Thousand Gnomes
Date: Thu Jul 31 2014 - 10:21:29 EST


> +static int fintek_8250_get_index(resource_size_t base_addr)
> +{
> + resource_size_t base[] = {0x3f8, 0x2f8, 0x3e8, 0x2e8};
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(base); i++)
> + if (base_addr == base[i])
> + return i;
> +
> + return -ENODEV;

Less than ideal in some ways because the base may well be remapped by
other hardware or on non x86 devices. No obvious ideas how to fix it
though and PnP kind of implies x86.

> + mutex_lock(&fintek_mutex);
> + outb(LDN, ADDR_PORT);
> + outb(index, DATA_PORT);
> + outb(RS485, ADDR_PORT);
> + outb(config, DATA_PORT);
> + mutex_unlock(&fintek_mutex);

You really need to request that block of addresses because you may not be
the only superIO chip or driver playing with the various mux hack
registers that are used.

On the bright side you can then make the resource layer do your locking
work for you. We have an IORESOURCE_MUXED flag for these little horrors
so you can request the resource with IORESOURCE_MUXED. If the resource is
busy then you will get a failure back, if it is idle you will get the
resource, if it is busy but held by another driver using IORESOURCE_MUXED
then the request will block until they finish with it.

So you do

request_muxed_region
if failed then EBUSY
prod stuff
release_region


Alan

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/