All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Linus Walleij <linus.walleij@linaro.org>,
	Alexandre Courbot <gnurou@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-serial@vger.kernel.org, linux-gpio@vger.kernel.org,
	Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Sascha Weisenberger <sascha.weisenberger@siemens.com>
Subject: [PATCH v6 07/10] serial: exar: Factor out platform hooks
Date: Fri,  9 Jun 2017 20:33:15 +0200	[thread overview]
Message-ID: <8baf62a96105a2d8f84a73f887e55f6d86b7cae4.1497033197.git.jan.kiszka@siemens.com> (raw)
In-Reply-To: <cover.1497033197.git.jan.kiszka@siemens.com>
In-Reply-To: <cover.1497033197.git.jan.kiszka@siemens.com>

This prepares the addition of IOT2040 platform support by preparing the
needed setup and rs485_config hooks.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/tty/serial/8250/8250_exar.c | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index ee4b142f3ed0..1106f1f58c77 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -63,6 +63,11 @@
 
 struct exar8250;
 
+struct exar8250_platform {
+	int (*rs485_config)(struct uart_port *, struct serial_rs485 *);
+	int (*register_gpio)(struct pci_dev *, struct uart_8250_port *);
+};
+
 /**
  * struct exar8250_board - board information
  * @num_ports: number of serial ports
@@ -196,7 +201,7 @@ static void setup_gpio(struct pci_dev *pcidev, u8 __iomem *p)
 }
 
 static void *
-xr17v35x_register_gpio(struct pci_dev *pcidev)
+__xr17v35x_register_gpio(struct pci_dev *pcidev)
 {
 	struct platform_device *pdev;
 
@@ -215,17 +220,36 @@ xr17v35x_register_gpio(struct pci_dev *pcidev)
 	return pdev;
 }
 
+static int xr17v35x_register_gpio(struct pci_dev *pcidev,
+				  struct uart_8250_port *port)
+{
+	if (pcidev->vendor == PCI_VENDOR_ID_EXAR)
+		port->port.private_data =
+			__xr17v35x_register_gpio(pcidev);
+
+	return 0;
+}
+
+static const struct exar8250_platform exar8250_default_platform = {
+	.register_gpio = xr17v35x_register_gpio,
+};
+
 static int
 pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev,
 		   struct uart_8250_port *port, int idx)
 {
 	const struct exar8250_board *board = priv->board;
+	const struct exar8250_platform *platform;
 	unsigned int offset = idx * 0x400;
 	unsigned int baud = 7812500;
 	u8 __iomem *p;
 	int ret;
 
+	platform = &exar8250_default_platform;
+
 	port->port.uartclk = baud * 16;
+	port->port.rs485_config = platform->rs485_config;
+
 	/*
 	 * Setup the uart clock for the devices on expansion slot to
 	 * half the clock speed of the main chip (which is 125MHz)
@@ -248,12 +272,10 @@ pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev,
 		/* Setup Multipurpose Input/Output pins. */
 		setup_gpio(pcidev, p);
 
-		if (pcidev->vendor == PCI_VENDOR_ID_EXAR)
-			port->port.private_data =
-				xr17v35x_register_gpio(pcidev);
+		ret = platform->register_gpio(pcidev, port);
 	}
 
-	return 0;
+	return ret;
 }
 
 static void pci_xr17v35x_exit(struct pci_dev *pcidev)
-- 
2.12.3

  parent reply	other threads:[~2017-06-09 18:33 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-09 18:33 [PATCH v6 00/10] serial/gpio: exar: Fixes and support for IOT2000 Jan Kiszka
2017-06-09 18:33 ` [PATCH v6 01/10] gpio-exar/8250-exar: Do not even instantiate a GPIO device for Commtech cards Jan Kiszka
2017-06-29 14:48   ` Greg Kroah-Hartman
2017-06-09 18:33 ` [PATCH v6 02/10] gpio-exar/8250-exar: Fix passing in of parent PCI device Jan Kiszka
2017-06-20  8:13   ` Linus Walleij
2017-06-09 18:33 ` [PATCH v6 03/10] gpio: exar: Allocate resources on behalf of the platform device Jan Kiszka
2017-06-20  8:14   ` Linus Walleij
2017-06-09 18:33 ` [PATCH v6 04/10] gpio: exar: Fix iomap request Jan Kiszka
2017-06-20  8:15   ` Linus Walleij
2017-06-09 18:33 ` [PATCH v6 05/10] gpio: exar: Fix reading of directions and values Jan Kiszka
2017-06-20  8:16   ` Linus Walleij
2017-06-09 18:33 ` [PATCH v6 06/10] gpio-exar/8250-exar: Rearrange gpiochip parenthood Jan Kiszka
2017-06-09 18:33 ` Jan Kiszka [this message]
2017-06-29 14:48   ` [PATCH v6 07/10] serial: exar: Factor out platform hooks Greg Kroah-Hartman
2017-06-09 18:33 ` [PATCH v6 08/10] platform: Accept const properties Jan Kiszka
2017-06-09 18:33 ` [PATCH v6 09/10] gpio-exar/8250-exar: Make set of exported GPIOs configurable Jan Kiszka
2017-06-09 18:33 ` [PATCH v6 10/10] serial: exar: Add support for IOT2040 device Jan Kiszka
2017-06-29 14:49   ` Greg Kroah-Hartman
2017-06-20  8:19 ` [PATCH v6 00/10] serial/gpio: exar: Fixes and support for IOT2000 Linus Walleij
2017-06-20  8:54   ` Jan Kiszka
2017-06-20 11:38     ` Linus Walleij
2017-06-21  6:29       ` Jan Kiszka
2017-06-23 20:09         ` Jan Kiszka
2017-06-29  9:51           ` Linus Walleij
2017-06-29 11:43             ` Andy Shevchenko
2017-06-29 14:49             ` Greg Kroah-Hartman
2017-06-29 22:13               ` Linus Walleij
2017-07-03  7:21                 ` [PULL] " Jan Kiszka
2017-07-03  8:10                   ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8baf62a96105a2d8f84a73f887e55f6d86b7cae4.1497033197.git.jan.kiszka@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=gnurou@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=sascha.weisenberger@siemens.com \
    --cc=sudip.mukherjee@codethink.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.