firmware: read firmware size using i_size_read()
PATCH 1/1 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.
--- drivers/base/firmware_class.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/base/firmware_class.c +1 -14
@@ -279,26 +279,13 @@ 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); + size =i_size_read (file_inode (file));if (size <=0 )return -EINVAL ; buf =vmalloc (size);
Signature · 1 line
1.9.1
Quoted 31 lines · Dmitry Kasatkin
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 <[email protected]>--- drivers/base/firmware_class.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)drivers/base/firmware_class.c +0
-13@@ -279,26 +279,13 @@ 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) {
drivers/base/firmware_class.c static const char * const fw_path[] = {
Quoted 10 lines
drivers/base/firmware_class.c +1
-2int size;char *buf;int rc; - size =fw_file_size (file); + size =i_size_read (file_inode (file));if (size <=0 )return -EINVAL ; buf =vmalloc (size); --
fw_file_size() not only return size of the file, but also check if it is a regular file, and its size.
Thanks,
--
Ming Lei
v2 cover read firmware size using i_size_read()
Hi,
You are right about file type.
inode structure also contains information about file type.. There is no need to use vfs_getattr().
Thanks,
Dmitry
Dmitry Kasatkin (1):
firmware: read firmware size using i_size_read()
drivers/base/firmware_class.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/1 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.
--- drivers/base/firmware_class.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/base/firmware_class.c +3 -14
@@ -279,26 +279,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);
Signature · 1 line
1.9.1
Quoted 4 lines · Dmitry Kasatkin
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 <[email protected]>
Thanks,
--
Ming Lei
Quoted 5 lines · Ming Lei
Quoted 3 lines · Dmitry Kasatkin
There is no need to read attr because inode structure contains size of the file. Use
i_size_read()instead.
Quoted 8 lines
Quoted 1 line
Signed-off-by Dmitry Kasatkin <[email protected]>Acked-by Ming Lei <[email protected]>Thanks,
--
Ming Lei
Thanks.
Signature · 2 lines
Thanks, Dmitry
Quoted 10 lines · Dmitry Kasatkin
Quoted 9 lines · Ming Lei
Quoted 4 lines · Dmitry Kasatkin
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 <[email protected]>Acked-by Ming Lei <[email protected]>
Hi,
BTW. To what tree it is applied?
Signature · 2 lines
Thanks, Dmitry
Quoted 9 lines · Dmitry Kasatkin
Quoted 8 lines · Dmitry Kasatkin
Quoted 7 lines · Ming Lei
Quoted 4 lines · Dmitry Kasatkin
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 <[email protected]>
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Acked-by Ming Lei <[email protected]>Hi,
BTW. To what tree it is applied?
Greg will take it in driver-core tree.
Thanks,
--
Ming Lei
Greg Kroah-Hartman
maintainerQuoted 15 lines · Ming Lei
Quoted 13 lines · Dmitry Kasatkin
Quoted 10 lines · Dmitry Kasatkin
Quoted 9 lines · Ming Lei
Quoted 4 lines · Dmitry Kasatkin
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 <[email protected]>Acked-by Ming Lei <[email protected]>
Quoted 5 lines
Quoted 3 lines
Hi,
BTW. To what tree it is applied?
Greg will take it in driver-core tree.
Yes, I'll catch up on pending patches next week, thanks.
greg k-h
Greg Kroah-Hartman
maintainerQuoted 9 lines · Dmitry Kasatkin
Quoted 8 lines · Dmitry Kasatkin
Quoted 7 lines · Ming Lei
Quoted 4 lines · Dmitry Kasatkin
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 <[email protected]>
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Acked-by Ming Lei <[email protected]>Hi,
BTW. To what tree it is applied?
Mine now, you should get an email soon...