]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - lib/kobject_uevent.c
[ATM]: Annotations.
[linux-2.6-omap-h63xx.git] / lib / kobject_uevent.c
index 982226daf9398112185a5eb717c28d396fcb9341..a1922765ff315dfe1a90879f567c82e08521eaa2 100644 (file)
 #define BUFFER_SIZE    2048    /* buffer for the variables */
 #define NUM_ENVP       32      /* number of env pointers */
 
-#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
+#if defined(CONFIG_HOTPLUG)
 u64 uevent_seqnum;
 char uevent_helper[UEVENT_HELPER_PATH_LEN] = "/sbin/hotplug";
 static DEFINE_SPINLOCK(sequence_lock);
+#if defined(CONFIG_NET)
 static struct sock *uevent_sock;
+#endif
 
 static char *action_to_string(enum kobject_action action)
 {
@@ -48,18 +50,22 @@ static char *action_to_string(enum kobject_action action)
                return "offline";
        case KOBJ_ONLINE:
                return "online";
+       case KOBJ_MOVE:
+               return "move";
        default:
                return NULL;
        }
 }
 
 /**
- * kobject_uevent - notify userspace by ending an uevent
+ * kobject_uevent_env - send an uevent with environmental data
  *
- * @action: action that is happening (usually KOBJ_ADD and KOBJ_REMOVE)
+ * @action: action that is happening (usually KOBJ_MOVE)
  * @kobj: struct kobject that the action is happening to
+ * @envp_ext: pointer to environmental data
  */
-void kobject_uevent(struct kobject *kobj, enum kobject_action action)
+void kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
+                       char *envp_ext[])
 {
        char **envp;
        char *buffer;
@@ -74,6 +80,7 @@ void kobject_uevent(struct kobject *kobj, enum kobject_action action)
        char *seq_buff;
        int i = 0;
        int retval;
+       int j;
 
        pr_debug("%s\n", __FUNCTION__);
 
@@ -132,7 +139,8 @@ void kobject_uevent(struct kobject *kobj, enum kobject_action action)
        scratch += sprintf (scratch, "DEVPATH=%s", devpath) + 1;
        envp [i++] = scratch;
        scratch += sprintf(scratch, "SUBSYSTEM=%s", subsystem) + 1;
-
+       for (j = 0; envp_ext && envp_ext[j]; j++)
+               envp[i++] = envp_ext[j];
        /* just reserve the space, overwrite it after kset call has returned */
        envp[i++] = seq_buff = scratch;
        scratch += strlen("SEQNUM=18446744073709551616") + 1;
@@ -155,6 +163,7 @@ void kobject_uevent(struct kobject *kobj, enum kobject_action action)
        spin_unlock(&sequence_lock);
        sprintf(seq_buff, "SEQNUM=%llu", (unsigned long long)seq);
 
+#if defined(CONFIG_NET)
        /* send netlink message */
        if (uevent_sock) {
                struct sk_buff *skb;
@@ -179,6 +188,7 @@ void kobject_uevent(struct kobject *kobj, enum kobject_action action)
                        netlink_broadcast(uevent_sock, skb, 0, 1, GFP_KERNEL);
                }
        }
+#endif
 
        /* call uevent_helper, usually only enabled during early boot */
        if (uevent_helper[0]) {
@@ -196,6 +206,20 @@ exit:
        kfree(envp);
        return;
 }
+
+EXPORT_SYMBOL_GPL(kobject_uevent_env);
+
+/**
+ * kobject_uevent - notify userspace by ending an uevent
+ *
+ * @action: action that is happening (usually KOBJ_ADD and KOBJ_REMOVE)
+ * @kobj: struct kobject that the action is happening to
+ */
+void kobject_uevent(struct kobject *kobj, enum kobject_action action)
+{
+       kobject_uevent_env(kobj, action, NULL);
+}
+
 EXPORT_SYMBOL_GPL(kobject_uevent);
 
 /**
@@ -249,6 +273,7 @@ int add_uevent_var(char **envp, int num_envp, int *cur_index,
 }
 EXPORT_SYMBOL_GPL(add_uevent_var);
 
+#if defined(CONFIG_NET)
 static int __init kobject_uevent_init(void)
 {
        uevent_sock = netlink_kernel_create(NETLINK_KOBJECT_UEVENT, 1, NULL,
@@ -264,5 +289,6 @@ static int __init kobject_uevent_init(void)
 }
 
 postcore_initcall(kobject_uevent_init);
+#endif
 
 #endif /* CONFIG_HOTPLUG */