Skip to content

Commit 37f0679

Browse files
Andreas Wernergregkh
authored andcommitted
tty: serial: men_z135_uart.c: use mcb memory region size instead of hardcoded 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 <[email protected]> Acked-by: Johannes Thumshirn <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 270c2ad commit 37f0679

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

drivers/tty/serial/men_z135_uart.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
#define MEN_Z135_BAUD_REG 0x810
3636
#define MEN_Z135_TIMEOUT 0x814
3737

38-
#define MEN_Z135_MEM_SIZE 0x818
39-
4038
#define IRQ_ID(x) ((x) & 0x1f)
4139

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

735734
static void men_z135_release_port(struct uart_port *port)
736735
{
736+
struct men_z135_port *uart = to_men_z135(port);
737+
737738
iounmap(port->membase);
738739
port->membase = NULL;
739740

740-
release_mem_region(port->mapbase, MEN_Z135_MEM_SIZE);
741+
mcb_release_mem(uart->mem);
741742
}
742743

743744
static int men_z135_request_port(struct uart_port *port)
744745
{
745-
int size = MEN_Z135_MEM_SIZE;
746+
struct men_z135_port *uart = to_men_z135(port);
747+
struct mcb_device *mdev = uart->mdev;
748+
struct resource *mem;
749+
750+
mem = mcb_request_mem(uart->mdev, dev_name(&mdev->dev));
751+
if (IS_ERR(mem))
752+
return PTR_ERR(mem);
746753

747-
if (!request_mem_region(port->mapbase, size, "men_z135_port"))
748-
return -EBUSY;
754+
port->mapbase = mem->start;
755+
uart->mem = mem;
749756

750-
port->membase = ioremap(port->mapbase, MEN_Z135_MEM_SIZE);
757+
port->membase = ioremap(mem->start, resource_size(mem));
751758
if (port->membase == NULL) {
752-
release_mem_region(port->mapbase, MEN_Z135_MEM_SIZE);
759+
mcb_release_mem(mem);
753760
return -ENOMEM;
754761
}
755762

0 commit comments

Comments
 (0)