Re: [PATCH 2/4] staging: iio: ad9832: add SPDX identifier

2019-04-01 Thread Mukesh Ojha



On 4/1/2019 10:43 PM, Greg KH wrote:

On Mon, Apr 01, 2019 at 08:36:50PM +0530, Mukesh Ojha wrote:

On 4/1/2019 8:07 PM, Marcelo Schmitt wrote:

Add SPDX identifier of GPL-2.0 for the ad9832 driver.

Signed-off-by: Marcelo Schmitt 
---
   drivers/staging/iio/frequency/ad9832.c | 3 +--
   1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/iio/frequency/ad9832.c 
b/drivers/staging/iio/frequency/ad9832.c
index 50a583020072..d8d4a7936275 100644
--- a/drivers/staging/iio/frequency/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0

FYI

Use C notations here as per https://lkml.org/lkml/2019/2/13/570.



Once you fix it then you can take mine
Reviewed-by: Mukesh Ojha 

Did you read the documentation about how to put a proper SPDX line in
the kernel documentation?  For .c files, you have to use "//", not "/* */"

Please read:
Documentation/process/license-rules.rst
and see the section "Style" for all of the details.

Thanks for the detail Greg.

Missed the fact.

Reviewed-by: Mukesh Ojha 

Cheers,
-Mukesh



thanks,

greg k-h

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/4] staging: iio: ad9832: add SPDX identifier

2019-04-01 Thread Greg KH
On Mon, Apr 01, 2019 at 08:36:50PM +0530, Mukesh Ojha wrote:
> 
> On 4/1/2019 8:07 PM, Marcelo Schmitt wrote:
> > Add SPDX identifier of GPL-2.0 for the ad9832 driver.
> > 
> > Signed-off-by: Marcelo Schmitt 
> > ---
> >   drivers/staging/iio/frequency/ad9832.c | 3 +--
> >   1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/staging/iio/frequency/ad9832.c 
> > b/drivers/staging/iio/frequency/ad9832.c
> > index 50a583020072..d8d4a7936275 100644
> > --- a/drivers/staging/iio/frequency/ad9832.c
> > +++ b/drivers/staging/iio/frequency/ad9832.c
> > @@ -1,9 +1,8 @@
> > +// SPDX-License-Identifier: GPL-2.0
> 
> FYI
> 
> Use C notations here as per https://lkml.org/lkml/2019/2/13/570.
> 
> 
> 
> Once you fix it then you can take mine
> Reviewed-by: Mukesh Ojha 

Did you read the documentation about how to put a proper SPDX line in
the kernel documentation?  For .c files, you have to use "//", not "/* */"

Please read:
Documentation/process/license-rules.rst
and see the section "Style" for all of the details.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: Work on iio: stating: frequency: ad9832

2019-04-01 Thread Jonathan Cameron
On Mon, 1 Apr 2019 11:25:29 -0300
Marcelo Schmitt  wrote:

> Hello,
> 
> I was looking for some work on staging: iio: ad9832 and made some
> observations while reading the driver.
> 
> Apparently it had no devicetree documentation so I tried to elaborate
> one. 
> It uses a platform_data variable to load external clock
> frequency (I tried to make it use linux's clock framework).
Good.

> Some device attributes don't seem to be standardized on
> Documentation/ABI/testing/sysfs-bus-iio and there's no specific ABI
> for ad9832 nearby nor at staging/iio/Documentation. So maybe those
> missing ABI could be documented.
Beware. It's an old driver, so it may be that we actually want to change
it's ABI rather than documenting what is there (I have haven't looked!)

> The device has to set some internal registers to operate correctly,
> AD9832_FREQXHM and AD9832_PHASEXH, would it be feasible to set iio
> chanels for this?

What are they?  If they correspond to output channels in some sensible
way then maybe...

> I couldn't understand why checkpatch.pl gave errors on IIO_DEV_ATTR_*
> macros. To me they seem to have no problem.
> Also it has that platform_data to be moved to include/linux/iio. Is
> there any special reason for it not being there already? Which are
> the criterions a platform_data need to satisfy to be put there?
A driver moving out of staging shouldn't have platform data. It needs
to be converted over to more modern mechanisms.   We don't have a problem
supporting platform data for devices that have old school device files
already in tree, but that shouldn't be the case for a driver in staging.

Hence we can clean it up and move forward with just DT bindings.
> 
> I'm sending a patchset with some things I've already done.
Cool. I'll look at those later in the week if no one beats me to them.

> 
> Is there something else that could be done in this device driver?
> Please, tell if I've forgotten something.

I'll take a look, but it may be a little while before I do.
Hopefully someone else gets there first!

Jonathan

> 
> Any advice is welcome.
> Thanks,
> 
> Marcelo


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: android: ion: refactory ion_alloc for kernel driver use

2019-04-01 Thread Laura Abbott

On 3/29/19 7:26 PM, Zengtao (B) wrote:

Hi laura:


-Original Message-
From: Laura Abbott [mailto:labb...@redhat.com]
Sent: Friday, March 29, 2019 9:27 PM
To: Zengtao (B) ; sumit.sem...@linaro.org
Cc: Greg Kroah-Hartman ; Arve Hjønnevåg
; Todd Kjos ; Martijn Coenen
; Joel Fernandes ;
Christian Brauner ; de...@driverdev.osuosl.org;
dri-de...@lists.freedesktop.org; linaro-mm-...@lists.linaro.org;
linux-ker...@vger.kernel.org
Subject: Re: [PATCH] staging: android: ion: refactory ion_alloc for kernel
driver use

On 3/29/19 11:40 AM, Zeng Tao wrote:

There are two reasons for this patch:
1. There are some potential requirements for ion_alloc in kernel
space, some media drivers need to allocate media buffers from ion
instead of buddy or dma framework, this is more convient and clean
very for media drivers. And In that case, ion is the only media buffer
provider, it's more easier to maintain.
2. Fd is only needed by user processes, not the kernel space, so
dma_buf should be returned instead of fd for kernel space, and
dma_buf_fd should be called only for userspace api.



I really want to just NAK this because it doesn't seem like something
that's necessary. The purpose of Ion is to provide buffers to userspace
because there's no other way for userspace to get access to the memory.
The kernel already has other APIs to access the memory. This also
complicates the re-work that's been happening where the requirement is
only userspace.

Can you be more detailed about which media drivers you are referring to
and why they can't just use other APIs?



I think I 've got your point, the ION is designed for usespace, but for kernel
  space, we are really lacking of someone which plays the same role,(allocate
media memory, share the memory using dma_buf, provide debug and statistics
for media memory).

In fact, for kernel space, we have the dma framework, dma-buf, etc..
And we can work on top of such apis, but some duplicate jobs(everyone has
  to maintain its own buffer sharing, debug and statistics).
So we need to have some to do the common things(ION's the best choice now)



Keep in mind that Ion is a thin shell of what it was as most of the
debugging and statistics was removed because it was buggy. Most of that
should end up going at the dma_buf layer since it's really a dma_buf allocation
API.


When the ION was introduced, a lot of media memory frameworks existed, the
dma framework was not so good, so ION heaps, integrated buffer sharing, 
statistics
and usespace api were the required features, but now dma framework is more 
powerful,
we don't even need ION heaps now, but the userspace api, buffer sharing, 
statistics are
still needed, and the buffer sharing, statistics can be re-worked and export to 
kernel space,
not only used by userspace, , and that is my point.



I see what you are getting at but I don't think the same thing
applies to the kernel as it does userspace. We can enforce a
single way of using the dma_buf fd in userspace but the kernel
has a variety of ways to use dma_buf because each driver and
framework has its own needs. I'm still not convinced that adding
Ion APIs in the kernel is the right option since as you point out
we don't really need the heaps. That mostly leaves Ion as a wrapper
to handle doing the export. Maybe we could benefit from that
but I think it might require more thought.

I'd rather see a proposal in the media API itself showing what
you think is necessary but without using Ion. That would be
a good start so we could fully review what might make sense to
pull out of Ion into something common.

Thanks,
Laura




Signed-off-by: Zeng Tao 
---
   drivers/staging/android/ion/ion.c | 32

+---

   1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c
b/drivers/staging/android/ion/ion.c
index 92c2914..e93fb49 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -387,13 +387,13 @@ static const struct dma_buf_ops

dma_buf_ops = {

.unmap = ion_dma_buf_kunmap,
   };

-static int ion_alloc(size_t len, unsigned int heap_id_mask, unsigned
int flags)
+struct dma_buf *ion_alloc(size_t len, unsigned int heap_id_mask,
+ unsigned int flags)
   {
struct ion_device *dev = internal_dev;
struct ion_buffer *buffer = NULL;
struct ion_heap *heap;
DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
-   int fd;
struct dma_buf *dmabuf;

pr_debug("%s: len %zu heap_id_mask %u flags %x\n", __func__,

@@

-407,7 +407,7 @@ static int ion_alloc(size_t len, unsigned int

heap_id_mask, unsigned int flags)

len = PAGE_ALIGN(len);

if (!len)
-   return -EINVAL;
+   return ERR_PTR(-EINVAL);

down_read(>lock);
plist_for_each_entry(heap, >heaps, node) { @@ -421,10

+421,10

@@ static int ion_alloc(size_t len, unsigned int heap_id_mask,

unsigned int flags)


Re: [PATCH v2] Staging: comedi: drivers: pcl818: Fixed a coding style error.

2019-04-01 Thread Greg KH
On Mon, Apr 01, 2019 at 10:01:30AM -0400, Will Cunningham wrote:
> Removed unnecessary parentheses.
> 
> Signed-off-by: Will Cunningham 
> ---
> Changes in v2:
>  - Removed a typo from the commit message.
> ---
>  drivers/staging/comedi/drivers/pcl818.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/comedi/drivers/pcl818.c 
> b/drivers/staging/comedi/drivers/pcl818.c
> index 0af5315d4357..da5d53a288f7 100644
> --- a/drivers/staging/comedi/drivers/pcl818.c
> +++ b/drivers/staging/comedi/drivers/pcl818.c
> @@ -1012,7 +1012,7 @@ static int pcl818_attach(struct comedi_device *dev, 
> struct comedi_devconfig *it)
>   pcl818_alloc_dma(dev, it->options[2]);
>  
>   /* use 1MHz or 10MHz oscilator */
> - if ((it->options[3] == 0) || (it->options[3] == 10))
> + if (it->options[3] == 0 || it->options[3] == 10)

Again, no, the original is best.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/4] staging: iio: ad9832: use clock framework for clock reference

2019-04-01 Thread Marcelo Schmitt
Previously external clock were set through platform_data struct.
Now device uses clk struct defined in include/linux/clk.h to handle
external clock source.
It also removes mclk from platform_data struct.

Signed-off-by: Marcelo Schmitt 
---
 drivers/staging/iio/frequency/ad9832.c | 37 +-
 drivers/staging/iio/frequency/ad9832.h |  1 -
 2 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/iio/frequency/ad9832.c 
b/drivers/staging/iio/frequency/ad9832.c
index d8d4a7936275..74308a2e72db 100644
--- a/drivers/staging/iio/frequency/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -7,6 +7,7 @@
 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -95,7 +96,7 @@ struct ad9832_state {
struct spi_device   *spi;
struct regulator*avdd;
struct regulator*dvdd;
-   unsigned long   mclk;
+   struct clk  *mclk;
unsigned short  ctrl_fp;
unsigned short  ctrl_ss;
unsigned short  ctrl_src;
@@ -130,10 +131,10 @@ static int ad9832_write_frequency(struct ad9832_state *st,
 {
unsigned long regval;
 
-   if (fout > (st->mclk / 2))
+   if (fout > (clk_get_rate(st->mclk) / 2))
return -EINVAL;
 
-   regval = ad9832_calc_freqreg(st->mclk, fout);
+   regval = ad9832_calc_freqreg(clk_get_rate(st->mclk), fout);
 
st->freq_data[0] = cpu_to_be16((AD9832_CMD_FRE8BITSW << CMD_SHIFT) |
(addr << ADD_SHIFT) |
@@ -334,7 +335,16 @@ static int ad9832_probe(struct spi_device *spi)
goto error_disable_avdd;
}
 
-   st->mclk = pdata->mclk;
+   st->mclk = devm_clk_get(>dev, "mclk");
+   if (IS_ERR(st->mclk)) {
+   ret = PTR_ERR(st->mclk);
+   goto error_disable_dvdd;
+   }
+
+   ret = clk_prepare_enable(st->mclk);
+   if (ret < 0)
+   goto error_disable_dvdd;
+
st->spi = spi;
mutex_init(>lock);
 
@@ -385,39 +395,41 @@ static int ad9832_probe(struct spi_device *spi)
ret = spi_sync(st->spi, >msg);
if (ret) {
dev_err(>dev, "device init failed\n");
-   goto error_disable_dvdd;
+   goto error_unprepare_mclk;
}
 
ret = ad9832_write_frequency(st, AD9832_FREQ0HM, pdata->freq0);
if (ret)
-   goto error_disable_dvdd;
+   goto error_unprepare_mclk;
 
ret = ad9832_write_frequency(st, AD9832_FREQ1HM, pdata->freq1);
if (ret)
-   goto error_disable_dvdd;
+   goto error_unprepare_mclk;
 
ret = ad9832_write_phase(st, AD9832_PHASE0H, pdata->phase0);
if (ret)
-   goto error_disable_dvdd;
+   goto error_unprepare_mclk;
 
ret = ad9832_write_phase(st, AD9832_PHASE1H, pdata->phase1);
if (ret)
-   goto error_disable_dvdd;
+   goto error_unprepare_mclk;
 
ret = ad9832_write_phase(st, AD9832_PHASE2H, pdata->phase2);
if (ret)
-   goto error_disable_dvdd;
+   goto error_unprepare_mclk;
 
ret = ad9832_write_phase(st, AD9832_PHASE3H, pdata->phase3);
if (ret)
-   goto error_disable_dvdd;
+   goto error_unprepare_mclk;
 
ret = iio_device_register(indio_dev);
if (ret)
-   goto error_disable_dvdd;
+   goto error_unprepare_mclk;
 
return 0;
 
+error_unprepare_mclk:
+   clk_disable_unprepare(st->mclk);
 error_disable_dvdd:
regulator_disable(st->dvdd);
 error_disable_avdd:
@@ -432,6 +444,7 @@ static int ad9832_remove(struct spi_device *spi)
struct ad9832_state *st = iio_priv(indio_dev);
 
iio_device_unregister(indio_dev);
+   clk_disable_unprepare(st->mclk);
regulator_disable(st->dvdd);
regulator_disable(st->avdd);
 
diff --git a/drivers/staging/iio/frequency/ad9832.h 
b/drivers/staging/iio/frequency/ad9832.h
index 39d326cc1af9..032579a2d539 100644
--- a/drivers/staging/iio/frequency/ad9832.h
+++ b/drivers/staging/iio/frequency/ad9832.h
@@ -24,7 +24,6 @@
  */
 
 struct ad9832_platform_data {
-   unsigned long   mclk;
unsigned long   freq0;
unsigned long   freq1;
unsigned short  phase0;
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/4] staging: iio: ad9832: add devicetree documentation

2019-04-01 Thread Marcelo Schmitt
Add a devicetree documentation for the ad9832 direct digital
synthesizer, waveform generator.

Signed-off-by: Marcelo Schmitt 
---
 .../bindings/iio/frequency/ad9832.txt | 26 +++
 1 file changed, 26 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/frequency/ad9832.txt

diff --git a/Documentation/devicetree/bindings/iio/frequency/ad9832.txt 
b/Documentation/devicetree/bindings/iio/frequency/ad9832.txt
new file mode 100644
index ..6a35fdff5a48
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/frequency/ad9832.txt
@@ -0,0 +1,26 @@
+Analog Devices AD9832 Direct Digital Synthesizer, Waveform Generator
+
+Data sheet:
+https://www.analog.com/media/en/technical-documentation/data-sheets/AD9832.pdf
+
+Required properties:
+   - compatible : Must be "adi,ad9832"
+   - reg : SPI chip select number for the device
+   - spi-max-frequency = Max SPI frequency to use (< 2500)
+   - clocks : The clock reference for the DDS output
+   - clock-names : Must be "mclk"
+
+Optional properties:
+   - avdd-supply:  Definition of the regulator used as analog supply
+   - dvdd-supply : Definition of the regulator used as digital supply
+
+Example:
+   adi9832-dds@0 {
+   compatible = "adi,ad9832";
+   reg = <0>;
+   spi-max-frequency = <2500>;
+   clocks = <_mclk>;
+   clock-names = "mclk";
+   avdd-suppy = <>;
+   dvdd-suppy = <>;
+   };
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/4] staging: iio: ad9832: add SPDX identifier

2019-04-01 Thread Marcelo Schmitt
Add SPDX identifier of GPL-2.0 for the ad9832 driver.

Signed-off-by: Marcelo Schmitt 
---
 drivers/staging/iio/frequency/ad9832.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/iio/frequency/ad9832.c 
b/drivers/staging/iio/frequency/ad9832.c
index 50a583020072..d8d4a7936275 100644
--- a/drivers/staging/iio/frequency/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * AD9832 SPI DDS driver
  *
  * Copyright 2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
  */
 
 #include 
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/4] staging: iio: ad9832: organize includes

2019-04-01 Thread Marcelo Schmitt
Organize includes to list them in lexicographic order.

Signed-off-by: Marcelo Schmitt 
---
 drivers/staging/iio/frequency/ad9832.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/iio/frequency/ad9832.c 
b/drivers/staging/iio/frequency/ad9832.c
index a3ce50427724..50a583020072 100644
--- a/drivers/staging/iio/frequency/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -6,22 +6,24 @@
  * Licensed under the GPL-2.
  */
 
+#include 
+
 #include 
+#include 
 #include 
+#include 
+#include 
 #include 
-#include 
 #include 
-#include 
-#include 
-#include 
-#include 
+#include 
 
 #include 
 #include 
-#include "dds.h"
 
 #include "ad9832.h"
 
+#include "dds.h"
+
 /* Registers */
 
 #define AD9832_FREQ0LL 0x0
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/4] staging: iio: ad9832: use clock framework

2019-04-01 Thread Marcelo Schmitt
This series of patches do minor codestyle ajusts, set SPDX licence
identifier, set use of linux's clock framework to handle external
clock, and add a devicetree documentation.

Marcelo Schmitt (4):
  staging: iio: ad9832: organize includes
  staging: iio: ad9832: add SPDX identifier
  staging: iio: ad9832: use clock framework for clock reference
  staging: iio: ad9832: add devicetree documentation

 .../bindings/iio/frequency/ad9832.txt | 26 +
 drivers/staging/iio/frequency/ad9832.c| 54 ---
 drivers/staging/iio/frequency/ad9832.h|  1 -
 3 files changed, 60 insertions(+), 21 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/frequency/ad9832.txt

-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] Staging: greybus: usb: Fixed a coding style error

2019-04-01 Thread Alex Elder
On 4/1/19 9:22 AM, Will Cunningham wrote:
> Line was >80 characters.

This looks fine, but "tmp" is not a meaningful name.
That argument to gb_connection_create() is a cport id,
so "cport_id" would be a much better name for the variable.

It seems picky, but details like this make the code much
more understandable.

-Alex


> Signed-off-by: Will Cunningham 
> ---
> Changes in v2:
>  - Created a tmp variable to shorten line length.
> ---
>  drivers/staging/greybus/usb.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/greybus/usb.c b/drivers/staging/greybus/usb.c
> index 1c246c73a085..c09793b48850 100644
> --- a/drivers/staging/greybus/usb.c
> +++ b/drivers/staging/greybus/usb.c
> @@ -163,14 +163,14 @@ static int gb_usb_probe(struct gbphy_device *gbphy_dev,
>   struct gb_usb_device *gb_usb_dev;
>   struct usb_hcd *hcd;
>   int retval;
> + u16 tmp;
>  
>   hcd = usb_create_hcd(_gb_hc_driver, dev, dev_name(dev));
>   if (!hcd)
>   return -ENOMEM;
>  
> - connection = gb_connection_create(gbphy_dev->bundle,
> -   
> le16_to_cpu(gbphy_dev->cport_desc->id),
> -   NULL);
> + tmp = le16_to_cpu(gbphy_dev->cport_desc->id);
> + connection = gb_connection_create(gbphy_dev->bundle, tmp, NULL);
>   if (IS_ERR(connection)) {
>   retval = PTR_ERR(connection);
>   goto exit_usb_put;
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Work on iio: stating: frequency: ad9832

2019-04-01 Thread Marcelo Schmitt
Hello,

I was looking for some work on staging: iio: ad9832 and made some
observations while reading the driver.

Apparently it had no devicetree documentation so I tried to elaborate
one. 
It uses a platform_data variable to load external clock
frequency (I tried to make it use linux's clock framework).
Some device attributes don't seem to be standardized on
Documentation/ABI/testing/sysfs-bus-iio and there's no specific ABI
for ad9832 nearby nor at staging/iio/Documentation. So maybe those
missing ABI could be documented.
The device has to set some internal registers to operate correctly,
AD9832_FREQXHM and AD9832_PHASEXH, would it be feasible to set iio
chanels for this?
I couldn't understand why checkpatch.pl gave errors on IIO_DEV_ATTR_*
macros. To me they seem to have no problem.
Also it has that platform_data to be moved to include/linux/iio. Is
there any special reason for it not being there already? Which are
the criterions a platform_data need to satisfy to be put there?

I'm sending a patchset with some things I've already done.

Is there something else that could be done in this device driver?
Please, tell if I've forgotten something.

Any advice is welcome.
Thanks,

Marcelo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] Staging: greybus: usb: Fixed a coding style error

2019-04-01 Thread Will Cunningham
Line was >80 characters.

Signed-off-by: Will Cunningham 
---
Changes in v2:
 - Created a tmp variable to shorten line length.
---
 drivers/staging/greybus/usb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/greybus/usb.c b/drivers/staging/greybus/usb.c
index 1c246c73a085..c09793b48850 100644
--- a/drivers/staging/greybus/usb.c
+++ b/drivers/staging/greybus/usb.c
@@ -163,14 +163,14 @@ static int gb_usb_probe(struct gbphy_device *gbphy_dev,
struct gb_usb_device *gb_usb_dev;
struct usb_hcd *hcd;
int retval;
+   u16 tmp;
 
hcd = usb_create_hcd(_gb_hc_driver, dev, dev_name(dev));
if (!hcd)
return -ENOMEM;
 
-   connection = gb_connection_create(gbphy_dev->bundle,
- 
le16_to_cpu(gbphy_dev->cport_desc->id),
- NULL);
+   tmp = le16_to_cpu(gbphy_dev->cport_desc->id);
+   connection = gb_connection_create(gbphy_dev->bundle, tmp, NULL);
if (IS_ERR(connection)) {
retval = PTR_ERR(connection);
goto exit_usb_put;
-- 
2.19.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] Staging: comedi: drivers: pcl818: Fixed a coding style error.

2019-04-01 Thread Will Cunningham
Removed unnecessary parentheses.

Signed-off-by: Will Cunningham 
---
Changes in v2:
 - Removed a typo from the commit message.
---
 drivers/staging/comedi/drivers/pcl818.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/pcl818.c 
b/drivers/staging/comedi/drivers/pcl818.c
index 0af5315d4357..da5d53a288f7 100644
--- a/drivers/staging/comedi/drivers/pcl818.c
+++ b/drivers/staging/comedi/drivers/pcl818.c
@@ -1012,7 +1012,7 @@ static int pcl818_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
pcl818_alloc_dma(dev, it->options[2]);
 
/* use 1MHz or 10MHz oscilator */
-   if ((it->options[3] == 0) || (it->options[3] == 10))
+   if (it->options[3] == 0 || it->options[3] == 10)
osc_base = I8254_OSC_BASE_10MHZ;
else
osc_base = I8254_OSC_BASE_1MHZ;
@@ -1026,7 +1026,7 @@ static int pcl818_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
devpriv->ns_min = board->ns_min;
if (!board->is_818) {
/* extended PCL718 to 100kHz DAC */
-   if ((it->options[6] == 1) || (it->options[6] == 100))
+   if (it->options[6] == 1 || it->options[6] == 100)
devpriv->ns_min = 1;
}
 
@@ -1067,12 +1067,12 @@ static int pcl818_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
s->maxdata  = 0x0fff;
s->range_table  = _unipolar5;
if (board->is_818) {
-   if ((it->options[4] == 1) || (it->options[4] == 10))
+   if (it->options[4] == 1 || it->options[4] == 10)
s->range_table = _unipolar10;
if (it->options[4] == 2)
s->range_table = _unknown;
} else {
-   if ((it->options[5] == 1) || (it->options[5] == 10))
+   if (it->options[5] == 1 || it->options[5] == 10)
s->range_table = _unipolar10;
if (it->options[5] == 2)
s->range_table = _unknown;
-- 
2.19.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 14/14] staging: most: Documentation: update driver documentation

2019-04-01 Thread Christian Gromm
This patch updates the driver documentation files to reflect the
latest changes regarding configfs.

Signed-off-by: Christian Gromm 
v2:
- changed kernel version to 5.2
v3:

Signed-off-by: Christian Gromm 
---
 .../most/Documentation/ABI/configfs-most.txt   | 204 +
 .../staging/most/Documentation/driver_usage.txt| 131 +++--
 2 files changed, 284 insertions(+), 51 deletions(-)
 create mode 100644 drivers/staging/most/Documentation/ABI/configfs-most.txt

diff --git a/drivers/staging/most/Documentation/ABI/configfs-most.txt 
b/drivers/staging/most/Documentation/ABI/configfs-most.txt
new file mode 100644
index 000..25b3e18
--- /dev/null
+++ b/drivers/staging/most/Documentation/ABI/configfs-most.txt
@@ -0,0 +1,204 @@
+What:  /sys/kernel/config/most_
+Date:  March 8, 2019
+KernelVersion:  5.2
+Description:   Interface is used to configure and connect device channels
+   to component drivers.
+
+   Attributes are visible only when configfs is mounted. To mount
+   configfs in /sys/kernel/config directory use:
+   # mount -t configfs none /sys/kernel/config/
+
+
+What:  /sys/kernel/config/most_cdev/
+Date:  March 8, 2019
+KernelVersion:  5.2
+Description:
+   The attributes:
+
+   buffer_size configure the buffer size for this channel
+
+   subbuffer_size  configure the sub-buffer size for this channel
+   (needed for synchronous and isochrnous data)
+
+
+   num_buffers configure number of buffers used for this
+   channel
+
+   datatypeconfigure type of data that will travel over
+   this channel
+
+   direction   configure whether this link will be an input
+   or output
+
+   dbr_sizeconfigure DBR data buffer size (this is used
+   for MediaLB communiction only)
+
+   packets_per_xact
+   configure the number of packets that will be
+   collected from the network before being
+   transmitted via USB (this is used for USB
+   communiction only)
+
+   device  name of the device the link is to be attached to
+
+   channel name of the channel the link is to be attached 
to
+
+   comp_params pass parameters needed by some components
+
+   create_link write '1' to this attribute to trigger the
+   creation of the link. In case of speculative
+   configuration, the creation is post-poned until
+   a physical device is being attached to the bus.
+
+   destroy_linkwrite '1' to this attribute to destroy an
+   active link
+
+What:  /sys/kernel/config/most_video/
+Date:  March 8, 2019
+KernelVersion:  5.2
+Description:
+   The attributes:
+
+   buffer_size configure the buffer size for this channel
+
+   subbuffer_size  configure the sub-buffer size for this channel
+   (needed for synchronous and isochrnous data)
+
+
+   num_buffers configure number of buffers used for this
+   channel
+
+   datatypeconfigure type of data that will travel over
+   this channel
+
+   direction   configure whether this link will be an input
+   or output
+
+   dbr_sizeconfigure DBR data buffer size (this is used
+   for MediaLB communiction only)
+
+   packets_per_xact
+   configure the number of packets that will be
+   collected from the network before being
+   transmitted via USB (this is used for USB
+   communiction only)
+
+   device  name of the device the link is to be attached to
+
+   channel name of the channel the link is to be attached 
to
+
+   comp_params pass parameters needed by some components
+
+   create_link write '1' to this attribute to trigger the
+   creation of the link. In case of speculative
+   configuration, the creation is post-poned until
+   a physical device is being attached to the bus.
+
+   destroy_linkwrite '1' to this attribute to destroy an
+   active link
+
+What:  /sys/kernel/config/most_net/
+Date:  March 8, 

[PATCH v3 10/14] staging: most: allow speculative configuration

2019-04-01 Thread Christian Gromm
This patch makes the driver accept a link configuration eventhough no
device is attached to the bus. Instead the configuration is being applied
as soon as a device is being registered with the core.

Signed-off-by: Christian Gromm 
---
v2:
- follow-up adaptions due to changes introduced w/ [PATCH v2 01/14]
v3:
Reported-by: Dan Carpenter 
- remove filter for particular error message ENODATA in function
  set_config_and_add_link and check for negative values instead

 drivers/staging/most/configfs.c| 60 --
 drivers/staging/most/core.c| 16 +++---
 drivers/staging/most/core.h|  1 +
 drivers/staging/most/sound/sound.c |  6 ++--
 4 files changed, 53 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/most/configfs.c b/drivers/staging/most/configfs.c
index b8d4fd5..ee1ad32 100644
--- a/drivers/staging/most/configfs.c
+++ b/drivers/staging/most/configfs.c
@@ -14,6 +14,7 @@
 
 struct mdev_link {
struct config_item item;
+   struct list_head list;
bool create;
u16 num_buffers;
u16 buffer_size;
@@ -29,6 +30,8 @@ struct mdev_link {
char param[PAGE_SIZE];
 };
 
+struct list_head mdev_link_list;
+
 static int set_cfg_buffer_size(struct mdev_link *link)
 {
if (!link->buffer_size)
@@ -105,33 +108,41 @@ static ssize_t mdev_link_create_show(struct config_item 
*item, char *page)
return snprintf(page, PAGE_SIZE, "%d\n", to_mdev_link(item)->create);
 }
 
+static int set_config_and_add_link(struct mdev_link *mdev_link)
+{
+   int i;
+   int ret;
+
+   for (i = 0; i < ARRAY_SIZE(set_config_val); i++) {
+   ret = set_config_val[i](mdev_link);
+   if (ret < 0 && ret != -ENODEV) {
+   pr_err("Config failed\n");
+   return ret;
+   }
+   }
+
+   return most_add_link(mdev_link->mdev, mdev_link->channel,
+mdev_link->comp, mdev_link->name,
+mdev_link->param);
+}
+
 static ssize_t mdev_link_create_store(struct config_item *item,
  const char *page, size_t count)
 {
struct mdev_link *mdev_link = to_mdev_link(item);
bool tmp;
int ret;
-   int i;
 
ret = kstrtobool(page, );
if (ret)
return ret;
-
-   for (i = 0; i < ARRAY_SIZE(set_config_val); i++) {
-   ret = set_config_val[i](mdev_link);
-   if (ret < 0)
-   return ret;
-   }
-
-   if (tmp)
-   ret = most_add_link(mdev_link->mdev, mdev_link->channel,
-   mdev_link->comp, mdev_link->name,
-   mdev_link->param);
-   else
-   ret = most_remove_link(mdev_link->mdev, mdev_link->channel,
-  mdev_link->comp);
-   if (ret)
+   if (!tmp)
+   return most_remove_link(mdev_link->mdev, mdev_link->channel,
+   mdev_link->comp);
+   ret = set_config_and_add_link(mdev_link);
+   if (ret && ret != -ENODEV)
return ret;
+   list_add_tail(_link->list, _link_list);
mdev_link->create = tmp;
return count;
 }
@@ -590,6 +601,22 @@ int most_register_configfs_subsys(struct core_component *c)
 }
 EXPORT_SYMBOL_GPL(most_register_configfs_subsys);
 
+void most_interface_register_notify(const char *mdev)
+{
+   bool register_snd_card = false;
+   struct mdev_link *mdev_link;
+
+   list_for_each_entry(mdev_link, _link_list, list) {
+   if (!strcmp(mdev_link->mdev, mdev)) {
+   set_config_and_add_link(mdev_link);
+   if (!strcmp(mdev_link->comp, "sound"))
+   register_snd_card = true;
+   }
+   }
+   if (register_snd_card)
+   most_cfg_complete("sound");
+}
+
 void most_deregister_configfs_subsys(struct core_component *c)
 {
if (!strcmp(c->name, "cdev"))
@@ -618,6 +645,7 @@ int __init configfs_init(void)
mutex_init(_sound_subsys.subsys.su_mutex);
 
INIT_LIST_HEAD(_sound_subsys.soundcard_list);
+   INIT_LIST_HEAD(_link_list);
 
return 0;
 }
diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index df1d774..b1f7f70 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -720,19 +720,10 @@ int most_cfg_complete(char *comp_name)
 int most_add_link(char *mdev, char *mdev_ch, char *comp_name, char *link_name,
  char *comp_param)
 {
-   struct most_channel *c;
-   struct core_component *comp;
-   char buf[STRING_SIZE];
+   struct most_channel *c = get_channel(mdev, mdev_ch);
+   struct core_component *comp = match_component(comp_name);
 
-   comp = match_component(comp_name);
-   if (!comp)
-   return 

[PATCH v3 02/14] staging: most: change signature of function probe_channel

2019-04-01 Thread Christian Gromm
This patch adds the param argument to the function parameter of
the call-back probe_channel. This parameter is needed to configure
the channels of an attached device.

Signed-off-by: Christian Gromm 
---
v2:
v3:

 drivers/staging/most/cdev/cdev.c   | 2 +-
 drivers/staging/most/core.c| 6 --
 drivers/staging/most/core.h| 3 ++-
 drivers/staging/most/net/net.c | 3 ++-
 drivers/staging/most/sound/sound.c | 3 +--
 drivers/staging/most/video/video.c | 3 ++-
 6 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c
index f2b347c..97408ec 100644
--- a/drivers/staging/most/cdev/cdev.c
+++ b/drivers/staging/most/cdev/cdev.c
@@ -425,7 +425,7 @@ static int comp_tx_completion(struct most_interface *iface, 
int channel_id)
  * Returns 0 on success or error code otherwise.
  */
 static int comp_probe(struct most_interface *iface, int channel_id,
- struct most_channel_config *cfg, char *name)
+ struct most_channel_config *cfg, char *name, char *args)
 {
struct comp_channel *c;
unsigned long cl_flags;
diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 18936cd..fb19b63 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -701,6 +701,7 @@ static struct most_channel *get_channel(char *mdev, char 
*mdev_ch)
 static
 inline int link_channel_to_component(struct most_channel *c,
 struct core_component *comp,
+char *name,
 char *comp_param)
 {
int ret;
@@ -714,7 +715,8 @@ inline int link_channel_to_component(struct most_channel *c,
return -ENOSPC;
 
*comp_ptr = comp;
-   ret = comp->probe_channel(c->iface, c->channel_id, >cfg, comp_param);
+   ret = comp->probe_channel(c->iface, c->channel_id, >cfg, name,
+ comp_param);
if (ret) {
*comp_ptr = NULL;
return ret;
@@ -775,7 +777,7 @@ static ssize_t add_link_store(struct device_driver *drv,
if (!c)
return -ENODEV;
 
-   ret = link_channel_to_component(c, comp, comp_param);
+   ret = link_channel_to_component(c, comp, "name", comp_param);
if (ret)
return ret;
return len;
diff --git a/drivers/staging/most/core.h b/drivers/staging/most/core.h
index 64cc02f..025dd1d 100644
--- a/drivers/staging/most/core.h
+++ b/drivers/staging/most/core.h
@@ -266,7 +266,8 @@ struct core_component {
struct list_head list;
const char *name;
int (*probe_channel)(struct most_interface *iface, int channel_idx,
-struct most_channel_config *cfg, char *name);
+struct most_channel_config *cfg, char *name,
+char *param);
int (*disconnect_channel)(struct most_interface *iface,
  int channel_idx);
int (*rx_completion)(struct mbo *mbo);
diff --git a/drivers/staging/most/net/net.c b/drivers/staging/most/net/net.c
index e20584b..c8a64e2 100644
--- a/drivers/staging/most/net/net.c
+++ b/drivers/staging/most/net/net.c
@@ -293,7 +293,8 @@ static struct net_dev_context *get_net_dev_hold(struct 
most_interface *iface)
 }
 
 static int comp_probe_channel(struct most_interface *iface, int channel_idx,
- struct most_channel_config *ccfg, char *name)
+ struct most_channel_config *ccfg, char *name,
+ char *args)
 {
struct net_dev_context *nd;
struct net_dev_channel *ch;
diff --git a/drivers/staging/most/sound/sound.c 
b/drivers/staging/most/sound/sound.c
index 79ab3a7..02fcd32 100644
--- a/drivers/staging/most/sound/sound.c
+++ b/drivers/staging/most/sound/sound.c
@@ -579,7 +579,7 @@ static void release_adapter(struct sound_adapter *adpt)
  */
 static int audio_probe_channel(struct most_interface *iface, int channel_id,
   struct most_channel_config *cfg,
-  char *arg_list)
+  char *device_name, char *arg_list)
 {
struct channel *channel;
struct sound_adapter *adpt;
@@ -588,7 +588,6 @@ static int audio_probe_channel(struct most_interface 
*iface, int channel_id,
int capture_count = 0;
int ret;
int direction;
-   char *device_name;
u16 ch_num;
u8 create = 0;
char *sample_res;
diff --git a/drivers/staging/most/video/video.c 
b/drivers/staging/most/video/video.c
index ad7e28a..adca250 100644
--- a/drivers/staging/most/video/video.c
+++ b/drivers/staging/most/video/video.c
@@ -453,7 +453,8 @@ static void comp_v4l2_dev_release(struct v4l2_device 
*v4l2_dev)
 }
 
 static int comp_probe_channel(struct most_interface *iface, int channel_idx,
-   

[PATCH v3 13/14] staging: most: configfs: rename config attributes

2019-04-01 Thread Christian Gromm
This patch introduces attribute names that are more self explaining.

Signed-off-by: Christian Gromm 
---
v2:
- follow-up adaptions due to changes introduced w/ [PATCH v2 01/14]
v3:

 drivers/staging/most/configfs.c | 97 +
 1 file changed, 49 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/most/configfs.c b/drivers/staging/most/configfs.c
index d430df2..934fb6d 100644
--- a/drivers/staging/most/configfs.c
+++ b/drivers/staging/most/configfs.c
@@ -15,8 +15,8 @@
 struct mdev_link {
struct config_item item;
struct list_head list;
-   bool create;
-   bool destroy;
+   bool create_link;
+   bool destroy_link;
u16 num_buffers;
u16 buffer_size;
u16 subbuffer_size;
@@ -25,10 +25,10 @@ struct mdev_link {
char datatype[PAGE_SIZE];
char direction[PAGE_SIZE];
char name[PAGE_SIZE];
-   char mdev[PAGE_SIZE];
+   char device[PAGE_SIZE];
char channel[PAGE_SIZE];
char comp[PAGE_SIZE];
-   char param[PAGE_SIZE];
+   char comp_params[PAGE_SIZE];
 };
 
 struct list_head mdev_link_list;
@@ -37,7 +37,7 @@ static int set_cfg_buffer_size(struct mdev_link *link)
 {
if (!link->buffer_size)
return -ENODATA;
-   return most_set_cfg_buffer_size(link->mdev, link->channel,
+   return most_set_cfg_buffer_size(link->device, link->channel,
link->buffer_size);
 }
 
@@ -45,7 +45,7 @@ static int set_cfg_subbuffer_size(struct mdev_link *link)
 {
if (!link->subbuffer_size)
return -ENODATA;
-   return most_set_cfg_subbuffer_size(link->mdev, link->channel,
+   return most_set_cfg_subbuffer_size(link->device, link->channel,
   link->subbuffer_size);
 }
 
@@ -53,7 +53,7 @@ static int set_cfg_dbr_size(struct mdev_link *link)
 {
if (!link->dbr_size)
return -ENODATA;
-   return most_set_cfg_dbr_size(link->mdev, link->channel,
+   return most_set_cfg_dbr_size(link->device, link->channel,
 link->dbr_size);
 }
 
@@ -61,7 +61,7 @@ static int set_cfg_num_buffers(struct mdev_link *link)
 {
if (!link->num_buffers)
return -ENODATA;
-   return most_set_cfg_num_buffers(link->mdev, link->channel,
+   return most_set_cfg_num_buffers(link->device, link->channel,
link->num_buffers);
 }
 
@@ -69,7 +69,7 @@ static int set_cfg_packets_xact(struct mdev_link *link)
 {
if (!link->packets_per_xact)
return -ENODATA;
-   return most_set_cfg_packets_xact(link->mdev, link->channel,
+   return most_set_cfg_packets_xact(link->device, link->channel,
 link->packets_per_xact);
 }
 
@@ -77,7 +77,7 @@ static int set_cfg_direction(struct mdev_link *link)
 {
if (!strlen(link->direction))
return -ENODATA;
-   return most_set_cfg_direction(link->mdev, link->channel,
+   return most_set_cfg_direction(link->device, link->channel,
  link->direction);
 }
 
@@ -85,7 +85,7 @@ static int set_cfg_datatype(struct mdev_link *link)
 {
if (!strlen(link->datatype))
return -ENODATA;
-   return most_set_cfg_datatype(link->mdev, link->channel,
+   return most_set_cfg_datatype(link->device, link->channel,
 link->datatype);
 }
 
@@ -117,13 +117,13 @@ static int set_config_and_add_link(struct mdev_link 
*mdev_link)
}
}
 
-   return most_add_link(mdev_link->mdev, mdev_link->channel,
+   return most_add_link(mdev_link->device, mdev_link->channel,
 mdev_link->comp, mdev_link->name,
-mdev_link->param);
+mdev_link->comp_params);
 }
 
-static ssize_t mdev_link_create_store(struct config_item *item,
- const char *page, size_t count)
+static ssize_t mdev_link_create_link_store(struct config_item *item,
+  const char *page, size_t count)
 {
struct mdev_link *mdev_link = to_mdev_link(item);
bool tmp;
@@ -138,12 +138,12 @@ static ssize_t mdev_link_create_store(struct config_item 
*item,
if (ret && ret != -ENODEV)
return ret;
list_add_tail(_link->list, _link_list);
-   mdev_link->create = tmp;
+   mdev_link->create_link = tmp;
return count;
 }
 
-static ssize_t mdev_link_destroy_store(struct config_item *item,
-  const char *page, size_t count)
+static ssize_t mdev_link_destroy_link_store(struct config_item *item,
+   const char *page, size_t count)
 {
struct mdev_link *mdev_link = to_mdev_link(item);
bool tmp;
@@ -154,8 

[PATCH v3 08/14] staging: most: usb: remove prefix from description tag

2019-04-01 Thread Christian Gromm
This patch cuts off the usb_device prefix of the description string.
It is not needed, as the interface type is already available with the
interface attribute of a channel.

Signed-off-by: Christian Gromm 
---
v2:
v3:

 drivers/staging/most/usb/usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c
index c0293d8..360cb5b 100644
--- a/drivers/staging/most/usb/usb.c
+++ b/drivers/staging/most/usb/usb.c
@@ -1072,7 +1072,7 @@ hdm_probe(struct usb_interface *interface, const struct 
usb_device_id *id)
mdev->iface.num_channels = num_endpoints;
 
snprintf(mdev->description, sizeof(mdev->description),
-"usb_device %d-%s:%d.%d",
+"%d-%s:%d.%d",
 usb_dev->bus->busnum,
 usb_dev->devpath,
 usb_dev->config->desc.bConfigurationValue,
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 06/14] staging: most: core: make sysfs attributes read-only

2019-04-01 Thread Christian Gromm
This patch changes the access flags of the channel attributes to
read-only. This is needed, because configuration is done via configfs.

Signed-off-by: Christian Gromm 
---
v2:
v3:

 drivers/staging/most/core.c | 122 +++-
 1 file changed, 7 insertions(+), 115 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index e7a8d89..a5df53e 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -272,19 +272,6 @@ static ssize_t set_number_of_buffers_show(struct device 
*dev,
return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.num_buffers);
 }
 
-static ssize_t set_number_of_buffers_store(struct device *dev,
-  struct device_attribute *attr,
-  const char *buf,
-  size_t count)
-{
-   struct most_channel *c = to_channel(dev);
-   int ret = kstrtou16(buf, 0, >cfg.num_buffers);
-
-   if (ret)
-   return ret;
-   return count;
-}
-
 static ssize_t set_buffer_size_show(struct device *dev,
struct device_attribute *attr,
char *buf)
@@ -294,19 +281,6 @@ static ssize_t set_buffer_size_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.buffer_size);
 }
 
-static ssize_t set_buffer_size_store(struct device *dev,
-struct device_attribute *attr,
-const char *buf,
-size_t count)
-{
-   struct most_channel *c = to_channel(dev);
-   int ret = kstrtou16(buf, 0, >cfg.buffer_size);
-
-   if (ret)
-   return ret;
-   return count;
-}
-
 static ssize_t set_direction_show(struct device *dev,
  struct device_attribute *attr,
  char *buf)
@@ -320,28 +294,6 @@ static ssize_t set_direction_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "unconfigured\n");
 }
 
-static ssize_t set_direction_store(struct device *dev,
-  struct device_attribute *attr,
-  const char *buf,
-  size_t count)
-{
-   struct most_channel *c = to_channel(dev);
-
-   if (!strcmp(buf, "dir_rx\n")) {
-   c->cfg.direction = MOST_CH_RX;
-   } else if (!strcmp(buf, "rx\n")) {
-   c->cfg.direction = MOST_CH_RX;
-   } else if (!strcmp(buf, "dir_tx\n")) {
-   c->cfg.direction = MOST_CH_TX;
-   } else if (!strcmp(buf, "tx\n")) {
-   c->cfg.direction = MOST_CH_TX;
-   } else {
-   pr_info("WARN: invalid attribute settings\n");
-   return -EINVAL;
-   }
-   return count;
-}
-
 static ssize_t set_datatype_show(struct device *dev,
 struct device_attribute *attr,
 char *buf)
@@ -356,28 +308,6 @@ static ssize_t set_datatype_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "unconfigured\n");
 }
 
-static ssize_t set_datatype_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t count)
-{
-   int i;
-   struct most_channel *c = to_channel(dev);
-
-   for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
-   if (!strcmp(buf, ch_data_type[i].name)) {
-   c->cfg.data_type = ch_data_type[i].most_ch_data_type;
-   break;
-   }
-   }
-
-   if (i == ARRAY_SIZE(ch_data_type)) {
-   pr_info("WARN: invalid attribute settings\n");
-   return -EINVAL;
-   }
-   return count;
-}
-
 static ssize_t set_subbuffer_size_show(struct device *dev,
   struct device_attribute *attr,
   char *buf)
@@ -387,19 +317,6 @@ static ssize_t set_subbuffer_size_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.subbuffer_size);
 }
 
-static ssize_t set_subbuffer_size_store(struct device *dev,
-   struct device_attribute *attr,
-   const char *buf,
-   size_t count)
-{
-   struct most_channel *c = to_channel(dev);
-   int ret = kstrtou16(buf, 0, >cfg.subbuffer_size);
-
-   if (ret)
-   return ret;
-   return count;
-}
-
 static ssize_t set_packets_per_xact_show(struct device *dev,
 struct device_attribute *attr,
 char *buf)
@@ -409,19 +326,6 @@ static ssize_t set_packets_per_xact_show(struct device 
*dev,
return snprintf(buf, PAGE_SIZE, 

[PATCH v3 07/14] staging: most: core: use device description as name

2019-04-01 Thread Christian Gromm
This patch uses the device description to clearly identity a device
attached to the bus. It is needed as the currently useed mdevX
notation is not sufficiant in case more than one network
interface controller is being used at the same time.

Signed-off-by: Christian Gromm 
---
v2:
v3:

 drivers/staging/most/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index a5df53e..e0a6806 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -1467,7 +1467,7 @@ int most_register_interface(struct most_interface *iface)
 
INIT_LIST_HEAD(>p->channel_list);
iface->p->dev_id = id;
-   snprintf(iface->p->name, STRING_SIZE, "mdev%d", id);
+   strcpy(iface->p->name, iface->description);
iface->dev.init_name = iface->p->name;
iface->dev.bus = 
iface->dev.parent = 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 03/14] staging: most: core: add configfs interface functions

2019-04-01 Thread Christian Gromm
This patch adds the core's interface to configfs file.

Signed-off-by: Christian Gromm 
---
v2:
v3:

 drivers/staging/most/core.c | 142 
 drivers/staging/most/core.h |  16 -
 2 files changed, 157 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index fb19b63..d5cf58f 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -783,6 +783,127 @@ static ssize_t add_link_store(struct device_driver *drv,
return len;
 }
 
+int most_set_cfg_buffer_size(char *mdev, char *mdev_ch, u16 val)
+{
+   struct most_channel *c = get_channel(mdev, mdev_ch);
+
+   if (!c)
+   return -ENODEV;
+   c->cfg.buffer_size = val;
+   return 0;
+}
+
+int most_set_cfg_subbuffer_size(char *mdev, char *mdev_ch, u16 val)
+{
+   struct most_channel *c = get_channel(mdev, mdev_ch);
+
+   if (!c)
+   return -ENODEV;
+   c->cfg.subbuffer_size = val;
+   return 0;
+}
+
+int most_set_cfg_dbr_size(char *mdev, char *mdev_ch, u16 val)
+{
+   struct most_channel *c = get_channel(mdev, mdev_ch);
+
+   if (!c)
+   return -ENODEV;
+   c->cfg.dbr_size = val;
+   return 0;
+}
+
+int most_set_cfg_num_buffers(char *mdev, char *mdev_ch, u16 val)
+{
+   struct most_channel *c = get_channel(mdev, mdev_ch);
+
+   if (!c)
+   return -ENODEV;
+   c->cfg.num_buffers = val;
+   return 0;
+}
+
+int most_set_cfg_datatype(char *mdev, char *mdev_ch, char *buf)
+{
+   int i;
+   struct most_channel *c = get_channel(mdev, mdev_ch);
+
+   if (!c)
+   return -ENODEV;
+   for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
+   if (!strcmp(buf, ch_data_type[i].name)) {
+   c->cfg.data_type = ch_data_type[i].most_ch_data_type;
+   break;
+   }
+   }
+
+   if (i == ARRAY_SIZE(ch_data_type))
+   pr_info("WARN: invalid attribute settings\n");
+   return 0;
+}
+
+int most_set_cfg_direction(char *mdev, char *mdev_ch, char *buf)
+{
+   struct most_channel *c = get_channel(mdev, mdev_ch);
+
+   if (!c)
+   return -ENODEV;
+   if (!strcmp(buf, "dir_rx\n")) {
+   c->cfg.direction = MOST_CH_RX;
+   } else if (!strcmp(buf, "rx\n")) {
+   c->cfg.direction = MOST_CH_RX;
+   } else if (!strcmp(buf, "dir_tx\n")) {
+   c->cfg.direction = MOST_CH_TX;
+   } else if (!strcmp(buf, "tx\n")) {
+   c->cfg.direction = MOST_CH_TX;
+   } else {
+   pr_info("Invalid direction\n");
+   return -ENODATA;
+   }
+   return 0;
+}
+
+int most_set_cfg_packets_xact(char *mdev, char *mdev_ch, u16 val)
+{
+   struct most_channel *c = get_channel(mdev, mdev_ch);
+
+   if (!c)
+   return -ENODEV;
+   c->cfg.packets_per_xact = val;
+   return 0;
+}
+
+int most_cfg_complete(char *comp_name)
+{
+   struct core_component *comp;
+
+   comp = match_component(comp_name);
+   if (!comp)
+   return -ENODEV;
+
+   return comp->cfg_complete();
+}
+
+int most_add_link(char *mdev, char *mdev_ch, char *comp_name, char *link_name,
+ char *comp_param)
+{
+   struct most_channel *c;
+   struct core_component *comp;
+   char buf[STRING_SIZE];
+
+   comp = match_component(comp_name);
+   if (!comp)
+   return -ENODEV;
+   if (!comp_param || *comp_param == 0) {
+   snprintf(buf, sizeof(buf), "%s-%s", mdev, mdev_ch);
+   comp_param = buf;
+   }
+   c = get_channel(mdev, mdev_ch);
+   if (!c)
+   return -ENODEV;
+
+   return link_channel_to_component(c, comp, link_name, comp_param);
+}
 /**
  * remove_link_store - store function for remove_link attribute
  * @drv: device driver
@@ -825,6 +946,27 @@ static ssize_t remove_link_store(struct device_driver *drv,
return len;
 }
 
+int most_remove_link(char *mdev, char *mdev_ch, char *comp_name)
+{
+   struct most_channel *c;
+   struct core_component *comp;
+
+   comp = match_component(comp_name);
+   if (!comp)
+   return -ENODEV;
+   c = get_channel(mdev, mdev_ch);
+   if (!c)
+   return -ENODEV;
+
+   if (comp->disconnect_channel(c->iface, c->channel_id))
+   return -EIO;
+   if (c->pipe0.comp == comp)
+   c->pipe0.comp = NULL;
+   if (c->pipe1.comp == comp)
+   c->pipe1.comp = NULL;
+   return 0;
+}
+
 #define DRV_ATTR(_name)  (_attr_##_name.attr)
 
 static DRIVER_ATTR_RO(links);
diff --git a/drivers/staging/most/core.h b/drivers/staging/most/core.h
index 025dd1d..12c5992 100644
--- a/drivers/staging/most/core.h
+++ b/drivers/staging/most/core.h
@@ -272,6 +272,7 @@ struct core_component {
  int channel_idx);
int 

[PATCH v3 01/14] staging: most: add new file configfs.c

2019-04-01 Thread Christian Gromm
This patch adds the file configfs.c to the driver directory. The file
registers the necessary subsystems with configfs in order to move the
driver configuration from sysfs to configfs.

Signed-off-by: Christian Gromm 
---
v2:
Reported-by: Dan Carpenter 
- remove unnecessary variable init
- replace strcmp w/ sysfs_streq
- prefer snprintf over sprintf
- fix array size
- remove empty exit function
- use bool type for create attributes and kstrtobool function
- remove redundant local variables
- remove inline keyword
- remove check for NULL pointers for struct config_item
v3:
- invert sysfs_streq return value evaluation

 drivers/staging/most/configfs.c | 623 
 1 file changed, 623 insertions(+)
 create mode 100644 drivers/staging/most/configfs.c

diff --git a/drivers/staging/most/configfs.c b/drivers/staging/most/configfs.c
new file mode 100644
index 000..b8d4fd5
--- /dev/null
+++ b/drivers/staging/most/configfs.c
@@ -0,0 +1,623 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * configfs.c - Implementation of configfs interface to the driver stack
+ *
+ * Copyright (C) 2013-2015 Microchip Technology Germany II GmbH & Co. KG
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct mdev_link {
+   struct config_item item;
+   bool create;
+   u16 num_buffers;
+   u16 buffer_size;
+   u16 subbuffer_size;
+   u16 packets_per_xact;
+   u16 dbr_size;
+   char datatype[PAGE_SIZE];
+   char direction[PAGE_SIZE];
+   char name[PAGE_SIZE];
+   char mdev[PAGE_SIZE];
+   char channel[PAGE_SIZE];
+   char comp[PAGE_SIZE];
+   char param[PAGE_SIZE];
+};
+
+static int set_cfg_buffer_size(struct mdev_link *link)
+{
+   if (!link->buffer_size)
+   return -ENODATA;
+   return most_set_cfg_buffer_size(link->mdev, link->channel,
+   link->buffer_size);
+}
+
+static int set_cfg_subbuffer_size(struct mdev_link *link)
+{
+   if (!link->subbuffer_size)
+   return -ENODATA;
+   return most_set_cfg_subbuffer_size(link->mdev, link->channel,
+  link->subbuffer_size);
+}
+
+static int set_cfg_dbr_size(struct mdev_link *link)
+{
+   if (!link->dbr_size)
+   return -ENODATA;
+   return most_set_cfg_dbr_size(link->mdev, link->channel,
+link->dbr_size);
+}
+
+static int set_cfg_num_buffers(struct mdev_link *link)
+{
+   if (!link->num_buffers)
+   return -ENODATA;
+   return most_set_cfg_num_buffers(link->mdev, link->channel,
+   link->num_buffers);
+}
+
+static int set_cfg_packets_xact(struct mdev_link *link)
+{
+   if (!link->packets_per_xact)
+   return -ENODATA;
+   return most_set_cfg_packets_xact(link->mdev, link->channel,
+link->packets_per_xact);
+}
+
+static int set_cfg_direction(struct mdev_link *link)
+{
+   if (!strlen(link->direction))
+   return -ENODATA;
+   return most_set_cfg_direction(link->mdev, link->channel,
+ link->direction);
+}
+
+static int set_cfg_datatype(struct mdev_link *link)
+{
+   if (!strlen(link->datatype))
+   return -ENODATA;
+   return most_set_cfg_datatype(link->mdev, link->channel,
+link->datatype);
+}
+
+static int (*set_config_val[])(struct mdev_link *link) = {
+   set_cfg_buffer_size,
+   set_cfg_subbuffer_size,
+   set_cfg_dbr_size,
+   set_cfg_num_buffers,
+   set_cfg_packets_xact,
+   set_cfg_direction,
+   set_cfg_datatype,
+};
+
+static struct mdev_link *to_mdev_link(struct config_item *item)
+{
+   return container_of(item, struct mdev_link, item);
+}
+
+static ssize_t mdev_link_create_show(struct config_item *item, char *page)
+{
+   return snprintf(page, PAGE_SIZE, "%d\n", to_mdev_link(item)->create);
+}
+
+static ssize_t mdev_link_create_store(struct config_item *item,
+ const char *page, size_t count)
+{
+   struct mdev_link *mdev_link = to_mdev_link(item);
+   bool tmp;
+   int ret;
+   int i;
+
+   ret = kstrtobool(page, );
+   if (ret)
+   return ret;
+
+   for (i = 0; i < ARRAY_SIZE(set_config_val); i++) {
+   ret = set_config_val[i](mdev_link);
+   if (ret < 0)
+   return ret;
+   }
+
+   if (tmp)
+   ret = most_add_link(mdev_link->mdev, mdev_link->channel,
+   mdev_link->comp, mdev_link->name,
+   mdev_link->param);
+   else
+   ret = most_remove_link(mdev_link->mdev, mdev_link->channel,
+ 

[PATCH v3 05/14] staging: most: enable configfs support

2019-04-01 Thread Christian Gromm
This patch enables the configfs functionality of the driver by
registering the configfs subsystems and compiling the configfs
part of the sources.

Signed-off-by: Christian Gromm 
---
v2:
- remove call to configfs_exit function
v3:

 drivers/staging/most/Makefile  |  1 +
 drivers/staging/most/cdev/cdev.c   |  6 ++
 drivers/staging/most/core.c|  2 +-
 drivers/staging/most/sound/sound.c | 11 ++-
 4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/most/Makefile b/drivers/staging/most/Makefile
index c7662f6..85ea5a4 100644
--- a/drivers/staging/most/Makefile
+++ b/drivers/staging/most/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_MOST) += most_core.o
 most_core-y := core.o
+most_core-y += configfs.o
 ccflags-y += -I $(srctree)/drivers/staging/
 
 obj-$(CONFIG_MOST_CDEV)+= cdev/
diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c
index 97408ec..d98977c 100644
--- a/drivers/staging/most/cdev/cdev.c
+++ b/drivers/staging/most/cdev/cdev.c
@@ -527,8 +527,13 @@ static int __init mod_init(void)
err = most_register_component();
if (err)
goto free_cdev;
+   err = most_register_configfs_subsys();
+   if (err)
+   goto deregister_comp;
return 0;
 
+deregister_comp:
+   most_deregister_component();
 free_cdev:
unregister_chrdev_region(comp.devno, CHRDEV_REGION_SIZE);
 dest_ida:
@@ -543,6 +548,7 @@ static void __exit mod_exit(void)
 
pr_info("exit module\n");
 
+   most_deregister_configfs_subsys();
most_deregister_component();
 
list_for_each_entry_safe(c, tmp, _list, list) {
diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index d5cf58f..e7a8d89 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -1765,7 +1765,7 @@ static int __init most_init(void)
err = -ENOMEM;
goto err_unregister_driver;
}
-
+   configfs_init();
return 0;
 
 err_unregister_driver:
diff --git a/drivers/staging/most/sound/sound.c 
b/drivers/staging/most/sound/sound.c
index 8261742..6b5438c 100644
--- a/drivers/staging/most/sound/sound.c
+++ b/drivers/staging/most/sound/sound.c
@@ -790,16 +790,25 @@ static struct core_component comp = {
 
 static int __init audio_init(void)
 {
+   int ret;
+
pr_info("init()\n");
 
INIT_LIST_HEAD(_list);
 
-   return most_register_component();
+   ret = most_register_component();
+   if (ret)
+   pr_err("Failed to register %s\n", comp.name);
+   ret = most_register_configfs_subsys();
+   if (ret)
+   pr_err("Failed to register %s configfs subsys\n", comp.name);
+   return ret;
 }
 
 static void __exit audio_exit(void)
 {
pr_info("exit()\n");
+   most_deregister_configfs_subsys();
most_deregister_component();
 }
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 09/14] staging: most: core: remove attribute add_link

2019-04-01 Thread Christian Gromm
This patch removes the driver attribute add_link. It is not needed, because
the link management is now done via configfs.

Signed-off-by: Christian Gromm 
---
v2:
v3:

 drivers/staging/most/core.c | 61 -
 1 file changed, 61 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index e0a6806..df1d774 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -616,65 +616,6 @@ inline int link_channel_to_component(struct most_channel 
*c,
return 0;
 }
 
-/**
- * add_link_store - store function for add_link attribute
- * @drv: device driver
- * @buf: buffer
- * @len: buffer length
- *
- * This parses the string given by buf and splits it into
- * four substrings. Note: last substring is optional. In case a cdev
- * component is loaded the optional 4th substring will make up the name of
- * device node in the /dev directory. If omitted, the device node will
- * inherit the channel's name within sysfs.
- *
- * Searches for (device, channel) pair and probes the component
- *
- * Example:
- * (1) echo "mdev0:ch6:cdev:my_rxchannel" >add_link
- * (2) echo "mdev1:ep81:cdev" >add_link
- *
- * (1) would create the device node /dev/my_rxchannel
- * (2) would create the device node /dev/mdev1-ep81
- */
-static ssize_t add_link_store(struct device_driver *drv,
- const char *buf,
- size_t len)
-{
-   struct most_channel *c;
-   struct core_component *comp;
-   char buffer[STRING_SIZE];
-   char *mdev;
-   char *mdev_ch;
-   char *comp_name;
-   char *comp_param;
-   char devnod_buf[STRING_SIZE];
-   int ret;
-   size_t max_len = min_t(size_t, len + 1, STRING_SIZE);
-
-   strlcpy(buffer, buf, max_len);
-   ret = split_string(buffer, , _ch, _name, _param);
-   if (ret)
-   return ret;
-   comp = match_component(comp_name);
-   if (!comp)
-   return -ENODEV;
-   if (!comp_param || *comp_param == 0) {
-   snprintf(devnod_buf, sizeof(devnod_buf), "%s-%s", mdev,
-mdev_ch);
-   comp_param = devnod_buf;
-   }
-
-   c = get_channel(mdev, mdev_ch);
-   if (!c)
-   return -ENODEV;
-
-   ret = link_channel_to_component(c, comp, "name", comp_param);
-   if (ret)
-   return ret;
-   return len;
-}
-
 int most_set_cfg_buffer_size(char *mdev, char *mdev_ch, u16 val)
 {
struct most_channel *c = get_channel(mdev, mdev_ch);
@@ -863,13 +804,11 @@ int most_remove_link(char *mdev, char *mdev_ch, char 
*comp_name)
 
 static DRIVER_ATTR_RO(links);
 static DRIVER_ATTR_RO(components);
-static DRIVER_ATTR_WO(add_link);
 static DRIVER_ATTR_WO(remove_link);
 
 static struct attribute *mc_attrs[] = {
DRV_ATTR(links),
DRV_ATTR(components),
-   DRV_ATTR(add_link),
DRV_ATTR(remove_link),
NULL,
 };
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 11/14] staging: most: configfs: make create attributes write-only

2019-04-01 Thread Christian Gromm
Reading the create attribute that triggers the creation of a link to
a certain channel is not necessary. Hence, it is being removed.

Signed-off-by: Christian Gromm 
---
v2:
v3:

 drivers/staging/most/configfs.c | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/most/configfs.c b/drivers/staging/most/configfs.c
index ee1ad32..9d8b679 100644
--- a/drivers/staging/most/configfs.c
+++ b/drivers/staging/most/configfs.c
@@ -103,11 +103,6 @@ static struct mdev_link *to_mdev_link(struct config_item 
*item)
return container_of(item, struct mdev_link, item);
 }
 
-static ssize_t mdev_link_create_show(struct config_item *item, char *page)
-{
-   return snprintf(page, PAGE_SIZE, "%d\n", to_mdev_link(item)->create);
-}
-
 static int set_config_and_add_link(struct mdev_link *mdev_link)
 {
int i;
@@ -329,7 +324,7 @@ static ssize_t mdev_link_dbr_size_store(struct config_item 
*item,
return count;
 }
 
-CONFIGFS_ATTR(mdev_link_, create);
+CONFIGFS_ATTR_WO(mdev_link_, create);
 CONFIGFS_ATTR(mdev_link_, mdev);
 CONFIGFS_ATTR(mdev_link_, channel);
 CONFIGFS_ATTR(mdev_link_, comp);
@@ -477,11 +472,6 @@ static struct config_item *most_snd_grp_make_item(struct 
config_group *group,
return _link->item;
 }
 
-static ssize_t most_snd_grp_create_show(struct config_item *item, char *page)
-{
-   return snprintf(page, PAGE_SIZE, "%d\n", to_most_snd_grp(item)->create);
-}
-
 static ssize_t most_snd_grp_create_store(struct config_item *item,
 const char *page, size_t count)
 {
@@ -501,7 +491,7 @@ static ssize_t most_snd_grp_create_store(struct config_item 
*item,
return count;
 }
 
-CONFIGFS_ATTR(most_snd_grp_, create);
+CONFIGFS_ATTR_WO(most_snd_grp_, create);
 
 static struct configfs_attribute *most_snd_grp_attrs[] = {
_snd_grp_attr_create,
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 00/14] staging: most: switch to configfs

2019-04-01 Thread Christian Gromm
This patch set makes the driver provide its configuration interface via
configfs. The configuration interface is being switched to simplify the
process of setting up the driver and to introduce the new feature of
speculative configuration.

v2:
v3:

Christian Gromm (14):
  staging: most: add new file configfs.c
  staging: most: change signature of function probe_channel
  staging: most: core: add configfs interface functions
  staging: most: sound: introduce new sound adapter management
  staging: most: enable configfs support
  staging: most: core: make sysfs attributes read-only
  staging: most: core: use device description as name
  staging: most: usb: remove prefix from description tag
  staging: most: core: remove attribute add_link
  staging: most: allow speculative configuration
  staging: most: configfs: make create attributes write-only
  staging: most: configfs: add code for link removal
  staging: most: configfs: rename config attributes
  staging: most: Documentation: update driver documentation

 .../most/Documentation/ABI/configfs-most.txt   | 204 +++
 .../staging/most/Documentation/driver_usage.txt| 131 ++--
 drivers/staging/most/Makefile  |   1 +
 drivers/staging/most/cdev/cdev.c   |   8 +-
 drivers/staging/most/configfs.c| 676 +
 drivers/staging/most/core.c| 305 +-
 drivers/staging/most/core.h|  20 +-
 drivers/staging/most/net/net.c |   3 +-
 drivers/staging/most/sound/sound.c |  59 +-
 drivers/staging/most/usb/usb.c |   2 +-
 drivers/staging/most/video/video.c |   3 +-
 11 files changed, 1164 insertions(+), 248 deletions(-)
 create mode 100644 drivers/staging/most/Documentation/ABI/configfs-most.txt
 create mode 100644 drivers/staging/most/configfs.c

-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 12/14] staging: most: configfs: add code for link removal

2019-04-01 Thread Christian Gromm
This patch adds code that cleans up established links whenever the destroy
attribute is set or if the config_item (directory) is being removed.

Signed-off-by: Christian Gromm 
---
v2:
- follow-up adaptions due to changes introduced w/ [PATCH v2 01/14]
v3:

 drivers/staging/most/configfs.c | 38 --
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/most/configfs.c b/drivers/staging/most/configfs.c
index 9d8b679..d430df2 100644
--- a/drivers/staging/most/configfs.c
+++ b/drivers/staging/most/configfs.c
@@ -16,6 +16,7 @@ struct mdev_link {
struct config_item item;
struct list_head list;
bool create;
+   bool destroy;
u16 num_buffers;
u16 buffer_size;
u16 subbuffer_size;
@@ -132,8 +133,7 @@ static ssize_t mdev_link_create_store(struct config_item 
*item,
if (ret)
return ret;
if (!tmp)
-   return most_remove_link(mdev_link->mdev, mdev_link->channel,
-   mdev_link->comp);
+   return count;
ret = set_config_and_add_link(mdev_link);
if (ret && ret != -ENODEV)
return ret;
@@ -142,6 +142,28 @@ static ssize_t mdev_link_create_store(struct config_item 
*item,
return count;
 }
 
+static ssize_t mdev_link_destroy_store(struct config_item *item,
+  const char *page, size_t count)
+{
+   struct mdev_link *mdev_link = to_mdev_link(item);
+   bool tmp;
+   int ret;
+
+   ret = kstrtobool(page, );
+   if (ret)
+   return ret;
+   if (!tmp)
+   return count;
+   mdev_link->destroy = tmp;
+   ret = most_remove_link(mdev_link->mdev, mdev_link->channel,
+  mdev_link->comp);
+   if (ret)
+   return ret;
+   if (!list_empty(_link_list))
+   list_del(_link->list);
+   return count;
+}
+
 static ssize_t mdev_link_direction_show(struct config_item *item, char *page)
 {
return snprintf(page, PAGE_SIZE, "%s\n", to_mdev_link(item)->direction);
@@ -325,6 +347,7 @@ static ssize_t mdev_link_dbr_size_store(struct config_item 
*item,
 }
 
 CONFIGFS_ATTR_WO(mdev_link_, create);
+CONFIGFS_ATTR_WO(mdev_link_, destroy);
 CONFIGFS_ATTR(mdev_link_, mdev);
 CONFIGFS_ATTR(mdev_link_, channel);
 CONFIGFS_ATTR(mdev_link_, comp);
@@ -339,6 +362,7 @@ CONFIGFS_ATTR(mdev_link_, dbr_size);
 
 static struct configfs_attribute *mdev_link_attrs[] = {
_link_attr_create,
+   _link_attr_destroy,
_link_attr_mdev,
_link_attr_channel,
_link_attr_comp,
@@ -355,6 +379,16 @@ static struct configfs_attribute *mdev_link_attrs[] = {
 
 static void mdev_link_release(struct config_item *item)
 {
+   struct mdev_link *mdev_link = to_mdev_link(item);
+   int ret;
+
+   if (!list_empty(_link_list)) {
+   ret = most_remove_link(mdev_link->mdev, mdev_link->channel,
+  mdev_link->comp);
+   if (ret && (ret != -ENODEV))
+   pr_err("Removing link failed.\n");
+   list_del(_link->list);
+   }
kfree(to_mdev_link(item));
 }
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 04/14] staging: most: sound: introduce new sound adapter management

2019-04-01 Thread Christian Gromm
This patch adapts the sound card management to the configfs changes.

Signed-off-by: Christian Gromm 
---
v2:
v3:
Reported-by: Dan Carpenter 
- return 0 in function audio_create_sound_card

 drivers/staging/most/sound/sound.c | 41 +-
 1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/most/sound/sound.c 
b/drivers/staging/most/sound/sound.c
index 02fcd32..8261742 100644
--- a/drivers/staging/most/sound/sound.c
+++ b/drivers/staging/most/sound/sound.c
@@ -471,17 +471,11 @@ static const struct snd_pcm_ops pcm_ops = {
.page   = snd_pcm_lib_get_vmalloc_page,
 };
 
-static int split_arg_list(char *buf, char **device_name, u16 *ch_num,
- char **sample_res, u8 *create)
+static int split_arg_list(char *buf, u16 *ch_num, char **sample_res)
 {
char *num;
int ret;
 
-   *device_name = strsep(, ".");
-   if (!*device_name) {
-   pr_err("Missing sound card name\n");
-   return -EIO;
-   }
num = strsep(, "x");
if (!num)
goto err;
@@ -492,8 +486,6 @@ static int split_arg_list(char *buf, char **device_name, 
u16 *ch_num,
if (!*sample_res)
goto err;
 
-   if (buf && !strcmp(buf, "create"))
-   *create = 1;
return 0;
 
 err:
@@ -589,7 +581,6 @@ static int audio_probe_channel(struct most_interface 
*iface, int channel_id,
int ret;
int direction;
u16 ch_num;
-   u8 create = 0;
char *sample_res;
 
if (!iface)
@@ -600,8 +591,7 @@ static int audio_probe_channel(struct most_interface 
*iface, int channel_id,
return -EINVAL;
}
 
-   ret = split_arg_list(arg_list, _name, _num, _res,
-);
+   ret = split_arg_list(arg_list, _num, _res);
if (ret < 0)
return ret;
 
@@ -672,12 +662,6 @@ static int audio_probe_channel(struct most_interface 
*iface, int channel_id,
strscpy(pcm->name, device_name, sizeof(pcm->name));
snd_pcm_set_ops(pcm, direction, _ops);
 
-   if (create) {
-   ret = snd_card_register(adpt->card);
-   if (ret < 0)
-   goto err_free_adpt;
-   adpt->registered = true;
-   }
return 0;
 
 err_free_adpt:
@@ -685,6 +669,26 @@ static int audio_probe_channel(struct most_interface 
*iface, int channel_id,
return ret;
 }
 
+static int audio_create_sound_card(void)
+{
+   int ret;
+   struct sound_adapter *adpt;
+
+   list_for_each_entry(adpt, _list, list) {
+   if (!adpt->registered)
+   goto adpt_alloc;
+   }
+   return -ENODEV;
+adpt_alloc:
+   ret = snd_card_register(adpt->card);
+   if (ret < 0) {
+   release_adapter(adpt);
+   return ret;
+   }
+   adpt->registered = true;
+   return 0;
+}
+
 /**
  * audio_disconnect_channel - function to disconnect a channel
  * @iface: pointer to interface instance
@@ -781,6 +785,7 @@ static struct core_component comp = {
.disconnect_channel = audio_disconnect_channel,
.rx_completion = audio_rx_completion,
.tx_completion = audio_tx_completion,
+   .cfg_complete = audio_create_sound_card,
 };
 
 static int __init audio_init(void)
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] mips: ralink: allow to choose function which belongs with multiple groups

2019-04-01 Thread John Crispin

On 31/03/2019 09:31, NOGUCHI Hiroshi wrote:

This allows the signals which can be assigned from multiple GPIO pins
to be really assigned as expected.

That one case is "refclk" signal in MT76x8.
It was forcibily assigned to the pin matched by signal name at first.
Eventually it always appears as GPIO #37. We cannot use refclk with the other 
pin.


Hi,

have you considered using pinctrl-simple instead ? the rt2880 style 
pinmux is a simple register (or 2 on the newer versions) and there is no 
need for a dedicated driver.


    John




Signed-off-by: NOGUCHI Hiroshi 
---
  arch/mips/include/asm/mach-ralink/pinmux.h|   3 +-
  .../staging/mt7621-pinctrl/pinctrl-rt2880.c   | 164 ++
  2 files changed, 136 insertions(+), 31 deletions(-)

diff --git a/arch/mips/include/asm/mach-ralink/pinmux.h 
b/arch/mips/include/asm/mach-ralink/pinmux.h
index ba8ac331af0c..e2974a04ff61 100644
--- a/arch/mips/include/asm/mach-ralink/pinmux.h
+++ b/arch/mips/include/asm/mach-ralink/pinmux.h
@@ -32,8 +32,7 @@ struct rt2880_pmx_func {
int pin_count;
int *pins;
  
-	int *groups;

-   int group_count;
+   int group_idx;
  
  	int enabled;

  };
diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c 
b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
index 9b52d44abef1..bdfd93dba02c 100644
--- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
+++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
@@ -26,6 +26,12 @@
  #define SYSC_REG_GPIO_MODE0x60
  #define SYSC_REG_GPIO_MODE2   0x64
  
+struct rt2880_func_group_map {

+   const char *func_name;
+   const char **group_names;
+   int num_groups;
+};
+
  struct rt2880_priv {
struct device *dev;
  
@@ -39,6 +45,10 @@ struct rt2880_priv {

const char **group_names;
int group_count;
  
+	struct rt2880_func_group_map *func_to_group_map;

+   s16 *group_to_func_map;
+   int func_to_group_count;
+
u8 *gpio;
int max_pins;
  };
@@ -86,7 +96,7 @@ static int rt2880_pmx_func_count(struct pinctrl_dev *pctrldev)
  {
struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev);
  
-	return p->func_count;

+   return p->func_to_group_count;
  }
  
  static const char *rt2880_pmx_func_name(struct pinctrl_dev *pctrldev,

@@ -94,7 +104,7 @@ static const char *rt2880_pmx_func_name(struct pinctrl_dev 
*pctrldev,
  {
struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev);
  
-	return p->func[func]->name;

+   return p->func_to_group_map[func].func_name;
  }
  
  static int rt2880_pmx_group_get_groups(struct pinctrl_dev *pctrldev,

@@ -104,12 +114,8 @@ static int rt2880_pmx_group_get_groups(struct pinctrl_dev 
*pctrldev,
  {
struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev);
  
-	if (p->func[func]->group_count == 1)

-   *groups = >group_names[p->func[func]->groups[0]];
-   else
-   *groups = p->group_names;
-
-   *num_groups = p->func[func]->group_count;
+   *groups = p->func_to_group_map[func].group_names;
+   *num_groups = p->func_to_group_map[func].num_groups;
  
  	return 0;

  }
@@ -122,6 +128,7 @@ static int rt2880_pmx_group_enable(struct pinctrl_dev 
*pctrldev,
u32 reg = SYSC_REG_GPIO_MODE;
int i;
int shift;
+   int func_in_grp;
  
  	/* dont allow double use */

if (p->groups[group].enabled) {
@@ -130,8 +137,13 @@ static int rt2880_pmx_group_enable(struct pinctrl_dev 
*pctrldev,
return -EBUSY;
}
  
+	func_in_grp =

+   p->group_to_func_map[(group * p->func_to_group_count) + func];
+   if (func_in_grp < 0)
+   return -EINVAL;
+
p->groups[group].enabled = 1;
-   p->func[func]->enabled = 1;
+   p->func[func_in_grp]->enabled = 1;
  
  	shift = p->groups[group].shift;

if (shift >= 32) {
@@ -149,9 +161,9 @@ static int rt2880_pmx_group_enable(struct pinctrl_dev 
*pctrldev,
if (func == 0) {
mode |= p->groups[group].gpio << shift;
} else {
-   for (i = 0; i < p->func[func]->pin_count; i++)
-   p->gpio[p->func[func]->pins[i]] = 0;
-   mode |= p->func[func]->value << shift;
+   for (i = 0; i < p->func[func_in_grp]->pin_count; i++)
+   p->gpio[p->func[func_in_grp]->pins[i]] = 0;
+   mode |= p->func[func_in_grp]->value << shift;
}
rt_sysc_w32(mode, reg);
  
@@ -191,6 +203,111 @@ static struct rt2880_pmx_func gpio_func = {

.name = "gpio",
  };
  
+static int rt2880_build_internal_map(struct rt2880_priv *p)

+{
+   int i, j;
+   struct rt2880_func_group_map *f_g;
+   struct rt2880_func_group_map *f_g_tmp;
+   int16_t *g_f;
+   int c = 0;
+   int ret = 0;
+
+   /* func_to_group_map[0] is used for gpio */
+   f_g = devm_kzalloc(p->dev, sizeof(f_g[0]) * 1, GFP_KERNEL);
+   if (!f_g) {
+   ret = -ENOMEM;
+   goto 

Re: [PATCH] Staging: comedi: drivers: pcl818: Fixed a coding style error.

2019-04-01 Thread Mukesh Ojha



On 4/1/2019 4:23 AM, Will Cunningham wrote:

Removed unnecessary parentheses.`

Remove the extra character at the end.

Fix the above thing then you can take.

Reviewed-by: Mukesh Ojha 

Cheers,
-Mukesh



Signed-off-by: Will Cunningham 
---
  drivers/staging/comedi/drivers/pcl818.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/pcl818.c 
b/drivers/staging/comedi/drivers/pcl818.c
index 0af5315d4357..da5d53a288f7 100644
--- a/drivers/staging/comedi/drivers/pcl818.c
+++ b/drivers/staging/comedi/drivers/pcl818.c
@@ -1012,7 +1012,7 @@ static int pcl818_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
pcl818_alloc_dma(dev, it->options[2]);
  
  	/* use 1MHz or 10MHz oscilator */

-   if ((it->options[3] == 0) || (it->options[3] == 10))
+   if (it->options[3] == 0 || it->options[3] == 10)
osc_base = I8254_OSC_BASE_10MHZ;
else
osc_base = I8254_OSC_BASE_1MHZ;
@@ -1026,7 +1026,7 @@ static int pcl818_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
devpriv->ns_min = board->ns_min;
if (!board->is_818) {
/* extended PCL718 to 100kHz DAC */
-   if ((it->options[6] == 1) || (it->options[6] == 100))
+   if (it->options[6] == 1 || it->options[6] == 100)
devpriv->ns_min = 1;
}
  
@@ -1067,12 +1067,12 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)

s->maxdata   = 0x0fff;
s->range_table   = _unipolar5;
if (board->is_818) {
-   if ((it->options[4] == 1) || (it->options[4] == 10))
+   if (it->options[4] == 1 || it->options[4] == 10)
s->range_table = _unipolar10;
if (it->options[4] == 2)
s->range_table = _unknown;
} else {
-   if ((it->options[5] == 1) || (it->options[5] == 10))
+   if (it->options[5] == 1 || it->options[5] == 10)
s->range_table = _unipolar10;
if (it->options[5] == 2)
s->range_table = _unknown;

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: erofs: keep corrupted fs from crashing kernel in erofs_readdir()

2019-04-01 Thread Gao Xiang
Hi,

On 2019/3/30 21:45, Sasha Levin wrote:
> Hi,
> 
> [This is an automated email]
> 
> This commit has been processed because it contains a "Fixes:" tag,
> fixing commit: 3aa8ec716e52 staging: erofs: add directory operations.
> 
> The bot has tested the following trees: v5.0.5, v4.19.32.
> 
> v5.0.5: Build OK!
> v4.19.32: Failed to apply! Possible dependencies:
> 6e78901a9f23 ("staging: erofs: separate erofs_get_meta_page")
> 7dd68b147d60 ("staging: erofs: use explicit unsigned int type")
> 8be31270362b ("staging: erofs: introduce erofs_grab_bio")
> ab47dd2b0819 ("staging: erofs: cleanup z_erofs_vle_work_{lookup, 
> register}")
> 
> 
> How should we proceed with this patch?

I have made a 4.19 patch for this:
https://lore.kernel.org/lkml/20190401065309.68109-2-gaoxian...@huawei.com/

Thanks,
Gao Xiang

> 
> --
> Thanks,
> Sasha
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: comedi: drivers: pcl818: Fixed a coding style error.

2019-04-01 Thread Greg KH
On Sun, Mar 31, 2019 at 06:53:36PM -0400, Will Cunningham wrote:
> Removed unnecessary parentheses.`

Odd trailing character :(

> 
> Signed-off-by: Will Cunningham 
> ---
>  drivers/staging/comedi/drivers/pcl818.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/comedi/drivers/pcl818.c 
> b/drivers/staging/comedi/drivers/pcl818.c
> index 0af5315d4357..da5d53a288f7 100644
> --- a/drivers/staging/comedi/drivers/pcl818.c
> +++ b/drivers/staging/comedi/drivers/pcl818.c
> @@ -1012,7 +1012,7 @@ static int pcl818_attach(struct comedi_device *dev, 
> struct comedi_devconfig *it)
>   pcl818_alloc_dma(dev, it->options[2]);
>  
>   /* use 1MHz or 10MHz oscilator */
> - if ((it->options[3] == 0) || (it->options[3] == 10))
> + if (it->options[3] == 0 || it->options[3] == 10)

No, please leave as-is.  () are there for humans to read, and having to
always remember the order of operations is not something you ever want
to do.

I _REALLY_ hate this option of checkpatch :(

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel