Lines Matching +full:iio +full:- +full:consumer
1 // SPDX-License-Identifier: GPL-2.0-only
16 #include <linux/hwmon-sysfs.h>
17 #include <linux/iio/consumer.h>
18 #include <linux/iio/types.h>
21 * struct iio_hwmon_state - device instance state
22 * @channels: filled with array of channels from iio
37 * Assumes that IIO and hwmon operate in the same base units.
49 struct iio_channel *chan = &state->channels[sattr->index]; in iio_hwmon_read_val()
61 result *= 1000; /* mili-Watts to micro-Watts conversion */ in iio_hwmon_read_val()
68 struct device *dev = &pdev->dev; in iio_hwmon_probe()
80 if (PTR_ERR(channels) == -ENODEV) in iio_hwmon_probe()
81 return -EPROBE_DEFER; in iio_hwmon_probe()
87 return -ENOMEM; in iio_hwmon_probe()
89 st->channels = channels; in iio_hwmon_probe()
92 while (st->channels[st->num_channels].indio_dev) in iio_hwmon_probe()
93 st->num_channels++; in iio_hwmon_probe()
95 st->attrs = devm_kcalloc(dev, in iio_hwmon_probe()
96 st->num_channels + 1, sizeof(*st->attrs), in iio_hwmon_probe()
98 if (st->attrs == NULL) in iio_hwmon_probe()
99 return -ENOMEM; in iio_hwmon_probe()
101 for (i = 0; i < st->num_channels; i++) { in iio_hwmon_probe()
107 return -ENOMEM; in iio_hwmon_probe()
109 sysfs_attr_init(&a->dev_attr.attr); in iio_hwmon_probe()
110 ret = iio_get_channel_type(&st->channels[i], &type); in iio_hwmon_probe()
136 return -EINVAL; in iio_hwmon_probe()
139 a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL, in iio_hwmon_probe()
142 if (a->dev_attr.attr.name == NULL) in iio_hwmon_probe()
143 return -ENOMEM; in iio_hwmon_probe()
145 a->dev_attr.show = iio_hwmon_read_val; in iio_hwmon_probe()
146 a->dev_attr.attr.mode = 0444; in iio_hwmon_probe()
147 a->index = i; in iio_hwmon_probe()
148 st->attrs[i] = &a->dev_attr.attr; in iio_hwmon_probe()
151 st->attr_group.attrs = st->attrs; in iio_hwmon_probe()
152 st->groups[0] = &st->attr_group; in iio_hwmon_probe()
157 return -ENOMEM; in iio_hwmon_probe()
158 strreplace(sname, '-', '_'); in iio_hwmon_probe()
164 st->groups); in iio_hwmon_probe()
169 { .compatible = "iio-hwmon", },
185 MODULE_DESCRIPTION("IIO to hwmon driver");