Skip to content

Commit e88728f

Browse files
vivekgautam1rafaeljw
authored andcommitted
driver core: Rename flag AUTOREMOVE to AUTOREMOVE_CONSUMER
Now that we want to add another flag to autoremove the device link on supplier unbind, it's fair to rename the existing flag from DL_FLAG_AUTOREMOVE to DL_FLAG_AUTOREMOVE_CONSUMER so that we can add similar flag for supplier later. And, while we are touching device.h, fix a doc build warning. Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 1e4b044 commit e88728f

7 files changed

Lines changed: 24 additions & 21 deletions

File tree

‎Documentation/driver-api/device_link.rst‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ integration is desired.
8181
Two other flags are specifically targeted at use cases where the device
8282
link is added from the consumer's ``->probe`` callback: ``DL_FLAG_RPM_ACTIVE``
8383
can be specified to runtime resume the supplier upon addition of the
84-
device link. ``DL_FLAG_AUTOREMOVE`` causes the device link to be automatically
85-
purged when the consumer fails to probe or later unbinds. This obviates
86-
the need to explicitly delete the link in the ``->remove`` callback or in
87-
the error path of the ``->probe`` callback.
84+
device link. ``DL_FLAG_AUTOREMOVE_CONSUMER`` causes the device link to be
85+
automatically purged when the consumer fails to probe or later unbinds.
86+
This obviates the need to explicitly delete the link in the ``->remove``
87+
callback or in the error path of the ``->probe`` callback.
8888

8989
Limitations
9090
===========

‎drivers/base/core.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ void device_pm_move_to_tail(struct device *dev)
178178
* of the link. If DL_FLAG_PM_RUNTIME is not set, DL_FLAG_RPM_ACTIVE will be
179179
* ignored.
180180
*
181-
* If the DL_FLAG_AUTOREMOVE is set, the link will be removed automatically
182-
* when the consumer device driver unbinds from it. The combination of both
183-
* DL_FLAG_AUTOREMOVE and DL_FLAG_STATELESS set is invalid and will cause NULL
184-
* to be returned.
181+
* If the DL_FLAG_AUTOREMOVE_CONSUMER is set, the link will be removed
182+
* automatically when the consumer device driver unbinds from it.
183+
* The combination of both DL_FLAG_AUTOREMOVE_CONSUMER and DL_FLAG_STATELESS
184+
* set is invalid and will cause NULL to be returned.
185185
*
186186
* A side effect of the link creation is re-ordering of dpm_list and the
187187
* devices_kset list by moving the consumer device and all devices depending
@@ -198,7 +198,8 @@ struct device_link *device_link_add(struct device *consumer,
198198
struct device_link *link;
199199

200200
if (!consumer || !supplier ||
201-
((flags & DL_FLAG_STATELESS) && (flags & DL_FLAG_AUTOREMOVE)))
201+
((flags & DL_FLAG_STATELESS) &&
202+
(flags & DL_FLAG_AUTOREMOVE_CONSUMER)))
202203
return NULL;
203204

204205
device_links_write_lock();
@@ -479,7 +480,7 @@ static void __device_links_no_driver(struct device *dev)
479480
if (link->flags & DL_FLAG_STATELESS)
480481
continue;
481482

482-
if (link->flags & DL_FLAG_AUTOREMOVE)
483+
if (link->flags & DL_FLAG_AUTOREMOVE_CONSUMER)
483484
kref_put(&link->kref, __device_link_del);
484485
else if (link->status != DL_STATE_SUPPLIER_UNBIND)
485486
WRITE_ONCE(link->status, DL_STATE_AVAILABLE);
@@ -515,7 +516,7 @@ void device_links_driver_cleanup(struct device *dev)
515516
if (link->flags & DL_FLAG_STATELESS)
516517
continue;
517518

518-
WARN_ON(link->flags & DL_FLAG_AUTOREMOVE);
519+
WARN_ON(link->flags & DL_FLAG_AUTOREMOVE_CONSUMER);
519520
WARN_ON(link->status != DL_STATE_SUPPLIER_UNBIND);
520521
WRITE_ONCE(link->status, DL_STATE_DORMANT);
521522
}

‎drivers/gpu/drm/tegra/dc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2312,7 +2312,7 @@ static int tegra_dc_couple(struct tegra_dc *dc)
23122312
* POWER_CONTROL registers during CRTC enabling.
23132313
*/
23142314
if (dc->soc->coupled_pm && dc->pipe == 1) {
2315-
u32 flags = DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE;
2315+
u32 flags = DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE_CONSUMER;
23162316
struct device_link *link;
23172317
struct device *partner;
23182318

‎drivers/gpu/ipu-v3/ipu-pre.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ ipu_pre_lookup_by_phandle(struct device *dev, const char *name, int index)
128128
list_for_each_entry(pre, &ipu_pre_list, list) {
129129
if (pre_node == pre->dev->of_node) {
130130
mutex_unlock(&ipu_pre_list_mutex);
131-
device_link_add(dev, pre->dev, DL_FLAG_AUTOREMOVE);
131+
device_link_add(dev, pre->dev,
132+
DL_FLAG_AUTOREMOVE_CONSUMER);
132133
of_node_put(pre_node);
133134
return pre;
134135
}

‎drivers/gpu/ipu-v3/ipu-prg.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ ipu_prg_lookup_by_phandle(struct device *dev, const char *name, int ipu_id)
100100
list_for_each_entry(prg, &ipu_prg_list, list) {
101101
if (prg_node == prg->dev->of_node) {
102102
mutex_unlock(&ipu_prg_list_mutex);
103-
device_link_add(dev, prg->dev, DL_FLAG_AUTOREMOVE);
103+
device_link_add(dev, prg->dev,
104+
DL_FLAG_AUTOREMOVE_CONSUMER);
104105
prg->id = ipu_id;
105106
of_node_put(prg_node);
106107
return prg;

‎drivers/soc/imx/gpc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static int imx_pgc_power_domain_probe(struct platform_device *pdev)
202202
goto genpd_err;
203203
}
204204

205-
device_link_add(dev, dev->parent, DL_FLAG_AUTOREMOVE);
205+
device_link_add(dev, dev->parent, DL_FLAG_AUTOREMOVE_CONSUMER);
206206

207207
return 0;
208208

‎include/linux/device.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
9090
* @num_vf: Called to find out how many virtual functions a device on this
9191
* bus supports.
9292
* @dma_configure: Called to setup DMA configuration on a device on
93-
this bus.
93+
* this bus.
9494
* @pm: Power management operations of this bus, callback the specific
9595
* device driver's pm-ops.
9696
* @iommu_ops: IOMMU specific operations for this bus, used to attach IOMMU
@@ -784,14 +784,14 @@ enum device_link_state {
784784
* Device link flags.
785785
*
786786
* STATELESS: The core won't track the presence of supplier/consumer drivers.
787-
* AUTOREMOVE: Remove this link automatically on consumer driver unbind.
787+
* AUTOREMOVE_CONSUMER: Remove the link automatically on consumer driver unbind.
788788
* PM_RUNTIME: If set, the runtime PM framework will use this link.
789789
* RPM_ACTIVE: Run pm_runtime_get_sync() on the supplier during link creation.
790790
*/
791-
#define DL_FLAG_STATELESS BIT(0)
792-
#define DL_FLAG_AUTOREMOVE BIT(1)
793-
#define DL_FLAG_PM_RUNTIME BIT(2)
794-
#define DL_FLAG_RPM_ACTIVE BIT(3)
791+
#define DL_FLAG_STATELESS BIT(0)
792+
#define DL_FLAG_AUTOREMOVE_CONSUMER BIT(1)
793+
#define DL_FLAG_PM_RUNTIME BIT(2)
794+
#define DL_FLAG_RPM_ACTIVE BIT(3)
795795

796796
/**
797797
* struct device_link - Device link representation.

0 commit comments

Comments
 (0)