Add driver for TMP461 thermal sensor. Register new sysctl node
of integer type for device. Read register and fill sysctl with
valid temperature.
Details
- Reviewers
mw wma manu - Commits
- rGf89f6f9581bd: TMP461: Add thermal sensor driver
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
sys/dev/iicbus/tmp461.c | ||
---|---|---|
194 | This is a good opportunity to create a system global helper for integer sign extend, instead of creating yet another duplicate local implementation. |
As discussed on IRC, I propose that such a helper should have three arguments:
- the bitfield to extract from (32/64 bit?)
- the index of the least significant bit of the field to extract
- the number of bits in the field.
This roughly corresponds to the sbfx and ufbx instructions on ARM and is as flexible as needed. Both signed and unsigned versions should be provided.
Maybe a corresponding narrowing/insertion function (corresponding to the bfi instruction) would be nice, too.
@hum_semihalf.com
What Robert has in mind is something more akin to this (I allowed myself to replace the number of bits with an index to the most significant bit):
static __inline int32_t signed_extend32(uint32_t bitmap, int msb, int lsb) { return ((int32_t)(bitmap << (31 - msb)) >> (31 - msb + lsb)); }
This way we cover situations where the embedded value does not start at the beginning of the bit field.
Please also provide the remaining versions of those helpers.
On another note, these should go into a separate commit.