2023-12-29 11:24:36 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
/*
|
|
|
|
* MPRLS0025PA - Honeywell MicroPressure pressure sensor series driver
|
|
|
|
*
|
|
|
|
* Copyright (c) Andreas Klinger <ak@it-klinger.de>
|
|
|
|
*
|
|
|
|
* Data sheet:
|
|
|
|
* https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/micropressure-mpr-series/documents/sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/mod_devicetable.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
#include "mprls0025pa.h"
|
|
|
|
|
|
|
|
static int mpr_i2c_init(struct device *unused)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mpr_i2c_read(struct mpr_data *data, const u8 unused, const u8 cnt)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct i2c_client *client = to_i2c_client(data->dev);
|
|
|
|
|
|
|
|
if (cnt > MPR_MEASUREMENT_RD_SIZE)
|
|
|
|
return -EOVERFLOW;
|
|
|
|
|
|
|
|
memset(data->buffer, 0, MPR_MEASUREMENT_RD_SIZE);
|
|
|
|
ret = i2c_master_recv(client, data->buffer, cnt);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
else if (ret != cnt)
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mpr_i2c_write(struct mpr_data *data, const u8 cmd, const u8 unused)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct i2c_client *client = to_i2c_client(data->dev);
|
2025-06-11 17:39:17 -05:00
|
|
|
u8 wdata[MPR_PKT_SYNC_LEN] = { cmd };
|
2023-12-29 11:24:36 +02:00
|
|
|
|
|
|
|
ret = i2c_master_send(client, wdata, MPR_PKT_SYNC_LEN);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
else if (ret != MPR_PKT_SYNC_LEN)
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct mpr_ops mpr_i2c_ops = {
|
|
|
|
.init = mpr_i2c_init,
|
|
|
|
.read = mpr_i2c_read,
|
|
|
|
.write = mpr_i2c_write,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int mpr_i2c_probe(struct i2c_client *client)
|
|
|
|
{
|
|
|
|
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
return mpr_common_probe(&client->dev, &mpr_i2c_ops, client->irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct of_device_id mpr_i2c_match[] = {
|
|
|
|
{ .compatible = "honeywell,mprls0025pa" },
|
2025-04-11 15:49:34 -05:00
|
|
|
{ }
|
2023-12-29 11:24:36 +02:00
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, mpr_i2c_match);
|
|
|
|
|
|
|
|
static const struct i2c_device_id mpr_i2c_id[] = {
|
|
|
|
{ "mprls0025pa" },
|
2025-04-11 15:49:34 -05:00
|
|
|
{ }
|
2023-12-29 11:24:36 +02:00
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(i2c, mpr_i2c_id);
|
|
|
|
|
|
|
|
static struct i2c_driver mpr_i2c_driver = {
|
|
|
|
.probe = mpr_i2c_probe,
|
|
|
|
.id_table = mpr_i2c_id,
|
|
|
|
.driver = {
|
|
|
|
.name = "mprls0025pa",
|
|
|
|
.of_match_table = mpr_i2c_match,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
module_i2c_driver(mpr_i2c_driver);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Andreas Klinger <ak@it-klinger.de>");
|
|
|
|
MODULE_DESCRIPTION("Honeywell MPR pressure sensor i2c driver");
|
|
|
|
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_HONEYWELL_MPRLS0025PA");
|