public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 04/17] dm: clk: Define clk_get_by_id() for clk operations
Date: Thu, 31 Jan 2019 11:51:45 +0100	[thread overview]
Message-ID: <20190131115145.1c5cc2af@jawa> (raw)
In-Reply-To: <CAPnjgZ2Jz3=9N-UYdqbQuVh03aBH_57ATX0AxiphAmOZHZkNvA@mail.gmail.com>

Hi Simon,

> On Thu, 31 Jan 2019 at 02:04, Lukasz Majewski <lukma@denx.de> wrote:
> >
> > This commit adds the clk_get_by_id() function, which is responsible
> > for getting the udevice with matching clk->id. Such approach allows
> > re-usage of inherit DM list relationship for the same class
> > (UCLASS_CLK). As a result - we don't need any other external list -
> > it is just enough to look for UCLASS_CLK related udevices.
> >
> > Signed-off-by: Lukasz Majewski <lukma@denx.de>
> > ---
> >
> > Changes in v2: None
> >
> >  drivers/clk/clk-uclass.c | 22 ++++++++++++++++++++++
> >  include/clk.h            | 11 +++++++++++
> >  2 files changed, 33 insertions(+)
> >  
> 
> Please add a test that calls this.

Ok.

> 
> > diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
> > index f1640dda67..12ec0baa74 100644
> > --- a/drivers/clk/clk-uclass.c
> > +++ b/drivers/clk/clk-uclass.c
> > @@ -455,6 +455,28 @@ int clk_disable_bulk(struct clk_bulk *bulk)
> >         return 0;
> >  }
> >
> > +int clk_get_by_id(ulong id, struct clk **c)  
> 
> Can you use clkp instead of c?

Ok.

> 
> > +{
> > +       struct udevice *dev;
> > +       struct uclass *uc;
> > +       int ret;
> > +
> > +       ret = uclass_get(UCLASS_CLK, &uc);
> > +       if (ret)
> > +               return ret;
> > +
> > +       uclass_foreach_dev(dev, uc) {
> > +               struct clk *clk = (struct clk
> > *)dev_get_driver_data(dev); +
> > +               if (clk->id == id) {
> > +                       *c = clk;
> > +                       return 0;
> > +               }
> > +       }
> > +
> > +       return -ENODEV;  
> 
> I wonder if -ENOENT would be better?

Yes, it would better describe the situation.

> 
> > +}
> > +
> >  UCLASS_DRIVER(clk) = {
> >         .id             = UCLASS_CLK,
> >         .name           = "clk",
> > diff --git a/include/clk.h b/include/clk.h
> > index 8224295ec3..045e60357d 100644
> > --- a/include/clk.h
> > +++ b/include/clk.h
> > @@ -315,4 +315,15 @@ static inline bool clk_valid(struct clk *clk)
> >  {
> >         return !!clk->dev;
> >  }
> > +
> > +/**
> > + * clk_get_by_id() - Get the clock by knowing its ID
> > + *
> > + * @id:        The clock ID to search for
> > + *
> > + * @c: A pointer to clock struct that has been found among added
> > clocks
> > + *      to UCLASS_CLK
> > + * @return zero on success, or -ve error code.  
> 
> -NOENT on error? I think you can be specific here

Ok.

> 
> > + */
> > +int clk_get_by_id(ulong id, struct clk **c);
> >  #endif
> > --
> > 2.11.0
> >  
> 
> Regards,
> Simon


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190131/8ba3c6e7/attachment.sig>

  reply	other threads:[~2019-01-31 10:51 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-31  9:03 [U-Boot] [PATCH v2 00/17] imx: dm: Update mccmon6 board to only use DM/DTS in u-boot proper Lukasz Majewski
2019-01-31  9:03 ` [U-Boot] [PATCH v2 01/17] dm: Fix documentation entry as there is no UCLASS_CLOCK uclass Lukasz Majewski
2019-01-31 10:04   ` Simon Glass
2019-01-31  9:03 ` [U-Boot] [PATCH v2 02/17] cmd: Do not show frequency for clocks which .get_rate() return error Lukasz Majewski
2019-01-31 10:04   ` Simon Glass
2019-01-31  9:03 ` [U-Boot] [PATCH v2 03/17] dm: clk: Define clk_get_parent_rate() for clk operations Lukasz Majewski
2019-01-31 10:05   ` Simon Glass
2019-01-31 11:14     ` Lukasz Majewski
2019-01-31  9:03 ` [U-Boot] [PATCH v2 04/17] dm: clk: Define clk_get_by_id() " Lukasz Majewski
2019-01-31 10:05   ` Simon Glass
2019-01-31 10:51     ` Lukasz Majewski [this message]
2019-01-31  9:03 ` [U-Boot] [PATCH v2 05/17] clk: Port Linux common clock framework [CCF] for imx6q to U-boot (tag: 5.0-rc3) Lukasz Majewski
2019-01-31  9:03 ` [U-Boot] [PATCH v2 06/17] ARM: imx: cosmetic: Remove not needed comment from the mccmon6.h file Lukasz Majewski
2019-01-31  9:03 ` [U-Boot] [PATCH v2 07/17] ARM: imx: config: Disable support for USB on MCCMON6 Lukasz Majewski
2019-01-31  9:03 ` [U-Boot] [PATCH v2 08/17] net: imx: Add support for waiting some time after FEC gpio reset Lukasz Majewski
2019-01-31  9:03 ` [U-Boot] [PATCH v2 09/17] spi: imx: Add support for 'per' clock enabling via driver model Lukasz Majewski
2019-01-31  9:03 ` [U-Boot] [PATCH v2 10/17] ARM: imx: Covnert mccmon6 to use DM/DTS in the u-boot proper Lukasz Majewski
2019-01-31  9:03 ` [U-Boot] [PATCH v2 11/17] ARM: imx: Decouple mccmon6's SPL and u-boot proper code Lukasz Majewski
2019-01-31  9:03 ` [U-Boot] [PATCH v2 12/17] ARM: imx: Disable 1Gbps support on MCCMON6's KSZ9031 PHY Lukasz Majewski
2019-01-31  9:03 ` [U-Boot] [PATCH v2 13/17] Kconfig: Make CMD_SPL_NAND_OFS only available when proper memory is used Lukasz Majewski
2019-01-31  9:03 ` [U-Boot] [PATCH v2 14/17] Kconfig: cosmetic: Update description of CMD_SPL_NAND_OFS Lukasz Majewski
2019-01-31  9:03 ` [U-Boot] [PATCH v2 15/17] Kconfig: Add CMD_SPL_NOR_OFS config for falcon boot argument offset Lukasz Majewski
2019-01-31  9:03 ` [U-Boot] [PATCH v2 16/17] doc: Update parallel NOR flash related information in README.falcon Lukasz Majewski
2019-01-31  9:03 ` [U-Boot] [PATCH v2 17/17] imx: Convert mccmon6 to use fitImage instead of uImage+DTB Lukasz Majewski

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=20190131115145.1c5cc2af@jawa \
    --to=lukma@denx.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox