linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: Reyad Attiyat <reyad.attiyat@gmail.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jonathan Cameron <jic23@kernel.org>
Subject: Re: [PATCH v5 0/4] iio: Add support for rotation from north
Date: Tue, 15 Jul 2014 14:39:04 -0700	[thread overview]
Message-ID: <53C59F78.8060009@linux.intel.com> (raw)
In-Reply-To: <CA+BWVUSLtG9pH245ofyGsrST5H_5W_EbvOXZ_YkCxmg4DX09_A@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2275 bytes --]

Hi,

Since you have only one attribute, it is working for you.
There is a dereference error in *channels.

Check the attached diff, which will fix this.

Thanks,
Srinivas

On 07/09/2014 03:12 PM, Reyad Attiyat wrote:
> Hey Srinivas,
>
> I did look into the panic you sent. I wasn't sure exactly what caused
> the NULL pointer.
> I tested it with out applying the last rotation from north patch, so
> no hid usages are found, my device only has rotation_from_north, and
> hid_parse_report() would return -EINVAL.
> I added another check to make sure a iio channel were set up, and
> return -EINVAL if not, but couldn't think of anything else.
>
> Could you test this version with dynamic debugging and see if it is
> finding any hid usage attributes.
> Any ideas what could cause this? I think I'm handling errors properly
> by returning what parse_report returns (-EINVAL or -ENOMEM) in probe
>
> Thanks,
> Reyad Attiyat
>
> On Wed, Jul 9, 2014 at 2:45 PM, Srinivas Pandruvada
> <srinivas.pandruvada@linux.intel.com> wrote:
>> On 07/09/2014 12:30 PM, Reyad Attiyat wrote:
>>> This series of patches modifies magn-3d driver to handle the rotation
>>> from north usage. This is done by scanning the report and then building
>>> the iio arrays (vals and channels) dynamically.
>>>
>>> Changes from V4
>>> I use the address field of struct iio_chan_spec to hold the array index
>>> of the usage attribute. The scan_index field is generated when creating
>>> an iio channel.
>>>
>>> Reyad Attiyat (4):
>>>     iio: Documentation: Add documentation for rotation from north sensor
>>>       usage attributes
>>>     iio: types: Added support for rotation from north usage attributes
>>>     iio: hid-sensor-magn-3d: Scan for usage attributes before setting up
>>>       iio channels
>>>     iio: hid-sensor-magn-3d: Add support for rotation from north
>>>
>>>    Documentation/ABI/testing/sysfs-bus-iio       |  82 +++++++++++
>>>    drivers/iio/industrialio-core.c               |   4 +
>>>    drivers/iio/magnetometer/hid-sensor-magn-3d.c | 199
>>> ++++++++++++++++++++------
>>>    include/linux/iio/types.h                     |   4 +
>>>    4 files changed, 245 insertions(+), 44 deletions(-)
>>>
>> Did you get chance to look at the cause of panic?
>>
>> Thanks,
>> Srinivas


[-- Attachment #2: hid-sensor-magn-3d.diff --]
[-- Type: text/x-patch, Size: 1587 bytes --]

diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index 070d20e..63f23af 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -271,6 +271,7 @@ static int magn_3d_parse_report(struct platform_device *pdev,
 	int ret = 0;
 	int i;
 	int attr_count = 0;
+	struct iio_chan_spec *_channels;
 
 	/* Scan for each usage attribute supported */
 	for (i = 0; i < MAGN_3D_CHANNEL_MAX; i++) {
@@ -300,10 +301,10 @@ static int magn_3d_parse_report(struct platform_device *pdev,
 		return  -EINVAL;
 
 	/* Setup IIO channel array */
-	*channels = devm_kcalloc(&pdev->dev, attr_count,
+	_channels = devm_kcalloc(&pdev->dev, attr_count,
 								sizeof(struct iio_chan_spec),
 								GFP_KERNEL);
-	if (!*channels) {
+	if (!_channels) {
 		dev_err(&pdev->dev, "failed to allocate space for iio channels\n");
 		return -ENOMEM;
 	}
@@ -322,14 +323,16 @@ static int magn_3d_parse_report(struct platform_device *pdev,
 	{
 		if (st->magn[i].index >= 0) {
 			/* Setup IIO channel struct */
-			*channels[*chan_count] = magn_3d_channels[i];
+			_channels[*chan_count] = magn_3d_channels[i];
 
 			st->magn_val_addr[i] = &(st->iio_val[*chan_count]);
-			magn_3d_adjust_channel_bit_mask(*channels, *chan_count, st->magn[i].size);
+			magn_3d_adjust_channel_bit_mask(_channels, *chan_count, st->magn[i].size);
 			(*chan_count)++;
 		}
 	}
 
+	*channels = _channels;
+
 	st->scale_precision = hid_sensor_format_scale(
 				HID_USAGE_SENSOR_COMPASS_3D,
 				&st->magn[CHANNEL_SCAN_INDEX_X],

  parent reply	other threads:[~2014-07-15 21:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-09 19:30 [PATCH v5 0/4] iio: Add support for rotation from north Reyad Attiyat
2014-07-09 19:30 ` [PATCH v5 1/4] iio: Documentation: Add documentation for rotation from north sensor usage attributes Reyad Attiyat
2014-07-09 19:30 ` [PATCH v5 2/4] iio: types: Added support for rotation from north " Reyad Attiyat
2014-07-09 19:30 ` [PATCH v5 3/4] iio: hid-sensor-magn-3d: Scan for usage attributes before setting up iio channels Reyad Attiyat
2014-07-09 19:39   ` Reyad Attiyat
2014-07-09 19:30 ` [PATCH v5 4/4] iio: hid-sensor-magn-3d: Add support for rotation from north Reyad Attiyat
2014-07-09 19:45 ` [PATCH v5 0/4] iio: " Srinivas Pandruvada
2014-07-09 22:12   ` Reyad Attiyat
2014-07-15 18:16     ` Jonathan Cameron
2014-07-15 21:39     ` Srinivas Pandruvada [this message]
2014-07-16  3:38       ` Reyad Attiyat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53C59F78.8060009@linux.intel.com \
    --to=srinivas.pandruvada@linux.intel.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=reyad.attiyat@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).