add chaos_calmer branch
[15.05/openwrt.git] / package / kernel / ar7-atm / patches-D7.05.01.00 / 220-3.10-update_proc_code.patch
1 From 42d0f4c2f5cf0f73edd827263dc65aefc8f82192 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Thu, 26 Sep 2013 12:28:35 +0200
4 Subject: [PATCH] update proc code to fix compilation for 3.10
5
6 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
7
8 ---
9  tn7api.h |   66 ++-
10  tn7atm.c |  395 ++++++++---------
11  tn7dsl.c | 1439 ++++++++++++++++++++++++++++++--------------------------------
12  tn7sar.c |   91 ++--
13  4 files changed, 951 insertions(+), 1040 deletions(-)
14
15 --- a/tn7api.h
16 +++ b/tn7api.h
17 @@ -91,31 +91,29 @@ void * tn7atm_memcpy(void * dst, void co
18  /* tn7dsl.h */
19  void tn7dsl_exit(void);
20  int tn7dsl_init(void *priv);
21 -int tn7dsl_proc_eoc(char* buf, char **start, off_t offset, int count,int *eof, void *data);
22 -int tn7dsl_proc_stats(char* buf, char **start, off_t offset, int count,int *eof, void *data);
23 +extern struct file_operations tn7dsl_proc_eoc_fops;
24 +extern struct file_operations tn7dsl_proc_stats_fops;
25  
26  //#define ADV_DIAG_STATS  1  //CQ10275 To enable Adv Stats
27  
28  #ifdef ADV_DIAG_STATS
29 -int tn7dsl_proc_adv_stats(char* buf, char **start, off_t offset, int count,int *eof, void *data);
30 -int tn7dsl_proc_adv_stats1(char* buf, char **start, off_t offset, int count,int *eof, void *data);
31 -int tn7dsl_proc_adv_stats2(char* buf, char **start, off_t offset, int count,int *eof, void *data);
32 -int tn7dsl_proc_adv_stats3(char* buf, char **start, off_t offset, int count,int *eof, void *data);
33 +extern struct file_operations tn7dsl_proc_adv_stats_fops;
34 +extern struct file_operations tn7dsl_proc_adv1_stats_fops;
35 +extern struct file_operations tn7dsl_proc_adv2_stats_fops;
36 +extern struct file_operations tn7dsl_proc_adv3_stats_fops;
37  //UR8_MERGE_START CQ10682   Jack Zhang
38 -int tn7dsl_proc_dbg_cmsgs(char* buf, char **start, off_t offset, int count,int *eof, void *data);
39 -int tn7dsl_proc_dbg_rmsgs1(char* buf, char **start, off_t offset, int count,int *eof, void *data);
40 -int tn7dsl_proc_dbg_rmsgs2(char* buf, char **start, off_t offset, int count,int *eof, void *data);
41 -int tn7dsl_proc_dbg_rmsgs3(char* buf, char **start, off_t offset, int count,int *eof, void *data);
42 -int tn7dsl_proc_dbg_rmsgs4(char* buf, char **start, off_t offset, int count,int *eof, void *data);
43 +extern struct file_operations tn7dsl_proc_dbg_cmsgs_fops;
44 +extern struct file_operations tn7dsl_proc_dbg_cmsgs1_fops;
45 +extern struct file_operations tn7dsl_proc_dbg_cmsgs2_fops;
46 +extern struct file_operations tn7dsl_proc_dbg_cmsgs3_fops;
47 +extern struct file_operations tn7dsl_proc_dbg_cmsgs4_fops;
48  //UR8_MERGE_END   CQ10682*
49  #endif //ADV_DIAG_STATS
50  
51 -int tn7dsl_proc_write_stats(struct file *fp, const char * buf, unsigned long count, void * data);
52 -int tn7dsl_proc_modem(char* buf, char **start, off_t offset, int count,int *eof, void *data);
53 +extern struct file_operations tn7dsl_proc_modem_fops;
54  //UR8_MERGE_START CQ11813 Hao-Ting
55  #ifdef LINUX_CLI_SUPPORT
56 -int tn7dsl_proc_dbgmsg_write(struct file *fp, const char *buf, unsigned long count, void *data);
57 -int tn7dsl_proc_dbgmsg_read(char* buf, char **start, off_t offset, int count,int *eof, void *data);
58 +extern struct file_operations tn7dsl_proc_dbgmsg_fops;
59  #endif
60  //UR8_MERGE_END CQ11813
61  int tn7dsl_handle_interrupt(void);
62 @@ -142,31 +140,31 @@ int os_atoih(const char *pStr);
63  #endif
64  
65  unsigned long os_atoul(const char *pStr);
66 -int tn7dsl_proc_snr0(char* buf, char **start, off_t offset, int count, int *eof, void *data);
67 -int tn7dsl_proc_snr1(char* buf, char **start, off_t offset, int count, int *eof, void *data);
68 -int tn7dsl_proc_snr2(char* buf, char **start, off_t offset, int count, int *eof, void *data);
69 -int tn7dsl_proc_bit_allocation(char* buf, char **start, off_t offset, int count, int *eof, void *data);
70 -int tn7dsl_proc_ds_noise(char* buf, char **start, off_t offset, int count, int *eof, void *data);
71 -int tn7dsl_proc_generic_read_result(char* buf, char **start, off_t offset, int count, int *eof, void *data);
72 -int tn7dsl_proc_train_mode_export(char* buf, char **start, off_t offset, int count,int *eof, void *data);
73 +extern struct file_operations tn7dsl_proc_snr0_fops;
74 +extern struct file_operations tn7dsl_proc_snr1_fops;
75 +extern struct file_operations tn7dsl_proc_snr2_fops;
76 +extern struct file_operations tn7dsl_proc_bit_allocation_fops;
77 +extern struct file_operations tn7dsl_proc_ds_noise_fops;
78 +extern struct file_operations tn7dsl_proc_generic_read_result_fops;
79 +extern struct file_operations tn7dsl_proc_train_mode_export_fops;
80  
81  #ifndef NO_ADV_STATS
82 -int tn7dsl_proc_SNRpsds(char* buf, char **start, off_t offset, int count,int *eof, void *data);
83 -int tn7dsl_proc_QLNpsds(char* buf, char **start, off_t offset, int count,int *eof, void *data);
84 +extern struct file_operations tn7dsl_proc_SNRpsds_fops;
85 +extern struct file_operations tn7dsl_proc_QLNpsds_fops;
86  // *    UR8_MERGE_START CQ10979   Jack Zhang
87  #ifdef TR69_HLIN_IN
88 -//int tn7dsl_proc_HLINpsds(char* buf, char **start, off_t offset, int count,int *eof, void *data);
89 -int tn7dsl_proc_HLINpsds1(char* buf, char **start, off_t offset, int count,int *eof, void *data);
90 -int tn7dsl_proc_HLINpsds2(char* buf, char **start, off_t offset, int count,int *eof, void *data);
91 -int tn7dsl_proc_HLINpsds3(char* buf, char **start, off_t offset, int count,int *eof, void *data);
92 -int tn7dsl_proc_HLINpsds4(char* buf, char **start, off_t offset, int count,int *eof, void *data);
93 +//extern struct file_operations tn7dsl_proc_HLINpsds_fops;
94 +extern struct file_operations tn7dsl_proc_HLINpsds1_fops;
95 +extern struct file_operations tn7dsl_proc_HLINpsds2_fops;
96 +extern struct file_operations tn7dsl_proc_HLINpsds3_fops;
97 +extern struct file_operations tn7dsl_proc_HLINpsds4_fops;
98  #endif //TR69_HLIN_IN
99  // *    UR8_MERGE_END   CQ10979*
100  // *    UR8_MERGE_START CQ11057   Jack Zhang
101  #define TR69_PMD_IN
102  #ifdef TR69_PMD_IN
103 -//int tn7dsl_proc_PMDus(char* buf, char **start, off_t offset, int count,int *eof, void *data);
104 -int tn7dsl_proc_PMDus(char* buf, char **start, off_t offset, int count,int *eof, void *data);
105 +//extern struct file_operations tn7dsl_proc_PMDus_fops;
106 +extern struct file_operations tn7dsl_proc_PMDus_fops;
107  #endif  //TR69_PMD_IN
108  // *    UR8_MERGE_END   CQ11057 *
109  #endif
110 @@ -183,12 +181,12 @@ void tn7sar_get_sar_version(Tn7AtmPrivat
111  int tn7sar_get_near_end_loopback_count(unsigned int *pF4count, unsigned int *pF5count);
112  int tn7sar_oam_generation(void *privContext, int chan, int type, int vpi, int vci, int timeout);
113  int tn7sar_get_stats(void *priv1);
114 -int tn7sar_proc_sar_stat(char* buf, char **start, off_t offset, int count,int *eof, void *data);
115 +extern struct file_operations tn7sar_proc_sar_stat_fops;
116  #ifdef AR7_EFM
117  void tn7sar_get_EFM_firmware_version(unsigned int *pdsp_version_ms, unsigned int *pdsp_version_ls);
118  #endif
119  void tn7sar_get_sar_firmware_version(unsigned int *pdsp_version_ms, unsigned int *pdsp_version_ls);
120 -int tn7sar_proc_oam_ping(char* buf, char **start, off_t offset, int count,int *eof, void *data);
121 -int tn7sar_proc_pvc_table(char* buf, char **start, off_t offset, int count,int *eof, void *data);
122 +extern struct file_operations tn7sar_proc_oam_ping_fops;
123 +extern struct file_operations tn7sar_proc_pvc_table_fops;
124  int tn7sar_tx_flush(void *privContext, int chan, int queue, int skip);
125  #endif __SGAPI_H
126 --- a/tn7atm.c
127 +++ b/tn7atm.c
128 @@ -265,11 +265,9 @@ MODULE_PARM_DESC(oam_lb_timeout, "OAM LB
129  
130  #ifdef AR7_EFM
131  extern void tn7dsl_disable_alarm(void);
132 -extern int tn7efm_proc_channels (char *buf, char **start, 
133 -            off_t offset, int count, int *eof, void *data);
134 -extern int tn7efm_proc_ctrl_read (char *buf, char **start, off_t offset, int count, int *eof, void *data);
135 -extern int tn7efm_proc_ctrl_write (struct file *fp, const char *buf, unsigned long count, void *data);
136 -extern int tn7efm_proc_info (char *buf, char **start, off_t offset, int count, int *eof, void *data);
137 +extern struct file_operations tn7efm_proc_channels_fops;
138 +extern struct file_operations tn7efm_proc_ctrl_fops;
139 +extern struct file_operations tn7efm_proc_info_fops;
140  extern unsigned int g_efm_proc_ctl;
141  extern struct net_device *mydev_efm;
142  extern Tn7AtmPrivate *mypriv;
143 @@ -305,31 +303,17 @@ extern int tn7efm_register (Tn7AtmPrivat
144  static int tn7atm_irq_request (struct atm_dev *dev);
145  #endif
146  
147 -static int tn7atm_proc_version (char *buf, char **start, off_t offset,
148 -                                int count, int *eof, void *data);
149 +static struct file_operations tn7atm_proc_version_fops;
150  static void tn7atm_exit (void);
151 -static int tn7atm_proc_channels (char *buf, char **start, off_t offset,
152 -                                 int count, int *eof, void *data);
153 -static int tn7atm_proc_private (char *buf, char **start, off_t offset,
154 -                                int count, int *eof, void *data);
155 +static struct file_operations tn7atm_proc_channels_fops;
156 +static struct file_operations tn7atm_proc_private_fops;
157  inline static int tn7atm_queue_packet_to_sar (void *vcc1, void *skb1,
158                                                int chan);
159  
160 -static int tn7atm_xlate_proc_name (const char *name,
161 -                                   struct proc_dir_entry **ret,
162 -                                   const char **residual);
163 -static int tn7atm_proc_match (int len, const char *name,
164 -                              struct proc_dir_entry *de);
165 -static int tn7atm_proc_qos_read  (char *buf, char **start, off_t offset,
166 -                                  int count, int *eof, void *data);
167 -static int tn7atm_proc_qos_write (struct file *fp, const char *buf,
168 -                                  unsigned long count, void *data);
169 +static struct file_operations tn7atm_proc_qos_fops;
170  
171  // [KT]
172 -static int tn7atm_proc_turbodsl_read  (char *buf, char **start, off_t offset,
173 -                                  int count, int *eof, void *data);
174 -static int tn7atm_proc_turbodsl_write (struct file *fp, const char *buf,
175 -                                  unsigned long count, void *data);
176 +static struct file_operations tn7atm_proc_turbodsl_fops;
177  
178  //CT - Added function to return chipset Id
179         void tn7atm_get_chipsetId (char *pVerId);
180 @@ -456,78 +440,83 @@ const char drv_proc_root_folder[] = "ava
181  static struct proc_dir_entry *root_proc_dir_entry = NULL;
182  #define DRV_PROC_MODE 0644
183  static int proc_root_already_exists = TRUE;
184 +
185 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
186 +#define PDE_DATA(inode) PDE(inode)->data
187 +#endif
188 +
189  static struct
190  {
191      const unsigned char name[32];
192 -    int (*read_func) (char* , char **, off_t , int ,int *, void *);
193 -    int (*write_func) (struct file *, const char * , unsigned long , void *);
194 +    struct file_operations *fops;
195  
196  } proc_if[] = {
197  #ifdef AR7_EFM
198  #ifdef EFM_DEBUG
199 -    {"avsar_efm_channel",           tn7efm_proc_channels,          NULL},
200 +    {"avsar_efm_channel",           &tn7efm_proc_channels_fops},
201  #endif    
202 -    {"avsar_efm_info",              tn7efm_proc_info,              NULL},
203 -    {"avsar_efm_ctl",               tn7efm_proc_ctrl_read,  tn7efm_proc_ctrl_write},
204 +    {"avsar_efm_info",              &tn7efm_proc_info_fops},
205 +    {"avsar_efm_ctl",               &tn7efm_proc_ctrl_fops},
206  #endif
207 -    {"avsar_ver",                   tn7atm_proc_version,           NULL},
208 -    {"avsar_channels",              tn7atm_proc_channels,          NULL},
209 -    {"avsar_sarhal_stats",          tn7sar_proc_sar_stat,          NULL},
210 -    {"avsar_oam_ping",              tn7sar_proc_oam_ping,          NULL},
211 -    {"avsar_pvc_table",             tn7sar_proc_pvc_table,         NULL},
212 -    {"avsar_rxsnr0",                tn7dsl_proc_snr0,              NULL},
213 -    {"avsar_rxsnr1",                tn7dsl_proc_snr1,              NULL},
214 -    {"avsar_rxsnr2",                tn7dsl_proc_snr2,              NULL},
215 -    {"clear_eoc_stats",             tn7dsl_proc_eoc,               NULL},
216 -    {"avsar_bit_allocation_table",  tn7dsl_proc_bit_allocation,    NULL},
217 -    {"avsar_dsl_modulation_schemes",tn7dsl_proc_train_mode_export, NULL},
218 +    {"avsar_ver",                   &tn7atm_proc_version_fops},
219 +    {"avsar_channels",              &tn7atm_proc_channels_fops},
220 +    {"avsar_sarhal_stats",          &tn7sar_proc_sar_stat_fops},
221 +    {"avsar_oam_ping",              &tn7sar_proc_oam_ping_fops},
222 +    {"avsar_pvc_table",             &tn7sar_proc_pvc_table_fops},
223 +    {"avsar_rxsnr0",                &tn7dsl_proc_snr0_fops},
224 +    {"avsar_rxsnr1",                &tn7dsl_proc_snr1_fops},
225 +    {"avsar_rxsnr2",                &tn7dsl_proc_snr2_fops},
226 +    {"clear_eoc_stats",             &tn7dsl_proc_eoc_fops},
227 +    {"avsar_bit_allocation_table",  &tn7dsl_proc_bit_allocation_fops},
228 +    {"avsar_dsl_modulation_schemes",&tn7dsl_proc_train_mode_export_fops},
229  #ifndef NO_ADV_STATS
230 -    {"avsar_SNRpsds",               tn7dsl_proc_SNRpsds,           NULL},
231 -    {"avsar_QLNpsds",               tn7dsl_proc_QLNpsds,           NULL},
232 +    {"avsar_SNRpsds",               &tn7dsl_proc_SNRpsds_fops},
233 +    {"avsar_QLNpsds",               &tn7dsl_proc_QLNpsds_fops},
234  // *    UR8_MERGE_START CQ10979   Jack Zhang
235  #ifdef TR69_HLIN_IN
236 -//    {"avsar_HLINpsds",              tn7dsl_proc_HLINpsds,          NULL},
237 -    {"avsar_HLINpsds1",             tn7dsl_proc_HLINpsds1,         NULL},
238 -    {"avsar_HLINpsds2",             tn7dsl_proc_HLINpsds2,         NULL},
239 -    {"avsar_HLINpsds3",             tn7dsl_proc_HLINpsds3,         NULL},
240 -    {"avsar_HLINpsds4",             tn7dsl_proc_HLINpsds4,         NULL},
241 +//    {"avsar_HLINpsds",              &tn7dsl_proc_HLINpsds_fops},
242 +    {"avsar_HLINpsds1",             &tn7dsl_proc_HLINpsds1_fops},
243 +    {"avsar_HLINpsds2",             &tn7dsl_proc_HLINpsds2_fops},
244 +    {"avsar_HLINpsds3",             &tn7dsl_proc_HLINpsds3_fops},
245 +    {"avsar_HLINpsds4",             &tn7dsl_proc_HLINpsds4_fops},
246  #endif //TR69_HLIN_IN
247  // *    UR8_MERGE_END   CQ10979*
248  // *    UR8_MERGE_START CQ11057   Jack Zhang
249  #define TR69_PMD_IN
250  #ifdef TR69_PMD_IN
251 -    {"avsar_PMDTestus",             tn7dsl_proc_PMDus,            NULL},
252 -//    {"avsar_PMDTestus1",          tn7dsl_proc_PMDus1,            NULL},
253 +    {"avsar_PMDTestus",             &tn7dsl_proc_PMDus_fops},
254 +//    {"avsar_PMDTestus1",          &tn7dsl_proc_PMDus1_fops},
255  #endif  //TR69_PMD_IN
256  // *    UR8_MERGE_END   CQ11057 *
257  #endif
258 -    {"avsar_private",               tn7atm_proc_private,           NULL},
259 -    {"avsar_modem_training",        tn7dsl_proc_modem,             NULL},
260 -    {"avsar_modem_stats",           tn7dsl_proc_stats,             tn7dsl_proc_write_stats},
261 +    {"avsar_private",               &tn7atm_proc_private_fops},
262 +    {"avsar_modem_training",        &tn7dsl_proc_modem_fops},
263 +    {"avsar_modem_stats",           &tn7dsl_proc_stats_fops},
264  
265  #ifdef ADV_DIAG_STATS //CQ10275
266 -//for 2.6    {"avsar_modem_adv_stats",       tn7dsl_proc_adv_stats,         NULL},
267 +//for 2.6    {"avsar_modem_adv_stats",       &tn7dsl_proc_adv_stats_fops},
268  //For 2.4 kernel, due to proc file system size limitation
269 -    {"avsar_modem_adv_stats1",      tn7dsl_proc_adv_stats1,        NULL},
270 -    {"avsar_modem_adv_stats2",      tn7dsl_proc_adv_stats2,        NULL},
271 -    {"avsar_modem_adv_stats3",      tn7dsl_proc_adv_stats3,        NULL},
272 +    {"avsar_modem_adv_stats1",      &tn7dsl_proc_adv_stats1_fops},
273 +    {"avsar_modem_adv_stats2",      &tn7dsl_proc_adv_stats2_fops},
274 +    {"avsar_modem_adv_stats3",      &tn7dsl_proc_adv_stats3_fops},
275  //UR8_MERGE_START CQ10682   Jack Zhang
276 -    {"avsar_modem_dbg_cmsgs",       tn7dsl_proc_dbg_cmsgs,         NULL},
277 -    {"avsar_modem_dbg_rmsgs1",      tn7dsl_proc_dbg_rmsgs1,        NULL},
278 -    {"avsar_modem_dbg_rmsgs2",      tn7dsl_proc_dbg_rmsgs2,        NULL},
279 -    {"avsar_modem_dbg_rmsgs3",      tn7dsl_proc_dbg_rmsgs3,        NULL},
280 -    {"avsar_modem_dbg_rmsgs4",      tn7dsl_proc_dbg_rmsgs4,        NULL},
281 +    {"avsar_modem_dbg_cmsgs",       &tn7dsl_proc_dbg_cmsgs_fops},
282 +    {"avsar_modem_dbg_rmsgs1",      &tn7dsl_proc_dbg_rmsgs1_fops},
283 +    {"avsar_modem_dbg_rmsgs2",      &tn7dsl_proc_dbg_rmsgs2_fops},
284 +    {"avsar_modem_dbg_rmsgs3",      &tn7dsl_proc_dbg_rmsgs3_fops},
285 +    {"avsar_modem_dbg_rmsgs4",      &tn7dsl_proc_dbg_rmsgs4_fops},
286  // UR8_MERGE_END   CQ10682*
287  #endif //ADV_DIAG_STATS
288  //UR8_MERGE_START CQ11813 Hao-Ting
289  #ifdef LINUX_CLI_SUPPORT
290 -    {"avsar_dbg_enable",            tn7dsl_proc_dbgmsg_read,       tn7dsl_proc_dbgmsg_write},
291 +    {"avsar_dbg_enable",            &tn7dsl_proc_dbgmsg_fops},
292  #endif
293  //UR8_MERGE_END CQ11813
294 -    {"avsar_qos_enable",            tn7atm_proc_qos_read,          tn7atm_proc_qos_write},
295 +    {"avsar_qos_enable",            &tn7atm_proc_qos_fops},
296      #if 1 /* [MS] */
297 -    {"avsar_turbodsl",              tn7atm_proc_turbodsl_read,     tn7atm_proc_turbodsl_write}
298 +    {"avsar_turbodsl",              &tn7atm_proc_turbodsl_fops}
299      #endif
300 +
301  };
302  
303  /* *INDENT-ON* */
304 @@ -1811,76 +1800,81 @@ int tn7atm_receive (void *os_dev, int ch
305    return 0;
306  }
307  
308 -
309 -static int tn7atm_proc_channels (char *buf, char **start, off_t offset,
310 -                                 int count, int *eof, void *data)
311 +static int tn7atm_proc_channels (struct seq_file *m, void *data)
312  {
313 -  int len = 0;
314 -  int limit = count - 80;
315    int i;
316  
317    struct atm_dev *dev;
318    Tn7AtmPrivate *priv;
319  
320 -  dev = (struct atm_dev *) data;
321 +  dev = (struct atm_dev *) m->private;
322    priv = (Tn7AtmPrivate *) dev->dev_data;
323  
324 -  if (len <= limit)
325 -    len += sprintf (buf + len, "Chan  Inuse   ChanID   VPI     VCI \n");
326 -  if (len <= limit)
327 -    len +=
328 -      sprintf (buf + len,
329 +  seq_printf (m, "Chan  Inuse   ChanID   VPI     VCI \n");
330 +  seq_printf (m,
331                 "------------------------------------------------------------------\n");
332  
333    for (i = 0; i <= MAX_DMA_CHAN; i++)
334    {
335 -    if (len <= limit)
336 -    {
337 -      len += sprintf (buf + len,
338 -                      " %02d    %05d   %05d   %05d   %05d \n",
339 -                      i, priv->lut[i].inuse, priv->lut[i].chanid,
340 -                      priv->lut[i].vpi, priv->lut[i].vci);
341 -    }
342 +      seq_printf (m,
343 +                  " %02d    %05d   %05d   %05d   %05d \n",
344 +                  i, priv->lut[i].inuse, priv->lut[i].chanid,
345 +                  priv->lut[i].vpi, priv->lut[i].vci);
346    }
347  
348 -  if (len <= limit)
349 -    len +=
350 -      sprintf (buf + len,
351 +  seq_printf (m,
352                 "------------------------------------------------------------------\n");
353  
354 -  return len;
355 +  return 0;
356 +}
357 +
358 +static int tn7atm_proc_channels_open(struct inode *inode, struct file *file)
359 +{
360 +       return single_open(file, tn7atm_proc_channels, PDE_DATA(inode));
361  }
362  
363 -static int tn7atm_proc_private (char *buf, char **start, off_t offset,
364 -                                int count, int *eof, void *data)
365 +static struct file_operations tn7atm_proc_channels_fops = {
366 +       .owner          = THIS_MODULE,
367 +       .open           = tn7atm_proc_channels_open,
368 +       .read           = seq_read,
369 +       .llseek         = seq_lseek,
370 +       .release        = single_release,
371 +};
372 +
373 +
374 +static int tn7atm_proc_private (struct seq_file *m, void *data)
375  {
376 -  int len = 0;
377 -  int limit = count - 80;
378    struct atm_dev *dev;
379    Tn7AtmPrivate *priv;
380  
381 -  dev = (struct atm_dev *) data;
382 +  dev = (struct atm_dev *) m->private;
383    priv = (Tn7AtmPrivate *) dev->dev_data;
384  
385 -  if (len <= limit)
386 -    len += sprintf (buf + len, "\nPrivate Data Structure(%s):\n", priv->name);
387 -  if (len <= limit)
388 -    len += sprintf (buf + len, "----------------------------------------\n");
389 -  if (len <= limit)
390 -    len += sprintf (buf + len, "priv:  0x%p\n", priv);
391 -  if (len <= limit)
392 -    len += sprintf (buf + len, "next:  0x%p", priv->next);
393 -  if (len <= limit)
394 -    len += sprintf (buf + len, "\tdev:   0x%p\n", priv->dev);
395 -
396 -  if (len <= limit)
397 -    len += sprintf (buf + len, "tx_irq: %02d", priv->sar_irq);
398 -  if (len <= limit)
399 -    len += sprintf (buf + len, "rx_irq: %02d", priv->dsl_irq);
400 +  seq_printf (m, "\nPrivate Data Structure(%s):\n", priv->name);
401 +  seq_printf (m, "----------------------------------------\n");
402 +  seq_printf (m, "priv:  0x%p\n", priv);
403 +  seq_printf (m, "next:  0x%p", priv->next);
404 +  seq_printf (m, "\tdev:   0x%p\n", priv->dev);
405 +
406 +  seq_printf (m, "tx_irq: %02d", priv->sar_irq);
407 +  seq_printf (m, "rx_irq: %02d", priv->dsl_irq);
408 +
409 +  return 0;
410 +}
411  
412 -  return len;
413 +static int tn7atm_proc_private_open(struct inode *inode, struct file *file)
414 +{
415 +       return single_open(file, tn7atm_proc_private, PDE_DATA(inode));
416  }
417  
418 +static struct file_operations tn7atm_proc_private_fops = {
419 +       .owner          = THIS_MODULE,
420 +       .open           = tn7atm_proc_private_open,
421 +       .read           = seq_read,
422 +       .llseek         = seq_lseek,
423 +       .release        = single_release,
424 +};
425 +
426  void tn7atm_sarhal_isr_register (void *os_dev, void *hal_isr,
427                                   int interrupt_num)
428  {
429 @@ -2033,10 +2027,8 @@ static int __init tn7atm_register (Tn7At
430    return ATM_REG_OK;
431  }
432  
433 -static int tn7atm_proc_version (char *buf, char **start, off_t offset,
434 -                                int count, int *eof, void *data)
435 +static int tn7atm_proc_version (struct seq_file *m, void *data)
436  {
437 -  int len = 0;
438    char dslVer[8];
439    char dspVer[10];
440    char chipsetID[32]; //CT CQ10076 - Added temporary buffer to store chipset Id
441 @@ -2051,58 +2043,52 @@ static int tn7atm_proc_version (char *bu
442    priv = mydev->dev_data;
443  
444  #ifdef AR7_EFM
445 -  len +=
446 -    sprintf (buf + len, "ATM/EFM Driver version:[%d.%02d.%02d.%02d]\n",
447 -             LINUXATM_VERSION_MAJOR, LINUXATM_VERSION_MINOR,
448 -             LINUXATM_VERSION_BUGFIX, LINUXATM_VERSION_BUILDNUM);
449 -
450 +  seq_printf (m, "ATM/EFM Driver version:[%d.%02d.%02d.%02d]\n",
451 +              LINUXATM_VERSION_MAJOR, LINUXATM_VERSION_MINOR,
452 +              LINUXATM_VERSION_BUGFIX, LINUXATM_VERSION_BUILDNUM);
453  #else
454 -  len +=
455 -    sprintf (buf + len, "ATM Driver version:[%d.%02d.%02d.%02d]\n",
456 -             LINUXATM_VERSION_MAJOR, LINUXATM_VERSION_MINOR,
457 -             LINUXATM_VERSION_BUGFIX, LINUXATM_VERSION_BUILDNUM);
458 +  seq_printf (m, "ATM Driver version:[%d.%02d.%02d.%02d]\n",
459 +              LINUXATM_VERSION_MAJOR, LINUXATM_VERSION_MINOR,
460 +              LINUXATM_VERSION_BUGFIX, LINUXATM_VERSION_BUILDNUM);
461  #endif
462  
463    tn7dsl_get_dslhal_version (dslVer);
464  
465 -  len +=
466 -    sprintf (buf + len, "DSL HAL version: [%d.%02d.%02d.%02d]\n", dslVer[0],
467 -             dslVer[1], dslVer[2], dslVer[3]);
468 +  seq_printf (m, "DSL HAL version: [%d.%02d.%02d.%02d]\n", dslVer[0],
469 +              dslVer[1], dslVer[2], dslVer[3]);
470    tn7dsl_get_dsp_version (dspVer);
471  
472  #ifdef EFM_DEBUG
473 -  len +=
474 -    sprintf (buf + len, "DSP Datapump version: [%d.%02d.%02d.%02d(%u)] ",
475 -             dspVer[4], dspVer[5], dspVer[6], dspVer[7], (unsigned char) dspVer[7]);
476 +  seq_printf (m, "DSP Datapump version: [%d.%02d.%02d.%02d(%u)] ",
477 +              dspVer[4], dspVer[5], dspVer[6], dspVer[7], (unsigned char) dspVer[7]);
478  #else
479 -  len +=
480 -    sprintf (buf + len, "DSP Datapump version: [%d.%02d.%02d.%02d] ",
481 -             dspVer[4], dspVer[5], dspVer[6], dspVer[7]);
482 +  seq_printf (m, "DSP Datapump version: [%d.%02d.%02d.%02d] ",
483 +              dspVer[4], dspVer[5], dspVer[6], dspVer[7]);
484  #endif
485    if (dspVer[8] == 2)           // annex B
486 -    len += sprintf (buf + len, "Annex B\n");
487 +    seq_printf (m, "Annex B\n");
488    else if (dspVer[8] == 3)      // annex c
489 -    len += sprintf (buf + len, "Annex c\n");
490 +    seq_printf (m, "Annex c\n");
491    else
492 -    len += sprintf (buf + len, "Annex A\n");
493 +    seq_printf (m, "Annex A\n");
494  
495    tn7sar_get_sar_version (priv, &pSarVer);
496  
497 -  len += sprintf (buf + len, "SAR HAL version: [");
498 +  seq_printf (m, "SAR HAL version: [");
499    for (i = 0; i < 8; i++)
500    {
501 -    len += sprintf (buf + len, "%c", pSarVer[i + 7]);
502 +    seq_printf (m, "%c", pSarVer[i + 7]);
503    }
504 -  len += sprintf (buf + len, "]\n");
505 +  seq_printf (m, "]\n");
506  
507    tn7sar_get_sar_firmware_version (&pdspV1, &pdspV2);
508  
509  #ifndef AR7_EFM
510 -  len += sprintf (buf + len, "PDSP Firmware version:[%01x.%02x]\n",
511 +  seq_printf (m, "PDSP Firmware version:[%01x.%02x]\n",
512                    pdspV1, pdspV2);
513  #else
514  
515 -  len += sprintf (buf + len, "PDSP Firmware version:[%01x.%02x](ATM)%c\n",
516 +  seq_printf (m, "PDSP Firmware version:[%01x.%02x](ATM)%c\n",
517              pdspV1, pdspV2, (priv->curr_TC_mode== TC_MODE_ATM) ? '*' : ' ');
518  
519    tn7sar_get_EFM_firmware_version (&pdspV1, &pdspV2);
520 @@ -2114,26 +2100,37 @@ static int tn7atm_proc_version (char *bu
521  #endif
522      str = "EFM";  
523  
524 -  len += sprintf (buf + len, "PDSP Firmware version:[%01x.%02x](%s)%c\n",
525 +  seq_printf (m, "PDSP Firmware version:[%01x.%02x](%s)%c\n",
526              pdspV1, pdspV2, str, (priv->curr_TC_mode== TC_MODE_PTM) ? '*' : ' ');
527  
528  #endif
529  
530    //CT CQ10076 - Added code to report chipset ID using proc file system
531    tn7atm_get_chipsetId(chipsetID);
532 -  len += sprintf (buf + len, "Chipset ID: [%s]\n",chipsetID);
533 +  seq_printf (m, "Chipset ID: [%s]\n",chipsetID);
534 +
535 +  return 0;
536 +}
537  
538 -  return len;
539 +static int tn7atm_proc_version_open(struct inode *inode, struct file *file)
540 +{
541 +       return single_open(file, tn7atm_proc_version, PDE_DATA(inode));
542  }
543  
544 +static struct file_operations tn7atm_proc_version_fops = {
545 +       .owner          = THIS_MODULE,
546 +       .open           = tn7atm_proc_version_open,
547 +       .read           = seq_read,
548 +       .llseek         = seq_lseek,
549 +       .release        = single_release,
550 +};
551 +
552  
553  /* Device detection */
554  
555  static int __init tn7atm_detect (void)
556  {
557    Tn7AtmPrivate *priv;
558 -  struct proc_dir_entry *dsl_wr_file = NULL; /* Only for ones with a write
559 -                                                 * function. */
560    int ctr;
561    const char *residual;
562  
563 @@ -2214,24 +2211,7 @@ static int __init tn7atm_detect (void)
564     */
565    for (ctr = 0; ctr < (NUM_ELEMS (proc_if)); ctr++)
566    {
567 -      /* Only if we have a write function, we create a normal proc file. */
568 -      if(proc_if[ctr].write_func)
569 -      {
570 -          dsl_wr_file = create_proc_entry (proc_if[ctr].name, DRV_PROC_MODE, root_proc_dir_entry);
571 -          if (dsl_wr_file)
572 -          {
573 -            dsl_wr_file->read_proc  = proc_if[ctr].read_func;
574 -            dsl_wr_file->write_proc = proc_if[ctr].write_func;
575 -            dsl_wr_file->data = (void *)mydev; //UR8_MERGE_START_END CQ10700 Manjula K
576 -          }
577 -          dsl_wr_file = NULL;
578 -      }
579 -      else
580 -      {
581 -          /* Create a read-only entry. */
582 -          create_proc_read_entry (proc_if[ctr].name, 0, root_proc_dir_entry,
583 -                             proc_if[ctr].read_func, mydev);
584 -      }
585 +    proc_create_data(proc_if[ctr].name, DRV_PROC_MODE, root_proc_dir_entry, proc_if[ctr].fops, (void *)mydev);
586    }
587  
588    tn7dsl_dslmod_sysctl_register ();
589 @@ -2711,73 +2691,18 @@ static int tn7atm_set_can_support_adsl2
590    return TRUE;
591  }
592  
593 -/*
594 - * This function matches a name such as "serial", and that specified by the
595 - * proc_dir_entry
596 - */
597 -static int tn7atm_proc_match (int len, const char *name,
598 -                              struct proc_dir_entry *de)
599 +static int tn7atm_proc_qos_read(struct seq_file *m, void *data)
600  {
601 -  if (!de || !de->low_ino)
602 +    seq_printf (m, "\nEnableQoS = %d\n", EnableQoS);
603      return 0;
604 -  if (de->namelen != len)
605 -    return 0;
606 -  return !strncmp (name, de->name, len);
607 -}
608 -
609 -/*
610 - * This function parses a name such as "tty/driver/serial", and
611 - * returns the struct proc_dir_entry for "/proc/tty/driver", and
612 - * returns "serial" in residual.
613 - */
614 -static int tn7atm_xlate_proc_name (const char *name,
615 -                                   struct proc_dir_entry **ret,
616 -                                   const char **residual)
617 -{
618 -  const char *cp = name, *next;
619 -  struct proc_dir_entry *de;
620 -  int len;
621 -  extern struct proc_dir_entry proc_root;
622 -
623 -  de = &proc_root;
624 -  while (1)
625 -  {
626 -    next = strchr (cp, '/');
627 -    if (!next)
628 -      break;
629 -
630 -    len = next - cp;
631 -    for (de = de->subdir; de; de = de->next)
632 -    {
633 -      if (tn7atm_proc_match (len, cp, de))
634 -        break;
635 -    }
636 -    if (!de)
637 -      return -ENOENT;
638 -    cp += len + 1;
639 -  }
640 -  *residual = cp;
641 -  *ret = de;
642 -
643 -  return 0;
644 -}
645 -
646 -static int tn7atm_proc_qos_read(char *buf, char **start, off_t offset, int count, int *eof, void *data)
647 -{
648 -    int len = 0;
649 -
650 -    len += sprintf (buf + len, "\nEnableQoS = %d\n", EnableQoS);
651 -    return len;
652  
653  }
654  
655  // [KT]
656 -static int tn7atm_proc_turbodsl_read(char *buf, char **start, off_t offset, int count, int *eof, void *data)
657 +static int tn7atm_proc_turbodsl_read(struct seq_file *m, void *data)
658  {
659 -    int len = 0;
660 -
661 -    len += sprintf (buf + len, "%d\n", bTurboDsl);
662 -    return len;
663 +    seq_printf (m, "%d\n", bTurboDsl);
664 +    return 0;
665  }
666  
667  static int tn7atm_proc_qos_write(struct file *fp, const char *buf, unsigned long count, void *data)
668 @@ -2812,7 +2737,7 @@ static int tn7atm_proc_qos_write(struct
669  }
670  
671  // [KT]
672 -int tn7atm_proc_turbodsl_write(struct file *fp, const char *buf, unsigned long count, void *data)
673 +static int tn7atm_proc_turbodsl_write(struct file *fp, const char *buf, unsigned long count, void *data)
674  {
675      char local_buf[10];
676   
677 @@ -2843,5 +2768,33 @@ int tn7atm_proc_turbodsl_write(struct fi
678      return count;
679  }
680  
681 +static int tn7atm_proc_qos_open(struct inode *inode, struct file *file)
682 +{
683 +       return single_open(file, tn7atm_proc_qos_read, PDE_DATA(inode));
684 +}
685 +
686 +static struct file_operations tn7atm_proc_qos_fops = {
687 +       .owner          = THIS_MODULE,
688 +       .open           = tn7atm_proc_qos_open,
689 +       .read           = seq_read,
690 +       .llseek         = seq_lseek,
691 +       .release        = single_release,
692 +       .write          = tn7atm_proc_qos_write,
693 +};
694 +
695 +static int tn7atm_proc_turbodsl_open(struct inode *inode, struct file *file)
696 +{
697 +       return single_open(file, tn7atm_proc_turbodsl_read, PDE_DATA(inode));
698 +}
699 +
700 +static struct file_operations tn7atm_proc_turbodsl_fops = {
701 +       .owner          = THIS_MODULE,
702 +       .open           = tn7atm_proc_turbodsl_open,
703 +       .read           = seq_read,
704 +       .llseek         = seq_lseek,
705 +       .release        = single_release,
706 +       .write          = tn7atm_proc_turbodsl_write,
707 +};
708 +
709  module_init (tn7atm_detect);
710  module_exit (tn7atm_exit);
711 --- a/tn7dsl.c
712 +++ b/tn7dsl.c
713 @@ -233,6 +233,9 @@ static struct led_funcs ledreg[2];
714  
715  #define tn7dsl_kfree_skb(x)      dev_kfree_skb(x)
716  
717 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
718 +#define PDE_DATA(inode) PDE(inode)->data
719 +#endif
720  
721  //---------------------------------------------
722  // Begin Clear EOC definitions
723 @@ -366,7 +369,7 @@ static void tn7dsl_register_dslss_led(vo
724  void tn7dsl_dslmod_sysctl_register(void);
725  void tn7dsl_dslmod_sysctl_unregister(void);
726  static int tn7dsl_clear_eoc_receive(void);
727 -static int tn7dsl_proc_snr_print (char *buf, int count, int *eof, int data);
728 +static int tn7dsl_proc_snr_print (struct seq_file *m, int data);
729  /* end of internal functions */
730  
731  //  UR8_MERGE_START CQ11054   Jack Zhang
732 @@ -698,11 +701,9 @@ void shim_osCriticalExit(void)
733    spin_unlock_irqrestore(&shimLock, flags);
734  }
735  
736 -static int tn7dsl_proc_snr_print (char *buf, int count, int *eof, int data)
737 +static int tn7dsl_proc_snr_print (struct seq_file *m, int data)
738  {
739  
740 -  int len = 0;
741 -  int limit = count - 80;
742    int i, j;
743    int bin = (int) data;
744    unsigned short *rxSnrPerBin;
745 @@ -723,95 +724,128 @@ static int tn7dsl_proc_snr_print (char *
746        break;
747  
748    default:
749 -  if(len<=limit)
750 -        len += sprintf (buf + len, "\nInvalid bin selected Bin%d :\n", bin);
751 -  return len;
752 -}
753 +      seq_printf (m, "\nInvalid bin selected Bin%d :\n", bin);
754 +      return 0;
755 +  }
756  
757 -  if(len<=limit)
758 -    len += sprintf (buf + len, "\nAR7 DSL Modem Rx SNR Per Bin for Bin%d :\n", bin);
759 +  seq_printf (m, "\nAR7 DSL Modem Rx SNR Per Bin for Bin%d :\n", bin);
760  
761    for (i=0; i<pIhw->AppData.max_ds_tones/16; i++)
762    {
763      for(j=0;j<16;j++)
764      {
765 -      if(len <=limit)
766 -        len +=
767 -          sprintf (buf + len, "%04x ",
768 +      seq_printf (m, "%04x ",
769                     (unsigned short) rxSnrPerBin[i * 16 + j]);
770 -  }
771 -      if(len <=limit)
772 -        len += sprintf(buf+len, "\n");
773      }
774 +      seq_printf(m, "\n");
775 +  }
776  
777 -  return len;
778 +  return 0;
779  }
780  
781  
782  //@Added SNR per bin info per customer request. 05-14-2004
783 -int tn7dsl_proc_snr0 (char *buf, char **start, off_t offset, int count,
784 -                      int *eof, void *data)
785 +static int tn7dsl_proc_snr0 (struct seq_file *m, void *data)
786      {
787 -  return tn7dsl_proc_snr_print(buf, count, eof, 0);
788 +  return tn7dsl_proc_snr_print(m, 0);
789      }
790  
791 -int tn7dsl_proc_snr1 (char *buf, char **start, off_t offset, int count,
792 -                      int *eof, void *data)
793 +static int tn7dsl_proc_snr0_open(struct inode *inode, struct file *file)
794  {
795 -  return tn7dsl_proc_snr_print(buf, count, eof, 1);
796 +       return single_open(file, tn7dsl_proc_snr0, PDE_DATA(inode));
797 +}
798 +
799 +struct file_operations tn7dsl_proc_snr0_fops = {
800 +       .owner          = THIS_MODULE,
801 +       .open           = tn7dsl_proc_snr0_open,
802 +       .read           = seq_read,
803 +       .llseek         = seq_lseek,
804 +       .release        = single_release,
805 +};
806 +
807 +static int tn7dsl_proc_snr1 (struct seq_file *m, void *data)
808 +{
809 +  return tn7dsl_proc_snr_print(m, 1);
810    }
811  
812 -int tn7dsl_proc_snr2 (char *buf, char **start, off_t offset, int count,
813 -                      int *eof, void *data)
814 +static int tn7dsl_proc_snr1_open(struct inode *inode, struct file *file)
815  {
816 -  return tn7dsl_proc_snr_print(buf, count, eof, 2);
817 +       return single_open(file, tn7dsl_proc_snr1, PDE_DATA(inode));
818  }
819  
820 +struct file_operations tn7dsl_proc_snr1_fops = {
821 +       .owner          = THIS_MODULE,
822 +       .open           = tn7dsl_proc_snr1_open,
823 +       .read           = seq_read,
824 +       .llseek         = seq_lseek,
825 +       .release        = single_release,
826 +};
827 +
828 +static int tn7dsl_proc_snr2 (struct seq_file *m, void *data)
829 +{
830 +  return tn7dsl_proc_snr_print(m, 2);
831 +}
832 +
833 +static int tn7dsl_proc_snr2_open(struct inode *inode, struct file *file)
834 +{
835 +       return single_open(file, tn7dsl_proc_snr2, PDE_DATA(inode));
836 +}
837 +
838 +struct file_operations tn7dsl_proc_snr2_fops = {
839 +       .owner          = THIS_MODULE,
840 +       .open           = tn7dsl_proc_snr2_open,
841 +       .read           = seq_read,
842 +       .llseek         = seq_lseek,
843 +       .release        = single_release,
844 +};
845 +
846  //@Added bit allocation table per customer request. 05-14-2004
847 -int tn7dsl_proc_bit_allocation (char *buf, char **start, off_t offset,
848 -                                int count, int *eof, void *data)
849 +static int tn7dsl_proc_bit_allocation (struct seq_file *m, void *data)
850  {
851  
852 -  int len = 0;
853 -  int limit = count - 80;
854    int i, j;
855  
856 -  if(len<=limit)
857 -    len += sprintf(buf+len, "\nAR7 DSL Modem US Bit Allocation:");
858 +  seq_printf(m, "\nAR7 DSL Modem US Bit Allocation:");
859  
860    for(i=0; i<pIhw->AppData.max_us_tones; i++)
861      {
862      if (!(i%16))
863      {
864 -      if(len <=limit)
865 -        len += sprintf(buf+len, "\n");
866 +        seq_printf(m, "\n");
867      }
868 -    if(len <=limit)
869 -      len +=
870 -        sprintf (buf + len, "%02x ",
871 -                 (unsigned char) pIhw->AppData.BitAllocTblUstrm[i]);
872 +    seq_printf (m, "%02x ",
873 +                (unsigned char) pIhw->AppData.BitAllocTblUstrm[i]);
874    }
875  
876 -  if(len<=limit)
877 -    len += sprintf(buf+len, "\n\nAR7 DSL Modem DS Bit Allocation:\n");
878 +  seq_printf(m, "\n\nAR7 DSL Modem DS Bit Allocation:\n");
879  
880    for (i=0; i<pIhw->AppData.max_ds_tones/16; i++)
881    {
882      for(j=0;j<16;j++)
883      {
884 -      if(len <=limit)
885 -        len +=
886 -          sprintf (buf + len, "%02x ",
887 -                   (unsigned char) pIhw->AppData.BitAllocTblDstrm[i * 16 +
888 -                                                                  j]);
889 +      seq_printf (m, "%02x ",
890 +                  (unsigned char) pIhw->AppData.BitAllocTblDstrm[i * 16 +
891 +                                                                 j]);
892      }
893 -    if(len <=limit)
894 -        len += sprintf(buf+len, "\n");
895 +    seq_printf(m, "\n");
896    }
897  
898 -  return len;
899 +  return 0;
900 +}
901 +
902 +int tn7dsl_proc_bit_allocation_open(struct inode *inode, struct file *file)
903 +{
904 +       return single_open(file, tn7dsl_proc_bit_allocation, PDE_DATA(inode));
905  }
906  
907 +struct file_operations tn7dsl_proc_bit_allocation_fops = {
908 +       .owner          = THIS_MODULE,
909 +       .open           = tn7dsl_proc_bit_allocation_open,
910 +       .read           = seq_read,
911 +       .llseek         = seq_lseek,
912 +       .release        = single_release,
913 +};
914 +
915  #ifndef NO_ACT
916  int tn7dsl_proc_ds_noise(char* buf, char **start, off_t offset, int count,
917                   int *eof, void *data)
918 @@ -874,59 +908,48 @@ static char *pUnknown= "Unknown";
919  #ifdef ADV_DIAG_STATS //CQ10275, CQ10449
920  //UR8_MERGE_START CQ10449 Jack Zhang
921  
922 -static int proc_adv_stats_header(char* buf, int limit);
923 +static int proc_adv_stats_header(struct seq_file *m);
924  
925 -int tn7dsl_proc_adv_stats(char* buf, char **start, off_t offset, int count,
926 -                 int *eof, void *data)
927 +static int tn7dsl_proc_adv_stats(struct seq_file *m, void *data)
928  {
929  
930 -  int len = 0;
931 -  int limit = count - 80;
932    //char *cp = buf + offset;
933    char *cp = buf;
934    int i = 0;
935    int strt = 32;
936 -  static int ctr = 0;
937  
938  //  printk("proc_adv_stats: buf=0x%X, ctr=%d, offset=%d, count=%d, eof=%d\n",
939  //             (unsigned int)buf, ctr, offset, count, *eof);
940 -  if( ctr == 0)
941 -  {
942 -    len = proc_adv_stats_header( cp, limit);
943 +  proc_adv_stats_header(m);
944  
945 -    if( len<=limit)
946 -      len += sprintf(cp+len, "\n\tBin No.\tBits:\tMargin:\tSNR\n");
947 -  }
948 -  else
949 -  {
950 -    strt = ctr;
951 -  }
952 +  seq_printf(m, "\n\tBin No.\tBits:\tMargin:\tSNR\n");
953  
954    for( i =strt; i<512; i++)
955    {
956 -    if(len<=limit)
957 -    {
958 -      len += sprintf(cp+len, "\t%u\t%u\t%u\t%d\n", i,
959 +    seq_printf(m, "\t%u\t%u\t%u\t%d\n", i,
960                      (unsigned int)pIhw->AppData.BitAllocTblDstrm[i],
961                      (unsigned int)pIhw->AppData.marginTblDstrm[i],
962                      (int)pIhw->AppData.rxSnrPerBin0[i]);
963 -    }
964 -    else
965 -    {
966 -      ctr = i;
967 -      //*eof = 0;
968 -      *(cp + len) = '\0';
969 -      printk("proc_adv_stats - return: ctr=%d, len=%d\n", ctr, len);
970 -      return len;
971 -    }
972    }
973 -  ctr = 0;
974 -  *eof = 1;
975    printk("proc_adv_stats - return: ctr=%d, len=%d\n", ctr, len);
976 -  return len;
977 +  return 0;
978  }
979  
980 -static int proc_adv_stats_header(char* buf, int limit)
981 +
982 +static int tn7dsl_proc_adv_stats_open(struct inode *inode, struct file *file)
983 +{
984 +       return single_open(file, tn7dsl_proc_adv_stats, PDE_DATA(inode));
985 +}
986 +
987 +struct file_operations tn7dsl_proc_adv_stats_fops = {
988 +       .owner          = THIS_MODULE,
989 +       .open           = tn7dsl_proc_adv_stats_open,
990 +       .read           = seq_read,
991 +       .llseek         = seq_lseek,
992 +       .release        = single_release,
993 +};
994 +
995 +static int proc_adv_stats_header(struct seq_file *m)
996  {
997    int len = 0;
998    int i = 0;
999 @@ -935,66 +958,53 @@ static int proc_adv_stats_header(char* b
1000     */
1001  
1002    dslhal_api_gatherStatistics(pIhw);
1003 -  if(len<=limit)
1004 -    len += sprintf(buf+len, "\nAR7 DSL Modem Advanced Statistics:\n");
1005 +  seq_printf(m, "\nAR7 DSL Modem Advanced Statistics:\n");
1006  
1007 -  if(len<=limit)
1008 +  if(pIhw->lConnected != 1)
1009    {
1010 -    if(pIhw->lConnected != 1)
1011 -    {
1012 -      pIhw->AppData.USConRate = 0;
1013 -      pIhw->AppData.DSConRate = 0;
1014 -    }
1015 -    len +=
1016 -      sprintf (buf + len,
1017 +    pIhw->AppData.USConRate = 0;
1018 +    pIhw->AppData.DSConRate = 0;
1019 +  }
1020 +  seq_printf (m,
1021                 "\t[Connection Rate]\tUS:\t%u\tDS:\t%u\n",
1022                     (unsigned int)pIhw->AppData.USConRate,
1023                     (unsigned int)pIhw->AppData.DSConRate );
1024    }
1025 -  if(len<=limit)
1026  //  UR8_MERGE_START CQ11054   Jack Zhang
1027 +  if (dslhal_api_getHighPrecision())
1028    {
1029 -    if (dslhal_api_getHighPrecision())
1030 -    {
1031 -      len +=
1032 -        sprintf (buf + len, "\t[Margin]\tUS:\t%d.%u\tDS:\t\t%d.%u\n",
1033 -                   gInt(pIhw->AppData.usMargin), gDot1(pIhw->AppData.usMargin),
1034 -                   gInt(pIhw->AppData.dsMargin), gDot1(pIhw->AppData.dsMargin));
1035 -    }
1036 -    else
1037 -    {
1038 -      len +=
1039 -        sprintf (buf + len, "\t[Margin]\tUS:\t%u\tDS:\t\t%u\n",
1040 -                   (unsigned int)pIhw->AppData.usMargin,
1041 -                   (unsigned int)pIhw->AppData.dsMargin/2 );
1042 -    }
1043 +    seq_printf (m, "\t[Margin]\tUS:\t%d.%u\tDS:\t\t%d.%u\n",
1044 +                 gInt(pIhw->AppData.usMargin), gDot1(pIhw->AppData.usMargin),
1045 +                 gInt(pIhw->AppData.dsMargin), gDot1(pIhw->AppData.dsMargin));
1046 +  }
1047 +  else
1048 +  {
1049 +    seq_printf (m, "\t[Margin]\tUS:\t%u\tDS:\t\t%u\n",
1050 +                 (unsigned int)pIhw->AppData.usMargin,
1051 +                 (unsigned int)pIhw->AppData.dsMargin/2 );
1052    }
1053  //  UR8_MERGE_END   CQ11054*
1054  
1055    /*
1056     * Downstream/Upstream Interleaved Errors
1057     */
1058 -  if(len<=limit)
1059 -    len += sprintf(buf+len, "\t[Interleave path] US (TX):\tCRC: \t%u\tFEC: \t%u\n",
1060 +  seq_printf(m, "\t[Interleave path] US (TX):\tCRC: \t%u\tFEC: \t%u\n",
1061                     (unsigned int)pIhw->AppData.usICRC_errors,
1062                     (unsigned int)pIhw->AppData.usIFEC_errors);
1063 -  if(len<=limit)
1064 -    len += sprintf(buf+len, "\t[Interleave path] DS (RX):\tCRC: \t%u\tFEC: \t%u\n",
1065 +  seq_printf(m, "\t[Interleave path] DS (RX):\tCRC: \t%u\tFEC: \t%u\n",
1066                     (unsigned int)pIhw->AppData.dsICRC_errors,
1067                     (unsigned int)pIhw->AppData.dsIFEC_errors);
1068    /*
1069     * Upstream/Downstream Fast Errors
1070     */
1071 -  if(len<=limit)
1072 -    len += sprintf(buf+len, "\t[Fast path] US (TX):  \tCRC: \t%u\tFEC: \t%u\n",
1073 +  seq_printf(m, "\t[Fast path] US (TX):  \tCRC: \t%u\tFEC: \t%u\n",
1074                     (unsigned int)pIhw->AppData.usFCRC_errors,
1075                     (unsigned int)pIhw->AppData.usFFEC_errors);
1076 -  if(len<=limit)
1077 -    len += sprintf(buf+len, "\t[Fast path] DS (RX):\tCRC: \t%u\tFEC: \t%u\n",
1078 +  seq_printf(m, "\t[Fast path] DS (RX):\tCRC: \t%u\tFEC: \t%u\n",
1079                     (unsigned int)pIhw->AppData.dsFCRC_errors,
1080                     (unsigned int)pIhw->AppData.dsFFEC_errors);
1081  
1082 -  return len;
1083 +  return 0;
1084  }
1085  
1086  static int getDiagDisplayMode()
1087 @@ -1017,29 +1027,24 @@ static int getDiagDisplayMode()
1088      ret = 2;
1089    return ret;
1090  }
1091 -int tn7dsl_proc_adv_stats1(char* buf, char **start, off_t offset, int count,
1092 -                 int *eof, void *data)
1093 +int tn7dsl_proc_adv_stats1(struct seq_file *m, void *data)
1094  {
1095  
1096 -  int len = 0;
1097 -  int limit = count - 80;
1098    int i;
1099    int mode = 0;  //mode = 0 => ADSL1 or ADSL2 & 2+
1100    unsigned char SNRpsds[512];
1101    int n;
1102  
1103 -  len = proc_adv_stats_header( buf+len, limit);
1104 +  proc_adv_stats_header( m);
1105    mode = getDiagDisplayMode();
1106  
1107 -  if(len<=limit)
1108 -    len += sprintf(buf+len, "\tBin No.\tBits:\tMargin:\tSNR (Part 1 of 3)\n");
1109 +  seq_printf(m, "\tBin No.\tBits:\tMargin:\tSNR (Part 1 of 3)\n");
1110  
1111    if(mode==1) //ADSL1
1112    {
1113    for( i =32; i<128; i++)
1114    {
1115 -    if(len<=limit)
1116 -      len += sprintf(buf+len, "\t%u\t%u\t%u\t%d\n", i,
1117 +    seq_printf(m, "\t%u\t%u\t%u\t%d\n", i,
1118                      (unsigned int)pIhw->AppData.BitAllocTblDstrm[i],
1119                      (unsigned int)pIhw->AppData.marginTblDstrm[i],
1120                      (int)pIhw->AppData.rxSnrPerBin0[i]);
1121 @@ -1050,26 +1055,34 @@ int tn7dsl_proc_adv_stats1(char* buf, ch
1122      if (dslhal_api_getSNRpsds(pIhw, SNRpsds, 1))
1123      {
1124        dgprintf(4, "dslhal_api_getSNRpsds failed!\n");
1125 -      return len;
1126 +      return -EIO;
1127      }
1128      for( i =32; i<128; i++)
1129      {
1130 -      if(len<=limit)
1131 -          len += sprintf(buf+len, "\t%u\t%u\t%u\t%d\n", i,
1132 +      seq_printf(m, "\t%u\t%u\t%u\t%d\n", i,
1133                      (unsigned int)pIhw->AppData.BitAllocTblDstrm[i],
1134                      (unsigned int)pIhw->AppData.marginTblDstrm[i],
1135                      (i<pIhw->AppData.max_ds_tones)?(unsigned char)SNRpsds[i]:0);
1136      }
1137    }
1138 -  return len;
1139 +  return 0;
1140  }
1141  
1142 -int tn7dsl_proc_adv_stats2(char* buf, char **start, off_t offset, int count,
1143 -                 int *eof, void *data)
1144 +static int tn7dsl_proc_adv_stats1_open(struct inode *inode, struct file *file)
1145  {
1146 +       return single_open(file, tn7dsl_proc_adv_stats1, PDE_DATA(inode));
1147 +}
1148  
1149 -  int len = 0;
1150 -  int limit = count - 80;
1151 +struct file_operations tn7dsl_proc_adv_stats1_fops = {
1152 +       .owner          = THIS_MODULE,
1153 +       .open           = tn7dsl_proc_adv_stats1_open,
1154 +       .read           = seq_read,
1155 +       .llseek         = seq_lseek,
1156 +       .release        = single_release,
1157 +};
1158 +
1159 +int tn7dsl_proc_adv_stats2(struct seq_file *m, void *data)
1160 +{
1161    int i;
1162    int mode = 0;  //mode = 0 => ADSL1 or ADSL2 & 2+
1163    unsigned char SNRpsds[512];
1164 @@ -1079,12 +1092,10 @@ int tn7dsl_proc_adv_stats2(char* buf, ch
1165    if( mode==1) //ADSL1
1166    {
1167    dslhal_api_gatherStatistics(pIhw);
1168 -  if(len<=limit)
1169 -      len += sprintf(buf+len, "\tBin No.\tBits:\tMargin:\tSNR (Part 2 of 3):\n");
1170 +    seq_printf(m, "\tBin No.\tBits:\tMargin:\tSNR (Part 2 of 3):\n");
1171      for( i =128; i<320; i++)
1172      {
1173 -  if(len<=limit)
1174 -        len += sprintf(buf+len, "\t%u\t%u\t%u\t%d\n", i,
1175 +      seq_printf(m, "\t%u\t%u\t%u\t%d\n", i,
1176                      (unsigned int)pIhw->AppData.BitAllocTblDstrm[i],
1177                      (unsigned int)pIhw->AppData.marginTblDstrm[i],
1178                      (int)pIhw->AppData.rxSnrPerBin0[i]);
1179 @@ -1095,26 +1106,35 @@ int tn7dsl_proc_adv_stats2(char* buf, ch
1180      if (dslhal_api_getSNRpsds(pIhw, SNRpsds, 1))
1181      {
1182        dgprintf(4, "dslhal_api_getSNRpsds failed!\n");
1183 -      return len;
1184 +      return -EIO;
1185      }
1186    for( i =128; i<320; i++)
1187    {
1188 -    if(len<=limit)
1189 -      len += sprintf(buf+len, "\t%u\t%u\t%u\t%d\n", i,
1190 +    seq_printf(m, "\t%u\t%u\t%u\t%d\n", i,
1191                      (unsigned int)pIhw->AppData.BitAllocTblDstrm[i],
1192                      (unsigned int)pIhw->AppData.marginTblDstrm[i],
1193                      (i<pIhw->AppData.max_ds_tones)?(unsigned char)SNRpsds[i]:0);
1194      }
1195    }
1196 -  return len;
1197 +  return 0;
1198  }
1199  
1200 -int tn7dsl_proc_adv_stats3(char* buf, char **start, off_t offset, int count,
1201 -                 int *eof, void *data)
1202 +static int tn7dsl_proc_adv_stats2_open(struct inode *inode, struct file *file)
1203 +{
1204 +       return single_open(file, tn7dsl_proc_adv_stats2, PDE_DATA(inode));
1205 +}
1206 +
1207 +struct file_operations tn7dsl_proc_adv_stats2_fops = {
1208 +       .owner          = THIS_MODULE,
1209 +       .open           = tn7dsl_proc_adv_stats2_open,
1210 +       .read           = seq_read,
1211 +       .llseek         = seq_lseek,
1212 +       .release        = single_release,
1213 +};
1214 +
1215 +int tn7dsl_proc_adv_stats3(struct seq_file *m, void *data)
1216  {
1217  
1218 -  int len = 0;
1219 -  int limit = count - 80;
1220    int i;
1221    int mode = 0;  //mode = 0 => ADSL1 or ADSL2 & 2+
1222    unsigned char SNRpsds[512];
1223 @@ -1124,12 +1144,10 @@ int tn7dsl_proc_adv_stats3(char* buf, ch
1224    if( mode==1) //ADSL1
1225    {
1226    dslhal_api_gatherStatistics(pIhw);
1227 -  if(len<=limit)
1228 -      len += sprintf(buf+len, "\tBin No.\tBits:\tMargin:\tSNR (Part 3 of 3):\n");
1229 +    seq_printf(m, "\tBin No.\tBits:\tMargin:\tSNR (Part 3 of 3):\n");
1230      for( i =320; i<512; i++)
1231      {
1232 -  if(len<=limit)
1233 -        len += sprintf(buf+len, "\t%u\t%u\t%u\t%d\n", i,
1234 +      seq_printf(m, "\t%u\t%u\t%u\t%d\n", i,
1235                      (unsigned int)pIhw->AppData.BitAllocTblDstrm[i],
1236                      (unsigned int)pIhw->AppData.marginTblDstrm[i],
1237                      (int)pIhw->AppData.rxSnrPerBin0[i]);
1238 @@ -1140,283 +1158,287 @@ int tn7dsl_proc_adv_stats3(char* buf, ch
1239      if (dslhal_api_getSNRpsds(pIhw, SNRpsds, 1))
1240      {
1241        dgprintf(4, "dslhal_api_getSNRpsds failed!\n");
1242 -      return len;
1243 +      return -EIO;
1244      }
1245    for( i =320; i<512; i++)
1246    {
1247 -    if(len<=limit)
1248 -      len += sprintf(buf+len, "\t%u\t%u\t%u\t%d\n", i,
1249 +    seq_printf(m, "\t%u\t%u\t%u\t%d\n", i,
1250                      (unsigned int)pIhw->AppData.BitAllocTblDstrm[i],
1251                      (unsigned int)pIhw->AppData.marginTblDstrm[i],
1252                      (i<pIhw->AppData.max_ds_tones)?(unsigned char)SNRpsds[i]:0);
1253      }
1254    }
1255 -  if(len<=limit)
1256 -    len += sprintf(buf+len, "[End of Stats]\n");
1257 -  return len;
1258 +  seq_printf(m, "[End of Stats]\n");
1259 +  return 0;
1260  }
1261 -//UR8_MERGE_END  CQ10449
1262 -//UR8_MERGE_START CQ10682   Jack Zhang
1263 -int tn7dsl_proc_dbg_cmsgs(char* buf, char **start, off_t offset, int count,
1264 -                 int *eof, void *data)
1265 +
1266 +static int tn7dsl_proc_adv_stats3_open(struct inode *inode, struct file *file)
1267  {
1268 +       return single_open(file, tn7dsl_proc_adv_stats3, PDE_DATA(inode));
1269 +}
1270  
1271 -  int len = 0;
1272 -  int limit = count - 80;
1273 +struct file_operations tn7dsl_proc_adv_stats3_fops = {
1274 +       .owner          = THIS_MODULE,
1275 +       .open           = tn7dsl_proc_adv_stats3_open,
1276 +       .read           = seq_read,
1277 +       .llseek         = seq_lseek,
1278 +       .release        = single_release,
1279 +};
1280  
1281 +//UR8_MERGE_END  CQ10449
1282 +//UR8_MERGE_START CQ10682   Jack Zhang
1283 +int tn7dsl_proc_dbg_cmsgs(struct seq_file *m, void *data)
1284 +{
1285    int rc=0;
1286  
1287    dslhal_api_gatherStatistics(pIhw);
1288  
1289 -  if(len<=limit)
1290 -    len += sprintf(buf+len, "Training Messages (C-Msgs 1-5)..\n");
1291 +  seq_printf(m, "Training Messages (C-Msgs 1-5)..\n");
1292  
1293 -  if(len<=limit)
1294 -    len += sprintf(buf+len, "ADSL2 DELT C-Msg1Ld \t Message Length:%d\n",
1295 +  seq_printf(m, "ADSL2 DELT C-Msg1Ld \t Message Length:%d\n",
1296                              pIhw->adsl2DiagnosticMessages.cMsg1LdLen);
1297    for(rc=0;rc<pIhw->adsl2DiagnosticMessages.cMsg1LdLen;rc++)
1298    {
1299 -    if(len<=limit)
1300 -      len += sprintf(buf+len, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.cMsg1Ld[rc]);
1301 +    seq_printf(m, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.cMsg1Ld[rc]);
1302      if(rc!=0 && (rc%16==0))
1303 -      if(len<=limit)
1304 -        len += sprintf(buf+len, "\n");
1305 +      seq_printf(m, "\n");
1306    }
1307 -  if(len<=limit)
1308 -    len += sprintf(buf+len, "\nADSL2 DELT C-Msg2Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.cMsg2LdLen);
1309 +  seq_printf(m, "\nADSL2 DELT C-Msg2Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.cMsg2LdLen);
1310  
1311    for(rc=0;rc<pIhw->adsl2DiagnosticMessages.cMsg2LdLen;rc++)
1312    {
1313 -    if(len<=limit)
1314 -      len += sprintf(buf+len, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.cMsg2Ld[rc]);
1315 +    seq_printf(m, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.cMsg2Ld[rc]);
1316      if(rc!=0 && (rc%16==0))
1317 -      if(len<=limit)
1318 -        len += sprintf(buf+len, "\n");
1319 +      seq_printf(m, "\n");
1320    }
1321  
1322 -  if(len<=limit)
1323 -    len += sprintf(buf+len, "\nADSL2 DELT C-Msg3Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.cMsg3LdLen);
1324 +  seq_printf(m, "\nADSL2 DELT C-Msg3Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.cMsg3LdLen);
1325  
1326    for(rc=0;rc<pIhw->adsl2DiagnosticMessages.cMsg3LdLen;rc++)
1327    {
1328 -    if(len<=limit)
1329 -      len += sprintf(buf+len, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.cMsg3Ld[rc]);
1330 +    seq_printf(m, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.cMsg3Ld[rc]);
1331      if(rc!=0 && (rc%16==0))
1332 -      if(len<=limit)
1333 -        len += sprintf(buf+len, "\n");
1334 +      seq_printf(m, "\n");
1335    }
1336  
1337 -  if(len<=limit)
1338 -    len += sprintf(buf+len, "\nADSL2 DELT C-Msg4Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.cMsg4LdLen);
1339 +  seq_printf(m, "\nADSL2 DELT C-Msg4Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.cMsg4LdLen);
1340  
1341    for(rc=0;rc<pIhw->adsl2DiagnosticMessages.cMsg4LdLen;rc++)
1342    {
1343 -    if(len<=limit)
1344 -      len += sprintf(buf+len, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.cMsg4Ld[rc]);
1345 +    seq_printf(m, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.cMsg4Ld[rc]);
1346      if(rc!=0 && (rc%16==0))
1347 -      if(len<=limit)
1348 -        len += sprintf(buf+len, "\n");
1349 +      seq_printf(m, "\n");
1350    }
1351  
1352 -  if(len<=limit)
1353 -    len += sprintf(buf+len, "\nADSL2 DELT C-Msg5Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.cMsg5LdLen);
1354 +  seq_printf(m, "\nADSL2 DELT C-Msg5Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.cMsg5LdLen);
1355  
1356    for(rc=0;rc<pIhw->adsl2DiagnosticMessages.cMsg5LdLen;rc++)
1357    {
1358 -    if(len<=limit)
1359 -      len += sprintf(buf+len, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.cMsg5Ld[rc]);
1360 +    seq_printf(m, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.cMsg5Ld[rc]);
1361      if(rc!=0 && (rc%16==0))
1362 -      if(len<=limit)
1363 -        len += sprintf(buf+len, "\n");
1364 +      seq_printf(m, "\n");
1365    }
1366 -  if(len<=limit)
1367 -    len += sprintf(buf+len, "\n");
1368 -  return len;
1369 +  seq_printf(m, "\n");
1370 +  return 0;
1371  }
1372  
1373 -int tn7dsl_proc_dbg_rmsgs1(char* buf, char **start, off_t offset, int count,
1374 -                 int *eof, void *data)
1375 +static int tn7dsl_proc_dbg_cmsgs_open(struct inode *inode, struct file *file)
1376  {
1377 +       return single_open(file, tn7dsl_proc_dbg_cmsgs, PDE_DATA(inode));
1378 +}
1379  
1380 -  int len = 0;
1381 -  int limit = count - 80;
1382 +struct file_operations tn7dsl_proc_dbg_cmsgs_fops = {
1383 +       .owner          = THIS_MODULE,
1384 +       .open           = tn7dsl_proc_dbg_cmsgs_open,
1385 +       .read           = seq_read,
1386 +       .llseek         = seq_lseek,
1387 +       .release        = single_release,
1388 +};
1389 +
1390 +
1391 +int tn7dsl_proc_dbg_rmsgs1(struct seq_file *m, void *data)
1392 +{
1393  
1394    int rc=0;
1395  
1396    dslhal_api_gatherStatistics(pIhw);
1397  
1398 -  if(len<=limit)
1399 -    len += sprintf(buf+len, "Training Messages (R-Msgs 1-3)..\n");
1400 +  seq_printf(m, "Training Messages (R-Msgs 1-3)..\n");
1401  
1402 -  if(len<=limit)
1403 -    len += sprintf(buf+len, "\nADSL2 DELT R-Msg1Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsg1LdLen);
1404 +  seq_printf(m, "\nADSL2 DELT R-Msg1Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsg1LdLen);
1405  
1406    for(rc=0;rc<pIhw->adsl2DiagnosticMessages.rMsg1LdLen;rc++)
1407    {
1408 -    if(len<=limit)
1409 -      len += sprintf(buf+len, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg1Ld[rc]);
1410 +    seq_printf(m, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg1Ld[rc]);
1411      if(rc!=0 && (rc%16==0))
1412 -      if(len<=limit)
1413 -        len += sprintf(buf+len, "\n");
1414 +      seq_printf(m, "\n");
1415    }
1416  
1417 -  if(len<=limit)
1418 -    len += sprintf(buf+len, "\nADSL2 DELT R-Msg2Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsgxLdLen);
1419 +  seq_printf(m, "\nADSL2 DELT R-Msg2Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsgxLdLen);
1420  
1421    for(rc=0;rc<pIhw->adsl2DiagnosticMessages.rMsgxLdLen;rc++)
1422    {
1423 -    if(len<=limit)
1424 -      len += sprintf(buf+len, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg2Ld[rc]);
1425 +    seq_printf(m, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg2Ld[rc]);
1426      if(rc!=0 && (rc%16==0))
1427 -      if(len<=limit)
1428 -        len += sprintf(buf+len, "\n");
1429 +      seq_printf(m, "\n");
1430    }
1431  
1432 -  if(len<=limit)
1433 -    len += sprintf(buf+len, "\nADSL2 DELT R-Msg3Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsgxLdLen);
1434 +  seq_printf(m, "\nADSL2 DELT R-Msg3Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsgxLdLen);
1435    for(rc=0;rc<pIhw->adsl2DiagnosticMessages.rMsgxLdLen;rc++)
1436    {
1437 -    if(len<=limit)
1438 -      len += sprintf(buf+len, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg3Ld[rc]);
1439 +    seq_printf(m, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg3Ld[rc]);
1440      if(rc!=0 && (rc%16==0))
1441 -      if(len<=limit)
1442 -        len += sprintf(buf+len, "\n");
1443 +      seq_printf(m, "\n");
1444    }
1445 -  if(len<=limit)
1446 -    len += sprintf(buf+len, "\n");
1447 -  return len;
1448 +  seq_printf(m, "\n");
1449 +  return 0;
1450  }
1451  
1452 -int tn7dsl_proc_dbg_rmsgs2(char* buf, char **start, off_t offset, int count,
1453 -                 int *eof, void *data)
1454 +static int tn7dsl_proc_dbg_rmsgs1_open(struct inode *inode, struct file *file)
1455  {
1456 +       return single_open(file, tn7dsl_proc_dbg_rmsgs1, PDE_DATA(inode));
1457 +}
1458  
1459 -  int len = 0;
1460 -  int limit = count - 80;
1461 +struct file_operations tn7dsl_proc_dbg_rmsgs1_fops = {
1462 +       .owner          = THIS_MODULE,
1463 +       .open           = tn7dsl_proc_dbg_rmsgs1_open,
1464 +       .read           = seq_read,
1465 +       .llseek         = seq_lseek,
1466 +       .release        = single_release,
1467 +};
1468 +
1469 +
1470 +int tn7dsl_proc_dbg_rmsgs2(struct seq_file *m, void *data)
1471 +{
1472  
1473    int rc=0;
1474  
1475    dslhal_api_gatherStatistics(pIhw);
1476  
1477 -  if(len<=limit)
1478 -    len += sprintf(buf+len, "Training Messages (R-Msgs 4-5)..\n");
1479 +  seq_printf(m, "Training Messages (R-Msgs 4-5)..\n");
1480  
1481 -  if(len<=limit)
1482 -    len += sprintf(buf+len, "\nADSL2 DELT R-Msg4Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsgxLdLen);
1483 +  seq_printf(m, "\nADSL2 DELT R-Msg4Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsgxLdLen);
1484    for(rc=0;rc<pIhw->adsl2DiagnosticMessages.rMsgxLdLen;rc++)
1485    {
1486 -    if(len<=limit)
1487 -      len += sprintf(buf+len, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg4Ld[rc]);
1488 +    seq_printf(m, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg4Ld[rc]);
1489      if(rc!=0 && (rc%16==0))
1490 -      if(len<=limit)
1491 -        len += sprintf(buf+len, "\n");
1492 +      len += sprintf(m, "\n");
1493    }
1494  
1495 -  if(len<=limit)
1496 -    len += sprintf(buf+len, "\nADSL2 DELT R-Msg5Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsgxLdLen);
1497 +  seq_printf(m, "\nADSL2 DELT R-Msg5Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsgxLdLen);
1498    for(rc=0;rc<pIhw->adsl2DiagnosticMessages.rMsgxLdLen;rc++)
1499    {
1500 -    if(len<=limit)
1501 -      len += sprintf(buf+len, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg5Ld[rc]);
1502 +    seq_printf(m, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg5Ld[rc]);
1503      if(rc!=0 && (rc%16==0))
1504 -      if(len<=limit)
1505 -        len += sprintf(buf+len, "\n");
1506 +      seq_printf(m, "\n");
1507    }
1508  
1509 -  if(len<=limit)
1510 -    len += sprintf(buf+len, "\n");
1511 -  return len;
1512 +  seq_printf(m, "\n");
1513 +  return 0;
1514  }
1515  
1516 -int tn7dsl_proc_dbg_rmsgs3(char* buf, char **start, off_t offset, int count,
1517 -                 int *eof, void *data)
1518 +static int tn7dsl_proc_dbg_rmsgs2_open(struct inode *inode, struct file *file)
1519  {
1520 +       return single_open(file, tn7dsl_proc_dbg_rmsgs2, PDE_DATA(inode));
1521 +}
1522  
1523 -  int len = 0;
1524 -  int limit = count - 80;
1525 +struct file_operations _fops = {
1526 +       .owner          = THIS_MODULE,
1527 +       .open           = tn7dsl_proc_dbg_rmsgs2_open,
1528 +       .read           = seq_read,
1529 +       .llseek         = seq_lseek,
1530 +       .release        = single_release,
1531 +};
1532 +
1533 +int tn7dsl_proc_dbg_rmsgs3(struct seq_file *m, void *data)
1534 +{
1535  
1536    int rc=0;
1537  
1538    dslhal_api_gatherStatistics(pIhw);
1539  
1540 -  if(len<=limit)
1541 -    len += sprintf(buf+len, "Training Messages (R-Msgs 6-7)..\n");
1542 +  seq_printf(m, "Training Messages (R-Msgs 6-7)..\n");
1543  
1544 -  if(len<=limit)
1545 -    len += sprintf(buf+len, "\nADSL2 DELT R-Msg6Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsgxLdLen);
1546 +  seq_printf(m, "\nADSL2 DELT R-Msg6Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsgxLdLen);
1547    for(rc=0;rc<pIhw->adsl2DiagnosticMessages.rMsgxLdLen;rc++)
1548    {
1549 -    if(len<=limit)
1550 -      len += sprintf(buf+len, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg6Ld[rc]);
1551 +    seq_printf(m, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg6Ld[rc]);
1552      if(rc!=0 && (rc%16==0))
1553 -      if(len<=limit)
1554 -        len += sprintf(buf+len, "\n");
1555 +      seq_printf(m, "\n");
1556    }
1557 -  if(len<=limit)
1558 -    len += sprintf(buf+len, "\nADSL2 DELT R-Msg7Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsgxLdLen);
1559 +  seq_printf(m, "\nADSL2 DELT R-Msg7Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsgxLdLen);
1560    for(rc=0;rc<pIhw->adsl2DiagnosticMessages.rMsgxLdLen;rc++)
1561    {
1562 -    if(len<=limit)
1563 -      len += sprintf(buf+len, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg7Ld[rc]);
1564 +    seq_printf(m, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg7Ld[rc]);
1565      if(rc!=0 && (rc%16==0))
1566 -      if(len<=limit)
1567 -        len += sprintf(buf+len, "\n");
1568 +      seq_printf(m, "\n");
1569    }
1570 -  if(len<=limit)
1571 -    len += sprintf(buf+len, "\n");
1572 +  seq_printf(m, "\n");
1573  
1574 -  return len;
1575 +  return 0;
1576  }
1577  
1578 -int tn7dsl_proc_dbg_rmsgs4(char* buf, char **start, off_t offset, int count,
1579 -                 int *eof, void *data)
1580 +static int tn7dsl_proc_dbg_rmsgs3_open(struct inode *inode, struct file *file)
1581  {
1582 +       return single_open(file, tn7dsl_proc_dbg_rmsgs3, PDE_DATA(inode));
1583 +}
1584  
1585 -  int len = 0;
1586 -  int limit = count - 80;
1587 +struct file_operations tn7dsl_proc_dbg_rmsgs3_fops = {
1588 +       .owner          = THIS_MODULE,
1589 +       .open           = tn7dsl_proc_dbg_rmsgs3_open,
1590 +       .read           = seq_read,
1591 +       .llseek         = seq_lseek,
1592 +       .release        = single_release,
1593 +};
1594 +
1595 +int tn7dsl_proc_dbg_rmsgs4(struct seq_file *m, void *data)
1596 +{
1597  
1598    int rc=0;
1599  
1600    dslhal_api_gatherStatistics(pIhw);
1601  
1602 -  if(len<=limit)
1603 -    len += sprintf(buf+len, "Training Messages (R-Msgs 8-9)..\n");
1604 +  seq_printf(m, "Training Messages (R-Msgs 8-9)..\n");
1605  
1606 -  if(len<=limit)
1607 -    len += sprintf(buf+len, "\nADSL2 DELT R-Msg8Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsgxLdLen);
1608 +  seq_printf(m, "\nADSL2 DELT R-Msg8Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsgxLdLen);
1609    for(rc=0;rc<pIhw->adsl2DiagnosticMessages.rMsgxLdLen;rc++)
1610    {
1611 -    if(len<=limit)
1612 -      len += sprintf(buf+len, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg8Ld[rc]);
1613 +    seq_printf(m, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg8Ld[rc]);
1614      if(rc!=0 && (rc%16==0))
1615 -      if(len<=limit)
1616 -        len += sprintf(buf+len, "\n");
1617 +      seq_printf(m, "\n");
1618    }
1619  
1620 -  if(len<=limit)
1621 -    len += sprintf(buf+len, "\nADSL2 DELT R-Msg9Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsgxLdLen);
1622 +  seq_printf(m, "\nADSL2 DELT R-Msg9Ld \t Message Length:%d\n",pIhw->adsl2DiagnosticMessages.rMsgxLdLen);
1623    for(rc=0;rc<pIhw->adsl2DiagnosticMessages.rMsgxLdLen;rc++)
1624    {
1625 -    if(len<=limit)
1626 -      len += sprintf(buf+len, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg9Ld[rc]);
1627 +    seq_printf(m, "  %02x",(unsigned char)pIhw->adsl2DiagnosticMessages.rMsg9Ld[rc]);
1628      if(rc!=0 && (rc%16==0))
1629 -      if(len<=limit)
1630 -        len += sprintf(buf+len, "\n");
1631 +      seq_printf(m, "\n");
1632    }
1633 -  if(len<=limit)
1634 -    len += sprintf(buf+len, "\n");
1635 +  seq_printf(m, "\n");
1636  
1637 -  return len;
1638 +  return 0;
1639  }
1640 +
1641 +static int tn7dsl_proc_dbg_rmsgs4_open(struct inode *inode, struct file *file)
1642 +{
1643 +       return single_open(file, tn7dsl_proc_dbg_rmsgs4, PDE_DATA(inode));
1644 +}
1645 +
1646 +struct file_operations tn7dsl_proc_dbg_rmsgs4_fops = {
1647 +       .owner          = THIS_MODULE,
1648 +       .open           = tn7dsl_proc_dbg_rmsgs4_open,
1649 +       .read           = seq_read,
1650 +       .llseek         = seq_lseek,
1651 +       .release        = single_release,
1652 +};
1653 +
1654  //UR8_MERGE_END   CQ10682*
1655  #endif //ADV_DIAG_STATS
1656  
1657 -int tn7dsl_proc_stats(char* buf, char **start, off_t offset, int count,
1658 -                 int *eof, void *data)
1659 +static int tn7dsl_proc_stats(struct seq_file *m, void *data)
1660  {
1661  
1662 -  int len = 0;
1663 -  int limit = count - 80;
1664    int F4count, F5count;
1665    unsigned int maxRate=0;
1666    unsigned int us_maxRate=0;
1667 @@ -1424,80 +1446,58 @@ int tn7dsl_proc_stats(char* buf, char **
1668    //UR8_MERGE_START CQ10700 Manjula K
1669    struct atm_dev *dev;
1670    Tn7AtmPrivate *priv;
1671 -  dev = (struct atm_dev *)data;
1672 +  int offset[2] = { 32, 0 };
1673 +  unsigned int usBitswap, dsBitswap;
1674 +  dev = (struct atm_dev *)m->private;
1675    priv = (Tn7AtmPrivate *)dev->dev_data;
1676    //UR8_MERGE_END CQ10700
1677  
1678 +
1679    /*
1680     * Read Ax5 Stats
1681     */
1682  
1683    dslhal_api_gatherStatistics(pIhw);
1684 -  if(len<=limit)
1685 -    len += sprintf(buf+len, "\nAR7 DSL Modem Statistics:\n");
1686 -  if(len<=limit)
1687 -    len += sprintf(buf+len, "--------------------------------\n");
1688 +  seq_printf(m, "\nAR7 DSL Modem Statistics:\n");
1689 +  seq_printf(m, "--------------------------------\n");
1690    /*
1691     * us and ds Connection Rates
1692     */
1693 -  if(len<=limit)
1694 -    len += sprintf(buf+len, "[DSL Modem Stats]\n");
1695 +  seq_printf(m, "[DSL Modem Stats]\n");
1696  
1697  
1698 -  if(len<=limit)
1699 +  if(pIhw->lConnected != 1)
1700    {
1701 -    if(pIhw->lConnected != 1)
1702 -    {
1703 -      pIhw->AppData.USConRate = 0;
1704 -      pIhw->AppData.DSConRate = 0;
1705 -    }
1706 -    len +=
1707 -      sprintf (buf + len,
1708 -               "\tUS Connection Rate:\t%u\tDS Connection Rate:\t%u\n",
1709 -                   (unsigned int)pIhw->AppData.USConRate,
1710 -                   (unsigned int)pIhw->AppData.DSConRate );
1711 +    pIhw->AppData.USConRate = 0;
1712 +    pIhw->AppData.DSConRate = 0;
1713    }
1714 -  if(len<=limit)
1715 +  seq_printf (m,
1716 +             "\tUS Connection Rate:\t%u\tDS Connection Rate:\t%u\n",
1717 +                 (unsigned int)pIhw->AppData.USConRate,
1718 +                 (unsigned int)pIhw->AppData.DSConRate );
1719  //  UR8_MERGE_START CQ11054   Jack Zhang
1720 -  {
1721 -    if (dslhal_api_getHighPrecision())
1722 -    {
1723 -      len +=
1724 -        sprintf (buf + len, "\tDS Line Attenuation:\t%u.%u\tDS Margin:\t\t%d.%u\n",
1725 +  if (dslhal_api_getHighPrecision())
1726 +    seq_printf (m, "\tDS Line Attenuation:\t%u.%u\tDS Margin:\t\t%d.%u\n",
1727                     gInt(pIhw->AppData.dsLineAttn), gDot1(pIhw->AppData.dsLineAttn),
1728                     gInt(pIhw->AppData.dsMargin), gDot1(pIhw->AppData.dsMargin));
1729 -    }
1730 -    else{
1731 -      len +=
1732 -        sprintf (buf + len, "\tDS Line Attenuation:\t%u\tDS Margin:\t\t%u\n",
1733 +  else
1734 +    seq_printf (m, "\tDS Line Attenuation:\t%u\tDS Margin:\t\t%u\n",
1735                     (unsigned int)pIhw->AppData.dsLineAttn/2,
1736                     (unsigned int)pIhw->AppData.dsMargin/2 );
1737 -    }
1738 -  }
1739  //  UR8_MERGE_END   CQ11054*
1740  
1741 -  if(len<=limit)
1742  //  UR8_MERGE_START CQ11054   Jack Zhang
1743 -  {
1744 -    if (dslhal_api_getHighPrecision())
1745 -    {
1746 -      len +=
1747 -        sprintf (buf + len, "\tUS Line Attenuation:\t%u.%u\tUS Margin:\t\t%d.%u\n",
1748 +  if (dslhal_api_getHighPrecision())
1749 +    seq_printf (m, "\tUS Line Attenuation:\t%u.%u\tUS Margin:\t\t%d.%u\n",
1750                     gInt(pIhw->AppData.usLineAttn), gDot1(pIhw->AppData.usLineAttn),
1751                     gInt(pIhw->AppData.usMargin), gDot1(pIhw->AppData.usMargin));
1752 -    }
1753 -    else
1754 -    {
1755 -      len +=
1756 -        sprintf (buf + len, "\tUS Line Attenuation:\t%u\tUS Margin:\t\t%u\n",
1757 +  else
1758 +    seq_printf (m, "\tUS Line Attenuation:\t%u\tUS Margin:\t\t%u\n",
1759                     (unsigned int)pIhw->AppData.usLineAttn/2,
1760                     (unsigned int)pIhw->AppData.usMargin );
1761 -    }
1762 -  }
1763  //  UR8_MERGE_END   CQ11054*
1764  
1765 -  if(len<=limit)
1766 -    len += sprintf(buf+len, "\tUS Payload :\t\t%u\tDS Payload:\t\t%u\n",
1767 +  seq_printf(m, "\tUS Payload :\t\t%u\tDS Payload:\t\t%u\n",
1768                      ((unsigned int) pIhw->AppData.usAtm_count[0] +
1769                       (unsigned int) pIhw->AppData.usAtm_count[1]) * 48,
1770                      ((unsigned int) pIhw->AppData.dsGood_count[0] +
1771 @@ -1505,9 +1505,7 @@ int tn7dsl_proc_stats(char* buf, char **
1772    /*
1773     * Superframe Count
1774     */
1775 -  if(len<=limit)
1776 -    len +=
1777 -      sprintf (buf + len,
1778 +  seq_printf (m,
1779                 "\tUS Superframe Cnt :\t%u\tDS Superframe Cnt:\t%u\n",
1780                     (unsigned int)pIhw->AppData.usSuperFrmCnt,
1781                     (unsigned int)pIhw->AppData.dsSuperFrmCnt );
1782 @@ -1515,59 +1513,45 @@ int tn7dsl_proc_stats(char* buf, char **
1783    /*
1784     * US and DS power
1785     */
1786 -  if(len<=limit)
1787 +  if(pIhw->AppData.bState < 5)
1788    {
1789 -    if(pIhw->AppData.bState < 5)
1790 -    {
1791 -      pIhw->AppData.usTxPower = 0;
1792 -      pIhw->AppData.dsTxPower = 0;
1793 -    }
1794 -    len +=
1795 -      sprintf (buf + len,
1796 +    pIhw->AppData.usTxPower = 0;
1797 +    pIhw->AppData.dsTxPower = 0;
1798 +  }
1799 +  seq_printf (m,
1800  // UR8_MERGE_START - CQ11579 - Jeremy #1
1801                 "\tUS Transmit Power :\t%d\tDS Transmit Power:\t%d\n",
1802                     pIhw->AppData.usTxPower/256,
1803                     pIhw->AppData.dsTxPower/256 );
1804  // UR8_MERGE_END - CQ11579
1805 -  }
1806    /*
1807     * DSL Stats Errors
1808     */
1809 -  if(len<=limit)
1810 -    len += sprintf(buf+len, "\tLOS errors:\t\t%u\tSEF errors:\t\t%u\n",
1811 +  seq_printf(m, "\tLOS errors:\t\t%u\tSEF errors:\t\t%u\n",
1812                     (unsigned int)pIhw->AppData.LOS_errors,
1813                     (unsigned int)pIhw->AppData.SEF_errors );
1814  
1815    //UR8_MERGE_START Report_SES Manjula K
1816    //CQ10369
1817 -  if(len<=limit)
1818 -    len += sprintf(buf+len, "\tErrored Seconds:\t%u\tSeverely Err Secs:\t%u\n",
1819 +  seq_printf(m, "\tErrored Seconds:\t%u\tSeverely Err Secs:\t%u\n",
1820                     (unsigned int)pIhw->AppData.erroredSeconds,
1821                     (unsigned int)pIhw->AppData.severelyerrsecs );
1822    //UR8_MERGE_END Report_SES
1823  
1824 -  if(len<=limit)
1825 -    len += sprintf(buf+len, "\tFrame mode:\t\t%u\tMax Frame mode:\t\t%u\n",
1826 +  seq_printf(m, "\tFrame mode:\t\t%u\tMax Frame mode:\t\t%u\n",
1827                     (unsigned int)pIhw->AppData.FrmMode,
1828                     (unsigned int)pIhw->AppData.MaxFrmMode );
1829 -  if(len<=limit)
1830 -    len +=
1831 -      sprintf (buf + len, "\tTrained Path:\t\t%u\tUS Peak Cell Rate:\t%u\n",
1832 +  seq_printf (m, "\tTrained Path:\t\t%u\tUS Peak Cell Rate:\t%u\n",
1833                     (unsigned int)pIhw->AppData.TrainedPath,
1834                     (unsigned int)pIhw->AppData.USConRate*1000/8/53 );
1835 -  if(len<=limit)
1836 -    len +=
1837 -      sprintf (buf + len, "\tTrained Mode:\t\t%u\tSelected Mode:\t\t%u\n",
1838 +  seq_printf (m, "\tTrained Mode:\t\t%u\tSelected Mode:\t\t%u\n",
1839                 (unsigned int) pIhw->AppData.TrainedMode,
1840                 (unsigned int) pIhw->AppData.StdMode);
1841  
1842 -  if(len<=limit)
1843 -    len +=
1844 -      sprintf (buf + len, "\tATUC Vendor Code:\t%X\tATUC Revision:\t%u\n",
1845 +  seq_printf (m, "\tATUC Vendor Code:\t%X\tATUC Revision:\t%u\n",
1846                 (unsigned int) pIhw->AppData.atucVendorId,
1847                 pIhw->AppData.atucRevisionNum);
1848 -  if(len<=limit)
1849 -    len += sprintf(buf+len, "\tHybrid Selected:\t%u\tTrellis:\t\t%u\n",
1850 +  seq_printf(m, "\tHybrid Selected:\t%u\tTrellis:\t\t%u\n",
1851                     (unsigned int)pIhw->AppData.currentHybridNum, trellis);
1852  
1853    //@Added Maximum attainable bit rate information. 05-14-2004
1854 @@ -1581,12 +1565,12 @@ int tn7dsl_proc_stats(char* buf, char **
1855    }
1856    else
1857    {
1858 -     int offset[2] = {5, 1};
1859 +     int dspOffset[2] = { 5, 1 };
1860       unsigned char rMsgsRA[12];
1861       int numPayloadBytes = 0;
1862  
1863      dslhal_api_dspInterfaceRead (pIhw, (unsigned int) pIhw->pmainAddr, 2,
1864 -                                 (unsigned int *) &offset,
1865 +                                 (unsigned int *) &dspOffset,
1866                                   (unsigned char *) &rMsgsRA[0], 12);
1867  
1868       maxRate = (unsigned int)pIhw->AppData.DSConRate;
1869 @@ -1602,294 +1586,223 @@ int tn7dsl_proc_stats(char* buf, char **
1870       }
1871    }
1872  
1873 -  if(len<=limit)
1874 -    len +=
1875 -      sprintf (buf + len,
1876 +  seq_printf (m,
1877                 "\tShowtime Count:\t\t%u\tDS Max Attainable Bit Rate: %u kbps\n",
1878                     (unsigned int)pIhw->AppData.showtimeCount, maxRate);
1879  
1880 -  if(len<=limit)
1881 -  {
1882 -    int offset[2] = {32, 0};
1883 -    unsigned int usBitswap, dsBitswap;
1884 -
1885 -    tn7dsl_generic_read(2, (unsigned int *)&offset);
1886 -    dsBitswap = dslReg & dslhal_support_byteSwap32(0x000000ff);
1887 +  tn7dsl_generic_read(2, (unsigned int *)&offset);
1888 +  dsBitswap = dslReg & dslhal_support_byteSwap32(0x000000ff);
1889  
1890 -    offset[0] = 33;
1891 -    tn7dsl_generic_read(2, (unsigned int *)&offset);
1892 -    usBitswap = dslReg & dslhal_support_byteSwap32(0x000000ff);
1893 +  offset[0] = 33;
1894 +  tn7dsl_generic_read(2, (unsigned int *)&offset);
1895 +  usBitswap = dslReg & dslhal_support_byteSwap32(0x000000ff);
1896  
1897  // UR8_MERGE_START - CQ11579 - Jeremy
1898 -    if((pIhw->AppData.dsl_modulation > 5) && (pIhw->AppData.dsl_modulation != 128))
1899 +  if((pIhw->AppData.dsl_modulation > 5) && (pIhw->AppData.dsl_modulation != 128))
1900  // UR8_MERGE_END - CQ11579 - Jeremy
1901 -      len +=
1902 -        sprintf (buf + len,
1903 +    seq_printf (m,
1904                   "\tBitSwap:\t\t%u\tUS Max Attainable Bit Rate: %u bps\n",
1905                     (unsigned int)(usBitswap && dsBitswap), us_maxRate);
1906 -    else
1907 -      len +=
1908 -        sprintf (buf + len,
1909 +  else
1910 +    seq_printf (m,
1911                   "\tBitSwap:\t\t%u\tUS Max Attainable Bit Rate:\tn/a\n",
1912                     (unsigned int)(usBitswap && dsBitswap));
1913 -  }
1914  
1915  #if 1 // TR69
1916 -  if(len<=limit)
1917 -    len +=
1918 -      sprintf (buf + len, "\tAnnex: \t\t\t%s\tpsd_mask_qualifier: 0x%04x\n",
1919 +  seq_printf (m, "\tAnnex: \t\t\t%s\tpsd_mask_qualifier: 0x%04x\n",
1920               tn7dsl_AnnexFromNum(pIhw->AppData.annex_selected),
1921               pIhw->AppData.psd_mask_qualifier);
1922  
1923  //  UR8_MERGE_START CQ10979   Jack Zhang
1924  //  UR8_MERGE_START CQ10978   Jack Zhang
1925 -  if(len<=limit)
1926 -    len +=
1927 -      sprintf (buf + len, "\tPower Management Status: L%d\tDS HLINSC: %d\n",
1928 +  seq_printf (m, "\tPower Management Status: L%d\tDS HLINSC: %d\n",
1929               pIhw->AppData.pwrStatus, pIhw->AppData.dsHLINSC);
1930  //  UR8_MERGE_END   CQ10978*
1931  
1932 -  if(len<=limit)
1933 -    len +=
1934 -      sprintf (buf + len, "\tUS ACTPSD: \t\t%d\tDS ACTPSD: %d\n",
1935 +  seq_printf (m, "\tUS ACTPSD: \t\t%d\tDS ACTPSD: %d\n",
1936               pIhw->AppData.usACTPSD, pIhw->AppData.dsACTPSD);
1937  
1938 -  if(len<=limit)
1939 -    len +=
1940 -      sprintf (buf + len, "\tTotal init. errors: \t%d\tTotal init. timeouts: %d\n",
1941 +  seq_printf (m, "\tTotal init. errors: \t%d\tTotal init. timeouts: %d\n",
1942               pIhw->AppData.totalInitErrs, pIhw->AppData.totalInitTOs);
1943  
1944 -  if(len<=limit)
1945 -    len +=
1946 -      sprintf (buf + len, "\tShowtime init. errors: \t%d\tShowtime init. timeouts: %d\n",
1947 +  seq_printf (m, "\tShowtime init. errors: \t%d\tShowtime init. timeouts: %d\n",
1948               pIhw->AppData.showtimeInitErrs, pIhw->AppData.showtimeInitTOs);
1949  
1950 -  if(len<=limit)
1951 -    len +=
1952 -      sprintf (buf + len, "\tLast showtime init. errors: %d\tLast showtime init. timeouts: %d\n",
1953 +  seq_printf (m, "\tLast showtime init. errors: %d\tLast showtime init. timeouts: %d\n",
1954               pIhw->AppData.lastshowInitErrs, pIhw->AppData.lastshowInitTOs);
1955  //  UR8_MERGE_END   CQ10979*
1956  
1957 -  if (len<=limit)
1958 -  {
1959 -    len += sprintf(buf+len,"\tATUC ghsVid: ");
1960 -    for (i=0; i<8; i++)
1961 -      len+= sprintf(buf+len, " %02x", pIhw->AppData.ghsATUCVendorId[i]);
1962 -  }
1963 +  seq_printf(m,"\tATUC ghsVid: ");
1964 +  for (i=0; i<8; i++)
1965 +    seq_printf(m, " %02x", pIhw->AppData.ghsATUCVendorId[i]);
1966  
1967 -  if (len<=limit)
1968 -  {
1969 -    len += sprintf (buf + len, "\n");
1970 -  }
1971 +  seq_printf (m, "\n");
1972  
1973 -  if (len <= limit)
1974 -  {
1975 -    len +=
1976 -      sprintf (buf + len,
1977 +  seq_printf (m,
1978                 "\tT1413Vid: %02x %02x\t\tT1413Rev: %02x\t\tVendorRev: %02x\n",
1979                 pIhw->AppData.t1413ATUC.VendorId[0],
1980                 pIhw->AppData.t1413ATUC.VendorId[1],
1981        pIhw->AppData.t1413ATUC.t1413Revision,
1982        pIhw->AppData.t1413ATUC.VendorRevision);
1983 -  }
1984  
1985 -  if (len<=limit)
1986 -  {
1987 -    len += sprintf(buf+len,"\tATUR ghsVid: ");
1988 -    for (i=0; i<8; i++)
1989 -      len+= sprintf(buf+len, " %02x", pIhw->AppData.ghsATURVendorId[i]);
1990 -  }
1991 +  seq_printf(m,"\tATUR ghsVid: ");
1992 +  for (i=0; i<8; i++)
1993 +    seq_printf(m, " %02x", pIhw->AppData.ghsATURVendorId[i]);
1994  
1995 -  if (len<=limit)
1996 -  {
1997 -    len += sprintf (buf + len, "\n");
1998 -  }
1999 +  seq_printf (m, "\n");
2000  
2001 -  if (len <= limit)
2002 -  {
2003 -    len +=
2004 -      sprintf (buf + len,
2005 +  seq_printf (m,
2006                 "\tT1413Vid: %02x %02x\tT1413Rev: %02x\tVendorRev: %02x\n",
2007                 pIhw->AppData.t1413ATUR.VendorId[0],
2008                 pIhw->AppData.t1413ATUR.VendorId[1],
2009        pIhw->AppData.t1413ATUR.t1413Revision,
2010        pIhw->AppData.t1413ATUR.VendorRevision);
2011 -  }
2012  
2013  #ifdef AR7_EFM
2014 -  if (len <= limit)
2015 -  {
2016 -    len += sprintf(buf + len, "\tTC Mode: %s\n",
2017 +  seq_printf(m, "\tTC Mode: %s\n",
2018        (priv->curr_TC_mode == TC_MODE_PTM) ? "PTM" : "ATM");
2019 -  }
2020  #endif
2021  
2022  #endif
2023    /*
2024     * Upstream Interleaved Errors
2025     */
2026 -  if(len<=limit)
2027 -    len += sprintf(buf+len, "\n\t[Upstream (TX) Interleave path]\n");
2028 -  if(len<=limit)
2029 -    len += sprintf(buf+len, "\tCRC: \t%u\tFEC: \t%u\tNCD: \t%u\n",
2030 +  seq_printf(m, "\n\t[Upstream (TX) Interleave path]\n");
2031 +  seq_printf(m, "\tCRC: \t%u\tFEC: \t%u\tNCD: \t%u\n",
2032                     (unsigned int)pIhw->AppData.usICRC_errors,
2033                     (unsigned int)pIhw->AppData.usIFEC_errors,
2034                     (unsigned int)pIhw->AppData.usINCD_error);
2035 -  if(len<=limit)
2036 -    len += sprintf(buf+len, "\tLCD: \t%u\tHEC: \t%u\n",
2037 +  seq_printf(m, "\tLCD: \t%u\tHEC: \t%u\n",
2038                     (unsigned int)pIhw->AppData.usILCD_errors,
2039                     (unsigned int)pIhw->AppData.usIHEC_errors);
2040    /*
2041     * Downstream Interleaved Errors
2042     */
2043 -  if(len<=limit)
2044 -    len += sprintf(buf+len, "\n\t[Downstream (RX) Interleave path]\n");
2045 -  if(len<=limit)
2046 -    len += sprintf(buf+len, "\tCRC: \t%u\tFEC: \t%u\tNCD: \t%u\n",
2047 +  seq_printf(m, "\n\t[Downstream (RX) Interleave path]\n");
2048 +  seq_printf(m, "\tCRC: \t%u\tFEC: \t%u\tNCD: \t%u\n",
2049                     (unsigned int)pIhw->AppData.dsICRC_errors,
2050                     (unsigned int)pIhw->AppData.dsIFEC_errors,
2051                     (unsigned int)pIhw->AppData.dsINCD_error);
2052 -  if(len<=limit)
2053 -    len += sprintf(buf+len, "\tLCD: \t%u\tHEC: \t%u\n",
2054 +  seq_printf(m, "\tLCD: \t%u\tHEC: \t%u\n",
2055                     (unsigned int)pIhw->AppData.dsILCD_errors,
2056                     (unsigned int)pIhw->AppData.dsIHEC_errors);
2057    /*
2058     * Upstream Fast Errors
2059     */
2060 -  if(len<=limit)
2061 -    len += sprintf(buf+len, "\n\t[Upstream (TX) Fast path]\n");
2062 -  if(len<=limit)
2063 -    len += sprintf(buf+len, "\tCRC: \t%u\tFEC: \t%u\tNCD: \t%u\n",
2064 +  seq_printf(m, "\n\t[Upstream (TX) Fast path]\n");
2065 +  seq_printf(m, "\tCRC: \t%u\tFEC: \t%u\tNCD: \t%u\n",
2066                     (unsigned int)pIhw->AppData.usFCRC_errors,
2067                     (unsigned int)pIhw->AppData.usFFEC_errors,
2068                     (unsigned int)pIhw->AppData.usFNCD_error);
2069 -  if(len<=limit)
2070 -    len += sprintf(buf+len, "\tLCD: \t%u\tHEC: \t%u\n",
2071 +  seq_printf(m, "\tLCD: \t%u\tHEC: \t%u\n",
2072                     (unsigned int)pIhw->AppData.usFLCD_errors,
2073                     (unsigned int)pIhw->AppData.usFHEC_errors);
2074    /*
2075     * Downstream Fast Errors
2076     */
2077 -  if(len<=limit)
2078 -    len += sprintf(buf+len, "\n\t[Downstream (RX) Fast path]\n");
2079 -  if(len<=limit)
2080 -    len += sprintf(buf+len, "\tCRC: \t%u\tFEC: \t%u\tNCD: \t%u\n",
2081 +  seq_printf(m, "\n\t[Downstream (RX) Fast path]\n");
2082 +  seq_printf(m, "\tCRC: \t%u\tFEC: \t%u\tNCD: \t%u\n",
2083                     (unsigned int)pIhw->AppData.dsFCRC_errors,
2084                     (unsigned int)pIhw->AppData.dsFFEC_errors,
2085                     (unsigned int)pIhw->AppData.dsFNCD_error);
2086 -  if(len<=limit)
2087 -    len += sprintf(buf+len, "\tLCD: \t%u\tHEC: \t%u\n",
2088 -                   (unsigned int)pIhw->AppData.dsFLCD_errors,
2089 -                   (unsigned int)pIhw->AppData.dsFHEC_errors);
2090 +  seq_printf(m, "\tLCD: \t%u\tHEC: \t%u\n",
2091 +             (unsigned int)pIhw->AppData.dsFLCD_errors,
2092 +             (unsigned int)pIhw->AppData.dsFHEC_errors);
2093  
2094    /*
2095     * ATM stats upstream
2096     */
2097 -  if(len<=limit)
2098 -    len += sprintf(buf+len, "\n[ATM Stats]");
2099 -  if(len<=limit)
2100 -    len += sprintf(buf+len, "\n\t[Upstream/TX]\n");
2101 -  if(len<=limit)
2102 -    len +=
2103 -      sprintf (buf + len, "\tGood Cell Cnt:\t%u\n\tIdle Cell Cnt:\t%u\n\n",
2104 -               (unsigned int) pIhw->AppData.usAtm_count[0] +
2105 -               (unsigned int) pIhw->AppData.usAtm_count[1],
2106 -               (unsigned int) pIhw->AppData.usIdle_count[0] +
2107 -               (unsigned int) pIhw->AppData.usIdle_count[1]);
2108 +  seq_printf(m, "\n[ATM Stats]");
2109 +  seq_printf(m, "\n\t[Upstream/TX]\n");
2110 +  seq_printf (m, "\tGood Cell Cnt:\t%u\n\tIdle Cell Cnt:\t%u\n\n",
2111 +              (unsigned int) pIhw->AppData.usAtm_count[0] +
2112 +              (unsigned int) pIhw->AppData.usAtm_count[1],
2113 +              (unsigned int) pIhw->AppData.usIdle_count[0] +
2114 +              (unsigned int) pIhw->AppData.usIdle_count[1]);
2115  //UR8_MERGE_START CQ10700 Manjula K
2116 -  if (len <= limit)
2117 -    len +=
2118 -      sprintf (buf + len,
2119 +  seq_printf (m,
2120                 "\tTx Packets Dropped Count:\t%lu\n\tTx Bad Packets Count:\t%lu\n",
2121                 priv->stats.tx_dropped, priv->stats.tx_errors);
2122  //UR8_MERGE_END CQ10700
2123    /*
2124     * ATM stats downstream
2125     */
2126 -  if(len<=limit)
2127 -    len += sprintf(buf+len, "\n\t[Downstream/RX)]\n");
2128 -  if(len<=limit)
2129 -    len +=
2130 -      sprintf (buf + len,
2131 -               "\tGood Cell Cnt:\t%u\n\tIdle Cell Cnt:\t%u\n\tBad Hec Cell Cnt:\t%u\n",
2132 -               (unsigned int) pIhw->AppData.dsGood_count[0] +
2133 -               (unsigned int) pIhw->AppData.dsGood_count[1],
2134 -               (unsigned int) pIhw->AppData.dsIdle_count[0] +
2135 -               (unsigned int) pIhw->AppData.dsIdle_count[1],
2136 -               (unsigned int) pIhw->AppData.dsBadHec_count[0] +
2137 -               (unsigned int) pIhw->AppData.dsBadHec_count[1]);
2138 -  if(len<=limit)
2139 -    len += sprintf(buf+len, "\tOverflow Dropped Cell Cnt:\t%u\n",
2140 -                    (unsigned int) pIhw->AppData.dsOVFDrop_count[0] +
2141 -                    (unsigned int) pIhw->AppData.dsOVFDrop_count[1]);
2142 +  seq_printf(m, "\n\t[Downstream/RX)]\n");
2143 +  seq_printf (m,
2144 +              "\tGood Cell Cnt:\t%u\n\tIdle Cell Cnt:\t%u\n\tBad Hec Cell Cnt:\t%u\n",
2145 +              (unsigned int) pIhw->AppData.dsGood_count[0] +
2146 +              (unsigned int) pIhw->AppData.dsGood_count[1],
2147 +              (unsigned int) pIhw->AppData.dsIdle_count[0] +
2148 +              (unsigned int) pIhw->AppData.dsIdle_count[1],
2149 +              (unsigned int) pIhw->AppData.dsBadHec_count[0] +
2150 +              (unsigned int) pIhw->AppData.dsBadHec_count[1]);
2151 +  seq_printf(m, "\tOverflow Dropped Cell Cnt:\t%u\n",
2152 +             (unsigned int) pIhw->AppData.dsOVFDrop_count[0] +
2153 +             (unsigned int) pIhw->AppData.dsOVFDrop_count[1]);
2154  
2155   //UR8_MERGE_START CQ10700 Manjula K
2156 -  if (len <= limit)
2157 -    len +=
2158 -      sprintf (buf + len,
2159 -               "\tRx Packets Dropped Count:\t%lu\n\tRx Bad Packets Count:\t%lu\n\n",
2160 -               priv->stats.rx_dropped, priv->stats.rx_errors);
2161 +  seq_printf (m,
2162 +              "\tRx Packets Dropped Count:\t%lu\n\tRx Bad Packets Count:\t%lu\n\n",
2163 +              priv->stats.rx_dropped, priv->stats.rx_errors);
2164  //UR8_MERGE_END CQ10700
2165  
2166    tn7sar_get_stats(pIhw->pOsContext);
2167 -  if(len<=limit)
2168 -    len += sprintf(buf+len, "\n[SAR AAL5 Stats]\n");
2169 -  if(len<=limit)
2170 -    len += sprintf(buf+len, "\tTx PDU's:\t%u\n\tRx PDU's:\t%u\n",
2171 -                    sarStat.txPktCnt, sarStat.rxPktCnt);
2172 -  if(len<=limit)
2173 -    len +=
2174 -      sprintf (buf + len, "\tTx Total Bytes:\t%u\n\tRx Total Bytes:\t%u\n",
2175 -               sarStat.txBytes, sarStat.rxBytes);
2176 -  if (len <= limit)
2177 -    len +=
2178 -      sprintf (buf + len,
2179 -               "\tTx Total Error Counts:\t%u\n\tRx Total Error Counts:\t%u\n\n",
2180 -               sarStat.txErrors, sarStat.rxErrors);
2181 +  seq_printf(m, "\n[SAR AAL5 Stats]\n");
2182 +  seq_printf(m, "\tTx PDU's:\t%u\n\tRx PDU's:\t%u\n",
2183 +             sarStat.txPktCnt, sarStat.rxPktCnt);
2184 +  seq_printf (m, "\tTx Total Bytes:\t%u\n\tRx Total Bytes:\t%u\n",
2185 +              sarStat.txBytes, sarStat.rxBytes);
2186 +  seq_printf (m,
2187 +              "\tTx Total Error Counts:\t%u\n\tRx Total Error Counts:\t%u\n\n",
2188 +              sarStat.txErrors, sarStat.rxErrors);
2189  
2190    /*
2191     * oam loopback info
2192     */
2193 -  if(len<=limit)
2194 -    len += sprintf(buf+len, "\n[OAM Stats]\n");
2195 +  seq_printf(m, "\n[OAM Stats]\n");
2196  
2197    tn7sar_get_near_end_loopback_count(&F4count, &F5count);
2198  
2199 -  if(len<=limit)
2200 -    {
2201 -    len +=
2202 -      sprintf (buf + len,
2203 -               "\tNear End F5 Loop Back Count:\t%u\n\tNear End F4 Loop Back Count:\t%u\n\tFar End F5 Loop Back Count:\t%u\n\tFar End F4 Loop Back Count:\t%u\n",
2204 +  seq_printf (m,
2205 +              "\tNear End F5 Loop Back Count:\t%u\n\tNear End F4 Loop Back Count:\t%u\n\tFar End F5 Loop Back Count:\t%u\n\tFar End F4 Loop Back Count:\t%u\n",
2206                 F5count, F4count, oamFarLBCount[0] + oamFarLBCount[2],
2207                    oamFarLBCount[1] + oamFarLBCount[3]);
2208 -    }
2209  
2210  #define USE_OAM_DROP_COUNT   //CQ10273
2211    //Read OAM ping responses count:
2212  #ifdef USE_OAM_DROP_COUNT
2213 -  if(len<=limit)
2214 -  {
2215 -  /*  len +=
2216 -      sprintf (buf + len,
2217 -               "\tSAR OAM Retry in 0x%X cycles, Drop Count=%d\n",
2218 -               tn7dsl_get_memory(0xa30085cc), tn7dsl_get_memory(0xa30085c4)); */
2219 +/*  seq_printf (m,
2220 +              "\tSAR OAM Retry in 0x%X cycles, Drop Count=%d\n",
2221 +              tn7dsl_get_memory(0xa30085cc), tn7dsl_get_memory(0xa30085c4)); */
2222  
2223 -    len += sprintf (buf + len, "\tSAR OAM Ping Response Drop Count=%d\n",
2224 -               tn7dsl_get_memory(0xa30085b0));
2225 -  }
2226 +  seq_printf (m, "\tSAR OAM Ping Response Drop Count=%d\n",
2227 +              tn7dsl_get_memory(0xa30085b0));
2228  #endif // USE_OAM_DROP_COUNT
2229  
2230 -  return len;
2231 +  return 0;
2232  }
2233  
2234 -int tn7dsl_proc_modem(char* buf, char **start, off_t offset, int count,
2235 -                 int *eof, void *data)
2236 +static int tn7dsl_proc_stats_open(struct inode *inode, struct file *file)
2237 +{
2238 +       return single_open(file, tn7dsl_proc_stats, PDE_DATA(inode));
2239 +}
2240 +
2241 +int tn7dsl_proc_write_stats(struct file *fp, const char * buf, unsigned long count, void * data);
2242 +
2243 +struct file_operations tn7dsl_proc_stats_fops = {
2244 +       .owner          = THIS_MODULE,
2245 +       .open           = tn7dsl_proc_stats_open,
2246 +       .read           = seq_read,
2247 +       .llseek         = seq_lseek,
2248 +       .release        = single_release,
2249 +       .write          = tn7dsl_proc_write_stats,
2250 +};
2251 +
2252 +static int tn7dsl_proc_modem(struct seq_file *m, void *data)
2253  {
2254  #ifdef AR7_EFM
2255  extern int tn7efm_get_currTCmode(void);
2256  #endif
2257 -  int len = 0;
2258 -  int limit = count - 80;
2259    char *state;
2260    int tag;
2261  
2262 @@ -1923,22 +1836,31 @@ extern int tn7efm_get_currTCmode(void);
2263  
2264    if(pIhw->lConnected == 1)
2265      state = "SHOWTIME";
2266 -  if(len<=limit)
2267 -    len += sprintf(buf+len,"%s\n",state);
2268 -  if(len<=limit)
2269 -    len += sprintf(buf+len, "%d\n", dslReg);
2270 -  if(len<=limit)
2271 -    len += sprintf(buf+len, "failTrains=%d\n", pIhw->AppData.trainFails);
2272 +  seq_printf(m,"%s\n",state);
2273 +  seq_printf(m, "%d\n", dslReg);
2274 +  seq_printf(m, "failTrains=%d\n", pIhw->AppData.trainFails);
2275  
2276  #ifdef AR7_EFM
2277 -  if (len<=limit)
2278 -    len += sprintf(buf+len, "TCMODE=%s\n", 
2279 -      tn7efm_get_currTCmode()== TC_MODE_PTM ? "EFM" : "ATM");
2280 +  seq_printf(m, "TCMODE=%s\n", 
2281 +    tn7efm_get_currTCmode()== TC_MODE_PTM ? "EFM" : "ATM");
2282  #endif
2283  
2284 -  return len;
2285 +  return 0;
2286 +}
2287 +
2288 +static int tn7dsl_proc_modem_open(struct inode *inode, struct file *file)
2289 +{
2290 +       return single_open(file, tn7dsl_proc_modem, PDE_DATA(inode));
2291  }
2292  
2293 +struct file_operations tn7dsl_proc_modem_fops = {
2294 +       .owner          = THIS_MODULE,
2295 +       .open           = tn7dsl_proc_modem_open,
2296 +       .read           = seq_read,
2297 +       .llseek         = seq_lseek,
2298 +       .release        = single_release,
2299 +};
2300 +
2301  /**********************************************************************
2302  **                                                                    *
2303  **  tn7dsl_hdlc_update_crc() -- Calculate CRC                         *
2304 @@ -2203,11 +2125,8 @@ static int tn7dsl_hdlc_rx_process(unsign
2305    return(ret);
2306  }
2307  
2308 -int tn7dsl_proc_eoc (char *buf, char **start, off_t OffSet, int count,
2309 -                     int *eof, void *data)
2310 +static int tn7dsl_proc_eoc (struct seq_file *m, void *data)
2311  {
2312 -  int len = 0;
2313 -  int limit = count - 80;
2314    int offset[2] = {34, 0};  // point to buffer parameter data structure
2315    clearEocParm_t   peoc;
2316  
2317 @@ -2216,62 +2135,49 @@ int tn7dsl_proc_eoc (char *buf, char **s
2318                                 (unsigned char *) &peoc,
2319                                 sizeof (clearEocParm_t));
2320  
2321 -  if (len <= limit)
2322 -     len += sprintf(buf+len, "\nClear EOC Channel:\n\n");
2323 -  if (len <= limit)
2324 -     len += sprintf(buf+len, "  Enabled:\t%d\n", dslhal_support_byteSwap32(peoc.clearEocEnabled));
2325 -  if (len <= limit)
2326 -     len += sprintf(buf+len, "  TxBuf[0]:\t0x%08x\n", dslhal_support_byteSwap32((unsigned int)peoc.pTxBufDesc[0]));
2327 -  if (len <= limit)
2328 -     len += sprintf(buf+len, "  TxBuf[1]:\t0x%08x\n", dslhal_support_byteSwap32((unsigned int)peoc.pTxBufDesc[1]));
2329 -  if (len <= limit)
2330 -     len += sprintf(buf+len, "  TxBuf[2]:\t0x%08x\n", dslhal_support_byteSwap32((unsigned int)peoc.pTxBufDesc[2]));
2331 -  if (len <= limit)
2332 -     len += sprintf(buf+len, "  TxBuf[3]:\t0x%08x\n", dslhal_support_byteSwap32((unsigned int)peoc.pTxBufDesc[3]));
2333 -  if (len <= limit)
2334 -     len += sprintf(buf+len, "  RxBuf[0]:\t0x%08x\n", dslhal_support_byteSwap32((unsigned int)peoc.pRxBufDesc[0]));
2335 -  if (len <= limit)
2336 -     len += sprintf(buf+len, "  RxBuf[1]:\t0x%08x\n", dslhal_support_byteSwap32((unsigned int)peoc.pRxBufDesc[1]));
2337 -  if (len <= limit)
2338 -     len += sprintf(buf+len, "  RxBuf[2]:\t0x%08x\n", dslhal_support_byteSwap32((unsigned int)peoc.pRxBufDesc[2]));
2339 -  if (len <= limit)
2340 -     len += sprintf(buf+len, "  RxBuf[3]:\t0x%08x\n", dslhal_support_byteSwap32((unsigned int)peoc.pRxBufDesc[3]));
2341 -  if (len <= limit)
2342 -     len += sprintf(buf+len, "  txRdIndex:\t%d\n", dslhal_support_byteSwap32(peoc.txRdIndex));
2343 -  if (len <= limit)
2344 -     len += sprintf(buf+len, "  txWrIndex:\t%d\n", dslhal_support_byteSwap32(peoc.txWrIndex));
2345 -  if (len <= limit)
2346 -     len += sprintf(buf+len, "  rxRdIndex:\t%d\n", dslhal_support_byteSwap32(peoc.rxRdIndex));
2347 -  if (len <= limit)
2348 -     len += sprintf(buf+len, "  rxWrIndex:\t%d\n\n", dslhal_support_byteSwap32(peoc.rxWrIndex));
2349 -  if (len <= limit)
2350 -     len += sprintf(buf+len, "  TotalTxPkts:\t%d\n", EocTxTotalPackets);
2351 -  if (len <= limit)
2352 -     len += sprintf(buf+len, "  TotalRxPkts:\t%d\n", EocRxTotalPackets);
2353 -  if (len <= limit)
2354 -     len += sprintf(buf+len, "  TotalTxBytes:\t%d\n", EocTxTotalBytes);
2355 -  if (len <= limit)
2356 -     len += sprintf(buf+len, "  TotalRxBytes:\t%d\n\n", EocRxTotalBytes);
2357 -  if (len <= limit)
2358 -     len += sprintf(buf+len, "  ErrBufFull:\t%d\n", ErrEocBufFull);
2359 -  if (len <= limit)
2360 -     len += sprintf(buf+len, "  ErrBufIndx:\t%d\n", ErrEocBufIndex);
2361 -  if (len <= limit)
2362 -     len += sprintf(buf+len, "  ErrBufMax:\t%d\n", ErrEocBufMax);
2363 -  if (len <= limit)
2364 -     len += sprintf(buf+len, "  ErrMsgMax:\t%d\n", ErrEocMsgOversized);
2365 -  if (len <= limit)
2366 -     len += sprintf(buf+len, "  ErrTxHDLC:\t%d\n", ErrEocTxHdlcCRC);
2367 -  if (len <= limit)
2368 -     len += sprintf(buf+len, "  ErrRxHDLC:\t%d\n", ErrEocRxHdlcCRC);
2369 -  if (len <= limit)
2370 -     len += sprintf(buf+len, "  ErrRxSnmp:\t%d\n", ErrEocRxHdlcFraming);
2371 -  if (len <= limit)
2372 -     len += sprintf(buf+len, "  ErrRxPush:\t%d\n\n", ErrEocRxPush);
2373 +  seq_printf(m, "\nClear EOC Channel:\n\n");
2374 +  seq_printf(m, "  Enabled:\t%d\n", dslhal_support_byteSwap32(peoc.clearEocEnabled));
2375 +  seq_printf(m, "  TxBuf[0]:\t0x%08x\n", dslhal_support_byteSwap32((unsigned int)peoc.pTxBufDesc[0]));
2376 +  seq_printf(m, "  TxBuf[1]:\t0x%08x\n", dslhal_support_byteSwap32((unsigned int)peoc.pTxBufDesc[1]));
2377 +  seq_printf(m, "  TxBuf[2]:\t0x%08x\n", dslhal_support_byteSwap32((unsigned int)peoc.pTxBufDesc[2]));
2378 +  seq_printf(m, "  TxBuf[3]:\t0x%08x\n", dslhal_support_byteSwap32((unsigned int)peoc.pTxBufDesc[3]));
2379 +  seq_printf(m, "  RxBuf[0]:\t0x%08x\n", dslhal_support_byteSwap32((unsigned int)peoc.pRxBufDesc[0]));
2380 +  seq_printf(m, "  RxBuf[1]:\t0x%08x\n", dslhal_support_byteSwap32((unsigned int)peoc.pRxBufDesc[1]));
2381 +  seq_printf(m, "  RxBuf[2]:\t0x%08x\n", dslhal_support_byteSwap32((unsigned int)peoc.pRxBufDesc[2]));
2382 +  seq_printf(m, "  RxBuf[3]:\t0x%08x\n", dslhal_support_byteSwap32((unsigned int)peoc.pRxBufDesc[3]));
2383 +  seq_printf(m, "  txRdIndex:\t%d\n", dslhal_support_byteSwap32(peoc.txRdIndex));
2384 +  seq_printf(m, "  txWrIndex:\t%d\n", dslhal_support_byteSwap32(peoc.txWrIndex));
2385 +  seq_printf(m, "  rxRdIndex:\t%d\n", dslhal_support_byteSwap32(peoc.rxRdIndex));
2386 +  seq_printf(m, "  rxWrIndex:\t%d\n\n", dslhal_support_byteSwap32(peoc.rxWrIndex));
2387 +  seq_printf(m, "  TotalTxPkts:\t%d\n", EocTxTotalPackets);
2388 +  seq_printf(m, "  TotalRxPkts:\t%d\n", EocRxTotalPackets);
2389 +  seq_printf(m, "  TotalTxBytes:\t%d\n", EocTxTotalBytes);
2390 +  seq_printf(m, "  TotalRxBytes:\t%d\n\n", EocRxTotalBytes);
2391 +  seq_printf(m, "  ErrBufFull:\t%d\n", ErrEocBufFull);
2392 +  seq_printf(m, "  ErrBufIndx:\t%d\n", ErrEocBufIndex);
2393 +  seq_printf(m, "  ErrBufMax:\t%d\n", ErrEocBufMax);
2394 +  seq_printf(m, "  ErrMsgMax:\t%d\n", ErrEocMsgOversized);
2395 +  seq_printf(m, "  ErrTxHDLC:\t%d\n", ErrEocTxHdlcCRC);
2396 +  seq_printf(m, "  ErrRxHDLC:\t%d\n", ErrEocRxHdlcCRC);
2397 +  seq_printf(m, "  ErrRxSnmp:\t%d\n", ErrEocRxHdlcFraming);
2398 +  seq_printf(m, "  ErrRxPush:\t%d\n\n", ErrEocRxPush);
2399  
2400 -  return len;
2401 +  return 0;
2402 +}
2403 +
2404 +static int tn7dsl_proc_eoc_open(struct inode *inode, struct file *file)
2405 +{
2406 +       return single_open(file, tn7dsl_proc_eoc, PDE_DATA(inode));
2407  }
2408  
2409 +struct file_operations tn7dsl_proc_eoc_fops = {
2410 +       .owner          = THIS_MODULE,
2411 +       .open           = tn7dsl_proc_eoc_open,
2412 +       .read           = seq_read,
2413 +       .llseek         = seq_lseek,
2414 +       .release        = single_release,
2415 +};
2416 +
2417  int tn7dsl_clear_eoc_setup(void)
2418  {
2419    int   i;
2420 @@ -4624,14 +4530,10 @@ int tn7dsl_proc_write_stats (struct file
2421  }
2422  
2423  
2424 -int tn7dsl_proc_train_mode_export (char *buf, char **start, off_t offset,
2425 -                                   int count, int *eof, void *data)
2426 +static int tn7dsl_proc_train_mode_export (struct seq_file *m, void *data)
2427  {
2428  
2429 -  int len = 0;
2430 -  char *cp = buf + offset;
2431    int i = 0;
2432 -  static int ctr = 0;
2433  
2434    typedef struct
2435    {
2436 @@ -4712,197 +4614,185 @@ int tn7dsl_proc_train_mode_export (char
2437    }
2438  
2439  
2440 -    if(len <= count)
2441 +  for (i = 0; (i < num_entries) ; i++)
2442      {
2443 -        for (i = ctr; ((i < num_entries)&& (len <= count)) ; i++)
2444 -        {
2445 -      /*
2446 -       * Write the current string only if we can fit it into the buffer
2447 -       */
2448 -            if((strlen(dsl_modes[i].mode_name) + 6 + len) <= count)
2449 -        {
2450 -                len += snprintf(cp+len, (count - len), "%s\t\t\t%#x\n",
2451 -                                    dsl_modes[i].mode_name, dsl_modes[i].mode_value);
2452 -            }
2453 -            else
2454 -                break;
2455 -        }
2456 +              seq_printf(m, "%s\t\t\t%#x\n",
2457 +                         dsl_modes[i].mode_name, dsl_modes[i].mode_value);
2458      }
2459  
2460 -  /*
2461 -   * Data was completely written
2462 -   */
2463 -    if (i >= num_entries)
2464 -    {
2465 -    /*
2466 -     * We are done with this
2467 -     */
2468 -        *eof = 1;
2469 -        ctr = 0;
2470 -    }
2471 -    else
2472 -    {
2473 -    /*
2474 -     * We have not been able to write the complete data, and we have to nul
2475 -     * terminate the buffer.
2476 -        */
2477 -        *(cp + len) = '\0';
2478 -
2479 -    /*
2480 -     * Save the value of the counter for the next read for the rest of the
2481 -     * data.
2482 -        */
2483 -        ctr = i;
2484 -    }
2485 -
2486 -    return len;
2487 +    return 0;
2488  }
2489  
2490 -#ifndef NO_ADV_STATS
2491 -int tn7dsl_proc_SNRpsds(char* buf, char **start, off_t offset, int count,int *eof, void *data)
2492 +static int tn7dsl_proc_train_mode_export_open(struct inode *inode, struct file *file)
2493  {
2494 -  int len = 0;
2495 -
2496 +       return single_open(file, tn7dsl_proc_train_mode_export, PDE_DATA(inode));
2497 +}
2498  
2499 +struct file_operations tn7dsl_proc_train_mode_export_fops = {
2500 +       .owner          = THIS_MODULE,
2501 +       .open           = tn7dsl_proc_train_mode_export_open,
2502 +       .read           = seq_read,
2503 +       .llseek         = seq_lseek,
2504 +       .release        = single_release,
2505 +};
2506  
2507 -  int limit = count - 80;
2508 +#ifndef NO_ADV_STATS
2509 +int tn7dsl_proc_SNRpsds(struct seq_file *m, void *data)
2510 +{
2511    int i;
2512    unsigned char SNRpsds[512];
2513  
2514 -  if(len<=limit)
2515 -    len += sprintf(buf+len, "\nAR7 SNRpsds:");
2516 +  seq_printf(m, "\nAR7 SNRpsds:");
2517  
2518    if (dslhal_api_getSNRpsds(pIhw, SNRpsds, 1))
2519    {
2520      dgprintf(4, "dslhal_api_getSNRpsds failed!\n");
2521 -    return len;
2522 +    return -EIO;
2523    }
2524  
2525    for (i=0; i<pIhw->AppData.max_ds_tones; i++)
2526    {
2527      if (!(i%16))
2528      {
2529 -      if(len <=limit)
2530 -        len += sprintf(buf+len, "\n");
2531 +      seq_printf(m, "\n");
2532      }
2533  
2534 -    if(len <=limit)
2535 -      len += sprintf(buf+len, "%d ", (unsigned char)SNRpsds[i]);
2536 +    seq_printf(m, "%d ", (unsigned char)SNRpsds[i]);
2537    }
2538  
2539 -  if(len <=limit)
2540 -    len += sprintf(buf+len, "\n");
2541 +  seq_printf(m, "\n");
2542  
2543  
2544  
2545 -  return len;
2546 +  return 0;
2547 +}
2548 +
2549 +static int tn7dsl_proc_SNRpsds_open(struct inode *inode, struct file *file)
2550 +{
2551 +       return single_open(file, tn7dsl_proc_SNRpsds, PDE_DATA(inode));
2552  }
2553  
2554 +struct file_operations tn7dsl_proc_SNRpsds_fops = {
2555 +       .owner          = THIS_MODULE,
2556 +       .open           = tn7dsl_proc_SNRpsds_open,
2557 +       .read           = seq_read,
2558 +       .llseek         = seq_lseek,
2559 +       .release        = single_release,
2560 +};
2561 +
2562  #endif
2563  
2564  #ifndef NO_ADV_STATS
2565 -int tn7dsl_proc_QLNpsds(char* buf, char **start, off_t offset, int count,int *eof, void *data)
2566 +static int tn7dsl_proc_QLNpsds(struct seq_file *m, void *data)
2567  {
2568 -  int len = 0;
2569 -
2570 -  int limit = count - 80;
2571    unsigned char QLNpsds[512];
2572    int i;
2573  
2574 -  if(len<=limit)
2575 -    len += sprintf(buf+len, "\nAR7 QLNpsds:");
2576 +  seq_printf(m, "\nAR7 QLNpsds:");
2577  
2578    // call API instead of access internal buf directly
2579    if (dslhal_api_getQLNpsds(pIhw, QLNpsds, 0))
2580    {
2581      dgprintf(4, "dslhal_api_getQLNpsds failed!\n");
2582 -    return len;
2583 +    return -EIO;
2584    }
2585  
2586    for (i=0; i<pIhw->AppData.max_ds_tones; i++)
2587    {
2588      if (!(i%16))
2589      {
2590 -      if(len <=limit)
2591 -        len += sprintf(buf+len, "\n");
2592 +      seq_printf(m, "\n");
2593      }
2594  
2595 -    if(len <=limit)
2596 -      len += sprintf(buf+len, "%d ", (unsigned char)QLNpsds[i]);
2597 +    seq_printf(m, "%d ", (unsigned char)QLNpsds[i]);
2598    }
2599  
2600 -  if(len <=limit)
2601 -    len += sprintf(buf+len, "\n");
2602 +  seq_printf(m, "\n");
2603  
2604  
2605 -  return len;
2606 +  return 0;
2607  }
2608 +
2609 +static int tn7dsl_proc_QLNpsds_open(struct inode *inode, struct file *file)
2610 +{
2611 +       return single_open(file, tn7dsl_proc_QLNpsds, PDE_DATA(inode));
2612 +}
2613 +
2614 +struct file_operations tn7dsl_proc_QLNpsds_fops = {
2615 +       .owner          = THIS_MODULE,
2616 +       .open           = tn7dsl_proc_QLNpsds_open,
2617 +       .read           = seq_read,
2618 +       .llseek         = seq_lseek,
2619 +       .release        = single_release,
2620 +};
2621 +
2622  #endif
2623  
2624  //  UR8_MERGE_START CQ10979   Jack Zhang
2625  #ifdef TR69_HLIN_IN
2626  #ifndef NO_ADV_STATS
2627 -int tn7dsl_proc_HLINpsds(char* buf, char **start, off_t offset, int count,int *eof, void *data)
2628 +static int tn7dsl_proc_HLINpsds(struct seq_file *m, void *data)
2629  {
2630 -  int len = 0;
2631 -
2632 -  int limit = count - 80;
2633    short HLINpsds[2*512];
2634    int i;
2635  
2636 -  if(len<=limit)
2637 -    len += sprintf(buf+len, "\nAR7 HLINpsds:");
2638 +  seq_printf(m, "\nAR7 HLINpsds:");
2639  
2640    // call API instead of access internal buf directly
2641    if (dslhal_api_getHLINpsds(pIhw, (unsigned char *)HLINpsds, 1))
2642    {
2643      dgprintf(4, "dslhal_api_getHLINpsds failed!\n");
2644 -    return len;
2645 +    return -EIO;
2646    }
2647  
2648    for (i=0; i<pIhw->AppData.max_ds_tones; i++)
2649    {
2650      if (!(i%8))
2651      {
2652 -      if(len <=limit)
2653 -        len += sprintf(buf+len, "\n");
2654 +      seq_printf(m, "\n");
2655      }
2656  
2657 -    if(len <=limit)
2658 -      len += sprintf(buf+len, "(%d,%d) ", HLINpsds[2*i], HLINpsds[2*i+1]);
2659 +    seq_printf(m, "(%d,%d) ", HLINpsds[2*i], HLINpsds[2*i+1]);
2660    }
2661  
2662 -  if(len <=limit)
2663 -    len += sprintf(buf+len, "\n");
2664 +  seq_printf(m, "\n");
2665  
2666  
2667 -  return len;
2668 +  return 0;
2669  }
2670  
2671 -static int tn7dsl_proc_HLINpsdsIndx(char* buf, char **start, off_t offset, int count,int *eof, void *data, int indx)
2672 +static int tn7dsl_proc_HLINpsds_open(struct inode *inode, struct file *file)
2673  {
2674 -  int len = 0;
2675 +       return single_open(file, tn7dsl_proc_HLINpsds, PDE_DATA(inode));
2676 +}
2677  
2678 -  int limit = count - 80;
2679 +struct file_operations tn7dsl_proc_HLINpsds_fops = {
2680 +       .owner          = THIS_MODULE,
2681 +       .open           = tn7dsl_proc_HLINpsds_open,
2682 +       .read           = seq_read,
2683 +       .llseek         = seq_lseek,
2684 +       .release        = single_release,
2685 +};
2686 +
2687 +static int tn7dsl_proc_HLINpsdsIndx(struct seq_file *m, void *data, int indx)
2688 +{
2689    short HLINpsds[2*512];
2690    int i;
2691    int start=0, dim=128;
2692  
2693 -  if(len<=limit)
2694 -    len += sprintf(buf+len, "\nAR7 HLINpsds: (section %d)", indx);
2695 +  seq_printf(m, "\nAR7 HLINpsds: (section %d)", indx);
2696  
2697    if((indx > 2) && (pIhw->AppData.max_ds_tones <= 256))
2698    {
2699 -    if(len <=limit)
2700 -      len += sprintf(buf+len, "\n[End of data]");
2701 -    return len;
2702 +    seq_printf(m, "\n[End of data]");
2703 +    return 0;
2704    }
2705  
2706    // call API instead of access internal buf directly
2707    if (dslhal_api_getHLINpsds(pIhw, (unsigned char *)HLINpsds, 1))
2708    {
2709      dgprintf(4, "dslhal_api_getHLINpsds failed!\n");
2710 -    return len;
2711 +    return -1;
2712    }
2713  
2714    start = (indx -1) * 128;
2715 @@ -4911,39 +4801,89 @@ static int tn7dsl_proc_HLINpsdsIndx(char
2716    {
2717      if (!(i%8))
2718      {
2719 -      if(len <=limit)
2720 -        len += sprintf(buf+len, "\n%d: ", i);
2721 +      seq_printf(m, "\n%d: ", i);
2722      }
2723  
2724 -    if(len <=limit)
2725 -      len += sprintf(buf+len, "(%d,%d) ", HLINpsds[2*i], HLINpsds[2*i+1]);
2726 +    seq_printf(m, "(%d,%d) ", HLINpsds[2*i], HLINpsds[2*i+1]);
2727    }
2728  
2729 -  if(len <=limit)
2730 -    len += sprintf(buf+len, "\n");
2731 +  seq_printf(m, "\n");
2732  
2733 -  return len;
2734 +  return 0;
2735 +}
2736 +
2737 +static int tn7dsl_proc_HLINpsds1(struct seq_file *m, void *data)
2738 +{
2739 +  return tn7dsl_proc_HLINpsdsIndx(m, data, 1);
2740 +}
2741 +
2742 +static int tn7dsl_proc_HLINpsds2(struct seq_file *m, void *data)
2743 +{
2744 +  return tn7dsl_proc_HLINpsdsIndx(m, data, 2);
2745 +}
2746 +
2747 +static int tn7dsl_proc_HLINpsds3(struct seq_file *m, void *data)
2748 +{
2749 +  return tn7dsl_proc_HLINpsdsIndx(m, data, 3);
2750 +}
2751 +
2752 +static int tn7dsl_proc_HLINpsds4(struct seq_file *m, void *data)
2753 +{
2754 +  return tn7dsl_proc_HLINpsdsIndx(m, data, 4);
2755  }
2756  
2757 -int tn7dsl_proc_HLINpsds1(char* buf, char **start, off_t offset, int count,int *eof, void *data)
2758 +static int tn7dsl_proc_HLINpsds1_open(struct inode *inode, struct file *file)
2759  {
2760 -  return tn7dsl_proc_HLINpsdsIndx(buf, start, offset, count,eof, data, 1);
2761 +       return single_open(file, tn7dsl_proc_HLINpsds1, PDE_DATA(inode));
2762  }
2763  
2764 -int tn7dsl_proc_HLINpsds2(char* buf, char **start, off_t offset, int count,int *eof, void *data)
2765 +static int tn7dsl_proc_HLINpsds2_open(struct inode *inode, struct file *file)
2766  {
2767 -  return tn7dsl_proc_HLINpsdsIndx(buf, start, offset, count,eof, data, 2);
2768 +       return single_open(file, tn7dsl_proc_HLINpsds2, PDE_DATA(inode));
2769  }
2770  
2771 -int tn7dsl_proc_HLINpsds3(char* buf, char **start, off_t offset, int count,int *eof, void *data)
2772 +static int tn7dsl_proc_HLINpsds3_open(struct inode *inode, struct file *file)
2773  {
2774 -  return tn7dsl_proc_HLINpsdsIndx(buf, start, offset, count,eof, data, 3);
2775 +       return single_open(file, tn7dsl_proc_HLINpsds3, PDE_DATA(inode));
2776  }
2777  
2778 -int tn7dsl_proc_HLINpsds4(char* buf, char **start, off_t offset, int count,int *eof, void *data)
2779 +static int tn7dsl_proc_HLINpsds4_open(struct inode *inode, struct file *file)
2780  {
2781 -  return tn7dsl_proc_HLINpsdsIndx(buf, start, offset, count,eof, data, 4);
2782 +       return single_open(file, tn7dsl_proc_HLINpsds4, PDE_DATA(inode));
2783  }
2784 +
2785 +struct file_operations tn7dsl_proc_HLINpsds1_fops = {
2786 +       .owner          = THIS_MODULE,
2787 +       .open           = tn7dsl_proc_HLINpsds1_open,
2788 +       .read           = seq_read,
2789 +       .llseek         = seq_lseek,
2790 +       .release        = single_release,
2791 +};
2792 +
2793 +struct file_operations tn7dsl_proc_HLINpsds2_fops = {
2794 +       .owner          = THIS_MODULE,
2795 +       .open           = tn7dsl_proc_HLINpsds2_open,
2796 +       .read           = seq_read,
2797 +       .llseek         = seq_lseek,
2798 +       .release        = single_release,
2799 +};
2800 +
2801 +struct file_operations tn7dsl_proc_HLINpsds3_fops = {
2802 +       .owner          = THIS_MODULE,
2803 +       .open           = tn7dsl_proc_HLINpsds3_open,
2804 +       .read           = seq_read,
2805 +       .llseek         = seq_lseek,
2806 +       .release        = single_release,
2807 +};
2808 +
2809 +struct file_operations tn7dsl_proc_HLINpsds4_fops = {
2810 +       .owner          = THIS_MODULE,
2811 +       .open           = tn7dsl_proc_HLINpsds4_open,
2812 +       .read           = seq_read,
2813 +       .llseek         = seq_lseek,
2814 +       .release        = single_release,
2815 +};
2816 +
2817  #endif
2818  #endif //TR69_HLIN_IN
2819  //  UR8_MERGE_END   CQ10979*
2820 @@ -4951,64 +4891,48 @@ int tn7dsl_proc_HLINpsds4(char* buf, cha
2821  // *    UR8_MERGE_START CQ11057   Jack Zhang
2822  #ifdef TR69_PMD_IN
2823  #ifndef NO_ADV_STATS
2824 -int tn7dsl_proc_PMDus(char* buf, char **start, off_t offset, int count,int *eof, void *data)
2825 +static int tn7dsl_proc_PMDus(struct seq_file *m, void *data)
2826  {
2827 -  int len = 0;
2828 -
2829 -  int limit = count - 80;
2830    int i;
2831    CoPMDTestParams_t  co_pmdtest_params;
2832  
2833 -  if(len<=limit)
2834 -    len += sprintf(buf+len, "\nAR7 US PMD Test:\n");
2835 +  seq_printf(m, "\nAR7 US PMD Test:\n");
2836  
2837    // call API instead of access internal buf directly
2838    if (dslhal_api_getPMDTestus(pIhw, &co_pmdtest_params, 0) != DSLHAL_ERROR_NO_ERRORS)
2839    {
2840      dgprintf(4, "dslhal_api_getPMDTestus failed!\n");
2841 -    return len;
2842 +    return -EIO;
2843    }
2844  
2845 -  if(len<=limit)
2846 -    len += sprintf(buf+len, "LATN=%d\n", co_pmdtest_params.co_latn);
2847 +  seq_printf(m, "LATN=%d\n", co_pmdtest_params.co_latn);
2848  
2849 -  if(len<=limit)
2850 -    len += sprintf(buf+len, "SATN=%d\n", co_pmdtest_params.co_satn);
2851 +  seq_printf(m, "SATN=%d\n", co_pmdtest_params.co_satn);
2852  
2853 -  if(len<=limit)
2854 -    len += sprintf(buf+len, "SNRM=%d\n", co_pmdtest_params.usMargin);
2855 +  seq_printf(m, "SNRM=%d\n", co_pmdtest_params.usMargin);
2856  
2857 -  if(len<=limit)
2858 -    len += sprintf(buf+len, "attndr=%ld\n", co_pmdtest_params.co_attndr);
2859 +  seq_printf(m, "attndr=%ld\n", co_pmdtest_params.co_attndr);
2860  
2861 -  if(len<=limit)
2862 -    len += sprintf(buf+len, "NearActatp=%d\n", co_pmdtest_params.co_near_actatp);
2863 +  seq_printf(m, "NearActatp=%d\n", co_pmdtest_params.co_near_actatp);
2864  
2865 -  if(len<=limit)
2866 -    len += sprintf(buf+len, "FarActatp=%d\n", co_pmdtest_params.co_far_actatp);
2867 +  seq_printf(m, "FarActatp=%d\n", co_pmdtest_params.co_far_actatp);
2868  
2869    //HLOG
2870    for (i=0; i<pIhw->AppData.max_us_tones; i++)
2871    {
2872      if (!(i%16))
2873 -    {
2874 -      if(len <=limit)
2875 -        len += sprintf(buf+len, "\nHLOG(%3d):", i);
2876 -    }
2877 -    if(len <=limit)
2878 -      len += sprintf(buf+len, " %d", co_pmdtest_params.TestParmCOHlogfMsg[i]);
2879 +      seq_printf(m, "\nHLOG(%3d):", i);
2880 +
2881 +    seq_printf(m, " %d", co_pmdtest_params.TestParmCOHlogfMsg[i]);
2882    }
2883  
2884    //QLN
2885    for (i=0; i<pIhw->AppData.max_us_tones; i++)
2886    {
2887      if (!(i%16))
2888 -    {
2889 -      if(len <=limit)
2890 -        len += sprintf(buf+len, "\nQLN(%3d):", i);
2891 -    }
2892 -    if(len <=limit)
2893 -      len += sprintf(buf+len, " %d", co_pmdtest_params.TestParmCOQLNfMsg[i]);
2894 +      seq_printf(m, "\nQLN(%3d):", i);
2895 +
2896 +    seq_printf(m, " %d", co_pmdtest_params.TestParmCOQLNfMsg[i]);
2897  
2898    }
2899  
2900 @@ -5016,19 +4940,28 @@ int tn7dsl_proc_PMDus(char* buf, char **
2901    for (i=0; i<pIhw->AppData.max_us_tones; i++)
2902    {
2903      if (!(i%16))
2904 -    {
2905 -      if(len <=limit)
2906 -        len += sprintf(buf+len, "\nSNR(%3d):", i);
2907 -    }
2908 -    if(len <=limit)
2909 -      len += sprintf(buf+len, " %d", co_pmdtest_params.TestParmCOSNRfMsg[i]);
2910 +      seq_printf(m, "\nSNR(%3d):", i);
2911 +    seq_printf(m, " %d", co_pmdtest_params.TestParmCOSNRfMsg[i]);
2912    }
2913  
2914 -  if(len <=limit)
2915 -    len += sprintf(buf+len, "\n");
2916 +  seq_printf(m, "\n");
2917  
2918 -  return len;
2919 +  return 0;
2920 +}
2921 +
2922 +static int tn7dsl_proc_PMDus_open(struct inode *inode, struct file *file)
2923 +{
2924 +       return single_open(file, tn7dsl_proc_PMDus, PDE_DATA(inode));
2925  }
2926 +
2927 +struct file_operations tn7dsl_proc_PMDus_fops = {
2928 +       .owner          = THIS_MODULE,
2929 +       .open           = tn7dsl_proc_PMDus_open,
2930 +       .read           = seq_read,
2931 +       .llseek         = seq_lseek,
2932 +       .release        = single_release,
2933 +};
2934 +
2935  #endif //NO_ADV_STATS
2936  #endif //TR69_PMD_IN
2937  // *    UR8_MERGE_END   CQ11057 *
2938 --- a/tn7sar.c
2939 +++ b/tn7sar.c
2940 @@ -1553,44 +1553,70 @@ int tn7sar_oam_generation(void *privCont
2941    return 0;
2942  }
2943  
2944 -int tn7sar_proc_oam_ping(char* buf, char **start, off_t offset, int count,int *eof, void *data)
2945 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
2946 +#define PDE_DATA(inode) PDE(inode)->data
2947 +#endif
2948 +
2949 +static int tn7sar_proc_oam_ping(struct seq_file *m, void *data)
2950  {
2951 -  int len = 0;
2952    unsigned int oam_ps = oamPingStatus;
2953  
2954    if( oam_ps == OAM_PING_PENDING_RECVD )
2955      oam_ps = OAM_PING_PENDING;  //jz  CQ9861: Only export the PENDING status, not internal state
2956  
2957 -  len += sprintf(buf+len, "%d\n", oam_ps); //oamPingStatus);
2958 +  seq_printf(m, "%d\n", oam_ps); //oamPingStatus);
2959  
2960 -  return len;
2961 +  return 0;
2962  }
2963  
2964 -int tn7sar_proc_pvc_table(char* buf, char **start, off_t offset, int count,int *eof, void *data)
2965 +static int tn7sar_proc_oam_ping_open(struct inode *inode, struct file *file)
2966 +{
2967 +       return single_open(file, tn7sar_proc_oam_ping, PDE_DATA(inode));
2968 +}
2969 +
2970 +struct file_operations tn7sar_proc_oam_ping_fops = {
2971 +       .owner          = THIS_MODULE,
2972 +       .open           = tn7sar_proc_oam_ping_open,
2973 +       .read           = seq_read,
2974 +       .llseek         = seq_lseek,
2975 +       .release        = single_release,
2976 +};
2977 +
2978 +
2979 +static int tn7sar_proc_pvc_table(struct seq_file *m, void *data)
2980  {
2981 -  int len = 0;
2982    int i;
2983  
2984    for(i=0;i<16;i++)
2985    {
2986      if(pvc_result[i].bInUse)
2987      {
2988 -      len += sprintf(buf+len, "%d,%d\n", pvc_result[i].vpi,pvc_result[i].vci);
2989 +      seq_printf(m, "%d,%d\n", pvc_result[i].vpi,pvc_result[i].vci);
2990      }
2991      else
2992      {
2993 -      len += sprintf(buf+len, "0,0\n");
2994 +      seq_printf(m, "0,0\n");
2995      }
2996    }
2997 -  return len;
2998 +  return 0;
2999 +}
3000 +
3001 +static int tn7sar_proc_pvc_table_open(struct inode *inode, struct file *file)
3002 +{
3003 +       return single_open(file, tn7sar_proc_pvc_table, PDE_DATA(inode));
3004  }
3005  
3006 +struct file_operations tn7sar_proc_pvc_table_fops = {
3007 +       .owner          = THIS_MODULE,
3008 +       .open           = tn7sar_proc_pvc_table_open,
3009 +       .read           = seq_read,
3010 +       .llseek         = seq_lseek,
3011 +       .release        = single_release,
3012 +};
3013  
3014  
3015 -int tn7sar_proc_sar_stat(char* buf, char **start, off_t offset, int count,int *eof, void *data)
3016 +static int tn7sar_proc_sar_stat(struct seq_file *m, void *data)
3017  {
3018 -  int len = 0;
3019 -  int limit = count - 80;
3020    struct atm_dev *dev;
3021    Tn7AtmPrivate *priv;
3022    int i, j, k;
3023 @@ -1599,21 +1625,19 @@ int tn7sar_proc_sar_stat(char* buf, char
3024    unsigned int *pStateBase, *pSarStat;
3025    HAL_FUNCTIONS *pHalFunc;
3026    HAL_DEVICE    *pHalDev;
3027 -  int dBytes;
3028  
3029 -  dev = (struct atm_dev *)data;
3030 +  dev = (struct atm_dev *)m->private;
3031    priv = (Tn7AtmPrivate *)dev->dev_data;
3032  
3033    pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
3034    pHalDev  = (HAL_DEVICE *)priv->pSarHalDev;
3035  
3036 -  len += sprintf(buf+len, "SAR HAL Statistics");
3037 +  seq_printf(m, "SAR HAL Statistics");
3038    for(i=0;i<MAX_DMA_CHAN;i++)
3039    {
3040      if(priv->lut[i].inuse)
3041      {
3042 -      if(len<=limit)
3043 -      len += sprintf(buf+len, "\nChannel %d:\n",priv->lut[i].chanid);
3044 +      seq_printf(m, "\nChannel %d:\n",priv->lut[i].chanid);
3045        k=0;
3046        for(j=0;j<4;j++)
3047        {
3048 @@ -1626,26 +1650,16 @@ int tn7sar_proc_sar_stat(char* buf, char
3049          {
3050            if((char *)*pSarStat == NULL)
3051              break;
3052 -          if(len<=limit)
3053 -          {
3054 -            dBytes = sprintf(buf+len, "%s: ",(char *) *pSarStat);
3055 -            len += dBytes;
3056 -            k += dBytes;
3057 -          }
3058 +
3059 +          k += seq_printf(m, "%s: ",(char *) *pSarStat);
3060            pSarStat++;
3061 -          if(len<=limit)
3062 -          {
3063 -            dBytes = sprintf(buf+len, "%s;  \n",(char *) *pSarStat);
3064 -            len += dBytes;
3065 -            k += dBytes;
3066 -          }
3067 +          k += seq_printf(m, "%s;  \n",(char *) *pSarStat);
3068            pSarStat++;
3069  
3070            if(k > 60)
3071            {
3072              k=0;
3073 -            if(len<=limit)
3074 -            len += sprintf(buf+len, "\n");
3075 +            seq_printf(m, "\n");
3076            }
3077          }
3078  
3079 @@ -1654,9 +1668,22 @@ int tn7sar_proc_sar_stat(char* buf, char
3080      }
3081    }
3082  
3083 -  return len;
3084 +  return 0;
3085  }
3086  
3087 +static int tn7sar_proc_sar_stat_open(struct inode *inode, struct file *file)
3088 +{
3089 +       return single_open(file, tn7sar_proc_sar_stat, PDE_DATA(inode));
3090 +}
3091 +
3092 +struct file_operations tn7sar_proc_sar_stat_fops = {
3093 +       .owner          = THIS_MODULE,
3094 +       .open           = tn7sar_proc_sar_stat_open,
3095 +       .read           = seq_read,
3096 +       .llseek         = seq_lseek,
3097 +       .release        = single_release,
3098 +};
3099 +
3100  #ifdef AR7_EFM
3101  void tn7sar_get_EFM_firmware_version(unsigned int *pdsp_version_ms, unsigned int *pdsp_version_ls)
3102  {