2019-11-15 15:57:20 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
|
|
|
* AD7091RX Analog to Digital converter driver
|
|
|
|
*
|
|
|
|
* Copyright 2014-2019 Analog Devices Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/bitops.h>
|
2023-12-19 17:26:01 -03:00
|
|
|
#include <linux/bitfield.h>
|
2025-02-28 15:14:03 +02:00
|
|
|
#include <linux/cleanup.h>
|
2019-11-15 15:57:20 +02:00
|
|
|
#include <linux/iio/events.h>
|
|
|
|
#include <linux/iio/iio.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/regmap.h>
|
2019-11-15 15:57:21 +02:00
|
|
|
#include <linux/regulator/consumer.h>
|
2019-11-15 15:57:20 +02:00
|
|
|
|
|
|
|
#include "ad7091r-base.h"
|
|
|
|
|
2023-12-19 17:26:01 -03:00
|
|
|
const struct iio_event_spec ad7091r_events[] = {
|
|
|
|
{
|
|
|
|
.type = IIO_EV_TYPE_THRESH,
|
|
|
|
.dir = IIO_EV_DIR_RISING,
|
|
|
|
.mask_separate = BIT(IIO_EV_INFO_VALUE) |
|
|
|
|
BIT(IIO_EV_INFO_ENABLE),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.type = IIO_EV_TYPE_THRESH,
|
|
|
|
.dir = IIO_EV_DIR_FALLING,
|
|
|
|
.mask_separate = BIT(IIO_EV_INFO_VALUE) |
|
|
|
|
BIT(IIO_EV_INFO_ENABLE),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.type = IIO_EV_TYPE_THRESH,
|
|
|
|
.dir = IIO_EV_DIR_EITHER,
|
|
|
|
.mask_separate = BIT(IIO_EV_INFO_HYSTERESIS),
|
|
|
|
},
|
|
|
|
};
|
module: Convert symbol namespace to string literal
Clean up the existing export namespace code along the same lines of
commit 33def8498fdd ("treewide: Convert macro and uses of __section(foo)
to __section("foo")") and for the same reason, it is not desired for the
namespace argument to be a macro expansion itself.
Scripted using
git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
do
awk -i inplace '
/^#define EXPORT_SYMBOL_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/^#define MODULE_IMPORT_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/MODULE_IMPORT_NS/ {
$0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
}
/EXPORT_SYMBOL_NS/ {
if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
$0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
$0 !~ /^my/) {
getline line;
gsub(/[[:space:]]*\\$/, "");
gsub(/[[:space:]]/, "", line);
$0 = $0 " " line;
}
$0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
"\\1(\\2, \"\\3\")", "g");
}
}
{ print }' $file;
done
Requested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://mail.google.com/mail/u/2/#inbox/FMfcgzQXKWgMmjdFwwdsfgxzKpVHWPlc
Acked-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2024-12-02 15:59:47 +01:00
|
|
|
EXPORT_SYMBOL_NS_GPL(ad7091r_events, "IIO_AD7091R");
|
2023-12-19 17:26:01 -03:00
|
|
|
|
2019-11-15 15:57:20 +02:00
|
|
|
static int ad7091r_set_channel(struct ad7091r_state *st, unsigned int channel)
|
|
|
|
{
|
|
|
|
unsigned int dummy;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* AD7091R_REG_CHANNEL specified which channels to be converted */
|
|
|
|
ret = regmap_write(st->map, AD7091R_REG_CHANNEL,
|
|
|
|
BIT(channel) | (BIT(channel) << 8));
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* There is a latency of one conversion before the channel conversion
|
|
|
|
* sequence is updated
|
|
|
|
*/
|
|
|
|
return regmap_read(st->map, AD7091R_REG_RESULT, &dummy);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ad7091r_read_one(struct iio_dev *iio_dev,
|
|
|
|
unsigned int channel, unsigned int *read_val)
|
|
|
|
{
|
|
|
|
struct ad7091r_state *st = iio_priv(iio_dev);
|
|
|
|
unsigned int val;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = ad7091r_set_channel(st, channel);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = regmap_read(st->map, AD7091R_REG_RESULT, &val);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2023-12-19 17:29:30 -03:00
|
|
|
if (st->chip_info->reg_result_chan_id(val) != channel)
|
2019-11-15 15:57:20 +02:00
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
*read_val = AD7091R_REG_RESULT_CONV_RESULT(val);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ad7091r_read_raw(struct iio_dev *iio_dev,
|
|
|
|
struct iio_chan_spec const *chan,
|
|
|
|
int *val, int *val2, long m)
|
|
|
|
{
|
|
|
|
struct ad7091r_state *st = iio_priv(iio_dev);
|
|
|
|
unsigned int read_val;
|
|
|
|
int ret;
|
|
|
|
|
2024-01-28 15:05:37 +00:00
|
|
|
guard(mutex)(&st->lock);
|
2019-11-15 15:57:20 +02:00
|
|
|
|
|
|
|
switch (m) {
|
|
|
|
case IIO_CHAN_INFO_RAW:
|
2024-01-28 15:05:37 +00:00
|
|
|
if (st->mode != AD7091R_MODE_COMMAND)
|
|
|
|
return -EBUSY;
|
2019-11-15 15:57:20 +02:00
|
|
|
|
|
|
|
ret = ad7091r_read_one(iio_dev, chan->channel, &read_val);
|
|
|
|
if (ret)
|
2024-01-28 15:05:37 +00:00
|
|
|
return ret;
|
2019-11-15 15:57:20 +02:00
|
|
|
|
|
|
|
*val = read_val;
|
2024-01-28 15:05:37 +00:00
|
|
|
return IIO_VAL_INT;
|
2019-11-15 15:57:20 +02:00
|
|
|
|
2019-11-15 15:57:21 +02:00
|
|
|
case IIO_CHAN_INFO_SCALE:
|
|
|
|
if (st->vref) {
|
|
|
|
ret = regulator_get_voltage(st->vref);
|
|
|
|
if (ret < 0)
|
2024-01-28 15:05:37 +00:00
|
|
|
return ret;
|
2019-11-15 15:57:21 +02:00
|
|
|
|
|
|
|
*val = ret / 1000;
|
|
|
|
} else {
|
|
|
|
*val = st->chip_info->vref_mV;
|
|
|
|
}
|
|
|
|
|
|
|
|
*val2 = chan->scan_type.realbits;
|
2024-01-28 15:05:37 +00:00
|
|
|
return IIO_VAL_FRACTIONAL_LOG2;
|
2019-11-15 15:57:21 +02:00
|
|
|
|
2019-11-15 15:57:20 +02:00
|
|
|
default:
|
2024-01-28 15:05:37 +00:00
|
|
|
return -EINVAL;
|
2019-11-15 15:57:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-19 17:26:01 -03:00
|
|
|
static int ad7091r_read_event_config(struct iio_dev *indio_dev,
|
|
|
|
const struct iio_chan_spec *chan,
|
|
|
|
enum iio_event_type type,
|
|
|
|
enum iio_event_direction dir)
|
|
|
|
{
|
|
|
|
struct ad7091r_state *st = iio_priv(indio_dev);
|
|
|
|
int val, ret;
|
|
|
|
|
|
|
|
switch (dir) {
|
|
|
|
case IIO_EV_DIR_RISING:
|
|
|
|
ret = regmap_read(st->map,
|
|
|
|
AD7091R_REG_CH_HIGH_LIMIT(chan->channel),
|
|
|
|
&val);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
return val != AD7091R_HIGH_LIMIT;
|
|
|
|
case IIO_EV_DIR_FALLING:
|
|
|
|
ret = regmap_read(st->map,
|
|
|
|
AD7091R_REG_CH_LOW_LIMIT(chan->channel),
|
|
|
|
&val);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
return val != AD7091R_LOW_LIMIT;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ad7091r_write_event_config(struct iio_dev *indio_dev,
|
|
|
|
const struct iio_chan_spec *chan,
|
|
|
|
enum iio_event_type type,
|
iio: fix write_event_config signature
write_event_config callback use an int for state, but it is actually a
boolean. iio_ev_state_store is actually using kstrtobool to check user
input, then gives the converted boolean value to write_event_config.
Fix signature and update all iio drivers to use the new signature.
This patch has been partially written using coccinelle with the
following script:
$ cat iio-bool.cocci
// Options: --all-includes
virtual patch
@c1@
identifier iioinfo;
identifier wecfunc;
@@
static const struct iio_info iioinfo = {
...,
.write_event_config =
(
wecfunc
|
&wecfunc
),
...,
};
@@
identifier c1.wecfunc;
identifier indio_dev, chan, type, dir, state;
@@
int wecfunc(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir,
-int
+bool
state) {
...
}
make coccicheck MODE=patch COCCI=iio-bool.cocci M=drivers/iio
Unfortunately, this script didn't match all files:
* all write_event_config callbacks using iio_device_claim_direct_scoped
were not detected and not patched.
* all files that do not assign and declare the write_event_config
callback in the same file.
iio.h was also manually updated.
The patch was build tested using allmodconfig config.
cc: Julia Lawall <julia.lawall@inria.fr>
Signed-off-by: Julien Stephan <jstephan@baylibre.com>
Link: https://patch.msgid.link/20241031-iio-fix-write-event-config-signature-v2-7-2bcacbb517a2@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-31 16:27:02 +01:00
|
|
|
enum iio_event_direction dir,
|
|
|
|
bool state)
|
2023-12-19 17:26:01 -03:00
|
|
|
{
|
|
|
|
struct ad7091r_state *st = iio_priv(indio_dev);
|
|
|
|
|
|
|
|
if (state) {
|
|
|
|
return regmap_set_bits(st->map, AD7091R_REG_CONF,
|
|
|
|
AD7091R_REG_CONF_ALERT_EN);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Set thresholds either to 0 or to 2^12 - 1 as appropriate to
|
|
|
|
* prevent alerts and thus disable event generation.
|
|
|
|
*/
|
|
|
|
switch (dir) {
|
|
|
|
case IIO_EV_DIR_RISING:
|
|
|
|
return regmap_write(st->map,
|
|
|
|
AD7091R_REG_CH_HIGH_LIMIT(chan->channel),
|
|
|
|
AD7091R_HIGH_LIMIT);
|
|
|
|
case IIO_EV_DIR_FALLING:
|
|
|
|
return regmap_write(st->map,
|
|
|
|
AD7091R_REG_CH_LOW_LIMIT(chan->channel),
|
|
|
|
AD7091R_LOW_LIMIT);
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ad7091r_read_event_value(struct iio_dev *indio_dev,
|
|
|
|
const struct iio_chan_spec *chan,
|
|
|
|
enum iio_event_type type,
|
|
|
|
enum iio_event_direction dir,
|
|
|
|
enum iio_event_info info, int *val, int *val2)
|
|
|
|
{
|
|
|
|
struct ad7091r_state *st = iio_priv(indio_dev);
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
switch (info) {
|
|
|
|
case IIO_EV_INFO_VALUE:
|
|
|
|
switch (dir) {
|
|
|
|
case IIO_EV_DIR_RISING:
|
|
|
|
ret = regmap_read(st->map,
|
|
|
|
AD7091R_REG_CH_HIGH_LIMIT(chan->channel),
|
|
|
|
val);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
return IIO_VAL_INT;
|
|
|
|
case IIO_EV_DIR_FALLING:
|
|
|
|
ret = regmap_read(st->map,
|
|
|
|
AD7091R_REG_CH_LOW_LIMIT(chan->channel),
|
|
|
|
val);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
return IIO_VAL_INT;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
case IIO_EV_INFO_HYSTERESIS:
|
|
|
|
ret = regmap_read(st->map,
|
|
|
|
AD7091R_REG_CH_HYSTERESIS(chan->channel),
|
|
|
|
val);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
return IIO_VAL_INT;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ad7091r_write_event_value(struct iio_dev *indio_dev,
|
|
|
|
const struct iio_chan_spec *chan,
|
|
|
|
enum iio_event_type type,
|
|
|
|
enum iio_event_direction dir,
|
|
|
|
enum iio_event_info info, int val, int val2)
|
|
|
|
{
|
|
|
|
struct ad7091r_state *st = iio_priv(indio_dev);
|
|
|
|
|
|
|
|
switch (info) {
|
|
|
|
case IIO_EV_INFO_VALUE:
|
|
|
|
switch (dir) {
|
|
|
|
case IIO_EV_DIR_RISING:
|
|
|
|
return regmap_write(st->map,
|
|
|
|
AD7091R_REG_CH_HIGH_LIMIT(chan->channel),
|
|
|
|
val);
|
|
|
|
case IIO_EV_DIR_FALLING:
|
|
|
|
return regmap_write(st->map,
|
|
|
|
AD7091R_REG_CH_LOW_LIMIT(chan->channel),
|
|
|
|
val);
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
case IIO_EV_INFO_HYSTERESIS:
|
|
|
|
return regmap_write(st->map,
|
|
|
|
AD7091R_REG_CH_HYSTERESIS(chan->channel),
|
|
|
|
val);
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-15 15:57:20 +02:00
|
|
|
static const struct iio_info ad7091r_info = {
|
|
|
|
.read_raw = ad7091r_read_raw,
|
2023-12-19 17:26:01 -03:00
|
|
|
.read_event_config = &ad7091r_read_event_config,
|
|
|
|
.write_event_config = &ad7091r_write_event_config,
|
|
|
|
.read_event_value = &ad7091r_read_event_value,
|
|
|
|
.write_event_value = &ad7091r_write_event_value,
|
2019-11-15 15:57:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static irqreturn_t ad7091r_event_handler(int irq, void *private)
|
|
|
|
{
|
2023-12-16 14:46:11 -03:00
|
|
|
struct iio_dev *iio_dev = private;
|
|
|
|
struct ad7091r_state *st = iio_priv(iio_dev);
|
2019-11-15 15:57:20 +02:00
|
|
|
unsigned int i, read_val;
|
|
|
|
int ret;
|
|
|
|
s64 timestamp = iio_get_time_ns(iio_dev);
|
|
|
|
|
|
|
|
ret = regmap_read(st->map, AD7091R_REG_ALERT, &read_val);
|
|
|
|
if (ret)
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
|
|
|
|
for (i = 0; i < st->chip_info->num_channels; i++) {
|
|
|
|
if (read_val & BIT(i * 2))
|
|
|
|
iio_push_event(iio_dev,
|
|
|
|
IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, i,
|
|
|
|
IIO_EV_TYPE_THRESH,
|
|
|
|
IIO_EV_DIR_RISING), timestamp);
|
|
|
|
if (read_val & BIT(i * 2 + 1))
|
|
|
|
iio_push_event(iio_dev,
|
|
|
|
IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, i,
|
|
|
|
IIO_EV_TYPE_THRESH,
|
|
|
|
IIO_EV_DIR_FALLING), timestamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
2019-11-15 15:57:21 +02:00
|
|
|
static void ad7091r_remove(void *data)
|
|
|
|
{
|
|
|
|
struct ad7091r_state *st = data;
|
|
|
|
|
|
|
|
regulator_disable(st->vref);
|
|
|
|
}
|
|
|
|
|
2023-12-19 17:28:05 -03:00
|
|
|
int ad7091r_probe(struct device *dev, const struct ad7091r_init_info *init_info,
|
|
|
|
int irq)
|
2019-11-15 15:57:20 +02:00
|
|
|
{
|
|
|
|
struct iio_dev *iio_dev;
|
|
|
|
struct ad7091r_state *st;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
iio_dev = devm_iio_device_alloc(dev, sizeof(*st));
|
|
|
|
if (!iio_dev)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
st = iio_priv(iio_dev);
|
|
|
|
st->dev = dev;
|
2023-12-19 17:27:36 -03:00
|
|
|
init_info->init_adc_regmap(st, init_info->regmap_config);
|
|
|
|
if (IS_ERR(st->map))
|
|
|
|
return dev_err_probe(st->dev, PTR_ERR(st->map),
|
|
|
|
"Error initializing regmap\n");
|
2019-11-15 15:57:20 +02:00
|
|
|
|
|
|
|
iio_dev->info = &ad7091r_info;
|
|
|
|
iio_dev->modes = INDIO_DIRECT_MODE;
|
|
|
|
|
2023-12-19 17:32:36 -03:00
|
|
|
if (init_info->setup) {
|
|
|
|
ret = init_info->setup(st);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-11-15 15:57:20 +02:00
|
|
|
if (irq) {
|
2023-12-19 17:27:36 -03:00
|
|
|
st->chip_info = init_info->info_irq;
|
2023-12-16 14:46:37 -03:00
|
|
|
ret = regmap_update_bits(st->map, AD7091R_REG_CONF,
|
|
|
|
AD7091R_REG_CONF_ALERT_EN, BIT(4));
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2019-11-15 15:57:20 +02:00
|
|
|
ret = devm_request_threaded_irq(dev, irq, NULL,
|
2023-12-16 14:47:01 -03:00
|
|
|
ad7091r_event_handler,
|
|
|
|
IRQF_TRIGGER_FALLING |
|
2023-12-19 17:28:05 -03:00
|
|
|
IRQF_ONESHOT,
|
|
|
|
st->chip_info->name, iio_dev);
|
2019-11-15 15:57:20 +02:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2023-12-19 17:27:36 -03:00
|
|
|
} else {
|
|
|
|
st->chip_info = init_info->info_no_irq;
|
2019-11-15 15:57:20 +02:00
|
|
|
}
|
|
|
|
|
2023-12-19 17:27:36 -03:00
|
|
|
iio_dev->name = st->chip_info->name;
|
|
|
|
iio_dev->num_channels = st->chip_info->num_channels;
|
|
|
|
iio_dev->channels = st->chip_info->channels;
|
|
|
|
|
2019-11-15 15:57:21 +02:00
|
|
|
st->vref = devm_regulator_get_optional(dev, "vref");
|
|
|
|
if (IS_ERR(st->vref)) {
|
|
|
|
if (PTR_ERR(st->vref) == -EPROBE_DEFER)
|
|
|
|
return -EPROBE_DEFER;
|
2023-12-19 17:26:27 -03:00
|
|
|
|
2019-11-15 15:57:21 +02:00
|
|
|
st->vref = NULL;
|
2023-12-19 17:26:27 -03:00
|
|
|
/* Enable internal vref */
|
|
|
|
ret = regmap_set_bits(st->map, AD7091R_REG_CONF,
|
|
|
|
AD7091R_REG_CONF_INT_VREF);
|
|
|
|
if (ret)
|
|
|
|
return dev_err_probe(st->dev, ret,
|
|
|
|
"Error on enable internal reference\n");
|
2019-11-15 15:57:21 +02:00
|
|
|
} else {
|
|
|
|
ret = regulator_enable(st->vref);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
ret = devm_add_action_or_reset(dev, ad7091r_remove, st);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-11-15 15:57:20 +02:00
|
|
|
/* Use command mode by default to convert only desired channels*/
|
2023-12-19 17:28:45 -03:00
|
|
|
ret = st->chip_info->set_mode(st, AD7091R_MODE_COMMAND);
|
2019-11-15 15:57:20 +02:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return devm_iio_device_register(dev, iio_dev);
|
|
|
|
}
|
module: Convert symbol namespace to string literal
Clean up the existing export namespace code along the same lines of
commit 33def8498fdd ("treewide: Convert macro and uses of __section(foo)
to __section("foo")") and for the same reason, it is not desired for the
namespace argument to be a macro expansion itself.
Scripted using
git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
do
awk -i inplace '
/^#define EXPORT_SYMBOL_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/^#define MODULE_IMPORT_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/MODULE_IMPORT_NS/ {
$0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
}
/EXPORT_SYMBOL_NS/ {
if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
$0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
$0 !~ /^my/) {
getline line;
gsub(/[[:space:]]*\\$/, "");
gsub(/[[:space:]]/, "", line);
$0 = $0 " " line;
}
$0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
"\\1(\\2, \"\\3\")", "g");
}
}
{ print }' $file;
done
Requested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://mail.google.com/mail/u/2/#inbox/FMfcgzQXKWgMmjdFwwdsfgxzKpVHWPlc
Acked-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2024-12-02 15:59:47 +01:00
|
|
|
EXPORT_SYMBOL_NS_GPL(ad7091r_probe, "IIO_AD7091R");
|
2019-11-15 15:57:20 +02:00
|
|
|
|
2023-12-19 17:27:04 -03:00
|
|
|
bool ad7091r_writeable_reg(struct device *dev, unsigned int reg)
|
2019-11-15 15:57:20 +02:00
|
|
|
{
|
|
|
|
switch (reg) {
|
|
|
|
case AD7091R_REG_RESULT:
|
|
|
|
case AD7091R_REG_ALERT:
|
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
module: Convert symbol namespace to string literal
Clean up the existing export namespace code along the same lines of
commit 33def8498fdd ("treewide: Convert macro and uses of __section(foo)
to __section("foo")") and for the same reason, it is not desired for the
namespace argument to be a macro expansion itself.
Scripted using
git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
do
awk -i inplace '
/^#define EXPORT_SYMBOL_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/^#define MODULE_IMPORT_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/MODULE_IMPORT_NS/ {
$0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
}
/EXPORT_SYMBOL_NS/ {
if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
$0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
$0 !~ /^my/) {
getline line;
gsub(/[[:space:]]*\\$/, "");
gsub(/[[:space:]]/, "", line);
$0 = $0 " " line;
}
$0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
"\\1(\\2, \"\\3\")", "g");
}
}
{ print }' $file;
done
Requested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://mail.google.com/mail/u/2/#inbox/FMfcgzQXKWgMmjdFwwdsfgxzKpVHWPlc
Acked-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2024-12-02 15:59:47 +01:00
|
|
|
EXPORT_SYMBOL_NS_GPL(ad7091r_writeable_reg, "IIO_AD7091R");
|
2019-11-15 15:57:20 +02:00
|
|
|
|
2023-12-19 17:27:04 -03:00
|
|
|
bool ad7091r_volatile_reg(struct device *dev, unsigned int reg)
|
2019-11-15 15:57:20 +02:00
|
|
|
{
|
2025-04-21 11:55:34 -03:00
|
|
|
/* The volatile ad7091r registers are also the only RO ones. */
|
|
|
|
return !ad7091r_writeable_reg(dev, reg);
|
2019-11-15 15:57:20 +02:00
|
|
|
}
|
module: Convert symbol namespace to string literal
Clean up the existing export namespace code along the same lines of
commit 33def8498fdd ("treewide: Convert macro and uses of __section(foo)
to __section("foo")") and for the same reason, it is not desired for the
namespace argument to be a macro expansion itself.
Scripted using
git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
do
awk -i inplace '
/^#define EXPORT_SYMBOL_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/^#define MODULE_IMPORT_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/MODULE_IMPORT_NS/ {
$0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
}
/EXPORT_SYMBOL_NS/ {
if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
$0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
$0 !~ /^my/) {
getline line;
gsub(/[[:space:]]*\\$/, "");
gsub(/[[:space:]]/, "", line);
$0 = $0 " " line;
}
$0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
"\\1(\\2, \"\\3\")", "g");
}
}
{ print }' $file;
done
Requested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://mail.google.com/mail/u/2/#inbox/FMfcgzQXKWgMmjdFwwdsfgxzKpVHWPlc
Acked-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2024-12-02 15:59:47 +01:00
|
|
|
EXPORT_SYMBOL_NS_GPL(ad7091r_volatile_reg, "IIO_AD7091R");
|
2019-11-15 15:57:20 +02:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Beniamin Bia <beniamin.bia@analog.com>");
|
|
|
|
MODULE_DESCRIPTION("Analog Devices AD7091Rx multi-channel converters");
|
|
|
|
MODULE_LICENSE("GPL v2");
|