Thread (12 messages) 12 messages, 4 authors, 2012-09-03

Re: [PATCH v6 1/3] spi/pl022: Add chip select handling via GPIO

From: shiraz hashim <hidden>
Date: 2012-09-02 13:13:20
Also in: linux-spi, lkml

Hi Linus,

On Sun, Sep 2, 2012 at 12:48 PM, Linus Walleij [off-list ref] wrote:
On Sat, Sep 1, 2012 at 1:14 PM, shiraz hashim
[off-list ref] wrote:
quoted
Hi Roland,

On Wed, Aug 22, 2012 at 7:19 PM, Roland Stigge [off-list ref] wrote:
quoted
@@ -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

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help