mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jürg Billeter" <j@bitron.ch>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Gigi Joseph" <gigi.joseph@gmail.com>,
	"Colin Ian King" <colin.king@canonical.com>,
	linux-kernel@vger.kernel.org, "Jürg Billeter" <j@bitron.ch>
Subject: [PATCH 1/3] ti-st: st_kim: use ERR_PTR(-ENOMEM) instead of NULL
Date: Wed, 24 Jun 2015 12:24:04 +0200	[thread overview]
Message-ID: <1435141446-27236-1-git-send-email-j@bitron.ch> (raw)

This allows return of other error codes.

Signed-off-by: Jürg Billeter <j@bitron.ch>
---
 drivers/misc/ti-st/st_kim.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
index 5027b8f..af71584 100644
--- a/drivers/misc/ti-st/st_kim.c
+++ b/drivers/misc/ti-st/st_kim.c
@@ -752,8 +752,11 @@ static struct ti_st_plat_data *get_platform_data(struct device *dev)
 	int len;
 
 	dt_pdata = kzalloc(sizeof(*dt_pdata), GFP_KERNEL);
-	if (!dt_pdata)
-		return NULL;
+
+	if (!dt_pdata) {
+		pr_err("Can't allocate device_tree platform data\n");
+		return ERR_PTR(-ENOMEM);
+	}
 
 	dt_property = of_get_property(np, "dev_name", &len);
 	if (dt_property)
@@ -773,10 +776,13 @@ static int kim_probe(struct platform_device *pdev)
 	struct ti_st_plat_data	*pdata;
 	int err;
 
-	if (pdev->dev.of_node)
+	if (pdev->dev.of_node) {
 		pdata = get_platform_data(&pdev->dev);
-	else
+		if (IS_ERR(pdata))
+			return PTR_ERR(pdata);
+	} else {
 		pdata = pdev->dev.platform_data;
+	}
 
 	if (pdata == NULL) {
 		dev_err(&pdev->dev, "Platform Data is missing\n");
-- 
2.4.3


             reply	other threads:[~2015-06-24 11:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-24 10:24 Jürg Billeter [this message]
2015-06-24 10:24 ` [PATCH 2/3] ti-st: st_kim: fix nshutdown_gpio in get_platform_data Jürg Billeter
2015-06-24 15:31   ` Peter Hurley
2015-06-24 15:39     ` Jürg Billeter
2015-06-24 15:49       ` Peter Hurley
2015-06-24 10:24 ` [PATCH 3/3] ti-st: st_kim: use gpio_set_value_cansleep to fix warning Jürg Billeter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1435141446-27236-1-git-send-email-j@bitron.ch \
    --to=j@bitron.ch \
    --cc=colin.king@canonical.com \
    --cc=gigi.joseph@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®