Commit 69d2884d authored by Joe Perches's avatar Joe Perches Committed by Herbert Xu

crypto: ux500 - Fix logging, make arrays const, neatening

Logging messages without newlines are possibly interleaved
with other messages.  Add terminating newlines to avoid
this.

Other miscellaneous changes:

Make arrays const to reduce data size
Add pr_fmt to prefix pr_<level>, remove now unused DEV_DBG_NAME
Coalesce formats, align arguments
Remove unnecessary OOM messages as dump_stack is already done
Remove unnecessary cast of void *
Change kzalloc(sizeof(struct)...) to kzalloc(sizeof(*var), ...)
Reduce indents in struct definitions
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 997ad290
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
* License terms: GNU General Public License (GPL) version 2 * License terms: GNU General Public License (GPL) version 2
*/ */
#define pr_fmt(fmt) "hashX hashX: " fmt
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/err.h> #include <linux/err.h>
...@@ -35,8 +37,6 @@ ...@@ -35,8 +37,6 @@
#include "hash_alg.h" #include "hash_alg.h"
#define DEV_DBG_NAME "hashX hashX:"
static int hash_mode; static int hash_mode;
module_param(hash_mode, int, 0); module_param(hash_mode, int, 0);
MODULE_PARM_DESC(hash_mode, "CPU or DMA mode. CPU = 0 (default), DMA = 1"); MODULE_PARM_DESC(hash_mode, "CPU or DMA mode. CPU = 0 (default), DMA = 1");
...@@ -44,13 +44,13 @@ MODULE_PARM_DESC(hash_mode, "CPU or DMA mode. CPU = 0 (default), DMA = 1"); ...@@ -44,13 +44,13 @@ MODULE_PARM_DESC(hash_mode, "CPU or DMA mode. CPU = 0 (default), DMA = 1");
/** /**
* Pre-calculated empty message digests. * Pre-calculated empty message digests.
*/ */
static u8 zero_message_hash_sha1[SHA1_DIGEST_SIZE] = { static const u8 zero_message_hash_sha1[SHA1_DIGEST_SIZE] = {
0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d,
0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90,
0xaf, 0xd8, 0x07, 0x09 0xaf, 0xd8, 0x07, 0x09
}; };
static u8 zero_message_hash_sha256[SHA256_DIGEST_SIZE] = { static const u8 zero_message_hash_sha256[SHA256_DIGEST_SIZE] = {
0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14,
0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24,
0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c,
...@@ -58,14 +58,14 @@ static u8 zero_message_hash_sha256[SHA256_DIGEST_SIZE] = { ...@@ -58,14 +58,14 @@ static u8 zero_message_hash_sha256[SHA256_DIGEST_SIZE] = {
}; };
/* HMAC-SHA1, no key */ /* HMAC-SHA1, no key */
static u8 zero_message_hmac_sha1[SHA1_DIGEST_SIZE] = { static const u8 zero_message_hmac_sha1[SHA1_DIGEST_SIZE] = {
0xfb, 0xdb, 0x1d, 0x1b, 0x18, 0xaa, 0x6c, 0x08, 0xfb, 0xdb, 0x1d, 0x1b, 0x18, 0xaa, 0x6c, 0x08,
0x32, 0x4b, 0x7d, 0x64, 0xb7, 0x1f, 0xb7, 0x63, 0x32, 0x4b, 0x7d, 0x64, 0xb7, 0x1f, 0xb7, 0x63,
0x70, 0x69, 0x0e, 0x1d 0x70, 0x69, 0x0e, 0x1d
}; };
/* HMAC-SHA256, no key */ /* HMAC-SHA256, no key */
static u8 zero_message_hmac_sha256[SHA256_DIGEST_SIZE] = { static const u8 zero_message_hmac_sha256[SHA256_DIGEST_SIZE] = {
0xb6, 0x13, 0x67, 0x9a, 0x08, 0x14, 0xd9, 0xec, 0xb6, 0x13, 0x67, 0x9a, 0x08, 0x14, 0xd9, 0xec,
0x77, 0x2f, 0x95, 0xd7, 0x78, 0xc3, 0x5f, 0xc5, 0x77, 0x2f, 0x95, 0xd7, 0x78, 0xc3, 0x5f, 0xc5,
0xff, 0x16, 0x97, 0xc4, 0x93, 0x71, 0x56, 0x53, 0xff, 0x16, 0x97, 0xc4, 0x93, 0x71, 0x56, 0x53,
...@@ -145,7 +145,7 @@ static void hash_dma_setup_channel(struct hash_device_data *device_data, ...@@ -145,7 +145,7 @@ static void hash_dma_setup_channel(struct hash_device_data *device_data,
static void hash_dma_callback(void *data) static void hash_dma_callback(void *data)
{ {
struct hash_ctx *ctx = (struct hash_ctx *) data; struct hash_ctx *ctx = data;
complete(&ctx->device->dma.complete); complete(&ctx->device->dma.complete);
} }
...@@ -158,7 +158,7 @@ static int hash_set_dma_transfer(struct hash_ctx *ctx, struct scatterlist *sg, ...@@ -158,7 +158,7 @@ static int hash_set_dma_transfer(struct hash_ctx *ctx, struct scatterlist *sg,
dma_cookie_t cookie; dma_cookie_t cookie;
if (direction != DMA_TO_DEVICE) { if (direction != DMA_TO_DEVICE) {
dev_err(ctx->device->dev, "[%s] Invalid DMA direction", dev_err(ctx->device->dev, "%s: Invalid DMA direction\n",
__func__); __func__);
return -EFAULT; return -EFAULT;
} }
...@@ -172,20 +172,19 @@ static int hash_set_dma_transfer(struct hash_ctx *ctx, struct scatterlist *sg, ...@@ -172,20 +172,19 @@ static int hash_set_dma_transfer(struct hash_ctx *ctx, struct scatterlist *sg,
direction); direction);
if (!ctx->device->dma.sg_len) { if (!ctx->device->dma.sg_len) {
dev_err(ctx->device->dev, dev_err(ctx->device->dev, "%s: Could not map the sg list (TO_DEVICE)\n",
"[%s]: Could not map the sg list (TO_DEVICE)",
__func__); __func__);
return -EFAULT; return -EFAULT;
} }
dev_dbg(ctx->device->dev, "[%s]: Setting up DMA for buffer " dev_dbg(ctx->device->dev, "%s: Setting up DMA for buffer (TO_DEVICE)\n",
"(TO_DEVICE)", __func__); __func__);
desc = dmaengine_prep_slave_sg(channel, desc = dmaengine_prep_slave_sg(channel,
ctx->device->dma.sg, ctx->device->dma.sg_len, ctx->device->dma.sg, ctx->device->dma.sg_len,
direction, DMA_CTRL_ACK | DMA_PREP_INTERRUPT); direction, DMA_CTRL_ACK | DMA_PREP_INTERRUPT);
if (!desc) { if (!desc) {
dev_err(ctx->device->dev, dev_err(ctx->device->dev,
"[%s]: device_prep_slave_sg() failed!", __func__); "%s: device_prep_slave_sg() failed!\n", __func__);
return -EFAULT; return -EFAULT;
} }
...@@ -206,7 +205,6 @@ static void hash_dma_done(struct hash_ctx *ctx) ...@@ -206,7 +205,6 @@ static void hash_dma_done(struct hash_ctx *ctx)
dmaengine_device_control(chan, DMA_TERMINATE_ALL, 0); dmaengine_device_control(chan, DMA_TERMINATE_ALL, 0);
dma_unmap_sg(chan->device->dev, ctx->device->dma.sg, dma_unmap_sg(chan->device->dev, ctx->device->dma.sg,
ctx->device->dma.sg_len, DMA_TO_DEVICE); ctx->device->dma.sg_len, DMA_TO_DEVICE);
} }
static int hash_dma_write(struct hash_ctx *ctx, static int hash_dma_write(struct hash_ctx *ctx,
...@@ -214,8 +212,8 @@ static int hash_dma_write(struct hash_ctx *ctx, ...@@ -214,8 +212,8 @@ static int hash_dma_write(struct hash_ctx *ctx,
{ {
int error = hash_set_dma_transfer(ctx, sg, len, DMA_TO_DEVICE); int error = hash_set_dma_transfer(ctx, sg, len, DMA_TO_DEVICE);
if (error) { if (error) {
dev_dbg(ctx->device->dev, "[%s]: hash_set_dma_transfer() " dev_dbg(ctx->device->dev,
"failed", __func__); "%s: hash_set_dma_transfer() failed\n", __func__);
return error; return error;
} }
...@@ -255,9 +253,8 @@ static int get_empty_message_digest( ...@@ -255,9 +253,8 @@ static int get_empty_message_digest(
*zero_hash_size = SHA256_DIGEST_SIZE; *zero_hash_size = SHA256_DIGEST_SIZE;
*zero_digest = true; *zero_digest = true;
} else { } else {
dev_err(device_data->dev, "[%s] " dev_err(device_data->dev, "%s: Incorrect algorithm!\n",
"Incorrect algorithm!" __func__);
, __func__);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
...@@ -274,15 +271,14 @@ static int get_empty_message_digest( ...@@ -274,15 +271,14 @@ static int get_empty_message_digest(
*zero_hash_size = SHA256_DIGEST_SIZE; *zero_hash_size = SHA256_DIGEST_SIZE;
*zero_digest = true; *zero_digest = true;
} else { } else {
dev_err(device_data->dev, "[%s] " dev_err(device_data->dev, "%s: Incorrect algorithm!\n",
"Incorrect algorithm!" __func__);
, __func__);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
} else { } else {
dev_dbg(device_data->dev, "[%s] Continue hash " dev_dbg(device_data->dev,
"calculation, since hmac key avalable", "%s: Continue hash calculation, since hmac key available\n",
__func__); __func__);
} }
} }
...@@ -299,8 +295,7 @@ static int get_empty_message_digest( ...@@ -299,8 +295,7 @@ static int get_empty_message_digest(
* This function request for disabling power (regulator) and clock, * This function request for disabling power (regulator) and clock,
* and could also save current hw state. * and could also save current hw state.
*/ */
static int hash_disable_power( static int hash_disable_power(struct hash_device_data *device_data,
struct hash_device_data *device_data,
bool save_device_state) bool save_device_state)
{ {
int ret = 0; int ret = 0;
...@@ -319,7 +314,7 @@ static int hash_disable_power( ...@@ -319,7 +314,7 @@ static int hash_disable_power(
clk_disable(device_data->clk); clk_disable(device_data->clk);
ret = regulator_disable(device_data->regulator); ret = regulator_disable(device_data->regulator);
if (ret) if (ret)
dev_err(dev, "[%s] regulator_disable() failed!", __func__); dev_err(dev, "%s: regulator_disable() failed!\n", __func__);
device_data->power_state = false; device_data->power_state = false;
...@@ -337,8 +332,7 @@ static int hash_disable_power( ...@@ -337,8 +332,7 @@ static int hash_disable_power(
* This function request for enabling power (regulator) and clock, * This function request for enabling power (regulator) and clock,
* and could also restore a previously saved hw state. * and could also restore a previously saved hw state.
*/ */
static int hash_enable_power( static int hash_enable_power(struct hash_device_data *device_data,
struct hash_device_data *device_data,
bool restore_device_state) bool restore_device_state)
{ {
int ret = 0; int ret = 0;
...@@ -348,14 +342,13 @@ static int hash_enable_power( ...@@ -348,14 +342,13 @@ static int hash_enable_power(
if (!device_data->power_state) { if (!device_data->power_state) {
ret = regulator_enable(device_data->regulator); ret = regulator_enable(device_data->regulator);
if (ret) { if (ret) {
dev_err(dev, "[%s]: regulator_enable() failed!", dev_err(dev, "%s: regulator_enable() failed!\n",
__func__); __func__);
goto out; goto out;
} }
ret = clk_enable(device_data->clk); ret = clk_enable(device_data->clk);
if (ret) { if (ret) {
dev_err(dev, "[%s]: clk_enable() failed!", dev_err(dev, "%s: clk_enable() failed!\n", __func__);
__func__);
ret = regulator_disable( ret = regulator_disable(
device_data->regulator); device_data->regulator);
goto out; goto out;
...@@ -366,8 +359,7 @@ static int hash_enable_power( ...@@ -366,8 +359,7 @@ static int hash_enable_power(
if (device_data->restore_dev_state) { if (device_data->restore_dev_state) {
if (restore_device_state) { if (restore_device_state) {
device_data->restore_dev_state = false; device_data->restore_dev_state = false;
hash_resume_state(device_data, hash_resume_state(device_data, &device_data->state);
&device_data->state);
} }
} }
out: out:
...@@ -497,8 +489,8 @@ static int init_hash_hw(struct hash_device_data *device_data, ...@@ -497,8 +489,8 @@ static int init_hash_hw(struct hash_device_data *device_data,
ret = hash_setconfiguration(device_data, &ctx->config); ret = hash_setconfiguration(device_data, &ctx->config);
if (ret) { if (ret) {
dev_err(device_data->dev, "[%s] hash_setconfiguration() " dev_err(device_data->dev, "%s: hash_setconfiguration() failed!\n",
"failed!", __func__); __func__);
return ret; return ret;
} }
...@@ -528,9 +520,8 @@ static int hash_get_nents(struct scatterlist *sg, int size, bool *aligned) ...@@ -528,9 +520,8 @@ static int hash_get_nents(struct scatterlist *sg, int size, bool *aligned)
size -= sg->length; size -= sg->length;
/* hash_set_dma_transfer will align last nent */ /* hash_set_dma_transfer will align last nent */
if ((aligned && !IS_ALIGNED(sg->offset, HASH_DMA_ALIGN_SIZE)) if ((aligned && !IS_ALIGNED(sg->offset, HASH_DMA_ALIGN_SIZE)) ||
|| (!IS_ALIGNED(sg->length, HASH_DMA_ALIGN_SIZE) && (!IS_ALIGNED(sg->length, HASH_DMA_ALIGN_SIZE) && size > 0))
size > 0))
aligned_data = false; aligned_data = false;
sg = sg_next(sg); sg = sg_next(sg);
...@@ -585,20 +576,16 @@ static int hash_init(struct ahash_request *req) ...@@ -585,20 +576,16 @@ static int hash_init(struct ahash_request *req)
if (req->nbytes < HASH_DMA_ALIGN_SIZE) { if (req->nbytes < HASH_DMA_ALIGN_SIZE) {
req_ctx->dma_mode = false; /* Don't use DMA */ req_ctx->dma_mode = false; /* Don't use DMA */
pr_debug(DEV_DBG_NAME " [%s] DMA mode, but direct " pr_debug("%s: DMA mode, but direct to CPU mode for data size < %d\n",
"to CPU mode for data size < %d",
__func__, HASH_DMA_ALIGN_SIZE); __func__, HASH_DMA_ALIGN_SIZE);
} else { } else {
if (req->nbytes >= HASH_DMA_PERFORMANCE_MIN_SIZE && if (req->nbytes >= HASH_DMA_PERFORMANCE_MIN_SIZE &&
hash_dma_valid_data(req->src, hash_dma_valid_data(req->src, req->nbytes)) {
req->nbytes)) {
req_ctx->dma_mode = true; req_ctx->dma_mode = true;
} else { } else {
req_ctx->dma_mode = false; req_ctx->dma_mode = false;
pr_debug(DEV_DBG_NAME " [%s] DMA mode, but use" pr_debug("%s: DMA mode, but use CPU mode for datalength < %d or non-aligned data, except in last nent\n",
" CPU mode for datalength < %d" __func__,
" or non-aligned data, except "
"in last nent", __func__,
HASH_DMA_PERFORMANCE_MIN_SIZE); HASH_DMA_PERFORMANCE_MIN_SIZE);
} }
} }
...@@ -614,8 +601,7 @@ static int hash_init(struct ahash_request *req) ...@@ -614,8 +601,7 @@ static int hash_init(struct ahash_request *req)
* the HASH hardware. * the HASH hardware.
* *
*/ */
static void hash_processblock( static void hash_processblock(struct hash_device_data *device_data,
struct hash_device_data *device_data,
const u32 *message, int length) const u32 *message, int length)
{ {
int len = length / HASH_BYTES_PER_WORD; int len = length / HASH_BYTES_PER_WORD;
...@@ -666,15 +652,13 @@ static void hash_messagepad(struct hash_device_data *device_data, ...@@ -666,15 +652,13 @@ static void hash_messagepad(struct hash_device_data *device_data,
/* num_of_bytes == 0 => NBLW <- 0 (32 bits valid in DATAIN) */ /* num_of_bytes == 0 => NBLW <- 0 (32 bits valid in DATAIN) */
HASH_SET_NBLW(index_bytes * 8); HASH_SET_NBLW(index_bytes * 8);
dev_dbg(device_data->dev, "[%s] DIN=0x%08x NBLW=%d", __func__, dev_dbg(device_data->dev, "%s: DIN=0x%08x NBLW=%lu\n",
readl_relaxed(&device_data->base->din), __func__, readl_relaxed(&device_data->base->din),
(int)(readl_relaxed(&device_data->base->str) & readl_relaxed(&device_data->base->str) & HASH_STR_NBLW_MASK);
HASH_STR_NBLW_MASK));
HASH_SET_DCAL; HASH_SET_DCAL;
dev_dbg(device_data->dev, "[%s] after dcal -> DIN=0x%08x NBLW=%d", dev_dbg(device_data->dev, "%s: after dcal -> DIN=0x%08x NBLW=%lu\n",
__func__, readl_relaxed(&device_data->base->din), __func__, readl_relaxed(&device_data->base->din),
(int)(readl_relaxed(&device_data->base->str) & readl_relaxed(&device_data->base->str) & HASH_STR_NBLW_MASK);
HASH_STR_NBLW_MASK));
while (readl(&device_data->base->str) & HASH_STR_DCAL_MASK) while (readl(&device_data->base->str) & HASH_STR_DCAL_MASK)
cpu_relax(); cpu_relax();
...@@ -731,7 +715,7 @@ int hash_setconfiguration(struct hash_device_data *device_data, ...@@ -731,7 +715,7 @@ int hash_setconfiguration(struct hash_device_data *device_data,
break; break;
default: default:
dev_err(device_data->dev, "[%s] Incorrect algorithm.", dev_err(device_data->dev, "%s: Incorrect algorithm\n",
__func__); __func__);
return -EPERM; return -EPERM;
} }
...@@ -744,22 +728,21 @@ int hash_setconfiguration(struct hash_device_data *device_data, ...@@ -744,22 +728,21 @@ int hash_setconfiguration(struct hash_device_data *device_data,
HASH_CLEAR_BITS(&device_data->base->cr, HASH_CLEAR_BITS(&device_data->base->cr,
HASH_CR_MODE_MASK); HASH_CR_MODE_MASK);
else if (HASH_OPER_MODE_HMAC == config->oper_mode) { else if (HASH_OPER_MODE_HMAC == config->oper_mode) {
HASH_SET_BITS(&device_data->base->cr, HASH_SET_BITS(&device_data->base->cr, HASH_CR_MODE_MASK);
HASH_CR_MODE_MASK);
if (device_data->current_ctx->keylen > HASH_BLOCK_SIZE) { if (device_data->current_ctx->keylen > HASH_BLOCK_SIZE) {
/* Truncate key to blocksize */ /* Truncate key to blocksize */
dev_dbg(device_data->dev, "[%s] LKEY set", __func__); dev_dbg(device_data->dev, "%s: LKEY set\n", __func__);
HASH_SET_BITS(&device_data->base->cr, HASH_SET_BITS(&device_data->base->cr,
HASH_CR_LKEY_MASK); HASH_CR_LKEY_MASK);
} else { } else {
dev_dbg(device_data->dev, "[%s] LKEY cleared", dev_dbg(device_data->dev, "%s: LKEY cleared\n",
__func__); __func__);
HASH_CLEAR_BITS(&device_data->base->cr, HASH_CLEAR_BITS(&device_data->base->cr,
HASH_CR_LKEY_MASK); HASH_CR_LKEY_MASK);
} }
} else { /* Wrong hash mode */ } else { /* Wrong hash mode */
ret = -EPERM; ret = -EPERM;
dev_err(device_data->dev, "[%s] HASH_INVALID_PARAMETER!", dev_err(device_data->dev, "%s: HASH_INVALID_PARAMETER!\n",
__func__); __func__);
} }
return ret; return ret;
...@@ -794,7 +777,8 @@ void hash_begin(struct hash_device_data *device_data, struct hash_ctx *ctx) ...@@ -794,7 +777,8 @@ void hash_begin(struct hash_device_data *device_data, struct hash_ctx *ctx)
static int hash_process_data(struct hash_device_data *device_data, static int hash_process_data(struct hash_device_data *device_data,
struct hash_ctx *ctx, struct hash_req_ctx *req_ctx, struct hash_ctx *ctx, struct hash_req_ctx *req_ctx,
int msg_length, u8 *data_buffer, u8 *buffer, u8 *index) int msg_length, u8 *data_buffer, u8 *buffer,
u8 *index)
{ {
int ret = 0; int ret = 0;
u32 count; u32 count;
...@@ -809,24 +793,23 @@ static int hash_process_data(struct hash_device_data *device_data, ...@@ -809,24 +793,23 @@ static int hash_process_data(struct hash_device_data *device_data,
msg_length = 0; msg_length = 0;
} else { } else {
if (req_ctx->updated) { if (req_ctx->updated) {
ret = hash_resume_state(device_data, ret = hash_resume_state(device_data,
&device_data->state); &device_data->state);
memmove(req_ctx->state.buffer, memmove(req_ctx->state.buffer,
device_data->state.buffer, device_data->state.buffer,
HASH_BLOCK_SIZE / sizeof(u32)); HASH_BLOCK_SIZE / sizeof(u32));
if (ret) { if (ret) {
dev_err(device_data->dev, "[%s] " dev_err(device_data->dev,
"hash_resume_state()" "%s: hash_resume_state() failed!\n",
" failed!", __func__); __func__);
goto out; goto out;
} }
} else { } else {
ret = init_hash_hw(device_data, ctx); ret = init_hash_hw(device_data, ctx);
if (ret) { if (ret) {
dev_err(device_data->dev, "[%s] " dev_err(device_data->dev,
"init_hash_hw()" "%s: init_hash_hw() failed!\n",
" failed!", __func__); __func__);
goto out; goto out;
} }
req_ctx->updated = 1; req_ctx->updated = 1;
...@@ -838,15 +821,14 @@ static int hash_process_data(struct hash_device_data *device_data, ...@@ -838,15 +821,14 @@ static int hash_process_data(struct hash_device_data *device_data,
* HW peripheral, otherwise we first copy data * HW peripheral, otherwise we first copy data
* to a local buffer * to a local buffer
*/ */
if ((0 == (((u32)data_buffer) % 4)) if ((0 == (((u32)data_buffer) % 4)) &&
&& (0 == *index)) (0 == *index))
hash_processblock(device_data, hash_processblock(device_data,
(const u32 *) (const u32 *)data_buffer,
data_buffer, HASH_BLOCK_SIZE); HASH_BLOCK_SIZE);
else { else {
for (count = 0; count < for (count = 0;
(u32)(HASH_BLOCK_SIZE - count < (u32)(HASH_BLOCK_SIZE - *index);
*index);
count++) { count++) {
buffer[*index + count] = buffer[*index + count] =
*(data_buffer + count); *(data_buffer + count);
...@@ -868,9 +850,8 @@ static int hash_process_data(struct hash_device_data *device_data, ...@@ -868,9 +850,8 @@ static int hash_process_data(struct hash_device_data *device_data,
req_ctx->state.buffer, req_ctx->state.buffer,
HASH_BLOCK_SIZE / sizeof(u32)); HASH_BLOCK_SIZE / sizeof(u32));
if (ret) { if (ret) {
dev_err(device_data->dev, "[%s] " dev_err(device_data->dev, "%s: hash_save_state() failed!\n",
"hash_save_state()" __func__);
" failed!", __func__);
goto out; goto out;
} }
} }
...@@ -898,24 +879,23 @@ static int hash_dma_final(struct ahash_request *req) ...@@ -898,24 +879,23 @@ static int hash_dma_final(struct ahash_request *req)
if (ret) if (ret)
return ret; return ret;
dev_dbg(device_data->dev, "[%s] (ctx=0x%x)!", __func__, (u32) ctx); dev_dbg(device_data->dev, "%s: (ctx=0x%x)!\n", __func__, (u32) ctx);
if (req_ctx->updated) { if (req_ctx->updated) {
ret = hash_resume_state(device_data, &device_data->state); ret = hash_resume_state(device_data, &device_data->state);
if (ret) { if (ret) {
dev_err(device_data->dev, "[%s] hash_resume_state() " dev_err(device_data->dev, "%s: hash_resume_state() failed!\n",
"failed!", __func__); __func__);
goto out; goto out;
} }
} }
if (!req_ctx->updated) { if (!req_ctx->updated) {
ret = hash_setconfiguration(device_data, &ctx->config); ret = hash_setconfiguration(device_data, &ctx->config);
if (ret) { if (ret) {
dev_err(device_data->dev, "[%s] " dev_err(device_data->dev,
"hash_setconfiguration() failed!", "%s: hash_setconfiguration() failed!\n",
__func__); __func__);
goto out; goto out;
} }
...@@ -944,16 +924,16 @@ static int hash_dma_final(struct ahash_request *req) ...@@ -944,16 +924,16 @@ static int hash_dma_final(struct ahash_request *req)
/* Store the nents in the dma struct. */ /* Store the nents in the dma struct. */
ctx->device->dma.nents = hash_get_nents(req->src, req->nbytes, NULL); ctx->device->dma.nents = hash_get_nents(req->src, req->nbytes, NULL);
if (!ctx->device->dma.nents) { if (!ctx->device->dma.nents) {
dev_err(device_data->dev, "[%s] " dev_err(device_data->dev, "%s: ctx->device->dma.nents = 0\n",
"ctx->device->dma.nents = 0", __func__); __func__);
ret = ctx->device->dma.nents; ret = ctx->device->dma.nents;
goto out; goto out;
} }
bytes_written = hash_dma_write(ctx, req->src, req->nbytes); bytes_written = hash_dma_write(ctx, req->src, req->nbytes);
if (bytes_written != req->nbytes) { if (bytes_written != req->nbytes) {
dev_err(device_data->dev, "[%s] " dev_err(device_data->dev, "%s: hash_dma_write() failed!\n",
"hash_dma_write() failed!", __func__); __func__);
ret = bytes_written; ret = bytes_written;
goto out; goto out;
} }
...@@ -968,8 +948,8 @@ static int hash_dma_final(struct ahash_request *req) ...@@ -968,8 +948,8 @@ static int hash_dma_final(struct ahash_request *req)
unsigned int keylen = ctx->keylen; unsigned int keylen = ctx->keylen;
u8 *key = ctx->key; u8 *key = ctx->key;
dev_dbg(device_data->dev, "[%s] keylen: %d", __func__, dev_dbg(device_data->dev, "%s: keylen: %d\n",
ctx->keylen); __func__, ctx->keylen);
hash_hw_write_key(device_data, key, keylen); hash_hw_write_key(device_data, key, keylen);
} }
...@@ -1004,14 +984,14 @@ static int hash_hw_final(struct ahash_request *req) ...@@ -1004,14 +984,14 @@ static int hash_hw_final(struct ahash_request *req)
if (ret) if (ret)
return ret; return ret;
dev_dbg(device_data->dev, "[%s] (ctx=0x%x)!", __func__, (u32) ctx); dev_dbg(device_data->dev, "%s: (ctx=0x%x)!\n", __func__, (u32) ctx);
if (req_ctx->updated) { if (req_ctx->updated) {
ret = hash_resume_state(device_data, &device_data->state); ret = hash_resume_state(device_data, &device_data->state);
if (ret) { if (ret) {
dev_err(device_data->dev, "[%s] hash_resume_state() " dev_err(device_data->dev,
"failed!", __func__); "%s: hash_resume_state() failed!\n", __func__);
goto out; goto out;
} }
} else if (req->nbytes == 0 && ctx->keylen == 0) { } else if (req->nbytes == 0 && ctx->keylen == 0) {
...@@ -1029,27 +1009,29 @@ static int hash_hw_final(struct ahash_request *req) ...@@ -1029,27 +1009,29 @@ static int hash_hw_final(struct ahash_request *req)
memcpy(req->result, &zero_hash[0], ctx->digestsize); memcpy(req->result, &zero_hash[0], ctx->digestsize);
goto out; goto out;
} else if (!ret && !zero_digest) { } else if (!ret && !zero_digest) {
dev_dbg(device_data->dev, "[%s] HMAC zero msg with " dev_dbg(device_data->dev,
"key, continue...", __func__); "%s: HMAC zero msg with key, continue...\n",
__func__);
} else { } else {
dev_err(device_data->dev, "[%s] ret=%d, or wrong " dev_err(device_data->dev,
"digest size? %s", __func__, ret, "%s: ret=%d, or wrong digest size? %s\n",
(zero_hash_size == ctx->digestsize) ? __func__, ret,
zero_hash_size == ctx->digestsize ?
"true" : "false"); "true" : "false");
/* Return error */ /* Return error */
goto out; goto out;
} }
} else if (req->nbytes == 0 && ctx->keylen > 0) { } else if (req->nbytes == 0 && ctx->keylen > 0) {
dev_err(device_data->dev, "[%s] Empty message with " dev_err(device_data->dev, "%s: Empty message with keylength > 0, NOT supported\n",
"keylength > 0, NOT supported.", __func__); __func__);
goto out; goto out;
} }
if (!req_ctx->updated) { if (!req_ctx->updated) {
ret = init_hash_hw(device_data, ctx); ret = init_hash_hw(device_data, ctx);
if (ret) { if (ret) {
dev_err(device_data->dev, "[%s] init_hash_hw() " dev_err(device_data->dev,
"failed!", __func__); "%s: init_hash_hw() failed!\n", __func__);
goto out; goto out;
} }
} }
...@@ -1067,8 +1049,8 @@ static int hash_hw_final(struct ahash_request *req) ...@@ -1067,8 +1049,8 @@ static int hash_hw_final(struct ahash_request *req)
unsigned int keylen = ctx->keylen; unsigned int keylen = ctx->keylen;
u8 *key = ctx->key; u8 *key = ctx->key;
dev_dbg(device_data->dev, "[%s] keylen: %d", __func__, dev_dbg(device_data->dev, "%s: keylen: %d\n",
ctx->keylen); __func__, ctx->keylen);
hash_hw_write_key(device_data, key, keylen); hash_hw_write_key(device_data, key, keylen);
} }
...@@ -1115,10 +1097,8 @@ int hash_hw_update(struct ahash_request *req) ...@@ -1115,10 +1097,8 @@ int hash_hw_update(struct ahash_request *req)
/* Check if ctx->state.length + msg_length /* Check if ctx->state.length + msg_length
overflows */ overflows */
if (msg_length > (req_ctx->state.length.low_word + msg_length) && if (msg_length > (req_ctx->state.length.low_word + msg_length) &&
HASH_HIGH_WORD_MAX_VAL == HASH_HIGH_WORD_MAX_VAL == req_ctx->state.length.high_word) {
req_ctx->state.length.high_word) { pr_err("%s: HASH_MSG_LENGTH_OVERFLOW!\n", __func__);
pr_err(DEV_DBG_NAME " [%s] HASH_MSG_LENGTH_OVERFLOW!",
__func__);
return -EPERM; return -EPERM;
} }
...@@ -1133,8 +1113,8 @@ int hash_hw_update(struct ahash_request *req) ...@@ -1133,8 +1113,8 @@ int hash_hw_update(struct ahash_request *req)
data_buffer, buffer, &index); data_buffer, buffer, &index);
if (ret) { if (ret) {
dev_err(device_data->dev, "[%s] hash_internal_hw_" dev_err(device_data->dev, "%s: hash_internal_hw_update() failed!\n",
"update() failed!", __func__); __func__);
goto out; goto out;
} }
...@@ -1142,9 +1122,8 @@ int hash_hw_update(struct ahash_request *req) ...@@ -1142,9 +1122,8 @@ int hash_hw_update(struct ahash_request *req)
} }
req_ctx->state.index = index; req_ctx->state.index = index;
dev_dbg(device_data->dev, "[%s] indata length=%d, bin=%d))", dev_dbg(device_data->dev, "%s: indata length=%d, bin=%d\n",
__func__, req_ctx->state.index, __func__, req_ctx->state.index, req_ctx->state.bit_index);
req_ctx->state.bit_index);
out: out:
release_hash_device(device_data); release_hash_device(device_data);
...@@ -1165,15 +1144,15 @@ int hash_resume_state(struct hash_device_data *device_data, ...@@ -1165,15 +1144,15 @@ int hash_resume_state(struct hash_device_data *device_data,
int hash_mode = HASH_OPER_MODE_HASH; int hash_mode = HASH_OPER_MODE_HASH;
if (NULL == device_state) { if (NULL == device_state) {
dev_err(device_data->dev, "[%s] HASH_INVALID_PARAMETER!", dev_err(device_data->dev, "%s: HASH_INVALID_PARAMETER!\n",
__func__); __func__);
return -EPERM; return -EPERM;
} }
/* Check correctness of index and length members */ /* Check correctness of index and length members */
if (device_state->index > HASH_BLOCK_SIZE if (device_state->index > HASH_BLOCK_SIZE ||
|| (device_state->length.low_word % HASH_BLOCK_SIZE) != 0) { (device_state->length.low_word % HASH_BLOCK_SIZE) != 0) {
dev_err(device_data->dev, "[%s] HASH_INVALID_PARAMETER!", dev_err(device_data->dev, "%s: HASH_INVALID_PARAMETER!\n",
__func__); __func__);
return -EPERM; return -EPERM;
} }
...@@ -1223,7 +1202,7 @@ int hash_save_state(struct hash_device_data *device_data, ...@@ -1223,7 +1202,7 @@ int hash_save_state(struct hash_device_data *device_data,
int hash_mode = HASH_OPER_MODE_HASH; int hash_mode = HASH_OPER_MODE_HASH;
if (NULL == device_state) { if (NULL == device_state) {
dev_err(device_data->dev, "[%s] HASH_INVALID_PARAMETER!", dev_err(device_data->dev, "%s: HASH_INVALID_PARAMETER!\n",
__func__); __func__);
return -ENOTSUPP; return -ENOTSUPP;
} }
...@@ -1270,20 +1249,18 @@ int hash_save_state(struct hash_device_data *device_data, ...@@ -1270,20 +1249,18 @@ int hash_save_state(struct hash_device_data *device_data,
int hash_check_hw(struct hash_device_data *device_data) int hash_check_hw(struct hash_device_data *device_data)
{ {
/* Checking Peripheral Ids */ /* Checking Peripheral Ids */
if (HASH_P_ID0 == readl_relaxed(&device_data->base->periphid0) if (HASH_P_ID0 == readl_relaxed(&device_data->base->periphid0) &&
&& HASH_P_ID1 == readl_relaxed(&device_data->base->periphid1) HASH_P_ID1 == readl_relaxed(&device_data->base->periphid1) &&
&& HASH_P_ID2 == readl_relaxed(&device_data->base->periphid2) HASH_P_ID2 == readl_relaxed(&device_data->base->periphid2) &&
&& HASH_P_ID3 == readl_relaxed(&device_data->base->periphid3) HASH_P_ID3 == readl_relaxed(&device_data->base->periphid3) &&
&& HASH_CELL_ID0 == readl_relaxed(&device_data->base->cellid0) HASH_CELL_ID0 == readl_relaxed(&device_data->base->cellid0) &&
&& HASH_CELL_ID1 == readl_relaxed(&device_data->base->cellid1) HASH_CELL_ID1 == readl_relaxed(&device_data->base->cellid1) &&
&& HASH_CELL_ID2 == readl_relaxed(&device_data->base->cellid2) HASH_CELL_ID2 == readl_relaxed(&device_data->base->cellid2) &&
&& HASH_CELL_ID3 == readl_relaxed(&device_data->base->cellid3) HASH_CELL_ID3 == readl_relaxed(&device_data->base->cellid3)) {
) {
return 0; return 0;
} }
dev_err(device_data->dev, "[%s] HASH_UNSUPPORTED_HW!", dev_err(device_data->dev, "%s: HASH_UNSUPPORTED_HW!\n", __func__);
__func__);
return -ENOTSUPP; return -ENOTSUPP;
} }
...@@ -1300,7 +1277,7 @@ void hash_get_digest(struct hash_device_data *device_data, ...@@ -1300,7 +1277,7 @@ void hash_get_digest(struct hash_device_data *device_data,
int loop_ctr; int loop_ctr;
if (algorithm != HASH_ALGO_SHA1 && algorithm != HASH_ALGO_SHA256) { if (algorithm != HASH_ALGO_SHA1 && algorithm != HASH_ALGO_SHA256) {
dev_err(device_data->dev, "[%s] Incorrect algorithm %d", dev_err(device_data->dev, "%s: Incorrect algorithm %d\n",
__func__, algorithm); __func__, algorithm);
return; return;
} }
...@@ -1310,7 +1287,7 @@ void hash_get_digest(struct hash_device_data *device_data, ...@@ -1310,7 +1287,7 @@ void hash_get_digest(struct hash_device_data *device_data,
else else
loop_ctr = SHA256_DIGEST_SIZE / sizeof(u32); loop_ctr = SHA256_DIGEST_SIZE / sizeof(u32);
dev_dbg(device_data->dev, "[%s] digest array:(0x%x)", dev_dbg(device_data->dev, "%s: digest array:(0x%x)\n",
__func__, (u32) digest); __func__, (u32) digest);
/* Copy result into digest array */ /* Copy result into digest array */
...@@ -1337,8 +1314,7 @@ static int ahash_update(struct ahash_request *req) ...@@ -1337,8 +1314,7 @@ static int ahash_update(struct ahash_request *req)
/* Skip update for DMA, all data will be passed to DMA in final */ /* Skip update for DMA, all data will be passed to DMA in final */
if (ret) { if (ret) {
pr_err(DEV_DBG_NAME " [%s] hash_hw_update() failed!", pr_err("%s: hash_hw_update() failed!\n", __func__);
__func__);
} }
return ret; return ret;
...@@ -1353,7 +1329,7 @@ static int ahash_final(struct ahash_request *req) ...@@ -1353,7 +1329,7 @@ static int ahash_final(struct ahash_request *req)
int ret = 0; int ret = 0;
struct hash_req_ctx *req_ctx = ahash_request_ctx(req); struct hash_req_ctx *req_ctx = ahash_request_ctx(req);
pr_debug(DEV_DBG_NAME " [%s] data size: %d", __func__, req->nbytes); pr_debug("%s: data size: %d\n", __func__, req->nbytes);
if ((hash_mode == HASH_MODE_DMA) && req_ctx->dma_mode) if ((hash_mode == HASH_MODE_DMA) && req_ctx->dma_mode)
ret = hash_dma_final(req); ret = hash_dma_final(req);
...@@ -1361,8 +1337,7 @@ static int ahash_final(struct ahash_request *req) ...@@ -1361,8 +1337,7 @@ static int ahash_final(struct ahash_request *req)
ret = hash_hw_final(req); ret = hash_hw_final(req);
if (ret) { if (ret) {
pr_err(DEV_DBG_NAME " [%s] hash_hw/dma_final() failed", pr_err("%s: hash_hw/dma_final() failed\n", __func__);
__func__);
} }
return ret; return ret;
...@@ -1379,8 +1354,8 @@ static int hash_setkey(struct crypto_ahash *tfm, ...@@ -1379,8 +1354,8 @@ static int hash_setkey(struct crypto_ahash *tfm,
*/ */
ctx->key = kmemdup(key, keylen, GFP_KERNEL); ctx->key = kmemdup(key, keylen, GFP_KERNEL);
if (!ctx->key) { if (!ctx->key) {
pr_err(DEV_DBG_NAME " [%s] Failed to allocate ctx->key " pr_err("%s: Failed to allocate ctx->key for %d\n",
"for %d\n", __func__, alg); __func__, alg);
return -ENOMEM; return -ENOMEM;
} }
ctx->keylen = keylen; ctx->keylen = keylen;
...@@ -1553,8 +1528,8 @@ static struct hash_algo_template hash_algs[] = { ...@@ -1553,8 +1528,8 @@ static struct hash_algo_template hash_algs[] = {
.halg.base = { .halg.base = {
.cra_name = "sha1", .cra_name = "sha1",
.cra_driver_name = "sha1-ux500", .cra_driver_name = "sha1-ux500",
.cra_flags = CRYPTO_ALG_TYPE_AHASH | .cra_flags = (CRYPTO_ALG_TYPE_AHASH |
CRYPTO_ALG_ASYNC, CRYPTO_ALG_ASYNC),
.cra_blocksize = SHA1_BLOCK_SIZE, .cra_blocksize = SHA1_BLOCK_SIZE,
.cra_ctxsize = sizeof(struct hash_ctx), .cra_ctxsize = sizeof(struct hash_ctx),
.cra_init = hash_cra_init, .cra_init = hash_cra_init,
...@@ -1575,8 +1550,8 @@ static struct hash_algo_template hash_algs[] = { ...@@ -1575,8 +1550,8 @@ static struct hash_algo_template hash_algs[] = {
.halg.base = { .halg.base = {
.cra_name = "sha256", .cra_name = "sha256",
.cra_driver_name = "sha256-ux500", .cra_driver_name = "sha256-ux500",
.cra_flags = CRYPTO_ALG_TYPE_AHASH | .cra_flags = (CRYPTO_ALG_TYPE_AHASH |
CRYPTO_ALG_ASYNC, CRYPTO_ALG_ASYNC),
.cra_blocksize = SHA256_BLOCK_SIZE, .cra_blocksize = SHA256_BLOCK_SIZE,
.cra_ctxsize = sizeof(struct hash_ctx), .cra_ctxsize = sizeof(struct hash_ctx),
.cra_type = &crypto_ahash_type, .cra_type = &crypto_ahash_type,
...@@ -1584,7 +1559,6 @@ static struct hash_algo_template hash_algs[] = { ...@@ -1584,7 +1559,6 @@ static struct hash_algo_template hash_algs[] = {
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} }
}, },
{ {
.conf.algorithm = HASH_ALGO_SHA1, .conf.algorithm = HASH_ALGO_SHA1,
...@@ -1600,8 +1574,8 @@ static struct hash_algo_template hash_algs[] = { ...@@ -1600,8 +1574,8 @@ static struct hash_algo_template hash_algs[] = {
.halg.base = { .halg.base = {
.cra_name = "hmac(sha1)", .cra_name = "hmac(sha1)",
.cra_driver_name = "hmac-sha1-ux500", .cra_driver_name = "hmac-sha1-ux500",
.cra_flags = CRYPTO_ALG_TYPE_AHASH | .cra_flags = (CRYPTO_ALG_TYPE_AHASH |
CRYPTO_ALG_ASYNC, CRYPTO_ALG_ASYNC),
.cra_blocksize = SHA1_BLOCK_SIZE, .cra_blocksize = SHA1_BLOCK_SIZE,
.cra_ctxsize = sizeof(struct hash_ctx), .cra_ctxsize = sizeof(struct hash_ctx),
.cra_type = &crypto_ahash_type, .cra_type = &crypto_ahash_type,
...@@ -1624,8 +1598,8 @@ static struct hash_algo_template hash_algs[] = { ...@@ -1624,8 +1598,8 @@ static struct hash_algo_template hash_algs[] = {
.halg.base = { .halg.base = {
.cra_name = "hmac(sha256)", .cra_name = "hmac(sha256)",
.cra_driver_name = "hmac-sha256-ux500", .cra_driver_name = "hmac-sha256-ux500",
.cra_flags = CRYPTO_ALG_TYPE_AHASH | .cra_flags = (CRYPTO_ALG_TYPE_AHASH |
CRYPTO_ALG_ASYNC, CRYPTO_ALG_ASYNC),
.cra_blocksize = SHA256_BLOCK_SIZE, .cra_blocksize = SHA256_BLOCK_SIZE,
.cra_ctxsize = sizeof(struct hash_ctx), .cra_ctxsize = sizeof(struct hash_ctx),
.cra_type = &crypto_ahash_type, .cra_type = &crypto_ahash_type,
...@@ -1649,7 +1623,7 @@ static int ahash_algs_register_all(struct hash_device_data *device_data) ...@@ -1649,7 +1623,7 @@ static int ahash_algs_register_all(struct hash_device_data *device_data)
ret = crypto_register_ahash(&hash_algs[i].hash); ret = crypto_register_ahash(&hash_algs[i].hash);
if (ret) { if (ret) {
count = i; count = i;
dev_err(device_data->dev, "[%s] alg registration failed", dev_err(device_data->dev, "%s: alg registration failed\n",
hash_algs[i].hash.halg.base.cra_driver_name); hash_algs[i].hash.halg.base.cra_driver_name);
goto unreg; goto unreg;
} }
...@@ -1683,9 +1657,8 @@ static int ux500_hash_probe(struct platform_device *pdev) ...@@ -1683,9 +1657,8 @@ static int ux500_hash_probe(struct platform_device *pdev)
struct hash_device_data *device_data; struct hash_device_data *device_data;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
device_data = kzalloc(sizeof(struct hash_device_data), GFP_ATOMIC); device_data = kzalloc(sizeof(*device_data), GFP_ATOMIC);
if (!device_data) { if (!device_data) {
dev_dbg(dev, "[%s] kzalloc() failed!", __func__);
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
...@@ -1695,14 +1668,14 @@ static int ux500_hash_probe(struct platform_device *pdev) ...@@ -1695,14 +1668,14 @@ static int ux500_hash_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { if (!res) {
dev_dbg(dev, "[%s] platform_get_resource() failed!", __func__); dev_dbg(dev, "%s: platform_get_resource() failed!\n", __func__);
ret = -ENODEV; ret = -ENODEV;
goto out_kfree; goto out_kfree;
} }
res = request_mem_region(res->start, resource_size(res), pdev->name); res = request_mem_region(res->start, resource_size(res), pdev->name);
if (res == NULL) { if (res == NULL) {
dev_dbg(dev, "[%s] request_mem_region() failed!", __func__); dev_dbg(dev, "%s: request_mem_region() failed!\n", __func__);
ret = -EBUSY; ret = -EBUSY;
goto out_kfree; goto out_kfree;
} }
...@@ -1710,8 +1683,7 @@ static int ux500_hash_probe(struct platform_device *pdev) ...@@ -1710,8 +1683,7 @@ static int ux500_hash_probe(struct platform_device *pdev)
device_data->phybase = res->start; device_data->phybase = res->start;
device_data->base = ioremap(res->start, resource_size(res)); device_data->base = ioremap(res->start, resource_size(res));
if (!device_data->base) { if (!device_data->base) {
dev_err(dev, "[%s] ioremap() failed!", dev_err(dev, "%s: ioremap() failed!\n", __func__);
__func__);
ret = -ENOMEM; ret = -ENOMEM;
goto out_free_mem; goto out_free_mem;
} }
...@@ -1721,7 +1693,7 @@ static int ux500_hash_probe(struct platform_device *pdev) ...@@ -1721,7 +1693,7 @@ static int ux500_hash_probe(struct platform_device *pdev)
/* Enable power for HASH1 hardware block */ /* Enable power for HASH1 hardware block */
device_data->regulator = regulator_get(dev, "v-ape"); device_data->regulator = regulator_get(dev, "v-ape");
if (IS_ERR(device_data->regulator)) { if (IS_ERR(device_data->regulator)) {
dev_err(dev, "[%s] regulator_get() failed!", __func__); dev_err(dev, "%s: regulator_get() failed!\n", __func__);
ret = PTR_ERR(device_data->regulator); ret = PTR_ERR(device_data->regulator);
device_data->regulator = NULL; device_data->regulator = NULL;
goto out_unmap; goto out_unmap;
...@@ -1730,27 +1702,27 @@ static int ux500_hash_probe(struct platform_device *pdev) ...@@ -1730,27 +1702,27 @@ static int ux500_hash_probe(struct platform_device *pdev)
/* Enable the clock for HASH1 hardware block */ /* Enable the clock for HASH1 hardware block */
device_data->clk = clk_get(dev, NULL); device_data->clk = clk_get(dev, NULL);
if (IS_ERR(device_data->clk)) { if (IS_ERR(device_data->clk)) {
dev_err(dev, "[%s] clk_get() failed!", __func__); dev_err(dev, "%s: clk_get() failed!\n", __func__);
ret = PTR_ERR(device_data->clk); ret = PTR_ERR(device_data->clk);
goto out_regulator; goto out_regulator;
} }
ret = clk_prepare(device_data->clk); ret = clk_prepare(device_data->clk);
if (ret) { if (ret) {
dev_err(dev, "[%s] clk_prepare() failed!", __func__); dev_err(dev, "%s: clk_prepare() failed!\n", __func__);
goto out_clk; goto out_clk;
} }
/* Enable device power (and clock) */ /* Enable device power (and clock) */
ret = hash_enable_power(device_data, false); ret = hash_enable_power(device_data, false);
if (ret) { if (ret) {
dev_err(dev, "[%s]: hash_enable_power() failed!", __func__); dev_err(dev, "%s: hash_enable_power() failed!\n", __func__);
goto out_clk_unprepare; goto out_clk_unprepare;
} }
ret = hash_check_hw(device_data); ret = hash_check_hw(device_data);
if (ret) { if (ret) {
dev_err(dev, "[%s] hash_check_hw() failed!", __func__); dev_err(dev, "%s: hash_check_hw() failed!\n", __func__);
goto out_power; goto out_power;
} }
...@@ -1766,8 +1738,8 @@ static int ux500_hash_probe(struct platform_device *pdev) ...@@ -1766,8 +1738,8 @@ static int ux500_hash_probe(struct platform_device *pdev)
ret = ahash_algs_register_all(device_data); ret = ahash_algs_register_all(device_data);
if (ret) { if (ret) {
dev_err(dev, "[%s] ahash_algs_register_all() " dev_err(dev, "%s: ahash_algs_register_all() failed!\n",
"failed!", __func__); __func__);
goto out_power; goto out_power;
} }
...@@ -1810,8 +1782,7 @@ static int ux500_hash_remove(struct platform_device *pdev) ...@@ -1810,8 +1782,7 @@ static int ux500_hash_remove(struct platform_device *pdev)
device_data = platform_get_drvdata(pdev); device_data = platform_get_drvdata(pdev);
if (!device_data) { if (!device_data) {
dev_err(dev, "[%s]: platform_get_drvdata() failed!", dev_err(dev, "%s: platform_get_drvdata() failed!\n", __func__);
__func__);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1841,7 +1812,7 @@ static int ux500_hash_remove(struct platform_device *pdev) ...@@ -1841,7 +1812,7 @@ static int ux500_hash_remove(struct platform_device *pdev)
ahash_algs_unregister_all(device_data); ahash_algs_unregister_all(device_data);
if (hash_disable_power(device_data, false)) if (hash_disable_power(device_data, false))
dev_err(dev, "[%s]: hash_disable_power() failed", dev_err(dev, "%s: hash_disable_power() failed\n",
__func__); __func__);
clk_unprepare(device_data->clk); clk_unprepare(device_data->clk);
...@@ -1870,7 +1841,7 @@ static void ux500_hash_shutdown(struct platform_device *pdev) ...@@ -1870,7 +1841,7 @@ static void ux500_hash_shutdown(struct platform_device *pdev)
device_data = platform_get_drvdata(pdev); device_data = platform_get_drvdata(pdev);
if (!device_data) { if (!device_data) {
dev_err(&pdev->dev, "[%s] platform_get_drvdata() failed!", dev_err(&pdev->dev, "%s: platform_get_drvdata() failed!\n",
__func__); __func__);
return; return;
} }
...@@ -1880,8 +1851,8 @@ static void ux500_hash_shutdown(struct platform_device *pdev) ...@@ -1880,8 +1851,8 @@ static void ux500_hash_shutdown(struct platform_device *pdev)
/* current_ctx allocates a device, NULL = unallocated */ /* current_ctx allocates a device, NULL = unallocated */
if (!device_data->current_ctx) { if (!device_data->current_ctx) {
if (down_trylock(&driver_data.device_allocation)) if (down_trylock(&driver_data.device_allocation))
dev_dbg(&pdev->dev, "[%s]: Cryp still in use!" dev_dbg(&pdev->dev, "%s: Cryp still in use! Shutting down anyway...\n",
"Shutting down anyway...", __func__); __func__);
/** /**
* (Allocate the device) * (Allocate the device)
* Need to set this to non-null (dummy) value, * Need to set this to non-null (dummy) value,
...@@ -1906,7 +1877,7 @@ static void ux500_hash_shutdown(struct platform_device *pdev) ...@@ -1906,7 +1877,7 @@ static void ux500_hash_shutdown(struct platform_device *pdev)
release_mem_region(res->start, resource_size(res)); release_mem_region(res->start, resource_size(res));
if (hash_disable_power(device_data, false)) if (hash_disable_power(device_data, false))
dev_err(&pdev->dev, "[%s] hash_disable_power() failed", dev_err(&pdev->dev, "%s: hash_disable_power() failed\n",
__func__); __func__);
} }
...@@ -1922,7 +1893,7 @@ static int ux500_hash_suspend(struct device *dev) ...@@ -1922,7 +1893,7 @@ static int ux500_hash_suspend(struct device *dev)
device_data = dev_get_drvdata(dev); device_data = dev_get_drvdata(dev);
if (!device_data) { if (!device_data) {
dev_err(dev, "[%s] platform_get_drvdata() failed!", __func__); dev_err(dev, "%s: platform_get_drvdata() failed!\n", __func__);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1933,15 +1904,16 @@ static int ux500_hash_suspend(struct device *dev) ...@@ -1933,15 +1904,16 @@ static int ux500_hash_suspend(struct device *dev)
if (device_data->current_ctx == ++temp_ctx) { if (device_data->current_ctx == ++temp_ctx) {
if (down_interruptible(&driver_data.device_allocation)) if (down_interruptible(&driver_data.device_allocation))
dev_dbg(dev, "[%s]: down_interruptible() failed", dev_dbg(dev, "%s: down_interruptible() failed\n",
__func__); __func__);
ret = hash_disable_power(device_data, false); ret = hash_disable_power(device_data, false);
} else } else {
ret = hash_disable_power(device_data, true); ret = hash_disable_power(device_data, true);
}
if (ret) if (ret)
dev_err(dev, "[%s]: hash_disable_power()", __func__); dev_err(dev, "%s: hash_disable_power()\n", __func__);
return ret; return ret;
} }
...@@ -1958,7 +1930,7 @@ static int ux500_hash_resume(struct device *dev) ...@@ -1958,7 +1930,7 @@ static int ux500_hash_resume(struct device *dev)
device_data = dev_get_drvdata(dev); device_data = dev_get_drvdata(dev);
if (!device_data) { if (!device_data) {
dev_err(dev, "[%s] platform_get_drvdata() failed!", __func__); dev_err(dev, "%s: platform_get_drvdata() failed!\n", __func__);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1973,7 +1945,7 @@ static int ux500_hash_resume(struct device *dev) ...@@ -1973,7 +1945,7 @@ static int ux500_hash_resume(struct device *dev)
ret = hash_enable_power(device_data, true); ret = hash_enable_power(device_data, true);
if (ret) if (ret)
dev_err(dev, "[%s]: hash_enable_power() failed!", __func__); dev_err(dev, "%s: hash_enable_power() failed!\n", __func__);
return ret; return ret;
} }
......
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