From: "Antonino A. Daplas" <adaplas@gmail.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-fbdev-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, rpurdie@rpsys.net
Subject: [PATCH] fbdev: Fix return error of fb_write
Date: Sat, 15 Apr 2006 13:38:19 +0800 [thread overview]
Message-ID: <444086CB.2000700@gmail.com> (raw)
In-Reply-To: <20060414213105.09f0dd8d.akpm@osdl.org>
Fix return code of fb_write():
If at least 1 byte was transferred to the device, return number of bytes,
otherwise:
- return -EFBIG - if file offset is past the maximum allowable offset or
size is greater than framebuffer length
- return -ENOSPC - if size is greater than framebuffer length - offset
Signed-off-by: Antonino Daplas <adaplas@pol.net>
---
Andrew Morton wrote:
> "Antonino A. Daplas" <adaplas@gmail.com> wrote:
>> Richard Purdie wrote:
>>
>> - return -EFBIG if file offset is past the maximum allowable offset
>
> OK.
>
>> - return -EFBIG and write to end of framebuffer if size is bigger than the
>> framebuffer length
>
> We should return the number of bytes written in this case.
>
>> - return -ENOSPC and write to end of framebuffer if size is bigger than the
>> framebuffer length - file offset
>
> Also here.
>
>
> If we can transfer _any_ bytes, we should do so, then return the number of
> bytes transferred. If no bytes were transferrable then we should return
> -Ewhatever.
>
>
Okay, here's try #2:
drivers/video/fbmem.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 944855b..a4b6776 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -669,13 +669,19 @@ fb_write(struct file *file, const char _
total_size = info->fix.smem_len;
if (p > total_size)
- return 0;
+ return -EFBIG;
- if (count >= total_size)
+ if (count > total_size) {
+ err = -EFBIG;
count = total_size;
+ }
+
+ if (count + p > total_size) {
+ if (!err)
+ err = -ENOSPC;
- if (count + p > total_size)
count = total_size - p;
+ }
buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
GFP_KERNEL);
@@ -717,7 +723,7 @@ fb_write(struct file *file, const char _
kfree(buffer);
- return (err) ? err : cnt;
+ return (cnt) ? cnt : err;
}
#ifdef CONFIG_KMOD
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
next prev parent reply other threads:[~2006-04-15 5:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-14 10:16 Behaviour change of /dev/fb0? Richard Purdie
2006-04-14 23:29 ` [Linux-fbdev-devel] " Antonino A. Daplas
2006-04-15 0:13 ` Richard Purdie
2006-04-15 0:53 ` Antonino A. Daplas
2006-04-15 4:31 ` Andrew Morton
2006-04-15 5:38 ` Antonino A. Daplas [this message]
2006-04-17 14:45 ` [PATCH] fbdev: Fix return error of fb_write Richard Purdie
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=444086CB.2000700@gmail.com \
--to=adaplas@gmail.com \
--cc=akpm@osdl.org \
--cc=linux-fbdev-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=rpurdie@rpsys.net \
/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).