| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Maxim Integrated MAX5481-MAX5484 digital potentiometer driver |
|---|
| 3 | 4 | * Copyright 2016 Rockwell Collins |
|---|
| 4 | 5 | * |
|---|
| 5 | 6 | * Datasheet: |
|---|
| 6 | | - * http://datasheets.maximintegrated.com/en/ds/MAX5481-MAX5484.pdf |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 9 | | - * it under the terms of the gnu general public license version 2 as |
|---|
| 10 | | - * published by the free software foundation. |
|---|
| 11 | | - * |
|---|
| 7 | + * https://datasheets.maximintegrated.com/en/ds/MAX5481-MAX5484.pdf |
|---|
| 12 | 8 | */ |
|---|
| 13 | 9 | |
|---|
| 14 | | -#include <linux/acpi.h> |
|---|
| 15 | 10 | #include <linux/iio/iio.h> |
|---|
| 16 | 11 | #include <linux/iio/sysfs.h> |
|---|
| 17 | 12 | #include <linux/module.h> |
|---|
| 18 | | -#include <linux/of.h> |
|---|
| 19 | | -#include <linux/of_device.h> |
|---|
| 13 | +#include <linux/mod_devicetable.h> |
|---|
| 14 | +#include <linux/property.h> |
|---|
| 20 | 15 | #include <linux/spi/spi.h> |
|---|
| 21 | 16 | |
|---|
| 22 | 17 | /* write wiper reg */ |
|---|
| .. | .. |
|---|
| 121 | 116 | .write_raw = max5481_write_raw, |
|---|
| 122 | 117 | }; |
|---|
| 123 | 118 | |
|---|
| 124 | | -#if defined(CONFIG_OF) |
|---|
| 125 | 119 | static const struct of_device_id max5481_match[] = { |
|---|
| 126 | 120 | { .compatible = "maxim,max5481", .data = &max5481_cfg[max5481] }, |
|---|
| 127 | 121 | { .compatible = "maxim,max5482", .data = &max5481_cfg[max5482] }, |
|---|
| .. | .. |
|---|
| 130 | 124 | { } |
|---|
| 131 | 125 | }; |
|---|
| 132 | 126 | MODULE_DEVICE_TABLE(of, max5481_match); |
|---|
| 133 | | -#endif |
|---|
| 134 | 127 | |
|---|
| 135 | 128 | static int max5481_probe(struct spi_device *spi) |
|---|
| 136 | 129 | { |
|---|
| 137 | 130 | struct iio_dev *indio_dev; |
|---|
| 138 | 131 | struct max5481_data *data; |
|---|
| 139 | 132 | const struct spi_device_id *id = spi_get_device_id(spi); |
|---|
| 140 | | - const struct of_device_id *match; |
|---|
| 141 | 133 | int ret; |
|---|
| 142 | 134 | |
|---|
| 143 | 135 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*data)); |
|---|
| .. | .. |
|---|
| 149 | 141 | |
|---|
| 150 | 142 | data->spi = spi; |
|---|
| 151 | 143 | |
|---|
| 152 | | - match = of_match_device(of_match_ptr(max5481_match), &spi->dev); |
|---|
| 153 | | - if (match) |
|---|
| 154 | | - data->cfg = of_device_get_match_data(&spi->dev); |
|---|
| 155 | | - else |
|---|
| 144 | + data->cfg = device_get_match_data(&spi->dev); |
|---|
| 145 | + if (!data->cfg) |
|---|
| 156 | 146 | data->cfg = &max5481_cfg[id->driver_data]; |
|---|
| 157 | 147 | |
|---|
| 158 | 148 | indio_dev->name = id->name; |
|---|
| 159 | | - indio_dev->dev.parent = &spi->dev; |
|---|
| 160 | 149 | indio_dev->modes = INDIO_DIRECT_MODE; |
|---|
| 161 | 150 | |
|---|
| 162 | 151 | /* variant specific configuration */ |
|---|
| .. | .. |
|---|
| 192 | 181 | }; |
|---|
| 193 | 182 | MODULE_DEVICE_TABLE(spi, max5481_id_table); |
|---|
| 194 | 183 | |
|---|
| 195 | | -#if defined(CONFIG_ACPI) |
|---|
| 196 | | -static const struct acpi_device_id max5481_acpi_match[] = { |
|---|
| 197 | | - { "max5481", max5481 }, |
|---|
| 198 | | - { "max5482", max5482 }, |
|---|
| 199 | | - { "max5483", max5483 }, |
|---|
| 200 | | - { "max5484", max5484 }, |
|---|
| 201 | | - { } |
|---|
| 202 | | -}; |
|---|
| 203 | | -MODULE_DEVICE_TABLE(acpi, max5481_acpi_match); |
|---|
| 204 | | -#endif |
|---|
| 205 | | - |
|---|
| 206 | 184 | static struct spi_driver max5481_driver = { |
|---|
| 207 | 185 | .driver = { |
|---|
| 208 | 186 | .name = "max5481", |
|---|
| 209 | | - .of_match_table = of_match_ptr(max5481_match), |
|---|
| 210 | | - .acpi_match_table = ACPI_PTR(max5481_acpi_match), |
|---|
| 187 | + .of_match_table = max5481_match, |
|---|
| 211 | 188 | }, |
|---|
| 212 | 189 | .probe = max5481_probe, |
|---|
| 213 | 190 | .remove = max5481_remove, |
|---|