diff options
author | Jamie Iles <jamie@jamieiles.com> | 2011-08-01 12:25:17 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2011-08-10 07:00:24 -0400 |
commit | c3f4200f57c0efe05b15547f42edac0fd023da17 (patch) | |
tree | b4564834db3eaefb5e2ed012f2de0a7c92307e77 /drivers/crypto/picoxcell_crypto.c | |
parent | c39cc377f9168e24d58f82419af9595226fdc4ff (diff) |
crypto: picoxcell - convert to platform ID table
Use a platform ID table and a single platform_driver. It's neater and
makes the device tree addition easier and more consistent. Rename the
match values to be inline with what they'll be in the device tree
bindings. There aren't any current in-tree users of the existing device
names.
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Jamie Iles <jamie@jamieiles.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/picoxcell_crypto.c')
-rw-r--r-- | drivers/crypto/picoxcell_crypto.c | 93 |
1 files changed, 33 insertions, 60 deletions
diff --git a/drivers/crypto/picoxcell_crypto.c b/drivers/crypto/picoxcell_crypto.c index 230b5b8cda1f..4ffb903c5f9f 100644 --- a/drivers/crypto/picoxcell_crypto.c +++ b/drivers/crypto/picoxcell_crypto.c | |||
@@ -1657,25 +1657,38 @@ static struct spacc_alg l2_engine_algs[] = { | |||
1657 | }, | 1657 | }, |
1658 | }; | 1658 | }; |
1659 | 1659 | ||
1660 | static int __devinit spacc_probe(struct platform_device *pdev, | 1660 | static int __devinit spacc_probe(struct platform_device *pdev) |
1661 | unsigned max_ctxs, size_t cipher_pg_sz, | ||
1662 | size_t hash_pg_sz, size_t fifo_sz, | ||
1663 | struct spacc_alg *algs, size_t num_algs) | ||
1664 | { | 1661 | { |
1665 | int i, err, ret = -EINVAL; | 1662 | int i, err, ret = -EINVAL; |
1666 | struct resource *mem, *irq; | 1663 | struct resource *mem, *irq; |
1664 | const struct platform_device_id *platid = platform_get_device_id(pdev); | ||
1667 | struct spacc_engine *engine = devm_kzalloc(&pdev->dev, sizeof(*engine), | 1665 | struct spacc_engine *engine = devm_kzalloc(&pdev->dev, sizeof(*engine), |
1668 | GFP_KERNEL); | 1666 | GFP_KERNEL); |
1669 | if (!engine) | 1667 | if (!engine) |
1670 | return -ENOMEM; | 1668 | return -ENOMEM; |
1671 | 1669 | ||
1672 | engine->max_ctxs = max_ctxs; | 1670 | if (!platid) |
1673 | engine->cipher_pg_sz = cipher_pg_sz; | 1671 | return -EINVAL; |
1674 | engine->hash_pg_sz = hash_pg_sz; | 1672 | |
1675 | engine->fifo_sz = fifo_sz; | 1673 | if (!strcmp(platid->name, "picoxcell-ipsec")) { |
1676 | engine->algs = algs; | 1674 | engine->max_ctxs = SPACC_CRYPTO_IPSEC_MAX_CTXS; |
1677 | engine->num_algs = num_algs; | 1675 | engine->cipher_pg_sz = SPACC_CRYPTO_IPSEC_CIPHER_PG_SZ; |
1678 | engine->name = dev_name(&pdev->dev); | 1676 | engine->hash_pg_sz = SPACC_CRYPTO_IPSEC_HASH_PG_SZ; |
1677 | engine->fifo_sz = SPACC_CRYPTO_IPSEC_FIFO_SZ; | ||
1678 | engine->algs = ipsec_engine_algs; | ||
1679 | engine->num_algs = ARRAY_SIZE(ipsec_engine_algs); | ||
1680 | } else if (!strcmp(platid->name, "picoxcell-l2")) { | ||
1681 | engine->max_ctxs = SPACC_CRYPTO_L2_MAX_CTXS; | ||
1682 | engine->cipher_pg_sz = SPACC_CRYPTO_L2_CIPHER_PG_SZ; | ||
1683 | engine->hash_pg_sz = SPACC_CRYPTO_L2_HASH_PG_SZ; | ||
1684 | engine->fifo_sz = SPACC_CRYPTO_L2_FIFO_SZ; | ||
1685 | engine->algs = l2_engine_algs; | ||
1686 | engine->num_algs = ARRAY_SIZE(l2_engine_algs); | ||
1687 | } else { | ||
1688 | return -EINVAL; | ||
1689 | } | ||
1690 | |||
1691 | engine->name = dev_name(&pdev->dev); | ||
1679 | 1692 | ||
1680 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1693 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1681 | irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 1694 | irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
@@ -1800,72 +1813,32 @@ static int __devexit spacc_remove(struct platform_device *pdev) | |||
1800 | return 0; | 1813 | return 0; |
1801 | } | 1814 | } |
1802 | 1815 | ||
1803 | static int __devinit ipsec_probe(struct platform_device *pdev) | 1816 | static const struct platform_device_id spacc_id_table[] = { |
1804 | { | 1817 | { "picochip,spacc-ipsec", }, |
1805 | return spacc_probe(pdev, SPACC_CRYPTO_IPSEC_MAX_CTXS, | 1818 | { "picochip,spacc-l2", }, |
1806 | SPACC_CRYPTO_IPSEC_CIPHER_PG_SZ, | ||
1807 | SPACC_CRYPTO_IPSEC_HASH_PG_SZ, | ||
1808 | SPACC_CRYPTO_IPSEC_FIFO_SZ, ipsec_engine_algs, | ||
1809 | ARRAY_SIZE(ipsec_engine_algs)); | ||
1810 | } | ||
1811 | |||
1812 | static struct platform_driver ipsec_driver = { | ||
1813 | .probe = ipsec_probe, | ||
1814 | .remove = __devexit_p(spacc_remove), | ||
1815 | .driver = { | ||
1816 | .name = "picoxcell-ipsec", | ||
1817 | #ifdef CONFIG_PM | ||
1818 | .pm = &spacc_pm_ops, | ||
1819 | #endif /* CONFIG_PM */ | ||
1820 | }, | ||
1821 | }; | 1819 | }; |
1822 | 1820 | ||
1823 | static int __devinit l2_probe(struct platform_device *pdev) | 1821 | static struct platform_driver spacc_driver = { |
1824 | { | 1822 | .probe = spacc_probe, |
1825 | return spacc_probe(pdev, SPACC_CRYPTO_L2_MAX_CTXS, | ||
1826 | SPACC_CRYPTO_L2_CIPHER_PG_SZ, | ||
1827 | SPACC_CRYPTO_L2_HASH_PG_SZ, SPACC_CRYPTO_L2_FIFO_SZ, | ||
1828 | l2_engine_algs, ARRAY_SIZE(l2_engine_algs)); | ||
1829 | } | ||
1830 | |||
1831 | static struct platform_driver l2_driver = { | ||
1832 | .probe = l2_probe, | ||
1833 | .remove = __devexit_p(spacc_remove), | 1823 | .remove = __devexit_p(spacc_remove), |
1834 | .driver = { | 1824 | .driver = { |
1835 | .name = "picoxcell-l2", | 1825 | .name = "picochip,spacc", |
1836 | #ifdef CONFIG_PM | 1826 | #ifdef CONFIG_PM |
1837 | .pm = &spacc_pm_ops, | 1827 | .pm = &spacc_pm_ops, |
1838 | #endif /* CONFIG_PM */ | 1828 | #endif /* CONFIG_PM */ |
1839 | }, | 1829 | }, |
1830 | .id_table = spacc_id_table, | ||
1840 | }; | 1831 | }; |
1841 | 1832 | ||
1842 | static int __init spacc_init(void) | 1833 | static int __init spacc_init(void) |
1843 | { | 1834 | { |
1844 | int ret = platform_driver_register(&ipsec_driver); | 1835 | return platform_driver_register(&spacc_driver); |
1845 | if (ret) { | ||
1846 | pr_err("failed to register ipsec spacc driver"); | ||
1847 | goto out; | ||
1848 | } | ||
1849 | |||
1850 | ret = platform_driver_register(&l2_driver); | ||
1851 | if (ret) { | ||
1852 | pr_err("failed to register l2 spacc driver"); | ||
1853 | goto l2_failed; | ||
1854 | } | ||
1855 | |||
1856 | return 0; | ||
1857 | |||
1858 | l2_failed: | ||
1859 | platform_driver_unregister(&ipsec_driver); | ||
1860 | out: | ||
1861 | return ret; | ||
1862 | } | 1836 | } |
1863 | module_init(spacc_init); | 1837 | module_init(spacc_init); |
1864 | 1838 | ||
1865 | static void __exit spacc_exit(void) | 1839 | static void __exit spacc_exit(void) |
1866 | { | 1840 | { |
1867 | platform_driver_unregister(&ipsec_driver); | 1841 | platform_driver_unregister(&spacc_driver); |
1868 | platform_driver_unregister(&l2_driver); | ||
1869 | } | 1842 | } |
1870 | module_exit(spacc_exit); | 1843 | module_exit(spacc_exit); |
1871 | 1844 | ||