| 776 | sizeof(struct axp2xx_reg_sc), regnode_class); |
| 777 | |
| 778 | static int |
| 779 | axp2xx_sysctl(SYSCTL_HANDLER_ARGS) |
| 780 | { |
| 781 | struct axp2xx_softc *sc; |
| 782 | device_t dev = arg1; |
| 783 | enum axp2xx_sensor sensor = arg2; |
| 784 | uint8_t data[2]; |
| 785 | int val, error, i, found; |
| 786 | |
| 787 | sc = device_get_softc(dev); |
| 788 | |
| 789 | for (found = 0, i = 0; i < sc->nsensors; i++) { |
| 790 | if (sc->sensors[i].id == sensor) { |
| 791 | found = 1; |
| 792 | break; |
| 793 | } |
| 794 | } |
| 795 | |
| 796 | if (found == 0) |
| 797 | return (ENOENT); |
| 798 | |
| 799 | error = axp2xx_read(dev, sc->sensors[i].value_reg, data, 2); |
| 800 | if (error != 0) |
| 801 | return (error); |
| 802 | |
| 803 | val = ((data[0] & sc->sensors[i].h_value_mask) << |
| 804 | sc->sensors[i].h_value_shift); |
| 805 | val |= ((data[1] & sc->sensors[i].l_value_mask) << |
| 806 | sc->sensors[i].l_value_shift); |
| 807 | val *= sc->sensors[i].value_step; |
| 808 | val += sc->sensors[i].value_convert; |
| 809 | |
| 810 | return sysctl_handle_opaque(oidp, &val, sizeof(val), req); |
| 811 | } |
| 812 | |
| 813 | static void |
| 814 | axp2xx_shutdown(void *devp, int howto) |
nothing calls this directly
no test coverage detected