File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1595,15 +1595,23 @@ EXPORT_SYMBOL_GPL(nvmem_cell_put);
15951595static void nvmem_shift_read_buffer_in_place (struct nvmem_cell_entry * cell , void * buf )
15961596{
15971597 u8 * p , * b ;
1598- int i , extra , bit_offset = cell -> bit_offset ;
1598+ int i , padding , extra , bit_offset = cell -> bit_offset ;
1599+ int bytes = cell -> bytes ;
15991600
16001601 p = b = buf ;
16011602 if (bit_offset ) {
1603+ padding = bit_offset /8 ;
1604+ if (padding ) {
1605+ memmove (buf , buf + padding , bytes - padding );
1606+ bit_offset -= BITS_PER_BYTE * padding ;
1607+ bytes -= padding ;
1608+ }
1609+
16021610 /* First shift */
16031611 * b ++ >>= bit_offset ;
16041612
16051613 /* setup rest of the bytes if any */
1606- for (i = 1 ; i < cell -> bytes ; i ++ ) {
1614+ for (i = 1 ; i < bytes ; i ++ ) {
16071615 /* Get bits from next byte and shift them towards msb */
16081616 * p |= * b << (BITS_PER_BYTE - bit_offset );
16091617
@@ -1616,7 +1624,7 @@ static void nvmem_shift_read_buffer_in_place(struct nvmem_cell_entry *cell, void
16161624 }
16171625
16181626 /* result fits in less bytes */
1619- extra = cell -> bytes - DIV_ROUND_UP (cell -> nbits , BITS_PER_BYTE );
1627+ extra = bytes - DIV_ROUND_UP (cell -> nbits , BITS_PER_BYTE );
16201628 while (-- extra >= 0 )
16211629 * p -- = 0 ;
16221630
You can’t perform that action at this time.
0 commit comments