public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Deepak Saxena <dsaxena@plexity.net>
Cc: akpm@osdl.org, torvalds@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2.6] Fix dev_printk to work with unclaimed devices
Date: Thu, 26 Feb 2004 10:53:24 -0800	[thread overview]
Message-ID: <20040226185324.GA11980@kroah.com> (raw)
In-Reply-To: <20040226183439.GA17722@plexity.net>

On Thu, Feb 26, 2004 at 11:34:39AM -0700, Deepak Saxena wrote:
> 
> I need to do some fixup in platform_notify() and when trying to 
> use the dev_* print functions for informational messages, they OOPs 
> b/c the current code assumes that dev->driver exists. This is not the 
> case since platform_notify() is called before a device has been attached
> to any driver. 

Yeah, this "limitation" of the dev_* printks have been known for a
while, and it was determined that for situations like this, it's not
worth using those calls.

I have a patch somewhere in my tree that will give you a nice WARN()
output if this ever happens, so as to help when trying to port a new bus
to the driver model, but it's too ugly for mainline.  Ah, found it, it's
below...

thanks,

greg k-h


diff -Nru a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h	Thu Feb 26 10:48:37 2004
+++ b/include/linux/device.h	Thu Feb 26 10:48:37 2004
@@ -394,8 +394,20 @@
 extern void firmware_unregister(struct subsystem *);
 
 /* debugging and troubleshooting/diagnostic helpers. */
+#ifdef CONFIG_DEBUG_DEV_PRINTK
+#define dev_printk(level, dev, format, arg...)			\
+	do {							\
+		if (!(dev) || !(dev)->driver)			\
+			WARN_ON(1);				\
+		else						\
+			printk(level "%s %s: " format , 	\
+				(dev)->driver->name , 		\
+				(dev)->bus_id , ## arg);	\
+	} while (0)
+#else
 #define dev_printk(level, dev, format, arg...)	\
 	printk(level "%s %s: " format , (dev)->driver->name , (dev)->bus_id , ## arg)
+#endif
 
 #ifdef DEBUG
 #define dev_dbg(dev, format, arg...)		\

  parent reply	other threads:[~2004-02-26 18:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-26 18:34 [PATCH 2.6] Fix dev_printk to work with unclaimed devices Deepak Saxena
2004-02-26 18:45 ` Linus Torvalds
2004-02-26 18:53 ` Greg KH [this message]
2004-02-26 20:47   ` Deepak Saxena

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=20040226185324.GA11980@kroah.com \
    --to=greg@kroah.com \
    --cc=akpm@osdl.org \
    --cc=dsaxena@plexity.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.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