Skip to content

Commit

Permalink
tty: serial: men_z135_uart.c: use mcb memory region size instead of h…
Browse files Browse the repository at this point in the history
…ardcoded one

There is no need to hardcode the MEN_Z135_MEM_SIZE. The MCB subsystem
already knowns the size which is located in the chameleon table.
MCB parse the chameleon table to get the resources of each IP and provide
the mcb_request_mem function to get those resources.

Use mcb_request_mem to get the resources. This function also takes care of
the memory region naming allocated by the driver for each of the instances.

Signed-off-by: Andreas Werner <andy@wernerandy.de>
Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Andreas Werner authored and Greg Kroah-Hartman committed Oct 18, 2015
1 parent 270c2ad commit 37f0679
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions drivers/tty/serial/men_z135_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
#define MEN_Z135_BAUD_REG 0x810
#define MEN_Z135_TIMEOUT 0x814

#define MEN_Z135_MEM_SIZE 0x818

#define IRQ_ID(x) ((x) & 0x1f)

#define MEN_Z135_IER_RXCIEN BIT(0) /* RX Space IRQ */
Expand Down Expand Up @@ -124,6 +122,7 @@ MODULE_PARM_DESC(rx_timeout, "RX timeout. "
struct men_z135_port {
struct uart_port port;
struct mcb_device *mdev;
struct resource *mem;
unsigned char *rxbuf;
u32 stat_reg;
spinlock_t lock;
Expand Down Expand Up @@ -734,22 +733,30 @@ static const char *men_z135_type(struct uart_port *port)

static void men_z135_release_port(struct uart_port *port)
{
struct men_z135_port *uart = to_men_z135(port);

iounmap(port->membase);
port->membase = NULL;

release_mem_region(port->mapbase, MEN_Z135_MEM_SIZE);
mcb_release_mem(uart->mem);
}

static int men_z135_request_port(struct uart_port *port)
{
int size = MEN_Z135_MEM_SIZE;
struct men_z135_port *uart = to_men_z135(port);
struct mcb_device *mdev = uart->mdev;
struct resource *mem;

mem = mcb_request_mem(uart->mdev, dev_name(&mdev->dev));
if (IS_ERR(mem))
return PTR_ERR(mem);

if (!request_mem_region(port->mapbase, size, "men_z135_port"))
return -EBUSY;
port->mapbase = mem->start;
uart->mem = mem;

port->membase = ioremap(port->mapbase, MEN_Z135_MEM_SIZE);
port->membase = ioremap(mem->start, resource_size(mem));
if (port->membase == NULL) {
release_mem_region(port->mapbase, MEN_Z135_MEM_SIZE);
mcb_release_mem(mem);
return -ENOMEM;
}

Expand Down

0 comments on commit 37f0679

Please sign in to comment.