[PATCH v2 6/9] media: staging/imx: remove static subdev arrays

2017-12-14 Thread Steve Longerbeam
For more complex OF graphs, there will be more async subdevices
registered. Remove the static subdev[IMX_MEDIA_MAX_SUBDEVS] array,
so that imx-media places no limits on the number of async subdevs
that can be added and registered.

There were two uses for 'struct imx_media_subdev'. First was to act
as the async subdev list to be passed to v4l2_async_notifier_register().

Second was to aid in inheriting subdev controls to the capture devices,
and this is done by creating a list of capture devices that can be reached
from a subdev's source pad. So 'struct imx_media_subdev' also contained
a static array of 'struct imx_media_pad' for placing the capture device
lists at each pad.

'struct imx_media_subdev' has been completely removed. Instead, at async
completion, allocate an array of 'struct imx_media_pad' and attach it to
the subdev's host_priv pointer, in order to support subdev controls
inheritance.

Likewise, remove static async_ptrs[IMX_MEDIA_MAX_SUBDEVS] array.
Instead, allocate a 'struct imx_media_async_subdev' when forming
the async list, and add it to an asd_list list_head in
imx_media_add_async_subdev(). At async completion, allocate the
asd pointer list and pull the asd's off asd_list for
v4l2_async_notifier_register().

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-ic-prp.c|   4 +-
 drivers/staging/media/imx/imx-media-csi.c |   9 +-
 drivers/staging/media/imx/imx-media-dev.c | 215 --
 drivers/staging/media/imx/imx-media-internal-sd.c |  51 +++--
 drivers/staging/media/imx/imx-media-of.c  |  31 ++--
 drivers/staging/media/imx/imx-media-utils.c   |  43 ++---
 drivers/staging/media/imx/imx-media.h |  81 
 7 files changed, 216 insertions(+), 218 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prp.c 
b/drivers/staging/media/imx/imx-ic-prp.c
index 9e41987..c6d7e80 100644
--- a/drivers/staging/media/imx/imx-ic-prp.c
+++ b/drivers/staging/media/imx/imx-ic-prp.c
@@ -300,7 +300,7 @@ static int prp_link_validate(struct v4l2_subdev *sd,
 {
struct imx_ic_priv *ic_priv = v4l2_get_subdevdata(sd);
struct prp_priv *priv = ic_priv->prp_priv;
-   struct imx_media_subdev *csi;
+   struct v4l2_subdev *csi;
int ret;
 
ret = v4l2_subdev_link_validate_default(sd, link,
@@ -333,7 +333,7 @@ static int prp_link_validate(struct v4l2_subdev *sd,
}
 
if (csi) {
-   switch (csi->sd->grp_id) {
+   switch (csi->grp_id) {
case IMX_MEDIA_GRP_ID_CSI0:
priv->csi_id = 0;
break;
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index d7a4b7c..eb7be50 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -138,7 +138,6 @@ static int csi_get_upstream_endpoint(struct csi_priv *priv,
 struct v4l2_fwnode_endpoint *ep)
 {
struct device_node *endpoint, *port;
-   struct imx_media_subdev *imxsd;
struct media_entity *src;
struct v4l2_subdev *sd;
struct media_pad *pad;
@@ -154,10 +153,10 @@ static int csi_get_upstream_endpoint(struct csi_priv 
*priv,
 * CSI-2 receiver if it is in the path, otherwise stay
 * with video mux.
 */
-   imxsd = imx_media_find_upstream_subdev(priv->md, src,
-  IMX_MEDIA_GRP_ID_CSI2);
-   if (!IS_ERR(imxsd))
-   src = >sd->entity;
+   sd = imx_media_find_upstream_subdev(priv->md, src,
+   IMX_MEDIA_GRP_ID_CSI2);
+   if (!IS_ERR(sd))
+   src = >entity;
}
 
/* get source pad of entity directly upstream from src */
diff --git a/drivers/staging/media/imx/imx-media-dev.c 
b/drivers/staging/media/imx/imx-media-dev.c
index 0369c35..71586ae 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -33,28 +33,28 @@ static inline struct imx_media_dev *notifier2dev(struct 
v4l2_async_notifier *n)
 }
 
 /*
- * Find a subdev by fwnode or device name. This is called during
+ * Find an asd by fwnode or device name. This is called during
  * driver load to form the async subdev list and bind them.
  */
-struct imx_media_subdev *
-imx_media_find_async_subdev(struct imx_media_dev *imxmd,
-   struct fwnode_handle *fwnode,
-   const char *devname)
+static struct v4l2_async_subdev *
+find_async_subdev(struct imx_media_dev *imxmd,
+ struct fwnode_handle *fwnode,
+ const char *devname)
 {
-   struct imx_media_subdev *imxsd;
-   int i;
+   struct imx_media_async_subdev *imxasd;
+   struct 

[PATCH v2 7/9] media: staging/imx: convert static vdev lists to list_head

2017-12-14 Thread Steve Longerbeam
Although not technically necessary because imx-media has only a
maximum of 8 video devices, and once setup the video device lists
are static, in anticipation of moving control ineritance to
v4l2-core, make the vdev lists more generic by converting to
dynamic list_head's.

After doing that, 'struct imx_media_pad' is now just a list_head
of video devices reachable from a pad. Allocate an array of list_head's,
one list_head for each pad, and attach that array to sd->host_priv.
An entry in the pad lists is of type 'struct imx_media_pad_vdev', and
points to a video device from the master list.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-capture.c |  2 +
 drivers/staging/media/imx/imx-media-dev.c | 77 +++
 drivers/staging/media/imx/imx-media-utils.c   | 16 +-
 drivers/staging/media/imx/imx-media.h | 39 +++---
 4 files changed, 68 insertions(+), 66 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-capture.c 
b/drivers/staging/media/imx/imx-media-capture.c
index 7b67638..576bdc7 100644
--- a/drivers/staging/media/imx/imx-media-capture.c
+++ b/drivers/staging/media/imx/imx-media-capture.c
@@ -748,6 +748,8 @@ imx_media_capture_device_init(struct v4l2_subdev *src_sd, 
int pad)
vfd->queue = >q;
priv->vdev.vfd = vfd;
 
+   INIT_LIST_HEAD(>vdev.list);
+
video_set_drvdata(vfd, priv);
 
v4l2_ctrl_handler_init(>ctrl_hdlr, 0);
diff --git a/drivers/staging/media/imx/imx-media-dev.c 
b/drivers/staging/media/imx/imx-media-dev.c
index 71586ae..2800700 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -229,10 +229,11 @@ static int imx_media_add_vdev_to_pad(struct imx_media_dev 
*imxmd,
 struct media_pad *srcpad)
 {
struct media_entity *entity = srcpad->entity;
-   struct imx_media_pad *imxpad;
+   struct imx_media_pad_vdev *pad_vdev;
+   struct list_head *pad_vdev_list;
struct media_link *link;
struct v4l2_subdev *sd;
-   int i, vdev_idx, ret;
+   int i, ret;
 
/* skip this entity if not a v4l2_subdev */
if (!is_media_entity_v4l2_subdev(entity))
@@ -240,8 +241,8 @@ static int imx_media_add_vdev_to_pad(struct imx_media_dev 
*imxmd,
 
sd = media_entity_to_v4l2_subdev(entity);
 
-   imxpad = to_imx_media_pad(sd, srcpad->index);
-   if (!imxpad) {
+   pad_vdev_list = to_pad_vdev_list(sd, srcpad->index);
+   if (!pad_vdev_list) {
v4l2_warn(>v4l2_dev, "%s:%u has no vdev list!\n",
  entity->name, srcpad->index);
/*
@@ -251,23 +252,22 @@ static int imx_media_add_vdev_to_pad(struct imx_media_dev 
*imxmd,
return 0;
}
 
-   vdev_idx = imxpad->num_vdevs;
-
/* just return if we've been here before */
-   for (i = 0; i < vdev_idx; i++)
-   if (vdev == imxpad->vdev[i])
+   list_for_each_entry(pad_vdev, pad_vdev_list, list) {
+   if (pad_vdev->vdev == vdev)
return 0;
-
-   if (vdev_idx >= IMX_MEDIA_MAX_VDEVS) {
-   dev_err(imxmd->md.dev, "can't add %s to pad %s:%u\n",
-   vdev->vfd->entity.name, entity->name, srcpad->index);
-   return -ENOSPC;
}
 
dev_dbg(imxmd->md.dev, "adding %s to pad %s:%u\n",
vdev->vfd->entity.name, entity->name, srcpad->index);
-   imxpad->vdev[vdev_idx] = vdev;
-   imxpad->num_vdevs++;
+
+   pad_vdev = devm_kzalloc(imxmd->md.dev, sizeof(*pad_vdev), GFP_KERNEL);
+   if (!pad_vdev)
+   return -ENOMEM;
+
+   /* attach this vdev to this pad */
+   pad_vdev->vdev = vdev;
+   list_add_tail(_vdev->list, pad_vdev_list);
 
/* move upstream from this entity's sink pads */
for (i = 0; i < entity->num_pads; i++) {
@@ -289,22 +289,32 @@ static int imx_media_add_vdev_to_pad(struct imx_media_dev 
*imxmd,
return 0;
 }
 
+/*
+ * For every subdevice, allocate an array of list_head's, one list_head
+ * for each pad, to hold the list of video devices reachable from that
+ * pad.
+ */
 static int imx_media_alloc_pad_vdev_lists(struct imx_media_dev *imxmd)
 {
-   struct imx_media_pad *imxpads;
+   struct list_head *vdev_lists;
struct media_entity *entity;
struct v4l2_subdev *sd;
+   int i;
 
list_for_each_entry(sd, >v4l2_dev.subdevs, list) {
entity = >entity;
-   imxpads = devm_kzalloc(imxmd->md.dev,
-  entity->num_pads * sizeof(*imxpads),
-  GFP_KERNEL);
-   if (!imxpads)
+   vdev_lists = devm_kzalloc(
+   imxmd->md.dev,
+   entity->num_pads * sizeof(*vdev_lists),
+   GFP_KERNEL);
+   if 

[PATCH v2 2/9] media: staging/imx: remove static media link arrays

2017-12-14 Thread Steve Longerbeam
Remove the static list of media links that were formed at probe time.
These links can instead be created after all registered async subdevices
have been bound in imx_media_probe_complete().

The media links between subdevices that exist in the device tree, can
be created post-async completion by using v4l2_fwnode_parse_link() for
each endpoint node of that subdevice. Note this approach assumes
device-tree ports are equivalent to media pads (pad index equals
port id), and that device-tree endpoints are equivalent to media
links between pads.

Because links are no longer parsed by imx_media_of_parse(), its sole
function is now only to add subdevices that it encounters by walking
the OF graph to the async list, so the function has been renamed
imx_media_add_of_subdevs().

Similarly, the media links between the IPU-internal subdevice pads (the
CSI source pads, and all pads between the vdic, ic-prp, ic-prpenc, and
ic-prpvf subdevices), can be created post-async completion by looping
through the subdevice's media pads and using the const internal_subdev
table.

Because links are no longer parsed by imx_media_add_internal_subdevs(),
this function no longer needs an array of CSI subdevs to form links
from.

In summary, the following functions, which were used to form a list
of media links at probe time, are removed:

imx_media_add_pad_link()
add_internal_links()
of_add_pad_link()

replaced by these functions, called at probe time, which only populate
the async subdev list:

imx_media_add_of_subdevs()
imx_media_add_internal_subdevs()

and these functions, called at async completion, which create the
media links:

imx_media_create_of_links()
imx_media_create_csi_of_links()
imx_media_create_internal_links()

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-dev.c | 130 +++--
 drivers/staging/media/imx/imx-media-internal-sd.c | 219 +-
 drivers/staging/media/imx/imx-media-of.c  | 189 ---
 drivers/staging/media/imx/imx-media.h |  39 +---
 4 files changed, 281 insertions(+), 296 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-dev.c 
b/drivers/staging/media/imx/imx-media-dev.c
index c483b1d..09d2deb 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -128,50 +129,6 @@ imx_media_add_async_subdev(struct imx_media_dev *imxmd,
 }
 
 /*
- * Adds an imx-media link to a subdev pad's link list. This is called
- * during driver load when forming the links between subdevs.
- *
- * @pad: the local pad
- * @remote_node: the device node of the remote subdev
- * @remote_devname: the device name of the remote subdev
- * @local_pad: local pad index
- * @remote_pad: remote pad index
- */
-int imx_media_add_pad_link(struct imx_media_dev *imxmd,
-  struct imx_media_pad *pad,
-  struct device_node *remote_node,
-  const char *remote_devname,
-  int local_pad, int remote_pad)
-{
-   struct imx_media_link *link;
-   int link_idx, ret = 0;
-
-   mutex_lock(>mutex);
-
-   link_idx = pad->num_links;
-   if (link_idx >= IMX_MEDIA_MAX_LINKS) {
-   dev_err(imxmd->md.dev, "%s: too many links!\n", __func__);
-   ret = -ENOSPC;
-   goto out;
-   }
-
-   link = >link[link_idx];
-
-   link->remote_sd_node = remote_node;
-   if (remote_devname)
-   strncpy(link->remote_devname, remote_devname,
-   sizeof(link->remote_devname));
-
-   link->local_pad = local_pad;
-   link->remote_pad = remote_pad;
-
-   pad->num_links++;
-out:
-   mutex_unlock(>mutex);
-   return ret;
-}
-
-/*
  * get IPU from this CSI and add it to the list of IPUs
  * the media driver will control.
  */
@@ -240,76 +197,38 @@ static int imx_media_subdev_bound(struct 
v4l2_async_notifier *notifier,
 }
 
 /*
- * Create a single source->sink media link given a subdev and a single
- * link from one of its source pads. Called after all subdevs have
- * registered.
- */
-static int imx_media_create_link(struct imx_media_dev *imxmd,
-struct imx_media_subdev *src,
-struct imx_media_link *link)
-{
-   struct imx_media_subdev *sink;
-   u16 source_pad, sink_pad;
-   int ret;
-
-   sink = imx_media_find_async_subdev(imxmd, link->remote_sd_node,
-  link->remote_devname);
-   if (!sink) {
-   v4l2_warn(>v4l2_dev, "%s: no sink for %s:%d\n",
- __func__, src->sd->name, link->local_pad);
-   return 0;
-   }
-
-   source_pad = link->local_pad;
-   sink_pad = link->remote_pad;
-
-   v4l2_info(>v4l2_dev, "%s: %s:%d -> 

[PATCH v2 8/9] media: staging/imx: reorder function prototypes

2017-12-14 Thread Steve Longerbeam
Re-order some of the function prototypes in imx-media.h to
group them correctly by source file. No functional changes.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media.h | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media.h 
b/drivers/staging/media/imx/imx-media.h
index ebb24b1..2fd6dfd 100644
--- a/drivers/staging/media/imx/imx-media.h
+++ b/drivers/staging/media/imx/imx-media.h
@@ -157,6 +157,7 @@ enum codespace_sel {
CS_SEL_ANY,
 };
 
+/* imx-media-utils.c */
 const struct imx_media_pixfmt *
 imx_media_find_format(u32 fourcc, enum codespace_sel cs_sel, bool allow_bayer);
 int imx_media_enum_format(u32 *fourcc, u32 index, enum codespace_sel cs_sel);
@@ -181,17 +182,8 @@ int imx_media_mbus_fmt_to_ipu_image(struct ipu_image 
*image,
struct v4l2_mbus_framefmt *mbus);
 int imx_media_ipu_image_to_mbus_fmt(struct v4l2_mbus_framefmt *mbus,
struct ipu_image *image);
-int imx_media_add_async_subdev(struct imx_media_dev *imxmd,
-  struct fwnode_handle *fwnode,
-  struct platform_device *pdev);
 void imx_media_grp_id_to_sd_name(char *sd_name, int sz,
 u32 grp_id, int ipu_id);
-
-int imx_media_add_internal_subdevs(struct imx_media_dev *imxmd);
-int imx_media_create_internal_links(struct imx_media_dev *imxmd,
-   struct v4l2_subdev *sd);
-void imx_media_remove_internal_subdevs(struct imx_media_dev *imxmd);
-
 struct v4l2_subdev *
 imx_media_find_subdev_by_fwnode(struct imx_media_dev *imxmd,
struct fwnode_handle *fwnode);
@@ -227,6 +219,11 @@ int imx_media_pipeline_set_stream(struct imx_media_dev 
*imxmd,
  struct media_entity *entity,
  bool on);
 
+/* imx-media-dev.c */
+int imx_media_add_async_subdev(struct imx_media_dev *imxmd,
+  struct fwnode_handle *fwnode,
+  struct platform_device *pdev);
+
 /* imx-media-fim.c */
 struct imx_media_fim;
 void imx_media_fim_eof_monitor(struct imx_media_fim *fim, ktime_t timestamp);
@@ -237,6 +234,12 @@ int imx_media_fim_add_controls(struct imx_media_fim *fim);
 struct imx_media_fim *imx_media_fim_init(struct v4l2_subdev *sd);
 void imx_media_fim_free(struct imx_media_fim *fim);
 
+/* imx-media-internal-sd.c */
+int imx_media_add_internal_subdevs(struct imx_media_dev *imxmd);
+int imx_media_create_internal_links(struct imx_media_dev *imxmd,
+   struct v4l2_subdev *sd);
+void imx_media_remove_internal_subdevs(struct imx_media_dev *imxmd);
+
 /* imx-media-of.c */
 int imx_media_add_of_subdevs(struct imx_media_dev *dev,
 struct device_node *np);
-- 
2.7.4

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


[PATCH v2 9/9] media: staging/imx: update TODO

2017-12-14 Thread Steve Longerbeam
Update TODO file:

- Remove TODO info about the OV564x driver, while this still needs
  to be done (add a OV5642 driver or merge with OV5640 driver), it
  is not relevant here.

- Update TODO about methods for retrieving CSI bus config.

- Add some TODO's about OF graph parsing restrictions.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/TODO | 63 ++
 1 file changed, 51 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/media/imx/TODO b/drivers/staging/media/imx/TODO
index 0bee313..9eb7326 100644
--- a/drivers/staging/media/imx/TODO
+++ b/drivers/staging/media/imx/TODO
@@ -1,19 +1,14 @@
 
-- Clean up and move the ov5642 subdev driver to drivers/media/i2c, or
-  merge support for OV5642 into drivers/media/i2c/ov5640.c, and create
-  the binding docs for it.
-
 - The Frame Interval Monitor could be exported to v4l2-core for
   general use.
 
-- At driver load time, the device-tree node that is the original source
-  (the "sensor"), is parsed to record its media bus configuration, and
-  this info is required in imx-media-csi.c to setup the CSI.
-  Laurent Pinchart argues that instead the CSI subdev should call its
-  neighbor's g_mbus_config op (which should be propagated if necessary)
-  to get this info. However Hans Verkuil is planning to remove the
-  g_mbus_config op. For now this driver uses the parsed DT mbus config
-  method until this issue is resolved.
+- The CSI subdevice parses its nearest upstream neighbor's device-tree
+  bus config in order to setup the CSI. Laurent Pinchart argues that
+  instead the CSI subdev should call its neighbor's g_mbus_config op
+  (which should be propagated if necessary) to get this info. However
+  Hans Verkuil is planning to remove the g_mbus_config op. For now this
+  driver uses the parsed DT bus config method until this issue is
+  resolved.
 
 - This media driver supports inheriting V4L2 controls to the
   video capture devices, from the subdevices in the capture device's
@@ -21,3 +16,47 @@
   link_notify callback when the pipeline is modified. It should be
   decided whether this feature is useful enough to make it generally
   available by exporting to v4l2-core.
+
+- The OF graph is walked at probe time to form the list of fwnodes to
+  be passed to v4l2_async_notifier_register(), starting from the IPU
+  CSI ports. And after all async subdevices have been bound,
+  v4l2_fwnode_parse_link() is used to form the media links between
+  the entities discovered by walking the OF graph.
+
+  While this approach allows support for arbitrary OF graphs, there
+  are some assumptions for this to work:
+
+  1. All port parent nodes reachable in the graph from the IPU CSI
+ ports bind to V4L2 async subdevice drivers.
+
+ If a device has mixed-use ports such as video plus audio, the
+ endpoints from the audio ports are followed to devices that must
+ bind to V4L2 subdevice drivers, and not for example, to an ALSA
+ driver or a non-V4L2 media driver. If the device were bound to
+ such a driver, imx-media would never get an async completion
+ notification because the device fwnode was added to the async
+ list, but the driver does not interface with the V4L2 async
+ framework.
+
+  2. Every port reachable in the graph is treated as a media pad,
+ owned by the V4L2 subdevice that is bound to the port's parent.
+
+ This presents problems for devices that don't make this port = pad
+ assumption. Examples are SMIAPP compatible cameras which define only
+ a single output port node, but which define multiple pads owned
+ by multiple subdevices (pixel-array, binner, scaler). Or video
+ decoders (entity function MEDIA_ENT_F_ATV_DECODER), which also define
+ only a single output port node, but define multiple pads for video,
+ VBI, and audio out.
+
+ A workaround at present is to set the port reg properties to
+ correspond to the media pad index that the port represents. A
+ possible long-term solution is to implement a subdev API that
+ maps a port id to a media pad index.
+
+  3. Every endpoint of a port reachable in the graph is treated as
+ a media link, between V4L2 subdevices that are bound to the
+ port parents of the local and remote endpoints.
+
+ Which means a port must not contain mixed-use endpoints, they
+ must all refer to media links between V4L2 subdevices.
-- 
2.7.4

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


[PATCH v2 4/9] media: staging/imx: remove devname string from imx_media_subdev

2017-12-14 Thread Steve Longerbeam
A separate string for the device name, for DEVNAME async match, was
never needed. Just assign the asd device name to the passed platform
device name pointer in imx_media_add_async_subdev().

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-dev.c | 3 +--
 drivers/staging/media/imx/imx-media.h | 2 --
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-dev.c 
b/drivers/staging/media/imx/imx-media-dev.c
index 09d2deb..ab0617d6 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -112,8 +112,7 @@ imx_media_add_async_subdev(struct imx_media_dev *imxmd,
asd->match.fwnode.fwnode = of_fwnode_handle(np);
} else {
asd->match_type = V4L2_ASYNC_MATCH_DEVNAME;
-   strncpy(imxsd->devname, devname, sizeof(imxsd->devname));
-   asd->match.device_name.name = imxsd->devname;
+   asd->match.device_name.name = devname;
imxsd->pdev = pdev;
}
 
diff --git a/drivers/staging/media/imx/imx-media.h 
b/drivers/staging/media/imx/imx-media.h
index 08e34f9..c6cea27 100644
--- a/drivers/staging/media/imx/imx-media.h
+++ b/drivers/staging/media/imx/imx-media.h
@@ -128,8 +128,6 @@ struct imx_media_subdev {
 
/* the platform device if this is an IPU-internal subdev */
struct platform_device *pdev;
-   /* the devname is needed for async devname match */
-   char devname[32];
 };
 
 struct imx_media_dev {
-- 
2.7.4

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


[PATCH v2 0/9] media: imx: Add better OF graph support

2017-12-14 Thread Steve Longerbeam
This is a set of patches that improve support for more complex OF
graphs. Currently the imx-media driver only supports a single device
with a single port connected directly to either the CSI muxes or the
MIPI CSI-2 receiver input ports. There can't be a multi-port device in
between. This patch set removes those limitations.

For an example taken from automotive, a camera sensor or decoder could
be literally a remote device accessible over a FPD-III link, via TI
DS90Ux9xx deserializer/serializer pairs. This patch set would support
such OF graphs.

There are still some assumptions and restrictions, regarding the equivalence
of device-tree ports, port parents, and endpoints to media pads, entities,
and links that have been enumerated in the TODO file.

This patch set supersedes the following patch submitted earlier:

"[PATCH v2] media: staging/imx: do not return error in link_notify for unknown 
sources"

Tested by: Steve Longerbeam 
on SabreLite with the OV5640

Tested-by: Philipp Zabel 
on Nitrogen6X with the TC358743.

Tested-by: Russell King 
with the IMX219

History:
v2:
- this version is to resolve merge conflicts only, no functional
  changes since v1.


Steve Longerbeam (9):
  media: staging/imx: get CSI bus type from nearest upstream entity
  media: staging/imx: remove static media link arrays
  media: staging/imx: of: allow for recursing downstream
  media: staging/imx: remove devname string from imx_media_subdev
  media: staging/imx: pass fwnode handle to find/add async subdev
  media: staging/imx: remove static subdev arrays
  media: staging/imx: convert static vdev lists to list_head
  media: staging/imx: reorder function prototypes
  media: staging/imx: update TODO

 drivers/staging/media/imx/TODO|  63 +++-
 drivers/staging/media/imx/imx-ic-prp.c|   4 +-
 drivers/staging/media/imx/imx-media-capture.c |   2 +
 drivers/staging/media/imx/imx-media-csi.c | 187 +-
 drivers/staging/media/imx/imx-media-dev.c | 401 +-
 drivers/staging/media/imx/imx-media-internal-sd.c | 253 +++---
 drivers/staging/media/imx/imx-media-of.c  | 278 ---
 drivers/staging/media/imx/imx-media-utils.c   | 122 +++
 drivers/staging/media/imx/imx-media.h | 187 --
 9 files changed, 721 insertions(+), 776 deletions(-)

-- 
2.7.4

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


[PATCH v2 3/9] media: staging/imx: of: allow for recursing downstream

2017-12-14 Thread Steve Longerbeam
Calling of_parse_subdev() recursively to a downstream path that has
already been followed is ok, it just means that call will return
immediately since the subdevice was already added to the async list.

With that there is no need to determine whether a subdevice's port
is a sink or source, so 'num_{sink|src}_pads' is no longer used and
is removed.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-internal-sd.c | 17 -
 drivers/staging/media/imx/imx-media-of.c  | 78 ++-
 drivers/staging/media/imx/imx-media.h | 14 
 3 files changed, 21 insertions(+), 88 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-internal-sd.c 
b/drivers/staging/media/imx/imx-media-internal-sd.c
index 3e60df5..53f2383 100644
--- a/drivers/staging/media/imx/imx-media-internal-sd.c
+++ b/drivers/staging/media/imx/imx-media-internal-sd.c
@@ -78,13 +78,9 @@ struct internal_pad {
 static const struct internal_subdev {
const struct internal_subdev_id *id;
struct internal_pad pad[IMX_MEDIA_MAX_PADS];
-   int num_sink_pads;
-   int num_src_pads;
 } int_subdev[num_isd] = {
[isd_csi0] = {
.id = _id[isd_csi0],
-   .num_sink_pads = CSI_NUM_SINK_PADS,
-   .num_src_pads = CSI_NUM_SRC_PADS,
.pad[CSI_SRC_PAD_DIRECT] = {
.link = {
{
@@ -102,8 +98,6 @@ static const struct internal_subdev {
 
[isd_csi1] = {
.id = _id[isd_csi1],
-   .num_sink_pads = CSI_NUM_SINK_PADS,
-   .num_src_pads = CSI_NUM_SRC_PADS,
.pad[CSI_SRC_PAD_DIRECT] = {
.link = {
{
@@ -121,8 +115,6 @@ static const struct internal_subdev {
 
[isd_vdic] = {
.id = _id[isd_vdic],
-   .num_sink_pads = VDIC_NUM_SINK_PADS,
-   .num_src_pads = VDIC_NUM_SRC_PADS,
.pad[VDIC_SRC_PAD_DIRECT] = {
.link = {
{
@@ -136,8 +128,6 @@ static const struct internal_subdev {
 
[isd_ic_prp] = {
.id = _id[isd_ic_prp],
-   .num_sink_pads = PRP_NUM_SINK_PADS,
-   .num_src_pads = PRP_NUM_SRC_PADS,
.pad[PRP_SRC_PAD_PRPENC] = {
.link = {
{
@@ -160,14 +150,10 @@ static const struct internal_subdev {
 
[isd_ic_prpenc] = {
.id = _id[isd_ic_prpenc],
-   .num_sink_pads = PRPENCVF_NUM_SINK_PADS,
-   .num_src_pads = PRPENCVF_NUM_SRC_PADS,
},
 
[isd_ic_prpvf] = {
.id = _id[isd_ic_prpvf],
-   .num_sink_pads = PRPENCVF_NUM_SINK_PADS,
-   .num_src_pads = PRPENCVF_NUM_SRC_PADS,
},
 };
 
@@ -312,9 +298,6 @@ static int add_internal_subdev(struct imx_media_dev *imxmd,
if (IS_ERR(imxsd))
return PTR_ERR(imxsd);
 
-   imxsd->num_sink_pads = isd->num_sink_pads;
-   imxsd->num_src_pads = isd->num_src_pads;
-
return 0;
 }
 
diff --git a/drivers/staging/media/imx/imx-media-of.c 
b/drivers/staging/media/imx/imx-media-of.c
index d35c99e..a085e52 100644
--- a/drivers/staging/media/imx/imx-media-of.c
+++ b/drivers/staging/media/imx/imx-media-of.c
@@ -41,11 +41,12 @@ static int of_get_port_count(const struct device_node *np)
 /*
  * find the remote device node given local endpoint node
  */
-static void of_get_remote(struct device_node *epnode,
+static bool of_get_remote(struct device_node *epnode,
  struct device_node **remote_node)
 {
struct device_node *rp, *rpp;
struct device_node *remote;
+   bool is_csi_port;
 
rp = of_graph_get_remote_port(epnode);
rpp = of_graph_get_remote_port_parent(epnode);
@@ -54,9 +55,11 @@ static void of_get_remote(struct device_node *epnode,
/* the remote is one of the CSI ports */
remote = rp;
of_node_put(rpp);
+   is_csi_port = true;
} else {
remote = rpp;
of_node_put(rp);
+   is_csi_port = false;
}
 
if (!of_device_is_available(remote)) {
@@ -65,6 +68,8 @@ static void of_get_remote(struct device_node *epnode,
} else {
*remote_node = remote;
}
+
+   return is_csi_port;
 }
 
 static int
@@ -72,7 +77,7 @@ of_parse_subdev(struct imx_media_dev *imxmd, struct 
device_node *sd_np,
bool is_csi_port)
 {
struct imx_media_subdev *imxsd;
-   int i, num_pads, ret;
+   int i, num_ports, ret;
 
if (!of_device_is_available(sd_np)) {
dev_dbg(imxmd->md.dev, "%s: %s not enabled\n", __func__,
@@ -94,77 +99,36 @@ of_parse_subdev(struct imx_media_dev *imxmd, struct 
device_node *sd_np,

[PATCH v2 5/9] media: staging/imx: pass fwnode handle to find/add async subdev

2017-12-14 Thread Steve Longerbeam
Pass the subdev's fwnode_handle to imx_media_find_async_subdev() and
imx_media_add_async_subdev(), instead of a device_node.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-dev.c | 20 ++--
 drivers/staging/media/imx/imx-media-of.c  |  7 +++
 drivers/staging/media/imx/imx-media.h |  4 ++--
 3 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-dev.c 
b/drivers/staging/media/imx/imx-media-dev.c
index ab0617d6..0369c35 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -33,15 +33,14 @@ static inline struct imx_media_dev *notifier2dev(struct 
v4l2_async_notifier *n)
 }
 
 /*
- * Find a subdev by device node or device name. This is called during
+ * Find a subdev by fwnode or device name. This is called during
  * driver load to form the async subdev list and bind them.
  */
 struct imx_media_subdev *
 imx_media_find_async_subdev(struct imx_media_dev *imxmd,
-   struct device_node *np,
+   struct fwnode_handle *fwnode,
const char *devname)
 {
-   struct fwnode_handle *fwnode = np ? of_fwnode_handle(np) : NULL;
struct imx_media_subdev *imxsd;
int i;
 
@@ -67,7 +66,7 @@ imx_media_find_async_subdev(struct imx_media_dev *imxmd,
 
 
 /*
- * Adds a subdev to the async subdev list. If np is non-NULL, adds
+ * Adds a subdev to the async subdev list. If fwnode is non-NULL, adds
  * the async as a V4L2_ASYNC_MATCH_FWNODE match type, otherwise as
  * a V4L2_ASYNC_MATCH_DEVNAME match type using the dev_name of the
  * given platform_device. This is called during driver load when
@@ -75,9 +74,10 @@ imx_media_find_async_subdev(struct imx_media_dev *imxmd,
  */
 struct imx_media_subdev *
 imx_media_add_async_subdev(struct imx_media_dev *imxmd,
-  struct device_node *np,
+  struct fwnode_handle *fwnode,
   struct platform_device *pdev)
 {
+   struct device_node *np = to_of_node(fwnode);
struct imx_media_subdev *imxsd;
struct v4l2_async_subdev *asd;
const char *devname = NULL;
@@ -89,7 +89,7 @@ imx_media_add_async_subdev(struct imx_media_dev *imxmd,
devname = dev_name(>dev);
 
/* return -EEXIST if this subdev already added */
-   if (imx_media_find_async_subdev(imxmd, np, devname)) {
+   if (imx_media_find_async_subdev(imxmd, fwnode, devname)) {
dev_dbg(imxmd->md.dev, "%s: already added %s\n",
__func__, np ? np->name : devname);
imxsd = ERR_PTR(-EEXIST);
@@ -107,9 +107,9 @@ imx_media_add_async_subdev(struct imx_media_dev *imxmd,
imxsd = >subdev[sd_idx];
 
asd = >asd;
-   if (np) {
+   if (fwnode) {
asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
-   asd->match.fwnode.fwnode = of_fwnode_handle(np);
+   asd->match.fwnode.fwnode = fwnode;
} else {
asd->match_type = V4L2_ASYNC_MATCH_DEVNAME;
asd->match.device_name.name = devname;
@@ -162,13 +162,13 @@ static int imx_media_subdev_bound(struct 
v4l2_async_notifier *notifier,
  struct v4l2_async_subdev *asd)
 {
struct imx_media_dev *imxmd = notifier2dev(notifier);
-   struct device_node *np = to_of_node(sd->fwnode);
struct imx_media_subdev *imxsd;
int ret = 0;
 
mutex_lock(>mutex);
 
-   imxsd = imx_media_find_async_subdev(imxmd, np, dev_name(sd->dev));
+   imxsd = imx_media_find_async_subdev(imxmd, sd->fwnode,
+   dev_name(sd->dev));
if (!imxsd) {
ret = -EINVAL;
goto out;
diff --git a/drivers/staging/media/imx/imx-media-of.c 
b/drivers/staging/media/imx/imx-media-of.c
index a085e52..eb7a7f2 100644
--- a/drivers/staging/media/imx/imx-media-of.c
+++ b/drivers/staging/media/imx/imx-media-of.c
@@ -87,7 +87,8 @@ of_parse_subdev(struct imx_media_dev *imxmd, struct 
device_node *sd_np,
}
 
/* register this subdev with async notifier */
-   imxsd = imx_media_add_async_subdev(imxmd, sd_np, NULL);
+   imxsd = imx_media_add_async_subdev(imxmd, of_fwnode_handle(sd_np),
+  NULL);
ret = PTR_ERR_OR_ZERO(imxsd);
if (ret) {
if (ret == -EEXIST) {
@@ -176,9 +177,7 @@ static int create_of_link(struct imx_media_dev *imxmd,
if (link->local_port >= sd->entity.num_pads)
return -EINVAL;
 
-   remote = imx_media_find_async_subdev(imxmd,
-to_of_node(link->remote_node),
-NULL);
+   remote = imx_media_find_async_subdev(imxmd, link->remote_node, NULL);
if (!remote)

[PATCH v2 1/9] media: staging/imx: get CSI bus type from nearest upstream entity

2017-12-14 Thread Steve Longerbeam
The imx-media driver currently supports a device tree graph of
limited complexity. This patch is a first step in allowing imx-media
to work with more general OF graphs.

The CSI subdevice assumes the originating upstream subdevice (the
"sensor") is connected directly to either the CSI mux or the MIPI
CSI-2 receiver. But for more complex graphs, the sensor can be distant,
with possible bridge entities in between. Thus the sensor's bus type
could be quite different from what is entering the CSI. For example
a distant sensor could have a parallel interface, but the stream
entering the i.MX is MIPI CSI-2.

To remove this assumption, get the entering bus config from the entity
that is directly upstream from either the CSI mux, or the CSI-2 receiver.
If the CSI-2 receiver is not in the enabled pipeline, the bus type to the
CSI is parallel, otherwise the CSI is receiving MIPI CSI-2.

Note that we can't use the direct upstream source connected to CSI
(which is either the CSI mux or the CSI-2 receiver) to determine
bus type. The bus entering the CSI from the CSI-2 receiver is a 32-bit
parallel bus containing the demultiplexed MIPI CSI-2 virtual channels.
But the CSI and its IDMAC channels must be configured based on whether
it is receiving data from the CSI-2 receiver or from the CSI mux's
parallel interface pins.

The function csi_get_upstream_endpoint() is used to find this
endpoint. It makes use of a new utility function
imx_media_find_upstream_pad(), that if given a grp_id of 0, will
return the closest upstream pad from start_entity.

With these changes, imx_media_find_sensor() is no longer used and
is removed. As a result there is also no longer a need to identify
any sensor or set the sensor subdev's group id as a method to search
for it. So IMX_MEDIA_GRP_ID_SENSOR is removed. Also the video-mux group
id IMX_MEDIA_GRP_ID_VIDMUX was never used so that is removed as well.
The remaining IMX_MEDIA_GRP_ID_* definitions are entities internal
to the i.MX.

Another use of imx_media_find_sensor() in the CSI was to call the
sensor's g_skip_frames op to determine if a delay was needed before
enabling the CSI at stream on. If necessary this will have to be
re-addressed at a later time.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-csi.c   | 188 
 drivers/staging/media/imx/imx-media-dev.c   |  12 --
 drivers/staging/media/imx/imx-media-of.c|  21 
 drivers/staging/media/imx/imx-media-utils.c |  63 +-
 drivers/staging/media/imx/imx-media.h   |  27 ++--
 5 files changed, 150 insertions(+), 161 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index d90cfda..d7a4b7c 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -99,8 +100,8 @@ struct csi_priv {
/* the mipi virtual channel number at link validate */
int vc_num;
 
-   /* the attached sensor at stream on */
-   struct imx_media_subdev *sensor;
+   /* the upstream endpoint CSI is receiving from */
+   struct v4l2_fwnode_endpoint upstream_ep;
 
spinlock_t irqlock; /* protect eof_irq handler */
struct timer_list eof_timeout_timer;
@@ -120,6 +121,71 @@ static inline struct csi_priv *sd_to_dev(struct 
v4l2_subdev *sdev)
return container_of(sdev, struct csi_priv, sd);
 }
 
+static inline bool is_parallel_16bit_bus(struct v4l2_fwnode_endpoint *ep)
+{
+   return ep->bus_type != V4L2_MBUS_CSI2 &&
+   ep->bus.parallel.bus_width >= 16;
+}
+
+/*
+ * Parses the fwnode endpoint from the source pad of the entity
+ * connected to this CSI. This will either be the entity directly
+ * upstream from the CSI-2 receiver, or directly upstream from the
+ * video mux. The endpoint is needed to determine the bus type and
+ * bus config coming into the CSI.
+ */
+static int csi_get_upstream_endpoint(struct csi_priv *priv,
+struct v4l2_fwnode_endpoint *ep)
+{
+   struct device_node *endpoint, *port;
+   struct imx_media_subdev *imxsd;
+   struct media_entity *src;
+   struct v4l2_subdev *sd;
+   struct media_pad *pad;
+
+   if (!priv->src_sd)
+   return -EPIPE;
+
+   src = >src_sd->entity;
+
+   if (src->function == MEDIA_ENT_F_VID_MUX) {
+   /*
+* CSI is connected directly to video mux, skip up to
+* CSI-2 receiver if it is in the path, otherwise stay
+* with video mux.
+*/
+   imxsd = imx_media_find_upstream_subdev(priv->md, src,
+  IMX_MEDIA_GRP_ID_CSI2);
+   if (!IS_ERR(imxsd))
+   src = >sd->entity;
+   }
+
+   /* get source pad of entity directly 

syzbot bug reports

2017-12-14 Thread Dan Carpenter
Btw, Todd, you may have seen these but the syzbot reported a couple bugs
right before we added you to MAINTAINERS.

kernel BUG at drivers/android/binder_alloc.c:LINE!
http://lkml.iu.edu/hypermail/linux/kernel/1712.0/00907.html

general protection fault in binder_poll
http://lkml.iu.edu/hypermail/linux/kernel/1712.0/01348.html

WARNING in binder_send_failed_reply
http://lkml.iu.edu/hypermail/linux/kernel/1712.0/00548.html

regards,
dan carpenter

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


Re: [PATCH 1/3] staging: vchiq_arm: Remove useless comments

2017-12-14 Thread Greg KH
On Thu, Dec 14, 2017 at 11:40:03PM +0300, Mikhail Shvetsov wrote:
> Signed-off-by: Mikhail Shvetsov 

I can't take patches without any changelog text at all.

Please fix all of these up and resend.

thanks,

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


[PATCH 2/3] staging: vchiq_arm: Fixing code style of comments

2017-12-14 Thread Mikhail Shvetsov
Signed-off-by: Mikhail Shvetsov 
---
 .../vc04_services/interface/vchiq_arm/vchiq_kern_lib.c   | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
index 4a40b9b31a5a..48f05062fc12 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
@@ -72,7 +72,9 @@ VCHIQ_STATUS_T vchiq_initialise(VCHIQ_INSTANCE_T 
*instance_out)
vchiq_log_trace(vchiq_core_log_level, "%s called", __func__);
 
/* VideoCore may not be ready due to boot up timing.
-  It may never be ready if kernel and firmware are mismatched, so 
don't block forever. */
+* It may never be ready if kernel and firmware are mismatched, so don't
+* block forever.
+*/
for (i = 0; i < VCHIQ_INIT_RETRIES; i++) {
state = vchiq_get_state();
if (state)
@@ -381,8 +383,9 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, 
void *data,
if ((bulk->data != data) ||
(bulk->size != size)) {
/* This is not a retry of the previous one.
-   ** Cancel the signal when the transfer
-   ** completes. */
+* Cancel the signal when the transfer
+* completes.
+*/
spin_lock(_waiter_spinlock);
bulk->userdata = NULL;
spin_unlock(_waiter_spinlock);
@@ -408,7 +411,8 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, 
void *data,
 
if (bulk) {
/* Cancel the signal when the transfer
-** completes. */
+* completes.
+*/
spin_lock(_waiter_spinlock);
bulk->userdata = NULL;
spin_unlock(_waiter_spinlock);
-- 
2.11.0

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


[PATCH 1/3] staging: vchiq_arm: Remove useless comments

2017-12-14 Thread Mikhail Shvetsov
Signed-off-by: Mikhail Shvetsov 
---
 .../interface/vchiq_arm/vchiq_kern_lib.c   | 35 +-
 1 file changed, 1 insertion(+), 34 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
index 34f746db19cd..4a40b9b31a5a 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
@@ -31,7 +31,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/*  Include Files  */
 
 #include 
 #include 
@@ -41,9 +40,6 @@
 #include "vchiq_arm.h"
 #include "vchiq_killable.h"
 
-/*  Public Variables - */
-
-/*  Private Constants and Types -- */
 
 struct bulk_waiter_node {
struct bulk_waiter bulk_waiter;
@@ -64,11 +60,7 @@ static VCHIQ_STATUS_T
 vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data,
unsigned int size, VCHIQ_BULK_DIR_T dir);
 
-/
-*
-*   vchiq_initialise
-*
-***/
+
 #define VCHIQ_INIT_RETRIES 10
 VCHIQ_STATUS_T vchiq_initialise(VCHIQ_INSTANCE_T *instance_out)
 {
@@ -120,11 +112,6 @@ VCHIQ_STATUS_T vchiq_initialise(VCHIQ_INSTANCE_T 
*instance_out)
 }
 EXPORT_SYMBOL(vchiq_initialise);
 
-/
-*
-*   vchiq_shutdown
-*
-***/
 
 VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance)
 {
@@ -168,22 +155,12 @@ VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance)
 }
 EXPORT_SYMBOL(vchiq_shutdown);
 
-/
-*
-*   vchiq_is_connected
-*
-***/
 
 static int vchiq_is_connected(VCHIQ_INSTANCE_T instance)
 {
return instance->connected;
 }
 
-/
-*
-*   vchiq_connect
-*
-***/
 
 VCHIQ_STATUS_T vchiq_connect(VCHIQ_INSTANCE_T instance)
 {
@@ -214,11 +191,6 @@ VCHIQ_STATUS_T vchiq_connect(VCHIQ_INSTANCE_T instance)
 }
 EXPORT_SYMBOL(vchiq_connect);
 
-/
-*
-*   vchiq_add_service
-*
-***/
 
 VCHIQ_STATUS_T vchiq_add_service(
VCHIQ_INSTANCE_T  instance,
@@ -259,11 +231,6 @@ VCHIQ_STATUS_T vchiq_add_service(
 }
 EXPORT_SYMBOL(vchiq_add_service);
 
-/
-*
-*   vchiq_open_service
-*
-***/
 
 VCHIQ_STATUS_T vchiq_open_service(
VCHIQ_INSTANCE_T  instance,
-- 
2.11.0

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


[PATCH 3/3] staging: vchiq_arm: Fixing code lines over 80 characters

2017-12-14 Thread Mikhail Shvetsov
Signed-off-by: Mikhail Shvetsov 
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
index 48f05062fc12..7a803d136987 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
@@ -87,7 +87,8 @@ VCHIQ_STATUS_T vchiq_initialise(VCHIQ_INSTANCE_T 
*instance_out)
goto failed;
} else if (i > 0) {
vchiq_log_warning(vchiq_core_log_level,
-   "%s: videocore initialized after %d retries\n", 
__func__, i);
+   "%s: videocore initialized after %d retries\n",
+   __func__, i);
}
 
instance = kzalloc(sizeof(*instance), GFP_KERNEL);
-- 
2.11.0

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


[PATCH 0/3] staging: vchiq_arm: code style fixing

2017-12-14 Thread Mikhail Shvetsov
Mikhail Shvetsov (3):
  Remove useless comments
  Fixing code style of comments
  Fixing code lines over 80 characters

 .../interface/vchiq_arm/vchiq_kern_lib.c   | 50 +-
 1 file changed, 11 insertions(+), 39 deletions(-)

-- 
2.11.0

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


Re: [PATCH] android: binder: Check for errors in binder_alloc_shrinker_init().

2017-12-14 Thread Dan Carpenter
On Thu, Dec 14, 2017 at 10:52:28AM -0800, Todd Kjos wrote:
> On Fri, Dec 8, 2017 at 3:08 AM, Dan Carpenter  
> wrote:
> > On Wed, Dec 06, 2017 at 02:05:58PM -0500, Sherry Yang wrote:
> >> Hi Tetsuo,
> >>
> >> It looks like this patch was not submitted to LKML. Perhaps you want
> >> to send it to the mailing list and add the correct set of recipients
> >> using scripts/get_maintainer.pl as suggested here
> >> https://www.kernel.org/doc/html/v4.12/process/submitting-patches.html.
> >>
> >> -Sherry
> >>
> >
> > I've always viewed the de...@driverdev.osuosl.org as sufficient.  You're
> > not really going to get more reviewers by CC'ing LKML...
> 
> Well it might have picked up some more android folks (like me) who
> aren't on that list.
> 

The right thing is to add you to MAINTAINERS and we've just done that.

You have procmail scripts which select android stuff from LKML?  You
should really be subscribed to driver devel as well because that is the
mailing list for Android stuff.  And you already seem to have procmail
set up so there really is no reason not.

regards,
dan carpenter


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


Re: rf69_get_lna_gain

2017-12-14 Thread Simon Sandström
On Thu, Dec 14, 2017 at 06:08:11PM +0200, Marcus Wolf wrote:
> Hi!
> 
> This is an information for all of you, doing experiments with real hardware!
> 
> I wanted to explain, what this lna_gain stuff is used for:
> 
> If you are receiving messages from different sender (let's say several
> thermometers), it may happen (e. g. due to different distance and different
> battery level) that the automatic gain control of the receiver amp isn't
> able to work correctly. E.g. if it gets a very strong singal first and a
> very weak afterwards, it is possible, that the agc isn't capable to
> recognize the second telegram predictable.
> 
> The procedure, need to be done in such a case is:
> Switch on agc. Wait for a correct telegram to be received. Read the
> lna_gain_current value and store it. This is the gain setting for optimal
> reception for one of your sender. You now can set gain_select to this value,
> in order to receive stuff from this sender (instead of using agc).
> If you want to receive stuff from an other sender, you may want to try with
> different other settings. As soon, as you have success, you can store this
> value and use it for receiving stuff from that sender.
> 
> Since I have just a 35m² flat, it is quite hard to have a setup, to test
> such stuff. In summer I did some experiments on the pavement, but the
> experimental code never was integrated in the productional source repo,
> because I focused on tx first. Deeper use of rx is planned for late spring
> next year.
> 
> If you want to do experiments with rx of signals with different strength,
> maybe you want to save a copy of the abstracions (rf69_set_lna_gain and
> rf69_get_lna_gain) befor they get deleted in staging-next.
> 
> Regards,
> 
> Marcus
> 

Hi Marcus,

There is no need to make backups of code as it's still there in the git
history. If we ever need to re-introduce rf69_get_lna_gain, or any other
function that is removed due to not being used right now, it's just a
simple matter of reverting the commit that removed them. Either revert
them directly or use the revert as a base for re-introducing the
functionality.

So you don't have to feel like we're throwing away work that you've
probably spent lots of time on. It will still be available for us when
we actually need it. But right now, from what I've read in this thread,
the functionality isn't used at all right now (dead code) and should
therefore be removed.


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


Re: [PATCH] hyperv: make HYPERV a menuconfig to ease disabling it all

2017-12-14 Thread Randy Dunlap
On 12/13/2017 11:51 PM, Greg KH wrote:
> On Wed, Dec 13, 2017 at 01:23:38PM -0800, Stephen Hemminger wrote:
>> On Wed, 13 Dec 2017 09:54:19 +0100
>> Vincent Legoll  wrote:
>>
>>> Hello,
>>>
>>> On Sun, Dec 10, 2017 at 6:50 AM, Stephen Hemminger
>>>  wrote:
 Will this break existing configs?  
>>>
>>> I don't think so. Last time I did some similar changes, the kbuild
>>> test robot found some warnings on some configurations, I hope
>>> it will find problems (if any) for that series too (this one is not alone,
>>> I've got a bunch of other similar patches in-flight)
>>>
>>> Thanks
>>
>> NAK
>>
>> Let me give a concrete example of how this will break users.
>>
>> 1. Assume user has a working .config file in their kernel build directory
>> which builds a kernel that works on Hyper-V.
>>
>> 2. Add your patch (or assume it makes into a later version).
>>
>> 3. User then does
>>
>> $ make oldconfig
>> scripts/kconfig/conf  --oldconfig Kconfig
>> *
>> * Restart config...
>> *
>> *
>> * Microsoft Hyper-V guest support
>> *
>> Microsoft Hyper-V guest support (HYPERV_MENU) [N/y] (NEW) 
>>
>> If they hit return, the default value is not enabling HyperV and they
>> will then go on to build a kernel that will not boot on your system.
>>
>> The default MUST be set to Yes.

That should work.

> Or you can just not take these types of odd and silly changes to the
> Kconfig files, and leave it as-is.  I have yet to see the good reason
> why these are needed at all.

Some of us would like to be able to disable many like drivers at one time
instead of having to go down a list of say 20-30 drivers and disable them
one at a time.

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


rf69_get_lna_gain

2017-12-14 Thread Marcus Wolf

Hi!

This is an information for all of you, doing experiments with real hardware!

I wanted to explain, what this lna_gain stuff is used for:

If you are receiving messages from different sender (let's say several 
thermometers), it may happen (e. g. due to different distance and 
different battery level) that the automatic gain control of the receiver 
amp isn't able to work correctly. E.g. if it gets a very strong singal 
first and a very weak afterwards, it is possible, that the agc isn't 
capable to recognize the second telegram predictable.


The procedure, need to be done in such a case is:
Switch on agc. Wait for a correct telegram to be received. Read the 
lna_gain_current value and store it. This is the gain setting for 
optimal reception for one of your sender. You now can set gain_select to 
this value, in order to receive stuff from this sender (instead of using 
agc).
If you want to receive stuff from an other sender, you may want to try 
with different other settings. As soon, as you have success, you can 
store this value and use it for receiving stuff from that sender.


Since I have just a 35m² flat, it is quite hard to have a setup, to test 
such stuff. In summer I did some experiments on the pavement, but the 
experimental code never was integrated in the productional source repo, 
because I focused on tx first. Deeper use of rx is planned for late 
spring next year.


If you want to do experiments with rx of signals with different 
strength, maybe you want to save a copy of the abstracions 
(rf69_set_lna_gain and rf69_get_lna_gain) befor they get deleted in 
staging-next.


Regards,

Marcus

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


[PATCH 6/8 v4] staging: pi433: remove unused function

2017-12-14 Thread Valentin Vidic
As it turns out rf69_get_lna_gain is not used at all.

Signed-off-by: Valentin Vidic 
---
v2: - drop change for SHIFT_DATAMODUL_MODULATION_TYPE
- move shifting to the header file
v3: - drop auto case
- use CURRENT suffix
- precompute define values
v4: - drop the whole function since it is not called
  from anywhere

 drivers/staging/pi433/rf69.c | 18 --
 drivers/staging/pi433/rf69.h |  1 -
 2 files changed, 19 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index f77ecd60f43a..2aae23a813a0 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -334,24 +334,6 @@ int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain 
lnaGain)
}
 }
 
-enum lnaGain rf69_get_lna_gain(struct spi_device *spi)
-{
-   u8 currentValue;
-
-   currentValue = rf69_read_reg(spi, REG_LNA);
-
-   switch (currentValue & MASK_LNA_CURRENT_GAIN >> 3) { // improvement: 
change 3 to define
-   case LNA_GAIN_AUTO: return automatic;
-   case LNA_GAIN_MAX:  return max;
-   case LNA_GAIN_MAX_MINUS_6:  return maxMinus6;
-   case LNA_GAIN_MAX_MINUS_12: return maxMinus12;
-   case LNA_GAIN_MAX_MINUS_24: return maxMinus24;
-   case LNA_GAIN_MAX_MINUS_36: return maxMinus36;
-   case LNA_GAIN_MAX_MINUS_48: return maxMinus48;
-   default:return undefined;
-   }
-}
-
 int rf69_set_dc_cut_off_frequency_intern(struct spi_device *spi, u8 reg, enum 
dccPercent dccPercent)
 {
switch (dccPercent) {
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index e8803241b13b..e8640b0ee33b 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -39,7 +39,6 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 
powerLevel);
 int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp);
 int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance 
antennaImpedance);
 int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain);
-enum lnaGain rf69_get_lna_gain(struct spi_device *spi);
 int rf69_set_dc_cut_off_frequency_intern(struct spi_device *spi, u8 reg, enum 
dccPercent dccPercent);
 int rf69_set_dc_cut_off_frequency(struct spi_device *spi, enum dccPercent 
dccPercent);
 int rf69_set_dc_cut_off_frequency_during_afc(struct spi_device *spi, enum 
dccPercent dccPercent);
-- 
2.15.0

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


Re: [PATCH 6/8 v3] staging: pi433: use defines for shifting register values

2017-12-14 Thread Dan Carpenter
You'll need to resend everything.  The thread is too messy.

On Wed, Dec 13, 2017 at 06:44:44PM +0100, Valentin Vidic wrote:
> diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
> index f77ecd60f43a..0889c65d5a31 100644
> --- a/drivers/staging/pi433/rf69.c
> +++ b/drivers/staging/pi433/rf69.c
> @@ -340,14 +340,13 @@ enum lnaGain rf69_get_lna_gain(struct spi_device *spi)

The rf69_get_lna_gain() function is never called.  Just delete it.

Also the enum lnaGain is just a pointless abstraction which complicates
the code needlessly.  It will be deleted eventually too.

regards,
dan carpenter

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


Re: [PATCH 04/10] staging: ccree: staging: ccree: replace sysfs by debugfs interface

2017-12-14 Thread Philippe Ombredanne
Gilad,

On Thu, Dec 14, 2017 at 3:02 PM, Gilad Ben-Yossef  wrote:
> The ccree driver has had a none standard sysfs interface for debugging.
> Replace it with a proper debugfs interface.
>
> Signed-off-by: Gilad Ben-Yossef 



> --- /dev/null
> +++ b/drivers/staging/ccree/cc_debugfs.c
> @@ -0,0 +1,114 @@
> +/*
> + * Copyright (C) 2012-2017 ARM Limited or its affiliates.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, see .
> + */

Could you use the new SPDX tags instead of this fine and long
boilerplate? See Thomas doc for details [1]

You could spare the world from ~14 lines of this fine legalese with this:

// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2012-2017 ARM Limited or its affiliates.

If you wonder about the C++ style comment, read Thomas doc patches [1]
and check the comments made on the list by Linus.

If you could spread the word out in your team too, this would be much welcomed!
Thanks!

[1] https://lkml.org/lkml/2017/12/4/934

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


[PATCH 10/10] staging: ccree: update TODO

2017-12-14 Thread Gilad Ben-Yossef
Update TODO with handling on sysfs -> debugfs transition

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/TODO | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/ccree/TODO b/drivers/staging/ccree/TODO
index f44edcd..6d8702b 100644
--- a/drivers/staging/ccree/TODO
+++ b/drivers/staging/ccree/TODO
@@ -6,6 +6,5 @@
 *  *
 *
 
-1. Migrate sysfs to debugfs.
-2. Handle HW FIFO fullness more cleanly.
+1. Handle HW FIFO fullness more cleanly.
 
-- 
2.7.4

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


[PATCH 09/10] staging: ccree: fix fips event irq handling build

2017-12-14 Thread Gilad Ben-Yossef
When moving from internal for kernel FIPS infrastructure the FIPS event irq
handling code was left with the old ifdef by mistake. Fix it.

Fixes: b7e607bf33a2 ("staging: ccree: move FIPS support to kernel 
infrastructure")
Cc: sta...@vger.kernel.org
Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/ssi_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ccree/ssi_driver.c 
b/drivers/staging/ccree/ssi_driver.c
index df6d415..56b5d45 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -123,7 +123,7 @@ static irqreturn_t cc_isr(int irq, void *dev_id)
irr &= ~CC_COMP_IRQ_MASK;
complete_request(drvdata);
}
-#ifdef CC_SUPPORT_FIPS
+#ifdef CONFIG_CRYPTO_FIPS
/* TEE FIPS interrupt */
if (irr & CC_GPR0_IRQ_MASK) {
/* Mask interrupt - will be unmasked in Deferred service
-- 
2.7.4

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


[PATCH 07/10] staging: ccree: turn compile time debug log to params

2017-12-14 Thread Gilad Ben-Yossef
The ccree driver has some support to dump runtime data
to kernel log to assist in debugging. The code used to be
enabled by a build time flag. Refactor to enable it via
module/kernel parameters.

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/ssi_config.h  |  2 --
 drivers/staging/ccree/ssi_driver.c  | 18 --
 drivers/staging/ccree/ssi_driver.h  | 16 ++--
 drivers/staging/ccree/ssi_request_mgr.c | 26 +-
 4 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/ccree/ssi_config.h 
b/drivers/staging/ccree/ssi_config.h
index b530974..bc90ad0 100644
--- a/drivers/staging/ccree/ssi_config.h
+++ b/drivers/staging/ccree/ssi_config.h
@@ -23,8 +23,6 @@
 
 #include 
 
-//#define CC_DUMP_DESCS
-// #define CC_DUMP_BYTES
 /* was 32 bit, but for juno's sake it was enlarged to 48 bit */
 #define DMA_BIT_MASK_LEN   48
 
diff --git a/drivers/staging/ccree/ssi_driver.c 
b/drivers/staging/ccree/ssi_driver.c
index dbca241..195fb27 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -72,20 +72,26 @@
 #include "ssi_pm.h"
 #include "ssi_fips.h"
 
-#ifdef CC_DUMP_BYTES
-void dump_byte_array(const char *name, const u8 *buf, size_t len)
+bool cc_dump_desc;
+module_param_named(dump_desc, cc_dump_desc, bool, 0600);
+MODULE_PARM_DESC(cc_dump_desc, "Dump descriptors to kernel log as debugging 
aid");
+
+bool cc_dump_bytes;
+module_param_named(dump_bytes, cc_dump_bytes, bool, 0600);
+MODULE_PARM_DESC(cc_dump_bytes, "Dump buffers to kernel log as debugging aid");
+
+void __dump_byte_array(const char *name, const u8 *buf, size_t len)
 {
-   char prefix[NAME_LEN];
+   char prefix[64];
 
if (!buf)
return;
 
snprintf(prefix, sizeof(prefix), "%s[%lu]: ", name, len);
 
-   print_hex_dump(KERN_DEBUG, prefix, DUMP_PREFIX_ADDRESS, 16, 1, len,
-  false);
+   print_hex_dump(KERN_DEBUG, prefix, DUMP_PREFIX_ADDRESS, 16, 1, buf,
+  len, false);
 }
-#endif
 
 static irqreturn_t cc_isr(int irq, void *dev_id)
 {
diff --git a/drivers/staging/ccree/ssi_driver.h 
b/drivers/staging/ccree/ssi_driver.h
index 4e05386..12e2a8b 100644
--- a/drivers/staging/ccree/ssi_driver.h
+++ b/drivers/staging/ccree/ssi_driver.h
@@ -48,6 +48,9 @@
 #include "cc_hw_queue_defs.h"
 #include "ssi_sram_mgr.h"
 
+extern bool cc_dump_desc;
+extern bool cc_dump_bytes;
+
 #define DRV_MODULE_VERSION "3.0"
 
 #define CC_DEV_NAME_STR "cc715ree"
@@ -169,13 +172,14 @@ static inline struct device *drvdata_to_dev(struct 
cc_drvdata *drvdata)
return >plat_dev->dev;
 }
 
-#ifdef CC_DUMP_BYTES
-void dump_byte_array(const char *name, const u8 *the_array,
-unsigned long size);
-#else
+void __dump_byte_array(const char *name, const u8 *the_array,
+  unsigned long size);
 static inline void dump_byte_array(const char *name, const u8 *the_array,
-  unsigned long size) {};
-#endif
+  unsigned long size)
+{
+   if (cc_dump_bytes)
+   __dump_byte_array(name, the_array, size);
+}
 
 int init_cc_regs(struct cc_drvdata *drvdata, bool is_probe);
 void fini_cc_regs(struct cc_drvdata *drvdata);
diff --git a/drivers/staging/ccree/ssi_request_mgr.c 
b/drivers/staging/ccree/ssi_request_mgr.c
index f6374b0..2aa21f8 100644
--- a/drivers/staging/ccree/ssi_request_mgr.c
+++ b/drivers/staging/ccree/ssi_request_mgr.c
@@ -161,11 +161,12 @@ int cc_req_mgr_init(struct cc_drvdata *drvdata)
return rc;
 }
 
-static void enqueue_seq(void __iomem *cc_base, struct cc_hw_desc seq[],
+static void enqueue_seq(struct cc_drvdata *drvdata, struct cc_hw_desc seq[],
unsigned int seq_len)
 {
int i, w;
-   void * __iomem reg = cc_base + CC_REG(DSCRPTR_QUEUE_WORD0);
+   void * __iomem reg = drvdata->cc_base + CC_REG(DSCRPTR_QUEUE_WORD0);
+   struct device *dev = drvdata_to_dev(drvdata);
 
/*
 * We do indeed write all 6 command words to the same
@@ -175,11 +176,12 @@ static void enqueue_seq(void __iomem *cc_base, struct 
cc_hw_desc seq[],
for (i = 0; i < seq_len; i++) {
for (w = 0; w <= 5; w++)
writel_relaxed(seq[i].word[w], reg);
-#ifdef CC_DUMP_DESCS
-   dev_dbg(dev, "desc[%02d]: 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 
0x%08X\n",
-   i, seq[i].word[0], seq[i].word[1], seq[i].word[2],
-   seq[i].word[3], seq[i].word[4], seq[i].word[5]);
-#endif
+
+   if (cc_dump_desc)
+   dev_dbg(dev, "desc[%02d]: 0x%08X 0x%08X 0x%08X 0x%08X 
0x%08X 0x%08X\n",
+   i, seq[i].word[0], seq[i].word[1],
+   seq[i].word[2], seq[i].word[3],
+   seq[i].word[4], seq[i].word[5]);
}
 }
 
@@ -256,7 +258,6 @@ 

[PATCH 08/10] staging: ccree: remove ssi_config.h

2017-12-14 Thread Gilad Ben-Yossef
Now that the only thing left in ssi_config is the maximum
DMA mask length we get move that to ssi_driver.h and get
rid of the file.

All of ccree is now runtime configurable or under Kbuild control.

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/cc_debugfs.c  |  1 -
 drivers/staging/ccree/ssi_aead.c|  1 -
 drivers/staging/ccree/ssi_buffer_mgr.h  |  1 -
 drivers/staging/ccree/ssi_cipher.c  |  1 -
 drivers/staging/ccree/ssi_config.h  | 30 --
 drivers/staging/ccree/ssi_driver.c  |  1 -
 drivers/staging/ccree/ssi_driver.h  |  4 +++-
 drivers/staging/ccree/ssi_fips.c|  1 -
 drivers/staging/ccree/ssi_hash.c|  1 -
 drivers/staging/ccree/ssi_ivgen.c   |  1 -
 drivers/staging/ccree/ssi_pm.c  |  1 -
 drivers/staging/ccree/ssi_pm.h  |  1 -
 drivers/staging/ccree/ssi_request_mgr.c |  1 -
 13 files changed, 3 insertions(+), 42 deletions(-)
 delete mode 100644 drivers/staging/ccree/ssi_config.h

diff --git a/drivers/staging/ccree/cc_debugfs.c 
b/drivers/staging/ccree/cc_debugfs.c
index 7768a7b..7cd33957 100644
--- a/drivers/staging/ccree/cc_debugfs.c
+++ b/drivers/staging/ccree/cc_debugfs.c
@@ -17,7 +17,6 @@
 #include 
 #include 
 #include 
-#include "ssi_config.h"
 #include "ssi_driver.h"
 #include "cc_crypto_ctx.h"
 
diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index ce26e68..1522b00 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -28,7 +28,6 @@
 #include 
 #include 
 #include 
-#include "ssi_config.h"
 #include "ssi_driver.h"
 #include "ssi_buffer_mgr.h"
 #include "ssi_aead.h"
diff --git a/drivers/staging/ccree/ssi_buffer_mgr.h 
b/drivers/staging/ccree/ssi_buffer_mgr.h
index da43354..395c93f 100644
--- a/drivers/staging/ccree/ssi_buffer_mgr.h
+++ b/drivers/staging/ccree/ssi_buffer_mgr.h
@@ -23,7 +23,6 @@
 
 #include 
 
-#include "ssi_config.h"
 #include "ssi_driver.h"
 
 enum cc_req_dma_buf_type {
diff --git a/drivers/staging/ccree/ssi_cipher.c 
b/drivers/staging/ccree/ssi_cipher.c
index f940568..86800a7 100644
--- a/drivers/staging/ccree/ssi_cipher.c
+++ b/drivers/staging/ccree/ssi_cipher.c
@@ -26,7 +26,6 @@
 #include 
 #include 
 
-#include "ssi_config.h"
 #include "ssi_driver.h"
 #include "cc_lli_defs.h"
 #include "ssi_buffer_mgr.h"
diff --git a/drivers/staging/ccree/ssi_config.h 
b/drivers/staging/ccree/ssi_config.h
deleted file mode 100644
index bc90ad0..000
--- a/drivers/staging/ccree/ssi_config.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2012-2017 ARM Limited or its affiliates.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see .
- */
-
-/* \file ssi_config.h
- * Definitions for ARM CryptoCell Linux Crypto Driver
- */
-
-#ifndef __CC_CONFIG_H__
-#define __CC_CONFIG_H__
-
-#include 
-
-/* was 32 bit, but for juno's sake it was enlarged to 48 bit */
-#define DMA_BIT_MASK_LEN   48
-
-#endif /*__CC_CONFIG_H__*/
-
diff --git a/drivers/staging/ccree/ssi_driver.c 
b/drivers/staging/ccree/ssi_driver.c
index 195fb27..df6d415 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -59,7 +59,6 @@
 #include 
 #include 
 
-#include "ssi_config.h"
 #include "ssi_driver.h"
 #include "ssi_request_mgr.h"
 #include "ssi_buffer_mgr.h"
diff --git a/drivers/staging/ccree/ssi_driver.h 
b/drivers/staging/ccree/ssi_driver.h
index 12e2a8b..5a56f7a 100644
--- a/drivers/staging/ccree/ssi_driver.h
+++ b/drivers/staging/ccree/ssi_driver.h
@@ -21,7 +21,6 @@
 #ifndef __CC_DRIVER_H__
 #define __CC_DRIVER_H__
 
-#include "ssi_config.h"
 #ifdef COMP_IN_WQ
 #include 
 #else
@@ -56,6 +55,9 @@ extern bool cc_dump_bytes;
 #define CC_DEV_NAME_STR "cc715ree"
 #define CC_COHERENT_CACHE_PARAMS 0xEEE
 
+/* Maximum DMA mask supported by IP */
+#define DMA_BIT_MASK_LEN 48
+
 #define CC_AXI_IRQ_MASK ((1 << CC_AXIM_CFG_BRESPMASK_BIT_SHIFT) | \
  (1 << CC_AXIM_CFG_RRESPMASK_BIT_SHIFT) | \
  (1 << CC_AXIM_CFG_INFLTMASK_BIT_SHIFT) | \
diff --git a/drivers/staging/ccree/ssi_fips.c b/drivers/staging/ccree/ssi_fips.c
index a1d7782..9ca6857 100644
--- a/drivers/staging/ccree/ssi_fips.c
+++ b/drivers/staging/ccree/ssi_fips.c
@@ -17,7 +17,6 @@
 #include 
 #include 
 
-#include "ssi_config.h"
 #include "ssi_driver.h"
 #include "ssi_fips.h"
 
diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c
index 

[PATCH 03/10] staging: ccree: add explicit module init/exit func

2017-12-14 Thread Gilad Ben-Yossef
We need to do a module global scope init/exit operation to support
the debugfs interface we are about to introduce in the next patch,
so wean the module of the boiler plate saving macro as it will no
longer be sufficient.

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/ssi_driver.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/ccree/ssi_driver.c 
b/drivers/staging/ccree/ssi_driver.c
index ad02d92..5427c7f 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -517,7 +517,18 @@ static struct platform_driver cc7x_driver = {
.probe = cc7x_probe,
.remove = cc7x_remove,
 };
-module_platform_driver(cc7x_driver);
+
+static int __init ccree_init(void)
+{
+   return platform_driver_register(_driver);
+}
+module_init(ccree_init);
+
+static void __exit ccree_exit(void)
+{
+   platform_driver_unregister(_driver);
+}
+module_exit(ccree_exit);
 
 /* Module description */
 MODULE_DESCRIPTION("ARM TrustZone CryptoCell REE Driver");
-- 
2.7.4

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


[PATCH 04/10] staging: ccree: staging: ccree: replace sysfs by debugfs interface

2017-12-14 Thread Gilad Ben-Yossef
The ccree driver has had a none standard sysfs interface for debugging.
Replace it with a proper debugfs interface.

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/Makefile  |   3 +-
 drivers/staging/ccree/cc_debugfs.c  | 114 +++
 drivers/staging/ccree/cc_debugfs.h  |  45 
 drivers/staging/ccree/ssi_aead.c|   1 -
 drivers/staging/ccree/ssi_cipher.c  |   1 -
 drivers/staging/ccree/ssi_config.h  |   2 -
 drivers/staging/ccree/ssi_driver.c  |  27 ++---
 drivers/staging/ccree/ssi_driver.h  |   2 +-
 drivers/staging/ccree/ssi_hash.c|   1 -
 drivers/staging/ccree/ssi_pm.c  |   1 -
 drivers/staging/ccree/ssi_request_mgr.c |   1 -
 drivers/staging/ccree/ssi_sysfs.c   | 192 
 drivers/staging/ccree/ssi_sysfs.h   |  32 --
 13 files changed, 176 insertions(+), 246 deletions(-)
 create mode 100644 drivers/staging/ccree/cc_debugfs.c
 create mode 100644 drivers/staging/ccree/cc_debugfs.h
 delete mode 100644 drivers/staging/ccree/ssi_sysfs.c
 delete mode 100644 drivers/staging/ccree/ssi_sysfs.h

diff --git a/drivers/staging/ccree/Makefile b/drivers/staging/ccree/Makefile
index ae702f3..ab9f073 100644
--- a/drivers/staging/ccree/Makefile
+++ b/drivers/staging/ccree/Makefile
@@ -1,3 +1,4 @@
 obj-$(CONFIG_CRYPTO_DEV_CCREE) := ccree.o
-ccree-y := ssi_driver.o ssi_sysfs.o ssi_buffer_mgr.o ssi_request_mgr.o 
ssi_cipher.o ssi_hash.o ssi_aead.o ssi_ivgen.o ssi_sram_mgr.o ssi_pm.o
+ccree-y := ssi_driver.o ssi_buffer_mgr.o ssi_request_mgr.o ssi_cipher.o 
ssi_hash.o ssi_aead.o ssi_ivgen.o ssi_sram_mgr.o ssi_pm.o
 ccree-$(CONFIG_CRYPTO_FIPS) += ssi_fips.o
+ccree-$(CONFIG_DEBUG_FS) += cc_debugfs.o
diff --git a/drivers/staging/ccree/cc_debugfs.c 
b/drivers/staging/ccree/cc_debugfs.c
new file mode 100644
index 000..7768a7b
--- /dev/null
+++ b/drivers/staging/ccree/cc_debugfs.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2012-2017 ARM Limited or its affiliates.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see .
+ */
+
+#include 
+#include 
+#include 
+#include "ssi_config.h"
+#include "ssi_driver.h"
+#include "cc_crypto_ctx.h"
+
+struct cc_debugfs_ctx {
+   struct dentry *dir;
+};
+
+#define CC_DEBUG_REG(_X) { \
+   .name = __stringify(_X),\
+   .offset = CC_REG(_X)\
+   }
+
+/*
+ * This is a global var for the dentry of the
+ * debugfs ccree/ dir. It is not tied down to
+ * a specific instance of ccree, hence it is
+ * global.
+ */
+static struct dentry *cc_debugfs_dir;
+
+struct debugfs_reg32 debug_regs[] = {
+   CC_DEBUG_REG(HOST_SIGNATURE),
+   CC_DEBUG_REG(HOST_IRR),
+   CC_DEBUG_REG(HOST_POWER_DOWN_EN),
+   CC_DEBUG_REG(AXIM_MON_ERR),
+   CC_DEBUG_REG(DSCRPTR_QUEUE_CONTENT),
+   CC_DEBUG_REG(HOST_IMR),
+   CC_DEBUG_REG(AXIM_CFG),
+   CC_DEBUG_REG(AXIM_CACHE_PARAMS),
+   CC_DEBUG_REG(HOST_VERSION),
+   CC_DEBUG_REG(GPR_HOST),
+   CC_DEBUG_REG(AXIM_MON_COMP),
+};
+
+int cc_debugfs_global_init(void)
+{
+   cc_debugfs_dir = debugfs_create_dir("ccree", NULL);
+
+   return !cc_debugfs_dir;
+}
+
+void cc_debugfs_global_fini(void)
+{
+   debugfs_remove(cc_debugfs_dir);
+}
+
+int cc_debugfs_init(struct cc_drvdata *drvdata)
+{
+   struct device *dev = drvdata_to_dev(drvdata);
+   struct cc_debugfs_ctx *ctx;
+   struct debugfs_regset32 *regset;
+   struct dentry *file;
+
+   ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
+   if (!ctx)
+   return -ENOMEM;
+
+   regset = devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL);
+   if (!regset)
+   return -ENOMEM;
+
+   regset->regs = debug_regs;
+   regset->nregs = ARRAY_SIZE(debug_regs);
+   regset->base = drvdata->cc_base;
+
+   ctx->dir = debugfs_create_dir(drvdata->plat_dev->name, cc_debugfs_dir);
+   if (!ctx->dir)
+   return -ENFILE;
+
+   file = debugfs_create_regset32("regs", 0400, ctx->dir, regset);
+   if (!file) {
+   debugfs_remove(ctx->dir);
+   return -ENFILE;
+   }
+
+   file = debugfs_create_bool("coherent", 0400, ctx->dir,
+  >coherent);
+
+   if (!file) {
+   debugfs_remove_recursive(ctx->dir);
+   return -ENFILE;
+   }
+
+   drvdata->debugfs = ctx;
+
+   return 0;
+}
+
+void cc_debugfs_fini(struct cc_drvdata 

[PATCH 00/10] staging: ccree: cleanups & fixes

2017-12-14 Thread Gilad Ben-Yossef
- More cleanups and dead code removal.
- Handle TODO item of moving none standard sysfs interface
  to debugfs
- One fix to FIPS event irq handling code

Gilad Ben-Yossef (10):
  staging: ccree: drop ifdef CONFIG_OF in code
  staging: ccree: clean up PM registration
  staging: ccree: add explicit module init/exit func
  staging: ccree: staging: ccree: replace sysfs by debugfs interface
  staging: ccree: remove CC_IRQ_DELAY dead code
  staging: ccree: remove useless debug code
  staging: ccree: turn compile time debug log to params
  staging: ccree: remove ssi_config.h
  staging: ccree: fix fips event irq handling build
  staging: ccree: update TODO

 drivers/staging/ccree/Makefile  |   3 +-
 drivers/staging/ccree/TODO  |   3 +-
 drivers/staging/ccree/cc_debugfs.c  | 113 +++
 drivers/staging/ccree/cc_debugfs.h  |  45 
 drivers/staging/ccree/ssi_aead.c|  47 
 drivers/staging/ccree/ssi_buffer_mgr.h  |   1 -
 drivers/staging/ccree/ssi_cipher.c  |   2 -
 drivers/staging/ccree/ssi_config.h  |  38 ---
 drivers/staging/ccree/ssi_driver.c  | 103 +++--
 drivers/staging/ccree/ssi_driver.h  |  22 ++--
 drivers/staging/ccree/ssi_fips.c|   1 -
 drivers/staging/ccree/ssi_hash.c|   2 -
 drivers/staging/ccree/ssi_ivgen.c   |   1 -
 drivers/staging/ccree/ssi_pm.c  |   6 +-
 drivers/staging/ccree/ssi_pm.h  |   4 +-
 drivers/staging/ccree/ssi_request_mgr.c |  51 +++--
 drivers/staging/ccree/ssi_sysfs.c   | 192 
 drivers/staging/ccree/ssi_sysfs.h   |  32 --
 18 files changed, 236 insertions(+), 430 deletions(-)
 create mode 100644 drivers/staging/ccree/cc_debugfs.c
 create mode 100644 drivers/staging/ccree/cc_debugfs.h
 delete mode 100644 drivers/staging/ccree/ssi_config.h
 delete mode 100644 drivers/staging/ccree/ssi_sysfs.c
 delete mode 100644 drivers/staging/ccree/ssi_sysfs.h

-- 
2.7.4

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


[PATCH 06/10] staging: ccree: remove useless debug code

2017-12-14 Thread Gilad Ben-Yossef
Remove a bunch of useless debug code ifdef'ed out

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/ssi_aead.c| 45 -
 drivers/staging/ccree/ssi_config.h  |  3 ---
 drivers/staging/ccree/ssi_driver.c  | 13 --
 drivers/staging/ccree/ssi_request_mgr.c | 23 -
 4 files changed, 84 deletions(-)

diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index dde6797..ce26e68 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -1834,51 +1834,6 @@ static int cc_gcm(struct aead_request *req, struct 
cc_hw_desc desc[],
return 0;
 }
 
-#ifdef CC_DEBUG
-static void cc_dump_gcm(const char *title, struct aead_request *req)
-{
-   struct crypto_aead *tfm = crypto_aead_reqtfm(req);
-   struct cc_aead_ctx *ctx = crypto_aead_ctx(tfm);
-   struct aead_req_ctx *req_ctx = aead_request_ctx(req);
-
-   if (ctx->cipher_mode != DRV_CIPHER_GCTR)
-   return;
-
-   if (title) {
-   dev_dbg(dev, 
"--");
-   dev_dbg(dev, "%s\n", title);
-   }
-
-   dev_dbg(dev, "cipher_mode %d, authsize %d, enc_keylen %d, assoclen %d, 
cryptlen %d\n",
-   ctx->cipher_mode, ctx->authsize, ctx->enc_keylen,
-   req->assoclen, req_ctx->cryptlen);
-
-   if (ctx->enckey)
-   dump_byte_array("mac key", ctx->enckey, 16);
-
-   dump_byte_array("req->iv", req->iv, AES_BLOCK_SIZE);
-
-   dump_byte_array("gcm_iv_inc1", req_ctx->gcm_iv_inc1, AES_BLOCK_SIZE);
-
-   dump_byte_array("gcm_iv_inc2", req_ctx->gcm_iv_inc2, AES_BLOCK_SIZE);
-
-   dump_byte_array("hkey", req_ctx->hkey, AES_BLOCK_SIZE);
-
-   dump_byte_array("mac_buf", req_ctx->mac_buf, AES_BLOCK_SIZE);
-
-   dump_byte_array("gcm_len_block", req_ctx->gcm_len_block.len_a,
-   AES_BLOCK_SIZE);
-
-   if (req->src && req->cryptlen)
-   dump_byte_array("req->src", sg_virt(req->src),
-   req->cryptlen + req->assoclen);
-
-   if (req->dst)
-   dump_byte_array("req->dst", sg_virt(req->dst),
-   req->cryptlen + ctx->authsize + req->assoclen);
-}
-#endif
-
 static int config_gcm_context(struct aead_request *req)
 {
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
diff --git a/drivers/staging/ccree/ssi_config.h 
b/drivers/staging/ccree/ssi_config.h
index e809103..b530974 100644
--- a/drivers/staging/ccree/ssi_config.h
+++ b/drivers/staging/ccree/ssi_config.h
@@ -23,11 +23,8 @@
 
 #include 
 
-//#define FLUSH_CACHE_ALL
-//#define COMPLETION_DELAY
 //#define CC_DUMP_DESCS
 // #define CC_DUMP_BYTES
-// #define CC_DEBUG
 /* was 32 bit, but for juno's sake it was enlarged to 48 bit */
 #define DMA_BIT_MASK_LEN   48
 
diff --git a/drivers/staging/ccree/ssi_driver.c 
b/drivers/staging/ccree/ssi_driver.c
index 6158794..dbca241 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -446,19 +446,6 @@ static int cc7x_probe(struct platform_device *plat_dev)
 {
int rc;
struct device *dev = _dev->dev;
-#if defined(CONFIG_ARM) && defined(CC_DEBUG)
-   u32 ctr, cacheline_size;
-
-   asm volatile("mrc p15, 0, %0, c0, c0, 1" : "=r" (ctr));
-   cacheline_size =  4 << ((ctr >> 16) & 0xf);
-   dev_dbg(dev, "CP15(L1_CACHE_BYTES) = %u , Kconfig(L1_CACHE_BYTES) = 
%u\n",
-   cacheline_size, L1_CACHE_BYTES);
-
-   asm volatile("mrc p15, 0, %0, c0, c0, 0" : "=r" (ctr));
-   dev_dbg(dev, "Main ID register (MIDR): Implementer 0x%02X, Arch 0x%01X, 
Part 0x%03X, Rev r%dp%d\n",
-   (ctr >> 24), (ctr >> 16) & 0xF, (ctr >> 4) & 0xFFF,
-   (ctr >> 20) & 0xF, ctr & 0xF);
-#endif
 
/* Map registers space */
rc = init_cc_resources(plat_dev);
diff --git a/drivers/staging/ccree/ssi_request_mgr.c 
b/drivers/staging/ccree/ssi_request_mgr.c
index 07b9404..f6374b0 100644
--- a/drivers/staging/ccree/ssi_request_mgr.c
+++ b/drivers/staging/ccree/ssi_request_mgr.c
@@ -20,9 +20,6 @@
 #include 
 #include 
 #include 
-#ifdef FLUSH_CACHE_ALL
-#include 
-#endif
 #include 
 #include "ssi_driver.h"
 #include "ssi_buffer_mgr.h"
@@ -359,9 +356,6 @@ int send_request(struct cc_drvdata *drvdata, struct 
cc_crypto_req *cc_req,
 
dev_dbg(dev, "Enqueue request head=%u\n", req_mgr_h->req_queue_head);
 
-#ifdef FLUSH_CACHE_ALL
-   flush_cache_all();
-#endif
/*
 * We are about to push command to the HW via the command registers
 * that may refernece hsot memory. We need to issue a memory barrier
@@ -493,23 +487,6 @@ static void proc_completions(struct cc_drvdata *drvdata)
 
cc_req = _mgr_handle->req_queue[*tail];
 
-#ifdef FLUSH_CACHE_ALL
-   flush_cache_all();
-#endif
-
-#ifdef COMPLETION_DELAY
-

[PATCH 05/10] staging: ccree: remove CC_IRQ_DELAY dead code

2017-12-14 Thread Gilad Ben-Yossef
Remove dead code from older version which is not supported in current
hardware.

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/ssi_config.h |  1 -
 drivers/staging/ccree/ssi_driver.c | 11 ---
 2 files changed, 12 deletions(-)

diff --git a/drivers/staging/ccree/ssi_config.h 
b/drivers/staging/ccree/ssi_config.h
index 15725cc..e809103 100644
--- a/drivers/staging/ccree/ssi_config.h
+++ b/drivers/staging/ccree/ssi_config.h
@@ -28,7 +28,6 @@
 //#define CC_DUMP_DESCS
 // #define CC_DUMP_BYTES
 // #define CC_DEBUG
-//#define CC_IRQ_DELAY 10
 /* was 32 bit, but for juno's sake it was enlarged to 48 bit */
 #define DMA_BIT_MASK_LEN   48
 
diff --git a/drivers/staging/ccree/ssi_driver.c 
b/drivers/staging/ccree/ssi_driver.c
index 14705dc..6158794 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -171,17 +171,6 @@ int init_cc_regs(struct cc_drvdata *drvdata, bool is_probe)
   CC_GPR0_IRQ_MASK));
cc_iowrite(drvdata, CC_REG(HOST_IMR), val);
 
-#ifdef CC_HOST_IRQ_TIMER_INIT_VAL_REG_OFFSET
-#ifdef CC_IRQ_DELAY
-   /* Set CC IRQ delay */
-   cc_iowrite(drvdata, CC_REG(HOST_IRQ_TIMER_INIT_VAL), CC_IRQ_DELAY);
-#endif
-   if (cc_ioread(drvdata, CC_REG(HOST_IRQ_TIMER_INIT_VAL)) > 0) {
-   dev_dbg(dev, "irq_delay=%d CC cycles\n",
-   cc_ioread(drvdata, CC_REG(HOST_IRQ_TIMER_INIT_VAL)));
-   }
-#endif
-
cache_params = (drvdata->coherent ? CC_COHERENT_CACHE_PARAMS : 0x0);
 
val = cc_ioread(drvdata, CC_REG(AXIM_CACHE_PARAMS));
-- 
2.7.4

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


[PATCH 02/10] staging: ccree: clean up PM registration

2017-12-14 Thread Gilad Ben-Yossef
Clean up power management registration.

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/ssi_driver.c | 16 +++-
 drivers/staging/ccree/ssi_pm.c |  4 
 drivers/staging/ccree/ssi_pm.h |  3 +++
 3 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/ccree/ssi_driver.c 
b/drivers/staging/ccree/ssi_driver.c
index fbf0338..ad02d92 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -500,18 +500,6 @@ static int cc7x_remove(struct platform_device *plat_dev)
return 0;
 }
 
-#if defined(CONFIG_PM)
-static const struct dev_pm_ops arm_cc7x_driver_pm = {
-   SET_RUNTIME_PM_OPS(cc_pm_suspend, cc_pm_resume, NULL)
-};
-#endif
-
-#if defined(CONFIG_PM)
-#defineCC_DRIVER_RUNTIME_PM(_cc7x_driver_pm)
-#else
-#defineCC_DRIVER_RUNTIME_PMNULL
-#endif
-
 static const struct of_device_id arm_cc7x_dev_of_match[] = {
{.compatible = "arm,cryptocell-712-ree"},
{}
@@ -522,7 +510,9 @@ static struct platform_driver cc7x_driver = {
.driver = {
   .name = "cc7xree",
   .of_match_table = arm_cc7x_dev_of_match,
-  .pm = CC_DRIVER_RUNTIME_PM,
+#ifdef CONFIG_PM
+  .pm = _pm,
+#endif
},
.probe = cc7x_probe,
.remove = cc7x_remove,
diff --git a/drivers/staging/ccree/ssi_pm.c b/drivers/staging/ccree/ssi_pm.c
index 3c4892b..0db935d 100644
--- a/drivers/staging/ccree/ssi_pm.c
+++ b/drivers/staging/ccree/ssi_pm.c
@@ -34,6 +34,10 @@
 #define POWER_DOWN_ENABLE 0x01
 #define POWER_DOWN_DISABLE 0x00
 
+const struct dev_pm_ops ccree_pm = {
+   SET_RUNTIME_PM_OPS(cc_pm_suspend, cc_pm_resume, NULL)
+};
+
 int cc_pm_suspend(struct device *dev)
 {
struct cc_drvdata *drvdata = dev_get_drvdata(dev);
diff --git a/drivers/staging/ccree/ssi_pm.h b/drivers/staging/ccree/ssi_pm.h
index a5f2b1b..91140a3 100644
--- a/drivers/staging/ccree/ssi_pm.h
+++ b/drivers/staging/ccree/ssi_pm.h
@@ -30,6 +30,9 @@ int cc_pm_init(struct cc_drvdata *drvdata);
 void cc_pm_fini(struct cc_drvdata *drvdata);
 
 #if defined(CONFIG_PM)
+
+extern const struct dev_pm_ops ccree_pm;
+
 int cc_pm_suspend(struct device *dev);
 
 int cc_pm_resume(struct device *dev);
-- 
2.7.4

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


[PATCH 01/10] staging: ccree: drop ifdef CONFIG_OF in code

2017-12-14 Thread Gilad Ben-Yossef
As we already depend on CONFIG_OF via Kconfig no need to
support conditional build without it.

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/ssi_driver.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/ccree/ssi_driver.c 
b/drivers/staging/ccree/ssi_driver.c
index 28cfbb4..fbf0338 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -512,20 +512,16 @@ static const struct dev_pm_ops arm_cc7x_driver_pm = {
 #defineCC_DRIVER_RUNTIME_PMNULL
 #endif
 
-#ifdef CONFIG_OF
 static const struct of_device_id arm_cc7x_dev_of_match[] = {
{.compatible = "arm,cryptocell-712-ree"},
{}
 };
 MODULE_DEVICE_TABLE(of, arm_cc7x_dev_of_match);
-#endif
 
 static struct platform_driver cc7x_driver = {
.driver = {
   .name = "cc7xree",
-#ifdef CONFIG_OF
   .of_match_table = arm_cc7x_dev_of_match,
-#endif
   .pm = CC_DRIVER_RUNTIME_PM,
},
.probe = cc7x_probe,
-- 
2.7.4

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


Re: [PATCH v2] staging: comedi: ni_*: Fix style warnings.

2017-12-14 Thread Joe Perches
On Thu, 2017-12-14 at 00:27 -0600, Aniruddha Shastri wrote:
> Three of these warnings are now line-too-long warnings. I think these 
> warnings are preferable to the ones listed below. The longest line 
> is only 87 chars wide, which is reasonable.
[]
> diff --git a/drivers/staging/comedi/drivers/ni_670x.c 
> b/drivers/staging/comedi/drivers/ni_670x.c
[]
> @@ -209,7 +209,7 @@ static int ni_670x_auto_attach(struct comedi_device *dev,
>   const struct comedi_lrange **range_table_list;
>  
>   range_table_list = kmalloc_array(32,
> -  sizeof(struct comedi_lrange *),
> +  sizeof(const struct 
> comedi_lrange *),

Adding const to a sizeof is unnecessary

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


Re: [PATCH] drivers/staging/greybus: fix max dup length for kstrndup

2017-12-14 Thread Rui Miguel Silva
Hi Ma,
Thanks for your patch.

Please make sure you use scripts/get_maintainer.pl so that your patches
goes to the right lists and people. I CC's them now. ;)


On Tue 12 Dec 2017 at 09:25, Ma Shimiao wrote:
> If source string longer than max, kstrndup will alloc max+1 space.
> So, we should make sure the result will not over limit.

I think we are good here. kstrndup alloc memory for us the max+1, and
in fact we want to have the 32 chars plus the \0 set by kstrndup.

So, I think the code as is now is ok.

---
Cheers,
Rui

>
> Signed-off-by: Ma Shimiao 
> ---
>  drivers/staging/greybus/light.c|  9 ++---
>  drivers/staging/greybus/power_supply.c | 10 ++
>  2 files changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
> index 010ae1e9c7fb..c7ac2ead5a07 100644
> --- a/drivers/staging/greybus/light.c
> +++ b/drivers/staging/greybus/light.c
> @@ -965,10 +965,12 @@ static int gb_lights_channel_config(struct gb_light 
> *light,
>   channel->mode = le32_to_cpu(conf.mode);
>   channel->flags = le32_to_cpu(conf.flags);
>   channel->color = le32_to_cpu(conf.color);
> - channel->color_name = kstrndup(conf.color_name, NAMES_MAX, GFP_KERNEL);
> + channel->color_name = kstrndup(conf.color_name,
> +NAMES_MAX - 1, GFP_KERNEL);
>   if (!channel->color_name)
>   return -ENOMEM;
> - channel->mode_name = kstrndup(conf.mode_name, NAMES_MAX, GFP_KERNEL);
> + channel->mode_name = kstrndup(conf.mode_name,
> +   NAMES_MAX - 1, GFP_KERNEL);
>   if (!channel->mode_name)
>   return -ENOMEM;
>  
> @@ -1027,7 +1029,8 @@ static int gb_lights_light_config(struct gb_lights 
> *glights, u8 id)
>   return -EINVAL;
>  
>   light->channels_count = conf.channel_count;
> - light->name = kstrndup(conf.name, NAMES_MAX, GFP_KERNEL);
> + light->name = kstrndup(conf.name,
> +NAMES_MAX - 1, GFP_KERNEL);
>  
>   light->channels = kcalloc(light->channels_count,
> sizeof(struct gb_channel), GFP_KERNEL);
> diff --git a/drivers/staging/greybus/power_supply.c 
> b/drivers/staging/greybus/power_supply.c
> index 0529e5628c24..7bc76633866b 100644
> --- a/drivers/staging/greybus/power_supply.c
> +++ b/drivers/staging/greybus/power_supply.c
> @@ -487,14 +487,16 @@ static int gb_power_supply_description_get(struct 
> gb_power_supply *gbpsy)
>   if (ret < 0)
>   return ret;
>  
> - gbpsy->manufacturer = kstrndup(resp.manufacturer, PROP_MAX, GFP_KERNEL);
> + gbpsy->manufacturer = kstrndup(resp.manufacturer,
> +PROP_MAX - 1, GFP_KERNEL);
>   if (!gbpsy->manufacturer)
>   return -ENOMEM;
> - gbpsy->model_name = kstrndup(resp.model, PROP_MAX, GFP_KERNEL);
> + gbpsy->model_name = kstrndup(resp.model,
> +  PROP_MAX - 1, GFP_KERNEL);
>   if (!gbpsy->model_name)
>   return -ENOMEM;
> - gbpsy->serial_number = kstrndup(resp.serial_number, PROP_MAX,
> -GFP_KERNEL);
> + gbpsy->serial_number = kstrndup(resp.serial_number,
> + PROP_MAX - 1, GFP_KERNEL);
>   if (!gbpsy->serial_number)
>   return -ENOMEM;

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