24 Jun, 2014

1 commit

  • commit 94859308a21b "w1: new w1_ds2406 driver" added a new driver
    that uses the crc16 library, but didn't ensure that the core is
    there. This adds the necessary Kconfig statements, just like we
    have it for other w1 drivers.

    Reported-by: kbuild test robot
    Signed-off-by: Arnd Bergmann
    Acked-by: Scott Alfter
    Cc: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     

20 Jun, 2014

9 commits

  • This patch replaces all calls to the "printk" function within the "masters"
    subdirectory 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
     
  • 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
     
  • This patch replaces all calls to the "printk" function within the "slaves"
    subdirectory 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
     
  • Some preliminary work at making use of this driver led me to implement
    CRC-16 checks on read and write to deal with the occasional glitchiness of
    the 1-Wire bus. The revised driver (attached) returns an I/O error if the
    CRC check fails. When reading the chip's state, either you get a valid
    indication or you get an I/O error. When changing its state, either the
    change is successful or an I/O error is returned.

    Signed-off-by: Scott Alfter
    Acked-by: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    Scott Alfter
     
  • Replace spaces at beginning of the string with tabs, and replace foo * bar with foo *bar in a pointer declaration.

    Signed-off-by: Thomas Wood
    Acked-by: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    Thomas Wood
     
  • According to the i.MX reference manual, the read/write bit operations
    takes from 60 us to 120 us.
    This patch optimizes mxc_w1_ds2_touch_bit() function to use proper
    value for such delay. Nevertheless, a small margin for the timeout has
    been added for the case if clock frequency is inaccurate.

    Signed-off-by: Alexander Shiyan
    Signed-off-by: Greg Kroah-Hartman

    Alexander Shiyan
     
  • This patch adds a software reset for 1-Wire module at driver startup.

    Signed-off-by: Alexander Shiyan
    Signed-off-by: Greg Kroah-Hartman

    Alexander Shiyan
     
  • According to the i.MX reference manual, the reset procedure and
    "presence" pulse takes 511 and 512 us, respectively. Measurement for
    i.MX27 is about 1100 us. There is no need to wait Reset+Presence
    more than this time.
    This patch optimizes mxc_w1_ds2_reset_bus() function to use proper
    value for delay after w1 bus reset. Nevertheless, a small margin for
    the timeout has been added for the case if clock frequency is inaccurate.

    Signed-off-by: Alexander Shiyan
    Signed-off-by: Greg Kroah-Hartman

    Alexander Shiyan
     
  • W1 reset_bus() should return zero if slave device is present.
    This patch fix this issue.

    Signed-off-by: Alexander Shiyan
    Signed-off-by: Greg Kroah-Hartman

    Alexander Shiyan
     

04 Jun, 2014

1 commit

  • …el/git/tip/tip into next

    Pull core locking updates from Ingo Molnar:
    "The main changes in this cycle were:

    - reduced/streamlined smp_mb__*() interface that allows more usecases
    and makes the existing ones less buggy, especially in rarer
    architectures

    - add rwsem implementation comments

    - bump up lockdep limits"

    * 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (33 commits)
    rwsem: Add comments to explain the meaning of the rwsem's count field
    lockdep: Increase static allocations
    arch: Mass conversion of smp_mb__*()
    arch,doc: Convert smp_mb__*()
    arch,xtensa: Convert smp_mb__*()
    arch,x86: Convert smp_mb__*()
    arch,tile: Convert smp_mb__*()
    arch,sparc: Convert smp_mb__*()
    arch,sh: Convert smp_mb__*()
    arch,score: Convert smp_mb__*()
    arch,s390: Convert smp_mb__*()
    arch,powerpc: Convert smp_mb__*()
    arch,parisc: Convert smp_mb__*()
    arch,openrisc: Convert smp_mb__*()
    arch,mn10300: Convert smp_mb__*()
    arch,mips: Convert smp_mb__*()
    arch,metag: Convert smp_mb__*()
    arch,m68k: Convert smp_mb__*()
    arch,m32r: Convert smp_mb__*()
    arch,ia64: Convert smp_mb__*()
    ...

    Linus Torvalds
     

28 May, 2014

2 commits

  • 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
     
  • Applications can submit a set of commands in one packet to the kernel,
    and in some cases it is required such as reading the temperature
    sensor results. This adds an option W1_CN_BUNDLE to the flags of
    cn_msg to request the kernel to reply in one packet for efficiency.

    The cn_msg flags now check for unknown flag values and return an error
    if one is seen. See "Proper handling of unknown flags in system
    calls" http://lwn.net/Articles/588444/

    This corrects the ack values returned as per the protocol standard,
    namely the original ack for status messages and seq + 1 for all others
    such as the data returned from a read.

    Some of the common variable names have been standardized as follows.
    struct cn_msg *cn
    struct w1_netlink_msg *msg
    struct w1_netlink_cmd *cmd
    struct w1_master *dev

    When an argument and a function scope variable would collide, add req_
    to the argument.

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

    David Fries
     

18 Apr, 2014

1 commit

  • Mostly scripted conversion of the smp_mb__* barriers.

    Signed-off-by: Peter Zijlstra
    Acked-by: Paul E. McKenney
    Link: http://lkml.kernel.org/n/tip-55dhyhocezdw1dg7u19hmh1u@git.kernel.org
    Cc: Linus Torvalds
    Cc: linux-arch@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

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

1 commit