Age | Commit message (Collapse) | Author | Files | Lines |
|
The only usage of these structs is to assign their address to the fops
field in the w1_family struct, which is a const pointer. Make them const
to allow the compiler to put them in read-only memory.
This was done with the following Coccinelle semantic patch
(http://coccinelle.lip6.fr/):
// <smpl>
@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct w1_family_ops i@p = {...};
@ok1@
identifier r1.i;
position p;
identifier s;
@@
static struct w1_family s = {
.fops=&i@p,
};
@bad1@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p
@depends on !bad1 disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct w1_family_ops i={};
// </smpl>
Signed-off-by: Rikard Falkeborn <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
The fops field in the w1_family struct is never modified. Make it const
to indicate that. Constifying the pointer makes it possible for drivers
to declare static w1_family_ops structs const, which in turn will allow
the compiler to put it in read-only memory.
Reviewed-by: Sebastian Reichel <[email protected]>
Signed-off-by: Rikard Falkeborn <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
Based on 3 normalized pattern(s):
this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version this program is distributed in the
hope that it will be useful but without any warranty without even
the implied warranty of merchantability or fitness for a particular
purpose see the gnu general public license for more details
this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version [author] [kishon] [vijay] [abraham]
[i] [kishon]@[ti] [com] this program is distributed in the hope that
it will be useful but without any warranty without even the implied
warranty of merchantability or fitness for a particular purpose see
the gnu general public license for more details
this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version [author] [graeme] [gregory]
[gg]@[slimlogic] [co] [uk] [author] [kishon] [vijay] [abraham] [i]
[kishon]@[ti] [com] [based] [on] [twl6030]_[usb] [c] [author] [hema]
[hk] [hemahk]@[ti] [com] this program is distributed in the hope
that it will be useful but without any warranty without even the
implied warranty of merchantability or fitness for a particular
purpose see the gnu general public license for more details
extracted by the scancode license scanner the SPDX license identifier
GPL-2.0-or-later
has been chosen to replace the boilerplate/reference in 1105 file(s).
Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Allison Randal <[email protected]>
Reviewed-by: Richard Fontana <[email protected]>
Reviewed-by: Kate Stewart <[email protected]>
Cc: [email protected]
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
Once a new slave device is detected, match it against all sub-nodes of the
master bus controller. If a match is found, set the slave device's of_node
pointer.
Signed-off-by: Daniel Mack <[email protected]>
Signed-off-by: Sebastian Reichel <[email protected]>
|
|
1wire family module autoload fails because of upper/lower
case mismatch.
Signed-off-by: Ingo Flaschberger <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Cc: stable <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
If device_register() returned an error! Always use put_device()
to give up the reference initialized in device_register().
Signed-off-by: Arvind Yadav <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
This patch has changes to w1.h/w1.c generic files to add (optional) hwmon
support structures.
Signed-off-by: Jaghathiswari Rankappagounder Natarajan <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Acked-by: Guenter Roeck <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
Add a one wire driver for the DS28E05 one wire slave chip. This chip
requires OverDrive support to talk to it.
Signed-off-by: Andrew Worsley <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
attribute_group are not supposed to change at runtime. All functions
working with attribute_group provided by <linux/sysfs.h> work with
const attribute_group. So mark the non-const structs as const.
Signed-off-by: Arvind Yadav <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Reviewed-by: Sebastian Reichel <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Cc: [email protected]
Fixes: 9fcbbac5ded489 ("w1: process w1 netlink commands in w1_process thread")
Cc: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
Fix 'timeout_us' parameter description.
Signed-off-by: Wei Yongjun <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
If kstrtoint() returns -ERANGE then "tmp" is uninitialized.
Signed-off-by: Dan Carpenter <[email protected]>
Acked-by: Evgeniy Polaykov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
w1_process() calls try_to_freeze(), but the thread doesn't mark itself
freezable through set_freezable(), so the try_to_freeze() call is useless.
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
Some of 1-Wire devices commonly associated with physical access control
systems are attached/generate presence for as short as 100 ms - hence
the tens-to-hundreds milliseconds scan intervals are required.
Signed-off-by: Dmitry Khromov <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Signed-off-by: NeilBrown <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Signed-off-by: Roman Sommer <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Acked-by: David Fries <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Cc: stable <[email protected]> # 3.15
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
__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 <[email protected]>
Signed-off-by: David Fries <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
Switch the code documentation format style to DocBook format, enable
DocBook documentation generation, and fix some comments.
Signed-off-by: David Fries <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Cc: Marcin Jurkowski <[email protected]>
Cc: Josh Boyer <[email protected]>
Cc: Sven Geggus <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Cc: Evgeniy Polyakov <[email protected]>
Cc: Greg KH <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
|
|
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 <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Cc: stable <[email protected]> # 3.11+
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Cc: stable <[email protected]> # 3.11+
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
The usage of strict_strtol() is not preferred, because strict_strtol() is
obsolete. Thus, kstrtol() should be used.
Signed-off-by: Jingoo Han <[email protected]>
Cc: Evgeniy Polyakov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
|
|
This lets w1 slave drivers declare an attribute group, and not have to
create/destroy sysfs files directly. All w1 slave drivers will be fixed
to use this field up in follow-on patches to this one.
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
As we have 2 sysfs files for the w1 slave devices, let the driver core
create / destroy them automatically by setting the default attribute
group for them, saving code and housekeeping logic.
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
W1 slave sysfs files are created _after_ userspace is notified that the
device has been added to the system. Fix that race by moving the
creation/remove of the files to the bus notifier that is there for doing
this type of thing.
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
This patch allows the 1-wire bus to autoload the corresponding module
for each slave being attached.
This works similar to bluetooth protocols.
Signed-off-by: Alexander Stein <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
> 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 <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Cc: Josh Boyer <[email protected]>
Tested-by: Sven Geggus <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Cc: stable <[email protected]> # 3.0+
|
|
Remove conditional code based on CONFIG_HOTPLUG being false. It's
always on now in preparation of it going away as an option.
Signed-off-by: Bill Pemberton <[email protected]>
Cc: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
This reverts commit 59d4467be405316916a4087d5b02d99196eeef04.
Turns out it was the wrong version, will apply the correct version after
this.
Reported-by: NeilBrown <[email protected]>
Cc: Evgeniy Polyakov <[email protected]>
Cc: Andrew Morton <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
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 <[email protected]>
Cc: Evgeniy Polyakov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
W1 core prints "Failed to register master driver" if error happens
on registering SLAVE driver. Fix it.
Signed-off-by: Dmitry Artamonow <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
This enables a much more efficient way of device searching. It uses the
1-wire read-rom operation which allows the direct reading of the slave
address. BUT this works only with exactly one slave on the bus.
Signed-off-by: Hubert Feurstein <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
index c374978..9761950 100644
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
|
Signed-off-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
|
|
This allows us to move duplicated code in <asm/atomic.h>
(atomic_inc_not_zero() for now) to <linux/atomic.h>
Signed-off-by: Arun Sharma <[email protected]>
Reviewed-by: Eric Dumazet <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: David Miller <[email protected]>
Cc: Eric Dumazet <[email protected]>
Acked-by: Mike Frysinger <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
|
|
Reorganize so the netlink connector one wire search command will update
the kernel list of detected slave devices. Otherwise, a newly detected
device is unusable because unless it's in the kernel list of known devices
any commands will result in ENODEV status.
Signed-off-by: David Fries <[email protected]>
Cc: Evgeniy Polyakov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
|