All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] usb: call bdev_read_only() only on CONFIG_BLOCK
@ 2007-03-27  9:03 David Rientjes
  2007-03-27  9:37 ` Sam Ravnborg
  0 siblings, 1 reply; 3+ messages in thread
From: David Rientjes @ 2007-03-27  9:03 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Alan Stern, linux-kernel

bdev_read_only() is only defined on CONFIG_BLOCK so we make sure not to
call it unless we have it.  A new static inline function,
is_inode_read_only(), is invoked to call bdev_read_only() on CONFIG_BLOCK
and return zero otherwise.

Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: David Rientjes <rientjes@google.com>
---
 drivers/usb/gadget/file_storage.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -3493,6 +3493,14 @@ static int fsg_main_thread(void *fsg_)
 	complete_and_exit(&fsg->thread_notifier, 0);
 }
 
+#ifdef CONFIG_BLOCK
+static inline int is_inode_read_only(struct inode *inode)
+{
+	return bdev_read_only(inode->i_bdev);
+}
+#else
+#define is_inode_read_only(inode)	(0)
+#endif
 
 /*-------------------------------------------------------------------------*/
 
@@ -3528,7 +3536,7 @@ static int open_backing_file(struct lun *curlun, const char *filename)
 	if (filp->f_path.dentry)
 		inode = filp->f_path.dentry->d_inode;
 	if (inode && S_ISBLK(inode->i_mode)) {
-		if (bdev_read_only(inode->i_bdev))
+		if (is_inode_read_only(inode))
 			ro = 1;
 	} else if (!inode || !S_ISREG(inode->i_mode)) {
 		LINFO(curlun, "invalid file type: %s\n", filename);

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

* Re: [patch] usb: call bdev_read_only() only on CONFIG_BLOCK
  2007-03-27  9:03 [patch] usb: call bdev_read_only() only on CONFIG_BLOCK David Rientjes
@ 2007-03-27  9:37 ` Sam Ravnborg
  2007-03-27 16:04   ` Alan Stern
  0 siblings, 1 reply; 3+ messages in thread
From: Sam Ravnborg @ 2007-03-27  9:37 UTC (permalink / raw)
  To: David Rientjes; +Cc: Linus Torvalds, Alan Stern, linux-kernel

On Tue, Mar 27, 2007 at 02:03:25AM -0700, David Rientjes wrote:
> bdev_read_only() is only defined on CONFIG_BLOCK so we make sure not to
> call it unless we have it.  A new static inline function,
> is_inode_read_only(), is invoked to call bdev_read_only() on CONFIG_BLOCK
> and return zero otherwise.
> 
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
>  drivers/usb/gadget/file_storage.c |   10 +++++++++-
>  1 files changed, 9 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
> --- a/drivers/usb/gadget/file_storage.c
> +++ b/drivers/usb/gadget/file_storage.c
> @@ -3493,6 +3493,14 @@ static int fsg_main_thread(void *fsg_)
>  	complete_and_exit(&fsg->thread_notifier, 0);
>  }
>  
> +#ifdef CONFIG_BLOCK
> +static inline int is_inode_read_only(struct inode *inode)
> +{
> +	return bdev_read_only(inode->i_bdev);
> +}
> +#else
> +#define is_inode_read_only(inode)	(0)
> +#endif

This looks like the wrong place to fix this.
Like we do with for exampel the pci_ functions we should provide a dummy
implementation in the kernel if configured without CONFIG_BLOCK.

In this way the decision to provide dummy functions are centralized
and benefits all users.

	Sam

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

* Re: [patch] usb: call bdev_read_only() only on CONFIG_BLOCK
  2007-03-27  9:37 ` Sam Ravnborg
@ 2007-03-27 16:04   ` Alan Stern
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Stern @ 2007-03-27 16:04 UTC (permalink / raw)
  To: David Rientjes, Sam Ravnborg; +Cc: Linus Torvalds, Kernel development list

On Tue, 27 Mar 2007, Sam Ravnborg wrote:

> On Tue, Mar 27, 2007 at 02:03:25AM -0700, David Rientjes wrote:
> > bdev_read_only() is only defined on CONFIG_BLOCK so we make sure not to
> > call it unless we have it.  A new static inline function,
> > is_inode_read_only(), is invoked to call bdev_read_only() on CONFIG_BLOCK
> > and return zero otherwise.
> > 
> > Cc: Alan Stern <stern@rowland.harvard.edu>
> > Signed-off-by: David Rientjes <rientjes@google.com>
> > ---
> >  drivers/usb/gadget/file_storage.c |   10 +++++++++-
> >  1 files changed, 9 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
> > --- a/drivers/usb/gadget/file_storage.c
> > +++ b/drivers/usb/gadget/file_storage.c
> > @@ -3493,6 +3493,14 @@ static int fsg_main_thread(void *fsg_)
> >  	complete_and_exit(&fsg->thread_notifier, 0);
> >  }
> >  
> > +#ifdef CONFIG_BLOCK
> > +static inline int is_inode_read_only(struct inode *inode)
> > +{
> > +	return bdev_read_only(inode->i_bdev);
> > +}
> > +#else
> > +#define is_inode_read_only(inode)	(0)
> > +#endif
> 
> This looks like the wrong place to fix this.
> Like we do with for exampel the pci_ functions we should provide a dummy
> implementation in the kernel if configured without CONFIG_BLOCK.
> 
> In this way the decision to provide dummy functions are centralized
> and benefits all users.

In any case this patch is unnecessary.  There is a patch in the USB 
development tree making USB_FILE_STORAGE dependent on CONFIG_BLOCK.

Alan Stern


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

end of thread, other threads:[~2007-03-27 16:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-27  9:03 [patch] usb: call bdev_read_only() only on CONFIG_BLOCK David Rientjes
2007-03-27  9:37 ` Sam Ravnborg
2007-03-27 16:04   ` Alan Stern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.