From: Andrew Lunn <andrew@lunn.ch>
To: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Cc: Woojung.Huh@microchip.com, devicetree@vger.kernel.org,
f.fainelli@gmail.com, vivien.didelot@savoirfairelinux.com,
netdev@vger.kernel.org, driverdev-devel@linuxdriverproject.org,
UNGLinuxDriver@microchip.com, davem@davemloft.net
Subject: Re: [PATCH 1/2] net: dsa: ksz9477: add I2C managed mode support
Date: Sun, 16 Dec 2018 09:15:42 +0100 [thread overview]
Message-ID: <20181216081542.GB18287@lunn.ch> (raw)
In-Reply-To: <20181216075741.13827-1-sergio.paracuellos@gmail.com>
On Sun, Dec 16, 2018 at 08:57:40AM +0100, Sergio Paracuellos wrote:
> +static int ksz_i2c_read_reg(struct i2c_client *client, u32 reg, u8 *val,
> + unsigned int len)
> +{
> + struct i2c_adapter *adapter = client->adapter;
> + struct i2c_msg msg[2];
> + u8 txd[2];
Hi Sergio
I'm not sure that having the TX buffer on the stack is safe. If the
i2c bus master is using DMA, you then DMA from the stack, which some
architectures memory models do no allow. You have to use memory which
comes from an alloc function.
> + int ret;
> +
> + txd[0] = (u8)(reg >> 8);
> + txd[1] = (u8)reg;
> +
> + msg[0].addr = client->addr;
> + msg[0].flags = 0;
> + msg[0].len = 2;
> + msg[0].buf = txd;
> +
> + msg[1].addr = client->addr;
> + msg[1].flags = I2C_M_RD;
> + msg[1].len = len;
> + msg[1].buf = val;
You potentially have the same issue with val.
Andrew
next prev parent reply other threads:[~2018-12-16 8:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-16 7:57 [PATCH 1/2] net: dsa: ksz9477: add I2C managed mode support Sergio Paracuellos
2018-12-16 7:57 ` [PATCH 2/2] dt-bindings: net: dsa: ksz9477: add sample of switch bindings managed in i2c mode Sergio Paracuellos
2018-12-16 8:18 ` Andrew Lunn
2018-12-16 8:32 ` Sergio Paracuellos
2018-12-16 8:15 ` Andrew Lunn [this message]
2018-12-16 8:35 ` [PATCH 1/2] net: dsa: ksz9477: add I2C managed mode support Sergio Paracuellos
2018-12-16 8:44 ` Andrew Lunn
2018-12-17 6:54 ` Dan Carpenter
2018-12-17 18:22 ` Sergio Paracuellos
2018-12-17 19:11 ` Dan Carpenter
2018-12-17 20:46 ` Sergio Paracuellos
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=20181216081542.GB18287@lunn.ch \
--to=andrew@lunn.ch \
--cc=UNGLinuxDriver@microchip.com \
--cc=Woojung.Huh@microchip.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=driverdev-devel@linuxdriverproject.org \
--cc=f.fainelli@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=sergio.paracuellos@gmail.com \
--cc=vivien.didelot@savoirfairelinux.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).