diff options
author | Jonathan Matthew <jmatthew@cvs.openbsd.org> | 2019-01-18 23:14:45 +0000 |
---|---|---|
committer | Jonathan Matthew <jmatthew@cvs.openbsd.org> | 2019-01-18 23:14:45 +0000 |
commit | 5e29643b839e09f4ac439bff070fcff5df33ca7f (patch) | |
tree | b4364fb679b86159e2dbf93d19dfee450b42cf18 | |
parent | 1a58a6e859f402daa552fa9d5e7b7d6a8d30b2a9 (diff) |
pack hmc bits in the right order
ok dlg@
-rw-r--r-- | sys/dev/pci/if_ixl.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/sys/dev/pci/if_ixl.c b/sys/dev/pci/if_ixl.c index 9ba9c857cb1..cc845777d8c 100644 --- a/sys/dev/pci/if_ixl.c +++ b/sys/dev/pci/if_ixl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ixl.c,v 1.8 2018/11/18 08:42:15 jmatthew Exp $ */ +/* $OpenBSD: if_ixl.c,v 1.9 2019/01/18 23:14:44 jmatthew Exp $ */ /* * Copyright (c) 2013-2015, Intel Corporation @@ -3654,24 +3654,25 @@ ixl_hmc_pack(void *d, const void *s, const struct ixl_hmc_pack *packing, unsigned int inbits = 0; if (align) { - inbits = *in++; - - *out++ |= inbits << align; + inbits = (*in++) << align; + *out++ |= (inbits & 0xff); + inbits >>= 8; width -= 8 - align; } while (width >= 8) { - inbits <<= 8; - inbits |= *in++; - - *out++ = inbits << align; + inbits |= (*in++) << align; + *out++ = (inbits & 0xff); + inbits >>= 8; width -= 8; } - if (width) - *out = inbits >> (8 - align); + if (width > 0) { + inbits |= (*in) << align; + *out |= (inbits & ((1 << width) - 1)); + } } } |