@@ -83,7 +83,7 @@ int pack(void *pbuf, u64 uval, size_t startbit, size_t endbit, size_t pbuflen,
8383 /* startbit is expected to be larger than endbit, and both are
8484 * expected to be within the logically addressable range of the buffer.
8585 */
86- if (unlikely (startbit < endbit || startbit >= 8 * pbuflen ))
86+ if (unlikely (startbit < endbit || startbit >= BITS_PER_BYTE * pbuflen ))
8787 /* Invalid function call */
8888 return - EINVAL ;
8989
@@ -106,8 +106,8 @@ int pack(void *pbuf, u64 uval, size_t startbit, size_t endbit, size_t pbuflen,
106106 * no quirks, u8 by u8 (aligned at u8 boundaries), from high to low
107107 * logical bit significance. "box" denotes the current logical u8.
108108 */
109- plogical_first_u8 = startbit / 8 ;
110- plogical_last_u8 = endbit / 8 ;
109+ plogical_first_u8 = startbit / BITS_PER_BYTE ;
110+ plogical_last_u8 = endbit / BITS_PER_BYTE ;
111111
112112 for (box = plogical_first_u8 ; box >= plogical_last_u8 ; box -- ) {
113113 /* Bit indices into the currently accessed 8-bit box */
@@ -123,11 +123,11 @@ int pack(void *pbuf, u64 uval, size_t startbit, size_t endbit, size_t pbuflen,
123123 * input arguments startbit and endbit.
124124 */
125125 if (box == plogical_first_u8 )
126- box_start_bit = startbit % 8 ;
126+ box_start_bit = startbit % BITS_PER_BYTE ;
127127 else
128128 box_start_bit = 7 ;
129129 if (box == plogical_last_u8 )
130- box_end_bit = endbit % 8 ;
130+ box_end_bit = endbit % BITS_PER_BYTE ;
131131 else
132132 box_end_bit = 0 ;
133133
@@ -138,8 +138,8 @@ int pack(void *pbuf, u64 uval, size_t startbit, size_t endbit, size_t pbuflen,
138138 * box is u8, the projection is u64 because it may fall
139139 * anywhere within the unpacked u64.
140140 */
141- proj_start_bit = ((box * 8 ) + box_start_bit ) - endbit ;
142- proj_end_bit = ((box * 8 ) + box_end_bit ) - endbit ;
141+ proj_start_bit = ((box * BITS_PER_BYTE ) + box_start_bit ) - endbit ;
142+ proj_end_bit = ((box * BITS_PER_BYTE ) + box_end_bit ) - endbit ;
143143 proj_mask = GENMASK_ULL (proj_start_bit , proj_end_bit );
144144 box_mask = GENMASK_ULL (box_start_bit , box_end_bit );
145145
@@ -199,7 +199,7 @@ int unpack(const void *pbuf, u64 *uval, size_t startbit, size_t endbit,
199199 /* startbit is expected to be larger than endbit, and both are
200200 * expected to be within the logically addressable range of the buffer.
201201 */
202- if (unlikely (startbit < endbit || startbit >= 8 * pbuflen ))
202+ if (unlikely (startbit < endbit || startbit >= BITS_PER_BYTE * pbuflen ))
203203 /* Invalid function call */
204204 return - EINVAL ;
205205
@@ -214,8 +214,8 @@ int unpack(const void *pbuf, u64 *uval, size_t startbit, size_t endbit,
214214 * no quirks, u8 by u8 (aligned at u8 boundaries), from high to low
215215 * logical bit significance. "box" denotes the current logical u8.
216216 */
217- plogical_first_u8 = startbit / 8 ;
218- plogical_last_u8 = endbit / 8 ;
217+ plogical_first_u8 = startbit / BITS_PER_BYTE ;
218+ plogical_last_u8 = endbit / BITS_PER_BYTE ;
219219
220220 for (box = plogical_first_u8 ; box >= plogical_last_u8 ; box -- ) {
221221 /* Bit indices into the currently accessed 8-bit box */
@@ -231,11 +231,11 @@ int unpack(const void *pbuf, u64 *uval, size_t startbit, size_t endbit,
231231 * input arguments startbit and endbit.
232232 */
233233 if (box == plogical_first_u8 )
234- box_start_bit = startbit % 8 ;
234+ box_start_bit = startbit % BITS_PER_BYTE ;
235235 else
236236 box_start_bit = 7 ;
237237 if (box == plogical_last_u8 )
238- box_end_bit = endbit % 8 ;
238+ box_end_bit = endbit % BITS_PER_BYTE ;
239239 else
240240 box_end_bit = 0 ;
241241
@@ -246,8 +246,8 @@ int unpack(const void *pbuf, u64 *uval, size_t startbit, size_t endbit,
246246 * box is u8, the projection is u64 because it may fall
247247 * anywhere within the unpacked u64.
248248 */
249- proj_start_bit = ((box * 8 ) + box_start_bit ) - endbit ;
250- proj_end_bit = ((box * 8 ) + box_end_bit ) - endbit ;
249+ proj_start_bit = ((box * BITS_PER_BYTE ) + box_start_bit ) - endbit ;
250+ proj_end_bit = ((box * BITS_PER_BYTE ) + box_end_bit ) - endbit ;
251251 proj_mask = GENMASK_ULL (proj_start_bit , proj_end_bit );
252252 box_mask = GENMASK_ULL (box_start_bit , box_end_bit );
253253
0 commit comments