From: Kim Kyuwon <q1.kim@samsung.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Trilok Soni <soni.trilok@gmail.com>,
LKML <linux-kernel@vger.kernel.org>,
linux-input@vger.kernel.org,
Kyungmin Park <kyungmin.park@samsung.com>,
Marek Szyprowski <m.szyprowski@samsung.com>
Subject: Re: [PATCH] Input: add MAX7359 key switch controller driver, v2
Date: Mon, 11 May 2009 10:51:32 +0900 [thread overview]
Message-ID: <4A0784A4.1010703@samsung.com> (raw)
In-Reply-To: <20090509200118.GB1617@dtor-d630.eng.vmware.com>
On Sun, May 10, 2009 at 5:01 AM, Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> P.S. I made a bunch of random changes, mostly to streamline the probe
> code (below), hopfully I did not break anything.
>
> diff --git a/drivers/input/keyboard/max7359_keypad.c b/drivers/input/keyboard/max7359_keypad.c
> index 918386c..280edc3 100644
> --- a/drivers/input/keyboard/max7359_keypad.c
> +++ b/drivers/input/keyboard/max7359_keypad.c
> @@ -204,71 +198,59 @@ static int __devinit max7359_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> struct max7359_keypad *keypad;
> - struct max7359_keypad_platform_data *pdata;
> + struct max7359_keypad_platform_data *pdata = client->dev.platform_data;
> struct input_dev *input_dev;
> int ret;
> + int error;
>
> - keypad = kzalloc(sizeof(struct max7359_keypad), GFP_KERNEL);
> - if (keypad == NULL) {
> - dev_err(&client->dev, "failed to allocate driver data\n");
> - return -ENOMEM;
> + if (!client->irq) {
> + dev_err(&client->dev, "The irq number should not be zero\n");
> + return -EINVAL;
> }
>
> - keypad->client = client;
> - pdata = keypad->pdata = client->dev.platform_data;
> - i2c_set_clientdata(client, keypad);
> -
> /* Detect MAX7359: The initial Keys FIFO value is '0x3F' */
> ret = max7359_read_reg(client, MAX7359_REG_KEYFIFO);
> if (ret < 0) {
> dev_err(&client->dev, "failed to detect device\n");
> - goto failed_free;
> - } else {
> - dev_info(&client->dev, "keys FIFO is 0x%02x"
> - ", succeeded in detecting device\n", ret);
> + return -ENODEV;
> }
>
> - /* Initialize MAX7359 */
> - max7359_initialize(client);
> + dev_dbg(&client->dev, "keys FIFO is 0x%02x\n", ret);
>
> - /* Create and register the input driver. */
> + keypad = kzalloc(sizeof(struct max7359_keypad), GFP_KERNEL);
> input_dev = input_allocate_device();
> - if (!input_dev) {
> - dev_err(&client->dev, "failed to allocate input device\n");
> - ret = -ENOMEM;
> - goto failed_free;
> + if (!keypad || !input_dev) {
> + dev_err(&client->dev, "failed to allocate memory\n");
> + error = -ENOMEM;
> + goto failed_free_mem;
> }
Hi Dmitry,
Thank you for streamlining this driver. I confirmed this streamlined driver
is nicely working on my S3C6410 board and of course I mostly like your
changes. But I'm afraid this 'error' variable is not used at the final
return statement in the probe function.
Thanks & Regards,
Kyuwon
P.S. You may need this kind of patch.
--
diff --git a/drivers/input/keyboard/max7359_keypad.c b/drivers/input/keyboard/max7359_keypad.c
index 280edc3..6e09e0d 100644
--- a/drivers/input/keyboard/max7359_keypad.c
+++ b/drivers/input/keyboard/max7359_keypad.c
@@ -200,7 +200,6 @@ static int __devinit max7359_probe(struct i2c_client *client,
struct max7359_keypad *keypad;
struct max7359_keypad_platform_data *pdata = client->dev.platform_data;
struct input_dev *input_dev;
- int ret;
int error;
if (!client->irq) {
@@ -209,13 +208,13 @@ static int __devinit max7359_probe(struct i2c_client *client,
}
/* Detect MAX7359: The initial Keys FIFO value is '0x3F' */
- ret = max7359_read_reg(client, MAX7359_REG_KEYFIFO);
- if (ret < 0) {
+ error = max7359_read_reg(client, MAX7359_REG_KEYFIFO);
+ if (error < 0) {
dev_err(&client->dev, "failed to detect device\n");
return -ENODEV;
}
- dev_dbg(&client->dev, "keys FIFO is 0x%02x\n", ret);
+ dev_dbg(&client->dev, "keys FIFO is 0x%02x\n", error);
keypad = kzalloc(sizeof(struct max7359_keypad), GFP_KERNEL);
input_dev = input_allocate_device();
@@ -254,8 +253,8 @@ static int __devinit max7359_probe(struct i2c_client *client,
}
/* Register the input device */
- ret = input_register_device(input_dev);
- if (ret) {
+ error = input_register_device(input_dev);
+ if (error) {
dev_err(&client->dev, "failed to register input device\n");
goto failed_free_irq;
}
@@ -273,7 +272,7 @@ failed_free_irq:
failed_free_mem:
input_free_device(input_dev);
kfree(keypad);
- return ret;
+ return error;
}
static int __devexit max7359_remove(struct i2c_client *client)
next prev parent reply other threads:[~2009-05-11 1:51 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-09 2:09 [PATCH] Input: add MAX7359 key switch controller driver, v2 Kim Kyuwon
2009-05-09 17:27 ` Trilok Soni
2009-05-09 20:01 ` Dmitry Torokhov
2009-05-11 1:51 ` Kim Kyuwon [this message]
2009-05-11 2:08 ` Dmitry Torokhov
2009-05-11 2:34 ` Kim Kyuwon
2009-05-11 3:12 ` Dmitry Torokhov
2009-06-19 17:38 ` Trilok Soni
2009-07-13 8:52 ` Trilok Soni
2009-07-13 9:31 ` Dmitry Torokhov
2009-07-14 3:09 ` Kim Kyuwon
2009-07-14 6:28 ` Marek Szyprowski
2009-07-14 8:24 ` Dmitry Torokhov
2009-07-14 8:53 ` Trilok Soni
2009-07-14 9:07 ` Marek Szyprowski
2009-07-14 9:11 ` Trilok Soni
2009-07-14 10:18 ` Marek Szyprowski
2009-07-14 10:23 ` Trilok Soni
2009-07-15 7:15 ` Marek Szyprowski
2009-09-16 8:57 ` Dmitry Torokhov
2009-09-18 8:14 ` Joonyoung Shim
2009-09-18 16:39 ` Dmitry Torokhov
2009-09-19 0:07 ` Joonyoung Shim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A0784A4.1010703@samsung.com \
--to=q1.kim@samsung.com \
--cc=dmitry.torokhov@gmail.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=soni.trilok@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).