aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnish Trivedi <anish@freescale.com>2011-01-24 18:08:39 -0600
committerAnish Trivedi <anish@freescale.com>2011-01-25 09:51:40 -0600
commit75749fa549a99e5bb325d47a94d4ae7a0a9c7e7e (patch)
tree207db2ababd8708cc51d26ea4cbe2ec1c28cf055
parent8d371aaa0540fe50c318fd5c7e26b24b8bb2eab0 (diff)
ENGR00138333 MX5x In security drivers use IS_ERR to check for clk pointer error
Error check of clk pointer should use IS_ERR instead of ERR_PTR(ENOENT). Updated SCC2 and SAHARA drivers to use this method for error checks as well as to propagate the error code where applicable. Signed-off-by: Anish Trivedi <anish@freescale.com>
-rw-r--r--drivers/mxc/security/sahara2/sah_driver_interface.c16
-rw-r--r--drivers/mxc/security/sahara2/sah_queue_manager.c4
-rw-r--r--drivers/mxc/security/sahara2/sah_status_manager.c18
-rw-r--r--drivers/mxc/security/scc2_driver.c30
4 files changed, 43 insertions, 25 deletions
diff --git a/drivers/mxc/security/sahara2/sah_driver_interface.c b/drivers/mxc/security/sahara2/sah_driver_interface.c
index 141fcbdf39d..cf01c5f8bfe 100644
--- a/drivers/mxc/security/sahara2/sah_driver_interface.c
+++ b/drivers/mxc/security/sahara2/sah_driver_interface.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2004-2011 Freescale Semiconductor, Inc. All Rights Reserved.
*/
/*
@@ -189,7 +189,9 @@ OS_DEV_INIT(sah_init)
#else
{
sah_clk = clk_get(NULL, "sahara_clk");
- if (sah_clk != ERR_PTR(ENOENT))
+ if (IS_ERR(sah_clk))
+ os_error_code = PTR_ERR(sah_clk);
+ else
clk_enable(sah_clk);
}
#endif
@@ -379,7 +381,9 @@ OS_DEV_INIT(sah_init)
mxc_clks_disable(SAHARA2_CLK);
#else
{
- if (sah_clk != ERR_PTR(ENOENT))
+ if (IS_ERR(sah_clk))
+ os_error_code = PTR_ERR(sah_clk);
+ else
clk_disable(sah_clk);
}
#endif
@@ -446,13 +450,15 @@ OS_DEV_SHUTDOWN(sah_cleanup)
mxc_clks_disable(SAHARA2_CLK);
#else
{
- if (sah_clk != ERR_PTR(ENOENT))
+ if (IS_ERR(sah_clk))
+ ret_val = PTR_ERR(sah_clk);
+ else
clk_disable(sah_clk);
clk_put(sah_clk);
}
#endif
- os_dev_shutdown_return(OS_ERROR_OK_S);
+ os_dev_shutdown_return(ret_val);
}
/*!
diff --git a/drivers/mxc/security/sahara2/sah_queue_manager.c b/drivers/mxc/security/sahara2/sah_queue_manager.c
index 324e4c6c6a0..78de3543cd2 100644
--- a/drivers/mxc/security/sahara2/sah_queue_manager.c
+++ b/drivers/mxc/security/sahara2/sah_queue_manager.c
@@ -354,7 +354,7 @@ void sah_Queue_Manager_Prime(sah_Head_Desc * entry)
#else
{
struct clk *clk = clk_get(NULL, "sahara_clk");
- if (clk != ERR_PTR(ENOENT))
+ if (!IS_ERR(clk))
clk_enable(clk);
clk_put(clk);
}
@@ -478,7 +478,7 @@ void sah_postprocess_queue(unsigned long reset_flag)
#else
{
struct clk *clk = clk_get(NULL, "sahara_clk");
- if (clk != ERR_PTR(ENOENT))
+ if (!IS_ERR(clk))
clk_disable(clk);
clk_put(clk);
}
diff --git a/drivers/mxc/security/sahara2/sah_status_manager.c b/drivers/mxc/security/sahara2/sah_status_manager.c
index 4c5011bdf59..f881b47591c 100644
--- a/drivers/mxc/security/sahara2/sah_status_manager.c
+++ b/drivers/mxc/security/sahara2/sah_status_manager.c
@@ -581,6 +581,7 @@ static int sah_dpm_suspend(struct platform_device *dev, pm_message_t state)
{
sah_Head_Desc *entry = NULL;
os_lock_context_t lock_flags;
+ int error_code = 0;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
switch (level) {
@@ -628,13 +629,14 @@ static int sah_dpm_suspend(struct platform_device *dev, pm_message_t state)
* any power */
{
struct clk *clk = clk_get(NULL, "sahara_clk");
- if (clk != ERR_PTR(ENOENT)) {
+ if (IS_ERR(clk))
+ error_code = PTR_ERR(clk);
+ else
clk_disable(clk);
- }
}
#endif
- return 0;
+ return error_code;
}
/*!
@@ -660,6 +662,7 @@ static int sah_dpm_resume(struct platform_device *dev)
{
sah_Head_Desc *entry = NULL;
os_lock_context_t lock_flags;
+ int error_code = 0;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
switch (level) {
@@ -690,9 +693,10 @@ static int sah_dpm_resume(struct platform_device *dev)
/* enable Sahara's clock */
struct clk *clk = clk_get(NULL, "sahara_clk");
- if (clk != ERR_PTR(ENOENT)) {
- clk_enable(clk);
- }
+ if (IS_ERR(clk))
+ error_code = PTR_ERR(clk);
+ else
+ clk_disable(clk);
}
sah_dpm_flag = FALSE;
@@ -704,7 +708,7 @@ static int sah_dpm_resume(struct platform_device *dev)
}
os_unlock_restore_context(desc_queue_lock, lock_flags);
#endif
- return 0;
+ return error_code;
}
#endif /* SAHARA_POWER_MANAGEMENT */
diff --git a/drivers/mxc/security/scc2_driver.c b/drivers/mxc/security/scc2_driver.c
index d4dc9d71174..e0cbb28a0ad 100644
--- a/drivers/mxc/security/scc2_driver.c
+++ b/drivers/mxc/security/scc2_driver.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2004-2011 Freescale Semiconductor, Inc. All Rights Reserved.
*/
/*
@@ -521,9 +521,11 @@ static int scc_init(void)
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18))
mxc_clks_enable(SCC_CLK);
#else
- if (scc_clk != ERR_PTR(ENOENT)) {
+ if (IS_ERR(scc_clk)) {
+ return_value = PTR_ERR(scc_clk);
+ goto out;
+ } else
clk_enable(scc_clk);
- }
#endif
/* Set up the hardware access locks */
@@ -653,7 +655,7 @@ static int scc_init(void)
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18))
mxc_clks_disable(SCC_CLK);
#else
- if (scc_clk != ERR_PTR(ENOENT))
+ if (!IS_ERR(scc_clk))
clk_disable(scc_clk);
#endif
@@ -732,7 +734,7 @@ static void scc_cleanup(void)
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18))
mxc_clks_disable(SCC_CLK);
#else
- if (scc_clk != ERR_PTR(ENOENT))
+ if (!IS_ERR(scc_clk))
clk_disable(scc_clk);
clk_put(scc_clk);
#endif
@@ -1355,8 +1357,11 @@ scc_encrypt_region(uint32_t part_base, uint32_t offset_bytes,
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18))
mxc_clks_enable(SCC_CLK);
#else
- if (scc_clk != ERR_PTR(ENOENT))
- clk_enable(scc_clk);
+ if (IS_ERR(scc_clk)) {
+ status = SCC_RET_FAIL;
+ goto out;
+ } else
+ clk_enable(scc_clk);
#endif
scm_command = ((offset_blocks << SCM_CCMD_OFFSET_SHIFT) |
@@ -1415,7 +1420,7 @@ out:
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18))
mxc_clks_disable(SCC_CLK);
#else
- if (scc_clk != ERR_PTR(ENOENT))
+ if (!IS_ERR(scc_clk))
clk_disable(scc_clk);
#endif
@@ -1450,8 +1455,11 @@ scc_decrypt_region(uint32_t part_base, uint32_t offset_bytes,
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18))
mxc_clks_enable(SCC_CLK);
#else
- if (scc_clk != ERR_PTR(ENOENT))
- clk_enable(scc_clk);
+ if (IS_ERR(scc_clk)) {
+ status = SCC_RET_FAIL;
+ goto out;
+ } else
+ clk_enable(scc_clk);
#endif
scm_command = ((offset_blocks << SCM_CCMD_OFFSET_SHIFT) |
(SCM_PART_NUMBER(part_base) << SCM_CCMD_PART_SHIFT));
@@ -1507,7 +1515,7 @@ out:
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18))
mxc_clks_disable(SCC_CLK);
#else
- if (scc_clk != ERR_PTR(ENOENT))
+ if (!IS_ERR(scc_clk))
clk_disable(scc_clk);
#endif
return status;