[PATCH 2/2] hwmon: spd5118: Fail probe if SPD writes are disabled

Tinsae Tadesse posted 2 patches 3 days, 20 hours ago
[PATCH 2/2] hwmon: spd5118: Fail probe if SPD writes are disabled
Posted by Tinsae Tadesse 3 days, 20 hours ago
SPD5118 requires write access for page selection, configuration,
and cache synchronization during suspend/resume. If the host
controller does not allow SPD writes, the driver cannot function
properly.

Detect this state using adapter quirks and determine whether to
stop the probe.

Signed-off-by: Tinsae Tadesse <tinsaetadesse2015@gmail.com>
---
 drivers/hwmon/spd5118.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/hwmon/spd5118.c b/drivers/hwmon/spd5118.c
index 5da44571b6a0..094d05472562 100644
--- a/drivers/hwmon/spd5118.c
+++ b/drivers/hwmon/spd5118.c
@@ -525,6 +525,8 @@ static int spd5118_common_probe(struct device *dev, struct regmap *regmap,
 	unsigned int capability, revision, vendor, bank;
 	struct spd5118_data *data;
 	struct device *hwmon_dev;
+	struct i2c_client *client;
+	const struct i2c_adapter_quirks *quirks;
 	int err;
 
 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
@@ -552,6 +554,19 @@ static int spd5118_common_probe(struct device *dev, struct regmap *regmap,
 	if (!spd5118_vendor_valid(bank, vendor))
 		return -ENODEV;
 
+	/*
+	 * SPD5118 requires write access for correct operation
+	 * (page selection, configuration, and suspend/resume cache sync).
+	 * If the SPD writes are blocked by the SMBus controller, the
+	 * probe fails.
+	 */
+	client = to_i2c_client(dev);
+	quirks = client->adapter->quirks;
+	if (quirks && (quirks->flags & I2C_AQ_SPD_WRITE_DISABLED)) {
+		dev_err_probe(dev, -ENODEV, "SPD Write Disable is set on adapter; refusing probe\n");
+		return -ENODEV;
+	}
+
 	data->regmap = regmap;
 	mutex_init(&data->nvmem_lock);
 	dev_set_drvdata(dev, data);
-- 
2.52.0
Re: [PATCH 2/2] hwmon: spd5118: Fail probe if SPD writes are disabled
Posted by Guenter Roeck 3 days, 17 hours ago
On Thu, Feb 05, 2026 at 01:29:25PM +0300, Tinsae Tadesse wrote:
> SPD5118 requires write access for page selection, configuration,
> and cache synchronization during suspend/resume. If the host
> controller does not allow SPD writes, the driver cannot function
> properly.
> 
> Detect this state using adapter quirks and determine whether to
> stop the probe.
> 
> Signed-off-by: Tinsae Tadesse <tinsaetadesse2015@gmail.com>
> ---
>  drivers/hwmon/spd5118.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/hwmon/spd5118.c b/drivers/hwmon/spd5118.c
> index 5da44571b6a0..094d05472562 100644
> --- a/drivers/hwmon/spd5118.c
> +++ b/drivers/hwmon/spd5118.c
> @@ -525,6 +525,8 @@ static int spd5118_common_probe(struct device *dev, struct regmap *regmap,
>  	unsigned int capability, revision, vendor, bank;
>  	struct spd5118_data *data;
>  	struct device *hwmon_dev;
> +	struct i2c_client *client;
> +	const struct i2c_adapter_quirks *quirks;
>  	int err;
>  
>  	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> @@ -552,6 +554,19 @@ static int spd5118_common_probe(struct device *dev, struct regmap *regmap,
>  	if (!spd5118_vendor_valid(bank, vendor))
>  		return -ENODEV;
>  
> +	/*
> +	 * SPD5118 requires write access for correct operation
> +	 * (page selection, configuration, and suspend/resume cache sync).
> +	 * If the SPD writes are blocked by the SMBus controller, the
> +	 * probe fails.
> +	 */
> +	client = to_i2c_client(dev);
> +	quirks = client->adapter->quirks;
> +	if (quirks && (quirks->flags & I2C_AQ_SPD_WRITE_DISABLED)) {
> +		dev_err_probe(dev, -ENODEV, "SPD Write Disable is set on adapter; refusing probe\n");
> +		return -ENODEV;

		return dev_err_probe(...);

> +	}
> +
>  	data->regmap = regmap;
>  	mutex_init(&data->nvmem_lock);
>  	dev_set_drvdata(dev, data);
> -- 
> 2.52.0
>