Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5255200yba; Mon, 13 May 2019 07:55:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwt9cexaQu5WJdKBz1G23BhpimgD7NNYlNgKPm5U4RxEYj37uNXLjjruNonxWoGNsV9lpR X-Received: by 2002:a62:450e:: with SMTP id s14mr17029792pfa.255.1557759308067; Mon, 13 May 2019 07:55:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557759308; cv=none; d=google.com; s=arc-20160816; b=D+345Jiontlv7PY+TPKkJtoiiUL5A9Z6O6JGfcTi14sOfNPmEQJdcfDRjBy9sabbBb sI1D3G43yctEOMt0WqqNvsJbkCYJ3HLrME1m+ngcMeuHhFGQxb3nX/lVQRqESeCWJFQw kKko2U2e+XAyx0Drhd6WZobNKTsqbUTf3z8w9wovr8U8Us3TGWpWhCG6QWAfQwlgb4iO peX9VxlXdLFo7MrSG1XN1iQ9/xWPkODxmkCoWG96Wn/ohJUDZeMROHHQ+oDTSsmZ8a4W oNLFXg4bZyQF4bd2cl0hprwQBHh+kHnGKK5Zh1wxjxSmXfzUVdx4ByxOyj0NYfXjeOYZ +UGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=PQAI6siW4cNO+sOH4gruinsFaRFo34gNIcs15+r5RiM=; b=aMEPSJVa1m4LOHDGPD40mCyfHfWfGRjtZvdcgxfrFQVaPU6t8EX83oGEiZ6uZDlBSf iMuSi945MoDtFuN966dcYrAuTTFZCis2887a0eG0DpIGWz5CaSKoLrB+TmlwvWtw9odP 9pm8LDbrNmvTuBeaXoqjsvqmuKxHVFRmlzhR5+8Hvj+dSBX+1GJnQAAxVf6txnEAp43p T7fAy67ztWE+65a+oxVFBL9/eU0n9D4OO6aKxuoaLgcEWQ0NxduFxfHlMK2vo4QlrtTp udaoh5AYurWLwGzAemWFvgC+VYU5lRmQV9JRZtDroVbzfnjtQmmZ4cN+/P74Rm+aRs+t MKjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ql2hmnxF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x21si2915694pfa.48.2019.05.13.07.54.51; Mon, 13 May 2019 07:55:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ql2hmnxF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729771AbfEMNoK (ORCPT + 99 others); Mon, 13 May 2019 09:44:10 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:36766 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729751AbfEMNoJ (ORCPT ); Mon, 13 May 2019 09:44:09 -0400 Received: by mail-pg1-f194.google.com with SMTP id a3so6819448pgb.3 for ; Mon, 13 May 2019 06:44:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PQAI6siW4cNO+sOH4gruinsFaRFo34gNIcs15+r5RiM=; b=ql2hmnxF9nJL0x8AgT95ZpQIxKW1hydgHFKjBe+CmdJjYztyN4k0pX/KfJst2CQptn vvjH/ah7nWDZYWTyERZA7NMSwcPwiD51DZnWj//nrd5UdolSqRp9IB0GeXZ/vrldSM8q lShhOkJceU1Dkqv4bKDLqaSkE25tcX96o9UWSgk9Y8ybhFzd6nTneUw/5xZ08TRcnY8W jCFnEEQRDBBpG/w8s7cN1SoVkBpe/Mro2eToylKQ3LexaTx9iIHd7tCmUid6xv2JxSrI pdZ7RoIdi4i5rFZLoccOE+BcDycMlcq6yCJEL7T8iv8CBamwJXB3aVmCmPeI1fk5KRnF YLDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PQAI6siW4cNO+sOH4gruinsFaRFo34gNIcs15+r5RiM=; b=PyzFpIF5MvO/S4r+VwpAveztt7/A4+s+qxZDnsI6BKkUeU4pM4eJqMo6SXFLDp+eVk kH/IXfpUOvYkExjKBSkwGE8wUtynO7R012JO6VNNy+Tai0RrcaRPd7SU08Y+QKSt1Wi9 Ljad5tI70NORaSPtug0pNm8TPh55UxLVQk34Rf8N9AfNaqhTEo4uqLlUQ1j9CuD6KD6c 3a4PQXO1eeb9VCemXUgOlIXP/lQtza0RQW8gmtKd4Z452F4YvbHIdq9CBnxpBI4O+U+N dtv0EkKvWGAdJM9bpcSvxtufF7q128KxJZfD69KUXe7yek99sTKo9zzdyyA4BGBm1Vmj KDHw== X-Gm-Message-State: APjAAAUmF+3tR/ZZmHavSmN2S1JzNjwfW8wsACAIOk5E2VqCGXJ+X+zO zCTvwwx0emZhGLi2CaMW+fY= X-Received: by 2002:a63:fb45:: with SMTP id w5mr31297379pgj.397.1557755048248; Mon, 13 May 2019 06:44:08 -0700 (PDT) Received: from bnva-HP-Pavilion-g6-Notebook-PC.domain.name ([117.248.72.152]) by smtp.gmail.com with ESMTPSA id e10sm10874261pfm.137.2019.05.13.06.44.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 06:44:07 -0700 (PDT) From: Vandana BN To: dan.carpenter@oracle.com, gregkh@linuxfoundation.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, lukas.bulwahn@gmail.com Cc: skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, Vandana BN Subject: [PATCH v4 6/8] Staging: kpc2000: kpc_dma: Resolve warning Missing blank line after declarations & labels not to be indented. Date: Mon, 13 May 2019 19:13:25 +0530 Message-Id: <20190513134327.26320-6-bnvandana@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513134327.26320-1-bnvandana@gmail.com> References: <20190510193833.1051-1-bnvandana@gmail.com> <20190513134327.26320-1-bnvandana@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch resloves below warnings reported by checkpath in kpc_dma WARNING: Missing a blank line after declarations WARNING: labels should not be indented CHECK: Please don't use multiple blank lines CHECK: Please use a blank line after function/struct/union/enum declarations Signed-off-by: Vandana BN --- v2 - split changes to multiple patches v3 - edit commit message, subject line v4 - edit commit message drivers/staging/kpc2000/kpc_dma/dma.c | 8 +++++--- drivers/staging/kpc2000/kpc_dma/fileops.c | 11 ++++++++++- drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c | 15 ++++++++------- drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h | 8 ++++++-- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/dma.c b/drivers/staging/kpc2000/kpc_dma/dma.c index 2053316009bc..ac842fa38c64 100644 --- a/drivers/staging/kpc2000/kpc_dma/dma.c +++ b/drivers/staging/kpc2000/kpc_dma/dma.c @@ -27,6 +27,7 @@ void ndd_irq_worker(struct work_struct *ws) { struct kpc_dma_descriptor *cur; struct kpc_dma_device *eng = container_of(ws, struct kpc_dma_device, irq_work); + lock_engine(eng); if (GetEngineCompletePtr(eng) == 0) @@ -67,7 +68,6 @@ void ndd_irq_worker(struct work_struct *ws) unlock_engine(eng); } - /********** DMA Engine Init/Teardown **********/ void start_dma_engine(struct kpc_dma_device *eng) { @@ -91,6 +91,7 @@ int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt) dma_addr_t head_handle; unsigned int i; int rv; + dev_dbg(&eng->pldev->dev, "Setting up DMA engine [%p]\n", eng); caps = GetEngineCapabilities(eng); @@ -159,6 +160,7 @@ int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt) void stop_dma_engine(struct kpc_dma_device *eng) { unsigned long timeout; + dev_dbg(&eng->pldev->dev, "Destroying DMA engine [%p]\n", eng); // Disable the descriptor engine @@ -220,6 +222,7 @@ void destroy_dma_engine(struct kpc_dma_device *eng) for (i = 0 ; i < eng->desc_pool_cnt ; i++) { struct kpc_dma_descriptor *next = cur->Next; dma_addr_t next_handle = cur->DescNextDescPtr; + dma_pool_free(eng->desc_pool, cur, cur_handle); cur_handle = next_handle; cur = next; @@ -230,13 +233,12 @@ void destroy_dma_engine(struct kpc_dma_device *eng) free_irq(eng->irq, eng); } - - /********** Helper Functions **********/ int count_descriptors_available(struct kpc_dma_device *eng) { u32 count = 0; struct kpc_dma_descriptor *cur = eng->desc_next; + while (cur != eng->desc_completed) { BUG_ON(cur == NULL); count++; diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index c09147aaa4ef..13c0e532437e 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -21,6 +21,7 @@ unsigned int count_pages(unsigned long iov_base, size_t iov_len) { unsigned long first = (iov_base & PAGE_MASK) >> PAGE_SHIFT; unsigned long last = ((iov_base+iov_len-1) & PAGE_MASK) >> PAGE_SHIFT; + return last - first + 1; } @@ -28,6 +29,7 @@ static inline unsigned int count_parts_for_sge(struct scatterlist *sg) { unsigned int sg_length = sg_dma_len(sg); + sg_length += (0x80000-1); return (sg_length / 0x80000); } @@ -262,6 +264,7 @@ int kpc_dma_open(struct inode *inode, struct file *filp) { struct dev_private_data *priv; struct kpc_dma_device *ldev = kpc_dma_lookup_device(iminor(inode)); + if (ldev == NULL) return -ENODEV; @@ -287,6 +290,7 @@ int kpc_dma_close(struct inode *inode, struct file *filp) struct kpc_dma_descriptor *cur; struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; struct kpc_dma_device *eng = priv->ldev; + dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_close(inode = [%p], filp = [%p]) priv = [%p], ldev = [%p]\n", inode, filp, priv, priv->ldev); lock_engine(eng); @@ -321,6 +325,7 @@ static int kpc_dma_aio_cancel(struct kiocb *kcb) { struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; + dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_aio_cancel(kcb = [%p]) priv = [%p], ldev = [%p]\n", kcb, priv, priv->ldev); return 0; } @@ -329,6 +334,7 @@ static ssize_t kpc_dma_aio_read(struct kiocb *kcb, const struct iovec *iov, unsigned long iov_count, loff_t pos) { struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; + dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_aio_read(kcb = [%p], iov = [%p], iov_count = %ld, pos = %lld) priv = [%p], ldev = [%p]\n", kcb, iov, iov_count, pos, priv, priv->ldev); if (priv->ldev->dir != DMA_FROM_DEVICE) @@ -348,6 +354,7 @@ static ssize_t kpc_dma_aio_write(struct kiocb *kcb, const struct iovec *iov, unsigned long iov_count, loff_t pos) { struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; + dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_aio_write(kcb = [%p], iov = [%p], iov_count = %ld, pos = %lld) priv = [%p], ldev = [%p]\n", kcb, iov, iov_count, pos, priv, priv->ldev); if (priv->ldev->dir != DMA_TO_DEVICE) @@ -368,6 +375,7 @@ static ssize_t kpc_dma_read(struct file *filp, char __user *user_buf, size_t count, loff_t *ppos) { struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; + dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_read(filp = [%p], user_buf = [%p], count = %zu, ppos = [%p]) priv = [%p], ldev = [%p]\n", filp, user_buf, count, ppos, priv, priv->ldev); if (priv->ldev->dir != DMA_FROM_DEVICE) @@ -380,6 +388,7 @@ static ssize_t kpc_dma_write(struct file *filp, const char __user *user_buf, size_t count, loff_t *ppos) { struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; + dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_write(filp = [%p], user_buf = [%p], count = %zu, ppos = [%p]) priv = [%p], ldev = [%p]\n", filp, user_buf, count, ppos, priv, priv->ldev); if (priv->ldev->dir != DMA_TO_DEVICE) @@ -392,6 +401,7 @@ static long kpc_dma_ioctl(struct file *filp, unsigned int ioctl_num, unsigned long ioctl_param) { struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; + dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_ioctl(filp = [%p], ioctl_num = 0x%x, ioctl_param = 0x%lx) priv = [%p], ldev = [%p]\n", filp, ioctl_num, ioctl_param, priv, priv->ldev); switch (ioctl_num) { @@ -408,7 +418,6 @@ long kpc_dma_ioctl(struct file *filp, unsigned int ioctl_num, unsigned long ioc return -ENOTTY; } - struct file_operations kpc_dma_fops = { .owner = THIS_MODULE, .open = kpc_dma_open, diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c index e996ced77bd6..135428e62f8e 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c @@ -19,11 +19,11 @@ static DEFINE_MUTEX(kpc_dma_mtx); static int assigned_major_num; static LIST_HEAD(kpc_dma_list); - /********** kpc_dma_list list management **********/ struct kpc_dma_device *kpc_dma_lookup_device(int minor) { struct kpc_dma_device *c; + mutex_lock(&kpc_dma_mtx); list_for_each_entry(c, &kpc_dma_list, list) { if (c->pldev->id == minor) { @@ -31,7 +31,7 @@ struct kpc_dma_device *kpc_dma_lookup_device(int minor) } } c = NULL; // not-found case - out: +out: mutex_unlock(&kpc_dma_mtx); return c; } @@ -55,6 +55,7 @@ static ssize_t show_engine_regs(struct device *dev, struct device_attribute *at { struct kpc_dma_device *ldev; struct platform_device *pldev = to_platform_device(dev); + if (!pldev) return 0; ldev = platform_get_drvdata(pldev); @@ -89,7 +90,6 @@ static const struct attribute *ndd_attr_list[] = { struct class *kpc_dma_class; - /********** Platform Driver Functions **********/ static int kpc_dma_probe(struct platform_device *pldev) @@ -99,6 +99,7 @@ int kpc_dma_probe(struct platform_device *pldev) dev_t dev; struct kpc_dma_device *ldev = kzalloc(sizeof(struct kpc_dma_device), GFP_KERNEL); + if (!ldev) { dev_err(&pldev->dev, "kpc_dma_probe: unable to kzalloc space for kpc_dma_device\n"); rv = -ENOMEM; @@ -178,6 +179,7 @@ static int kpc_dma_remove(struct platform_device *pldev) { struct kpc_dma_device *ldev = platform_get_drvdata(pldev); + if (!ldev) return -ENXIO; @@ -193,7 +195,6 @@ int kpc_dma_remove(struct platform_device *pldev) return 0; } - /********** Driver Functions **********/ struct platform_driver kpc_dma_plat_driver_i = { .probe = kpc_dma_probe, @@ -231,11 +232,11 @@ int __init kpc_dma_driver_init(void) return err; - fail_platdriver_register: +fail_platdriver_register: class_destroy(kpc_dma_class); - fail_class_create: +fail_class_create: __unregister_chrdev(KPC_DMA_CHAR_MAJOR, 0, KPC_DMA_NUM_MINORS, "kpc_dma"); - fail_chrdev_register: +fail_chrdev_register: return err; } module_init(kpc_dma_driver_init); diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h index 8101601736a2..cf781940ac1b 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h @@ -18,7 +18,6 @@ #include #include "../kpc.h" - struct kp2000_device; struct kpc_dma_device { struct list_head list; @@ -157,15 +156,18 @@ void WriteEngineControl(struct kpc_dma_device *eng, u32 value) { writel(value, eng->eng_regs + 1); } + static inline u32 GetEngineControl(struct kpc_dma_device *eng) { return readl(eng->eng_regs + 1); } + static inline void SetClearEngineControl(struct kpc_dma_device *eng, u32 set_bits, u32 clear_bits) { u32 val = GetEngineControl(eng); + val |= set_bits; val &= ~clear_bits; WriteEngineControl(eng, val); @@ -176,16 +178,19 @@ void SetEngineNextPtr(struct kpc_dma_device *eng, struct kpc_dma_descriptor *de { writel(desc->MyDMAAddr, eng->eng_regs + 2); } + static inline void SetEngineSWPtr(struct kpc_dma_device *eng, struct kpc_dma_descriptor *desc) { writel(desc->MyDMAAddr, eng->eng_regs + 3); } + static inline void ClearEngineCompletePtr(struct kpc_dma_device *eng) { writel(0, eng->eng_regs + 4); } + static inline u32 GetEngineCompletePtr(struct kpc_dma_device *eng) { @@ -206,7 +211,6 @@ void unlock_engine(struct kpc_dma_device *eng) mutex_unlock(&eng->sem); } - /// Shared Functions void start_dma_engine(struct kpc_dma_device *eng); int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt); -- 2.17.1