* [PATCH] atlas_btns: fix mixing acpi_status and int for return value
@ 2010-07-13 9:31 Axel Lin
2010-07-13 16:25 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2010-07-13 9:31 UTC (permalink / raw)
To: linux-kernel; +Cc: Dmitry Torokhov, Lin Ming, linux-input
To improve readability, this patch fixes mixing acpi_status
and int for return value.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/input/misc/atlas_btns.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/input/misc/atlas_btns.c b/drivers/input/misc/atlas_btns.c
index 7d53608..ea14800 100644
--- a/drivers/input/misc/atlas_btns.c
+++ b/drivers/input/misc/atlas_btns.c
@@ -60,12 +60,12 @@ static acpi_status acpi_atlas_button_handler(u32 function,
input_report_key(input_dev, atlas_keymap[code], key_down);
input_sync(input_dev);
- status = 0;
+ status = AE_OK;
} else {
printk(KERN_WARNING "atlas: shrugged on unexpected function"
":function=%x,address=%lx,value=%x\n",
function, (unsigned long)address, (u32)*value);
- status = -EINVAL;
+ status = AE_BAD_PARAMETER;
}
return status;
@@ -114,26 +114,27 @@ static int atlas_acpi_button_add(struct acpi_device *device)
if (ACPI_FAILURE(status)) {
printk(KERN_ERR "Atlas: Error installing addr spc handler\n");
input_unregister_device(input_dev);
- status = -EINVAL;
+ err = -EINVAL;
}
- return status;
+ return err;
}
static int atlas_acpi_button_remove(struct acpi_device *device, int type)
{
acpi_status status;
+ int err = 0;
status = acpi_remove_address_space_handler(device->handle,
0x81, &acpi_atlas_button_handler);
if (ACPI_FAILURE(status)) {
printk(KERN_ERR "Atlas: Error removing addr spc handler\n");
- status = -EINVAL;
+ err = -EINVAL;
}
input_unregister_device(input_dev);
- return status;
+ return err;
}
static const struct acpi_device_id atlas_device_ids[] = {
--
1.5.4.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] atlas_btns: fix mixing acpi_status and int for return value
2010-07-13 9:31 [PATCH] atlas_btns: fix mixing acpi_status and int for return value Axel Lin
@ 2010-07-13 16:25 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2010-07-13 16:25 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Lin Ming, linux-input
On Tue, Jul 13, 2010 at 05:31:15PM +0800, Axel Lin wrote:
> To improve readability, this patch fixes mixing acpi_status
> and int for return value.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
> drivers/input/misc/atlas_btns.c | 13 +++++++------
> 1 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/input/misc/atlas_btns.c b/drivers/input/misc/atlas_btns.c
> index 7d53608..ea14800 100644
> --- a/drivers/input/misc/atlas_btns.c
> +++ b/drivers/input/misc/atlas_btns.c
> @@ -60,12 +60,12 @@ static acpi_status acpi_atlas_button_handler(u32 function,
> input_report_key(input_dev, atlas_keymap[code], key_down);
> input_sync(input_dev);
>
> - status = 0;
> + status = AE_OK;
> } else {
> printk(KERN_WARNING "atlas: shrugged on unexpected function"
> ":function=%x,address=%lx,value=%x\n",
> function, (unsigned long)address, (u32)*value);
> - status = -EINVAL;
> + status = AE_BAD_PARAMETER;
> }
>
> return status;
> @@ -114,26 +114,27 @@ static int atlas_acpi_button_add(struct acpi_device *device)
> if (ACPI_FAILURE(status)) {
> printk(KERN_ERR "Atlas: Error installing addr spc handler\n");
> input_unregister_device(input_dev);
> - status = -EINVAL;
> + err = -EINVAL;
> }
>
> - return status;
> + return err;
> }
>
> static int atlas_acpi_button_remove(struct acpi_device *device, int type)
> {
> acpi_status status;
> + int err = 0;
>
> status = acpi_remove_address_space_handler(device->handle,
> 0x81, &acpi_atlas_button_handler);
> if (ACPI_FAILURE(status)) {
> printk(KERN_ERR "Atlas: Error removing addr spc handler\n");
> - status = -EINVAL;
> + err = -EINVAL;
> }
>
> input_unregister_device(input_dev);
>
> - return status;
> + return err;
We should not report any errors since operation is irreversible, just
log them. I believe typing remove methods as returning int instead of
void was a mistake.
I'll fix it up and apply both patches, thanks Axel.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-07-13 16:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-13 9:31 [PATCH] atlas_btns: fix mixing acpi_status and int for return value Axel Lin
2010-07-13 16:25 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).