2013-05-29 11:53:11

by Sachin Kamat

[permalink] [raw]
Subject: [PATCH 1/4] crypto: dcp: Remove redundant platform_set_drvdata()

Commit 0998d06310 (device-core: Ensure drvdata = NULL when no
driver is bound) removes the need to set driver data field to
NULL.

Signed-off-by: Sachin Kamat <[email protected]>
Cc: Tobias Rauter <[email protected]>
---
This series compile tested against linux-next (20130529).
---
drivers/crypto/dcp.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/crypto/dcp.c b/drivers/crypto/dcp.c
index eea194c..83eaefc 100644
--- a/drivers/crypto/dcp.c
+++ b/drivers/crypto/dcp.c
@@ -876,7 +876,6 @@ static int dcp_remove(struct platform_device *pdev)
struct dcp_dev *dev;
int j;
dev = platform_get_drvdata(pdev);
- platform_set_drvdata(pdev, NULL);

dma_free_coherent(&pdev->dev,
DCP_MAX_PKG * sizeof(struct dcp_hw_packet),
--
1.7.9.5


2013-05-29 11:53:14

by Sachin Kamat

[permalink] [raw]
Subject: [PATCH 2/4] crypto: dcp: Use devm_* APIs

devm_* APIs are device managed and make cleanup and exit
code simpler.

Signed-off-by: Sachin Kamat <[email protected]>
Cc: Tobias Rauter <[email protected]>
---
drivers/crypto/dcp.c | 32 ++++++++++----------------------
1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/crypto/dcp.c b/drivers/crypto/dcp.c
index 83eaefc..9e91c2c 100644
--- a/drivers/crypto/dcp.c
+++ b/drivers/crypto/dcp.c
@@ -723,12 +723,10 @@ static int dcp_probe(struct platform_device *pdev)
struct resource *r;
int i, ret, j;

- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
- if (dev == NULL) {
- dev_err(&pdev->dev, "Failed to allocate structure\n");
- ret = -ENOMEM;
- goto err;
- }
+ dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
+ if (!dev)
+ return -ENOMEM;
+
global_dev = dev;
dev->dev = &pdev->dev;

@@ -737,11 +735,10 @@ static int dcp_probe(struct platform_device *pdev)
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!r) {
dev_err(&pdev->dev, "failed to get IORESOURCE_MEM\n");
- ret = -ENXIO;
- goto err_dev;
+ return -ENXIO;
}
- dev->dcp_regs_base = ioremap(r->start, resource_size(r));
-
+ dev->dcp_regs_base = devm_ioremap(&pdev->dev, r->start,
+ resource_size(r));

dcp_set(dev, DCP_CTRL_SFRST, DCP_REG_CTRL);
udelay(10);
@@ -762,15 +759,13 @@ static int dcp_probe(struct platform_device *pdev)
r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!r) {
dev_err(&pdev->dev, "can't get IRQ resource (0)\n");
- ret = -EIO;
- goto err_unmap_mem;
+ return -EIO;
}
dev->dcp_vmi_irq = r->start;
ret = request_irq(dev->dcp_vmi_irq, dcp_vmi_irq, 0, "dcp", dev);
if (ret != 0) {
dev_err(&pdev->dev, "can't request_irq (0)\n");
- ret = -EIO;
- goto err_unmap_mem;
+ return -EIO;
}

r = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
@@ -863,11 +858,7 @@ err_free_irq1:
free_irq(dev->dcp_irq, dev);
err_free_irq0:
free_irq(dev->dcp_vmi_irq, dev);
-err_unmap_mem:
- iounmap((void *) dev->dcp_regs_base);
-err_dev:
- kfree(dev);
-err:
+
return ret;
}

@@ -890,14 +881,11 @@ static int dcp_remove(struct platform_device *pdev)
tasklet_kill(&dev->done_task);
tasklet_kill(&dev->queue_task);

- iounmap((void *) dev->dcp_regs_base);
-
for (j = 0; j < ARRAY_SIZE(algs); j++)
crypto_unregister_alg(&algs[j]);

misc_deregister(&dev->dcp_bootstream_misc);

- kfree(dev);
return 0;
}

--
1.7.9.5

2013-05-29 11:53:16

by Sachin Kamat

[permalink] [raw]
Subject: [PATCH 3/4] crypto: dcp: Use NULL instead of 0

Use NULL instead of 0 for pointer variables.

Signed-off-by: Sachin Kamat <[email protected]>
---
drivers/crypto/dcp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/dcp.c b/drivers/crypto/dcp.c
index 9e91c2c..49dd560 100644
--- a/drivers/crypto/dcp.c
+++ b/drivers/crypto/dcp.c
@@ -408,7 +408,7 @@ static void dcp_done_task(unsigned long data)
ablkcipher_walk_complete(&dev->ctx->walk);
dev->ctx->req->base.complete(&dev->ctx->req->base,
dev->ctx->stat);
- dev->ctx->req = 0;
+ dev->ctx->req = NULL;
/* in case there are other requests in the queue */
tasklet_schedule(&dev->queue_task);
}
--
1.7.9.5

2013-05-29 11:53:18

by Sachin Kamat

[permalink] [raw]
Subject: [PATCH 4/4] crypto: dcp: Staticize local symbols

These symbols are referenced only in this file and hence
should be static.

Signed-off-by: Sachin Kamat <[email protected]>
---
drivers/crypto/dcp.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/dcp.c b/drivers/crypto/dcp.c
index 49dd560..a8a7dd4 100644
--- a/drivers/crypto/dcp.c
+++ b/drivers/crypto/dcp.c
@@ -195,7 +195,7 @@ struct dcp_hw_packet {
uint32_t stat;
};

-struct dcp_dev *global_dev;
+static struct dcp_dev *global_dev;

static inline u32 dcp_chan_reg(u32 reg, int chan)
{
@@ -227,14 +227,14 @@ static inline unsigned int dcp_read(struct dcp_dev *dev, u32 reg)
return readl(dev->dcp_regs_base + reg);
}

-void dcp_dma_unmap(struct dcp_dev *dev, struct dcp_hw_packet *pkt)
+static void dcp_dma_unmap(struct dcp_dev *dev, struct dcp_hw_packet *pkt)
{
dma_unmap_page(dev->dev, pkt->src, pkt->size, DMA_TO_DEVICE);
dma_unmap_page(dev->dev, pkt->dst, pkt->size, DMA_FROM_DEVICE);
dev_dbg(dev->dev, "unmap packet %x", (unsigned int) pkt);
}

-int dcp_dma_map(struct dcp_dev *dev,
+static int dcp_dma_map(struct dcp_dev *dev,
struct ablkcipher_walk *walk, struct dcp_hw_packet *pkt)
{
dev_dbg(dev->dev, "map packet %x", (unsigned int) pkt);
@@ -413,7 +413,7 @@ static void dcp_done_task(unsigned long data)
tasklet_schedule(&dev->queue_task);
}

-void dcp_watchdog(unsigned long data)
+static void dcp_watchdog(unsigned long data)
{
struct dcp_dev *dev = (struct dcp_dev *)data;
dev->ctx->stat |= dcp_read(dev,
--
1.7.9.5

2013-06-04 19:21:12

by Tobias Rauter

[permalink] [raw]
Subject: Re: [PATCH 1/4] crypto: dcp: Remove redundant platform_set_drvdata()

On 29.05.2013 13:39, Sachin Kamat wrote:
> Commit 0998d06310 (device-core: Ensure drvdata = NULL when no
> driver is bound) removes the need to set driver data field to
> NULL.
>
> Signed-off-by: Sachin Kamat <[email protected]>
> Cc: Tobias Rauter <[email protected]>
> ---
> This series compile tested against linux-next (20130529).

Hi!

Thank you for the corrections.

I tested this series on Freescale's evalboard with v3.10-rc4.

regards,
tr

2013-06-05 03:22:05

by Sachin Kamat

[permalink] [raw]
Subject: Re: [PATCH 1/4] crypto: dcp: Remove redundant platform_set_drvdata()

Hi Tobias,

On 5 June 2013 00:51, Tobias Rauter <[email protected]> wrote:
> On 29.05.2013 13:39, Sachin Kamat wrote:
>>
>> Commit 0998d06310 (device-core: Ensure drvdata = NULL when no
>> driver is bound) removes the need to set driver data field to
>> NULL.
>>
>> Signed-off-by: Sachin Kamat <[email protected]>
>> Cc: Tobias Rauter <[email protected]>
>> ---
>> This series compile tested against linux-next (20130529).
>
>
> Hi!
>
> Thank you for the corrections.
>
> I tested this series on Freescale's evalboard with v3.10-rc4.

Thanks for testing. Perhaps Herbert could add you to "Tested-by:"
while applying this series?


--
With warm regards,
Sachin

2013-06-05 08:54:15

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH 1/4] crypto: dcp: Remove redundant platform_set_drvdata()

On Wed, Jun 05, 2013 at 08:52:03AM +0530, Sachin Kamat wrote:
> Hi Tobias,
>
> On 5 June 2013 00:51, Tobias Rauter <[email protected]> wrote:
> > On 29.05.2013 13:39, Sachin Kamat wrote:
> >>
> >> Commit 0998d06310 (device-core: Ensure drvdata = NULL when no
> >> driver is bound) removes the need to set driver data field to
> >> NULL.
> >>
> >> Signed-off-by: Sachin Kamat <[email protected]>
> >> Cc: Tobias Rauter <[email protected]>
> >> ---
> >> This series compile tested against linux-next (20130529).
> >
> >
> > Hi!
> >
> > Thank you for the corrections.
> >
> > I tested this series on Freescale's evalboard with v3.10-rc4.
>
> Thanks for testing. Perhaps Herbert could add you to "Tested-by:"
> while applying this series?

I've added the tag. All applied. Thanks!
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt