Commit 4d8e8d21de89ff9d86b83182f723129533aacaa9

Authored by Al Viro
1 parent 03b642a701

hysdn: stash pointer to card into proc_dir_entry->data

no need to search later - we know the card when we are
creating procfs entries

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Showing 2 changed files with 18 additions and 85 deletions Side-by-side Diff

drivers/isdn/hysdn/hysdn_procconf.c
... ... @@ -229,23 +229,12 @@
229 229 hysdn_conf_open(struct inode *ino, struct file *filep)
230 230 {
231 231 hysdn_card *card;
232   - struct proc_dir_entry *pd;
233 232 struct conf_writedata *cnf;
234 233 char *cp, *tmp;
235 234  
236 235 /* now search the addressed card */
237 236 mutex_lock(&hysdn_conf_mutex);
238   - card = card_root;
239   - while (card) {
240   - pd = card->procconf;
241   - if (pd == PDE(ino))
242   - break;
243   - card = card->next; /* search next entry */
244   - }
245   - if (!card) {
246   - mutex_unlock(&hysdn_conf_mutex);
247   - return (-ENODEV); /* device is unknown/invalid */
248   - }
  237 + card = PDE(ino)->data;
249 238 if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL))
250 239 hysdn_addlog(card, "config open for uid=%d gid=%d mode=0x%x",
251 240 filep->f_cred->fsuid, filep->f_cred->fsgid,
252 241  
... ... @@ -317,21 +306,9 @@
317 306 hysdn_card *card;
318 307 struct conf_writedata *cnf;
319 308 int retval = 0;
320   - struct proc_dir_entry *pd;
321 309  
322 310 mutex_lock(&hysdn_conf_mutex);
323   - /* search the addressed card */
324   - card = card_root;
325   - while (card) {
326   - pd = card->procconf;
327   - if (pd == PDE(ino))
328   - break;
329   - card = card->next; /* search next entry */
330   - }
331   - if (!card) {
332   - mutex_unlock(&hysdn_conf_mutex);
333   - return (-ENODEV); /* device is unknown/invalid */
334   - }
  311 + card = PDE(ino)->data;
335 312 if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL))
336 313 hysdn_addlog(card, "config close for uid=%d gid=%d mode=0x%x",
337 314 filep->f_cred->fsuid, filep->f_cred->fsgid,
338 315  
... ... @@ -394,10 +371,11 @@
394 371 while (card) {
395 372  
396 373 sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid);
397   - if ((card->procconf = (void *) proc_create(conf_name,
  374 + if ((card->procconf = (void *) proc_create_data(conf_name,
398 375 S_IFREG | S_IRUGO | S_IWUSR,
399 376 hysdn_proc_entry,
400   - &conf_fops)) != NULL) {
  377 + &conf_fops,
  378 + card)) != NULL) {
401 379 hysdn_proclog_init(card); /* init the log file entry */
402 380 }
403 381 card = card->next; /* next entry */
drivers/isdn/hysdn/hysdn_proclog.c
... ... @@ -173,27 +173,14 @@
173 173 {
174 174 struct log_data *inf;
175 175 int len;
176   - struct proc_dir_entry *pde = PDE(file_inode(file));
177   - struct procdata *pd = NULL;
178   - hysdn_card *card;
  176 + hysdn_card *card = PDE(file_inode(file))->data;
179 177  
180 178 if (!*((struct log_data **) file->private_data)) {
  179 + struct procdata *pd = card->proclog;
181 180 if (file->f_flags & O_NONBLOCK)
182 181 return (-EAGAIN);
183 182  
184   - /* sorry, but we need to search the card */
185   - card = card_root;
186   - while (card) {
187   - pd = card->proclog;
188   - if (pd->log == pde)
189   - break;
190   - card = card->next; /* search next entry */
191   - }
192   - if (card)
193   - interruptible_sleep_on(&(pd->rd_queue));
194   - else
195   - return (-EAGAIN);
196   -
  183 + interruptible_sleep_on(&(pd->rd_queue));
197 184 }
198 185 if (!(inf = *((struct log_data **) file->private_data)))
199 186 return (0);
200 187  
201 188  
202 189  
... ... @@ -215,27 +202,15 @@
215 202 static int
216 203 hysdn_log_open(struct inode *ino, struct file *filep)
217 204 {
218   - hysdn_card *card;
219   - struct procdata *pd = NULL;
220   - unsigned long flags;
  205 + hysdn_card *card = PDE(ino)->data;
221 206  
222 207 mutex_lock(&hysdn_log_mutex);
223   - card = card_root;
224   - while (card) {
225   - pd = card->proclog;
226   - if (pd->log == PDE(ino))
227   - break;
228   - card = card->next; /* search next entry */
229   - }
230   - if (!card) {
231   - mutex_unlock(&hysdn_log_mutex);
232   - return (-ENODEV); /* device is unknown/invalid */
233   - }
234   - filep->private_data = card; /* remember our own card */
235   -
236 208 if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) {
237 209 /* write only access -> write log level only */
  210 + filep->private_data = card; /* remember our own card */
238 211 } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
  212 + struct procdata *pd = card->proclog;
  213 + unsigned long flags;
239 214  
240 215 /* read access -> log/debug read */
241 216 spin_lock_irqsave(&card->hysdn_lock, flags);
242 217  
... ... @@ -275,21 +250,13 @@
275 250 } else {
276 251 /* read access -> log/debug read, mark one further file as closed */
277 252  
278   - pd = NULL;
279 253 inf = *((struct log_data **) filep->private_data); /* get first log entry */
280 254 if (inf)
281 255 pd = (struct procdata *) inf->proc_ctrl; /* still entries there */
282 256 else {
283 257 /* no info available -> search card */
284   - card = card_root;
285   - while (card) {
286   - pd = card->proclog;
287   - if (pd->log == PDE(ino))
288   - break;
289   - card = card->next; /* search next entry */
290   - }
291   - if (card)
292   - pd = card->proclog; /* pointer to procfs log */
  258 + card = PDE(file_inode(filep))->data;
  259 + pd = card->proclog; /* pointer to procfs log */
293 260 }
294 261 if (pd)
295 262 pd->if_used--; /* decrement interface usage count by one */
296 263  
... ... @@ -319,24 +286,12 @@
319 286 hysdn_log_poll(struct file *file, poll_table *wait)
320 287 {
321 288 unsigned int mask = 0;
322   - struct proc_dir_entry *pde = PDE(file_inode(file));
323   - hysdn_card *card;
324   - struct procdata *pd = NULL;
  289 + hysdn_card *card = PDE(file_inode(file))->data;
  290 + struct procdata *pd = card->proclog;
325 291  
326 292 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE)
327 293 return (mask); /* no polling for write supported */
328 294  
329   - /* we need to search the card */
330   - card = card_root;
331   - while (card) {
332   - pd = card->proclog;
333   - if (pd->log == pde)
334   - break;
335   - card = card->next; /* search next entry */
336   - }
337   - if (!card)
338   - return (mask); /* card not found */
339   -
340 295 poll_wait(file, &(pd->rd_queue), wait);
341 296  
342 297 if (*((struct log_data **) file->private_data))
343 298  
... ... @@ -373,9 +328,9 @@
373 328  
374 329 if ((pd = kzalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) {
375 330 sprintf(pd->log_name, "%s%d", PROC_LOG_BASENAME, card->myid);
376   - pd->log = proc_create(pd->log_name,
  331 + pd->log = proc_create_data(pd->log_name,
377 332 S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry,
378   - &log_fops);
  333 + &log_fops, card);
379 334  
380 335 init_waitqueue_head(&(pd->rd_queue));
381 336