kernel-fxtec-pro1x/Documentation/driver-api
Rafael J. Wysocki 53a895ff19 driver core: Remove device link creation limitation
commit 515db266a9dace92b0cbaed9a6044dd5304b8ca9 upstream.

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: Saravana Kannan <saravanak@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-20 11:55:58 +01:00
..
80211 cfg80211: remove unused function ieee80211_data_from_8023() 2017-09-21 11:42:02 +02:00
dmaengine dmaengine: Fix spelling for parenthesis in dmatest documentation 2018-03-26 10:40:37 -06:00
firmware Documentation: update firmware loader fallback reference 2018-07-07 17:45:25 +02:00
fpga docs: fpga: document fpga manager flags 2018-09-30 08:49:55 -07:00
gpio docs: Fix some broken references 2018-06-15 18:10:01 -03:00
iio docs: driver-api: add iio hw consumer section 2018-01-10 10:30:06 +00:00
pm PM / core: Direct DPM_FLAG_LEAVE_SUSPENDED handling 2018-01-03 00:30:00 +01:00
soundwire Documentation: soundwire: Add more documentation 2018-05-11 21:47:02 +05:30
usb USB: core: Fix bug caused by duplicate interface PM usage counter 2019-05-08 07:21:44 +02:00
basics.rst docs: refcount_t documentation 2017-12-11 14:37:11 -07:00
clk.rst This time we have a good set of changes to the core framework that do some 2018-06-09 12:06:24 -07:00
conf.py doc-rst: make driver-api folder buildable stand-alone 2016-10-26 17:25:00 -06:00
device-io.rst docs: Convert the deviceio template to RST 2017-01-31 17:31:21 -07: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 2020-03-20 11:55:58 +01: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
frame-buffer.rst
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 SCSI misc on 20180610 2018-06-10 13:01:12 -07:00
infrastructure.rst dma-mapping: move all DMA mapping code to kernel/dma 2018-06-14 08:50:37 +02:00
input.rst
libata.rst libata: remove ata_sff_data_xfer_noirq() 2018-07-11 10:45:28 -07: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: nand: correct documentation for NAND_ECC_HW8_512 2018-07-23 09:39:42 -06:00
pci.rst Documentation: fix docs build error after source file removed 2017-12-03 15:11:45 -07:00
pinctl.rst pinctrl/gpio: Unify namespace for cross-calls 2017-09-22 11:02:10 +02:00
rapidio.rst docs-rst: convert rapidio book to ReST 2017-05-16 08:44:16 -03:00
regulator.rst docs: Convert the regulator docbook to RST 2017-01-31 17:31:41 -07:00
s390-drivers.rst s390/docs: reword airq section 2018-02-02 10:47:15 +01:00
scsi.rst scsi: target: add driver-api document 2018-04-20 19:14:40 -04:00
slimbus.rst slimbus: stream: add stream support 2018-07-07 17:25:23 +02:00
sound.rst
spi.rst docs: split up serial-interfaces.rst 2016-09-06 09:14:52 -06:00
target.rst scsi: target: add driver-api document 2018-04-20 19:14:40 -04:00
uio-howto.rst docs: uio-howto.rst: use a code block to solve a warning 2018-05-10 15:42:43 -06: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