From: shiraz hashim <shiraz.linux.kernel@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Roland Stigge <stigge@antcom.de>,
aletes.xgr@gmail.com, broonie@opensource.wolfsonmicro.com,
grant.likely@secretlab.ca, rob.herring@calxeda.com,
rob@landley.net, devicetree-discuss@lists.ozlabs.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
spi-devel-general@lists.sourceforge.net,
gabriel.fernandez@stericsson.com, lee.jones@linaro.org,
viresh.kumar@linaro.org, sachin.verma@st.com
Subject: Re: [PATCH v6 1/3] spi/pl022: Add chip select handling via GPIO
Date: Sun, 2 Sep 2012 18:42:49 +0530 [thread overview]
Message-ID: <CAPub14891Bhdt=KNz8SZLS6Ps2snhy9LgOU=yGGMrntcK9xxRA@mail.gmail.com> (raw)
In-Reply-To: <CACRpkdY3atmx4N-Zq2imrgPoukueYiexzndD7bVyQTgV02Vpuw@mail.gmail.com>
Hi Linus,
On Sun, Sep 2, 2012 at 12:48 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Sat, Sep 1, 2012 at 1:14 PM, shiraz hashim
> <shiraz.linux.kernel@gmail.com> wrote:
>> Hi Roland,
>>
>> On Wed, Aug 22, 2012 at 7:19 PM, Roland Stigge <stigge@antcom.de> wrote:
>>> @@ -2016,6 +2030,8 @@ pl022_probe(struct amba_device *adev, co
>>> pl022->master_info = platform_info;
>>> pl022->adev = adev;
>>> pl022->vendor = id->data;
>>> + /* Point chipselects to allocated memory beyond the main struct */
>>> + pl022->chipselects = (int *) pl022 + sizeof(struct pl022);
>>
>> This is going beyond memory allocated for chipselects
>> as it adds 4 * sizeof(struct pl022) bytes to pl022.
>
> Yes that is why the allocation looks like this:
>
> + master = spi_alloc_master(dev, sizeof(struct pl022) + sizeof(int) *
> + platform_info->num_chipselect);
>
The allocation is such because type of chipselects is int.
The statement for allocation is correct, but
pl022->chipselects = (int *) pl022 + sizeof(struct pl022);
is not adding sizeof(struct pl022) bytes to pl022 base (which we want),
but infact 4 times the size of pl022 (because type of pl022 is now int *).
Do you get my point ? This would go way beyond memory allocated
for chipselects.
--
regards
Shiraz Hashim
next prev parent reply other threads:[~2012-09-02 13:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-22 13:49 [PATCH v6 1/3] spi/pl022: Add chip select handling via GPIO Roland Stigge
2012-08-22 13:49 ` [PATCH v6 2/3] spi/pl022: Add devicetree support Roland Stigge
2012-08-22 18:38 ` Linus Walleij
2012-08-22 13:49 ` [PATCH v6 3/3] DT bindings documentation: "num-cs" property for SPI controllers Roland Stigge
2012-08-22 18:39 ` Linus Walleij
2012-08-22 19:03 ` Mark Brown
2012-08-22 18:37 ` [PATCH v6 1/3] spi/pl022: Add chip select handling via GPIO Linus Walleij
2012-09-01 11:14 ` shiraz hashim
2012-09-02 7:18 ` Linus Walleij
2012-09-02 13:12 ` shiraz hashim [this message]
2012-09-03 9:10 ` Linus Walleij
2012-09-02 20:04 ` Roland Stigge
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='CAPub14891Bhdt=KNz8SZLS6Ps2snhy9LgOU=yGGMrntcK9xxRA@mail.gmail.com' \
--to=shiraz.linux.kernel@gmail.com \
--cc=aletes.xgr@gmail.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=gabriel.fernandez@stericsson.com \
--cc=grant.likely@secretlab.ca \
--cc=lee.jones@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rob.herring@calxeda.com \
--cc=rob@landley.net \
--cc=sachin.verma@st.com \
--cc=spi-devel-general@lists.sourceforge.net \
--cc=stigge@antcom.de \
--cc=viresh.kumar@linaro.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).