patch-1.3.97 linux/drivers/sound/pss.c

Next file: linux/fs/ext2/ioctl.c
Previous file: linux/drivers/sound/Readme.modules
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.96/linux/drivers/sound/pss.c linux/drivers/sound/pss.c
@@ -520,10 +520,11 @@
 
     case SNDCTL_COPR_SENDMSG:
       {
+	/* send buf->len words from buf->data to DSP */
+
 	copr_msg       *buf;
 	unsigned long   flags;
 	unsigned short *data;
-	unsigned short  tmp;
 	int             i;
 
 	buf = (copr_msg *) kmalloc (sizeof (copr_msg), GFP_KERNEL);
@@ -534,19 +535,17 @@
 
 	data = (unsigned short *) (buf->data);
 
-	/* printk( "SNDCTL_COPR_SENDMSG: data = %d", data ); */
-
 	save_flags (flags);
 	cli ();
 
 	for (i = 0; i < buf->len; i++)
 	  {
-	    tmp = *data++;
-	    if (!pss_put_dspword (devc, tmp))
+	    if (!pss_put_dspword (devc, *data++))
 	      {
 		restore_flags (flags);
-		buf->len = i;	/* feed back number of WORDs sent */
-		memcpy_tofs ((&((char *) arg)[0]), &buf, sizeof (buf));
+		/* feed back number of WORDs sent */
+		memcpy_tofs( (char *)(&(((copr_msg *)arg)->len)),
+				(char *)(&i), sizeof(buf->len));
 		kfree (buf);
 		return -EIO;
 	      }
@@ -562,6 +561,7 @@
 
     case SNDCTL_COPR_RCVMSG:
       {
+	/* try to read as much words as possible from DSP into buf */
 	copr_msg       *buf;
 	unsigned long   flags;
 	unsigned short *data;
@@ -571,27 +571,31 @@
 	buf = (copr_msg *) kmalloc (sizeof (copr_msg), GFP_KERNEL);
 	if (buf == NULL)
 	  return -ENOSPC;
-
+#if 0
 	memcpy_fromfs ((char *) buf, &(((char *) arg)[0]), sizeof (*buf));
+#endif
 
 	data = (unsigned short *) buf->data;
 
 	save_flags (flags);
 	cli ();
 
-	for (i = 0; i < buf->len; i++)
+	for (i = 0; i < sizeof(buf->data); i++)
 	  {
 	    if (!pss_get_dspword (devc, data++))
 	      {
 		buf->len = i;	/* feed back number of WORDs read */
-		err = -EIO;
+		err = (i==0)? -EIO : 0;	   /* EIO only if no word read */
 		break;
 	      }
 	  }
 
+	if( i==sizeof(buf->data) )
+		buf->len = i;
+
 	restore_flags (flags);
 
-	memcpy_tofs ((&((char *) arg)[0]), &buf, sizeof (buf));
+	memcpy_tofs ((&((char *) arg)[0]), buf, sizeof (*buf));
 	kfree (buf);
 
 	return err;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this