Messages in this thread | | | Date | Thu, 31 Jul 2014 15:19:41 +0100 | From | One Thousand Gnomes <> | Subject | Re: [PATCH 2/2] serial: Add support for Fintek F81216A LPC to 4 UART |
| |
> +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
| |