spi: dw-pci: provide platform specific data via driver_data
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 29 Aug 2014 09:41:42 +0000 (12:41 +0300)
committerMark Brown <broonie@kernel.org>
Mon, 1 Sep 2014 10:29:03 +0000 (11:29 +0100)
Instead of checking for device and vendor IDs inside probe function let's
provide a helper function via driver_data.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-dw-pci.c

index 9e8d18cac03fbd1958df0276a47054b50cd2a52d..958bc460087736c443e4a96865b240e2878ee63d 100644 (file)
@@ -32,11 +32,19 @@ struct dw_spi_pci {
        struct dw_spi   dws;
 };
 
-static int spi_pci_probe(struct pci_dev *pdev,
-       const struct pci_device_id *ent)
+struct spi_pci_desc {
+       int     (*setup)(struct dw_spi *);
+};
+
+static struct spi_pci_desc spi_pci_mid_desc = {
+       .setup = dw_spi_mid_init,
+};
+
+static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        struct dw_spi_pci *dwpci;
        struct dw_spi *dws;
+       struct spi_pci_desc *desc = (struct spi_pci_desc *)ent->driver_data;
        int pci_bar = 0;
        int ret;
 
@@ -64,11 +72,11 @@ static int spi_pci_probe(struct pci_dev *pdev,
        dws->irq = pdev->irq;
 
        /*
-        * Specific handling for Intel MID paltforms, like dma setup,
+        * Specific handling for paltforms, like dma setup,
         * clock rate, FIFO depth.
         */
-       if (pdev->device == 0x0800) {
-               ret = dw_spi_mid_init(dws);
+       if (desc && desc->setup) {
+               ret = desc->setup(dws);
                if (ret)
                        return ret;
        }
@@ -115,7 +123,7 @@ static SIMPLE_DEV_PM_OPS(dw_spi_pm_ops, spi_suspend, spi_resume);
 
 static const struct pci_device_id pci_ids[] = {
        /* Intel MID platform SPI controller 0 */
-       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0800) },
+       { PCI_VDEVICE(INTEL, 0x0800), (kernel_ulong_t)&spi_pci_mid_desc},
        {},
 };