input: tegra: Use of_property_read_variable_u32_array() and of_property_present()
Subsystems (4)
PATCH 1/1 input: tegra: Use of_property_read_variable_u32_array() and of_property_present()
There's no need to get the length of an DT array property before parsing the array. of_property_read_variable_u32_array() takes a minimum and maximum length and returns the actual length (or error code).
This is part of a larger effort to remove callers of of_get_property() and similar functions. of_get_property() leaks the DT property data pointer which is a problem for dynamically allocated nodes which may be freed.
--- drivers/input/keyboard/tegra-kbc.c | 72 +++++++++++------------------- 1 file changed, 27 insertions(+), 45 deletions(-)
drivers/input/keyboard/tegra-kbc.c +27 -45
@@ -491,12 +491,10 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc)struct device_node *np = kbc->dev->of_node;u32 prop;int i; -u32 num_rows =0 ; -u32 num_cols =0 ; +int num_rows; +int num_cols;u32 cols_cfg[KBC_MAX_GPIO ];u32 rows_cfg[KBC_MAX_GPIO ]; -int proplen; -int ret;if (!of_property_read_u32 (np,"nvidia,debounce-delay-ms" , &prop)) kbc->debounce_cnt = prop;
@@ -510,56 +508,23 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc) of_property_read_bool(np, "nvidia,wakeup-source")) /* legacy */ kbc->wakeup = true; -if (!of_get_property (np,"nvidia,kbc-row-pins" , &proplen)) { -dev_err (kbc->dev,"property nvidia,kbc-row-pins not found\n" ); -return -ENOENT ; - } - num_rows = proplen /sizeof (u32); - -if (!of_get_property (np,"nvidia,kbc-col-pins" , &proplen)) { -dev_err (kbc->dev,"property nvidia,kbc-col-pins not found\n" ); -return -ENOENT ; - } - num_cols = proplen /sizeof (u32); - -if (num_rows > kbc->hw_support->max_rows) { -dev_err (kbc->dev, -"Number of rows is more than supported by hardware\n" ); -return -EINVAL ; - } - -if (num_cols > kbc->hw_support->max_columns) { -dev_err (kbc->dev, -"Number of cols is more than supported by hardware\n" ); -return -EINVAL ; - } - -if (!of_get_property (np,"linux,keymap" , &proplen)) { +if (!of_property_present (np,"linux,keymap" )) {dev_err (kbc->dev,"property linux,keymap not found\n" );return -ENOENT ; } -if (!num_rows || !num_cols || ((num_rows + num_cols) >KBC_MAX_GPIO )) { -dev_err (kbc->dev, -"keypad rows/columns not properly specified\n" ); -return -EINVAL ; - } -/* Set all pins as non-configured */ for (i =0 ; i < kbc->num_rows_and_columns; i++) kbc->pin_cfg[i].type =PIN_CFG_IGNORE ; - ret =of_property_read_u32_array (np,"nvidia,kbc-row-pins" , - rows_cfg, num_rows); -if (ret <0 ) { + num_rows =of_property_read_variable_u32_array (np,"nvidia,kbc-row-pins" , + rows_cfg,1 ,KBC_MAX_GPIO ); +if (num_rows <0 ) {dev_err (kbc->dev,"Rows configurations are not proper\n" ); -return -EINVAL ; - } - - ret =of_property_read_u32_array (np,"nvidia,kbc-col-pins" , - cols_cfg, num_cols); -if (ret <0 ) { -dev_err (kbc->dev,"Cols configurations are not proper\n" ); +return num_rows; + }else if (num_rows > kbc->hw_support->max_rows) { +dev_err (kbc->dev, +"Number of rows is more than supported by hardware\n" );return -EINVAL ; }
@@ -568,11 +533,28 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc) kbc->pin_cfg[rows_cfg[i]].num = i; } + num_cols =of_property_read_variable_u32_array (np,"nvidia,kbc-col-pins" , + cols_cfg,1 ,KBC_MAX_GPIO ); +if (num_cols <0 ) { +dev_err (kbc->dev,"Cols configurations are not proper\n" ); +return num_cols; + }else if (num_cols > kbc->hw_support->max_columns) { +dev_err (kbc->dev, +"Number of cols is more than supported by hardware\n" ); +return -EINVAL ; + } +for (i =0 ; i < num_cols; i++) { kbc->pin_cfg[cols_cfg[i]].type =PIN_CFG_COL ; kbc->pin_cfg[cols_cfg[i]].num = i; } +if (!num_rows || !num_cols || ((num_rows + num_cols) >KBC_MAX_GPIO )) { +dev_err (kbc->dev, +"keypad rows/columns not properly specified\n" ); +return -EINVAL ; + } +return 0 ; }
Signature · 1 line
2.43.0
Quoted 112 lines · Rob Herring (Arm)
There's no need to get the length of an DT array property before parsing the array.
of_property_read_variable_u32_array()takes a minimum and maximum length and returns the actual length (or error code).This is part of a larger effort to remove callers of
of_get_property()and similar functions.of_get_property()leaks the DT property data pointer which is a problem for dynamically allocated nodes which may be freed.--- drivers/input/keyboard/tegra-kbc.c | 72 +++++++++++------------------- 1 file changed, 27 insertions(+), 45 deletions(-)drivers/input/keyboard/tegra-kbc.c +21
-45@@ -491,12 +491,10 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc)struct device_node *np = kbc->dev->of_node;u32 prop;int i; -u32 num_rows =0 ; -u32 num_cols =0 ; +int num_rows; +int num_cols;u32 cols_cfg[KBC_MAX_GPIO ];u32 rows_cfg[KBC_MAX_GPIO ]; -int proplen; -int ret;if (!of_property_read_u32 (np,"nvidia,debounce-delay-ms" , &prop)) kbc->debounce_cnt = prop;@@ -510,56 +508,23 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc) of_property_read_bool(np, "nvidia,wakeup-source")) /* legacy */ kbc->wakeup = true; -if (!of_get_property (np,"nvidia,kbc-row-pins" , &proplen)) { -dev_err (kbc->dev,"property nvidia,kbc-row-pins not found\n" ); -return -ENOENT ; - } - num_rows = proplen /sizeof (u32); - -if (!of_get_property (np,"nvidia,kbc-col-pins" , &proplen)) { -dev_err (kbc->dev,"property nvidia,kbc-col-pins not found\n" ); -return -ENOENT ; - } - num_cols = proplen /sizeof (u32); - -if (num_rows > kbc->hw_support->max_rows) { -dev_err (kbc->dev, -"Number of rows is more than supported by hardware\n" ); -return -EINVAL ; - } - -if (num_cols > kbc->hw_support->max_columns) { -dev_err (kbc->dev, -"Number of cols is more than supported by hardware\n" ); -return -EINVAL ; - } - -if (!of_get_property (np,"linux,keymap" , &proplen)) { +if (!of_property_present (np,"linux,keymap" )) {dev_err (kbc->dev,"property linux,keymap not found\n" );return -ENOENT ; } -if (!num_rows || !num_cols || ((num_rows + num_cols) >KBC_MAX_GPIO )) { -dev_err (kbc->dev, -"keypad rows/columns not properly specified\n" ); -return -EINVAL ; - } -/* Set all pins as non-configured */ for (i =0 ; i < kbc->num_rows_and_columns; i++) kbc->pin_cfg[i].type =PIN_CFG_IGNORE ; - ret =of_property_read_u32_array (np,"nvidia,kbc-row-pins" , - rows_cfg, num_rows); -if (ret <0 ) { + num_rows =of_property_read_variable_u32_array (np,"nvidia,kbc-row-pins" , + rows_cfg,1 ,KBC_MAX_GPIO ); +if (num_rows <0 ) {dev_err (kbc->dev,"Rows configurations are not proper\n" ); -return -EINVAL ; - } - - ret =of_property_read_u32_array (np,"nvidia,kbc-col-pins" , - cols_cfg, num_cols); -if (ret <0 ) { -dev_err (kbc->dev,"Cols configurations are not proper\n" ); +return num_rows; + }else if (num_rows > kbc->hw_support->max_rows) { +dev_err (kbc->dev, +"Number of rows is more than supported by hardware\n" );return -EINVAL ; }@@ -568,11 +533,28 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc) kbc->pin_cfg[rows_cfg[i]].num = i; } + num_cols =of_property_read_variable_u32_array (np,"nvidia,kbc-col-pins" , + cols_cfg,1 ,KBC_MAX_GPIO ); +if (num_cols <0 ) { +dev_err (kbc->dev,"Cols configurations are not proper\n" ); +return num_cols; + }else if (num_cols > kbc->hw_support->max_columns) { +dev_err (kbc->dev, +"Number of cols is more than supported by hardware\n" ); +return -EINVAL ; + } +
drivers/input/keyboard/tegra-kbc.c static int tegra_kbc_parse_dt(struct tegra_kbc *kbc) · line 556
Quoted 10 lines
drivers/input/keyboard/tegra-kbc.c +5
-0for (i =0 ; i < num_cols; i++) { kbc->pin_cfg[cols_cfg[i]].type =PIN_CFG_COL ; kbc->pin_cfg[cols_cfg[i]].num = i; } +if (!num_rows || !num_cols || ((num_rows + num_cols) >KBC_MAX_GPIO )) { +dev_err (kbc->dev, +"keypad rows/columns not properly specified\n" ); +return -EINVAL ; + }
Previously we wouldn't try to initialize the columns when the rows/columns were invalid, so this block could move before the last for loop above.
But it doesn't really matter given that these are exceptions and really shouldn't happen, so:
Quoted 128 lines · Thierry Reding
Quoted 112 lines · Rob Herring (Arm)
There's no need to get the length of an DT array property before parsing the array.
of_property_read_variable_u32_array()takes a minimum and maximum length and returns the actual length (or error code).This is part of a larger effort to remove callers of
of_get_property()and similar functions.of_get_property()leaks the DT property data pointer which is a problem for dynamically allocated nodes which may be freed.--- drivers/input/keyboard/tegra-kbc.c | 72 +++++++++++------------------- 1 file changed, 27 insertions(+), 45 deletions(-)drivers/input/keyboard/tegra-kbc.c +21
-45@@ -491,12 +491,10 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc)struct device_node *np = kbc->dev->of_node;u32 prop;int i; -u32 num_rows =0 ; -u32 num_cols =0 ; +int num_rows; +int num_cols;u32 cols_cfg[KBC_MAX_GPIO ];u32 rows_cfg[KBC_MAX_GPIO ]; -int proplen; -int ret;if (!of_property_read_u32 (np,"nvidia,debounce-delay-ms" , &prop)) kbc->debounce_cnt = prop;@@ -510,56 +508,23 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc) of_property_read_bool(np, "nvidia,wakeup-source")) /* legacy */ kbc->wakeup = true; -if (!of_get_property (np,"nvidia,kbc-row-pins" , &proplen)) { -dev_err (kbc->dev,"property nvidia,kbc-row-pins not found\n" ); -return -ENOENT ; - } - num_rows = proplen /sizeof (u32); - -if (!of_get_property (np,"nvidia,kbc-col-pins" , &proplen)) { -dev_err (kbc->dev,"property nvidia,kbc-col-pins not found\n" ); -return -ENOENT ; - } - num_cols = proplen /sizeof (u32); - -if (num_rows > kbc->hw_support->max_rows) { -dev_err (kbc->dev, -"Number of rows is more than supported by hardware\n" ); -return -EINVAL ; - } - -if (num_cols > kbc->hw_support->max_columns) { -dev_err (kbc->dev, -"Number of cols is more than supported by hardware\n" ); -return -EINVAL ; - } - -if (!of_get_property (np,"linux,keymap" , &proplen)) { +if (!of_property_present (np,"linux,keymap" )) {dev_err (kbc->dev,"property linux,keymap not found\n" );return -ENOENT ; } -if (!num_rows || !num_cols || ((num_rows + num_cols) >KBC_MAX_GPIO )) { -dev_err (kbc->dev, -"keypad rows/columns not properly specified\n" ); -return -EINVAL ; - } -/* Set all pins as non-configured */ for (i =0 ; i < kbc->num_rows_and_columns; i++) kbc->pin_cfg[i].type =PIN_CFG_IGNORE ; - ret =of_property_read_u32_array (np,"nvidia,kbc-row-pins" , - rows_cfg, num_rows); -if (ret <0 ) { + num_rows =of_property_read_variable_u32_array (np,"nvidia,kbc-row-pins" , + rows_cfg,1 ,KBC_MAX_GPIO ); +if (num_rows <0 ) {dev_err (kbc->dev,"Rows configurations are not proper\n" ); -return -EINVAL ; - } - - ret =of_property_read_u32_array (np,"nvidia,kbc-col-pins" , - cols_cfg, num_cols); -if (ret <0 ) { -dev_err (kbc->dev,"Cols configurations are not proper\n" ); +return num_rows; + }else if (num_rows > kbc->hw_support->max_rows) { +dev_err (kbc->dev, +"Number of rows is more than supported by hardware\n" );return -EINVAL ; }@@ -568,11 +533,28 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc) kbc->pin_cfg[rows_cfg[i]].num = i; } + num_cols =of_property_read_variable_u32_array (np,"nvidia,kbc-col-pins" , + cols_cfg,1 ,KBC_MAX_GPIO ); +if (num_cols <0 ) { +dev_err (kbc->dev,"Cols configurations are not proper\n" ); +return num_cols; + }else if (num_cols > kbc->hw_support->max_columns) { +dev_err (kbc->dev, +"Number of cols is more than supported by hardware\n" ); +return -EINVAL ; + } +drivers/input/keyboard/tegra-kbc.c static int tegra_kbc_parse_dt(struct tegra_kbc *kbc) · line 556
Quoted 10 lines
drivers/input/keyboard/tegra-kbc.c +5
-0for (i =0 ; i < num_cols; i++) { kbc->pin_cfg[cols_cfg[i]].type =PIN_CFG_COL ; kbc->pin_cfg[cols_cfg[i]].num = i; } +if (!num_rows || !num_cols || ((num_rows + num_cols) >KBC_MAX_GPIO )) { +dev_err (kbc->dev, +"keypad rows/columns not properly specified\n" ); +return -EINVAL ; + }Previously we wouldn't try to initialize the columns when the rows/columns were invalid, so this block could move before the last for loop above.
Quoted 4 lines
But it doesn't really matter given that these are exceptions and really shouldn't happen, so:
Acked-by Thierry Reding <[email protected]>
I don't quite like of_property_read_variable_u32_array() because it is OF-specific. device_property_count_u32() will return the number of elements in an array. But I guess this driver will only be used on an OF system...
Applied, thank you.
Signature · 1 line
Dmitry
Dmitry Torokhov
maintainerQuoted 132 lines · Dmitry Torokhov
Quoted 131 lines · Thierry Reding
Quoted 112 lines · Rob Herring (Arm)
There's no need to get the length of an DT array property before parsing the array.
of_property_read_variable_u32_array()takes a minimum and maximum length and returns the actual length (or error code).This is part of a larger effort to remove callers of
of_get_property()and similar functions.of_get_property()leaks the DT property data pointer which is a problem for dynamically allocated nodes which may be freed.--- drivers/input/keyboard/tegra-kbc.c | 72 +++++++++++------------------- 1 file changed, 27 insertions(+), 45 deletions(-)drivers/input/keyboard/tegra-kbc.c +21
-45@@ -491,12 +491,10 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc)struct device_node *np = kbc->dev->of_node;u32 prop;int i; -u32 num_rows =0 ; -u32 num_cols =0 ; +int num_rows; +int num_cols;u32 cols_cfg[KBC_MAX_GPIO ];u32 rows_cfg[KBC_MAX_GPIO ]; -int proplen; -int ret;if (!of_property_read_u32 (np,"nvidia,debounce-delay-ms" , &prop)) kbc->debounce_cnt = prop;@@ -510,56 +508,23 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc) of_property_read_bool(np, "nvidia,wakeup-source")) /* legacy */ kbc->wakeup = true; -if (!of_get_property (np,"nvidia,kbc-row-pins" , &proplen)) { -dev_err (kbc->dev,"property nvidia,kbc-row-pins not found\n" ); -return -ENOENT ; - } - num_rows = proplen /sizeof (u32); - -if (!of_get_property (np,"nvidia,kbc-col-pins" , &proplen)) { -dev_err (kbc->dev,"property nvidia,kbc-col-pins not found\n" ); -return -ENOENT ; - } - num_cols = proplen /sizeof (u32); - -if (num_rows > kbc->hw_support->max_rows) { -dev_err (kbc->dev, -"Number of rows is more than supported by hardware\n" ); -return -EINVAL ; - } - -if (num_cols > kbc->hw_support->max_columns) { -dev_err (kbc->dev, -"Number of cols is more than supported by hardware\n" ); -return -EINVAL ; - } - -if (!of_get_property (np,"linux,keymap" , &proplen)) { +if (!of_property_present (np,"linux,keymap" )) {dev_err (kbc->dev,"property linux,keymap not found\n" );return -ENOENT ; } -if (!num_rows || !num_cols || ((num_rows + num_cols) >KBC_MAX_GPIO )) { -dev_err (kbc->dev, -"keypad rows/columns not properly specified\n" ); -return -EINVAL ; - } -/* Set all pins as non-configured */ for (i =0 ; i < kbc->num_rows_and_columns; i++) kbc->pin_cfg[i].type =PIN_CFG_IGNORE ; - ret =of_property_read_u32_array (np,"nvidia,kbc-row-pins" , - rows_cfg, num_rows); -if (ret <0 ) { + num_rows =of_property_read_variable_u32_array (np,"nvidia,kbc-row-pins" , + rows_cfg,1 ,KBC_MAX_GPIO ); +if (num_rows <0 ) {dev_err (kbc->dev,"Rows configurations are not proper\n" ); -return -EINVAL ; - } - - ret =of_property_read_u32_array (np,"nvidia,kbc-col-pins" , - cols_cfg, num_cols); -if (ret <0 ) { -dev_err (kbc->dev,"Cols configurations are not proper\n" ); +return num_rows; + }else if (num_rows > kbc->hw_support->max_rows) { +dev_err (kbc->dev, +"Number of rows is more than supported by hardware\n" );return -EINVAL ; }@@ -568,11 +533,28 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc) kbc->pin_cfg[rows_cfg[i]].num = i; } + num_cols =of_property_read_variable_u32_array (np,"nvidia,kbc-col-pins" , + cols_cfg,1 ,KBC_MAX_GPIO ); +if (num_cols <0 ) { +dev_err (kbc->dev,"Cols configurations are not proper\n" ); +return num_cols; + }else if (num_cols > kbc->hw_support->max_columns) { +dev_err (kbc->dev, +"Number of cols is more than supported by hardware\n" ); +return -EINVAL ; + } +drivers/input/keyboard/tegra-kbc.c static int tegra_kbc_parse_dt(struct tegra_kbc *kbc) · line 556
Quoted 10 lines
drivers/input/keyboard/tegra-kbc.c +5
-0for (i =0 ; i < num_cols; i++) { kbc->pin_cfg[cols_cfg[i]].type =PIN_CFG_COL ; kbc->pin_cfg[cols_cfg[i]].num = i; } +if (!num_rows || !num_cols || ((num_rows + num_cols) >KBC_MAX_GPIO )) { +dev_err (kbc->dev, +"keypad rows/columns not properly specified\n" ); +return -EINVAL ; + }Previously we wouldn't try to initialize the columns when the rows/columns were invalid, so this block could move before the last for loop above.
But it doesn't really matter given that these are exceptions and really shouldn't happen, so:
Quoted 8 lines
Quoted 1 line
Acked-by Thierry Reding <[email protected]>I don't quite like
of_property_read_variable_u32_array()because it is OF-specific.device_property_count_u32()will return the number of elements in an array. But I guess this driver will only be used on an OF system...Applied, thank you.
Oh, wait, can I get your SOB please?
Signature · 1 line
Dmitry
Quoted 132 lines · Dmitry Torokhov
Quoted 131 lines · Thierry Reding
Quoted 112 lines · Rob Herring (Arm)
There's no need to get the length of an DT array property before parsing the array.
of_property_read_variable_u32_array()takes a minimum and maximum length and returns the actual length (or error code).This is part of a larger effort to remove callers of
of_get_property()and similar functions.of_get_property()leaks the DT property data pointer which is a problem for dynamically allocated nodes which may be freed.--- drivers/input/keyboard/tegra-kbc.c | 72 +++++++++++------------------- 1 file changed, 27 insertions(+), 45 deletions(-)drivers/input/keyboard/tegra-kbc.c +21
-45@@ -491,12 +491,10 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc)struct device_node *np = kbc->dev->of_node;u32 prop;int i; -u32 num_rows =0 ; -u32 num_cols =0 ; +int num_rows; +int num_cols;u32 cols_cfg[KBC_MAX_GPIO ];u32 rows_cfg[KBC_MAX_GPIO ]; -int proplen; -int ret;if (!of_property_read_u32 (np,"nvidia,debounce-delay-ms" , &prop)) kbc->debounce_cnt = prop;@@ -510,56 +508,23 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc) of_property_read_bool(np, "nvidia,wakeup-source")) /* legacy */ kbc->wakeup = true; -if (!of_get_property (np,"nvidia,kbc-row-pins" , &proplen)) { -dev_err (kbc->dev,"property nvidia,kbc-row-pins not found\n" ); -return -ENOENT ; - } - num_rows = proplen /sizeof (u32); - -if (!of_get_property (np,"nvidia,kbc-col-pins" , &proplen)) { -dev_err (kbc->dev,"property nvidia,kbc-col-pins not found\n" ); -return -ENOENT ; - } - num_cols = proplen /sizeof (u32); - -if (num_rows > kbc->hw_support->max_rows) { -dev_err (kbc->dev, -"Number of rows is more than supported by hardware\n" ); -return -EINVAL ; - } - -if (num_cols > kbc->hw_support->max_columns) { -dev_err (kbc->dev, -"Number of cols is more than supported by hardware\n" ); -return -EINVAL ; - } - -if (!of_get_property (np,"linux,keymap" , &proplen)) { +if (!of_property_present (np,"linux,keymap" )) {dev_err (kbc->dev,"property linux,keymap not found\n" );return -ENOENT ; } -if (!num_rows || !num_cols || ((num_rows + num_cols) >KBC_MAX_GPIO )) { -dev_err (kbc->dev, -"keypad rows/columns not properly specified\n" ); -return -EINVAL ; - } -/* Set all pins as non-configured */ for (i =0 ; i < kbc->num_rows_and_columns; i++) kbc->pin_cfg[i].type =PIN_CFG_IGNORE ; - ret =of_property_read_u32_array (np,"nvidia,kbc-row-pins" , - rows_cfg, num_rows); -if (ret <0 ) { + num_rows =of_property_read_variable_u32_array (np,"nvidia,kbc-row-pins" , + rows_cfg,1 ,KBC_MAX_GPIO ); +if (num_rows <0 ) {dev_err (kbc->dev,"Rows configurations are not proper\n" ); -return -EINVAL ; - } - - ret =of_property_read_u32_array (np,"nvidia,kbc-col-pins" , - cols_cfg, num_cols); -if (ret <0 ) { -dev_err (kbc->dev,"Cols configurations are not proper\n" ); +return num_rows; + }else if (num_rows > kbc->hw_support->max_rows) { +dev_err (kbc->dev, +"Number of rows is more than supported by hardware\n" );return -EINVAL ; }@@ -568,11 +533,28 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc) kbc->pin_cfg[rows_cfg[i]].num = i; } + num_cols =of_property_read_variable_u32_array (np,"nvidia,kbc-col-pins" , + cols_cfg,1 ,KBC_MAX_GPIO ); +if (num_cols <0 ) { +dev_err (kbc->dev,"Cols configurations are not proper\n" ); +return num_cols; + }else if (num_cols > kbc->hw_support->max_columns) { +dev_err (kbc->dev, +"Number of cols is more than supported by hardware\n" ); +return -EINVAL ; + } +drivers/input/keyboard/tegra-kbc.c static int tegra_kbc_parse_dt(struct tegra_kbc *kbc) · line 556
Quoted 10 lines
drivers/input/keyboard/tegra-kbc.c +5
-0for (i =0 ; i < num_cols; i++) { kbc->pin_cfg[cols_cfg[i]].type =PIN_CFG_COL ; kbc->pin_cfg[cols_cfg[i]].num = i; } +if (!num_rows || !num_cols || ((num_rows + num_cols) >KBC_MAX_GPIO )) { +dev_err (kbc->dev, +"keypad rows/columns not properly specified\n" ); +return -EINVAL ; + }Previously we wouldn't try to initialize the columns when the rows/columns were invalid, so this block could move before the last for loop above.
But it doesn't really matter given that these are exceptions and really shouldn't happen, so:
Quoted 6 lines
Quoted 1 line
Acked-by Thierry Reding <[email protected]>I don't quite like
of_property_read_variable_u32_array()because it is OF-specific.device_property_count_u32()will return the number of elements in an array. But I guess this driver will only be used on an OF system...
Yeah, this hardware only exists on fairly old Tegra devices and I know of no plans to support anything other that DT on those.
Thierry
Dmitry Torokhov
maintainerQuoted 4 lines · Dmitry Torokhov
Quoted 2 lines
Applied, thank you.
Oh, wait, can I get your SOB please?
Rob, I am still waiting on your SOB please.
Signature · 1 line
Dmitry
Quoted 8 lines · Dmitry Torokhov
Quoted 4 lines · Dmitry Torokhov
Quoted 2 lines
Applied, thank you.
Oh, wait, can I get your SOB please?
Rob, I am still waiting on your SOB please.
Oh, missed this. That's weird it is missing. New patch coming.
Rob