MCPcopy Create free account
hub / github.com/F-Stack/f-stack / axp2xx_sysctl

Function axp2xx_sysctl

freebsd/arm/allwinner/axp209.c:778–811  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

776 sizeof(struct axp2xx_reg_sc), regnode_class);
777
778static int
779axp2xx_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
813static void
814axp2xx_shutdown(void *devp, int howto)

Callers

nothing calls this directly

Calls 3

device_get_softcFunction · 0.85
axp2xx_readFunction · 0.85
sysctl_handle_opaqueFunction · 0.85

Tested by

no test coverage detected