[PATCH 06/50] staging: most: sound: rename module

2017-11-21 Thread Christian Gromm
This patch renames the folder of the sound module. It is needed
to clean up the directory layout of the driver.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/Kconfig  | 2 +-
 drivers/staging/most/{aim-sound => sound}/Kconfig | 6 +++---
 drivers/staging/most/sound/Makefile   | 4 
 drivers/staging/most/{aim-sound => sound}/sound.c | 0
 4 files changed, 8 insertions(+), 4 deletions(-)
 rename drivers/staging/most/{aim-sound => sound}/Kconfig (72%)
 create mode 100644 drivers/staging/most/sound/Makefile
 rename drivers/staging/most/{aim-sound => sound}/sound.c (100%)

diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig
index 68a9c89..3f12711 100644
--- a/drivers/staging/most/Kconfig
+++ b/drivers/staging/most/Kconfig
@@ -21,7 +21,7 @@ source "drivers/staging/most/cdev/Kconfig"
 
 source "drivers/staging/most/net/Kconfig"
 
-source "drivers/staging/most/aim-sound/Kconfig"
+source "drivers/staging/most/sound/Kconfig"
 
 source "drivers/staging/most/aim-v4l2/Kconfig"
 
diff --git a/drivers/staging/most/aim-sound/Kconfig 
b/drivers/staging/most/sound/Kconfig
similarity index 72%
rename from drivers/staging/most/aim-sound/Kconfig
rename to drivers/staging/most/sound/Kconfig
index 3194c21..115262a 100644
--- a/drivers/staging/most/aim-sound/Kconfig
+++ b/drivers/staging/most/sound/Kconfig
@@ -2,12 +2,12 @@
 # MOST ALSA configuration
 #
 
-config AIM_SOUND
-   tristate "ALSA AIM"
+config MOST_SOUND
+   tristate "Sound"
depends on SND
select SND_PCM
---help---
  Say Y here if you want to commumicate via ALSA/sound devices.
 
  To compile this driver as a module, choose M here: the
- module will be called aim_sound.
+ module will be called most_sound.
diff --git a/drivers/staging/most/sound/Makefile 
b/drivers/staging/most/sound/Makefile
new file mode 100644
index 000..eee8774
--- /dev/null
+++ b/drivers/staging/most/sound/Makefile
@@ -0,0 +1,4 @@
+obj-$(CONFIG_MOST_SOUND) += most_sound.o
+
+most_sound-objs := sound.o
+ccflags-y += -Idrivers/staging/
diff --git a/drivers/staging/most/aim-sound/sound.c 
b/drivers/staging/most/sound/sound.c
similarity index 100%
rename from drivers/staging/most/aim-sound/sound.c
rename to drivers/staging/most/sound/sound.c
-- 
2.7.4

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


[PATCH 00/50] staging: most: rework driver architecture and fix defects

2017-11-21 Thread Christian Gromm
This patch set fixes bugs and integrates the driver to the kernel's device
model by revising its architecture. Part of this change is rearranging the
directory layout, renaming of files and folders and thereby creating a
clean driver structure.


Andrey Shvetsov (2):
  staging: most: update driver usage file
  staging: most: core: fix list traversing

Christian Gromm (48):
  staging: most: move core files
  staging: most: cdev: rename module
  staging: most: i2c: rename module
  staging: most: dim2: rename module
  staging: most: net: rename module
  staging: most: sound: rename module
  staging: most: usb: rename module
  staging: most: video: rename module
  staging: most: remove proprietary kobjects
  staging: most: core: remove function get_channel_by_iface
  staging: most: core: add a match function for the bus
  staging: most: core: encapsulate code in function
  staging: most: core: rename structure
  staging: most: core: rename struct most_c_aim_obj to pipe
  staging: most: core: rename struct memeber
  staging: most: core: rename members aim* of struct most_channel
  staging: most: core: use structure to pack driver specific data
  staging: most: core: track aim modules with linked list
  staging: most: core: fix sysfs attribute management
  staging: most: core: remove struct device
  staging: most: core: rename function
  staging: most: core: replace struct most_inst_obj
  staging: most: core: put channel name in struct most_channel
  staging: most: core: remove context pointer
  staging: most: usb: remove pointer initialization
  staging: most: rename struct most_aim
  staging: most: rename functions to register a driver with most_core
  staging: most: core: rename mod_list
  staging: most: core: rename aim variables
  staging: most: core: rename function link_channel_to_aim
  staging: most: net: remove aim designators
  staging: most: sound: remove aim designator
  staging: most: video: remove aim designators
  staging: most: cdev: rename struct aim_channel
  staging: most: cdev: rename variable aim_devno
  staging: most: cdev: rename class instance aim_class
  staging: most: cdev: rename variable cdev_aim
  staging: most: fix comment sections
  staging: most: core: denote modules as components
  staging: most: core: fix formatting
  staging: most: usb: clear functional stall on OUT endpoint
  staging: most: core: fix data type
  staging: most: core: check value returned by match function
  staging: most: cdev: replace function prefix
  staging: most: cdev: bundle module variables in structure
  staging: most: core: remove class generation
  staging: most: add ABI documentation
  staging: most: usb: fix show/store function names

 .../most/Documentation/ABI/sysfs-bus-most.txt  |  313 
 .../staging/most/Documentation/driver_usage.txt|  192 +-
 drivers/staging/most/Kconfig   |   27 +-
 drivers/staging/most/Makefile  |5 +-
 drivers/staging/most/aim-cdev/Makefile |2 +-
 drivers/staging/most/aim-network/Makefile  |2 +-
 drivers/staging/most/aim-sound/Makefile|2 +-
 drivers/staging/most/aim-v4l2/Makefile |2 +-
 drivers/staging/most/{aim-cdev => cdev}/Kconfig|6 +-
 drivers/staging/most/cdev/Makefile |4 +
 drivers/staging/most/{aim-cdev => cdev}/cdev.c |  186 +-
 drivers/staging/most/core.c| 1609 
 .../staging/most/{mostcore/mostcore.h => core.h}   |   69 +-
 drivers/staging/most/{hdm-dim2 => dim2}/Kconfig|6 +-
 drivers/staging/most/dim2/Makefile |4 +
 .../most/{hdm-dim2/dim2_hdm.c => dim2/dim2.c}  |   31 +-
 .../most/{hdm-dim2/dim2_hdm.h => dim2/dim2.h}  |2 +-
 .../most/{hdm-dim2/dim2_errors.h => dim2/errors.h} |2 +-
 .../most/{hdm-dim2/dim2_hal.c => dim2/hal.c}   |8 +-
 .../most/{hdm-dim2/dim2_hal.h => dim2/hal.h}   |4 +-
 .../most/{hdm-dim2/dim2_reg.h => dim2/reg.h}   |2 +-
 drivers/staging/most/dim2/sysfs.c  |   55 +
 .../most/{hdm-dim2/dim2_sysfs.h => dim2/sysfs.h}   |8 +-
 drivers/staging/most/hdm-dim2/Makefile |2 +-
 drivers/staging/most/hdm-dim2/dim2_sysfs.c |  115 --
 drivers/staging/most/hdm-i2c/Makefile  |2 +-
 drivers/staging/most/hdm-usb/Makefile  |2 +-
 drivers/staging/most/{hdm-i2c => i2c}/Kconfig  |6 +-
 drivers/staging/most/i2c/Makefile  |4 +
 .../staging/most/{hdm-i2c/hdm_i2c.c => i2c/i2c.c}  |   11 +-
 drivers/staging/most/mostcore/Kconfig  |   14 -
 drivers/staging/most/mostcore/Makefile |3 -
 drivers/staging/most/mostcore/core.c   | 1949 
 drivers/staging/most/{aim-network => net}/Kconfig  |6 +-
 drivers/staging/most/net/Makefile  |4 +
 .../most/{aim-network/networking.c => net/net.c}   |   51 +-
 drivers/staging/most/{aim-sound => sound}/Kconfig

[PATCH 03/50] staging: most: i2c: rename module

2017-11-21 Thread Christian Gromm
This patch renames the folder of the i2c module. It is needed
to clear the directory layout.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/Kconfig  | 2 +-
 drivers/staging/most/{hdm-i2c => i2c}/Kconfig | 6 +++---
 drivers/staging/most/i2c/Makefile | 4 
 drivers/staging/most/{hdm-i2c/hdm_i2c.c => i2c/i2c.c} | 2 +-
 4 files changed, 9 insertions(+), 5 deletions(-)
 rename drivers/staging/most/{hdm-i2c => i2c}/Kconfig (72%)
 create mode 100644 drivers/staging/most/i2c/Makefile
 rename drivers/staging/most/{hdm-i2c/hdm_i2c.c => i2c/i2c.c} (99%)

diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig
index 60a2825..b3393a5 100644
--- a/drivers/staging/most/Kconfig
+++ b/drivers/staging/most/Kconfig
@@ -27,7 +27,7 @@ source "drivers/staging/most/aim-v4l2/Kconfig"
 
 source "drivers/staging/most/hdm-dim2/Kconfig"
 
-source "drivers/staging/most/hdm-i2c/Kconfig"
+source "drivers/staging/most/i2c/Kconfig"
 
 source "drivers/staging/most/hdm-usb/Kconfig"
 
diff --git a/drivers/staging/most/hdm-i2c/Kconfig 
b/drivers/staging/most/i2c/Kconfig
similarity index 72%
rename from drivers/staging/most/hdm-i2c/Kconfig
rename to drivers/staging/most/i2c/Kconfig
index 6fd7983..79d0ff2 100644
--- a/drivers/staging/most/hdm-i2c/Kconfig
+++ b/drivers/staging/most/i2c/Kconfig
@@ -2,11 +2,11 @@
 # MOST I2C configuration
 #
 
-config HDM_I2C
-   tristate "I2C HDM"
+config MOST_I2C
+   tristate "I2C"
depends on I2C
---help---
  Say Y here if you want to connect via I2C to network tranceiver.
 
  To compile this driver as a module, choose M here: the
- module will be called hdm_i2c.
+ module will be called most_i2c.
diff --git a/drivers/staging/most/i2c/Makefile 
b/drivers/staging/most/i2c/Makefile
new file mode 100644
index 000..a7d094c
--- /dev/null
+++ b/drivers/staging/most/i2c/Makefile
@@ -0,0 +1,4 @@
+obj-$(CONFIG_MOST_I2C) += most_i2c.o
+
+most_i2c-objs := i2c.o
+ccflags-y += -Idrivers/staging/
diff --git a/drivers/staging/most/hdm-i2c/hdm_i2c.c 
b/drivers/staging/most/i2c/i2c.c
similarity index 99%
rename from drivers/staging/most/hdm-i2c/hdm_i2c.c
rename to drivers/staging/most/i2c/i2c.c
index 746d56f..6081943 100644
--- a/drivers/staging/most/hdm-i2c/hdm_i2c.c
+++ b/drivers/staging/most/i2c/i2c.c
@@ -1,5 +1,5 @@
 /*
- * hdm_i2c.c - Hardware Dependent Module for I2C Interface
+ * i2c.c - Hardware Dependent Module for I2C Interface
  *
  * Copyright (C) 2013-2015, Microchip Technology Germany II GmbH & Co. KG
  *
-- 
2.7.4

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


[PATCH 09/50] staging: most: remove proprietary kobjects

2017-11-21 Thread Christian Gromm
This patch removes the proprietary kobjects used by the driver modules and
replaces them with device structs. The patch is needed to have the driver
being integrated into the kernel's device model.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/cdev/cdev.c   |   6 +-
 drivers/staging/most/core.c| 803 +++--
 drivers/staging/most/core.h|  13 +-
 drivers/staging/most/dim2/dim2.c   |  19 +-
 drivers/staging/most/dim2/sysfs.c  |  92 +
 drivers/staging/most/dim2/sysfs.h  |   6 +-
 drivers/staging/most/i2c/i2c.c |   7 +-
 drivers/staging/most/net/net.c |   3 +-
 drivers/staging/most/sound/sound.c |   3 +-
 drivers/staging/most/usb/usb.c | 243 +++
 drivers/staging/most/video/video.c |   3 +-
 11 files changed, 342 insertions(+), 856 deletions(-)

diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c
index b6849c8..c6baa9c 100644
--- a/drivers/staging/most/cdev/cdev.c
+++ b/drivers/staging/most/cdev/cdev.c
@@ -418,7 +418,6 @@ static int aim_tx_completion(struct most_interface *iface, 
int channel_id)
  * @iface: pointer to interface instance
  * @channel_id: channel index/ID
  * @cfg: pointer to actual channel configuration
- * @parent: pointer to kobject (needed for sysfs hook-up)
  * @name: name of the device to be created
  *
  * This allocates achannel object and creates the device node in /dev
@@ -426,15 +425,14 @@ static int aim_tx_completion(struct most_interface 
*iface, int channel_id)
  * Returns 0 on success or error code otherwise.
  */
 static int aim_probe(struct most_interface *iface, int channel_id,
-struct most_channel_config *cfg,
-struct kobject *parent, char *name)
+struct most_channel_config *cfg, char *name)
 {
struct aim_channel *c;
unsigned long cl_flags;
int retval;
int current_minor;
 
-   if ((!iface) || (!cfg) || (!parent) || (!name)) {
+   if ((!iface) || (!cfg) || (!name)) {
pr_info("Probing AIM with bad arguments");
return -EINVAL;
}
diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 6ee6acf..8c9b10d 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -33,7 +33,7 @@
 #define STRING_SIZE80
 
 static struct class *most_class;
-static struct device *core_dev;
+static struct device core_dev;
 static struct ida mdev_id;
 static int dummy_num_buffers;
 
@@ -44,7 +44,7 @@ struct most_c_aim_obj {
 };
 
 struct most_c_obj {
-   struct kobject kobj;
+   struct device dev;
struct completion cleanup;
atomic_t mbo_ref;
atomic_t mbo_nq_level;
@@ -69,14 +69,13 @@ struct most_c_obj {
wait_queue_head_t hdm_fifo_wq;
 };
 
-#define to_c_obj(d) container_of(d, struct most_c_obj, kobj)
+#define to_c_obj(d) container_of(d, struct most_c_obj, dev)
 
 struct most_inst_obj {
int dev_id;
struct most_interface *iface;
struct list_head channel_list;
struct most_c_obj *channel[MAX_CHANNELS];
-   struct kobject kobj;
struct list_head list;
 };
 
@@ -91,8 +90,6 @@ static const struct {
{ MOST_CH_ISOC, "isoc_avp\n"},
 };
 
-#define to_inst_obj(d) container_of(d, struct most_inst_obj, kobj)
-
 /**
  * list_pop_mbo - retrieves the first MBO of the list and removes it
  * @ptr: the list head to grab the MBO from.
@@ -109,68 +106,6 @@ static const struct {
  */
 
 /**
- * struct most_c_attr - to access the attributes of a channel object
- * @attr: attributes of a channel
- * @show: pointer to the show function
- * @store: pointer to the store function
- */
-struct most_c_attr {
-   struct attribute attr;
-   ssize_t (*show)(struct most_c_obj *d,
-   struct most_c_attr *attr,
-   char *buf);
-   ssize_t (*store)(struct most_c_obj *d,
-struct most_c_attr *attr,
-const char *buf,
-size_t count);
-};
-
-#define to_channel_attr(a) container_of(a, struct most_c_attr, attr)
-
-/**
- * channel_attr_show - show function of channel object
- * @kobj: pointer to its kobject
- * @attr: pointer to its attributes
- * @buf: buffer
- */
-static ssize_t channel_attr_show(struct kobject *kobj, struct attribute *attr,
-char *buf)
-{
-   struct most_c_attr *channel_attr = to_channel_attr(attr);
-   struct most_c_obj *c_obj = to_c_obj(kobj);
-
-   if (!channel_attr->show)
-   return -EIO;
-
-   return channel_attr->show(c_obj, channel_attr, buf);
-}
-
-/**
- * channel_attr_store - store function of channel object
- * @kobj: pointer to its kobject
- * @attr: pointer to its attributes
- * @buf: buffer
- * @len: length of buffer
- */
-static ssize_t channel_attr_store(struct kobject *kobj,
- struct attribute *attr,
- 

[PATCH 02/50] staging: most: cdev: rename module

2017-11-21 Thread Christian Gromm
This patch renames the folder of the cdev module. This is needed
to clear the directory layout.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/Kconfig| 2 +-
 drivers/staging/most/{aim-cdev => cdev}/Kconfig | 6 +++---
 drivers/staging/most/cdev/Makefile  | 4 
 drivers/staging/most/{aim-cdev => cdev}/cdev.c  | 0
 4 files changed, 8 insertions(+), 4 deletions(-)
 rename drivers/staging/most/{aim-cdev => cdev}/Kconfig (70%)
 create mode 100644 drivers/staging/most/cdev/Makefile
 rename drivers/staging/most/{aim-cdev => cdev}/cdev.c (100%)

diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig
index 2045f7a..60a2825 100644
--- a/drivers/staging/most/Kconfig
+++ b/drivers/staging/most/Kconfig
@@ -17,7 +17,7 @@ menuconfig MOST
 
 if MOST
 
-source "drivers/staging/most/aim-cdev/Kconfig"
+source "drivers/staging/most/cdev/Kconfig"
 
 source "drivers/staging/most/aim-network/Kconfig"
 
diff --git a/drivers/staging/most/aim-cdev/Kconfig 
b/drivers/staging/most/cdev/Kconfig
similarity index 70%
rename from drivers/staging/most/aim-cdev/Kconfig
rename to drivers/staging/most/cdev/Kconfig
index 3c59f1b..2b04e26 100644
--- a/drivers/staging/most/aim-cdev/Kconfig
+++ b/drivers/staging/most/cdev/Kconfig
@@ -2,11 +2,11 @@
 # MOST Cdev configuration
 #
 
-config AIM_CDEV
-   tristate "Cdev AIM"
+config MOST_CDEV
+   tristate "Cdev"
 
---help---
  Say Y here if you want to commumicate via character devices.
 
  To compile this driver as a module, choose M here: the
- module will be called aim_cdev.
\ No newline at end of file
+ module will be called most_cdev.
diff --git a/drivers/staging/most/cdev/Makefile 
b/drivers/staging/most/cdev/Makefile
new file mode 100644
index 000..afb9870
--- /dev/null
+++ b/drivers/staging/most/cdev/Makefile
@@ -0,0 +1,4 @@
+obj-$(CONFIG_MOST_CDEV) += most_cdev.o
+
+most_cdev-objs := cdev.o
+ccflags-y += -Idrivers/staging/
diff --git a/drivers/staging/most/aim-cdev/cdev.c 
b/drivers/staging/most/cdev/cdev.c
similarity index 100%
rename from drivers/staging/most/aim-cdev/cdev.c
rename to drivers/staging/most/cdev/cdev.c
-- 
2.7.4

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


[PATCH 01/50] staging: most: move core files

2017-11-21 Thread Christian Gromm
This patch moves the core files to the root dir of the driver.
This is needed to clean up the directory layout.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/Kconfig | 13 -
 drivers/staging/most/Makefile|  5 -
 drivers/staging/most/aim-cdev/Makefile   |  2 +-
 drivers/staging/most/aim-cdev/cdev.c |  2 +-
 drivers/staging/most/aim-network/Makefile|  2 +-
 drivers/staging/most/aim-network/networking.c|  2 +-
 drivers/staging/most/aim-sound/Makefile  |  2 +-
 drivers/staging/most/aim-sound/sound.c   |  2 +-
 drivers/staging/most/aim-v4l2/Makefile   |  2 +-
 drivers/staging/most/aim-v4l2/video.c|  2 +-
 drivers/staging/most/{mostcore => }/core.c   |  2 +-
 drivers/staging/most/{mostcore/mostcore.h => core.h} |  2 +-
 drivers/staging/most/hdm-dim2/Makefile   |  2 +-
 drivers/staging/most/hdm-dim2/dim2_hdm.c |  2 +-
 drivers/staging/most/hdm-i2c/Makefile|  2 +-
 drivers/staging/most/hdm-i2c/hdm_i2c.c   |  2 +-
 drivers/staging/most/hdm-usb/Makefile|  2 +-
 drivers/staging/most/hdm-usb/hdm_usb.c   |  2 +-
 drivers/staging/most/mostcore/Kconfig| 14 --
 drivers/staging/most/mostcore/Makefile   |  3 ---
 20 files changed, 28 insertions(+), 39 deletions(-)
 rename drivers/staging/most/{mostcore => }/core.c (99%)
 rename drivers/staging/most/{mostcore/mostcore.h => core.h} (99%)
 delete mode 100644 drivers/staging/most/mostcore/Kconfig
 delete mode 100644 drivers/staging/most/mostcore/Makefile

diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig
index 0b9b9b5..2045f7a 100644
--- a/drivers/staging/most/Kconfig
+++ b/drivers/staging/most/Kconfig
@@ -1,10 +1,15 @@
 menuconfig MOST
-tristate "MOST driver"
+tristate "MOST support"
depends on HAS_DMA
-select MOSTCORE
 default n
 ---help---
-  This option allows you to enable support for MOST Network 
transceivers.
+ Say Y here if you want to enable MOST support.
+ This driver needs at least one additional component to enable the
+ desired access from userspace (e.g. character devices) and one that
+ matches the network controller's hardware interface (e.g. USB).
+
+ To compile this driver as a module, choose M here: the
+ module will be called most_core.
 
   If in doubt, say N here.
 
@@ -12,8 +17,6 @@ menuconfig MOST
 
 if MOST
 
-source "drivers/staging/most/mostcore/Kconfig"
-
 source "drivers/staging/most/aim-cdev/Kconfig"
 
 source "drivers/staging/most/aim-network/Kconfig"
diff --git a/drivers/staging/most/Makefile b/drivers/staging/most/Makefile
index f5bbb9d..7f6aa9c 100644
--- a/drivers/staging/most/Makefile
+++ b/drivers/staging/most/Makefile
@@ -1,5 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_MOSTCORE) += mostcore/
+obj-$(CONFIG_MOST) += most_core.o
+most_core-y := core.o
+ccflags-y += -Idrivers/staging/
+
 obj-$(CONFIG_AIM_CDEV) += aim-cdev/
 obj-$(CONFIG_AIM_NETWORK)  += aim-network/
 obj-$(CONFIG_AIM_SOUND)+= aim-sound/
diff --git a/drivers/staging/most/aim-cdev/Makefile 
b/drivers/staging/most/aim-cdev/Makefile
index 0bcc6c6..b7afcb4 100644
--- a/drivers/staging/most/aim-cdev/Makefile
+++ b/drivers/staging/most/aim-cdev/Makefile
@@ -1,4 +1,4 @@
 obj-$(CONFIG_AIM_CDEV) += aim_cdev.o
 
 aim_cdev-objs := cdev.o
-ccflags-y += -Idrivers/staging/most/mostcore/
\ No newline at end of file
+ccflags-y += -Idrivers/staging/
diff --git a/drivers/staging/most/aim-cdev/cdev.c 
b/drivers/staging/most/aim-cdev/cdev.c
index 1e5cbc8..b6849c8 100644
--- a/drivers/staging/most/aim-cdev/cdev.c
+++ b/drivers/staging/most/aim-cdev/cdev.c
@@ -22,7 +22,7 @@
 #include 
 #include 
 #include 
-#include "mostcore.h"
+#include "most/core.h"
 
 static dev_t aim_devno;
 static struct class *aim_class;
diff --git a/drivers/staging/most/aim-network/Makefile 
b/drivers/staging/most/aim-network/Makefile
index 840c1dd..a874aac8d 100644
--- a/drivers/staging/most/aim-network/Makefile
+++ b/drivers/staging/most/aim-network/Makefile
@@ -1,4 +1,4 @@
 obj-$(CONFIG_AIM_NETWORK) += aim_network.o
 
 aim_network-objs := networking.o
-ccflags-y += -Idrivers/staging/most/mostcore/
+ccflags-y += -Idrivers/staging/
diff --git a/drivers/staging/most/aim-network/networking.c 
b/drivers/staging/most/aim-network/networking.c
index 936f013..4936249 100644
--- a/drivers/staging/most/aim-network/networking.c
+++ b/drivers/staging/most/aim-network/networking.c
@@ -21,7 +21,7 @@
 #include 
 #include 
 #include 
-#include "mostcore.h"
+#include "most/core.h"
 
 #define MEP_HDR_LEN 8
 #define MDP_HDR_LEN 16
diff --git a/drivers/staging/most/aim-sound/Makefile 
b/drivers/staging/most/aim-sound/Makefile
index beba958..d41b85b 100644
--- a/drivers/staging/most/aim-

[PATCH 14/50] staging: most: core: rename struct most_c_aim_obj to pipe

2017-11-21 Thread Christian Gromm
This patch replaces the confusing name of struct "most_c_aim_obj" with
"pipe" to better express the function that is behind the structure.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index f7aa5ad..5b51cd3 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -37,7 +37,7 @@ static struct device core_dev;
 static struct ida mdev_id;
 static int dummy_num_buffers;
 
-struct most_c_aim_obj {
+struct pipe {
struct most_aim *ptr;
int refs;
int num_buffers;
@@ -62,8 +62,8 @@ struct most_channel {
spinlock_t fifo_lock;
struct list_head halt_fifo;
struct list_head list;
-   struct most_c_aim_obj aim0;
-   struct most_c_aim_obj aim1;
+   struct pipe aim0;
+   struct pipe aim1;
struct list_head trash_fifo;
struct task_struct *hdm_enqueue_task;
wait_queue_head_t hdm_fifo_wq;
-- 
2.7.4

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


[PATCH 13/50] staging: most: core: rename structure

2017-11-21 Thread Christian Gromm
This patch renames the structure most_c_obj to most_channel. This is needed
to enhance readability.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 104 ++--
 1 file changed, 52 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 662fe1c..f7aa5ad 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -43,7 +43,7 @@ struct most_c_aim_obj {
int num_buffers;
 };
 
-struct most_c_obj {
+struct most_channel {
struct device dev;
struct completion cleanup;
atomic_t mbo_ref;
@@ -69,13 +69,13 @@ struct most_c_obj {
wait_queue_head_t hdm_fifo_wq;
 };
 
-#define to_c_obj(d) container_of(d, struct most_c_obj, dev)
+#define to_channel(d) container_of(d, struct most_channel, dev)
 
 struct most_inst_obj {
int dev_id;
struct most_interface *iface;
struct list_head channel_list;
-   struct most_c_obj *channel[MAX_CHANNELS];
+   struct most_channel *channel[MAX_CHANNELS];
struct list_head list;
 };
 
@@ -112,7 +112,7 @@ static const struct {
  */
 static void most_free_mbo_coherent(struct mbo *mbo)
 {
-   struct most_c_obj *c = mbo->context;
+   struct most_channel *c = mbo->context;
u16 const coherent_buf_size = c->cfg.buffer_size + c->cfg.extra_len;
 
dma_free_coherent(NULL, coherent_buf_size, mbo->virt_address,
@@ -126,7 +126,7 @@ static void most_free_mbo_coherent(struct mbo *mbo)
  * flush_channel_fifos - clear the channel fifos
  * @c: pointer to channel object
  */
-static void flush_channel_fifos(struct most_c_obj *c)
+static void flush_channel_fifos(struct most_channel *c)
 {
unsigned long flags, hf_flags;
struct mbo *mbo, *tmp;
@@ -160,7 +160,7 @@ static void flush_channel_fifos(struct most_c_obj *c)
  * flush_trash_fifo - clear the trash fifo
  * @c: pointer to channel object
  */
-static int flush_trash_fifo(struct most_c_obj *c)
+static int flush_trash_fifo(struct most_channel *c)
 {
struct mbo *mbo, *tmp;
unsigned long flags;
@@ -180,7 +180,7 @@ static ssize_t available_directions_show(struct device *dev,
 struct device_attribute *attr,
 char *buf)
 {
-   struct most_c_obj *c = to_c_obj(dev);
+   struct most_channel *c = to_channel(dev);
unsigned int i = c->channel_id;
 
strcpy(buf, "");
@@ -196,7 +196,7 @@ static ssize_t available_datatypes_show(struct device *dev,
struct device_attribute *attr,
char *buf)
 {
-   struct most_c_obj *c = to_c_obj(dev);
+   struct most_channel *c = to_channel(dev);
unsigned int i = c->channel_id;
 
strcpy(buf, "");
@@ -216,7 +216,7 @@ static ssize_t number_of_packet_buffers_show(struct device 
*dev,
 struct device_attribute *attr,
 char *buf)
 {
-   struct most_c_obj *c = to_c_obj(dev);
+   struct most_channel *c = to_channel(dev);
unsigned int i = c->channel_id;
 
return snprintf(buf, PAGE_SIZE, "%d\n",
@@ -227,7 +227,7 @@ static ssize_t number_of_stream_buffers_show(struct device 
*dev,
 struct device_attribute *attr,
 char *buf)
 {
-   struct most_c_obj *c = to_c_obj(dev);
+   struct most_channel *c = to_channel(dev);
unsigned int i = c->channel_id;
 
return snprintf(buf, PAGE_SIZE, "%d\n",
@@ -238,7 +238,7 @@ static ssize_t size_of_packet_buffer_show(struct device 
*dev,
  struct device_attribute *attr,
  char *buf)
 {
-   struct most_c_obj *c = to_c_obj(dev);
+   struct most_channel *c = to_channel(dev);
unsigned int i = c->channel_id;
 
return snprintf(buf, PAGE_SIZE, "%d\n",
@@ -249,7 +249,7 @@ static ssize_t size_of_stream_buffer_show(struct device 
*dev,
  struct device_attribute *attr,
  char *buf)
 {
-   struct most_c_obj *c = to_c_obj(dev);
+   struct most_channel *c = to_channel(dev);
unsigned int i = c->channel_id;
 
return snprintf(buf, PAGE_SIZE, "%d\n",
@@ -260,7 +260,7 @@ static ssize_t channel_starving_show(struct device *dev,
 struct device_attribute *attr,
 char *buf)
 {
-   struct most_c_obj *c = to_c_obj(dev);
+   struct most_channel *c = to_channel(dev);
 
return snprintf(buf, PAGE_SIZE, "%d\n", c->is_starving);
 }
@@ -269,7 +269,7 @@ static ssize_t set_number_of_buffers_show(struct device 
*dev,
  struct device_attribute *attr,
  

[PATCH 05/50] staging: most: net: rename module

2017-11-21 Thread Christian Gromm
This patch renames the folder and the source file of the networking module.
It is needed to clean up the directory layout of the driver.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/Kconfig | 2 +-
 drivers/staging/most/{aim-network => net}/Kconfig| 6 +++---
 drivers/staging/most/net/Makefile| 4 
 drivers/staging/most/{aim-network/networking.c => net/net.c} | 2 +-
 4 files changed, 9 insertions(+), 5 deletions(-)
 rename drivers/staging/most/{aim-network => net}/Kconfig (69%)
 create mode 100644 drivers/staging/most/net/Makefile
 rename drivers/staging/most/{aim-network/networking.c => net/net.c} (99%)

diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig
index 88a415b..68a9c89 100644
--- a/drivers/staging/most/Kconfig
+++ b/drivers/staging/most/Kconfig
@@ -19,7 +19,7 @@ if MOST
 
 source "drivers/staging/most/cdev/Kconfig"
 
-source "drivers/staging/most/aim-network/Kconfig"
+source "drivers/staging/most/net/Kconfig"
 
 source "drivers/staging/most/aim-sound/Kconfig"
 
diff --git a/drivers/staging/most/aim-network/Kconfig 
b/drivers/staging/most/net/Kconfig
similarity index 69%
rename from drivers/staging/most/aim-network/Kconfig
rename to drivers/staging/most/net/Kconfig
index 4c66b24..795330b 100644
--- a/drivers/staging/most/aim-network/Kconfig
+++ b/drivers/staging/most/net/Kconfig
@@ -2,12 +2,12 @@
 # MOST Networking configuration
 #
 
-config AIM_NETWORK
-   tristate "Networking AIM"
+config MOST_NET
+   tristate "Net"
depends on NET
 
---help---
  Say Y here if you want to commumicate via a networking device.
 
  To compile this driver as a module, choose M here: the
- module will be called aim_network.
+ module will be called most_net.
diff --git a/drivers/staging/most/net/Makefile 
b/drivers/staging/most/net/Makefile
new file mode 100644
index 000..54500aa
--- /dev/null
+++ b/drivers/staging/most/net/Makefile
@@ -0,0 +1,4 @@
+obj-$(CONFIG_MOST_NET) += most_net.o
+
+most_net-objs := net.o
+ccflags-y += -Idrivers/staging/
diff --git a/drivers/staging/most/aim-network/networking.c 
b/drivers/staging/most/net/net.c
similarity index 99%
rename from drivers/staging/most/aim-network/networking.c
rename to drivers/staging/most/net/net.c
index 4936249..9b4a804 100644
--- a/drivers/staging/most/aim-network/networking.c
+++ b/drivers/staging/most/net/net.c
@@ -502,7 +502,7 @@ static int aim_rx_data(struct mbo *mbo)
 }
 
 static struct most_aim aim = {
-   .name = "networking",
+   .name = "net",
.probe_channel = aim_probe_channel,
.disconnect_channel = aim_disconnect_channel,
.tx_completion = aim_resume_tx_channel,
-- 
2.7.4

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


[PATCH 11/50] staging: most: core: add a match function for the bus

2017-11-21 Thread Christian Gromm
This patch adds the function most_match. It is needed to accociate
registered devices and drivers with the bus.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index d8e3b88..dbd7258 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -762,11 +762,20 @@ static const struct attribute_group *aim_attr_groups[] = {
  *  ___C O R E___
  */
 
+int most_match(struct device *dev, struct device_driver *drv)
+{
+   if (!strcmp(dev_name(dev), "most"))
+   return 0;
+   else
+   return 1;
+}
+
 /**
  * Instantiation of the MOST bus
  */
 static struct bus_type most_bus = {
.name = "most",
+   .match = most_match,
 };
 
 /**
-- 
2.7.4

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


[PATCH 10/50] staging: most: core: remove function get_channel_by_iface

2017-11-21 Thread Christian Gromm
This patch removes the function get_channel_by_iface that walks a list of
all registered interfaces and returns a pointer to a channel when matched.
Instead the private field of the interface structure is used to directly
access the channel via the id. The patch is needed to remove unnecessary
list traversing.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 47 +
 1 file changed, 13 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 8c9b10d..d8e3b88 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -995,37 +995,10 @@ static void most_write_completion(struct mbo *mbo)
arm_mbo(mbo);
 }
 
-/**
- * get_channel_by_iface - get pointer to channel object
- * @iface: pointer to interface instance
- * @id: channel ID
- *
- * This retrieves a pointer to a channel of the given interface and channel ID.
- */
-static struct
-most_c_obj *get_channel_by_iface(struct most_interface *iface, int id)
-{
-   struct most_inst_obj *i;
-
-   if (unlikely(!iface)) {
-   pr_err("Bad interface\n");
-   return NULL;
-   }
-   if (unlikely((id < 0) || (id >= iface->num_channels))) {
-   pr_err("Channel index (%d) out of range\n", id);
-   return NULL;
-   }
-   i = iface->priv;
-   if (unlikely(!i)) {
-   pr_err("interface is not registered\n");
-   return NULL;
-   }
-   return i->channel[id];
-}
-
 int channel_has_mbo(struct most_interface *iface, int id, struct most_aim *aim)
 {
-   struct most_c_obj *c = get_channel_by_iface(iface, id);
+   struct most_inst_obj *inst = iface->priv;
+   struct most_c_obj *c = inst->channel[id];
unsigned long flags;
int empty;
 
@@ -1057,10 +1030,11 @@ struct mbo *most_get_mbo(struct most_interface *iface, 
int id,
 {
struct mbo *mbo;
struct most_c_obj *c;
+   struct most_inst_obj *inst = iface->priv;
unsigned long flags;
int *num_buffers_ptr;
 
-   c = get_channel_by_iface(iface, id);
+   c = inst->channel[id];
if (unlikely(!c))
return NULL;
 
@@ -1162,7 +1136,8 @@ int most_start_channel(struct most_interface *iface, int 
id,
 {
int num_buffer;
int ret;
-   struct most_c_obj *c = get_channel_by_iface(iface, id);
+   struct most_inst_obj *inst = iface->priv;
+   struct most_c_obj *c = inst->channel[id];
 
if (unlikely(!c))
return -EINVAL;
@@ -1230,13 +1205,15 @@ EXPORT_SYMBOL_GPL(most_start_channel);
 int most_stop_channel(struct most_interface *iface, int id,
  struct most_aim *aim)
 {
+   struct most_inst_obj *inst;
struct most_c_obj *c;
 
if (unlikely((!iface) || (id >= iface->num_channels) || (id < 0))) {
pr_err("Bad interface or index out of range\n");
return -EINVAL;
}
-   c = get_channel_by_iface(iface, id);
+   inst = iface->priv;
+   c = inst->channel[id];
if (unlikely(!c))
return -EINVAL;
 
@@ -1513,7 +1490,8 @@ EXPORT_SYMBOL_GPL(most_deregister_interface);
  */
 void most_stop_enqueue(struct most_interface *iface, int id)
 {
-   struct most_c_obj *c = get_channel_by_iface(iface, id);
+   struct most_inst_obj *inst = iface->priv;
+   struct most_c_obj *c = inst->channel[id];
 
if (!c)
return;
@@ -1534,7 +1512,8 @@ EXPORT_SYMBOL_GPL(most_stop_enqueue);
  */
 void most_resume_enqueue(struct most_interface *iface, int id)
 {
-   struct most_c_obj *c = get_channel_by_iface(iface, id);
+   struct most_inst_obj *inst = iface->priv;
+   struct most_c_obj *c = inst->channel[id];
 
if (!c)
return;
-- 
2.7.4

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


[PATCH 04/50] staging: most: dim2: rename module

2017-11-21 Thread Christian Gromm
This patch renames the folder and source files of the dim2 module. It is
needed to clear the directory layout of the driver.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/Kconfig   |  2 +-
 drivers/staging/most/{hdm-dim2 => dim2}/Kconfig|  6 +++---
 drivers/staging/most/dim2/Makefile |  4 
 drivers/staging/most/{hdm-dim2/dim2_hdm.c => dim2/dim2.c}  | 10 +-
 drivers/staging/most/{hdm-dim2/dim2_hdm.h => dim2/dim2.h}  |  2 +-
 drivers/staging/most/{hdm-dim2/dim2_errors.h => dim2/errors.h} |  2 +-
 drivers/staging/most/{hdm-dim2/dim2_hal.c => dim2/hal.c}   |  8 
 drivers/staging/most/{hdm-dim2/dim2_hal.h => dim2/hal.h}   |  4 ++--
 drivers/staging/most/{hdm-dim2/dim2_reg.h => dim2/reg.h}   |  2 +-
 drivers/staging/most/{hdm-dim2/dim2_sysfs.c => dim2/sysfs.c}   |  4 ++--
 drivers/staging/most/{hdm-dim2/dim2_sysfs.h => dim2/sysfs.h}   |  2 +-
 11 files changed, 25 insertions(+), 21 deletions(-)
 rename drivers/staging/most/{hdm-dim2 => dim2}/Kconfig (83%)
 create mode 100644 drivers/staging/most/dim2/Makefile
 rename drivers/staging/most/{hdm-dim2/dim2_hdm.c => dim2/dim2.c} (99%)
 rename drivers/staging/most/{hdm-dim2/dim2_hdm.h => dim2/dim2.h} (94%)
 rename drivers/staging/most/{hdm-dim2/dim2_errors.h => dim2/errors.h} (95%)
 rename drivers/staging/most/{hdm-dim2/dim2_hal.c => dim2/hal.c} (99%)
 rename drivers/staging/most/{hdm-dim2/dim2_hal.h => dim2/hal.h} (98%)
 rename drivers/staging/most/{hdm-dim2/dim2_reg.h => dim2/reg.h} (98%)
 rename drivers/staging/most/{hdm-dim2/dim2_sysfs.c => dim2/sysfs.c} (97%)
 rename drivers/staging/most/{hdm-dim2/dim2_sysfs.h => dim2/sysfs.h} (95%)

diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig
index b3393a5..88a415b 100644
--- a/drivers/staging/most/Kconfig
+++ b/drivers/staging/most/Kconfig
@@ -25,7 +25,7 @@ source "drivers/staging/most/aim-sound/Kconfig"
 
 source "drivers/staging/most/aim-v4l2/Kconfig"
 
-source "drivers/staging/most/hdm-dim2/Kconfig"
+source "drivers/staging/most/dim2/Kconfig"
 
 source "drivers/staging/most/i2c/Kconfig"
 
diff --git a/drivers/staging/most/hdm-dim2/Kconfig 
b/drivers/staging/most/dim2/Kconfig
similarity index 83%
rename from drivers/staging/most/hdm-dim2/Kconfig
rename to drivers/staging/most/dim2/Kconfig
index 663bfeb..e39c4e5 100644
--- a/drivers/staging/most/hdm-dim2/Kconfig
+++ b/drivers/staging/most/dim2/Kconfig
@@ -2,8 +2,8 @@
 # MediaLB configuration
 #
 
-config HDM_DIM2
-   tristate "DIM2 HDM"
+config MOST_DIM2
+   tristate "DIM2"
depends on HAS_IOMEM
 
---help---
@@ -13,4 +13,4 @@ config HDM_DIM2
  maintainer of this driver.
 
  To compile this driver as a module, choose M here: the
- module will be called hdm_dim2.
+ module will be called most_dim2.
diff --git a/drivers/staging/most/dim2/Makefile 
b/drivers/staging/most/dim2/Makefile
new file mode 100644
index 000..66676f5
--- /dev/null
+++ b/drivers/staging/most/dim2/Makefile
@@ -0,0 +1,4 @@
+obj-$(CONFIG_MOST_DIM2) += most_dim2.o
+
+most_dim2-objs := dim2.o hal.o sysfs.o
+ccflags-y += -Idrivers/staging/
diff --git a/drivers/staging/most/hdm-dim2/dim2_hdm.c 
b/drivers/staging/most/dim2/dim2.c
similarity index 99%
rename from drivers/staging/most/hdm-dim2/dim2_hdm.c
rename to drivers/staging/most/dim2/dim2.c
index 4793e63..0a1b785 100644
--- a/drivers/staging/most/hdm-dim2/dim2_hdm.c
+++ b/drivers/staging/most/dim2/dim2.c
@@ -1,5 +1,5 @@
 /*
- * dim2_hdm.c - MediaLB DIM2 Hardware Dependent Module
+ * dim2.c - MediaLB DIM2 Hardware Dependent Module
  *
  * Copyright (C) 2015-2016, Microchip Technology Germany II GmbH & Co. KG
  *
@@ -26,10 +26,10 @@
 #include 
 
 #include "most/core.h"
-#include "dim2_hal.h"
-#include "dim2_hdm.h"
-#include "dim2_errors.h"
-#include "dim2_sysfs.h"
+#include "hal.h"
+#include "dim2.h"
+#include "errors.h"
+#include "sysfs.h"
 
 #define DMA_CHANNELS (32 - 1)  /* channel 0 is a system channel */
 
diff --git a/drivers/staging/most/hdm-dim2/dim2_hdm.h 
b/drivers/staging/most/dim2/dim2.h
similarity index 94%
rename from drivers/staging/most/hdm-dim2/dim2_hdm.h
rename to drivers/staging/most/dim2/dim2.h
index 4050e7c..7fff99c 100644
--- a/drivers/staging/most/hdm-dim2/dim2_hdm.h
+++ b/drivers/staging/most/dim2/dim2.h
@@ -1,5 +1,5 @@
 /*
- * dim2_hdm.h - MediaLB DIM2 HDM Header
+ * dim2.h - MediaLB DIM2 HDM Header
  *
  * Copyright (C) 2015, Microchip Technology Germany II GmbH & Co. KG
  *
diff --git a/drivers/staging/most/hdm-dim2/dim2_errors.h 
b/drivers/staging/most/dim2/errors.h
similarity index 95%
rename from drivers/staging/most/hdm-dim2/dim2_errors.h
rename to drivers/staging/most/dim2/errors.h
index 66343ba..0cd8400 100644
--- a/drivers/staging/most/hdm-dim2/dim2_errors.h
+++ b/drivers/staging/most/dim2/errors.h
@@ -1,5 +1,5 @@
 /*
- * dim2_errors.h - Definitions of errors for DIM2 HAL API
+ * errors.h - Definitions of errors for DI

[PATCH 08/50] staging: most: video: rename module

2017-11-21 Thread Christian Gromm
This patch renames the folder of the video module. It is needed
to clean up the directory layout of the driver.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/Kconfig | 2 +-
 drivers/staging/most/{aim-v4l2 => video}/Kconfig | 6 +++---
 drivers/staging/most/video/Makefile  | 4 
 drivers/staging/most/{aim-v4l2 => video}/video.c | 0
 4 files changed, 8 insertions(+), 4 deletions(-)
 rename drivers/staging/most/{aim-v4l2 => video}/Kconfig (71%)
 create mode 100644 drivers/staging/most/video/Makefile
 rename drivers/staging/most/{aim-v4l2 => video}/video.c (100%)

diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig
index 86d4f12..20047ab 100644
--- a/drivers/staging/most/Kconfig
+++ b/drivers/staging/most/Kconfig
@@ -23,7 +23,7 @@ source "drivers/staging/most/net/Kconfig"
 
 source "drivers/staging/most/sound/Kconfig"
 
-source "drivers/staging/most/aim-v4l2/Kconfig"
+source "drivers/staging/most/video/Kconfig"
 
 source "drivers/staging/most/dim2/Kconfig"
 
diff --git a/drivers/staging/most/aim-v4l2/Kconfig 
b/drivers/staging/most/video/Kconfig
similarity index 71%
rename from drivers/staging/most/aim-v4l2/Kconfig
rename to drivers/staging/most/video/Kconfig
index d70eaaf..ce6af4f 100644
--- a/drivers/staging/most/aim-v4l2/Kconfig
+++ b/drivers/staging/most/video/Kconfig
@@ -2,11 +2,11 @@
 # MOST V4L2 configuration
 #
 
-config AIM_V4L2
-   tristate "V4L2 AIM"
+config MOST_VIDEO
+   tristate "Video"
depends on VIDEO_V4L2
---help---
  Say Y here if you want to commumicate via Video 4 Linux.
 
  To compile this driver as a module, choose M here: the
- module will be called aim_v4l2.
\ No newline at end of file
+ module will be called most_video.
diff --git a/drivers/staging/most/video/Makefile 
b/drivers/staging/most/video/Makefile
new file mode 100644
index 000..1c8e520
--- /dev/null
+++ b/drivers/staging/most/video/Makefile
@@ -0,0 +1,4 @@
+obj-$(CONFIG_MOST_VIDEO) += most_video.o
+
+most_video-objs := video.o
+ccflags-y += -Idrivers/staging/
diff --git a/drivers/staging/most/aim-v4l2/video.c 
b/drivers/staging/most/video/video.c
similarity index 100%
rename from drivers/staging/most/aim-v4l2/video.c
rename to drivers/staging/most/video/video.c
-- 
2.7.4

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


[PATCH 12/50] staging: most: core: encapsulate code in function

2017-11-21 Thread Christian Gromm
This patch adds the function link_channel_to_aim to increase readability
of the function add_link_store.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 39 ++-
 1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index dbd7258..662fe1c 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -626,6 +626,30 @@ most_c_obj *get_channel_by_name(char *mdev, char *mdev_ch)
return c;
 }
 
+static inline int link_channel_to_aim(struct most_c_obj *c,
+ struct most_aim *aim, char *aim_param)
+{
+   int ret;
+   struct most_aim **aim_ptr;
+
+   if (!c->aim0.ptr)
+   aim_ptr = &c->aim0.ptr;
+   else if (!c->aim1.ptr)
+   aim_ptr = &c->aim1.ptr;
+   else
+   return -ENOSPC;
+
+   *aim_ptr = aim;
+   ret = aim->probe_channel(c->iface, c->channel_id,
+&c->cfg, aim_param);
+   if (ret) {
+   *aim_ptr = NULL;
+   return ret;
+   }
+
+   return 0;
+}
+
 /**
  * add_link_store - store() function for add_link attribute
  * @aim_obj: pointer to AIM object
@@ -654,7 +678,6 @@ static ssize_t add_link_store(struct device *dev,
  size_t len)
 {
struct most_c_obj *c;
-   struct most_aim **aim_ptr;
struct most_aim *aim = to_most_aim(dev);
char buffer[STRING_SIZE];
char *mdev;
@@ -680,19 +703,9 @@ static ssize_t add_link_store(struct device *dev,
if (IS_ERR(c))
return -ENODEV;
 
-   if (!c->aim0.ptr)
-   aim_ptr = &c->aim0.ptr;
-   else if (!c->aim1.ptr)
-   aim_ptr = &c->aim1.ptr;
-   else
-   return -ENOSPC;
-
-   *aim_ptr = aim;
-   ret = aim->probe_channel(c->iface, c->channel_id, &c->cfg, mdev_devnod);
-   if (ret) {
-   *aim_ptr = NULL;
+   ret = link_channel_to_aim(c, aim, mdev_devnod);
+   if (ret)
return ret;
-   }
 
return len;
 }
-- 
2.7.4

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


[PATCH 24/50] staging: most: core: remove context pointer

2017-11-21 Thread Christian Gromm
This patch removes the unused context pointer that was meant to provide the
opportunity to store context information.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/most/core.h b/drivers/staging/most/core.h
index fe0ad62..fd8a703 100644
--- a/drivers/staging/most/core.h
+++ b/drivers/staging/most/core.h
@@ -278,7 +278,6 @@ struct most_aim {
  int channel_idx);
int (*rx_completion)(struct mbo *mbo);
int (*tx_completion)(struct most_interface *iface, int channel_idx);
-   void *context;
 };
 
 #define to_most_aim(d) container_of(d, struct most_aim, dev)
-- 
2.7.4

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


[PATCH 07/50] staging: most: usb: rename module

2017-11-21 Thread Christian Gromm
This patch renames the folder of the usb module. It is needed
to clean up the  directory layout of the driver.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/Kconfig  | 2 +-
 drivers/staging/most/{hdm-usb => usb}/Kconfig | 7 +++
 drivers/staging/most/usb/Makefile | 4 
 drivers/staging/most/{hdm-usb/hdm_usb.c => usb/usb.c} | 2 +-
 4 files changed, 9 insertions(+), 6 deletions(-)
 rename drivers/staging/most/{hdm-usb => usb}/Kconfig (77%)
 create mode 100644 drivers/staging/most/usb/Makefile
 rename drivers/staging/most/{hdm-usb/hdm_usb.c => usb/usb.c} (99%)

diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig
index 3f12711..86d4f12 100644
--- a/drivers/staging/most/Kconfig
+++ b/drivers/staging/most/Kconfig
@@ -29,6 +29,6 @@ source "drivers/staging/most/dim2/Kconfig"
 
 source "drivers/staging/most/i2c/Kconfig"
 
-source "drivers/staging/most/hdm-usb/Kconfig"
+source "drivers/staging/most/usb/Kconfig"
 
 endif
diff --git a/drivers/staging/most/hdm-usb/Kconfig 
b/drivers/staging/most/usb/Kconfig
similarity index 77%
rename from drivers/staging/most/hdm-usb/Kconfig
rename to drivers/staging/most/usb/Kconfig
index 487f1f3..ebbdb57 100644
--- a/drivers/staging/most/hdm-usb/Kconfig
+++ b/drivers/staging/most/usb/Kconfig
@@ -2,13 +2,12 @@
 # MOST USB configuration
 #
 
-config HDM_USB
-   tristate "USB HDM"
+config MOST_USB
+   tristate "USB"
depends on USB && NET
-
---help---
  Say Y here if you want to connect via USB to network tranceiver.
  This device driver depends on the networking AIM.
 
  To compile this driver as a module, choose M here: the
- module will be called hdm_usb.
+ module will be called most_usb.
diff --git a/drivers/staging/most/usb/Makefile 
b/drivers/staging/most/usb/Makefile
new file mode 100644
index 000..18d28cb
--- /dev/null
+++ b/drivers/staging/most/usb/Makefile
@@ -0,0 +1,4 @@
+obj-$(CONFIG_MOST_USB) += most_usb.o
+
+most_usb-objs := usb.o
+ccflags-y += -Idrivers/staging/
diff --git a/drivers/staging/most/hdm-usb/hdm_usb.c 
b/drivers/staging/most/usb/usb.c
similarity index 99%
rename from drivers/staging/most/hdm-usb/hdm_usb.c
rename to drivers/staging/most/usb/usb.c
index 5734e541..492480d 100644
--- a/drivers/staging/most/hdm-usb/hdm_usb.c
+++ b/drivers/staging/most/usb/usb.c
@@ -1,5 +1,5 @@
 /*
- * hdm_usb.c - Hardware dependent module for USB
+ * usb.c - Hardware dependent module for USB
  *
  * Copyright (C) 2013-2015 Microchip Technology Germany II GmbH & Co. KG
  *
-- 
2.7.4

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


[PATCH 16/50] staging: most: core: rename members aim* of struct most_channel

2017-11-21 Thread Christian Gromm
This patch renames the struct members "aim0" and "aim0" to "pipe0" and
"pipe1".  It is needed to have a conclusive nomenclature of the struct and
its instances.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 104 ++--
 1 file changed, 52 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 193e4ad..2b923fb 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -62,8 +62,8 @@ struct most_channel {
spinlock_t fifo_lock;
struct list_head halt_fifo;
struct list_head list;
-   struct pipe aim0;
-   struct pipe aim1;
+   struct pipe pipe0;
+   struct pipe pipe1;
struct list_head trash_fifo;
struct task_struct *hdm_enqueue_task;
wait_queue_head_t hdm_fifo_wq;
@@ -542,7 +542,7 @@ static ssize_t links_show(struct device *dev, struct 
device_attribute *attr,
 
list_for_each_entry(i, &instance_list, list) {
list_for_each_entry(c, &i->channel_list, list) {
-   if (c->aim0.aim == aim || c->aim1.aim == aim) {
+   if (c->pipe0.aim == aim || c->pipe1.aim == aim) {
offs += snprintf(buf + offs, PAGE_SIZE - offs,
 "%s:%s\n",
 dev_name(&i->iface->dev),
@@ -632,10 +632,10 @@ inline int link_channel_to_aim(struct most_channel *c, 
struct most_aim *aim,
int ret;
struct most_aim **aim_ptr;
 
-   if (!c->aim0.aim)
-   aim_ptr = &c->aim0.aim;
-   else if (!c->aim1.aim)
-   aim_ptr = &c->aim1.aim;
+   if (!c->pipe0.aim)
+   aim_ptr = &c->pipe0.aim;
+   else if (!c->pipe1.aim)
+   aim_ptr = &c->pipe1.aim;
else
return -ENOSPC;
 
@@ -744,10 +744,10 @@ static ssize_t remove_link_store(struct device *dev,
 
if (aim->disconnect_channel(c->iface, c->channel_id))
return -EIO;
-   if (c->aim0.aim == aim)
-   c->aim0.aim = NULL;
-   if (c->aim1.aim == aim)
-   c->aim1.aim = NULL;
+   if (c->pipe0.aim == aim)
+   c->pipe0.aim = NULL;
+   if (c->pipe1.aim == aim)
+   c->pipe1.aim = NULL;
return len;
 }
 
@@ -916,11 +916,11 @@ static void arm_mbo(struct mbo *mbo)
list_add_tail(&mbo->list, &c->fifo);
spin_unlock_irqrestore(&c->fifo_lock, flags);
 
-   if (c->aim0.refs && c->aim0.aim->tx_completion)
-   c->aim0.aim->tx_completion(c->iface, c->channel_id);
+   if (c->pipe0.refs && c->pipe0.aim->tx_completion)
+   c->pipe0.aim->tx_completion(c->iface, c->channel_id);
 
-   if (c->aim1.refs && c->aim1.aim->tx_completion)
-   c->aim1.aim->tx_completion(c->iface, c->channel_id);
+   if (c->pipe1.refs && c->pipe1.aim->tx_completion)
+   c->pipe1.aim->tx_completion(c->iface, c->channel_id);
 }
 
 /**
@@ -1027,9 +1027,9 @@ int channel_has_mbo(struct most_interface *iface, int id, 
struct most_aim *aim)
if (unlikely(!c))
return -EINVAL;
 
-   if (c->aim0.refs && c->aim1.refs &&
-   ((aim == c->aim0.aim && c->aim0.num_buffers <= 0) ||
-(aim == c->aim1.aim && c->aim1.num_buffers <= 0)))
+   if (c->pipe0.refs && c->pipe1.refs &&
+   ((aim == c->pipe0.aim && c->pipe0.num_buffers <= 0) ||
+(aim == c->pipe1.aim && c->pipe1.num_buffers <= 0)))
return 0;
 
spin_lock_irqsave(&c->fifo_lock, flags);
@@ -1060,15 +1060,15 @@ struct mbo *most_get_mbo(struct most_interface *iface, 
int id,
if (unlikely(!c))
return NULL;
 
-   if (c->aim0.refs && c->aim1.refs &&
-   ((aim == c->aim0.aim && c->aim0.num_buffers <= 0) ||
-(aim == c->aim1.aim && c->aim1.num_buffers <= 0)))
+   if (c->pipe0.refs && c->pipe1.refs &&
+   ((aim == c->pipe0.aim && c->pipe0.num_buffers <= 0) ||
+(aim == c->pipe1.aim && c->pipe1.num_buffers <= 0)))
return NULL;
 
-   if (aim == c->aim0.aim)
-   num_buffers_ptr = &c->aim0.num_buffers;
-   else if (aim == c->aim1.aim)
-   num_buffers_ptr = &c->aim1.num_buffers;
+   if (aim == c->pipe0.aim)
+   num_buffers_ptr = &c->pipe0.num_buffers;
+   else if (aim == c->pipe1.aim)
+   num_buffers_ptr = &c->pipe1.num_buffers;
else
num_buffers_ptr = &dummy_num_buffers;
 
@@ -1132,12 +1132,12 @@ static void most_read_completion(struct mbo *mbo)
if (atomic_sub_and_test(1, &c->mbo_nq_level))
c->is_starving = 1;
 
-   if (c->aim0.refs && c->aim0.aim->rx_completion &&
-   c->aim0.aim->rx_completion(mbo) == 0)
+   if (c->pipe0.refs && c->pipe0.aim->rx_completion &&
+   c->pipe0.aim->rx_completion(

[PATCH 20/50] staging: most: core: remove struct device

2017-11-21 Thread Christian Gromm
This patch takes out the struct device of struct most_aim, because it is
not needed.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 17 -
 drivers/staging/most/core.h |  1 -
 2 files changed, 18 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 7014f6a..8f6fa9e 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -1310,32 +1310,16 @@ int most_stop_channel(struct most_interface *iface, int 
id,
 }
 EXPORT_SYMBOL_GPL(most_stop_channel);
 
-void release_aim(struct device *dev)
-{
-   pr_info("releasing aim %s\n", dev_name(dev));
-}
-
 /**
  * most_register_aim - registers an AIM (driver) with the core
  * @aim: instance of AIM to be registered
  */
 int most_register_aim(struct most_aim *aim)
 {
-   int ret;
-
if (!aim) {
pr_err("Bad driver\n");
return -EINVAL;
}
-   aim->dev.init_name = aim->name;
-   aim->dev.bus = &mc.bus;
-   aim->dev.parent = &mc.dev;
-   aim->dev.release = release_aim;
-   ret = device_register(&aim->dev);
-   if (ret) {
-   pr_err("registering device %s failed\n", aim->name);
-   return ret;
-   }
list_add_tail(&aim->list, &mc.mod_list);
pr_info("registered new application interfacing module %s\n", 
aim->name);
return 0;
@@ -1367,7 +1351,6 @@ int most_deregister_aim(struct most_aim *aim)
c->pipe1.aim = NULL;
}
}
-   device_unregister(&aim->dev);
list_del(&aim->list);
pr_info("deregistering application interfacing module %s\n", aim->name);
return 0;
diff --git a/drivers/staging/most/core.h b/drivers/staging/most/core.h
index 0199be0..a4fb75c 100644
--- a/drivers/staging/most/core.h
+++ b/drivers/staging/most/core.h
@@ -268,7 +268,6 @@ struct most_interface {
  * @context: context pointer to be used by mostcore
  */
 struct most_aim {
-   struct device dev;
struct list_head list;
const char *name;
int (*probe_channel)(struct most_interface *iface, int channel_idx,
-- 
2.7.4

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


[PATCH 15/50] staging: most: core: rename struct memeber

2017-11-21 Thread Christian Gromm
This patch renames the member "ptr" of struct pipe to "aim". This is needed
to increase the readability of the code.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 78 ++---
 1 file changed, 39 insertions(+), 39 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 5b51cd3..193e4ad 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -38,7 +38,7 @@ static struct ida mdev_id;
 static int dummy_num_buffers;
 
 struct pipe {
-   struct most_aim *ptr;
+   struct most_aim *aim;
int refs;
int num_buffers;
 };
@@ -542,7 +542,7 @@ static ssize_t links_show(struct device *dev, struct 
device_attribute *attr,
 
list_for_each_entry(i, &instance_list, list) {
list_for_each_entry(c, &i->channel_list, list) {
-   if (c->aim0.ptr == aim || c->aim1.ptr == aim) {
+   if (c->aim0.aim == aim || c->aim1.aim == aim) {
offs += snprintf(buf + offs, PAGE_SIZE - offs,
 "%s:%s\n",
 dev_name(&i->iface->dev),
@@ -632,10 +632,10 @@ inline int link_channel_to_aim(struct most_channel *c, 
struct most_aim *aim,
int ret;
struct most_aim **aim_ptr;
 
-   if (!c->aim0.ptr)
-   aim_ptr = &c->aim0.ptr;
-   else if (!c->aim1.ptr)
-   aim_ptr = &c->aim1.ptr;
+   if (!c->aim0.aim)
+   aim_ptr = &c->aim0.aim;
+   else if (!c->aim1.aim)
+   aim_ptr = &c->aim1.aim;
else
return -ENOSPC;
 
@@ -744,10 +744,10 @@ static ssize_t remove_link_store(struct device *dev,
 
if (aim->disconnect_channel(c->iface, c->channel_id))
return -EIO;
-   if (c->aim0.ptr == aim)
-   c->aim0.ptr = NULL;
-   if (c->aim1.ptr == aim)
-   c->aim1.ptr = NULL;
+   if (c->aim0.aim == aim)
+   c->aim0.aim = NULL;
+   if (c->aim1.aim == aim)
+   c->aim1.aim = NULL;
return len;
 }
 
@@ -916,11 +916,11 @@ static void arm_mbo(struct mbo *mbo)
list_add_tail(&mbo->list, &c->fifo);
spin_unlock_irqrestore(&c->fifo_lock, flags);
 
-   if (c->aim0.refs && c->aim0.ptr->tx_completion)
-   c->aim0.ptr->tx_completion(c->iface, c->channel_id);
+   if (c->aim0.refs && c->aim0.aim->tx_completion)
+   c->aim0.aim->tx_completion(c->iface, c->channel_id);
 
-   if (c->aim1.refs && c->aim1.ptr->tx_completion)
-   c->aim1.ptr->tx_completion(c->iface, c->channel_id);
+   if (c->aim1.refs && c->aim1.aim->tx_completion)
+   c->aim1.aim->tx_completion(c->iface, c->channel_id);
 }
 
 /**
@@ -1028,8 +1028,8 @@ int channel_has_mbo(struct most_interface *iface, int id, 
struct most_aim *aim)
return -EINVAL;
 
if (c->aim0.refs && c->aim1.refs &&
-   ((aim == c->aim0.ptr && c->aim0.num_buffers <= 0) ||
-(aim == c->aim1.ptr && c->aim1.num_buffers <= 0)))
+   ((aim == c->aim0.aim && c->aim0.num_buffers <= 0) ||
+(aim == c->aim1.aim && c->aim1.num_buffers <= 0)))
return 0;
 
spin_lock_irqsave(&c->fifo_lock, flags);
@@ -1061,13 +1061,13 @@ struct mbo *most_get_mbo(struct most_interface *iface, 
int id,
return NULL;
 
if (c->aim0.refs && c->aim1.refs &&
-   ((aim == c->aim0.ptr && c->aim0.num_buffers <= 0) ||
-(aim == c->aim1.ptr && c->aim1.num_buffers <= 0)))
+   ((aim == c->aim0.aim && c->aim0.num_buffers <= 0) ||
+(aim == c->aim1.aim && c->aim1.num_buffers <= 0)))
return NULL;
 
-   if (aim == c->aim0.ptr)
+   if (aim == c->aim0.aim)
num_buffers_ptr = &c->aim0.num_buffers;
-   else if (aim == c->aim1.ptr)
+   else if (aim == c->aim1.aim)
num_buffers_ptr = &c->aim1.num_buffers;
else
num_buffers_ptr = &dummy_num_buffers;
@@ -1132,12 +1132,12 @@ static void most_read_completion(struct mbo *mbo)
if (atomic_sub_and_test(1, &c->mbo_nq_level))
c->is_starving = 1;
 
-   if (c->aim0.refs && c->aim0.ptr->rx_completion &&
-   c->aim0.ptr->rx_completion(mbo) == 0)
+   if (c->aim0.refs && c->aim0.aim->rx_completion &&
+   c->aim0.aim->rx_completion(mbo) == 0)
return;
 
-   if (c->aim1.refs && c->aim1.ptr->rx_completion &&
-   c->aim1.ptr->rx_completion(mbo) == 0)
+   if (c->aim1.refs && c->aim1.aim->rx_completion &&
+   c->aim1.aim->rx_completion(mbo) == 0)
return;
 
most_put_mbo(mbo);
@@ -1205,9 +1205,9 @@ int most_start_channel(struct most_interface *iface, int 
id,
atomic_set(&c->mbo_ref, num_buffer);
 
 out:
-   if (aim == c->aim0.ptr)
+   if (aim == c->a

[PATCH 25/50] staging: most: usb: remove pointer initialization

2017-11-21 Thread Christian Gromm
This patch removes the initialization of the priv pointer of the
most_interface structure.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/usb/usb.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c
index da2fc54..acd0a36 100644
--- a/drivers/staging/most/usb/usb.c
+++ b/drivers/staging/most/usb/usb.c
@@ -1043,8 +1043,6 @@ hdm_probe(struct usb_interface *interface, const struct 
usb_device_id *id)
goto exit_free1;
 
mdev->iface.channel_vector = mdev->cap;
-   mdev->iface.priv = NULL;
-
mdev->ep_address =
kcalloc(num_endpoints, sizeof(*mdev->ep_address), GFP_KERNEL);
if (!mdev->ep_address)
-- 
2.7.4

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


[PATCH 18/50] staging: most: core: track aim modules with linked list

2017-11-21 Thread Christian Gromm
The core needs to know what modules are registered. This patch makes the
core keep track of the registered modules.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 6 --
 drivers/staging/most/core.h | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 9a313cc..b9b9739 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -1300,8 +1300,8 @@ int most_register_aim(struct most_aim *aim)
pr_err("registering device %s failed\n", aim->name);
return ret;
}
-   pr_info("registered new application interfacing module %s\n",
-   aim->name);
+   list_add_tail(&aim->list, &mc.mod_list);
+   pr_info("registered new application interfacing module %s\n", 
aim->name);
return 0;
 }
 EXPORT_SYMBOL_GPL(most_register_aim);
@@ -1332,6 +1332,7 @@ int most_deregister_aim(struct most_aim *aim)
}
}
device_unregister(&aim->dev);
+   list_del(&aim->list);
pr_info("deregistering application interfacing module %s\n", aim->name);
return 0;
 }
@@ -1551,6 +1552,7 @@ static int __init most_init(void)
 
pr_info("init()\n");
INIT_LIST_HEAD(&instance_list);
+   INIT_LIST_HEAD(&mc.mod_list);
ida_init(&mdev_id);
 
mc.bus.name = "most",
diff --git a/drivers/staging/most/core.h b/drivers/staging/most/core.h
index b392ba5..0199be0 100644
--- a/drivers/staging/most/core.h
+++ b/drivers/staging/most/core.h
@@ -269,6 +269,7 @@ struct most_interface {
  */
 struct most_aim {
struct device dev;
+   struct list_head list;
const char *name;
int (*probe_channel)(struct most_interface *iface, int channel_idx,
 struct most_channel_config *cfg, char *name);
-- 
2.7.4

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


[PATCH 19/50] staging: most: core: fix sysfs attribute management

2017-11-21 Thread Christian Gromm
This patch creates a new attribute group to manage the attributes
of a registered aim module in sysfs and changes the show and store
functions accordingly.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 109 +---
 1 file changed, 73 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index b9b9739..7014f6a 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -540,28 +540,57 @@ static const struct attribute_group 
*interface_attr_groups[] = {
 /*  ___ ___
  *  ___A I M___
  */
-static ssize_t links_show(struct device *dev, struct device_attribute *attr,
- char *buf)
+static struct most_aim *match_module(char *name)
+{
+   struct most_aim *aim;
+
+   list_for_each_entry(aim, &mc.mod_list, list) {
+   if (!strcmp(aim->name, name))
+   return aim;
+   }
+   return NULL;
+}
+
+static ssize_t links_show(struct device_driver *drv, char *buf)
 {
struct most_channel *c;
struct most_inst_obj *i;
-   struct most_aim *aim = to_most_aim(dev);
int offs = 0;
 
list_for_each_entry(i, &instance_list, list) {
list_for_each_entry(c, &i->channel_list, list) {
-   if (c->pipe0.aim == aim || c->pipe1.aim == aim) {
-   offs += snprintf(buf + offs, PAGE_SIZE - offs,
-"%s:%s\n",
+   if (c->pipe0.aim) {
+   offs += snprintf(buf + offs,
+PAGE_SIZE - offs,
+"%s:%s:%s\n",
+c->pipe0.aim->name,
+dev_name(&i->iface->dev),
+dev_name(&c->dev));
+   }
+   if (c->pipe1.aim) {
+   offs += snprintf(buf + offs,
+PAGE_SIZE - offs,
+"%s:%s:%s\n",
+c->pipe1.aim->name,
 dev_name(&i->iface->dev),
 dev_name(&c->dev));
}
}
}
-
return offs;
 }
 
+static ssize_t modules_show(struct device_driver *drv, char *buf)
+{
+   struct most_aim *aim;
+   int offs = 0;
+
+   list_for_each_entry(aim, &mc.mod_list, list) {
+   offs += snprintf(buf + offs, PAGE_SIZE - offs, "%s\n",
+aim->name);
+   }
+   return offs;
+}
 /**
  * split_string - parses and changes string in the buffer buf and
  * splits it into two mandatory and one optional substrings.
@@ -584,7 +613,7 @@ static ssize_t links_show(struct device *dev, struct 
device_attribute *attr,
  * Input: "mdev1:ep81"
  * Output: *a -> "mdev1", *b -> "ep81", *c == NULL
  */
-static int split_string(char *buf, char **a, char **b, char **c)
+static int split_string(char *buf, char **a, char **b, char **c, char **d)
 {
*a = strsep(&buf, ":");
if (!*a)
@@ -594,8 +623,12 @@ static int split_string(char *buf, char **a, char **b, 
char **c)
if (!*b)
return -EIO;
 
-   if (c)
-   *c = strsep(&buf, ":\n");
+   *c = strsep(&buf, ":\n");
+   if (!*c)
+   return -EIO;
+
+   if (d)
+   *d = strsep(&buf, ":\n");
 
return 0;
 }
@@ -680,38 +713,38 @@ inline int link_channel_to_aim(struct most_channel *c, 
struct most_aim *aim,
  * (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 *dev,
- struct device_attribute *attr,
+static ssize_t add_link_store(struct device_driver *drv,
  const char *buf,
  size_t len)
 {
struct most_channel *c;
-   struct most_aim *aim = to_most_aim(dev);
+   struct most_aim *aim;
char buffer[STRING_SIZE];
char *mdev;
char *mdev_ch;
-   char *mdev_devnod;
+   char *aim_name;
+   char *aim_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, &mdev, &mdev_ch, &mdev_devnod);
+   ret = split_string(buffer, &mdev, &mdev_ch, &aim_name, &aim_param);
if (ret)
return ret;
-
-   if (!mdev_devnod || *mdev_devnod == 0) {
+   aim = match_module(aim_name);
+   if (!aim_param || *aim_param == 0) {
snp

[PATCH 23/50] staging: most: core: put channel name in struct most_channel

2017-11-21 Thread Christian Gromm
This patch stores a channel's name inside the most_channel structure. It
is needed to have the channel attributes tied together.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 87178a8..f47d581 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -57,6 +57,7 @@ struct most_channel {
atomic_t mbo_ref;
atomic_t mbo_nq_level;
u16 channel_id;
+   char name[STRING_SIZE];
bool is_poisoned;
struct mutex start_mutex;
struct mutex nq_mutex; /* nq thread synchronization */
@@ -1376,7 +1377,6 @@ int most_register_interface(struct most_interface *iface)
 {
unsigned int i;
int id;
-   char channel_name[STRING_SIZE];
struct most_channel *c;
 
if (!iface || !iface->enqueue || !iface->configure ||
@@ -1416,15 +1416,14 @@ int most_register_interface(struct most_interface 
*iface)
for (i = 0; i < iface->num_channels; i++) {
const char *name_suffix = iface->channel_vector[i].name_suffix;
 
-   if (!name_suffix)
-   snprintf(channel_name, STRING_SIZE, "ch%d", i);
-   else
-   snprintf(channel_name, STRING_SIZE, "%s", name_suffix);
-
c = kzalloc(sizeof(*c), GFP_KERNEL);
if (!c)
goto free_instance;
-   c->dev.init_name = channel_name;
+   if (!name_suffix)
+   snprintf(c->name, STRING_SIZE, "ch%d", i);
+   else
+   snprintf(c->name, STRING_SIZE, "%s", name_suffix);
+   c->dev.init_name = c->name;
c->dev.parent = &iface->dev;
c->dev.groups = channel_attr_groups;
c->dev.release = release_channel;
-- 
2.7.4

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


[PATCH 27/50] staging: most: rename functions to register a driver with most_core

2017-11-21 Thread Christian Gromm
This patch renames the functions to register and deregister a component
module with the core. It is needed because the modules that interface the
userspace are referred to as components.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/cdev/cdev.c   |  4 ++--
 drivers/staging/most/core.c| 13 +++--
 drivers/staging/most/core.h|  4 ++--
 drivers/staging/most/net/net.c |  4 ++--
 drivers/staging/most/sound/sound.c |  4 ++--
 drivers/staging/most/video/video.c |  6 +++---
 6 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c
index e1290b8..5f8f003 100644
--- a/drivers/staging/most/cdev/cdev.c
+++ b/drivers/staging/most/cdev/cdev.c
@@ -524,7 +524,7 @@ static int __init mod_init(void)
err = PTR_ERR(aim_class);
goto free_cdev;
}
-   err = most_register_aim(&cdev_aim);
+   err = most_register_component(&cdev_aim);
if (err)
goto dest_class;
return 0;
@@ -544,7 +544,7 @@ static void __exit mod_exit(void)
 
pr_info("exit module\n");
 
-   most_deregister_aim(&cdev_aim);
+   most_deregister_component(&cdev_aim);
 
list_for_each_entry_safe(c, tmp, &channel_list, list) {
destroy_cdev(c);
diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index fa1ed89d6..db453f2 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -75,6 +75,7 @@ struct most_channel {
struct list_head trash_fifo;
struct task_struct *hdm_enqueue_task;
wait_queue_head_t hdm_fifo_wq;
+
 };
 
 #define to_channel(d) container_of(d, struct most_channel, dev)
@@ -1305,10 +1306,10 @@ int most_stop_channel(struct most_interface *iface, int 
id,
 EXPORT_SYMBOL_GPL(most_stop_channel);
 
 /**
- * most_register_aim - registers an AIM (driver) with the core
+ * most_register_component - registers an AIM (driver) with the core
  * @aim: instance of AIM to be registered
  */
-int most_register_aim(struct core_component *aim)
+int most_register_component(struct core_component *aim)
 {
if (!aim) {
pr_err("Bad driver\n");
@@ -1318,7 +1319,7 @@ int most_register_aim(struct core_component *aim)
pr_info("registered new application interfacing module %s\n", 
aim->name);
return 0;
 }
-EXPORT_SYMBOL_GPL(most_register_aim);
+EXPORT_SYMBOL_GPL(most_register_component);
 
 static int disconnect_channels(struct device *dev, void *data)
 {
@@ -1339,10 +1340,10 @@ static int disconnect_channels(struct device *dev, void 
*data)
 }
 
 /**
- * most_deregister_aim - deregisters an AIM (driver) with the core
+ * most_deregister_component - deregisters an AIM (driver) with the core
  * @aim: AIM to be removed
  */
-int most_deregister_aim(struct core_component *aim)
+int most_deregister_component(struct core_component *aim)
 {
if (!aim) {
pr_err("Bad driver\n");
@@ -1354,7 +1355,7 @@ int most_deregister_aim(struct core_component *aim)
pr_info("deregistering module %s\n", aim->name);
return 0;
 }
-EXPORT_SYMBOL_GPL(most_deregister_aim);
+EXPORT_SYMBOL_GPL(most_deregister_component);
 
 static void release_interface(struct device *dev)
 {
diff --git a/drivers/staging/most/core.h b/drivers/staging/most/core.h
index cfd5884..3c2975b 100644
--- a/drivers/staging/most/core.h
+++ b/drivers/staging/most/core.h
@@ -314,8 +314,8 @@ void most_stop_enqueue(struct most_interface *iface, int 
channel_idx);
  * in wait fifo.
  */
 void most_resume_enqueue(struct most_interface *iface, int channel_idx);
-int most_register_aim(struct core_component *comp);
-int most_deregister_aim(struct core_component *comp);
+int most_register_component(struct core_component *comp);
+int most_deregister_component(struct core_component *comp);
 struct mbo *most_get_mbo(struct most_interface *iface, int channel_idx,
 struct core_component *comp);
 void most_put_mbo(struct mbo *mbo);
diff --git a/drivers/staging/most/net/net.c b/drivers/staging/most/net/net.c
index b418436..a7c7c58 100644
--- a/drivers/staging/most/net/net.c
+++ b/drivers/staging/most/net/net.c
@@ -512,12 +512,12 @@ static int __init most_net_init(void)
 {
spin_lock_init(&list_lock);
mutex_init(&probe_disc_mt);
-   return most_register_aim(&aim);
+   return most_register_component(&aim);
 }
 
 static void __exit most_net_exit(void)
 {
-   most_deregister_aim(&aim);
+   most_deregister_component(&aim);
 }
 
 /**
diff --git a/drivers/staging/most/sound/sound.c 
b/drivers/staging/most/sound/sound.c
index 2c13344..85bb024 100644
--- a/drivers/staging/most/sound/sound.c
+++ b/drivers/staging/most/sound/sound.c
@@ -739,7 +739,7 @@ static int __init audio_init(void)
 
INIT_LIST_HEAD(&dev_list);
 
-   return most_register_aim(&audio_aim);
+   return most_register_component(&audio_aim);
 }
 
 static void __exit audio

[PATCH 31/50] staging: most: net: remove aim designators

2017-11-21 Thread Christian Gromm
This patch renames the all aim designators with comp. It is needed because
userspace interfacing modules are referred to as components.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/net/net.c | 44 +-
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/most/net/net.c b/drivers/staging/most/net/net.c
index a7c7c58..00a5ddf 100644
--- a/drivers/staging/most/net/net.c
+++ b/drivers/staging/most/net/net.c
@@ -1,5 +1,5 @@
 /*
- * Networking AIM - Networking Application Interface Module for MostCore
+ * Networking component - Networking Application Interface Module for MostCore
  *
  * Copyright (C) 2015, Microchip Technology Germany II GmbH & Co. KG
  *
@@ -74,7 +74,7 @@ struct net_dev_context {
 static struct list_head net_devices = LIST_HEAD_INIT(net_devices);
 static struct mutex probe_disc_mt; /* ch->linked = true, most_nd_open */
 static struct spinlock list_lock; /* list_head, ch->linked = false, dev_hold */
-static struct core_component aim;
+static struct core_component comp;
 
 static int skb_to_mamac(const struct sk_buff *skb, struct mbo *mbo)
 {
@@ -184,15 +184,15 @@ static int most_nd_open(struct net_device *dev)
 
mutex_lock(&probe_disc_mt);
 
-   if (most_start_channel(nd->iface, nd->rx.ch_id, &aim)) {
+   if (most_start_channel(nd->iface, nd->rx.ch_id, &comp)) {
netdev_err(dev, "most_start_channel() failed\n");
ret = -EBUSY;
goto unlock;
}
 
-   if (most_start_channel(nd->iface, nd->tx.ch_id, &aim)) {
+   if (most_start_channel(nd->iface, nd->tx.ch_id, &comp)) {
netdev_err(dev, "most_start_channel() failed\n");
-   most_stop_channel(nd->iface, nd->rx.ch_id, &aim);
+   most_stop_channel(nd->iface, nd->rx.ch_id, &comp);
ret = -EBUSY;
goto unlock;
}
@@ -218,8 +218,8 @@ static int most_nd_stop(struct net_device *dev)
netif_stop_queue(dev);
if (nd->iface->request_netinfo)
nd->iface->request_netinfo(nd->iface, nd->tx.ch_id, NULL);
-   most_stop_channel(nd->iface, nd->rx.ch_id, &aim);
-   most_stop_channel(nd->iface, nd->tx.ch_id, &aim);
+   most_stop_channel(nd->iface, nd->rx.ch_id, &comp);
+   most_stop_channel(nd->iface, nd->tx.ch_id, &comp);
 
return 0;
 }
@@ -231,7 +231,7 @@ static netdev_tx_t most_nd_start_xmit(struct sk_buff *skb,
struct mbo *mbo;
int ret;
 
-   mbo = most_get_mbo(nd->iface, nd->tx.ch_id, &aim);
+   mbo = most_get_mbo(nd->iface, nd->tx.ch_id, &comp);
 
if (!mbo) {
netif_stop_queue(dev);
@@ -296,8 +296,8 @@ static struct net_dev_context *get_net_dev_hold(struct 
most_interface *iface)
return nd;
 }
 
-static int aim_probe_channel(struct most_interface *iface, int channel_idx,
-struct most_channel_config *ccfg, char *name)
+static int comp_probe_channel(struct most_interface *iface, int channel_idx,
+ struct most_channel_config *ccfg, char *name)
 {
struct net_dev_context *nd;
struct net_dev_channel *ch;
@@ -352,8 +352,8 @@ static int aim_probe_channel(struct most_interface *iface, 
int channel_idx,
return ret;
 }
 
-static int aim_disconnect_channel(struct most_interface *iface,
- int channel_idx)
+static int comp_disconnect_channel(struct most_interface *iface,
+  int channel_idx)
 {
struct net_dev_context *nd;
struct net_dev_channel *ch;
@@ -399,8 +399,8 @@ static int aim_disconnect_channel(struct most_interface 
*iface,
return ret;
 }
 
-static int aim_resume_tx_channel(struct most_interface *iface,
-int channel_idx)
+static int comp_resume_tx_channel(struct most_interface *iface,
+ int channel_idx)
 {
struct net_dev_context *nd;
 
@@ -418,7 +418,7 @@ static int aim_resume_tx_channel(struct most_interface 
*iface,
return 0;
 }
 
-static int aim_rx_data(struct mbo *mbo)
+static int comp_rx_data(struct mbo *mbo)
 {
const u32 zero = 0;
struct net_dev_context *nd;
@@ -500,24 +500,24 @@ static int aim_rx_data(struct mbo *mbo)
return ret;
 }
 
-static struct core_component aim = {
+static struct core_component comp = {
.name = "net",
-   .probe_channel = aim_probe_channel,
-   .disconnect_channel = aim_disconnect_channel,
-   .tx_completion = aim_resume_tx_channel,
-   .rx_completion = aim_rx_data,
+   .probe_channel = comp_probe_channel,
+   .disconnect_channel = comp_disconnect_channel,
+   .tx_completion = comp_resume_tx_channel,
+   .rx_completion = comp_rx_data,
 };
 
 static int __init most_net_init(void)
 {
spin_lock_init(&list_lock);
mutex_init(&probe_disc_mt);
-   return most_register_component(&aim);
+

[PATCH 17/50] staging: most: core: use structure to pack driver specific data

2017-11-21 Thread Christian Gromm
This patch introduces the structure "mostcore" to bundle core specific
data structures.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 73 +
 1 file changed, 34 insertions(+), 39 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 2b923fb..9a313cc 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -32,11 +32,19 @@
 #define MAX_CHANNELS   64
 #define STRING_SIZE80
 
-static struct class *most_class;
-static struct device core_dev;
 static struct ida mdev_id;
 static int dummy_num_buffers;
 
+static struct mostcore {
+   struct device dev;
+   struct device_driver drv;
+   struct bus_type bus;
+   struct class *class;
+   struct list_head mod_list;
+} mc;
+
+#define to_driver(d) container_of(d, struct mostcore, drv);
+
 struct pipe {
struct most_aim *aim;
int refs;
@@ -783,22 +791,6 @@ int most_match(struct device *dev, struct device_driver 
*drv)
return 1;
 }
 
-/**
- * Instantiation of the MOST bus
- */
-static struct bus_type most_bus = {
-   .name = "most",
-   .match = most_match,
-};
-
-/**
- * Instantiation of the core driver
- */
-static struct device_driver mostcore = {
-   .name = "mostcore",
-   .bus = &most_bus,
-};
-
 static inline void trash_mbo(struct mbo *mbo)
 {
unsigned long flags;
@@ -1299,8 +1291,8 @@ int most_register_aim(struct most_aim *aim)
return -EINVAL;
}
aim->dev.init_name = aim->name;
-   aim->dev.bus = &most_bus;
-   aim->dev.parent = &core_dev;
+   aim->dev.bus = &mc.bus;
+   aim->dev.parent = &mc.dev;
aim->dev.groups = aim_attr_groups;
aim->dev.release = release_aim;
ret = device_register(&aim->dev);
@@ -1397,8 +1389,8 @@ int most_register_interface(struct most_interface *iface)
list_add_tail(&inst->list, &instance_list);
snprintf(name, STRING_SIZE, "mdev%d", id);
iface->dev.init_name = name;
-   iface->dev.bus = &most_bus;
-   iface->dev.parent = &core_dev;
+   iface->dev.bus = &mc.bus;
+   iface->dev.parent = &mc.dev;
iface->dev.groups = interface_attr_groups;
iface->dev.release = release_interface;
if (device_register(&iface->dev)) {
@@ -1561,28 +1553,31 @@ static int __init most_init(void)
INIT_LIST_HEAD(&instance_list);
ida_init(&mdev_id);
 
-   err = bus_register(&most_bus);
+   mc.bus.name = "most",
+   mc.bus.match = most_match,
+   mc.drv.name = "most_core",
+   mc.drv.bus = &mc.bus,
+
+   err = bus_register(&mc.bus);
if (err) {
pr_info("Cannot register most bus\n");
return err;
}
-
-   most_class = class_create(THIS_MODULE, "most");
-   if (IS_ERR(most_class)) {
+   mc.class = class_create(THIS_MODULE, "most");
+   if (IS_ERR(mc.class)) {
pr_info("No udev support.\n");
-   err = PTR_ERR(most_class);
+   err = PTR_ERR(mc.class);
goto exit_bus;
}
 
-   err = driver_register(&mostcore);
+   err = driver_register(&mc.drv);
if (err) {
pr_info("Cannot register core driver\n");
goto exit_class;
}
-
-   core_dev.init_name = "most_bus";
-   core_dev.release = release_most_sub;
-   if (device_register(&core_dev)) {
+   mc.dev.init_name = "most_bus";
+   mc.dev.release = release_most_sub;
+   if (device_register(&mc.dev)) {
err = -ENOMEM;
goto exit_driver;
}
@@ -1590,21 +1585,21 @@ static int __init most_init(void)
return 0;
 
 exit_driver:
-   driver_unregister(&mostcore);
+   driver_unregister(&mc.drv);
 exit_class:
-   class_destroy(most_class);
+   class_destroy(mc.class);
 exit_bus:
-   bus_unregister(&most_bus);
+   bus_unregister(&mc.bus);
return err;
 }
 
 static void __exit most_exit(void)
 {
pr_info("exit core module\n");
-   device_unregister(&core_dev);
-   driver_unregister(&mostcore);
-   class_destroy(most_class);
-   bus_unregister(&most_bus);
+   device_unregister(&mc.dev);
+   driver_unregister(&mc.drv);
+   class_destroy(mc.class);
+   bus_unregister(&mc.bus);
ida_destroy(&mdev_id);
 }
 
-- 
2.7.4

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


[PATCH 30/50] staging: most: core: rename function link_channel_to_aim

2017-11-21 Thread Christian Gromm
This patch renames the function link_channel_to_aim to
link_channel_to_component. It is needed because userspace
interfacing modules are referred to as components.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index c80fb9b..6d7fe7d 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -667,9 +667,9 @@ static struct most_channel *get_channel(char *mdev, char 
*mdev_ch)
 }
 
 static
-inline int link_channel_to_aim(struct most_channel *c,
-  struct core_component *comp,
-  char *comp_param)
+inline int link_channel_to_component(struct most_channel *c,
+struct core_component *comp,
+char *comp_param)
 {
int ret;
struct core_component **comp_ptr;
@@ -745,7 +745,7 @@ static ssize_t add_link_store(struct device_driver *drv,
if (!c)
return -ENODEV;
 
-   ret = link_channel_to_aim(c, comp, comp_param);
+   ret = link_channel_to_component(c, comp, comp_param);
if (ret)
return ret;
 
-- 
2.7.4

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


[PATCH 22/50] staging: most: core: replace struct most_inst_obj

2017-11-21 Thread Christian Gromm
This patch introduces struct interface_private as a replacement for
the struct most_inst_obj. This structure holds private data that is
only needed by the core module and will be accessed by a pointer from
within the most_interface structure. As a result of this replacement
the bus helper functions can be used to search for devices.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 200 +---
 drivers/staging/most/core.h |   2 +
 2 files changed, 99 insertions(+), 103 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 4caea38..87178a8 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -62,7 +62,6 @@ struct most_channel {
struct mutex nq_mutex; /* nq thread synchronization */
int is_starving;
struct most_interface *iface;
-   struct most_inst_obj *inst;
struct most_channel_config cfg;
bool keep_mbo;
bool enqueue_halt;
@@ -79,12 +78,11 @@ struct most_channel {
 
 #define to_channel(d) container_of(d, struct most_channel, dev)
 
-struct most_inst_obj {
+struct interface_private {
int dev_id;
-   struct most_interface *iface;
-   struct list_head channel_list;
+   char name[STRING_SIZE];
struct most_channel *channel[MAX_CHANNELS];
-   struct list_head list;
+   struct list_head channel_list;
 };
 
 static const struct {
@@ -478,9 +476,6 @@ static const struct attribute_group *channel_attr_groups[] 
= {
 /*  ___   ___
  *  ___I N S T A N C E___
  */
-
-static struct list_head instance_list;
-
 static ssize_t description_show(struct device *dev,
struct device_attribute *attr,
char *buf)
@@ -551,33 +546,38 @@ static struct most_aim *match_module(char *name)
return NULL;
 }
 
-static ssize_t links_show(struct device_driver *drv, char *buf)
+int print_links(struct device *dev, void *data)
 {
-   struct most_channel *c;
-   struct most_inst_obj *i;
int offs = 0;
+   char *buf = data;
+   struct most_channel *c;
+   struct most_interface *iface = to_most_interface(dev);
 
-   list_for_each_entry(i, &instance_list, list) {
-   list_for_each_entry(c, &i->channel_list, list) {
-   if (c->pipe0.aim) {
-   offs += snprintf(buf + offs,
-PAGE_SIZE - offs,
-"%s:%s:%s\n",
-c->pipe0.aim->name,
-dev_name(&i->iface->dev),
-dev_name(&c->dev));
-   }
-   if (c->pipe1.aim) {
-   offs += snprintf(buf + offs,
-PAGE_SIZE - offs,
-"%s:%s:%s\n",
-c->pipe1.aim->name,
-dev_name(&i->iface->dev),
-dev_name(&c->dev));
-   }
+   list_for_each_entry(c, &iface->p->channel_list, list) {
+   if (c->pipe0.aim) {
+   offs += snprintf(buf + offs,
+PAGE_SIZE - offs,
+"%s:%s:%s\n",
+c->pipe0.aim->name,
+dev_name(&iface->dev),
+dev_name(&c->dev));
+   }
+   if (c->pipe1.aim) {
+   offs += snprintf(buf + offs,
+PAGE_SIZE - offs,
+"%s:%s:%s\n",
+c->pipe1.aim->name,
+dev_name(&iface->dev),
+dev_name(&c->dev));
}
}
-   return offs;
+   return 0;
+}
+
+static ssize_t links_show(struct device_driver *drv, char *buf)
+{
+   bus_for_each_dev(&mc.bus, NULL, buf, print_links);
+   return strlen(buf);
 }
 
 static ssize_t modules_show(struct device_driver *drv, char *buf)
@@ -633,6 +633,13 @@ static int split_string(char *buf, char **a, char **b, 
char **c, char **d)
return 0;
 }
 
+static int match_bus_dev(struct device *dev, void *data)
+{
+   char *mdev_name = data;
+
+   return !strcmp(dev_name(dev), mdev_name);
+}
+
 /**
  * get_channel - get pointer to channel object
  * @mdev: name of the device instance
@@ -642,28 +649,19 @@ static int split_string(char *buf, char **a, char **b, 
char **c, char **d)
  */
 static struct most_channel *get_channel(char *mdev, char 

[PATCH 35/50] staging: most: cdev: rename variable aim_devno

2017-11-21 Thread Christian Gromm
This patch renames the variable aim_devno to comp_devno. It is needed
to complete the process of changing the module designator from AIM to
Component.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/cdev/cdev.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c
index 2008a38..5c6d0ae 100644
--- a/drivers/staging/most/cdev/cdev.c
+++ b/drivers/staging/most/cdev/cdev.c
@@ -24,7 +24,7 @@
 #include 
 #include "most/core.h"
 
-static dev_t aim_devno;
+static dev_t comp_devno;
 static struct class *aim_class;
 static struct ida minor_id;
 static unsigned int major;
@@ -513,10 +513,10 @@ static int __init mod_init(void)
spin_lock_init(&ch_list_lock);
ida_init(&minor_id);
 
-   err = alloc_chrdev_region(&aim_devno, 0, 50, "cdev");
+   err = alloc_chrdev_region(&comp_devno, 0, 50, "cdev");
if (err < 0)
goto dest_ida;
-   major = MAJOR(aim_devno);
+   major = MAJOR(comp_devno);
 
aim_class = class_create(THIS_MODULE, "most_cdev_aim");
if (IS_ERR(aim_class)) {
@@ -532,7 +532,7 @@ static int __init mod_init(void)
 dest_class:
class_destroy(aim_class);
 free_cdev:
-   unregister_chrdev_region(aim_devno, 1);
+   unregister_chrdev_region(comp_devno, 1);
 dest_ida:
ida_destroy(&minor_id);
return err;
@@ -551,7 +551,7 @@ static void __exit mod_exit(void)
destroy_channel(c);
}
class_destroy(aim_class);
-   unregister_chrdev_region(aim_devno, 1);
+   unregister_chrdev_region(comp_devno, 1);
ida_destroy(&minor_id);
 }
 
-- 
2.7.4

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


[PATCH 34/50] staging: most: cdev: rename struct aim_channel

2017-11-21 Thread Christian Gromm
This patch renames the structure aim_channel to comp_channel. It is needed
to complete the process of changing the module designator from AIM to
Component.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/cdev/cdev.c | 38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c
index 5f8f003..2008a38 100644
--- a/drivers/staging/most/cdev/cdev.c
+++ b/drivers/staging/most/cdev/cdev.c
@@ -30,7 +30,7 @@ static struct ida minor_id;
 static unsigned int major;
 static struct core_component cdev_aim;
 
-struct aim_channel {
+struct comp_channel {
wait_queue_head_t wq;
spinlock_t unlink;  /* synchronization lock to unlink channels */
struct cdev cdev;
@@ -46,16 +46,16 @@ struct aim_channel {
struct list_head list;
 };
 
-#define to_channel(d) container_of(d, struct aim_channel, cdev)
+#define to_channel(d) container_of(d, struct comp_channel, cdev)
 static struct list_head channel_list;
 static spinlock_t ch_list_lock;
 
-static inline bool ch_has_mbo(struct aim_channel *c)
+static inline bool ch_has_mbo(struct comp_channel *c)
 {
return channel_has_mbo(c->iface, c->channel_id, &cdev_aim) > 0;
 }
 
-static inline bool ch_get_mbo(struct aim_channel *c, struct mbo **mbo)
+static inline bool ch_get_mbo(struct comp_channel *c, struct mbo **mbo)
 {
if (!kfifo_peek(&c->fifo, mbo)) {
*mbo = most_get_mbo(c->iface, c->channel_id, &cdev_aim);
@@ -65,9 +65,9 @@ static inline bool ch_get_mbo(struct aim_channel *c, struct 
mbo **mbo)
return *mbo;
 }
 
-static struct aim_channel *get_channel(struct most_interface *iface, int id)
+static struct comp_channel *get_channel(struct most_interface *iface, int id)
 {
-   struct aim_channel *c, *tmp;
+   struct comp_channel *c, *tmp;
unsigned long flags;
int found_channel = 0;
 
@@ -84,7 +84,7 @@ static struct aim_channel *get_channel(struct most_interface 
*iface, int id)
return c;
 }
 
-static void stop_channel(struct aim_channel *c)
+static void stop_channel(struct comp_channel *c)
 {
struct mbo *mbo;
 
@@ -93,7 +93,7 @@ static void stop_channel(struct aim_channel *c)
most_stop_channel(c->iface, c->channel_id, &cdev_aim);
 }
 
-static void destroy_cdev(struct aim_channel *c)
+static void destroy_cdev(struct comp_channel *c)
 {
unsigned long flags;
 
@@ -104,7 +104,7 @@ static void destroy_cdev(struct aim_channel *c)
spin_unlock_irqrestore(&ch_list_lock, flags);
 }
 
-static void destroy_channel(struct aim_channel *c)
+static void destroy_channel(struct comp_channel *c)
 {
ida_simple_remove(&minor_id, MINOR(c->devno));
kfifo_free(&c->fifo);
@@ -121,7 +121,7 @@ static void destroy_channel(struct aim_channel *c)
  */
 static int aim_open(struct inode *inode, struct file *filp)
 {
-   struct aim_channel *c;
+   struct comp_channel *c;
int ret;
 
c = to_channel(inode->i_cdev);
@@ -165,7 +165,7 @@ static int aim_open(struct inode *inode, struct file *filp)
  */
 static int aim_close(struct inode *inode, struct file *filp)
 {
-   struct aim_channel *c = to_channel(inode->i_cdev);
+   struct comp_channel *c = to_channel(inode->i_cdev);
 
mutex_lock(&c->io_mutex);
spin_lock(&c->unlink);
@@ -194,7 +194,7 @@ static ssize_t aim_write(struct file *filp, const char 
__user *buf,
int ret;
size_t to_copy, left;
struct mbo *mbo = NULL;
-   struct aim_channel *c = filp->private_data;
+   struct comp_channel *c = filp->private_data;
 
mutex_lock(&c->io_mutex);
while (c->dev && !ch_get_mbo(c, &mbo)) {
@@ -247,7 +247,7 @@ aim_read(struct file *filp, char __user *buf, size_t count, 
loff_t *offset)
 {
size_t to_copy, not_copied, copied;
struct mbo *mbo;
-   struct aim_channel *c = filp->private_data;
+   struct comp_channel *c = filp->private_data;
 
mutex_lock(&c->io_mutex);
while (c->dev && !kfifo_peek(&c->fifo, &mbo)) {
@@ -289,7 +289,7 @@ aim_read(struct file *filp, char __user *buf, size_t count, 
loff_t *offset)
 
 static unsigned int aim_poll(struct file *filp, poll_table *wait)
 {
-   struct aim_channel *c = filp->private_data;
+   struct comp_channel *c = filp->private_data;
unsigned int mask = 0;
 
poll_wait(filp, &c->wq, wait);
@@ -326,7 +326,7 @@ static const struct file_operations channel_fops = {
  */
 static int aim_disconnect_channel(struct most_interface *iface, int channel_id)
 {
-   struct aim_channel *c;
+   struct comp_channel *c;
 
if (!iface) {
pr_info("Bad interface pointer\n");
@@ -362,7 +362,7 @@ static int aim_disconnect_channel(struct most_interface 
*iface, int channel_id)
  */
 static int aim_rx_completion(struct mbo *mbo)
 {
-   struct aim_channel *c;
+   struct comp_channel *c;
 
if (!mbo)
  

[PATCH 36/50] staging: most: cdev: rename class instance aim_class

2017-11-21 Thread Christian Gromm
This patch renames the instance  aim_class of struct class to comp_class.
It is needed to complete the process of changing the module designator from
AIM to Component.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/cdev/cdev.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c
index 5c6d0ae..e47d6aa 100644
--- a/drivers/staging/most/cdev/cdev.c
+++ b/drivers/staging/most/cdev/cdev.c
@@ -25,7 +25,7 @@
 #include "most/core.h"
 
 static dev_t comp_devno;
-static struct class *aim_class;
+static struct class *comp_class;
 static struct ida minor_id;
 static unsigned int major;
 static struct core_component cdev_aim;
@@ -97,7 +97,7 @@ static void destroy_cdev(struct comp_channel *c)
 {
unsigned long flags;
 
-   device_destroy(aim_class, c->devno);
+   device_destroy(comp_class, c->devno);
cdev_del(&c->cdev);
spin_lock_irqsave(&ch_list_lock, flags);
list_del(&c->list);
@@ -470,7 +470,7 @@ static int aim_probe(struct most_interface *iface, int 
channel_id,
spin_lock_irqsave(&ch_list_lock, cl_flags);
list_add_tail(&c->list, &channel_list);
spin_unlock_irqrestore(&ch_list_lock, cl_flags);
-   c->dev = device_create(aim_class,
+   c->dev = device_create(comp_class,
 NULL,
 c->devno,
 NULL,
@@ -518,10 +518,10 @@ static int __init mod_init(void)
goto dest_ida;
major = MAJOR(comp_devno);
 
-   aim_class = class_create(THIS_MODULE, "most_cdev_aim");
-   if (IS_ERR(aim_class)) {
+   comp_class = class_create(THIS_MODULE, "most_cdev_aim");
+   if (IS_ERR(comp_class)) {
pr_err("no udev support\n");
-   err = PTR_ERR(aim_class);
+   err = PTR_ERR(comp_class);
goto free_cdev;
}
err = most_register_component(&cdev_aim);
@@ -530,7 +530,7 @@ static int __init mod_init(void)
return 0;
 
 dest_class:
-   class_destroy(aim_class);
+   class_destroy(comp_class);
 free_cdev:
unregister_chrdev_region(comp_devno, 1);
 dest_ida:
@@ -550,7 +550,7 @@ static void __exit mod_exit(void)
destroy_cdev(c);
destroy_channel(c);
}
-   class_destroy(aim_class);
+   class_destroy(comp_class);
unregister_chrdev_region(comp_devno, 1);
ida_destroy(&minor_id);
 }
-- 
2.7.4

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


[PATCH 37/50] staging: most: cdev: rename variable cdev_aim

2017-11-21 Thread Christian Gromm
This patch renames the variable cdev_aim to cdev_comp. It is needed to
complete the process of changing the module designator from AIM to
Component.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/cdev/cdev.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c
index e47d6aa..c741231 100644
--- a/drivers/staging/most/cdev/cdev.c
+++ b/drivers/staging/most/cdev/cdev.c
@@ -28,7 +28,7 @@ static dev_t comp_devno;
 static struct class *comp_class;
 static struct ida minor_id;
 static unsigned int major;
-static struct core_component cdev_aim;
+static struct core_component cdev_comp;
 
 struct comp_channel {
wait_queue_head_t wq;
@@ -52,13 +52,13 @@ static spinlock_t ch_list_lock;
 
 static inline bool ch_has_mbo(struct comp_channel *c)
 {
-   return channel_has_mbo(c->iface, c->channel_id, &cdev_aim) > 0;
+   return channel_has_mbo(c->iface, c->channel_id, &cdev_comp) > 0;
 }
 
 static inline bool ch_get_mbo(struct comp_channel *c, struct mbo **mbo)
 {
if (!kfifo_peek(&c->fifo, mbo)) {
-   *mbo = most_get_mbo(c->iface, c->channel_id, &cdev_aim);
+   *mbo = most_get_mbo(c->iface, c->channel_id, &cdev_comp);
if (*mbo)
kfifo_in(&c->fifo, mbo, 1);
}
@@ -90,7 +90,7 @@ static void stop_channel(struct comp_channel *c)
 
while (kfifo_out((struct kfifo *)&c->fifo, &mbo, 1))
most_put_mbo(mbo);
-   most_stop_channel(c->iface, c->channel_id, &cdev_aim);
+   most_stop_channel(c->iface, c->channel_id, &cdev_comp);
 }
 
 static void destroy_cdev(struct comp_channel *c)
@@ -149,7 +149,7 @@ static int aim_open(struct inode *inode, struct file *filp)
}
 
c->mbo_offs = 0;
-   ret = most_start_channel(c->iface, c->channel_id, &cdev_aim);
+   ret = most_start_channel(c->iface, c->channel_id, &cdev_comp);
if (!ret)
c->access_ref = 1;
mutex_unlock(&c->io_mutex);
@@ -495,7 +495,7 @@ static int aim_probe(struct most_interface *iface, int 
channel_id,
return retval;
 }
 
-static struct core_component cdev_aim = {
+static struct core_component cdev_comp = {
.name = "cdev",
.probe_channel = aim_probe,
.disconnect_channel = aim_disconnect_channel,
@@ -518,13 +518,13 @@ static int __init mod_init(void)
goto dest_ida;
major = MAJOR(comp_devno);
 
-   comp_class = class_create(THIS_MODULE, "most_cdev_aim");
+   comp_class = class_create(THIS_MODULE, "most_cdev_comp");
if (IS_ERR(comp_class)) {
pr_err("no udev support\n");
err = PTR_ERR(comp_class);
goto free_cdev;
}
-   err = most_register_component(&cdev_aim);
+   err = most_register_component(&cdev_comp);
if (err)
goto dest_class;
return 0;
@@ -544,7 +544,7 @@ static void __exit mod_exit(void)
 
pr_info("exit module\n");
 
-   most_deregister_component(&cdev_aim);
+   most_deregister_component(&cdev_comp);
 
list_for_each_entry_safe(c, tmp, &channel_list, list) {
destroy_cdev(c);
-- 
2.7.4

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


[PATCH 32/50] staging: most: sound: remove aim designator

2017-11-21 Thread Christian Gromm
This patch removes all 'aim' designators and replaces them with 'comp'.  It
is needd because userspace interfacing modules are referred to as
components.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/sound/sound.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/most/sound/sound.c 
b/drivers/staging/most/sound/sound.c
index 85bb024..2c9e6c9 100644
--- a/drivers/staging/most/sound/sound.c
+++ b/drivers/staging/most/sound/sound.c
@@ -1,5 +1,5 @@
 /*
- * sound.c - Audio Application Interface Module for Mostcore
+ * sound.c - Sound component for Mostcore
  *
  * Copyright (C) 2015 Microchip Technology Germany II GmbH & Co. KG
  *
@@ -27,7 +27,7 @@
 #define DRIVER_NAME "sound"
 
 static struct list_head dev_list;
-static struct core_component audio_aim;
+static struct core_component comp;
 
 /**
  * struct channel - private structure to keep channel specific data
@@ -240,7 +240,7 @@ static int playback_thread(void *data)
kthread_should_stop() ||
(channel->is_stream_running &&
 (mbo = most_get_mbo(channel->iface, channel->id,
-&audio_aim;
+∁
if (!mbo)
continue;
 
@@ -283,7 +283,7 @@ static int pcm_open(struct snd_pcm_substream *substream)
}
}
 
-   if (most_start_channel(channel->iface, channel->id, &audio_aim)) {
+   if (most_start_channel(channel->iface, channel->id, &comp)) {
pr_err("most_start_channel() failed!\n");
if (cfg->direction == MOST_CH_TX)
kthread_stop(channel->playback_task);
@@ -310,7 +310,7 @@ static int pcm_close(struct snd_pcm_substream *substream)
 
if (channel->cfg->direction == MOST_CH_TX)
kthread_stop(channel->playback_task);
-   most_stop_channel(channel->iface, channel->id, &audio_aim);
+   most_stop_channel(channel->iface, channel->id, &comp);
 
return 0;
 }
@@ -725,7 +725,7 @@ static int audio_tx_completion(struct most_interface 
*iface, int channel_id)
 /**
  * Initialization of the struct core_component
  */
-static struct core_component audio_aim = {
+static struct core_component comp = {
.name = DRIVER_NAME,
.probe_channel = audio_probe_channel,
.disconnect_channel = audio_disconnect_channel,
@@ -739,7 +739,7 @@ static int __init audio_init(void)
 
INIT_LIST_HEAD(&dev_list);
 
-   return most_register_component(&audio_aim);
+   return most_register_component(&comp);
 }
 
 static void __exit audio_exit(void)
@@ -753,7 +753,7 @@ static void __exit audio_exit(void)
snd_card_free(channel->card);
}
 
-   most_deregister_component(&audio_aim);
+   most_deregister_component(&comp);
 }
 
 module_init(audio_init);
-- 
2.7.4

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


[PATCH 39/50] staging: most: core: denote modules as components

2017-11-21 Thread Christian Gromm
Substrings containing 'module' are replaced with 'component' by this patch.
It is needed to complete the process of changing the module designator from
AIM to Component.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index d490bdc..b0e9179 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -526,7 +526,7 @@ static const struct attribute_group 
*interface_attr_groups[] = {
NULL,
 };
 
-static struct core_component *match_module(char *name)
+static struct core_component *match_component(char *name)
 {
struct core_component *comp;
 
@@ -571,7 +571,7 @@ static ssize_t links_show(struct device_driver *drv, char 
*buf)
return strlen(buf);
 }
 
-static ssize_t modules_show(struct device_driver *drv, char *buf)
+static ssize_t components_show(struct device_driver *drv, char *buf)
 {
struct core_component *comp;
int offs = 0;
@@ -720,7 +720,7 @@ static ssize_t add_link_store(struct device_driver *drv,
ret = split_string(buffer, &mdev, &mdev_ch, &comp_name, &comp_param);
if (ret)
return ret;
-   comp = match_module(comp_name);
+   comp = match_component(comp_name);
if (!comp_param || *comp_param == 0) {
snprintf(devnod_buf, sizeof(devnod_buf), "%s-%s", mdev,
 mdev_ch);
@@ -764,7 +764,7 @@ static ssize_t remove_link_store(struct device_driver *drv,
ret = split_string(buffer, &mdev, &mdev_ch, &comp_name, NULL);
if (ret)
return ret;
-   comp = match_module(comp_name);
+   comp = match_component(comp_name);
c = get_channel(mdev, mdev_ch);
if (!c)
return -ENODEV;
@@ -781,24 +781,24 @@ static ssize_t remove_link_store(struct device_driver 
*drv,
 #define DRV_ATTR(_name)  (&driver_attr_##_name.attr)
 
 static DRIVER_ATTR_RO(links);
-static DRIVER_ATTR_RO(modules);
+static DRIVER_ATTR_RO(components);
 static DRIVER_ATTR_WO(add_link);
 static DRIVER_ATTR_WO(remove_link);
 
-static struct attribute *module_attrs[] = {
+static struct attribute *mc_attrs[] = {
DRV_ATTR(links),
-   DRV_ATTR(modules),
+   DRV_ATTR(components),
DRV_ATTR(add_link),
DRV_ATTR(remove_link),
NULL,
 };
 
-static struct attribute_group module_attr_group = {
-   .attrs = module_attrs,
+static struct attribute_group mc_attr_group = {
+   .attrs = mc_attrs,
 };
 
-static const struct attribute_group *module_attr_groups[] = {
-   &module_attr_group,
+static const struct attribute_group *mc_attr_groups[] = {
+   &mc_attr_group,
NULL,
 };
 
@@ -1558,7 +1558,7 @@ static int __init most_init(void)
mc.bus.match = most_match,
mc.drv.name = "most_core",
mc.drv.bus = &mc.bus,
-   mc.drv.groups = module_attr_groups;
+   mc.drv.groups = mc_attr_groups;
 
err = bus_register(&mc.bus);
if (err) {
-- 
2.7.4

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


[PATCH 21/50] staging: most: core: rename function

2017-11-21 Thread Christian Gromm
The core module used to have two functions to find a certain
channel. One by name and one by interface. Since no channel is
searched by its interface name anymore the by_name suffix is
rendered redundant. This patch renames the function accordingly.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 8f6fa9e..4caea38 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -634,13 +634,13 @@ static int split_string(char *buf, char **a, char **b, 
char **c, char **d)
 }
 
 /**
- * get_channel_by_name - get pointer to channel object
+ * get_channel - get pointer to channel object
  * @mdev: name of the device instance
  * @mdev_ch: name of the respective channel
  *
  * This retrieves the pointer to a channel object.
  */
-static struct most_channel *get_channel_by_name(char *mdev, char *mdev_ch)
+static struct most_channel *get_channel(char *mdev, char *mdev_ch)
 {
struct most_channel *c, *tmp;
struct most_inst_obj *i, *i_tmp;
@@ -740,7 +740,7 @@ static ssize_t add_link_store(struct device_driver *drv,
aim_param = devnod_buf;
}
 
-   c = get_channel_by_name(mdev, mdev_ch);
+   c = get_channel(mdev, mdev_ch);
if (IS_ERR(c))
return -ENODEV;
 
@@ -779,7 +779,7 @@ static ssize_t remove_link_store(struct device_driver *drv,
if (ret)
return ret;
aim = match_module(aim_name);
-   c = get_channel_by_name(mdev, mdev_ch);
+   c = get_channel(mdev, mdev_ch);
if (IS_ERR(c))
return -ENODEV;
 
-- 
2.7.4

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


[PATCH 45/50] staging: most: cdev: replace function prefix

2017-11-21 Thread Christian Gromm
This patch replaces the function prefixes aim_* with comp_*. It is needed
to complete the process of changing the module designator from AIM to
Component.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/cdev/cdev.c | 58 
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c
index 225369d..be535ae 100644
--- a/drivers/staging/most/cdev/cdev.c
+++ b/drivers/staging/most/cdev/cdev.c
@@ -112,14 +112,14 @@ static void destroy_channel(struct comp_channel *c)
 }
 
 /**
- * aim_open - implements the syscall to open the device
+ * comp_open - implements the syscall to open the device
  * @inode: inode pointer
  * @filp: file pointer
  *
  * This stores the channel pointer in the private data field of
  * the file structure and activates the channel within the core.
  */
-static int aim_open(struct inode *inode, struct file *filp)
+static int comp_open(struct inode *inode, struct file *filp)
 {
struct comp_channel *c;
int ret;
@@ -157,13 +157,13 @@ static int aim_open(struct inode *inode, struct file 
*filp)
 }
 
 /**
- * aim_close - implements the syscall to close the device
+ * comp_close - implements the syscall to close the device
  * @inode: inode pointer
  * @filp: file pointer
  *
  * This stops the channel within the core.
  */
-static int aim_close(struct inode *inode, struct file *filp)
+static int comp_close(struct inode *inode, struct file *filp)
 {
struct comp_channel *c = to_channel(inode->i_cdev);
 
@@ -182,14 +182,14 @@ static int aim_close(struct inode *inode, struct file 
*filp)
 }
 
 /**
- * aim_write - implements the syscall to write to the device
+ * comp_write - implements the syscall to write to the device
  * @filp: file pointer
  * @buf: pointer to user buffer
  * @count: number of bytes to write
  * @offset: offset from where to start writing
  */
-static ssize_t aim_write(struct file *filp, const char __user *buf,
-size_t count, loff_t *offset)
+static ssize_t comp_write(struct file *filp, const char __user *buf,
+ size_t count, loff_t *offset)
 {
int ret;
size_t to_copy, left;
@@ -236,14 +236,14 @@ static ssize_t aim_write(struct file *filp, const char 
__user *buf,
 }
 
 /**
- * aim_read - implements the syscall to read from the device
+ * comp_read - implements the syscall to read from the device
  * @filp: file pointer
  * @buf: pointer to user buffer
  * @count: number of bytes to read
  * @offset: offset from where to start reading
  */
 static ssize_t
-aim_read(struct file *filp, char __user *buf, size_t count, loff_t *offset)
+comp_read(struct file *filp, char __user *buf, size_t count, loff_t *offset)
 {
size_t to_copy, not_copied, copied;
struct mbo *mbo;
@@ -287,7 +287,7 @@ aim_read(struct file *filp, char __user *buf, size_t count, 
loff_t *offset)
return copied;
 }
 
-static unsigned int aim_poll(struct file *filp, poll_table *wait)
+static unsigned int comp_poll(struct file *filp, poll_table *wait)
 {
struct comp_channel *c = filp->private_data;
unsigned int mask = 0;
@@ -309,22 +309,22 @@ static unsigned int aim_poll(struct file *filp, 
poll_table *wait)
  */
 static const struct file_operations channel_fops = {
.owner = THIS_MODULE,
-   .read = aim_read,
-   .write = aim_write,
-   .open = aim_open,
-   .release = aim_close,
-   .poll = aim_poll,
+   .read = comp_read,
+   .write = comp_write,
+   .open = comp_open,
+   .release = comp_close,
+   .poll = comp_poll,
 };
 
 /**
- * aim_disconnect_channel - disconnect a channel
+ * comp_disconnect_channel - disconnect a channel
  * @iface: pointer to interface instance
  * @channel_id: channel index
  *
  * This frees allocated memory and removes the cdev that represents this
  * channel in user space.
  */
-static int aim_disconnect_channel(struct most_interface *iface, int channel_id)
+static int comp_disconnect_channel(struct most_interface *iface, int 
channel_id)
 {
struct comp_channel *c;
 
@@ -354,13 +354,13 @@ static int aim_disconnect_channel(struct most_interface 
*iface, int channel_id)
 }
 
 /**
- * aim_rx_completion - completion handler for rx channels
+ * comp_rx_completion - completion handler for rx channels
  * @mbo: pointer to buffer object that has completed
  *
  * This searches for the channel linked to this MBO and stores it in the local
  * fifo buffer.
  */
-static int aim_rx_completion(struct mbo *mbo)
+static int comp_rx_completion(struct mbo *mbo)
 {
struct comp_channel *c;
 
@@ -387,13 +387,13 @@ static int aim_rx_completion(struct mbo *mbo)
 }
 
 /**
- * aim_tx_completion - completion handler for tx channels
+ * comp_tx_completion - completion handler for tx channels
  * @iface: pointer to interface instance
  * @channel_id: channel index/ID
  *
  * This wakes sleeping processes in 

[PATCH 26/50] staging: most: rename struct most_aim

2017-11-21 Thread Christian Gromm
The designator of a module that proivdes means to interface userspace is
called an AIM. Since this name seems to be unappropiate, this kind of
moduels are going to be referred to as componetns. This is done because
such modules function as components to enhance the core with new features.
This patch renames the struct most_aim to core_component.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/cdev/cdev.c   |  4 ++--
 drivers/staging/most/core.c| 30 +++---
 drivers/staging/most/core.h| 16 +++-
 drivers/staging/most/net/net.c |  4 ++--
 drivers/staging/most/sound/sound.c |  6 +++---
 drivers/staging/most/video/video.c |  4 ++--
 6 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c
index c6baa9c..e1290b8 100644
--- a/drivers/staging/most/cdev/cdev.c
+++ b/drivers/staging/most/cdev/cdev.c
@@ -28,7 +28,7 @@ static dev_t aim_devno;
 static struct class *aim_class;
 static struct ida minor_id;
 static unsigned int major;
-static struct most_aim cdev_aim;
+static struct core_component cdev_aim;
 
 struct aim_channel {
wait_queue_head_t wq;
@@ -495,7 +495,7 @@ static int aim_probe(struct most_interface *iface, int 
channel_id,
return retval;
 }
 
-static struct most_aim cdev_aim = {
+static struct core_component cdev_aim = {
.name = "cdev",
.probe_channel = aim_probe,
.disconnect_channel = aim_disconnect_channel,
diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index f47d581..fa1ed89d6 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -46,7 +46,7 @@ static struct mostcore {
 #define to_driver(d) container_of(d, struct mostcore, drv);
 
 struct pipe {
-   struct most_aim *aim;
+   struct core_component *aim;
int refs;
int num_buffers;
 };
@@ -536,9 +536,9 @@ static const struct attribute_group 
*interface_attr_groups[] = {
 /*  ___ ___
  *  ___A I M___
  */
-static struct most_aim *match_module(char *name)
+static struct core_component *match_module(char *name)
 {
-   struct most_aim *aim;
+   struct core_component *aim;
 
list_for_each_entry(aim, &mc.mod_list, list) {
if (!strcmp(aim->name, name))
@@ -583,7 +583,7 @@ static ssize_t links_show(struct device_driver *drv, char 
*buf)
 
 static ssize_t modules_show(struct device_driver *drv, char *buf)
 {
-   struct most_aim *aim;
+   struct core_component *aim;
int offs = 0;
 
list_for_each_entry(aim, &mc.mod_list, list) {
@@ -666,11 +666,11 @@ static struct most_channel *get_channel(char *mdev, char 
*mdev_ch)
 }
 
 static
-inline int link_channel_to_aim(struct most_channel *c, struct most_aim *aim,
+inline int link_channel_to_aim(struct most_channel *c, struct core_component 
*aim,
   char *aim_param)
 {
int ret;
-   struct most_aim **aim_ptr;
+   struct core_component **aim_ptr;
 
if (!c->pipe0.aim)
aim_ptr = &c->pipe0.aim;
@@ -717,7 +717,7 @@ static ssize_t add_link_store(struct device_driver *drv,
  size_t len)
 {
struct most_channel *c;
-   struct most_aim *aim;
+   struct core_component *aim;
char buffer[STRING_SIZE];
char *mdev;
char *mdev_ch;
@@ -765,7 +765,7 @@ static ssize_t remove_link_store(struct device_driver *drv,
 size_t len)
 {
struct most_channel *c;
-   struct most_aim *aim;
+   struct core_component *aim;
char buffer[STRING_SIZE];
char *mdev;
char *mdev_ch;
@@ -1045,7 +1045,7 @@ static void most_write_completion(struct mbo *mbo)
arm_mbo(mbo);
 }
 
-int channel_has_mbo(struct most_interface *iface, int id, struct most_aim *aim)
+int channel_has_mbo(struct most_interface *iface, int id, struct 
core_component *aim)
 {
struct most_channel *c = iface->p->channel[id];
unsigned long flags;
@@ -1075,7 +1075,7 @@ EXPORT_SYMBOL_GPL(channel_has_mbo);
  * Returns a pointer to MBO on success or NULL otherwise.
  */
 struct mbo *most_get_mbo(struct most_interface *iface, int id,
-struct most_aim *aim)
+struct core_component *aim)
 {
struct mbo *mbo;
struct most_channel *c;
@@ -1180,7 +1180,7 @@ static void most_read_completion(struct mbo *mbo)
  * Returns 0 on success or error code otherwise.
  */
 int most_start_channel(struct most_interface *iface, int id,
-  struct most_aim *aim)
+  struct core_component *aim)
 {
int num_buffer;
int ret;
@@ -1250,7 +1250,7 @@ EXPORT_SYMBOL_GPL(most_start_channel);
  * @id: channel ID
  */
 int most_stop_channel(struct most_interface *iface, int id,
- struct most_aim *aim)
+ struct core

[PATCH 28/50] staging: most: core: rename mod_list

2017-11-21 Thread Christian Gromm
This patch renames the variable mod_list to comp_list.  It is needed
because modules that interface userspace are referred to as components.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index db453f2..42f35ed 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -40,7 +40,7 @@ static struct mostcore {
struct device_driver drv;
struct bus_type bus;
struct class *class;
-   struct list_head mod_list;
+   struct list_head comp_list;
 } mc;
 
 #define to_driver(d) container_of(d, struct mostcore, drv);
@@ -541,7 +541,7 @@ static struct core_component *match_module(char *name)
 {
struct core_component *aim;
 
-   list_for_each_entry(aim, &mc.mod_list, list) {
+   list_for_each_entry(aim, &mc.comp_list, list) {
if (!strcmp(aim->name, name))
return aim;
}
@@ -587,7 +587,7 @@ static ssize_t modules_show(struct device_driver *drv, char 
*buf)
struct core_component *aim;
int offs = 0;
 
-   list_for_each_entry(aim, &mc.mod_list, list) {
+   list_for_each_entry(aim, &mc.comp_list, list) {
offs += snprintf(buf + offs, PAGE_SIZE - offs, "%s\n",
 aim->name);
}
@@ -1315,7 +1315,7 @@ int most_register_component(struct core_component *aim)
pr_err("Bad driver\n");
return -EINVAL;
}
-   list_add_tail(&aim->list, &mc.mod_list);
+   list_add_tail(&aim->list, &mc.comp_list);
pr_info("registered new application interfacing module %s\n", 
aim->name);
return 0;
 }
@@ -1565,7 +1565,7 @@ static int __init most_init(void)
int err;
 
pr_info("init()\n");
-   INIT_LIST_HEAD(&mc.mod_list);
+   INIT_LIST_HEAD(&mc.comp_list);
ida_init(&mdev_id);
 
mc.bus.name = "most",
-- 
2.7.4

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


[PATCH 43/50] staging: most: core: check value returned by match function

2017-11-21 Thread Christian Gromm
This patch adds a check for the pointer returned by the function
match_component. It is needed to prevent a NULL pointer dereference in
case the provided component name does not match any list entry.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 79a90a2..72f1526 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -717,6 +717,8 @@ static ssize_t add_link_store(struct device_driver *drv,
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);
@@ -760,6 +762,8 @@ static ssize_t remove_link_store(struct device_driver *drv,
if (ret)
return ret;
comp = match_component(comp_name);
+   if (!comp)
+   return -ENODEV;
c = get_channel(mdev, mdev_ch);
if (!c)
return -ENODEV;
-- 
2.7.4

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


[PATCH 48/50] staging: most: core: fix list traversing

2017-11-21 Thread Christian Gromm
From: Andrey Shvetsov 

This patch fixes the offset and data handling when traversing
the list of devices that are attached to the bus.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index d03ff97..9729206 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -535,10 +535,16 @@ static struct core_component *match_component(char *name)
return NULL;
 }
 
+struct show_links_data {
+   int offs;
+   char *buf;
+};
+
 int print_links(struct device *dev, void *data)
 {
-   int offs = 0;
-   char *buf = data;
+   struct show_links_data *d = data;
+   int offs = d->offs;
+   char *buf = d->buf;
struct most_channel *c;
struct most_interface *iface = to_most_interface(dev);
 
@@ -560,13 +566,16 @@ int print_links(struct device *dev, void *data)
 dev_name(&c->dev));
}
}
+   d->offs = offs;
return 0;
 }
 
 static ssize_t links_show(struct device_driver *drv, char *buf)
 {
-   bus_for_each_dev(&mc.bus, NULL, buf, print_links);
-   return strlen(buf);
+   struct show_links_data d = { .buf = buf };
+
+   bus_for_each_dev(&mc.bus, NULL, &d, print_links);
+   return d.offs;
 }
 
 static ssize_t components_show(struct device_driver *drv, char *buf)
-- 
2.7.4

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


[PATCH 47/50] staging: most: core: remove class generation

2017-11-21 Thread Christian Gromm
This patch stops the core from generating a module owned class and
registering it with the kernel. It is needed, because there is no need for
a default MOST class to be present in the kernel.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 72f1526..d03ff97 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -39,7 +39,6 @@ static struct mostcore {
struct device dev;
struct device_driver drv;
struct bus_type bus;
-   struct class *class;
struct list_head comp_list;
 } mc;
 
@@ -1564,17 +1563,10 @@ static int __init most_init(void)
pr_info("Cannot register most bus\n");
return err;
}
-   mc.class = class_create(THIS_MODULE, "most");
-   if (IS_ERR(mc.class)) {
-   pr_info("No udev support.\n");
-   err = PTR_ERR(mc.class);
-   goto exit_bus;
-   }
-
err = driver_register(&mc.drv);
if (err) {
pr_info("Cannot register core driver\n");
-   goto exit_class;
+   goto exit_bus;
}
mc.dev.init_name = "most_bus";
mc.dev.release = release_most_sub;
@@ -1587,8 +1579,6 @@ static int __init most_init(void)
 
 exit_driver:
driver_unregister(&mc.drv);
-exit_class:
-   class_destroy(mc.class);
 exit_bus:
bus_unregister(&mc.bus);
return err;
@@ -1599,7 +1589,6 @@ static void __exit most_exit(void)
pr_info("exit core module\n");
device_unregister(&mc.dev);
driver_unregister(&mc.drv);
-   class_destroy(mc.class);
bus_unregister(&mc.bus);
ida_destroy(&mdev_id);
 }
-- 
2.7.4

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


[PATCH 29/50] staging: most: core: rename aim variables

2017-11-21 Thread Christian Gromm
This patch replaces the 'aim' substrings of variable names with 'comp'.
It is needed because of the renaming of AIM modules to components.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c | 172 ++--
 1 file changed, 87 insertions(+), 85 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 42f35ed..c80fb9b 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -46,7 +46,7 @@ static struct mostcore {
 #define to_driver(d) container_of(d, struct mostcore, drv);
 
 struct pipe {
-   struct core_component *aim;
+   struct core_component *comp;
int refs;
int num_buffers;
 };
@@ -539,11 +539,11 @@ static const struct attribute_group 
*interface_attr_groups[] = {
  */
 static struct core_component *match_module(char *name)
 {
-   struct core_component *aim;
+   struct core_component *comp;
 
-   list_for_each_entry(aim, &mc.comp_list, list) {
-   if (!strcmp(aim->name, name))
-   return aim;
+   list_for_each_entry(comp, &mc.comp_list, list) {
+   if (!strcmp(comp->name, name))
+   return comp;
}
return NULL;
 }
@@ -556,19 +556,19 @@ int print_links(struct device *dev, void *data)
struct most_interface *iface = to_most_interface(dev);
 
list_for_each_entry(c, &iface->p->channel_list, list) {
-   if (c->pipe0.aim) {
+   if (c->pipe0.comp) {
offs += snprintf(buf + offs,
 PAGE_SIZE - offs,
 "%s:%s:%s\n",
-c->pipe0.aim->name,
+c->pipe0.comp->name,
 dev_name(&iface->dev),
 dev_name(&c->dev));
}
-   if (c->pipe1.aim) {
+   if (c->pipe1.comp) {
offs += snprintf(buf + offs,
 PAGE_SIZE - offs,
 "%s:%s:%s\n",
-c->pipe1.aim->name,
+c->pipe1.comp->name,
 dev_name(&iface->dev),
 dev_name(&c->dev));
}
@@ -584,12 +584,12 @@ static ssize_t links_show(struct device_driver *drv, char 
*buf)
 
 static ssize_t modules_show(struct device_driver *drv, char *buf)
 {
-   struct core_component *aim;
+   struct core_component *comp;
int offs = 0;
 
-   list_for_each_entry(aim, &mc.comp_list, list) {
+   list_for_each_entry(comp, &mc.comp_list, list) {
offs += snprintf(buf + offs, PAGE_SIZE - offs, "%s\n",
-aim->name);
+comp->name);
}
return offs;
 }
@@ -667,24 +667,25 @@ static struct most_channel *get_channel(char *mdev, char 
*mdev_ch)
 }
 
 static
-inline int link_channel_to_aim(struct most_channel *c, struct core_component 
*aim,
-  char *aim_param)
+inline int link_channel_to_aim(struct most_channel *c,
+  struct core_component *comp,
+  char *comp_param)
 {
int ret;
-   struct core_component **aim_ptr;
+   struct core_component **comp_ptr;
 
-   if (!c->pipe0.aim)
-   aim_ptr = &c->pipe0.aim;
-   else if (!c->pipe1.aim)
-   aim_ptr = &c->pipe1.aim;
+   if (!c->pipe0.comp)
+   comp_ptr = &c->pipe0.comp;
+   else if (!c->pipe1.comp)
+   comp_ptr = &c->pipe1.comp;
else
return -ENOSPC;
 
-   *aim_ptr = aim;
-   ret = aim->probe_channel(c->iface, c->channel_id,
-&c->cfg, aim_param);
+   *comp_ptr = comp;
+   ret = comp->probe_channel(c->iface, c->channel_id,
+&c->cfg, comp_param);
if (ret) {
-   *aim_ptr = NULL;
+   *comp_ptr = NULL;
return ret;
}
 
@@ -718,33 +719,33 @@ static ssize_t add_link_store(struct device_driver *drv,
  size_t len)
 {
struct most_channel *c;
-   struct core_component *aim;
+   struct core_component *comp;
char buffer[STRING_SIZE];
char *mdev;
char *mdev_ch;
-   char *aim_name;
-   char *aim_param;
+   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, &mdev, &mdev_ch, &aim_name, &aim_param);
+   ret = split_string(buffer, &mdev, &mdev_ch, &comp_name, &comp_param);
  

[PATCH 41/50] staging: most: usb: clear functional stall on OUT endpoint

2017-11-21 Thread Christian Gromm
For the MOST packet channel there are two dedicated USB endpoints. But
internally the hardware has actually one channel for data forwarding from
and to MOST. To have the hardware clean up its state machine correctly in
case of an error, both USB pipes need to be reset.  This patch triggers the
host to also clear the OUT endpoint's halt condition in case an IN endpoint
has signaled to be stalled.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/usb/usb.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c
index acd0a36..49f5495 100644
--- a/drivers/staging/most/usb/usb.c
+++ b/drivers/staging/most/usb/usb.c
@@ -815,6 +815,21 @@ static void wq_clear_halt(struct work_struct *wq_obj)
if (usb_clear_halt(mdev->usb_device, pipe))
dev_warn(&mdev->usb_device->dev, "Failed to reset endpoint.\n");
 
+   /* If the functional Stall condition has been set on an
+* asynchronous rx channel, we need to clear the tx channel
+* too, since the hardware runs its clean-up sequence on both
+* channels, as they are physically one on the network.
+*
+* The USB interface that exposes the asynchronous channels
+* contains always two endpoints, and two only.
+*/
+   if (mdev->conf[channel].data_type == MOST_CH_ASYNC &&
+   mdev->conf[channel].direction == MOST_CH_RX) {
+   int peer = 1 - channel;
+   int snd_pipe = usb_sndbulkpipe(mdev->usb_device,
+  mdev->ep_address[peer]);
+   usb_clear_halt(mdev->usb_device, snd_pipe);
+   }
mdev->is_channel_healthy[channel] = true;
most_resume_enqueue(&mdev->iface, channel);
mutex_unlock(&mdev->io_mutex);
-- 
2.7.4

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


[PATCH 50/50] staging: most: usb: fix show/store function names

2017-11-21 Thread Christian Gromm
This patch renames the show/store functions of the USB module.
It is needed to make the module meet the established naming
convention.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/usb/usb.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c
index 49f5495..b5369b4 100644
--- a/drivers/staging/most/usb/usb.c
+++ b/drivers/staging/most/usb/usb.c
@@ -893,7 +893,7 @@ static int get_stat_reg_addr(const struct regs *regs, int 
size,
 #define get_static_reg_addr(regs, name, reg_addr) \
get_stat_reg_addr(regs, ARRAY_SIZE(regs), name, reg_addr)
 
-static ssize_t show_value(struct device *dev, struct device_attribute *attr,
+static ssize_t value_show(struct device *dev, struct device_attribute *attr,
  char *buf)
 {
const char *name = attr->attr.name;
@@ -918,7 +918,7 @@ static ssize_t show_value(struct device *dev, struct 
device_attribute *attr,
return snprintf(buf, PAGE_SIZE, "%04x\n", val);
 }
 
-static ssize_t store_value(struct device *dev, struct device_attribute *attr,
+static ssize_t value_store(struct device *dev, struct device_attribute *attr,
   const char *buf, size_t count)
 {
u16 val;
@@ -951,21 +951,21 @@ static ssize_t store_value(struct device *dev, struct 
device_attribute *attr,
return count;
 }
 
-DEVICE_ATTR(ni_state, 0444, show_value, NULL);
-DEVICE_ATTR(packet_bandwidth, 0444, show_value, NULL);
-DEVICE_ATTR(node_address, 0444, show_value, NULL);
-DEVICE_ATTR(node_position, 0444, show_value, NULL);
-DEVICE_ATTR(sync_ep, 0200, NULL, store_value);
-DEVICE_ATTR(mep_filter, 0644, show_value, store_value);
-DEVICE_ATTR(mep_hash0, 0644, show_value, store_value);
-DEVICE_ATTR(mep_hash1, 0644, show_value, store_value);
-DEVICE_ATTR(mep_hash2, 0644, show_value, store_value);
-DEVICE_ATTR(mep_hash3, 0644, show_value, store_value);
-DEVICE_ATTR(mep_eui48_hi, 0644, show_value, store_value);
-DEVICE_ATTR(mep_eui48_mi, 0644, show_value, store_value);
-DEVICE_ATTR(mep_eui48_lo, 0644, show_value, store_value);
-DEVICE_ATTR(arb_address, 0644, show_value, store_value);
-DEVICE_ATTR(arb_value, 0644, show_value, store_value);
+DEVICE_ATTR(ni_state, 0444, value_show, NULL);
+DEVICE_ATTR(packet_bandwidth, 0444, value_show, NULL);
+DEVICE_ATTR(node_address, 0444, value_show, NULL);
+DEVICE_ATTR(node_position, 0444, value_show, NULL);
+DEVICE_ATTR(sync_ep, 0200, NULL, value_store);
+DEVICE_ATTR(mep_filter, 0644, value_show, value_store);
+DEVICE_ATTR(mep_hash0, 0644, value_show, value_store);
+DEVICE_ATTR(mep_hash1, 0644, value_show, value_store);
+DEVICE_ATTR(mep_hash2, 0644, value_show, value_store);
+DEVICE_ATTR(mep_hash3, 0644, value_show, value_store);
+DEVICE_ATTR(mep_eui48_hi, 0644, value_show, value_store);
+DEVICE_ATTR(mep_eui48_mi, 0644, value_show, value_store);
+DEVICE_ATTR(mep_eui48_lo, 0644, value_show, value_store);
+DEVICE_ATTR(arb_address, 0644, value_show, value_store);
+DEVICE_ATTR(arb_value, 0644, value_show, value_store);
 
 static struct attribute *dci_attrs[] = {
&dev_attr_ni_state.attr,
-- 
2.7.4

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


[PATCH 40/50] staging: most: core: fix formatting

2017-11-21 Thread Christian Gromm
This patch fixes coding style violations.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.c| 7 +--
 drivers/staging/most/video/video.c | 2 +-
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index b0e9179..79a90a2 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -283,7 +283,6 @@ static ssize_t set_number_of_buffers_store(struct device 
*dev,
   size_t count)
 {
struct most_channel *c = to_channel(dev);
-
int ret = kstrtou16(buf, 0, &c->cfg.num_buffers);
 
if (ret)
@@ -669,13 +668,11 @@ inline int link_channel_to_component(struct most_channel 
*c,
return -ENOSPC;
 
*comp_ptr = comp;
-   ret = comp->probe_channel(c->iface, c->channel_id,
-&c->cfg, comp_param);
+   ret = comp->probe_channel(c->iface, c->channel_id, &c->cfg, comp_param);
if (ret) {
*comp_ptr = NULL;
return ret;
}
-
return 0;
 }
 
@@ -716,7 +713,6 @@ static ssize_t add_link_store(struct device_driver *drv,
size_t max_len = min_t(size_t, len + 1, STRING_SIZE);
 
strlcpy(buffer, buf, max_len);
-
ret = split_string(buffer, &mdev, &mdev_ch, &comp_name, &comp_param);
if (ret)
return ret;
@@ -734,7 +730,6 @@ static ssize_t add_link_store(struct device_driver *drv,
ret = link_channel_to_component(c, comp, comp_param);
if (ret)
return ret;
-
return len;
 }
 
diff --git a/drivers/staging/most/video/video.c 
b/drivers/staging/most/video/video.c
index 1577f36..a55a2e6 100644
--- a/drivers/staging/most/video/video.c
+++ b/drivers/staging/most/video/video.c
@@ -547,7 +547,7 @@ static int comp_probe_channel(struct most_interface *iface, 
int channel_idx,
 }
 
 static int comp_disconnect_channel(struct most_interface *iface,
- int channel_idx)
+  int channel_idx)
 {
struct most_video_dev *mdev = get_comp_dev(iface, channel_idx);
 
-- 
2.7.4

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


[PATCH 49/50] staging: most: add ABI documentation

2017-11-21 Thread Christian Gromm
This patchg adds the sysfs-bus-most.txt file to the source tree.
It is needed to have an ABI description of the driver's sysfs
interface.

Signed-off-by: Christian Gromm 
---
 .../most/Documentation/ABI/sysfs-bus-most.txt  | 313 +
 1 file changed, 313 insertions(+)
 create mode 100644 drivers/staging/most/Documentation/ABI/sysfs-bus-most.txt

diff --git a/drivers/staging/most/Documentation/ABI/sysfs-bus-most.txt 
b/drivers/staging/most/Documentation/ABI/sysfs-bus-most.txt
new file mode 100644
index 000..d8fa841
--- /dev/null
+++ b/drivers/staging/most/Documentation/ABI/sysfs-bus-most.txt
@@ -0,0 +1,313 @@
+What:  /sys/bus/most/devices/.../description
+Date:  March 2017
+KernelVersion: 4.15
+Contact:   Christian Gromm 
+Description:
+   Provides information about the interface type and the physical
+   location of the device. Hardware attached via USB, for instance,
+   might return 
+Users:
+
+What:  /sys/bus/most/devices/.../interface
+Date:  March 2017
+KernelVersion: 4.15
+Contact:   Christian Gromm 
+Description:
+   Indicates the type of peripheral interface the device uses.
+Users:
+
+What:  /sys/bus/most/devices/.../dci
+Date:  June 2016
+KernelVersion: 4.15
+Contact:   Christian Gromm 
+Description:
+   If the network interface controller is attached via USB, a dci
+   directory is created that allows applications to read and
+   write the controller's DCI registers.
+Users:
+
+What:  /sys/bus/most/devices/.../dci/arb_address
+Date:  June 2016
+KernelVersion: 4.15
+Contact:   Christian Gromm 
+Description:
+   This is used to set an arbitrary DCI register address an
+   application wants to read from or write to.
+Users:
+
+What:  /sys/bus/most/devices/.../dci/arb_value
+Date:  June 2016
+KernelVersion: 4.15
+Contact:   Christian Gromm 
+Description:
+   This is used to read and write the DCI register whose address
+   is stored in arb_address.
+Users:
+
+What:  /sys/bus/most/devices/.../dci/mep_eui48_hi
+Date:  June 2016
+KernelVersion: 4.15
+Contact:   Christian Gromm 
+Description:
+   This is used to check and configure the MAC address.
+Users:
+
+What:  /sys/bus/most/devices/.../dci/mep_eui48_lo
+Date:  June 2016
+KernelVersion: 4.15
+Contact:   Christian Gromm 
+Description:
+   This is used to check and configure the MAC address.
+Users:
+
+What:  /sys/bus/most/devices/.../dci/mep_eui48_mi
+Date:  June 2016
+KernelVersion: 4.15
+Contact:   Christian Gromm 
+Description:
+   This is used to check and configure the MAC address.
+Users:
+
+What:  /sys/bus/most/devices/.../dci/mep_filter
+Date:  June 2016
+KernelVersion: 4.15
+Contact:   Christian Gromm 
+Description:
+   This is used to check and configure the MEP filter address.
+Users:
+
+What:  /sys/bus/most/devices/.../dci/mep_hash0
+Date:  June 2016
+KernelVersion: 4.15
+Contact:   Christian Gromm 
+Description:
+   This is used to check and configure the MEP hash table.
+Users:
+
+What:  /sys/bus/most/devices/.../dci/mep_hash1
+Date:  June 2016
+KernelVersion: 4.15
+Contact:   Christian Gromm 
+Description:
+   This is used to check and configure the MEP hash table.
+Users:
+
+What:  /sys/bus/most/devices/.../dci/mep_hash2
+Date:  June 2016
+KernelVersion: 4.15
+Contact:   Christian Gromm 
+Description:
+   This is used to check and configure the MEP hash table.
+Users:
+
+What:  /sys/bus/most/devices/.../dci/mep_hash3
+Date:  June 2016
+KernelVersion: 4.15
+Contact:   Christian Gromm 
+Description:
+   This is used to check and configure the MEP hash table.
+Users:
+
+What:  /sys/bus/most/devices/.../dci/ni_state
+Date:  June 2016
+KernelVersion: 4.15
+Contact:   Christian Gromm 
+Description:
+   Indicates the current network interface state.
+Users:
+
+What:  /sys/bus/most/devices/.../dci/node_address
+Date:  June 2016
+KernelVersion: 4.15
+Contact:   Christian Gromm 
+Description:
+   Indicates the current node address.
+Users:
+
+What:  /sys/bus/most/devices/.../dci/node_position
+Date:  June 2016
+KernelVersion: 4.15
+Contact:   Christian Gromm 
+Description:
+   Indicates the current node position.
+Users:
+
+What:  /sys/bus/most/devices/.../dci/packet_bandwidth
+Date:  June 2016
+KernelVersion: 4.15
+Contact:   Christian Gromm 
+Description:
+   Indicates the configured packet bandwidth.
+Users:
+
+What:  /sys/bus/most/devices/.../dci/sync_ep
+Date:  June 2016
+KernelVersion: 4.15
+C

[PATCH 42/50] staging: most: core: fix data type

2017-11-21 Thread Christian Gromm
This patch fixes the type used to manage the channels of an
registered MOST interface.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/core.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/most/core.h b/drivers/staging/most/core.h
index d6e9b87..7c44791 100644
--- a/drivers/staging/most/core.h
+++ b/drivers/staging/most/core.h
@@ -238,7 +238,7 @@ struct most_interface {
struct module *mod;
enum most_interface_type interface;
const char *description;
-   int num_channels;
+   unsigned int num_channels;
struct most_channel_capability *channel_vector;
int (*configure)(struct most_interface *iface, int channel_idx,
 struct most_channel_config *channel_config);
-- 
2.7.4

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


[PATCH 46/50] staging: most: cdev: bundle module variables in structure

2017-11-21 Thread Christian Gromm
This patch creates the structure comp to put the module variables for
encapsulation purposes. For an improved readability some variables are
renamed.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/cdev/cdev.c | 88 
 1 file changed, 43 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c
index be535ae..6dcd4f3 100644
--- a/drivers/staging/most/cdev/cdev.c
+++ b/drivers/staging/most/cdev/cdev.c
@@ -24,11 +24,13 @@
 #include 
 #include "most/core.h"
 
-static dev_t comp_devno;
-static struct class *comp_class;
-static struct ida minor_id;
-static unsigned int major;
-static struct core_component cdev_comp;
+static struct cdev_component {
+   dev_t devno;
+   struct ida minor_id;
+   unsigned int major;
+   struct class *class;
+   struct core_component cc;
+} comp;
 
 struct comp_channel {
wait_queue_head_t wq;
@@ -52,13 +54,13 @@ static spinlock_t ch_list_lock;
 
 static inline bool ch_has_mbo(struct comp_channel *c)
 {
-   return channel_has_mbo(c->iface, c->channel_id, &cdev_comp) > 0;
+   return channel_has_mbo(c->iface, c->channel_id, &comp.cc) > 0;
 }
 
 static inline bool ch_get_mbo(struct comp_channel *c, struct mbo **mbo)
 {
if (!kfifo_peek(&c->fifo, mbo)) {
-   *mbo = most_get_mbo(c->iface, c->channel_id, &cdev_comp);
+   *mbo = most_get_mbo(c->iface, c->channel_id, &comp.cc);
if (*mbo)
kfifo_in(&c->fifo, mbo, 1);
}
@@ -90,14 +92,14 @@ static void stop_channel(struct comp_channel *c)
 
while (kfifo_out((struct kfifo *)&c->fifo, &mbo, 1))
most_put_mbo(mbo);
-   most_stop_channel(c->iface, c->channel_id, &cdev_comp);
+   most_stop_channel(c->iface, c->channel_id, &comp.cc);
 }
 
 static void destroy_cdev(struct comp_channel *c)
 {
unsigned long flags;
 
-   device_destroy(comp_class, c->devno);
+   device_destroy(comp.class, c->devno);
cdev_del(&c->cdev);
spin_lock_irqsave(&ch_list_lock, flags);
list_del(&c->list);
@@ -106,7 +108,7 @@ static void destroy_cdev(struct comp_channel *c)
 
 static void destroy_channel(struct comp_channel *c)
 {
-   ida_simple_remove(&minor_id, MINOR(c->devno));
+   ida_simple_remove(&comp.minor_id, MINOR(c->devno));
kfifo_free(&c->fifo);
kfree(c);
 }
@@ -149,7 +151,7 @@ static int comp_open(struct inode *inode, struct file *filp)
}
 
c->mbo_offs = 0;
-   ret = most_start_channel(c->iface, c->channel_id, &cdev_comp);
+   ret = most_start_channel(c->iface, c->channel_id, &comp.cc);
if (!ret)
c->access_ref = 1;
mutex_unlock(&c->io_mutex);
@@ -440,7 +442,7 @@ static int comp_probe(struct most_interface *iface, int 
channel_id,
if (c)
return -EEXIST;
 
-   current_minor = ida_simple_get(&minor_id, 0, 0, GFP_KERNEL);
+   current_minor = ida_simple_get(&comp.minor_id, 0, 0, GFP_KERNEL);
if (current_minor < 0)
return current_minor;
 
@@ -450,7 +452,7 @@ static int comp_probe(struct most_interface *iface, int 
channel_id,
goto error_alloc_channel;
}
 
-   c->devno = MKDEV(major, current_minor);
+   c->devno = MKDEV(comp.major, current_minor);
cdev_init(&c->cdev, &channel_fops);
c->cdev.owner = THIS_MODULE;
cdev_add(&c->cdev, c->devno, 1);
@@ -470,11 +472,7 @@ static int comp_probe(struct most_interface *iface, int 
channel_id,
spin_lock_irqsave(&ch_list_lock, cl_flags);
list_add_tail(&c->list, &channel_list);
spin_unlock_irqrestore(&ch_list_lock, cl_flags);
-   c->dev = device_create(comp_class,
-NULL,
-c->devno,
-NULL,
-"%s", name);
+   c->dev = device_create(comp.class, NULL, c->devno, NULL, "%s", name);
 
if (IS_ERR(c->dev)) {
retval = PTR_ERR(c->dev);
@@ -491,16 +489,18 @@ static int comp_probe(struct most_interface *iface, int 
channel_id,
cdev_del(&c->cdev);
kfree(c);
 error_alloc_channel:
-   ida_simple_remove(&minor_id, current_minor);
+   ida_simple_remove(&comp.minor_id, current_minor);
return retval;
 }
 
-static struct core_component cdev_comp = {
-   .name = "cdev",
-   .probe_channel = comp_probe,
-   .disconnect_channel = comp_disconnect_channel,
-   .rx_completion = comp_rx_completion,
-   .tx_completion = comp_tx_completion,
+static struct cdev_component comp = {
+   .cc = {
+   .name = "cdev",
+   .probe_channel = comp_probe,
+   .disconnect_channel = comp_disconnect_channel,
+   .rx_completion = comp_rx_completion,
+   .tx_completion = comp_tx_completion,
+   },
 };

[PATCH 44/50] staging: most: update driver usage file

2017-11-21 Thread Christian Gromm
From: Andrey Shvetsov 

This patch keeps the usage file up to date.

Signed-off-by: Christian Gromm 
---
 .../staging/most/Documentation/driver_usage.txt| 192 +++--
 1 file changed, 105 insertions(+), 87 deletions(-)

diff --git a/drivers/staging/most/Documentation/driver_usage.txt 
b/drivers/staging/most/Documentation/driver_usage.txt
index a4dc0c3..bb9b4e8 100644
--- a/drivers/staging/most/Documentation/driver_usage.txt
+++ b/drivers/staging/most/Documentation/driver_usage.txt
@@ -23,20 +23,29 @@ audio/video streaming. Therefore, the driver perfectly fits 
to the mission
 of Automotive Grade Linux to create open source software solutions for
 automotive applications.
 
-The driver consists basically of three layers. The hardware layer, the
-core layer and the application layer. The core layer consists of the core
-module only. This module handles the communication flow through all three
-layers, the configuration of the driver, the configuration interface
-representation in sysfs, and the buffer management.
-For each of the other two layers a selection of modules is provided. These
-modules can arbitrarily be combined to meet the needs of the desired
-system architecture. A module of the hardware layer is referred to as an
-HDM (hardware dependent module). Each module of this layer handles exactly
-one of the peripheral interfaces of a network interface controller (e.g.
-USB, MediaLB, I2C). A module of the application layer is referred to as an
-AIM (application interfacing module). The modules of this layer give access
-to MOST via one the following ways: character devices, ALSA, Networking or
-V4L2.
+The MOST driver uses module stacking to divide the associated modules into
+three layers. From bottom up these layers are: the adapter layer, the core
+layer and the application layer. The core layer implements the MOST
+subsystem and consists basically of the module core.c and its API. It
+registers the MOST bus with the kernel's device model, handles the data
+routing through all three layers, the configuration of the driver, the
+representation of the configuration interface in sysfs and the buffer
+management.
+
+For each of the other two layers a set of modules is provided. Those can be
+arbitrarily combined with the core to meet the connectivity of the desired
+system architecture.
+
+A module of the adapter layer is basically a device driver for a different
+subsystem. It is registered with the core to connect the MOST subsystem to
+the attached network interface controller hardware. Hence, a given module
+of this layer is designed to handle exactly one of the peripheral
+interfaces (e.g. USB, MediaLB, I2C) the hardware provides.
+
+A module of the application layer is referred to as a core comoponent,
+which kind of extends the core by providing connectivity to the user space.
+Applications, then, can access a MOST network via character devices, an
+ALSA soundcard, a Network adapter or a V4L2 capture device.
 
 To physically access MOST, an Intelligent Network Interface Controller
 (INIC) is needed. For more information on available controllers visit:
@@ -44,15 +53,14 @@ www.microchip.com
 
 
 
-   Section 1.1 Hardware Layer
+   Section 1.1 Adapter Layer
 
-The hardware layer contains so called hardware dependent modules (HDM). For 
each
-peripheral interface the hardware supports the driver has a suitable module
-that handles the interface.
-
-The HDMs encapsulate the peripheral interface specific knowledge of the driver
-and provides an easy way of extending the number of supported interfaces.
-Currently the following HDMs are available:
+The adapter layer contains a pool of device drivers. For each peripheral
+interface the hardware supports there is one suitable module that handles
+the interface. Adapter drivers encapsulate the peripheral interface
+specific knowledge of the MOST driver stack and provide an easy way of
+extending the number of supported interfaces. Currently the following
+interfaces are available:
 
1) MediaLB (DIM2)
   Host wants to communicate with hardware via MediaLB.
@@ -63,26 +71,34 @@ Currently the following HDMs are available:
3) USB
   Host wants to communicate with the hardware via USB.
 
+Once an adapter driver recognizes a MOST device being attached, it
+registers it with the core, which, in turn, assigns the necessary members
+of the embedded struct device (e.g. the bus this device belongs to and
+attribute groups) and registers it with the kernel's device model.
 
-   Section 1.2 Core Layer
-
-The core layer contains the mostcore module only, which processes the driver
-configuration via sysfs, buffer management and data forwarding.
 
+   Section 1.2 Core Layer
 
+This layer implements the MOST subsystem. It contains the core module and
+the header file most.h that exposes the API of the core. When inserted in
+the kernel, it registers the MOST bus_type with the k

[PATCH 38/50] staging: most: fix comment sections

2017-11-21 Thread Christian Gromm
This patch updates and corrects the comment sections of the code.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/cdev/cdev.c   |   4 +-
 drivers/staging/most/core.c| 108 -
 drivers/staging/most/core.h|  39 ++
 drivers/staging/most/net/net.c |   4 +-
 drivers/staging/most/sound/sound.c |   2 +-
 drivers/staging/most/video/video.c |   4 +-
 6 files changed, 70 insertions(+), 91 deletions(-)

diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c
index c741231..225369d 100644
--- a/drivers/staging/most/cdev/cdev.c
+++ b/drivers/staging/most/cdev/cdev.c
@@ -1,5 +1,5 @@
 /*
- * cdev.c - Application interfacing module for character devices
+ * cdev.c - Character device component for Mostcore
  *
  * Copyright (C) 2013-2015 Microchip Technology Germany II GmbH & Co. KG
  *
@@ -559,4 +559,4 @@ module_init(mod_init);
 module_exit(mod_exit);
 MODULE_AUTHOR("Christian Gromm ");
 MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("character device AIM for mostcore");
+MODULE_DESCRIPTION("character device component for mostcore");
diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 6d7fe7d..d490bdc 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -109,14 +109,9 @@ static const struct {
_mbo;   \
 })
 
-/*  ___ ___
- *  ___C H A N N E L___
- */
-
 /**
  * most_free_mbo_coherent - free an MBO and its coherent buffer
- * @mbo: buffer to be released
- *
+ * @mbo: most buffer
  */
 static void most_free_mbo_coherent(struct mbo *mbo)
 {
@@ -475,9 +470,6 @@ static const struct attribute_group *channel_attr_groups[] 
= {
NULL,
 };
 
-/*  ___   ___
- *  ___I N S T A N C E___
- */
 static ssize_t description_show(struct device *dev,
struct device_attribute *attr,
char *buf)
@@ -534,9 +526,6 @@ static const struct attribute_group 
*interface_attr_groups[] = {
NULL,
 };
 
-/*  ___ ___
- *  ___A I M___
- */
 static struct core_component *match_module(char *name)
 {
struct core_component *comp;
@@ -594,26 +583,26 @@ static ssize_t modules_show(struct device_driver *drv, 
char *buf)
return offs;
 }
 /**
- * split_string - parses and changes string in the buffer buf and
- * splits it into two mandatory and one optional substrings.
+ * split_string - parses buf and extracts ':' separated substrings.
  *
  * @buf: complete string from attribute 'add_channel'
- * @a: address of pointer to 1st substring (=instance name)
- * @b: address of pointer to 2nd substring (=channel name)
- * @c: optional address of pointer to 3rd substring (=user defined name)
+ * @a: storage for 1st substring (=interface name)
+ * @b: storage for 2nd substring (=channel name)
+ * @c: storage for 3rd substring (=component name)
+ * @d: storage optional 4th substring (=user defined name)
  *
  * Examples:
  *
- * Input: "mdev0:ch6:my_channel\n" or
- *"mdev0:ch6:my_channel"
+ * Input: "mdev0:ch6:cdev:my_channel\n" or
+ *"mdev0:ch6:cdev:my_channel"
  *
- * Output: *a -> "mdev0", *b -> "ch6", *c -> "my_channel"
+ * Output: *a -> "mdev0", *b -> "ch6", *c -> "cdev" *d -> "my_channel"
  *
- * Input: "mdev1:ep81\n"
- * Output: *a -> "mdev1", *b -> "ep81", *c -> ""
+ * Input: "mdev1:ep81:cdev\n"
+ * Output: *a -> "mdev1", *b -> "ep81", *c -> "cdev" *d -> ""
  *
  * Input: "mdev1:ep81"
- * Output: *a -> "mdev1", *b -> "ep81", *c == NULL
+ * Output: *a -> "mdev1", *b -> "ep81", *c -> "cdev" *d == NULL
  */
 static int split_string(char *buf, char **a, char **b, char **c, char **d)
 {
@@ -643,11 +632,9 @@ static int match_bus_dev(struct device *dev, void *data)
 }
 
 /**
- * get_channel - get pointer to channel object
- * @mdev: name of the device instance
- * @mdev_ch: name of the respective channel
- *
- * This retrieves the pointer to a channel object.
+ * get_channel - get pointer to channel
+ * @mdev: name of the device interface
+ * @mdev_ch: name of channel
  */
 static struct most_channel *get_channel(char *mdev, char *mdev_ch)
 {
@@ -693,23 +680,22 @@ inline int link_channel_to_component(struct most_channel 
*c,
 }
 
 /**
- * add_link_store - store() function for add_link attribute
- * @aim_obj: pointer to AIM object
- * @attr: its attributes
+ * 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
- * three substrings. Note: third substring is optional. In case a cdev
- * AIM is loaded the optional 3rd substring will make up the name of
+ * 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

[PATCH 33/50] staging: most: video: remove aim designators

2017-11-21 Thread Christian Gromm
This patch takes the 'aim' prefixes and variable names off the module and
uses component instead. It is needed because userspace interfacing modules
are referred to as components.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/video/video.c | 152 ++---
 1 file changed, 76 insertions(+), 76 deletions(-)

diff --git a/drivers/staging/most/video/video.c 
b/drivers/staging/most/video/video.c
index 34ffdab..b06488b 100644
--- a/drivers/staging/most/video/video.c
+++ b/drivers/staging/most/video/video.c
@@ -1,5 +1,5 @@
 /*
- * V4L2 AIM - V4L2 Application Interface Module for MostCore
+ * V4L2 Component - V4L2 Application Interface Module for MostCore
  *
  * Copyright (C) 2015, Microchip Technology Germany II GmbH & Co. KG
  *
@@ -29,9 +29,9 @@
 
 #include "most/core.h"
 
-#define V4L2_AIM_MAX_INPUT  1
+#define V4L2_CMP_MAX_INPUT  1
 
-static struct core_component aim_info;
+static struct core_component comp;
 
 struct most_video_dev {
struct most_interface *iface;
@@ -52,7 +52,7 @@ struct most_video_dev {
wait_queue_head_t wait_data;
 };
 
-struct aim_fh {
+struct comp_fh {
/* must be the first field of this struct! */
struct v4l2_fh fh;
struct most_video_dev *mdev;
@@ -72,14 +72,14 @@ static inline struct mbo *get_top_mbo(struct most_video_dev 
*mdev)
return list_first_entry(&mdev->pending_mbos, struct mbo, list);
 }
 
-static int aim_vdev_open(struct file *filp)
+static int comp_vdev_open(struct file *filp)
 {
int ret;
struct video_device *vdev = video_devdata(filp);
struct most_video_dev *mdev = video_drvdata(filp);
-   struct aim_fh *fh;
+   struct comp_fh *fh;
 
-   v4l2_info(&mdev->v4l2_dev, "aim_vdev_open()\n");
+   v4l2_info(&mdev->v4l2_dev, "comp_vdev_open()\n");
 
switch (vdev->vfl_type) {
case VFL_TYPE_GRABBER:
@@ -104,7 +104,7 @@ static int aim_vdev_open(struct file *filp)
 
v4l2_fh_add(&fh->fh);
 
-   ret = most_start_channel(mdev->iface, mdev->ch_idx, &aim_info);
+   ret = most_start_channel(mdev->iface, mdev->ch_idx, &comp);
if (ret) {
v4l2_err(&mdev->v4l2_dev, "most_start_channel() failed\n");
goto err_rm;
@@ -122,13 +122,13 @@ static int aim_vdev_open(struct file *filp)
return ret;
 }
 
-static int aim_vdev_close(struct file *filp)
+static int comp_vdev_close(struct file *filp)
 {
-   struct aim_fh *fh = filp->private_data;
+   struct comp_fh *fh = filp->private_data;
struct most_video_dev *mdev = fh->mdev;
struct mbo *mbo, *tmp;
 
-   v4l2_info(&mdev->v4l2_dev, "aim_vdev_close()\n");
+   v4l2_info(&mdev->v4l2_dev, "comp_vdev_close()\n");
 
/*
 * We need to put MBOs back before we call most_stop_channel()
@@ -148,7 +148,7 @@ static int aim_vdev_close(struct file *filp)
spin_lock_irq(&mdev->list_lock);
}
spin_unlock_irq(&mdev->list_lock);
-   most_stop_channel(mdev->iface, mdev->ch_idx, &aim_info);
+   most_stop_channel(mdev->iface, mdev->ch_idx, &comp);
mdev->mute = false;
 
v4l2_fh_del(&fh->fh);
@@ -159,10 +159,10 @@ static int aim_vdev_close(struct file *filp)
return 0;
 }
 
-static ssize_t aim_vdev_read(struct file *filp, char __user *buf,
-size_t count, loff_t *pos)
+static ssize_t comp_vdev_read(struct file *filp, char __user *buf,
+ size_t count, loff_t *pos)
 {
-   struct aim_fh *fh = filp->private_data;
+   struct comp_fh *fh = filp->private_data;
struct most_video_dev *mdev = fh->mdev;
int ret = 0;
 
@@ -209,9 +209,9 @@ static ssize_t aim_vdev_read(struct file *filp, char __user 
*buf,
return ret;
 }
 
-static unsigned int aim_vdev_poll(struct file *filp, poll_table *wait)
+static unsigned int comp_vdev_poll(struct file *filp, poll_table *wait)
 {
-   struct aim_fh *fh = filp->private_data;
+   struct comp_fh *fh = filp->private_data;
struct most_video_dev *mdev = fh->mdev;
unsigned int mask = 0;
 
@@ -224,7 +224,7 @@ static unsigned int aim_vdev_poll(struct file *filp, 
poll_table *wait)
return mask;
 }
 
-static void aim_set_format_struct(struct v4l2_format *f)
+static void comp_set_format_struct(struct v4l2_format *f)
 {
f->fmt.pix.width = 8;
f->fmt.pix.height = 8;
@@ -236,8 +236,8 @@ static void aim_set_format_struct(struct v4l2_format *f)
f->fmt.pix.priv = 0;
 }
 
-static int aim_set_format(struct most_video_dev *mdev, unsigned int cmd,
- struct v4l2_format *format)
+static int comp_set_format(struct most_video_dev *mdev, unsigned int cmd,
+  struct v4l2_format *format)
 {
if (format->fmt.pix.pixelformat != V4L2_PIX_FMT_MPEG)
return -EINVAL;
@@ -245,7 +245,7 @@ static int aim_set_format(struct most_video_dev *mdev, 
unsigned int cmd,
if (cmd =

[PATCH] Staging: comedi: adl_pci9118: fixed some parentheses coding style issue

2017-11-21 Thread Guilherme Tadashi Maeoka
Fixed some code style issues.

Signed-off-by: Guilherme Tadashi Maeoka 
---
 drivers/staging/comedi/drivers/adl_pci9118.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c 
b/drivers/staging/comedi/drivers/adl_pci9118.c
index 1cc9b7ef1ff9..53f13994ac94 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -947,7 +947,7 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct 
comedi_subdevice *s)
if (devpriv->master) {
devpriv->usedma = 1;
if ((cmd->flags & CMDF_WAKE_EOS) &&
-   (cmd->scan_end_arg == 1)) {
+   cmd->scan_end_arg == 1) {
if (cmd->convert_src == TRIG_NOW)
devpriv->ai_add_back = 1;
if (cmd->convert_src == TRIG_TIMER) {
@@ -960,7 +960,7 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct 
comedi_subdevice *s)
}
if ((cmd->flags & CMDF_WAKE_EOS) &&
(cmd->scan_end_arg & 1) &&
-   (cmd->scan_end_arg > 1)) {
+   cmd->scan_end_arg > 1) {
if (cmd->scan_begin_src == TRIG_FOLLOW) {
devpriv->usedma = 0;
/*
@@ -983,7 +983,7 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct 
comedi_subdevice *s)
 */
if (cmd->convert_src == TRIG_NOW && devpriv->softsshdelay) {
devpriv->ai_add_front = 2;
-   if ((devpriv->usedma == 1) && (devpriv->ai_add_back == 1)) {
+   if (devpriv->usedma == 1 && devpriv->ai_add_back == 1) {
/* move it to front */
devpriv->ai_add_front++;
devpriv->ai_add_back = 0;
@@ -1185,7 +1185,7 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev,
(!(cmd->convert_src & (TRIG_TIMER | TRIG_NOW
err |= -EINVAL;
 
-   if ((cmd->scan_begin_src == TRIG_FOLLOW) &&
+   if (cmd->scan_begin_src == TRIG_FOLLOW &&
(!(cmd->convert_src & (TRIG_TIMER | TRIG_EXT
err |= -EINVAL;
 
@@ -1210,8 +1210,8 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev,
if (cmd->scan_begin_src & (TRIG_FOLLOW | TRIG_EXT))
err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
 
-   if ((cmd->scan_begin_src == TRIG_TIMER) &&
-   (cmd->convert_src == TRIG_TIMER) && (cmd->scan_end_arg == 1)) {
+   if (cmd->scan_begin_src == TRIG_TIMER &&
+   cmd->convert_src == TRIG_TIMER && cmd->scan_end_arg == 1) {
cmd->scan_begin_src = TRIG_FOLLOW;
cmd->convert_arg = cmd->scan_begin_arg;
cmd->scan_begin_arg = 0;
-- 
2.15.0

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


[PATCH] tools/hv: Fix IP reporting by KVP daemon with SRIOV

2017-11-21 Thread Haiyang Zhang
From: Haiyang Zhang 

On Hyper-V the VF NIC has the same MAC as the related synthetic NIC.
VF NIC can work under the synthetic NIC transparently, without its
own IP address. The existing KVP daemon only gets IP from the first
NIC matching a MAC address, and may not be able to find the IP in
this case.

This patch fixes the problem by searching the NIC matching the MAC,
and having an IP address. So, the IP address will be found and
reported to the host successfully.

Signed-off-by: Haiyang Zhang 
---
 tools/hv/hv_kvp_daemon.c | 138 ++-
 1 file changed, 65 insertions(+), 73 deletions(-)

diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index eaa3bec273c8..16964a7811a9 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -676,64 +676,6 @@ static char *kvp_if_name_to_mac(char *if_name)
return mac_addr;
 }
 
-
-/*
- * Retrieve the interface name given tha MAC address.
- */
-
-static char *kvp_mac_to_if_name(char *mac)
-{
-   DIR *dir;
-   struct dirent *entry;
-   FILE*file;
-   char*p, *x;
-   char*if_name = NULL;
-   charbuf[256];
-   char dev_id[PATH_MAX];
-   unsigned int i;
-
-   dir = opendir(KVP_NET_DIR);
-   if (dir == NULL)
-   return NULL;
-
-   while ((entry = readdir(dir)) != NULL) {
-   /*
-* Set the state for the next pass.
-*/
-   snprintf(dev_id, sizeof(dev_id), "%s%s/address", KVP_NET_DIR,
-entry->d_name);
-
-   file = fopen(dev_id, "r");
-   if (file == NULL)
-   continue;
-
-   p = fgets(buf, sizeof(buf), file);
-   if (p) {
-   x = strchr(p, '\n');
-   if (x)
-   *x = '\0';
-
-   for (i = 0; i < strlen(p); i++)
-   p[i] = toupper(p[i]);
-
-   if (!strcmp(p, mac)) {
-   /*
-* Found the MAC match; return the interface
-* name. The caller will free the memory.
-*/
-   if_name = strdup(entry->d_name);
-   fclose(file);
-   break;
-   }
-   }
-   fclose(file);
-   }
-
-   closedir(dir);
-   return if_name;
-}
-
-
 static void kvp_process_ipconfig_file(char *cmd,
char *config_buf, unsigned int len,
int element_size, int offset)
@@ -1039,6 +981,70 @@ kvp_get_ip_info(int family, char *if_name, int op,
return error;
 }
 
+/*
+ * Retrieve the IP given the MAC address.
+ */
+static int kvp_mac_to_ip(struct hv_kvp_ipaddr_value *kvp_ip_val)
+{
+   char *mac = (char *)kvp_ip_val->adapter_id;
+   DIR *dir;
+   struct dirent *entry;
+   FILE*file;
+   char*p, *x;
+   char*if_name = NULL;
+   charbuf[256];
+   char dev_id[PATH_MAX];
+   unsigned int i;
+   int error = HV_E_FAIL;
+
+   dir = opendir(KVP_NET_DIR);
+   if (dir == NULL)
+   return HV_E_FAIL;
+
+   while ((entry = readdir(dir)) != NULL) {
+   /*
+* Set the state for the next pass.
+*/
+   snprintf(dev_id, sizeof(dev_id), "%s%s/address", KVP_NET_DIR,
+entry->d_name);
+
+   file = fopen(dev_id, "r");
+   if (file == NULL)
+   continue;
+
+   p = fgets(buf, sizeof(buf), file);
+   fclose(file);
+   if (!p)
+   continue;
+
+   x = strchr(p, '\n');
+   if (x)
+   *x = '\0';
+
+   for (i = 0; i < strlen(p); i++)
+   p[i] = toupper(p[i]);
+
+   if (strcmp(p, mac))
+   continue;
+
+   /*
+* Found the MAC match.
+* A NIC (e.g. VF) matching the MAC, but without IP, is skipped.
+*/
+   if_name = entry->d_name;
+   if (!if_name)
+   continue;
+
+   error = kvp_get_ip_info(0, if_name, KVP_OP_GET_IP_INFO,
+   kvp_ip_val, MAX_IP_ADDR_SIZE * 2);
+
+   if (!error && strlen((char *)kvp_ip_val->ip_addr))
+   break;
+   }
+
+   closedir(dir);
+   return error;
+}
 
 static int expand_ipv6(char *addr, int type)
 {
@@ -1514,26 +1520,12 @@ int main(int argc, char *argv[])
switch (op) {
case KVP_OP_GET_IP_INFO:
kvp_ip_val = &hv_msg->body.kvp_ip_val;
-   if_name =

[PATCH v2 1/2] olpc_dcon: Change bitshifts to BIT macro

2017-11-21 Thread zebmccorkle
From: Zebulon McCorkle 

checkpatch.pl reported the bitshifts (1<
---
 drivers/staging/olpc_dcon/olpc_dcon.h | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/olpc_dcon/olpc_dcon.h 
b/drivers/staging/olpc_dcon/olpc_dcon.h
index 8fbde5d3b4a6..fa89bb97c7b0 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.h
+++ b/drivers/staging/olpc_dcon/olpc_dcon.h
@@ -10,18 +10,18 @@
 #define DCON_REG_ID 0
 #define DCON_REG_MODE   1
 
-#define MODE_PASSTHRU  (1<<0)
-#define MODE_SLEEP (1<<1)
-#define MODE_SLEEP_AUTO(1<<2)
-#define MODE_BL_ENABLE (1<<3)
-#define MODE_BLANK (1<<4)
-#define MODE_CSWIZZLE  (1<<5)
-#define MODE_COL_AA(1<<6)
-#define MODE_MONO_LUMA (1<<7)
-#define MODE_SCAN_INT  (1<<8)
-#define MODE_CLOCKDIV  (1<<9)
-#define MODE_DEBUG (1<<14)
-#define MODE_SELFTEST  (1<<15)
+#define MODE_PASSTHRU  BIT(0)
+#define MODE_SLEEP BIT(1)
+#define MODE_SLEEP_AUTOBIT(2)
+#define MODE_BL_ENABLE BIT(3)
+#define MODE_BLANK BIT(4)
+#define MODE_CSWIZZLE  BIT(5)
+#define MODE_COL_AABIT(6)
+#define MODE_MONO_LUMA BIT(7)
+#define MODE_SCAN_INT  BIT(8)
+#define MODE_CLOCKDIV  BIT(9)
+#define MODE_DEBUG BIT(14)
+#define MODE_SELFTEST  BIT(15)
 
 #define DCON_REG_HRES  0x2
 #define DCON_REG_HTOTAL0x3
@@ -36,11 +36,11 @@
 #define DCON_REG_MEM_OPT_B 0x42
 
 /* Load Delay Locked Loop (DLL) settings for clock delay */
-#define MEM_DLL_CLOCK_DELAY(1<<0)
+#define MEM_DLL_CLOCK_DELAYBIT(0)
 /* Memory controller power down function */
-#define MEM_POWER_DOWN (1<<8)
+#define MEM_POWER_DOWN BIT(8)
 /* Memory controller software reset */
-#define MEM_SOFT_RESET (1<<0)
+#define MEM_SOFT_RESET BIT(0)
 
 /* Status values */
 
-- 
2.11.0

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


[PATCH v2 0/2] olpc_dcon: Fix style issues

2017-11-21 Thread zebmccorkle
From: Zebulon McCorkle 

checkpatch.pl was complaining about style issues in the olpc_dcon driver.

I've split this into two patches at the request of Greg Kroah-Hartman's
patch-bot.

Zebulon McCorkle (2):
  olpc_dcon: Change bitshifts to BIT macro
  olpc_dcon: Line up parentheses in func calls and defs

 drivers/staging/olpc_dcon/olpc_dcon.c  | 30 --
 drivers/staging/olpc_dcon/olpc_dcon.h  | 30 +++---
 drivers/staging/olpc_dcon/olpc_dcon_xo_1.c |  2 +-
 3 files changed, 36 insertions(+), 26 deletions(-)

-- 
2.11.0

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


[PATCH v2 2/2] olpc_dcon: Line up parentheses in func calls and defs

2017-11-21 Thread zebmccorkle
From: Zebulon McCorkle 

Line up arguments to opening parentheses and ensure lines stay under 80
columns, since checkpatch.pl was complaining about incorrect indentation
in function calls and definitions.

Signed-off-by: Zebulon McCorkle 
---
 drivers/staging/olpc_dcon/olpc_dcon.c  | 30 --
 drivers/staging/olpc_dcon/olpc_dcon_xo_1.c |  2 +-
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c 
b/drivers/staging/olpc_dcon/olpc_dcon.c
index 82bffd911435..2744c9f0920e 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -393,7 +393,8 @@ static void dcon_set_source_sync(struct dcon_priv *dcon, 
int arg)
 }
 
 static ssize_t dcon_mode_show(struct device *dev,
-   struct device_attribute *attr, char *buf)
+ struct device_attribute *attr,
+ char *buf)
 {
struct dcon_priv *dcon = dev_get_drvdata(dev);
 
@@ -401,7 +402,8 @@ static ssize_t dcon_mode_show(struct device *dev,
 }
 
 static ssize_t dcon_sleep_show(struct device *dev,
-   struct device_attribute *attr, char *buf)
+  struct device_attribute *attr,
+  char *buf)
 {
struct dcon_priv *dcon = dev_get_drvdata(dev);
 
@@ -409,7 +411,8 @@ static ssize_t dcon_sleep_show(struct device *dev,
 }
 
 static ssize_t dcon_freeze_show(struct device *dev,
-   struct device_attribute *attr, char *buf)
+   struct device_attribute *attr,
+   char *buf)
 {
struct dcon_priv *dcon = dev_get_drvdata(dev);
 
@@ -417,7 +420,8 @@ static ssize_t dcon_freeze_show(struct device *dev,
 }
 
 static ssize_t dcon_mono_show(struct device *dev,
-   struct device_attribute *attr, char *buf)
+ struct device_attribute *attr,
+ char *buf)
 {
struct dcon_priv *dcon = dev_get_drvdata(dev);
 
@@ -425,13 +429,15 @@ static ssize_t dcon_mono_show(struct device *dev,
 }
 
 static ssize_t dcon_resumeline_show(struct device *dev,
-   struct device_attribute *attr, char *buf)
+   struct device_attribute *attr,
+   char *buf)
 {
return sprintf(buf, "%d\n", resumeline);
 }
 
 static ssize_t dcon_mono_store(struct device *dev,
-   struct device_attribute *attr, const char *buf, size_t count)
+  struct device_attribute *attr,
+  const char *buf, size_t count)
 {
unsigned long enable_mono;
int rc;
@@ -446,7 +452,8 @@ static ssize_t dcon_mono_store(struct device *dev,
 }
 
 static ssize_t dcon_freeze_store(struct device *dev,
-   struct device_attribute *attr, const char *buf, size_t count)
+struct device_attribute *attr,
+const char *buf, size_t count)
 {
struct dcon_priv *dcon = dev_get_drvdata(dev);
unsigned long output;
@@ -474,7 +481,8 @@ static ssize_t dcon_freeze_store(struct device *dev,
 }
 
 static ssize_t dcon_resumeline_store(struct device *dev,
-   struct device_attribute *attr, const char *buf, size_t count)
+struct device_attribute *attr,
+const char *buf, size_t count)
 {
unsigned short rl;
int rc;
@@ -490,7 +498,8 @@ static ssize_t dcon_resumeline_store(struct device *dev,
 }
 
 static ssize_t dcon_sleep_store(struct device *dev,
-   struct device_attribute *attr, const char *buf, size_t count)
+   struct device_attribute *attr,
+   const char *buf, size_t count)
 {
unsigned long output;
int ret;
@@ -641,7 +650,8 @@ static int dcon_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
/* Add the backlight device for the DCON */
dcon_bl_props.brightness = dcon->bl_val;
dcon->bl_dev = backlight_device_register("dcon-bl", &dcon_device->dev,
-   dcon, &dcon_bl_ops, &dcon_bl_props);
+dcon, &dcon_bl_ops,
+&dcon_bl_props);
if (IS_ERR(dcon->bl_dev)) {
dev_err(&client->dev, "cannot register backlight dev (%ld)\n",
PTR_ERR(dcon->bl_dev));
diff --git a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c 
b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c
index 0c5a10c69401..633c58ce24ee 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c
@@ -69,7 +69,7 @@ static int dcon_init_xo_1(struct dcon_priv *dcon)
gpio_direction_input(OLPC_GPIO_DCON_IRQ);
gpio_direction_input(OLPC_GPIO_DCON_BLANK);
gpio_direction_output(OLPC_GPIO_DCON_LOAD,
-   dcon->curr_s

Re: [PATCH v2] staging: fsl-mc: fix mc-portal to use u32 type

2017-11-21 Thread Tobin C. Harding
On Tue, Nov 21, 2017 at 10:35:23AM +0530, Bharat Bhushan wrote:
> According to MC APIs, size of mc-portal in 32bit.
> Also fsl_create_mc_io() storing 32 bit mc-portal size.
>" mc_io->portal_size = mc_portal_size;"
>While "mc_io->portal_size" is u16 type and
>"mc_portal_size" is u32 type.
> 
> This patches changes mc_io->portal_size from u16 to u32

You may like to read Documentation/process/submitting-patches.rst for
tips or writing the git commit log.

> Signed-off-by: Bharat Bhushan 
> ---

Include here what changed from v1 -> v2

>  drivers/staging/fsl-mc/include/mc-sys.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/fsl-mc/include/mc-sys.h 
> b/drivers/staging/fsl-mc/include/mc-sys.h
> index dca7f90..11d4367 100644
> --- a/drivers/staging/fsl-mc/include/mc-sys.h
> +++ b/drivers/staging/fsl-mc/include/mc-sys.h
> @@ -75,7 +75,7 @@
>  struct fsl_mc_io {
>   struct device *dev;
>   u16 flags;
> - u16 portal_size;
> + u32 portal_size;
>   phys_addr_t portal_phys_addr;
>   void __iomem *portal_virt_addr;
>   struct fsl_mc_device *dpmcp_dev;

I was not able to apply this patch to either Greg's staging tree or
Linus' mainline.

Does this change clear any Sparse warnings? If so you may like to note
that in the commit log.

Hope this helps,
Tobin.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: comedi: adl_pci9118: fixed some parentheses coding style issue

2017-11-21 Thread Tobin C. Harding
You may like to limit the git log brief description to 50 characters
(this is going to be hard with such a long pre-fix though :)

Brief description should be in imperative mood i.e 'Fix foo' instead of
'fixed foo'.

On Tue, Nov 21, 2017 at 05:17:53PM -0200, Guilherme Tadashi Maeoka wrote:
> Fixed some code style issues.

This is not descriptive enough. You may like to read

Documentation/process/submitting-patches.rst

for tips on writing git log messages. 

> Signed-off-by: Guilherme Tadashi Maeoka 
> ---
>  drivers/staging/comedi/drivers/adl_pci9118.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c 
> b/drivers/staging/comedi/drivers/adl_pci9118.c
> index 1cc9b7ef1ff9..53f13994ac94 100644
> --- a/drivers/staging/comedi/drivers/adl_pci9118.c
> +++ b/drivers/staging/comedi/drivers/adl_pci9118.c
> @@ -947,7 +947,7 @@ static int pci9118_ai_cmd(struct comedi_device *dev, 
> struct comedi_subdevice *s)
>   if (devpriv->master) {
>   devpriv->usedma = 1;
>   if ((cmd->flags & CMDF_WAKE_EOS) &&
> - (cmd->scan_end_arg == 1)) {
> + cmd->scan_end_arg == 1) {

The code was easier to read before this change IMO.

>   if (cmd->convert_src == TRIG_NOW)
>   devpriv->ai_add_back = 1;
>   if (cmd->convert_src == TRIG_TIMER) {
> @@ -960,7 +960,7 @@ static int pci9118_ai_cmd(struct comedi_device *dev, 
> struct comedi_subdevice *s)
>   }
>   if ((cmd->flags & CMDF_WAKE_EOS) &&
>   (cmd->scan_end_arg & 1) &&
> - (cmd->scan_end_arg > 1)) {
> + cmd->scan_end_arg > 1) {
>   if (cmd->scan_begin_src == TRIG_FOLLOW) {
>   devpriv->usedma = 0;
>   /*
> @@ -983,7 +983,7 @@ static int pci9118_ai_cmd(struct comedi_device *dev, 
> struct comedi_subdevice *s)
>*/
>   if (cmd->convert_src == TRIG_NOW && devpriv->softsshdelay) {
>   devpriv->ai_add_front = 2;
> - if ((devpriv->usedma == 1) && (devpriv->ai_add_back == 1)) {
> + if (devpriv->usedma == 1 && devpriv->ai_add_back == 1) {

Likewise, this is not making the code easier to read.

>   /* move it to front */
>   devpriv->ai_add_front++;
>   devpriv->ai_add_back = 0;
> @@ -1185,7 +1185,7 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev,
>   (!(cmd->convert_src & (TRIG_TIMER | TRIG_NOW
>   err |= -EINVAL;
>  
> - if ((cmd->scan_begin_src == TRIG_FOLLOW) &&
> + if (cmd->scan_begin_src == TRIG_FOLLOW &&
>   (!(cmd->convert_src & (TRIG_TIMER | TRIG_EXT
>   err |= -EINVAL;
>  
> @@ -1210,8 +1210,8 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev,
>   if (cmd->scan_begin_src & (TRIG_FOLLOW | TRIG_EXT))
>   err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
>  
> - if ((cmd->scan_begin_src == TRIG_TIMER) &&
> - (cmd->convert_src == TRIG_TIMER) && (cmd->scan_end_arg == 1)) {
> + if (cmd->scan_begin_src == TRIG_TIMER &&
> + cmd->convert_src == TRIG_TIMER && cmd->scan_end_arg == 1) {
>   cmd->scan_begin_src = TRIG_FOLLOW;
>   cmd->convert_arg = cmd->scan_begin_arg;
>   cmd->scan_begin_arg = 0;

Remember, we are writing code for developers to read. It should be as
easy to parse as possible.

Hope this helps,
Tobin.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Fix style issues in olpc_dcon

2017-11-21 Thread Tobin C. Harding
Missing subsystem in subject line. Please use the same git brief
description format that has been used previously for files you want to
patch. You can view previous commits for a file using

git log --pretty=oneline --abbrev --reverse

On Mon, Nov 20, 2017 at 03:14:21PM -0600, zebmccor...@disr.it wrote:
> From: Zebulon McCorkle 
> 
> The olpc_dcon driver had some slight style issues, mostly pertaining to
> indentation in function calls and definitions. I've solved those, and
> plan to work on the issues in the TODO.

Please read Documentation/process/submitting-patches.rst for tips on how to
write git commit log messages. Especially section '2) Describe your changes'.

> Signed-off-by: Zebulon McCorkle 
> ---
>  drivers/staging/olpc_dcon/olpc_dcon.c  | 30 
> --
>  drivers/staging/olpc_dcon/olpc_dcon.h  | 30 
> +++---
>  drivers/staging/olpc_dcon/olpc_dcon_xo_1.c |  2 +-
>  3 files changed, 36 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c 
> b/drivers/staging/olpc_dcon/olpc_dcon.c
> index 82bffd911435..2744c9f0920e 100644
> --- a/drivers/staging/olpc_dcon/olpc_dcon.c
> +++ b/drivers/staging/olpc_dcon/olpc_dcon.c
> @@ -393,7 +393,8 @@ static void dcon_set_source_sync(struct dcon_priv *dcon, 
> int arg)
>  }
>  
>  static ssize_t dcon_mode_show(struct device *dev,
> - struct device_attribute *attr, char *buf)
> +   struct device_attribute *attr,
> +   char *buf)
>  {
>   struct dcon_priv *dcon = dev_get_drvdata(dev);
>  
> @@ -401,7 +402,8 @@ static ssize_t dcon_mode_show(struct device *dev,
>  }
>  
>  static ssize_t dcon_sleep_show(struct device *dev,
> - struct device_attribute *attr, char *buf)
> +struct device_attribute *attr,
> +char *buf)
>  {
>   struct dcon_priv *dcon = dev_get_drvdata(dev);
>  
> @@ -409,7 +411,8 @@ static ssize_t dcon_sleep_show(struct device *dev,
>  }
>  
>  static ssize_t dcon_freeze_show(struct device *dev,
> - struct device_attribute *attr, char *buf)
> + struct device_attribute *attr,
> + char *buf)
>  {
>   struct dcon_priv *dcon = dev_get_drvdata(dev);
>  
> @@ -417,7 +420,8 @@ static ssize_t dcon_freeze_show(struct device *dev,
>  }
>  
>  static ssize_t dcon_mono_show(struct device *dev,
> - struct device_attribute *attr, char *buf)
> +   struct device_attribute *attr,
> +   char *buf)
>  {
>   struct dcon_priv *dcon = dev_get_drvdata(dev);
>  
> @@ -425,13 +429,15 @@ static ssize_t dcon_mono_show(struct device *dev,
>  }
>  
>  static ssize_t dcon_resumeline_show(struct device *dev,
> - struct device_attribute *attr, char *buf)
> + struct device_attribute *attr,
> + char *buf)
>  {
>   return sprintf(buf, "%d\n", resumeline);
>  }
>  
>  static ssize_t dcon_mono_store(struct device *dev,
> - struct device_attribute *attr, const char *buf, size_t count)
> +struct device_attribute *attr,
> +const char *buf, size_t count)
>  {
>   unsigned long enable_mono;
>   int rc;
> @@ -446,7 +452,8 @@ static ssize_t dcon_mono_store(struct device *dev,
>  }
>  
>  static ssize_t dcon_freeze_store(struct device *dev,
> - struct device_attribute *attr, const char *buf, size_t count)
> +  struct device_attribute *attr,
> +  const char *buf, size_t count)
>  {
>   struct dcon_priv *dcon = dev_get_drvdata(dev);
>   unsigned long output;
> @@ -474,7 +481,8 @@ static ssize_t dcon_freeze_store(struct device *dev,
>  }
>  
>  static ssize_t dcon_resumeline_store(struct device *dev,
> - struct device_attribute *attr, const char *buf, size_t count)
> +  struct device_attribute *attr,
> +  const char *buf, size_t count)
>  {
>   unsigned short rl;
>   int rc;
> @@ -490,7 +498,8 @@ static ssize_t dcon_resumeline_store(struct device *dev,
>  }
>  
>  static ssize_t dcon_sleep_store(struct device *dev,
> - struct device_attribute *attr, const char *buf, size_t count)
> + struct device_attribute *attr,
> + const char *buf, size_t count)
>  {
>   unsigned long output;
>   int ret;
> @@ -641,7 +650,8 @@ static int dcon_probe(struct i2c_client *client, const 
> struct i2c_device_id *id)
>   /* Add the backlight device for the DCON */
>   dcon_bl_props.brightness = dcon->bl_val;
>   dcon->bl_dev = backlight_device_register("dcon-bl", &dcon_device->dev,
> - dcon, &dcon_bl_ops, &dcon_bl_props);
> +  dcon, &dcon_bl_ops,
> +   

[PATCH 24/30] staging: rts5208: deprecate pci_get_bus_and_slot()

2017-11-21 Thread Sinan Kaya
pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as
where a PCI device is present. This restricts the device drivers to be
reused for other domain numbers.

Use pci_get_domain_bus_and_slot() with a domain number of 0 where we can't
extract the domain number. Other places, use the actual domain number from
the device.

Signed-off-by: Sinan Kaya 
---
 drivers/staging/rts5208/rtsx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c
index 89e2cfe..13b14fe 100644
--- a/drivers/staging/rts5208/rtsx.c
+++ b/drivers/staging/rts5208/rtsx.c
@@ -281,7 +281,7 @@ int rtsx_read_pci_cfg_byte(u8 bus, u8 dev, u8 func, u8 
offset, u8 *val)
u8 data;
u8 devfn = (dev << 3) | func;
 
-   pdev = pci_get_bus_and_slot(bus, devfn);
+   pdev = pci_get_domain_bus_and_slot(0, bus, devfn);
if (!pdev)
return -1;
 
-- 
1.9.1

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


[PATCH 23/30] [media] atomisp: deprecate pci_get_bus_and_slot()

2017-11-21 Thread Sinan Kaya
pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as
where a PCI device is present. This restricts the device drivers to be
reused for other domain numbers.

Use pci_get_domain_bus_and_slot() with a domain number of 0 where we can't
extract the domain number. Other places, use the actual domain number from
the device.

Signed-off-by: Sinan Kaya 
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c   | 2 +-
 drivers/staging/media/atomisp/platform/intel-mid/intel_mid_pcihelpers.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c
index 663aa91..95b9c7a 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c
@@ -1233,7 +1233,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
isp->pdev = dev;
isp->dev = &dev->dev;
isp->sw_contex.power_state = ATOM_ISP_POWER_UP;
-   isp->pci_root = pci_get_bus_and_slot(0, 0);
+   isp->pci_root = pci_get_domain_bus_and_slot(0, 0, 0);
if (!isp->pci_root) {
dev_err(&dev->dev, "Unable to find PCI host\n");
return -ENODEV;
diff --git 
a/drivers/staging/media/atomisp/platform/intel-mid/intel_mid_pcihelpers.c 
b/drivers/staging/media/atomisp/platform/intel-mid/intel_mid_pcihelpers.c
index 4631b1d..51dcef57 100644
--- a/drivers/staging/media/atomisp/platform/intel-mid/intel_mid_pcihelpers.c
+++ b/drivers/staging/media/atomisp/platform/intel-mid/intel_mid_pcihelpers.c
@@ -39,7 +39,7 @@ static inline int platform_is(u8 model)
 
 static int intel_mid_msgbus_init(void)
 {
-   pci_root = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0));
+   pci_root = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(0, 0));
if (!pci_root) {
pr_err("%s: Error: msgbus PCI handle NULL\n", __func__);
return -ENODEV;
-- 
1.9.1

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


Re: [PATCH v2] staging: comedi: add missing MODULE_DESCRIPTION/LICENSE

2017-11-21 Thread Matthew Giassa

* Ian Abbott  [2017-11-20 10:46:36 +]:


On 20/11/17 10:29, Ian Abbott wrote:

On 20/11/17 07:50, Jesse Chan wrote:

This change resolves a new compile-time warning
when built as a loadable module:

WARNING: modpost: missing MODULE_LICENSE() in 
drivers/staging/comedi/drivers/ni_atmio.o

see include/linux/module.h for more information

This adds the license as "GPL", which matches the header of the file.

MODULE_DESCRIPTION is also added.

Signed-off-by: Jesse Chan 
---
  drivers/staging/comedi/drivers/ni_atmio.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/drivers/staging/comedi/drivers/ni_atmio.c 
b/drivers/staging/comedi/drivers/ni_atmio.c

index 2d62a8c57332..b61d56367773 100644
--- a/drivers/staging/comedi/drivers/ni_atmio.c
+++ b/drivers/staging/comedi/drivers/ni_atmio.c
@@ -361,3 +361,6 @@ static struct comedi_driver ni_atmio_driver = {
  .detach    = ni_atmio_detach,
  };
  module_comedi_driver(ni_atmio_driver);
+
+MODULE_DESCRIPTION("Comedi low-level driver");
+MODULE_LICENSE("GPL");


Thanks!  I wonder how I managed to miss out this driver in commit 
3c323c01b6bd ("Staging: comedi: Add MODULE_LICENSE and similar to NI 
modules")?


Reviewed-by: Ian Abbott 


Despite my above comment, we should probably give precedence to 
Matthew Giassa's patch for the same issue, since it was sent earlier.


--
-=( Ian Abbott @ MEV Ltd.E-mail:  )=-
-=(  Web: http://www.mev.co.uk/  )=-


--

Thanks. Also, this one should probably include the MODULE_AUTHOR macro
as well.

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