linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] firmware: read firmware size using i_size_read()
@ 2014-06-12 21:05 Dmitry Kasatkin
  2014-06-13 14:56 ` Ming Lei
  0 siblings, 1 reply; 10+ messages in thread
From: Dmitry Kasatkin @ 2014-06-12 21:05 UTC (permalink / raw)
  To: ming.lei; +Cc: gregkh, linux-kernel, 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 <d.kasatkin@samsung.com>
---
 drivers/base/firmware_class.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index c30df50e..9aaa97b 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -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);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/1] firmware: read firmware size using i_size_read()
  2014-06-12 21:05 [PATCH 1/1] firmware: read firmware size using i_size_read() Dmitry Kasatkin
@ 2014-06-13 14:56 ` Ming Lei
  2014-06-13 15:09   ` [PATCH v2 0/1] " Dmitry Kasatkin
  0 siblings, 1 reply; 10+ messages in thread
From: Ming Lei @ 2014-06-13 14:56 UTC (permalink / raw)
  To: Dmitry Kasatkin
  Cc: Greg Kroah-Hartman, Linux Kernel Mailing List, Dmitry Kasatkin

On Fri, Jun 13, 2014 at 5:05 AM, Dmitry Kasatkin
<dmitry.kasatkin@gmail.com> wrote:
> 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>
> ---
>  drivers/base/firmware_class.c | 15 +--------------
>  1 file changed, 1 insertion(+), 14 deletions(-)
>
> diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
> index c30df50e..9aaa97b 100644
> --- a/drivers/base/firmware_class.c
> +++ b/drivers/base/firmware_class.c
> @@ -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);
> --

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 0/1] read firmware size using i_size_read()
  2014-06-13 14:56 ` Ming Lei
@ 2014-06-13 15:09   ` Dmitry Kasatkin
  2014-06-13 15:09     ` [PATCH v2 1/1] firmware: " Dmitry Kasatkin
  0 siblings, 1 reply; 10+ messages in thread
From: Dmitry Kasatkin @ 2014-06-13 15:09 UTC (permalink / raw)
  To: ming.lei; +Cc: gregkh, linux-kernel, dmitry.kasatkin, Dmitry Kasatkin

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(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/1] firmware: read firmware size using i_size_read()
  2014-06-13 15:09   ` [PATCH v2 0/1] " Dmitry Kasatkin
@ 2014-06-13 15:09     ` Dmitry Kasatkin
  2014-06-13 16:03       ` Ming Lei
  0 siblings, 1 reply; 10+ messages in thread
From: Dmitry Kasatkin @ 2014-06-13 15:09 UTC (permalink / raw)
  To: ming.lei; +Cc: gregkh, linux-kernel, dmitry.kasatkin, 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 <d.kasatkin@samsung.com>
---
 drivers/base/firmware_class.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index d276e33..e84da14 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -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);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/1] firmware: read firmware size using i_size_read()
  2014-06-13 15:09     ` [PATCH v2 1/1] firmware: " Dmitry Kasatkin
@ 2014-06-13 16:03       ` Ming Lei
  2014-06-13 16:06         ` Dmitry Kasatkin
  0 siblings, 1 reply; 10+ messages in thread
From: Ming Lei @ 2014-06-13 16:03 UTC (permalink / raw)
  To: Dmitry Kasatkin
  Cc: Greg Kroah-Hartman, Linux Kernel Mailing List, Dmitry Kasatkin

On Fri, Jun 13, 2014 at 11:09 PM, Dmitry Kasatkin
<d.kasatkin@samsung.com> wrote:
> 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>


Thanks,
--
Ming Lei

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/1] firmware: read firmware size using i_size_read()
  2014-06-13 16:03       ` Ming Lei
@ 2014-06-13 16:06         ` Dmitry Kasatkin
  2014-06-25 16:46           ` Dmitry Kasatkin
  0 siblings, 1 reply; 10+ messages in thread
From: Dmitry Kasatkin @ 2014-06-13 16:06 UTC (permalink / raw)
  To: Ming Lei; +Cc: Dmitry Kasatkin, Greg Kroah-Hartman, Linux Kernel Mailing List

On 13 June 2014 19:03, Ming Lei <ming.lei@canonical.com> wrote:
> On Fri, Jun 13, 2014 at 11:09 PM, Dmitry Kasatkin
> <d.kasatkin@samsung.com> wrote:
>> 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>
>
>
> Thanks,
> --
> Ming Lei

Thanks.



-- 
Thanks,
Dmitry

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/1] firmware: read firmware size using i_size_read()
  2014-06-13 16:06         ` Dmitry Kasatkin
@ 2014-06-25 16:46           ` Dmitry Kasatkin
  2014-07-02  1:33             ` Ming Lei
  2014-07-08 22:26             ` Greg Kroah-Hartman
  0 siblings, 2 replies; 10+ messages in thread
From: Dmitry Kasatkin @ 2014-06-25 16:46 UTC (permalink / raw)
  To: Ming Lei; +Cc: Dmitry Kasatkin, Greg Kroah-Hartman, Linux Kernel Mailing List

On 13 June 2014 19:06, Dmitry Kasatkin <dmitry.kasatkin@gmail.com> wrote:
> On 13 June 2014 19:03, Ming Lei <ming.lei@canonical.com> wrote:
>> On Fri, Jun 13, 2014 at 11:09 PM, Dmitry Kasatkin
>> <d.kasatkin@samsung.com> wrote:
>>> 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>
>>


Hi,

BTW. To what tree it is applied?

-- 
Thanks,
Dmitry

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/1] firmware: read firmware size using i_size_read()
  2014-06-25 16:46           ` Dmitry Kasatkin
@ 2014-07-02  1:33             ` Ming Lei
  2014-07-02  5:27               ` Greg Kroah-Hartman
  2014-07-08 22:26             ` Greg Kroah-Hartman
  1 sibling, 1 reply; 10+ messages in thread
From: Ming Lei @ 2014-07-02  1:33 UTC (permalink / raw)
  To: Dmitry Kasatkin
  Cc: Dmitry Kasatkin, Greg Kroah-Hartman, Linux Kernel Mailing List

On Thu, Jun 26, 2014 at 12:46 AM, Dmitry Kasatkin
<dmitry.kasatkin@gmail.com> wrote:
> On 13 June 2014 19:06, Dmitry Kasatkin <dmitry.kasatkin@gmail.com> wrote:
>> On 13 June 2014 19:03, Ming Lei <ming.lei@canonical.com> wrote:
>>> On Fri, Jun 13, 2014 at 11:09 PM, Dmitry Kasatkin
>>> <d.kasatkin@samsung.com> wrote:
>>>> 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>
>>>
>
>
> Hi,
>
> BTW. To what tree it is applied?

Greg will take it in driver-core tree.

Thanks,
--
Ming Lei

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/1] firmware: read firmware size using i_size_read()
  2014-07-02  1:33             ` Ming Lei
@ 2014-07-02  5:27               ` Greg Kroah-Hartman
  0 siblings, 0 replies; 10+ messages in thread
From: Greg Kroah-Hartman @ 2014-07-02  5:27 UTC (permalink / raw)
  To: Ming Lei; +Cc: Dmitry Kasatkin, Dmitry Kasatkin, Linux Kernel Mailing List

On Wed, Jul 02, 2014 at 09:33:49AM +0800, Ming Lei wrote:
> On Thu, Jun 26, 2014 at 12:46 AM, Dmitry Kasatkin
> <dmitry.kasatkin@gmail.com> wrote:
> > On 13 June 2014 19:06, Dmitry Kasatkin <dmitry.kasatkin@gmail.com> wrote:
> >> On 13 June 2014 19:03, Ming Lei <ming.lei@canonical.com> wrote:
> >>> On Fri, Jun 13, 2014 at 11:09 PM, Dmitry Kasatkin
> >>> <d.kasatkin@samsung.com> wrote:
> >>>> 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>
> >>>
> >
> >
> > 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/1] firmware: read firmware size using i_size_read()
  2014-06-25 16:46           ` Dmitry Kasatkin
  2014-07-02  1:33             ` Ming Lei
@ 2014-07-08 22:26             ` Greg Kroah-Hartman
  1 sibling, 0 replies; 10+ messages in thread
From: Greg Kroah-Hartman @ 2014-07-08 22:26 UTC (permalink / raw)
  To: Dmitry Kasatkin; +Cc: Ming Lei, Dmitry Kasatkin, Linux Kernel Mailing List

On Wed, Jun 25, 2014 at 07:46:41PM +0300, Dmitry Kasatkin wrote:
> On 13 June 2014 19:06, Dmitry Kasatkin <dmitry.kasatkin@gmail.com> wrote:
> > On 13 June 2014 19:03, Ming Lei <ming.lei@canonical.com> wrote:
> >> On Fri, Jun 13, 2014 at 11:09 PM, Dmitry Kasatkin
> >> <d.kasatkin@samsung.com> wrote:
> >>> 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>
> >>
> 
> 
> Hi,
> 
> BTW. To what tree it is applied?

Mine now, you should get an email soon...

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-07-08 22:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-12 21:05 [PATCH 1/1] firmware: read firmware size using i_size_read() Dmitry Kasatkin
2014-06-13 14:56 ` Ming Lei
2014-06-13 15:09   ` [PATCH v2 0/1] " Dmitry Kasatkin
2014-06-13 15:09     ` [PATCH v2 1/1] firmware: " Dmitry Kasatkin
2014-06-13 16:03       ` Ming Lei
2014-06-13 16:06         ` Dmitry Kasatkin
2014-06-25 16:46           ` Dmitry Kasatkin
2014-07-02  1:33             ` Ming Lei
2014-07-02  5:27               ` Greg Kroah-Hartman
2014-07-08 22:26             ` Greg Kroah-Hartman

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).