Commit Graph

28 Commits

Author SHA1 Message Date
David Fries af00a2d5a0 W1: w1_int.c use first available master number
Follow the example of other devices (like the joystick device).  Pick the
first available id for each detected device.  Currently for USB devices,
suspending and resuming would cause the number to increment.

Signed-off-by: David Fries <david@fries.net>
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-16 11:21:50 -07:00
David Fries 9141f57c7e W1: new module parameter search_count
Added a new module parameter search_count which allows overriding the
default search count.  -1 continual, 0 disabled, N that many times.

Signed-off-by: David Fries <david@fries.net>
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-16 11:21:49 -07:00
David Fries 6a158c0de7 W1: feature, enable hardware strong pullup
Add a strong pullup option to the w1 system.  This supplies extra power
for parasite powered devices.  There is a w1_master_pullup sysfs entry and
enable_pullup module parameter to enable or disable the strong pullup.

The one wire bus requires at a minimum one wire and ground.  The common
wire is used for sending and receiving data as well as supplying power to
devices that are parasite powered of which temperature sensors can be one
example.  The bus must be idle and left high while a temperature
conversion is in progress, in addition the normal pullup resister on
larger networks or even higher temperatures might not supply enough power.
 The pullup resister can't provide too much pullup current, because
devices need to pull the bus down to write a value.  This enables the
strong pullup for supported hardware, which can supply more current when
requested.  Unsupported hardware will just delay with the bus high.

The hardware USB 2490 one wire bus master has a bit on some commands which
will enable the strong pullup as soon as the command finishes executing.
To use strong pullup, call the new w1_next_pullup function to register the
duration.  The next write command will call set_pullup before sending the
data, and reset the duration to zero once it returns.

Switched from simple_strtol to strict_strtol.

Signed-off-by: David Fries <david@fries.net>
Cc: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-16 11:21:49 -07:00
David Fries 3c52e4e627 W1: w1_process, block or sleep
The w1_process thread's sleeping and termination has been modified.
msleep_interruptible was replaced by schedule_timeout and schedule to
allow for kthread_stop and wake_up_process to interrupt the sleep and the
unbounded sleeping when a bus search is disabled.  The W1_MASTER_NEED_EXIT
and flags variable were removed as they were redundant with
kthread_should_stop and kthread_stop.  If w1_process is sleeping,
requesting a search will immediately wake it up rather than waiting for
the end of msleep_interruptible previously.

Signed-off-by: David Fries <david@fries.net>
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-16 11:21:49 -07:00
David Fries 01e14d6db9 W1: don't delay search start
Move the creation of the w1_process thread to after the device has been
initialized.  This way w1_process doesn't have to check to see if it has
been initialized and the bus search can proceed without sleeping.  That
also eliminates two checks in the w1_process loop.  The sleep now happens
at the end of the loop not the beginning.

Also added a comment for why the atomic_set was 2.

Signed-off-by: David Fries <david@fries.net>
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-16 11:21:49 -07:00
David Fries c30c9b1518 W1: fix deadlocks and remove w1_control_thread
w1_control_thread was removed which would wake up every second and process
newly registered family codes and complete some final cleanup for a
removed master.  Those routines were moved to the threads that were
previously requesting those operations.  A new function
w1_reconnect_slaves takes care of reconnecting existing slave devices when
a new family code is registered or removed.  The removal case was missing
and would cause a deadlock waiting for the family code reference count to
decrease, which will now happen.  A problem with registering a family code
was fixed.  A slave device would be unattached if it wasn't yet claimed,
then attached at the end of the list, two unclaimed slaves would cause an
infinite loop.

The struct w1_bus_master.search now takes a pointer to the struct
w1_master device to avoid searching for it, which would have caused a
lock ordering deadlock with the removal of w1_control_thread.

Signed-off-by: David Fries <david@fries.net>
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-16 11:21:49 -07:00
Evgeniy Polyakov 59d9445e85 w1: fix w1_remove_master_device() searching
In case bus master driver provided bogus value as its private data, search
can be incorrect.  Problem found by Adrian Bunk.

Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Cc: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-08-22 19:52:46 -07:00
Yoann Padioleau dd00cc486a some kmalloc/memset ->kzalloc (tree wide)
Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc).

Here is a short excerpt of the semantic patch performing
this transformation:

@@
type T2;
expression x;
identifier f,fld;
expression E;
expression E1,E2;
expression e1,e2,e3,y;
statement S;
@@

 x =
- kmalloc
+ kzalloc
  (E1,E2)
  ...  when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
- memset((T2)x,0,E1);

@@
expression E1,E2,E3;
@@

- kzalloc(E1 * E2,E3)
+ kcalloc(E1,E2,E3)

[akpm@linux-foundation.org: get kcalloc args the right way around]
Signed-off-by: Yoann Padioleau <padator@wanadoo.fr>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Acked-by: Russell King <rmk@arm.linux.org.uk>
Cc: Bryan Wu <bryan.wu@analog.com>
Acked-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Dave Airlie <airlied@linux.ie>
Acked-by: Roland Dreier <rolandd@cisco.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Acked-by: Dmitry Torokhov <dtor@mail.ru>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Acked-by: Pierre Ossman <drzeus-list@drzeus.cx>
Cc: Jeff Garzik <jeff@garzik.org>
Cc: "David S. Miller" <davem@davemloft.net>
Acked-by: Greg KH <greg@kroah.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-07-19 10:04:50 -07:00
Evgeniy Polyakov c1f858b763 w1: allow bus master to have reset and byte ops
Signed-off-by: Matt Reimer <mreimer@vpop.net>
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-08 11:15:14 -07:00
Evgeniy Polyakov 70d484bff4 [PATCH] W1: possible cleanups
This patch contains the following possible cleanups:
- the following file did't #include the header with the prototypes for
  it's global functions:
  - w1_int.c
- #if 0 the following unused global function:
  - w1_family.c: w1_family_get()
- make the following needlessly global functions static:
  - w1_family.c: __w1_family_put()
  - w1_io.c: w1_delay()
  - w1_io.c: w1_touch_bit()
  - w1_io.c: w1_read_8()
- remove the following unused EXPORT_SYMBOL's:
  - w1_family.c: w1_family_put
  - w1_family.c: w1_family_registered

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-06-22 11:22:50 -07:00
Evgeniy Polyakov 2c5bfdac33 [PATCH] W1: cleanups
Nice cleanup spotted by Adrian Bunk, which was lost due to moving to the
completely new functionality.

Shame-shame-shame on me.

Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-06-22 11:22:50 -07:00
Evgeniy Polyakov abd52a1320 [PATCH] w1: Use mutexes instead of semaphores.
Use mutexes instead of semaphores.
Patch tested on x86_64 and i386 with test bus master driver.

Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-06-22 11:22:50 -07:00
Evgeniy Polyakov 12003375ac [PATCH] w1: Userspace communication protocol over connector.
There are three types of messages between w1 core and userspace:
1. Events. They are generated each time new master or slave device found
	either due to automatic or requested search.
2. Userspace commands. Includes read/write and search/alarm search comamnds.
3. Replies to userspace commands.

From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-06-22 11:22:50 -07:00
Evgeniy Polyakov 674a396c6d [PATCH] w1: use kthread api.
This patch removes old-style kernel thread initialization
and changes w1 to use kthread api.
It is based on Christoph Hellwig <hch@lst.de> work.

Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-03-23 17:28:13 -08:00
Patrick McHardy ecd5136c85 [PATCH] W1: Remove incorrect MODULE_ALIAS
The w1 netlink socket is created by a hardware specific driver calling
w1_add_master_device, so there is no point in including a module alias
for netlink autoloading in the core.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Acked-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-03-23 17:28:13 -08:00
Adrian Bunk a9fb1c7b95 [PATCH] w1: misc cleanups
This patch contains the following cleanups:
- make needlessly global code static
- declarations for global code belong into header files
- w1.c: #if 0 the unused struct w1_slave_device

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Acked-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-03-23 17:28:12 -08:00
Evgeniy Polyakov 3aca692d3e [PATCH] w1: Detouching bug fixed.
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-08 14:41:26 -07:00
Evgeniy Polyakov 7f772ed8df [PATCH] w1: hotplug support.
Here is W1 hotplug in addition to netlink notifications.

Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-08 14:41:26 -07:00
Evgeniy Polyakov 2d8331792e [PATCH] W1: w1_netlink: New init/fini netlink callbacks.
They are guarded with NETLINK_DISABLE compile time options,
so if CONFIG_NET is disabled, no linking errors occur.
Bug noticed by Adrian Bunk <bunk@stusta.de>.

Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-08 14:41:25 -07:00
Patrick McHardy 066286071d [NETLINK]: Add "groups" argument to netlink_kernel_create
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-08-29 16:01:11 -07:00
Evgeniy Polyakov ad93e266a1 [NETLINK]: w1_int.c: fix default netlink group
w1 does not need to multicast its state to several groups at once,
and upcoming netlink changes will not allow bitmask for groups anyway.

Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-08-29 16:00:29 -07:00
Harald Welte 4fdb3bb723 [NETLINK]: Add properly module refcounting for kernel netlink sockets.
- Remove bogus code for compiling netlink as module
- Add module refcounting support for modules implementing a netlink
  protocol
- Add support for autoloading modules that implement a netlink protocol
  as soon as someone opens a socket for that protocol

Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-08-29 15:35:08 -07:00
David S. Miller 48647feed9 [W1]: Do not use NFLOG netlink number.
Use the reserved by never used NETLINK_SKIP value instead.

Signed-off-by: David S. Miller <davem@davemloft.net>
2005-07-24 19:30:28 -07:00
Evgeniy Polyakov 6adf87bd7b [PATCH] w1: reconnect feature.
I've created reconnect feature - if on start there are no registered families
all new devices will have defailt family, later when driver for appropriate
family is loaded, slaves, which were faound earlier, will still have defult
family instead of right one. Reconnect feature will force control thread to run
through all master devices and all slaves found and search for slaves with
default family id and try to reconnect them.

It does not store newly registered family and does not check only those slaves
which have reg_num.family the same as being registered one - all slaves with
default family are reconnected.

Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-06-21 21:43:12 -07:00
Evgeniy Polyakov 2a9d0c1781 [PATCH] w1: Adds a sysfs entry (w1_master_search) that allows you to disable/enable periodic searches.
Adds a sysfs entry (w1_master_search) that allows you to disable/enable
periodic searches.

Signed-off-by: Ben Gardner <bgardner@wabtec.com>
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-06-21 21:43:11 -07:00
Evgeniy Polyakov be57ce267f [PATCH] w1: Cleans up usage of touch_bit/w1_read_bit/w1_write_bit.
Cleans up usage of touch_bit/w1_read_bit/w1_write_bit.

Signed-off-by: Ben Gardner <bgardner@wabtec.com>
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-06-21 21:43:10 -07:00
Evgeniy Polyakov 7785925dd8 [PATCH] w1: cleanups.
- white space changes.
 - list_for_each_entry/list_for_each_entry_safe and reverse changes.
 - small coding style changes.
 - removed redundant NULL checks.
 - use attribute group and macros instead of direct device attributes.
Patch is havily based on work from Adrian Bunk and Dmitry Torokhov,
thanks guys.

Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-06-21 21:43:09 -07:00
Linus Torvalds 1da177e4c3 Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!
2005-04-16 15:20:36 -07:00