From: Sebastian Reichel <sre@kernel.org>
To: Sebastian Reichel <sre@kernel.org>
Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>,
Kai Vehmanen <kvcontact@nosignal.fi>, Pavel Machek <pavel@ucw.cz>,
Pali Rohar <pali.rohar@gmail.com>,
Aaro Koskinen <aaro.koskinen@iki.fi>,
Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>,
linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-api@vger.kernel.org, Kai Vehmanen <kai.vehmanen@nokia.com>,
Joni Lapilainen <joni.lapilainen@gmail.com>
Subject: [PATCH 2/9] HSI: cmt_speech: Avoid GFP_ATOMIC in cs_char_open
Date: Mon, 2 Mar 2015 05:38:52 +0100 [thread overview]
Message-ID: <1425271139-24715-3-git-send-email-sre@kernel.org> (raw)
In-Reply-To: <1425271139-24715-1-git-send-email-sre@kernel.org>
From: Kai Vehmanen <kai.vehmanen@nokia.com>
Also fixes a bug in updating 'opened' state in case cs_hsi_start()
fails when opening the char device.
Signed-off-by: Kai Vehmanen <kai.vehmanen@nokia.com>
Signed-off-by: Joni Lapilainen <joni.lapilainen@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
drivers/hsi/clients/cmt_speech.c | 43 +++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 18 deletions(-)
diff --git a/drivers/hsi/clients/cmt_speech.c b/drivers/hsi/clients/cmt_speech.c
index 7c0f711..389eafb 100644
--- a/drivers/hsi/clients/cmt_speech.c
+++ b/drivers/hsi/clients/cmt_speech.c
@@ -1271,38 +1271,45 @@ static int cs_char_mmap(struct file *file, struct vm_area_struct *vma)
static int cs_char_open(struct inode *unused, struct file *file)
{
int ret = 0;
+ unsigned long p;
spin_lock_bh(&cs_char_data.lock);
if (cs_char_data.opened) {
ret = -EBUSY;
spin_unlock_bh(&cs_char_data.lock);
- goto out;
- }
- cs_char_data.mmap_base = get_zeroed_page(GFP_ATOMIC);
- if (!cs_char_data.mmap_base) {
- dev_err(&cs_char_data.cl->device,
- "Shared memory allocation failed.\n");
- ret = -ENOMEM;
- spin_unlock_bh(&cs_char_data.lock);
- goto out;
+ goto out1;
}
- cs_char_data.mmap_size = CS_MMAP_SIZE;
- cs_char_data.dataind_pending = 0;
cs_char_data.opened = 1;
- file->private_data = &cs_char_data;
+ cs_char_data.dataind_pending = 0;
spin_unlock_bh(&cs_char_data.lock);
- BUG_ON(cs_char_data.hi);
+ p = get_zeroed_page(GFP_KERNEL);
+ if (!p) {
+ ret = -ENOMEM;
+ goto out2;
+ }
- ret = cs_hsi_start(&cs_char_data.hi, cs_char_data.cl,
- cs_char_data.mmap_base, cs_char_data.mmap_size);
+ ret = cs_hsi_start(&cs_char_data.hi, cs_char_data.cl, p, CS_MMAP_SIZE);
if (ret) {
dev_err(&cs_char_data.cl->device, "Unable to initialize HSI\n");
- free_page(cs_char_data.mmap_base);
- goto out;
+ goto out3;
}
-out:
+ /* these are only used in release so lock not needed */
+ cs_char_data.mmap_base = p;
+ cs_char_data.mmap_size = CS_MMAP_SIZE;
+
+ file->private_data = &cs_char_data;
+
+ return 0;
+
+out3:
+ free_page(p);
+out2:
+ spin_lock_bh(&cs_char_data.lock);
+ cs_char_data.opened = 0;
+ spin_unlock_bh(&cs_char_data.lock);
+out1:
return ret;
}
--
2.1.4
next prev parent reply other threads:[~2015-03-02 4:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-02 4:38 [PATCH 0/9] N900 Modem Speech Support Sebastian Reichel
2015-03-02 4:38 ` [PATCH 1/9] HSI: cmt_speech: Add cmt-speech driver Sebastian Reichel
2015-03-02 10:22 ` Oliver Neukum
2015-03-02 15:26 ` Sebastian Reichel
2015-03-02 10:29 ` Oliver Neukum
2015-03-02 20:56 ` Aaro Koskinen
2015-03-02 4:38 ` Sebastian Reichel [this message]
2015-03-02 4:38 ` [PATCH 3/9] HSI: cmt_speech: Return error if HSI port not configured Sebastian Reichel
2015-03-02 4:38 ` [PATCH 4/9] HSI: cmt_speech: Fix build for 4.0 kernel Sebastian Reichel
2015-03-02 4:38 ` [PATCH 5/9] HSI: cmt_speech: Cleanup initialisation Sebastian Reichel
2015-03-02 4:38 ` [PATCH 6/9] HSI: cmt_speech: Rename driver to cmt-speech Sebastian Reichel
2015-03-02 4:38 ` [PATCH 7/9] HSI: cmt_speech: Move cs-protocol.h to include/uapi/linux/hsi Sebastian Reichel
2015-03-02 4:38 ` [PATCH 8/9] HSI: cmt_speech: Remove hardcoded channel numbers Sebastian Reichel
2015-03-02 4:38 ` [PATCH 9/9] HSI: nokia-modem: Add cmt_speech support Sebastian Reichel
2015-03-02 19:05 ` [PATCH 0/9] N900 Modem Speech Support Pali Rohár
2015-03-02 20:51 ` Sebastian Reichel
2015-03-03 17:46 ` Pali Rohár
2015-03-03 13:33 ` Pavel Machek
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=1425271139-24715-3-git-send-email-sre@kernel.org \
--to=sre@kernel.org \
--cc=aaro.koskinen@iki.fi \
--cc=ivo.g.dimitrov.75@gmail.com \
--cc=joni.lapilainen@gmail.com \
--cc=kai.vehmanen@nokia.com \
--cc=kvcontact@nosignal.fi \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=pali.rohar@gmail.com \
--cc=pavel@ucw.cz \
--cc=peter.ujfalusi@ti.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).