summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/storage_common.h
diff options
context:
space:
mode:
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>2013-10-09 10:05:53 +0200
committerFelipe Balbi <balbi@ti.com>2013-10-10 10:21:47 -0500
commitbd528d4e699b212a763eecda9cacffb4b85a5fe6 (patch)
treeecb585092a6e4375d94639e8fe2a934ee87e4b99 /drivers/usb/gadget/storage_common.h
parent8502d66d33704d66d29c715ba5e91192b554cef0 (diff)
downloadop-kernel-dev-bd528d4e699b212a763eecda9cacffb4b85a5fe6.zip
op-kernel-dev-bd528d4e699b212a763eecda9cacffb4b85a5fe6.tar.gz
usb: gadget: f_mass_storage: make sysfs interface optional
When configfs is in place, the luns will not be represented in sysfs, so there will be no struct device associated with a lun. In order to maintain compatibility and allow configfs adoption sysfs is made optional in this patch. As a consequence some debug macros need to be adjusted. Two new fields are added to struct fsg_lun: name and name_pfx. The "name" is for storing a string which is presented to the user instead of the dev_name. The "name_pfx", if non-NULL, is prepended to the "name" at printing time. The name_pfx is for a future lun.0, which will be a default group in mass_storage.<name>. By design at USB function configfs group's creation time its name is not known (but instead set a bit later in drivers/usb/gadget/configfs.c:function_make) and it is this name that serves the purpose of the said name prefix. So instead of copying a yet-unknown string a pointer to it is stored in struct fsg_lun. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/storage_common.h')
-rw-r--r--drivers/usb/gadget/storage_common.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/usb/gadget/storage_common.h b/drivers/usb/gadget/storage_common.h
index 1fcda2b..d8cc090 100644
--- a/drivers/usb/gadget/storage_common.h
+++ b/drivers/usb/gadget/storage_common.h
@@ -17,10 +17,20 @@
#define VLDBG(lun, fmt, args...) do { } while (0)
#endif /* VERBOSE_DEBUG */
-#define LDBG(lun, fmt, args...) dev_dbg(&(lun)->dev, fmt, ## args)
-#define LERROR(lun, fmt, args...) dev_err(&(lun)->dev, fmt, ## args)
-#define LWARN(lun, fmt, args...) dev_warn(&(lun)->dev, fmt, ## args)
-#define LINFO(lun, fmt, args...) dev_info(&(lun)->dev, fmt, ## args)
+#define _LMSG(func, lun, fmt, args...) \
+ do { \
+ if ((lun)->name_pfx && *(lun)->name_pfx) \
+ func("%s/%s: " fmt, *(lun)->name_pfx, \
+ (lun)->name, ## args); \
+ else \
+ func("%s: " fmt, (lun)->name, ## args); \
+ } while (0)
+
+#define LDBG(lun, fmt, args...) _LMSG(pr_debug, lun, fmt, ## args)
+#define LERROR(lun, fmt, args...) _LMSG(pr_err, lun, fmt, ## args)
+#define LWARN(lun, fmt, args...) _LMSG(pr_warn, lun, fmt, ## args)
+#define LINFO(lun, fmt, args...) _LMSG(pr_info, lun, fmt, ## args)
+
#ifdef DUMP_MSGS
@@ -100,6 +110,8 @@ struct fsg_lun {
of bound block device */
unsigned int blksize; /* logical block size of bound block device */
struct device dev;
+ const char *name; /* "lun.name" */
+ const char **name_pfx; /* "function.name" */
};
static inline bool fsg_lun_is_open(struct fsg_lun *curlun)
OpenPOWER on IntegriCloud