Commit 753e3856 authored by Andrew Morton's avatar Andrew Morton Committed by james toy

readability tweaks

Cc: Len Brown <lenb@kernel.org>
Cc: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 97488aa5
......@@ -40,6 +40,7 @@ static int cmpc_add_acpi_notify_device(struct acpi_device *acpi, char *name,
struct input_dev *inputdev;
acpi_status status;
int error;
inputdev = input_allocate_device();
if (!inputdev) {
error = -ENOMEM;
......@@ -72,6 +73,7 @@ static int cmpc_remove_acpi_notify_device(struct acpi_device *acpi,
{
struct input_dev *inputdev;
acpi_status status;
status = acpi_remove_notify_handler(acpi->handle, ACPI_DEVICE_NOTIFY,
handler);
inputdev = dev_get_drvdata(&acpi->dev);
......@@ -80,16 +82,15 @@ static int cmpc_remove_acpi_notify_device(struct acpi_device *acpi,
return 0;
}
/*
* Accelerometer code.
*/
static acpi_status cmpc_start_accel(acpi_handle handle)
{
union acpi_object param[2];
struct acpi_object_list input;
acpi_status status;
param[0].type = ACPI_TYPE_INTEGER;
param[0].integer.value = 0x3;
param[1].type = ACPI_TYPE_INTEGER;
......@@ -104,6 +105,7 @@ static acpi_status cmpc_stop_accel(acpi_handle handle)
union acpi_object param[2];
struct acpi_object_list input;
acpi_status status;
param[0].type = ACPI_TYPE_INTEGER;
param[0].integer.value = 0x4;
param[1].type = ACPI_TYPE_INTEGER;
......@@ -117,6 +119,7 @@ static acpi_status cmpc_accel_set_sense(acpi_handle handle, int val)
{
union acpi_object param[2];
struct acpi_object_list input;
param[0].type = ACPI_TYPE_INTEGER;
param[0].integer.value = 0x02;
param[1].type = ACPI_TYPE_INTEGER;
......@@ -136,6 +139,7 @@ static acpi_status cmpc_get_accel(acpi_handle handle,
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, 0 };
unsigned char *locs;
acpi_status status;
param[0].type = ACPI_TYPE_INTEGER;
param[0].integer.value = 0x01;
param[1].type = ACPI_TYPE_INTEGER;
......@@ -156,12 +160,14 @@ static acpi_status cmpc_get_accel(acpi_handle handle,
static void cmpc_accel_handler(acpi_handle handle, u32 event, void *ctx)
{
struct input_dev *inputdev = ctx;
acpi_status status;
unsigned char x, y, z;
if (event == 0x81) {
unsigned char x, y, z;
acpi_status status;
status = cmpc_get_accel(handle, &x, &y, &z);
if (ACPI_SUCCESS(status)) {
struct input_dev *inputdev = ctx;
input_report_abs(inputdev, ABS_X, x);
input_report_abs(inputdev, ABS_Y, y);
input_report_abs(inputdev, ABS_Z, z);
......@@ -176,6 +182,7 @@ static ssize_t cmpc_accel_sense_store(struct device *dev,
{
struct acpi_device *acpi;
int sense;
acpi = to_acpi_device(dev);
if (sscanf(buf, "%d", &sense) <= 0)
return -EINVAL;
......@@ -191,6 +198,7 @@ struct device_attribute cmpc_accel_sense_attr = {
static int cmpc_accel_open(struct input_dev *input)
{
struct acpi_device *acpi;
acpi = to_acpi_device(input->dev.parent);
if (ACPI_SUCCESS(cmpc_start_accel(acpi->handle)))
return 0;
......@@ -200,6 +208,7 @@ static int cmpc_accel_open(struct input_dev *input)
static void cmpc_accel_close(struct input_dev *input)
{
struct acpi_device *acpi;
acpi = to_acpi_device(input->dev.parent);
cmpc_stop_accel(acpi->handle);
}
......@@ -217,6 +226,7 @@ static void cmpc_accel_idev_init(struct input_dev *inputdev)
static int cmpc_accel_add(struct acpi_device *acpi)
{
int error;
error = device_create_file(&acpi->dev, &cmpc_accel_sense_attr);
if (error)
return error;
......@@ -260,6 +270,7 @@ static acpi_status cmpc_get_tablet(acpi_handle handle,
struct acpi_object_list input;
unsigned long long output;
acpi_status status;
param.type = ACPI_TYPE_INTEGER;
param.integer.value = 0x01;
input.count = 1;
......@@ -274,6 +285,7 @@ static void cmpc_tablet_handler(acpi_handle handle, u32 event, void *ctx)
{
unsigned long long val = 0;
struct input_dev *inputdev = ctx;
if (event == 0x81) {
if (ACPI_SUCCESS(cmpc_get_tablet(handle, &val)))
input_report_switch(inputdev, SW_TABLET_MODE, !val);
......@@ -328,6 +340,7 @@ static acpi_status cmpc_get_brightness(acpi_handle handle,
struct acpi_object_list input;
unsigned long long output;
acpi_status status;
param.type = ACPI_TYPE_INTEGER;
param.integer.value = 0xC0;
input.count = 1;
......@@ -345,6 +358,7 @@ static acpi_status cmpc_set_brightness(acpi_handle handle,
struct acpi_object_list input;
acpi_status status;
unsigned long long output;
param[0].type = ACPI_TYPE_INTEGER;
param[0].integer.value = 0xC0;
param[1].type = ACPI_TYPE_INTEGER;
......@@ -360,6 +374,7 @@ static int cmpc_bl_get_brightness(struct backlight_device *bd)
acpi_status status;
acpi_handle handle;
unsigned long long brightness;
handle = bl_get_data(bd);
status = cmpc_get_brightness(handle, &brightness);
if (ACPI_SUCCESS(status))
......@@ -372,6 +387,7 @@ static int cmpc_bl_update_status(struct backlight_device *bd)
{
acpi_status status;
acpi_handle handle;
handle = bl_get_data(bd);
status = cmpc_set_brightness(handle, bd->props.brightness);
if (ACPI_SUCCESS(status))
......@@ -388,6 +404,7 @@ static struct backlight_ops cmpc_bl_ops = {
static int cmpc_bl_add(struct acpi_device *acpi)
{
struct backlight_device *bd;
bd = backlight_device_register("cmpc_bl", &acpi->dev,
acpi->handle, &cmpc_bl_ops);
bd->props.max_brightness = 7;
......@@ -398,6 +415,7 @@ static int cmpc_bl_add(struct acpi_device *acpi)
static int cmpc_bl_remove(struct acpi_device *acpi, int type)
{
struct backlight_device *bd;
bd = dev_get_drvdata(&acpi->dev);
backlight_device_unregister(bd);
return 0;
......@@ -439,6 +457,7 @@ static void cmpc_keys_handler(acpi_handle handle, u32 event, void *ctx)
{
struct input_dev *inputdev;
int code = KEY_MAX;
if ((event & 0x0F) < ARRAY_SIZE(cmpc_keys_codes))
code = cmpc_keys_codes[event & 0x0F];
inputdev = ctx;
......@@ -448,6 +467,7 @@ static void cmpc_keys_handler(acpi_handle handle, u32 event, void *ctx)
static void cmpc_keys_idev_init(struct input_dev *inputdev)
{
int i;
set_bit(EV_KEY, inputdev->evbit);
for (i = 0; cmpc_keys_codes[i] != KEY_MAX; i++)
set_bit(cmpc_keys_codes[i], inputdev->keybit);
......@@ -491,6 +511,7 @@ static bool cmpc_keys_driver_registered;
static int cmpc_init(void)
{
int result;
result = acpi_bus_register_driver(&cmpc_keys_acpi_driver);
cmpc_keys_driver_registered = !!result;
result = acpi_bus_register_driver(&cmpc_bl_acpi_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment