public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Maciej Szmigiero <mhej@o2.pl>
To: Ben Nizette <bn@niasdigital.com>
Cc: Jonathan Cameron <jic23@cam.ac.uk>,
	johnpol@2ka.mipt.ru, linux-kernel@vger.kernel.org,
	David Brownell <dbrownell@users.sourceforge.net>
Subject: Re: [W1] a driver for DS2405 chip
Date: Thu, 04 Nov 2010 21:01:49 +0100	[thread overview]
Message-ID: <4CD3112D.2010700@o2.pl> (raw)
In-Reply-To: <6B41915B-1667-4CA1-A73A-45B043ED8C11@niasdigital.com>

W dniu 03.11.2010 11:54, Ben Nizette pisze:
> 
> On 03/11/2010, at 6:53 AM, Maciej Szmigiero wrote:
> 
>> W dniu 01.11.2010 13:35, Jonathan Cameron pisze:
>>> On 10/28/10 21:52, Maciej Szmigiero wrote:
>>>> [W1] a driver for DS2405 chip
>>>>
>>>> This is a driver for DS2405 1-wire single-channel addressable switch / PIO.
>>>> DS2405 can also work as single-channel binary remote sensor.
>>> Perhaps handle this as a gpio chip? (be it a fairly limited one)
>>> To my mind it would make it more generally useful...
>>
>> I think the GPIO infrastructure is meant for on-system GPIOs, where 1-wire devices are mostly 
>> used for remote data acquisition.
> 
> Nope!  The contents of drivers/gpio is split roughly 50/50 between on- and off-chip gpio expanders. 
> 
>> That's probably why w1_therm (for 1-wire thermometers) is not integrated with HWMON subsystem.
> 
> Don't know why this is but kinda sounds like it should be looked at more closely - conceptually 1-W is just another bus like, eg, SPI.
> 
> 	--Ben.


Looking at GPIO subsystem I think it's not a best solution for this device. One reason is that GPIOs are
identified by integer which is either #defined by platform (as Documentation/gpio.txt says) or assigned randomly.

First approach obviously doesn't fit, as I'm yet to find anybody using ds2405 for anything platform-related.
Second leads to problems in locating particular device (numbers will depend on order of detection/plugging).
In contrast with that, 1W subsystem provides clear and unique identification for every device as it appears under
its hardware address.

In addition to that the chip removal code (gpiochip_remove() function) does not sleep when removal fails due
to chip being in use, returning EBUSY instead. 
This leads to inefficient unplugging (like trying to remove chip in loop hoping that finally somebody releases it).
Probably this loop will also have to check if device reappeared, so the driver doesn't try to register new instance of chip
while there is still one in existence.
Note that Documentation/gpio.txt says "Removing a GPIO controller should be rare; use gpiochip_remove() when it is unavoidable".
Characteristics of long W1 buses cause devices to disappear and reappear from time to time so it won't be a "rare" operation here.

And all this added complexity for what? - to replace two tiny attributes under device sysfs directory?

Maciej Szmigiero

  reply	other threads:[~2010-11-04 20:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-28 20:52 [W1] a driver for DS2405 chip Maciej Szmigiero
2010-11-01 12:35 ` Jonathan Cameron
2010-11-02 19:53   ` Maciej Szmigiero
2010-11-03 10:54     ` Ben Nizette
2010-11-04 20:01       ` Maciej Szmigiero [this message]
2010-11-04 21:16         ` Ben Nizette
2010-11-04 22:15           ` Maciej Szmigiero
2010-11-05  7:38             ` Ben Nizette

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=4CD3112D.2010700@o2.pl \
    --to=mhej@o2.pl \
    --cc=bn@niasdigital.com \
    --cc=dbrownell@users.sourceforge.net \
    --cc=jic23@cam.ac.uk \
    --cc=johnpol@2ka.mipt.ru \
    --cc=linux-kernel@vger.kernel.org \
    /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