linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
To: Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Emmanuel Deloget <logout-GANU6spQydw@public.gmane.org>,
	Barry Carter
	<barry.carter-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: [RESEND PATCH v1 2/2] i2c: Add bus driver for for OSIF USB i2c device.
Date: Sat, 4 Jan 2014 23:28:42 +0100	[thread overview]
Message-ID: <20140104222842.GF3150@katana> (raw)
In-Reply-To: <1387312308-2222-2-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 2918 bytes --]

Hi, thanks for the submission...


> +#define DRIVER_AUTHOR  "Barry Carter <barry.carter-hIwygO75nSHCXR85Y8Hu3Q@public.gmane.org>,"	\
> +	"Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>"
> +#define DRIVER_DESC    "OSIF driver"

No defines, use directly.

> +static int usb_read(struct i2c_adapter *adapter, int cmd,
> +		    int value, int index, void *data, int len);
> +
> +static int usb_write(struct i2c_adapter *adapter, int cmd,
> +		     int value, int index, void *data, int len);

With a bit of reshuffling, these can be skipped.

> +	dev_dbg(&adapter->dev, "master xfer %d messages:\n", num);

Skip. This info is available with I2C core debug messages.

> +	pstatus = kmalloc(sizeof(*pstatus), GFP_KERNEL);
> +	if (!pstatus)
> +		return -ENOMEM;

Does it really make sense to allocate this every time?

> +		dev_dbg(&adapter->dev,
> +			"  %d: %s (flags %d) %d bytes to 0x%02x\n",
> +			i, pmsg->flags & I2C_M_RD ? "read" : "write",
> +			pmsg->flags, pmsg->len, pmsg->addr);

This is also available with i2c core debug messages.

> +/* Structure to hold all of our device specific stuff */
> +struct priv {
> +	struct usb_device *usb_dev; /* the usb device for this device */
> +	struct usb_interface *interface; /* the interface for this device */
> +	struct i2c_adapter adapter; /* i2c related things */
> +};

Remove comments, too obvious IMO.

> +static int usb_read(struct i2c_adapter *adapter, int cmd,
> +		    int value, int index, void *data, int len)
> +{
> +	struct priv *priv = (struct priv *)adapter->algo_data;
> +
> +	/* do control transfer */

ditto.

> +	return usb_control_msg(priv->usb_dev, usb_rcvctrlpipe(priv->usb_dev, 0),
> +			       cmd, USB_TYPE_VENDOR | USB_RECIP_INTERFACE |
> +			       USB_DIR_IN, value, index, data, len, 2000);
> +}
> +
> +static int usb_write(struct i2c_adapter *adapter, int cmd,
> +		    int value, int index, void *data, int len)
> +{
> +
> +	struct priv *priv = (struct priv *)adapter->algo_data;
> +
> +	/* do control transfer */

ditto.

> +	return usb_control_msg(priv->usb_dev, usb_sndctrlpipe(priv->usb_dev, 0),
> +			       cmd, USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
> +			       value, index, data, len, 2000);
> +}
> +
> +static void osif_free(struct priv *priv)
> +{
> +	usb_put_dev(priv->usb_dev);
> +}

Not sure if this is worth a seperate function, but well...

> +static int osif_probe(struct usb_interface *interface,
> +			     const struct usb_device_id *id)
> +{
> +	struct priv *priv = NULL;

Unneeded assignment.

> +	int retval = -ENOMEM;
> +	u16 version;
> +
> +	dev_dbg(&interface->dev, "probing usb device");

This is available via driver core debug messages.

> +	/* inform user about successful attachment to i2c layer */
> +	dev_info(&priv->adapter.dev, "connected OSIF device\n");

I think this message should be merged with the "version xx found"
message above.

> +MODULE_LICENSE("GPL");

"GPL v2" according to header.


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2014-01-04 22:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-17 20:31 [RESEND PATCH v1 1/2] i2c: i2c-tiny-usb: Remove RobotFuzz USB vendor:product ID Andrew Lunn
     [not found] ` <1387312308-2222-1-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2013-12-17 20:31   ` [RESEND PATCH v1 2/2] i2c: Add bus driver for for OSIF USB i2c device Andrew Lunn
     [not found]     ` <1387312308-2222-2-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-01-04 22:28       ` Wolfram Sang [this message]
2014-01-06  3:55         ` [PATCH 1/2] i2c: i2c-tiny-usb: Remove RobotFuzz USB vendor:product ID Andrew Lunn
     [not found]           ` <1388980536-7588-1-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-01-06  3:55             ` [PATCH 2/2] i2c: Add bus driver for for OSIF USB i2c device Andrew Lunn
     [not found]               ` <1388980536-7588-2-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-01-09 21:49                 ` Wolfram Sang
2014-01-10 18:01                   ` Andrew Lunn
     [not found]                     ` <20140110180154.GK9681-g2DYL2Zd6BY@public.gmane.org>
2014-01-10 18:16                       ` Wolfram Sang
2014-01-10 19:21                         ` Andrew Lunn
     [not found]                           ` <20140110192148.GN9681-g2DYL2Zd6BY@public.gmane.org>
2014-01-10 19:25                             ` Wolfram Sang
2014-01-10 23:23                   ` [PATCH v3 1/2] i2c: i2c-tiny-usb: Remove RobotFuzz USB vendor:product ID Andrew Lunn
     [not found]                     ` <1389396239-21026-1-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-01-10 23:23                       ` [PATCH v3 2/2] i2c: Add bus driver for for OSIF USB i2c device Andrew Lunn
     [not found]                         ` <1389396239-21026-2-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-01-13 12:56                           ` Wolfram Sang

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=20140104222842.GF3150@katana \
    --to=wsa-z923lk4zbo2bacvfa/9k2g@public.gmane.org \
    --cc=andrew-g2DYL2Zd6BY@public.gmane.org \
    --cc=barry.carter-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=logout-GANU6spQydw@public.gmane.org \
    /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).