mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
driver core: Replace dev->of_node_reused with dev_of_node_reused()
In C, bitfields are not necessarily safe to modify from multiple threads without locking. Switch "of_node_reused" over to the "flags" field so modifications are safe. Cc: Johan Hovold <johan@kernel.org> Acked-by: Mark Brown <broonie@kernel.org> Reviewed-by: Rafael J. Wysocki (Intel) <rafael@kernel.org> Reviewed-by: Danilo Krummrich <dakr@kernel.org> Signed-off-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: Johan Hovold <johan@kernel.org> Acked-by: Manivannan Sadhasivam <mani@kernel.org> # PCI_PWRCTRL Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> Link: https://patch.msgid.link/20260406162231.v5.8.I806b8636cd3724f6cd1f5e199318ab8694472d90@changeid Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
parent
3e2c1e213a
commit
4aca5e62f3
|
|
@ -5279,7 +5279,7 @@ void device_set_of_node_from_dev(struct device *dev, const struct device *dev2)
|
|||
{
|
||||
of_node_put(dev->of_node);
|
||||
dev->of_node = of_node_get(dev2->of_node);
|
||||
dev->of_node_reused = true;
|
||||
dev_set_of_node_reused(dev);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(device_set_of_node_from_dev);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ int pinctrl_bind_pins(struct device *dev)
|
|||
{
|
||||
int ret;
|
||||
|
||||
if (dev->of_node_reused)
|
||||
if (dev_of_node_reused(dev))
|
||||
return 0;
|
||||
|
||||
dev->pins = devm_kzalloc(dev, sizeof(*(dev->pins)), GFP_KERNEL);
|
||||
|
|
|
|||
|
|
@ -858,7 +858,7 @@ struct platform_device *platform_device_register_full(const struct platform_devi
|
|||
pdev->dev.parent = pdevinfo->parent;
|
||||
pdev->dev.fwnode = pdevinfo->fwnode;
|
||||
pdev->dev.of_node = of_node_get(to_of_node(pdev->dev.fwnode));
|
||||
pdev->dev.of_node_reused = pdevinfo->of_node_reused;
|
||||
dev_assign_of_node_reused(&pdev->dev, pdevinfo->of_node_reused);
|
||||
|
||||
if (pdevinfo->dma_mask) {
|
||||
pdev->platform_dma_mask = pdevinfo->dma_mask;
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ static int xpcs_plat_init_dev(struct dw_xpcs_plat *pxpcs)
|
|||
* up later. Make sure DD-core is aware of the OF-node being re-used.
|
||||
*/
|
||||
device_set_node(&mdiodev->dev, fwnode_handle_get(dev_fwnode(dev)));
|
||||
mdiodev->dev.of_node_reused = true;
|
||||
dev_set_of_node_reused(&mdiodev->dev);
|
||||
|
||||
/* Pass the data further so the DW XPCS driver core could use it */
|
||||
mdiodev->dev.platform_data = (void *)device_get_match_data(dev);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
const struct of_device_id *of_match_device(const struct of_device_id *matches,
|
||||
const struct device *dev)
|
||||
{
|
||||
if (!matches || !dev->of_node || dev->of_node_reused)
|
||||
if (!matches || !dev->of_node || dev_of_node_reused(dev))
|
||||
return NULL;
|
||||
return of_match_node(matches, dev->of_node);
|
||||
}
|
||||
|
|
@ -192,7 +192,7 @@ ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len)
|
|||
{
|
||||
ssize_t sl;
|
||||
|
||||
if (!dev || !dev->of_node || dev->of_node_reused)
|
||||
if (!dev || !dev->of_node || dev_of_node_reused(dev))
|
||||
return -ENODEV;
|
||||
|
||||
sl = of_modalias(dev->of_node, str, len - 2);
|
||||
|
|
@ -254,7 +254,7 @@ int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *
|
|||
{
|
||||
int sl;
|
||||
|
||||
if ((!dev) || (!dev->of_node) || dev->of_node_reused)
|
||||
if ((!dev) || (!dev->of_node) || dev_of_node_reused(dev))
|
||||
return -ENODEV;
|
||||
|
||||
/* Devicetree modalias is tricky, we add it in 2 steps */
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ int pci_set_of_node(struct pci_dev *dev)
|
|||
struct device *pdev __free(put_device) =
|
||||
bus_find_device_by_of_node(&platform_bus_type, node);
|
||||
if (pdev)
|
||||
dev->bus->dev.of_node_reused = true;
|
||||
dev_set_of_node_reused(&dev->bus->dev);
|
||||
|
||||
device_set_node(&dev->dev, of_fwnode_handle(no_free_ptr(node)));
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ static int pci_pwrctrl_notify(struct notifier_block *nb, unsigned long action,
|
|||
* If we got here then the PCI device is the second after the
|
||||
* power control platform device. Mark its OF node as reused.
|
||||
*/
|
||||
dev->of_node_reused = true;
|
||||
dev_set_of_node_reused(dev);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ static int serial_base_device_init(struct uart_port *port,
|
|||
dev->parent = parent_dev;
|
||||
dev->bus = &serial_base_bus_type;
|
||||
dev->release = release;
|
||||
dev->of_node_reused = true;
|
||||
dev_set_of_node_reused(dev);
|
||||
|
||||
device_set_node(dev, fwnode_handle_get(dev_fwnode(parent_dev)));
|
||||
|
||||
|
|
|
|||
|
|
@ -593,7 +593,7 @@ int ast_vhub_init_dev(struct ast_vhub *vhub, unsigned int idx)
|
|||
d->gadget.max_speed = USB_SPEED_HIGH;
|
||||
d->gadget.speed = USB_SPEED_UNKNOWN;
|
||||
d->gadget.dev.of_node = vhub->pdev->dev.of_node;
|
||||
d->gadget.dev.of_node_reused = true;
|
||||
dev_set_of_node_reused(&d->gadget.dev);
|
||||
|
||||
rc = usb_add_gadget_udc(d->port_dev, &d->gadget);
|
||||
if (rc != 0)
|
||||
|
|
|
|||
|
|
@ -529,6 +529,8 @@ struct device_physical_location {
|
|||
* driver/bus sync_state() callback.
|
||||
* @DEV_FLAG_DMA_COHERENT: This particular device is dma coherent, even if the
|
||||
* architecture supports non-coherent devices.
|
||||
* @DEV_FLAG_OF_NODE_REUSED: Set if the device-tree node is shared with an
|
||||
* ancestor device.
|
||||
* @DEV_FLAG_COUNT: Number of defined struct_device_flags.
|
||||
*/
|
||||
enum struct_device_flags {
|
||||
|
|
@ -539,6 +541,7 @@ enum struct_device_flags {
|
|||
DEV_FLAG_DMA_OPS_BYPASS = 4,
|
||||
DEV_FLAG_STATE_SYNCED = 5,
|
||||
DEV_FLAG_DMA_COHERENT = 6,
|
||||
DEV_FLAG_OF_NODE_REUSED = 7,
|
||||
|
||||
DEV_FLAG_COUNT
|
||||
};
|
||||
|
|
@ -620,8 +623,6 @@ enum struct_device_flags {
|
|||
*
|
||||
* @offline_disabled: If set, the device is permanently online.
|
||||
* @offline: Set after successful invocation of bus type's .offline().
|
||||
* @of_node_reused: Set if the device-tree node is shared with an ancestor
|
||||
* device.
|
||||
* @flags: DEV_FLAG_XXX flags. Use atomic bitfield operations to modify.
|
||||
*
|
||||
* At the lowest level, every device in a Linux system is represented by an
|
||||
|
|
@ -728,7 +729,6 @@ struct device {
|
|||
|
||||
bool offline_disabled:1;
|
||||
bool offline:1;
|
||||
bool of_node_reused:1;
|
||||
|
||||
DECLARE_BITMAP(flags, DEV_FLAG_COUNT);
|
||||
};
|
||||
|
|
@ -762,6 +762,7 @@ __create_dev_flag_accessors(dma_skip_sync, DEV_FLAG_DMA_SKIP_SYNC);
|
|||
__create_dev_flag_accessors(dma_ops_bypass, DEV_FLAG_DMA_OPS_BYPASS);
|
||||
__create_dev_flag_accessors(state_synced, DEV_FLAG_STATE_SYNCED);
|
||||
__create_dev_flag_accessors(dma_coherent, DEV_FLAG_DMA_COHERENT);
|
||||
__create_dev_flag_accessors(of_node_reused, DEV_FLAG_OF_NODE_REUSED);
|
||||
|
||||
#undef __create_dev_flag_accessors
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user