2019-05-27 08:55:06 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-01-28 15:05:52 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014, Samsung Electronics Co. Ltd. All Rights Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/iio/common/ssp_sensors.h>
|
2017-01-02 19:28:30 +00:00
|
|
|
#include <linux/iio/buffer.h>
|
2015-01-28 15:05:52 +01:00
|
|
|
#include <linux/iio/kfifo_buf.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/slab.h>
|
2024-12-14 20:14:20 +01:00
|
|
|
#include <linux/unaligned.h>
|
|
|
|
#include <linux/units.h>
|
2015-01-28 15:05:52 +01:00
|
|
|
#include "ssp_iio_sensor.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ssp_common_buffer_postenable() - generic postenable callback for ssp buffer
|
|
|
|
*
|
|
|
|
* @indio_dev: iio device
|
|
|
|
*
|
|
|
|
* Returns 0 or negative value in case of error
|
|
|
|
*/
|
|
|
|
int ssp_common_buffer_postenable(struct iio_dev *indio_dev)
|
|
|
|
{
|
|
|
|
struct ssp_sensor_data *spd = iio_priv(indio_dev);
|
|
|
|
struct ssp_data *data = dev_get_drvdata(indio_dev->dev.parent->parent);
|
|
|
|
|
|
|
|
/* the allocation is made in post because scan size is known in this
|
|
|
|
* moment
|
|
|
|
* */
|
|
|
|
spd->buffer = kmalloc(indio_dev->scan_bytes, GFP_KERNEL | GFP_DMA);
|
|
|
|
if (!spd->buffer)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
return ssp_enable_sensor(data, spd->type,
|
|
|
|
ssp_get_sensor_delay(data, spd->type));
|
|
|
|
}
|
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(ssp_common_buffer_postenable, "IIO_SSP_SENSORS");
|
2015-01-28 15:05:52 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ssp_common_buffer_postdisable() - generic postdisable callback for ssp buffer
|
|
|
|
*
|
|
|
|
* @indio_dev: iio device
|
|
|
|
*
|
|
|
|
* Returns 0 or negative value in case of error
|
|
|
|
*/
|
|
|
|
int ssp_common_buffer_postdisable(struct iio_dev *indio_dev)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct ssp_sensor_data *spd = iio_priv(indio_dev);
|
|
|
|
struct ssp_data *data = dev_get_drvdata(indio_dev->dev.parent->parent);
|
|
|
|
|
|
|
|
ret = ssp_disable_sensor(data, spd->type);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
kfree(spd->buffer);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
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(ssp_common_buffer_postdisable, "IIO_SSP_SENSORS");
|
2015-01-28 15:05:52 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ssp_common_process_data() - Common process data callback for ssp sensors
|
|
|
|
*
|
|
|
|
* @indio_dev: iio device
|
|
|
|
* @buf: source buffer
|
|
|
|
* @len: sensor data length
|
|
|
|
* @timestamp: system timestamp
|
|
|
|
*
|
|
|
|
* Returns 0 or negative value in case of error
|
|
|
|
*/
|
|
|
|
int ssp_common_process_data(struct iio_dev *indio_dev, void *buf,
|
|
|
|
unsigned int len, int64_t timestamp)
|
|
|
|
{
|
2024-12-14 20:14:20 +01:00
|
|
|
int64_t calculated_time;
|
2015-01-28 15:05:52 +01:00
|
|
|
struct ssp_sensor_data *spd = iio_priv(indio_dev);
|
|
|
|
|
|
|
|
if (indio_dev->scan_bytes == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* it always sends full set of samples, remember about available masks
|
|
|
|
*/
|
|
|
|
memcpy(spd->buffer, buf, len);
|
|
|
|
|
2024-12-14 20:14:20 +01:00
|
|
|
calculated_time = timestamp +
|
|
|
|
(int64_t)get_unaligned_le32(buf + len) * MEGA;
|
2015-01-28 15:05:52 +01:00
|
|
|
|
|
|
|
return iio_push_to_buffers_with_timestamp(indio_dev, spd->buffer,
|
|
|
|
calculated_time);
|
|
|
|
}
|
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(ssp_common_process_data, "IIO_SSP_SENSORS");
|
2015-01-28 15:05:52 +01:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Karol Wrona <k.wrona@samsung.com>");
|
|
|
|
MODULE_DESCRIPTION("Samsung sensorhub commons");
|
|
|
|
MODULE_LICENSE("GPL");
|
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
|
|
|
MODULE_IMPORT_NS("IIO_SSP_SENSORS");
|