diff options
author | Jean Delvare <khali@linux-fr.org> | 2010-08-14 15:08:48 -0400 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2010-08-14 15:08:48 -0400 |
commit | b9783dcebe952bf73449fe70a19ee4814adc81a0 (patch) | |
tree | 0941a77358b59095e6d136cbd46221c1767ff748 | |
parent | df149d02ea8ee49cd14c6609cc7ef980d62dce80 (diff) |
hwmon: (pc87360) Fix device resource declaration
It's not OK to call platform_device_add_resources() multiple times
in a row. Despite its name, this functions sets the resources, it
doesn't add them. So we have to prepare an array with all the
resources, and then call platform_device_add_resources() once.
Before this fix, only the last I/O resource would be actually
registered. The other I/O resources were leaked.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Jim Cromie <jim.cromie@gmail.com>
Cc: stable@kernel.org
-rw-r--r-- | drivers/hwmon/pc87360.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index 4a64b85d4ec9..68e69a49633c 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c | |||
@@ -1610,11 +1610,8 @@ static struct pc87360_data *pc87360_update_device(struct device *dev) | |||
1610 | 1610 | ||
1611 | static int __init pc87360_device_add(unsigned short address) | 1611 | static int __init pc87360_device_add(unsigned short address) |
1612 | { | 1612 | { |
1613 | struct resource res = { | 1613 | struct resource res[3]; |
1614 | .name = "pc87360", | 1614 | int err, i, res_count; |
1615 | .flags = IORESOURCE_IO, | ||
1616 | }; | ||
1617 | int err, i; | ||
1618 | 1615 | ||
1619 | pdev = platform_device_alloc("pc87360", address); | 1616 | pdev = platform_device_alloc("pc87360", address); |
1620 | if (!pdev) { | 1617 | if (!pdev) { |
@@ -1623,22 +1620,28 @@ static int __init pc87360_device_add(unsigned short address) | |||
1623 | goto exit; | 1620 | goto exit; |
1624 | } | 1621 | } |
1625 | 1622 | ||
1623 | memset(res, 0, 3 * sizeof(struct resource)); | ||
1624 | res_count = 0; | ||
1626 | for (i = 0; i < 3; i++) { | 1625 | for (i = 0; i < 3; i++) { |
1627 | if (!extra_isa[i]) | 1626 | if (!extra_isa[i]) |
1628 | continue; | 1627 | continue; |
1629 | res.start = extra_isa[i]; | 1628 | res[res_count].start = extra_isa[i]; |
1630 | res.end = extra_isa[i] + PC87360_EXTENT - 1; | 1629 | res[res_count].end = extra_isa[i] + PC87360_EXTENT - 1; |
1630 | res[res_count].name = "pc87360", | ||
1631 | res[res_count].flags = IORESOURCE_IO, | ||
1631 | 1632 | ||
1632 | err = acpi_check_resource_conflict(&res); | 1633 | err = acpi_check_resource_conflict(&res[res_count]); |
1633 | if (err) | 1634 | if (err) |
1634 | goto exit_device_put; | 1635 | goto exit_device_put; |
1635 | 1636 | ||
1636 | err = platform_device_add_resources(pdev, &res, 1); | 1637 | res_count++; |
1637 | if (err) { | 1638 | } |
1638 | printk(KERN_ERR "pc87360: Device resource[%d] " | 1639 | |
1639 | "addition failed (%d)\n", i, err); | 1640 | err = platform_device_add_resources(pdev, res, res_count); |
1640 | goto exit_device_put; | 1641 | if (err) { |
1641 | } | 1642 | printk(KERN_ERR "pc87360: Device resources addition failed " |
1643 | "(%d)\n", err); | ||
1644 | goto exit_device_put; | ||
1642 | } | 1645 | } |
1643 | 1646 | ||
1644 | err = platform_device_add(pdev); | 1647 | err = platform_device_add(pdev); |