Skip to contentSkip to conversation

NULL arg for get_device() / put_device()

PATCH Applied Hannes Reinecke 2 participants 4 messages Sep 27, 2004 – Sep 29, 2004

lore
Share & tools
lore
#0 lore raw

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

Signature · 15 lines
Dr. Hannes Reinecke			[email protected]
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#1 lore raw
Quoted 4 lines · Hannes Reinecke

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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#2 lore raw

PATCH 1/1 NULL arg for get_device() / put_device()

Quoted 4 lines · Greg KH
Quoted 2 lines · Hannes Reinecke

Hi all,

Quoted 8 lines
Quoted 2 lines

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

Signature · 4 lines
Dr. Hannes Reinecke			[email protected]
SuSE Linux AG				S390 & zSeries
Maxfeldstraße 5				+49 911 74053 688
90409 Nürnberg				http://www.suse.de

# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet
# 2004/09/28 08:59:54+02:00 [email protected]
# Since get_device() accepts a NULL argument, put_device() should do so, too.
#
# Signed-off-by: Hannes Reinecke <[email protected]>
#

# drivers/base/core.c
#   2004/09/28 08:59:49+02:00 [email protected] +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);
 }
Applied
#3 lore raw
Quoted 9 lines · Hannes Reinecke
Quoted 8 lines · Greg KH
Quoted 4 lines · Hannes Reinecke

Hi all,

is there a specific reason that get_device accepts NULL as argument, whereas put_device() does not?

Quoted 5 lines
Quoted 4 lines

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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel