Loading drivers/power/qcom/msm-pm.c +33 −12 Original line number Diff line number Diff line /* Copyright (c) 2010-2016, The Linux Foundation. All rights reserved. /* Copyright (c) 2010-2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -87,6 +87,7 @@ static long *msm_pc_debug_counters; static cpumask_t retention_cpus; static DEFINE_SPINLOCK(retention_lock); static DEFINE_MUTEX(msm_pc_debug_mutex); static bool msm_pm_is_L1_writeback(void) { Loading Loading @@ -678,33 +679,48 @@ static ssize_t msm_pc_debug_counters_file_read(struct file *file, char __user *bufu, size_t count, loff_t *ppos) { struct msm_pc_debug_counters_buffer *data; ssize_t ret; mutex_lock(&msm_pc_debug_mutex); data = file->private_data; if (!data) return -EINVAL; if (!data) { ret = -EINVAL; goto exit; } if (!bufu) return -EINVAL; if (!bufu) { ret = -EINVAL; goto exit; } if (!access_ok(VERIFY_WRITE, bufu, count)) return -EFAULT; if (!access_ok(VERIFY_WRITE, bufu, count)) { ret = -EFAULT; goto exit; } if (*ppos >= data->len && data->len == 0) data->len = msm_pc_debug_counters_copy(data); return simple_read_from_buffer(bufu, count, ppos, ret = simple_read_from_buffer(bufu, count, ppos, data->buf, data->len); exit: mutex_unlock(&msm_pc_debug_mutex); return ret; } static int msm_pc_debug_counters_file_open(struct inode *inode, struct file *file) { struct msm_pc_debug_counters_buffer *buf; int ret = 0; mutex_lock(&msm_pc_debug_mutex); if (!inode->i_private) return -EINVAL; if (!inode->i_private) { ret = -EINVAL; goto exit; } file->private_data = kzalloc( sizeof(struct msm_pc_debug_counters_buffer), GFP_KERNEL); Loading @@ -713,19 +729,24 @@ static int msm_pc_debug_counters_file_open(struct inode *inode, pr_err("%s: ERROR kmalloc failed to allocate %zu bytes\n", __func__, sizeof(struct msm_pc_debug_counters_buffer)); return -ENOMEM; ret = -ENOMEM; goto exit; } buf = file->private_data; buf->reg = (long *)inode->i_private; return 0; exit: mutex_unlock(&msm_pc_debug_mutex); return ret; } static int msm_pc_debug_counters_file_close(struct inode *inode, struct file *file) { mutex_lock(&msm_pc_debug_mutex); kfree(file->private_data); mutex_unlock(&msm_pc_debug_mutex); return 0; } Loading Loading
drivers/power/qcom/msm-pm.c +33 −12 Original line number Diff line number Diff line /* Copyright (c) 2010-2016, The Linux Foundation. All rights reserved. /* Copyright (c) 2010-2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -87,6 +87,7 @@ static long *msm_pc_debug_counters; static cpumask_t retention_cpus; static DEFINE_SPINLOCK(retention_lock); static DEFINE_MUTEX(msm_pc_debug_mutex); static bool msm_pm_is_L1_writeback(void) { Loading Loading @@ -678,33 +679,48 @@ static ssize_t msm_pc_debug_counters_file_read(struct file *file, char __user *bufu, size_t count, loff_t *ppos) { struct msm_pc_debug_counters_buffer *data; ssize_t ret; mutex_lock(&msm_pc_debug_mutex); data = file->private_data; if (!data) return -EINVAL; if (!data) { ret = -EINVAL; goto exit; } if (!bufu) return -EINVAL; if (!bufu) { ret = -EINVAL; goto exit; } if (!access_ok(VERIFY_WRITE, bufu, count)) return -EFAULT; if (!access_ok(VERIFY_WRITE, bufu, count)) { ret = -EFAULT; goto exit; } if (*ppos >= data->len && data->len == 0) data->len = msm_pc_debug_counters_copy(data); return simple_read_from_buffer(bufu, count, ppos, ret = simple_read_from_buffer(bufu, count, ppos, data->buf, data->len); exit: mutex_unlock(&msm_pc_debug_mutex); return ret; } static int msm_pc_debug_counters_file_open(struct inode *inode, struct file *file) { struct msm_pc_debug_counters_buffer *buf; int ret = 0; mutex_lock(&msm_pc_debug_mutex); if (!inode->i_private) return -EINVAL; if (!inode->i_private) { ret = -EINVAL; goto exit; } file->private_data = kzalloc( sizeof(struct msm_pc_debug_counters_buffer), GFP_KERNEL); Loading @@ -713,19 +729,24 @@ static int msm_pc_debug_counters_file_open(struct inode *inode, pr_err("%s: ERROR kmalloc failed to allocate %zu bytes\n", __func__, sizeof(struct msm_pc_debug_counters_buffer)); return -ENOMEM; ret = -ENOMEM; goto exit; } buf = file->private_data; buf->reg = (long *)inode->i_private; return 0; exit: mutex_unlock(&msm_pc_debug_mutex); return ret; } static int msm_pc_debug_counters_file_close(struct inode *inode, struct file *file) { mutex_lock(&msm_pc_debug_mutex); kfree(file->private_data); mutex_unlock(&msm_pc_debug_mutex); return 0; } Loading