diff mbox

Input: ar1021-i2c - fix too long name in driver's device table

Message ID 20161212235702.GA10843@dtor-ws (mailing list archive)
State New, archived
Headers show

Commit Message

Dmitry Torokhov Dec. 12, 2016, 11:57 p.m. UTC
The name field in structure i2c_device_id is 20 characters, and we
expect it to be NULL-terminated, however we are trying to stuff it with
21 bytes and thus NULL-terminator is lost. This causes issues when one
creates device with name "MICROCHIP_AR1021_I2C" as i2c core cuts off the
last "C", and automatic module loading by alias does not work as result.

The -I2C suffix in the device name is superfluous, we know what bus we
are dealing with, so let's drop it.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=116211
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/ar1021_i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Wolfram Sang Dec. 13, 2016, 5:58 a.m. UTC | #1
On Mon, Dec 12, 2016 at 03:57:02PM -0800, Dmitry Torokhov wrote:
> The name field in structure i2c_device_id is 20 characters, and we
> expect it to be NULL-terminated, however we are trying to stuff it with
> 21 bytes and thus NULL-terminator is lost. This causes issues when one
> creates device with name "MICROCHIP_AR1021_I2C" as i2c core cuts off the
> last "C", and automatic module loading by alias does not work as result.
> 
> The -I2C suffix in the device name is superfluous, we know what bus we
> are dealing with, so let's drop it.
> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=116211
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Acked-by: Wolfram Sang <wsa@the-dreams.de>
Christian Gmeiner Dec. 13, 2016, 7:41 a.m. UTC | #2
2016-12-13 0:57 GMT+01:00 Dmitry Torokhov <dmitry.torokhov@gmail.com>:
> The name field in structure i2c_device_id is 20 characters, and we
> expect it to be NULL-terminated, however we are trying to stuff it with
> 21 bytes and thus NULL-terminator is lost. This causes issues when one
> creates device with name "MICROCHIP_AR1021_I2C" as i2c core cuts off the
> last "C", and automatic module loading by alias does not work as result.
>
> The -I2C suffix in the device name is superfluous, we know what bus we
> are dealing with, so let's drop it.
>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=116211
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/input/touchscreen/ar1021_i2c.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/input/touchscreen/ar1021_i2c.c b/drivers/input/touchscreen/ar1021_i2c.c
> index 71b5a63..89f9587 100644
> --- a/drivers/input/touchscreen/ar1021_i2c.c
> +++ b/drivers/input/touchscreen/ar1021_i2c.c
> @@ -152,7 +152,7 @@ static int __maybe_unused ar1021_i2c_resume(struct device *dev)
>  static SIMPLE_DEV_PM_OPS(ar1021_i2c_pm, ar1021_i2c_suspend, ar1021_i2c_resume);
>
>  static const struct i2c_device_id ar1021_i2c_id[] = {
> -       { "MICROCHIP_AR1021_I2C", 0 },
> +       { "MICROCHIP_AR1021", 0 },
>         { },
>  };
>  MODULE_DEVICE_TABLE(i2c, ar1021_i2c_id);
> --
> 2.8.0.rc3.226.g39d4020
>

Reviewed-By: Christian Gmeiner <christian.gmeiner@gmail.com>
--
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
Jean Delvare Dec. 13, 2016, 2:06 p.m. UTC | #3
Hi Dmitry,

On lun., 2016-12-12 at 15:57 -0800, Dmitry Torokhov wrote:
> The name field in structure i2c_device_id is 20 characters, and we
> expect it to be NULL-terminated, however we are trying to stuff it with
> 21 bytes and thus NULL-terminator is lost. This causes issues when one
> creates device with name "MICROCHIP_AR1021_I2C" as i2c core cuts off the
> last "C", and automatic module loading by alias does not work as result.
> 
> The -I2C suffix in the device name is superfluous, we know what bus we
> are dealing with, so let's drop it.
> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=116211
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/input/touchscreen/ar1021_i2c.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/input/touchscreen/ar1021_i2c.c b/drivers/input/touchscreen/ar1021_i2c.c
> index 71b5a63..89f9587 100644
> --- a/drivers/input/touchscreen/ar1021_i2c.c
> +++ b/drivers/input/touchscreen/ar1021_i2c.c
> @@ -152,7 +152,7 @@ static int __maybe_unused ar1021_i2c_resume(struct device *dev)
>  static SIMPLE_DEV_PM_OPS(ar1021_i2c_pm, ar1021_i2c_suspend, ar1021_i2c_resume);
>  
>  static const struct i2c_device_id ar1021_i2c_id[] = {
> -	{ "MICROCHIP_AR1021_I2C", 0 },
> +	{ "MICROCHIP_AR1021", 0 },
>  	{ },
>  };
>  MODULE_DEVICE_TABLE(i2c, ar1021_i2c_id);

For consistency with the rest of the universe, the name should simply be
"ar1021". No other driver uses capitals, and the manufacturer name is
normally not included, except in very rare cases of incompatible name
collisions.

Thanks,
diff mbox

Patch

diff --git a/drivers/input/touchscreen/ar1021_i2c.c b/drivers/input/touchscreen/ar1021_i2c.c
index 71b5a63..89f9587 100644
--- a/drivers/input/touchscreen/ar1021_i2c.c
+++ b/drivers/input/touchscreen/ar1021_i2c.c
@@ -152,7 +152,7 @@  static int __maybe_unused ar1021_i2c_resume(struct device *dev)
 static SIMPLE_DEV_PM_OPS(ar1021_i2c_pm, ar1021_i2c_suspend, ar1021_i2c_resume);
 
 static const struct i2c_device_id ar1021_i2c_id[] = {
-	{ "MICROCHIP_AR1021_I2C", 0 },
+	{ "MICROCHIP_AR1021", 0 },
 	{ },
 };
 MODULE_DEVICE_TABLE(i2c, ar1021_i2c_id);