* Re: [PATCH] HID: hid-sensor-hub: Correct documentation
From: Srinivas Pandruvada @ 2015-01-07 16:35 UTC (permalink / raw)
To: Jiri Kosina
Cc: jic23-DgEjT+Ai2ygdnm+yROfE0A, linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <alpine.LNX.2.00.1501071718240.25732-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
On Wed, 2015-01-07 at 17:27 +0100, Jiri Kosina wrote:
> On Wed, 7 Jan 2015, Srinivas Pandruvada wrote:
>
> > > Most importantly, you seem to have inter-mixed three patch series (with
> > > 4,8 and 9 patches respectively) into one thread, plus there are 4 patches
> > > which aren't marked by series numbering. All this is mixed together into
> > > one thread without any particular ordering.
> > >
> > There are 7 series:
> > - The four patches, which are single independent patches
> > - The others 3 are multiple patches part of series.
>
> What I see this this:
>
> =====
> Jan 6 Srinivas Pandruvada (4379) . [PATCH] HID: hid-sensor-hub: Correct documentation
> Jan 6 Srinivas Pandruvada (4207) |-[PATCH] HID: sensor-hub: correct dyn_callback_lock IRQ-safe change
> Jan 6 Srinivas Pandruvada (5440) |-[PATCH 1/4] HID: hid-sensor-hub: Enhance feature report API
> Jan 6 Srinivas Pandruvada (5112) |-[PATCH 2/4] iio: hid_sensor_hub: update parameters to get feature report
> Jan 6 Srinivas Pandruvada (5618) |-[PATCH 1/9] HID: hid-sensor-hub: Extend API for async reads
> Jan 6 Srinivas Pandruvada (3575) |-[PATCH 2/9] iio: hid-sensor-accel-3d: Adjust parameter for attribute read
> Jan 6 Srinivas Pandruvada (5408) |-[PATCH 3/4] HID: hid-sensor-hub: Enhance feature report set API
> Jan 6 Srinivas Pandruvada (3561) |-[PATCH 3/9] iio: hid-sensor-gyro-3d: Adjust parameter for attribute read
> Jan 6 Srinivas Pandruvada (5306) |-[PATCH 4/4] iio: hid_sensor_hub: update parameters to set feature report
> Jan 6 Srinivas Pandruvada (3535) |-[PATCH 4/9] iio: hid-sensor-als: Adjust parameter for attribute read
> Jan 6 Srinivas Pandruvada (3544) |-[PATCH 5/9] iio: hid-sensor-prox: Adjust parameter for attribute read
> Jan 6 Srinivas Pandruvada (3599) |-[PATCH 6/9] iio: hid-sensor-magn-3d: Adjust parameter for attribute read
> Jan 6 Srinivas Pandruvada (3600) |-[PATCH 7/9] iio: hid-sensor-incl-3d: Adjust parameter for attribute read
> Jan 6 Srinivas Pandruvada (11K) |-[PATCH] HID: hid-sensor-hub: Allow parallel synchronous reads
> Jan 6 Srinivas Pandruvada (3568) |-[PATCH 8/9] iio: hid-sensor-press: Adjust parameter for attribute read
> Jan 6 Srinivas Pandruvada (4136) |-[PATCH 3/8] iio: hid-sensor-gyro-3d: Introduce PM
> Jan 6 Srinivas Pandruvada (3692) |-[PATCH 9/9] drivers/rtc/rtc-hid-sensor-time.c: Adjust parameter for attribute read
> Jan 6 Srinivas Pandruvada (4192) |-[PATCH 4/8] iio: hid-sensor-als: Introduce PM
> Jan 6 Srinivas Pandruvada (4162) |-[PATCH 2/8] iio: hid-sensor-accel-3d: Introduce PM
> Jan 6 Srinivas Pandruvada (7791) |-[PATCH 1/8] iio: hid_sensor_hub: Common PM functions
> Jan 6 Srinivas Pandruvada (4210) |-[PATCH 5/8] iio: hid-sensor-prox: Introduce PM
> Jan 6 Srinivas Pandruvada (4161) |-[PATCH 6/8] iio: hid-sensor-magn-3d: Introduce PM
> Jan 6 Srinivas Pandruvada (4174) |-[PATCH 7/8] iio: hid-sensor-incl-3d: Introduce PM
> Jan 6 Srinivas Pandruvada (4239) |-[PATCH 8/8] iio: hid-sensor-press: Introduce PM
> Jan 6 Srinivas Pandruvada (7319) \-[PATCH] HID: hid-sensor-hub: Add collection device
> =====
>
> i.e. all the patches from all the seris (and some out of the series) are
> referncing just a single e-mail, and that's
>
> 1420592328-9942-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org
>
> Which is a giant mess.
I see.
What about I send the 26 patches in a series (1/26 .. 2/26, 3/26...).
This way the ordering is preserved?
Thanks,
Srinivas
>
> --
> Jiri Kosina
> SUSE Labs
^ permalink raw reply
* Re: [PATCH v1] input: make use of the input_set_capability helper
From: Dmitry Torokhov @ 2015-01-07 17:43 UTC (permalink / raw)
To: Olliver Schinagl
Cc: Olliver Schinagl, Wolfram Sang, Paul Gortmaker, Jingoo Han,
David S. Miller, Sam Ravnborg, linux-input, linux-kernel
In-Reply-To: <54ACFF44.9050805@schinagl.nl>
On Wed, Jan 07, 2015 at 10:41:24AM +0100, Olliver Schinagl wrote:
> HEy Dmitry,
>
> On 07-01-15 09:26, Dmitry Torokhov wrote:
> >On Wed, Jan 07, 2015 at 09:19:28AM +0100, Olliver Schinagl wrote:
> >>Hey Dmitry,
> >>
> >>On 07-01-15 08:57, Dmitry Torokhov wrote:
> >>>Hi Olliver,
> >>>
> >>>On Wed, Jan 07, 2015 at 08:31:06AM +0100, Olliver Schinagl wrote:
> >>>>From: Olliver Schinagl <oliver@schinagl.nl>
> >>>>
> >>>>Almost all of the speaker drivers under input manipulate the ev bits
> >>>>directly, which is not needed, as there is a helper available.
> >>>>
> >>>>This patch makes use of the helper for the speaker drivers.
> >>>>
> >>>>Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
> >>>>---
> >>>> drivers/input/misc/cm109.c | 4 ++--
> >>>> drivers/input/misc/ixp4xx-beeper.c | 5 ++---
> >>>> drivers/input/misc/m68kspkr.c | 5 ++---
> >>>> drivers/input/misc/pcspkr.c | 5 ++---
> >>>> drivers/input/misc/pwm-beeper.c | 5 +----
> >>>> drivers/input/misc/sparcspkr.c | 6 ++----
> >>>> 6 files changed, 11 insertions(+), 19 deletions(-)
> >>>>
> >>>>diff --git a/drivers/input/misc/cm109.c b/drivers/input/misc/cm109.c
> >>>>index 9365535..8e41070 100644
> >>>>--- a/drivers/input/misc/cm109.c
> >>>>+++ b/drivers/input/misc/cm109.c
> >>>>@@ -767,10 +767,10 @@ static int cm109_usb_probe(struct usb_interface *intf,
> >>>> input_dev->keycodesize = sizeof(unsigned char);
> >>>> input_dev->keycodemax = ARRAY_SIZE(dev->keymap);
> >>>>- input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_SND);
> >>>>- input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
> >>>>+ input_set_capability(input_dev, EV_SND, SND_BELL | SND_TONE);
> >>>No, input_set_capability() takes single event code, not bitmask. The
> >>>fact that it works for these 2 values of SND events is pure coincidence
> >>>(the old code wasn't much better though).
> >Ah, not, it does not work at all. Instead of setting bits 1 and 2 your
> >code sets bit 3 in dev->sndbit.
> >
> >>What do you suggest we should do then? Fix input_set_capability to
> >>take bit masks? or multiline events?
> >>I'm not sure why __set_bits() wouldn't work for bitmasks, could you
> >>educate me?
> >Call it once per event:
> >
> > input_set_capability(input_dev, EV_SND, SND_BELL);
> > input_set_capability(input_dev, EV_SND, SND_TONE);
> roger, done
> >
> >>>> /* register available key events */
> >>>>+ input_dev->evbit[0] = BIT_MASK(EV_KEY);
> >>>Would prefer __set_bit(EV_KEY, input_dev->evbit); here instead.
> >>I only moved the EV_KEY bit from above to its appropiate place here.
> >The original code was setting combination of bits; here we set single
> >one and __set_bit() is cleaner IMO.
> The documentation contradicts this actually, it says to use
> set_bit() first, but favors the direct writing as above as it is
> 'shorter in some cases'.
Right, sometimes, when you need to set 3-4 values on evbit (that is
pretty much guaranteed to fit into one long word) it is shoerted to
write
input->evbit[0] = BIT(EV_A) | BIT(EV_B) | BIT(EV_C);
it is shorted, but it is not that great as it relies on knowledge of
EV_* values. Now relying on that knowledge is pretty safe as they form
userspace ABI and will not be changed, only extended. But nowadays I
prefer using __set_bit() or input_set_capability() if possible.
>
> Furthermore, I'm a little confused as what the purpose of
> input_set_capability() is, if we use set_bits (or __set_bits) here.
> It appears we use set_bits here because it is manipulating several
> entries in the array (well atleast index 0) and
> set_input_capability() doesn't handle arrays? But when I look at
> struct input_dev, all those entries are arrays, including sndbit. So
> we only use set_input_capabilities when manipulating index 0 when
> its the only one? Feels a little strange to me, but probably is my
> lack of knowledge herin, so appologies for that.
__set_bit() sets arbitrary bit in memory started at given address. So to
set bit 65 (or bit 1 in the 3rd element of u32 array a) on you do:
__set_bit(65, a);
input_set_capability() is a wrapper that does set both evbit and
appropriate *bit for given event type and event code and caller does not
need to know all the details about bitmap names inside input device
structure.
Thanks.
--
Dmitry
^ permalink raw reply
* [PATCH 1/2] HID: hid-sensor-hub: Correct documentation
From: Srinivas Pandruvada @ 2015-01-07 18:14 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
In-Reply-To: <1420654484-6410-1-git-send-email-srinivas.pandruvada@linux.intel.com>
During changes to the interface, some documentation field comments
were missed. Added missing comments.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
include/linux/hid-sensor-hub.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index 51f7cca..4173a8f 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -33,6 +33,8 @@
* @units: Measurment unit for this attribute.
* @unit_expo: Exponent used in the data.
* @size: Size in bytes for data size.
+ * @logical_minimum: Logical minimum value for this attribute.
+ * @logical_maximum: Logical maximum value for this attribute.
*/
struct hid_sensor_hub_attribute_info {
u32 usage_id;
@@ -146,6 +148,7 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
/**
* sensor_hub_input_attr_get_raw_value() - Synchronous read request
+* @hsdev: Hub device instance.
* @usage_id: Attribute usage id of parent physical device as per spec
* @attr_usage_id: Attribute usage id as per spec
* @report_id: Report id to look for
@@ -160,6 +163,7 @@ int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev,
u32 attr_usage_id, u32 report_id);
/**
* sensor_hub_set_feature() - Feature set request
+* @hsdev: Hub device instance.
* @report_id: Report id to look for
* @field_index: Field index inside a report
* @value: Value to set
@@ -172,6 +176,7 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
/**
* sensor_hub_get_feature() - Feature get request
+* @hsdev: Hub device instance.
* @report_id: Report id to look for
* @field_index: Field index inside a report
* @value: Place holder for return value
--
1.9.3
^ permalink raw reply related
* [PATCH 0/2] HID Sensor hub driver fixes
From: Srinivas Pandruvada @ 2015-01-07 18:14 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
Address two bug fixes in the existing code.
Srinivas Pandruvada (2):
HID: hid-sensor-hub: Correct documentation
HID: sensor-hub: correct dyn_callback_lock IRQ-safe change
drivers/hid/hid-sensor-hub.c | 8 +++++---
include/linux/hid-sensor-hub.h | 5 +++++
2 files changed, 10 insertions(+), 3 deletions(-)
--
1.9.3
^ permalink raw reply
* [PATCH 2/2] HID: sensor-hub: correct dyn_callback_lock IRQ-safe change
From: Srinivas Pandruvada @ 2015-01-07 18:14 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
In-Reply-To: <1420654484-6410-1-git-send-email-srinivas.pandruvada@linux.intel.com>
Commit 0ccf091d1fbc1f99bb7f93bff8cf346769a9b0cd ("HID: sensor-hub:
make dyn_callback_lock IRQ-safe) was supposed to change locks
in sensor_hub_get_callback(), but missed.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/hid/hid-sensor-hub.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 6a58b6c..e54ce10 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -135,8 +135,9 @@ static struct hid_sensor_hub_callbacks *sensor_hub_get_callback(
{
struct hid_sensor_hub_callbacks_list *callback;
struct sensor_hub_data *pdata = hid_get_drvdata(hdev);
+ unsigned long flags;
- spin_lock(&pdata->dyn_callback_lock);
+ spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
list_for_each_entry(callback, &pdata->dyn_callback_list, list)
if (callback->usage_id == usage_id &&
(collection_index >=
@@ -145,10 +146,11 @@ static struct hid_sensor_hub_callbacks *sensor_hub_get_callback(
callback->hsdev->end_collection_index)) {
*priv = callback->priv;
*hsdev = callback->hsdev;
- spin_unlock(&pdata->dyn_callback_lock);
+ spin_unlock_irqrestore(&pdata->dyn_callback_lock,
+ flags);
return callback->usage_callback;
}
- spin_unlock(&pdata->dyn_callback_lock);
+ spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
return NULL;
}
--
1.9.3
^ permalink raw reply related
* [PATCH 0/2] Core driver enhancements
From: Srinivas Pandruvada @ 2015-01-07 18:24 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, Srinivas Pandruvada
Enhance core to support next generation of hub devices for fast response
and fusion sensors.
Srinivas Pandruvada (2):
HID: hid-sensor-hub: Allow parallel synchronous reads
HID: hid-sensor-hub: Add collection device
drivers/hid/hid-sensor-hub.c | 140 +++++++++++++++++++++++++----------------
include/linux/hid-sensor-hub.h | 24 +++++++
include/linux/hid-sensor-ids.h | 2 +
3 files changed, 113 insertions(+), 53 deletions(-)
--
1.9.3
^ permalink raw reply
* [PATCH 2/2] HID: hid-sensor-hub: Add collection device
From: Srinivas Pandruvada @ 2015-01-07 18:24 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
In-Reply-To: <1420655051-6587-1-git-send-email-srinivas.pandruvada@linux.intel.com>
HID sensor hub exports several sensor which are fusion sensors, where
data is interpreted from one or more sensors. Some of them can't be
exported via IIO like sysfs as the user space download some firmware,
which defines what sensor will look like. They can be a part of a
collection.
Creating a MFD cell for a collection to write a standalone driver
to manage collections. Most of the time they will be propritery drivers
may not be even upstreamed. This patch allows framework to have
capability to write such drivers.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/hid/hid-sensor-hub.c | 50 ++++++++++++++++++++++++++++++++++++++----
include/linux/hid-sensor-ids.h | 2 ++
2 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 865cd56..83b6e15 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -119,11 +119,12 @@ static struct hid_sensor_hub_callbacks *sensor_hub_get_callback(
spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
list_for_each_entry(callback, &pdata->dyn_callback_list, list)
- if (callback->usage_id == usage_id &&
+ if (callback->usage_id == HID_USAGE_SENSOR_TYPE_COLLECTION ||
+ (callback->usage_id == usage_id &&
(collection_index >=
callback->hsdev->start_collection_index) &&
(collection_index <
- callback->hsdev->end_collection_index)) {
+ callback->hsdev->end_collection_index))) {
*priv = callback->priv;
*hsdev = callback->hsdev;
spin_unlock_irqrestore(&pdata->dyn_callback_lock,
@@ -159,7 +160,12 @@ int sensor_hub_register_callback(struct hid_sensor_hub_device *hsdev,
callback->usage_callback = usage_callback;
callback->usage_id = usage_id;
callback->priv = NULL;
- list_add_tail(&callback->list, &pdata->dyn_callback_list);
+ /* Give higher priority to collection device, so add to front */
+ if (usage_id == HID_USAGE_SENSOR_TYPE_COLLECTION)
+ list_add(&callback->list, &pdata->dyn_callback_list);
+ else
+ list_add_tail(&callback->list, &pdata->dyn_callback_list);
+
spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
return 0;
@@ -547,6 +553,37 @@ static __u8 *sensor_hub_report_fixup(struct hid_device *hdev, __u8 *rdesc,
return rdesc;
}
+static int sensor_hub_add_collection_device(struct hid_device *hdev,
+ struct sensor_hub_data *sd)
+{
+ struct hid_sensor_hub_device *hsdev;
+ char *name;
+
+ hsdev = devm_kzalloc(&hdev->dev, sizeof(*hsdev), GFP_KERNEL);
+ if (!hsdev)
+ return -ENOMEM;
+
+ hsdev->hdev = hdev;
+ hsdev->vendor_id = hdev->vendor;
+ hsdev->product_id = hdev->product;
+ hsdev->usage = HID_USAGE_SENSOR_TYPE_COLLECTION;
+ mutex_init(&hsdev->mutex);
+ name = devm_kasprintf(&hdev->dev, GFP_KERNEL, "HID-SENSOR-%x",
+ HID_USAGE_SENSOR_TYPE_COLLECTION);
+ if (name == NULL) {
+ hid_err(hdev, "Failed MFD device name\n");
+ return -ENOMEM;
+ }
+ sd->hid_sensor_hub_client_devs[sd->hid_sensor_client_cnt].name = name;
+ sd->hid_sensor_hub_client_devs[
+ sd->hid_sensor_client_cnt].platform_data = hsdev;
+ sd->hid_sensor_hub_client_devs[
+ sd->hid_sensor_client_cnt].pdata_size = sizeof(*hsdev);
+ sd->hid_sensor_client_cnt++;
+
+ return 0;
+}
+
static int sensor_hub_probe(struct hid_device *hdev,
const struct hid_device_id *id)
{
@@ -591,7 +628,8 @@ static int sensor_hub_probe(struct hid_device *hdev,
ret = -EINVAL;
goto err_stop_hw;
}
- sd->hid_sensor_hub_client_devs = devm_kzalloc(&hdev->dev, dev_cnt *
+ sd->hid_sensor_hub_client_devs = devm_kzalloc(&hdev->dev,
+ (dev_cnt + 1) *
sizeof(struct mfd_cell),
GFP_KERNEL);
if (sd->hid_sensor_hub_client_devs == NULL) {
@@ -645,6 +683,10 @@ static int sensor_hub_probe(struct hid_device *hdev,
if (last_hsdev)
last_hsdev->end_collection_index = i;
+ ret = sensor_hub_add_collection_device(hdev, sd);
+ if (ret)
+ goto err_stop_hw;
+
ret = mfd_add_hotplug_devices(&hdev->dev,
sd->hid_sensor_hub_client_devs,
sd->hid_sensor_client_cnt);
diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h
index 109f0e6..300ffea 100644
--- a/include/linux/hid-sensor-ids.h
+++ b/include/linux/hid-sensor-ids.h
@@ -21,6 +21,8 @@
#define HID_MAX_PHY_DEVICES 0xFF
+#define HID_USAGE_SENSOR_TYPE_COLLECTION 0x200001
+
/* Accel 3D (200073) */
#define HID_USAGE_SENSOR_ACCEL_3D 0x200073
#define HID_USAGE_SENSOR_DATA_ACCELERATION 0x200452
--
1.9.3
^ permalink raw reply related
* [PATCH 1/2] HID: hid-sensor-hub: Allow parallel synchronous reads
From: Srinivas Pandruvada @ 2015-01-07 18:24 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
In-Reply-To: <1420655051-6587-1-git-send-email-srinivas.pandruvada@linux.intel.com>
Current implementation only allows one outstanding synchronous read.
This is a performance hit when user mode is requesting raw reads
of sensor attributes on multiple sensors together.
This change changes the mutex lock to per hid sensor hub device instead
of global lock. Although request to hid sensor hub is serialized, there
can be multiple outstanding read requests pending for responses via
hid reports.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/hid/hid-sensor-hub.c | 90 +++++++++++++++++++-----------------------
include/linux/hid-sensor-hub.h | 24 +++++++++++
2 files changed, 65 insertions(+), 49 deletions(-)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index e54ce10..865cd56 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -29,29 +29,10 @@
#define HID_SENSOR_HUB_ENUM_QUIRK 0x01
/**
- * struct sensor_hub_pending - Synchronous read pending information
- * @status: Pending status true/false.
- * @ready: Completion synchronization data.
- * @usage_id: Usage id for physical device, E.g. Gyro usage id.
- * @attr_usage_id: Usage Id of a field, E.g. X-AXIS for a gyro.
- * @raw_size: Response size for a read request.
- * @raw_data: Place holder for received response.
- */
-struct sensor_hub_pending {
- bool status;
- struct completion ready;
- u32 usage_id;
- u32 attr_usage_id;
- int raw_size;
- u8 *raw_data;
-};
-
-/**
* struct sensor_hub_data - Hold a instance data for a HID hub device
* @hsdev: Stored hid instance for current hub device.
* @mutex: Mutex to serialize synchronous request.
* @lock: Spin lock to protect pending request structure.
- * @pending: Holds information of pending sync read request.
* @dyn_callback_list: Holds callback function
* @dyn_callback_lock: spin lock to protect callback list
* @hid_sensor_hub_client_devs: Stores all MFD cells for a hub instance.
@@ -61,7 +42,6 @@ struct sensor_hub_pending {
struct sensor_hub_data {
struct mutex mutex;
spinlock_t lock;
- struct sensor_hub_pending pending;
struct list_head dyn_callback_list;
spinlock_t dyn_callback_lock;
struct mfd_cell *hid_sensor_hub_client_devs;
@@ -266,40 +246,42 @@ int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev,
struct hid_report *report;
int ret_val = 0;
- mutex_lock(&data->mutex);
- memset(&data->pending, 0, sizeof(data->pending));
- init_completion(&data->pending.ready);
- data->pending.usage_id = usage_id;
- data->pending.attr_usage_id = attr_usage_id;
- data->pending.raw_size = 0;
+ mutex_lock(&hsdev->mutex);
+ memset(&hsdev->pending, 0, sizeof(hsdev->pending));
+ init_completion(&hsdev->pending.ready);
+ hsdev->pending.usage_id = usage_id;
+ hsdev->pending.attr_usage_id = attr_usage_id;
+ hsdev->pending.raw_size = 0;
spin_lock_irqsave(&data->lock, flags);
- data->pending.status = true;
+ hsdev->pending.status = true;
spin_unlock_irqrestore(&data->lock, flags);
report = sensor_hub_report(report_id, hsdev->hdev, HID_INPUT_REPORT);
if (!report)
goto err_free;
+ mutex_lock(&data->mutex);
hid_hw_request(hsdev->hdev, report, HID_REQ_GET_REPORT);
- wait_for_completion_interruptible_timeout(&data->pending.ready, HZ*5);
- switch (data->pending.raw_size) {
+ mutex_unlock(&data->mutex);
+ wait_for_completion_interruptible_timeout(&hsdev->pending.ready, HZ*5);
+ switch (hsdev->pending.raw_size) {
case 1:
- ret_val = *(u8 *)data->pending.raw_data;
+ ret_val = *(u8 *)hsdev->pending.raw_data;
break;
case 2:
- ret_val = *(u16 *)data->pending.raw_data;
+ ret_val = *(u16 *)hsdev->pending.raw_data;
break;
case 4:
- ret_val = *(u32 *)data->pending.raw_data;
+ ret_val = *(u32 *)hsdev->pending.raw_data;
break;
default:
ret_val = 0;
}
- kfree(data->pending.raw_data);
+ kfree(hsdev->pending.raw_data);
err_free:
- data->pending.status = false;
- mutex_unlock(&data->mutex);
+ hsdev->pending.status = false;
+ mutex_unlock(&hsdev->mutex);
return ret_val;
}
@@ -455,16 +437,6 @@ static int sensor_hub_raw_event(struct hid_device *hdev,
report->field[i]->report_count)/8);
sz = (report->field[i]->report_size *
report->field[i]->report_count)/8;
- if (pdata->pending.status && pdata->pending.attr_usage_id ==
- report->field[i]->usage->hid) {
- hid_dbg(hdev, "data was pending ...\n");
- pdata->pending.raw_data = kmemdup(ptr, sz, GFP_ATOMIC);
- if (pdata->pending.raw_data)
- pdata->pending.raw_size = sz;
- else
- pdata->pending.raw_size = 0;
- complete(&pdata->pending.ready);
- }
collection = &hdev->collection[
report->field[i]->usage->collection_index];
hid_dbg(hdev, "collection->usage %x\n",
@@ -474,8 +446,21 @@ static int sensor_hub_raw_event(struct hid_device *hdev,
report->field[i]->physical,
report->field[i]->usage[0].collection_index,
&hsdev, &priv);
-
- if (callback && callback->capture_sample) {
+ if (!callback) {
+ ptr += sz;
+ continue;
+ }
+ if (hsdev->pending.status && hsdev->pending.attr_usage_id ==
+ report->field[i]->usage->hid) {
+ hid_dbg(hdev, "data was pending ...\n");
+ hsdev->pending.raw_data = kmemdup(ptr, sz, GFP_ATOMIC);
+ if (hsdev->pending.raw_data)
+ hsdev->pending.raw_size = sz;
+ else
+ hsdev->pending.raw_size = 0;
+ complete(&hsdev->pending.ready);
+ }
+ if (callback->capture_sample) {
if (report->field[i]->logical)
callback->capture_sample(hsdev,
report->field[i]->logical, sz, ptr,
@@ -630,6 +615,8 @@ static int sensor_hub_probe(struct hid_device *hdev,
hsdev->hdev = hdev;
hsdev->vendor_id = hdev->vendor;
hsdev->product_id = hdev->product;
+ hsdev->usage = collection->usage;
+ mutex_init(&hsdev->mutex);
hsdev->start_collection_index = i;
if (last_hsdev)
last_hsdev->end_collection_index = i;
@@ -676,13 +663,18 @@ static void sensor_hub_remove(struct hid_device *hdev)
{
struct sensor_hub_data *data = hid_get_drvdata(hdev);
unsigned long flags;
+ int i;
hid_dbg(hdev, " hardware removed\n");
hid_hw_close(hdev);
hid_hw_stop(hdev);
spin_lock_irqsave(&data->lock, flags);
- if (data->pending.status)
- complete(&data->pending.ready);
+ for (i = 0; i < data->hid_sensor_client_cnt; ++i) {
+ struct hid_sensor_hub_device *hsdev =
+ data->hid_sensor_hub_client_devs[i].platform_data;
+ if (hsdev->pending.status)
+ complete(&hsdev->pending.ready);
+ }
spin_unlock_irqrestore(&data->lock, flags);
mfd_remove_devices(&hdev->dev);
hid_set_drvdata(hdev, NULL);
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index 4173a8f..0b21c4f 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -49,19 +49,43 @@ struct hid_sensor_hub_attribute_info {
};
/**
+ * struct sensor_hub_pending - Synchronous read pending information
+ * @status: Pending status true/false.
+ * @ready: Completion synchronization data.
+ * @usage_id: Usage id for physical device, E.g. Gyro usage id.
+ * @attr_usage_id: Usage Id of a field, E.g. X-AXIS for a gyro.
+ * @raw_size: Response size for a read request.
+ * @raw_data: Place holder for received response.
+ */
+struct sensor_hub_pending {
+ bool status;
+ struct completion ready;
+ u32 usage_id;
+ u32 attr_usage_id;
+ int raw_size;
+ u8 *raw_data;
+};
+
+/**
* struct hid_sensor_hub_device - Stores the hub instance data
* @hdev: Stores the hid instance.
* @vendor_id: Vendor id of hub device.
* @product_id: Product id of hub device.
+ * @usage: Usage id for this hub device instance.
* @start_collection_index: Starting index for a phy type collection
* @end_collection_index: Last index for a phy type collection
+ * @mutex: synchronizing mutex.
+ * @pending: Holds information of pending sync read request.
*/
struct hid_sensor_hub_device {
struct hid_device *hdev;
u32 vendor_id;
u32 product_id;
+ u32 usage;
int start_collection_index;
int end_collection_index;
+ struct mutex mutex;
+ struct sensor_hub_pending pending;
};
/**
--
1.9.3
^ permalink raw reply related
* [PATCH] Input:Flush client events on clk_type change
From: Anshul Garg @ 2015-01-07 18:26 UTC (permalink / raw)
To: dmitry.torokhov, dtor, linux-input; +Cc: aksgarg1989, anshul.g
From: Anshul Garg <aksgarg1989@gmail.com>
Since the client clk_type is changed , flush pending
events from client buffer and queue SYN_DROPPED event.
Added check for duplicate clk_type change request.
Signed-off-by: Anshul Garg <anshul.g@samsung.com>
---
drivers/input/evdev.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index b1a52ab..d024fc6 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -62,8 +62,12 @@ struct evdev_client {
struct input_event buffer[];
};
-static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid)
+static int evdev_set_clk_type(struct evdev_client *client,
+ struct input_dev *dev, unsigned int clkid)
{
+ if (client->clk_type == clkid)
+ return 0;
+
switch (clkid) {
case CLOCK_REALTIME:
@@ -78,7 +82,17 @@ static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid)
default:
return -EINVAL;
}
+
+ spin_lock_irq(&dev->event_lock);
+ spin_lock(&client->buffer_lock);
+ spin_unlock(&dev->event_lock);
+ /* Flush clients events after clk_type is changed
+ * and queue SYN_DROPPED event.*/
+ client->packet_head = client->head = client->tail;
+ spin_unlock_irq(&client->buffer_lock);
+
+ evdev_queue_syn_dropped(client);
return 0;
}
@@ -908,7 +922,7 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
if (copy_from_user(&i, p, sizeof(unsigned int)))
return -EFAULT;
- return evdev_set_clk_type(client, i);
+ return evdev_set_clk_type(client, dev, i);
case EVIOCGKEYCODE:
return evdev_handle_get_keycode(dev, p);
--
1.7.9.5
---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com
^ permalink raw reply related
* [PATCH 0/4] Enhance feature report APIs
From: Srinivas Pandruvada @ 2015-01-07 18:31 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, Srinivas Pandruvada
Current get and set feature report is enhanced to have multiple
values in get and set.
Srinivas Pandruvada (4):
HID: hid-sensor-hub: Enhance feature report API
iio: hid_sensor_hub: update parameters to get feature report
HID: hid-sensor-hub: Enhance feature report set API
iio: hid_sensor_hub: update parameters to set feature report
drivers/hid/hid-sensor-hub.c | 38 +++++++++++++++++++---
.../iio/common/hid-sensors/hid-sensor-attributes.c | 24 +++++++-------
.../iio/common/hid-sensors/hid-sensor-trigger.c | 13 ++++----
include/linux/hid-sensor-hub.h | 13 +++++---
4 files changed, 61 insertions(+), 27 deletions(-)
--
1.9.3
^ permalink raw reply
* [PATCH 1/4] HID: hid-sensor-hub: Enhance feature report API
From: Srinivas Pandruvada @ 2015-01-07 18:31 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, Srinivas Pandruvada
In-Reply-To: <1420655508-6736-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Some hid sensor feature report can contain more than one reports.
This API can now support receiving multiple values from the feature
report.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/hid/hid-sensor-hub.c | 16 ++++++++++++++--
include/linux/hid-sensor-hub.h | 8 +++++---
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 83b6e15..d17aa67 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -218,10 +218,11 @@ done_proc:
EXPORT_SYMBOL_GPL(sensor_hub_set_feature);
int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
- u32 field_index, s32 *value)
+ u32 field_index, int buffer_size, void *buffer)
{
struct hid_report *report;
struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev);
+ int report_size;
int ret = 0;
mutex_lock(&data->mutex);
@@ -233,7 +234,18 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
}
hid_hw_request(hsdev->hdev, report, HID_REQ_GET_REPORT);
hid_hw_wait(hsdev->hdev);
- *value = report->field[field_index]->value[0];
+
+ /* calculate number of bytes required to read this field */
+ report_size = report->field[field_index]->report_size / 8;
+ if (report->field[field_index]->report_size % 8)
+ ++report_size;
+ report_size *= report->field[field_index]->report_count;
+ if (!report_size) {
+ ret = -EINVAL;
+ goto done_proc;
+ }
+ ret = min(report_size, buffer_size);
+ memcpy(buffer, report->field[field_index]->value, ret);
done_proc:
mutex_unlock(&data->mutex);
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index 0b21c4f..1995bbd 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -203,13 +203,15 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
* @hsdev: Hub device instance.
* @report_id: Report id to look for
* @field_index: Field index inside a report
-* @value: Place holder for return value
+* @buffer_size: size of the buffer
+* @buffer: buffer to copy output
*
* Used to get a field in feature report. For example this can get polling
-* interval, sensitivity, activate/deactivate state.
+* interval, sensitivity, activate/deactivate state. On success it returns
+* number of bytes copied to buffer. On failure, it returns value < 0.
*/
int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
- u32 field_index, s32 *value);
+ u32 field_index, int buffer_size, void *buffer);
/* hid-sensor-attributes */
--
1.9.3
^ permalink raw reply related
* [PATCH 2/4] iio: hid_sensor_hub: update parameters to get feature report
From: Srinivas Pandruvada @ 2015-01-07 18:31 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, Srinivas Pandruvada
In-Reply-To: <1420655508-6736-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
The new sensor_hub_get_feature can return multiple values, this
resulted in the change in API. Update the API usage here.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 13 +++++++------
drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 4 ++--
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
index 25b01e1..e1435e9 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
@@ -153,8 +153,8 @@ s32 hid_sensor_read_poll_value(struct hid_sensor_common *st)
int ret;
ret = sensor_hub_get_feature(st->hsdev,
- st->poll.report_id,
- st->poll.index, &value);
+ st->poll.report_id,
+ st->poll.index, sizeof(value), &value);
if (ret < 0 || value < 0) {
return -EINVAL;
@@ -174,8 +174,8 @@ int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st,
int ret;
ret = sensor_hub_get_feature(st->hsdev,
- st->poll.report_id,
- st->poll.index, &value);
+ st->poll.report_id,
+ st->poll.index, sizeof(value), &value);
if (ret < 0 || value < 0) {
*val1 = *val2 = 0;
return -EINVAL;
@@ -229,8 +229,9 @@ int hid_sensor_read_raw_hyst_value(struct hid_sensor_common *st,
int ret;
ret = sensor_hub_get_feature(st->hsdev,
- st->sensitivity.report_id,
- st->sensitivity.index, &value);
+ st->sensitivity.report_id,
+ st->sensitivity.index, sizeof(value),
+ &value);
if (ret < 0 || value < 0) {
*val1 = *val2 = 0;
return -EINVAL;
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index 92068cd..ef0c495 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -76,8 +76,8 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
}
sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
- st->power_state.index,
- &state_val);
+ st->power_state.index,
+ sizeof(state_val), &state_val);
return 0;
}
EXPORT_SYMBOL(hid_sensor_power_state);
--
1.9.3
^ permalink raw reply related
* [PATCH 3/4] HID: hid-sensor-hub: Enhance feature report set API
From: Srinivas Pandruvada @ 2015-01-07 18:31 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
In-Reply-To: <1420655508-6736-1-git-send-email-srinivas.pandruvada@linux.intel.com>
Current API only allows setting one offset in the field. This API
is extended to set multiple offsets in the field report.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/hid/hid-sensor-hub.c | 22 ++++++++++++++++++++--
include/linux/hid-sensor-hub.h | 5 +++--
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index d17aa67..8bed109 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -194,10 +194,14 @@ int sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev,
EXPORT_SYMBOL_GPL(sensor_hub_remove_callback);
int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
- u32 field_index, s32 value)
+ u32 field_index, int buffer_size, void *buffer)
{
struct hid_report *report;
struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev);
+ __s32 *buf32 = (__s32 *)buffer;
+ int i = 0;
+ int remaining_bytes;
+ __s32 value;
int ret = 0;
mutex_lock(&data->mutex);
@@ -206,7 +210,21 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
ret = -EINVAL;
goto done_proc;
}
- hid_set_field(report->field[field_index], 0, value);
+
+ remaining_bytes = do_div(buffer_size, sizeof(__s32));
+ if (buffer_size) {
+ for (i = 0; i < buffer_size; ++i) {
+ hid_set_field(report->field[field_index], i,
+ cpu_to_le32(*buf32));
+ ++buf32;
+ }
+ }
+ if (remaining_bytes) {
+ value = 0;
+ memcpy(&value, (u8 *)buf32, remaining_bytes);
+ hid_set_field(report->field[field_index], i,
+ cpu_to_le32(value));
+ }
hid_hw_request(hsdev->hdev, report, HID_REQ_SET_REPORT);
hid_hw_wait(hsdev->hdev);
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index 1995bbd..a51c768 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -190,13 +190,14 @@ int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev,
* @hsdev: Hub device instance.
* @report_id: Report id to look for
* @field_index: Field index inside a report
-* @value: Value to set
+* @buffer_size: size of the buffer
+* @buffer: buffer to use in the feature set
*
* Used to set a field in feature report. For example this can set polling
* interval, sensitivity, activate/deactivate state.
*/
int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
- u32 field_index, s32 value);
+ u32 field_index, int buffer_size, void *buffer);
/**
* sensor_hub_get_feature() - Feature get request
--
1.9.3
^ permalink raw reply related
* [PATCH 4/4] iio: hid_sensor_hub: update parameters to set feature report
From: Srinivas Pandruvada @ 2015-01-07 18:31 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
In-Reply-To: <1420655508-6736-1-git-send-email-srinivas.pandruvada@linux.intel.com>
The new sensor_hub_set_feature can set multiple values, this
resulted in the change in API. Update the API usage here.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 11 +++++------
drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 9 +++++----
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
index e1435e9..e81f434 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
@@ -212,9 +212,8 @@ int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st,
else
value = 0;
}
- ret = sensor_hub_set_feature(st->hsdev,
- st->poll.report_id,
- st->poll.index, value);
+ ret = sensor_hub_set_feature(st->hsdev, st->poll.report_id,
+ st->poll.index, sizeof(value), &value);
if (ret < 0 || value < 0)
ret = -EINVAL;
@@ -254,9 +253,9 @@ int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
value = convert_to_vtf_format(st->sensitivity.size,
st->sensitivity.unit_expo,
val1, val2);
- ret = sensor_hub_set_feature(st->hsdev,
- st->sensitivity.report_id,
- st->sensitivity.index, value);
+ ret = sensor_hub_set_feature(st->hsdev, st->sensitivity.report_id,
+ st->sensitivity.index, sizeof(value),
+ &value);
if (ret < 0 || value < 0)
ret = -EINVAL;
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index ef0c495..910e82a 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -64,15 +64,16 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
if (state_val >= 0) {
state_val += st->power_state.logical_minimum;
sensor_hub_set_feature(st->hsdev, st->power_state.report_id,
- st->power_state.index,
- (s32)state_val);
+ st->power_state.index, sizeof(state_val),
+ &state_val);
}
if (report_val >= 0) {
report_val += st->report_state.logical_minimum;
sensor_hub_set_feature(st->hsdev, st->report_state.report_id,
- st->report_state.index,
- (s32)report_val);
+ st->report_state.index,
+ sizeof(report_val),
+ &report_val);
}
sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
--
1.9.3
^ permalink raw reply related
* [PATCH 0/9] Asynchronous attribute reads
From: Srinivas Pandruvada @ 2015-01-07 18:47 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A,
a.zummo-BfzFCNDTiLLj+vYz1yj4TQ
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, holler-SXC+2es9fhnfWeYVQQPykw,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw, Srinivas Pandruvada
Patches related to asynchronous attribute reads. This series
enhances core and driver using this API.
Srinivas Pandruvada (9):
HID: hid-sensor-hub: Extend API for async reads
iio: hid-sensor-accel-3d: Adjust parameter for attribute read
iio: hid-sensor-gyro-3d: Adjust parameter for attribute read
iio: hid-sensor-als: Adjust parameter for attribute read
iio: hid-sensor-prox: Adjust parameter for attribute read
iio: hid-sensor-magn-3d: Adjust parameter for attribute read
iio: hid-sensor-incl-3d: Adjust parameter for attribute read
iio: hid-sensor-press: Adjust parameter for attribute read
drivers/rtc/rtc-hid-sensor-time.c: Adjust parameter for attribute read
drivers/hid/hid-sensor-hub.c | 15 ++++++++++++++-
drivers/iio/accel/hid-sensor-accel-3d.c | 3 ++-
drivers/iio/gyro/hid-sensor-gyro-3d.c | 3 ++-
drivers/iio/light/hid-sensor-als.c | 3 ++-
drivers/iio/light/hid-sensor-prox.c | 3 ++-
drivers/iio/magnetometer/hid-sensor-magn-3d.c | 3 ++-
drivers/iio/orientation/hid-sensor-incl-3d.c | 3 ++-
drivers/iio/pressure/hid-sensor-press.c | 3 ++-
drivers/rtc/rtc-hid-sensor-time.c | 2 +-
include/linux/hid-sensor-hub.h | 19 +++++++++++++------
10 files changed, 42 insertions(+), 15 deletions(-)
--
1.9.3
^ permalink raw reply
* [PATCH 1/9] HID: hid-sensor-hub: Extend API for async reads
From: Srinivas Pandruvada @ 2015-01-07 18:47 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A,
a.zummo-BfzFCNDTiLLj+vYz1yj4TQ
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, holler-SXC+2es9fhnfWeYVQQPykw,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw, Srinivas Pandruvada
In-Reply-To: <1420656483-7093-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Add additional flag to read in async mode. In this mode the caller
need to register for events and match attribute usage id for result.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/hid/hid-sensor-hub.c | 15 ++++++++++++++-
include/linux/hid-sensor-hub.h | 19 +++++++++++++------
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 8bed109..7403b25 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -275,13 +275,26 @@ EXPORT_SYMBOL_GPL(sensor_hub_get_feature);
int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev,
u32 usage_id,
- u32 attr_usage_id, u32 report_id)
+ u32 attr_usage_id, u32 report_id,
+ enum sensor_hub_read_flags flag)
{
struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev);
unsigned long flags;
struct hid_report *report;
int ret_val = 0;
+ if (flag == SENSOR_HUB_ASYNC) {
+ report = sensor_hub_report(report_id, hsdev->hdev,
+ HID_INPUT_REPORT);
+ if (!report)
+ return -EINVAL;
+
+ mutex_lock(&data->mutex);
+ hid_hw_request(hsdev->hdev, report, HID_REQ_GET_REPORT);
+ mutex_unlock(&data->mutex);
+ return 0;
+ }
+
mutex_lock(&hsdev->mutex);
memset(&hsdev->pending, 0, sizeof(hsdev->pending));
init_completion(&hsdev->pending.ready);
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index a51c768..d48e91f 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -171,20 +171,27 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
struct hid_sensor_hub_attribute_info *info);
/**
-* sensor_hub_input_attr_get_raw_value() - Synchronous read request
+* sensor_hub_input_attr_get_raw_value() - Attribute read request
* @hsdev: Hub device instance.
* @usage_id: Attribute usage id of parent physical device as per spec
* @attr_usage_id: Attribute usage id as per spec
* @report_id: Report id to look for
+* @flag: Synchronour or asynchronous read
*
-* Issues a synchronous read request for an input attribute. Returns
-* data upto 32 bits. Since client can get events, so this call should
-* not be used for data paths, this will impact performance.
+* Issues a synchronous or asynchronous read request for an input attribute.
+* Returns data upto 32 bits.
*/
+enum sensor_hub_read_flags {
+ SENSOR_HUB_SYNC,
+ SENSOR_HUB_ASYNC,
+};
+
int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev,
- u32 usage_id,
- u32 attr_usage_id, u32 report_id);
+ u32 usage_id,
+ u32 attr_usage_id, u32 report_id,
+ enum sensor_hub_read_flags flag
+);
/**
* sensor_hub_set_feature() - Feature set request
* @hsdev: Hub device instance.
--
1.9.3
^ permalink raw reply related
* [PATCH 5/9] iio: hid-sensor-prox: Adjust parameter for attribute read
From: Srinivas Pandruvada @ 2015-01-07 18:47 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A,
a.zummo-BfzFCNDTiLLj+vYz1yj4TQ
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, holler-SXC+2es9fhnfWeYVQQPykw,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw, Srinivas Pandruvada
In-Reply-To: <1420656483-7093-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
The new API added a flag for sync/async mode. Added sync mode flag.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/iio/light/hid-sensor-prox.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index f5a5146..db9c60e 100644
--- a/drivers/iio/light/hid-sensor-prox.c
+++ b/drivers/iio/light/hid-sensor-prox.c
@@ -105,7 +105,8 @@ static int prox_read_raw(struct iio_dev *indio_dev,
*val = sensor_hub_input_attr_get_raw_value(
prox_state->common_attributes.hsdev,
HID_USAGE_SENSOR_PROX, address,
- report_id);
+ report_id,
+ SENSOR_HUB_SYNC);
hid_sensor_power_state(&prox_state->common_attributes,
false);
} else {
--
1.9.3
^ permalink raw reply related
* [PATCH 6/9] iio: hid-sensor-magn-3d: Adjust parameter for attribute read
From: Srinivas Pandruvada @ 2015-01-07 18:48 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A,
a.zummo-BfzFCNDTiLLj+vYz1yj4TQ
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, holler-SXC+2es9fhnfWeYVQQPykw,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw, Srinivas Pandruvada
In-Reply-To: <1420656483-7093-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
The new API added a flag for sync/async mode. Added sync mode flag.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/iio/magnetometer/hid-sensor-magn-3d.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index 6294575..4d299f3 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -178,7 +178,8 @@ static int magn_3d_read_raw(struct iio_dev *indio_dev,
*val = sensor_hub_input_attr_get_raw_value(
magn_state->common_attributes.hsdev,
HID_USAGE_SENSOR_COMPASS_3D, address,
- report_id);
+ report_id,
+ SENSOR_HUB_SYNC);
else {
*val = 0;
hid_sensor_power_state(&magn_state->common_attributes,
--
1.9.3
^ permalink raw reply related
* [PATCH 8/9] iio: hid-sensor-press: Adjust parameter for attribute read
From: Srinivas Pandruvada @ 2015-01-07 18:48 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A,
a.zummo-BfzFCNDTiLLj+vYz1yj4TQ
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, holler-SXC+2es9fhnfWeYVQQPykw,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw, Srinivas Pandruvada
In-Reply-To: <1420656483-7093-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
The new API added a flag for sync/async mode. Added sync mode flag.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/iio/pressure/hid-sensor-press.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
index 7649286..ac150f0 100644
--- a/drivers/iio/pressure/hid-sensor-press.c
+++ b/drivers/iio/pressure/hid-sensor-press.c
@@ -108,7 +108,8 @@ static int press_read_raw(struct iio_dev *indio_dev,
*val = sensor_hub_input_attr_get_raw_value(
press_state->common_attributes.hsdev,
HID_USAGE_SENSOR_PRESSURE, address,
- report_id);
+ report_id,
+ SENSOR_HUB_SYNC);
hid_sensor_power_state(&press_state->common_attributes,
false);
} else {
--
1.9.3
^ permalink raw reply related
* [PATCH 9/9] drivers/rtc/rtc-hid-sensor-time.c: Adjust parameter for attribute read
From: Srinivas Pandruvada @ 2015-01-07 18:48 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A,
a.zummo-BfzFCNDTiLLj+vYz1yj4TQ
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, holler-SXC+2es9fhnfWeYVQQPykw,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw, Srinivas Pandruvada
In-Reply-To: <1420656483-7093-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
The new API added a flag for sync/async mode. Added sync mode flag.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/rtc/rtc-hid-sensor-time.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-hid-sensor-time.c b/drivers/rtc/rtc-hid-sensor-time.c
index ae7c2ba..af4f85a 100644
--- a/drivers/rtc/rtc-hid-sensor-time.c
+++ b/drivers/rtc/rtc-hid-sensor-time.c
@@ -213,7 +213,7 @@ static int hid_rtc_read_time(struct device *dev, struct rtc_time *tm)
/* get a report with all values through requesting one value */
sensor_hub_input_attr_get_raw_value(time_state->common_attributes.hsdev,
HID_USAGE_SENSOR_TIME, hid_time_addresses[0],
- time_state->info[0].report_id);
+ time_state->info[0].report_id, SENSOR_HUB_SYNC);
/* wait for all values (event) */
ret = wait_for_completion_killable_timeout(
&time_state->comp_last_time, HZ*6);
--
1.9.3
^ permalink raw reply related
* [PATCH 2/9] iio: hid-sensor-accel-3d: Adjust parameter for attribute read
From: Srinivas Pandruvada @ 2015-01-07 18:47 UTC (permalink / raw)
To: jkosina, jic23, a.zummo
Cc: linux-iio, linux-input, holler, rtc-linux, Srinivas Pandruvada
In-Reply-To: <1420656483-7093-1-git-send-email-srinivas.pandruvada@linux.intel.com>
The new API added a flag for sync/async mode. Added sync mode flag.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/accel/hid-sensor-accel-3d.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index d5d9531..0085c2f 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -130,7 +130,8 @@ static int accel_3d_read_raw(struct iio_dev *indio_dev,
*val = sensor_hub_input_attr_get_raw_value(
accel_state->common_attributes.hsdev,
HID_USAGE_SENSOR_ACCEL_3D, address,
- report_id);
+ report_id,
+ SENSOR_HUB_SYNC);
else {
*val = 0;
hid_sensor_power_state(&accel_state->common_attributes,
--
1.9.3
^ permalink raw reply related
* [PATCH 3/9] iio: hid-sensor-gyro-3d: Adjust parameter for attribute read
From: Srinivas Pandruvada @ 2015-01-07 18:47 UTC (permalink / raw)
To: jkosina, jic23, a.zummo
Cc: linux-iio, linux-input, holler, rtc-linux, Srinivas Pandruvada
In-Reply-To: <1420656483-7093-1-git-send-email-srinivas.pandruvada@linux.intel.com>
The new API added a flag for sync/async mode. Added sync mode flag.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/gyro/hid-sensor-gyro-3d.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index a3ea1e8..bdcd105 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -130,7 +130,8 @@ static int gyro_3d_read_raw(struct iio_dev *indio_dev,
*val = sensor_hub_input_attr_get_raw_value(
gyro_state->common_attributes.hsdev,
HID_USAGE_SENSOR_GYRO_3D, address,
- report_id);
+ report_id,
+ SENSOR_HUB_SYNC);
else {
*val = 0;
hid_sensor_power_state(&gyro_state->common_attributes,
--
1.9.3
^ permalink raw reply related
* [PATCH 4/9] iio: hid-sensor-als: Adjust parameter for attribute read
From: Srinivas Pandruvada @ 2015-01-07 18:47 UTC (permalink / raw)
To: jkosina, jic23, a.zummo
Cc: linux-iio, linux-input, holler, rtc-linux, Srinivas Pandruvada
In-Reply-To: <1420656483-7093-1-git-send-email-srinivas.pandruvada@linux.intel.com>
The new API added a flag for sync/async mode. Added sync mode flag.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/light/hid-sensor-als.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index a5283d7..321862d 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -109,7 +109,8 @@ static int als_read_raw(struct iio_dev *indio_dev,
*val = sensor_hub_input_attr_get_raw_value(
als_state->common_attributes.hsdev,
HID_USAGE_SENSOR_ALS, address,
- report_id);
+ report_id,
+ SENSOR_HUB_SYNC);
hid_sensor_power_state(&als_state->common_attributes,
false);
} else {
--
1.9.3
^ permalink raw reply related
* [PATCH 7/9] iio: hid-sensor-incl-3d: Adjust parameter for attribute read
From: Srinivas Pandruvada @ 2015-01-07 18:48 UTC (permalink / raw)
To: jkosina, jic23, a.zummo
Cc: linux-iio, linux-input, holler, rtc-linux, Srinivas Pandruvada
In-Reply-To: <1420656483-7093-1-git-send-email-srinivas.pandruvada@linux.intel.com>
The new API added a flag for sync/async mode. Added sync mode flag.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/orientation/hid-sensor-incl-3d.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c
index 1ff181b..45bed08 100644
--- a/drivers/iio/orientation/hid-sensor-incl-3d.c
+++ b/drivers/iio/orientation/hid-sensor-incl-3d.c
@@ -132,7 +132,8 @@ static int incl_3d_read_raw(struct iio_dev *indio_dev,
*val = sensor_hub_input_attr_get_raw_value(
incl_state->common_attributes.hsdev,
HID_USAGE_SENSOR_INCLINOMETER_3D, address,
- report_id);
+ report_id,
+ SENSOR_HUB_SYNC);
else {
hid_sensor_power_state(&incl_state->common_attributes,
false);
--
1.9.3
^ permalink raw reply related
* [PATCH 6/8] iio: hid-sensor-magn-3d: Introduce PM
From: Srinivas Pandruvada @ 2015-01-07 18:55 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, Srinivas Pandruvada
In-Reply-To: <1420656960-7365-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Use common hid sensor iio pm functions. Also the poll time read and
wait is part of power up function of hid sensor iio pm function, so
remove from the client drivers.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/iio/magnetometer/hid-sensor-magn-3d.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index 4d299f3..4f9c0be 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -157,20 +157,12 @@ static int magn_3d_read_raw(struct iio_dev *indio_dev,
int report_id = -1;
u32 address;
int ret_type;
- s32 poll_value;
*val = 0;
*val2 = 0;
switch (mask) {
case 0:
- poll_value = hid_sensor_read_poll_value(
- &magn_state->common_attributes);
- if (poll_value < 0)
- return -EINVAL;
-
hid_sensor_power_state(&magn_state->common_attributes, true);
- msleep_interruptible(poll_value * 2);
-
report_id =
magn_state->magn[chan->address].report_id;
address = magn_3d_addresses[chan->address];
@@ -531,6 +523,7 @@ static struct platform_driver hid_magn_3d_platform_driver = {
.id_table = hid_magn_3d_ids,
.driver = {
.name = KBUILD_MODNAME,
+ .pm = &hid_sensor_pm_ops,
},
.probe = hid_magn_3d_probe,
.remove = hid_magn_3d_remove,
--
1.9.3
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox