From: Joe Perches <joe@perches.com>
To: Kishon Vijay Abraham I <kishon@ti.com>
Cc: akpm@linux-foundation.org, davem@davemloft.net,
santosh.shilimkar@ti.com, grant.likely@secretlab.ca,
balbi@ti.com, arnd@arndb.de, gregkh@linuxfoundation.org,
linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, robherring2@gmail.com,
richard.zhao@freescale.com, B29397@freescale.com,
alexander.shishkin@linux.intel.com, mkl@pengutronix.de,
marex@denx.de, p.paneri@samsung.com,
devicetree-discuss@lists.ozlabs.org,
broonie@opensource.wolfsonmicro.com
Subject: Re: [PATCH] drivers: phy: add generic PHY framework
Date: Wed, 26 Sep 2012 09:57:57 -0700 [thread overview]
Message-ID: <1348678677.15175.18.camel@joe-AO722> (raw)
In-Reply-To: <1348671675-20830-1-git-send-email-kishon@ti.com>
On Wed, 2012-09-26 at 20:31 +0530, Kishon Vijay Abraham I wrote:
> The PHY framework provides a set of API's for the PHY drivers to
> create/destroy a PHY and API's
Just some trivial notes.
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
[]
> @@ -0,0 +1,445 @@
[]
> +static void devm_phy_release(struct device *dev, void *res)
> +{
> + struct phy *phy = *(struct phy **)res;
That's a bit twisted isn't it?
Perhaps
struct phy *phy = res;
[]
> +static int devm_phy_match(struct device *dev, void *res, void *match_data)
> +{
> + return res == match_data;
static bool devm_phy_match(etc...)
[]
> +struct phy *devm_of_phy_get(struct device *dev, const char *phandle, u8 index)
> +{
> + struct phy *phy = NULL, **ptr;
> + struct device_node *node;
> +
> + if (!dev->of_node) {
> + dev_dbg(dev, "device does not have a device node entry\n");
> + return ERR_PTR(-EINVAL);
> + }
> +
> + node = of_parse_phandle(dev->of_node, phandle, index);
> + if (!node) {
> + dev_dbg(dev, "failed to get %s phandle in %s node\n", phandle,
> + dev->of_node->full_name);
> + return ERR_PTR(-ENODEV);
> + }
> +
> + ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
Is this the right size?
Because ptr is **, perhaps sizeof(struct phy) is clearer.
> + if (!ptr) {
> + dev_dbg(dev, "failed to allocate memory for devres\n");
alloc failures generally don't need specific OOM messages
as the general alloc OOM dumps stack.
> + return ERR_PTR(-ENOMEM);
> + }
> +
> + mutex_lock(&phy_list_mutex);
> +
> + phy = of_phy_lookup(dev, node);
> + if (IS_ERR(phy) || !phy->dev.class ||
> + !try_module_get(phy->dev.class->owner)) {
I think it's tasteful coding style to align like:
if (IS_ERR(phy) || !phy->dev.class ||
!try_module_get(phy->dev.class->owner)) {
[]
> +struct phy *phy_create(struct device *dev, struct phy_descriptor *desc)
> +{
> + int ret;
> + struct phy *phy;
> + struct phy_bind *phy_bind;
> + const char *devname = NULL;
> +
> + if (!dev || !desc) {
> + dev_err(dev, "no descriptor/device provided for PHY\n");
> + ret = -EINVAL;
> + goto err0;
> + }
> +
> + if (!desc->ops) {
> + dev_err(dev, "no PHY ops provided\n");
> + ret = -EINVAL;
> + goto err0;
> + }
> +
> + phy = kzalloc(sizeof(*phy), GFP_KERNEL);
> + if (!phy) {
> + dev_err(dev, "no memory for PHY\n");
No OOM message required...
[]
> +static int __init phy_core_init(void)
> +{
> + phy_class = class_create(THIS_MODULE, "phy");
> + if (IS_ERR(phy_class)) {
> + pr_err("failed to create phy class --> %ld\n",
> + PTR_ERR(phy_class));
You might add #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
before any include so that pr_<levels> are prefixed.
cheers, Joe
next prev parent reply other threads:[~2012-09-26 16:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-26 15:01 [PATCH] drivers: phy: add generic PHY framework Kishon Vijay Abraham I
2012-09-26 16:57 ` Joe Perches [this message]
2012-09-26 17:41 ` Dmitry Torokhov
2012-09-26 18:01 ` Marc Kleine-Budde
2012-09-26 17:04 ` Greg KH
2012-09-26 17:08 ` David Miller
2012-09-26 20:07 ` Marc Kleine-Budde
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=1348678677.15175.18.camel@joe-AO722 \
--to=joe@perches.com \
--cc=B29397@freescale.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=arnd@arndb.de \
--cc=balbi@ti.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=davem@davemloft.net \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@secretlab.ca \
--cc=gregkh@linuxfoundation.org \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=marex@denx.de \
--cc=mkl@pengutronix.de \
--cc=p.paneri@samsung.com \
--cc=richard.zhao@freescale.com \
--cc=robherring2@gmail.com \
--cc=santosh.shilimkar@ti.com \
/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;
as well as URLs for NNTP newsgroup(s).