From ba25f9dcc4ea6e30839fcab5a5516f2176d5bfed Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Thu, 18 Oct 2007 23:40:40 -0700 Subject: Use helpers to obtain task pid in printks The task_struct->pid member is going to be deprecated, so start using the helpers (task_pid_nr/task_pid_vnr/task_pid_nr_ns) in the kernel. The first thing to start with is the pid, printed to dmesg - in this case we may safely use task_pid_nr(). Besides, printks produce more (much more) than a half of all the explicit pid usage. [akpm@linux-foundation.org: git-drm went and changed lots of stuff] Signed-off-by: Pavel Emelyanov Cc: Dave Airlie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/drm/drm_bufs.c | 2 +- drivers/char/drm/drm_drv.c | 2 +- drivers/char/drm/drm_fops.c | 7 ++++--- drivers/char/drm/drm_lock.c | 6 +++--- drivers/char/drm/drm_os_linux.h | 2 +- drivers/char/drm/i810_dma.c | 2 +- drivers/char/drm/i830_dma.c | 2 +- drivers/char/sx.c | 2 +- drivers/char/tty_io.c | 6 +++--- 9 files changed, 16 insertions(+), 15 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c index 856774fbe02..d24a6c2c2c2 100644 --- a/drivers/char/drm/drm_bufs.c +++ b/drivers/char/drm/drm_bufs.c @@ -1456,7 +1456,7 @@ int drm_freebufs(struct drm_device *dev, void *data, buf = dma->buflist[idx]; if (buf->file_priv != file_priv) { DRM_ERROR("Process %d freeing buffer not owned\n", - current->pid); + task_pid_nr(current)); return -EINVAL; } drm_free_buffer(dev, buf); diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c index 72668b15e5c..44a46268b02 100644 --- a/drivers/char/drm/drm_drv.c +++ b/drivers/char/drm/drm_drv.c @@ -463,7 +463,7 @@ int drm_ioctl(struct inode *inode, struct file *filp, ++file_priv->ioctl_count; DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n", - current->pid, cmd, nr, + task_pid_nr(current), cmd, nr, (long)old_encode_dev(file_priv->head->device), file_priv->authenticated); diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c index f383fc37190..3992f73299c 100644 --- a/drivers/char/drm/drm_fops.c +++ b/drivers/char/drm/drm_fops.c @@ -234,7 +234,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp, if (!drm_cpu_valid()) return -EINVAL; - DRM_DEBUG("pid = %d, minor = %d\n", current->pid, minor); + DRM_DEBUG("pid = %d, minor = %d\n", task_pid_nr(current), minor); priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES); if (!priv) @@ -244,7 +244,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp, filp->private_data = priv; priv->filp = filp; priv->uid = current->euid; - priv->pid = current->pid; + priv->pid = task_pid_nr(current); priv->minor = minor; priv->head = drm_heads[minor]; priv->ioctl_count = 0; @@ -339,7 +339,8 @@ int drm_release(struct inode *inode, struct file *filp) */ DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n", - current->pid, (long)old_encode_dev(file_priv->head->device), + task_pid_nr(current), + (long)old_encode_dev(file_priv->head->device), dev->open_count); if (dev->driver->reclaim_buffers_locked && dev->lock.hw_lock) { diff --git a/drivers/char/drm/drm_lock.c b/drivers/char/drm/drm_lock.c index c6b73e744d6..bea2a7d5b2b 100644 --- a/drivers/char/drm/drm_lock.c +++ b/drivers/char/drm/drm_lock.c @@ -58,12 +58,12 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv) if (lock->context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", - current->pid, lock->context); + task_pid_nr(current), lock->context); return -EINVAL; } DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", - lock->context, current->pid, + lock->context, task_pid_nr(current), dev->lock.hw_lock->lock, lock->flags); if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE)) @@ -153,7 +153,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv) if (lock->context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", - current->pid, lock->context); + task_pid_nr(current), lock->context); return -EINVAL; } diff --git a/drivers/char/drm/drm_os_linux.h b/drivers/char/drm/drm_os_linux.h index 114e54e0f61..76e44ac94fb 100644 --- a/drivers/char/drm/drm_os_linux.h +++ b/drivers/char/drm/drm_os_linux.h @@ -7,7 +7,7 @@ #include /** Current process ID */ -#define DRM_CURRENTPID current->pid +#define DRM_CURRENTPID task_pid_nr(current) #define DRM_SUSER(p) capable(CAP_SYS_ADMIN) #define DRM_UDELAY(d) udelay(d) /** Read a byte from a MMIO region */ diff --git a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c index 8e841bdee6d..eb381a7c5be 100644 --- a/drivers/char/drm/i810_dma.c +++ b/drivers/char/drm/i810_dma.c @@ -1024,7 +1024,7 @@ static int i810_getbuf(struct drm_device *dev, void *data, retcode = i810_dma_get_buffer(dev, d, file_priv); DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n", - current->pid, retcode, d->granted); + task_pid_nr(current), retcode, d->granted); sarea_priv->last_dispatch = (int)hw_status[5]; diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c index 43a1f78712d..69a363edb0d 100644 --- a/drivers/char/drm/i830_dma.c +++ b/drivers/char/drm/i830_dma.c @@ -1409,7 +1409,7 @@ static int i830_getbuf(struct drm_device *dev, void *data, retcode = i830_dma_get_buffer(dev, d, file_priv); DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n", - current->pid, retcode, d->granted); + task_pid_nr(current), retcode, d->granted); sarea_priv->last_dispatch = (int)hw_status[5]; diff --git a/drivers/char/sx.c b/drivers/char/sx.c index 85a23283dff..a6e1c9ba121 100644 --- a/drivers/char/sx.c +++ b/drivers/char/sx.c @@ -1467,7 +1467,7 @@ static int sx_open(struct tty_struct *tty, struct file *filp) line = tty->index; sx_dprintk(SX_DEBUG_OPEN, "%d: opening line %d. tty=%p ctty=%p, " - "np=%d)\n", current->pid, line, tty, + "np=%d)\n", task_pid_nr(current), line, tty, current->signal->tty, sx_nports); if ((line < 0) || (line >= SX_NPORTS) || (line >= sx_nports)) diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index e4054494713..13a53575a01 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -3530,7 +3530,7 @@ void __do_SAK(struct tty_struct *tty) do_each_pid_task(session, PIDTYPE_SID, p) { printk(KERN_NOTICE "SAK: killed process %d" " (%s): task_session_nr(p)==tty->session\n", - p->pid, p->comm); + task_pid_nr(p), p->comm); send_sig(SIGKILL, p, 1); } while_each_pid_task(session, PIDTYPE_SID, p); /* Now kill any processes that happen to have the @@ -3540,7 +3540,7 @@ void __do_SAK(struct tty_struct *tty) if (p->signal->tty == tty) { printk(KERN_NOTICE "SAK: killed process %d" " (%s): task_session_nr(p)==tty->session\n", - p->pid, p->comm); + task_pid_nr(p), p->comm); send_sig(SIGKILL, p, 1); continue; } @@ -3560,7 +3560,7 @@ void __do_SAK(struct tty_struct *tty) filp->private_data == tty) { printk(KERN_NOTICE "SAK: killed process %d" " (%s): fd#%d opened to the tty\n", - p->pid, p->comm, i); + task_pid_nr(p), p->comm, i); force_sig(SIGKILL, p); break; } -- cgit v1.2.3-18-g5258