diff options
author | markj <markj@FreeBSD.org> | 2013-04-08 17:46:45 +0000 |
---|---|---|
committer | markj <markj@FreeBSD.org> | 2013-04-08 17:46:45 +0000 |
commit | a0696b397d54d11a134b0d601561b8b3a89a74c5 (patch) | |
tree | 5f91eff0d0ed32759dc5ded30064257f5ee6a7fd /usr.sbin/mfiutil/mfi_show.c | |
parent | 3b1d7ef89c2c487d251c919e6ae498f60926e0d6 (diff) | |
download | FreeBSD-src-a0696b397d54d11a134b0d601561b8b3a89a74c5.zip FreeBSD-src-a0696b397d54d11a134b0d601561b8b3a89a74c5.tar.gz |
Add support for getting and setting BBU properties related to battery
relearning. Specifically, add subcommands to mfiutil(8) which allow the
user to set the BBU and autolearn modes when the firmware supports it,
and add a subcommand which kicks off a battery relearn.
Reviewed by: sbruno, rstone
Tested by: sbruno
Approved by: rstone (co-mentor)
MFC after: 2 weeks
Sponsored by: Sandvine Incorporated
Diffstat (limited to 'usr.sbin/mfiutil/mfi_show.c')
-rw-r--r-- | usr.sbin/mfiutil/mfi_show.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/usr.sbin/mfiutil/mfi_show.c b/usr.sbin/mfiutil/mfi_show.c index be395bb..06721c2 100644 --- a/usr.sbin/mfiutil/mfi_show.c +++ b/usr.sbin/mfiutil/mfi_show.c @@ -140,9 +140,11 @@ show_battery(int ac, char **av __unused) { struct mfi_bbu_capacity_info cap; struct mfi_bbu_design_info design; + struct mfi_bbu_properties props; struct mfi_bbu_status stat; uint8_t status; - int comma, error, fd, show_capacity; + int comma, error, fd, show_capacity, show_props; + char buf[32]; if (ac != 1) { warnx("show battery: extra arguments"); @@ -186,6 +188,14 @@ show_battery(int ac, char **av __unused) return (error); } + if (mfi_bbu_get_props(fd, &props, &status) < 0) { + error = errno; + warn("Failed to get properties"); + close(fd); + return (error); + } + show_props = (status == MFI_STAT_OK); + printf("mfi%d: Battery State:\n", mfi_unit); printf(" Manufacture Date: %d/%d/%d\n", design.mfg_date >> 5 & 0x0f, design.mfg_date & 0x1f, design.mfg_date >> 9 & 0xffff); @@ -205,6 +215,23 @@ show_battery(int ac, char **av __unused) printf(" Design Voltage: %d mV\n", design.design_voltage); printf(" Current Voltage: %d mV\n", stat.voltage); printf(" Temperature: %d C\n", stat.temperature); + if (show_props) { + mfi_autolearn_period(props.auto_learn_period, buf, sizeof(buf)); + printf(" Autolearn period: %s\n", buf); + if (props.auto_learn_mode != 0) + snprintf(buf, sizeof(buf), "never"); + else + mfi_next_learn_time(props.next_learn_time, buf, + sizeof(buf)); + printf(" Next learn time: %s\n", buf); + printf(" Learn delay interval: %u hour%s\n", + props.learn_delay_interval, + props.learn_delay_interval != 1 ? "s" : ""); + mfi_autolearn_mode(props.auto_learn_mode, buf, sizeof(buf)); + printf(" Autolearn mode: %s\n", buf); + if (props.bbu_mode != 0) + printf(" BBU Mode: %d\n", props.bbu_mode); + } printf(" Status:"); comma = 0; if (stat.fw_status & MFI_BBU_STATE_PACK_MISSING) { |