diff mbox

[v2] input: synaptics-rmi4 - use snprintf instead of sprintf in rmi_i2c.c

Message ID 20140109082858.GE27160@core.coreip.homeip.net (mailing list archive)
State New, archived
Headers show

Commit Message

Dmitry Torokhov Jan. 9, 2014, 8:28 a.m. UTC
On Thu, Jan 09, 2014 at 12:04:54AM -0800, Dmitry Torokhov wrote:
> On Wed, Jan 08, 2014 at 05:18:39PM -0800, Christopher Heiny wrote:
> > This is a trivial change to replace the sprintf loop with snprintf using
> > up-to-date format capability.
> 
> Hmm, how about we do this instead:

And another small one...

Input: synaptics-rmi4 - transport name should be a const pointer

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/rmi4/rmi_bus.h |    2 +-
 drivers/input/rmi4/rmi_i2c.c |    4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)

Comments

Christopher Heiny Jan. 9, 2014, 8:29 p.m. UTC | #1
On 01/09/2014 12:28 AM, Dmitry Torokhov wrote:
> On Thu, Jan 09, 2014 at 12:04:54AM -0800, Dmitry Torokhov wrote:
>> On Wed, Jan 08, 2014 at 05:18:39PM -0800, Christopher Heiny wrote:
>>> This is a trivial change to replace the sprintf loop with snprintf using
>>> up-to-date format capability.
>>
>> Hmm, how about we do this instead:
>
> And another small one...
>
> Input: synaptics-rmi4 - transport name should be a const pointer
>
> From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Looks good to me.  I think the correct protocol is to Ack the patch, so...

Acked-by: Christopher Heiny <cheiny@synaptics.com>


> ---
>   drivers/input/rmi4/rmi_bus.h |    2 +-
>   drivers/input/rmi4/rmi_i2c.c |    4 +---
>   2 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_bus.h b/drivers/input/rmi4/rmi_bus.h
> index 65dd934..3e8b57a 100644
> --- a/drivers/input/rmi4/rmi_bus.h
> +++ b/drivers/input/rmi4/rmi_bus.h
> @@ -148,7 +148,7 @@ struct rmi_driver {
>    * @att_count Number of times ATTN assertions have been handled.
>    */
>   struct rmi_transport_info {
> -	char *proto;
> +	const char *proto;
>   	long tx_count;
>   	long tx_bytes;
>   	long tx_errs;
> diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
> index ea01823..ebe74ec 100644
> --- a/drivers/input/rmi4/rmi_i2c.c
> +++ b/drivers/input/rmi4/rmi_i2c.c
> @@ -38,8 +38,6 @@ struct rmi_i2c_data {
>   #define RMI_PAGE_SELECT_REGISTER 0xff
>   #define RMI_I2C_PAGE(addr) (((addr) >> 8) & 0xff)
>
> -static char *xport_proto_name = "i2c";
> -
>   /*
>    * rmi_set_page - Set RMI page
>    * @xport: The pointer to the rmi_transport_dev struct
> @@ -217,7 +215,7 @@ static int rmi_i2c_probe(struct i2c_client *client,
>
>   	xport->write_block = rmi_i2c_write_block;
>   	xport->read_block = rmi_i2c_read_block;
> -	xport->info.proto = xport_proto_name;
> +	xport->info.proto = "i2c";
>
>   	mutex_init(&data->page_mutex);
>
>
Dmitry Torokhov Jan. 9, 2014, 8:48 p.m. UTC | #2
Christopher Heiny <cheiny@synaptics.com> wrote:
>On 01/09/2014 12:28 AM, Dmitry Torokhov wrote:
>> On Thu, Jan 09, 2014 at 12:04:54AM -0800, Dmitry Torokhov wrote:
>>> On Wed, Jan 08, 2014 at 05:18:39PM -0800, Christopher Heiny wrote:
>>>> This is a trivial change to replace the sprintf loop with snprintf
>using
>>>> up-to-date format capability.
>>>
>>> Hmm, how about we do this instead:
>>
>> And another small one...
>>
>> Input: synaptics-rmi4 - transport name should be a const pointer
>>
>> From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>>
>> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>
>Looks good to me.  I think the correct protocol is to Ack the patch,
>so...
>
>Acked-by: Christopher Heiny <cheiny@synaptics.com>

Both or only the const name one?

>
>
>> ---
>>   drivers/input/rmi4/rmi_bus.h |    2 +-
>>   drivers/input/rmi4/rmi_i2c.c |    4 +---
>>   2 files changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/input/rmi4/rmi_bus.h
>b/drivers/input/rmi4/rmi_bus.h
>> index 65dd934..3e8b57a 100644
>> --- a/drivers/input/rmi4/rmi_bus.h
>> +++ b/drivers/input/rmi4/rmi_bus.h
>> @@ -148,7 +148,7 @@ struct rmi_driver {
>>    * @att_count Number of times ATTN assertions have been handled.
>>    */
>>   struct rmi_transport_info {
>> -	char *proto;
>> +	const char *proto;
>>   	long tx_count;
>>   	long tx_bytes;
>>   	long tx_errs;
>> diff --git a/drivers/input/rmi4/rmi_i2c.c
>b/drivers/input/rmi4/rmi_i2c.c
>> index ea01823..ebe74ec 100644
>> --- a/drivers/input/rmi4/rmi_i2c.c
>> +++ b/drivers/input/rmi4/rmi_i2c.c
>> @@ -38,8 +38,6 @@ struct rmi_i2c_data {
>>   #define RMI_PAGE_SELECT_REGISTER 0xff
>>   #define RMI_I2C_PAGE(addr) (((addr) >> 8) & 0xff)
>>
>> -static char *xport_proto_name = "i2c";
>> -
>>   /*
>>    * rmi_set_page - Set RMI page
>>    * @xport: The pointer to the rmi_transport_dev struct
>> @@ -217,7 +215,7 @@ static int rmi_i2c_probe(struct i2c_client
>*client,
>>
>>   	xport->write_block = rmi_i2c_write_block;
>>   	xport->read_block = rmi_i2c_read_block;
>> -	xport->info.proto = xport_proto_name;
>> +	xport->info.proto = "i2c";
>>
>>   	mutex_init(&data->page_mutex);
>>
>>
Christopher Heiny Jan. 9, 2014, 9:02 p.m. UTC | #3
On 01/09/2014 12:48 PM, Dmitry Torokhov wrote:
> Christopher Heiny<cheiny@synaptics.com>  wrote:
>> >On 01/09/2014 12:28 AM, Dmitry Torokhov wrote:
>>> >>On Thu, Jan 09, 2014 at 12:04:54AM -0800, Dmitry Torokhov wrote:
>>>> >>>On Wed, Jan 08, 2014 at 05:18:39PM -0800, Christopher Heiny wrote:
>>>>> >>>>This is a trivial change to replace the sprintf loop with snprintf
>> >using
>>>>> >>>>up-to-date format capability.
>>>> >>>
>>>> >>>Hmm, how about we do this instead:
>>> >>
>>> >>And another small one...
>>> >>
>>> >>Input: synaptics-rmi4 - transport name should be a const pointer
>>> >>
>>> >>From: Dmitry Torokhov<dmitry.torokhov@gmail.com>
>>> >>
>>> >>Signed-off-by: Dmitry Torokhov<dmitry.torokhov@gmail.com>
>> >
>> >Looks good to me.  I think the correct protocol is to Ack the patch,
>> >so...
>> >
>> >Acked-by: Christopher Heiny<cheiny@synaptics.com>
> Both or only the const name one?
>

The const name one only at this point.  I have a couple of comments on 
the debug output, one.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/input/rmi4/rmi_bus.h b/drivers/input/rmi4/rmi_bus.h
index 65dd934..3e8b57a 100644
--- a/drivers/input/rmi4/rmi_bus.h
+++ b/drivers/input/rmi4/rmi_bus.h
@@ -148,7 +148,7 @@  struct rmi_driver {
  * @att_count Number of times ATTN assertions have been handled.
  */
 struct rmi_transport_info {
-	char *proto;
+	const char *proto;
 	long tx_count;
 	long tx_bytes;
 	long tx_errs;
diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
index ea01823..ebe74ec 100644
--- a/drivers/input/rmi4/rmi_i2c.c
+++ b/drivers/input/rmi4/rmi_i2c.c
@@ -38,8 +38,6 @@  struct rmi_i2c_data {
 #define RMI_PAGE_SELECT_REGISTER 0xff
 #define RMI_I2C_PAGE(addr) (((addr) >> 8) & 0xff)
 
-static char *xport_proto_name = "i2c";
-
 /*
  * rmi_set_page - Set RMI page
  * @xport: The pointer to the rmi_transport_dev struct
@@ -217,7 +215,7 @@  static int rmi_i2c_probe(struct i2c_client *client,
 
 	xport->write_block = rmi_i2c_write_block;
 	xport->read_block = rmi_i2c_read_block;
-	xport->info.proto = xport_proto_name;
+	xport->info.proto = "i2c";
 
 	mutex_init(&data->page_mutex);