Skip to content

Commit

Permalink
dm: treewide: Rename auto_alloc_size members to be shorter
Browse files Browse the repository at this point in the history
This construct is quite long-winded. In earlier days it made some sense
since auto-allocation was a strange concept. But with driver model now
used pretty universally, we can shorten this to 'auto'. This reduces
verbosity and makes it easier to read.

Coincidentally it also ensures that every declaration is on one line,
thus making dtoc's job easier.

Signed-off-by: Simon Glass <[email protected]>
  • Loading branch information
sjg20 committed Dec 13, 2020
1 parent 78128d5 commit 41575d8
Show file tree
Hide file tree
Showing 956 changed files with 1,365 additions and 1,369 deletions.
2 changes: 1 addition & 1 deletion arch/arm/mach-ipq40xx/clock-ipq4019.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ U_BOOT_DRIVER(clk_msm) = {
.id = UCLASS_CLK,
.of_match = msm_clk_ids,
.ops = &msm_clk_ops,
.priv_auto_alloc_size = sizeof(struct msm_clk_priv),
.priv_auto = sizeof(struct msm_clk_priv),
.probe = msm_clk_probe,
};
2 changes: 1 addition & 1 deletion arch/arm/mach-ipq40xx/pinctrl-snapdragon.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ U_BOOT_DRIVER(pinctrl_snapdraon) = {
.name = "pinctrl_msm",
.id = UCLASS_PINCTRL,
.of_match = msm_pinctrl_ids,
.priv_auto_alloc_size = sizeof(struct msm_pinctrl_priv),
.priv_auto = sizeof(struct msm_pinctrl_priv),
.ops = &msm_pinctrl_ops,
.probe = msm_pinctrl_probe,
};
2 changes: 1 addition & 1 deletion arch/arm/mach-snapdragon/clock-snapdragon.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,6 @@ U_BOOT_DRIVER(clk_msm) = {
.id = UCLASS_CLK,
.of_match = msm_clk_ids,
.ops = &msm_clk_ops,
.priv_auto_alloc_size = sizeof(struct msm_clk_priv),
.priv_auto = sizeof(struct msm_clk_priv),
.probe = msm_clk_probe,
};
2 changes: 1 addition & 1 deletion arch/arm/mach-snapdragon/pinctrl-snapdragon.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ U_BOOT_DRIVER(pinctrl_snapdraon) = {
.name = "pinctrl_msm",
.id = UCLASS_PINCTRL,
.of_match = msm_pinctrl_ids,
.priv_auto_alloc_size = sizeof(struct msm_pinctrl_priv),
.priv_auto = sizeof(struct msm_pinctrl_priv),
.ops = &msm_pinctrl_ops,
.probe = msm_pinctrl_probe,
};
2 changes: 1 addition & 1 deletion arch/arm/mach-stm32mp/bsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ U_BOOT_DRIVER(stm32mp_bsec) = {
.id = UCLASS_MISC,
.of_match = stm32mp_bsec_ids,
.ofdata_to_platdata = stm32mp_bsec_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct stm32mp_bsec_platdata),
.platdata_auto = sizeof(struct stm32mp_bsec_platdata),
.ops = &stm32mp_bsec_ops,
.probe = stm32mp_bsec_probe,
};
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-stm32mp/pwr_regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ U_BOOT_DRIVER(stm32mp_pwr_pmic) = {
.bind = stm32mp_pwr_bind,
.ops = &stm32mp_pwr_ops,
.ofdata_to_platdata = stm32mp_pwr_ofdata_to_platdata,
.priv_auto_alloc_size = sizeof(struct stm32mp_pwr_priv),
.priv_auto = sizeof(struct stm32mp_pwr_priv),
};

static const struct stm32mp_pwr_reg_info stm32mp_pwr_reg11 = {
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/cpu/acpi_gpe.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,5 @@ U_BOOT_DRIVER(acpi_gpe_drv) = {
.of_match = acpi_gpe_ids,
.ops = &acpi_gpe_ops,
.ofdata_to_platdata = acpi_gpe_ofdata_to_platdata,
.priv_auto_alloc_size = sizeof(struct acpi_gpe_priv),
.priv_auto = sizeof(struct acpi_gpe_priv),
};
2 changes: 1 addition & 1 deletion arch/x86/cpu/apollolake/hostbridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ U_BOOT_DRIVER(intel_apl_hostbridge) = {
.ofdata_to_platdata = apl_hostbridge_ofdata_to_platdata,
.probe = apl_hostbridge_probe,
.remove = apl_hostbridge_remove,
.platdata_auto_alloc_size = sizeof(struct apl_hostbridge_platdata),
.platdata_auto = sizeof(struct apl_hostbridge_platdata),
ACPI_OPS_PTR(&apl_hostbridge_acpi_ops)
.flags = DM_FLAG_OS_PREPARE,
};
2 changes: 1 addition & 1 deletion arch/x86/cpu/apollolake/pmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,5 @@ U_BOOT_DRIVER(intel_apl_pmc) = {
.ofdata_to_platdata = apl_pmc_ofdata_to_uc_platdata,
.probe = apl_pmc_probe,
.ops = &apl_pmc_ops,
.platdata_auto_alloc_size = sizeof(struct apl_pmc_platdata),
.platdata_auto = sizeof(struct apl_pmc_platdata),
};
2 changes: 1 addition & 1 deletion arch/x86/cpu/apollolake/spl.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ U_BOOT_DRIVER(winbond_w25q128fw) = {
.of_match = apl_flash_ids,
.bind = apl_flash_bind,
.probe = apl_flash_probe,
.priv_auto_alloc_size = sizeof(struct spi_flash),
.priv_auto = sizeof(struct spi_flash),
.ops = &apl_flash_ops,
};

Expand Down
4 changes: 2 additions & 2 deletions arch/x86/cpu/apollolake/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ U_BOOT_DRIVER(intel_apl_ns16550) = {
.name = "intel_apl_ns16550",
.id = UCLASS_SERIAL,
.of_match = apl_ns16550_serial_ids,
.platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
.priv_auto_alloc_size = sizeof(struct NS16550),
.platdata_auto = sizeof(struct ns16550_platdata),
.priv_auto = sizeof(struct NS16550),
.ops = &ns16550_serial_ops,
.ofdata_to_platdata = apl_ns16550_ofdata_to_platdata,
.probe = apl_ns16550_probe,
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/cpu/broadwell/cpu_full.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,6 @@ U_BOOT_DRIVER(cpu_x86_broadwell_drv) = {
.bind = cpu_x86_bind,
.probe = cpu_x86_broadwell_probe,
.ops = &cpu_x86_broadwell_ops,
.priv_auto_alloc_size = sizeof(struct cpu_broadwell_priv),
.priv_auto = sizeof(struct cpu_broadwell_priv),
.flags = DM_FLAG_PRE_RELOC,
};
2 changes: 1 addition & 1 deletion arch/x86/cpu/broadwell/sata.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,5 @@ U_BOOT_DRIVER(ahci_broadwell_drv) = {
.of_match = broadwell_ahci_ids,
.ofdata_to_platdata = broadwell_sata_ofdata_to_platdata,
.probe = broadwell_sata_probe,
.platdata_auto_alloc_size = sizeof(struct sata_platdata),
.platdata_auto = sizeof(struct sata_platdata),
};
4 changes: 2 additions & 2 deletions arch/x86/cpu/intel_common/itss.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,6 @@ U_BOOT_DRIVER(intel_itss) = {
.ops = &itss_ops,
.bind = itss_bind,
.ofdata_to_platdata = itss_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct itss_platdata),
.priv_auto_alloc_size = sizeof(struct itss_priv),
.platdata_auto = sizeof(struct itss_platdata),
.priv_auto = sizeof(struct itss_priv),
};
4 changes: 2 additions & 2 deletions arch/x86/cpu/intel_common/p2sb.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ U_BOOT_DRIVER(intel_p2sb) = {
.remove = p2sb_remove,
.ops = &p2sb_ops,
.ofdata_to_platdata = p2sb_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct p2sb_platdata),
.per_child_platdata_auto_alloc_size =
.platdata_auto = sizeof(struct p2sb_platdata),
.per_child_platdata_auto =
sizeof(struct p2sb_child_platdata),
.child_post_bind = p2sb_child_post_bind,
.flags = DM_FLAG_OS_PREPARE,
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/cpu/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,5 +362,5 @@ U_BOOT_DRIVER(irq_router_drv) = {
.id = UCLASS_IRQ,
.of_match = irq_router_ids,
.probe = irq_router_probe,
.priv_auto_alloc_size = sizeof(struct irq_router),
.priv_auto = sizeof(struct irq_router),
};
4 changes: 2 additions & 2 deletions arch/x86/cpu/slimbootloader/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ U_BOOT_DRIVER(serial_slimbootloader) = {
.id = UCLASS_SERIAL,
.of_match = slimbootloader_serial_ids,
.ofdata_to_platdata = slimbootloader_serial_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
.priv_auto_alloc_size = sizeof(struct NS16550),
.platdata_auto = sizeof(struct ns16550_platdata),
.priv_auto = sizeof(struct NS16550),
.probe = ns16550_serial_probe,
.ops = &ns16550_serial_ops,
};
2 changes: 1 addition & 1 deletion arch/x86/cpu/tangier/pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,5 @@ U_BOOT_DRIVER(tangier_pinctrl) = {
.id = UCLASS_SYSCON,
.of_match = tangier_pinctrl_match,
.probe = tangier_pinctrl_probe,
.priv_auto_alloc_size = sizeof(struct mrfld_pinctrl),
.priv_auto = sizeof(struct mrfld_pinctrl),
};
2 changes: 1 addition & 1 deletion arch/x86/lib/pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,5 @@ U_BOOT_DRIVER(intel_mid_pmu) = {
.id = UCLASS_SYSCON,
.of_match = pmu_mid_match,
.probe = pmu_mid_probe,
.priv_auto_alloc_size = sizeof(struct pmu_mid),
.priv_auto = sizeof(struct pmu_mid),
};
2 changes: 1 addition & 1 deletion arch/x86/lib/scu.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,5 @@ U_BOOT_DRIVER(scu_ipc) = {
.id = UCLASS_SYSCON,
.of_match = scu_ipc_match,
.probe = scu_ipc_probe,
.priv_auto_alloc_size = sizeof(struct scu),
.priv_auto = sizeof(struct scu),
};
2 changes: 1 addition & 1 deletion board/renesas/ulcb/cpld.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,5 @@ U_BOOT_DRIVER(sysreset_renesas_ulcb) = {
.ops = &renesas_ulcb_sysreset,
.probe = renesas_ulcb_sysreset_probe,
.of_match = renesas_ulcb_sysreset_ids,
.priv_auto_alloc_size = sizeof(struct renesas_ulcb_sysreset_priv),
.priv_auto = sizeof(struct renesas_ulcb_sysreset_priv),
};
6 changes: 3 additions & 3 deletions common/usb_hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -958,9 +958,9 @@ UCLASS_DRIVER(usb_hub) = {
.post_bind = dm_scan_fdt_dev,
.post_probe = usb_hub_post_probe,
.child_pre_probe = usb_child_pre_probe,
.per_child_auto_alloc_size = sizeof(struct usb_device),
.per_child_platdata_auto_alloc_size = sizeof(struct usb_dev_platdata),
.per_device_auto_alloc_size = sizeof(struct usb_hub_device),
.per_child_auto = sizeof(struct usb_device),
.per_child_platdata_auto = sizeof(struct usb_dev_platdata),
.per_device_auto = sizeof(struct usb_hub_device),
};

static const struct usb_device_id hub_id_table[] = {
Expand Down
2 changes: 1 addition & 1 deletion common/usb_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ U_BOOT_DRIVER(usb_mass_storage) = {
.of_match = usb_mass_storage_ids,
.probe = usb_mass_storage_probe,
#if CONFIG_IS_ENABLED(BLK)
.platdata_auto_alloc_size = sizeof(struct us_data),
.platdata_auto = sizeof(struct us_data),
#endif
};

Expand Down
26 changes: 13 additions & 13 deletions doc/driver-model/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,10 @@ The easiest way to make this work it to add a few members to the driver:

.. code-block:: c
.platdata_auto_alloc_size = sizeof(struct dm_test_pdata),
.platdata_auto = sizeof(struct dm_test_pdata),
.ofdata_to_platdata = testfdt_ofdata_to_platdata,
The 'auto_alloc' feature allowed space for the platdata to be allocated
The 'auto' feature allowed space for the platdata to be allocated
and zeroed before the driver's ofdata_to_platdata() method is called. The
ofdata_to_platdata() method, which the driver write supplies, should parse
the device tree node for this device and place it in dev->platdata. Thus
Expand All @@ -464,7 +464,7 @@ probe method it will be called next. See Driver Lifecycle below for more
details.

If you don't want to have the platdata automatically allocated then you
can leave out platdata_auto_alloc_size. In this case you can use malloc
can leave out platdata_auto. In this case you can use malloc
in your ofdata_to_platdata (or probe) method to allocate the required memory,
and you should free it in the remove method.

Expand Down Expand Up @@ -589,7 +589,7 @@ as the bus speed for each device.

To achieve this, the bus device can use dev->parent_platdata in each of its
three children. This can be auto-allocated if the bus driver (or bus uclass)
has a non-zero value for per_child_platdata_auto_alloc_size. If not, then
has a non-zero value for per_child_platdata_auto. If not, then
the bus device or uclass can allocate the space itself before the child
device is probed.

Expand Down Expand Up @@ -695,24 +695,24 @@ platdata. A parent's ofdata is always read before a child.

The steps are:

1. If priv_auto_alloc_size is non-zero, then the device-private space
1. If priv_auto is non-zero, then the device-private space
is allocated for the device and zeroed. It will be accessible as
dev->priv. The driver can put anything it likes in there, but should use
it for run-time information, not platform data (which should be static
and known before the device is probed).

2. If platdata_auto_alloc_size is non-zero, then the platform data space
2. If platdata_auto is non-zero, then the platform data space
is allocated. This is only useful for device tree operation, since
otherwise you would have to specific the platform data in the
U_BOOT_DEVICE() declaration. The space is allocated for the device and
zeroed. It will be accessible as dev->platdata.

3. If the device's uclass specifies a non-zero per_device_auto_alloc_size,
3. If the device's uclass specifies a non-zero per_device_auto,
then this space is allocated and zeroed also. It is allocated for and
stored in the device, but it is uclass data. owned by the uclass driver.
It is possible for the device to access it.

4. If the device's immediate parent specifies a per_child_auto_alloc_size
4. If the device's immediate parent specifies a per_child_auto
then this space is allocated. This is intended for use by the parent
device to keep track of things related to the child. For example a USB
flash stick attached to a USB host controller would likely use this
Expand All @@ -726,7 +726,7 @@ The steps are:
works the same way whether it was bound using a device tree node or
U_BOOT_DEVICE() structure. In either case, the platform data is now stored
in the platdata structure. Typically you will use the
platdata_auto_alloc_size feature to specify the size of the platform data
platdata_auto feature to specify the size of the platform data
structure, and U-Boot will automatically allocate and zero it for you before
entry to ofdata_to_platdata(). But if not, you can allocate it yourself in
ofdata_to_platdata(). Note that it is preferable to do all the device tree
Expand Down Expand Up @@ -795,9 +795,9 @@ as above and then following these steps (see device_probe()):
- uclass data in dev->uclass_priv (for things the uclass stores
about this device)

Note: If you don't use priv_auto_alloc_size then you will need to
Note: If you don't use priv_auto then you will need to
allocate the priv space here yourself. The same applies also to
platdata_auto_alloc_size. Remember to free them in the remove() method.
platdata_auto. Remember to free them in the remove() method.

5. The device is marked 'activated'

Expand Down Expand Up @@ -843,10 +843,10 @@ remove it. This performs the probe steps in reverse:
be dynamically allocated, and thus needs to be deallocated during the
remove() method, either:

- if the platdata_auto_alloc_size is non-zero, the deallocation
- if the platdata_auto is non-zero, the deallocation
happens automatically within the driver model core; or

- when platdata_auto_alloc_size is 0, both the allocation (in probe()
- when platdata_auto is 0, both the allocation (in probe()
or preferably ofdata_to_platdata()) and the deallocation in remove()
are the responsibility of the driver author.

Expand Down
8 changes: 4 additions & 4 deletions doc/driver-model/ethernet.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ the UCLASS_ETH .id field in the U-Boot driver struct:
.ofdata_to_platdata = eth_ape_ofdata_to_platdata,
.probe = eth_ape_probe,
.ops = &eth_ape_ops,
.priv_auto_alloc_size = sizeof(struct eth_ape_priv),
.platdata_auto_alloc_size = sizeof(struct eth_ape_pdata),
.priv_auto = sizeof(struct eth_ape_priv),
.platdata_auto = sizeof(struct eth_ape_pdata),
.flags = DM_FLAG_ALLOC_PRIV_DMA,
};
struct eth_ape_priv contains runtime per-instance data, like buffers, pointers
to current descriptors, current speed settings, pointers to PHY related data
(like struct mii_dev) and so on. Declaring its size in .priv_auto_alloc_size
(like struct mii_dev) and so on. Declaring its size in .priv_auto
will let the driver framework allocate it at the right time.
It can be retrieved using a dev_get_priv(dev) call.

struct eth_ape_pdata contains static platform data, like the MMIO base address,
a hardware variant, the MAC address. ``struct eth_pdata eth_pdata``
as the first member of this struct helps to avoid duplicated code.
If you don't need any more platform data beside the standard member,
just use sizeof(struct eth_pdata) for the platdata_auto_alloc_size.
just use sizeof(struct eth_pdata) for the platdata_auto.

PCI devices add a line pointing to supported vendor/device ID pairs:

Expand Down
6 changes: 3 additions & 3 deletions doc/driver-model/of-plat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ For example:
.of_match = mmc_ids,
.ofdata_to_platdata = mmc_ofdata_to_platdata,
.probe = mmc_probe,
.priv_auto_alloc_size = sizeof(struct mmc_priv),
.platdata_auto_alloc_size = sizeof(struct mmc_platdata),
.priv_auto = sizeof(struct mmc_priv),
.platdata_auto = sizeof(struct mmc_platdata),
};
U_BOOT_DRIVER_ALIAS(mmc_drv, vendor_mmc) /* matches compatible string */
Expand All @@ -305,7 +305,7 @@ keep the use of each of-platdata struct to the smallest possible code area.
There is just one driver C file for each struct, that can convert from the
of-platdata struct to the standard one used by the driver.

In the case where SPL_OF_PLATDATA is enabled, platdata_auto_alloc_size is
In the case where SPL_OF_PLATDATA is enabled, platdata_auto is
still used to allocate space for the platform data. This is different from
the normal behaviour and is triggered by the use of of-platdata (strictly
speaking it is a non-zero platdata_size which triggers this).
Expand Down
6 changes: 3 additions & 3 deletions doc/driver-model/spi-howto.rst
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ tree, but we need to tell it the size:
U_BOOT_DRIVER(spi_exynos) = {
...
.platdata_auto_alloc_size = sizeof(struct exynos_spi_platdata),
.platdata_auto = sizeof(struct exynos_spi_platdata),
Here is a sample function. It gets a pointer to the platform data and
Expand Down Expand Up @@ -335,7 +335,7 @@ DM can auto-allocate this also:
U_BOOT_DRIVER(spi_exynos) = {
...
.priv_auto_alloc_size = sizeof(struct exynos_spi_priv),
.priv_auto = sizeof(struct exynos_spi_priv),
Note that this is created before the probe method is called, and destroyed
Expand Down Expand Up @@ -621,7 +621,7 @@ needs, but this is the minimum.
U_BOOT_DRIVER(exynos_spi) = {
...
.per_child_auto_alloc_size = sizeof(struct spi_slave),
.per_child_auto = sizeof(struct spi_slave),
}
Expand Down
6 changes: 3 additions & 3 deletions doc/driver-model/usb-info.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ as drivers in the USB uclass. For example:
.probe = tegra_ehci_usb_probe,
.remove = tegra_ehci_usb_remove,
.ops = &ehci_usb_ops,
.platdata_auto_alloc_size = sizeof(struct usb_platdata),
.priv_auto_alloc_size = sizeof(struct fdt_usb),
.platdata_auto = sizeof(struct usb_platdata),
.priv_auto = sizeof(struct fdt_usb),
.flags = DM_FLAG_ALLOC_PRIV_DMA,
};
Expand All @@ -58,7 +58,7 @@ The ops here are ehci_usb_ops. All EHCI drivers will use these same ops in
most cases, since they are all EHCI-compatible. For EHCI there are also some
special operations that can be overridden when calling ehci_register().

The driver can use priv_auto_alloc_size to set the size of its private data.
The driver can use priv_auto to set the size of its private data.
This can hold run-time information needed by the driver for operation. It
exists when the device is probed (not when it is bound) and is removed when
the driver is removed.
Expand Down
2 changes: 1 addition & 1 deletion doc/imx/clk/ccf.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Design decisions:
modify clk-uclass.c file and add there struct uc_clk_priv, which would have
clock related members (like pointer to clk). As of this writing there is no
such need, so to avoid extra allocations (as it can be auto allocated by
setting .per_device_auto_alloc_size = sizeof(struct uc_clk_priv)) the
setting .per_device_auto = sizeof(struct uc_clk_priv)) the
uclass_priv stores the pointer to struct clk.

* Non-CCF clocks do not have a pointer to a clock in clk->dev->priv. In the case
Expand Down
Loading

0 comments on commit 41575d8

Please sign in to comment.