Skip to content

Commit b58bd4c

Browse files
Andrej Picejgroeck
authored andcommitted
hwmon: (lm70) Add support for ACPI
This commit adds support for lm70 commpatible drivers with systems that use ACPI. Signed-off-by: Andrej Picej <[email protected]> [groeck: Fix various issues seen if CONFIG_ACPI=n] Signed-off-by: Guenter Roeck <[email protected]>
1 parent b8a13e5 commit b58bd4c

File tree

1 file changed

+40
-7
lines changed

1 file changed

+40
-7
lines changed

drivers/hwmon/lm70.c

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <linux/spi/spi.h>
2626
#include <linux/slab.h>
2727
#include <linux/of_device.h>
28-
28+
#include <linux/acpi.h>
2929

3030
#define DRVNAME "lm70"
3131

@@ -148,18 +148,50 @@ static const struct of_device_id lm70_of_ids[] = {
148148
MODULE_DEVICE_TABLE(of, lm70_of_ids);
149149
#endif
150150

151+
#ifdef CONFIG_ACPI
152+
static const struct acpi_device_id lm70_acpi_ids[] = {
153+
{
154+
.id = "LM000070",
155+
.driver_data = LM70_CHIP_LM70,
156+
},
157+
{
158+
.id = "TMP00121",
159+
.driver_data = LM70_CHIP_TMP121,
160+
},
161+
{
162+
.id = "LM000071",
163+
.driver_data = LM70_CHIP_LM71,
164+
},
165+
{
166+
.id = "LM000074",
167+
.driver_data = LM70_CHIP_LM74,
168+
},
169+
{},
170+
};
171+
MODULE_DEVICE_TABLE(acpi, lm70_acpi_ids);
172+
#endif
173+
151174
static int lm70_probe(struct spi_device *spi)
152175
{
153-
const struct of_device_id *match;
176+
const struct of_device_id *of_match;
154177
struct device *hwmon_dev;
155178
struct lm70 *p_lm70;
156179
int chip;
157180

158-
match = of_match_device(lm70_of_ids, &spi->dev);
159-
if (match)
160-
chip = (int)(uintptr_t)match->data;
161-
else
162-
chip = spi_get_device_id(spi)->driver_data;
181+
of_match = of_match_device(lm70_of_ids, &spi->dev);
182+
if (of_match)
183+
chip = (int)(uintptr_t)of_match->data;
184+
else {
185+
#ifdef CONFIG_ACPI
186+
const struct acpi_device_id *acpi_match;
187+
188+
acpi_match = acpi_match_device(lm70_acpi_ids, &spi->dev);
189+
if (acpi_match)
190+
chip = (int)(uintptr_t)acpi_match->driver_data;
191+
else
192+
#endif
193+
chip = spi_get_device_id(spi)->driver_data;
194+
}
163195

164196
/* signaling is SPI_MODE_0 */
165197
if (spi->mode & (SPI_CPOL | SPI_CPHA))
@@ -195,6 +227,7 @@ static struct spi_driver lm70_driver = {
195227
.driver = {
196228
.name = "lm70",
197229
.of_match_table = of_match_ptr(lm70_of_ids),
230+
.acpi_match_table = ACPI_PTR(lm70_acpi_ids),
198231
},
199232
.id_table = lm70_ids,
200233
.probe = lm70_probe,

0 commit comments

Comments
 (0)