History

Merge tag 'hwmon-for-v6.3-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon fixes from Guenter Roeck: - ltc2992, adm1266: Set missing can_sleep flag - tmp512/tmp513: Drop of_match_ptr for ID table to fix build with !CONFIG_OF - ucd90320: Fix back-to-back access problem - ina3221: Fix bad error return from probe function - xgene: Fix use-after-free bug in remove function - adt7475: Fix hysteresis register bit masks, and fix association of 'smoothing' attributes * tag 'hwmon-for-v6.3-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (ltc2992) Set `can_sleep` flag for GPIO chip hwmon: (adm1266) Set `can_sleep` flag for GPIO chip hwmon: tmp512: drop of_match_ptr for ID table hwmon: (ucd90320) Add minimum delay between bus accesses hwmon: (ina3221) return prober error code hwmon: (xgene) Fix use after free bug in xgene_hwmon_remove due to race condition hwmon: (adt7475) Fix masking of hysteresis registers hwmon: (adt7475) Display smoothing attributes in correct order

Linus Torvalds committed 3 years ago

Commit 2a3e75a2 parents f900bff ab007097 files · +84 −6Browse files

Unified · Split

7 files
  1. drivers/hwmon/adt7475.c +4 −4
  2. drivers/hwmon/ina3221.c +1 −1
  3. drivers/hwmon/ltc2992.c +1 −0
  4. drivers/hwmon/pmbus/adm1266.c +1 −0
  5. drivers/hwmon/pmbus/ucd9000.c +75 −0
  6. drivers/hwmon/tmp513.c +1 −1
  7. drivers/hwmon/xgene-hwmon.c +1 −0
drivers/hwmon/adt7475.c+4−4
@@ -488,10 +488,10 @@ static ssize_t temp_store(struct device *dev, struct device_attribute *attr, · 487 unmodified lines
488 val = (temp - val) / 1000;488 val = (temp - val) / 1000;
489 489
490 if (sattr->index != 1) {490 if (sattr->index != 1) {
491 data->temp[HYSTERSIS][sattr->index] &= 0xF0;491 data->temp[HYSTERSIS][sattr->index] &= 0x0F;
492 data->temp[HYSTERSIS][sattr->index] |= (val & 0xF) << 4;492 data->temp[HYSTERSIS][sattr->index] |= (val & 0xF) << 4;
493 } else {493 } else {
494 data->temp[HYSTERSIS][sattr->index] &= 0x0F;494 data->temp[HYSTERSIS][sattr->index] &= 0xF0;
495 data->temp[HYSTERSIS][sattr->index] |= (val & 0xF);495 data->temp[HYSTERSIS][sattr->index] |= (val & 0xF);
496 }496 }
497 497
@@ -556,11 +556,11 @@ static ssize_t temp_st_show(struct device *dev, struct device_attribute *attr, · 58 unmodified lines
556 val = data->enh_acoustics[0] & 0xf;556 val = data->enh_acoustics[0] & 0xf;
557 break;557 break;
558 case 1:558 case 1:
559 val = (data->enh_acoustics[1] >> 4) & 0xf;559 val = data->enh_acoustics[1] & 0xf;
560 break;560 break;
561 case 2:561 case 2:
562 default:562 default:
563 val = data->enh_acoustics[1] & 0xf;563 val = (data->enh_acoustics[1] >> 4) & 0xf;
564 break;564 break;
565 }565 }
566 566
drivers/hwmon/ina3221.c+1−1
@@ -772,7 +772,7 @@ static int ina3221_probe_child_from_dt(struct device *dev, · 771 unmodified lines
772 return ret;772 return ret;
773 } else if (val > INA3221_CHANNEL3) {773 } else if (val > INA3221_CHANNEL3) {
774 dev_err(dev, "invalid reg %d of %pOFn\n", val, child);774 dev_err(dev, "invalid reg %d of %pOFn\n", val, child);
775 return ret;775 return -EINVAL;
776 }776 }
777 777
778 input = &ina->inputs[val];778 input = &ina->inputs[val];
drivers/hwmon/ltc2992.c+1−0
@@ -323,6 +323,7 @@ static int ltc2992_config_gpio(struct ltc2992_state *st) · 322 unmodified lines
323 st->gc.label = name;323 st->gc.label = name;
324 st->gc.parent = &st->client->dev;324 st->gc.parent = &st->client->dev;
325 st->gc.owner = THIS_MODULE;325 st->gc.owner = THIS_MODULE;
326 st->gc.can_sleep = true;
326 st->gc.base = -1;327 st->gc.base = -1;
327 st->gc.names = st->gpio_names;328 st->gc.names = st->gpio_names;
328 st->gc.ngpio = ARRAY_SIZE(st->gpio_names);329 st->gc.ngpio = ARRAY_SIZE(st->gpio_names);
drivers/hwmon/pmbus/adm1266.c+1−0
@@ -301,6 +301,7 @@ static int adm1266_config_gpio(struct adm1266_data *data) · 300 unmodified lines
301 data->gc.label = name;301 data->gc.label = name;
302 data->gc.parent = &data->client->dev;302 data->gc.parent = &data->client->dev;
303 data->gc.owner = THIS_MODULE;303 data->gc.owner = THIS_MODULE;
304 data->gc.can_sleep = true;
304 data->gc.base = -1;305 data->gc.base = -1;
305 data->gc.names = data->gpio_names;306 data->gc.names = data->gpio_names;
306 data->gc.ngpio = ARRAY_SIZE(data->gpio_names);307 data->gc.ngpio = ARRAY_SIZE(data->gpio_names);
drivers/hwmon/pmbus/ucd9000.c+75−0
@@ -7,6 +7,7 @@ · 6 unmodified lines
7 */7 */
8 8
9#include <linux/debugfs.h>9#include <linux/debugfs.h>
10#include <linux/delay.h>
10#include <linux/kernel.h>11#include <linux/kernel.h>
11#include <linux/module.h>12#include <linux/module.h>
12#include <linux/of_device.h>13#include <linux/of_device.h>
@@ -16,6 +17,7 @@ · 3 unmodified lines
16#include <linux/i2c.h>17#include <linux/i2c.h>
17#include <linux/pmbus.h>18#include <linux/pmbus.h>
18#include <linux/gpio/driver.h>19#include <linux/gpio/driver.h>
20#include <linux/timekeeping.h>
19#include "pmbus.h"21#include "pmbus.h"
20 22
21enum chips { ucd9000, ucd90120, ucd90124, ucd90160, ucd90320, ucd9090,23enum chips { ucd9000, ucd90120, ucd90124, ucd90160, ucd90320, ucd9090,
@@ -65,6 +67,7 @@ struct ucd9000_data { · 43 unmodified lines
65 struct gpio_chip gpio;67 struct gpio_chip gpio;
66#endif68#endif
67 struct dentry *debugfs;69 struct dentry *debugfs;
70 ktime_t write_time;
68};71};
69#define to_ucd9000_data(_info) container_of(_info, struct ucd9000_data, info)72#define to_ucd9000_data(_info) container_of(_info, struct ucd9000_data, info)
70 73
@@ -73,6 +76,73 @@ struct ucd9000_debugfs_entry { · 2 unmodified lines
73 u8 index;76 u8 index;
74};77};
75 78
79/*
80 * It has been observed that the UCD90320 randomly fails register access when
81 * doing another access right on the back of a register write. To mitigate this
82 * make sure that there is a minimum delay between a write access and the
83 * following access. The 250us is based on experimental data. At a delay of
84 * 200us the issue seems to go away. Add a bit of extra margin to allow for
85 * system to system differences.
86 */
87#define UCD90320_WAIT_DELAY_US 250
88
89static inline void ucd90320_wait(const struct ucd9000_data *data)
90{
91 s64 delta = ktime_us_delta(ktime_get(), data->write_time);
92
93 if (delta < UCD90320_WAIT_DELAY_US)
94 udelay(UCD90320_WAIT_DELAY_US - delta);
95}
96
97static int ucd90320_read_word_data(struct i2c_client *client, int page,
98 int phase, int reg)
99{
100 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
101 struct ucd9000_data *data = to_ucd9000_data(info);
102
103 if (reg >= PMBUS_VIRT_BASE)
104 return -ENXIO;
105
106 ucd90320_wait(data);
107 return pmbus_read_word_data(client, page, phase, reg);
108}
109
110static int ucd90320_read_byte_data(struct i2c_client *client, int page, int reg)
111{
112 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
113 struct ucd9000_data *data = to_ucd9000_data(info);
114
115 ucd90320_wait(data);
116 return pmbus_read_byte_data(client, page, reg);
117}
118
119static int ucd90320_write_word_data(struct i2c_client *client, int page,
120 int reg, u16 word)
121{
122 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
123 struct ucd9000_data *data = to_ucd9000_data(info);
124 int ret;
125
126 ucd90320_wait(data);
127 ret = pmbus_write_word_data(client, page, reg, word);
128 data->write_time = ktime_get();
129
130 return ret;
131}
132
133static int ucd90320_write_byte(struct i2c_client *client, int page, u8 value)
134{
135 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
136 struct ucd9000_data *data = to_ucd9000_data(info);
137 int ret;
138
139 ucd90320_wait(data);
140 ret = pmbus_write_byte(client, page, value);
141 data->write_time = ktime_get();
142
143 return ret;
144}
145
76static int ucd9000_get_fan_config(struct i2c_client *client, int fan)146static int ucd9000_get_fan_config(struct i2c_client *client, int fan)
77{147{
78 int fan_config = 0;148 int fan_config = 0;
@@ -598,6 +668,11 @@ static int ucd9000_probe(struct i2c_client *client) · 519 unmodified lines
598 info->read_byte_data = ucd9000_read_byte_data;668 info->read_byte_data = ucd9000_read_byte_data;
599 info->func[0] |= PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12669 info->func[0] |= PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12
600 | PMBUS_HAVE_FAN34 | PMBUS_HAVE_STATUS_FAN34;670 | PMBUS_HAVE_FAN34 | PMBUS_HAVE_STATUS_FAN34;
671 } else if (mid->driver_data == ucd90320) {
672 info->read_byte_data = ucd90320_read_byte_data;
673 info->read_word_data = ucd90320_read_word_data;
674 info->write_byte = ucd90320_write_byte;
675 info->write_word_data = ucd90320_write_word_data;
601 }676 }
602 677
603 ucd9000_probe_gpio(client, mid, data);678 ucd9000_probe_gpio(client, mid, data);
drivers/hwmon/tmp513.c+1−1
@@ -758,7 +758,7 @@ static int tmp51x_probe(struct i2c_client *client) · 757 unmodified lines
758static struct i2c_driver tmp51x_driver = {758static struct i2c_driver tmp51x_driver = {
759 .driver = {759 .driver = {
760 .name = "tmp51x",760 .name = "tmp51x",
761 .of_match_table = of_match_ptr(tmp51x_of_match),761 .of_match_table = tmp51x_of_match,
762 },762 },
763 .probe_new = tmp51x_probe,763 .probe_new = tmp51x_probe,
764 .id_table = tmp51x_id,764 .id_table = tmp51x_id,
drivers/hwmon/xgene-hwmon.c+1−0
@@ -761,6 +761,7 @@ static int xgene_hwmon_remove(struct platform_device *pdev) · 760 unmodified lines
761{761{
762 struct xgene_hwmon_dev *ctx = platform_get_drvdata(pdev);762 struct xgene_hwmon_dev *ctx = platform_get_drvdata(pdev);
763 763
764 cancel_work_sync(&ctx->workq);
764 hwmon_device_unregister(ctx->hwmon_dev);765 hwmon_device_unregister(ctx->hwmon_dev);
765 kfifo_free(&ctx->async_msg_fifo);766 kfifo_free(&ctx->async_msg_fifo);
766 if (acpi_disabled)767 if (acpi_disabled)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t