pch_uart: Add MSI support
[linux-flexiantxendom0.git] / drivers / tty / serial / pch_uart.c
index f2cb750..35cb9af 100644 (file)
@@ -14,6 +14,7 @@
  *along with this program; if not, write to the Free Software
  *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
  */
+#include <linux/kernel.h>
 #include <linux/serial_reg.h>
 #include <linux/slab.h>
 #include <linux/module.h>
@@ -137,8 +138,6 @@ enum {
 #define PCH_UART_DLL           0x00
 #define PCH_UART_DLM           0x01
 
-#define DIV_ROUND(a, b)        (((a) + ((b)/2)) / (b))
-
 #define PCH_UART_IID_RLS       (PCH_UART_IIR_REI)
 #define PCH_UART_IID_RDR       (PCH_UART_IIR_RRI)
 #define PCH_UART_IID_RDR_TO    (PCH_UART_IIR_RRI | PCH_UART_IIR_TOI)
@@ -316,7 +315,7 @@ static int pch_uart_hal_set_line(struct eg20t_port *priv, int baud,
        unsigned int dll, dlm, lcr;
        int div;
 
-       div = DIV_ROUND(priv->base_baud / 16, baud);
+       div = DIV_ROUND_CLOSEST(priv->base_baud / 16, baud);
        if (div < 0 || USHRT_MAX <= div) {
                dev_err(priv->port.dev, "Invalid Baud(div=0x%x)\n", div);
                return -EINVAL;
@@ -1427,6 +1426,8 @@ static struct eg20t_port *pch_uart_init_port(struct pci_dev *pdev,
                goto init_port_hal_free;
        }
 
+       pci_enable_msi(pdev);
+
        iobase = pci_resource_start(pdev, 0);
        mapbase = pci_resource_start(pdev, 1);
        priv->mapbase = mapbase;
@@ -1483,6 +1484,8 @@ static void pch_uart_pci_remove(struct pci_dev *pdev)
        struct eg20t_port *priv;
 
        priv = (struct eg20t_port *)pci_get_drvdata(pdev);
+
+       pci_disable_msi(pdev);
        pch_uart_exit_port(priv);
        pci_disable_device(pdev);
        kfree(priv);
@@ -1566,6 +1569,7 @@ static int __devinit pch_uart_pci_probe(struct pci_dev *pdev,
        return ret;
 
 probe_disable_device:
+       pci_disable_msi(pdev);
        pci_disable_device(pdev);
 probe_error:
        return ret;