| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Industrial I/O driver for Microchip digital potentiometers |
|---|
| 3 | 4 | * Copyright (c) 2015 Axentia Technologies AB |
|---|
| .. | .. |
|---|
| 22 | 23 | * mcp4652 2 257 5, 10, 50, 100 01011xx |
|---|
| 23 | 24 | * mcp4661 2 257 5, 10, 50, 100 0101xxx |
|---|
| 24 | 25 | * mcp4662 2 257 5, 10, 50, 100 01011xx |
|---|
| 25 | | - * |
|---|
| 26 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 27 | | - * under the terms of the GNU General Public License version 2 as published by |
|---|
| 28 | | - * the Free Software Foundation. |
|---|
| 29 | 26 | */ |
|---|
| 30 | 27 | |
|---|
| 31 | 28 | #include <linux/module.h> |
|---|
| 32 | 29 | #include <linux/i2c.h> |
|---|
| 33 | 30 | #include <linux/err.h> |
|---|
| 34 | | -#include <linux/of.h> |
|---|
| 35 | | -#include <linux/of_device.h> |
|---|
| 31 | +#include <linux/mod_devicetable.h> |
|---|
| 32 | +#include <linux/property.h> |
|---|
| 36 | 33 | |
|---|
| 37 | 34 | #include <linux/iio/iio.h> |
|---|
| 38 | 35 | |
|---|
| .. | .. |
|---|
| 278 | 275 | }; |
|---|
| 279 | 276 | MODULE_DEVICE_TABLE(i2c, mcp4531_id); |
|---|
| 280 | 277 | |
|---|
| 281 | | -#ifdef CONFIG_OF |
|---|
| 282 | | - |
|---|
| 283 | 278 | #define MCP4531_COMPATIBLE(of_compatible, cfg) { \ |
|---|
| 284 | 279 | .compatible = of_compatible, \ |
|---|
| 285 | 280 | .data = &mcp4531_cfg[cfg], \ |
|---|
| .. | .. |
|---|
| 353 | 348 | { /* sentinel */ } |
|---|
| 354 | 349 | }; |
|---|
| 355 | 350 | MODULE_DEVICE_TABLE(of, mcp4531_of_match); |
|---|
| 356 | | -#endif |
|---|
| 357 | 351 | |
|---|
| 358 | 352 | static int mcp4531_probe(struct i2c_client *client) |
|---|
| 359 | 353 | { |
|---|
| 360 | 354 | struct device *dev = &client->dev; |
|---|
| 361 | 355 | struct mcp4531_data *data; |
|---|
| 362 | 356 | struct iio_dev *indio_dev; |
|---|
| 363 | | - const struct of_device_id *match; |
|---|
| 364 | 357 | |
|---|
| 365 | 358 | if (!i2c_check_functionality(client->adapter, |
|---|
| 366 | 359 | I2C_FUNC_SMBUS_WORD_DATA)) { |
|---|
| .. | .. |
|---|
| 375 | 368 | i2c_set_clientdata(client, indio_dev); |
|---|
| 376 | 369 | data->client = client; |
|---|
| 377 | 370 | |
|---|
| 378 | | - match = of_match_device(of_match_ptr(mcp4531_of_match), dev); |
|---|
| 379 | | - if (match) |
|---|
| 380 | | - data->cfg = of_device_get_match_data(dev); |
|---|
| 381 | | - else |
|---|
| 371 | + data->cfg = device_get_match_data(dev); |
|---|
| 372 | + if (!data->cfg) |
|---|
| 382 | 373 | data->cfg = &mcp4531_cfg[i2c_match_id(mcp4531_id, client)->driver_data]; |
|---|
| 383 | 374 | |
|---|
| 384 | | - indio_dev->dev.parent = dev; |
|---|
| 385 | 375 | indio_dev->info = &mcp4531_info; |
|---|
| 386 | 376 | indio_dev->channels = mcp4531_channels; |
|---|
| 387 | 377 | indio_dev->num_channels = data->cfg->wipers; |
|---|
| .. | .. |
|---|
| 393 | 383 | static struct i2c_driver mcp4531_driver = { |
|---|
| 394 | 384 | .driver = { |
|---|
| 395 | 385 | .name = "mcp4531", |
|---|
| 396 | | - .of_match_table = of_match_ptr(mcp4531_of_match), |
|---|
| 386 | + .of_match_table = mcp4531_of_match, |
|---|
| 397 | 387 | }, |
|---|
| 398 | 388 | .probe_new = mcp4531_probe, |
|---|
| 399 | 389 | .id_table = mcp4531_id, |
|---|
| .. | .. |
|---|
| 403 | 393 | |
|---|
| 404 | 394 | MODULE_AUTHOR("Peter Rosin <peda@axentia.se>"); |
|---|
| 405 | 395 | MODULE_DESCRIPTION("MCP4531 digital potentiometer"); |
|---|
| 406 | | -MODULE_LICENSE("GPL"); |
|---|
| 396 | +MODULE_LICENSE("GPL v2"); |
|---|