static int __init lenovo_sl_laptop_init(void) { int ret; acpi_status status; hkey_handle = ec0_handle = NULL; if (acpi_disabled) return -ENODEV; lensl_wq = create_singlethread_workqueue(LENSL_WORKQUEUE_NAME); if (!lensl_wq) { vdbg_printk(LENSL_ERR, "Failed to create a workqueue\n"); return -ENOMEM; } status = acpi_get_handle(NULL, LENSL_HKEY, &hkey_handle); if (ACPI_FAILURE(status)) { vdbg_printk(LENSL_ERR, "Failed to get ACPI handle for %s\n", LENSL_HKEY); return -ENODEV; } status = acpi_get_handle(NULL, LENSL_EC0, &ec0_handle); if (ACPI_FAILURE(status)) { vdbg_printk(LENSL_ERR, "Failed to get ACPI handle for %s\n", LENSL_EC0); return -ENODEV; } lensl_pdev = platform_device_register_simple(LENSL_DRVR_NAME, -1, NULL, 0); if (IS_ERR(lensl_pdev)) { ret = PTR_ERR(lensl_pdev); lensl_pdev = NULL; vdbg_printk(LENSL_ERR, "Failed to register platform device\n"); return ret; } ret = hkey_inputdev_init(); if (ret) return -ENODEV; radio_init(LENSL_BLUETOOTH); radio_init(LENSL_WWAN); radio_init(LENSL_UWB); led_init(); mutex_init(&hkey_poll_mutex); hwmon_init(); if (debug_ec) lenovo_sl_procfs_init(); vdbg_printk(LENSL_INFO, "Loaded Lenovo ThinkPad SL Series driver\n"); return 0; }
static int __init lenovo_sl_laptop_init(void) { int ret; acpi_status status; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28) if (!acpi_video_backlight_support()) control_backlight = 1; #endif hkey_handle = ec0_handle = NULL; if (acpi_disabled) return -ENODEV; lensl_wq = create_singlethread_workqueue(LENSL_WORKQUEUE_NAME); if (!lensl_wq) { vdbg_printk(LENSL_ERR, "Failed to create a workqueue\n"); return -ENOMEM; } status = acpi_get_handle(NULL, LENSL_HKEY, &hkey_handle); if (ACPI_FAILURE(status)) { vdbg_printk(LENSL_ERR, "Failed to get ACPI handle for %s\n", LENSL_HKEY); return -ENODEV; } status = acpi_get_handle(NULL, LENSL_EC0, &ec0_handle); if (ACPI_FAILURE(status)) { vdbg_printk(LENSL_ERR, "Failed to get ACPI handle for %s\n", LENSL_EC0); return -ENODEV; } lensl_pdev = platform_device_register_simple(LENSL_DRVR_NAME, -1, NULL, 0); if (IS_ERR(lensl_pdev)) { ret = PTR_ERR(lensl_pdev); lensl_pdev = NULL; vdbg_printk(LENSL_ERR, "Failed to register platform device\n"); return ret; } ret = hkey_inputdev_init(); if (ret) return -ENODEV; bluetooth_init(); if (control_backlight) backlight_init(); led_init(); mutex_init(&hkey_poll_mutex); hkey_poll_start(); hwmon_init(); if (debug_ec) lenovo_sl_procfs_init(); vdbg_printk(LENSL_INFO, "Loaded Lenovo ThinkPad SL Series driver\n"); return 0; }
/* * Main entry point */ int main(int argc, char **argv) { int opt_v = 0; char *opt_c = NULL; char *opt_s = NULL; int ch; /* check we're running as root */ if(getuid() != 0) { errno = EACCES; ERR("I must be run as root\n"); return -1; } /* handle command line arguments */ while ((ch = getopt(argc, argv, "hvc:s:")) != -1) { switch (ch) { case 'v': // enables verbose logging opt_v++; break; case 'c': // allows use to override location of config opt_c = strdup(optarg); break; case 's': // changes location of unix socket opt_s = strdup(optarg); break; case 'h': // help! default: usage(argc, argv); } } argc -= optind; argv += optind; /* set the logging level */ if (opt_v == 0) { opt_v = LOG_LEVEL_DEFAULT; } log_level(opt_v); INF("thermal manager starting...\n"); /* bring up "subsystems" */ sensor_init(); hwmon_init(); actions_init(); /* read and parse sensor config file */ if (opt_c == NULL) { opt_c = strdup(DEFAULT_CONFIG_FILE_PATH); if (opt_c == NULL) { ERR("unable to allocate memory\n"); return -1; } } INF("parsing thermal.conf...\n"); if (parse_config(opt_c) < 0) { ERR("failed to parse config file\n"); return -1; } /* discover HWMON sensors */ INF("discovering platform HWMON sensors...\n"); if (hwmon_find_sensors()) { ERR("failed to find platform HWMON sensors\n"); return -1; } /* startup client socket */ if (opt_s != NULL) { INF("overriding default socket path (%s)!\n", opt_s); socket_setunixsocket(opt_s); } INF("starting client communication socket...\n"); if (socket_init()) { ERR("unable to start socket communication\n"); return -1; } /* set sensor values & start monitoring */ INF("configuring initial sensor value...\n"); if (sensor_configure_all()) { ERR("Unable to configure HWMON sensors\n"); return -1; } /* finally stop and wait for the server thread to * shutdown (ie a catostrophic error has occured) */ socket_wait(); INF("thermal manager going down!\n"); free(opt_c); if (opt_s) { free(opt_s); } return 0; }