static int __devinit toshiba_acpi_add(struct acpi_device *acpi_dev) { struct toshiba_acpi_dev *dev; const char *hci_method; u32 dummy; bool bt_present; int ret = 0; struct backlight_properties props; if (toshiba_acpi) return -EBUSY; pr_info("Toshiba Laptop ACPI Extras version %s\n", TOSHIBA_ACPI_VERSION); hci_method = find_hci_method(acpi_dev->handle); if (!hci_method) { pr_err("HCI interface not found\n"); return -ENODEV; } dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; dev->acpi_dev = acpi_dev; dev->method_hci = hci_method; acpi_dev->driver_data = dev; if (toshiba_acpi_setup_keyboard(dev)) pr_info("Unable to activate hotkeys\n"); mutex_init(&dev->mutex); props.type = BACKLIGHT_PLATFORM; props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1; dev->backlight_dev = backlight_device_register("toshiba", &acpi_dev->dev, dev, &toshiba_backlight_data, &props); if (IS_ERR(dev->backlight_dev)) { ret = PTR_ERR(dev->backlight_dev); pr_err("Could not register toshiba backlight device\n"); dev->backlight_dev = NULL; goto error; } dev->backlight_dev->props.brightness = get_lcd(dev->backlight_dev); /* */ if (hci_get_bt_present(dev, &bt_present) == HCI_SUCCESS && bt_present) { dev->bt_rfk = rfkill_alloc("Toshiba Bluetooth", &acpi_dev->dev, RFKILL_TYPE_BLUETOOTH, &toshiba_rfk_ops, dev); if (!dev->bt_rfk) { pr_err("unable to allocate rfkill device\n"); ret = -ENOMEM; goto error; } ret = rfkill_register(dev->bt_rfk); if (ret) { pr_err("unable to register rfkill device\n"); rfkill_destroy(dev->bt_rfk); goto error; } } if (toshiba_illumination_available(dev)) { dev->led_dev.name = "toshiba::illumination"; dev->led_dev.max_brightness = 1; dev->led_dev.brightness_set = toshiba_illumination_set; dev->led_dev.brightness_get = toshiba_illumination_get; if (!led_classdev_register(&acpi_dev->dev, &dev->led_dev)) dev->illumination_supported = 1; } /* */ ret = get_video_status(dev, &dummy); dev->video_supported = !ret; ret = get_fan_status(dev, &dummy); dev->fan_supported = !ret; create_toshiba_proc_entries(dev); toshiba_acpi = dev; return 0; error: toshiba_acpi_remove(acpi_dev, 0); return ret; }
static int toshiba_acpi_add(struct acpi_device *acpi_dev) { struct toshiba_acpi_dev *dev; const char *hci_method; u32 dummy; bool bt_present; int ret = 0; if (toshiba_acpi) return -EBUSY; pr_info("Toshiba Laptop ACPI Extras version %s\n", TOSHIBA_ACPI_VERSION); hci_method = find_hci_method(acpi_dev->handle); if (!hci_method) { pr_err("HCI interface not found\n"); return -ENODEV; } dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; dev->acpi_dev = acpi_dev; dev->method_hci = hci_method; acpi_dev->driver_data = dev; if (toshiba_acpi_setup_keyboard(dev)) pr_info("Unable to activate hotkeys\n"); mutex_init(&dev->mutex); ret = toshiba_acpi_setup_backlight(dev); if (ret) goto error; /* Register rfkill switch for Bluetooth */ if (hci_get_bt_present(dev, &bt_present) == HCI_SUCCESS && bt_present) { dev->bt_rfk = rfkill_alloc("Toshiba Bluetooth", &acpi_dev->dev, RFKILL_TYPE_BLUETOOTH, &toshiba_rfk_ops, dev); if (!dev->bt_rfk) { pr_err("unable to allocate rfkill device\n"); ret = -ENOMEM; goto error; } ret = rfkill_register(dev->bt_rfk); if (ret) { pr_err("unable to register rfkill device\n"); rfkill_destroy(dev->bt_rfk); goto error; } } if (toshiba_illumination_available(dev)) { dev->led_dev.name = "toshiba::illumination"; dev->led_dev.max_brightness = 1; dev->led_dev.brightness_set = toshiba_illumination_set; dev->led_dev.brightness_get = toshiba_illumination_get; if (!led_classdev_register(&acpi_dev->dev, &dev->led_dev)) dev->illumination_supported = 1; } /* Determine whether or not BIOS supports fan and video interfaces */ ret = get_video_status(dev, &dummy); dev->video_supported = !ret; ret = get_fan_status(dev, &dummy); dev->fan_supported = !ret; create_toshiba_proc_entries(dev); toshiba_acpi = dev; return 0; error: toshiba_acpi_remove(acpi_dev); return ret; }