From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from wolverine02.qualcomm.com ([199.106.114.251]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XtBh1-0001RC-Np for ath10k@lists.infradead.org; Tue, 25 Nov 2014 08:41:52 +0000 From: Kalle Valo Subject: Re: [PATCH v2 2/2] ath10k: add memory dump debugfs interface References: <20141124164037.29422.14033.stgit@potku.adurom.net> <20141124164208.29422.76134.stgit@potku.adurom.net> Date: Tue, 25 Nov 2014 10:41:25 +0200 In-Reply-To: <20141124164208.29422.76134.stgit@potku.adurom.net> (Kalle Valo's message of "Mon, 24 Nov 2014 18:42:08 +0200") Message-ID: <87r3wr1xl6.fsf@kamboji.qca.qualcomm.com> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "ath10k" Errors-To: ath10k-bounces+kvalo=adurom.com@lists.infradead.org To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org Kalle Valo writes: > +static ssize_t ath10k_mem_value_read(struct file *file, > + char __user *user_buf, > + size_t count, loff_t *ppos) > +{ > + struct ath10k *ar = file->private_data; > + u8 *buf; > + int ret; > + > + if (*ppos < 0) > + return -EINVAL; > + > + if (!count) > + return 0; > + > + buf = vmalloc(count); > + if (!buf) > + return -ENOMEM; > + > + ret = ath10k_hif_diag_read(ar, *ppos, buf, count); > + if (ret) { > + ath10k_warn(ar, "failed to read address 0x%08x via diagnose window from debugfs: %d\n", > + (u32)(*ppos), ret); > + goto read_err; > + } > + [...] > +static ssize_t ath10k_mem_value_write(struct file *file, > + const char __user *user_buf, > + size_t count, loff_t *ppos) > +{ > + struct ath10k *ar = file->private_data; > + u8 *buf; > + int ret; > + > + if (*ppos < 0) > + return -EINVAL; > + > + if (!count) > + return 0; > + > + buf = vmalloc(count); > + if (!buf) > + return -ENOMEM; > + > + ret = copy_from_user(buf, user_buf, count); > + if (ret) > + goto err_free_copy; > + > + ret = ath10k_hif_diag_write(ar, *ppos, buf, count); > + if (ret) { > + ath10k_warn(ar, "failed to write address 0x%08x via diagnose window from debugfs: %d\n", > + (u32)(*ppos), ret); > + goto err_free_copy; > + } In these two functions we also need to check ar->state. -- Kalle Valo _______________________________________________ ath10k mailing list ath10k@lists.infradead.org http://lists.infradead.org/mailman/listinfo/ath10k