aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/pktcdvd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/pktcdvd.c')
-rw-r--r--drivers/block/pktcdvd.c82
1 files changed, 36 insertions, 46 deletions
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 93e44d0292ab..bc9b2bcd7dba 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -58,6 +58,7 @@
58#include <linux/suspend.h> 58#include <linux/suspend.h>
59#include <scsi/scsi_cmnd.h> 59#include <scsi/scsi_cmnd.h>
60#include <scsi/scsi_ioctl.h> 60#include <scsi/scsi_ioctl.h>
61#include <scsi/scsi.h>
61 62
62#include <asm/uaccess.h> 63#include <asm/uaccess.h>
63 64
@@ -380,6 +381,7 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *
380 memcpy(rq->cmd, cgc->cmd, CDROM_PACKET_SIZE); 381 memcpy(rq->cmd, cgc->cmd, CDROM_PACKET_SIZE);
381 if (sizeof(rq->cmd) > CDROM_PACKET_SIZE) 382 if (sizeof(rq->cmd) > CDROM_PACKET_SIZE)
382 memset(rq->cmd + CDROM_PACKET_SIZE, 0, sizeof(rq->cmd) - CDROM_PACKET_SIZE); 383 memset(rq->cmd + CDROM_PACKET_SIZE, 0, sizeof(rq->cmd) - CDROM_PACKET_SIZE);
384 rq->cmd_len = COMMAND_SIZE(rq->cmd[0]);
383 385
384 rq->ref_count++; 386 rq->ref_count++;
385 rq->flags |= REQ_NOMERGE; 387 rq->flags |= REQ_NOMERGE;
@@ -1495,40 +1497,42 @@ static int pkt_set_write_settings(struct pktcdvd_device *pd)
1495} 1497}
1496 1498
1497/* 1499/*
1498 * 0 -- we can write to this track, 1 -- we can't 1500 * 1 -- we can write to this track, 0 -- we can't
1499 */ 1501 */
1500static int pkt_good_track(track_information *ti) 1502static int pkt_writable_track(struct pktcdvd_device *pd, track_information *ti)
1501{ 1503{
1502 /* 1504 switch (pd->mmc3_profile) {
1503 * only good for CD-RW at the moment, not DVD-RW 1505 case 0x1a: /* DVD+RW */
1504 */ 1506 case 0x12: /* DVD-RAM */
1507 /* The track is always writable on DVD+RW/DVD-RAM */
1508 return 1;
1509 default:
1510 break;
1511 }
1505 1512
1506 /* 1513 if (!ti->packet || !ti->fp)
1507 * FIXME: only for FP
1508 */
1509 if (ti->fp == 0)
1510 return 0; 1514 return 0;
1511 1515
1512 /* 1516 /*
1513 * "good" settings as per Mt Fuji. 1517 * "good" settings as per Mt Fuji.
1514 */ 1518 */
1515 if (ti->rt == 0 && ti->blank == 0 && ti->packet == 1) 1519 if (ti->rt == 0 && ti->blank == 0)
1516 return 0; 1520 return 1;
1517 1521
1518 if (ti->rt == 0 && ti->blank == 1 && ti->packet == 1) 1522 if (ti->rt == 0 && ti->blank == 1)
1519 return 0; 1523 return 1;
1520 1524
1521 if (ti->rt == 1 && ti->blank == 0 && ti->packet == 1) 1525 if (ti->rt == 1 && ti->blank == 0)
1522 return 0; 1526 return 1;
1523 1527
1524 printk("pktcdvd: bad state %d-%d-%d\n", ti->rt, ti->blank, ti->packet); 1528 printk("pktcdvd: bad state %d-%d-%d\n", ti->rt, ti->blank, ti->packet);
1525 return 1; 1529 return 0;
1526} 1530}
1527 1531
1528/* 1532/*
1529 * 0 -- we can write to this disc, 1 -- we can't 1533 * 1 -- we can write to this disc, 0 -- we can't
1530 */ 1534 */
1531static int pkt_good_disc(struct pktcdvd_device *pd, disc_information *di) 1535static int pkt_writable_disc(struct pktcdvd_device *pd, disc_information *di)
1532{ 1536{
1533 switch (pd->mmc3_profile) { 1537 switch (pd->mmc3_profile) {
1534 case 0x0a: /* CD-RW */ 1538 case 0x0a: /* CD-RW */
@@ -1537,10 +1541,10 @@ static int pkt_good_disc(struct pktcdvd_device *pd, disc_information *di)
1537 case 0x1a: /* DVD+RW */ 1541 case 0x1a: /* DVD+RW */
1538 case 0x13: /* DVD-RW */ 1542 case 0x13: /* DVD-RW */
1539 case 0x12: /* DVD-RAM */ 1543 case 0x12: /* DVD-RAM */
1540 return 0; 1544 return 1;
1541 default: 1545 default:
1542 VPRINTK("pktcdvd: Wrong disc profile (%x)\n", pd->mmc3_profile); 1546 VPRINTK("pktcdvd: Wrong disc profile (%x)\n", pd->mmc3_profile);
1543 return 1; 1547 return 0;
1544 } 1548 }
1545 1549
1546 /* 1550 /*
@@ -1549,25 +1553,25 @@ static int pkt_good_disc(struct pktcdvd_device *pd, disc_information *di)
1549 */ 1553 */
1550 if (di->disc_type == 0xff) { 1554 if (di->disc_type == 0xff) {
1551 printk("pktcdvd: Unknown disc. No track?\n"); 1555 printk("pktcdvd: Unknown disc. No track?\n");
1552 return 1; 1556 return 0;
1553 } 1557 }
1554 1558
1555 if (di->disc_type != 0x20 && di->disc_type != 0) { 1559 if (di->disc_type != 0x20 && di->disc_type != 0) {
1556 printk("pktcdvd: Wrong disc type (%x)\n", di->disc_type); 1560 printk("pktcdvd: Wrong disc type (%x)\n", di->disc_type);
1557 return 1; 1561 return 0;
1558 } 1562 }
1559 1563
1560 if (di->erasable == 0) { 1564 if (di->erasable == 0) {
1561 printk("pktcdvd: Disc not erasable\n"); 1565 printk("pktcdvd: Disc not erasable\n");
1562 return 1; 1566 return 0;
1563 } 1567 }
1564 1568
1565 if (di->border_status == PACKET_SESSION_RESERVED) { 1569 if (di->border_status == PACKET_SESSION_RESERVED) {
1566 printk("pktcdvd: Can't write to last track (reserved)\n"); 1570 printk("pktcdvd: Can't write to last track (reserved)\n");
1567 return 1; 1571 return 0;
1568 } 1572 }
1569 1573
1570 return 0; 1574 return 1;
1571} 1575}
1572 1576
1573static int pkt_probe_settings(struct pktcdvd_device *pd) 1577static int pkt_probe_settings(struct pktcdvd_device *pd)
@@ -1592,23 +1596,9 @@ static int pkt_probe_settings(struct pktcdvd_device *pd)
1592 return ret; 1596 return ret;
1593 } 1597 }
1594 1598
1595 if (pkt_good_disc(pd, &di)) 1599 if (!pkt_writable_disc(pd, &di))
1596 return -ENXIO; 1600 return -EROFS;
1597 1601
1598 switch (pd->mmc3_profile) {
1599 case 0x1a: /* DVD+RW */
1600 printk("pktcdvd: inserted media is DVD+RW\n");
1601 break;
1602 case 0x13: /* DVD-RW */
1603 printk("pktcdvd: inserted media is DVD-RW\n");
1604 break;
1605 case 0x12: /* DVD-RAM */
1606 printk("pktcdvd: inserted media is DVD-RAM\n");
1607 break;
1608 default:
1609 printk("pktcdvd: inserted media is CD-R%s\n", di.erasable ? "W" : "");
1610 break;
1611 }
1612 pd->type = di.erasable ? PACKET_CDRW : PACKET_CDR; 1602 pd->type = di.erasable ? PACKET_CDRW : PACKET_CDR;
1613 1603
1614 track = 1; /* (di.last_track_msb << 8) | di.last_track_lsb; */ 1604 track = 1; /* (di.last_track_msb << 8) | di.last_track_lsb; */
@@ -1617,9 +1607,9 @@ static int pkt_probe_settings(struct pktcdvd_device *pd)
1617 return ret; 1607 return ret;
1618 } 1608 }
1619 1609
1620 if (pkt_good_track(&ti)) { 1610 if (!pkt_writable_track(pd, &ti)) {
1621 printk("pktcdvd: can't write to this track\n"); 1611 printk("pktcdvd: can't write to this track\n");
1622 return -ENXIO; 1612 return -EROFS;
1623 } 1613 }
1624 1614
1625 /* 1615 /*
@@ -1633,7 +1623,7 @@ static int pkt_probe_settings(struct pktcdvd_device *pd)
1633 } 1623 }
1634 if (pd->settings.size > PACKET_MAX_SECTORS) { 1624 if (pd->settings.size > PACKET_MAX_SECTORS) {
1635 printk("pktcdvd: packet size is too big\n"); 1625 printk("pktcdvd: packet size is too big\n");
1636 return -ENXIO; 1626 return -EROFS;
1637 } 1627 }
1638 pd->settings.fp = ti.fp; 1628 pd->settings.fp = ti.fp;
1639 pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1); 1629 pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1);
@@ -1675,7 +1665,7 @@ static int pkt_probe_settings(struct pktcdvd_device *pd)
1675 break; 1665 break;
1676 default: 1666 default:
1677 printk("pktcdvd: unknown data mode\n"); 1667 printk("pktcdvd: unknown data mode\n");
1678 return 1; 1668 return -EROFS;
1679 } 1669 }
1680 return 0; 1670 return 0;
1681} 1671}
@@ -1886,7 +1876,7 @@ static int pkt_open_write(struct pktcdvd_device *pd)
1886 1876
1887 if ((ret = pkt_probe_settings(pd))) { 1877 if ((ret = pkt_probe_settings(pd))) {
1888 VPRINTK("pktcdvd: %s failed probe\n", pd->name); 1878 VPRINTK("pktcdvd: %s failed probe\n", pd->name);
1889 return -EROFS; 1879 return ret;
1890 } 1880 }
1891 1881
1892 if ((ret = pkt_set_write_settings(pd))) { 1882 if ((ret = pkt_set_write_settings(pd))) {