summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/storage_common.c
diff options
context:
space:
mode:
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>2013-10-09 10:06:03 +0200
committerFelipe Balbi <balbi@ti.com>2013-10-10 10:24:15 -0500
commit77850ae28607f33c1388928b9a4146ee2e0e57cf (patch)
tree1b5280848da08002e9674963ee0fe6f9b0452867 /drivers/usb/gadget/storage_common.c
parent2412fbf1ffac21da14308924ccb17fe1a5506b1a (diff)
downloadtalos-obmc-linux-77850ae28607f33c1388928b9a4146ee2e0e57cf.tar.gz
talos-obmc-linux-77850ae28607f33c1388928b9a4146ee2e0e57cf.zip
usb: gadget: storage_common: make attribute operations more generic
Show/store methods for sysfs attributes contain code which can be used also by configfs. Make them abstract the source the lun and rw_semaphore are taken from. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/storage_common.c')
-rw-r--r--drivers/usb/gadget/storage_common.c31
1 files changed, 6 insertions, 25 deletions
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
index 3e2500f19140..969948dc2596 100644
--- a/drivers/usb/gadget/storage_common.c
+++ b/drivers/usb/gadget/storage_common.c
@@ -31,11 +31,6 @@
#include "storage_common.h"
-static inline struct fsg_lun *fsg_lun_from_dev(struct device *dev)
-{
- return container_of(dev, struct fsg_lun, dev);
-}
-
/* There is only one interface. */
struct usb_interface_descriptor fsg_intf_desc = {
@@ -324,31 +319,23 @@ EXPORT_SYMBOL(store_cdrom_address);
/*-------------------------------------------------------------------------*/
-ssize_t fsg_show_ro(struct device *dev, struct device_attribute *attr,
- char *buf)
+ssize_t fsg_show_ro(struct fsg_lun *curlun, char *buf)
{
- struct fsg_lun *curlun = fsg_lun_from_dev(dev);
-
return sprintf(buf, "%d\n", fsg_lun_is_open(curlun)
? curlun->ro
: curlun->initially_ro);
}
EXPORT_SYMBOL(fsg_show_ro);
-ssize_t fsg_show_nofua(struct device *dev, struct device_attribute *attr,
- char *buf)
+ssize_t fsg_show_nofua(struct fsg_lun *curlun, char *buf)
{
- struct fsg_lun *curlun = fsg_lun_from_dev(dev);
-
return sprintf(buf, "%u\n", curlun->nofua);
}
EXPORT_SYMBOL(fsg_show_nofua);
-ssize_t fsg_show_file(struct device *dev, struct device_attribute *attr,
+ssize_t fsg_show_file(struct fsg_lun *curlun, struct rw_semaphore *filesem,
char *buf)
{
- struct fsg_lun *curlun = fsg_lun_from_dev(dev);
- struct rw_semaphore *filesem = dev_get_drvdata(dev);
char *p;
ssize_t rc;
@@ -373,12 +360,10 @@ ssize_t fsg_show_file(struct device *dev, struct device_attribute *attr,
EXPORT_SYMBOL(fsg_show_file);
-ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr,
+ssize_t fsg_store_ro(struct fsg_lun *curlun, struct rw_semaphore *filesem,
const char *buf, size_t count)
{
ssize_t rc;
- struct fsg_lun *curlun = fsg_lun_from_dev(dev);
- struct rw_semaphore *filesem = dev_get_drvdata(dev);
unsigned ro;
rc = kstrtouint(buf, 2, &ro);
@@ -404,10 +389,8 @@ ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr,
}
EXPORT_SYMBOL(fsg_store_ro);
-ssize_t fsg_store_nofua(struct device *dev, struct device_attribute *attr,
- const char *buf, size_t count)
+ssize_t fsg_store_nofua(struct fsg_lun *curlun, const char *buf, size_t count)
{
- struct fsg_lun *curlun = fsg_lun_from_dev(dev);
unsigned nofua;
int ret;
@@ -425,11 +408,9 @@ ssize_t fsg_store_nofua(struct device *dev, struct device_attribute *attr,
}
EXPORT_SYMBOL(fsg_store_nofua);
-ssize_t fsg_store_file(struct device *dev, struct device_attribute *attr,
+ssize_t fsg_store_file(struct fsg_lun *curlun, struct rw_semaphore *filesem,
const char *buf, size_t count)
{
- struct fsg_lun *curlun = fsg_lun_from_dev(dev);
- struct rw_semaphore *filesem = dev_get_drvdata(dev);
int rc = 0;
if (curlun->prevent_medium_removal && fsg_lun_is_open(curlun)) {
OpenPOWER on IntegriCloud