static int pcb_get_temp(struct thermal_dev *tdev) { struct platform_device *pdev = to_platform_device(tdev->dev); struct pcb_temp_sensor *temp_sensor = platform_get_drvdata(pdev); temp_sensor->therm_fw->current_temp = pcb_read_current_temp(temp_sensor); return temp_sensor->therm_fw->current_temp; }
static int pcb_temp_sensor_read_temp(struct device *dev, struct device_attribute *devattr, char *buf) { struct platform_device *pdev = to_platform_device(dev); struct pcb_temp_sensor *temp_sensor = platform_get_drvdata(pdev); int temp = 0; temp = pcb_read_current_temp(temp_sensor); return sprintf(buf, "%d\n", temp); }
static int pcb_get_temp(struct thermal_dev *tdev) { struct platform_device *pdev = to_platform_device(tdev->dev); struct pcb_temp_sensor *temp_sensor = platform_get_drvdata(pdev); int temp = 0, retry = 10; do { temp = pcb_read_current_temp(temp_sensor); msleep(1); } while (temp < 0 && retry-- ); temp_sensor->therm_fw->current_temp = temp; return temp; }
static int pcb_temp_sensor_read_temp(struct device *dev, struct device_attribute *devattr, char *buf) { struct platform_device *pdev = to_platform_device(dev); struct pcb_temp_sensor *temp_sensor = platform_get_drvdata(pdev); int temp = 0, retry = 10; do { temp = pcb_read_current_temp(temp_sensor); msleep(1); } while(temp < 0 && retry--); return sprintf(buf, "%d\n", temp); }
static void pcb_report_fw_temp(struct thermal_dev *tdev) { struct platform_device *pdev = to_platform_device(tdev->dev); struct pcb_temp_sensor *temp_sensor = platform_get_drvdata(pdev); int ret; pcb_read_current_temp(temp_sensor); if (temp_sensor->therm_fw->current_temp != -EINVAL) { ret = thermal_sensor_set_temp(temp_sensor->therm_fw); if (ret == -ENODEV) pr_err("%s:thermal_sensor_set_temp reports error\n", __func__); else cancel_delayed_work_sync(&temp_sensor->pcb_sensor_work); kobject_uevent(&temp_sensor->dev->kobj, KOBJ_CHANGE); } }