stringbuf: A string buffer implementation
Subsystems (3)
PATCH 1/4 stringbuf: A string buffer implementation
Consecutive calls to printk are non-atomic, which leads to various implementations for accumulating strings which can be printed in one call. This is a generic string buffer which can also be used for non-printk purposes. There is no sb_scanf implementation yet as I haven't identified a user for it.
--- include/linux/stringbuf.h | 85 +++++++++++++++++++++++++++++++++++++++++++++ lib/Makefile | 2 +- lib/stringbuf.c | 79 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+), 1 deletions(-) create mode 100644 include/linux/stringbuf.h create mode 100644 lib/stringbuf.c
include/linux/stringbuf.h new file +85 -0
@@ -0,0 +1,85 @@ +/* +* An auto-expanding string buffer. There's no sb_alloc because you really +* want to allocate it on the stack or embed it in another structure. +* +* Please don't access the elements directly; that will give us the chance +* to change the implementation later if necessary. +* +* No locking is performed, although memory allocation is done with +* GFP_ATOMIC to allow it to be called when you're holding a lock. +*/ + +#include <stdarg.h> +#include <linux/string.h> + +struct stringbuf { +char *s; +int alloc; +int len; +}; + +/* +* Returns the current length of the string. Note that more memory +* may have been allocated for the string than this. +*/ +static inline int sb_len (struct stringbuf *sb) +{ +return sb->len; +} + +/* +* Returns a negative errno if an error has been found with this stringbuf, +* or 0 if no error has occurred. If an error has occurred, sb_string() +* returns a suitable description of the error +*/ +static inline int sb_error (struct stringbuf *sb) +{ +return sb->alloc <0 ? sb->alloc :0 ; +} + +/* +* Initialise a newly-allocated stringbuf +*/ +static inline void sb_init (struct stringbuf *sb) +{ +memset (sb,0 ,sizeof (*sb)); +} + +/* +* Free the contents of a stringbuf, not the stringbuf itself. The +* stringbuf is then reinitialised so it can be reused, or sb_free can +* be called on it multiple times. +*/ +static inline void sb_free (struct stringbuf *sb) +{ +if (sb->alloc >0 ) +kfree (sb->s); +sb_init (sb); +} + +extern void sb_printf (struct stringbuf *sb,const char *fmt, ...) + __attribute__((format (printf,2 ,3 ))); +#if 0 +/* Waiting for a user to show up */ +extern void sb_vprintf (struct stringbuf *sb,const char *fmt,va_list args) + __attribute__((format (printf,2 ,0 ))); +#endif + +/* Get a pointer to the string. */ +static inline char *sb_string (struct stringbuf *sb) +{ +return sb->s; +} + +/* +* Convert the stringbuf to a string. It is the caller's responsibility +* to free the string. The stringbuf is then ready to be reused. +*/ +static inline char *sb_to_string (struct stringbuf *sb) +{ +char *s = sb->s; +if (sb_error (sb)) + s =kstrdup (s,GFP_ATOMIC ); +sb_init (sb); +return s; +}
lib/Makefile +1 -1
@@ -2,7 +2,7 @@ # Makefile for some libs needed in the kernel. # -lib-y := ctype.o string.o vsprintf.o cmdline.o \ +lib-y := ctype.o string.o stringbuf.o vsprintf.o cmdline.o \ rbtree.o radix-tree.o dump_stack.o \ idr.o int_sqrt.o bitmap.o extable.o prio_tree.o \ sha1.o irq_regs.o reciprocal_div.o argv_split.o \
lib/stringbuf.c new file +79 -0
79 lines not on this page · raw message
Signature · 1 line
1.5.3.4
PATCH 2/4 isdn: Use stringbuf
Get rid of the _cdebbuf structure that was used to accumulate strings for a debug printk and use the stringbuf instead. Allocate the stringbuf on the stack instead of with kmalloc. Return a char * to the callers rather than a stringbuf.
--- drivers/isdn/capi/capidrv.c | 18 ++-- drivers/isdn/capi/capiutil.c | 220 ++++++++++------------------------------- drivers/isdn/capi/kcapi.c | 35 +++---- include/linux/isdn/capiutil.h | 16 +--- 4 files changed, 83 insertions(+), 206 deletions(-)
drivers/isdn/capi/capidrv.c +9 -9
@@ -995,7 +995,7 @@ static void handle_plci(_cmsg * cmsg)capidrv_contr *card =findcontrbynumber (cmsg->adr.adrController &0x7f );capidrv_plci *plcip;isdn_ctrl cmd; -_cdebbuf *cdb; +char *s;if (!card) { printk(KERN_ERR "capidrv: %s from unknown controller 0x%x\n",
@@ -1128,11 +1128,11 @@ static void handle_plci(_cmsg * cmsg)break ; } } - cdb =capi_cmsg2str (cmsg); -if (cdb) { + s =capi_cmsg2str (cmsg); +if (s) {printk (KERN_WARNING "capidrv-%d: %s\n" , - card->contrnr, cdb->buf); -cdebbuf_free (cdb); + card->contrnr, s); +kfree (s); }else printk (KERN_WARNING "capidrv-%d: CAPI_INFO_IND InfoNumber %x not handled\n" , card->contrnr, cmsg->InfoNumber);
@@ -1385,12 +1385,12 @@ static void capidrv_recv_message(struct capi20_appl *ap, struct sk_buff *skb) {capi_message2cmsg (&s_cmsg, skb->data);if (debugmode >3 ) { -_cdebbuf *cdb =capi_cmsg2str (&s_cmsg); +char *s =capi_cmsg2str (&s_cmsg); -if (cdb) { +if (s) {printk (KERN_DEBUG "%s: applid=%d %s\n" , __FUNCTION__, - ap->applid, cdb->buf); -cdebbuf_free (cdb); + ap->applid, s); +kfree (s); }else printk(KERN_DEBUG "%s: applid=%d %s not traced\n", __FUNCTION__, ap->applid,
drivers/isdn/capi/capiutil.c +54 -166
351 lines not on this page · raw message
drivers/isdn/capi/kcapi.c +17 -18
@@ -276,14 +276,13 @@ void capi_ctr_handle_message(struct capi_ctr * card, u16 appl, struct sk_buff *sint showctl =0 ;u8 cmd, subcmd;unsigned long flags; -_cdebbuf *cdb;if (card->cardstate !=CARD_RUNNING ) { - cdb =capi_message2str (skb->data); -if (cdb) { +char *s =capi_message2str (skb->data); +if (s) {printk (KERN_INFO "kcapi: controller [%03d] not active, got: %s" , - card->cnr, cdb->buf); -cdebbuf_free (cdb); + card->cnr, s); +kfree (s); }else printk (KERN_INFO "kcapi: controller [%03d] not active, cannot trace\n" , card->cnr);
@@ -307,11 +306,11 @@ void capi_ctr_handle_message(struct capi_ctr * card, u16 appl, struct sk_buff *scapi_cmd2str (cmd, subcmd), CAPIMSG_LEN(skb->data)); }else { - cdb =capi_message2str (skb->data); -if (cdb) { +char *s =capi_message2str (skb->data); +if (s) {printk (KERN_DEBUG "kcapi: got [%03d] %s\n" , - card->cnr, cdb->buf); -cdebbuf_free (cdb); + card->cnr, s); +kfree (s); }else printk(KERN_DEBUG "kcapi: got [%03d] id#%d %s len=%u, cannot trace\n", card->cnr, CAPIMSG_APPID(skb->data),
@@ -324,12 +323,13 @@ void capi_ctr_handle_message(struct capi_ctr * card, u16 appl, struct sk_buff *sread_lock_irqsave (&application_lock, flags); ap =get_capi_appl_by_nr (CAPIMSG_APPID (skb->data));if ((!ap) || (ap->release_in_progress)) { +char *s;read_unlock_irqrestore (&application_lock, flags); - cdb =capi_message2str (skb->data); -if (cdb) { + s =capi_message2str (skb->data); +if (s) {printk (KERN_ERR "kcapi: handle_message: applid %d state released (%s)\n" , -CAPIMSG_APPID (skb->data), cdb->buf); -cdebbuf_free (cdb); +CAPIMSG_APPID (skb->data), s); +kfree (s); }else printk(KERN_ERR "kcapi: handle_message: applid %d state released (%s) cannot trace\n", CAPIMSG_APPID(skb->data),
@@ -649,12 +649,11 @@ u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb)capi_cmd2str (cmd, subcmd), CAPIMSG_LEN(skb->data)); }else { -_cdebbuf *cdb =capi_message2str (skb->data); -if (cdb) { +char *s =capi_message2str (skb->data); +if (s) {printk (KERN_DEBUG "kcapi: put [%03d] %s\n" , -CAPIMSG_CONTROLLER (skb->data), - cdb->buf); -cdebbuf_free (cdb); +CAPIMSG_CONTROLLER (skb->data), s); +kfree (s); }else printk(KERN_DEBUG "kcapi: put [%03d] id#%d %s len=%u cannot trace\n", CAPIMSG_CONTROLLER(skb->data),
include/linux/isdn/capiutil.h +3 -13
@@ -177,22 +177,12 @@ char *capi_info2str(__u16 reason);char *capi_cmd2str (__u8 cmd,__u8 subcmd); -typedef struct { -u_char *buf; -u_char *p; -size_t size; -size_t pos; -}_cdebbuf ; - -#define CDEBUG_SIZE 1024 -#define CDEBUG_GSIZE 4096 - -void cdebbuf_free (_cdebbuf *cdb);int cdebug_init (void );void cdebug_exit (void ); -_cdebbuf *capi_cmsg2str (_cmsg *cmsg); -_cdebbuf *capi_message2str (__u8 *msg); +/* Callers must kfree the strings returned from these functions */ +char *capi_cmsg2str (_cmsg *cmsg); +char *capi_message2str (__u8 *msg);/*-----------------------------------------------------------------------*/
Signature · 1 line
1.5.3.4
PATCH 3/4 sound: Use stringbuf
sound/ had its own snd_info_buffer for doing proc reads, which can be profitably replaced with stringbuf. It actually finds a bug since ->read and ->write now have a different signature.
--- include/sound/info.h | 7 ++- sound/core/hwdep.c | 2 +- sound/core/info.c | 81 +++++-------------------------- sound/core/info_oss.c | 6 +- sound/core/init.c | 8 ++-- sound/core/oss/mixer_oss.c | 2 +- sound/core/oss/pcm_oss.c | 2 +- sound/core/pcm.c | 16 +++--- sound/core/pcm_memory.c | 4 +- sound/core/rawmidi.c | 2 +- sound/core/seq/oss/seq_oss.c | 2 +- sound/core/seq/oss/seq_oss_device.h | 8 ++-- sound/core/seq/oss/seq_oss_init.c | 2 +- sound/core/seq/oss/seq_oss_midi.c | 2 +- sound/core/seq/oss/seq_oss_readq.c | 2 +- sound/core/seq/oss/seq_oss_synth.c | 2 +- sound/core/seq/seq_clientmgr.c | 8 ++-- sound/core/seq/seq_device.c | 2 +- sound/core/seq/seq_info.c | 2 +- sound/core/seq/seq_info.h | 6 +- sound/core/seq/seq_memory.c | 2 +- sound/core/seq/seq_queue.c | 2 +- sound/core/seq/seq_timer.c | 2 +- sound/core/sound.c | 2 +- sound/core/sound_oss.c | 2 +- sound/core/timer.c | 2 +- sound/drivers/vx/vx_core.c | 2 +- sound/i2c/l3/uda1341.c | 4 +- sound/isa/ad1848/ad1848_lib.c | 2 +- sound/isa/gus/gus_irq.c | 2 +- sound/isa/gus/gus_mem.c | 4 +- sound/isa/opti9xx/miro.c | 2 +- sound/isa/sb/sb16_csp.c | 4 +- sound/pci/ac97/ac97_proc.c | 12 ++-- sound/pci/ac97/ak4531_codec.c | 2 +- sound/pci/ad1889.c | 2 +- sound/pci/ali5451/ali5451.c | 2 +- sound/pci/atiixp.c | 2 +- sound/pci/atiixp_modem.c | 2 +- sound/pci/ca0106/ca0106_proc.c | 17 +++---- sound/pci/cmipci.c | 2 +- sound/pci/cs4281.c | 2 +- sound/pci/cs46xx/dsp_spos.c | 14 +++--- sound/pci/cs46xx/dsp_spos_scb_lib.c | 4 +- sound/pci/emu10k1/emu10k1x.c | 2 +- sound/pci/emu10k1/emuproc.c | 28 +++++----- sound/pci/ens1370.c | 2 +- sound/pci/hda/hda_proc.c | 16 +++--- sound/pci/ice1712/ice1712.c | 2 +- sound/pci/ice1712/ice1724.c | 2 +- sound/pci/ice1712/pontis.c | 4 +- sound/pci/intel8x0.c | 2 +- sound/pci/intel8x0m.c | 2 +- sound/pci/korg1212/korg1212.c | 2 +- sound/pci/mixart/mixart.c | 2 +- sound/pci/pcxhr/pcxhr.c | 4 +- sound/pci/riptide/riptide.c | 2 +- sound/pci/rme32.c | 2 +- sound/pci/rme96.c | 2 +- sound/pci/rme9652/hdsp.c | 2 +- sound/pci/rme9652/hdspm.c | 6 +- sound/pci/rme9652/rme9652.c | 2 +- sound/pci/sonicvibes.c | 2 +- sound/pci/trident/trident_main.c | 2 +- sound/pci/via82xx.c | 2 +- sound/pci/via82xx_modem.c | 2 +- sound/pci/ymfpci/ymfpci_main.c | 2 +- sound/pcmcia/pdaudiocf/pdaudiocf_core.c | 2 +- sound/sparc/dbri.c | 4 +- sound/synth/emux/emux_proc.c | 2 +- sound/usb/usbaudio.c | 10 ++-- sound/usb/usbmixer.c | 2 +- 72 files changed, 158 insertions(+), 215 deletions(-)
include/sound/info.h +4 -3
@@ -23,6 +23,7 @@*/ #include <linux/poll.h> +#include <linux/stringbuf.h> /* buffer for information */ struct snd_info_buffer {
@@ -40,7 +41,7 @@ struct snd_info_buffer {struct snd_info_entry ;struct snd_info_entry_text { -void (*read) (struct snd_info_entry *entry,struct snd_info_buffer *buffer); +void (*read) (struct snd_info_entry *entry,struct stringbuf *buffer);void (*write) (struct snd_info_entry *entry,struct snd_info_buffer *buffer); };
@@ -104,7 +105,7 @@ extern struct snd_info_entry *snd_oss_root;#define snd_oss_root NULL#endif -int snd_iprintf (struct snd_info_buffer * buffer,char *fmt,...) __attribute__ ((format (printf,2 ,3 ))); +#define snd_iprintf(buffer, fmt, args...) sb_printf(buffer, fmt , ## args)int snd_info_init (void );int snd_info_done (void );
@@ -131,7 +132,7 @@ int snd_card_proc_new(struct snd_card *card, const char *name, struct snd_info_estatic inline void snd_info_set_text_ops (struct snd_info_entry *entry,void *private_data, -void (*read)(struct snd_info_entry *,struct snd_info_buffer *)) +void (*read)(struct snd_info_entry *,struct stringbuf *)) { entry->private_data = private_data; entry->c.text.read = read;
sound/core/hwdep.c +1 -1
@@ -463,7 +463,7 @@ static int snd_hwdep_dev_disconnect(struct snd_device *device)*/ static void snd_hwdep_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_hwdep *hwdep;
sound/core/info.c +12 -69
137 lines not on this page · raw message
sound/core/info_oss.c +3 -3
@@ -66,9 +66,9 @@ int snd_oss_info_register(int dev, int num, char *string)EXPORT_SYMBOL (snd_oss_info_register); -extern void snd_card_info_read_oss (struct snd_info_buffer *buffer); +extern void snd_card_info_read_oss (struct stringbuf *buffer); -static int snd_sndstat_show_strings (struct snd_info_buffer *buf,char *id,int dev) +static int snd_sndstat_show_strings (struct stringbuf *buf,char *id,int dev) {int idx, ok =-1 ;char *str;
@@ -92,7 +92,7 @@ static int snd_sndstat_show_strings(struct snd_info_buffer *buf, char *id, int d }static void snd_sndstat_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {snd_iprintf (buffer,"Sound Driver:3.8.1a-980706 (ALSA v" CONFIG_SND_VERSION " emulation code)\n" ); snd_iprintf(buffer, "Kernel: %s %s %s %s %s\n",
sound/core/init.c +4 -4
@@ -50,7 +50,7 @@ EXPORT_SYMBOL(snd_mixer_oss_notify_callback);#ifdef CONFIG_PROC_FS static void snd_card_id_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {snd_iprintf (buffer,"%s\n" , entry->card->id); }
@@ -538,7 +538,7 @@ EXPORT_SYMBOL(snd_card_register);static struct snd_info_entry *snd_card_info_entry;static void snd_card_info_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {int idx, count;struct snd_card *card;
@@ -563,7 +563,7 @@ static void snd_card_info_read(struct snd_info_entry *entry,#ifdef CONFIG_SND_OSSEMUL -void snd_card_info_read_oss (struct snd_info_buffer *buffer) +void snd_card_info_read_oss (struct stringbuf *buffer) {int idx, count;struct snd_card *card;
@@ -586,7 +586,7 @@ void snd_card_info_read_oss(struct snd_info_buffer *buffer)#ifdef MODULE static struct snd_info_entry *snd_card_module_info_entry;static void snd_card_module_info_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {int idx;struct snd_card *card;
sound/core/oss/mixer_oss.c +1 -1
@@ -1088,7 +1088,7 @@ static char *oss_mixer_names[SNDRV_OSS_MAX_MIXERS] = {*/ static void snd_mixer_oss_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_mixer_oss *mixer = entry->private_data;int i;
sound/core/oss/pcm_oss.c +1 -1
@@ -2768,7 +2768,7 @@ static int snd_pcm_oss_mmap(struct file *file, struct vm_area_struct *area)*/ static void snd_pcm_oss_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_pcm_str *pstr = entry->private_data;struct snd_pcm_oss_setup *setup = pstr->oss.setup_list;
sound/core/pcm.c +8 -8
@@ -291,7 +291,7 @@ static const char *snd_pcm_oss_format_name(int format)#endif static void snd_pcm_proc_info_read (struct snd_pcm_substream *substream, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_pcm_info *info;int err;
@@ -326,21 +326,21 @@ static void snd_pcm_proc_info_read(struct snd_pcm_substream *substream, }static void snd_pcm_stream_proc_info_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {snd_pcm_proc_info_read (((struct snd_pcm_str *)entry->private_data)->substream, buffer); }static void snd_pcm_substream_proc_info_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {snd_pcm_proc_info_read ((struct snd_pcm_substream *)entry->private_data, buffer); }static void snd_pcm_substream_proc_hw_params_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_pcm_substream *substream = entry->private_data;struct snd_pcm_runtime *runtime = substream->runtime;
@@ -373,7 +373,7 @@ static void snd_pcm_substream_proc_hw_params_read(struct snd_info_entry *entry, }static void snd_pcm_substream_proc_sw_params_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_pcm_substream *substream = entry->private_data;struct snd_pcm_runtime *runtime = substream->runtime;
@@ -398,7 +398,7 @@ static void snd_pcm_substream_proc_sw_params_read(struct snd_info_entry *entry, }static void snd_pcm_substream_proc_status_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_pcm_substream *substream = entry->private_data;struct snd_pcm_runtime *runtime = substream->runtime;
@@ -429,7 +429,7 @@ static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry,#ifdef CONFIG_SND_PCM_XRUN_DEBUG static void snd_pcm_xrun_debug_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_pcm_str *pstr = entry->private_data;snd_iprintf (buffer,"%d\n" , pstr->xrun_debug);
@@ -1058,7 +1058,7 @@ EXPORT_SYMBOL(snd_pcm_notify);*/ static void snd_pcm_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_pcm *pcm;
sound/core/pcm_memory.c +2 -2
@@ -137,7 +137,7 @@ EXPORT_SYMBOL(snd_pcm_lib_preallocate_free_for_all);* prints the current allocated size in kB. */ static void snd_pcm_lib_preallocate_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_pcm_substream *substream = entry->private_data;snd_iprintf (buffer,"%lu\n" , (unsigned long ) substream->dma_buffer.bytes /1024 );
@@ -149,7 +149,7 @@ static void snd_pcm_lib_preallocate_proc_read(struct snd_info_entry *entry,* prints the maximum allowed size in kB. */ static void snd_pcm_lib_preallocate_max_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_pcm_substream *substream = entry->private_data;snd_iprintf (buffer,"%lu\n" , (unsigned long ) substream->dma_max /1024 );
sound/core/rawmidi.c +1 -1
@@ -1299,7 +1299,7 @@ static unsigned int snd_rawmidi_poll(struct file *file, poll_table * wait)*/ static void snd_rawmidi_proc_info_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_rawmidi *rmidi;struct snd_rawmidi_substream *substream;
sound/core/seq/oss/seq_oss.c +1 -1
@@ -268,7 +268,7 @@ unregister_device(void)static struct snd_info_entry *info_entry;static void -info_read (struct snd_info_entry *entry,struct snd_info_buffer *buf) +info_read (struct snd_info_entry *entry,struct stringbuf *buf) {mutex_lock (®ister_mutex);snd_iprintf (buf,"OSS sequencer emulation version %s\n" ,SNDRV_SEQ_OSS_VERSION_STR );
sound/core/seq/oss/seq_oss_device.h +4 -4
@@ -139,10 +139,10 @@ void snd_seq_oss_process_queue(struct seq_oss_devinfo *dp, abstime_t time);/* proc interface */ -void snd_seq_oss_system_info_read (struct snd_info_buffer *buf); -void snd_seq_oss_midi_info_read (struct snd_info_buffer *buf); -void snd_seq_oss_synth_info_read (struct snd_info_buffer *buf); -void snd_seq_oss_readq_info_read (struct seq_oss_readq *q,struct snd_info_buffer *buf); +void snd_seq_oss_system_info_read (struct stringbuf *buf); +void snd_seq_oss_midi_info_read (struct stringbuf *buf); +void snd_seq_oss_synth_info_read (struct stringbuf *buf); +void snd_seq_oss_readq_info_read (struct seq_oss_readq *q,struct stringbuf *buf);/* file mode macros */ #define is_read_mode (mode) ((mode) & SNDRV_SEQ_OSS_FILE_READ)
sound/core/seq/oss/seq_oss_init.c +1 -1
@@ -515,7 +515,7 @@ filemode_str(int val)* proc interface */ void -snd_seq_oss_system_info_read (struct snd_info_buffer *buf) +snd_seq_oss_system_info_read (struct stringbuf *buf) {int i;struct seq_oss_devinfo *dp;
sound/core/seq/oss/seq_oss_midi.c +1 -1
@@ -687,7 +687,7 @@ capmode_str(int val) }void -snd_seq_oss_midi_info_read (struct snd_info_buffer *buf) +snd_seq_oss_midi_info_read (struct stringbuf *buf) {int i;struct seq_oss_midi *mdev;
sound/core/seq/oss/seq_oss_readq.c +1 -1
@@ -227,7 +227,7 @@ snd_seq_oss_readq_put_timestamp(struct seq_oss_readq *q, unsigned long curt, int* proc interface */ void -snd_seq_oss_readq_info_read (struct seq_oss_readq *q,struct snd_info_buffer *buf) +snd_seq_oss_readq_info_read (struct seq_oss_readq *q,struct stringbuf *buf) { snd_iprintf(buf, " read queue [%s] length = %d : tick = %ld\n", (waitqueue_active(&q->midi_sleep) ? "sleeping":"running"),
sound/core/seq/oss/seq_oss_synth.c +1 -1
@@ -626,7 +626,7 @@ snd_seq_oss_synth_make_info(struct seq_oss_devinfo *dp, int dev, struct synth_in* proc interface */ void -snd_seq_oss_synth_info_read (struct snd_info_buffer *buf) +snd_seq_oss_synth_info_read (struct stringbuf *buf) {int i;struct seq_oss_synth *rec;
sound/core/seq/seq_clientmgr.c +4 -4
@@ -2427,7 +2427,7 @@ EXPORT_SYMBOL(snd_seq_kernel_client_write_poll);/* * /proc interface */ -static void snd_seq_info_dump_subscribers (struct snd_info_buffer *buffer, +static void snd_seq_info_dump_subscribers (struct stringbuf *buffer,struct snd_seq_port_subs_info *group,int is_src,char *msg) {
@@ -2466,7 +2466,7 @@ static void snd_seq_info_dump_subscribers(struct snd_info_buffer *buffer,#define FLAG_PERM_DUPLEX (perm) ((perm) & SNDRV_SEQ_PORT_CAP_DUPLEX ? 'X' : '-') -static void snd_seq_info_dump_ports (struct snd_info_buffer *buffer, +static void snd_seq_info_dump_ports (struct stringbuf *buffer,struct snd_seq_client *client) {struct snd_seq_client_port *p;
@@ -2486,12 +2486,12 @@ static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer, } -void snd_seq_info_pool (struct snd_info_buffer *buffer, +void snd_seq_info_pool (struct stringbuf *buffer,struct snd_seq_pool *pool,char *space);/* exported to seq_info.c */ void snd_seq_info_clients_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {int c;struct snd_seq_client *client;
sound/core/seq/seq_device.c +1 -1
@@ -104,7 +104,7 @@ static void remove_drivers(void);#ifdef CONFIG_PROC_FS static void snd_seq_device_info (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct ops_list *ops;
sound/core/seq/seq_info.c +1 -1
@@ -35,7 +35,7 @@ static struct snd_info_entry *timer_entry;static struct snd_info_entry *__init create_info_entry (char *name,void (*read)(struct snd_info_entry *, -struct snd_info_buffer *)) +struct stringbuf *)) {struct snd_info_entry *entry;
sound/core/seq/seq_info.h +3 -3
@@ -24,9 +24,9 @@#include <sound/info.h> #include <sound/seq_kernel.h> -void snd_seq_info_clients_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer); -void snd_seq_info_timer_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer); -void snd_seq_info_queues_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer); +void snd_seq_info_clients_read (struct snd_info_entry *entry,struct stringbuf *buffer); +void snd_seq_info_timer_read (struct snd_info_entry *entry,struct stringbuf *buffer); +void snd_seq_info_queues_read (struct snd_info_entry *entry,struct stringbuf *buffer);#ifdef CONFIG_PROC_FS
sound/core/seq/seq_memory.c +1 -1
@@ -504,7 +504,7 @@ void __exit snd_sequencer_memory_done(void)/* exported to seq_clientmgr.c */ -void snd_seq_info_pool (struct snd_info_buffer *buffer, +void snd_seq_info_pool (struct stringbuf *buffer,struct snd_seq_pool *pool,char *space) {if (pool ==NULL )
sound/core/seq/seq_queue.c +1 -1
@@ -759,7 +759,7 @@ int snd_seq_control_queue(struct snd_seq_event *ev, int atomic, int hop)#ifdef CONFIG_PROC_FS /* exported to seq_info.c */ void snd_seq_info_queues_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {int i, bpm;struct snd_seq_queue *q;
sound/core/seq/seq_timer.c +1 -1
@@ -428,7 +428,7 @@ snd_seq_tick_time_t snd_seq_timer_get_cur_tick(struct snd_seq_timer *tmr)#ifdef CONFIG_PROC_FS /* exported to seq_info.c */ void snd_seq_info_timer_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {int idx;struct snd_seq_queue *q;
sound/core/sound.c +1 -1
@@ -379,7 +379,7 @@ static const char *snd_device_type_name(int type) } } -static void snd_minor_info_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +static void snd_minor_info_read (struct snd_info_entry *entry,struct stringbuf *buffer) {int minor;struct snd_minor *mptr;
sound/core/sound_oss.c +1 -1
@@ -229,7 +229,7 @@ static const char *snd_oss_device_type_name(int type) }static void snd_minor_info_oss_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {int minor;struct snd_minor *mptr;
sound/core/timer.c +1 -1
@@ -1026,7 +1026,7 @@ static int snd_timer_register_system(void)*/ static void snd_timer_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_timer *timer;struct snd_timer_instance *ti;
sound/drivers/vx/vx_core.c +1 -1
@@ -592,7 +592,7 @@ static void vx_reset_board(struct vx_core *chip, int cold_reset)* proc interface */ -static void vx_proc_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +static void vx_proc_read (struct snd_info_entry *entry,struct stringbuf *buffer) {struct vx_core *chip = entry->private_data;static char *audio_src_vxp[] = {"Line" ,"Mic" ,"Digital" };
sound/i2c/l3/uda1341.c +2 -2
@@ -428,7 +428,7 @@ static const char *peak_value[] = { };static void snd_uda1341_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct l3_client *clnt = entry->private_data;struct uda1341 *uda = clnt->driver_data;
@@ -493,7 +493,7 @@ static void snd_uda1341_proc_read(struct snd_info_entry *entry, }static void snd_uda1341_proc_regs_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct l3_client *clnt = entry->private_data;struct uda1341 *uda = clnt->driver_data;
sound/isa/ad1848/ad1848_lib.c +1 -1
@@ -213,7 +213,7 @@ static void snd_ad1848_mce_down(struct snd_ad1848 *chip)for (timeout =12000 ; timeout >0 && (inb (AD1848P (chip,REGSEL )) &AD1848_INIT ); timeout--)udelay (100 ); -snd_printdd ("(1) timeout = %d\n" , timeout); +snd_printdd ("(1) timeout = %ld\n" , timeout);#ifdef CONFIG_SND_DEBUG if (inb (AD1848P (chip,REGSEL )) &AD1848_INIT )
sound/isa/gus/gus_irq.c +1 -1
@@ -114,7 +114,7 @@ __again:#ifdef CONFIG_SND_DEBUG static void snd_gus_irq_info_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_gus_card *gus;struct snd_gus_voice *pvoice;
sound/isa/gus/gus_mem.c +2 -2
@@ -28,7 +28,7 @@#ifdef CONFIG_SND_DEBUG static void snd_gf1_mem_info_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer); +struct stringbuf *buffer);#endif void snd_gf1_mem_lock (struct snd_gf1_mem * alloc,int xup)
@@ -286,7 +286,7 @@ int snd_gf1_mem_done(struct snd_gus_card * gus)#ifdef CONFIG_SND_DEBUG static void snd_gf1_mem_info_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_gus_card *gus;struct snd_gf1_mem *alloc;
sound/isa/opti9xx/miro.c +1 -1
@@ -842,7 +842,7 @@ static void snd_miro_write(struct snd_miro *chip, unsigned char reg,*/ static void snd_miro_proc_read (struct snd_info_entry * entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_miro *miro = (struct snd_miro *) entry->private_data;char * model ="unknown" ;
sound/isa/sb/sb16_csp.c +2 -2
@@ -110,7 +110,7 @@ static void snd_sb_qsound_destroy(struct snd_sb_csp * p);static int snd_sb_csp_qsound_transfer (struct snd_sb_csp * p);static int init_proc_entry (struct snd_sb_csp * p,int device); -static void info_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer); +static void info_read (struct snd_info_entry *entry,struct stringbuf *buffer);/* * Detect CSP chip and create a new instance
@@ -1149,7 +1149,7 @@ static int init_proc_entry(struct snd_sb_csp * p, int device)return 0 ; } -static void info_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +static void info_read (struct snd_info_entry *entry,struct stringbuf *buffer) {struct snd_sb_csp *p = entry->private_data;
sound/pci/ac97/ac97_proc.c +6 -6
@@ -36,7 +36,7 @@* proc interface */ -static void snd_ac97_proc_read_functions (struct snd_ac97 *ac97,struct snd_info_buffer *buffer) +static void snd_ac97_proc_read_functions (struct snd_ac97 *ac97,struct stringbuf *buffer) {int header =0 , function;unsigned short info, sense_info;
@@ -106,7 +106,7 @@ static const char *snd_ac97_stereo_enhancements[] = /* 31 */ "Reserved 31" }; -static void snd_ac97_proc_read_main (struct snd_ac97 *ac97,struct snd_info_buffer *buffer,int subidx) +static void snd_ac97_proc_read_main (struct snd_ac97 *ac97,struct stringbuf *buffer,int subidx) {char name[64 ];unsigned short val, tmp, ext, mext;
@@ -340,7 +340,7 @@ static void snd_ac97_proc_read_main(struct snd_ac97 *ac97, struct snd_info_buffe } } -static void snd_ac97_proc_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +static void snd_ac97_proc_read (struct snd_info_entry *entry,struct stringbuf *buffer) {struct snd_ac97 *ac97 = entry->private_data;
@@ -375,7 +375,7 @@ static void snd_ac97_proc_read(struct snd_info_entry *entry, struct snd_info_buf#ifdef CONFIG_SND_DEBUG /* direct register write for debugging */ -static void snd_ac97_proc_regs_write (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +static void snd_ac97_proc_regs_write (struct snd_info_entry *entry,struct stringbuf *buffer) {struct snd_ac97 *ac97 = entry->private_data;char line[64 ];
@@ -392,7 +392,7 @@ static void snd_ac97_proc_regs_write(struct snd_info_entry *entry, struct snd_in }#endif -static void snd_ac97_proc_regs_read_main (struct snd_ac97 *ac97,struct snd_info_buffer *buffer,int subidx) +static void snd_ac97_proc_regs_read_main (struct snd_ac97 *ac97,struct stringbuf *buffer,int subidx) {int reg, val;
@@ -403,7 +403,7 @@ static void snd_ac97_proc_regs_read_main(struct snd_ac97 *ac97, struct snd_info_ }static void snd_ac97_proc_regs_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_ac97 *ac97 = entry->private_data;
sound/pci/ac97/ak4531_codec.c +1 -1
@@ -466,7 +466,7 @@ void snd_ak4531_resume(struct snd_ak4531 *ak4531)*/ static void snd_ak4531_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_ak4531 *ak4531 = entry->private_data;
sound/pci/ad1889.c +1 -1
@@ -665,7 +665,7 @@ snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device, struct snd_pcm **rpcm) }static void -snd_ad1889_proc_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +snd_ad1889_proc_read (struct snd_info_entry *entry,struct stringbuf *buffer) {struct snd_ad1889 *chip = entry->private_data;u16 reg;
sound/pci/ali5451/ali5451.c +1 -1
@@ -2126,7 +2126,7 @@ static int snd_ali_chip_init(struct snd_ali *codec)/* proc for register dump */ static void snd_ali_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buf) +struct stringbuf *buf) {struct snd_ali *codec = entry->private_data;int i;
sound/pci/atiixp.c +1 -1
@@ -1524,7 +1524,7 @@ static int snd_atiixp_resume(struct pci_dev *pci)*/ static void snd_atiixp_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct atiixp *chip = entry->private_data;int i;
sound/pci/atiixp_modem.c +1 -1
@@ -1168,7 +1168,7 @@ static int snd_atiixp_resume(struct pci_dev *pci)*/ static void snd_atiixp_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct atiixp_modem *chip = entry->private_data;int i;
sound/pci/ca0106/ca0106_proc.c +8 -9
@@ -99,7 +99,7 @@ static struct snd_ca0106_category_str snd_ca0106_con_category[] = { }; -static void snd_ca0106_proc_dump_iec958 (struct snd_info_buffer *buffer,u32 value) +static void snd_ca0106_proc_dump_iec958 (struct stringbuf *buffer,u32 value) {int i;u32 status[4 ];
@@ -274,7 +274,7 @@ static void snd_ca0106_proc_dump_iec958( struct snd_info_buffer *buffer, u32 val }static void snd_ca0106_proc_iec958 (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_ca0106 *emu = entry->private_data;u32 value;
@@ -314,7 +314,7 @@ static void snd_ca0106_proc_reg_write32(struct snd_info_entry *entry, }static void snd_ca0106_proc_reg_read32 (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_ca0106 *emu = entry->private_data;unsigned long value;
@@ -330,7 +330,7 @@ static void snd_ca0106_proc_reg_read32(struct snd_info_entry *entry, }static void snd_ca0106_proc_reg_read16 (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_ca0106 *emu = entry->private_data;unsigned int value;
@@ -346,7 +346,7 @@ static void snd_ca0106_proc_reg_read16(struct snd_info_entry *entry, }static void snd_ca0106_proc_reg_read8 (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_ca0106 *emu = entry->private_data;unsigned int value;
@@ -362,7 +362,7 @@ static void snd_ca0106_proc_reg_read8(struct snd_info_entry *entry, }static void snd_ca0106_proc_reg_read1 (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_ca0106 *emu = entry->private_data;unsigned long value;
@@ -380,7 +380,7 @@ static void snd_ca0106_proc_reg_read1(struct snd_info_entry *entry, }static void snd_ca0106_proc_reg_read2 (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_ca0106 *emu = entry->private_data;unsigned long value;
@@ -448,10 +448,9 @@ int __devinit snd_ca0106_proc_init(struct snd_ca0106 * emu)// entry->private_data = emu; }if (!snd_card_proc_new (emu->card,"ca0106_i2c" , &entry)) { -snd_info_set_text_ops (entry, emu, snd_ca0106_proc_i2c_write); + entry->private_data = emu; entry->c.text.write = snd_ca0106_proc_i2c_write; entry->mode |=S_IWUSR ; -// entry->private_data = emu; }if (!snd_card_proc_new (emu->card,"ca0106_regs2" , &entry))snd_info_set_text_ops (entry, emu, snd_ca0106_proc_reg_read2);
sound/pci/cmipci.c +1 -1
@@ -2706,7 +2706,7 @@ static int __devinit snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_devic#ifdef CONFIG_PROC_FS static void snd_cmipci_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct cmipci *cm = entry->private_data;int i, v;
sound/pci/cs4281.c +1 -1
@@ -1127,7 +1127,7 @@ static int __devinit snd_cs4281_mixer(struct cs4281 * chip)*/ static void snd_cs4281_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct cs4281 *chip = entry->private_data;
sound/pci/cs46xx/dsp_spos.c +7 -7
@@ -484,8 +484,8 @@ cs46xx_dsp_lookup_symbol_addr (struct snd_cs46xx * chip, u32 address, int symbol } -static void cs46xx_dsp_proc_symbol_table_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +static void cs46xx_dsp_proc_symbol_table_read (struct snd_info_entry *entry, +struct stringbuf *buffer) {struct snd_cs46xx *chip = entry->private_data;struct dsp_spos_instance * ins = chip->dsp_spos_instance;
@@ -513,7 +513,7 @@ static void cs46xx_dsp_proc_symbol_table_read (struct snd_info_entry *entry,static void cs46xx_dsp_proc_modules_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_cs46xx *chip = entry->private_data;struct dsp_spos_instance * ins = chip->dsp_spos_instance;
@@ -536,7 +536,7 @@ static void cs46xx_dsp_proc_modules_read (struct snd_info_entry *entry, }static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_cs46xx *chip = entry->private_data;struct dsp_spos_instance * ins = chip->dsp_spos_instance;
@@ -564,7 +564,7 @@ static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry *entry, }static void cs46xx_dsp_proc_scb_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_cs46xx *chip = entry->private_data;struct dsp_spos_instance * ins = chip->dsp_spos_instance;
@@ -597,7 +597,7 @@ static void cs46xx_dsp_proc_scb_read (struct snd_info_entry *entry, }static void cs46xx_dsp_proc_parameter_dump_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_cs46xx *chip = entry->private_data;/*struct dsp_spos_instance * ins = chip->dsp_spos_instance; */
@@ -625,7 +625,7 @@ static void cs46xx_dsp_proc_parameter_dump_read (struct snd_info_entry *entry, }static void cs46xx_dsp_proc_sample_dump_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_cs46xx *chip = entry->private_data;int i,col =0 ;
sound/pci/cs46xx/dsp_spos_scb_lib.c +2 -2
@@ -66,8 +66,8 @@ static void remove_symbol (struct snd_cs46xx * chip, struct dsp_symbol_entry * s }#ifdef CONFIG_PROC_FS -static void cs46xx_dsp_proc_scb_info_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +static void cs46xx_dsp_proc_scb_info_read (struct snd_info_entry *entry, +struct stringbuf *buffer) {struct proc_scb_info * scb_info = entry->private_data;struct dsp_scb_descriptor * scb = scb_info->scb_desc;
sound/pci/emu10k1/emu10k1x.c +1 -1
@@ -1004,7 +1004,7 @@ static int __devinit snd_emu10k1x_create(struct snd_card *card, }static void snd_emu10k1x_proc_reg_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct emu10k1x *emu = entry->private_data;unsigned long value,value1,value2;
sound/pci/emu10k1/emuproc.c +14 -14
@@ -37,7 +37,7 @@#ifdef CONFIG_PROC_FS static void snd_emu10k1_proc_spdif_status (struct snd_emu10k1 * emu, -struct snd_info_buffer *buffer, +struct stringbuf *buffer,char *title,int status_reg,int rate_reg)
@@ -80,7 +80,7 @@ static void snd_emu10k1_proc_spdif_status(struct snd_emu10k1 * emu, }static void snd_emu10k1_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {/* FIXME - output names are in emufx.c too */ static char *creative_outs[32 ] = {
@@ -237,7 +237,7 @@ static void snd_emu10k1_proc_read(struct snd_info_entry *entry, }static void snd_emu10k1_proc_spdif_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_emu10k1 *emu = entry->private_data;u32 value;
@@ -285,7 +285,7 @@ static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry, }static void snd_emu10k1_proc_rates_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {static int samplerate[8 ] = {44100 ,48000 ,96000 ,192000 ,4 ,5 ,6 ,7 };struct snd_emu10k1 *emu = entry->private_data;
@@ -300,7 +300,7 @@ static void snd_emu10k1_proc_rates_read(struct snd_info_entry *entry, }static void snd_emu10k1_proc_acode_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {u32 pc;struct snd_emu10k1 *emu = entry->private_data;
@@ -389,7 +389,7 @@ static long snd_emu10k1_fx8010_read(struct snd_info_entry *entry, }static void snd_emu10k1_proc_voices_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_emu10k1 *emu = entry->private_data;struct snd_emu10k1_voice *voice;
@@ -410,7 +410,7 @@ static void snd_emu10k1_proc_voices_read(struct snd_info_entry *entry,#ifdef CONFIG_SND_DEBUG static void snd_emu_proc_emu1010_reg_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_emu10k1 *emu = entry->private_data;int value;
@@ -427,7 +427,7 @@ static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry, }static void snd_emu_proc_io_reg_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_emu10k1 *emu = entry->private_data;unsigned long value;
@@ -496,7 +496,7 @@ static void snd_ptr_write(struct snd_emu10k1 *emu,static void snd_emu_proc_ptr_reg_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer,int iobase,int offset,int length,int voices) +struct stringbuf *buffer,int iobase,int offset,int length,int voices) {struct snd_emu10k1 *emu = entry->private_data;unsigned long value;
@@ -547,31 +547,31 @@ static void snd_emu_proc_ptr_reg_write20(struct snd_info_entry *entry,static void snd_emu_proc_ptr_reg_read00a (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {snd_emu_proc_ptr_reg_read (entry, buffer,0 ,0 ,0x40 ,64 ); }static void snd_emu_proc_ptr_reg_read00b (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {snd_emu_proc_ptr_reg_read (entry, buffer,0 ,0x40 ,0x40 ,64 ); }static void snd_emu_proc_ptr_reg_read20a (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {snd_emu_proc_ptr_reg_read (entry, buffer,0x20 ,0 ,0x40 ,4 ); }static void snd_emu_proc_ptr_reg_read20b (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {snd_emu_proc_ptr_reg_read (entry, buffer,0x20 ,0x40 ,0x40 ,4 ); }static void snd_emu_proc_ptr_reg_read20c (struct snd_info_entry *entry, -struct snd_info_buffer * buffer) +struct stringbuf * buffer) {snd_emu_proc_ptr_reg_read (entry, buffer,0x20 ,0x80 ,0x20 ,4 ); }
sound/pci/ens1370.c +1 -1
@@ -1865,7 +1865,7 @@ static inline void snd_ensoniq_free_gameport(struct ensoniq *ensoniq) { }*/ static void snd_ensoniq_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct ensoniq *ensoniq = entry->private_data;
sound/pci/hda/hda_proc.c +8 -8
@@ -47,7 +47,7 @@ static const char *get_wid_type_name(unsigned int wid_value)return "UNKNOWN Widget" ; } -static void print_amp_caps (struct snd_info_buffer *buffer, +static void print_amp_caps (struct stringbuf *buffer,struct hda_codec *codec,hda_nid_t nid,int dir) {unsigned int caps;
@@ -66,7 +66,7 @@ static void print_amp_caps(struct snd_info_buffer *buffer, (caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT); } -static void print_amp_vals (struct snd_info_buffer *buffer, +static void print_amp_vals (struct stringbuf *buffer,struct hda_codec *codec,hda_nid_t nid,int dir,int stereo,int indices) {
@@ -90,7 +90,7 @@ static void print_amp_vals(struct snd_info_buffer *buffer,snd_iprintf (buffer,"\n" ); } -static void print_pcm_rates (struct snd_info_buffer *buffer,unsigned int pcm) +static void print_pcm_rates (struct stringbuf *buffer,unsigned int pcm) {static unsigned int rates[] = {8000 ,11025 ,16000 ,22050 ,32000 ,44100 ,48000 ,88200 ,
@@ -106,7 +106,7 @@ static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm)snd_iprintf (buffer,"\n" ); } -static void print_pcm_bits (struct snd_info_buffer *buffer,unsigned int pcm) +static void print_pcm_bits (struct stringbuf *buffer,unsigned int pcm) {static unsigned int bits[] = {8 ,16 ,20 ,24 ,32 };int i;
@@ -119,7 +119,7 @@ static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm)snd_iprintf (buffer,"\n" ); } -static void print_pcm_formats (struct snd_info_buffer *buffer, +static void print_pcm_formats (struct stringbuf *buffer,unsigned int streams) {snd_iprintf (buffer," formats [0x%x]:" , streams &0xf );
@@ -132,7 +132,7 @@ static void print_pcm_formats(struct snd_info_buffer *buffer,snd_iprintf (buffer,"\n" ); } -static void print_pcm_caps (struct snd_info_buffer *buffer, +static void print_pcm_caps (struct stringbuf *buffer,struct hda_codec *codec,hda_nid_t nid) {unsigned int pcm =snd_hda_param_read (codec, nid,AC_PAR_PCM );
@@ -202,7 +202,7 @@ static const char *get_jack_color(u32 cfg)return "UNKNOWN" ; } -static void print_pin_caps (struct snd_info_buffer *buffer, +static void print_pin_caps (struct stringbuf *buffer,struct hda_codec *codec,hda_nid_t nid) {static char *jack_conns[4 ] = {"Jack" ,"N/A" ,"Fixed" ,"Both" };
@@ -241,7 +241,7 @@ static void print_pin_caps(struct snd_info_buffer *buffer,static void print_codec_info (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct hda_codec *codec = entry->private_data;char buf[32 ];
sound/pci/ice1712/ice1712.c +1 -1
@@ -1543,7 +1543,7 @@ static inline unsigned int eeprom_double(struct snd_ice1712 *ice, int idx) }static void snd_ice1712_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_ice1712 *ice = entry->private_data;unsigned int idx;
sound/pci/ice1712/ice1724.c +1 -1
@@ -1248,7 +1248,7 @@ static inline unsigned int eeprom_triple(struct snd_ice1712 *ice, int idx) }static void snd_vt1724_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_ice1712 *ice = entry->private_data;unsigned int idx;
sound/pci/ice1712/pontis.c +2 -2
@@ -651,7 +651,7 @@ static void wm_proc_regs_write(struct snd_info_entry *entry, struct snd_info_bufmutex_unlock (&ice->gpio_mutex); } -static void wm_proc_regs_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +static void wm_proc_regs_read (struct snd_info_entry *entry,struct stringbuf *buffer) {struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data;int reg, val;
@@ -674,7 +674,7 @@ static void wm_proc_init(struct snd_ice1712 *ice) } } -static void cs_proc_regs_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +static void cs_proc_regs_read (struct snd_info_entry *entry,struct stringbuf *buffer) {struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data;int reg, val;
sound/pci/intel8x0.c +1 -1
@@ -2655,7 +2655,7 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip)#ifdef CONFIG_PROC_FS static void snd_intel8x0_proc_read (struct snd_info_entry * entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct intel8x0 *chip = entry->private_data;unsigned int tmp;
sound/pci/intel8x0m.c +1 -1
@@ -1060,7 +1060,7 @@ static int intel8x0m_resume(struct pci_dev *pci)#ifdef CONFIG_PROC_FS static void snd_intel8x0m_proc_read (struct snd_info_entry * entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct intel8x0m *chip = entry->private_data;unsigned int tmp;
sound/pci/korg1212/korg1212.c +1 -1
@@ -2051,7 +2051,7 @@ static struct snd_kcontrol_new snd_korg1212_controls[] = {*/ static void snd_korg1212_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {int n;struct snd_korg1212 *korg1212 = entry->private_data;
sound/pci/mixart/mixart.c +1 -1
@@ -1202,7 +1202,7 @@ static struct snd_info_entry_ops snd_mixart_proc_ops_BA1 = {static void snd_mixart_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_mixart *chip = entry->private_data;u32 ref;
sound/pci/pcxhr/pcxhr.c +2 -2
@@ -1059,7 +1059,7 @@ static int __devinit pcxhr_create(struct pcxhr_mgr *mgr, struct snd_card *card, }/* proc interface */ -static void pcxhr_proc_info (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +static void pcxhr_proc_info (struct snd_info_entry *entry,struct stringbuf *buffer) {struct snd_pcxhr *chip = entry->private_data;struct pcxhr_mgr *mgr = chip->mgr;
@@ -1120,7 +1120,7 @@ static void pcxhr_proc_info(struct snd_info_entry *entry, struct snd_info_buffersnd_iprintf (buffer,"no firmware loaded\n" );snd_iprintf (buffer,"\n" ); } -static void pcxhr_proc_sync (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +static void pcxhr_proc_sync (struct snd_info_entry *entry,struct stringbuf *buffer) {struct snd_pcxhr *chip = entry->private_data;struct pcxhr_mgr *mgr = chip->mgr;
sound/pci/riptide/riptide.c +1 -1
@@ -1928,7 +1928,7 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci,static void snd_riptide_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_riptide *chip = entry->private_data;struct pcmhw *data;
sound/pci/rme32.c +1 -1
@@ -1463,7 +1463,7 @@ static int __devinit snd_rme32_create(struct rme32 * rme32)*/ static void -snd_rme32_proc_read (struct snd_info_entry * entry,struct snd_info_buffer *buffer) +snd_rme32_proc_read (struct snd_info_entry * entry,struct stringbuf *buffer) {int n;struct rme32 *rme32 = (struct rme32 *) entry->private_data;
sound/pci/rme96.c +1 -1
@@ -1663,7 +1663,7 @@ snd_rme96_create(struct rme96 *rme96)*/ static void -snd_rme96_proc_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +snd_rme96_proc_read (struct snd_info_entry *entry,struct stringbuf *buffer) {int n;struct rme96 *rme96 = (struct rme96 *)entry->private_data;
sound/pci/rme9652/hdsp.c +1 -1
@@ -3242,7 +3242,7 @@ static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp)------------------------------------------------------------*/ static void -snd_hdsp_proc_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +snd_hdsp_proc_read (struct snd_info_entry *entry,struct stringbuf *buffer) {struct hdsp *hdsp = (struct hdsp *) entry->private_data;unsigned int status;
sound/pci/rme9652/hdspm.c +3 -3
@@ -2938,7 +2938,7 @@ static int snd_hdspm_create_controls(struct snd_card *card, struct hdspm * hdspmstatic void snd_hdspm_proc_read_madi (struct snd_info_entry * entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct hdspm *hdspm = entry->private_data;unsigned int status;
@@ -3133,7 +3133,7 @@ snd_hdspm_proc_read_madi(struct snd_info_entry * entry,static void snd_hdspm_proc_read_aes32 (struct snd_info_entry * entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct hdspm *hdspm = entry->private_data;unsigned int status;
@@ -3305,7 +3305,7 @@ snd_hdspm_proc_read_aes32(struct snd_info_entry * entry,#ifdef CONFIG_SND_DEBUG static void snd_hdspm_proc_read_debug (struct snd_info_entry * entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct hdspm *hdspm = entry->private_data;
sound/pci/rme9652/rme9652.c +1 -1
@@ -1589,7 +1589,7 @@ static int snd_rme9652_create_controls(struct snd_card *card, struct snd_rme9652------------------------------------------------------------*/ static void -snd_rme9652_proc_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +snd_rme9652_proc_read (struct snd_info_entry *entry,struct stringbuf *buffer) {struct snd_rme9652 *rme9652 = (struct snd_rme9652 *) entry->private_data;u32 thru_bits = rme9652->thru_bits;
sound/pci/sonicvibes.c +1 -1
@@ -1110,7 +1110,7 @@ static int __devinit snd_sonicvibes_mixer(struct sonicvibes * sonic)*/ static void snd_sonicvibes_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct sonicvibes *sonic = entry->private_data;unsigned char tmp;
sound/pci/trident/trident_main.c +1 -1
@@ -3281,7 +3281,7 @@ static int snd_trident_sis_reset(struct snd_trident *trident)*/ static void snd_trident_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_trident *trident = entry->private_data;char *s;
sound/pci/via82xx.c +1 -1
@@ -2017,7 +2017,7 @@ static int __devinit snd_via686_init_misc(struct via82xx *chip)* proc interface */ static void snd_via82xx_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct via82xx *chip = entry->private_data;int i;
sound/pci/via82xx_modem.c +1 -1
@@ -913,7 +913,7 @@ static int __devinit snd_via82xx_mixer_new(struct via82xx_modem *chip)/* * proc interface */ -static void snd_via82xx_proc_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +static void snd_via82xx_proc_read (struct snd_info_entry *entry,struct stringbuf *buffer) {struct via82xx_modem *chip = entry->private_data;int i;
sound/pci/ymfpci/ymfpci_main.c +1 -1
@@ -1929,7 +1929,7 @@ int __devinit snd_ymfpci_timer(struct snd_ymfpci *chip, int device)*/ static void snd_ymfpci_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_ymfpci *chip = entry->private_data;int i;
sound/pcmcia/pdaudiocf/pdaudiocf_core.c +1 -1
@@ -128,7 +128,7 @@ void pdacf_reinit(struct snd_pdacf *chip, int resume) }static void pdacf_proc_read (struct snd_info_entry * entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_pdacf *chip = entry->private_data;u16 tmp;
sound/sparc/dbri.c +2 -2
@@ -2446,7 +2446,7 @@ static int __devinit snd_dbri_mixer(struct snd_card *card)/proc interface ****************************************************************************/ static void dbri_regs_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_dbri *dbri = entry->private_data;
@@ -2458,7 +2458,7 @@ static void dbri_regs_read(struct snd_info_entry *entry,#ifdef DBRI_DEBUG static void dbri_debug_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) {struct snd_dbri *dbri = entry->private_data;int pipe;
sound/synth/emux/emux_proc.c +1 -1
@@ -30,7 +30,7 @@static void snd_emux_proc_info_read (struct snd_info_entry *entry, -struct snd_info_buffer *buf) +struct stringbuf *buf) {struct snd_emux *emu;int i;
sound/usb/usbaudio.c +5 -5
@@ -2101,7 +2101,7 @@ static struct usb_driver usb_audio_driver = {/* * proc interface for list the supported pcm formats */ -static void proc_dump_substream_formats (struct snd_usb_substream *subs,struct snd_info_buffer *buffer) +static void proc_dump_substream_formats (struct snd_usb_substream *subs,struct stringbuf *buffer) {struct list_head *p;static char *sync_types[4 ] = {
@@ -2137,7 +2137,7 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s } } -static void proc_dump_substream_status (struct snd_usb_substream *subs,struct snd_info_buffer *buffer) +static void proc_dump_substream_status (struct snd_usb_substream *subs,struct stringbuf *buffer) {if (subs->running) {unsigned int i;
@@ -2159,7 +2159,7 @@ static void proc_dump_substream_status(struct snd_usb_substream *subs, struct sn } } -static void proc_pcm_format_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +static void proc_pcm_format_read (struct snd_info_entry *entry,struct stringbuf *buffer) {struct snd_usb_stream *stream = entry->private_data;
@@ -3327,14 +3327,14 @@ static int snd_usb_create_quirk(struct snd_usb_audio *chip,/* * common proc files to show the usb device info */ -static void proc_audio_usbbus_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +static void proc_audio_usbbus_read (struct snd_info_entry *entry,struct stringbuf *buffer) {struct snd_usb_audio *chip = entry->private_data;if (! chip->shutdown)snd_iprintf (buffer,"%03d/%03d\n" , chip->dev->bus->busnum, chip->dev->devnum); } -static void proc_audio_usbid_read (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +static void proc_audio_usbid_read (struct snd_info_entry *entry,struct stringbuf *buffer) {struct snd_usb_audio *chip = entry->private_data;if (! chip->shutdown)
sound/usb/usbmixer.c +1 -1
@@ -1961,7 +1961,7 @@ static int snd_audigy2nx_controls_create(struct usb_mixer_interface *mixer) }static void snd_audigy2nx_proc_read (struct snd_info_entry *entry, -struct snd_info_buffer *buffer) +struct stringbuf *buffer) { static const struct { int unitid;
Signature · 1 line
1.5.3.4
PATCH 4/4 partitions: Fix non-atomic printk
With asynchronous disk scanning, it's quite common for the partition report to be interrupted by reports of other discs being discovered. Use a new function, print_partition, to accumulate the partitions into a stringbuf.
--- fs/partitions/acorn.c | 24 ++++++++++-------------- fs/partitions/amiga.c | 9 ++++----- fs/partitions/atari.c | 20 +++++++++----------- fs/partitions/check.c | 19 ++++++++++++++----- fs/partitions/check.h | 6 +++++- fs/partitions/efi.c | 1 - fs/partitions/ibm.c | 11 +++++------ fs/partitions/karma.c | 1 - fs/partitions/ldm.c | 11 +++++------ fs/partitions/mac.c | 3 +-- fs/partitions/msdos.c | 36 +++++++++++++++++------------------- fs/partitions/osf.c | 1 - fs/partitions/sgi.c | 1 - fs/partitions/sun.c | 1 - fs/partitions/sysv68.c | 5 ++--- fs/partitions/ultrix.c | 1 - 16 files changed, 72 insertions(+), 78 deletions(-)
fs/partitions/acorn.c +10 -14
@@ -46,7 +46,7 @@ adfs_partition(struct parsed_partitions *state, char *name, char *data, (le32_to_cpu (dr->disc_size) >>9 );if (name) -printk (" [%s]" , name); +print_partition (state," [%s]" , name);put_partition (state, slot, first_sector, nr_sects);return dr; }
@@ -81,14 +81,14 @@ riscix_partition(struct parsed_partitions *state, struct block_device *bdev,if (!rr)return -1 ; -printk (" [RISCiX]" ); +print_partition (state," [RISCiX]" );if (rr->magic ==RISCIX_MAGIC ) {unsigned long size = nr_sects >2 ?2 : nr_sects;int part; -printk (" <" ); +print_partition (state," <" );put_partition (state, slot++, first_sect, size);for (part =0 ; part <8 ; part++) {
@@ -97,11 +97,11 @@ riscix_partition(struct parsed_partitions *state, struct block_device *bdev,put_partition (state, slot++,le32_to_cpu (rr->part[part].start),le32_to_cpu (rr->part[part].length)); -printk ("(%s)" , rr->part[part].name); +print_partition (state,"(%s)" , rr->part[part].name); } } -printk (" >\n" ); +print_partition (state," >" ); }else {put_partition (state, slot++, first_sect, nr_sects); }
@@ -131,7 +131,7 @@ linux_partition(struct parsed_partitions *state, struct block_device *bdev,struct linux_part *linuxp;unsigned long size = nr_sects >2 ?2 : nr_sects; -printk (" [Linux]" ); +print_partition (state," [Linux]" );put_partition (state, slot++, first_sect, size);
@@ -139,7 +139,7 @@ linux_partition(struct parsed_partitions *state, struct block_device *bdev,if (!linuxp)return -1 ; -printk (" <" ); +print_partition (state," <" );while (linuxp->magic ==cpu_to_le32 (LINUX_NATIVE_MAGIC ) || linuxp->magic ==cpu_to_le32 (LINUX_SWAP_MAGIC )) {if (slot == state->limit)
@@ -149,7 +149,7 @@ linux_partition(struct parsed_partitions *state, struct block_device *bdev, le32_to_cpu(linuxp->nr_sects)); linuxp ++; } -printk (" >" ); +print_partition (state," >" );put_dev_sector (sect);return slot;
@@ -306,7 +306,6 @@ adfspart_check_ADFS(struct parsed_partitions *state, struct block_device *bdev) break; } } -printk ("\n" );return 1 ; }#endif
@@ -379,7 +378,7 @@ adfspart_check_ICS(struct parsed_partitions *state, struct block_device *bdev)return 0 ; } -printk (" [ICS]" ); +print_partition (state," [ICS]" );for (slot =1 , p = (const struct ics_part *)data; p->size; p++) {u32 start =le32_to_cpu (p->start);
@@ -413,7 +412,6 @@ adfspart_check_ICS(struct parsed_partitions *state, struct block_device *bdev) }put_dev_sector (sect); -printk ("\n" );return 1 ; }#endif
@@ -474,7 +472,7 @@ adfspart_check_POWERTEC(struct parsed_partitions *state, struct block_device *bdreturn 0 ; } -printk (" [POWERTEC]" ); +print_partition (state," [POWERTEC]" );for (i =0 , p = (const struct ptec_part *)data; i <12 ; i++, p++) {u32 start =le32_to_cpu (p->start);
@@ -485,7 +483,6 @@ adfspart_check_POWERTEC(struct parsed_partitions *state, struct block_device *bd }put_dev_sector (sect); -printk ("\n" );return 1 ; }#endif
@@ -557,7 +554,6 @@ adfspart_check_EESOX(struct parsed_partitions *state, struct block_device *bdev) size =get_capacity (bdev->bd_disk);put_partition (state, slot++, start, size - start); -printk ("\n" ); }return i ?1 :0 ;
fs/partitions/amiga.c +4 -5
@@ -70,7 +70,7 @@ amiga_partition(struct parsed_partitions *state, struct block_device *bdev)/* blksize is blocks per 512 byte standard block */ blksize =be32_to_cpu ( rdb->rdb_BlockBytes ) /512 ; -printk (" RDSK (%d)" , blksize *512 );/* Be more informative */ +print_partition (state," RDSK (%d)" , blksize *512 );/* Be more informative */ blk =be32_to_cpu (rdb->rdb_PartitionList);put_dev_sector (sect);for (part =1 ; blk>0 && part<=16 ; part++,put_dev_sector (sect)) {
@@ -110,20 +110,19 @@ amiga_partition(struct parsed_partitions *state, struct block_device *bdev)__be32 *dt = (__be32 *)dostype; *dt = pb->pb_Environment[16 ];if (dostype[3 ] <' ' ) -printk (" (%c%c%c^%c)" , +print_partition (state," (%c%c%c^%c)" , dostype[0 ], dostype[1 ], dostype[2 ], dostype[3 ] +'@' );else -printk (" (%c%c%c%c)" , +print_partition (state," (%c%c%c%c)" , dostype[0 ], dostype[1 ], dostype[2 ], dostype[3 ]); -printk ("(res %d spb %d)" , +print_partition (state,"(res %d spb %d)" ,be32_to_cpu (pb->pb_Environment[6 ]),be32_to_cpu (pb->pb_Environment[4 ])); } res =1 ; } -printk ("\n" ); rdb_done:return res;
fs/partitions/atari.c +9 -11
@@ -62,7 +62,7 @@ int atari_partition(struct parsed_partitions *state, struct block_device *bdev) } pi = &rs->part[0 ]; -printk (" AHDI" ); +print_partition (state," AHDI" );for (slot =1 ; pi < &rs->part[4 ] && slot < state->limit; slot++, pi++) {struct rootsector *xrs;Sector sect2;
@@ -81,19 +81,19 @@ int atari_partition(struct parsed_partitions *state, struct block_device *bdev)#ifdef ICD_PARTS part_fmt =1 ;#endif -printk (" XGM<" ); +print_partition (state," XGM<" ); partsect = extensect =be32_to_cpu (pi->st);while (1 ) { xrs = (struct rootsector *)read_dev_sector (bdev, partsect, §2);if (!xrs) { -printk (" block %ld read failed\n" , partsect); +print_partition (state," block %ld read failed\n" , partsect);put_dev_sector (sect);return -1 ; }/* ++roman: sanity check: bit 0 of flg field must be set */ if (!(xrs->part[0 ].flg &1 )) { -printk ("\nFirst sub-partition in extended partition is not valid!\n" ); +printk ("First sub-partition in extended partition is not valid!\n" );put_dev_sector (sect2);break ; }
@@ -108,7 +108,7 @@ int atari_partition(struct parsed_partitions *state, struct block_device *bdev)break ; }if (memcmp ( xrs->part[1 ].id,"XGM" ,3 ) !=0 ) { -printk ("\nID of extended partition is not XGM!\n" ); +printk ("ID of extended partition is not XGM!\n" );put_dev_sector (sect2);break ; }
@@ -116,18 +116,18 @@ int atari_partition(struct parsed_partitions *state, struct block_device *bdev) partsect =be32_to_cpu (xrs->part[1 ].st) + extensect;put_dev_sector (sect2);if (++slot == state->limit) { -printk ("\nMaximum number of partitions reached!\n" ); +printk ("Maximum number of partitions reached!\n" );break ; } } -printk (" >" ); +print_partition (state," >" ); }#ifdef ICD_PARTS if ( part_fmt!=1 ) {/* no extended partitions -> test ICD-format */ pi = &rs->icdpart[0 ];/* sanity check: no ICD format if first partition invalid */ if (OK_id (pi->id)) { -printk (" ICD<" ); +print_partition (state," ICD<" );for (; pi < &rs->icdpart[8 ] && slot < state->limit; slot++, pi++) {/* accept only GEM,BGM,RAW,LNX,SWP partitions */ if (!((pi->flg &1 ) &&OK_id (pi->id)))
@@ -137,13 +137,11 @@ int atari_partition(struct parsed_partitions *state, struct block_device *bdev)be32_to_cpu (pi->st), be32_to_cpu(pi->siz)); } -printk (" >" ); +print_partition (state," >" ); } }#endif put_dev_sector (sect); -printk ("\n" ); -return 1 ; }
fs/partitions/check.c +14 -5
@@ -162,9 +162,10 @@ check_partition(struct gendisk *hd, struct block_device *bdev) state =kmalloc (sizeof (struct parsed_partitions ),GFP_KERNEL );if (!state)return NULL ; +sb_init (&state->sb);disk_name (hd,0 , state->name); -printk (KERN_INFO " %s:" , state->name); +print_partition (state,"%s:" , state->name);if (isdigit (state->name[strlen (state->name)-1 ]))sprintf (state->name,"p" );
@@ -182,15 +183,23 @@ check_partition(struct gendisk *hd, struct block_device *bdev) } } -if (res >0 ) + +if (res >0 ) { +printk (KERN_INFO " %s\n" ,sb_string (&state->sb)); +sb_free (&state->sb);return state; -if (err) + } +/* The partition is unrecognized. So report I/O errors if there were any */ +if (err) res = err;if (!res) -printk (" unknown partition table\n" ); +print_partition (state," unknown partition table" );else if (warn_no_part) -printk (" unable to read partition table\n" ); +print_partition (state," unable to read partition table" ); + +printk (KERN_INFO " %s\n" ,sb_string (&state->sb)); +sb_free (&state->sb);kfree (state);return ERR_PTR (res); }
fs/partitions/check.h +5 -1
@@ -1,5 +1,6 @@#include <linux/pagemap.h> #include <linux/blkdev.h> +#include <linux/stringbuf.h> /* * add_gd_partition adds a partitions details to the devices partition
@@ -16,15 +17,18 @@ struct parsed_partitions { } parts[MAX_PART ];int next;int limit; +struct stringbuf sb; }; +#define print_partition(p, fmt, args...) sb_printf(&p->sb, fmt , ## args) +static inline void put_partition (struct parsed_partitions *p,int n,sector_t from,sector_t size) {if (n < p->limit) { p->parts[n].from = from; p->parts[n].size = size; -printk (" %s%d" , p->name, n); +sb_printf (&p->sb," %s%d" , p->name, n); } }
fs/partitions/efi.c +0 -1
@@ -634,6 +634,5 @@ efi_partition(struct parsed_partitions *state, struct block_device *bdev) }kfree (ptes);kfree (gpt); -printk ("\n" );return 1 ; }
fs/partitions/ibm.c +5 -6
@@ -111,14 +111,14 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)* VM style CMS1 labeled disk */ if (label->cms.disk_offset !=0 ) { -printk ("CMS1/%8s(MDSK):" , name); +print_partition (state,"CMS1/%8s(MDSK):" , name);/* disk is reserved minidisk */ blocksize = label->cms.block_size; offset = label->cms.disk_offset; size = (label->cms.block_count -1 ) * (blocksize >>9 ); }else { -printk ("CMS1/%8s:" , name); +print_partition (state,"CMS1/%8s:" , name); offset = (info->label_block +1 ); size = i_size >>9 ; }
@@ -127,9 +127,9 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)* Old style LNX1 or unlabeled disk */ if (strncmp (type,"LNX1" ,4 ) ==0 ) -printk ("LNX1/%8s:" , name); +print_partition (state,"LNX1/%8s:" , name);else -printk ("(nonl)" ); +print_partition (state,"(nonl)" ); offset = (info->label_block +1 ); size = i_size >>9 ; }
@@ -147,7 +147,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)* if not, something is wrong, skipping partition detection */ if (strncmp (type,"VOL1" ,4 ) ==0 ) { -printk ("VOL1/%8s:" , name); +print_partition (state,"VOL1/%8s:" , name);/* * get block number and read then go through format1 * labels
@@ -203,7 +203,6 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) } -printk ("\n" ); goto out_freeall;
fs/partitions/karma.c +0 -1
@@ -50,7 +50,6 @@ int karma_partition(struct parsed_partitions *state, struct block_device *bdev) } slot++; } -printk ("\n" );put_dev_sector (sect);return 1 ; }
fs/partitions/ldm.c +5 -6
@@ -611,7 +611,7 @@ static struct vblk * ldm_get_disk_objid (const struct ldmdb *ldb)/** * ldm_create_data_partitions - Create data partitions for this device -* @pp: List of the partitions parsed so far +* @state: List of the partitions parsed so far * @ldb: Cache of the database structures * * The database contains ALL the partitions for ALL disk groups, so we need to
@@ -626,7 +626,7 @@ static struct vblk * ldm_get_disk_objid (const struct ldmdb *ldb)* Return: 'true' Partition created * 'false' Error, probably a range checking problem */ -static bool ldm_create_data_partitions (struct parsed_partitions *pp, +static bool ldm_create_data_partitions (struct parsed_partitions *state,const struct ldmdb *ldb) {struct list_head *item;
@@ -635,7 +635,7 @@ static bool ldm_create_data_partitions (struct parsed_partitions *pp,struct vblk_part *part;int part_num =1 ; -BUG_ON (!pp || !ldb); +BUG_ON (!state || !ldb); disk =ldm_get_disk_objid (ldb);if (!disk) {
@@ -643,7 +643,7 @@ static bool ldm_create_data_partitions (struct parsed_partitions *pp,return false; } -printk (" [LDM]" ); +print_partition (state," [LDM]" );/* Create the data partitions */ list_for_each (item, &ldb->v_part) {
@@ -653,12 +653,11 @@ static bool ldm_create_data_partitions (struct parsed_partitions *pp,if (part->disk_id != disk->obj_id)continue ; -put_partition (pp, part_num, ldb->ph.logical_disk_start + +put_partition (state, part_num, ldb->ph.logical_disk_start + part->start, part->size); part_num++; } -printk ("\n" );return true; }
fs/partitions/mac.c +1 -2
@@ -59,7 +59,7 @@ int mac_partition(struct parsed_partitions *state, struct block_device *bdev)put_dev_sector (sect);return 0 ;/* not a MacOS disk */ } -printk (" [mac]" ); +print_partition (state," [mac]" ); blocks_in_map =be32_to_cpu (part->map_count);for (blk =1 ; blk <= blocks_in_map; ++blk) {int pos = blk * secsize;
@@ -127,6 +127,5 @@ int mac_partition(struct parsed_partitions *state, struct block_device *bdev)#endif put_dev_sector (sect); -printk ("\n" );return 1 ; }
fs/partitions/msdos.c +17 -19
@@ -212,9 +212,9 @@ parse_solaris_x86(struct parsed_partitions *state, struct block_device *bdev,put_dev_sector (sect);return ; } -printk (" %s%d: <solaris:" , state->name, origin); +print_partition (state," %s%d: <solaris:" , state->name, origin);if (le32_to_cpu (v->v_version) !=1 ) { -printk (" cannot handle version %d vtoc>\n" , +print_partition (state," cannot handle version %d vtoc>\n" ,le32_to_cpu (v->v_version));put_dev_sector (sect);return ;
@@ -225,7 +225,7 @@ parse_solaris_x86(struct parsed_partitions *state, struct block_device *bdev,struct solaris_x86_slice *s = &v->v_slice[i];if (s->s_size ==0 )continue ; -printk (" [s%d]" , i); +print_partition (state," [s%d]" , i);/* solaris partitions are relative to current MS-DOS * one; must add the offset of the current partition */ put_partition(state, state->next++,
@@ -233,7 +233,7 @@ parse_solaris_x86(struct parsed_partitions *state, struct block_device *bdev, le32_to_cpu(s->s_size)); }put_dev_sector (sect); -printk (" >\n" ); +print_partition (state," >" );#endif }
@@ -258,7 +258,7 @@ parse_bsd(struct parsed_partitions *state, struct block_device *bdev,put_dev_sector (sect);return ; } -printk (" %s%d: <%s:" , state->name, origin, flavour); +print_partition (state," %s%d: <%s:" , state->name, origin, flavour);if (le16_to_cpu (l->d_npartitions) < max_partitions) max_partitions =le16_to_cpu (l->d_npartitions);
@@ -275,16 +275,16 @@ parse_bsd(struct parsed_partitions *state, struct block_device *bdev,/* full parent partition, we have it already */ continue ;if (offset > bsd_start || offset+size < bsd_start+bsd_size) { -printk ("bad subpartition - ignored\n" ); +printk ("bad subpartition %d - ignored\n" , p - l->d_partitions);continue ; } put_partition(state, state->next++, bsd_start, bsd_size); }put_dev_sector (sect);if (le16_to_cpu (l->d_npartitions) > max_partitions) -printk (" (ignored %d more)" , +print_partition (state," (ignored %d more)" ,le16_to_cpu (l->d_npartitions) - max_partitions); -printk (" >\n" ); +print_partition (state," >" ); }#endif
@@ -339,7 +339,7 @@ parse_unixware(struct parsed_partitions *state, struct block_device *bdev,put_dev_sector (sect);return ; } -printk (" %s%d: <unixware:" , state->name, origin); +print_partition (state," %s%d: <unixware:" , state->name, origin); p = &l->vtoc.v_slice[1 ];/* I omit the 0th slice as it is the same as whole disk. */ while (p - &l->vtoc.v_slice[0 ] <UNIXWARE_NUMSLICE ) {
@@ -352,7 +352,7 @@ parse_unixware(struct parsed_partitions *state, struct block_device *bdev, p++; }put_dev_sector (sect); -printk (" >\n" ); +print_partition (state," >" );#endif }
@@ -383,7 +383,7 @@ parse_minix(struct parsed_partitions *state, struct block_device *bdev,if (msdos_magic_present (data +510 ) &&SYS_IND (p) ==MINIX_PARTITION ) {/* subpartition table present */ -printk (" %s%d: <minix:" , state->name, origin); +print_partition (state," %s%d: <minix:" , state->name, origin);for (i =0 ; i <MINIX_NR_SUBPARTITIONS ; i++, p++) {if (state->next == state->limit)break ;
@@ -392,7 +392,7 @@ parse_minix(struct parsed_partitions *state, struct block_device *bdev,put_partition (state, state->next++, START_SECT(p), NR_SECTS(p)); } -printk (" >\n" ); +print_partition (state," >" ); }put_dev_sector (sect);#endif /* CONFIG_MINIX_SUBPARTITION */
@@ -431,7 +431,7 @@ int msdos_partition(struct parsed_partitions *state, struct block_device *bdev)if (aix_magic_present (data, bdev)) {put_dev_sector (sect); -printk (" [AIX]" ); +print_partition (state," [AIX]" );return 0 ; }
@@ -477,22 +477,20 @@ int msdos_partition(struct parsed_partitions *state, struct block_device *bdev)/* prevent someone doing mkfs or mkswap on an extended partition, but leave room for LILO */ put_partition (state, slot, start, size ==1 ?1 :2 ); -printk (" <" ); +print_partition (state," <" );parse_extended (state, bdev, start, size); -printk (" >" ); +print_partition (state," >" );continue ; }put_partition (state, slot, start, size);if (SYS_IND (p) ==LINUX_RAID_PARTITION ) state->parts[slot].flags =1 ;if (SYS_IND (p) ==DM6_PARTITION ) -printk ("[DM]" ); +print_partition (state,"[DM]" );if (SYS_IND (p) ==EZD_PARTITION ) -printk ("[EZD]" ); +print_partition (state,"[EZD]" ); } -printk ("\n" ); -/* second pass - output for each on a separate line */ p = (struct partition *) (0x1be + data);for (slot =1 ; slot <=4 ; slot++, p++) {
fs/partitions/osf.c +0 -1
@@ -72,7 +72,6 @@ int osf_partition(struct parsed_partitions *state, struct block_device *bdev) le32_to_cpu(partition->p_size)); slot++; } -printk ("\n" );put_dev_sector (sect);return 1 ; }
fs/partitions/sgi.c +0 -1
@@ -76,7 +76,6 @@ int sgi_partition(struct parsed_partitions *state, struct block_device *bdev) } slot++; } -printk ("\n" );put_dev_sector (sect);return 1 ; }
fs/partitions/sun.c +0 -1
@@ -116,7 +116,6 @@ int sun_partition(struct parsed_partitions *state, struct block_device *bdev) } slot++; } -printk ("\n" );put_dev_sector (sect);return 1 ; }
fs/partitions/sysv68.c +2 -3
@@ -73,7 +73,7 @@ int sysv68_partition(struct parsed_partitions *state, struct block_device *bdev)return -1 ; slices -=1 ;/* last slice is the whole disk */ -printk ("sysV68: %s(s%u)" , state->name, slices); +print_partition (state,"sysV68: %s(s%u)" , state->name, slices); slice = (struct slice *)data;for (i =0 ; i < slices; i++, slice++) {if (slot == state->limit)
@@ -82,11 +82,10 @@ int sysv68_partition(struct parsed_partitions *state, struct block_device *bdev)put_partition (state, slot,be32_to_cpu (slice->blkoff),be32_to_cpu (slice->nblocks)); -printk ("(s%u)" , i); +print_partition (state,"(s%u)" , i); } slot++; } -printk ("\n" );put_dev_sector (sect);return 1 ; }
fs/partitions/ultrix.c +0 -1
@@ -39,7 +39,6 @@ int ultrix_partition(struct parsed_partitions *state, struct block_device *bdev) label->pt_part[i].pi_blkoff, label->pt_part[i].pi_nblocks);put_dev_sector (sect); -printk ("\n" );return 1 ; }else {put_dev_sector (sect);
Signature · 1 line
1.5.3.4
Re: [PATCH 3/4] sound: Use stringbuf
In reply to Matthew WilcoxAt Tue, 23 Oct 2007 17:12:45 -0400,
Quoted 4 lines · Matthew Wilcox
sound/had its ownsnd_info_bufferfor doing proc reads, which can be profitably replaced with stringbuf. It actually finds a bug since ->read and ->write now have a different signature.
Do you mean the assignment of snd_ca0106_proc_reg_write? I also found it out today coindentally :)
Any other bugs I missed?
sound/pci/ac97/ac97_proc.c static void snd_ac97_proc_read(struct snd_info_entry *entry, struct snd_info_buf · line 381
Quoted 9 lines
sound/pci/ac97/ac97_proc.c +1
-1@@ -375,7 +375,7 @@ static void snd_ac97_proc_read(struct snd_info_entry *entry, struct snd_info_buf#ifdef CONFIG_SND_DEBUG /* direct register write for debugging */ -static void snd_ac97_proc_regs_write (struct snd_info_entry *entry,struct snd_info_buffer *buffer) +static void snd_ac97_proc_regs_write (struct snd_info_entry *entry,struct stringbuf *buffer) {struct snd_ac97 *ac97 = entry->private_data;char line[64 ];
This shouldn't be changed.
thanks,
Takashi
Re: [PATCH 3/4] sound: Use stringbuf
Quoted 9 lines · Takashi Iwai
At Tue, 23 Oct 2007 17:12:45 -0400,
Quoted 4 lines · Matthew Wilcox
sound/had its ownsnd_info_bufferfor doing proc reads, which can be profitably replaced with stringbuf. It actually finds a bug since ->read and ->write now have a different signature.Do you mean the assignment of
snd_ca0106_proc_reg_write? I also found it out today coindentally :)
I was referring to this hunk, so yes:
@@ -448,10 +448,9 @@ int __devinit snd_ca0106_proc_init(struct snd_ca0106 * emu)
// entry->private_data = emu;
}
if(! snd_card_proc_new(emu->card, "ca0106_i2c", &entry)) {
- snd_info_set_text_ops(entry, emu, snd_ca0106_proc_i2c_write);
+ entry->private_data = emu;
entry->c.text.write = snd_ca0106_proc_i2c_write;
entry->mode |= S_IWUSR;
-// entry->private_data = emu;
}
if(! snd_card_proc_new(emu->card, "ca0106_regs2", &entry))
snd_info_set_text_ops(entry, emu, snd_ca0106_proc_reg_read2);Quoted 1 line
Any other bugs I missed?
Let me try to find them ... there was this warning fix:
sound/isa/ad1848/ad1848_lib.c +0 -0
@@ -213,7 +213,7 @@ static void snd_ad1848_mce_down(struct snd_ad1848 *chip) for (timeout = 12000; timeout > 0 && (inb(AD1848P(chip, REGSEL)) & AD184
8_INIT); timeout--)
udelay(100);
- snd_printdd("(1) timeout = %d\n", timeout);
+ snd_printdd("(1) timeout = %ld\n", timeout);
#ifdef CONFIG_SND_DEBUG
if (inb(AD1848P(chip, REGSEL)) & AD1848_INIT)but I think that's the only one.
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +1
-1-static void snd_ac97_proc_regs_write(struct snd_info_entry *entry, struct snd_info_buffer *buffer) +static void snd_ac97_proc_regs_write(struct snd_info_entry *entry, struct stringbuf *buffer)This shouldn't be changed.
Quite right, sorry about that, will omit it from the next round.
Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Re: [PATCH 3/4] sound: Use stringbuf
At Wed, 24 Oct 2007 10:01:05 -0600,
Quoted 20 lines · Matthew Wilcox
Quoted 2 lines
Any other bugs I missed?
Let me try to find them ... there was this warning fix:
sound/isa/ad1848/ad1848_lib.c +1
-1@@ -213,7 +213,7 @@ static void snd_ad1848_mce_down(struct snd_ad1848 *chip)for (timeout =12000 ; timeout >0 && (inb (AD1848P (chip,REGSEL )) &AD184 8_INIT); timeout--)udelay (100 ); -snd_printdd ("(1) timeout = %d\n" , timeout); +snd_printdd ("(1) timeout = %ld\n" , timeout);#ifdef CONFIG_SND_DEBUG if (inb(AD1848P(chip, REGSEL)) & AD1848_INIT)
Quoted 1 line
but I think that's the only one.
OK, thanks. I fixed it on ALSA tree now.
Takashi
Quoted 5 lines · Matthew Wilcox
Consecutive calls to printk are non-atomic, which leads to various implementations for accumulating strings which can be printed in one call. This is a generic string buffer which can also be used for non-printk purposes. There is no
sb_scanfimplementation yet as I haven't identified a user for it.
You might want to consider growing the buffer by no less than a small constant factor like 1.3x. This will keep things that do short concats in a loop from degrading to O(n^2) performance due to realloc and memcpy.
Quoted 2 lines
+ * No locking is performed, although memory allocation is done with
+ *GFP_ATOMICto allow it to be called when you're holding a lock.
Should probably just bite the bullet and pass a flag.
Quoted 1 line
+#define
INITIAL_SIZE32
Too small. That will guarantee that most users end up doing a realloc. Can we have 128 instead?
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Quoted 4 lines · Matt Mackall
You might want to consider growing the buffer by no less than a small constant factor like 1.3x. This will keep things that do short concats in a loop from degrading to O(n^2) performance due to realloc and memcpy.
I looked at slab and slub, and would grow the buffer by no less than 1.5x each time, thanks to the buckets. I'd initially implemented 2x, but switched to allocating size+1 and calling ksize() as being a more efficient implementation.
I presume slob is different? Actually, slob doesn't seem to provide krealloc, so I think stringbuf won't work on slob. Will you have time to fix this?
Quoted 1 line
Should probably just bite the bullet and pass a flag.
Hrm.
extern void sb_printf(struct stringbuf *sb, gfp_t gfp, const char *fmt, ...)
__attribute__((format(printf, 3, 4)));
? Any objections?
Quoted 4 lines
Quoted 1 line
+#define
INITIAL_SIZE32Too small. That will guarantee that most users end up doing a realloc. Can we have 128 instead?
I don't care. Sure!
Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Quoted 10 lines · Matthew Wilcox
Quoted 4 lines · Matt Mackall
You might want to consider growing the buffer by no less than a small constant factor like 1.3x. This will keep things that do short concats in a loop from degrading to O(n^2) performance due to realloc and memcpy.
I looked at slab and slub, and would grow the buffer by no less than 1.5x each time, thanks to the buckets. I'd initially implemented 2x, but switched to allocating size+1 and calling
ksize()as being a more efficient implementation.
Fair enough.
Quoted 3 lines
I presume slob is different? Actually, slob doesn't seem to provide krealloc, so I think stringbuf won't work on slob. Will you have time to fix this?
http://lxr.linux.no/source/mm/slob.c#L207
Yep, slob is different, it has no kmalloc buckets.
Quoted 8 lines
Quoted 1 line
Should probably just bite the bullet and pass a flag.
Hrm.
extern void
sb_printf(struct stringbuf *sb, gfp_t gfp, const char *fmt, ...)__attribute__((format(printf, 3, 4)));? Any objections?
Fine by me.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
+#define
INITIAL_SIZE32Too small. That will guarantee that most users end up doing a realloc. Can we have 128 instead?
I don't care. Sure!
Most of these objects will have very short lifetimes, so there's very little downside.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Quoted 6 lines · Matt Mackall
Quoted 3 lines · Matthew Wilcox
I presume slob is different? Actually, slob doesn't seem to provide krealloc, so I think stringbuf won't work on slob. Will you have time to fix this?
That's 2.6.22.6; I was looking at 2.6.23, where clameter had moved krealloc into mm/util.c. So that explains why I thought slob didn't provide it. Apologies for the confusion.
Quoted 1 line
Yep, slob is different, it has no kmalloc buckets.
OK. I have no problem with making stringbuf allocate max(oldsize * 1.5, newsize+1).
Quoted 6 lines
Quoted 4 lines
extern void
sb_printf(struct stringbuf *sb, gfp_t gfp, const char *fmt, ...)__attribute__((format(printf, 3, 4)));? Any objections?
Fine by me.
OK, I'll do that for the next round of patches.
Quoted 2 lines
Most of these objects will have very short lifetimes, so there's very little downside.
I agree. It was good for testing though, when I inadvertently wrote to the wrong bit of the string on a realloc ;-)
Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Quoted 4 lines · Matthew Wilcox
This is a generic string buffer which can also be used for non-printk purposes. There is no
sb_scanfimplementation yet as I haven't identified a user for it.
Hmm. Have you looked at the git "strbuf" code?
And stuff like "sb_string()" are just evil. The string is there. Just call it something better than "s", and let people just use "sb->buf" or something. Why make the interface harder to use than necessary?
Linus
Quoted 6 lines · Linus Torvalds
Quoted 3 lines · Matthew Wilcox
This is a generic string buffer which can also be used for non-printk purposes. There is no
sb_scanfimplementation yet as I haven't identified a user for it.Hmm. Have you looked at the git "strbuf" code?
I hadn't. It's quite spookily similar in some ways. There's a lot of things you've added because you presumably have use for them in git that could easily be added once we had users for them in the kernel. There's a few things stringbufs do that strbufs don't need to because they're in userspace.
I can easily change the API at this point, so if renaming things will make you happier, just say so.
Quoted 3 lines
And stuff like "
sb_string()" are just evil. The string is there. Just call it something better than "s", and let people just use "sb->buf" or something. Why make the interface harder to use than necessary?
It's a matter of taste ... some people prefer to use accessors for everything, other people prefer to expose the underlying structure directly. I have to confess to being influenced by Java in 1998-99, so possibly I tend to go for accessors too often. Or possibly it's just my experience of restructuring things in Linux where diffs would be smaller if we only had used accessors for something. In any case, I don't care to fight about this; if you want it to be called buf, then buf it shall be called, and I'll get rid of sb_string.
Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Andrew Morton
maintainerQuoted 3 lines · On Tue, 23 Oct 2007 20:30:35 -0600 Matthew Wilcox <[email protected]> wrote:
It's a matter of taste ... some people prefer to use accessors for everything, other people prefer to expose the underlying structure directly.
Experience tells us that when you use accessors you end up thanking yourself later on. Especially when diddling struct page ;)
Although one really should make a best-effort guess at "how likely is this to change in the future". If the implementation-to-be-copied has been out there for a while then "not very" is a good answer.
But hey, don't listen to me - I like C++, and approve of Java.
include/linux/stringbuf.h line 20
Quoted 13 lines · Matthew Wilcox
Consecutive calls to printk are non-atomic, which leads to various implementations for accumulating strings which can be printed in one call. This is a generic string buffer which can also be used for non-printk purposes. There is no
sb_scanfimplementation yet as I haven't identified a user for it.include/linux/stringbuf.h new file +7
-0+ +struct stringbuf { +char *s; +int alloc; +int len; +}; +
I don't know if copy-on-write semantics are really useful for current in-kernel uses, but I've coded and used a C++ string class like this in the past:
struct string_data
{
int nrefs;
unsigned len;
unsigned capacity;
//char data[capacity]; /* allocated along string_data */
};struct string /* or typedef in C... */
{
struct string *data;
};[ struct string_data is a hidden implementation detail, only struct string is exposed ]
Multiple string objects can share the same data, by increasing the nrefs count, a new data is allocated if the string is modified and nrefs > 1.
Not having to iterate over the string to calculate it's length, allocating a larger buffer to eliminate re-allocation and copy-on-write semantics make a string like this a vast performance improvement over a normal C string for a minimal (about 3 ints per data buffer) memory cost.
By using it correctly it can prevents buffer overflows.
You still always null terminate the string stored in data to directly use it a normal C string.
You also statically allocate an empty string which is shared by all "uninitialized" or empty strings.
Even without copy-on-write semantics and reference counting, I think this approach is better because it uses 1 less "object" and allocation:
struct string - "handle" (pointer really) to string data struct string_data - string data
versus:
struct stringbuf *sb - pointer to string object
struct stringbuf - string object
char *s (member of stringbuf) - string data
Best regards,
- Eric
Quoted 3 lines · Eric St-Laurent
I don't know if copy-on-write semantics are really useful for current in-kernel uses, but I've coded and used a C++ string class like this in the past:
CoW isn't in the slightest bit helpful. The point of these is to provide an accumulator, therefore the majority of accesses to these stringbufs are writes.
Quoted 2 lines
Multiple string objects can share the same data, by increasing the nrefs count, a new data is allocated if the string is modified and nrefs > 1.
If we were trying to get rid of char * throughout the kernel, that might make some sense; stringbufs have a more limited target though.
Quoted 11 lines
Even without copy-on-write semantics and reference counting, I think this approach is better because it uses 1 less "object" and allocation:
struct string - "handle" (pointer really) to string data struct
string_data- string dataversus:
struct stringbuf *sb - pointer to string object
struct stringbuf - string object
char *s (member of stringbuf) - string data
I think you missed the part of the patch where I said that the stringbuf is normally allocated on the stack or as part of some other structure. The only thing that should be allocated is the string itself.
Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
On Tue, 2007-10-23 at 20:35 -0600, Matthew Wilcox wrote:
[...]
Quoted 6 lines
Quoted 2 lines
Multiple string objects can share the same data, by increasing the nrefs count, a new data is allocated if the string is modified and nrefs > 1.
If we were trying to get rid of char * throughout the kernel, that might make some sense; stringbufs have a more limited target though.
[...]
No contest, my suggestions only make sense for a general uses string library.
I suspect most in-kernel string manipulations are limited to prepare buffers to be copied to (and read from) user-space.
- Eric
* Matthew Wilcox:
include/linux/stringbuf.h line 19
Quoted 5 lines
include/linux/stringbuf.h new file +5
-0+struct stringbuf { +char *s; +int alloc; +int len; +};
I think alloc and len should be unsigned (including some return values in the remaining patch).
Quoted 8 lines · Florian Weimer
include/linux/stringbuf.h line 19
Quoted 5 lines
include/linux/stringbuf.h new file +5
-0+struct stringbuf { +char *s; +int alloc; +int len; +};I think alloc and len should be unsigned (including some return values in the remaining patch).
I don't. Strings should never be as long as 2GB. To put this in perspective, the *entire* Encyclopaedia Britannica (all 32 volumes) is estimated at being 1GB of text.
While it would be a fair criticism that I haven't put a check for overrunning 2GB in the code, the implementation relies on a single continuous buffer from kmalloc, and that's currently limited to 33554432 bytes (32MB). I don't foresee kmalloc's maximum size going up by 7 orders of magnitude -- and if it did, fragmentation would prevent you from ever getting it.
So, I might consider a change to set -E2BIG instead of -ENOMEM if we pass KMALLOC_MAX_SIZE, but I do think this criticism is rather straining at gnats.
Also, 'alloc' can be an errno, and that is signalled by a negative number. Yes, we could do something like if (sb->alloc > (unsigned)-4095) like the mmap code does, but given the points above, it's just not worth doing.
Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Hi,
lib/stringbuf.c line 37
Quoted 9 lines · Matthew Wilcox
lib/stringbuf.c new file +9
-0+static void sb_vprintf (struct stringbuf *sb,const char *format,va_list args) +{ +char *s; +int size; + +if (sb->alloc == -ENOMEM ) +return ; +if (sb->alloc ==0 ) { + sb->s =kmalloc (INITIAL_SIZE ,GFP_ATOMIC );
How about putting ->gfp_flags to struct stringbuf and initializing that in sb_init() instead of hard-coding to GFP_ATOMIC here?
Btw, the "sb" abbrevation is already used for "superblock". Perhaps we could use "str" for these?
Pekka
Quoted 5 lines · Matthew Wilcox
Consecutive calls to printk are non-atomic, which leads to various implementations for accumulating strings which can be printed in one call. This is a generic string buffer which can also be used for non-printk purposes. There is no
sb_scanfimplementation yet as I haven't identified a user for it.
GFP_ATOMIC alloca5tion there is bad news. It can randomly fail..... without good method of handling that in caller.
Pavel
include/linux/stringbuf.h line 85
Quoted 12 lines
include/linux/stringbuf.h new file +12
-0+/* +* Convert the stringbuf to a string. It is the caller's responsibility +* to free the string. The stringbuf is then ready to be reused. +*/ +static inline char *sb_to_string (struct stringbuf *sb) +{ +char *s = sb->s; +if (sb_error (sb)) + s =kstrdup (s,GFP_ATOMIC ); +sb_init (sb); +return s; +}
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 13 lines · Matthew Wilcox
Consecutive calls to printk are non-atomic, which leads to various implementations for accumulating strings which can be printed in one call. This is a generic string buffer which can also be used for non-printk purposes. There is no
sb_scanfimplementation yet as I haven't identified a user for it.Signed-off-by Matthew Wilcox <[email protected]>include/linux/stringbuf.h new file +5
-0+static inline void sb_free (struct stringbuf *sb) +{ +if (sb->alloc >0 ) +kfree (sb->s); +sb_init (sb);
include/linux/stringbuf.h line 85
Quoted 10 lines
include/linux/stringbuf.h new file +9
-0+} +static inline char *sb_to_string (struct stringbuf *sb) +{ +char *s = sb->s; +if (sb_error (sb)) + s =kstrdup (s,GFP_ATOMIC ); +sb_init (sb); +return s; +}
I am not sure inlining these functions is a win.
--
vda