| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0+ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Driver for the ADC on Freescale Semiconductor MC13783 and MC13892 PMICs. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. |
|---|
| 5 | 6 | * Copyright (C) 2009 Sascha Hauer, Pengutronix |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or |
|---|
| 8 | | - * modify it under the terms of the GNU General Public License |
|---|
| 9 | | - * as published by the Free Software Foundation; either version 2 |
|---|
| 10 | | - * of the License, or (at your option) any later version. |
|---|
| 11 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - * GNU General Public License for more details. |
|---|
| 15 | | - * |
|---|
| 16 | | - * You should have received a copy of the GNU General Public License along with |
|---|
| 17 | | - * this program; if not, write to the Free Software Foundation, Inc., 51 |
|---|
| 18 | | - * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 19 | 7 | */ |
|---|
| 20 | 8 | |
|---|
| 21 | 9 | #include <linux/mfd/mc13xxx.h> |
|---|
| .. | .. |
|---|
| 75 | 63 | return 0; |
|---|
| 76 | 64 | } |
|---|
| 77 | 65 | |
|---|
| 78 | | -static ssize_t mc13783_adc_read_bp(struct device *dev, |
|---|
| 79 | | - struct device_attribute *devattr, char *buf) |
|---|
| 66 | +static ssize_t mc13783_adc_bp_show(struct device *dev, |
|---|
| 67 | + struct device_attribute *devattr, |
|---|
| 68 | + char *buf) |
|---|
| 80 | 69 | { |
|---|
| 81 | 70 | unsigned val; |
|---|
| 82 | 71 | struct platform_device *pdev = to_platform_device(dev); |
|---|
| .. | .. |
|---|
| 98 | 87 | return sprintf(buf, "%u\n", val); |
|---|
| 99 | 88 | } |
|---|
| 100 | 89 | |
|---|
| 101 | | -static ssize_t mc13783_adc_read_gp(struct device *dev, |
|---|
| 102 | | - struct device_attribute *devattr, char *buf) |
|---|
| 90 | +static ssize_t mc13783_adc_gp_show(struct device *dev, |
|---|
| 91 | + struct device_attribute *devattr, |
|---|
| 92 | + char *buf) |
|---|
| 103 | 93 | { |
|---|
| 104 | 94 | unsigned val; |
|---|
| 105 | 95 | int ret = mc13783_adc_read(dev, devattr, &val); |
|---|
| .. | .. |
|---|
| 116 | 106 | return sprintf(buf, "%u\n", val); |
|---|
| 117 | 107 | } |
|---|
| 118 | 108 | |
|---|
| 119 | | -static ssize_t mc13783_adc_read_uid(struct device *dev, |
|---|
| 120 | | - struct device_attribute *devattr, char *buf) |
|---|
| 109 | +static ssize_t mc13783_adc_uid_show(struct device *dev, |
|---|
| 110 | + struct device_attribute *devattr, |
|---|
| 111 | + char *buf) |
|---|
| 121 | 112 | { |
|---|
| 122 | 113 | unsigned int val; |
|---|
| 123 | 114 | struct platform_device *pdev = to_platform_device(dev); |
|---|
| .. | .. |
|---|
| 137 | 128 | return sprintf(buf, "%u\n", val); |
|---|
| 138 | 129 | } |
|---|
| 139 | 130 | |
|---|
| 140 | | -static ssize_t mc13783_adc_read_temp(struct device *dev, |
|---|
| 141 | | - struct device_attribute *devattr, char *buf) |
|---|
| 131 | +static ssize_t mc13783_adc_temp_show(struct device *dev, |
|---|
| 132 | + struct device_attribute *devattr, |
|---|
| 133 | + char *buf) |
|---|
| 142 | 134 | { |
|---|
| 143 | 135 | unsigned int val; |
|---|
| 144 | 136 | struct platform_device *pdev = to_platform_device(dev); |
|---|
| .. | .. |
|---|
| 168 | 160 | } |
|---|
| 169 | 161 | |
|---|
| 170 | 162 | static DEVICE_ATTR_RO(name); |
|---|
| 171 | | -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, mc13783_adc_read_bp, NULL, 2); |
|---|
| 172 | | -static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, mc13783_adc_read_gp, NULL, 5); |
|---|
| 173 | | -static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, mc13783_adc_read_gp, NULL, 6); |
|---|
| 174 | | -static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, mc13783_adc_read_gp, NULL, 7); |
|---|
| 175 | | -static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, mc13783_adc_read_gp, NULL, 8); |
|---|
| 176 | | -static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, mc13783_adc_read_gp, NULL, 9); |
|---|
| 177 | | -static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, mc13783_adc_read_gp, NULL, 10); |
|---|
| 178 | | -static SENSOR_DEVICE_ATTR(in11_input, S_IRUGO, mc13783_adc_read_gp, NULL, 11); |
|---|
| 179 | | -static SENSOR_DEVICE_ATTR(in12_input, S_IRUGO, mc13783_adc_read_gp, NULL, 12); |
|---|
| 180 | | -static SENSOR_DEVICE_ATTR(in13_input, S_IRUGO, mc13783_adc_read_gp, NULL, 13); |
|---|
| 181 | | -static SENSOR_DEVICE_ATTR(in14_input, S_IRUGO, mc13783_adc_read_gp, NULL, 14); |
|---|
| 182 | | -static SENSOR_DEVICE_ATTR(in15_input, S_IRUGO, mc13783_adc_read_gp, NULL, 15); |
|---|
| 183 | | -static SENSOR_DEVICE_ATTR(in16_input, S_IRUGO, mc13783_adc_read_uid, NULL, 16); |
|---|
| 184 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, |
|---|
| 185 | | - mc13783_adc_read_temp, NULL, 17); |
|---|
| 163 | +static SENSOR_DEVICE_ATTR_RO(in2_input, mc13783_adc_bp, 2); |
|---|
| 164 | +static SENSOR_DEVICE_ATTR_RO(in5_input, mc13783_adc_gp, 5); |
|---|
| 165 | +static SENSOR_DEVICE_ATTR_RO(in6_input, mc13783_adc_gp, 6); |
|---|
| 166 | +static SENSOR_DEVICE_ATTR_RO(in7_input, mc13783_adc_gp, 7); |
|---|
| 167 | +static SENSOR_DEVICE_ATTR_RO(in8_input, mc13783_adc_gp, 8); |
|---|
| 168 | +static SENSOR_DEVICE_ATTR_RO(in9_input, mc13783_adc_gp, 9); |
|---|
| 169 | +static SENSOR_DEVICE_ATTR_RO(in10_input, mc13783_adc_gp, 10); |
|---|
| 170 | +static SENSOR_DEVICE_ATTR_RO(in11_input, mc13783_adc_gp, 11); |
|---|
| 171 | +static SENSOR_DEVICE_ATTR_RO(in12_input, mc13783_adc_gp, 12); |
|---|
| 172 | +static SENSOR_DEVICE_ATTR_RO(in13_input, mc13783_adc_gp, 13); |
|---|
| 173 | +static SENSOR_DEVICE_ATTR_RO(in14_input, mc13783_adc_gp, 14); |
|---|
| 174 | +static SENSOR_DEVICE_ATTR_RO(in15_input, mc13783_adc_gp, 15); |
|---|
| 175 | +static SENSOR_DEVICE_ATTR_RO(in16_input, mc13783_adc_uid, 16); |
|---|
| 176 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, mc13783_adc_temp, 17); |
|---|
| 186 | 177 | |
|---|
| 187 | 178 | static struct attribute *mc13783_attr_base[] = { |
|---|
| 188 | 179 | &dev_attr_name.attr, |
|---|