@@ -358,7 +358,8 @@ struct debug_buffer {
358358 struct usb_bus * bus ;
359359 struct mutex mutex ; /* protect filling of buffer */
360360 size_t count ; /* number of characters filled into buffer */
361- char * page ;
361+ char * output_buf ;
362+ size_t alloc_size ;
362363};
363364
364365#define speed_char (info1 ) ({ char tmp; \
@@ -488,8 +489,8 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf)
488489
489490 hcd = bus_to_hcd (buf -> bus );
490491 ehci = hcd_to_ehci (hcd );
491- next = buf -> page ;
492- size = PAGE_SIZE ;
492+ next = buf -> output_buf ;
493+ size = buf -> alloc_size ;
493494
494495 * next = 0 ;
495496
@@ -510,7 +511,7 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf)
510511 }
511512 spin_unlock_irqrestore (& ehci -> lock , flags );
512513
513- return strlen (buf -> page );
514+ return strlen (buf -> output_buf );
514515}
515516
516517#define DBG_SCHED_LIMIT 64
@@ -531,8 +532,8 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
531532
532533 hcd = bus_to_hcd (buf -> bus );
533534 ehci = hcd_to_ehci (hcd );
534- next = buf -> page ;
535- size = PAGE_SIZE ;
535+ next = buf -> output_buf ;
536+ size = buf -> alloc_size ;
536537
537538 temp = scnprintf (next , size , "size = %d\n" , ehci -> periodic_size );
538539 size -= temp ;
@@ -649,7 +650,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
649650 spin_unlock_irqrestore (& ehci -> lock , flags );
650651 kfree (seen );
651652
652- return PAGE_SIZE - size ;
653+ return buf -> alloc_size - size ;
653654}
654655#undef DBG_SCHED_LIMIT
655656
@@ -665,8 +666,8 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
665666
666667 hcd = bus_to_hcd (buf -> bus );
667668 ehci = hcd_to_ehci (hcd );
668- next = buf -> page ;
669- size = PAGE_SIZE ;
669+ next = buf -> output_buf ;
670+ size = buf -> alloc_size ;
670671
671672 spin_lock_irqsave (& ehci -> lock , flags );
672673
@@ -808,7 +809,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
808809done :
809810 spin_unlock_irqrestore (& ehci -> lock , flags );
810811
811- return PAGE_SIZE - size ;
812+ return buf -> alloc_size - size ;
812813}
813814
814815static struct debug_buffer * alloc_buffer (struct usb_bus * bus ,
@@ -822,6 +823,7 @@ static struct debug_buffer *alloc_buffer(struct usb_bus *bus,
822823 buf -> bus = bus ;
823824 buf -> fill_func = fill_func ;
824825 mutex_init (& buf -> mutex );
826+ buf -> alloc_size = PAGE_SIZE ;
825827 }
826828
827829 return buf ;
@@ -831,10 +833,10 @@ static int fill_buffer(struct debug_buffer *buf)
831833{
832834 int ret = 0 ;
833835
834- if (!buf -> page )
835- buf -> page = (char * )get_zeroed_page ( GFP_KERNEL );
836+ if (!buf -> output_buf )
837+ buf -> output_buf = (char * )vmalloc ( buf -> alloc_size );
836838
837- if (!buf -> page ) {
839+ if (!buf -> output_buf ) {
838840 ret = - ENOMEM ;
839841 goto out ;
840842 }
@@ -867,7 +869,7 @@ static ssize_t debug_output(struct file *file, char __user *user_buf,
867869 mutex_unlock (& buf -> mutex );
868870
869871 ret = simple_read_from_buffer (user_buf , len , offset ,
870- buf -> page , buf -> count );
872+ buf -> output_buf , buf -> count );
871873
872874out :
873875 return ret ;
@@ -879,8 +881,8 @@ static int debug_close(struct inode *inode, struct file *file)
879881 struct debug_buffer * buf = file -> private_data ;
880882
881883 if (buf ) {
882- if (buf -> page )
883- free_page (( unsigned long ) buf -> page );
884+ if (buf -> output_buf )
885+ vfree ( buf -> output_buf );
884886 kfree (buf );
885887 }
886888
@@ -895,10 +897,14 @@ static int debug_async_open(struct inode *inode, struct file *file)
895897
896898static int debug_periodic_open (struct inode * inode , struct file * file )
897899{
898- file -> private_data = alloc_buffer (inode -> i_private ,
899- fill_periodic_buffer );
900+ struct debug_buffer * buf ;
901+ buf = alloc_buffer (inode -> i_private , fill_periodic_buffer );
902+ if (!buf )
903+ return - ENOMEM ;
900904
901- return file -> private_data ? 0 : - ENOMEM ;
905+ buf -> alloc_size = (sizeof (void * ) == 4 ? 6 : 8 )* PAGE_SIZE ;
906+ file -> private_data = buf ;
907+ return 0 ;
902908}
903909
904910static int debug_registers_open (struct inode * inode , struct file * file )
0 commit comments