static ssize_t ro_show(struct device *dev, struct device_attribute *attr, char *buf)
{
- return fsg_show_ro(dev, attr, buf);
+ struct fsg_lun *curlun = fsg_lun_from_dev(dev);
+
+ return fsg_show_ro(curlun, buf);
}
static ssize_t nofua_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
- return fsg_show_nofua(dev, attr, buf);
+ struct fsg_lun *curlun = fsg_lun_from_dev(dev);
+
+ return fsg_show_nofua(curlun, buf);
}
static ssize_t file_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
- return fsg_show_file(dev, attr, buf);
+ struct fsg_lun *curlun = fsg_lun_from_dev(dev);
+ struct rw_semaphore *filesem = dev_get_drvdata(dev);
+
+ return fsg_show_file(curlun, filesem, buf);
}
static ssize_t ro_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- return fsg_store_ro(dev, attr, buf, count);
+ struct fsg_lun *curlun = fsg_lun_from_dev(dev);
+ struct rw_semaphore *filesem = dev_get_drvdata(dev);
+
+ return fsg_store_ro(curlun, filesem, buf, count);
}
static ssize_t nofua_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- return fsg_store_nofua(dev, attr, buf, count);
+ struct fsg_lun *curlun = fsg_lun_from_dev(dev);
+
+ return fsg_store_nofua(curlun, buf, count);
}
static ssize_t file_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- return fsg_store_file(dev, attr, buf, count);
+ struct fsg_lun *curlun = fsg_lun_from_dev(dev);
+ struct rw_semaphore *filesem = dev_get_drvdata(dev);
+
+ return fsg_store_file(curlun, filesem, buf, count);
}
static DEVICE_ATTR_RW(ro);
#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 = {
/*-------------------------------------------------------------------------*/
-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;
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);
}
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;
}
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)) {
return 0xffffff & (u32) get_unaligned_be32(buf - 1);
}
+static inline struct fsg_lun *fsg_lun_from_dev(struct device *dev)
+{
+ return container_of(dev, struct fsg_lun, dev);
+}
+
enum {
FSG_STRING_INTERFACE
};
int fsg_lun_open(struct fsg_lun *curlun, const char *filename);
int fsg_lun_fsync_sub(struct fsg_lun *curlun);
void store_cdrom_address(u8 *dest, int msf, u32 addr);
-ssize_t fsg_show_ro(struct device *dev, struct device_attribute *attr,
- char *buf);
-ssize_t fsg_show_nofua(struct device *dev, struct device_attribute *attr,
- char *buf);
-ssize_t fsg_show_file(struct device *dev, struct device_attribute *attr,
+ssize_t fsg_show_ro(struct fsg_lun *curlun, char *buf);
+ssize_t fsg_show_nofua(struct fsg_lun *curlun, char *buf);
+ssize_t fsg_show_file(struct fsg_lun *curlun, struct rw_semaphore *filesem,
char *buf);
-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 fsg_store_nofua(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count);
-ssize_t fsg_store_file(struct device *dev, struct device_attribute *attr,
+ssize_t fsg_store_nofua(struct fsg_lun *curlun, const char *buf, size_t count);
+ssize_t fsg_store_file(struct fsg_lun *curlun, struct rw_semaphore *filesem,
const char *buf, size_t count);
#endif /* USB_STORAGE_COMMON_H */