[PATCH] staging: bcm2835-audio: Disconnect and free vchi_instance on module_exit()

2018-04-16 Thread Kirill Marinushkin
In the current implementation, vchi_instance is inited during the first
call of bcm2835_audio_open_connection(), and is never freed. It causes a
memory leak when the module `snd_bcm2835` is removed.

Here is how this commit fixes it:

* the VCHI context (including vchi_instance) is created once in the
  platform's devres
* the VCHI context is allocated and connected once during module_init()
* all created bcm2835_chips have a pointer to this VCHI context
* bcm2835_audio_open_connection() can access the VCHI context through the
  associated bcm2835_chip
* the VCHI context is disconnected and freed once during module_exit()

After this commit is applied, I don't see other issues with the module's
init/exit, so I also remove the associated TODO task.

Steps to reproduce the memory leak before this commit:


root@raspberrypi:/home/pi# aplay test0.wav
Playing WAVE 'test0.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Ster
^CAborted by signal Interrupt...
root@raspberrypi:/home/pi# rmmod snd_bcm2835
root@raspberrypi:/home/pi# modprobe snd_bcm2835
root@raspberrypi:/home/pi# aplay test0.wav
Playing WAVE 'test0.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Ster
^CAborted by signal Interrupt...
root@raspberrypi:/home/pi# echo scan > /sys/kernel/debug/kmemleak
root@raspberrypi:/home/pi# cat /sys/kernel/debug/kmemleak
unreferenced object 0xb6794c00 (size 128):
  comm "aplay", pid 406, jiffies 36870 (age 116.650s)
  hex dump (first 32 bytes):
08 a5 82 81 01 00 00 00 08 4c 79 b6 08 4c 79 b6  .Ly..Ly.
00 00 00 00 00 00 00 00 ad 4e ad de ff ff ff ff  .N..
  backtrace:
[<802af5e0>] kmem_cache_alloc_trace+0x294/0x3d0
[<806ce620>] vchiq_initialise+0x98/0x1b0
[<806d0b34>] vchi_initialise+0x24/0x34
[<7f1311ec>] 0x7f1311ec
[<7f1303bc>] 0x7f1303bc
[<7f130590>] 0x7f130590
[<7f111fd8>] snd_pcm_open_substream+0x68/0xc4 [snd_pcm]
[<7f112108>] snd_pcm_open+0xd4/0x248 [snd_pcm]
[<7f112334>] snd_pcm_playback_open+0x4c/0x6c [snd_pcm]
[<7f0e250c>] snd_open+0xa8/0x14c [snd]
[<802ce590>] chrdev_open+0xac/0x188
[<802c57b4>] do_dentry_open+0x10c/0x314
[<802c6ba8>] vfs_open+0x5c/0x88
[<802d9a68>] path_openat+0x368/0x944
[<802dacd4>] do_filp_open+0x70/0xc4
[<802c6f70>] do_sys_open+0x110/0x1d4


Signed-off-by: Kirill Marinushkin 
Cc: Eric Anholt 
Cc: Stefan Wahren 
Cc: Greg Kroah-Hartman 
Cc: Florian Fainelli 
Cc: Ray Jui 
Cc: Scott Branden 
Cc: Andy Shevchenko 
Cc: bcm-kernel-feedback-l...@broadcom.com
Cc: linux-rpi-ker...@lists.infradead.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: de...@driverdev.osuosl.org
Cc: linux-ker...@vger.kernel.org
---
 .../vc04_services/bcm2835-audio/bcm2835-vchiq.c| 64 +-
 .../staging/vc04_services/bcm2835-audio/bcm2835.c  | 43 ++-
 .../staging/vc04_services/bcm2835-audio/bcm2835.h  | 12 
 3 files changed, 91 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c 
b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
index 3c6f1d91d22d..389a18f9350a 100644
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
@@ -33,7 +33,6 @@
 
 /*  Include Files  
*/
 
-#include "interface/vchi/vchi.h"
 #include "vc_vchi_audioserv_defs.h"
 
 /*  Private Constants and Types -- 
*/
@@ -371,14 +370,46 @@ static int vc_vchi_audio_deinit(struct 
bcm2835_audio_instance *instance)
return 0;
 }
 
+int bcm2835_new_vchi_ctx(struct bcm2835_vchi_ctx *vchi_ctx)
+{
+   int ret;
+
+   /* Initialize and create a VCHI connection */
+   ret = vchi_initialise(_ctx->vchi_instance);
+   if (ret) {
+   LOG_ERR("%s: failed to initialise VCHI instance (ret=%d)\n",
+   __func__, ret);
+
+   return -EIO;
+   }
+
+   ret = vchi_connect(NULL, 0, vchi_ctx->vchi_instance);
+   if (ret) {
+   LOG_ERR("%s: failed to connect VCHI instance (ret=%d)\n",
+   __func__, ret);
+
+   kfree(vchi_ctx->vchi_instance);
+   vchi_ctx->vchi_instance = NULL;
+
+   return -EIO;
+   }
+
+   return 0;
+}
+
+void bcm2835_free_vchi_ctx(struct bcm2835_vchi_ctx *vchi_ctx)
+{
+   /* Close the VCHI connection - it will also free vchi_instance */
+   WARN_ON(vchi_disconnect(vchi_ctx->vchi_instance));
+
+   vchi_ctx->vchi_instance = NULL;
+}
+
 static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream 
*alsa_stream)
 {
-   static VCHI_INSTANCE_T vchi_instance;
-   static VCHI_CONNECTION_T *vchi_connection;
-   static int initted;

[PATCH] staging: ks7010: Fix coding style issues

2018-04-16 Thread Fernando Pereira
Fix most of checkpatch.pl issues unrelated with 80 columns limit

Signed-off-by: Fernando Pereira 
---
 drivers/staging/ks7010/ks_hostif.c   | 17 +
 drivers/staging/ks7010/ks_wlan_net.c |  5 ++---
 drivers/staging/ks7010/michael_mic.c |  5 ++---
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 676961c..de9b01a 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -44,7 +44,7 @@ static inline u8 get_byte(struct ks_wlan_private *priv)
 {
u8 data;
 
-   data = *(priv->rxp)++;
+   data = *priv->rxp++;
/* length check in advance ! */
--(priv->rx_size);
return data;
@@ -186,7 +186,8 @@ int get_current_ap(struct ks_wlan_private *priv, struct 
link_ap_info_t *ap_info)
memcpy(wrqu.ap_addr.sa_data,
   priv->current_ap.bssid, ETH_ALEN);
netdev_dbg(priv->net_dev,
-  "IWEVENT: connect bssid=%pM\n", 
wrqu.ap_addr.sa_data);
+  "IWEVENT: connect bssid=%pM\n",
+  wrqu.ap_addr.sa_data);
wireless_send_event(netdev, SIOCGIWAP, , NULL);
}
netdev_dbg(priv->net_dev, "Link AP\n");
@@ -199,7 +200,7 @@ int get_current_ap(struct ks_wlan_private *priv, struct 
link_ap_info_t *ap_info)
   "capability=%04X\n",
   ap->bssid[0], ap->bssid[1], ap->bssid[2],
   ap->bssid[3], ap->bssid[4], ap->bssid[5],
-  &(ap->ssid.body[0]),
+  >ssid.body[0],
   ap->rate_set.body[0], ap->rate_set.body[1],
   ap->rate_set.body[2], ap->rate_set.body[3],
   ap->rate_set.body[4], ap->rate_set.body[5],
@@ -221,7 +222,6 @@ static u8 read_ie(unsigned char *bp, u8 max, u8 *body)
return size;
 }
 
-
 static
 int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
   struct local_ap_t *ap)
@@ -793,9 +793,9 @@ void hostif_scan_indication(struct ks_wlan_private *priv)
priv->scan_ind_count++;
if (priv->scan_ind_count < LOCAL_APLIST_MAX + 1) {
netdev_dbg(priv->net_dev, " scan_ind_count=%d :: 
aplist.size=%d\n",
-   priv->scan_ind_count, priv->aplist.size);
+  priv->scan_ind_count, priv->aplist.size);
get_ap_information(priv, (struct ap_info_t *)(priv->rxp),
-  &(priv->aplist.ap[priv->scan_ind_count - 
1]));
+  >aplist.ap[priv->scan_ind_count - 1]);
priv->aplist.size = priv->scan_ind_count;
} else {
netdev_dbg(priv->net_dev, " count over :: scan_ind_count=%d\n",
@@ -910,8 +910,8 @@ void hostif_bss_scan_confirm(struct ks_wlan_private *priv)
union iwreq_data wrqu;
 
result_code = get_dword(priv);
-   netdev_dbg(priv->net_dev, "result=%d :: scan_ind_count=%d\n", 
result_code,
-  priv->scan_ind_count);
+   netdev_dbg(priv->net_dev, "result=%d :: scan_ind_count=%d\n",
+  result_code, priv->scan_ind_count);
 
priv->sme_i.sme_flag &= ~SME_AP_SCAN;
hostif_sme_enqueue(priv, SME_BSS_SCAN_CONFIRM);
@@ -2360,6 +2360,7 @@ void hostif_sme_enqueue(struct ks_wlan_private *priv, 
unsigned short event)
 static inline void hostif_aplist_init(struct ks_wlan_private *priv)
 {
size_t size = LOCAL_APLIST_MAX * sizeof(struct local_ap_t);
+
priv->aplist.size = 0;
memset(>aplist.ap[0], 0, size);
 }
diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 9078e13..47d2e0e 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -206,7 +206,7 @@ static int ks_wlan_set_freq(struct net_device *dev,
/* for SLEEP MODE */
/* If setting by frequency, convert to a channel */
if ((fwrq->e == 1) &&
-   (fwrq->m >= (int)2.412e8) && (fwrq->m <= (int)2.487e8)) {
+   (fwrq->m >= 2.412e8) && (fwrq->m <= 2.487e8)) {
int f = fwrq->m / 10;
int c = 0;
 
@@ -1247,7 +1247,7 @@ static int ks_wlan_get_aplist(struct net_device *dev,
return -EPERM;
/* for SLEEP MODE */
for (i = 0; i < priv->aplist.size; i++) {
-   memcpy(address[i].sa_data, &(priv->aplist.ap[i].bssid[0]),
+   memcpy(address[i].sa_data, >aplist.ap[i].bssid[0],
   ETH_ALEN);
address[i].sa_family = ARPHRD_ETHER;
qual[i].level = 256 - priv->aplist.ap[i].rssi;
@@ -1303,7 +1303,6 @@ static inline char *ks_wlan_translate_scan(struct 
net_device *dev,
   char *current_ev, char *end_buf,
   

Proposal

2018-04-16 Thread MS Zeliha Omer Faruk
Hello

Greeetings to you please did you get my previous email regarding my
investment proposal last week friday ?

MS.Zeliha ömer faruk
zeliha.omer.fa...@gmail.com


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


[PATCH v2 2/4] uio_hv_generic: make ring buffer attribute for primary channel

2018-04-16 Thread Stephen Hemminger
The primary channel also needs a ring buffer attribute. This allows
application to check if kernel supports uio sub channels, and also
makes all channels use consistent API.

Signed-off-by: Stephen Hemminger 
---
 drivers/uio/uio_hv_generic.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
index 7ff659dff11d..972a42dd2a46 100644
--- a/drivers/uio/uio_hv_generic.c
+++ b/drivers/uio/uio_hv_generic.c
@@ -326,6 +326,11 @@ hv_uio_probe(struct hv_device *dev,
vmbus_set_chn_rescind_callback(dev->channel, hv_uio_rescind);
vmbus_set_sc_create_callback(dev->channel, hv_uio_new_channel);
 
+   ret = sysfs_create_bin_file(>channel->kobj, _buffer_bin_attr);
+   if (ret)
+   dev_notice(>device,
+  "sysfs create ring bin file failed; %d\n", ret);
+
hv_set_drvdata(dev, pdata);
 
return 0;
-- 
2.17.0

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


[PATCH v2 4/4] uio_hv_generic: fix subchannel ring mmap

2018-04-16 Thread Stephen Hemminger
The fault method of handling subchannel ring, did not work correctly
(it only worked for the first page).

Since ring buffer is physically contiguous, using the vm helper
function is simpler and handles more cases.

Fixes: 37b96a4931db ("uio_hv_generic: support sub-channels")
Signed-off-by: Stephen Hemminger 
---
 drivers/uio/uio_hv_generic.c | 49 +++-
 1 file changed, 9 insertions(+), 40 deletions(-)

diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
index a9d7be4b964f..c690d100adcd 100644
--- a/drivers/uio/uio_hv_generic.c
+++ b/drivers/uio/uio_hv_generic.c
@@ -19,7 +19,7 @@
  * # echo -n "ed963694-e847-4b2a-85af-bc9cfc11d6f3" \
  *> /sys/bus/vmbus/drivers/uio_hv_generic/bind
  */
-
+#define DEBUG 1
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include 
@@ -122,54 +122,23 @@ static void hv_uio_rescind(struct vmbus_channel *channel)
uio_event_notify(>info);
 }
 
-/*
- * Handle fault when looking for sub channel ring buffer
- * Subchannel ring buffer is same as resource 0 which is main ring buffer
- * This is derived from uio_vma_fault
+/* Sysfs API to allow mmap of the ring buffers
+ * The ring buffer is allocated as contiguous memory by vmbus_open
  */
-static int hv_uio_vma_fault(struct vm_fault *vmf)
-{
-   struct vm_area_struct *vma = vmf->vma;
-   void *ring_buffer = vma->vm_private_data;
-   struct page *page;
-   void *addr;
-
-   addr = ring_buffer + (vmf->pgoff << PAGE_SHIFT);
-   page = virt_to_page(addr);
-   get_page(page);
-   vmf->page = page;
-   return 0;
-}
-
-static const struct vm_operations_struct hv_uio_vm_ops = {
-   .fault = hv_uio_vma_fault,
-};
-
-/* Sysfs API to allow mmap of the ring buffers */
 static int hv_uio_ring_mmap(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr,
struct vm_area_struct *vma)
 {
struct vmbus_channel *channel
= container_of(kobj, struct vmbus_channel, kobj);
-   unsigned long requested_pages, actual_pages;
-
-   if (vma->vm_end < vma->vm_start)
-   return -EINVAL;
+   struct hv_device *dev = channel->primary_channel->device_obj;
+   u16 q_idx = channel->offermsg.offer.sub_channel_index;
 
-   /* only allow 0 for now */
-   if (vma->vm_pgoff > 0)
-   return -EINVAL;
+   dev_dbg(>device, "mmap channel %u pages %#lx at %#lx\n",
+   q_idx, vma_pages(vma), vma->vm_pgoff);
 
-   requested_pages = vma_pages(vma);
-   actual_pages = 2 * HV_RING_SIZE;
-   if (requested_pages > actual_pages)
-   return -EINVAL;
-
-   vma->vm_private_data = channel->ringbuffer_pages;
-   vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
-   vma->vm_ops = _uio_vm_ops;
-   return 0;
+   return vm_iomap_memory(vma, virt_to_phys(channel->ringbuffer_pages),
+  channel->ringbuffer_pagecount << PAGE_SHIFT);
 }
 
 static const struct bin_attribute ring_buffer_bin_attr = {
-- 
2.17.0

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


[PATCH v2 3/4] uio_hv_generic: use correct channel in isr

2018-04-16 Thread Stephen Hemminger
Need to mask the correct sub-channel in the callback from VMBUS
isr.  Otherwise, can get in to infinite interrupt storm.

Fixes: 37b96a4931db ("uio_hv_generic: support sub-channels")
Signed-off-by: Stephen Hemminger 
---
 drivers/uio/uio_hv_generic.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
index 972a42dd2a46..a9d7be4b964f 100644
--- a/drivers/uio/uio_hv_generic.c
+++ b/drivers/uio/uio_hv_generic.c
@@ -94,10 +94,11 @@ hv_uio_irqcontrol(struct uio_info *info, s32 irq_state)
  */
 static void hv_uio_channel_cb(void *context)
 {
-   struct hv_uio_private_data *pdata = context;
-   struct hv_device *dev = pdata->device;
+   struct vmbus_channel *chan = context;
+   struct hv_device *hv_dev = chan->device_obj;
+   struct hv_uio_private_data *pdata = hv_get_drvdata(hv_dev);
 
-   dev->channel->inbound.ring_buffer->interrupt_mask = 1;
+   chan->inbound.ring_buffer->interrupt_mask = 1;
virt_mb();
 
uio_event_notify(>info);
@@ -180,19 +181,18 @@ static const struct bin_attribute ring_buffer_bin_attr = {
.mmap = hv_uio_ring_mmap,
 };
 
-/* Callback from VMBUS subystem when new channel created. */
+/* Callback from VMBUS subsystem when new channel created. */
 static void
 hv_uio_new_channel(struct vmbus_channel *new_sc)
 {
struct hv_device *hv_dev = new_sc->primary_channel->device_obj;
struct device *device = _dev->device;
-   struct hv_uio_private_data *pdata = hv_get_drvdata(hv_dev);
const size_t ring_bytes = HV_RING_SIZE * PAGE_SIZE;
int ret;
 
/* Create host communication ring */
ret = vmbus_open(new_sc, ring_bytes, ring_bytes, NULL, 0,
-hv_uio_channel_cb, pdata);
+hv_uio_channel_cb, new_sc);
if (ret) {
dev_err(device, "vmbus_open subchannel failed: %d\n", ret);
return;
@@ -234,7 +234,7 @@ hv_uio_probe(struct hv_device *dev,
 
ret = vmbus_open(dev->channel, HV_RING_SIZE * PAGE_SIZE,
 HV_RING_SIZE * PAGE_SIZE, NULL, 0,
-hv_uio_channel_cb, pdata);
+hv_uio_channel_cb, dev->channel);
if (ret)
goto fail;
 
-- 
2.17.0

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


[PATCH v2 1/4] uio_hv_generic: set size of ring buffer attribute

2018-04-16 Thread Stephen Hemminger
The original code had ring size as a module parameter, but
then it was made a fixed value.  The code to set the size of
the ring buffer binary file was lost in the transistion.
The size is needed by user mode driver to know the size of
the ring buffer.

Fixes: 37b96a4931db ("uio_hv_generic: support sub-channels")
Signed-off-by: Stephen Hemminger 
---
 drivers/uio/uio_hv_generic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
index f695a7e8c314..7ff659dff11d 100644
--- a/drivers/uio/uio_hv_generic.c
+++ b/drivers/uio/uio_hv_generic.c
@@ -171,12 +171,12 @@ static int hv_uio_ring_mmap(struct file *filp, struct 
kobject *kobj,
return 0;
 }
 
-static struct bin_attribute ring_buffer_bin_attr __ro_after_init = {
+static const struct bin_attribute ring_buffer_bin_attr = {
.attr = {
.name = "ring",
.mode = 0600,
-   /* size is set at init time */
},
+   .size = 2 * HV_RING_SIZE * PAGE_SIZE,
.mmap = hv_uio_ring_mmap,
 };
 
-- 
2.17.0

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


[PATCH v2 0/4] uio_hv_generic fixes

2018-04-16 Thread Stephen Hemminger
These are fixes for the UIO Hyper-V driver found while testing
multiple channel support with DPDK.

v2
  - add additional fixes for isr and mmap support

Stephen Hemminger (4):
  uio_hv_generic: set size of ring buffer attribute
  uio_hv_generic: make ring buffer attribute for primary channel
  uio_hv_generic: use correct channel in isr
  uio_hv_generic: fix subchannel ring mmap

 drivers/uio/uio_hv_generic.c | 72 
 1 file changed, 23 insertions(+), 49 deletions(-)

-- 
2.17.0

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


[PATCH 0/9] Do some atomisp cleanups

2018-04-16 Thread Mauro Carvalho Chehab
When I started building media subsystem with the atomisp driver,
I ended by adding several hacks on their Makefiles, in order to
get rid of thousands of warnings. I felt a little guty of hiding how
broken is this driver, so I decided t remove two Makefile hacks that
affect sensors and fix the warnings. 

Yet, there's still one such hack at 
drivers/staging/media/atomisp/pci/atomisp2/Makefile, with:

# HACK! While this driver is in bad shape, don't enable several warnings
#   that would be otherwise enabled with W=1
ccflags-y += $(call cc-disable-warning, implicit-fallthrough)
ccflags-y += $(call cc-disable-warning, missing-prototypes)
ccflags-y += $(call cc-disable-warning, missing-declarations)
ccflags-y += $(call cc-disable-warning, suggest-attribute=format)
ccflags-y += $(call cc-disable-warning, unused-const-variable)
ccflags-y += $(call cc-disable-warning, unused-but-set-variable)

Getting his of those is a big task, as there are thousands of warnings
hidden there. In order to seriously get rid of them, one should start
getting rid of the several abstraction layers at the driver and have
hardware for test.

As I don't have any hardware to test, nor any reason why
dedicating myself to such task, I'll just leave this task for others
to do.

Mauro Carvalho Chehab (9):
  media: staging: atomisp: get rid of __KERNEL macros
  media: staging: atomisp: reenable warnings for I2C
  media: atomisp: ov2680.h: fix identation
  media: staging: atomisp-gc2235: don't fill an unused var
  media: staging: atomisp: Comment out several unused sensor resolutions
  media: atomisp: ov2680: don't declare unused vars
  media: atomisp-gc0310: return errors at gc0310_init()
  media: atomisp-mt9m114: remove dead data
  media: atomisp-mt9m114: comment out unused stuff

 drivers/staging/media/atomisp/i2c/Makefile |   7 -
 drivers/staging/media/atomisp/i2c/atomisp-gc0310.c |   2 +-
 drivers/staging/media/atomisp/i2c/atomisp-gc2235.c |   6 +-
 .../staging/media/atomisp/i2c/atomisp-mt9m114.c|  11 +-
 drivers/staging/media/atomisp/i2c/atomisp-ov2680.c |   6 +-
 drivers/staging/media/atomisp/i2c/gc2235.h |   9 +-
 drivers/staging/media/atomisp/i2c/mt9m114.h|  13 +-
 drivers/staging/media/atomisp/i2c/ov2680.h | 900 +++--
 drivers/staging/media/atomisp/i2c/ov2722.h |   6 +
 drivers/staging/media/atomisp/i2c/ov5693/Makefile  |   7 -
 drivers/staging/media/atomisp/i2c/ov5693/ov5693.h  |  18 +-
 .../css_2401_csi2p_system/host/system_local.h  |  15 -
 .../hive_isp_css_common/host/system_local.h|  15 -
 .../css2400/hive_isp_css_include/math_support.h|   5 -
 .../css2400/hive_isp_css_include/print_support.h   |   3 -
 .../media/atomisp/pci/atomisp2/css2400/sh_css_sp.c |   4 -
 16 files changed, 503 insertions(+), 524 deletions(-)

-- 
2.14.3


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


[PATCH 8/9] media: atomisp-mt9m114: remove dead data

2018-04-16 Thread Mauro Carvalho Chehab
It seems that, originally, the logic would allow selecting between
fine and coarse integration. However, only coarse seems to be
implemented.

Get rid of this warning:

  drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c: In function 
'mt9m114_s_exposure':
  drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:1003:6: warning: variable 
'exposure_local' set but not used [-Wunused-but-set-variable]
u16 exposure_local[3];
^~

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c 
b/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c
index 44db9f9f1fc5..454a5c31a206 100644
--- a/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c
+++ b/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c
@@ -995,12 +995,10 @@ static long mt9m114_s_exposure(struct v4l2_subdev *sd,
struct mt9m114_device *dev = to_mt9m114_sensor(sd);
int ret = 0;
unsigned int coarse_integration = 0;
-   unsigned int fine_integration = 0;
unsigned int FLines = 0;
unsigned int FrameLengthLines = 0; /* ExposureTime.FrameLengthLines; */
unsigned int AnalogGain, DigitalGain;
u32 AnalogGainToWrite = 0;
-   u16 exposure_local[3];
 
dev_dbg(>dev, "%s(0x%X 0x%X 0x%X)\n", __func__,
exposure->integration_time[0], exposure->gain[0],
@@ -1032,10 +1030,7 @@ static long mt9m114_s_exposure(struct v4l2_subdev *sd,
return -EINVAL;
}
 
-   /* set coarse/fine integration */
-   exposure_local[0] = REG_EXPO_COARSE;
-   exposure_local[1] = (u16)coarse_integration;
-   exposure_local[2] = (u16)fine_integration;
+   /* set coarse integration */
/* 3A provide real exposure time.
should not translate to any value here. */
ret = mt9m114_write_reg(client, MISENSOR_16BIT,
-- 
2.14.3

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


[PATCH 7/9] media: atomisp-gc0310: return errors at gc0310_init()

2018-04-16 Thread Mauro Carvalho Chehab
If something wrong gets there, return the error.

Get rid of this warning:

  drivers/staging/media/atomisp/i2c/atomisp-gc0310.c: In function 'gc0310_init':
  drivers/staging/media/atomisp/i2c/atomisp-gc0310.c:713:6: warning: variable 
'ret' set but not used [-Wunused-but-set-variable]
int ret;
^~~

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/i2c/atomisp-gc0310.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c 
b/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c
index 512fa87fa11b..3b38cbccf294 100644
--- a/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c
+++ b/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c
@@ -727,7 +727,7 @@ static int gc0310_init(struct v4l2_subdev *sd)
mutex_unlock(>input_lock);
 
pr_info("%s E\n", __func__);
-   return 0;
+   return ret;
 }
 
 static int power_ctrl(struct v4l2_subdev *sd, bool flag)
-- 
2.14.3

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


[PATCH 9/9] media: atomisp-mt9m114: comment out unused stuff

2018-04-16 Thread Mauro Carvalho Chehab
There are lots of data structs defined there but aren't used
anywhere.

Comment them out. Gets rid of those warnings:

drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:1808:45: warning: 
'mt9m114_entity_ops' defined but not used [-Wunused-const-variable=]
 static const struct media_entity_operations mt9m114_entity_ops = {
 ^~
In file included from drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:35:0:
drivers/staging/media/atomisp/i2c/mt9m114.h:805:34: warning: 'mt9m114_iq' 
defined but not used [-Wunused-const-variable=]
 static struct misensor_reg const mt9m114_iq[] = {
  ^~
drivers/staging/media/atomisp/i2c/mt9m114.h:797:34: warning: 
'mt9m114_antiflicker_60hz' defined but not used [-Wunused-const-variable=]
 static struct misensor_reg const mt9m114_antiflicker_60hz[] = {
  ^~~~
drivers/staging/media/atomisp/i2c/mt9m114.h:789:34: warning: 
'mt9m114_antiflicker_50hz' defined but not used [-Wunused-const-variable=]
 static struct misensor_reg const mt9m114_antiflicker_50hz[] = {
  ^~~~
drivers/staging/media/atomisp/i2c/mt9m114.h:682:34: warning: 
'mt9m114_720_480P_init' defined but not used [-Wunused-const-variable=]
 static struct misensor_reg const mt9m114_720_480P_init[] = {
  ^
drivers/staging/media/atomisp/i2c/mt9m114.h:533:34: warning: 
'mt9m114_960P_init' defined but not used [-Wunused-const-variable=]
 static struct misensor_reg const mt9m114_960P_init[] = {
  ^
drivers/staging/media/atomisp/i2c/mt9m114.h:518:34: warning: 
'mt9m114_wakeup_reg' defined but not used [-Wunused-const-variable=]
 static struct misensor_reg const mt9m114_wakeup_reg[] = {
  ^~
drivers/staging/media/atomisp/i2c/mt9m114.h:504:34: warning: 
'mt9m114_streaming' defined but not used [-Wunused-const-variable=]
 static struct misensor_reg const mt9m114_streaming[] = {
  ^
drivers/staging/media/atomisp/i2c/mt9m114.h:497:34: warning: 'mt9m114_suspend' 
defined but not used [-Wunused-const-variable=]
 static struct misensor_reg const mt9m114_suspend[] = {
  ^~~
drivers/staging/media/atomisp/i2c/mt9m114.h:393:34: warning: 
'mt9m114_exitstandby' defined but not used [-Wunused-const-variable=]
 static struct misensor_reg const mt9m114_exitstandby[] = {
  ^~~

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c |  4 
 drivers/staging/media/atomisp/i2c/mt9m114.h | 13 -
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c 
b/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c
index 454a5c31a206..8e180f903335 100644
--- a/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c
+++ b/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c
@@ -1805,10 +1805,6 @@ static const struct v4l2_subdev_ops mt9m114_ops = {
.sensor = _sensor_ops,
 };
 
-static const struct media_entity_operations mt9m114_entity_ops = {
-   .link_setup = NULL,
-};
-
 static int mt9m114_remove(struct i2c_client *client)
 {
struct mt9m114_device *dev;
diff --git a/drivers/staging/media/atomisp/i2c/mt9m114.h 
b/drivers/staging/media/atomisp/i2c/mt9m114.h
index 0af79d77a404..de39cc141308 100644
--- a/drivers/staging/media/atomisp/i2c/mt9m114.h
+++ b/drivers/staging/media/atomisp/i2c/mt9m114.h
@@ -390,6 +390,7 @@ static struct mt9m114_res_struct mt9m114_res[] = {
 };
 #define N_RES (ARRAY_SIZE(mt9m114_res))
 
+#if 0 /* Currently unused */
 static struct misensor_reg const mt9m114_exitstandby[] = {
{MISENSOR_16BIT,  0x098E, 0xDC00},
/* exit-standby */
@@ -397,6 +398,7 @@ static struct misensor_reg const mt9m114_exitstandby[] = {
{MISENSOR_16BIT,  0x0080, 0x8002},
{MISENSOR_TOK_TERM, 0, 0}
 };
+#endif
 
 static struct misensor_reg const mt9m114_exp_win[5][5] = {
{
@@ -494,6 +496,7 @@ static struct misensor_reg const mt9m114_exp_center[] = {
{MISENSOR_TOK_TERM, 0, 0}
 };
 
+#if 0 /* Currently unused */
 static struct misensor_reg const mt9m114_suspend[] = {
 {MISENSOR_16BIT,  0x098E, 0xDC00},
 {MISENSOR_8BIT,  0xDC00, 0x40},
@@ -507,6 +510,7 @@ static struct misensor_reg const mt9m114_streaming[] = {
 {MISENSOR_16BIT,  0x0080, 0x8002},
 {MISENSOR_TOK_TERM, 0, 0}
 };
+#endif
 
 static struct misensor_reg const mt9m114_standby_reg[] = {
 {MISENSOR_16BIT,  0x098E, 0xDC00},
@@ -515,12 +519,14 @@ static struct misensor_reg const mt9m114_standby_reg[] = {
 {MISENSOR_TOK_TERM, 0, 0}
 };
 
+#if 0 /* Currently unused */
 static struct 

[PATCH 6/9] media: atomisp: ov2680: don't declare unused vars

2018-04-16 Thread Mauro Carvalho Chehab
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c: In function 
‘__ov2680_set_exposure’:
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:400:10: warning: variable 
‘hts’ set but not used [-Wunused-but-set-variable]
  u16 vts,hts;
  ^~~
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c: In function ‘ov2680_detect’:
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:1164:5: warning: variable 
‘revision’ set but not used [-Wunused-but-set-variable]
  u8 revision;
 ^~~~

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/i2c/atomisp-ov2680.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c 
b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c
index c0849299d592..bba3d1745908 100644
--- a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c
+++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c
@@ -397,14 +397,13 @@ static long __ov2680_set_exposure(struct v4l2_subdev *sd, 
int coarse_itg,
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct ov2680_device *dev = to_ov2680_sensor(sd);
-   u16 vts,hts;
+   u16 vts;
int ret,exp_val;
 
dev_dbg(>dev,
"+++__ov2680_set_exposure coarse_itg %d, gain %d, digitgain 
%d++\n",
coarse_itg, gain, digitgain);
 
-   hts = ov2680_res[dev->fmt_idx].pixels_per_line;
vts = ov2680_res[dev->fmt_idx].lines_per_frame;
 
/* group hold */
@@ -1185,7 +1184,8 @@ static int ov2680_detect(struct i2c_client *client)
OV2680_SC_CMMN_SUB_ID, );
revision = (u8) high & 0x0f;
 
-   dev_info(>dev, "sensor_revision id = 0x%x\n", id);
+   dev_info(>dev, "sensor_revision id = 0x%x, rev= %d\n",
+id, revision);
 
return 0;
 }
-- 
2.14.3

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


[PATCH 3/9] media: atomisp: ov2680.h: fix identation

2018-04-16 Thread Mauro Carvalho Chehab
The identation for several tables there are broken.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/i2c/ov2680.h | 895 ++---
 1 file changed, 447 insertions(+), 448 deletions(-)

diff --git a/drivers/staging/media/atomisp/i2c/ov2680.h 
b/drivers/staging/media/atomisp/i2c/ov2680.h
index cb38e6e79409..c83ae379f517 100644
--- a/drivers/staging/media/atomisp/i2c/ov2680.h
+++ b/drivers/staging/media/atomisp/i2c/ov2680.h
@@ -299,131 +299,131 @@ struct ov2680_format {
 * 176x144 30fps  VBlanking 1lane 10Bit (binning)
 */
static struct ov2680_reg const ov2680_QCIF_30fps[] = {
-   {OV2680_8BIT, 0x3086, 0x01},
-   {OV2680_8BIT, 0x3501, 0x24},
-   {OV2680_8BIT, 0x3502, 0x40},
-   {OV2680_8BIT, 0x370a, 0x23},
-   {OV2680_8BIT, 0x3801, 0xa0},
-   {OV2680_8BIT, 0x3802, 0x00},
-   {OV2680_8BIT, 0x3803, 0x78},
-   {OV2680_8BIT, 0x3804, 0x05},
-   {OV2680_8BIT, 0x3805, 0xaf},
-   {OV2680_8BIT, 0x3806, 0x04},
-   {OV2680_8BIT, 0x3807, 0x47},
-   {OV2680_8BIT, 0x3808, 0x00},
-   {OV2680_8BIT, 0x3809, 0xC0},
-   {OV2680_8BIT, 0x380a, 0x00},
-   {OV2680_8BIT, 0x380b, 0xa0},
-   {OV2680_8BIT, 0x380c, 0x06},
-   {OV2680_8BIT, 0x380d, 0xb0},
-   {OV2680_8BIT, 0x380e, 0x02},
-   {OV2680_8BIT, 0x380f, 0x84},
-   {OV2680_8BIT, 0x3810, 0x00},
-   {OV2680_8BIT, 0x3811, 0x04},
-   {OV2680_8BIT, 0x3812, 0x00},
-   {OV2680_8BIT, 0x3813, 0x04},
-   {OV2680_8BIT, 0x3814, 0x31},
-   {OV2680_8BIT, 0x3815, 0x31},
-   {OV2680_8BIT, 0x4000, 0x81},
-   {OV2680_8BIT, 0x4001, 0x40},
-   {OV2680_8BIT, 0x4008, 0x00},
-   {OV2680_8BIT, 0x4009, 0x03},
-   {OV2680_8BIT, 0x5081, 0x41},
-   {OV2680_8BIT, 0x5708, 0x00}, //add for full size flip off and mirror 
off 2014/09/11
-   {OV2680_8BIT, 0x5704, 0x10},
-   {OV2680_8BIT, 0x5705, 0xa0},
-   {OV2680_8BIT, 0x5706, 0x0c},
-   {OV2680_8BIT, 0x5707, 0x78},
-   {OV2680_8BIT, 0x3820, 0xc2},
-   {OV2680_8BIT, 0x3821, 0x01},
-// {OV2680_8BIT, 0x5090, 0x0c},
-{OV2680_TOK_TERM, 0, 0}
+   {OV2680_8BIT, 0x3086, 0x01},
+   {OV2680_8BIT, 0x3501, 0x24},
+   {OV2680_8BIT, 0x3502, 0x40},
+   {OV2680_8BIT, 0x370a, 0x23},
+   {OV2680_8BIT, 0x3801, 0xa0},
+   {OV2680_8BIT, 0x3802, 0x00},
+   {OV2680_8BIT, 0x3803, 0x78},
+   {OV2680_8BIT, 0x3804, 0x05},
+   {OV2680_8BIT, 0x3805, 0xaf},
+   {OV2680_8BIT, 0x3806, 0x04},
+   {OV2680_8BIT, 0x3807, 0x47},
+   {OV2680_8BIT, 0x3808, 0x00},
+   {OV2680_8BIT, 0x3809, 0xC0},
+   {OV2680_8BIT, 0x380a, 0x00},
+   {OV2680_8BIT, 0x380b, 0xa0},
+   {OV2680_8BIT, 0x380c, 0x06},
+   {OV2680_8BIT, 0x380d, 0xb0},
+   {OV2680_8BIT, 0x380e, 0x02},
+   {OV2680_8BIT, 0x380f, 0x84},
+   {OV2680_8BIT, 0x3810, 0x00},
+   {OV2680_8BIT, 0x3811, 0x04},
+   {OV2680_8BIT, 0x3812, 0x00},
+   {OV2680_8BIT, 0x3813, 0x04},
+   {OV2680_8BIT, 0x3814, 0x31},
+   {OV2680_8BIT, 0x3815, 0x31},
+   {OV2680_8BIT, 0x4000, 0x81},
+   {OV2680_8BIT, 0x4001, 0x40},
+   {OV2680_8BIT, 0x4008, 0x00},
+   {OV2680_8BIT, 0x4009, 0x03},
+   {OV2680_8BIT, 0x5081, 0x41},
+   {OV2680_8BIT, 0x5708, 0x00}, //add for full size flip off and 
mirror off 2014/09/11
+   {OV2680_8BIT, 0x5704, 0x10},
+   {OV2680_8BIT, 0x5705, 0xa0},
+   {OV2680_8BIT, 0x5706, 0x0c},
+   {OV2680_8BIT, 0x5707, 0x78},
+   {OV2680_8BIT, 0x3820, 0xc2},
+   {OV2680_8BIT, 0x3821, 0x01},
+   // {OV2680_8BIT, 0x5090, 0x0c},
+   {OV2680_TOK_TERM, 0, 0}
};
 
/*
 * 352x288 30fps  VBlanking 1lane 10Bit (binning)
 */
static struct ov2680_reg const ov2680_CIF_30fps[] = {
-   {OV2680_8BIT, 0x3086, 0x01},
-   {OV2680_8BIT, 0x3501, 0x24},
-   {OV2680_8BIT, 0x3502, 0x40},
-   {OV2680_8BIT, 0x370a, 0x23},
-   {OV2680_8BIT, 0x3801, 0xa0},
-   {OV2680_8BIT, 0x3802, 0x00},
-   {OV2680_8BIT, 0x3803, 0x78},
-   {OV2680_8BIT, 0x3804, 0x03},
-   {OV2680_8BIT, 0x3805, 0x8f},
-   {OV2680_8BIT, 0x3806, 0x02},
-   {OV2680_8BIT, 0x3807, 0xe7},
-   {OV2680_8BIT, 0x3808, 0x01},
-   {OV2680_8BIT, 0x3809, 0x70},
-   {OV2680_8BIT, 0x380a, 0x01},
-   {OV2680_8BIT, 0x380b, 0x30},
-   {OV2680_8BIT, 0x380c, 0x06},
-   {OV2680_8BIT, 0x380d, 0xb0},
-   {OV2680_8BIT, 0x380e, 0x02},
-   {OV2680_8BIT, 0x380f, 0x84},
-   {OV2680_8BIT, 0x3810, 0x00},
-   {OV2680_8BIT, 0x3811, 0x04},
-   {OV2680_8BIT, 0x3812, 0x00},
-   {OV2680_8BIT, 0x3813, 0x04},
-   

[PATCH 5/9] media: staging: atomisp: Comment out several unused sensor resolutions

2018-04-16 Thread Mauro Carvalho Chehab
The register settings for several resolutions aren't used
currently. So, comment them out.

Fix those warnings:

In file included from drivers/staging/media/atomisp/i2c/atomisp-gc2235.c:35:0:
drivers/staging/media/atomisp/i2c/gc2235.h:340:32: warning: 
'gc2235_960_640_30fps' defined but not used [-Wunused-const-variable=]
 static struct gc2235_reg const gc2235_960_640_30fps[] = {
^~~~
drivers/staging/media/atomisp/i2c/gc2235.h:287:32: warning: 
'gc2235_1296_736_30fps' defined but not used [-Wunused-const-variable=]
 static struct gc2235_reg const gc2235_1296_736_30fps[] = {
^
In file included from drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:35:0:
drivers/staging/media/atomisp/i2c/ov2722.h:999:32: warning: 'ov2722_720p_30fps' 
defined but not used [-Wunused-const-variable=]
 static struct ov2722_reg const ov2722_720p_30fps[] = {
^
drivers/staging/media/atomisp/i2c/ov2722.h:787:32: warning: 'ov2722_1M3_30fps' 
defined but not used [-Wunused-const-variable=]
 static struct ov2722_reg const ov2722_1M3_30fps[] = {
^~~~
drivers/staging/media/atomisp/i2c/ov2722.h:476:32: warning: 'ov2722_VGA_30fps' 
defined but not used [-Wunused-const-variable=]
 static struct ov2722_reg const ov2722_VGA_30fps[] = {
^~~~
drivers/staging/media/atomisp/i2c/ov2722.h:367:32: warning: 'ov2722_480P_30fps' 
defined but not used [-Wunused-const-variable=]
 static struct ov2722_reg const ov2722_480P_30fps[] = {
^
drivers/staging/media/atomisp/i2c/ov2722.h:257:32: warning: 'ov2722_QVGA_30fps' 
defined but not used [-Wunused-const-variable=]
 static struct ov2722_reg const ov2722_QVGA_30fps[] = {
^
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c: In function 
'__ov2680_set_exposure':
In file included from drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:35:0:
At top level:
drivers/staging/media/atomisp/i2c/ov2680.h:736:33: warning: 
'ov2680_1616x1082_30fps' defined but not used [-Wunused-const-variable=]
  static struct ov2680_reg const ov2680_1616x1082_30fps[] = {
 ^~
drivers/staging/media/atomisp/i2c/ov2680.h:649:33: warning: 
'ov2680_1456x1096_30fps' defined but not used [-Wunused-const-variable=]
  static struct ov2680_reg const ov2680_1456x1096_30fps[]= {
 ^~
drivers/staging/media/atomisp/i2c/ov2680.h:606:33: warning: 
'ov2680_1296x976_30fps' defined but not used [-Wunused-const-variable=]
  static struct ov2680_reg const ov2680_1296x976_30fps[] = {
 ^
drivers/staging/media/atomisp/i2c/ov2680.h:563:33: warning: 'ov2680_720p_30fps' 
defined but not used [-Wunused-const-variable=]
  static struct ov2680_reg const ov2680_720p_30fps[] = {
 ^
drivers/staging/media/atomisp/i2c/ov2680.h:520:33: warning: 
'ov2680_800x600_30fps' defined but not used [-Wunused-const-variable=]
  static struct ov2680_reg const ov2680_800x600_30fps[] = {
 ^~~~
drivers/staging/media/atomisp/i2c/ov2680.h:475:33: warning: 
'ov2680_720x592_30fps' defined but not used [-Wunused-const-variable=]
  static struct ov2680_reg const ov2680_720x592_30fps[] = {
 ^~~~
drivers/staging/media/atomisp/i2c/ov2680.h:433:33: warning: 
'ov2680_656x496_30fps' defined but not used [-Wunused-const-variable=]
  static struct ov2680_reg const ov2680_656x496_30fps[] = {
 ^~~~
drivers/staging/media/atomisp/i2c/ov2680.h:389:33: warning: 'ov2680_QVGA_30fps' 
defined but not used [-Wunused-const-variable=]
  static struct ov2680_reg const ov2680_QVGA_30fps[] = {
 ^
drivers/staging/media/atomisp/i2c/ov2680.h:346:33: warning: 'ov2680_CIF_30fps' 
defined but not used [-Wunused-const-variable=]
  static struct ov2680_reg const ov2680_CIF_30fps[] = {
 ^~~~
drivers/staging/media/atomisp/i2c/ov2680.h:301:33: warning: 'ov2680_QCIF_30fps' 
defined but not used [-Wunused-const-variable=]
  static struct ov2680_reg const ov2680_QCIF_30fps[] = {
 ^
In file included from 
drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:36:0:
drivers/staging/media/atomisp/i2c/ov5693/ov5693.h:988:32: warning: 
'ov5693_1424x1168_30fps' defined but not used [-Wunused-const-variable=]
 static struct ov5693_reg const ov5693_1424x1168_30fps[] = {
^~
drivers/staging/media/atomisp/i2c/ov5693/ov5693.h:954:32: warning: 
'ov5693_2592x1944_30fps' defined but 

[PATCH 1/9] media: staging: atomisp: get rid of __KERNEL macros

2018-04-16 Thread Mauro Carvalho Chehab
There's no sense for a Kernel driver to have __KERNEL macros
on it.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../css2400/css_2401_csi2p_system/host/system_local.h | 15 ---
 .../css2400/hive_isp_css_common/host/system_local.h   | 15 ---
 .../atomisp2/css2400/hive_isp_css_include/math_support.h  |  5 -
 .../atomisp2/css2400/hive_isp_css_include/print_support.h |  3 ---
 .../media/atomisp/pci/atomisp2/css2400/sh_css_sp.c|  4 
 5 files changed, 42 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2401_csi2p_system/host/system_local.h
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2401_csi2p_system/host/system_local.h
index c16670989702..5600b32e29f4 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2401_csi2p_system/host/system_local.h
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2401_csi2p_system/host/system_local.h
@@ -31,23 +31,8 @@
 #define HRT_ADDRESS_WIDTH  64  /* Surprise, this is a local 
property */
 #endif
 
-#if !defined(__KERNEL__) || (1 == 1)
 /* This interface is deprecated */
 #include "hrt/hive_types.h"
-#else  /* __KERNEL__ */
-#include 
-
-#if HRT_ADDRESS_WIDTH == 64
-typedef uint64_t   hrt_address;
-#elif HRT_ADDRESS_WIDTH == 32
-typedef uint32_t   hrt_address;
-#else
-#error "system_local.h: HRT_ADDRESS_WIDTH must be one of {32,64}"
-#endif
-
-typedef uint32_t   hrt_vaddress;
-typedef uint32_t   hrt_data;
-#endif /* __KERNEL__ */
 
 /*
  * Cell specific address maps
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/system_local.h
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/system_local.h
index 111b346dfafb..8be1cd020bf4 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/system_local.h
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/system_local.h
@@ -33,23 +33,8 @@
 #define HRT_ADDRESS_WIDTH  64  /* Surprise, this is a local 
property */
 #endif
 
-#if !defined(__KERNEL__) || (1==1)
 /* This interface is deprecated */
 #include "hrt/hive_types.h"
-#else  /* __KERNEL__ */
-#include 
-
-#if HRT_ADDRESS_WIDTH==64
-typedef uint64_t   hrt_address;
-#elif HRT_ADDRESS_WIDTH==32
-typedef uint32_t   hrt_address;
-#else
-#error "system_local.h: HRT_ADDRESS_WIDTH must be one of {32,64}"
-#endif
-
-typedef uint32_t   hrt_vaddress;
-typedef uint32_t   hrt_data;
-#endif /* __KERNEL__ */
 
 /*
  * Cell specific address maps
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/math_support.h
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/math_support.h
index 6436dae0007e..7c52ba54fcf1 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/math_support.h
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/math_support.h
@@ -15,9 +15,7 @@
 #ifndef __MATH_SUPPORT_H
 #define __MATH_SUPPORT_H
 
-#if defined(__KERNEL__)
 #include  /* Override the definition of max/min from linux 
kernel*/
-#endif /*__KERNEL__*/
 
 #if defined(_MSC_VER)
 #include  /* Override the definition of max/min from stdlib.h*/
@@ -216,8 +214,5 @@ static inline unsigned int ceil_pow2(unsigned int a)
 #define OP_std_modadd(base, offset, size) ((base+offset)%(size))
 #endif /* !defined(__ISP) */
 
-#if !defined(__KERNEL__)
-#define clamp(a, min_val, max_val) MIN(MAX((a), (min_val)), (max_val))
-#endif /* !defined(__KERNEL__) */
 
 #endif /* __MATH_SUPPORT_H */
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/print_support.h
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/print_support.h
index ca0fbbb57788..37e8116b74a4 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/print_support.h
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/print_support.h
@@ -17,9 +17,6 @@
 
 
 #include 
-#if !defined(__KERNEL__)
-#include 
-#endif
 
 extern int (*sh_css_printf) (const char *fmt, va_list args);
 /* depends on host supplied print function in ia_css_init() */
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_sp.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_sp.c
index 85263725540d..cdbe914787c8 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_sp.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_sp.c
@@ -1592,10 +1592,6 @@ ia_css_pipe_set_irq_mask(struct ia_css_pipe *pipe,
 * - compare with (uint16_t)~0 or 0x
 * - different assert for Linux and Windows
 */
-#ifndef __KERNEL__
-   assert(or_mask <= UINT16_MAX);

[PATCH 2/9] media: staging: atomisp: reenable warnings for I2C

2018-04-16 Thread Mauro Carvalho Chehab
When atomisp got merged, there were so many warnings with W=1
that we simply disabled the ones that were causing troubles.

Since then, several changes got applied to atomisp, and the
number of warnings are a way smaller than it used to be.

So, let's reenable warnings there and fix the issues.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/i2c/Makefile| 7 ---
 drivers/staging/media/atomisp/i2c/ov5693/Makefile | 7 ---
 2 files changed, 14 deletions(-)

diff --git a/drivers/staging/media/atomisp/i2c/Makefile 
b/drivers/staging/media/atomisp/i2c/Makefile
index 99ea35c043fd..8d022986e199 100644
--- a/drivers/staging/media/atomisp/i2c/Makefile
+++ b/drivers/staging/media/atomisp/i2c/Makefile
@@ -16,10 +16,3 @@ obj-$(CONFIG_VIDEO_ATOMISP_MSRLIST_HELPER) += 
atomisp-libmsrlisthelper.o
 #
 
 obj-$(CONFIG_VIDEO_ATOMISP_LM3554) += atomisp-lm3554.o
-
-# HACK! While this driver is in bad shape, don't enable several warnings
-#   that would be otherwise enabled with W=1
-ccflags-y += $(call cc-disable-warning, unused-but-set-variable)
-ccflags-y += $(call cc-disable-warning, unused-const-variable)
-ccflags-y += $(call cc-disable-warning, missing-prototypes)
-ccflags-y += $(call cc-disable-warning, missing-declarations)
diff --git a/drivers/staging/media/atomisp/i2c/ov5693/Makefile 
b/drivers/staging/media/atomisp/i2c/ov5693/Makefile
index aa6be85c5a60..3275f2be229e 100644
--- a/drivers/staging/media/atomisp/i2c/ov5693/Makefile
+++ b/drivers/staging/media/atomisp/i2c/ov5693/Makefile
@@ -1,9 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_VIDEO_ATOMISP_OV5693) += atomisp-ov5693.o
-
-# HACK! While this driver is in bad shape, don't enable several warnings
-#   that would be otherwise enabled with W=1
-ccflags-y += $(call cc-disable-warning, unused-but-set-variable)
-ccflags-y += $(call cc-disable-warning, unused-const-variable)
-ccflags-y += $(call cc-disable-warning, missing-prototypes)
-ccflags-y += $(call cc-disable-warning, missing-declarations)
-- 
2.14.3

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


[PATCH 4/9] media: staging: atomisp-gc2235: don't fill an unused var

2018-04-16 Thread Mauro Carvalho Chehab
The code with uses the dummy var is commented out. So,
coment out its definition/initialization.

Fix this warning:

  drivers/staging/media/atomisp/i2c/atomisp-gc2235.c: In function 
'gc2235_get_intg_factor':
  drivers/staging/media/atomisp/i2c/atomisp-gc2235.c:249:26: warning: variable 
'dummy' set but not used [-Wunused-but-set-variable]
u16 reg_val, reg_val_h, dummy;
^

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/i2c/atomisp-gc2235.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c 
b/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c
index 93f9c618f3d8..4b6b6568b3cf 100644
--- a/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c
+++ b/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c
@@ -246,7 +246,7 @@ static int gc2235_get_intg_factor(struct i2c_client *client,
struct v4l2_subdev *sd = i2c_get_clientdata(client);
struct gc2235_device *dev = to_gc2235_sensor(sd);
struct atomisp_sensor_mode_data *buf = >data;
-   u16 reg_val, reg_val_h, dummy;
+   u16 reg_val, reg_val_h;
int ret;
 
if (!info)
@@ -316,7 +316,9 @@ static int gc2235_get_intg_factor(struct i2c_client *client,
if (ret)
return ret;
 
-   dummy = (reg_val_h << 8) | reg_val;
+#if 0
+   u16 dummy = (reg_val_h << 8) | reg_val;
+#endif
 
ret = gc2235_read_reg(client, GC2235_8BIT,
GC2235_SH_DELAY_H, _val_h);
-- 
2.14.3

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


[PATCH] android: binder: Change return type to vm_fault_t

2018-04-16 Thread Souptick Joarder
Use new return type vm_fault_t for fault handler
in struct vm_operations_struct. For now, this is
just documenting that the function returns a 
VM_FAULT value rather than an errno.  Once all
instances are converted, vm_fault_t will become
a distinct type.

Reference commit id->
1c8f422059ae5da07db7406ab916203f9417e396

Signed-off-by: Souptick Joarder 
---
 drivers/android/binder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 15e3d3c..65be4ec 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -4671,7 +4671,7 @@ static void binder_vma_close(struct vm_area_struct *vma)
binder_defer_work(proc, BINDER_DEFERRED_PUT_FILES);
 }

-static int binder_vm_fault(struct vm_fault *vmf)
+static vm_fault_t binder_vm_fault(struct vm_fault *vmf)
 {
return VM_FAULT_SIGBUS;
 }
--
1.9.1

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


Re: [PATCH 08/25] staging: lustre: libcfs: add cpu distance handling

2018-04-16 Thread Dan Carpenter
On Mon, Apr 16, 2018 at 12:09:50AM -0400, James Simmons wrote:
> +int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len)
> +{
> + char *tmp = buf;
> + int rc = -EFBIG;
> + int i;
> + int j;
> +
> + for (i = 0; i < cptab->ctb_nparts; i++) {
> + if (len <= 0)
> + goto err;
> +
> + rc = snprintf(tmp, len, "%d\t:", i);
> + len -= rc;
> +
> + if (len <= 0)
> + goto err;


The "goto err" here is sort of an example of a "do-nothing" goto.  There
are no resources to free or anything like that.

I don't like do-nothing gotos because "return -EFBIG;" is self
documenting code and "goto err;" is totally ambiguous what it does.  The
second problem is that do-nothing error labels easily turn into
do-everything one err style error paths which I loath.  And the third
problem is that they introduce "forgot to set the error code" bugs.

It looks like we forgot to set the error code here although it's also
possible that was intended.  This code is ambiguous.

> +
> + tmp += rc;
> + for (j = 0; j < cptab->ctb_nparts; j++) {
> + rc = snprintf(tmp, len, " %d:%d",
> +   j, cptab->ctb_parts[i].cpt_distance[j]);
> + len -= rc;
> + if (len <= 0)
> + goto err;
> + tmp += rc;
> + }
> +
> + *tmp = '\n';
> + tmp++;
> + len--;
> + }
> + rc = 0;
> +err:
> + if (rc < 0)
> + return rc;
> +
> + return tmp - buf;
> +}

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


Re: [PATCH v4 02/13] dt-bindings: usb: add documentation for typec port controller(TCPCI)

2018-04-16 Thread Rob Herring
On Mon, Apr 16, 2018 at 6:54 AM, Jun Li  wrote:
> Hi
>> -Original Message-
>> From: Rob Herring [mailto:r...@kernel.org]
>> Sent: 2018年4月10日 4:04
>> To: Jun Li 
>> Cc: gre...@linuxfoundation.org; heikki.kroge...@linux.intel.com;
>> li...@roeck-us.net; a.ha...@samsung.com; shufan_...@richtek.com; Peter
>> Chen ; devicet...@vger.kernel.org;
>> linux-...@vger.kernel.org; dl-linux-imx ;
>> de...@driverdev.osuosl.org
>> Subject: Re: [PATCH v4 02/13] dt-bindings: usb: add documentation for typec
>> port controller(TCPCI)
>>
>> On Thu, Mar 29, 2018 at 12:06:07AM +0800, Li Jun wrote:

[...]

>> > +ptn5110@50 {
>> > +   compatible = "usb-tcpci,ptn5110";
>> > +   reg = <0x50>;
>> > +   interrupt-parent = <>;
>> > +   interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
>> > +
>> > +   usb_con: connector {
>>
>> How is the OF graph done in this case? You need some link to the USB 
>> controller.
>
> The platform(i.MX8MQ EVK) for this is still on the way of start upstream, I 
> was
> Planning to add this part with enabling USB3 function, as of how this will be 
> done,
> I only have usb3 ss data(no display port or Sideband), is something like 
> below OK?
>
> typec: ptn5110@50 {
> compatible = "nxp,ptn5110";
> ...
>
> usb_con: connector {
> compatible = "usb-c-connector";
> label = "USB-C";
> ...
>
> ports {
> #address-cells = <1>;
> #size-cells = <0>;
>
> port@1 {
> reg = <1>;
> usb_con_ss: endpoint {
> remote-endpoint = <_phy_ss>;
> };
> };
> };
> };
> };
>
> _phy0 {
> status = "okay";
>
> port {
> usb3_phy_ss: endpoint {

Normally, the graph connection would be to the USB controller, not the
phy as the phy is just referred to with a "phys" property.

> remote-endpoint = <_con_ss>;
> };
> };
> }
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 07/25] staging: lustre: libcfs: NUMA support

2018-04-16 Thread Dan Carpenter
On Mon, Apr 16, 2018 at 12:09:49AM -0400, James Simmons wrote:
> @@ -114,6 +115,15 @@ struct cfs_cpt_table *
>   memset(cptab->ctb_cpu2cpt, -1,
>  nr_cpu_ids * sizeof(cptab->ctb_cpu2cpt[0]));
>  
> + cptab->ctb_node2cpt = kvmalloc_array(nr_node_ids,
> +  sizeof(cptab->ctb_node2cpt[0]),
> +  GFP_KERNEL);
> + if (!cptab->ctb_node2cpt)
> + goto failed;
> +
> + memset(cptab->ctb_node2cpt, -1,
> +nr_node_ids * sizeof(cptab->ctb_node2cpt[0]));
> +
>   cptab->ctb_parts = kvmalloc_array(ncpt, sizeof(cptab->ctb_parts[0]),
> GFP_KERNEL);
>   if (!cptab->ctb_parts)


You didn't introduce this, but I was explaining earlier that you should
always be suspicious of code which does "goto failed".  The bug here is
that cptab->ctb_parts is allocated with kvmalloc_array() which
doesn't zero out the memory.  So if we only initialize it part way
because art->cpt_nodemask = kzalloc() fails or something then it's
problem:

91  void
92  cfs_cpt_table_free(struct cfs_cpt_table *cptab)
93  {
94  int i;
95  
96  kvfree(cptab->ctb_cpu2cpt);
97  
98  for (i = 0; cptab->ctb_parts && i < cptab->ctb_nparts; i++) {
99  struct cfs_cpu_partition *part = >ctb_parts[i];
   100  
   101  kfree(part->cpt_nodemask);
 ^^^
   102  free_cpumask_var(part->cpt_cpumask);
 ^
These are uninitialized so it will crash.  It turns out there isn't a
kvcalloc() or kvzalloc_array() function.  We don't seem to have a
vcalloc() either...  Very strange.

   103  }
   104  
   105  kvfree(cptab->ctb_parts);
   106  
   107  kfree(cptab->ctb_nodemask);
   108  free_cpumask_var(cptab->ctb_cpumask);
   109  
   110  kfree(cptab);
   111  }

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


Re: [PATCH 04/25] staging: lustre: libcfs: replace MAX_NUMNODES with nr_node_ids

2018-04-16 Thread Dan Carpenter
On Mon, Apr 16, 2018 at 12:09:46AM -0400, James Simmons wrote:
> From: Amir Shehata 
> 
> Replace depricated MAX_NUMNODES with nr_node_ids.
> 

The changelog makes it sound like this is just a style change, but it's
actually a behavior change isn't it?

regards,
dan carpenter

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


Re: [PATCH 03/25] staging: lustre: libcfs: implement cfs_cpt_cpumask for UMP case

2018-04-16 Thread Dan Carpenter
On Mon, Apr 16, 2018 at 12:09:45AM -0400, James Simmons wrote:
> diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
> b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
> index 705abf2..5ea294f 100644
> --- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
> +++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
> @@ -54,6 +54,9 @@ struct cfs_cpt_table *
>   cptab = kzalloc(sizeof(*cptab), GFP_NOFS);
>   if (cptab) {

Don't do "success handling", do "error handling".  Success handling
means we have to indent the code and it makes it more complicated to
read.  Ideally code would look like:

do_this();
do_that();
do_the_next_thing();

But because of error handling then we have to add a bunch of if
statements.  It's better when those if statements are very quick and
we can move on.  The success path is all at indent level one still like
and ideal situation above and the the error paths are at indent level
two.

if (!cptab)
return NULL;


>   cptab->ctb_version = CFS_CPU_VERSION_MAGIC;
> + if (!zalloc_cpumask_var(>ctb_mask, GFP_NOFS))
> + return NULL;

This leaks.  It should be:

if (!zalloc_cpumask_var(>ctb_mask, GFP_NOFS)) {
kfree(cptab);
return NULL;
}

> + cpumask_set_cpu(0, cptab->ctb_mask);
>   node_set(0, cptab->ctb_nodemask);
>   cptab->ctb_nparts  = ncpt;
>   }

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


Re: [PATCH 01/25] staging: lustre: libcfs: remove useless CPU partition code

2018-04-16 Thread Dan Carpenter
On Mon, Apr 16, 2018 at 12:09:43AM -0400, James Simmons wrote:
> @@ -1033,6 +953,7 @@ static int cfs_cpu_dead(unsigned int cpu)
>  #endif
>   ret = -EINVAL;
>  
> + get_online_cpus();
>   if (*cpu_pattern) {
>   char *cpu_pattern_dup = kstrdup(cpu_pattern, GFP_KERNEL);
>  
> @@ -1058,13 +979,7 @@ static int cfs_cpu_dead(unsigned int cpu)
>   }
>   }
>  
> - spin_lock(_data.cpt_lock);
> - if (cfs_cpt_table->ctb_version != cpt_data.cpt_version) {
> - spin_unlock(_data.cpt_lock);
> - CERROR("CPU hotplug/unplug during setup\n");
> - goto failed;
> - }
> - spin_unlock(_data.cpt_lock);
> + put_online_cpus();
>  
>   LCONSOLE(0, "HW nodes: %d, HW CPU cores: %d, npartitions: %d\n",
>num_online_nodes(), num_online_cpus(),
> @@ -1072,6 +987,7 @@ static int cfs_cpu_dead(unsigned int cpu)
>   return 0;
>  
>   failed:
> + put_online_cpus();
>   cfs_cpu_fini();
>   return ret;
>  }

When you have a one label called "failed" then I call that "one err"
style error handling and it's the most bug prone style of error handling
to use.  Always be suspicious of code that uses a "err:" labels.

The bug here is typical.  We are calling put_online_cpus() on paths
where we didn't call get_online_cpus().

The best way to do error handling is to keep track of each resource that
was allocated and then only free the things that have been allocated.
Also the label name should indicate what was freed.  Generally avoid
magic, opaque functions like cfs_cpu_fini().  As a reviewer, it's
harder for me to check that cfs_cpu_fini() frees everything correctly
instead of the a normal list of frees like:

free_table:
cfs_cpt_table_free(cfs_cpt_table);
free_hotplug_stuff:
cpuhp_remove_state_nocalls(lustre_cpu_online);
set_state_dead:
cpuhp_remove_state_nocalls(CPUHP_LUSTRE_CFS_DEAD);

When I'm reading the code, and I see a "goto free_table;", I only need
to ask, "Was table the most recently allocated resource?"  If yes, then
the code is correct, if no then it's buggy.  It's simple review.

regards,
dan carpenter

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


RE: [PATCH v4 02/13] dt-bindings: usb: add documentation for typec port controller(TCPCI)

2018-04-16 Thread Jun Li
Hi
> -Original Message-
> From: Rob Herring [mailto:r...@kernel.org]
> Sent: 2018年4月10日 4:04
> To: Jun Li 
> Cc: gre...@linuxfoundation.org; heikki.kroge...@linux.intel.com;
> li...@roeck-us.net; a.ha...@samsung.com; shufan_...@richtek.com; Peter
> Chen ; devicet...@vger.kernel.org;
> linux-...@vger.kernel.org; dl-linux-imx ;
> de...@driverdev.osuosl.org
> Subject: Re: [PATCH v4 02/13] dt-bindings: usb: add documentation for typec
> port controller(TCPCI)
> 
> On Thu, Mar 29, 2018 at 12:06:07AM +0800, Li Jun wrote:
> > TCPCI stands for typec port controller interface, its implementation
> > has full typec port control with power delivery support, it's a
> > standard i2c slave with GPIO input as irq interface, detail see spec
> > "Universal Serial Bus Type-C Port Controller Interface Specification
> > Revision 1.0, Version 1.1"
> >
> > Signed-off-by: Li Jun 
> > ---
> >  .../devicetree/bindings/usb/typec-tcpci.txt| 33
> ++
> >  1 file changed, 33 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/usb/typec-tcpci.txt
> > b/Documentation/devicetree/bindings/usb/typec-tcpci.txt
> > new file mode 100644
> > index 000..7a7a8e0
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/usb/typec-tcpci.txt
> > @@ -0,0 +1,33 @@
> > +TCPCI(Typec port cotroller interface) binding
> > +-
> > +
> > +Required properties:
> > +- compatible:   should be "usb-tcpci,chip-specific-string".
> 
> Compatible strings should be in the form of ","
> 

OK, I will list the specific compatible string here and change
my example case to be "nxp,ptn5110".

> > +- reg:  the i2c slave address of typec port controller device.
> > +- interrupt-parent: the phandle to the interrupt controller which provides
> > +the interrupt.
> > +- interrupts:   interrupt specification for tcpci alert.
> > +
> > +Required sub-node:
> > +- connector: The "usb-c-connector" attached to the tcpci chip, the
> > +bindings
> > +  of connector node are specified in
> > +  Documentation/devicetree/bindings/connector/usb-connector.txt
> > +
> > +Example:
> > +
> > +ptn5110@50 {
> > +   compatible = "usb-tcpci,ptn5110";
> > +   reg = <0x50>;
> > +   interrupt-parent = <>;
> > +   interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
> > +
> > +   usb_con: connector {
> 
> How is the OF graph done in this case? You need some link to the USB 
> controller.

The platform(i.MX8MQ EVK) for this is still on the way of start upstream, I was
Planning to add this part with enabling USB3 function, as of how this will be 
done,
I only have usb3 ss data(no display port or Sideband), is something like below 
OK?

typec: ptn5110@50 {
compatible = "nxp,ptn5110";
...

usb_con: connector {
compatible = "usb-c-connector";
label = "USB-C";
...

ports {
#address-cells = <1>;
#size-cells = <0>;

port@1 {
reg = <1>;
usb_con_ss: endpoint {
remote-endpoint = <_phy_ss>;
};
};
};
};
};

_phy0 {
status = "okay";

port {
usb3_phy_ss: endpoint {
remote-endpoint = <_con_ss>;
};
};
}

Thanks
Jun
> 
> > +   compatible = "usb-c-connector";
> > +   label = "USB-C";
> > +   port-type = "dual";
> > +   try-power-role = "sink"
> > +   source-pdos = <0x380190c8>;
> > +   sink-pdos = <0x380190c8 0x3802d0c8>;
> > +   op-sink-microwatt-hours = <900>;
> > +   };
> > +};
> > --
> > 2.7.4
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe devicetree"
> > in the body of a message to majord...@vger.kernel.org More majordomo
> > info at
> > https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fvger
> > .kernel.org%2Fmajordomo-info.html=02%7C01%7Cjun.li%40nxp.com%7C
> 86
> >
> a7c0da18204df434d208d59e550c27%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0
> %
> >
> 7C0%7C636589010562193065=0%2FmoDrqWn9YghWGucWYnMd1YK0BO2
> dVgp%2Fa
> > KNZZZ%2BXE%3D=0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/10] staging: ks7010: avoid one level indentation in devio_rec_ind function

2018-04-16 Thread Sergio Paracuellos
This commit changes logic to handle with the status of the device
at first checking for close state to return directly instead
of just do the stuff when device is open. This improves readability
avoiding one level indentation.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 31 ---
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 995cb9a..ceec638 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1569,24 +1569,25 @@ void hostif_mic_failure_request(struct ks_wlan_private 
*priv,
 static void devio_rec_ind(struct ks_wlan_private *priv, unsigned char *p,
  unsigned int size)
 {
-   if (priv->is_device_open) {
-   spin_lock(>dev_read_lock);/* request spin lock */
-   priv->dev_data[atomic_read(>rec_count)] = p;
-   priv->dev_size[atomic_read(>rec_count)] = size;
-
-   if (atomic_read(>event_count) != DEVICE_STOCK_COUNT) {
-   /* rx event count inc */
-   atomic_inc(>event_count);
-   }
-   atomic_inc(>rec_count);
-   if (atomic_read(>rec_count) == DEVICE_STOCK_COUNT)
-   atomic_set(>rec_count, 0);
+   if (!priv->is_device_open)
+   return;
 
-   wake_up_interruptible_all(>devread_wait);
+   spin_lock(>dev_read_lock);/* request spin lock */
+   priv->dev_data[atomic_read(>rec_count)] = p;
+   priv->dev_size[atomic_read(>rec_count)] = size;
 
-   /* release spin lock */
-   spin_unlock(>dev_read_lock);
+   if (atomic_read(>event_count) != DEVICE_STOCK_COUNT) {
+   /* rx event count inc */
+   atomic_inc(>event_count);
}
+   atomic_inc(>rec_count);
+   if (atomic_read(>rec_count) == DEVICE_STOCK_COUNT)
+   atomic_set(>rec_count, 0);
+
+   wake_up_interruptible_all(>devread_wait);
+
+   /* release spin lock */
+   spin_unlock(>dev_read_lock);
 }
 
 void hostif_receive(struct ks_wlan_private *priv, unsigned char *p,
-- 
2.7.4

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


[PATCH 05/10] staging: ks7010: change return value of ks_wlan_do_power_save function

2018-04-16 Thread Sergio Paracuellos
This commit change return value of ks_wlan_do_power_save function
from int to void. This function is just returning zero and return
value is not being checked also, so it is nonsense to return an
integer.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index f510c74..ec5e63d 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -92,14 +92,12 @@ static void ks_wlan_hw_wakeup_task(struct work_struct *work)
tasklet_enable(>sme_task);
 }
 
-static
-int ks_wlan_do_power_save(struct ks_wlan_private *priv)
+static void ks_wlan_do_power_save(struct ks_wlan_private *priv)
 {
if (is_connect_status(priv->connect_status))
hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST);
else
priv->dev_state = DEVICE_STATE_READY;
-   return 0;
 }
 
 static
-- 
2.7.4

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


[PATCH 04/10] staging: ks7010: remove superfluous comments in ks_hostif source file

2018-04-16 Thread Sergio Paracuellos
This commit removes some comments which are not necessary at all
because code is clear enough to understand its intention.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 39 +++---
 1 file changed, 7 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index ceec638..f510c74 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -17,9 +17,7 @@
 #include 
 #include 
 #include 
-
-/* Include Wireless Extension definition and check version */
-#include /* New driver API */
+#include 
 
 static inline void inc_smeqhead(struct ks_wlan_private *priv)
 {
@@ -118,34 +116,24 @@ int get_current_ap(struct ks_wlan_private *priv, struct 
link_ap_info_t *ap_info)
return -EPERM;
}
 
-   /* bssid */
memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
-   /* essid */
memcpy(ap->ssid.body, priv->reg.ssid.body,
   priv->reg.ssid.size);
ap->ssid.size = priv->reg.ssid.size;
-   /* rate_set */
memcpy(ap->rate_set.body, ap_info->rate_set.body,
   ap_info->rate_set.size);
ap->rate_set.size = ap_info->rate_set.size;
if (ap_info->ext_rate_set.size != 0) {
-   /* rate_set */
memcpy(>rate_set.body[ap->rate_set.size],
   ap_info->ext_rate_set.body,
   ap_info->ext_rate_set.size);
ap->rate_set.size += ap_info->ext_rate_set.size;
}
-   /* channel */
ap->channel = ap_info->ds_parameter.channel;
-   /* rssi */
ap->rssi = ap_info->rssi;
-   /* sq */
ap->sq = ap_info->sq;
-   /* noise */
ap->noise = ap_info->noise;
-   /* capability */
ap->capability = le16_to_cpu(ap_info->capability);
-   /* rsn */
if ((ap_info->rsn_mode & RSN_MODE_WPA2) &&
(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)) {
ap->rsn_ie.id = 0x30;
@@ -229,17 +217,11 @@ int get_ap_information(struct ks_wlan_private *priv, 
struct ap_info_t *ap_info,
 
memset(ap, 0, sizeof(struct local_ap_t));
 
-   /* bssid */
memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
-   /* rssi */
ap->rssi = ap_info->rssi;
-   /* sq */
ap->sq = ap_info->sq;
-   /* noise */
ap->noise = ap_info->noise;
-   /* capability */
ap->capability = le16_to_cpu(ap_info->capability);
-   /* channel */
ap->channel = ap_info->ch_info;
 
bp = ap_info->body;
@@ -507,7 +489,6 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
mib_val_type = get_word(priv);  /* MIB value type */
 
if (mib_status) {
-   /* in case of error */
netdev_err(priv->net_dev, "attribute=%08X, status=%08X\n",
   mib_attribute, mib_status);
return;
@@ -515,7 +496,6 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
 
switch (mib_attribute) {
case DOT11_MAC_ADDRESS:
-   /* MAC address */
hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS);
memcpy(priv->eth_addr, priv->rxp, ETH_ALEN);
priv->mac_address_valid = true;
@@ -530,7 +510,6 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
netdev_info(dev, "MAC ADDRESS = %pM\n", priv->eth_addr);
break;
case DOT11_PRODUCT_VERSION:
-   /* firmware version */
priv->version_size = priv->rx_size;
memcpy(priv->firmware_version, priv->rxp, priv->rx_size);
priv->firmware_version[priv->rx_size] = '\0';
@@ -720,13 +699,13 @@ void hostif_connect_indication(struct ks_wlan_private 
*priv)
connect_code = get_word(priv);
 
switch (connect_code) {
-   case RESULT_CONNECT:/* connect */
+   case RESULT_CONNECT:
if (!(priv->connect_status & FORCE_DISCONNECT))
netif_carrier_on(netdev);
tmp = FORCE_DISCONNECT & priv->connect_status;
priv->connect_status = tmp + CONNECT_STATUS;
break;
-   case RESULT_DISCONNECT: /* disconnect */
+   case RESULT_DISCONNECT:
netif_carrier_off(netdev);
tmp = FORCE_DISCONNECT & priv->connect_status;
priv->connect_status = tmp + DISCONNECT_STATUS;
@@ -968,7 +947,7 @@ void hostif_event_check(struct ks_wlan_private *priv)
 {
unsigned short event;
 
-   event = get_word(priv); /* get event */
+   event = get_word(priv);
switch (event) {
case HIF_DATA_IND:
hostif_data_indication(priv);
@@ -1572,7 +1551,7 @@ static void devio_rec_ind(struct ks_wlan_private *priv, 
unsigned char *p,
if (!priv->is_device_open)
return;
 
-  

[PATCH 09/10] staging: ks7010: avoid blank line between definitions in hostif_data_request

2018-04-16 Thread Sergio Paracuellos
This commit removes a blank line between definition in
hostif_data_request function.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index ebc3fb2..00e9fdf 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1029,7 +1029,6 @@ static void *hostif_generic_request(size_t size, int 
event)
 int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
 {
unsigned int skb_len = 0;
-
unsigned char *buffer = NULL;
unsigned int length = 0;
struct hostif_data_request_t *pp;
-- 
2.7.4

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


[PATCH 10/10] staging: ks7010: group some cases in switch-case block in hostif_mib_set_confirm

2018-04-16 Thread Sergio Paracuellos
This commit groups some case statements because its behaviour is
just do nothing which is the same as the default. Clean 'break'
keyword in those which are affected.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 00e9fdf..b182530 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -621,8 +621,6 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv)
case DOT11_RSN_CONFIG_AUTH_SUITE:
hostif_sme_enqueue(priv, SME_RSN_AUTH_CONFIRM);
break;
-   case DOT11_PMK_TSC:
-   break;
case DOT11_GMK1_TSC:
if (atomic_read(>psstatus.snooze_guard))
atomic_set(>psstatus.snooze_guard, 0);
@@ -631,15 +629,12 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv)
if (atomic_read(>psstatus.snooze_guard))
atomic_set(>psstatus.snooze_guard, 0);
break;
+   case DOT11_PMK_TSC:
case LOCAL_PMK:
-   break;
case LOCAL_GAIN:
-   break;
 #ifdef WPS
case LOCAL_WPS_ENABLE:
-   break;
case LOCAL_WPS_PROBE_REQ:
-   break;
 #endif /* WPS */
case LOCAL_REGION:
default:
-- 
2.7.4

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


[PATCH 07/10] staging: ks7010: refactor code for hostif_sme_sleep_set function

2018-04-16 Thread Sergio Paracuellos
This commit refactors code for hostif_sme_sleep_set function. This
function was using a switch-case block to handle only two states
where the action to do for them is the same. Just refactor a bit
to check for return condition at first and doing the common action
after in other case.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index ed329f9..1c10384 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -2014,19 +2014,13 @@ void hostif_sme_power_mgmt_set(struct ks_wlan_private 
*priv)
hostif_power_mgmt_request(priv, mode, wake_up, receive_dtims);
 }
 
-static
-void hostif_sme_sleep_set(struct ks_wlan_private *priv)
+static void hostif_sme_sleep_set(struct ks_wlan_private *priv)
 {
-   switch (priv->sleep_mode) {
-   case SLP_SLEEP:
-   hostif_sleep_request(priv, priv->sleep_mode);
-   break;
-   case SLP_ACTIVE:
-   hostif_sleep_request(priv, priv->sleep_mode);
-   break;
-   default:
-   break;
-   }
+   if (priv->sleep_mode != SLP_SLEEP &&
+   priv->sleep_mode != SLP_ACTIVE)
+   return;
+
+   hostif_sleep_request(priv, priv->sleep_mode);
 }
 
 static
-- 
2.7.4

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


[PATCH 08/10] staging: ks7010: fix warning aout long line in init_request

2018-04-16 Thread Sergio Paracuellos
This commit fix length of the definition line of init_request
function. Warning from checkpatch script for this is fixed.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 1c10384..ebc3fb2 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1283,7 +1283,8 @@ static __le16 ks_wlan_cap(struct ks_wlan_private *priv)
return cpu_to_le16((uint16_t)capability);
 }
 
-static void init_request(struct ks_wlan_private *priv, struct hostif_request_t 
*req)
+static void init_request(struct ks_wlan_private *priv,
+struct hostif_request_t *req)
 {
req->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
req->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
-- 
2.7.4

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


[PATCH 06/10] staging: ks7010: remove nonsense break from case block

2018-04-16 Thread Sergio Paracuellos
This commit removes 'break' from case block because the
code is just using the 'default' break for some cases and
this one can be included also there.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index ec5e63d..ed329f9 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -2285,7 +2285,6 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int 
event)
case SME_RSN_ENABLED_CONFIRM:
case SME_RSN_MODE_CONFIRM:
case SME_MODE_SET_CONFIRM:
-   break;
case SME_TERMINATE:
default:
break;
-- 
2.7.4

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


[PATCH 00/10] staging: ks7010: some new cleanups

2018-04-16 Thread Sergio Paracuellos
This patch series continue with the driver cleanups. It just contains
trivial cleanups in some files of the driver. For this to be applied
properly previous sent patch series must be applied before.

Sergio Paracuellos (10):
  staging: ks7010: use linux circular buffer header macros to handle tx
and rx queues
  staging: ks7010: change name and type for device_open_status field
  staging: ks7010: avoid one level indentation in devio_rec_ind function
  staging: ks7010: remove superfluous comments in ks_hostif source file
  staging: ks7010: change return value of ks_wlan_do_power_save function
  staging: ks7010: remove nonsense break from case block
  staging: ks7010: refactor code for hostif_sme_sleep_set function
  staging: ks7010: fix warning aout long line in init_request
  staging: ks7010: avoid blank line between definitions in
hostif_data_request
  staging: ks7010: group some cases in switch-case block in
hostif_mib_set_confirm

 drivers/staging/ks7010/ks7010_sdio.c |  49 ++---
 drivers/staging/ks7010/ks_hostif.c   | 100 +++
 drivers/staging/ks7010/ks_wlan.h |   2 +-
 drivers/staging/ks7010/ks_wlan_net.c |   4 +-
 4 files changed, 64 insertions(+), 91 deletions(-)

-- 
2.7.4

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


[PATCH 01/10] staging: ks7010: use linux circular buffer header macros to handle tx and rx queues

2018-04-16 Thread Sergio Paracuellos
This commit replace current custom implementation of some circular
buffer head and tail logic in favour of the use of macros defined
in linux circ_buf.h header. Queue related inline function names
have been review also.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c | 49 ++--
 1 file changed, 30 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 9c591e0..fedcbb3 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -10,6 +10,7 @@
  *   published by the Free Software Foundation.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -111,11 +112,10 @@ static inline void inc_txqtail(struct ks_wlan_private 
*priv)
priv->tx_dev.qtail = (priv->tx_dev.qtail + 1) % TX_DEVICE_BUFF_SIZE;
 }
 
-static inline unsigned int cnt_txqbody(struct ks_wlan_private *priv)
+static inline bool txq_has_space(struct ks_wlan_private *priv)
 {
-   unsigned int tx_cnt = priv->tx_dev.qtail - priv->tx_dev.qhead;
-
-   return (tx_cnt + TX_DEVICE_BUFF_SIZE) % TX_DEVICE_BUFF_SIZE;
+   return (CIRC_SPACE(priv->tx_dev.qhead, priv->tx_dev.qtail,
+  TX_DEVICE_BUFF_SIZE) > 0);
 }
 
 static inline void inc_rxqhead(struct ks_wlan_private *priv)
@@ -128,11 +128,22 @@ static inline void inc_rxqtail(struct ks_wlan_private 
*priv)
priv->rx_dev.qtail = (priv->rx_dev.qtail + 1) % RX_DEVICE_BUFF_SIZE;
 }
 
-static inline unsigned int cnt_rxqbody(struct ks_wlan_private *priv)
+static inline bool rxq_has_space(struct ks_wlan_private *priv)
+{
+   return (CIRC_SPACE(priv->rx_dev.qhead, priv->rx_dev.qtail,
+  RX_DEVICE_BUFF_SIZE) > 0);
+}
+
+static inline unsigned int txq_count(struct ks_wlan_private *priv)
 {
-   unsigned int rx_cnt = priv->rx_dev.qtail - priv->rx_dev.qhead;
+   return CIRC_CNT_TO_END(priv->tx_dev.qhead, priv->tx_dev.qtail,
+  TX_DEVICE_BUFF_SIZE);
+}
 
-   return (rx_cnt + RX_DEVICE_BUFF_SIZE) % RX_DEVICE_BUFF_SIZE;
+static inline unsigned int rxq_count(struct ks_wlan_private *priv)
+{
+   return CIRC_CNT_TO_END(priv->rx_dev.qhead, priv->rx_dev.qtail,
+  RX_DEVICE_BUFF_SIZE);
 }
 
 /* Read single byte from device address into byte (CMD52) */
@@ -258,11 +269,11 @@ static void _ks_wlan_hw_power_save(struct ks_wlan_private 
*priv)
   atomic_read(>psstatus.status),
   atomic_read(>psstatus.confirm_wait),
   atomic_read(>psstatus.snooze_guard),
-  cnt_txqbody(priv));
+  txq_count(priv));
 
if (atomic_read(>psstatus.confirm_wait) ||
atomic_read(>psstatus.snooze_guard) ||
-   cnt_txqbody(priv)) {
+   txq_has_space(priv)) {
queue_delayed_work(priv->wq, >rw_dwork, 0);
return;
}
@@ -308,7 +319,7 @@ static int enqueue_txdev(struct ks_wlan_private *priv, 
unsigned char *p,
goto err_complete;
}
 
-   if ((TX_DEVICE_BUFF_SIZE - 1) <= cnt_txqbody(priv)) {
+   if ((TX_DEVICE_BUFF_SIZE - 1) <= txq_count(priv)) {
netdev_err(priv->net_dev, "tx buffer overflow\n");
ret = -EOVERFLOW;
goto err_complete;
@@ -366,7 +377,7 @@ static void tx_device_task(struct ks_wlan_private *priv)
struct tx_device_buffer *sp;
int ret;
 
-   if (cnt_txqbody(priv) <= 0 ||
+   if (!txq_has_space(priv) ||
atomic_read(>psstatus.status) == PS_SNOOZE)
return;
 
@@ -385,7 +396,7 @@ static void tx_device_task(struct ks_wlan_private *priv)
(*sp->complete_handler)(priv, sp->skb);
inc_txqhead(priv);
 
-   if (cnt_txqbody(priv) > 0)
+   if (txq_has_space(priv))
queue_delayed_work(priv->wq, >rw_dwork, 0);
 }
 
@@ -413,7 +424,7 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, 
unsigned long size,
result = enqueue_txdev(priv, p, size, complete_handler, skb);
spin_unlock(>tx_dev.tx_dev_lock);
 
-   if (cnt_txqbody(priv) > 0)
+   if (txq_has_space(priv))
queue_delayed_work(priv->wq, >rw_dwork, 0);
 
return result;
@@ -424,12 +435,12 @@ static void rx_event_task(unsigned long dev)
struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;
struct rx_device_buffer *rp;
 
-   if (cnt_rxqbody(priv) > 0 && priv->dev_state >= DEVICE_STATE_BOOT) {
+   if (rxq_has_space(priv) && priv->dev_state >= DEVICE_STATE_BOOT) {
rp = >rx_dev.rx_dev_buff[priv->rx_dev.qhead];
hostif_receive(priv, rp->data, rp->size);
inc_rxqhead(priv);
 
-   if (cnt_rxqbody(priv) > 0)
+   if (rxq_has_space(priv))
tasklet_schedule(>rx_bh_task);
}
 }
@@ -442,7 

[PATCH 02/10] staging: ks7010: change name and type for device_open_status field

2018-04-16 Thread Sergio Paracuellos
This commit changes type for device_open_status field of ks_wlan_private
structure from int to bool. This variable is only be set to 1
on ks_wlan_net_start and set to 0 on ks_wlan_net_stop. For this
purpose it is not necessary at all to use an integer because a bool
is enough. This also renames field name from device_open_status to
is_device_open.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c   | 2 +-
 drivers/staging/ks7010/ks_wlan.h | 2 +-
 drivers/staging/ks7010/ks_wlan_net.c | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index f6ac9f0..995cb9a 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1569,7 +1569,7 @@ void hostif_mic_failure_request(struct ks_wlan_private 
*priv,
 static void devio_rec_ind(struct ks_wlan_private *priv, unsigned char *p,
  unsigned int size)
 {
-   if (priv->device_open_status) {
+   if (priv->is_device_open) {
spin_lock(>dev_read_lock);/* request spin lock */
priv->dev_data[atomic_read(>rec_count)] = p;
priv->dev_size[atomic_read(>rec_count)] = size;
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index 1b7036c..c1bab57 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -443,7 +443,7 @@ struct ks_wlan_private {
unsigned int need_commit;   /* for ioctl */
 
/* DeviceIoControl */
-   int device_open_status;
+   bool is_device_open;
atomic_t event_count;
atomic_t rec_count;
int dev_count;
diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index c0cea2f..5a4d661 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2877,7 +2877,7 @@ int ks_wlan_net_start(struct net_device *dev)
priv->mac_address_valid = false;
priv->need_commit = 0;
 
-   priv->device_open_status = 1;
+   priv->is_device_open = true;
 
/* phy information update timer */
atomic_set(_phyinfo, 0);
@@ -2908,7 +2908,7 @@ int ks_wlan_net_stop(struct net_device *dev)
 {
struct ks_wlan_private *priv = netdev_priv(dev);
 
-   priv->device_open_status = 0;
+   priv->is_device_open = false;
del_timer_sync(_phyinfo_timer);
 
if (netif_running(dev))
-- 
2.7.4

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


[PATCHv2 02/17] media: staging: atomisp: don't declare the same vars as both private and public

2018-04-16 Thread Mauro Carvalho Chehab
The mmu_private.h header is included at mmu.c, with duplicates the
already existing definitions at mmu_public.h.

Fix this by removing the erroneous header file.

Solve those issues:


drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/mmu_private.h:24:26:
 warning: function 'mmu_reg_store' with external linkage has definition

drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/mmu_private.h:35:30:
 warning: function 'mmu_reg_load' with external linkage has definition

drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/mmu_private.h:24:26:
 warning: function 'mmu_reg_store' with external linkage has definition

drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/mmu_private.h:35:30:
 warning: function 'mmu_reg_load' with external linkage has definition

Signed-off-by: Mauro Carvalho Chehab 
---

v2: re-added two function definitions that were at the mmu_private.h

 .../css2400/hive_isp_css_common/host/mmu.c |  4 --
 .../css2400/hive_isp_css_common/host/mmu_private.h | 44 --
 .../css2400/hive_isp_css_include/host/mmu_public.h | 22 +--
 .../css2400/hive_isp_css_include/mmu_device.h  |  8 
 4 files changed, 18 insertions(+), 60 deletions(-)
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/mmu_private.h

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/mmu.c
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/mmu.c
index a28b67eb66ea..1a1719d3e745 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/mmu.c
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/mmu.c
@@ -15,10 +15,6 @@
 /* The name "mmu.h is already taken" */
 #include "mmu_device.h"
 
-#ifndef __INLINE_MMU__
-#include "mmu_private.h"
-#endif /* __INLINE_MMU__ */
-
 void mmu_set_page_table_base_index(
const mmu_ID_t  ID,
const hrt_data  base_index)
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/mmu_private.h
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/mmu_private.h
deleted file mode 100644
index 7377666f6eb7..
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/mmu_private.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2010-2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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.
- */
-
-#ifndef __MMU_PRIVATE_H_INCLUDED__
-#define __MMU_PRIVATE_H_INCLUDED__
-
-#include "mmu_public.h"
-
-#include "device_access.h"
-
-#include "assert_support.h"
-
-STORAGE_CLASS_MMU_H void mmu_reg_store(
-   const mmu_ID_t  ID,
-   const unsigned int  reg,
-   const hrt_data  value)
-{
-   assert(ID < N_MMU_ID);
-   assert(MMU_BASE[ID] != (hrt_address)-1);
-   ia_css_device_store_uint32(MMU_BASE[ID] + reg*sizeof(hrt_data), value);
-   return;
-}
-
-STORAGE_CLASS_MMU_H hrt_data mmu_reg_load(
-   const mmu_ID_t  ID,
-   const unsigned int  reg)
-{
-   assert(ID < N_MMU_ID);
-   assert(MMU_BASE[ID] != (hrt_address)-1);
-   return ia_css_device_load_uint32(MMU_BASE[ID] + reg*sizeof(hrt_data));
-}
-
-#endif /* __MMU_PRIVATE_H_INCLUDED__ */
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/host/mmu_public.h
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/host/mmu_public.h
index 0a13eda73607..bbff4128603b 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/host/mmu_public.h
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/host/mmu_public.h
@@ -16,6 +16,8 @@
 #define __MMU_PUBLIC_H_INCLUDED__
 
 #include "system_types.h"
+#include "device_access.h"
+#include "assert_support.h"
 
 /*! Set the page table base index of MMU[ID]
 
@@ -62,10 +64,17 @@ extern void mmu_invalidate_cache_all(void);
 
  \return none, MMU[ID].ctrl[reg] = value
  */
-STORAGE_CLASS_MMU_H void mmu_reg_store(
+static inline void mmu_reg_store(
const mmu_ID_t  ID,
const unsigned int  reg,
-   const hrt_data  value);
+   const hrt_data  value)
+{
+   assert(ID < N_MMU_ID);
+   assert(MMU_BASE[ID] != (hrt_address)-1);
+