Re: [PATCH 3/5] hwmon: (max1668) Convert to use regmap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/26/24 08:20, Tzung-Bi Shih wrote:
On Thu, Jul 25, 2024 at 05:43:27PM -0700, Guenter Roeck wrote:
@@ -15,6 +16,7 @@
  #include <linux/jiffies.h>

Should be able to drop.

  #include <linux/module.h>
  #include <linux/mutex.h>

Should be able to drop too.


Indeed.

  static ssize_t show_fault(struct device *dev,
  			  struct device_attribute *devattr, char *buf)
  {
  	int index = to_sensor_dev_attr(devattr)->index;
-	struct max1668_data *data = max1668_update_device(dev);
+	struct max1668_data *data = dev_get_drvdata(dev);
+	struct regmap *regmap = data->regmap;
+	u32 alarm, temp;
+	int ret;
- if (IS_ERR(data))
-		return PTR_ERR(data);
+	ret = regmap_read(regmap, MAX1668_REG_STAT1, &alarm);
+	if (ret)
+		return ret;
- return sprintf(buf, "%u\n",
-		       (data->alarms & BIT(12)) && data->temp[index] == 127);
+	ret = regmap_read(regmap, MAX1668_REG_TEMP(index), &temp);
+	if (ret)
+		return ret;
+
+	return sprintf(buf, "%u\n", (alarm & BIT(12)) && temp == 127);

Should be BIT(12 & 7).

You are correct. BIT(4), really.

Thanks a lot for the reviews!

Guenter





[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux