03 Jul, 2018

1 commit


01 Sep, 2017

1 commit


28 Aug, 2017

2 commits


17 Jul, 2017

1 commit

  • 1-Wire bus have very fast algorith for exchange with single slave
    device. Fix incorrect count of slave devices on connect second slave
    device. This case on slave device probe() step we need use generic
    (multislave) functions for read/write device.

    Signed-off-by: Alex A. Mihaylov
    Acked-by: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    Alex A. Mihaylov
     

09 Jun, 2017

1 commit

  • Like other subsystems we should be able to define slave devices outside
    of the w1 directory. To do this we move public facing interface
    definitions to include/linux/w1.h and rename the internal definition
    file to w1_internal.h.

    As w1_family.h and w1_int.h contained almost entirely public
    driver interface definitions we simply removed these files and
    moved the remaining definitions into w1_internal.h.

    With this we can now start to move slave devices out of w1/slaves and
    into the subsystem based on the function they implement, again like
    other drivers.

    Signed-off-by: Andrew F. Davis
    Reviewed-by: Sebastian Reichel
    Acked-by: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    Andrew F. Davis
     

26 May, 2017

1 commit

  • Structures and functions should be ordered such that forward declaration
    use is minimized.

    MODULE_* macros should immediately follow the structures and functions
    upon which they act.

    Remaining MODULE_* macros should be at the end of the file in
    alphabetical order.

    Signed-off-by: Andrew F. Davis
    Acked-by: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    Andrew F. Davis
     

09 Apr, 2017

1 commit

  • The only use of assert() is in matrox_w1.c and is used to check the input
    to probe() from the PCI subsystem for NULL values, these are guaranteed
    to be populated and no other PCI driver makes this check, remove this.

    As this was the only definition in w1_log.h, remove this also.

    Signed-off-by: Andrew F. Davis
    Signed-off-by: Greg Kroah-Hartman

    Andrew F. Davis
     

25 Jan, 2017

2 commits

  • Remove filename from file, this is not done anymore as it doesn't
    add anything and usually is incorrect as filename change often.

    Also shorten the GPL to the more common address-less version and
    remove excess white-space.

    Signed-off-by: Andrew F. Davis
    Signed-off-by: Greg Kroah-Hartman

    Andrew F. Davis
     
  • Near the beginning of w1_attach_slave_device() we increment a w1 master
    reference count.
    Later, when we are going to exit this function without actually attaching
    a slave device (due to failure of __w1_attach_slave_device()) we need to
    decrement this reference count back.

    Signed-off-by: Maciej S. Szmigiero
    Cc: stable@vger.kernel.org
    Fixes: 9fcbbac5ded489 ("w1: process w1 netlink commands in w1_process thread")
    Cc: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    Maciej S. Szmigiero
     

31 Aug, 2016

1 commit


02 May, 2016

1 commit


12 Feb, 2016

1 commit


25 May, 2015

1 commit


27 Nov, 2014

1 commit

  • 1/ change request_module call to zero-pad single digit
    family numbers. This appears to be the intention of
    the code, but not what it actually does.

    This means that the alias created for W1_FAMILY_SMEM_01
    might actually be useful.

    2/ Define a family name for the BQ27000 battery charge monitor.
    Unfortunately this is the same number as W1_FAMILY_SMEM_01
    so if both a compiled on a system, one module might need to
    be blacklisted.

    3/ Add a MODULE_ALIAS for the bq27000.

    Acked-by: Evgeniy Polyakov
    Signed-off-by: NeilBrown
    Signed-off-by: Greg Kroah-Hartman

    NeilBrown
     

20 Jun, 2014

1 commit

  • This patch replaces all calls to the "printk" function within the main "w1"
    directory by calls to the appropriate "pr_*" function thus addressing
    the following warning generated by the checkpatch script:

    WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ...
    then dev_err(dev, ... then pr_err(... to printk(KERN_ERR ...

    Signed-off-by: Fjodor Schelichow
    Signed-off-by: Roman Sommer
    Acked-by: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    Fjodor Schelichow
     

28 May, 2014

1 commit

  • w1_process_callbacks() expects to be called with dev->list_mutex held,
    but it is the fact only in w1_process(). __w1_remove_master_device()
    calls w1_process_callbacks() after it releases list_mutex.

    The patch fixes __w1_remove_master_device() to acquire list_mutex
    for w1_process_callbacks().

    Found by Linux Driver Verification project (linuxtesting.org).

    Signed-off-by: Alexey Khoroshilov
    Acked-by: David Fries
    Acked-by: Evgeniy Polyakov
    Cc: stable # 3.15
    Signed-off-by: Greg Kroah-Hartman

    Alexey Khoroshilov
     

17 Apr, 2014

1 commit

  • __w1_attach_slave_device calls device_add which calls w1_bus_notify
    which calls the w1_bq27000 slave driver, which calls
    platform_device_add and device_add and deadlocks on getting
    &(&priv->bus_notifier)->rwsem as it is still held in the previous
    device_add. This avoids the problem by processing the family
    add/remove outside of the slave device_add call.

    Commit 47eba33a0997fc7362a introduced this deadlock and added
    a KOBJ_ADD, as the add was already reported in device_register two add
    events were being sent. This change suppresses the device_register
    add so that any slave device sysfs entries are setup before the add
    goes out.

    Belisko Marek reported this change fixed the deadlock he was seeing on
    ARM device tree, while testing on my x86-64 system never saw the
    deadlock.

    Reported-by: Belisko Marek
    Signed-off-by: David Fries
    Signed-off-by: Greg Kroah-Hartman

    David Fries
     

16 Feb, 2014

1 commit

  • On 64 bit systems, a large value for "long tmp" is truncated when
    assigning to "int md->max_slave_count" so we still end up with a value
    less than one despite the "tmp < 1" check.

    This is more of a problem for static checkers than a real life issue,
    but it's simple enough to fix.

    Acked-by: David Fries
    Signed-off-by: Dan Carpenter
    Signed-off-by: Greg Kroah-Hartman

    Dan Carpenter
     

08 Feb, 2014

7 commits

  • Switch the code documentation format style to DocBook format, enable
    DocBook documentation generation, and fix some comments.

    Signed-off-by: David Fries
    Acked-by: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    David Fries
     
  • Netlink is a socket interface and is expected to be asynchronous.
    Clients can now make w1 requests without blocking by making use of the
    w1_master thread to process netlink commands which was previously only
    used for doing an automatic bus search.

    Signed-off-by: David Fries
    Acked-by: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    David Fries
     
  • Introduce new commands to add, remove, and list slave devices through
    the netlink interface. This can be useful to skip the search on a
    static network. They could previously only be added or removed
    through automatic search or sysfs, and this allows a program to only
    use netlink.

    Only allocate memory when needed, so move kzalloc into w1_get_slaves
    where it was used.

    Signed-off-by: David Fries
    Acked-by: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    David Fries
     
  • Search will detect at most max_slave_count devices per run, if there
    are more pick up the next search where the previous left off.

    Signed-off-by: David Fries
    Acked-by: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    David Fries
     
  • w1_max_slave_count is only used to abort the search early
    or take a fast search (when 1), so there isn't any reason to not allow
    it to be updated through sysfs. Memory is not allocated based on
    the current value and 10 is a rather low base number, increasing to
    64, and printing a message the first time the count is reached and
    there were more devices to discover to let the user know why not
    all the devices were found.

    Signed-off-by: David Fries
    Acked-by: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    David Fries
     
  • It's valid to set the search count to 0 to stop searching, so don't
    wake up the search thread to not search.

    Signed-off-by: David Fries
    Acked-by: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    David Fries
     
  • Before 63706172f33 "rework kthread_stop()" kthread_should_stop()
    always returned false when called from a non-kthread task, after it
    would oops as a non-kthread didn't have that structure and netlink was
    calling search from a thread which wasn't a kthread. 9d1817cab2f030
    "w1: fix oops when w1_search is called from netlink connector",
    modified the code to avoid calling kthread_stop from a netlink thread.

    Introduce a w1_master flag and bit W1_ABORT_SEARCH to identify abort
    to cleanly support both kthread and netlink search abort. A search
    can take seconds to run, so it is important to abort early if the
    hardware is removed in the middle of a search.

    Signed-off-by: David Fries
    Acked-by: Evgeniy Polyakov
    Cc: Marcin Jurkowski
    Cc: Josh Boyer
    Cc: Sven Geggus
    Signed-off-by: Greg Kroah-Hartman

    David Fries
     

13 Nov, 2013

1 commit

  • On architectures where long is more then 32 bits, modifying a 32-bit field
    with set_bit (and other atomic bit operations) may cause bytes following
    the field to by modified.

    Because the endianness of the bits within a field is the native endianness
    of the CPU[1], on big-endian machines, bit number zero is in the last byte
    of the field.

    Therefore, `set_bit(0, ptr)' on a 64-bit big-endian machine is roughly
    equivalent to `((char *)ptr)[7] |= 1', and since w1 driver uses a 32-bit
    field for holding the flags, this causes bytes beyond the field to be
    modified.

    [1] From Documentation/atomic_ops.txt:

    Native atomic bit operations are defined to operate on objects
    aligned to the size of an "unsigned long" C data type, and are
    least of that size. The endianness of the bits within each
    "unsigned long" are the native endianness of the cpu.

    Signed-off-by: Michal Nazarewicz
    Cc: Evgeniy Polyakov
    Cc: Greg KH
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michal Nazarewicz
     

07 Oct, 2013

2 commits

  • request_module for w1 slave modules needs to be called with the w1
    master mutex unlocked. Because w1_attach_slave_device gets always(?)
    called with mutex locked, we need to temporarily unlock the w1 master
    mutex for the loading of the w1 slave module.

    Signed-off by: Hans-Frieder Vogt
    Acked-by: Evgeniy Polyakov
    Cc: stable # 3.11+

    Signed-off-by: Greg Kroah-Hartman

    Hans-Frieder Vogt
     
  • Introduce a check to make sure that fops are only called if they have
    been defined by the slave module.

    Without this check modules like w1_smem cause a NULL pointer dereference
    bug.

    Signed-off by: Hans-Frieder Vogt
    Acked-by: Evgeniy Polyakov
    Cc: stable # 3.11+

    Signed-off-by: Greg Kroah-Hartman

    Hans-Frieder Vogt
     

12 Sep, 2013

1 commit


23 Aug, 2013

3 commits


04 Jun, 2013

1 commit


13 Mar, 2013

1 commit

  • On Sat, Mar 02, 2013 at 10:45:10AM +0100, Sven Geggus wrote:
    > This is the bad commit I found doing git bisect:
    > 04f482faf50535229a5a5c8d629cf963899f857c is the first bad commit
    > commit 04f482faf50535229a5a5c8d629cf963899f857c
    > Author: Patrick McHardy
    > Date: Mon Mar 28 08:39:36 2011 +0000

    Good job. I was too lazy to bisect for bad commit;)

    Reading the code I found problematic kthread_should_stop call from netlink
    connector which causes the oops. After applying a patch, I've been testing
    owfs+w1 setup for nearly two days and it seems to work very reliable (no
    hangs, no memleaks etc).
    More detailed description and possible fix is given below:

    Function w1_search can be called from either kthread or netlink callback.
    While the former works fine, the latter causes oops due to kthread_should_stop
    invocation.

    This patch adds a check if w1_search is serving netlink command, skipping
    kthread_should_stop invocation if so.

    Signed-off-by: Marcin Jurkowski
    Acked-by: Evgeniy Polyakov
    Cc: Josh Boyer
    Tested-by: Sven Geggus
    Signed-off-by: Greg Kroah-Hartman
    Cc: stable # 3.0+

    Marcin Jurkowski
     

22 Nov, 2012

1 commit


14 Jun, 2012

2 commits

  • The 'mutex' in struct w1_master is use for two very different
    purposes.

    Firstly it protects various data structures such as the list of all
    slaves.

    Secondly it protects the w1 buss against concurrent accesses.

    This can lead to deadlocks when the ->probe code called while adding a
    slave needs to talk on the bus, as is the case for power_supply
    devices.
    ds2780 and ds2781 drivers contain a work around to track which
    process hold the lock simply to avoid this deadlock. bq27000 doesn't
    have that work around and so deadlocks.

    There are other possible deadlocks involving sysfs.
    When removing a device the sysfs s_active lock is held, so the lock
    that protects the slave list must take precedence over s_active.
    However when access power_supply attributes via sysfs, the s_active
    lock must take precedence over the lock that protects accesses to
    the bus.

    So to avoid deadlocks between w1 slaves and sysfs, these must be
    two separate locks. Making them separate means that the work around
    in ds2780 and ds2781 can be removed.

    So this patch:
    - adds a new mutex: "bus_mutex" which serialises access to the bus.
    - takes in mutex in w1_search and ds1wm_search while they access
    the bus for searching. The mutex is dropped before calling the
    callback which adds the slave.
    - changes all slaves to use bus_mutex instead of mutex to
    protect access to the bus
    - removes w1_ds2790_io_nolock and w1_ds2781_io_nolock, and the
    related code from drivers/power/ds278[01]_battery.c which
    calls them.

    Signed-off-by: NeilBrown
    Acked-by: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    NeilBrown
     
  • This reverts commit 59d4467be405316916a4087d5b02d99196eeef04.

    Turns out it was the wrong version, will apply the correct version after
    this.

    Reported-by: NeilBrown
    Cc: Evgeniy Polyakov
    Cc: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

13 Jun, 2012

2 commits

  • There were some return statements around in the w1_uevent, used goto
    to cleanup those return statements with the help of err variable,
    and also removed a semi colon at the end of the w1_uevent's closing
    brace.

    Signed-off-by: Devendra Naga
    Acked-by: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    Devendra Naga
     
  • w1 devices need a mutex to serial IO. Most use master->mutex.
    However that is used for other purposes and they can conflict.

    In particular master->mutex is held while w1_attach_slave_device is
    called.

    For bq27000, this registers a 'powersupply' device which tries to read the
    current status. The attempt to read will cause a deadlock on
    master->mutex.

    So create a new per-slave mutex and use that for serializing IO for
    bq27000.

    Signed-off-by: NeilBrown
    Cc: Evgeniy Polyakov
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    NeilBrown