mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Adam Wujek <dev_public@wujek.eu>
To: unlisted-recipients:; (no To-header on input)
Cc: Adam Wujek <dev_public@wujek.eu>,
	Guenter Roeck <linux@roeck-us.net>,
	Jean Delvare <jdelvare@suse.com>,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] hwmod: (pmbus) disable PEC if not enabled
Date: Wed, 20 Apr 2022 12:54:45 +0000	[thread overview]
Message-ID: <20220420125421.415716-1-dev_public@wujek.eu> (raw)
In-Reply-To: <d2d09fe1-dada-e844-cafa-da48424855a4@roeck-us.net>

Explicitly disable PEC when the client does not support it.
The problematic scenario is the following. A device with enabled PEC
support is up and running, a kernel driver loaded.
Then the driver is unloaded (or device unbound), the HW device
is reconfigured externally (e.g. by i2cset) to advertise itself as not
supporting PEC. Without a new code, at the second load of the driver
(or bind) the "flags" variable is not updated to avoid PEC usage. As a
consequence the further communication with the device is done with
the PEC enabled, which is wrong.

Signed-off-by: Adam Wujek <dev_public@wujek.eu>
---
 drivers/hwmon/pmbus/pmbus_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index b2618b1d529e..0af7a3d74f47 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -2334,7 +2334,8 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
 				client->flags |= I2C_CLIENT_PEC;
 			}
 		}
-	}
+	} else
+		client->flags &= ~I2C_CLIENT_PEC;

 	/*
 	 * Check if the chip is write protected. If it is, we can not clear
--
2.25.1



  reply	other threads:[~2022-04-20 12:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-19 20:53 Adam Wujek
2022-04-19 22:00 ` Guenter Roeck
2022-04-19 22:10   ` wujek dev
2022-04-19 23:46     ` Guenter Roeck
2022-04-20  1:00 ` Guenter Roeck
2022-04-20 12:54   ` Adam Wujek [this message]
2022-04-20 13:55     ` Guenter Roeck
2022-04-20 14:51       ` [v3 PATCH] hwmon: " Adam Wujek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220420125421.415716-1-dev_public@wujek.eu \
    --to=dev_public@wujek.eu \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®