[PATCH 04/05] input: F01 Device control

2012-12-18 Thread Christopher Heiny
In addition to the changes described in 0/0 of this patchset, this patch
includes:

* changes to the handling of sysfs as requested in feedback to our
previous patch.

* device serialization updated to conform to the latest specification.

Signed-off-by: Christopher Heiny 
Cc: Dmitry Torokhov 
Cc: Linus Walleij 
Cc: Joeri de Gram 
Acked-by: Jean Delvare 

---

 drivers/input/rmi4/rmi_f01.c |  733 --
 drivers/input/rmi4/rmi_f01.h |   29 +--
 2 files changed, 425 insertions(+), 337 deletions(-)

diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
index d7461d7..d33fa16 100644
--- a/drivers/input/rmi4/rmi_f01.c
+++ b/drivers/input/rmi4/rmi_f01.c
@@ -2,19 +2,9 @@
  * Copyright (c) 2011-2012 Synaptics Incorporated
  * Copyright (c) 2011 Unixphere
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
  */

 #include 
@@ -26,6 +16,8 @@
 #include "rmi_driver.h"
 #include "rmi_f01.h"

+#define FUNCTION_NUMBER 0x01
+
 /**
  * @reset - set this bit to force a firmware reset of the sensor.
  */
@@ -109,11 +101,17 @@ struct f01_ds4_queries {
u8 reset_pin_number:4;
 } __attribute__((__packed__));

+/*
+ *
+ * @serialization - 7 bytes of device serialization data.  The meaning of
+ * these bytes varies from product to product, consult your product spec sheet.
+ */
 struct f01_data {
struct f01_device_control device_control;
struct f01_basic_queries basic_queries;
struct f01_device_status device_status;
-   u8 product_id[RMI_PRODUCT_ID_LENGTH + 1];
+   u8 serialization[F01_SERIALIZATION_SIZE];
+   u8 product_id[RMI_PRODUCT_ID_LENGTH+1];

u16 interrupt_enable_addr;
u16 doze_interval_addr;
@@ -136,19 +134,19 @@ struct f01_data {
 #ifdef CONFIG_RMI4_DEBUG
 struct f01_debugfs_data {
bool done;
-   struct rmi_function *fn;
+   struct rmi_function_dev *fn_dev;
 };

 static int f01_debug_open(struct inode *inodep, struct file *filp)
 {
struct f01_debugfs_data *data;
-   struct rmi_function *fn = inodep->i_private;
+   struct rmi_function_dev *fn_dev = inodep->i_private;

data = kzalloc(sizeof(struct f01_debugfs_data), GFP_KERNEL);
if (!data)
return -ENOMEM;

-   data->fn = fn;
+   data->fn_dev = fn_dev;
filp->private_data = data;
return 0;
 }
@@ -167,7 +165,7 @@ static ssize_t interrupt_enable_read(struct file *filp, 
char __user *buffer,
char local_buf[size];
char *current_buf = local_buf;
struct f01_debugfs_data *data = filp->private_data;
-   struct f01_data *f01 = data->fn->data;
+   struct f01_data *f01 = data->fn_dev->data;

if (data->done)
return 0;
@@ -197,7 +195,7 @@ static ssize_t interrupt_enable_read(struct file *filp, 
char __user *buffer,
current_buf += len;
total_len += len;
} else {
-   dev_err(>fn->dev, "Failed to build 
interrupt_enable buffer, code = %d.\n",
+   dev_err(>fn_dev->dev, "Failed to build 
interrupt_enable buffer, code = %d.\n",
len);
return snprintf(local_buf, size, "unknown\n");
}
@@ -206,7 +204,7 @@ static ssize_t interrupt_enable_read(struct file *filp, 
char __user *buffer,
if (len > 0)
total_len += len;
else
-   dev_warn(>fn->dev, "%s: Failed to append carriage 
return.\n",
+   dev_warn(>fn_dev->dev, "%s: Failed to append carriage 
return.\n",
 __func__);

if (copy_to_user(buffer, local_buf, total_len))
@@ -224,7 +222,7 @@ static ssize_t interrupt_enable_write(struct file *filp,
int irq_count = 0;
int irq_reg = 0;
struct f01_debugfs_data *data = filp->private_data;
-   struct f01_data *f01 = data->fn->data;
+   struct f01_data *f01 = data->fn_dev->data;

retval = copy_from_user(buf, buffer, size);
if (retval)
@@ -244,7 +242,7 @@ static ssize_t interrupt_enable_write(struct 

[PATCH 04/05] input: F01 Device control

2012-12-18 Thread Christopher Heiny
In addition to the changes described in 0/0 of this patchset, this patch
includes:

* changes to the handling of sysfs as requested in feedback to our
previous patch.

* device serialization updated to conform to the latest specification.

Signed-off-by: Christopher Heiny che...@synaptics.com
Cc: Dmitry Torokhov dmitry.torok...@gmail.com
Cc: Linus Walleij linus.wall...@stericsson.com
Cc: Joeri de Gram j.de.g...@gmail.com
Acked-by: Jean Delvare kh...@linux-fr.org

---

 drivers/input/rmi4/rmi_f01.c |  733 --
 drivers/input/rmi4/rmi_f01.h |   29 +--
 2 files changed, 425 insertions(+), 337 deletions(-)

diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
index d7461d7..d33fa16 100644
--- a/drivers/input/rmi4/rmi_f01.c
+++ b/drivers/input/rmi4/rmi_f01.c
@@ -2,19 +2,9 @@
  * Copyright (c) 2011-2012 Synaptics Incorporated
  * Copyright (c) 2011 Unixphere
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
  */

 #include linux/kernel.h
@@ -26,6 +16,8 @@
 #include rmi_driver.h
 #include rmi_f01.h

+#define FUNCTION_NUMBER 0x01
+
 /**
  * @reset - set this bit to force a firmware reset of the sensor.
  */
@@ -109,11 +101,17 @@ struct f01_ds4_queries {
u8 reset_pin_number:4;
 } __attribute__((__packed__));

+/*
+ *
+ * @serialization - 7 bytes of device serialization data.  The meaning of
+ * these bytes varies from product to product, consult your product spec sheet.
+ */
 struct f01_data {
struct f01_device_control device_control;
struct f01_basic_queries basic_queries;
struct f01_device_status device_status;
-   u8 product_id[RMI_PRODUCT_ID_LENGTH + 1];
+   u8 serialization[F01_SERIALIZATION_SIZE];
+   u8 product_id[RMI_PRODUCT_ID_LENGTH+1];

u16 interrupt_enable_addr;
u16 doze_interval_addr;
@@ -136,19 +134,19 @@ struct f01_data {
 #ifdef CONFIG_RMI4_DEBUG
 struct f01_debugfs_data {
bool done;
-   struct rmi_function *fn;
+   struct rmi_function_dev *fn_dev;
 };

 static int f01_debug_open(struct inode *inodep, struct file *filp)
 {
struct f01_debugfs_data *data;
-   struct rmi_function *fn = inodep-i_private;
+   struct rmi_function_dev *fn_dev = inodep-i_private;

data = kzalloc(sizeof(struct f01_debugfs_data), GFP_KERNEL);
if (!data)
return -ENOMEM;

-   data-fn = fn;
+   data-fn_dev = fn_dev;
filp-private_data = data;
return 0;
 }
@@ -167,7 +165,7 @@ static ssize_t interrupt_enable_read(struct file *filp, 
char __user *buffer,
char local_buf[size];
char *current_buf = local_buf;
struct f01_debugfs_data *data = filp-private_data;
-   struct f01_data *f01 = data-fn-data;
+   struct f01_data *f01 = data-fn_dev-data;

if (data-done)
return 0;
@@ -197,7 +195,7 @@ static ssize_t interrupt_enable_read(struct file *filp, 
char __user *buffer,
current_buf += len;
total_len += len;
} else {
-   dev_err(data-fn-dev, Failed to build 
interrupt_enable buffer, code = %d.\n,
+   dev_err(data-fn_dev-dev, Failed to build 
interrupt_enable buffer, code = %d.\n,
len);
return snprintf(local_buf, size, unknown\n);
}
@@ -206,7 +204,7 @@ static ssize_t interrupt_enable_read(struct file *filp, 
char __user *buffer,
if (len  0)
total_len += len;
else
-   dev_warn(data-fn-dev, %s: Failed to append carriage 
return.\n,
+   dev_warn(data-fn_dev-dev, %s: Failed to append carriage 
return.\n,
 __func__);

if (copy_to_user(buffer, local_buf, total_len))
@@ -224,7 +222,7 @@ static ssize_t interrupt_enable_write(struct file *filp,
int irq_count = 0;
int irq_reg = 0;
struct f01_debugfs_data *data = filp-private_data;
-   struct f01_data *f01 = data-fn-data;
+   struct f01_data *f01 = data-fn_dev-data;

retval =