1
0
Fork 0
alistair23-linux/Documentation/driver-api
Rafael J. Wysocki 515db266a9 driver core: Remove device link creation limitation
If device_link_add() is called for a consumer/supplier pair with an
existing device link between them and the existing link's type is
not in agreement with the flags passed to that function by its
caller, NULL will be returned.  That is seriously inconvenient,
because it forces the callers of device_link_add() to worry about
what others may or may not do even if that is not relevant to them
for any other reasons.

It turns out, however, that this limitation can be made go away
relatively easily.

The underlying observation is that if DL_FLAG_STATELESS has been
passed to device_link_add() in flags for the given consumer/supplier
pair at least once, calling either device_link_del() or
device_link_remove() to release the link returned by it should work,
but there are no other requirements associated with that flag.  In
turn, if at least one of the callers of device_link_add() for the
given consumer/supplier pair has not passed DL_FLAG_STATELESS to it
in flags, the driver core should track the status of the link and act
on it as appropriate (ie. the link should be treated as "managed").
This means that DL_FLAG_STATELESS needs to be set for managed device
links and it should be valid to call device_link_del() or
device_link_remove() to drop references to them in certain
sutiations.

To allow that to happen, introduce a new (internal) device link flag
called DL_FLAG_MANAGED and make device_link_add() set it automatically
whenever DL_FLAG_STATELESS is not passed to it.  Also make it take
additional references to existing device links that were previously
stateless (that is, with DL_FLAG_STATELESS set and DL_FLAG_MANAGED
unset) and will need to be managed going forward and initialize
their status (which has been DL_STATE_NONE so far).

Accordingly, when a managed device link is dropped automatically
by the driver core, make it clear DL_FLAG_MANAGED, reset the link's
status back to DL_STATE_NONE and drop the reference to it associated
with DL_FLAG_MANAGED instead of just deleting it right away (to
allow it to stay around in case it still needs to be released
explicitly by someone).

With that, since setting DL_FLAG_STATELESS doesn't mean that the
device link in question is not managed any more, replace all of the
status-tracking checks against DL_FLAG_STATELESS with analogous
checks against DL_FLAG_MANAGED and update the documentation to
reflect these changes.

While at it, make device_link_add() reject flags that it does not
recognize, including DL_FLAG_MANAGED.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Saravana Kannan <saravanak@google.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Review-by: Saravana Kannan <saravanak@google.com>
Link: https://lore.kernel.org/r/2305283.AStDPdUUnE@kreacher
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-07-25 13:31:18 +02:00
..
80211 mac80211: call rate_control_send_low() internally 2019-06-14 14:17:37 +02:00
acpi Documentation: ACPI: move scan_handlers.txt to driver-api/acpi and convert to reST 2019-04-25 23:07:19 +02:00
backlight docs: lp855x-driver.rst: add it to the driver-api book 2019-07-15 11:03:02 -03:00
dmaengine Documentation: dmaengine: clean up description of dmatest usage 2019-07-05 12:21:01 +05:30
driver-model This round of clk driver and framework updates is heavy on the driver update 2019-07-17 10:07:48 -07:00
early-userspace docs: add SPDX tags to new index files 2019-07-15 11:03:03 -03:00
firmware docs: Fix a misdirected kerneldoc directive 2019-05-24 14:31:50 -06:00
fpga docs: fpga: document programming fpgas using regions 2018-10-16 11:13:50 +02:00
gpio docs: driver-model: move it to the driver-api book 2019-07-15 11:03:02 -03:00
i3c docs: driver-api: Add I3C documentation 2018-11-12 10:33:49 +01:00
iio docs: Do not seek kerneldoc comments in hw-consumer.h 2019-05-24 14:43:42 -06:00
md docs: add SPDX tags to new index files 2019-07-15 11:03:03 -03:00
mei mei: docs: update mei documentation 2019-06-06 16:51:37 +02:00
memory-devices docs: add SPDX tags to new index files 2019-07-15 11:03:03 -03:00
mmc docs: add SPDX tags to new index files 2019-07-15 11:03:03 -03:00
mtd docs: add SPDX tags to new index files 2019-07-15 11:03:03 -03:00
nfc docs: add SPDX tags to new index files 2019-07-15 11:03:03 -03:00
nvdimm docs: don't use nested tables 2019-07-15 11:03:04 -03:00
pci Documentation: Kill all references to mmiowb() 2019-04-08 12:00:45 +01:00
phy docs: add SPDX tags to new index files 2019-07-15 11:03:03 -03:00
pm docs: power: convert docs to ReST and rename to *.rst 2019-06-14 16:08:36 -05:00
rapidio docs: add SPDX tags to new index files 2019-07-15 11:03:03 -03:00
serial docs: serial: move it to the driver-api 2019-07-15 11:03:03 -03:00
soundwire docs: soundwire: locking: fix tags for a code-block 2019-06-04 20:48:45 +05:30
usb docs: power: convert docs to ReST and rename to *.rst 2019-06-14 16:08:36 -05:00
xilinx docs: driver-api: add xilinx driver API documentation 2019-07-15 11:03:02 -03:00
basics.rst docs: Do not seek comments in kernel/rcu/tree_plugin.h 2019-05-24 14:23:40 -06:00
bt8xxgpio.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
clk.rst docs: clk: fix struct syntax 2019-06-07 11:35:15 -06:00
component.rst drm/doc: document recommended component helper usage 2019-02-19 12:22:24 +01:00
conf.py doc-rst: make driver-api folder buildable stand-alone 2016-10-26 17:25:00 -06:00
connector.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
console.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
dcdbas.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
dell_rbu.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
device-io.rst Documentation: Kill all references to mmiowb() 2019-04-08 12:00:45 +01:00
device_connection.rst Documentation: driver-api: fix device_connection.rst kernel-doc error 2018-04-27 17:17:34 -06:00
device_link.rst driver core: Remove device link creation limitation 2019-07-25 13:31:18 +02:00
dma-buf.rst dma-fence: Polish kernel-doc for dma-fence.c 2018-07-04 12:18:37 +02:00
edac.rst edac.rst: move concepts dictionary from edac.h 2016-12-15 08:58:12 -02:00
edid.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
eisa.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
firewire.rst FireWire: add driver-api Introduction section 2018-09-06 09:41:16 -06:00
frame-buffer.rst
generic-counter.rst counter: fix Documentation build error due to incorrect source file name 2019-05-20 13:18:45 -06:00
hsi.rst docs: split up serial-interfaces.rst 2016-09-06 09:14:52 -06:00
i2c.rst Merge branch 'i2c/for-4.13' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2017-07-12 10:04:56 -07:00
index.rst docs: add a memory-devices subdir to driver-api 2019-07-15 11:03:03 -03:00
infrastructure.rst dma-mapping: move all DMA mapping code to kernel/dma 2018-06-14 08:50:37 +02:00
input.rst
interconnect.rst docs: interconnect.rst: add it to the driver-api guide 2019-07-15 09:20:28 -03:00
ipmb.rst docs: ipmb: place it at driver-api and convert to ReST 2019-06-30 19:33:25 -05:00
isa.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
isapnp.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
libata.rst libata: remove ata_sff_data_xfer_noirq() 2018-07-11 10:45:28 -07:00
lightnvm-pblk.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
men-chameleon-bus.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
message-based.rst docs: Don't format internal MPT docs 2016-09-06 09:15:48 -06:00
misc_devices.rst docs-rst: core_api: move driver-specific stuff to drivers_api 2017-04-02 14:17:43 -06:00
miscellaneous.rst docs: driver-api: Remove trailing blank line 2017-08-07 14:27:45 -06:00
mtdnand.rst mtd: rawnand: Deprecate ->chip_delay 2018-10-03 11:12:25 +02:00
ntb.rst New feature to add support for NTB virtual MSI interrupts, the ability 2019-07-21 09:46:59 -07:00
nvmem.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
parport-lowlevel.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
pinctl.rst pinctrl.txt: Remove outdated information 2019-01-28 10:07:58 +01:00
pps.rst docs: driver-api: add remaining converted dirs to it 2019-07-15 11:03:03 -03:00
pti_intel_mid.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
ptp.rst docs: driver-api: add remaining converted dirs to it 2019-07-15 11:03:03 -03:00
pwm.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
regulator.rst docs: Convert the regulator docbook to RST 2017-01-31 17:31:41 -07:00
rfkill.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
s390-drivers.rst docs: s390: convert docs to ReST and rename to *.rst 2019-06-11 09:48:14 +02:00
scsi.rst scsi: target: add driver-api document 2018-04-20 19:14:40 -04:00
sgi-ioc4.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
slimbus.rst slimbus: stream: add stream support 2018-07-07 17:25:23 +02:00
sm501.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
smsc_ece1099.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
sound.rst
spi.rst docs: split up serial-interfaces.rst 2016-09-06 09:14:52 -06:00
switchtec.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
sync_file.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
target.rst docs: No structured comments in target_core_device.c 2019-05-24 15:01:30 -06:00
uio-howto.rst doc: fix documentation about UIO_MEM_LOGICAL using 2019-06-19 19:31:21 +02:00
vfio-mediated-device.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
vfio.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
vme.rst docs: Update VME documentation to include kerneldoc comments 2017-03-17 15:10:49 +09:00
w1.rst There has been a fair amount of activity in the docs tree this time 2017-07-03 21:13:25 -07:00
xillybus.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
zorro.rst docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00