* [PATCH v1 1/4] dmaengine: hsu: Finish conversion to managed resources
@ 2022-07-13 17:22 Andy Shevchenko
2022-07-13 17:22 ` [PATCH v1 2/4] dmaengine: hsu: using for_each_set_bit to simplify the code Andy Shevchenko
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-07-13 17:22 UTC (permalink / raw)
To: Andy Shevchenko, dmaengine, linux-kernel; +Cc: Vinod Koul
With help of devm_add_action_or_reset() we may finish conversion
the driver to use managed resources.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/dma/hsu/pci.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/drivers/dma/hsu/pci.c b/drivers/dma/hsu/pci.c
index 6a2df3dd78d0..4ed6a4ef1512 100644
--- a/drivers/dma/hsu/pci.c
+++ b/drivers/dma/hsu/pci.c
@@ -47,8 +47,14 @@ static irqreturn_t hsu_pci_irq(int irq, void *dev)
return IRQ_RETVAL(ret);
}
+static void hsu_pci_dma_remove(void *chip)
+{
+ hsu_dma_remove(chip);
+}
+
static int hsu_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
+ struct device *dev = &pdev->dev;
struct hsu_dma_chip *chip;
int ret;
@@ -87,9 +93,13 @@ static int hsu_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
if (ret)
return ret;
- ret = request_irq(chip->irq, hsu_pci_irq, 0, "hsu_dma_pci", chip);
+ ret = devm_add_action_or_reset(dev, hsu_pci_dma_remove, chip);
if (ret)
- goto err_register_irq;
+ return ret;
+
+ ret = devm_request_irq(dev, chip->irq, hsu_pci_irq, 0, "hsu_dma_pci", chip);
+ if (ret)
+ return ret;
/*
* On Intel Tangier B0 and Anniedale the interrupt line, disregarding
@@ -105,18 +115,6 @@ static int hsu_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
pci_set_drvdata(pdev, chip);
return 0;
-
-err_register_irq:
- hsu_dma_remove(chip);
- return ret;
-}
-
-static void hsu_pci_remove(struct pci_dev *pdev)
-{
- struct hsu_dma_chip *chip = pci_get_drvdata(pdev);
-
- free_irq(chip->irq, chip);
- hsu_dma_remove(chip);
}
static const struct pci_device_id hsu_pci_id_table[] = {
@@ -130,7 +128,6 @@ static struct pci_driver hsu_pci_driver = {
.name = "hsu_dma_pci",
.id_table = hsu_pci_id_table,
.probe = hsu_pci_probe,
- .remove = hsu_pci_remove,
};
module_pci_driver(hsu_pci_driver);
--
2.35.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 2/4] dmaengine: hsu: using for_each_set_bit to simplify the code
2022-07-13 17:22 [PATCH v1 1/4] dmaengine: hsu: Finish conversion to managed resources Andy Shevchenko
@ 2022-07-13 17:22 ` Andy Shevchenko
2022-07-13 17:22 ` [PATCH v1 3/4] dmaengine: hsu: Use GENMASK() consistently Andy Shevchenko
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-07-13 17:22 UTC (permalink / raw)
To: Andy Shevchenko, dmaengine, linux-kernel; +Cc: Vinod Koul
It's more cleanly to use for_each_set_bit() instead of opencoding it.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/dma/hsu/pci.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/dma/hsu/pci.c b/drivers/dma/hsu/pci.c
index 4ed6a4ef1512..8cdf715a7e9e 100644
--- a/drivers/dma/hsu/pci.c
+++ b/drivers/dma/hsu/pci.c
@@ -26,22 +26,19 @@
static irqreturn_t hsu_pci_irq(int irq, void *dev)
{
struct hsu_dma_chip *chip = dev;
- u32 dmaisr;
- u32 status;
+ unsigned long dmaisr;
unsigned short i;
+ u32 status;
int ret = 0;
int err;
dmaisr = readl(chip->regs + HSU_PCI_DMAISR);
- for (i = 0; i < chip->hsu->nr_channels; i++) {
- if (dmaisr & 0x1) {
- err = hsu_dma_get_status(chip, i, &status);
- if (err > 0)
- ret |= 1;
- else if (err == 0)
- ret |= hsu_dma_do_irq(chip, i, status);
- }
- dmaisr >>= 1;
+ for_each_set_bit(i, &dmaisr, chip->hsu->nr_channels) {
+ err = hsu_dma_get_status(chip, i, &status);
+ if (err > 0)
+ ret |= 1;
+ else if (err == 0)
+ ret |= hsu_dma_do_irq(chip, i, status);
}
return IRQ_RETVAL(ret);
--
2.35.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 3/4] dmaengine: hsu: Use GENMASK() consistently
2022-07-13 17:22 [PATCH v1 1/4] dmaengine: hsu: Finish conversion to managed resources Andy Shevchenko
2022-07-13 17:22 ` [PATCH v1 2/4] dmaengine: hsu: using for_each_set_bit to simplify the code Andy Shevchenko
@ 2022-07-13 17:22 ` Andy Shevchenko
2022-07-13 17:22 ` [PATCH v1 4/4] dmaengine: hsu: Include headers we are direct user of Andy Shevchenko
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-07-13 17:22 UTC (permalink / raw)
To: Andy Shevchenko, dmaengine, linux-kernel; +Cc: Vinod Koul
For the masks replace chain of BIT() macros by GENMASK().
While at it, explicitly include bits.h.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/dma/hsu/hsu.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/dma/hsu/hsu.h b/drivers/dma/hsu/hsu.h
index 9e5956345748..1c1195709c2f 100644
--- a/drivers/dma/hsu/hsu.h
+++ b/drivers/dma/hsu/hsu.h
@@ -10,6 +10,7 @@
#ifndef __DMA_HSU_H__
#define __DMA_HSU_H__
+#include <linux/bits.h>
#include <linux/spinlock.h>
#include <linux/dma/hsu.h>
@@ -36,11 +37,11 @@
/* Bits in HSU_CH_SR */
#define HSU_CH_SR_DESCTO(x) BIT(8 + (x))
-#define HSU_CH_SR_DESCTO_ANY (BIT(11) | BIT(10) | BIT(9) | BIT(8))
+#define HSU_CH_SR_DESCTO_ANY GENMASK(11, 8)
#define HSU_CH_SR_CHE BIT(15)
#define HSU_CH_SR_DESCE(x) BIT(16 + (x))
-#define HSU_CH_SR_DESCE_ANY (BIT(19) | BIT(18) | BIT(17) | BIT(16))
-#define HSU_CH_SR_CDESC_ANY (BIT(31) | BIT(30))
+#define HSU_CH_SR_DESCE_ANY GENMASK(19, 16)
+#define HSU_CH_SR_CDESC_ANY GENMASK(31, 30)
/* Bits in HSU_CH_CR */
#define HSU_CH_CR_CHA BIT(0)
--
2.35.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 4/4] dmaengine: hsu: Include headers we are direct user of
2022-07-13 17:22 [PATCH v1 1/4] dmaengine: hsu: Finish conversion to managed resources Andy Shevchenko
2022-07-13 17:22 ` [PATCH v1 2/4] dmaengine: hsu: using for_each_set_bit to simplify the code Andy Shevchenko
2022-07-13 17:22 ` [PATCH v1 3/4] dmaengine: hsu: Use GENMASK() consistently Andy Shevchenko
@ 2022-07-13 17:22 ` Andy Shevchenko
2022-08-23 15:07 ` [PATCH v1 1/4] dmaengine: hsu: Finish conversion to managed resources Andy Shevchenko
2022-09-04 17:19 ` Vinod Koul
4 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-07-13 17:22 UTC (permalink / raw)
To: Andy Shevchenko, dmaengine, linux-kernel; +Cc: Vinod Koul
For the sake of integrity, include headers we are direct user of.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/dma/hsu/hsu.c | 8 ++++++++
drivers/dma/hsu/hsu.h | 5 ++++-
drivers/dma/hsu/pci.c | 1 +
include/linux/dma/hsu.h | 6 ++++--
include/linux/platform_data/dma-hsu.h | 2 +-
5 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/drivers/dma/hsu/hsu.c b/drivers/dma/hsu/hsu.c
index 92caae55aece..af5a2e252c25 100644
--- a/drivers/dma/hsu/hsu.c
+++ b/drivers/dma/hsu/hsu.c
@@ -16,12 +16,20 @@
* port 3, and so on.
*/
+#include <linux/bits.h>
#include <linux/delay.h>
+#include <linux/device.h>
#include <linux/dmaengine.h>
#include <linux/dma-mapping.h>
#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/list.h>
#include <linux/module.h>
+#include <linux/percpu-defs.h>
+#include <linux/scatterlist.h>
#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/spinlock.h>
#include "hsu.h"
diff --git a/drivers/dma/hsu/hsu.h b/drivers/dma/hsu/hsu.h
index 1c1195709c2f..3bca577b98a1 100644
--- a/drivers/dma/hsu/hsu.h
+++ b/drivers/dma/hsu/hsu.h
@@ -11,7 +11,10 @@
#define __DMA_HSU_H__
#include <linux/bits.h>
-#include <linux/spinlock.h>
+#include <linux/container_of.h>
+#include <linux/io.h>
+#include <linux/types.h>
+
#include <linux/dma/hsu.h>
#include "../virt-dma.h"
diff --git a/drivers/dma/hsu/pci.c b/drivers/dma/hsu/pci.c
index 8cdf715a7e9e..0fcc0c0c22fc 100644
--- a/drivers/dma/hsu/pci.c
+++ b/drivers/dma/hsu/pci.c
@@ -10,6 +10,7 @@
#include <linux/bitops.h>
#include <linux/device.h>
+#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/pci.h>
diff --git a/include/linux/dma/hsu.h b/include/linux/dma/hsu.h
index a6b7bc707356..77ea602c287c 100644
--- a/include/linux/dma/hsu.h
+++ b/include/linux/dma/hsu.h
@@ -8,11 +8,13 @@
#ifndef _DMA_HSU_H
#define _DMA_HSU_H
-#include <linux/device.h>
-#include <linux/interrupt.h>
+#include <linux/errno.h>
+#include <linux/kconfig.h>
+#include <linux/types.h>
#include <linux/platform_data/dma-hsu.h>
+struct device;
struct hsu_dma;
/**
diff --git a/include/linux/platform_data/dma-hsu.h b/include/linux/platform_data/dma-hsu.h
index c65b412b2b33..611bae193c1c 100644
--- a/include/linux/platform_data/dma-hsu.h
+++ b/include/linux/platform_data/dma-hsu.h
@@ -8,7 +8,7 @@
#ifndef _PLATFORM_DATA_DMA_HSU_H
#define _PLATFORM_DATA_DMA_HSU_H
-#include <linux/device.h>
+struct device;
struct hsu_dma_slave {
struct device *dma_dev;
--
2.35.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/4] dmaengine: hsu: Finish conversion to managed resources
2022-07-13 17:22 [PATCH v1 1/4] dmaengine: hsu: Finish conversion to managed resources Andy Shevchenko
` (2 preceding siblings ...)
2022-07-13 17:22 ` [PATCH v1 4/4] dmaengine: hsu: Include headers we are direct user of Andy Shevchenko
@ 2022-08-23 15:07 ` Andy Shevchenko
2022-09-04 17:19 ` Vinod Koul
4 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-08-23 15:07 UTC (permalink / raw)
To: dmaengine, linux-kernel; +Cc: Vinod Koul
On Wed, Jul 13, 2022 at 08:22:32PM +0300, Andy Shevchenko wrote:
> With help of devm_add_action_or_reset() we may finish conversion
> the driver to use managed resources.
Vinod, can these be applied?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/4] dmaengine: hsu: Finish conversion to managed resources
2022-07-13 17:22 [PATCH v1 1/4] dmaengine: hsu: Finish conversion to managed resources Andy Shevchenko
` (3 preceding siblings ...)
2022-08-23 15:07 ` [PATCH v1 1/4] dmaengine: hsu: Finish conversion to managed resources Andy Shevchenko
@ 2022-09-04 17:19 ` Vinod Koul
4 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2022-09-04 17:19 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: dmaengine, linux-kernel
On 13-07-22, 20:22, Andy Shevchenko wrote:
> With help of devm_add_action_or_reset() we may finish conversion
> the driver to use managed resources.
Applied all, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-09-04 17:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-13 17:22 [PATCH v1 1/4] dmaengine: hsu: Finish conversion to managed resources Andy Shevchenko
2022-07-13 17:22 ` [PATCH v1 2/4] dmaengine: hsu: using for_each_set_bit to simplify the code Andy Shevchenko
2022-07-13 17:22 ` [PATCH v1 3/4] dmaengine: hsu: Use GENMASK() consistently Andy Shevchenko
2022-07-13 17:22 ` [PATCH v1 4/4] dmaengine: hsu: Include headers we are direct user of Andy Shevchenko
2022-08-23 15:07 ` [PATCH v1 1/4] dmaengine: hsu: Finish conversion to managed resources Andy Shevchenko
2022-09-04 17:19 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).