Re: [PATCH] HC-SR04 ultrasonic ranger IIO driver

2016-06-01 Thread Daniel Baluta
On Wed, Jun 1, 2016 at 12:05 AM,   wrote:
> From: Johannes Thoma 
>
> The HC-SR04 is an ultrasonic distance sensor attached to two GPIO
> pins. The driver based on Industrial I/O (iio) subsystem and is
> controlled via configfs and sysfs. It supports an (in theory) unlimited
> number of HC-SR04 devices.
>
> Datasheet to the device can be found at:
>
> http://www.micropik.com/PDF/HCSR04.pdf
> Signed-off-by: Johannes Thoma 

Please send this to the linux-iio mailing list (linux-...@vger.kernel.org )

thanks,
Daniel.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: [PATCH] HC-SR04 ultrasonic ranger IIO driver

2016-05-31 Thread Valdis . Kletnieks
On Tue, 31 May 2016 23:05:57 +0200, johan...@johannesthoma.com said:

Looks good overall, far from the ugliest driver I've seen.  I spotted one
locking bug, and a few small typos etc, noted inline...

> From: Johannes Thoma 
>
> The HC-SR04 is an ultrasonic distance sensor attached to two GPIO
> pins. The driver based on Industrial I/O (iio) subsystem and is

The driver is based on the Industrial...


> + * To configure a device do a
> + *
> + *mkdir /config/iio/triggers/hc-sr04/sensor0
> + *
> + * (you need to mount configfs to /config first)

Most distros seem to be using /sys/kernel/config as the mount point for this...


> + * Then you can measure distance with:
> + *
> + *cat /sys/devices/trigger0/measure

What are the units of the returned value? Inches? Hundredths of an inch?
inches.hundredths?   Other?

(Yes, I looked at the datasheet.. and your driver source is more helpful
than the sheed :)


> + struct gpio_desc *echo_desc;
> + /* Used to measure length of ECHO signal */

I was going to say "comments on same line", but that would result in *long*
lines, this is better


> +static int do_measurement(struct hc_sr04 *device,
> +   long long *usecs_elapsed)
> +{
(...)
> + if (!mutex_trylock(&device->measurement_mutex))
> + return -EBUSY;

OK... this is a potential problem, because...

> + irq = gpiod_to_irq(device->echo_desc);
> + if (irq < 0)
> + return -EIO;

Here you do a 'return' without unlocking.  This should probably be:

 if (irq < 0) {
ret = -EIO;
goto out_mutex;
}

I admit not knowing the GPIO or IIO stuff well enough to comment on those
details, but I didn't see anything obviously insane either

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: [PATCH] HC-SR04 ultrasonic ranger IIO driver

2016-05-31 Thread Greg KH
On Tue, May 31, 2016 at 11:05:57PM +0200, johan...@johannesthoma.com wrote:
> From: Johannes Thoma 
> 
> The HC-SR04 is an ultrasonic distance sensor attached to two GPIO
> pins. The driver based on Industrial I/O (iio) subsystem and is
> controlled via configfs and sysfs. It supports an (in theory) unlimited
> number of HC-SR04 devices.
> 
> Datasheet to the device can be found at:
> 
> http://www.micropik.com/PDF/HCSR04.pdf
> Signed-off-by: Johannes Thoma 
> ---
>  MAINTAINERS   |   7 +
>  drivers/iio/Kconfig   |   1 +
>  drivers/iio/Makefile  |   1 +
>  drivers/iio/ultrasonic-distance/Kconfig   |  16 ++
>  drivers/iio/ultrasonic-distance/Makefile  |   6 +
>  drivers/iio/ultrasonic-distance/hc-sr04.c | 460 
> ++
>  6 files changed, 491 insertions(+)
>  create mode 100644 drivers/iio/ultrasonic-distance/Kconfig
>  create mode 100644 drivers/iio/ultrasonic-distance/Makefile
>  create mode 100644 drivers/iio/ultrasonic-distance/hc-sr04.c

Hint, use scripts/get_maintainer.pl to find the correct mailing list and
developers to send this patch to, in order to ensure the correct people
who can apply it, receive it.

thanks,

greg k-h

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: [PATCH] HC-SR04 ultrasonic ranger IIO driver

2016-05-31 Thread Johannes Thoma
Dear List,

I've ported my hc-sr04 driver to IIO now and wanted to ask if it is ok 
to post it to the
main kernel list (or some other list?) like this (see original mail, 
sent with git send-mail).

Thanks a lot,

- Johannes

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies