summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_bus.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2010-06-12 13:20:38 +0000
committerkib <kib@FreeBSD.org>2010-06-12 13:20:38 +0000
commit2605a178f6cbf6e7cfb6b504bb08b984305a055d (patch)
treec2dd794f3616180bb91ead153032bfae8023ddad /sys/kern/subr_bus.c
parentb0d57d4b56d4d65ca0ca32af08a2448072cb86f4 (diff)
downloadFreeBSD-src-2605a178f6cbf6e7cfb6b504bb08b984305a055d.zip
FreeBSD-src-2605a178f6cbf6e7cfb6b504bb08b984305a055d.tar.gz
Add modifications of devctl_notify(9) functions that take flags. Use
flags to specify M_WAITOK/M_NOWAIT. M_WAITOK allows devctl to sleep for the memory allocation. As Warner noted, allowing the functions to sleep might cause reordering of the queued notifications. Reviewed by: imp, jh MFC after: 3 weeks
Diffstat (limited to 'sys/kern/subr_bus.c')
-rw-r--r--sys/kern/subr_bus.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 8b933bd..33a7473 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -539,7 +539,7 @@ devctl_process_running(void)
* that @p data is allocated using the M_BUS malloc type.
*/
void
-devctl_queue_data(char *data)
+devctl_queue_data_f(char *data, int flags)
{
struct dev_event_info *n1 = NULL, *n2 = NULL;
struct proc *p;
@@ -548,7 +548,7 @@ devctl_queue_data(char *data)
goto out;
if (devctl_queue_length == 0)
goto out;
- n1 = malloc(sizeof(*n1), M_BUS, M_NOWAIT);
+ n1 = malloc(sizeof(*n1), M_BUS, flags);
if (n1 == NULL)
goto out;
n1->dei_data = data;
@@ -588,12 +588,19 @@ out:
return;
}
+void
+devctl_queue_data(char *data)
+{
+
+ devctl_queue_data_f(data, M_NOWAIT);
+}
+
/**
* @brief Send a 'notification' to userland, using standard ways
*/
void
-devctl_notify(const char *system, const char *subsystem, const char *type,
- const char *data)
+devctl_notify_f(const char *system, const char *subsystem, const char *type,
+ const char *data, int flags)
{
int len = 0;
char *msg;
@@ -611,7 +618,7 @@ devctl_notify(const char *system, const char *subsystem, const char *type,
if (data != NULL)
len += strlen(data);
len += 3; /* '!', '\n', and NUL */
- msg = malloc(len, M_BUS, M_NOWAIT);
+ msg = malloc(len, M_BUS, flags);
if (msg == NULL)
return; /* Drop it on the floor */
if (data != NULL)
@@ -620,7 +627,15 @@ devctl_notify(const char *system, const char *subsystem, const char *type,
else
snprintf(msg, len, "!system=%s subsystem=%s type=%s\n",
system, subsystem, type);
- devctl_queue_data(msg);
+ devctl_queue_data_f(msg, flags);
+}
+
+void
+devctl_notify(const char *system, const char *subsystem, const char *type,
+ const char *data)
+{
+
+ devctl_notify_f(system, subsystem, type, data, M_NOWAIT);
}
/*
OpenPOWER on IntegriCloud