From: Dan Carpenter <dan.carpenter@oracle.com>
To: "Samuel Iglesias Gonsálvez" <siglesias@igalia.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org,
Jens Taprogge <jens.taprogge@taprogge.org>,
linux-kernel@vger.kernel.org,
industrypack-devel@lists.sourceforge.net
Subject: Re: [PATCH 03/20] Staging: ipack/bridges/tpci200: provide new callbacks to tpci200
Date: Tue, 11 Sep 2012 11:47:02 +0300 [thread overview]
Message-ID: <20120911084702.GM19396@mwanda> (raw)
In-Reply-To: <1347267118-9580-3-git-send-email-siglesias@igalia.com>
I had a few style comments on this patchset. Nothing that couldn't
be fixed later.
On Mon, Sep 10, 2012 at 10:51:41AM +0200, Samuel Iglesias Gonsálvez wrote:
> From: Jens Taprogge <jens.taprogge@taprogge.org>
>
> Provide get_clockrate, set_clockrate, get_error, get_timeout and reset_timeout
> callbacks.
>
> Signed-off-by: Jens Taprogge <jens.taprogge@taprogge.org>
> Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
> ---
> drivers/staging/ipack/bridges/tpci200.c | 107 +++++++++++++++++++++++++++++++
> 1 file changed, 107 insertions(+)
>
> diff --git a/drivers/staging/ipack/bridges/tpci200.c b/drivers/staging/ipack/bridges/tpci200.c
> index 4383953..861b00d 100644
> --- a/drivers/staging/ipack/bridges/tpci200.c
> +++ b/drivers/staging/ipack/bridges/tpci200.c
> @@ -14,6 +14,20 @@
> #include <linux/module.h>
> #include "tpci200.h"
>
> +static u16 tpci200_status_timeout[] = {
> + TPCI200_A_TIMEOUT,
> + TPCI200_B_TIMEOUT,
> + TPCI200_C_TIMEOUT,
> + TPCI200_D_TIMEOUT,
> +};
> +
> +static u16 tpci200_status_error[] = {
> + TPCI200_A_ERROR,
> + TPCI200_B_ERROR,
> + TPCI200_C_ERROR,
> + TPCI200_D_ERROR,
> +};
> +
> static struct ipack_bus_ops tpci200_bus_ops;
>
> static int tpci200_slot_unregister(struct ipack_device *dev);
> @@ -507,6 +521,94 @@ out_unlock:
> return res;
> }
>
> +static int tpci200_get_clockrate(struct ipack_device *dev)
> +{
> + struct tpci200_board *tpci200 = check_slot(dev);
> + __le16 __iomem *addr;
The point of the underscores in the __le16 is that you don't want to
pollute user space headers in glibc with a bunch of kernel typedefs.
It is not needed here. (Or if it is, then we would need to replace
the u16 uses as well).
> +
> + if (!tpci200)
> + return -ENODEV;
> +
> + addr = &tpci200->info->interface_regs->control[dev->slot];
> + return (ioread16(addr) & TPCI200_CLK32) ? 32 : 8;
> +}
> +
> +static int tpci200_set_clockrate(struct ipack_device *dev, int mherz)
> +{
> + struct tpci200_board *tpci200 = check_slot(dev);
> + __le16 __iomem *addr;
> + u16 reg;
> +
> + if (!tpci200)
> + return -ENODEV;
> +
> + addr = &tpci200->info->interface_regs->control[dev->slot];
> +
> + /* Ensure the control register is not changed by another task after we
> + * have read it. */
> + mutex_lock(&tpci200->mutex);
> + reg = ioread16(addr);
> + switch (mherz) {
> + case 8:
> + reg &= ~(TPCI200_CLK32); break;
> + case 32:
> + reg |= TPCI200_CLK32; break;
Put the breaks on the next line so that we can see them. At first I
thought it fell through.
> + default:
> + mutex_unlock(&tpci200->mutex);
> + return -EINVAL;
> + }
> + iowrite16(reg, addr);
> + mutex_unlock(&tpci200->mutex);
> + return 0;
> +}
> +
> +static int tpci200_get_error(struct ipack_device *dev)
> +{
> + struct tpci200_board *tpci200 = check_slot(dev);
> + __le16 __iomem *addr;
> + u16 mask;
> +
> + if (!tpci200)
> + return -ENODEV;
> +
> + addr = &tpci200->info->interface_regs->status;
> + mask = tpci200_status_error[dev->slot];
> + return (ioread16(addr) & mask) ? 1 : 0;
> +}
> +
> +static int tpci200_get_timeout(struct ipack_device *dev)
> +{
> + struct tpci200_board *tpci200 = check_slot(dev);
> + __le16 __iomem *addr;
> + u16 mask;
> +
> + if (!tpci200)
> + return -ENODEV;
> +
> + addr = &tpci200->info->interface_regs->status;
> + mask = tpci200_status_timeout[dev->slot];
> +
> + return (ioread16(addr) & mask) ? 1 : 0;
> +}
> +
> +static int tpci200_reset_timeout(struct ipack_device *dev)
> +{
> + struct tpci200_board *tpci200 = check_slot(dev);
> + __le16 __iomem *addr;
> + u16 mask;
> +
> + if (!tpci200)
> + return -ENODEV;
> +
> + addr = &tpci200->info->interface_regs->status;
> + mask = tpci200_status_timeout[dev->slot];
> +
> + iowrite16(mask, addr);
> + return 0;
> +}
> +
> +
> +
Only one blank line is here.
> static void tpci200_uninstall(struct tpci200_board *tpci200)
> {
> int i;
> @@ -524,6 +626,11 @@ static struct ipack_bus_ops tpci200_bus_ops = {
> .request_irq = tpci200_request_irq,
> .free_irq = tpci200_free_irq,
> .remove_device = tpci200_slot_unregister,
> + .get_clockrate = tpci200_get_clockrate,
> + .set_clockrate = tpci200_set_clockrate,
> + .get_error = tpci200_get_error,
> + .get_timeout = tpci200_get_timeout,
> + .reset_timeout = tpci200_reset_timeout,
> };
>
> static int tpci200_install(struct tpci200_board *tpci200)
> --
> 1.7.10.4
>
> _______________________________________________
> devel mailing list
> devel@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/devel
next prev parent reply other threads:[~2012-09-11 8:48 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-10 8:51 [PATCH 01/20] Staging: ipack/bridges/tpci200: Put the TPCI200 control registers into a struct Samuel Iglesias Gonsálvez
2012-09-10 8:51 ` [PATCH 02/20] Staging: ipack: Provide several carrier callbacks Samuel Iglesias Gonsálvez
2012-09-10 8:51 ` [PATCH 03/20] Staging: ipack/bridges/tpci200: provide new callbacks to tpci200 Samuel Iglesias Gonsálvez
2012-09-11 8:47 ` Dan Carpenter [this message]
2012-09-12 9:28 ` Jens Taprogge
2012-09-12 11:13 ` Dan Carpenter
2012-09-12 11:21 ` Samuel Iglesias Gonsálvez
2012-09-12 11:59 ` Dan Carpenter
2012-09-12 12:28 ` Jens Taprogge
2012-09-12 12:47 ` Samuel Iglesias Gonsálvez
2012-09-12 11:58 ` Jens Taprogge
2012-09-10 8:51 ` [PATCH 04/20] Staging: ipack: Obtain supported speeds from ID ROM Samuel Iglesias Gonsálvez
2012-09-11 8:47 ` Dan Carpenter
2012-09-10 8:51 ` [PATCH 05/20] Staging: ipack: Choose the optimum bus speed by default Samuel Iglesias Gonsálvez
2012-09-11 8:47 ` Dan Carpenter
2012-09-10 8:51 ` [PATCH 06/20] Staging: ipack: remove field driver from struct ipack_device Samuel Iglesias Gonsálvez
2012-09-10 8:51 ` [PATCH 07/20] Staging: ipack/bridges/tpci200: remove struct list_head Samuel Iglesias Gonsálvez
2012-09-10 8:51 ` [PATCH 08/20] Staging: ipack: Switch to 8MHz operation before reading ID Samuel Iglesias Gonsálvez
2012-09-11 8:48 ` Dan Carpenter
2012-09-11 11:31 ` Samuel Iglesias Gonsálvez
2012-09-11 11:39 ` Jens Taprogge
2012-09-11 14:39 ` Samuel Iglesias Gonsálvez
2012-09-11 15:33 ` Dan Carpenter
2012-09-10 8:51 ` [PATCH 09/20] Staging: ipack: reset previous timeouts during device registration Samuel Iglesias Gonsálvez
2012-09-11 8:48 ` Dan Carpenter
2012-09-10 8:51 ` [PATCH 10/20] Staging: ipack: check the device ID space CRC Samuel Iglesias Gonsálvez
2012-09-10 8:51 ` [PATCH 11/20] Staging: ipack/bridges/tpci200: reorder the iounmap and pci_release_region Samuel Iglesias Gonsálvez
2012-09-11 8:49 ` Dan Carpenter
2012-09-10 8:51 ` [PATCH 12/20] Staging: ipack/bridges/tpci200: increment the reference counter of the pci_dev Samuel Iglesias Gonsálvez
2012-09-10 8:51 ` [PATCH 13/20] Staging: ipack/bridges/tpci200: fix the uninstall the ipack device Samuel Iglesias Gonsálvez
2012-09-10 8:51 ` [PATCH 14/20] Staging: ipack/devices/ipoctal: change exiting procedure Samuel Iglesias Gonsálvez
2012-09-10 8:51 ` [PATCH 15/20] Staging: ipack/devices/ipoctal: free the IRQ Samuel Iglesias Gonsálvez
2012-09-10 8:51 ` [PATCH 16/20] Staging: ipack: unregister devices when uninstall the carrier device Samuel Iglesias Gonsálvez
2012-09-10 8:51 ` [PATCH 17/20] Staging: ipack/bridges/tpci200: delete ipack_device_unregister calls when exiting Samuel Iglesias Gonsálvez
2012-09-10 8:51 ` [PATCH 18/20] Staging: ipack/bridges/tpci200: remove tpci200_slot_unregister Samuel Iglesias Gonsálvez
2012-09-10 8:51 ` [PATCH 19/20] Staging: ipack: delete .remove_device() callback Samuel Iglesias Gonsálvez
2012-09-10 8:51 ` [PATCH 20/20] Staging: ipack/bridges/tpci200: Store the irq holder in slot_irq Samuel Iglesias Gonsálvez
2012-09-11 8:51 ` Dan Carpenter
2012-09-11 9:05 ` Samuel Iglesias Gonsálvez
2012-09-11 9:57 ` Dan Carpenter
2012-09-10 18:29 ` [PATCH 01/20] Staging: ipack/bridges/tpci200: Put the TPCI200 control registers into a struct Greg Kroah-Hartman
2012-09-11 7:01 ` Samuel Iglesias Gonsálvez
2012-09-11 7:42 ` Miguel Gómez
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=20120911084702.GM19396@mwanda \
--to=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=industrypack-devel@lists.sourceforge.net \
--cc=jens.taprogge@taprogge.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