Re: [PATCH v2 2/4] rtc: pcf2123: port to regmap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 19/06/2019 13:42:52+0000, Dylan Howey wrote:
> The 06/19/2019 15:19, Alexandre Belloni wrote:
> > I'm ready to apply that series but...
> > 
> > On 03/05/2019 19:52:10+0000, Dylan Howey wrote:
> > >  static int pcf2123_read_offset(struct device *dev, long *offset)
> > >  {
> > > -	int ret;
> > > -	s8 reg;
> > > +	struct pcf2123_plat_data *pdata = dev_get_platdata(dev);
> > > +	int ret, val;
> > > +	unsigned int reg;
> > >  
> > > -	ret = pcf2123_read(dev, PCF2123_REG_OFFSET, &reg, 1);
> > > -	if (ret < 0)
> > > +	ret = regmap_read(pdata->map, PCF2123_REG_OFFSET, &reg);
> > > +	if (ret)
> > >  		return ret;
> > >  
> > > +	val = sign_extend32((reg & OFFSET_MASK), OFFSET_SIGN_BIT);
> > > +
> > >  	if (reg & OFFSET_COARSE)
> > > -		reg <<= 1; /* multiply by 2 and sign extend */
> > > -	else
> > > -		reg = sign_extend32(reg, OFFSET_SIGN_BIT);
> > > +		val *= 2;
> > >  
> > 
> > Please remove that change that sneaked in ;)
> > 
> > -- 
> > Alexandre Belloni, Bootlin
> > Embedded Linux and Kernel engineering
> > https://bootlin.com
> 
> I believe this change is necessary. In the old code reg was 8-bit, which
> means reg <<= 1 was discarding the coarse bit. Now that I'm using a
> larger reg I can't use that trick and have to use sign_extend32 and a
> multiply.
> 

That's correct.


-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux