| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * ROHM BH1710/BH1715/BH1721/BH1750/BH1751 ambient light sensor driver |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) Tomasz Duszynski <tduszyns@gmail.com> |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 8 | | - * published by the Free Software Foundation. |
|---|
| 9 | 6 | * |
|---|
| 10 | 7 | * Data sheets: |
|---|
| 11 | 8 | * http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1710fvc-e.pdf |
|---|
| .. | .. |
|---|
| 257 | 254 | return ret; |
|---|
| 258 | 255 | |
|---|
| 259 | 256 | mutex_init(&data->lock); |
|---|
| 260 | | - indio_dev->dev.parent = &client->dev; |
|---|
| 261 | 257 | indio_dev->info = &bh1750_info; |
|---|
| 262 | 258 | indio_dev->name = id->name; |
|---|
| 263 | 259 | indio_dev->channels = bh1750_channels; |
|---|
| .. | .. |
|---|
| 281 | 277 | return 0; |
|---|
| 282 | 278 | } |
|---|
| 283 | 279 | |
|---|
| 284 | | -#ifdef CONFIG_PM_SLEEP |
|---|
| 285 | | -static int bh1750_suspend(struct device *dev) |
|---|
| 280 | +static int __maybe_unused bh1750_suspend(struct device *dev) |
|---|
| 286 | 281 | { |
|---|
| 287 | 282 | int ret; |
|---|
| 288 | 283 | struct bh1750_data *data = |
|---|
| .. | .. |
|---|
| 300 | 295 | } |
|---|
| 301 | 296 | |
|---|
| 302 | 297 | static SIMPLE_DEV_PM_OPS(bh1750_pm_ops, bh1750_suspend, NULL); |
|---|
| 303 | | -#define BH1750_PM_OPS (&bh1750_pm_ops) |
|---|
| 304 | | -#else |
|---|
| 305 | | -#define BH1750_PM_OPS NULL |
|---|
| 306 | | -#endif |
|---|
| 307 | 298 | |
|---|
| 308 | 299 | static const struct i2c_device_id bh1750_id[] = { |
|---|
| 309 | 300 | { "bh1710", BH1710 }, |
|---|
| .. | .. |
|---|
| 315 | 306 | }; |
|---|
| 316 | 307 | MODULE_DEVICE_TABLE(i2c, bh1750_id); |
|---|
| 317 | 308 | |
|---|
| 309 | +static const struct of_device_id bh1750_of_match[] = { |
|---|
| 310 | + { .compatible = "rohm,bh1710", }, |
|---|
| 311 | + { .compatible = "rohm,bh1715", }, |
|---|
| 312 | + { .compatible = "rohm,bh1721", }, |
|---|
| 313 | + { .compatible = "rohm,bh1750", }, |
|---|
| 314 | + { .compatible = "rohm,bh1751", }, |
|---|
| 315 | + { } |
|---|
| 316 | +}; |
|---|
| 317 | +MODULE_DEVICE_TABLE(of, bh1750_of_match); |
|---|
| 318 | + |
|---|
| 318 | 319 | static struct i2c_driver bh1750_driver = { |
|---|
| 319 | 320 | .driver = { |
|---|
| 320 | 321 | .name = "bh1750", |
|---|
| 321 | | - .pm = BH1750_PM_OPS, |
|---|
| 322 | + .of_match_table = bh1750_of_match, |
|---|
| 323 | + .pm = &bh1750_pm_ops, |
|---|
| 322 | 324 | }, |
|---|
| 323 | 325 | .probe = bh1750_probe, |
|---|
| 324 | 326 | .remove = bh1750_remove, |
|---|