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

Function max10_sensor_init

dpdk/drivers/raw/ifpga/base/opae_intel_max10.c:831–954  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

829}
830
831static int
832max10_sensor_init(struct intel_max10_device *dev, int parent)
833{
834 int i, ret = 0, offset = 0;
835 const fdt32_t *num;
836 const char *ptr;
837 u64 start, size;
838 struct raw_sensor_info *raw;
839 struct opae_sensor_info *sensor;
840 char *fdt_root = dev->fdt_root;
841
842 if (!fdt_root) {
843 dev_debug(dev, "skip sensor init as not find Device Tree\n");
844 return 0;
845 }
846
847 fdt_for_each_subnode(offset, fdt_root, parent) {
848 ptr = fdt_get_name(fdt_root, offset, NULL);
849 if (!ptr) {
850 dev_err(dev, "failed to fdt get name\n");
851 continue;
852 }
853
854 if (!strstr(ptr, "sensor")) {
855 dev_debug(dev, "%s is not a sensor node\n", ptr);
856 continue;
857 }
858
859 dev_debug(dev, "found sensor node %s\n", ptr);
860
861 raw = (struct raw_sensor_info *)opae_zmalloc(sizeof(*raw));
862 if (!raw) {
863 ret = -ENOMEM;
864 goto free_sensor;
865 }
866
867 raw->name = fdt_getprop(fdt_root, offset, "sensor_name", NULL);
868 if (!raw->name) {
869 ret = -EINVAL;
870 goto free_sensor;
871 }
872
873 raw->type = fdt_getprop(fdt_root, offset, "type", NULL);
874 if (!raw->type) {
875 ret = -EINVAL;
876 goto free_sensor;
877 }
878
879 for (i = SENSOR_REG_VALUE; i < SENSOR_REG_MAX; i++) {
880 ret = fdt_get_named_reg(fdt_root, offset,
881 sensor_reg_name[i], &start,
882 &size);
883 if (ret) {
884 dev_debug(dev, "no found %d: sensor node %s, %s\n",
885 ret, ptr, sensor_reg_name[i]);
886 if (i == SENSOR_REG_VALUE) {
887 ret = -EINVAL;
888 goto free_sensor;

Callers 2

max10_secure_hw_initFunction · 0.85
max10_non_secure_hw_initFunction · 0.85

Calls 7

fdt_get_nameFunction · 0.85
strstrFunction · 0.85
fdt_getpropFunction · 0.85
fdt_get_named_regFunction · 0.85
fdt32_to_cpuFunction · 0.85
max10_add_sensorFunction · 0.85
max10_sensor_uinitFunction · 0.85

Tested by

no test coverage detected