lkml.org 
[lkml]   [2020]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 2/2] power: supply: add CellWise cw2015 fuel gauge driver
On Tue, Mar 10, 2020 at 07:55:42PM +0100, Tobias Schramm wrote:

> >> +static int cw_read_word(struct cw_battery *cw_bat, u8 reg, u16 *val)
> >> +{
> >> + u8 reg_val[2];
> >> + int ret;
> >> +
> >> + ret = regmap_raw_read(cw_bat->regmap, reg, reg_val, 2);
> >> + *val = (reg_val[0] << 8) + reg_val[1];
> >> + return ret;
> >> +}
> >
> > NIH BE type of readings? Can REGMAP_ENDIAN_BIG help?
>
> Not really, or can it? Registers on the cw2015 are a wild mix of single
> bytes and words. There does not seem to be a per register override for
> reg_/val_bits.

I see.
Perhaps

__be16 value;


ret = regmap(..., (...)value, sizeof(value));
if (ret)
return ret; // note, you missed this in above.

*val = be16_to_cpu(value);
return 0;

--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2020-03-11 09:15    [W:0.082 / U:2.424 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site