static void __exit msi_cleanup(void) { if (quirks->load_scm_model) { i8042_remove_filter(msi_laptop_i8042_filter); msi_laptop_input_destroy(); cancel_delayed_work_sync(&msi_rfkill_dwork); cancel_work_sync(&msi_rfkill_work); rfkill_cleanup(); } sysfs_remove_group(&msipf_device->dev.kobj, &msipf_attribute_group); if (!quirks->old_ec_model && threeg_exists) device_remove_file(&msipf_device->dev, &dev_attr_threeg); platform_device_unregister(msipf_device); platform_driver_unregister(&msipf_driver); backlight_device_unregister(msibl_device); if (quirks->old_ec_model) { /* Enable automatic brightness control again */ if (auto_brightness != 2) set_auto_brightness(1); } pr_info("driver unloaded\n"); }
static int __init load_scm_model_init(struct platform_device *sdev) { u8 data; int result; if (!quirks->ec_read_only) { /* allow userland write sysfs file */ pax_open_kernel(); *(void **)&dev_attr_bluetooth.store = store_bluetooth; *(void **)&dev_attr_wlan.store = store_wlan; *(void **)&dev_attr_threeg.store = store_threeg; *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR; *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR; *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR; pax_close_kernel(); } /* disable hardware control by fn key */ result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data); if (result < 0) return result; result = ec_write(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, data | MSI_STANDARD_EC_SCM_LOAD_MASK); if (result < 0) return result; /* initial rfkill */ result = rfkill_init(sdev); if (result < 0) goto fail_rfkill; /* setup input device */ result = msi_laptop_input_setup(); if (result) goto fail_input; result = i8042_install_filter(msi_laptop_i8042_filter); if (result) { pr_err("Unable to install key filter\n"); goto fail_filter; } return 0; fail_filter: msi_laptop_input_destroy(); fail_input: rfkill_cleanup(); fail_rfkill: return result; }
static int __init load_scm_model_init(struct platform_device *sdev) { u8 data; int result; dev_attr_bluetooth.store = store_bluetooth; dev_attr_wlan.store = store_wlan; dev_attr_threeg.store = store_threeg; dev_attr_bluetooth.attr.mode |= S_IWUSR; dev_attr_wlan.attr.mode |= S_IWUSR; dev_attr_threeg.attr.mode |= S_IWUSR; result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data); if (result < 0) return result; result = ec_write(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, data | MSI_STANDARD_EC_SCM_LOAD_MASK); if (result < 0) return result; result = rfkill_init(sdev); if (result < 0) goto fail_rfkill; result = msi_laptop_input_setup(); if (result) goto fail_input; result = i8042_install_filter(msi_laptop_i8042_filter); if (result) { pr_err("Unable to install key filter\n"); goto fail_filter; } return 0; fail_filter: msi_laptop_input_destroy(); fail_input: rfkill_cleanup(); fail_rfkill: return result; }
static int load_scm_model_init(struct platform_device *sdev) { u8 data; int result; /* allow userland write sysfs file */ dev_attr_bluetooth.store = store_bluetooth; dev_attr_wlan.store = store_wlan; dev_attr_threeg.store = store_threeg; dev_attr_bluetooth.attr.mode |= S_IWUSR; dev_attr_wlan.attr.mode |= S_IWUSR; dev_attr_threeg.attr.mode |= S_IWUSR; /* disable hardware control by fn key */ result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data); if (result < 0) return result; result = ec_write(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, data | MSI_STANDARD_EC_SCM_LOAD_MASK); if (result < 0) return result; /* initial rfkill */ result = rfkill_init(sdev); if (result < 0) goto fail_rfkill; result = i8042_install_filter(msi_laptop_i8042_filter); if (result) { printk(KERN_ERR "msi-laptop: Unable to install key filter\n"); goto fail_filter; } return 0; fail_filter: rfkill_cleanup(); fail_rfkill: return result; }
static void __exit msi_cleanup(void) { sysfs_remove_group(&msipf_device->dev.kobj, &msipf_attribute_group); if (!old_ec_model && threeg_exists) device_remove_file(&msipf_device->dev, &dev_attr_threeg); platform_device_unregister(msipf_device); platform_driver_unregister(&msipf_driver); backlight_device_unregister(msibl_device); rfkill_cleanup(); /* Enable automatic brightness control again */ if (auto_brightness != 2) set_auto_brightness(1); printk(KERN_INFO "msi-laptop: driver unloaded.\n"); }
static int __init msi_init(void) { int ret; if (acpi_disabled) return -ENODEV; dmi_check_system(msi_dmi_table); if (!quirks) /* quirks may be NULL if no match in DMI table */ quirks = &quirk_load_scm_model; if (force) quirks = &quirk_old_ec_model; if (!quirks->old_ec_model) get_threeg_exists(); if (auto_brightness < 0 || auto_brightness > 2) return -EINVAL; /* Register backlight stuff */ if (!quirks->old_ec_model || acpi_video_backlight_support()) { pr_info("Brightness ignored, must be controlled by ACPI video driver\n"); } else { struct backlight_properties props; memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_PLATFORM; props.max_brightness = MSI_LCD_LEVEL_MAX - 1; msibl_device = backlight_device_register("msi-laptop-bl", NULL, NULL, &msibl_ops, &props); if (IS_ERR(msibl_device)) return PTR_ERR(msibl_device); } ret = platform_driver_register(&msipf_driver); if (ret) goto fail_backlight; /* Register platform stuff */ msipf_device = platform_device_alloc("msi-laptop-pf", -1); if (!msipf_device) { ret = -ENOMEM; goto fail_platform_driver; } ret = platform_device_add(msipf_device); if (ret) goto fail_platform_device1; if (quirks->load_scm_model && (load_scm_model_init(msipf_device) < 0)) { ret = -EINVAL; goto fail_platform_device1; } ret = sysfs_create_group(&msipf_device->dev.kobj, &msipf_attribute_group); if (ret) goto fail_platform_device2; if (!quirks->old_ec_model) { if (threeg_exists) ret = device_create_file(&msipf_device->dev, &dev_attr_threeg); if (ret) goto fail_platform_device2; } else { ret = sysfs_create_group(&msipf_device->dev.kobj, &msipf_old_attribute_group); if (ret) goto fail_platform_device2; /* Disable automatic brightness control by default because * this module was probably loaded to do brightness control in * software. */ if (auto_brightness != 2) set_auto_brightness(auto_brightness); } pr_info("driver " MSI_DRIVER_VERSION " successfully loaded\n"); return 0; fail_platform_device2: if (quirks->load_scm_model) { i8042_remove_filter(msi_laptop_i8042_filter); cancel_delayed_work_sync(&msi_rfkill_dwork); cancel_work_sync(&msi_rfkill_work); rfkill_cleanup(); } platform_device_del(msipf_device); fail_platform_device1: platform_device_put(msipf_device); fail_platform_driver: platform_driver_unregister(&msipf_driver); fail_backlight: backlight_device_unregister(msibl_device); return ret; }