in char/bbc_envctrl.c [566:592]
int bbc_envctrl_init(struct bbc_i2c_bus *bp)
{
struct platform_device *op;
int temp_index = 0;
int fan_index = 0;
int devidx = 0;
while ((op = bbc_i2c_getdev(bp, devidx++)) != NULL) {
if (of_node_name_eq(op->dev.of_node, "temperature"))
attach_one_temp(bp, op, temp_index++);
if (of_node_name_eq(op->dev.of_node, "fan-control"))
attach_one_fan(bp, op, fan_index++);
}
if (temp_index != 0 && fan_index != 0) {
kenvctrld_task = kthread_run(kenvctrld, NULL, "kenvctrld");
if (IS_ERR(kenvctrld_task)) {
int err = PTR_ERR(kenvctrld_task);
kenvctrld_task = NULL;
destroy_all_temps(bp);
destroy_all_fans(bp);
return err;
}
}
return 0;
}