acpi-als.c (94e17d606ec9a4c3af7421b79e4fb235d07861b4) | acpi-als.c (17395ce299211a8148ee45d1d71eb740a3fec48d) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * ACPI Ambient Light Sensor Driver 4 * 5 * Based on ALS driver: 6 * Copyright (C) 2009 Zhang Rui <rui.zhang@intel.com> 7 * 8 * Rework for IIO subsystem: --- 12 unchanged lines hidden (view full) --- 21#include <linux/iio/iio.h> 22#include <linux/iio/buffer.h> 23#include <linux/iio/kfifo_buf.h> 24 25#define ACPI_ALS_CLASS "als" 26#define ACPI_ALS_DEVICE_NAME "acpi-als" 27#define ACPI_ALS_NOTIFY_ILLUMINANCE 0x80 28 | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * ACPI Ambient Light Sensor Driver 4 * 5 * Based on ALS driver: 6 * Copyright (C) 2009 Zhang Rui <rui.zhang@intel.com> 7 * 8 * Rework for IIO subsystem: --- 12 unchanged lines hidden (view full) --- 21#include <linux/iio/iio.h> 22#include <linux/iio/buffer.h> 23#include <linux/iio/kfifo_buf.h> 24 25#define ACPI_ALS_CLASS "als" 26#define ACPI_ALS_DEVICE_NAME "acpi-als" 27#define ACPI_ALS_NOTIFY_ILLUMINANCE 0x80 28 |
29ACPI_MODULE_NAME("acpi-als"); 30 |
|
29/* 30 * So far, there's only one channel in here, but the specification for 31 * ACPI0008 says there can be more to what the block can report. Like 32 * chromaticity and such. We are ready for incoming additions! 33 */ 34static const struct iio_chan_spec acpi_als_channels[] = { 35 { 36 .type = IIO_LIGHT, --- 47 unchanged lines hidden (view full) --- 84{ 85 unsigned long long temp_val; 86 acpi_status status; 87 88 status = acpi_evaluate_integer(als->device->handle, prop, NULL, 89 &temp_val); 90 91 if (ACPI_FAILURE(status)) { | 31/* 32 * So far, there's only one channel in here, but the specification for 33 * ACPI0008 says there can be more to what the block can report. Like 34 * chromaticity and such. We are ready for incoming additions! 35 */ 36static const struct iio_chan_spec acpi_als_channels[] = { 37 { 38 .type = IIO_LIGHT, --- 47 unchanged lines hidden (view full) --- 86{ 87 unsigned long long temp_val; 88 acpi_status status; 89 90 status = acpi_evaluate_integer(als->device->handle, prop, NULL, 91 &temp_val); 92 93 if (ACPI_FAILURE(status)) { |
92 acpi_evaluation_failure_warn(als->device->handle, prop, status); | 94 ACPI_EXCEPTION((AE_INFO, status, "Error reading ALS %s", prop)); |
93 return -EIO; 94 } 95 96 *val = temp_val; 97 98 return 0; 99} 100 --- 57 unchanged lines hidden (view full) --- 158static const struct iio_info acpi_als_info = { 159 .read_raw = acpi_als_read_raw, 160}; 161 162static int acpi_als_add(struct acpi_device *device) 163{ 164 struct acpi_als *als; 165 struct iio_dev *indio_dev; | 95 return -EIO; 96 } 97 98 *val = temp_val; 99 100 return 0; 101} 102 --- 57 unchanged lines hidden (view full) --- 160static const struct iio_info acpi_als_info = { 161 .read_raw = acpi_als_read_raw, 162}; 163 164static int acpi_als_add(struct acpi_device *device) 165{ 166 struct acpi_als *als; 167 struct iio_dev *indio_dev; |
166 struct iio_buffer *buffer; | 168 int ret; |
167 168 indio_dev = devm_iio_device_alloc(&device->dev, sizeof(*als)); 169 if (!indio_dev) 170 return -ENOMEM; 171 172 als = iio_priv(indio_dev); 173 174 device->driver_data = indio_dev; 175 als->device = device; 176 mutex_init(&als->lock); 177 178 indio_dev->name = ACPI_ALS_DEVICE_NAME; 179 indio_dev->info = &acpi_als_info; | 169 170 indio_dev = devm_iio_device_alloc(&device->dev, sizeof(*als)); 171 if (!indio_dev) 172 return -ENOMEM; 173 174 als = iio_priv(indio_dev); 175 176 device->driver_data = indio_dev; 177 als->device = device; 178 mutex_init(&als->lock); 179 180 indio_dev->name = ACPI_ALS_DEVICE_NAME; 181 indio_dev->info = &acpi_als_info; |
180 indio_dev->modes = INDIO_BUFFER_SOFTWARE; | |
181 indio_dev->channels = acpi_als_channels; 182 indio_dev->num_channels = ARRAY_SIZE(acpi_als_channels); 183 | 182 indio_dev->channels = acpi_als_channels; 183 indio_dev->num_channels = ARRAY_SIZE(acpi_als_channels); 184 |
184 buffer = devm_iio_kfifo_allocate(&device->dev); 185 if (!buffer) 186 return -ENOMEM; | 185 ret = devm_iio_kfifo_buffer_setup(&device->dev, indio_dev, 186 INDIO_BUFFER_SOFTWARE, NULL); 187 if (ret) 188 return ret; |
187 | 189 |
188 iio_device_attach_buffer(indio_dev, buffer); 189 | |
190 return devm_iio_device_register(&device->dev, indio_dev); 191} 192 193static const struct acpi_device_id acpi_als_device_ids[] = { 194 {"ACPI0008", 0}, 195 {}, 196}; 197 --- 19 unchanged lines hidden --- | 190 return devm_iio_device_register(&device->dev, indio_dev); 191} 192 193static const struct acpi_device_id acpi_als_device_ids[] = { 194 {"ACPI0008", 0}, 195 {}, 196}; 197 --- 19 unchanged lines hidden --- |