static int mtk_cl_shutdown_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) { #if defined(MTK_COOLER_SHUTDOWN_SIGNAL) //volatile unsigned long original_state; #endif //mtk_cooler_shutdown_dprintk("mtk_cl_shutdown_set_cur_state() %s %d\n", cdev->type, state); #if defined(MTK_COOLER_SHUTDOWN_SIGNAL) //original_state = *((unsigned long*) cdev->devdata); #endif *((unsigned long*) cdev->devdata) = state; if (0 == state) { if (sd_cnt > 0) sd_cnt--; else ; } else if (1 == state) { sd_cnt++; } if (sd_debouncet == sd_cnt) { #if defined(MTK_COOLER_SHUTDOWN_UEVENT) { // send uevent to notify current call must be dropped char event[] = "SHUTDOWN=1"; char *envp[] = { event, NULL }; kobject_uevent_env(&(cdev->device.kobj), KOBJ_CHANGE, envp); } #endif #if defined(MTK_COOLER_SHUTDOWN_SIGNAL) if (0 == sd_happened) // make this an edge trigger instead of level trigger { // send signal to target process _mtk_cl_sd_send_signal(); sd_happened = 1; } #endif } return 0; }
static int mtk_cl_shutdown_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) { struct sd_state *cl_state = (struct sd_state *) cdev->devdata; #if defined(MTK_COOLER_SHUTDOWN_SIGNAL) volatile unsigned long original_state; #endif /* mtk_cooler_shutdown_dprintk("mtk_cl_shutdown_set_cur_state() %s %d\n", cdev->type, state); */ if (!cl_state) return -1; #if defined(MTK_COOLER_SHUTDOWN_SIGNAL) original_state = cl_state->state; #endif cl_state->state = state; if (0 == state) { if (cl_state->sd_cnt > 0) cl_state->sd_cnt--; } else if (1 == state) { cl_state->sd_cnt++; } if (sd_debouncet == cl_state->sd_cnt) { #if defined(MTK_COOLER_SHUTDOWN_UEVENT) { /* send uevent to notify current call must be dropped */ char event[11] = "SHUTDOWN=1"; char *envp[2] = { event, NULL }; kobject_uevent_env(&(cdev->device.kobj), KOBJ_CHANGE, envp); } #endif #if defined(MTK_COOLER_SHUTDOWN_SIGNAL) if (0 == sd_happened) { /* make this an edge trigger instead of level trigger */ /* send signal to target process */ _mtk_cl_sd_send_signal(); sd_happened = 1; } #endif } return 0; }