Skip to content

Commit

Permalink
hwmon: (spd5118) Use generic parity calculation
Browse files Browse the repository at this point in the history
Make use of the new generic helper for calculating the parity.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Link: https://lore.kernel.org/r/20250107090204.6593-3-wsa+renesas@sang-engineering.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
  • Loading branch information
Wolfram Sang authored and Alexandre Belloni committed Jan 12, 2025
1 parent c320592 commit 32a8d36
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions drivers/hwmon/spd5118.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,20 +291,14 @@ static umode_t spd5118_is_visible(const void *_data, enum hwmon_sensor_types typ
}
}

static inline bool spd5118_parity8(u8 w)
{
w ^= w >> 4;
return (0x6996 >> (w & 0xf)) & 1;
}

/*
* Bank and vendor id are 8-bit fields with seven data bits and odd parity.
* Vendor IDs 0 and 0x7f are invalid.
* See Jedec standard JEP106BJ for details and a list of assigned vendor IDs.
*/
static bool spd5118_vendor_valid(u8 bank, u8 id)
{
if (!spd5118_parity8(bank) || !spd5118_parity8(id))
if (parity8(bank) == 0 || parity8(id) == 0)
return false;

id &= 0x7f;
Expand Down

0 comments on commit 32a8d36

Please sign in to comment.