Skip to contentSkip to conversation

Packet writing problems

DISCUSSION Julien Oster 2 participants 2 messages Aug 18, 2004 – Aug 19, 2004 1 message not in the archive Block layer

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Alex Riesen <[email protected]> writes:

(I guess your mail was also meant to lkml?)

Quoted 6 lines

this part has '\n' missing.

BTW, all the printks have "pktcdvd: inserted media " prefixed and no arguments. Probably something like this can be useful:

static void inserted_media(const char* desc)

[...]

Quoted 1 line

The purpose is clear without an extra comment.

Aaaand another one.

Maybe the following approach is nice?

We're making a lot of mess about some simple output.

drivers/block/pktcdvd.c +65 -31
@@ -1528,7 +1528,7 @@ static int pkt_set_write_settings(struct
 }
 
 /*
- * 0 -- we can write to this track, 1 -- we can't
+ * 1 -- we can write to this track, 0 -- we can't
  */
 static int pkt_good_track(track_information *ti)
 {
@@ -1540,66 +1540,111 @@ static int pkt_good_track(track_informat
 	 * FIXME: only for FP
 	 */
 	if (ti->fp == 0)
-		return 0;
+		return 1;
 
 	/*
 	 * "good" settings as per Mt Fuji.
 	 */
 	if (ti->rt == 0 && ti->blank == 0 && ti->packet == 1)
-		return 0;
+		return 1;
 
 	if (ti->rt == 0 && ti->blank == 1 && ti->packet == 1)
-		return 0;
+		return 1;
 
 	if (ti->rt == 1 && ti->blank == 0 && ti->packet == 1)
-		return 0;
+		return 1;
 
 	printk("pktcdvd: bad state %d-%d-%d\n", ti->rt, ti->blank, ti->packet);
-	return 1;
+	return 0;
 }
 
 /*
- * 0 -- we can write to this disc, 1 -- we can't
+ * 1 -- we can write to this disc, 0 -- we can't
  */
 static int pkt_good_disc(struct pktcdvd_device *pd, disc_information *di)
 {
+        char *mediatypename;
+	int packet_ok;
+
 	switch (pd->mmc3_profile) {
-		case 0x0a: /* CD-RW */
-		case 0xffff: /* MMC3 not supported */
+	        case 0x08: /* CD-ROM */
+		        mediatypename = "CD-ROM";
+			packet_ok = 0;
+			break;
+	        case 0x09: /* CD-R */
+		        mediatypename = "CD-R";
+			packet_ok = 0;
+			break;
+	        case 0x0a: /* CD-RW */
+		        mediatypename = "CD-RW";
+			packet_ok = 1;
+			break;
+	        case 0x10: /* DVD-ROM */
+		        mediatypename = "DVD-ROM";
+			packet_ok = 0;
+			break;
+	        case 0x11: /* DVD-R */
+		        mediatypename = "DVD-R";
+			packet_ok = 0;
+			break;
+	        case 0x12: /* DVD-RAM */
+		        mediatypename = "DVD-RAM";
+			packet_ok = 0;
+			break;
+		case 0x13: /* DVD-RW restricted overwrite */
+		        mediatypename = "DVD-RW w/ restricted overwrite";
+			packet_ok = 1;
+			break;
+		case 0x14: /* DVD-RW sequential recording */
+		        mediatypename = "DVD-RW w/ sequential recording";
+			packet_ok = 0;
 			break;
 		case 0x1a: /* DVD+RW */
-		case 0x13: /* DVD-RW */
-			return 0;
+		        mediatypename = "DVD+RW";
+			packet_ok = 1;
+			break;
+		case 0xffff: /* unconforming */
+		        mediatypename = "MMC unconforming";
+
+			/* handle it specially below */
+			packet_ok = 2;
+			break;
 		default:
-			printk("pktcdvd: Wrong disc profile (%x)\n", pd->mmc3_profile);
-			return 1;
+		        mediatypename = "unknown to pktcdvd";
+			packet_ok = 0;
 	}
 
+	printk("pktcdvd: inserted media is %s %s\n", mediatypename,
+	       packet_ok ? "" : "- no packet writing supported");
+
+	if (packet_ok != 2)
+	  return packet_ok;
+
 	/*
 	 * for disc type 0xff we should probably reserve a new track.
 	 * but i'm not sure, should we leave this to user apps? probably.
 	 */
 	if (di->disc_type == 0xff) {
 		printk("pktcdvd: Unknown disc. No track?\n");
-		return 1;
+		return 0;
 	}
 
 	if (di->disc_type != 0x20 && di->disc_type != 0) {
 		printk("pktcdvd: Wrong disc type (%x)\n", di->disc_type);
-		return 1;
+		return 0;
 	}
 
 	if (di->erasable == 0) {
 		printk("pktcdvd: Disc not erasable\n");
-		return 1;
+		return 0;
 	}
 
 	if (di->border_status == PACKET_SESSION_RESERVED) {
 		printk("pktcdvd: Can't write to last track (reserved)\n");
-		return 1;
+		return 0;
 	}
 
-	return 0;
+	return 1;
 }
 
 static int pkt_probe_settings(struct pktcdvd_device *pd)
@@ -1624,20 +1669,9 @@ static int pkt_probe_settings(struct pkt
 		return ret;
 	}
 
-	if (pkt_good_disc(pd, &di))
+	if (!pkt_good_disc(pd, &di))
 		return -ENXIO;
 
-	switch (pd->mmc3_profile) {
-		case 0x1a: /* DVD+RW */
-			printk("pktcdvd: inserted media is DVD+RW\n");
-			break;
-		case 0x13: /* DVD-RW */
-			printk("pktcdvd: inserted media is DVD-RW\n");
-			break;
-		default:
-			printk("pktcdvd: inserted media is CD-R%s\n", di.erasable ? "W" : "");
-			break;
-	}
 	pd->type = di.erasable ? PACKET_CDRW : PACKET_CDR;
 
 	track = 1; /* (di.last_track_msb << 8) | di.last_track_lsb; */
@@ -1646,7 +1680,7 @@ static int pkt_probe_settings(struct pkt
 		return ret;
 	}
 
-	if (pkt_good_track(&ti)) {
+	if (!pkt_good_track(&ti)) {
 		printk("pktcdvd: can't write to this track\n");
 		return -ENXIO;
 	}

Regards,
Julien

#2 lore raw

Julien Oster, Wed, Aug 18, 2004 19:08:15 +0200:

Quoted 1 line

(I guess your mail was also meant to lkml?)

yes, I'm just reading the list off the archive at marc, so replies do not go automatically to lkml if you have to copy-paste the text.

Quoted 1 line

We're making a lot of mess about some simple output.

Well, it's a lot of simple output.

Quoted 3 lines

static int pkt_good_disc(struct pktcdvd_device *pd, disc_information *di) {
+ char *mediatypename;

it is "const char*", actually. And the indentation before the line is 8 spaces, instead of 1 tab (unlike everything in the file).