From: Dan Carpenter <dan.carpenter@oracle.com>
To: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/3] Staging: IndustryPack bus for the Linux Kernel
Date: Mon, 7 May 2012 11:04:58 +0300 [thread overview]
Message-ID: <20120507080458.GN22134@mwanda> (raw)
In-Reply-To: <1336375569-21692-1-git-send-email-siglesias@igalia.com>
On Mon, May 07, 2012 at 09:26:07AM +0200, Samuel Iglesias Gonsalvez wrote:
> +int ipack_bus_register(struct ipack_bus_device *bus)
> +{
> + int bus_nr;
Blank line here between declaration and code.
> + bus_nr = ipack_assign_bus_number();
> + if (bus_nr < 0)
> + return -1;
> + bus->bus_nr = bus_nr;
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(ipack_bus_register);
[snip]
> +int ipack_driver_register(struct ipack_driver *edrv)
> +{
> + int ret;
> +
> + edrv->driver.bus = &ipack_bus_type;
> + ret = driver_register(&edrv->driver);
> + if (ret < 0)
> + goto exit_driver_register;
> +
> +exit_driver_register:
> + return ret;
> +}
Better to write it like this:
int ipack_driver_register(struct ipack_driver *edrv)
{
edrv->driver.bus = &ipack_bus_type;
return driver_register(&edrv->driver);
}
[snip]
> +int ipack_device_find_drv(struct device_driver *driver, void *param)
> +{
> + int ret;
> + struct ipack_device *dev = (struct ipack_device *)param;
> +
> + ret = ipack_bus_match(&dev->dev, driver);
> + if (ret)
> + return !ipack_bus_probe(&dev->dev);
Wouldn't probe() return zero or a negative error code?
> +
> + return ret;
return 0;
> +}
> +
> +int ipack_device_register(struct ipack_device *dev)
> +{
> + int ret;
> +
> + if (!bus_for_each_drv(&ipack_bus_type, NULL, dev, ipack_device_find_drv)) {
> + ret = -ENODEV;
> + goto exit_device_register;
Just return directly here. I was expecting a reason for a goto but
a nonsense goto is misleading.
> + }
> +
> + dev->dev.bus = &ipack_bus_type;
> + dev->dev.release = ipack_device_release;
> + dev_set_name(&dev->dev, "%s.%u.%u", dev->board_name, dev->bus_nr, dev->slot);
> + ret = device_register(&dev->dev);
> + if (ret < 0) {
> + printk(KERN_ERR "ipack: error registering the device.\n");
> + dev->driver->ops->remove(dev);
> + }
> +
> +exit_device_register:
> + return ret;
> +}
regards,
dan carpenter
next prev parent reply other threads:[~2012-05-07 8:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1336375569-21692-1-git-send-email-siglesias@igalia.com>
2012-05-07 7:26 ` [PATCH v2 2/3] Staging: ipack: added support for the TEWS TPCI-200 carrier board Samuel Iglesias Gonsalvez
2012-05-07 8:20 ` Manohar Vanga
2012-05-07 8:36 ` Samuel Iglesias Gonsálvez
2012-05-07 7:26 ` [PATCH v2 3/3] Staging: ipack: add support for IP-OCTAL mezzanine board Samuel Iglesias Gonsalvez
2012-05-07 8:40 ` Dan Carpenter
2012-05-07 8:04 ` Dan Carpenter [this message]
2012-05-07 8:24 ` [PATCH v2 1/3] Staging: IndustryPack bus for the Linux Kernel Samuel Iglesias Gonsálvez
2012-05-07 14:24 ` Samuel Iglesias Gonsálvez
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=20120507080458.GN22134@mwanda \
--to=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=siglesias@igalia.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