From: Zev Weiss Date: Mon, 2 Jan 2023 21:28:57 +0000 (-0800) Subject: hwmon: (nct6775) Fix incorrect parenthesization in nct6775_write_fan_div() X-Git-Tag: v6.1.21~632 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=688ae6ce05bebf4ec46ccf55ccb537e8225d1f36;p=platform%2Fkernel%2Flinux-starfive.git hwmon: (nct6775) Fix incorrect parenthesization in nct6775_write_fan_div() commit 2fbb848b65cde5b876cce52ebcb34de4aaa5a94a upstream. Commit 4ef2774511dc ("hwmon: (nct6775) Convert register access to regmap API") fumbled the shifting & masking of the fan_div values such that odd-numbered fan divisors would always be set to zero. Fix it so that we actually OR in the bits we meant to. Signed-off-by: Zev Weiss Fixes: 4ef2774511dc ("hwmon: (nct6775) Convert register access to regmap API") Cc: stable@kernel.org # v5.19+ Link: https://lore.kernel.org/r/20230102212857.5670-1-zev@bewilderbeest.net Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/hwmon/nct6775-core.c b/drivers/hwmon/nct6775-core.c index da9ec69..c54233f 100644 --- a/drivers/hwmon/nct6775-core.c +++ b/drivers/hwmon/nct6775-core.c @@ -1150,7 +1150,7 @@ static int nct6775_write_fan_div(struct nct6775_data *data, int nr) if (err) return err; reg &= 0x70 >> oddshift; - reg |= data->fan_div[nr] & (0x7 << oddshift); + reg |= (data->fan_div[nr] & 0x7) << oddshift; return nct6775_write_value(data, fandiv_reg, reg); }