* [PATCH] max17042_battery: fix model download bug.
@ 2016-07-28 18:07 Sven Van Asbroeck
0 siblings, 0 replies; 3+ messages in thread
From: Sven Van Asbroeck @ 2016-07-28 18:07 UTC (permalink / raw)
To: linux-pm, David Woodhouse, Dmitry Eremin-Solenikov,
Sebastian Reichel
The device's model download function returns the model data as
an array of u32s, which is later compared to the reference
model data. However, since the latter is an array of u16s,
the comparison does not happen correctly, and model verification
fails. This in turn breaks the POR initialization sequence.
Signed-off-by: Sven Van Asbroeck <TheSven73@googlemail.com>
---
drivers/power/max17042_battery.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c
index 9c65f13..da7a75f 100644
--- a/drivers/power/max17042_battery.c
+++ b/drivers/power/max17042_battery.c
@@ -457,13 +457,16 @@ static inline void
max17042_write_model_data(struct max17042_chip *chip,
}
static inline void max17042_read_model_data(struct max17042_chip *chip,
- u8 addr, u32 *data, int size)
+ u8 addr, u16 *data, int size)
{
struct regmap *map = chip->regmap;
int i;
+ u32 tmp;
- for (i = 0; i < size; i++)
- regmap_read(map, addr + i, &data[i]);
+ for (i = 0; i < size; i++) {
+ regmap_read(map, addr + i, &tmp);
+ data[i] = (u16)tmp;
+ }
}
static inline int max17042_model_data_compare(struct max17042_chip *chip,
@@ -486,7 +489,7 @@ static int max17042_init_model(struct max17042_chip *chip)
{
int ret;
int table_size = ARRAY_SIZE(chip->pdata->config_data->cell_char_tbl);
- u32 *temp_data;
+ u16 *temp_data;
temp_data = kcalloc(table_size, sizeof(*temp_data), GFP_KERNEL);
if (!temp_data)
@@ -501,7 +504,7 @@ static int max17042_init_model(struct max17042_chip *chip)
ret = max17042_model_data_compare(
chip,
chip->pdata->config_data->cell_char_tbl,
- (u16 *)temp_data,
+ temp_data,
table_size);
max10742_lock_model(chip);
@@ -514,7 +517,7 @@ static int max17042_verify_model_lock(struct
max17042_chip *chip)
{
int i;
int table_size = ARRAY_SIZE(chip->pdata->config_data->cell_char_tbl);
- u32 *temp_data;
+ u16 *temp_data;
int ret = 0;
temp_data = kcalloc(table_size, sizeof(*temp_data), GFP_KERNEL);
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] max17042_battery: fix model download bug.
[not found] <CAGngYiVv=+RKDcuwqPxyg5GpU6iCBkuR2v7EFmnDM3Xf+w0b_g@mail.gmail.com>
@ 2016-08-09 18:54 ` Sebastian Reichel
2016-08-10 8:27 ` Krzysztof Kozlowski
0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Reichel @ 2016-08-09 18:54 UTC (permalink / raw)
To: Sven Van Asbroeck
Cc: linux-kernel, linux-pm, Jonghwa Lee, Krzysztof Kozlowski
[-- Attachment #1: Type: text/plain, Size: 2611 bytes --]
Hi,
[adding some people to CC]
On Wed, Aug 03, 2016 at 10:03:46AM -0400, Sven Van Asbroeck wrote:
> The device's model download function returns the model data as
> an array of u32s, which is later compared to the reference
> model data. However, since the latter is an array of u16s,
> the comparison does not happen correctly, and model verification
> fails. This in turn breaks the POR initialization sequence.
Patch looks ok, except for missing Fixes. I guess it should be
"Fixes: 39e7213edc4f3". I will wait with queuing it for a few
days giving Samsung people a chance to reply.
-- Sebastian
> drivers/power/max17042_battery.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c
> index 9c65f13..da7a75f 100644
> --- a/drivers/power/max17042_battery.c
> +++ b/drivers/power/max17042_battery.c
> @@ -457,13 +457,16 @@ static inline void
> max17042_write_model_data(struct max17042_chip *chip,
> }
>
> static inline void max17042_read_model_data(struct max17042_chip *chip,
> - u8 addr, u32 *data, int size)
> + u8 addr, u16 *data, int size)
> {
> struct regmap *map = chip->regmap;
> int i;
> + u32 tmp;
>
> - for (i = 0; i < size; i++)
> - regmap_read(map, addr + i, &data[i]);
> + for (i = 0; i < size; i++) {
> + regmap_read(map, addr + i, &tmp);
> + data[i] = (u16)tmp;
> + }
> }
>
> static inline int max17042_model_data_compare(struct max17042_chip *chip,
> @@ -486,7 +489,7 @@ static int max17042_init_model(struct max17042_chip *chip)
> {
> int ret;
> int table_size = ARRAY_SIZE(chip->pdata->config_data->cell_char_tbl);
> - u32 *temp_data;
> + u16 *temp_data;
>
> temp_data = kcalloc(table_size, sizeof(*temp_data), GFP_KERNEL);
> if (!temp_data)
> @@ -501,7 +504,7 @@ static int max17042_init_model(struct max17042_chip *chip)
> ret = max17042_model_data_compare(
> chip,
> chip->pdata->config_data->cell_char_tbl,
> - (u16 *)temp_data,
> + temp_data,
> table_size);
>
> max10742_lock_model(chip);
> @@ -514,7 +517,7 @@ static int max17042_verify_model_lock(struct
> max17042_chip *chip)
> {
> int i;
> int table_size = ARRAY_SIZE(chip->pdata->config_data->cell_char_tbl);
> - u32 *temp_data;
> + u16 *temp_data;
> int ret = 0;
>
> temp_data = kcalloc(table_size, sizeof(*temp_data), GFP_KERNEL);
> --
> 1.9.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] max17042_battery: fix model download bug.
2016-08-09 18:54 ` [PATCH] max17042_battery: fix model download bug Sebastian Reichel
@ 2016-08-10 8:27 ` Krzysztof Kozlowski
0 siblings, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2016-08-10 8:27 UTC (permalink / raw)
To: Sebastian Reichel, Sven Van Asbroeck
Cc: linux-kernel, linux-pm, Jonghwa Lee, Dan Carpenter
On 08/09/2016 08:54 PM, Sebastian Reichel wrote:
> Hi,
>
> [adding some people to CC]
>
> On Wed, Aug 03, 2016 at 10:03:46AM -0400, Sven Van Asbroeck wrote:
>> The device's model download function returns the model data as
>> an array of u32s, which is later compared to the reference
>> model data. However, since the latter is an array of u16s,
>> the comparison does not happen correctly, and model verification
>> fails. This in turn breaks the POR initialization sequence.
>
> Patch looks ok, except for missing Fixes. I guess it should be
> "Fixes: 39e7213edc4f3". I will wait with queuing it for a few
> days giving Samsung people a chance to reply.
Looks correct.
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Also:
Cc: <stable@vger.kernel.org>
And how about:
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
https://www.marc.info/?l=linux-pm&m=143954612610000&w=4
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-08-10 8:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CAGngYiVv=+RKDcuwqPxyg5GpU6iCBkuR2v7EFmnDM3Xf+w0b_g@mail.gmail.com>
2016-08-09 18:54 ` [PATCH] max17042_battery: fix model download bug Sebastian Reichel
2016-08-10 8:27 ` Krzysztof Kozlowski
2016-07-28 18:07 Sven Van Asbroeck
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).