public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH][0/2] [RESEND] Hotplug variable patches
@ 2004-09-27 16:31 Roland Dreier
  2004-09-27 16:31 ` [PATCH][1/2] [RESEND] kobject: add HOTPLUG_ENV_VAR Roland Dreier
  0 siblings, 1 reply; 11+ messages in thread
From: Roland Dreier @ 2004-09-27 16:31 UTC (permalink / raw)
  To: greg, linux-kernel

(Resending because this seems to have gotten dropped)

Hi Greg,

When I wanted to implement some environment variables in my hotplug
method, I looked for an example of how to do it.  I noticed two
things: adding values ends up being kind of messy, and the hotplug
method in drivers/usb/core/usb.c is subtly wrong!  These two patches
attempt to fix both of those problems.

Let me know if you don't like the HOTPLUG_ENV_VAR name and want
something different.

If you apply these, I'll send patches to use HOTPLUG_ENV_VAR in net/,
drivers/ieee1394/, etc.

Thanks,
  Roland


^ permalink raw reply	[flat|nested] 11+ messages in thread
* [PATCH][1/2] [RESEND] kobject: add HOTPLUG_ENV_VAR
@ 2004-09-27 16:59 Roland Dreier
  2004-09-27 16:59 ` [PATCH][2/2] [RESEND] USB: use HOTPLUG_ENV_VAR in core/usb.c Roland Dreier
  0 siblings, 1 reply; 11+ messages in thread
From: Roland Dreier @ 2004-09-27 16:59 UTC (permalink / raw)
  To: greg, linux-kernel

Add a HOTPLUG_ENV_VAR macro to <linux/kobject.h>.  There's a lot of
boilerplate code involved in setting environment variables in a
hotplug method, so we should have a convenience macro to consolidate
it (and avoid subtle bugs).


Signed-off-by: Roland Dreier <roland@topspin.com>

Index: linux-bk/include/linux/kobject.h
===================================================================
--- linux-bk.orig/include/linux/kobject.h	2004-09-12 15:17:02.000000000 -0700
+++ linux-bk/include/linux/kobject.h	2004-09-12 19:44:31.000000000 -0700
@@ -95,6 +95,20 @@
 			int num_envp, char *buffer, int buffer_size);
 };
 
+#define HOTPLUG_ENV_VAR(_buf, _size, _envp, _nenvp, _index, _fmt, _arg...) \
+	({								\
+		int len, ret = 0;					\
+		_envp[_index++] = _buf;					\
+		len = snprintf(_buf, _size, _fmt, ## _arg);		\
+		if (_size - len <= 0 || _index >= _nenvp)		\
+			ret = -ENOMEM;					\
+		else {							\
+			_buf  += len + 1;				\
+			_size -= len + 1;				\
+		}							\
+		ret;							\
+	})
+
 struct kset {
 	struct subsystem	* subsys;
 	struct kobj_type	* ktype;


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-09-28 22:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-27 16:31 [PATCH][0/2] [RESEND] Hotplug variable patches Roland Dreier
2004-09-27 16:31 ` [PATCH][1/2] [RESEND] kobject: add HOTPLUG_ENV_VAR Roland Dreier
2004-09-27 16:31   ` [PATCH][2/2] [RESEND] USB: use HOTPLUG_ENV_VAR in core/usb.c Roland Dreier
2004-09-27 20:10   ` [PATCH][1/2] [RESEND] kobject: add HOTPLUG_ENV_VAR Paul Jackson
2004-09-27 22:10     ` Roland Dreier
2004-09-28  6:43       ` Paul Jackson
2004-09-28 15:29         ` Roland Dreier
2004-09-28 16:00           ` Paul Jackson
2004-09-28 16:13             ` Roland Dreier
2004-09-28 21:56               ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2004-09-27 16:59 Roland Dreier
2004-09-27 16:59 ` [PATCH][2/2] [RESEND] USB: use HOTPLUG_ENV_VAR in core/usb.c Roland Dreier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox