Commit 20903169 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Darren Hart

intel_scu_ipc: Convert to use struct device *

Switch the code to use struct device * instead of struct pci_dev * since there
is no reason to access PCI related features in the driver.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarDarren Hart <dvhart@linux.intel.com>
parent b0b3f578
...@@ -92,11 +92,8 @@ static struct intel_scu_ipc_pdata_t intel_scu_ipc_tangier_pdata = { ...@@ -92,11 +92,8 @@ static struct intel_scu_ipc_pdata_t intel_scu_ipc_tangier_pdata = {
.irq_mode = 0, .irq_mode = 0,
}; };
static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id);
static void ipc_remove(struct pci_dev *pdev);
struct intel_scu_ipc_dev { struct intel_scu_ipc_dev {
struct pci_dev *pdev; struct device *dev;
void __iomem *ipc_base; void __iomem *ipc_base;
void __iomem *i2c_base; void __iomem *i2c_base;
struct completion cmd_complete; struct completion cmd_complete;
...@@ -181,7 +178,7 @@ static inline int busy_loop(struct intel_scu_ipc_dev *scu) ...@@ -181,7 +178,7 @@ static inline int busy_loop(struct intel_scu_ipc_dev *scu)
} }
if (status & BIT(0)) { if (status & BIT(0)) {
dev_err(&scu->pdev->dev, "IPC timed out"); dev_err(scu->dev, "IPC timed out");
return -ETIMEDOUT; return -ETIMEDOUT;
} }
...@@ -197,8 +194,7 @@ static inline int ipc_wait_for_interrupt(struct intel_scu_ipc_dev *scu) ...@@ -197,8 +194,7 @@ static inline int ipc_wait_for_interrupt(struct intel_scu_ipc_dev *scu)
int status; int status;
if (!wait_for_completion_timeout(&scu->cmd_complete, 3 * HZ)) { if (!wait_for_completion_timeout(&scu->cmd_complete, 3 * HZ)) {
struct device *dev = &scu->pdev->dev; dev_err(scu->dev, "IPC timed out\n");
dev_err(dev, "IPC timed out\n");
return -ETIMEDOUT; return -ETIMEDOUT;
} }
...@@ -228,7 +224,7 @@ static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id) ...@@ -228,7 +224,7 @@ static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id)
mutex_lock(&ipclock); mutex_lock(&ipclock);
if (scu->pdev == NULL) { if (scu->dev == NULL) {
mutex_unlock(&ipclock); mutex_unlock(&ipclock);
return -ENODEV; return -ENODEV;
} }
...@@ -445,7 +441,7 @@ int intel_scu_ipc_simple_command(int cmd, int sub) ...@@ -445,7 +441,7 @@ int intel_scu_ipc_simple_command(int cmd, int sub)
int err; int err;
mutex_lock(&ipclock); mutex_lock(&ipclock);
if (scu->pdev == NULL) { if (scu->dev == NULL) {
mutex_unlock(&ipclock); mutex_unlock(&ipclock);
return -ENODEV; return -ENODEV;
} }
...@@ -475,7 +471,7 @@ int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen, ...@@ -475,7 +471,7 @@ int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen,
int i, err; int i, err;
mutex_lock(&ipclock); mutex_lock(&ipclock);
if (scu->pdev == NULL) { if (scu->dev == NULL) {
mutex_unlock(&ipclock); mutex_unlock(&ipclock);
return -ENODEV; return -ENODEV;
} }
...@@ -518,7 +514,7 @@ int intel_scu_ipc_i2c_cntrl(u32 addr, u32 *data) ...@@ -518,7 +514,7 @@ int intel_scu_ipc_i2c_cntrl(u32 addr, u32 *data)
u32 cmd = 0; u32 cmd = 0;
mutex_lock(&ipclock); mutex_lock(&ipclock);
if (scu->pdev == NULL) { if (scu->dev == NULL) {
mutex_unlock(&ipclock); mutex_unlock(&ipclock);
return -ENODEV; return -ENODEV;
} }
...@@ -533,7 +529,7 @@ int intel_scu_ipc_i2c_cntrl(u32 addr, u32 *data) ...@@ -533,7 +529,7 @@ int intel_scu_ipc_i2c_cntrl(u32 addr, u32 *data)
mdelay(1); mdelay(1);
writel(addr, scu->i2c_base + IPC_I2C_CNTRL_ADDR); writel(addr, scu->i2c_base + IPC_I2C_CNTRL_ADDR);
} else { } else {
dev_err(&scu->pdev->dev, dev_err(scu->dev,
"intel_scu_ipc: I2C INVALID_CMD = 0x%x\n", cmd); "intel_scu_ipc: I2C INVALID_CMD = 0x%x\n", cmd);
mutex_unlock(&ipclock); mutex_unlock(&ipclock);
...@@ -563,42 +559,42 @@ static irqreturn_t ioc(int irq, void *dev_id) ...@@ -563,42 +559,42 @@ static irqreturn_t ioc(int irq, void *dev_id)
/** /**
* ipc_probe - probe an Intel SCU IPC * ipc_probe - probe an Intel SCU IPC
* @dev: the PCI device matching * @pdev: the PCI device matching
* @id: entry in the match table * @id: entry in the match table
* *
* Enable and install an intel SCU IPC. This appears in the PCI space * Enable and install an intel SCU IPC. This appears in the PCI space
* but uses some hard coded addresses as well. * but uses some hard coded addresses as well.
*/ */
static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id) static int ipc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{ {
int err; int err;
struct intel_scu_ipc_dev *scu = &ipcdev; struct intel_scu_ipc_dev *scu = &ipcdev;
struct intel_scu_ipc_pdata_t *pdata; struct intel_scu_ipc_pdata_t *pdata;
if (scu->pdev) /* We support only one SCU */ if (scu->dev) /* We support only one SCU */
return -EBUSY; return -EBUSY;
pdata = (struct intel_scu_ipc_pdata_t *)id->driver_data; pdata = (struct intel_scu_ipc_pdata_t *)id->driver_data;
scu->pdev = pci_dev_get(dev); scu->dev = &pdev->dev;
scu->irq_mode = pdata->irq_mode; scu->irq_mode = pdata->irq_mode;
err = pcim_enable_device(dev); err = pcim_enable_device(pdev);
if (err) if (err)
return err; return err;
err = pcim_iomap_regions(dev, 1 << 0, pci_name(dev)); err = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev));
if (err) if (err)
return err; return err;
init_completion(&scu->cmd_complete); init_completion(&scu->cmd_complete);
err = devm_request_irq(&dev->dev, dev->irq, ioc, 0, "intel_scu_ipc", err = devm_request_irq(&pdev->dev, pdev->irq, ioc, 0, "intel_scu_ipc",
scu); scu);
if (err) if (err)
return err; return err;
scu->ipc_base = pcim_iomap_table(dev)[0]; scu->ipc_base = pcim_iomap_table(pdev)[0];
scu->i2c_base = ioremap_nocache(pdata->i2c_base, pdata->i2c_len); scu->i2c_base = ioremap_nocache(pdata->i2c_base, pdata->i2c_len);
if (!scu->i2c_base) if (!scu->i2c_base)
...@@ -606,7 +602,7 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id) ...@@ -606,7 +602,7 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id)
intel_scu_devices_create(); intel_scu_devices_create();
pci_set_drvdata(dev, scu); pci_set_drvdata(pdev, scu);
return 0; return 0;
} }
...@@ -624,8 +620,7 @@ static void ipc_remove(struct pci_dev *pdev) ...@@ -624,8 +620,7 @@ static void ipc_remove(struct pci_dev *pdev)
{ {
struct intel_scu_ipc_dev *scu = pci_get_drvdata(pdev); struct intel_scu_ipc_dev *scu = pci_get_drvdata(pdev);
pci_dev_put(scu->pdev); scu->dev = NULL;
scu->pdev = NULL;
iounmap(scu->i2c_base); iounmap(scu->i2c_base);
intel_scu_devices_destroy(); intel_scu_devices_destroy();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment