17 Apr, 2014

2 commits

  • __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
     
  • If the message type is W1_MASTER_CMD or W1_SLAVE_CMD, then a reference
    is taken when searching for the slave or master device. If there
    isn't any following data m->len (mlen is a copy) is 0 and packing up
    the message for later execution is skipped leaving nothing to
    decrement the reference counts.

    Way back when, m->len was checked before the search that increments the
    reference count, but W1_LIST_MASTERS has no additional data, the check
    was moved in 9be62e0b2fadaf5ff causing this bug.

    This change reorders to put the check before the reference count is
    incremented avoiding the problem.

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

    David Fries
     

01 Mar, 2014

4 commits


16 Feb, 2014

2 commits

  • of_get_gpio() might return -EPROBE_DEFER meaning that the driver
    providing the gpio isn't ready yet. If that happens for the first gpio
    the resulting kernel output without this patch is:

    w1-gpio somename: Failed to parse DT
    platform somename: Driver w1-gpio requests probe deferral

    The first message is misleading and so is suppressed with this patch.

    Further if determining the gpio to switch the external pullup yields
    -EPROBE_DEFER this error should be passed back to the caller instead of
    just continuing without pullup.

    Signed-off-by: Uwe Kleine-König
    Signed-off-by: Greg Kroah-Hartman

    Uwe Kleine-König
     
  • 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
     

09 Feb, 2014

1 commit

  • This reverts ds1wm.c from commit d3a8a9dbb903c73a7ec2deae4c9b7d74b6834f4c.
    Of the three files changed ds1wm.c ds2490.c and w1_netlink.c, it turns out
    ds1wm.c was locking bus_mutex, but inside the loop and I missed it.
    Reverting ds1wm.c to the previous version.

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

    David Fries
     

08 Feb, 2014

15 commits

  • The bus_mutex needs to be taken to serialize access to a specific bus.
    netlink wasn't updated when bus_mutex was added and was calling
    without that lock held, and not all of the masters were holding the
    bus_mutex in a search. This was causing the ds2490 hardware to stop
    responding when both netlink and /sys slaves were executing bus
    commands at the same time.

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

    David Fries
     
  • 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
     
  • The first line printed from w1_slave gives the context of the w1
    device. So does the second line, but if the CRC check failed, the
    second line contains the last successful result. It is confusing when
    it prints the temperature next to the line that might be a previous
    conversion and has nothing to do with that printed temperature value.
    Modify the code to store the last good conversion in family_data,
    which is designed for custom data structures.

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

    David Fries
     
  • The hardware search was failing without the COMM_RST flag. Enabled
    the flag and rewrote the function to handle more than one buffer of
    results and to continuing where the search left off. Remove hardware
    search note from the limitations now that it works. The "w1: ds2490
    USB setup fixes" change went from 23.16 seconds to about 3 seconds,
    this takes the time for the search down to .307346 seconds.

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

    David Fries
     
  • Calling usb_reset_configuration after usb_set_interface resets the
    interface that was just selected, so call reset first.
    Using alternative 3 greatly speeds the one wire search.
    alt 0 or 1, 10ms int, 23.16 seconds
    alt 2 or 3, 1ms int, 2.99 to 3.05 seconds

    Use usb_interrupt_msg not usb_bulk_msg as it is an interrupt pipe
    (bulk worked, it was just technically the wrong call).

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

    David Fries
     
  • Use a #define for the usb vendor request type, clear the status
    byte and use that instead of a magic offset in checking if idle.

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

    David Fries
     
  • Unicast one wire replies back to the sender portid to avoid multiple
    programs getting each other's messages, especially as the response
    can't be uniquely identified with the sequence coming from the
    requesting program when both programs generate the same id. Continue
    to broadcast events such as add/remove master/slave devices.

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

    David Fries
     
  • This allows replying only to the requestor portid while still
    supporting broadcasting. Pass 0 to portid for the previous behavior.

    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
     
  • Previous logic,
    if (avail > 8) {
    store slave;
    return;
    }
    send data; clear;

    The logic error is, if there isn't space send the buffer and clear,
    but the slave wasn't added to the now empty buffer loosing that slave
    id. It also should have been "if (avail >= 8)" because when it is 8,
    there is space.

    Instead, if there isn't space send and clear the buffer, then there is
    always space for the slave id.

    Signed-off-by: David Fries
    Cc: stable@vger.kernel.org
    Acked-by: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    David Fries
     

24 Jan, 2014

1 commit


09 Dec, 2013

3 commits


15 Nov, 2013

1 commit

  • Use the wrapper function for retrieving the platform data instead of
    accessing dev->platform_data directly. This is a cosmetic change to make
    the code simpler and enhance the readability.

    Signed-off-by: Jingoo Han
    Acked-by: Evgeniy Polyakov
    Cc: Greg KH
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jingoo Han
     

13 Nov, 2013

2 commits

  • 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
     
  • Use the wrapper function for retrieving the platform data instead of
    accessing dev->platform_data directly. This is a cosmetic change to make
    the code simpler and enhance the readability.

    Signed-off-by: Jingoo Han
    Acked-by: Evgeniy Polyakov
    Cc: Greg KH
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jingoo Han
     

30 Oct, 2013

2 commits


20 Oct, 2013

1 commit


17 Oct, 2013

2 commits


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
     

13 Sep, 2013

1 commit


12 Sep, 2013

1 commit