All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Replace hardcoded hexa formating
@ 2009-01-23 22:42 LCID Fire
  2009-01-26  9:04 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: LCID Fire @ 2009-01-23 22:42 UTC (permalink / raw)
  To: Alsa-devel

[-- Attachment #1: Type: text/plain, Size: 69 bytes --]

The attached patch replaces the hardcoded hexa formats in usbaudio.c

[-- Attachment #2: commit-079e4ef --]
[-- Type: text/plain, Size: 3598 bytes --]

commit 079e4efba0603e7a32bf1d352d98c2b265b91cd6
Author: LCID Fire <lcid-fire@gmx.net>
Date:   Fri Jan 23 23:39:06 2009 +0100

    Rather use printf format instead of hardcoding it.
    A next step would be to predefine certain formats.
    
    Signed-off-by: Andreas Bergmeier <lcid-fire@gmx.net>

diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index bbd70d5..77ac5c9 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -1292,14 +1292,14 @@ static int init_usb_sample_rate(struct usb_device *dev, int iface,
 		if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR,
 					   USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT,
 					   SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) {
-			snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep 0x%x\n",
+			snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep %#x\n",
 				   dev->devnum, iface, fmt->altsetting, rate, ep);
 			return err;
 		}
 		if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR,
 					   USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN,
 					   SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) {
-			snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep 0x%x\n",
+			snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep %#x\n",
 				   dev->devnum, iface, fmt->altsetting, ep);
 			return 0; /* some devices don't support reading */
 		}
@@ -1468,7 +1468,7 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
 	channels = params_channels(hw_params);
 	fmt = find_format(subs, format, rate, channels);
 	if (!fmt) {
-		snd_printd(KERN_DEBUG "cannot set format: format = 0x%x, rate = %d, channels = %d\n",
+		snd_printd(KERN_DEBUG "cannot set format: format = %#x, rate = %d, channels = %d\n",
 			   format, rate, channels);
 		return -EINVAL;
 	}
@@ -2160,7 +2160,7 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s
 		fp = list_entry(p, struct audioformat, list);
 		snd_iprintf(buffer, "  Interface %d\n", fp->iface);
 		snd_iprintf(buffer, "    Altset %d\n", fp->altsetting);
-		snd_iprintf(buffer, "    Format: 0x%x\n", fp->format);
+		snd_iprintf(buffer, "    Format: %#x\n", fp->format);
 		snd_iprintf(buffer, "    Channels: %d\n", fp->channels);
 		snd_iprintf(buffer, "    Endpoint: %d %s (%s)\n",
 			    fp->endpoint & USB_ENDPOINT_NUMBER_MASK,
@@ -2180,7 +2180,7 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s
 			snd_iprintf(buffer, "\n");
 		}
 		// snd_iprintf(buffer, "    Max Packet Size = %d\n", fp->maxpacksize);
-		// snd_iprintf(buffer, "    EP Attribute = 0x%x\n", fp->attributes);
+		// snd_iprintf(buffer, "    EP Attribute = %#x\n", fp->attributes);
 	}
 }
 
@@ -2619,7 +2619,7 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip, struct audioformat
 		fp->format = SNDRV_PCM_FORMAT_MPEG;
 		break;
 	default:
-		snd_printd(KERN_INFO "%d:%u:%d : unknown format tag 0x%x is detected.  processed as MPEG.\n",
+		snd_printd(KERN_INFO "%d:%u:%d : unknown format tag %#x is detected.  processed as MPEG.\n",
 			   chip->dev->devnum, fp->iface, fp->altsetting, format);
 		fp->format = SNDRV_PCM_FORMAT_MPEG;
 		break;
@@ -2817,7 +2817,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
 			continue;
 		}
 
-		snd_printdd(KERN_INFO "%d:%u:%d: add audio endpoint 0x%x\n", dev->devnum, iface_no, altno, fp->endpoint);
+		snd_printdd(KERN_INFO "%d:%u:%d: add audio endpoint %#x\n", dev->devnum, iface_no, altno, fp->endpoint);
 		err = add_audio_endpoint(chip, stream, fp);
 		if (err < 0) {
 			kfree(fp->rate_table);

[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Replace hardcoded hexa formating
  2009-01-23 22:42 [PATCH] Replace hardcoded hexa formating LCID Fire
@ 2009-01-26  9:04 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2009-01-26  9:04 UTC (permalink / raw)
  To: LCID Fire; +Cc: Alsa-devel

At Fri, 23 Jan 2009 23:42:19 +0100,
LCID Fire wrote:
> 
> commit 079e4efba0603e7a32bf1d352d98c2b265b91cd6
> Author: LCID Fire <lcid-fire@gmx.net>
> Date:   Fri Jan 23 23:39:06 2009 +0100
> 
>     Rather use printf format instead of hardcoding it.
>     A next step would be to predefine certain formats.
>     
>     Signed-off-by: Andreas Bergmeier <lcid-fire@gmx.net>

The change looks OK, but could you create a patch via git format-patch
(or git show --pretty=email) so that I can apply your patches directly?

This format (either made via gitk or git show without pretty option)
isn't applicable via git-am.


thanks,

Takashi


> diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
> index bbd70d5..77ac5c9 100644
> --- a/sound/usb/usbaudio.c
> +++ b/sound/usb/usbaudio.c
> @@ -1292,14 +1292,14 @@ static int init_usb_sample_rate(struct usb_device *dev, int iface,
>  		if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR,
>  					   USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT,
>  					   SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) {
> -			snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep 0x%x\n",
> +			snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep %#x\n",
>  				   dev->devnum, iface, fmt->altsetting, rate, ep);
>  			return err;
>  		}
>  		if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR,
>  					   USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN,
>  					   SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) {
> -			snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep 0x%x\n",
> +			snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep %#x\n",
>  				   dev->devnum, iface, fmt->altsetting, ep);
>  			return 0; /* some devices don't support reading */
>  		}
> @@ -1468,7 +1468,7 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
>  	channels = params_channels(hw_params);
>  	fmt = find_format(subs, format, rate, channels);
>  	if (!fmt) {
> -		snd_printd(KERN_DEBUG "cannot set format: format = 0x%x, rate = %d, channels = %d\n",
> +		snd_printd(KERN_DEBUG "cannot set format: format = %#x, rate = %d, channels = %d\n",
>  			   format, rate, channels);
>  		return -EINVAL;
>  	}
> @@ -2160,7 +2160,7 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s
>  		fp = list_entry(p, struct audioformat, list);
>  		snd_iprintf(buffer, "  Interface %d\n", fp->iface);
>  		snd_iprintf(buffer, "    Altset %d\n", fp->altsetting);
> -		snd_iprintf(buffer, "    Format: 0x%x\n", fp->format);
> +		snd_iprintf(buffer, "    Format: %#x\n", fp->format);
>  		snd_iprintf(buffer, "    Channels: %d\n", fp->channels);
>  		snd_iprintf(buffer, "    Endpoint: %d %s (%s)\n",
>  			    fp->endpoint & USB_ENDPOINT_NUMBER_MASK,
> @@ -2180,7 +2180,7 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s
>  			snd_iprintf(buffer, "\n");
>  		}
>  		// snd_iprintf(buffer, "    Max Packet Size = %d\n", fp->maxpacksize);
> -		// snd_iprintf(buffer, "    EP Attribute = 0x%x\n", fp->attributes);
> +		// snd_iprintf(buffer, "    EP Attribute = %#x\n", fp->attributes);
>  	}
>  }
>  
> @@ -2619,7 +2619,7 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip, struct audioformat
>  		fp->format = SNDRV_PCM_FORMAT_MPEG;
>  		break;
>  	default:
> -		snd_printd(KERN_INFO "%d:%u:%d : unknown format tag 0x%x is detected.  processed as MPEG.\n",
> +		snd_printd(KERN_INFO "%d:%u:%d : unknown format tag %#x is detected.  processed as MPEG.\n",
>  			   chip->dev->devnum, fp->iface, fp->altsetting, format);
>  		fp->format = SNDRV_PCM_FORMAT_MPEG;
>  		break;
> @@ -2817,7 +2817,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
>  			continue;
>  		}
>  
> -		snd_printdd(KERN_INFO "%d:%u:%d: add audio endpoint 0x%x\n", dev->devnum, iface_no, altno, fp->endpoint);
> +		snd_printdd(KERN_INFO "%d:%u:%d: add audio endpoint %#x\n", dev->devnum, iface_no, altno, fp->endpoint);
>  		err = add_audio_endpoint(chip, stream, fp);
>  		if (err < 0) {
>  			kfree(fp->rate_table);
> [3  <text/plain; us-ascii (7bit)>]
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-01-26  9:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-23 22:42 [PATCH] Replace hardcoded hexa formating LCID Fire
2009-01-26  9:04 ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.