Lines Matching +full:micro +full:- +full:watts

1 // SPDX-License-Identifier: GPL-2.0-only
16 #include <linux/hwmon-sysfs.h>
21 * struct iio_hwmon_state - device instance state
42 struct iio_channel *chan = &state->channels[sattr->index]; in iio_hwmon_read_label()
60 struct iio_channel *chan = &state->channels[sattr->index]; in iio_hwmon_read_val()
68 /* mili-Watts to micro-Watts conversion */ in iio_hwmon_read_val()
80 struct device *dev = &pdev->dev; in iio_hwmon_probe()
94 if (ret == -ENODEV) in iio_hwmon_probe()
95 ret = -EPROBE_DEFER; in iio_hwmon_probe()
103 return -ENOMEM; in iio_hwmon_probe()
105 st->channels = channels; in iio_hwmon_probe()
108 while (st->channels[st->num_channels].indio_dev) in iio_hwmon_probe()
109 st->num_channels++; in iio_hwmon_probe()
111 st->attrs = devm_kcalloc(dev, in iio_hwmon_probe()
112 2 * st->num_channels + 1, sizeof(*st->attrs), in iio_hwmon_probe()
114 if (st->attrs == NULL) in iio_hwmon_probe()
115 return -ENOMEM; in iio_hwmon_probe()
117 for (i = 0; i < st->num_channels; i++) { in iio_hwmon_probe()
123 return -ENOMEM; in iio_hwmon_probe()
125 sysfs_attr_init(&a->dev_attr.attr); in iio_hwmon_probe()
126 ret = iio_get_channel_type(&st->channels[i], &type); in iio_hwmon_probe()
152 return -EINVAL; in iio_hwmon_probe()
155 a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL, in iio_hwmon_probe()
158 if (a->dev_attr.attr.name == NULL) in iio_hwmon_probe()
159 return -ENOMEM; in iio_hwmon_probe()
161 a->dev_attr.show = iio_hwmon_read_val; in iio_hwmon_probe()
162 a->dev_attr.attr.mode = 0444; in iio_hwmon_probe()
163 a->index = i; in iio_hwmon_probe()
164 st->attrs[attr++] = &a->dev_attr.attr; in iio_hwmon_probe()
167 if (iio_read_channel_label(&st->channels[i], buf) < 0) in iio_hwmon_probe()
172 return -ENOMEM; in iio_hwmon_probe()
174 sysfs_attr_init(&a->dev_attr.attr); in iio_hwmon_probe()
175 a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL, in iio_hwmon_probe()
178 if (!a->dev_attr.attr.name) in iio_hwmon_probe()
179 return -ENOMEM; in iio_hwmon_probe()
181 a->dev_attr.show = iio_hwmon_read_label; in iio_hwmon_probe()
182 a->dev_attr.attr.mode = 0444; in iio_hwmon_probe()
183 a->index = i; in iio_hwmon_probe()
184 st->attrs[attr++] = &a->dev_attr.attr; in iio_hwmon_probe()
189 st->attr_group.attrs = st->attrs; in iio_hwmon_probe()
190 st->groups[0] = &st->attr_group; in iio_hwmon_probe()
195 return -ENOMEM; in iio_hwmon_probe()
196 strreplace(sname, '-', '_'); in iio_hwmon_probe()
202 st->groups); in iio_hwmon_probe()
207 { .compatible = "iio-hwmon", },