From: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
To: Anders Berg <anders.berg-1wcpHE2jlwO1Z/+hSey0Gg@public.gmane.org>
Cc: devicetree <devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] i2c: axxia: Add I2C driver for AXM55xx
Date: Mon, 22 Sep 2014 11:59:39 +0200 [thread overview]
Message-ID: <20140922095939.GB1406@katana> (raw)
In-Reply-To: <CAE0=X_0VQ8rWrUgbsgKm1MwCP8bwWm3UJPq9p=xNDfjP4CC7Bg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 2722 bytes --]
> >> + if (idev->msg_xfrd == 0 && i2c_m_recv_len(msg)) {
> >> + /*
> >> + * Check length byte for SMBus block read
> >> + */
> >> + if (c <= 0) {
> >> + idev->msg_err = -EPROTO;
> >> + i2c_int_disable(idev, ~0);
> >> + complete(&idev->msg_complete);
> >> + break;
> >> + } else if (c > I2C_SMBUS_BLOCK_MAX) {
> >> + c = I2C_SMBUS_BLOCK_MAX;
> >
> > What about returning -EPROTO here as well? I don't think that reading
> > just a slice of all the data is helpful.
> >
>
> Right, that is probably true. This came from the device I was using to
> test the block-read operation. This device violated the
> I2C_SMBUS_BLOCK_MAX limit, so I added this truncation to at least get
> something out...
Which device was it? I know there are some doing that, yet I like to
know which ones.
> >> +{
> >> + struct axxia_i2c_dev *idev = _dev;
> >> + u32 status;
> >> +
> >> + if (!idev->msg)
> >> + return IRQ_NONE;
> >
> > This is actually not true. There might be interrupt bits set, so there
> > is an IRQ. There shouldn't be one, right, but that's another case IMO.
> >
>
> You could see it as: there is no interrupt that this handler is
> interested in serving. I'd like to keep this test as there is some
> legacy software that could be run on platforms with this driver that
> access the I2C controller directly. If this happens, this test assures
> that the user get an informative "unhandled irq" error message
> (instead of a null pointer dereference).
IRQ_NONE is "this interrupt wasn't by me" so for shared IRQs, the next
handler can check. You shouldn't remove the check per se. Still, since
this interrupt was definately from the I2C core, you should return
IRQ_HANDLED and print an error message to the logs.
> >> +static int
> >> +axxia_i2c_xfer_msg(struct axxia_i2c_dev *idev, struct i2c_msg *msg)
> >> +{
> >> + u32 int_mask = MST_STATUS_ERR | MST_STATUS_SNS;
> >> + u32 rx_xfer, tx_xfer;
> >> + u32 addr_1, addr_2;
> >> + int ret;
> >> +
> >> + if (msg->len == 0 || msg->len > 255)
> >> + return -EINVAL;
> >
> > Ouch, really? Maybe we should warn the user here.
>
> Yeah, the transfer length register limits the length to 255. I'll add
> a warning here.
Please also add this information to the Kconfig description and
somewhere at the top of the source file. This is an important flaw which
people should easily find out about.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2014-09-22 9:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-25 11:51 [PATCH] i2c: axxia: Add I2C driver for AXM55xx Anders Berg
[not found] ` <1408967482-17723-1-git-send-email-anders.berg-1wcpHE2jlwO1Z/+hSey0Gg@public.gmane.org>
2014-09-20 12:12 ` Wolfram Sang
2014-09-22 9:19 ` Anders Berg
[not found] ` <CAE0=X_0VQ8rWrUgbsgKm1MwCP8bwWm3UJPq9p=xNDfjP4CC7Bg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-22 9:59 ` Wolfram Sang [this message]
2014-09-22 10:24 ` Anders Berg
2014-09-22 10:47 ` Anders Berg
[not found] ` <CAE0=X_1v_1eNr=dPTgofamFuy6zP9ff=LS7dyexj4CeutDqaPA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-22 11:04 ` Wolfram Sang
2014-09-22 12:18 ` Anders Berg
2014-09-22 13:03 ` Russell King - ARM Linux
[not found] ` <20140922130351.GL5182-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-09-22 14:49 ` Wolfram Sang
2014-09-22 13:16 ` Uwe Kleine-König
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=20140922095939.GB1406@katana \
--to=wsa-z923lk4zbo2bacvfa/9k2g@public.gmane.org \
--cc=anders.berg-1wcpHE2jlwO1Z/+hSey0Gg@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@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).