All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] driver: input :touchscreen :Modify Raydium Firmware update input file
@ 2017-12-21 13:51 jeffrey.lin
  2018-01-05  5:53 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: jeffrey.lin @ 2017-12-21 13:51 UTC (permalink / raw)
  To: dmitry.torokhov, groeck, keith.tzeng, Katherine.Hsieh, bleung
  Cc: jeffrey.lin, KP.li, albert.shieh, calvin.tseng, linux-kernel,
	linux-input

Modify update firmware to accept alternative file name

Signed-off-by: jeffrey.lin <jeffrey.lin@rad-ic.com>
---
 drivers/input/touchscreen/raydium_i2c_ts.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c
index a99fb5cac5a0..439d43c3519c 100644
--- a/drivers/input/touchscreen/raydium_i2c_ts.c
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -130,6 +130,7 @@ struct raydium_data {
 	struct gpio_desc *reset_gpio;
 
 	struct raydium_info info;
+	char fw_file[64];
 
 	struct mutex sysfs_mutex;
 
@@ -752,12 +753,16 @@ static int raydium_i2c_fw_update(struct raydium_data *ts)
 {
 	struct i2c_client *client = ts->client;
 	const struct firmware *fw = NULL;
-	const char *fw_file = "raydium.fw";
 	int error;
 
-	error = request_firmware(&fw, fw_file, &client->dev);
+	/* Firmware name */
+	snprintf(ts->fw_file, sizeof(ts->fw_file),
+		"raydium_%x.fw", ts->info.hw_ver);
+	dev_dbg(&client->dev, "firmware name: %s\n", ts->fw_file);
+
+	error = request_firmware(&fw, ts->fw_file, &client->dev);
 	if (error) {
-		dev_err(&client->dev, "Unable to open firmware %s\n", fw_file);
+		dev_err(&client->dev, "Unable to open firmware %s\n", ts->fw_file);
 		return error;
 	}
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] driver: input :touchscreen :Modify Raydium Firmware update input file
  2017-12-21 13:51 [PATCH] driver: input :touchscreen :Modify Raydium Firmware update input file jeffrey.lin
@ 2018-01-05  5:53 ` Dmitry Torokhov
  2018-01-05 12:12   ` Jeffrey Lin (林義章)
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2018-01-05  5:53 UTC (permalink / raw)
  To: jeffrey.lin
  Cc: groeck, keith.tzeng, Katherine.Hsieh, bleung, jeffrey.lin, KP.li,
	albert.shieh, calvin.tseng, linux-kernel, linux-input

Hi Jeffrey,

On Thu, Dec 21, 2017 at 09:51:22PM +0800, jeffrey.lin wrote:
> Modify update firmware to accept alternative file name
> 
> Signed-off-by: jeffrey.lin <jeffrey.lin@rad-ic.com>
> ---
>  drivers/input/touchscreen/raydium_i2c_ts.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c
> index a99fb5cac5a0..439d43c3519c 100644
> --- a/drivers/input/touchscreen/raydium_i2c_ts.c
> +++ b/drivers/input/touchscreen/raydium_i2c_ts.c
> @@ -130,6 +130,7 @@ struct raydium_data {
>  	struct gpio_desc *reset_gpio;
>  
>  	struct raydium_info info;
> +	char fw_file[64];

You do not really need to keep the firmware name in driver data, just
use a temporary in raydium_i2c_fw_update().

>  
>  	struct mutex sysfs_mutex;
>  
> @@ -752,12 +753,16 @@ static int raydium_i2c_fw_update(struct raydium_data *ts)
>  {
>  	struct i2c_client *client = ts->client;
>  	const struct firmware *fw = NULL;
> -	const char *fw_file = "raydium.fw";
>  	int error;
>  
> -	error = request_firmware(&fw, fw_file, &client->dev);
> +	/* Firmware name */
> +	snprintf(ts->fw_file, sizeof(ts->fw_file),
> +		"raydium_%x.fw", ts->info.hw_ver);

hw_ver is LE32, you need to convert it to CPU endianness before using.
Also it would be better if we used the same encoding for the hardware
version as the one that we use when we output it in sysfs. It makes
userspace life a bit easier I think.

How about the version of the patch below?

Thanks.

-- 
Dmitry


Input: raydium_i2c_ts - include hardware version in firmware name

From: Jeffrey Lin <jeffrey.lin@rad-ic.com>

Add hardware version to the firmware file name to handle scenarios where
single system image supports variety of devices.

Signed-off-by: Jeffrey Lin <jeffrey.lin@rad-ic.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/raydium_i2c_ts.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c
index 100538d64fff..d1c09e6a2cb6 100644
--- a/drivers/input/touchscreen/raydium_i2c_ts.c
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -752,13 +752,20 @@ static int raydium_i2c_fw_update(struct raydium_data *ts)
 {
 	struct i2c_client *client = ts->client;
 	const struct firmware *fw = NULL;
-	const char *fw_file = "raydium.fw";
+	char *fw_file;
 	int error;
 
+	fw_file = kasprintf(GFP_KERNEL, "raydium_%#04x.fw",
+			    le32_to_cpu(ts->info.hw_ver));
+	if (!fw_file)
+		return -ENOMEM;
+
+	dev_dbg(&client->dev, "firmware name: %s\n", fw_file);
+
 	error = request_firmware(&fw, fw_file, &client->dev);
 	if (error) {
 		dev_err(&client->dev, "Unable to open firmware %s\n", fw_file);
-		return error;
+		goto out_free_fw_file;
 	}
 
 	disable_irq(client->irq);
@@ -787,6 +794,9 @@ static int raydium_i2c_fw_update(struct raydium_data *ts)
 
 	release_firmware(fw);
 
+out_free_fw_file:
+	kfree(fw_file);
+
 	return error;
 }
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] driver: input :touchscreen :Modify Raydium Firmware update input file
  2018-01-05  5:53 ` Dmitry Torokhov
@ 2018-01-05 12:12   ` Jeffrey Lin (林義章)
  0 siblings, 0 replies; 3+ messages in thread
From: Jeffrey Lin (林義章) @ 2018-01-05 12:12 UTC (permalink / raw)
  To: Dmitry Torokhov, jeffrey.lin
  Cc: groeck, keith.tzeng, Katherine.Hsieh, bleung,
	KP Li (李昆倍),
	Albert Shieh (謝欣瑋),
	Calvin Tseng  (曾國宗),
	linux-kernel, linux-input, Kevin Chiu (邱俊睿),
	Jacky Lin (林冠明)

Dmitry:
I've verified pass the patch you had modified. Many thanks.

Best Regards
----------------------------------------------------------------------
Jeffrey Lin, 林義章
Raydium Semiconductor Corporation, 瑞鼎科技
Tel:(03)666-1818 Ext.4163
Fax:(03)666-1919

-----Original Message-----
From: Dmitry Torokhov [mailto:dmitry.torokhov@gmail.com]
Sent: Friday, January 05, 2018 1:54 PM
To: jeffrey.lin
Cc: groeck@chromium.org; keith.tzeng@quantatw.com; Katherine.Hsieh@quantatw.com; bleung@google.com; Jeffrey Lin (林義章); KP Li (李昆倍); Albert Shieh (謝欣瑋); Calvin Tseng (曾國宗); linux-kernel@vger.kernel.org; linux-input@vger.kernel.org
Subject: Re: [PATCH] driver: input :touchscreen :Modify Raydium Firmware update input file

Hi Jeffrey,

On Thu, Dec 21, 2017 at 09:51:22PM +0800, jeffrey.lin wrote:
> Modify update firmware to accept alternative file name
>
> Signed-off-by: jeffrey.lin <jeffrey.lin@rad-ic.com>
> ---
>  drivers/input/touchscreen/raydium_i2c_ts.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c
> index a99fb5cac5a0..439d43c3519c 100644
> --- a/drivers/input/touchscreen/raydium_i2c_ts.c
> +++ b/drivers/input/touchscreen/raydium_i2c_ts.c
> @@ -130,6 +130,7 @@ struct raydium_data {
>       struct gpio_desc *reset_gpio;
>
>       struct raydium_info info;
> +     char fw_file[64];

You do not really need to keep the firmware name in driver data, just
use a temporary in raydium_i2c_fw_update().

>
>       struct mutex sysfs_mutex;
>
> @@ -752,12 +753,16 @@ static int raydium_i2c_fw_update(struct raydium_data *ts)
>  {
>       struct i2c_client *client = ts->client;
>       const struct firmware *fw = NULL;
> -     const char *fw_file = "raydium.fw";
>       int error;
>
> -     error = request_firmware(&fw, fw_file, &client->dev);
> +     /* Firmware name */
> +     snprintf(ts->fw_file, sizeof(ts->fw_file),
> +             "raydium_%x.fw", ts->info.hw_ver);

hw_ver is LE32, you need to convert it to CPU endianness before using.
Also it would be better if we used the same encoding for the hardware
version as the one that we use when we output it in sysfs. It makes
userspace life a bit easier I think.

How about the version of the patch below?

Thanks.

--
Dmitry


Input: raydium_i2c_ts - include hardware version in firmware name

From: Jeffrey Lin <jeffrey.lin@rad-ic.com>

Add hardware version to the firmware file name to handle scenarios where
single system image supports variety of devices.

Signed-off-by: Jeffrey Lin <jeffrey.lin@rad-ic.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/raydium_i2c_ts.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c
index 100538d64fff..d1c09e6a2cb6 100644
--- a/drivers/input/touchscreen/raydium_i2c_ts.c
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -752,13 +752,20 @@ static int raydium_i2c_fw_update(struct raydium_data *ts)
 {
        struct i2c_client *client = ts->client;
        const struct firmware *fw = NULL;
-       const char *fw_file = "raydium.fw";
+       char *fw_file;
        int error;

+       fw_file = kasprintf(GFP_KERNEL, "raydium_%#04x.fw",
+                           le32_to_cpu(ts->info.hw_ver));
+       if (!fw_file)
+               return -ENOMEM;
+
+       dev_dbg(&client->dev, "firmware name: %s\n", fw_file);
+
        error = request_firmware(&fw, fw_file, &client->dev);
        if (error) {
                dev_err(&client->dev, "Unable to open firmware %s\n", fw_file);
-               return error;
+               goto out_free_fw_file;
        }

        disable_irq(client->irq);
@@ -787,6 +794,9 @@ static int raydium_i2c_fw_update(struct raydium_data *ts)

        release_firmware(fw);

+out_free_fw_file:
+       kfree(fw_file);
+
        return error;
 }

CONFIDENTIALITY AND PROPRIETARY REMINDER:
This message and any attachment may contain confidential information. All rights including intellectual property rights arising out of this correspondence shall belong to Raydium Semiconductor Corp. Any unauthorized disclosure, forwarding, using, modifying, spreading, publishing or copying this email and the content is illegal and strictly prohibited.
If you are not the intended recipient, please notify the sender by replying to this message and delete all copies of it from your system. Thank you for cooperation.

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-05 12:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-21 13:51 [PATCH] driver: input :touchscreen :Modify Raydium Firmware update input file jeffrey.lin
2018-01-05  5:53 ` Dmitry Torokhov
2018-01-05 12:12   ` Jeffrey Lin (林義章)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.