#define device_unregister(...) 0
#define device_create_file(...) 0
#define kref_get(...) do {} while (0)
+#define kref_init(...) do {} while (0)
+#define module_init(...)
+#define module_exit(...)
+#define wait_for_completion(...) do {} while (0)
+#define dev_get_drvdata(...) NULL
struct kref {int;};
struct completion {int;};
/* If the thread isn't already dead, tell it to exit now */
if (fsg->state != FSG_STATE_TERMINATED) {
raise_exception(fsg, FSG_STATE_EXIT);
- //wait_for_completion(&fsg->thread_notifier);
+ wait_for_completion(&fsg->thread_notifier);
/* The cleanup routine waits for this completion also */
complete(&fsg->thread_notifier);
* the buffer will also work with the bulk-out (and
* interrupt-in) endpoint. */
bh->buf = kmalloc(mod_data.buflen, GFP_KERNEL);
- if (!bh->buf){
+ if (!bh->buf)
goto out;
- }
bh->next = bh + 1;
}
fsg->buffhds[FSG_NUM_BUFFERS - 1].next = &fsg->buffhds[0];
fsg->thread_task = kthread_create(fsg_main_thread, fsg,
"file-storage-gadget");
- /*
if (IS_ERR(fsg->thread_task)) {
rc = PTR_ERR(fsg->thread_task);
- goto out;
- }*/
+ //goto out;
+ }
INFO(fsg, DRIVER_DESC ", version: " DRIVER_VERSION "\n");
INFO(fsg, "Number of LUNs=%d\n", fsg->nluns);
out:
fsg->state = FSG_STATE_TERMINATED; // The thread is dead
fsg_unbind(gadget);
- //complete(&fsg->thread_notifier);
+ complete(&fsg->thread_notifier);
return rc;
}
return -ENOMEM;
spin_lock_init(&fsg->lock);
init_rwsem(&fsg->filesem);
- //kref_init(&fsg->ref);
- //init_completion(&fsg->thread_notifier);
+ kref_init(&fsg->ref);
+ init_completion(&fsg->thread_notifier);
the_fsg = fsg;
return 0;
return rc;
fsg = the_fsg;
if ((rc = usb_gadget_register_driver(&fsg_driver)) != 0)
- //kref_put(&fsg->ref, fsg_release);
- do { } while (0);
+ kref_put(&fsg->ref, fsg_release);
usb_gadget_connect(the_fsg->gadget);
return rc;
}
-//module_init(fsg_init);
+module_init(fsg_init);
static void __exit fsg_cleanup(void)
usb_gadget_unregister_driver(&fsg_driver);
/* Wait for the thread to finish up */
- //wait_for_completion(&fsg->thread_notifier);
+ wait_for_completion(&fsg->thread_notifier);
- //kref_put(&fsg->ref, fsg_release);
+ kref_put(&fsg->ref, fsg_release);
}
-//module_exit(fsg_cleanup);
+module_exit(fsg_cleanup);
#define up_write(...) do { } while (0)
#define down_read(...) do { } while (0)
#define up_read(...) do { } while (0)
+#define ETOOSMALL 525
#include <usb_mass_storage.h>
extern struct ums_board_info *ums_info;
size = ums_info->get_capacity();
if (size < 0) {
- //LINFO(curlun, "unable to find file size: %s\n", filename);
+ LINFO(curlun, "unable to find file size: %s\n", filename);
rc = (int) size;
goto out;
}
num_sectors = size >> 9; /* File size in 512-byte blocks */
min_sectors = 1;
- /*if (num_sectors < min_sectors) {
+ if (num_sectors < min_sectors) {
LINFO(curlun, "file too small: %s\n", filename);
rc = -ETOOSMALL;
goto out;
- }*/
+ }
curlun->ro = ro;
curlun->file_length = size;
curlun->num_sectors = num_sectors;
- //LDBG(curlun, "open backing file: %s\n", filename);
+ LDBG(curlun, "open backing file: %s\n", filename);
rc = 0;
out:
struct fsg_lun *curlun = fsg_lun_from_dev(dev);
unsigned long ro;
- //if (strict_strtoul(buf, 2, &ro))
ro = simple_strtoul(buf, NULL, 2);
/*
*/
curlun->ro = ro;
curlun->initially_ro = ro;
- //LDBG(curlun, "read-only status set to %d\n", curlun->ro);
+ LDBG(curlun, "read-only status set to %d\n", curlun->ro);
return rc;
}
struct fsg_lun *curlun = fsg_lun_from_dev(dev);
unsigned long nofua;
- //if (strict_strtoul(buf, 2, &nofua))
nofua = simple_strtoul(buf, NULL, 2);
/* Sync data when switching from async mode to sync */