All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: u-boot@lists.denx.de
Subject: [PATCH v2 03/37] dm: core: Add macros to access the new linker lists
Date: Thu, 4 Feb 2021 14:46:14 +0100	[thread overview]
Message-ID: <410f06ec-8b93-100e-02a2-0275686b428a@gmx.de> (raw)
In-Reply-To: <20210203094345.v2.3.I203d6c2e1211d979289198ee3410009acd7353e6@changeid>

On 03.02.21 17:43, Simon Glass wrote:
> Add macros which work with instantiated devices and uclasses, as created
> at build time by dtoc. Include variants that can be used in data
> structures.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> (no changes since v1)
>
>  include/dm/device-internal.h | 26 ++++++++++++++++++++++++++
>  include/dm/device.h          | 11 +++++++++++
>  include/dm/uclass-internal.h | 23 +++++++++++++++++++++++
>  include/dm/uclass.h          | 20 ++++++++++++++++++++
>  4 files changed, 80 insertions(+)
>
> diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h
> index 639bbd293d9..9d7256130cd 100644
> --- a/include/dm/device-internal.h
> +++ b/include/dm/device-internal.h
> @@ -10,11 +10,37 @@
>  #ifndef _DM_DEVICE_INTERNAL_H
>  #define _DM_DEVICE_INTERNAL_H
>
> +#include <linker_lists.h>
>  #include <dm/ofnode.h>
>
>  struct device_node;
>  struct udevice;
>
> +/*
> + * These are only allowed these in code generated by dtoc, because the ordering
> + * is important and if other instances creep in then they may mess up the
> + * ordering expected by dtoc.
> + */
> +
> +/* Declare a bound device ready for run-time use */
> +#define DM_DEVICE_INST(__name)						\
> +	ll_entry_declare(struct udevice, __name, udevice)
> +
> +/* Declare a bound device as an extern, so it can be referenced at build time */
> +#define DM_DEVICE_DECL(__name)						\
> +	ll_entry_decl(struct udevice, __name, udevice)
> +
> +/*
> + * Get a pointer to a given device, for use in data structures. This requires
> + * that the symbol be declared with DM_DRIVER_DECL() first
> + */
> +#define DM_DEVICE_REF(__name)						\
> +	ll_entry_ref(struct udevice, __name, udevice)
> +
> +/* Get a pointer to a given device */
> +#define DM_DEVICE_GET(__name)						\
> +	ll_entry_get(struct udevice, __name, udevice)
> +
>  /**
>   * device_bind() - Create a device and bind it to a driver
>   *
> diff --git a/include/dm/device.h b/include/dm/device.h
> index 1c52c9d3120..38ef47baa01 100644
> --- a/include/dm/device.h
> +++ b/include/dm/device.h
> @@ -338,6 +338,17 @@ struct driver {
>  #define DM_DRIVER_GET(__name)						\
>  	ll_entry_get(struct driver, __name, driver)
>
> +/* Declare a driver as an extern, so it can be referenced at build time */
> +#define DM_DRIVER_DECL(__name)					\
> +	ll_entry_decl(struct driver, __name, driver)
> +
> +/*
> + * Get a pointer to a given driver, for use in data structures. This requires
> + * that the symbol be declared with DM_DRIVER_DECL() first
> + */
> +#define DM_DRIVER_REF(__name)					\
> +	ll_entry_ref(struct driver, __name, driver)
> +
>  /**
>   * Declare a macro to state a alias for a driver name. This macro will
>   * produce no code but its information will be parsed by tools like
> diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h
> index c5a464be7c4..fc4d8dc2b53 100644
> --- a/include/dm/uclass-internal.h
> +++ b/include/dm/uclass-internal.h
> @@ -11,6 +11,29 @@
>
>  #include <dm/ofnode.h>
>
> +/*
> + * These are only allowed these in code generated by dtoc, because the ordering

%s/These/The next three macros/

> + * is important and if other instances creep in then they may mess up the
> + * ordering expected by dtoc.
> + */
> +
> +/*
> + * Declare a uclass ready for run-time use. This adds an actual struct uclass
> + * to a list which is found by driver model on start-up.
> + */

It is unclear which type __name might have.

Please, describe in Sphinx style for each macro  what the macro is used
for, how it is used, what the parameters are used for, which type they take.

Best regards

Heinrich

> +#define DM_UCLASS_INST(__name)						\
> +	ll_entry_declare(struct uclass, __name, uclass)
> +
> +#define DM_UCLASS_DECL(__name)						\
> +	ll_entry_decl(struct uclass, __name, uclass)
> +
> +/*
> + * Declare a uclass as an extern, so it can be referenced at build time. This
> + * is an extern for DM_UCLASS_INST().
> + */
> +#define DM_UCLASS_REF(__name)						\
> +	ll_entry_ref(struct uclass, __name, uclass)
> +
>  /**
>   * uclass_set_priv() - Set the private data for a uclass
>   *
> diff --git a/include/dm/uclass.h b/include/dm/uclass.h
> index d95683740cb..152f49e97dc 100644
> --- a/include/dm/uclass.h
> +++ b/include/dm/uclass.h
> @@ -114,6 +114,26 @@ struct uclass_driver {
>  #define UCLASS_DRIVER(__name)						\
>  	ll_entry_declare(struct uclass_driver, __name, uclass_driver)
>
> +/*
> + * These two macros are related to of-platdata, and normally only used in
> + * code generated by dtoc
> + */
> +
> +/*
> + * Declare a uclass driver as an extern, so it can be referenced at build time
> + * This is the extern equivalent of UCLASS_DRIVER(). You need to place this at
> + * the top level before you use DM_UCLASS_DRIVER_REF() in a file.
> + */
> +#define DM_UCLASS_DRIVER_DECL(__name)					\
> +	ll_entry_decl(struct uclass_driver, __name, uclass_driver)
> +
> +/*
> + * Get a pointer to a given uclass driver, for use in data structures. This
> + * requires that the symbol be declared with DM_UCLASS_DRIVER_DECL() first
> + */
> +#define DM_UCLASS_DRIVER_REF(__name)					\
> +	ll_entry_ref(struct uclass_driver, __name, uclass_driver)
> +
>  /**
>   * uclass_get_priv() - Get the private data for a uclass
>   *
>

  reply	other threads:[~2021-02-04 13:46 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-03 16:43 [PATCH v2 00/37] dm: Implement OF_PLATDATA_INST in driver model (part E) Simon Glass
2021-02-03 16:43 ` [PATCH v2 01/37] sandbox: Drop debug message in os_spl_to_uboot() Simon Glass
2021-02-04 13:36   ` Heinrich Schuchardt
2021-02-03 16:43 ` [PATCH v2 02/37] linker_lists: Allow use in data structures Simon Glass
2021-02-04 13:54   ` Heinrich Schuchardt
2021-02-07 14:37     ` Simon Glass
2021-02-03 16:43 ` [PATCH v2 03/37] dm: core: Add macros to access the new linker lists Simon Glass
2021-02-04 13:46   ` Heinrich Schuchardt [this message]
2021-02-03 16:43 ` [PATCH v2 04/37] dm: core: Allow dropping run-time binding of devices Simon Glass
2021-02-04 13:57   ` Heinrich Schuchardt
2021-02-03 16:43 ` [PATCH v2 05/37] dm: core: Adjust uclass setup with of-platdata Simon Glass
2021-02-03 16:43 ` [PATCH v2 06/37] dm: core: Set up driver model for OF_PLATDATA_INST Simon Glass
2021-02-03 16:43 ` [PATCH v2 07/37] dm: core: Skip adding uclasses with OF_PLATDATA_INST Simon Glass
2021-02-03 16:43 ` [PATCH v2 08/37] dm: Add the new dtoc-generated files to the build Simon Glass
2021-02-03 16:43 ` [PATCH v2 09/37] dm: core: Include dt-decl.h automatically Simon Glass
2021-02-03 16:43 ` [PATCH v2 10/37] dm: test: Avoid destroying uclasses with of-platdata-inst Simon Glass
2021-02-03 16:43 ` [PATCH v2 11/37] clk: sandbox: Move priv/plat data to a header file Simon Glass
2021-02-03 16:43 ` [PATCH v2 12/37] clk: fixed-rate: Export driver parts for OF_PLATDATA_INST Simon Glass
2021-02-03 16:43 ` [PATCH v2 13/37] clk: sandbox: Create a special fixed-rate driver Simon Glass
2021-02-03 16:43 ` [PATCH v2 14/37] dm: core: Drop device_get_by_driver_info() Simon Glass
2021-02-03 16:43 ` [PATCH v2 15/37] dm: core: Drop uclass_find_device_by_phandle() with of-platdata Simon Glass
2021-02-03 16:43 ` [PATCH v2 16/37] sandbox: i2c: Move platdata structs to header files Simon Glass
2021-02-03 16:43 ` [PATCH v2 17/37] dm: Rename device_get_by_driver_info_idx() Simon Glass
2021-02-03 16:43 ` [PATCH v2 18/37] sandbox_spl: Increase SPL malloc() size Simon Glass
2021-02-04 14:01   ` Heinrich Schuchardt
2021-02-03 16:43 ` [PATCH v2 19/37] sandbox: i2c: Support i2c emulation with of-platdata Simon Glass
2021-02-03 16:43 ` [PATCH v2 20/37] Revert "sandbox: Disable I2C emulators in SPL" Simon Glass
2021-02-03 16:43 ` [PATCH v2 21/37] sandbox: Create a new sandbox_noinst build Simon Glass
2021-02-03 16:43 ` [PATCH v2 22/37] test: Run sandbox_spl tests on sandbox_noinst Simon Glass
2021-02-03 16:43 ` [PATCH v2 23/37] azure/gitlab: Add tests for sandbox_noinst Simon Glass
2021-02-03 16:43 ` [PATCH v2 24/37] dm: core: Add an option to support SPL in read-only memory Simon Glass
2021-02-03 16:43 ` [PATCH v2 25/37] dm: core: Create a struct for device runtime info Simon Glass
2021-02-03 16:43 ` [PATCH v2 26/37] dm: core: Move flags to device-runtime info Simon Glass
2021-02-03 16:43 ` [PATCH v2 27/37] dm: core: Allow storing priv/plat data separately Simon Glass
2021-02-03 16:43 ` [PATCH v2 28/37] sandbox: Define a region for device priv/plat data Simon Glass
2021-02-03 16:43 ` [PATCH v2 29/37] dm: core: Use separate priv/plat data region Simon Glass
2021-02-03 16:43 ` [PATCH v2 30/37] x86: Define a region for device priv/plat data Simon Glass
2021-02-03 16:43 ` [PATCH v2 31/37] x86: apl: Fix the header order in pmc Simon Glass
2021-02-03 16:43 ` [PATCH v2 32/37] x86: apl: Tell of-platdata about a required header file Simon Glass
2021-02-03 16:43 ` [PATCH v2 33/37] x86: itss: Tidy up bind() for of-platdata-inst Simon Glass
2021-02-03 16:43 ` [PATCH v2 34/37] x86: Support a fake PCI device with of-platdata-inst Simon Glass
2021-02-03 16:43 ` [PATCH v2 35/37] x86: Don't include reset driver in SPL Simon Glass
2021-02-03 16:43 ` [PATCH v2 36/37] x86: coral: Drop ACPI properties from of-platdata Simon Glass
2021-02-03 16:43 ` [PATCH v2 37/37] x86: apl: Use read-only SPL and new of-platdata Simon Glass
2021-02-04  7:48 ` [PATCH v2 00/37] dm: Implement OF_PLATDATA_INST in driver model (part E) Heinrich Schuchardt
2021-02-04 15:08   ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=410f06ec-8b93-100e-02a2-0275686b428a@gmx.de \
    --to=xypron.glpk@gmx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.