lkml.org 
[lkml]   [2011]   [May]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [22/44] driver core: let dev_set_drvdata return int instead of void as it can fail
On Fri, May 20, 2011 at 02:53:30AM -0500, Milton Miller wrote:
> On Fri, 20 May 2011 about 00:10:40 -0000, Greg Kroah-Hartman wrote:
> >
> > From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> >
> > 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>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
> >
>
> I obviously didn't follow the discussions close enough and got
> confused[1], but I don't like the anticipated fallout of pushing this
> change though all the drivers. Let alone see the arguments that not
> being able to free the device when it fails is no reason to fail.
>
> So, my first question is: When is it legal for a driver to set driver
> data before a device is registered?
A driver cannot set driver data on an unregistered device because it
doesn't get it's hands on it before. So it's only the code that
registers a device that has a chance to do so.

A while back I thought about breaking these constructs by setting
driver_data to NULL before a device is handed to a driver. Never came
around to make a patch tough.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2011-05-20 10:03    [W:0.061 / U:1.644 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site