static int __init mtk_cooler_kshutdown_init(void) { int err = 0; int i; for (i = MAX_NUM_INSTANCE_MTK_COOLER_KSHUTDOWN; i-- > 0; ) { cl_kshutdown_dev[i] = NULL; cl_kshutdown_state[i] = 0; } //cl_kshutdown_dev = NULL; mtk_cooler_kshutdown_dprintk("init\n"); err = mtk_cooler_kshutdown_register_ltf(); if (err) goto err_unreg; return 0; err_unreg: mtk_cooler_kshutdown_unregister_ltf(); return err; }
static int mtk_cl_kshutdown_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) { /* mtk_cooler_kshutdown_dprintk("mtk_cl_kshutdown_set_cur_state() %s %d\n", cdev->type, state); */ #if 1 *((unsigned long *)cdev->devdata) = state; #else cl_kshutdown_state[(int)cdev->type[16]] = state; #endif if (1 == state) { mtk_cooler_kshutdown_dprintk("%s %s invokes machine_power_off\n", __func__, cdev->type); machine_power_off(); } return 0; }
static void mtk_cooler_kshutdown_unregister_ltf(void) { int i; mtk_cooler_kshutdown_dprintk("unregister ltf\n"); for (i = MAX_NUM_INSTANCE_MTK_COOLER_KSHUTDOWN; i-- > 0;) { if (cl_kshutdown_dev[i]) { mtk_thermal_cooling_device_unregister(cl_kshutdown_dev[i]); cl_kshutdown_dev[i] = NULL; cl_kshutdown_state[i] = 0; } } #if 0 if (cl_kshutdown_dev) { mtk_thermal_cooling_device_unregister(cl_kshutdown_dev); cl_kshutdown_dev = NULL; } #endif }
static int mtk_cooler_kshutdown_register_ltf(void) { int i; mtk_cooler_kshutdown_dprintk("register ltf\n"); for (i = MAX_NUM_INSTANCE_MTK_COOLER_KSHUTDOWN; i-- > 0;) { char temp[20] = { 0 }; sprintf(temp, "mtk-cl-kshutdown%02d", i); cl_kshutdown_dev[i] = mtk_thermal_cooling_device_register(temp, (void *) &cl_kshutdown_state[i], &mtk_cl_kshutdown_ops); } #if 0 cl_kshutdown_dev = mtk_thermal_cooling_device_register("mtk-cl-shutdown", NULL, &mtk_cl_kshutdown_ops); #endif return 0; }
static void __exit mtk_cooler_kshutdown_exit(void) { mtk_cooler_kshutdown_dprintk("exit\n"); mtk_cooler_kshutdown_unregister_ltf(); }