summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorDmitry Kasatkin <d.kasatkin@samsung.com>2014-06-13 18:09:54 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-07-08 15:27:04 -0700
commit6af6b163b3191bd2802868f17d4843c58bc4046f (patch)
tree7e5c23b2698550828906ea98ca5c1e25e4025020 /drivers/base
parent5a1379e8748a5cfa3eb068f812d61bde849ef76c (diff)
firmware: read firmware size using i_size_read()
There is no need to read attr because inode structure contains size of the file. Use i_size_read() instead. Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com> Acked-by: Ming Lei <ming.lei@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/firmware_class.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 46ea5f4c3bb5..304691c5e2bc 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -284,26 +284,15 @@ static const char * const fw_path[] = {
module_param_string(path, fw_path_para, sizeof(fw_path_para), 0644);
MODULE_PARM_DESC(path, "customized firmware image search path with a higher priority than default path");
-/* Don't inline this: 'struct kstat' is biggish */
-static noinline_for_stack int fw_file_size(struct file *file)
-{
- struct kstat st;
- if (vfs_getattr(&file->f_path, &st))
- return -1;
- if (!S_ISREG(st.mode))
- return -1;
- if (st.size != (int)st.size)
- return -1;
- return st.size;
-}
-
static int fw_read_file_contents(struct file *file, struct firmware_buf *fw_buf)
{
int size;
char *buf;
int rc;
- size = fw_file_size(file);
+ if (!S_ISREG(file_inode(file)->i_mode))
+ return -EINVAL;
+ size = i_size_read(file_inode(file));
if (size <= 0)
return -EINVAL;
buf = vmalloc(size);