diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2012-07-09 17:52:04 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2012-07-10 15:37:33 -0400 |
commit | 4f31f5b19eb0418a847b989abc9ac22af1991fe2 (patch) | |
tree | 6a27eabb1317d5bd1518646b44ffdf71c497b3f6 /drivers/crypto | |
parent | afec8a770a6461d3e57a779484a10ef3ed0c800f (diff) |
PM / crypto / ux500: Use struct dev_pm_ops for power management
Make the ux500 crypto driver define its PM callbacks through
struct dev_pm_ops objects rather than by using legacy PM hooks
in struct platform_driver.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/ux500/cryp/cryp_core.c | 39 | ||||
-rw-r--r-- | drivers/crypto/ux500/hash/hash_core.c | 33 |
2 files changed, 34 insertions, 38 deletions
diff --git a/drivers/crypto/ux500/cryp/cryp_core.c b/drivers/crypto/ux500/cryp/cryp_core.c index 7cac12793a4b..1c307e1b840c 100644 --- a/drivers/crypto/ux500/cryp/cryp_core.c +++ b/drivers/crypto/ux500/cryp/cryp_core.c | |||
@@ -1661,27 +1661,26 @@ static void ux500_cryp_shutdown(struct platform_device *pdev) | |||
1661 | 1661 | ||
1662 | } | 1662 | } |
1663 | 1663 | ||
1664 | static int ux500_cryp_suspend(struct platform_device *pdev, pm_message_t state) | 1664 | static int ux500_cryp_suspend(struct device *dev) |
1665 | { | 1665 | { |
1666 | int ret; | 1666 | int ret; |
1667 | struct platform_device *pdev = to_platform_device(dev); | ||
1667 | struct cryp_device_data *device_data; | 1668 | struct cryp_device_data *device_data; |
1668 | struct resource *res_irq; | 1669 | struct resource *res_irq; |
1669 | struct cryp_ctx *temp_ctx = NULL; | 1670 | struct cryp_ctx *temp_ctx = NULL; |
1670 | 1671 | ||
1671 | dev_dbg(&pdev->dev, "[%s]", __func__); | 1672 | dev_dbg(dev, "[%s]", __func__); |
1672 | 1673 | ||
1673 | /* Handle state? */ | 1674 | /* Handle state? */ |
1674 | device_data = platform_get_drvdata(pdev); | 1675 | device_data = platform_get_drvdata(pdev); |
1675 | if (!device_data) { | 1676 | if (!device_data) { |
1676 | dev_err(&pdev->dev, "[%s]: platform_get_drvdata() failed!", | 1677 | dev_err(dev, "[%s]: platform_get_drvdata() failed!", __func__); |
1677 | __func__); | ||
1678 | return -ENOMEM; | 1678 | return -ENOMEM; |
1679 | } | 1679 | } |
1680 | 1680 | ||
1681 | res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 1681 | res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
1682 | if (!res_irq) | 1682 | if (!res_irq) |
1683 | dev_err(&pdev->dev, "[%s]: IORESOURCE_IRQ, unavailable", | 1683 | dev_err(dev, "[%s]: IORESOURCE_IRQ, unavailable", __func__); |
1684 | __func__); | ||
1685 | else | 1684 | else |
1686 | disable_irq(res_irq->start); | 1685 | disable_irq(res_irq->start); |
1687 | 1686 | ||
@@ -1692,32 +1691,32 @@ static int ux500_cryp_suspend(struct platform_device *pdev, pm_message_t state) | |||
1692 | 1691 | ||
1693 | if (device_data->current_ctx == ++temp_ctx) { | 1692 | if (device_data->current_ctx == ++temp_ctx) { |
1694 | if (down_interruptible(&driver_data.device_allocation)) | 1693 | if (down_interruptible(&driver_data.device_allocation)) |
1695 | dev_dbg(&pdev->dev, "[%s]: down_interruptible() " | 1694 | dev_dbg(dev, "[%s]: down_interruptible() failed", |
1696 | "failed", __func__); | 1695 | __func__); |
1697 | ret = cryp_disable_power(&pdev->dev, device_data, false); | 1696 | ret = cryp_disable_power(dev, device_data, false); |
1698 | 1697 | ||
1699 | } else | 1698 | } else |
1700 | ret = cryp_disable_power(&pdev->dev, device_data, true); | 1699 | ret = cryp_disable_power(dev, device_data, true); |
1701 | 1700 | ||
1702 | if (ret) | 1701 | if (ret) |
1703 | dev_err(&pdev->dev, "[%s]: cryp_disable_power()", __func__); | 1702 | dev_err(dev, "[%s]: cryp_disable_power()", __func__); |
1704 | 1703 | ||
1705 | return ret; | 1704 | return ret; |
1706 | } | 1705 | } |
1707 | 1706 | ||
1708 | static int ux500_cryp_resume(struct platform_device *pdev) | 1707 | static int ux500_cryp_resume(struct device *dev) |
1709 | { | 1708 | { |
1710 | int ret = 0; | 1709 | int ret = 0; |
1710 | struct platform_device *pdev = to_platform_device(dev); | ||
1711 | struct cryp_device_data *device_data; | 1711 | struct cryp_device_data *device_data; |
1712 | struct resource *res_irq; | 1712 | struct resource *res_irq; |
1713 | struct cryp_ctx *temp_ctx = NULL; | 1713 | struct cryp_ctx *temp_ctx = NULL; |
1714 | 1714 | ||
1715 | dev_dbg(&pdev->dev, "[%s]", __func__); | 1715 | dev_dbg(dev, "[%s]", __func__); |
1716 | 1716 | ||
1717 | device_data = platform_get_drvdata(pdev); | 1717 | device_data = platform_get_drvdata(pdev); |
1718 | if (!device_data) { | 1718 | if (!device_data) { |
1719 | dev_err(&pdev->dev, "[%s]: platform_get_drvdata() failed!", | 1719 | dev_err(dev, "[%s]: platform_get_drvdata() failed!", __func__); |
1720 | __func__); | ||
1721 | return -ENOMEM; | 1720 | return -ENOMEM; |
1722 | } | 1721 | } |
1723 | 1722 | ||
@@ -1730,11 +1729,10 @@ static int ux500_cryp_resume(struct platform_device *pdev) | |||
1730 | if (!device_data->current_ctx) | 1729 | if (!device_data->current_ctx) |
1731 | up(&driver_data.device_allocation); | 1730 | up(&driver_data.device_allocation); |
1732 | else | 1731 | else |
1733 | ret = cryp_enable_power(&pdev->dev, device_data, true); | 1732 | ret = cryp_enable_power(dev, device_data, true); |
1734 | 1733 | ||
1735 | if (ret) | 1734 | if (ret) |
1736 | dev_err(&pdev->dev, "[%s]: cryp_enable_power() failed!", | 1735 | dev_err(dev, "[%s]: cryp_enable_power() failed!", __func__); |
1737 | __func__); | ||
1738 | else { | 1736 | else { |
1739 | res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 1737 | res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
1740 | if (res_irq) | 1738 | if (res_irq) |
@@ -1744,15 +1742,16 @@ static int ux500_cryp_resume(struct platform_device *pdev) | |||
1744 | return ret; | 1742 | return ret; |
1745 | } | 1743 | } |
1746 | 1744 | ||
1745 | static SIMPLE_DEV_PM_OPS(ux500_cryp_pm, ux500_cryp_suspend, ux500_cryp_resume); | ||
1746 | |||
1747 | static struct platform_driver cryp_driver = { | 1747 | static struct platform_driver cryp_driver = { |
1748 | .probe = ux500_cryp_probe, | 1748 | .probe = ux500_cryp_probe, |
1749 | .remove = ux500_cryp_remove, | 1749 | .remove = ux500_cryp_remove, |
1750 | .shutdown = ux500_cryp_shutdown, | 1750 | .shutdown = ux500_cryp_shutdown, |
1751 | .suspend = ux500_cryp_suspend, | ||
1752 | .resume = ux500_cryp_resume, | ||
1753 | .driver = { | 1751 | .driver = { |
1754 | .owner = THIS_MODULE, | 1752 | .owner = THIS_MODULE, |
1755 | .name = "cryp1" | 1753 | .name = "cryp1" |
1754 | .pm = &ux500_cryp_pm, | ||
1756 | } | 1755 | } |
1757 | }; | 1756 | }; |
1758 | 1757 | ||
diff --git a/drivers/crypto/ux500/hash/hash_core.c b/drivers/crypto/ux500/hash/hash_core.c index 6dbb9ec709a3..08d5032cb564 100644 --- a/drivers/crypto/ux500/hash/hash_core.c +++ b/drivers/crypto/ux500/hash/hash_core.c | |||
@@ -1894,19 +1894,17 @@ static void ux500_hash_shutdown(struct platform_device *pdev) | |||
1894 | 1894 | ||
1895 | /** | 1895 | /** |
1896 | * ux500_hash_suspend - Function that suspends the hash device. | 1896 | * ux500_hash_suspend - Function that suspends the hash device. |
1897 | * @pdev: The platform device. | 1897 | * @dev: Device to suspend. |
1898 | * @state: - | ||
1899 | */ | 1898 | */ |
1900 | static int ux500_hash_suspend(struct platform_device *pdev, pm_message_t state) | 1899 | static int ux500_hash_suspend(struct device *dev) |
1901 | { | 1900 | { |
1902 | int ret; | 1901 | int ret; |
1903 | struct hash_device_data *device_data; | 1902 | struct hash_device_data *device_data; |
1904 | struct hash_ctx *temp_ctx = NULL; | 1903 | struct hash_ctx *temp_ctx = NULL; |
1905 | 1904 | ||
1906 | device_data = platform_get_drvdata(pdev); | 1905 | device_data = dev_get_drvdata(dev); |
1907 | if (!device_data) { | 1906 | if (!device_data) { |
1908 | dev_err(&pdev->dev, "[%s] platform_get_drvdata() failed!", | 1907 | dev_err(dev, "[%s] platform_get_drvdata() failed!", __func__); |
1909 | __func__); | ||
1910 | return -ENOMEM; | 1908 | return -ENOMEM; |
1911 | } | 1909 | } |
1912 | 1910 | ||
@@ -1917,33 +1915,32 @@ static int ux500_hash_suspend(struct platform_device *pdev, pm_message_t state) | |||
1917 | 1915 | ||
1918 | if (device_data->current_ctx == ++temp_ctx) { | 1916 | if (device_data->current_ctx == ++temp_ctx) { |
1919 | if (down_interruptible(&driver_data.device_allocation)) | 1917 | if (down_interruptible(&driver_data.device_allocation)) |
1920 | dev_dbg(&pdev->dev, "[%s]: down_interruptible() " | 1918 | dev_dbg(dev, "[%s]: down_interruptible() failed", |
1921 | "failed", __func__); | 1919 | __func__); |
1922 | ret = hash_disable_power(device_data, false); | 1920 | ret = hash_disable_power(device_data, false); |
1923 | 1921 | ||
1924 | } else | 1922 | } else |
1925 | ret = hash_disable_power(device_data, true); | 1923 | ret = hash_disable_power(device_data, true); |
1926 | 1924 | ||
1927 | if (ret) | 1925 | if (ret) |
1928 | dev_err(&pdev->dev, "[%s]: hash_disable_power()", __func__); | 1926 | dev_err(dev, "[%s]: hash_disable_power()", __func__); |
1929 | 1927 | ||
1930 | return ret; | 1928 | return ret; |
1931 | } | 1929 | } |
1932 | 1930 | ||
1933 | /** | 1931 | /** |
1934 | * ux500_hash_resume - Function that resume the hash device. | 1932 | * ux500_hash_resume - Function that resume the hash device. |
1935 | * @pdev: The platform device. | 1933 | * @dev: Device to resume. |
1936 | */ | 1934 | */ |
1937 | static int ux500_hash_resume(struct platform_device *pdev) | 1935 | static int ux500_hash_resume(struct device *dev) |
1938 | { | 1936 | { |
1939 | int ret = 0; | 1937 | int ret = 0; |
1940 | struct hash_device_data *device_data; | 1938 | struct hash_device_data *device_data; |
1941 | struct hash_ctx *temp_ctx = NULL; | 1939 | struct hash_ctx *temp_ctx = NULL; |
1942 | 1940 | ||
1943 | device_data = platform_get_drvdata(pdev); | 1941 | device_data = dev_get_drvdata(dev); |
1944 | if (!device_data) { | 1942 | if (!device_data) { |
1945 | dev_err(&pdev->dev, "[%s] platform_get_drvdata() failed!", | 1943 | dev_err(dev, "[%s] platform_get_drvdata() failed!", __func__); |
1946 | __func__); | ||
1947 | return -ENOMEM; | 1944 | return -ENOMEM; |
1948 | } | 1945 | } |
1949 | 1946 | ||
@@ -1958,21 +1955,21 @@ static int ux500_hash_resume(struct platform_device *pdev) | |||
1958 | ret = hash_enable_power(device_data, true); | 1955 | ret = hash_enable_power(device_data, true); |
1959 | 1956 | ||
1960 | if (ret) | 1957 | if (ret) |
1961 | dev_err(&pdev->dev, "[%s]: hash_enable_power() failed!", | 1958 | dev_err(dev, "[%s]: hash_enable_power() failed!", __func__); |
1962 | __func__); | ||
1963 | 1959 | ||
1964 | return ret; | 1960 | return ret; |
1965 | } | 1961 | } |
1966 | 1962 | ||
1963 | static SIMPLE_DEV_PM_OPS(ux500_hash_pm, ux500_hash_suspend, ux500_hash_resume); | ||
1964 | |||
1967 | static struct platform_driver hash_driver = { | 1965 | static struct platform_driver hash_driver = { |
1968 | .probe = ux500_hash_probe, | 1966 | .probe = ux500_hash_probe, |
1969 | .remove = ux500_hash_remove, | 1967 | .remove = ux500_hash_remove, |
1970 | .shutdown = ux500_hash_shutdown, | 1968 | .shutdown = ux500_hash_shutdown, |
1971 | .suspend = ux500_hash_suspend, | ||
1972 | .resume = ux500_hash_resume, | ||
1973 | .driver = { | 1969 | .driver = { |
1974 | .owner = THIS_MODULE, | 1970 | .owner = THIS_MODULE, |
1975 | .name = "hash1", | 1971 | .name = "hash1", |
1972 | .pm = &ux500_hash_pm, | ||
1976 | } | 1973 | } |
1977 | }; | 1974 | }; |
1978 | 1975 | ||