Lines Matching refs:curlun
368 struct fsg_lun *curlun;
727 struct fsg_lun *curlun = common->curlun;
748 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
752 if (lba >= curlun->num_sectors) {
753 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
775 curlun->file_length - file_offset);
792 curlun->sense_data =
794 curlun->sense_data_info = file_offset >> 9;
795 curlun->info_valid = 1;
803 nread = vfs_read(curlun->filp,
806 VLDBG(curlun, "file read %u @ %llu -> %d\n", amount,
813 LDBG(curlun, "error in file read: %d\n",
817 LDBG(curlun, "partial file read: %d/%u\n",
829 curlun->sense_data = SS_UNRECOVERED_READ_ERROR;
830 curlun->sense_data_info = file_offset >> 9;
831 curlun->info_valid = 1;
856 struct fsg_lun *curlun = common->curlun;
867 if (curlun->ro) {
868 curlun->sense_data = SS_WRITE_PROTECTED;
871 spin_lock(&curlun->filp->f_lock);
872 curlun->filp->f_flags &= ~O_SYNC; /* Default is not to wait */
873 spin_unlock(&curlun->filp->f_lock);
887 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
891 spin_lock(&curlun->filp->f_lock);
892 curlun->filp->f_flags |= O_SYNC;
893 spin_unlock(&curlun->filp->f_lock);
896 if (lba >= curlun->num_sectors) {
897 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
923 amount = min((loff_t) amount, curlun->file_length -
932 curlun->sense_data =
934 curlun->sense_data_info = usb_offset >> 9;
935 curlun->info_valid = 1;
979 curlun->sense_data = SS_COMMUNICATION_FAILURE;
980 curlun->sense_data_info = file_offset >> 9;
981 curlun->info_valid = 1;
986 if (curlun->file_length - file_offset < amount) {
987 LERROR(curlun,
990 (unsigned long long) curlun->file_length);
991 amount = curlun->file_length - file_offset;
996 nwritten = vfs_write(curlun->filp,
999 VLDBG(curlun, "file write %u @ %llu -> %d\n", amount,
1006 LDBG(curlun, "error in file write: %d\n",
1010 LDBG(curlun, "partial file write: %d/%u\n",
1021 curlun->sense_data = SS_WRITE_ERROR;
1022 curlun->sense_data_info = file_offset >> 9;
1023 curlun->info_valid = 1;
1049 struct fsg_lun *curlun = common->curlun;
1054 rc = fsg_lun_fsync_sub(curlun);
1056 curlun->sense_data = SS_WRITE_ERROR;
1063 static void invalidate_sub(struct fsg_lun *curlun)
1065 struct file *filp = curlun->filp;
1070 VLDBG(curlun, "invalidate_mapping_pages -> %ld\n", rc);
1075 struct fsg_lun *curlun = common->curlun;
1087 if (lba >= curlun->num_sectors) {
1088 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
1095 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1108 fsg_lun_fsync_sub(curlun);
1112 invalidate_sub(curlun);
1127 curlun->file_length - file_offset);
1129 curlun->sense_data =
1131 curlun->sense_data_info = file_offset >> 9;
1132 curlun->info_valid = 1;
1138 nread = vfs_read(curlun->filp,
1141 VLDBG(curlun, "file read %u @ %llu -> %d\n", amount,
1148 LDBG(curlun, "error in file verify: %d\n",
1152 LDBG(curlun, "partial file verify: %d/%u\n",
1157 curlun->sense_data = SS_UNRECOVERED_READ_ERROR;
1158 curlun->sense_data_info = file_offset >> 9;
1159 curlun->info_valid = 1;
1173 struct fsg_lun *curlun = common->curlun;
1176 if (!curlun) { /* Unsupported LUNs are okay */
1184 buf[0] = curlun->cdrom ? TYPE_CDROM : TYPE_DISK;
1185 buf[1] = curlun->removable ? 0x80 : 0;
1199 struct fsg_lun *curlun = common->curlun;
1220 if (!curlun) { /* Unsupported LUNs are okay */
1226 sd = curlun->sense_data;
1227 sdinfo = curlun->sense_data_info;
1228 valid = curlun->info_valid << 7;
1229 curlun->sense_data = SS_NO_SENSE;
1230 curlun->sense_data_info = 0;
1231 curlun->info_valid = 0;
1247 struct fsg_lun *curlun = common->curlun;
1254 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1258 put_unaligned_be32(curlun->num_sectors - 1, &buf[0]);
1267 struct fsg_lun *curlun = common->curlun;
1273 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1276 if (lba >= curlun->num_sectors) {
1277 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
1290 struct fsg_lun *curlun = common->curlun;
1297 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1311 store_cdrom_address(&buf[16], msf, curlun->num_sectors);
1318 struct fsg_lun *curlun = common->curlun;
1328 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1334 curlun->sense_data = SS_SAVING_PARAMETERS_NOT_SUPPORTED;
1346 buf[2] = (curlun->ro ? 0x80 : 0x00); /* WP, DPOFUA */
1350 buf[3] = (curlun->ro ? 0x80 : 0x00); /* WP, DPOFUA */
1384 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1399 struct fsg_lun *curlun = common->curlun;
1402 if (!curlun) {
1404 } else if (!curlun->removable) {
1405 curlun->sense_data = SS_INVALID_COMMAND;
1409 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1419 if (!fsg_lun_is_open(curlun)) {
1420 curlun->sense_data = SS_MEDIUM_NOT_PRESENT;
1427 if (curlun->prevent_medium_removal) {
1428 LDBG(curlun, "unload attempt prevented\n");
1429 curlun->sense_data = SS_MEDIUM_REMOVAL_PREVENTED;
1438 int r = common->ops->pre_eject(common, curlun,
1439 curlun - common->luns);
1448 fsg_lun_close(curlun);
1453 ? min(0, common->ops->post_eject(common, curlun,
1454 curlun - common->luns))
1461 struct fsg_lun *curlun = common->curlun;
1464 if (!common->curlun) {
1466 } else if (!common->curlun->removable) {
1467 common->curlun->sense_data = SS_INVALID_COMMAND;
1473 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1477 if (curlun->prevent_medium_removal && !prevent)
1478 fsg_lun_fsync_sub(curlun);
1479 curlun->prevent_medium_removal = prevent;
1487 struct fsg_lun *curlun = common->curlun;
1494 put_unaligned_be32(curlun->num_sectors, &buf[0]);
1504 struct fsg_lun *curlun = common->curlun;
1507 if (curlun)
1508 curlun->sense_data = SS_INVALID_COMMAND;
1737 struct fsg_lun *curlun = common->curlun;
1752 if (curlun) {
1753 sd = curlun->sense_data;
1754 sdinfo = curlun->sense_data_info;
1804 struct fsg_lun *curlun;
1856 curlun = &common->luns[common->lun];
1857 common->curlun = curlun;
1859 curlun->sense_data = SS_NO_SENSE;
1860 curlun->sense_data_info = 0;
1861 curlun->info_valid = 0;
1864 common->curlun = NULL;
1865 curlun = NULL;
1879 if (curlun && curlun->unit_attention_data != SS_NO_SENSE &&
1882 curlun->sense_data = curlun->unit_attention_data;
1883 curlun->unit_attention_data = SS_NO_SENSE;
1891 if (curlun)
1892 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1899 if (curlun && !fsg_lun_is_open(curlun) && needs_medium) {
1900 curlun->sense_data = SS_MEDIUM_NOT_PRESENT;
2028 if (!common->curlun || !common->curlun->cdrom)
2040 if (!common->curlun || !common->curlun->cdrom)
2153 common->curlun->sense_data = SS_INVALID_COMMAND;
2422 struct fsg_lun *curlun;
2487 curlun = &common->luns[i];
2488 curlun->prevent_medium_removal = 0;
2489 curlun->sense_data = SS_NO_SENSE;
2490 curlun->unit_attention_data = SS_NO_SENSE;
2491 curlun->sense_data_info = 0;
2492 curlun->info_valid = 0;
2616 struct fsg_lun *curlun = common->luns;
2620 for (; i--; ++curlun) {
2621 if (!fsg_lun_is_open(curlun))
2624 fsg_lun_close(curlun);
2625 curlun->unit_attention_data = SS_MEDIUM_NOT_PRESENT;
2668 struct fsg_lun *curlun;
2709 curlun = kzalloc(nluns * sizeof *curlun, GFP_KERNEL);
2710 if (unlikely(!curlun)) {
2714 common->luns = curlun;
2718 for (i = 0, lcfg = cfg->luns; i < nluns; ++i, ++curlun, ++lcfg) {
2719 curlun->cdrom = !!lcfg->cdrom;
2720 curlun->ro = lcfg->cdrom || lcfg->ro;
2721 curlun->removable = lcfg->removable;
2722 curlun->dev.release = fsg_lun_release;
2723 curlun->dev.parent = &gadget->dev;
2724 dev_set_drvdata(&curlun->dev, &common->filesem);
2725 dev_set_name(&curlun->dev,
2731 rc = device_register(&curlun->dev);
2738 rc = device_create_file(&curlun->dev, &dev_attr_ro);
2741 rc = device_create_file(&curlun->dev, &dev_attr_file);
2746 rc = fsg_lun_open(curlun, lcfg->filename);
2749 } else if (!curlun->removable) {
2829 for (i = 0, nluns = common->nluns, curlun = common->luns;
2831 ++curlun, ++i) {
2833 if (fsg_lun_is_open(curlun)) {
2836 p = d_path(&curlun->filp->f_path,
2842 LINFO(curlun, "LUN: %s%s%sfile: %s\n",
2843 curlun->removable ? "removable " : "",
2844 curlun->ro ? "read only " : "",
2845 curlun->cdrom ? "CD-ROM " : "",