aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-07-18 12:02:58 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-18 12:02:58 -0400
commita406721dff91a9a5297d140dbb90327966cf9bc0 (patch)
tree43e9910434f91f4c94eed84d937661d4f303eba0
parentf560f6697f17e2465c8845c09f3a483faef38275 (diff)
parentd3f684f2820a7f42acef68bea6622d9032127fb2 (diff)
Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging
* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging: hwmon: (max1111) Fix race condition causing NULL pointer exception hwmon: (it87) Fix label group removal hwmon: (asus_atk0110) Fix memory leak
-rw-r--r--drivers/hwmon/asus_atk0110.c1
-rw-r--r--drivers/hwmon/it87.c2
-rw-r--r--drivers/hwmon/max1111.c11
3 files changed, 13 insertions, 1 deletions
diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
index dcb78a7a8047..00e98517f94c 100644
--- a/drivers/hwmon/asus_atk0110.c
+++ b/drivers/hwmon/asus_atk0110.c
@@ -674,6 +674,7 @@ static int atk_debugfs_gitm_get(void *p, u64 *val)
674 else 674 else
675 err = -EIO; 675 err = -EIO;
676 676
677 ACPI_FREE(ret);
677 return err; 678 return err;
678} 679}
679 680
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index bb6405b92007..5f5247750430 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -1538,7 +1538,7 @@ static struct attribute *it87_attributes_label[] = {
1538}; 1538};
1539 1539
1540static const struct attribute_group it87_group_label = { 1540static const struct attribute_group it87_group_label = {
1541 .attrs = it87_attributes_vid, 1541 .attrs = it87_attributes_label,
1542}; 1542};
1543 1543
1544/* SuperIO detection - will change isa_address if a chip is found */ 1544/* SuperIO detection - will change isa_address if a chip is found */
diff --git a/drivers/hwmon/max1111.c b/drivers/hwmon/max1111.c
index 12a54aa29776..14335bbc9bdc 100644
--- a/drivers/hwmon/max1111.c
+++ b/drivers/hwmon/max1111.c
@@ -40,6 +40,8 @@ struct max1111_data {
40 struct spi_transfer xfer[2]; 40 struct spi_transfer xfer[2];
41 uint8_t *tx_buf; 41 uint8_t *tx_buf;
42 uint8_t *rx_buf; 42 uint8_t *rx_buf;
43 struct mutex drvdata_lock;
44 /* protect msg, xfer and buffers from multiple access */
43}; 45};
44 46
45static int max1111_read(struct device *dev, int channel) 47static int max1111_read(struct device *dev, int channel)
@@ -48,6 +50,9 @@ static int max1111_read(struct device *dev, int channel)
48 uint8_t v1, v2; 50 uint8_t v1, v2;
49 int err; 51 int err;
50 52
53 /* writing to drvdata struct is not thread safe, wait on mutex */
54 mutex_lock(&data->drvdata_lock);
55
51 data->tx_buf[0] = (channel << MAX1111_CTRL_SEL_SH) | 56 data->tx_buf[0] = (channel << MAX1111_CTRL_SEL_SH) |
52 MAX1111_CTRL_PD0 | MAX1111_CTRL_PD1 | 57 MAX1111_CTRL_PD0 | MAX1111_CTRL_PD1 |
53 MAX1111_CTRL_SGL | MAX1111_CTRL_UNI | MAX1111_CTRL_STR; 58 MAX1111_CTRL_SGL | MAX1111_CTRL_UNI | MAX1111_CTRL_STR;
@@ -55,12 +60,15 @@ static int max1111_read(struct device *dev, int channel)
55 err = spi_sync(data->spi, &data->msg); 60 err = spi_sync(data->spi, &data->msg);
56 if (err < 0) { 61 if (err < 0) {
57 dev_err(dev, "spi_sync failed with %d\n", err); 62 dev_err(dev, "spi_sync failed with %d\n", err);
63 mutex_unlock(&data->drvdata_lock);
58 return err; 64 return err;
59 } 65 }
60 66
61 v1 = data->rx_buf[0]; 67 v1 = data->rx_buf[0];
62 v2 = data->rx_buf[1]; 68 v2 = data->rx_buf[1];
63 69
70 mutex_unlock(&data->drvdata_lock);
71
64 if ((v1 & 0xc0) || (v2 & 0x3f)) 72 if ((v1 & 0xc0) || (v2 & 0x3f))
65 return -EINVAL; 73 return -EINVAL;
66 74
@@ -176,6 +184,8 @@ static int __devinit max1111_probe(struct spi_device *spi)
176 if (err) 184 if (err)
177 goto err_free_data; 185 goto err_free_data;
178 186
187 mutex_init(&data->drvdata_lock);
188
179 data->spi = spi; 189 data->spi = spi;
180 spi_set_drvdata(spi, data); 190 spi_set_drvdata(spi, data);
181 191
@@ -213,6 +223,7 @@ static int __devexit max1111_remove(struct spi_device *spi)
213 223
214 hwmon_device_unregister(data->hwmon_dev); 224 hwmon_device_unregister(data->hwmon_dev);
215 sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group); 225 sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group);
226 mutex_destroy(&data->drvdata_lock);
216 kfree(data->rx_buf); 227 kfree(data->rx_buf);
217 kfree(data->tx_buf); 228 kfree(data->tx_buf);
218 kfree(data); 229 kfree(data);