Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F148636270
D54439.id169370.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D54439.id169370.diff
View Options
diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c
--- a/sys/dev/asmc/asmc.c
+++ b/sys/dev/asmc/asmc.c
@@ -108,6 +108,7 @@
static int asmc_mbp_sysctl_light_right(SYSCTL_HANDLER_ARGS);
static int asmc_mbp_sysctl_light_control(SYSCTL_HANDLER_ARGS);
static int asmc_mbp_sysctl_light_left_10byte(SYSCTL_HANDLER_ARGS);
+static int asmc_wol_sysctl(SYSCTL_HANDLER_ARGS);
struct asmc_model {
const char *smc_model; /* smbios.system.product env var. */
@@ -851,9 +852,12 @@
asmc_init(device_t dev)
{
struct asmc_softc *sc = device_get_softc(dev);
+ struct sysctl_ctx_list *sysctlctx;
int i, error = 1;
uint8_t buf[4];
+ sysctlctx = device_get_sysctl_ctx(dev);
+
if (sc->sc_model->smc_sms_x == NULL)
goto nosms;
@@ -923,6 +927,14 @@
out:
asmc_sms_calibrate(dev);
nosms:
+ /* Wake-on-LAN convenience sysctl */
+ SYSCTL_ADD_PROC(sysctlctx,
+ SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
+ OID_AUTO, "wol",
+ CTLTYPE_INT | CTLFLAG_RW,
+ dev, 0, asmc_wol_sysctl, "I",
+ "Wake-on-LAN enable (0=off, 1=on)");
+
sc->sc_nfan = asmc_fan_count(dev);
if (sc->sc_nfan > ASMC_MAXFANS) {
device_printf(dev, "more than %d fans were detected. Please "
@@ -1671,3 +1683,35 @@
return (error);
}
+
+/*
+ * Wake-on-LAN convenience sysctl.
+ * Reading returns 1 if WoL is enabled, 0 if disabled.
+ * Writing 1 enables WoL, 0 disables it.
+ */
+static int
+asmc_wol_sysctl(SYSCTL_HANDLER_ARGS)
+{
+ device_t dev = (device_t) arg1;
+ uint8_t aupo;
+ int val, error;
+
+ /* Read current AUPO value */
+ if (asmc_key_read(dev, "AUPO", &aupo, 1) != 0)
+ return (EIO);
+
+ val = (aupo != 0) ? 1 : 0;
+ error = sysctl_handle_int(oidp, &val, 0, req);
+ if (error || req->newptr == NULL)
+ return (error);
+
+ /* Clamp to 0 or 1 */
+ aupo = (val != 0) ? 1 : 0;
+
+ /* Write AUPO */
+ if (asmc_key_write(dev, "AUPO", &aupo, 1) != 0)
+ return (EIO);
+
+ return (0);
+}
+
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 20, 7:05 AM (6 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27599074
Default Alt Text
D54439.id169370.diff (2 KB)
Attached To
Mode
D54439: asmc: add Wake-on-LAN control via sysctl
Attached
Detach File
Event Timeline
Log In to Comment