Commit c3f4200f authored by Jamie Iles's avatar Jamie Iles Committed by Herbert Xu

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: default avatarJamie Iles <jamie@jamieiles.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent c39cc377
...@@ -1657,25 +1657,38 @@ static struct spacc_alg l2_engine_algs[] = { ...@@ -1657,25 +1657,38 @@ static struct spacc_alg l2_engine_algs[] = {
}, },
}; };
static int __devinit spacc_probe(struct platform_device *pdev, static int __devinit spacc_probe(struct platform_device *pdev)
unsigned max_ctxs, size_t cipher_pg_sz,
size_t hash_pg_sz, size_t fifo_sz,
struct spacc_alg *algs, size_t num_algs)
{ {
int i, err, ret = -EINVAL; int i, err, ret = -EINVAL;
struct resource *mem, *irq; struct resource *mem, *irq;
const struct platform_device_id *platid = platform_get_device_id(pdev);
struct spacc_engine *engine = devm_kzalloc(&pdev->dev, sizeof(*engine), struct spacc_engine *engine = devm_kzalloc(&pdev->dev, sizeof(*engine),
GFP_KERNEL); GFP_KERNEL);
if (!engine) if (!engine)
return -ENOMEM; return -ENOMEM;
engine->max_ctxs = max_ctxs; if (!platid)
engine->cipher_pg_sz = cipher_pg_sz; return -EINVAL;
engine->hash_pg_sz = hash_pg_sz;
engine->fifo_sz = fifo_sz; if (!strcmp(platid->name, "picoxcell-ipsec")) {
engine->algs = algs; engine->max_ctxs = SPACC_CRYPTO_IPSEC_MAX_CTXS;
engine->num_algs = num_algs; engine->cipher_pg_sz = SPACC_CRYPTO_IPSEC_CIPHER_PG_SZ;
engine->name = dev_name(&pdev->dev); engine->hash_pg_sz = SPACC_CRYPTO_IPSEC_HASH_PG_SZ;
engine->fifo_sz = SPACC_CRYPTO_IPSEC_FIFO_SZ;
engine->algs = ipsec_engine_algs;
engine->num_algs = ARRAY_SIZE(ipsec_engine_algs);
} else if (!strcmp(platid->name, "picoxcell-l2")) {
engine->max_ctxs = SPACC_CRYPTO_L2_MAX_CTXS;
engine->cipher_pg_sz = SPACC_CRYPTO_L2_CIPHER_PG_SZ;
engine->hash_pg_sz = SPACC_CRYPTO_L2_HASH_PG_SZ;
engine->fifo_sz = SPACC_CRYPTO_L2_FIFO_SZ;
engine->algs = l2_engine_algs;
engine->num_algs = ARRAY_SIZE(l2_engine_algs);
} else {
return -EINVAL;
}
engine->name = dev_name(&pdev->dev);
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
...@@ -1800,72 +1813,32 @@ static int __devexit spacc_remove(struct platform_device *pdev) ...@@ -1800,72 +1813,32 @@ static int __devexit spacc_remove(struct platform_device *pdev)
return 0; return 0;
} }
static int __devinit ipsec_probe(struct platform_device *pdev) static const struct platform_device_id spacc_id_table[] = {
{ { "picochip,spacc-ipsec", },
return spacc_probe(pdev, SPACC_CRYPTO_IPSEC_MAX_CTXS, { "picochip,spacc-l2", },
SPACC_CRYPTO_IPSEC_CIPHER_PG_SZ,
SPACC_CRYPTO_IPSEC_HASH_PG_SZ,
SPACC_CRYPTO_IPSEC_FIFO_SZ, ipsec_engine_algs,
ARRAY_SIZE(ipsec_engine_algs));
}
static struct platform_driver ipsec_driver = {
.probe = ipsec_probe,
.remove = __devexit_p(spacc_remove),
.driver = {
.name = "picoxcell-ipsec",
#ifdef CONFIG_PM
.pm = &spacc_pm_ops,
#endif /* CONFIG_PM */
},
}; };
static int __devinit l2_probe(struct platform_device *pdev) static struct platform_driver spacc_driver = {
{ .probe = spacc_probe,
return spacc_probe(pdev, SPACC_CRYPTO_L2_MAX_CTXS,
SPACC_CRYPTO_L2_CIPHER_PG_SZ,
SPACC_CRYPTO_L2_HASH_PG_SZ, SPACC_CRYPTO_L2_FIFO_SZ,
l2_engine_algs, ARRAY_SIZE(l2_engine_algs));
}
static struct platform_driver l2_driver = {
.probe = l2_probe,
.remove = __devexit_p(spacc_remove), .remove = __devexit_p(spacc_remove),
.driver = { .driver = {
.name = "picoxcell-l2", .name = "picochip,spacc",
#ifdef CONFIG_PM #ifdef CONFIG_PM
.pm = &spacc_pm_ops, .pm = &spacc_pm_ops,
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
}, },
.id_table = spacc_id_table,
}; };
static int __init spacc_init(void) static int __init spacc_init(void)
{ {
int ret = platform_driver_register(&ipsec_driver); return platform_driver_register(&spacc_driver);
if (ret) {
pr_err("failed to register ipsec spacc driver");
goto out;
}
ret = platform_driver_register(&l2_driver);
if (ret) {
pr_err("failed to register l2 spacc driver");
goto l2_failed;
}
return 0;
l2_failed:
platform_driver_unregister(&ipsec_driver);
out:
return ret;
} }
module_init(spacc_init); module_init(spacc_init);
static void __exit spacc_exit(void) static void __exit spacc_exit(void)
{ {
platform_driver_unregister(&ipsec_driver); platform_driver_unregister(&spacc_driver);
platform_driver_unregister(&l2_driver);
} }
module_exit(spacc_exit); module_exit(spacc_exit);
......
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