From: Roland Stigge <stigge-uj/7R2tJ6VmzQB+pC5nmwQ@public.gmane.org>
To: linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
shiraz.linux.kernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
aletes.xgr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org,
grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org,
rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org,
rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org,
linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
gabriel.fernandez-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org,
lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
sachin.verma-lpHj6iFQ3dU@public.gmane.org
Cc: Roland Stigge <stigge-uj/7R2tJ6VmzQB+pC5nmwQ@public.gmane.org>
Subject: [PATCH] spi/pl022: Fix chipselects pointer computation
Date: Mon, 3 Sep 2012 10:14:29 +0200 [thread overview]
Message-ID: <1346660069-16049-1-git-send-email-stigge@antcom.de> (raw)
The new chip select handling via GPIO introduced a pointer computation bug:
(int *) pl022 + sizeof(struct pl022)
doesn't point to the data immediately after the actual struct pl022 (as was
intended) but to a multiple of bytes after it because of the (int *) type.
Replacing the kludgy pointer arithmetic with managed memory allocation for the
chip selects.
Signed-off-by: Roland Stigge <stigge-uj/7R2tJ6VmzQB+pC5nmwQ@public.gmane.org>
---
drivers/spi/spi-pl022.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
--- linux-2.6.orig/drivers/spi/spi-pl022.c
+++ linux-2.6/drivers/spi/spi-pl022.c
@@ -2053,8 +2053,7 @@ pl022_probe(struct amba_device *adev, co
}
/* Allocate master with space for data */
- master = spi_alloc_master(dev, sizeof(struct pl022) + sizeof(int) *
- num_cs);
+ master = spi_alloc_master(dev, sizeof(struct pl022));
if (master == NULL) {
dev_err(&adev->dev, "probe - cannot alloc SPI master\n");
status = -ENOMEM;
@@ -2066,8 +2065,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);
+ pl022->chipselects = devm_kzalloc(dev, num_cs * sizeof(int),
+ GFP_KERNEL);
/*
* Bus Number Which has been Assigned to this SSP controller
------------------------------------------------------------------------------
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/
next reply other threads:[~2012-09-03 8:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-03 8:14 Roland Stigge [this message]
2012-09-03 9:11 ` [PATCH] spi/pl022: Fix chipselects pointer computation Linus Walleij
2012-09-05 23:44 ` Mark Brown
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=1346660069-16049-1-git-send-email-stigge@antcom.de \
--to=stigge-uj/7r2tj6vmzqb+pc5nmwq@public.gmane.org \
--cc=aletes.xgr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
--cc=gabriel.fernandez-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org \
--cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
--cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org \
--cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org \
--cc=sachin.verma-lpHj6iFQ3dU@public.gmane.org \
--cc=shiraz.linux.kernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@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).