.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * zopt2201.c - Support for IDT ZOPT2201 ambient light and UV B sensor |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright 2017 Peter Meerwald-Stadler <pmeerw@pmeerw.net> |
---|
5 | | - * |
---|
6 | | - * This file is subject to the terms and conditions of version 2 of |
---|
7 | | - * the GNU General Public License. See the file COPYING in the main |
---|
8 | | - * directory of this archive for more details. |
---|
9 | 6 | * |
---|
10 | 7 | * Datasheet: https://www.idt.com/document/dst/zopt2201-datasheet |
---|
11 | 8 | * 7-bit I2C slave addresses 0x53 (default) or 0x52 (programmed) |
---|
.. | .. |
---|
21 | 18 | |
---|
22 | 19 | #include <linux/iio/iio.h> |
---|
23 | 20 | #include <linux/iio/sysfs.h> |
---|
| 21 | + |
---|
| 22 | +#include <asm/unaligned.h> |
---|
24 | 23 | |
---|
25 | 24 | #define ZOPT2201_DRV_NAME "zopt2201" |
---|
26 | 25 | |
---|
.. | .. |
---|
222 | 221 | goto fail; |
---|
223 | 222 | mutex_unlock(&data->lock); |
---|
224 | 223 | |
---|
225 | | - return (buf[2] << 16) | (buf[1] << 8) | buf[0]; |
---|
| 224 | + return get_unaligned_le24(&buf[0]); |
---|
226 | 225 | |
---|
227 | 226 | fail: |
---|
228 | 227 | mutex_unlock(&data->lock); |
---|
.. | .. |
---|
528 | 527 | data->client = client; |
---|
529 | 528 | mutex_init(&data->lock); |
---|
530 | 529 | |
---|
531 | | - indio_dev->dev.parent = &client->dev; |
---|
532 | 530 | indio_dev->info = &zopt2201_info; |
---|
533 | 531 | indio_dev->channels = zopt2201_channels; |
---|
534 | 532 | indio_dev->num_channels = ARRAY_SIZE(zopt2201_channels); |
---|