gpio: ml-ioh: Convert to dev_pm_ops
Convert the legacy callback .suspend() and .resume() to the generic ones. While at it, replace ifdeffery by __maybe_unused attribute. Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
This commit is contained in:
committed by
Andy Shevchenko
parent
e73f0f0ee7
commit
40bb0e3e27
@@ -155,11 +155,10 @@ static int ioh_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PM
|
|
||||||
/*
|
/*
|
||||||
* Save register configuration and disable interrupts.
|
* Save register configuration and disable interrupts.
|
||||||
*/
|
*/
|
||||||
static void ioh_gpio_save_reg_conf(struct ioh_gpio *chip)
|
static void __maybe_unused ioh_gpio_save_reg_conf(struct ioh_gpio *chip)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -185,7 +184,7 @@ static void ioh_gpio_save_reg_conf(struct ioh_gpio *chip)
|
|||||||
/*
|
/*
|
||||||
* This function restores the register configuration of the GPIO device.
|
* This function restores the register configuration of the GPIO device.
|
||||||
*/
|
*/
|
||||||
static void ioh_gpio_restore_reg_conf(struct ioh_gpio *chip)
|
static void __maybe_unused ioh_gpio_restore_reg_conf(struct ioh_gpio *chip)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -207,7 +206,6 @@ static void ioh_gpio_restore_reg_conf(struct ioh_gpio *chip)
|
|||||||
&chip->reg->ioh_sel_reg[i]);
|
&chip->reg->ioh_sel_reg[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int ioh_gpio_to_irq(struct gpio_chip *gpio, unsigned offset)
|
static int ioh_gpio_to_irq(struct gpio_chip *gpio, unsigned offset)
|
||||||
{
|
{
|
||||||
@@ -522,47 +520,23 @@ static void ioh_gpio_remove(struct pci_dev *pdev)
|
|||||||
kfree(chip);
|
kfree(chip);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PM
|
static int __maybe_unused ioh_gpio_suspend(struct device *dev)
|
||||||
static int ioh_gpio_suspend(struct pci_dev *pdev, pm_message_t state)
|
|
||||||
{
|
{
|
||||||
s32 ret;
|
struct ioh_gpio *chip = dev_get_drvdata(dev);
|
||||||
struct ioh_gpio *chip = pci_get_drvdata(pdev);
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&chip->spinlock, flags);
|
spin_lock_irqsave(&chip->spinlock, flags);
|
||||||
ioh_gpio_save_reg_conf(chip);
|
ioh_gpio_save_reg_conf(chip);
|
||||||
spin_unlock_irqrestore(&chip->spinlock, flags);
|
spin_unlock_irqrestore(&chip->spinlock, flags);
|
||||||
|
|
||||||
ret = pci_save_state(pdev);
|
|
||||||
if (ret) {
|
|
||||||
dev_err(&pdev->dev, "pci_save_state Failed-%d\n", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
pci_disable_device(pdev);
|
|
||||||
pci_set_power_state(pdev, PCI_D0);
|
|
||||||
ret = pci_enable_wake(pdev, PCI_D0, 1);
|
|
||||||
if (ret)
|
|
||||||
dev_err(&pdev->dev, "pci_enable_wake Failed -%d\n", ret);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ioh_gpio_resume(struct pci_dev *pdev)
|
static int __maybe_unused ioh_gpio_resume(struct device *dev)
|
||||||
{
|
{
|
||||||
s32 ret;
|
struct ioh_gpio *chip = dev_get_drvdata(dev);
|
||||||
struct ioh_gpio *chip = pci_get_drvdata(pdev);
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
ret = pci_enable_wake(pdev, PCI_D0, 0);
|
|
||||||
|
|
||||||
pci_set_power_state(pdev, PCI_D0);
|
|
||||||
ret = pci_enable_device(pdev);
|
|
||||||
if (ret) {
|
|
||||||
dev_err(&pdev->dev, "pci_enable_device Failed-%d ", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
pci_restore_state(pdev);
|
|
||||||
|
|
||||||
spin_lock_irqsave(&chip->spinlock, flags);
|
spin_lock_irqsave(&chip->spinlock, flags);
|
||||||
iowrite32(0x01, &chip->reg->srst);
|
iowrite32(0x01, &chip->reg->srst);
|
||||||
iowrite32(0x00, &chip->reg->srst);
|
iowrite32(0x00, &chip->reg->srst);
|
||||||
@@ -571,10 +545,8 @@ static int ioh_gpio_resume(struct pci_dev *pdev)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#define ioh_gpio_suspend NULL
|
static SIMPLE_DEV_PM_OPS(ioh_gpio_pm_ops, ioh_gpio_suspend, ioh_gpio_resume);
|
||||||
#define ioh_gpio_resume NULL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const struct pci_device_id ioh_gpio_pcidev_id[] = {
|
static const struct pci_device_id ioh_gpio_pcidev_id[] = {
|
||||||
{ PCI_DEVICE(PCI_VENDOR_ID_ROHM, 0x802E) },
|
{ PCI_DEVICE(PCI_VENDOR_ID_ROHM, 0x802E) },
|
||||||
@@ -587,8 +559,9 @@ static struct pci_driver ioh_gpio_driver = {
|
|||||||
.id_table = ioh_gpio_pcidev_id,
|
.id_table = ioh_gpio_pcidev_id,
|
||||||
.probe = ioh_gpio_probe,
|
.probe = ioh_gpio_probe,
|
||||||
.remove = ioh_gpio_remove,
|
.remove = ioh_gpio_remove,
|
||||||
.suspend = ioh_gpio_suspend,
|
.driver = {
|
||||||
.resume = ioh_gpio_resume
|
.pm = &ioh_gpio_pm_ops,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
module_pci_driver(ioh_gpio_driver);
|
module_pci_driver(ioh_gpio_driver);
|
||||||
|
|||||||
Reference in New Issue
Block a user