* NULL arg for get_device() / put_device()
@ 2004-09-27 12:21 Hannes Reinecke
2004-09-28 1:28 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Hannes Reinecke @ 2004-09-27 12:21 UTC (permalink / raw)
To: linux-hotplug
Hi all,
is there a specific reason that get_device accepts NULL as argument,
whereas put_device() does not?
Currently, I'm doing
dev->cdev.dev = get_device(dev->dev);
if (class_device_register(&dev->cdev)) {
if (dev->dev)
put_device(dev->dev);
return;
}
which is a bit unwieldy.
Or is there a smarter way?
Cheers,
Hannes
--
Dr. Hannes Reinecke hare@suse.de
SuSE Linux AG S390 & zSeries
Maxfeldstraße 5 +49 911 74053 688
90409 Nürnberg http://www.suse.de
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: NULL arg for get_device() / put_device()
2004-09-27 12:21 NULL arg for get_device() / put_device() Hannes Reinecke
@ 2004-09-28 1:28 ` Greg KH
2004-09-28 7:03 ` [PATCH] " Hannes Reinecke
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2004-09-28 1:28 UTC (permalink / raw)
To: linux-hotplug
On Mon, Sep 27, 2004 at 02:21:49PM +0200, Hannes Reinecke wrote:
> Hi all,
>
> is there a specific reason that get_device accepts NULL as argument,
> whereas put_device() does not?
Um, I guess I never thought about it :)
I don't see why it wouldn't take it, feel free to send a patch.
thanks,
greg k-h
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] NULL arg for get_device() / put_device()
2004-09-28 1:28 ` Greg KH
@ 2004-09-28 7:03 ` Hannes Reinecke
2004-09-29 23:27 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Hannes Reinecke @ 2004-09-28 7:03 UTC (permalink / raw)
To: Greg KH; +Cc: hotplug, Linux Kernel
[-- Attachment #1: Type: text/plain, Size: 533 bytes --]
Greg KH wrote:
> On Mon, Sep 27, 2004 at 02:21:49PM +0200, Hannes Reinecke wrote:
>
>>Hi all,
>>
>>is there a specific reason that get_device accepts NULL as argument,
>>whereas put_device() does not?
>
>
> Um, I guess I never thought about it :)
>
> I don't see why it wouldn't take it, feel free to send a patch.
>
Here it is. Please apply.
Cheers,
Hannes
--
Dr. Hannes Reinecke hare@suse.de
SuSE Linux AG S390 & zSeries
Maxfeldstraße 5 +49 911 74053 688
90409 Nürnberg http://www.suse.de
[-- Attachment #2: null-argument-for-put_device.patch --]
[-- Type: text/x-patch, Size: 694 bytes --]
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2004/09/28 08:59:54+02:00 hare@lammermuir.suse.de
# Since get_device() accepts a NULL argument, put_device() should do so, too.
#
# Signed-off-by: Hannes Reinecke <hare@suse.de>
#
# drivers/base/core.c
# 2004/09/28 08:59:49+02:00 hare@lammermuir.suse.de +2 -1
# put_device() should accept a NULL argument.
#
diff -Nru a/drivers/base/core.c b/drivers/base/core.c
--- a/drivers/base/core.c 2004-09-28 09:01:20 +02:00
+++ b/drivers/base/core.c 2004-09-28 09:01:20 +02:00
@@ -293,7 +293,8 @@
*/
void put_device(struct device * dev)
{
- kobject_put(&dev->kobj);
+ if (dev)
+ kobject_put(&dev->kobj);
}
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] NULL arg for get_device() / put_device()
2004-09-28 7:03 ` [PATCH] " Hannes Reinecke
@ 2004-09-29 23:27 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2004-09-29 23:27 UTC (permalink / raw)
To: Hannes Reinecke; +Cc: hotplug, Linux Kernel
On Tue, Sep 28, 2004 at 09:03:21AM +0200, Hannes Reinecke wrote:
> Greg KH wrote:
> >On Mon, Sep 27, 2004 at 02:21:49PM +0200, Hannes Reinecke wrote:
> >
> >>Hi all,
> >>
> >>is there a specific reason that get_device accepts NULL as argument,
> >>whereas put_device() does not?
> >
> >
> >Um, I guess I never thought about it :)
> >
> >I don't see why it wouldn't take it, feel free to send a patch.
> >
> Here it is. Please apply.
Applied, thanks.
greg k-h
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-09-29 23:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-27 12:21 NULL arg for get_device() / put_device() Hannes Reinecke
2004-09-28 1:28 ` Greg KH
2004-09-28 7:03 ` [PATCH] " Hannes Reinecke
2004-09-29 23:27 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).