From 887611b1227c95b8d5588f920822435a7021fd2a Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sat, 29 Aug 2020 04:30:06 +0000 Subject: [PATCH] Retire devctl_notify_f() devctl_notify_f isn't needed, so retire it. The flags argument is now unused, so rather than keep it around, retire it. Convert all old users of it to devctl_notify(). This path no longer sleeps, so is safe to call from any context. Since it doesn't sleep, it doesn't need to know if it is OK to sleep or not. Reviewed by: markj@ Differential Revision: https://reviews.freebsd.org/D26140 --- sys/arm/ti/am335x/am335x_pmic.c | 2 +- sys/geom/geom_dev.c | 16 ++++++++-------- sys/kern/kern_conf.c | 2 +- sys/kern/kern_rctl.c | 4 ++-- sys/kern/subr_bus.c | 11 ++--------- sys/sys/devctl.h | 2 -- 6 files changed, 14 insertions(+), 23 deletions(-) diff --git a/sys/arm/ti/am335x/am335x_pmic.c b/sys/arm/ti/am335x/am335x_pmic.c index 50c359a8dd2e..0b0782ab72a6 100644 --- a/sys/arm/ti/am335x/am335x_pmic.c +++ b/sys/arm/ti/am335x/am335x_pmic.c @@ -113,7 +113,7 @@ am335x_pmic_intr(void *arg) if (int_reg.aci) { snprintf(notify_buf, sizeof(notify_buf), "notify=0x%02x", status_reg.acpwr); - devctl_notify_f("ACPI", "ACAD", "power", notify_buf, M_NOWAIT); + devctl_notify("ACPI", "ACAD", "power", notify_buf); } } diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c index 65453dcc9831..9e5dd8d7eed9 100644 --- a/sys/geom/geom_dev.c +++ b/sys/geom/geom_dev.c @@ -213,7 +213,7 @@ g_dev_destroy(void *arg, int flags __unused) sc = cp->private; g_trace(G_T_TOPOLOGY, "g_dev_destroy(%p(%s))", cp, gp->name); snprintf(buf, sizeof(buf), "cdev=%s", gp->name); - devctl_notify_f("GEOM", "DEV", "DESTROY", buf, M_WAITOK); + devctl_notify("GEOM", "DEV", "DESTROY", buf); if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0) g_access(cp, -cp->acr, -cp->acw, -cp->ace); g_detach(cp); @@ -277,13 +277,13 @@ g_dev_set_media(struct g_consumer *cp) sc = cp->private; dev = sc->sc_dev; snprintf(buf, sizeof(buf), "cdev=%s", dev->si_name); - devctl_notify_f("DEVFS", "CDEV", "MEDIACHANGE", buf, M_WAITOK); - devctl_notify_f("GEOM", "DEV", "MEDIACHANGE", buf, M_WAITOK); + devctl_notify("DEVFS", "CDEV", "MEDIACHANGE", buf); + devctl_notify("GEOM", "DEV", "MEDIACHANGE", buf); dev = sc->sc_alias; if (dev != NULL) { snprintf(buf, sizeof(buf), "cdev=%s", dev->si_name); - devctl_notify_f("DEVFS", "CDEV", "MEDIACHANGE", buf, M_WAITOK); - devctl_notify_f("GEOM", "DEV", "MEDIACHANGE", buf, M_WAITOK); + devctl_notify("DEVFS", "CDEV", "MEDIACHANGE", buf); + devctl_notify("GEOM", "DEV", "MEDIACHANGE", buf); } } @@ -308,7 +308,7 @@ g_dev_resize(struct g_consumer *cp) char buf[SPECNAMELEN + 6]; snprintf(buf, sizeof(buf), "cdev=%s", cp->provider->name); - devctl_notify_f("GEOM", "DEV", "SIZECHANGE", buf, M_WAITOK); + devctl_notify("GEOM", "DEV", "SIZECHANGE", buf); } struct g_provider * @@ -379,7 +379,7 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused) g_dev_attrchanged(cp, "GEOM::physpath"); snprintf(buf, sizeof(buf), "cdev=%s", gp->name); - devctl_notify_f("GEOM", "DEV", "CREATE", buf, M_WAITOK); + devctl_notify("GEOM", "DEV", "CREATE", buf); /* * Now add all the aliases for this drive */ @@ -392,7 +392,7 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused) continue; } snprintf(buf, sizeof(buf), "cdev=%s", gap->ga_alias); - devctl_notify_f("GEOM", "DEV", "CREATE", buf, M_WAITOK); + devctl_notify("GEOM", "DEV", "CREATE", buf); } return (gp); diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index f4de19e527cf..b971b7c6d0e7 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -546,7 +546,7 @@ notify(struct cdev *dev, const char *ev, int flags) return; memcpy(data, prefix, sizeof(prefix) - 1); memcpy(data + sizeof(prefix) - 1, dev->si_name, namelen + 1); - devctl_notify_f("DEVFS", "CDEV", ev, data, mflags); + devctl_notify("DEVFS", "CDEV", ev, data); free(data, M_TEMP); } diff --git a/sys/kern/kern_rctl.c b/sys/kern/kern_rctl.c index 68f03f2f6913..8ec66bc64c0a 100644 --- a/sys/kern/kern_rctl.c +++ b/sys/kern/kern_rctl.c @@ -591,8 +591,8 @@ rctl_enforce(struct proc *p, int resource, uint64_t amount) p->p_pid, p->p_ucred->cr_ruid, p->p_ucred->cr_prison->pr_prison_racct->prr_name); sbuf_finish(&sb); - devctl_notify_f("RCTL", "rule", "matched", - sbuf_data(&sb), M_NOWAIT); + devctl_notify("RCTL", "rule", "matched", + sbuf_data(&sb)); sbuf_delete(&sb); free(buf, M_RCTL); link->rrl_exceeded = 1; diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 2232799ebb92..503e73ff59b0 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -651,8 +651,8 @@ devctl_queue(struct dev_event_info *dei) * @brief Send a 'notification' to userland, using standard ways */ void -devctl_notify_f(const char *system, const char *subsystem, const char *type, - const char *data, int flags __unused) +devctl_notify(const char *system, const char *subsystem, const char *type, + const char *data) { struct dev_event_info *dei; struct sbuf sb; @@ -679,13 +679,6 @@ devctl_notify_f(const char *system, const char *subsystem, const char *type, devctl_queue(dei); } -void -devctl_notify(const char *system, const char *subsystem, const char *type, - const char *data) -{ - devctl_notify_f(system, subsystem, type, data, M_NOWAIT); -} - /* * Common routine that tries to make sending messages as easy as possible. * We allocate memory for the data, copy strings into that, but do not diff --git a/sys/sys/devctl.h b/sys/sys/devctl.h index 98ca1fd0f6ef..d952d1a492c8 100644 --- a/sys/sys/devctl.h +++ b/sys/sys/devctl.h @@ -36,8 +36,6 @@ * hook to send the message. */ boolean_t devctl_process_running(void); -void devctl_notify_f(const char *__system, const char *__subsystem, - const char *__type, const char *__data, int __flags); void devctl_notify(const char *__system, const char *__subsystem, const char *__type, const char *__data); struct sbuf;