All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] misc: atmel-ssc: Handle return value of clk_prepare_enable and clk_prepare
@ 2017-06-01  8:52 ` Arvind Yadav
  0 siblings, 0 replies; 4+ messages in thread
From: Arvind Yadav @ 2017-06-01  8:52 UTC (permalink / raw)
  To: gregkh, nicolas.ferre; +Cc: linux-arm-kernel, linux-kernel

clk_prepare_enable() and clk_prepare() can fail here and
we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/misc/atmel-ssc.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
index b2a0340..4d2b090 100644
--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -30,6 +30,7 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
 {
 	int ssc_valid = 0;
 	struct ssc_device *ssc;
+	int ret;
 
 	spin_lock(&user_lock);
 	list_for_each_entry(ssc, &ssc_list, list) {
@@ -60,7 +61,11 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
 	ssc->user++;
 	spin_unlock(&user_lock);
 
-	clk_prepare(ssc->clk);
+	ret = clk_prepare(ssc->clk);
+	if (ret) {
+		pr_err("Failed to prepare clock\n");
+		return ret;
+	}
 
 	return ssc;
 }
@@ -195,6 +200,7 @@ static int ssc_probe(struct platform_device *pdev)
 	struct resource *regs;
 	struct ssc_device *ssc;
 	const struct atmel_ssc_platform_data *plat_dat;
+	int ret;
 
 	ssc = devm_kzalloc(&pdev->dev, sizeof(struct ssc_device), GFP_KERNEL);
 	if (!ssc) {
@@ -229,7 +235,9 @@ static int ssc_probe(struct platform_device *pdev)
 	}
 
 	/* disable all interrupts */
-	clk_prepare_enable(ssc->clk);
+	ret = clk_prepare_enable(ssc->clk);
+	if (ret)
+		return ret;
 	ssc_writel(ssc->regs, IDR, -1);
 	ssc_readl(ssc->regs, SR);
 	clk_disable_unprepare(ssc->clk);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] misc: atmel-ssc: Handle return value of clk_prepare_enable and clk_prepare
@ 2017-06-01  8:52 ` Arvind Yadav
  0 siblings, 0 replies; 4+ messages in thread
From: Arvind Yadav @ 2017-06-01  8:52 UTC (permalink / raw)
  To: linux-arm-kernel

clk_prepare_enable() and clk_prepare() can fail here and
we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/misc/atmel-ssc.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
index b2a0340..4d2b090 100644
--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -30,6 +30,7 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
 {
 	int ssc_valid = 0;
 	struct ssc_device *ssc;
+	int ret;
 
 	spin_lock(&user_lock);
 	list_for_each_entry(ssc, &ssc_list, list) {
@@ -60,7 +61,11 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
 	ssc->user++;
 	spin_unlock(&user_lock);
 
-	clk_prepare(ssc->clk);
+	ret = clk_prepare(ssc->clk);
+	if (ret) {
+		pr_err("Failed to prepare clock\n");
+		return ret;
+	}
 
 	return ssc;
 }
@@ -195,6 +200,7 @@ static int ssc_probe(struct platform_device *pdev)
 	struct resource *regs;
 	struct ssc_device *ssc;
 	const struct atmel_ssc_platform_data *plat_dat;
+	int ret;
 
 	ssc = devm_kzalloc(&pdev->dev, sizeof(struct ssc_device), GFP_KERNEL);
 	if (!ssc) {
@@ -229,7 +235,9 @@ static int ssc_probe(struct platform_device *pdev)
 	}
 
 	/* disable all interrupts */
-	clk_prepare_enable(ssc->clk);
+	ret = clk_prepare_enable(ssc->clk);
+	if (ret)
+		return ret;
 	ssc_writel(ssc->regs, IDR, -1);
 	ssc_readl(ssc->regs, SR);
 	clk_disable_unprepare(ssc->clk);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] misc: atmel-ssc: Handle return value of clk_prepare_enable and clk_prepare
  2017-06-01  8:52 ` Arvind Yadav
@ 2017-06-01 13:14   ` kbuild test robot
  -1 siblings, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2017-06-01 13:14 UTC (permalink / raw)
  To: Arvind Yadav
  Cc: kbuild-all, gregkh, nicolas.ferre, linux-arm-kernel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1751 bytes --]

Hi Arvind,

[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on v4.12-rc3 next-20170601]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Arvind-Yadav/misc-atmel-ssc-Handle-return-value-of-clk_prepare_enable-and-clk_prepare/20170601-191011
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
        wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=xtensa 

All warnings (new ones prefixed by >>):

   drivers/misc/atmel-ssc.c: In function 'ssc_request':
>> drivers/misc/atmel-ssc.c:67:3: warning: return makes pointer from integer without a cast
      return ret;
      ^

vim +67 drivers/misc/atmel-ssc.c

    51			spin_unlock(&user_lock);
    52			pr_err("ssc: ssc%d platform device is missing\n", ssc_num);
    53			return ERR_PTR(-ENODEV);
    54		}
    55	
    56		if (ssc->user) {
    57			spin_unlock(&user_lock);
    58			dev_dbg(&ssc->pdev->dev, "module busy\n");
    59			return ERR_PTR(-EBUSY);
    60		}
    61		ssc->user++;
    62		spin_unlock(&user_lock);
    63	
    64		ret = clk_prepare(ssc->clk);
    65		if (ret) {
    66			pr_err("Failed to prepare clock\n");
  > 67			return ret;
    68		}
    69	
    70		return ssc;
    71	}
    72	EXPORT_SYMBOL(ssc_request);
    73	
    74	void ssc_free(struct ssc_device *ssc)
    75	{

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 50138 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] misc: atmel-ssc: Handle return value of clk_prepare_enable and clk_prepare
@ 2017-06-01 13:14   ` kbuild test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2017-06-01 13:14 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Arvind,

[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on v4.12-rc3 next-20170601]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Arvind-Yadav/misc-atmel-ssc-Handle-return-value-of-clk_prepare_enable-and-clk_prepare/20170601-191011
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
        wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=xtensa 

All warnings (new ones prefixed by >>):

   drivers/misc/atmel-ssc.c: In function 'ssc_request':
>> drivers/misc/atmel-ssc.c:67:3: warning: return makes pointer from integer without a cast
      return ret;
      ^

vim +67 drivers/misc/atmel-ssc.c

    51			spin_unlock(&user_lock);
    52			pr_err("ssc: ssc%d platform device is missing\n", ssc_num);
    53			return ERR_PTR(-ENODEV);
    54		}
    55	
    56		if (ssc->user) {
    57			spin_unlock(&user_lock);
    58			dev_dbg(&ssc->pdev->dev, "module busy\n");
    59			return ERR_PTR(-EBUSY);
    60		}
    61		ssc->user++;
    62		spin_unlock(&user_lock);
    63	
    64		ret = clk_prepare(ssc->clk);
    65		if (ret) {
    66			pr_err("Failed to prepare clock\n");
  > 67			return ret;
    68		}
    69	
    70		return ssc;
    71	}
    72	EXPORT_SYMBOL(ssc_request);
    73	
    74	void ssc_free(struct ssc_device *ssc)
    75	{

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 50138 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170601/e788021c/attachment-0001.gz>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-06-01 13:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-01  8:52 [PATCH] misc: atmel-ssc: Handle return value of clk_prepare_enable and clk_prepare Arvind Yadav
2017-06-01  8:52 ` Arvind Yadav
2017-06-01 13:14 ` kbuild test robot
2017-06-01 13:14   ` kbuild test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.