From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: "Greg Kroah-Hartman" <gregkh@suse.de>,
linux-kernel@vger.kernel.org, shiraz.hashim@st.com,
"Michał Mirosław" <mirqus@gmail.com>,
kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 5/5] driver core: let dev_set_drvdata return int instead of void as it can fail
Date: Fri, 29 Apr 2011 09:12:57 +0100 [thread overview]
Message-ID: <20110429081257.GW17290@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1303285486-28598-5-git-send-email-u.kleine-koenig@pengutronix.de>
On Wed, Apr 20, 2011 at 09:44:46AM +0200, Uwe Kleine-König wrote:
> Before commit
>
> b402843 (Driver core: move dev_get/set_drvdata to drivers/base/dd.c)
>
> calling dev_set_drvdata with dev=NULL was an unchecked error. After some
> discussion about what to return in this case removing the check (and so
> producing a null pointer exception) seems fine.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/base/dd.c | 7 +++----
> include/linux/device.h | 2 +-
> 2 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index da57ee9..f9d69d7 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -408,17 +408,16 @@ void *dev_get_drvdata(const struct device *dev)
> }
> EXPORT_SYMBOL(dev_get_drvdata);
>
> -void dev_set_drvdata(struct device *dev, void *data)
> +int dev_set_drvdata(struct device *dev, void *data)
> {
> int error;
>
> - if (!dev)
> - return;
> if (!dev->p) {
> error = device_private_init(dev);
> if (error)
> - return;
> + return error;
> }
> dev->p->driver_data = data;
> + return 0;
Who is going to modify all the thousands of drivers we have in the kernel
tree to check this return value?
If the answer is no one, its pointless returning an error value in the
first place (which I think is what the original author already thought
about.)
next prev parent reply other threads:[~2011-04-29 8:13 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5c561db378360ad1763da41f8350c7be816daa06.1298953633.git.viresh.kumar@st.com>
2011-03-01 7:59 ` [RFC] device.h: add device_set_platdata routine Uwe Kleine-König
2011-03-01 8:27 ` viresh kumar
2011-03-01 9:05 ` Uwe Kleine-König
2011-03-01 9:13 ` viresh kumar
2011-03-01 15:34 ` Greg KH
2011-04-06 9:24 ` [PATCH 1/5] driver core/platform_device_add_data: set platform_data to NULL if !data Uwe Kleine-König
2011-04-11 18:50 ` Uwe Kleine-König
2011-04-11 19:07 ` Greg KH
2011-04-06 9:24 ` [PATCH 2/5] driver core/platform_device_add_data: free platform data before overwriting Uwe Kleine-König
2011-04-06 9:24 ` [PATCH 3/5] driver core/platform_device_add_resources: set resource to NULL if !res Uwe Kleine-König
2011-04-06 9:24 ` [PATCH 4/5] driver core/platform_device_add_resources: free resource before overwriting Uwe Kleine-König
2011-04-06 9:24 ` [PATCH 5/5] driver core: let dev_set_drvdata return int instead of void as it can fail Uwe Kleine-König
2011-04-06 9:36 ` Michał Mirosław
2011-04-06 11:06 ` Uwe Kleine-König
2011-04-06 11:25 ` Michał Mirosław
2011-04-11 18:42 ` [PATCH v2] " Uwe Kleine-König
2011-04-19 23:58 ` Greg KH
2011-04-20 7:42 ` Uwe Kleine-König
2011-04-20 7:44 ` [PATCH v2 1/5] driver core/platform_device_add_data: set platform_data to NULL if !data Uwe Kleine-König
2011-04-20 7:44 ` [PATCH v2 2/5] driver core/platform_device_add_data: free platform data before overwriting Uwe Kleine-König
2011-04-20 7:44 ` [PATCH v2 3/5] driver core/platform_device_add_resources: set resource to NULL if !res Uwe Kleine-König
2011-04-20 7:44 ` [PATCH v2 4/5] driver core/platform_device_add_resources: free resource before overwriting Uwe Kleine-König
2011-04-20 7:44 ` [PATCH v2 5/5] driver core: let dev_set_drvdata return int instead of void as it can fail Uwe Kleine-König
2011-04-29 8:12 ` Russell King - ARM Linux [this message]
2011-04-29 9:16 ` Uwe Kleine-König
2011-04-20 16:17 ` [PATCH v2] " Greg KH
2011-04-20 9:09 ` Michał Mirosław
2011-04-20 16:15 ` Greg KH
2011-04-20 17:59 ` Michał Mirosław
2011-04-06 10:10 ` [PATCH 5/5] " viresh kumar
2011-04-06 11:41 ` Michał Mirosław
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=20110429081257.GW17290@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=gregkh@suse.de \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mirqus@gmail.com \
--cc=shiraz.hashim@st.com \
--cc=u.kleine-koenig@pengutronix.de \
/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®