[PATCH 07/20] Input: atmel_mxt_ts - add backupnv sysfs entry
From: Daniel Kurtz
Date: Tue Mar 13 2012 - 08:06:10 EST
Writing to the object sysfs entry permits individual object table entries
to be modified in the device RAM at run time. To permanently save
the settings, they must be written to Non-Volatile memory (NVM).
This patch adds a write-only sysfs entry to allow userspace to save
current settings to NVM, but restricts access to root.
Signed-off-by: Daniel Kurtz <djkurtz@xxxxxxxxxxxx>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index ac3dbb7..e988dc0 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -994,6 +994,23 @@ static ssize_t mxt_object_store(struct device *dev,
return count;
}
+static ssize_t mxt_backupnv_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct mxt_data *data = dev_get_drvdata(dev);
+ int ret;
+
+ /* Backup non-volatile memory */
+ ret = mxt_write_object(data, MXT_GEN_COMMAND_T6, MXT_COMMAND_BACKUPNV,
+ MXT_BACKUP_VALUE);
+ if (ret)
+ return ret;
+ msleep(MXT_BACKUP_TIME);
+
+ return count;
+}
+
static int mxt_load_fw(struct device *dev, const char *fn)
{
struct mxt_data *data = dev_get_drvdata(dev);
@@ -1099,11 +1116,13 @@ static ssize_t mxt_update_fw_store(struct device *dev,
return count;
}
+static DEVICE_ATTR(backupnv, S_IWUSR, NULL, mxt_backupnv_store);
static DEVICE_ATTR(object, S_IRUGO | S_IWUSR, mxt_object_show,
mxt_object_store);
static DEVICE_ATTR(update_fw, S_IWUSR, NULL, mxt_update_fw_store);
static struct attribute *mxt_attrs[] = {
+ &dev_attr_backupnv.attr,
&dev_attr_object.attr,
&dev_attr_update_fw.attr,
NULL
--
1.7.7.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/