Re: [PATCH 1/2] mm: add locked parameter to get_user_pages()

2016-11-07 Thread Lorenzo Stoakes
On Mon, Nov 07, 2016 at 11:49:18AM +0100, Jesper Nilsson wrote:
> For the cris-part:
> Acked-by: Jesper Nilsson 

Thanks very much for that, however just to avoid any confusion, I realised this
series was not not the right way forward after discussion with Paolo and rather
it makes more sense to keep the API as it is and to update callers where it
makes sense to.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/2] mm: remove get_user_pages_locked()

2016-10-31 Thread Lorenzo Stoakes
On Mon, Oct 31, 2016 at 06:55:33PM +0100, Paolo Bonzini wrote:
> > 2. There is currently only one caller of get_user_pages_locked() in
> >mm/frame_vector.c which seems to suggest this function isn't widely
> >used/known.
>
> Or not widely necessary. :)

Well, quite :)
>
> > 3. This change results in all slow-path get_user_pages*() functions having 
> > the
> >ability to use VM_FAULT_RETRY logic rather than 'defaulting' to using
> >get_user_pages() that doesn't let you do this even if you wanted to.
>
> This is only true if someone does the work though.  From a quick look
> at your series, the following files can be trivially changed to use
> get_user_pages_unlocked:
>
> - drivers/gpu/drm/via/via_dmablit.c
> - drivers/platform/goldfish/goldfish_pipe.c
> - drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> - drivers/rapidio/devices/rio_mport_cdev.c
> - drivers/virt/fsl_hypervisor.c
>

Ah indeed, I rather glossed through the callers and noticed that at least some
held locks long enough or were called with a lock held sufficient that I wasn't
sure it could be released.

> Also, videobuf_dma_init_user could be changed to use retry by adding a
> *locked argument to videobuf_dma_init_user_locked, prototype patch
> after my signature.
>

Very nice!

> Everything else is probably best kept using get_user_pages.
>
> > 4. It's somewhat confusing/redundant having both get_user_pages_locked() and
> >get_user_pages() functions which both require mmap_sem to be held (i.e. 
> > both
> >are 'locked' versions.)
> >
> >> If all callers were changed, then sure removing the _locked suffix would
> >> be a good idea.
> >
> > It seems many callers cannot release mmap_sem so VM_FAULT_RETRY logic 
> > couldn't
> > happen anyway in this cases and in these cases we couldn't change the 
> > caller.
>
> But then get_user_pages_locked remains a less-common case, so perhaps
> it's a good thing to give it a longer name!

My (somewhat minor) concern was that there would be confusion due to the
existence of the triumvirate of g_u_p()/g_u_p_unlocked()/g_u_p_locked(), however
the comments do a decent enough job of explaining the situation.

>
> > Overall, an alternative here might be to remove get_user_pages() and update
> > get_user_pages_locked() to add a 'vmas' parameter, however doing this 
> > renders
> > get_user_pages_unlocked() asymmetric as it would lack an vmas parameter 
> > (adding
> > one there would make no sense as VM_FAULT_RETRY logic invalidates VMAs) 
> > though
> > perhaps not such a big issue as it makes sense as to why this is the case.
>
> Adding the 'vmas' parameter to get_user_pages_locked would make little
> sense.  Since VM_FAULT_RETRY invalidates it and g_u_p_locked can and
> does retry, it would generally not be useful.

I meant only in the case where we'd remove get_user_pages() and instead be left
with get_user_pages_[un]locked() only, meaning we'd have to add some means of
retrieving vmas if locked was set NULL, of course in cases where locked is not
NULL it makes no sense to add it.

>
> So I think we have the right API now:
>
> - do not have lock?  Use get_user_pages_unlocked, get retry for free,
> no need to handle  mmap_sem and the locked argument; cannot get back vmas.
>
> - have and cannot drop lock?  User get_user_pages, no need to pass NULL
> for the locked argument; can get back vmas.
>
> - have but can drop lock (rare case)?  Use get_user_pages_locked,
> cannot get back vams.

Yeah I think this is sane as it is actually, this patch set was a lot less
convincing of a cleanup than prior ones and overall it seems we are better off
with the existing API.

I wonder whether a better patch series to come out of this would be to find
cases where the lock could be dropped (i.e. the ones you mention above) and to
switch to using get_user_pages_[un]locked() where it makes sense to.

I am happy to look into these cases (though of course I must leave your
suggested patch here to you :)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/2] mm: remove get_user_pages_locked()

2016-10-31 Thread Lorenzo Stoakes
On Mon, Oct 31, 2016 at 12:45:36PM +0100, Paolo Bonzini wrote:
>
>
> On 31/10/2016 11:02, Lorenzo Stoakes wrote:
> > - *
> > - * get_user_pages should be phased out in favor of
> > - * get_user_pages_locked|unlocked or get_user_pages_fast. Nothing
> > - * should use get_user_pages because it cannot pass
> > - * FAULT_FLAG_ALLOW_RETRY to handle_mm_fault.
>
> This comment should be preserved in some way.  In addition, removing

Could you clarify what you think should be retained?

The comment seems to me to be largely rendered redundant by this change -
get_user_pages() now offers identical behaviour, and of course the latter part
of the comment ('because it cannot pass FAULT_FLAG_ALLOW_RETRY') is rendered
incorrect by this change.

It could be replaced with a recommendation to make use of VM_FAULT_RETRY logic
if possible. Note that the line above retains the reference to
'get_user_pages_fast()' - 'See also get_user_pages_fast, for performance
critical applications.'

One important thing to note here is this is a comment on get_user_pages_remote()
for which it was already incorrect syntactically (I'm guessing once
get_user_pages_remote() was added it 'stole' get_user_pages()'s comment :)

> get_user_pages_locked() makes it harder (compared to a simple "git grep
> -w") to identify callers that lack allow-retry functionality).  So I'm
> not sure about the benefits of these patches.
>

That's a fair point, and certainly this cleanup series is less obviously helpful
than previous ones.

However, there are a few points in its favour:

1. get_user_pages_remote() was the mirror of get_user_pages() prior to adding an
   int *locked parameter to the former (necessary to allow for the unexport of
   __get_user_pages_unlocked()), differing only in task/mm being specified and
   FOLL_REMOTE being set. This patch series keeps these functions 'synchronised'
   in this respect.

2. There is currently only one caller of get_user_pages_locked() in
   mm/frame_vector.c which seems to suggest this function isn't widely
   used/known.

3. This change results in all slow-path get_user_pages*() functions having the
   ability to use VM_FAULT_RETRY logic rather than 'defaulting' to using
   get_user_pages() that doesn't let you do this even if you wanted to.

4. It's somewhat confusing/redundant having both get_user_pages_locked() and
   get_user_pages() functions which both require mmap_sem to be held (i.e. both
   are 'locked' versions.)

> If all callers were changed, then sure removing the _locked suffix would
> be a good idea.

It seems many callers cannot release mmap_sem so VM_FAULT_RETRY logic couldn't
happen anyway in this cases and in these cases we couldn't change the caller.


Overall, an alternative here might be to remove get_user_pages() and update
get_user_pages_locked() to add a 'vmas' parameter, however doing this renders
get_user_pages_unlocked() asymmetric as it would lack an vmas parameter (adding
one there would make no sense as VM_FAULT_RETRY logic invalidates VMAs) though
perhaps not such a big issue as it makes sense as to why this is the case.

get_user_pages_unlocked() definitely seems to be a useful helper and therefore
makes sense to retain.

Of course another alternative is to leave things be :)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] mm: add locked parameter to get_user_pages()

2016-10-31 Thread Lorenzo Stoakes
This patch adds an int *locked parameter to get_user_pages() to allow
VM_FAULT_RETRY faulting behaviour similar to get_user_pages_[un]locked().

It additionally clears the way for get_user_pages_locked() to be removed as its
sole remaining useful characteristic was to allow for VM_FAULT_RETRY behaviour
when faulting in pages.

It should not introduce any functional changes, however it does allow for
subsequent changes to get_user_pages() callers to take advantage of
VM_FAULT_RETRY.

Signed-off-by: Lorenzo Stoakes <lstoa...@gmail.com>
---
 arch/cris/arch-v32/drivers/cryptocop.c| 2 ++
 arch/ia64/kernel/err_inject.c | 2 +-
 arch/x86/mm/mpx.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c   | 2 +-
 drivers/gpu/drm/radeon/radeon_ttm.c   | 2 +-
 drivers/gpu/drm/via/via_dmablit.c | 2 +-
 drivers/infiniband/core/umem.c| 2 +-
 drivers/infiniband/hw/mthca/mthca_memfree.c   | 3 ++-
 drivers/infiniband/hw/qib/qib_user_pages.c| 2 +-
 drivers/infiniband/hw/usnic/usnic_uiom.c  | 2 +-
 drivers/media/v4l2-core/videobuf-dma-sg.c | 2 +-
 drivers/misc/mic/scif/scif_rma.c  | 1 +
 drivers/misc/sgi-gru/grufault.c   | 3 ++-
 drivers/platform/goldfish/goldfish_pipe.c | 2 +-
 drivers/rapidio/devices/rio_mport_cdev.c  | 2 +-
 .../staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c| 3 ++-
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 ++-
 drivers/virt/fsl_hypervisor.c | 2 +-
 include/linux/mm.h| 2 +-
 mm/gup.c  | 8 
 mm/ksm.c  | 3 ++-
 mm/mempolicy.c| 2 +-
 mm/nommu.c| 4 ++--
 virt/kvm/kvm_main.c   | 4 ++--
 24 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/arch/cris/arch-v32/drivers/cryptocop.c 
b/arch/cris/arch-v32/drivers/cryptocop.c
index 0068fd4..7444b45 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -2723,6 +2723,7 @@ static int cryptocop_ioctl_process(struct inode *inode, 
struct file *filp, unsig
 noinpages,
 0,  /* read access only for in data */
 inpages,
+NULL,
 NULL);
 
if (err < 0) {
@@ -2737,6 +2738,7 @@ static int cryptocop_ioctl_process(struct inode *inode, 
struct file *filp, unsig
 nooutpages,
 FOLL_WRITE, /* write access for out data */
 outpages,
+NULL,
 NULL);
up_read(>mm->mmap_sem);
if (err < 0) {
diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
index 5ed0ea9..99f3fa2 100644
--- a/arch/ia64/kernel/err_inject.c
+++ b/arch/ia64/kernel/err_inject.c
@@ -142,7 +142,7 @@ store_virtual_to_phys(struct device *dev, struct 
device_attribute *attr,
u64 virt_addr=simple_strtoull(buf, NULL, 16);
int ret;
 
-   ret = get_user_pages(virt_addr, 1, FOLL_WRITE, NULL, NULL);
+   ret = get_user_pages(virt_addr, 1, FOLL_WRITE, NULL, NULL, NULL);
if (ret<=0) {
 #ifdef ERR_INJ_DEBUG
printk("Virtual address %lx is not existing.\n",virt_addr);
diff --git a/arch/x86/mm/mpx.c b/arch/x86/mm/mpx.c
index e4f8009..b74a7b2 100644
--- a/arch/x86/mm/mpx.c
+++ b/arch/x86/mm/mpx.c
@@ -546,7 +546,7 @@ static int mpx_resolve_fault(long __user *addr, int write)
int nr_pages = 1;
 
gup_ret = get_user_pages((unsigned long)addr, nr_pages,
-   write ? FOLL_WRITE : 0, NULL, NULL);
+   write ? FOLL_WRITE : 0, NULL, NULL, NULL);
/*
 * get_user_pages() returns number of pages gotten.
 * 0 means we failed to fault in and get anything,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index dcaf691..3d9a195 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -584,7 +584,7 @@ int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct 
page **pages)
list_add(, >guptasks);
spin_unlock(>guptasklock);
 
-

[PATCH 2/2] mm: remove get_user_pages_locked()

2016-10-31 Thread Lorenzo Stoakes
get_user_pages() now has an int *locked parameter which renders
get_user_pages_locked() redundant, so remove it.

This patch should not introduce any functional changes.

Signed-off-by: Lorenzo Stoakes <lstoa...@gmail.com>
---
 include/linux/mm.h |  2 --
 mm/frame_vector.c  |  4 ++--
 mm/gup.c   | 56 +++---
 mm/nommu.c |  8 
 4 files changed, 22 insertions(+), 48 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 396984e..4db3147 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1278,8 +1278,6 @@ long get_user_pages_remote(struct task_struct *tsk, 
struct mm_struct *mm,
 long get_user_pages(unsigned long start, unsigned long nr_pages,
unsigned int gup_flags, struct page **pages,
struct vm_area_struct **vmas, int *locked);
-long get_user_pages_locked(unsigned long start, unsigned long nr_pages,
-   unsigned int gup_flags, struct page **pages, int *locked);
 long __get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm,
   unsigned long start, unsigned long nr_pages,
   struct page **pages, unsigned int gup_flags);
diff --git a/mm/frame_vector.c b/mm/frame_vector.c
index db77dcb..c5ce1b1 100644
--- a/mm/frame_vector.c
+++ b/mm/frame_vector.c
@@ -55,8 +55,8 @@ int get_vaddr_frames(unsigned long start, unsigned int 
nr_frames,
if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) {
vec->got_ref = true;
vec->is_pfns = false;
-   ret = get_user_pages_locked(start, nr_frames,
-   gup_flags, (struct page **)(vec->ptrs), );
+   ret = get_user_pages(start, nr_frames,
+   gup_flags, (struct page **)(vec->ptrs), NULL, );
goto out;
}
 
diff --git a/mm/gup.c b/mm/gup.c
index 6b5539e..6cec693 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -826,37 +826,6 @@ static __always_inline long __get_user_pages_locked(struct 
task_struct *tsk,
 }
 
 /*
- * We can leverage the VM_FAULT_RETRY functionality in the page fault
- * paths better by using either get_user_pages_locked() or
- * get_user_pages_unlocked().
- *
- * get_user_pages_locked() is suitable to replace the form:
- *
- *  down_read(>mmap_sem);
- *  do_something()
- *  get_user_pages(tsk, mm, ..., pages, NULL, NULL);
- *  up_read(>mmap_sem);
- *
- *  to:
- *
- *  int locked = 1;
- *  down_read(>mmap_sem);
- *  do_something()
- *  get_user_pages_locked(tsk, mm, ..., pages, );
- *  if (locked)
- *  up_read(>mmap_sem);
- */
-long get_user_pages_locked(unsigned long start, unsigned long nr_pages,
-  unsigned int gup_flags, struct page **pages,
-  int *locked)
-{
-   return __get_user_pages_locked(current, current->mm, start, nr_pages,
-  pages, NULL, locked, true,
-  gup_flags | FOLL_TOUCH);
-}
-EXPORT_SYMBOL(get_user_pages_locked);
-
-/*
  * Same as get_user_pages_unlocked(, FOLL_TOUCH) but it allows to
  * pass additional gup_flags as last parameter (like FOLL_HWPOISON).
  *
@@ -954,11 +923,6 @@ EXPORT_SYMBOL(get_user_pages_unlocked);
  * use the correct cache flushing APIs.
  *
  * See also get_user_pages_fast, for performance critical applications.
- *
- * get_user_pages should be phased out in favor of
- * get_user_pages_locked|unlocked or get_user_pages_fast. Nothing
- * should use get_user_pages because it cannot pass
- * FAULT_FLAG_ALLOW_RETRY to handle_mm_fault.
  */
 long get_user_pages_remote(struct task_struct *tsk, struct mm_struct *mm,
unsigned long start, unsigned long nr_pages,
@@ -976,6 +940,26 @@ EXPORT_SYMBOL(get_user_pages_remote);
  * less-flexible calling convention where we assume that the task
  * and mm being operated on are the current task's.  We also
  * obviously don't pass FOLL_REMOTE in here.
+ *
+ * We can leverage the VM_FAULT_RETRY functionality in the page fault
+ * paths better by using either get_user_pages()'s locked parameter or
+ * get_user_pages_unlocked().
+ *
+ * get_user_pages()'s locked parameter is suitable to replace the form:
+ *
+ *  down_read(>mmap_sem);
+ *  do_something()
+ *  get_user_pages(tsk, mm, ..., pages, NULL, NULL);
+ *  up_read(>mmap_sem);
+ *
+ *  to:
+ *
+ *  int locked = 1;
+ *  down_read(>mmap_sem);
+ *  do_something()
+ *  get_user_pages(tsk, mm, ..., pages, NULL, );
+ *  if (locked)
+ *  up_read(>mmap_sem);
  */
 long get_user_pages(unsigned long start, unsigned long nr_pages,
unsigned int gup_flags, struct page **pages,
diff --git a/mm/nommu.c b/mm/nommu.c
index 82aaa33..3d38d40 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -168,14 +168,6 @@ long get_use

[PATCH 0/2] mm: remove get_user_pages_locked()

2016-10-31 Thread Lorenzo Stoakes
by adding an int *locked parameter to get_user_pages() callers to this function
can now utilise VM_FAULT_RETRY functionality.

Taken in conjunction with the patch series adding the same parameter to
get_user_pages_remote() this means all slow-path get_user_pages*() functions
will now have the ability to utilise VM_FAULT_RETRY.

Additionally get_user_pages() and get_user_pages_remote() previously mirrored
one another in functionality differing only in the ability to specify task/mm,
this patch series reinstates this relationship.

This patch series should not introduce any functional changes.

Lorenzo Stoakes (2):
  mm: add locked parameter to get_user_pages()
  mm: remove get_user_pages_locked()

 arch/cris/arch-v32/drivers/cryptocop.c |  2 +
 arch/ia64/kernel/err_inject.c  |  2 +-
 arch/x86/mm/mpx.c  |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c|  2 +-
 drivers/gpu/drm/radeon/radeon_ttm.c|  2 +-
 drivers/gpu/drm/via/via_dmablit.c  |  2 +-
 drivers/infiniband/core/umem.c |  2 +-
 drivers/infiniband/hw/mthca/mthca_memfree.c|  3 +-
 drivers/infiniband/hw/qib/qib_user_pages.c |  2 +-
 drivers/infiniband/hw/usnic/usnic_uiom.c   |  2 +-
 drivers/media/v4l2-core/videobuf-dma-sg.c  |  2 +-
 drivers/misc/mic/scif/scif_rma.c   |  1 +
 drivers/misc/sgi-gru/grufault.c|  3 +-
 drivers/platform/goldfish/goldfish_pipe.c  |  2 +-
 drivers/rapidio/devices/rio_mport_cdev.c   |  2 +-
 .../interface/vchiq_arm/vchiq_2835_arm.c   |  3 +-
 .../vc04_services/interface/vchiq_arm/vchiq_arm.c  |  3 +-
 drivers/virt/fsl_hypervisor.c  |  2 +-
 include/linux/mm.h |  4 +-
 mm/frame_vector.c  |  4 +-
 mm/gup.c   | 62 --
 mm/ksm.c   |  3 +-
 mm/mempolicy.c |  2 +-
 mm/nommu.c | 10 +---
 virt/kvm/kvm_main.c|  4 +-
 25 files changed, 55 insertions(+), 73 deletions(-)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RESEND 2 1/5] staging: sm750fb: Use memset_io instead of memset

2015-03-23 Thread Lorenzo Stoakes
On 23 March 2015 at 13:21, Lorenzo Stoakes lstoa...@gmail.com wrote:
 Sigh. Checking the emails I actually sent, I seem to *somehow* have
 sent old files in this resend :S I really don't know how this
 happened. My copies of the patches all apply perfectly correctly, but
 these are not the ones I sent.

And just to add to my embarrassment, this is actually *not* the case,
they DO all apply, gmail mangled the patches. So they seem fine after
all!

Sudip - could you try to carefully grab each of the 5 patches with
[RESEND 2] in the subject to make sure you are applying them
correctly?

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RESEND 2 1/5] staging: sm750fb: Use memset_io instead of memset

2015-03-23 Thread Lorenzo Stoakes
On 23 March 2015 at 12:55, Sudip Mukherjee sudipm.mukher...@gmail.com wrote:

 and you need to send v3 now :(
 your series is not applying. Please refresh it against staging-testing

Applies to staging-testing for me. Are you sure you're applying the
correct 'RESEND 2' patches?

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RESEND 2 1/5] staging: sm750fb: Use memset_io instead of memset

2015-03-23 Thread Lorenzo Stoakes
On 23 March 2015 at 13:14, Sudip Mukherjee sudipm.mukher...@gmail.com wrote:
 On Mon, Mar 23, 2015 at 01:02:52PM +, Lorenzo Stoakes wrote:
 On 23 March 2015 at 12:55, Sudip Mukherjee sudipm.mukher...@gmail.com 
 wrote:

  and you need to send v3 now :(
  your series is not applying. Please refresh it against staging-testing

 Applies to staging-testing for me. Are you sure you're applying the
 correct 'RESEND 2' patches?
 i think. if you do git log drivers/staging/sm750fb/
 are you getting the first patch author as
 Ragavendra Nagraj ragavendra...@gmail.com ?

Yep:-

commit de99befd18c10d8085182a1facbb4b8760b2b6fe
Author: Ragavendra Nagraj ragavendra...@gmail.com
Date:   Wed Mar 18 02:37:42 2015 -0700

staging: sm750fb: Fixed no space and indent warns

I've tried applying resend 2 patches to both linux-next and
staging-testing in Greg's staging.git tree, they apply in both places.

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RESEND 2 1/5] staging: sm750fb: Use memset_io instead of memset

2015-03-23 Thread Lorenzo Stoakes
On 23 March 2015 at 11:51, Dan Carpenter dan.carpen...@oracle.com wrote:
 Oh hm...  This is an actual RESEND patch.

 RESEND is a flag to show a mess up in the system.  I like to take a look
 at those to see what went wrong.  The process failure was that you
 messed up the threading earlier.  Take a look at the --in-reply-to flag.

Will do, apologies for the mess up, it makes sense that the v2's
should be replies to their respective v1s.

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RESEND 2 1/5] staging: sm750fb: Use memset_io instead of memset

2015-03-23 Thread Lorenzo Stoakes
On 23 March 2015 at 13:16, Lorenzo Stoakes lstoa...@gmail.com wrote:
 I've tried applying resend 2 patches to both linux-next and
 staging-testing in Greg's staging.git tree, they apply in both places.

Sigh. Checking the emails I actually sent, I seem to *somehow* have
sent old files in this resend :S I really don't know how this
happened. My copies of the patches all apply perfectly correctly, but
these are not the ones I sent.

I'll bump versions using the correct --in-reply-to to fix this. Apologies again!

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RESEND 2 1/5] staging: sm750fb: Use memset_io instead of memset

2015-03-23 Thread Lorenzo Stoakes
On 23 March 2015 at 10:53, Dan Carpenter dan.carpen...@oracle.com wrote:
 Sorry I wasn't clear on this before.  Please, stop putting RESEND in the
 subject.  That's only for if you think we are screwing up or ignoring
 you.  Just put v2, and put what changed under the --- cut off.
 ---
 v2: changed the commit message

 https://www.google.com/#q=how+to+send+a+v2+patch


I have to say I'm quite massively confused on this :) and the linux
newbies link at the top of the results for that google search doesn't
seem to clear it up for me. May I be so cheeky as to ask you to help
me understand so I can do this better in future?:-

* Greg has asked me to send again because it wasn't clear which set
was applicable. This is why I appended RESEND 2 (the original RESEND
was the same deal but *also* containing fixups to apply to the latest
staging-testing) since I wasn't changing anything, just resending to
make clear which patch set is valid right now. In this case should I
simply append a version number to each patch in the series and resend?
* Which leads on to the next point of confusion - previously when I
changed *one* patch in a series then resent *all* patches in that
series with v2, I had complaints that 'this patch hasn't changed' on
the unchanged patches, leading me to think that you should only resend
patches that have actually changed (which fits the pattern of putting
a change message under the '---' - though of course you could say v2:
resend patchset or similar) - however this seems to be what causes the
confusion that leads to needing a resend in the first instance (maybe
a problem with options I'm passing to git send-email, perhaps I need
to use in-reply-to to make the v2's replies to the v1's.)
* If the former point is correct and I should only resend patches that
have actually changed, but I'm asked for a resend - what is the
correct course of action? And of course we end up with some patches at
v1, some at v1, so should all patches then be updated to v(MAX(v)+1)?

 Otherwise this set looks ok.  Thanks!

 Reviewed-by: Dan Carpenter dan.carpen...@oracle.com


Thanks for that, appreciated!

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RESEND 2 5/5] staging: sm750fb: Remove spinlock helper function

2015-03-20 Thread Lorenzo Stoakes
This patch removes the unnecessary spinlock helper function and instead
calls spin_lock and spin_unlock directly.

This does *not* resolve sparse warnings about context imbalances but these are
spurious.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/sm750.c | 53 +++--
 1 file changed, 30 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index be35429..a6658e1 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -56,23 +56,6 @@ static char * g_settings = NULL;
 static int g_dualview;
 static char * g_option = NULL;

-/* if not use spin_lock,system will die if user load driver
- * and immediatly unload driver frequently (dual)*/
-static inline void myspin_lock(spinlock_t * sl){
-   struct lynx_share * share;
-   share = container_of(sl,struct lynx_share,slock);
-   if(share-dual){
-   spin_lock(sl);
-   }
-}
-
-static inline void myspin_unlock(spinlock_t * sl){
-   struct lynx_share * share;
-   share = container_of(sl,struct lynx_share,slock);
-   if(share-dual){
-   spin_unlock(sl);
-   }
-}
 static const struct fb_videomode lynx750_ext[] = {
/*  1024x600-60 VESA[1.71:1]*/
{NULL,  60, 1024, 600, 20423, 144,  40, 18, 1, 104, 3,
@@ -209,13 +192,21 @@ static void lynxfb_ops_fillrect(struct fb_info* 
info,const struct fb_fillrect* r
color = (Bpp == 
1)?region-color:((u32*)info-pseudo_palette)[region-color];
rop = ( region-rop != ROP_COPY ) ? HW_ROP2_XOR:HW_ROP2_COPY;

-   myspin_lock(share-slock);
+   /*
+* If not use spin_lock,system will die if user load driver
+* and immediatly unload driver frequently (dual)
+*/
+   if (share-dual)
+   spin_lock(share-slock);
+
share-accel.de_fillrect(share-accel,
base,pitch,Bpp,
region-dx,region-dy,

region-width,region-height,
color,rop);
-   myspin_unlock(share-slock);
+
+   if (share-dual)
+   spin_unlock(share-slock);
 }

 static void lynxfb_ops_copyarea(struct fb_info * info,const struct fb_copyarea 
* region)
@@ -233,12 +224,20 @@ static void lynxfb_ops_copyarea(struct fb_info * 
info,const struct fb_copyarea *
pitch = info-fix.line_length;
Bpp = info-var.bits_per_pixel  3;

-   myspin_lock(share-slock);
+   /*
+* If not use spin_lock, system will die if user load driver
+* and immediatly unload driver frequently (dual)
+*/
+   if (share-dual)
+   spin_lock(share-slock);
+
share-accel.de_copyarea(share-accel,

base,pitch,region-sx,region-sy,

base,pitch,Bpp,region-dx,region-dy,

region-width,region-height,HW_ROP2_COPY);
-   myspin_unlock(share-slock);
+
+   if (share-dual)
+   spin_unlock(share-slock);
 }

 static void lynxfb_ops_imageblit(struct fb_info*info,const struct fb_image* 
image)
@@ -272,14 +271,22 @@ static void lynxfb_ops_imageblit(struct 
fb_info*info,const struct fb_image* imag
}
return;
 _do_work:
-   myspin_lock(share-slock);
+   /*
+* If not use spin_lock, system will die if user load driver
+* and immediatly unload driver frequently (dual)
+*/
+   if (share-dual)
+   spin_lock(share-slock);
+
share-accel.de_imageblit(share-accel,
image-data,image-width3,0,
base,pitch,Bpp,
image-dx,image-dy,
image-width,image-height,
fgcol,bgcol,HW_ROP2_COPY);
-   myspin_unlock(share-slock);
+
+   if (share-dual)
+   spin_unlock(share-slock);
 }

 static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,
--
2.3.3
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RESEND 2 2/5] staging: sm750fb: Make internal functions static

2015-03-20 Thread Lorenzo Stoakes
This patch declares externally unavailable functions static. This fixes
the following sparse warnings:-

drivers/staging/sm750fb/ddk750_hwi2c.c:63:6: warning: symbol 'hwI2CWaitTXDone' 
was not declared. Should it be static?
drivers/staging/sm750fb/ddk750_hwi2c.c:93:14: warning: symbol 'hwI2CWriteData' 
was not declared. Should it be static?
drivers/staging/sm750fb/ddk750_hwi2c.c:160:14: warning: symbol 'hwI2CReadData' 
was not declared. Should it be static?

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/ddk750_hwi2c.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_hwi2c.c 
b/drivers/staging/sm750fb/ddk750_hwi2c.c
index 84dfb6f..7826376 100644
--- a/drivers/staging/sm750fb/ddk750_hwi2c.c
+++ b/drivers/staging/sm750fb/ddk750_hwi2c.c
@@ -60,7 +60,7 @@ void hwI2CClose(void)
 }


-long hwI2CWaitTXDone(void)
+static long hwI2CWaitTXDone(void)
 {
 unsigned int timeout;

@@ -90,7 +90,7 @@ long hwI2CWaitTXDone(void)
  *  Return Value:
  *  Total number of bytes those are actually written.
  */
-unsigned int hwI2CWriteData(
+static unsigned int hwI2CWriteData(
 unsigned char deviceAddress,
 unsigned int length,
 unsigned char *pBuffer
@@ -157,7 +157,7 @@ unsigned int hwI2CWriteData(
  *  Return Value:
  *  Total number of actual bytes read from the slave device
  */
-unsigned int hwI2CReadData(
+static unsigned int hwI2CReadData(
 unsigned char deviceAddress,
 unsigned int length,
 unsigned char *pBuffer
--
2.3.2
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RESEND 2 4/5] staging: sm750fb: Fix __iomem pointer types

2015-03-20 Thread Lorenzo Stoakes
This patch annotates pointers as referring to I/O mapped memory where they ought
to be, removes now unnecessary ugly casts, eliminates an incorrect deref on I/O
mapped memory by using iowrite16 instead, and updates the pointer arithmetic
accordingly to take into account that the pointers are now byte-sized. This
fixes the following sparse warnings:-

drivers/staging/sm750fb/sm750_cursor.c:113:19: warning: cast removes address 
space of expression
drivers/staging/sm750fb/sm750_cursor.c:204:19: warning: cast removes address 
space of expression

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---

 drivers/staging/sm750fb/sm750_cursor.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750_cursor.c 
b/drivers/staging/sm750fb/sm750_cursor.c
index 6cceef1..c2ff3bd 100644
--- a/drivers/staging/sm750fb/sm750_cursor.c
+++ b/drivers/staging/sm750fb/sm750_cursor.c
@@ -98,7 +98,7 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
int i,j,count,pitch,offset;
u8 color,mask,opr;
u16 data;
-   u16 * pbuffer,*pstart;
+   void __iomem *pbuffer, *pstart;

/*  in byte*/
pitch = cursor-w  3;
@@ -106,11 +106,11 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
/* in byte  */
count = pitch * cursor-h;

-   /* in ushort */
-   offset = cursor-maxW * 2 / 8 / 2;
+   /* in byte */
+   offset = cursor-maxW * 2 / 8;

data = 0;
-   pstart = (u16 *)cursor-vstart;
+   pstart = cursor-vstart;
pbuffer = pstart;

 /*
@@ -161,7 +161,7 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
}
}
 #endif
-   *pbuffer = data;
+   iowrite16(data, pbuffer);

/* assume pitch is 1,2,4,8,...*/
 #if 0
@@ -174,7 +174,7 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
pstart += offset;
pbuffer = pstart;
}else{
-   pbuffer++;
+   pbuffer += sizeof(u16);
}

}
@@ -189,7 +189,7 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
int i,j,count,pitch,offset;
u8 color, mask;
u16 data;
-   u16 * pbuffer,*pstart;
+   void __iomem *pbuffer, *pstart;

/*  in byte*/
pitch = cursor-w  3;
@@ -197,11 +197,11 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
/* in byte  */
count = pitch * cursor-h;

-   /* in ushort */
-   offset = cursor-maxW * 2 / 8 / 2;
+   /* in byte */
+   offset = cursor-maxW * 2 / 8;

data = 0;
-   pstart = (u16 *)cursor-vstart;
+   pstart = cursor-vstart;
pbuffer = pstart;

for(i=0;icount;i++)
@@ -234,7 +234,7 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
data |= ((color  (1j))?1:2)(j*2);
}
 #endif
-   *pbuffer = data;
+   iowrite16(data, pbuffer);

/* assume pitch is 1,2,4,8,...*/
if(!(i(pitch-1)))
@@ -244,7 +244,7 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
pstart += offset;
pbuffer = pstart;
}else{
-   pbuffer++;
+   pbuffer += sizeof(u16);
}

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


[PATCH RESEND 2 1/5] staging: sm750fb: Use memset_io instead of memset

2015-03-20 Thread Lorenzo Stoakes
This patch takes into account that cursor-vstart, crtc-vScreen and
share-pvMem are pointers to memory-mapped I/O and thus we should use memset_io
to make this explicit. In addition, some architectures require special treatment
of memory-mapped I/O so the previous code could actually break without this
change.

This fixes the following sparse warnings:-

drivers/staging/sm750fb/sm750.c:489:17: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:490:17: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:501:17: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:502:17: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:833:5: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:1154:9: warning: incorrect type in argument 1 
(different address spaces)

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/sm750.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index aa0888c..3e36b6a 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -486,8 +486,8 @@ static int lynxfb_resume(struct pci_dev* pdev)
par = info-par;
crtc = par-crtc;
cursor = crtc-cursor;
-   memset(cursor-vstart, 0x0, cursor-size);
-   memset(crtc-vScreen,0x0,crtc-vidmem_size);
+   memset_io(cursor-vstart, 0x0, cursor-size);
+   memset_io(crtc-vScreen, 0x0, crtc-vidmem_size);
lynxfb_ops_set_par(info);
fb_set_suspend(info, 0);
}
@@ -498,8 +498,8 @@ static int lynxfb_resume(struct pci_dev* pdev)
par = info-par;
crtc = par-crtc;
cursor = crtc-cursor;
-   memset(cursor-vstart, 0x0, cursor-size);
-   memset(crtc-vScreen,0x0,crtc-vidmem_size);
+   memset_io(cursor-vstart, 0x0, cursor-size);
+   memset_io(crtc-vScreen, 0x0, crtc-vidmem_size);
lynxfb_ops_set_par(info);
fb_set_suspend(info, 0);
}
@@ -830,7 +830,7 @@ static int lynxfb_set_fbinfo(struct fb_info* info,int index)


 crtc-cursor.share = share;
-memset(crtc-cursor.vstart, 0, crtc-cursor.size);
+   memset_io(crtc-cursor.vstart, 0, crtc-cursor.size);
 if(!g_hwcursor){
 lynxfb_ops.fb_cursor = NULL;
 crtc-cursor.disable(crtc-cursor);
@@ -1151,7 +1151,7 @@ static int lynxfb_pci_probe(struct pci_dev * pdev,
}
 #endif

-   memset(share-pvMem,0,share-vidmem_size);
+   memset_io(share-pvMem, 0, share-vidmem_size);

pr_info(sm%3x mmio address = %p\n,share-devid,share-pvReg);

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


[PATCH RESEND 2 3/5] staging: sm750fb: Remove unused function

2015-03-20 Thread Lorenzo Stoakes
This patch removes the unused hw712_fillrect function. This patch fixes
the following sparse warning:-

drivers/staging/sm750fb/sm750_accel.c:95:5: warning: symbol 'hw712_fillrect' 
was not declared. Should it be static?

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/sm750_accel.c | 78 ---
 1 file changed, 78 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750_accel.c 
b/drivers/staging/sm750fb/sm750_accel.c
index 6521c3b..c5a3726 100644
--- a/drivers/staging/sm750fb/sm750_accel.c
+++ b/drivers/staging/sm750fb/sm750_accel.c
@@ -89,84 +89,6 @@ void hw_set2dformat(struct lynx_accel * accel,int fmt)
write_dpr(accel,DE_STRETCH_FORMAT,reg);
 }

-/* seems sm712 RectFill command is broken,so need use BitBlt to
- * replace it. */
-
-int hw712_fillrect(struct lynx_accel * accel,
-   u32 base,u32 pitch,u32 Bpp,
-   u32 x,u32 y,u32 width,u32 height,
-   u32 color,u32 rop)
-{
-   u32 deCtrl;
-   if(accel-de_wait() != 0)
-   {
-   /* int time wait and always busy,seems hardware
-* got something error */
-   pr_debug(%s:De engine always bussy\n,__func__);
-   return -1;
-   }
-   /* 24bpp 2d acceleration still not work,we already support 2d on
-* both 8/16/32 bpp now, so there is no harm if we disable 2d on
-* 24bpp for current stage. */
-#if 0
-   if(Bpp == 3){
-   width *= 3;
-   x *= 3;
-   write_dpr(accel,DE_PITCH,
-   FIELD_VALUE(0,DE_PITCH,DESTINATION,pitch)|
-   FIELD_VALUE(0,DE_PITCH,SOURCE,pitch));//dpr10
-   }
-   else
-#endif
-   {
-   write_dpr(accel,DE_PITCH,
-   FIELD_VALUE(0,DE_PITCH,DESTINATION,pitch/Bpp)|
-   FIELD_VALUE(0,DE_PITCH,SOURCE,pitch/Bpp));//dpr10
-
-   }
-
-   write_dpr(accel,DE_FOREGROUND,color);//DPR14
-   write_dpr(accel,DE_MONO_PATTERN_HIGH,~0);//DPR34
-   write_dpr(accel,DE_MONO_PATTERN_LOW,~0);//DPR38
-
-   write_dpr(accel,DE_WINDOW_SOURCE_BASE,base);//dpr44
-   write_dpr(accel,DE_WINDOW_DESTINATION_BASE,base);//dpr40
-
-
-   write_dpr(accel,DE_WINDOW_WIDTH,
-   FIELD_VALUE(0,DE_WINDOW_WIDTH,DESTINATION,pitch/Bpp)|
-   FIELD_VALUE(0,DE_WINDOW_WIDTH,SOURCE,pitch/Bpp));//dpr3c
-
-
-   write_dpr(accel,DE_DESTINATION,
-   FIELD_SET(0,DE_DESTINATION,WRAP,DISABLE)|
-   FIELD_VALUE(0,DE_DESTINATION,X,x)|
-   FIELD_VALUE(0,DE_DESTINATION,Y,y));//dpr4
-
-   write_dpr(accel,DE_DIMENSION,
-   FIELD_VALUE(0,DE_DIMENSION,X,width)|
-   FIELD_VALUE(0,DE_DIMENSION,Y_ET,height));//dpr8
-
-   deCtrl =
-   FIELD_SET(0,DE_CONTROL,STATUS,START)|
-   FIELD_SET(0,DE_CONTROL,COMMAND,BITBLT)|
-   FIELD_SET(0,DE_CONTROL,ROP2_SOURCE,PATTERN)|
-   FIELD_SET(0,DE_CONTROL,ROP_SELECT,ROP2)|
-   FIELD_VALUE(0,DE_CONTROL,ROP,rop);//dpr0xc
-#if 0
-   /* dump registers */
-   int i;
-   inf_msg(x,y,w,h = %d,%d,%d,%d\n,x,y,width,height);
-   for(i=0x04;i=0x44;i+=4){
-   inf_msg(dpr%02x = %08x\n,i,read_dpr(accel,i));
-   }
-   inf_msg(deCtrl = %08x\n,deCtrl);
-#endif
-
-   write_dpr(accel,DE_CONTROL,deCtrl);
-   return 0;
-}
-
 int hw_fillrect(struct lynx_accel * accel,
u32 base,u32 pitch,u32 Bpp,
u32 x,u32 y,u32 width,u32 height,
--
2.3.2
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RESEND v2 4/5] staging: sm750fb: Fix __iomem pointer types

2015-03-20 Thread Lorenzo Stoakes
On 20 March 2015 at 13:03, Greg KH gre...@linuxfoundation.org wrote:
 I only see 2 patches in this series, yet you refer to 5?  Please
 resend the whole series, I dropped your previous ones from my queue.

 thanks,

 greg k-h

I have resent all the patches as RESEND 2 as well as updating them to
apply against staging-testing.

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RESEND 5/5] staging: sm750fb: Remove spinlock helper function

2015-03-18 Thread Lorenzo Stoakes
This patch removes the unnecessary spinlock helper function and instead
calls spin_lock and spin_unlock directly.

This does *not* resolve sparse warnings about context imbalances but these are
spurious.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/sm750.c | 53 +++--
 1 file changed, 30 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index be35429..a6658e1 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -56,23 +56,6 @@ static char * g_settings = NULL;
 static int g_dualview;
 static char * g_option = NULL;

-/* if not use spin_lock,system will die if user load driver
- * and immediatly unload driver frequently (dual)*/
-static inline void myspin_lock(spinlock_t * sl){
-   struct lynx_share * share;
-   share = container_of(sl,struct lynx_share,slock);
-   if(share-dual){
-   spin_lock(sl);
-   }
-}
-
-static inline void myspin_unlock(spinlock_t * sl){
-   struct lynx_share * share;
-   share = container_of(sl,struct lynx_share,slock);
-   if(share-dual){
-   spin_unlock(sl);
-   }
-}
 static const struct fb_videomode lynx750_ext[] = {
/*  1024x600-60 VESA[1.71:1]*/
{NULL,  60, 1024, 600, 20423, 144,  40, 18, 1, 104, 3,
@@ -209,13 +192,21 @@ static void lynxfb_ops_fillrect(struct fb_info* 
info,const struct fb_fillrect* r
color = (Bpp == 
1)?region-color:((u32*)info-pseudo_palette)[region-color];
rop = ( region-rop != ROP_COPY ) ? HW_ROP2_XOR:HW_ROP2_COPY;

-   myspin_lock(share-slock);
+   /*
+* If not use spin_lock,system will die if user load driver
+* and immediatly unload driver frequently (dual)
+*/
+   if (share-dual)
+   spin_lock(share-slock);
+
share-accel.de_fillrect(share-accel,
base,pitch,Bpp,
region-dx,region-dy,

region-width,region-height,
color,rop);
-   myspin_unlock(share-slock);
+
+   if (share-dual)
+   spin_unlock(share-slock);
 }

 static void lynxfb_ops_copyarea(struct fb_info * info,const struct fb_copyarea 
* region)
@@ -233,12 +224,20 @@ static void lynxfb_ops_copyarea(struct fb_info * 
info,const struct fb_copyarea *
pitch = info-fix.line_length;
Bpp = info-var.bits_per_pixel  3;

-   myspin_lock(share-slock);
+   /*
+* If not use spin_lock, system will die if user load driver
+* and immediatly unload driver frequently (dual)
+*/
+   if (share-dual)
+   spin_lock(share-slock);
+
share-accel.de_copyarea(share-accel,

base,pitch,region-sx,region-sy,

base,pitch,Bpp,region-dx,region-dy,

region-width,region-height,HW_ROP2_COPY);
-   myspin_unlock(share-slock);
+
+   if (share-dual)
+   spin_unlock(share-slock);
 }

 static void lynxfb_ops_imageblit(struct fb_info*info,const struct fb_image* 
image)
@@ -272,14 +271,22 @@ static void lynxfb_ops_imageblit(struct 
fb_info*info,const struct fb_image* imag
}
return;
 _do_work:
-   myspin_lock(share-slock);
+   /*
+* If not use spin_lock, system will die if user load driver
+* and immediatly unload driver frequently (dual)
+*/
+   if (share-dual)
+   spin_lock(share-slock);
+
share-accel.de_imageblit(share-accel,
image-data,image-width3,0,
base,pitch,Bpp,
image-dx,image-dy,
image-width,image-height,
fgcol,bgcol,HW_ROP2_COPY);
-   myspin_unlock(share-slock);
+
+   if (share-dual)
+   spin_unlock(share-slock);
 }

 static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,
--
2.3.3
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RESEND 3/5] staging: sm750fb: Remove unused function

2015-03-18 Thread Lorenzo Stoakes
This patch removes the unused hw712_fillrect function. This patch fixes
the following sparse warning:-

drivers/staging/sm750fb/sm750_accel.c:95:5: warning: symbol 'hw712_fillrect' 
was not declared. Should it be static?

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/sm750_accel.c | 78 ---
 1 file changed, 78 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750_accel.c 
b/drivers/staging/sm750fb/sm750_accel.c
index 6521c3b..c5a3726 100644
--- a/drivers/staging/sm750fb/sm750_accel.c
+++ b/drivers/staging/sm750fb/sm750_accel.c
@@ -89,84 +89,6 @@ void hw_set2dformat(struct lynx_accel * accel,int fmt)
write_dpr(accel,DE_STRETCH_FORMAT,reg);
 }

-/* seems sm712 RectFill command is broken,so need use BitBlt to
- * replace it. */
-
-int hw712_fillrect(struct lynx_accel * accel,
-   u32 base,u32 pitch,u32 Bpp,
-   u32 x,u32 y,u32 width,u32 height,
-   u32 color,u32 rop)
-{
-   u32 deCtrl;
-   if(accel-de_wait() != 0)
-   {
-   /* int time wait and always busy,seems hardware
-* got something error */
-   pr_debug(%s:De engine always bussy\n,__func__);
-   return -1;
-   }
-   /* 24bpp 2d acceleration still not work,we already support 2d on
-* both 8/16/32 bpp now, so there is no harm if we disable 2d on
-* 24bpp for current stage. */
-#if 0
-   if(Bpp == 3){
-   width *= 3;
-   x *= 3;
-   write_dpr(accel,DE_PITCH,
-   FIELD_VALUE(0,DE_PITCH,DESTINATION,pitch)|
-   FIELD_VALUE(0,DE_PITCH,SOURCE,pitch));//dpr10
-   }
-   else
-#endif
-   {
-   write_dpr(accel,DE_PITCH,
-   FIELD_VALUE(0,DE_PITCH,DESTINATION,pitch/Bpp)|
-   FIELD_VALUE(0,DE_PITCH,SOURCE,pitch/Bpp));//dpr10
-
-   }
-
-   write_dpr(accel,DE_FOREGROUND,color);//DPR14
-   write_dpr(accel,DE_MONO_PATTERN_HIGH,~0);//DPR34
-   write_dpr(accel,DE_MONO_PATTERN_LOW,~0);//DPR38
-
-   write_dpr(accel,DE_WINDOW_SOURCE_BASE,base);//dpr44
-   write_dpr(accel,DE_WINDOW_DESTINATION_BASE,base);//dpr40
-
-
-   write_dpr(accel,DE_WINDOW_WIDTH,
-   FIELD_VALUE(0,DE_WINDOW_WIDTH,DESTINATION,pitch/Bpp)|
-   FIELD_VALUE(0,DE_WINDOW_WIDTH,SOURCE,pitch/Bpp));//dpr3c
-
-
-   write_dpr(accel,DE_DESTINATION,
-   FIELD_SET(0,DE_DESTINATION,WRAP,DISABLE)|
-   FIELD_VALUE(0,DE_DESTINATION,X,x)|
-   FIELD_VALUE(0,DE_DESTINATION,Y,y));//dpr4
-
-   write_dpr(accel,DE_DIMENSION,
-   FIELD_VALUE(0,DE_DIMENSION,X,width)|
-   FIELD_VALUE(0,DE_DIMENSION,Y_ET,height));//dpr8
-
-   deCtrl =
-   FIELD_SET(0,DE_CONTROL,STATUS,START)|
-   FIELD_SET(0,DE_CONTROL,COMMAND,BITBLT)|
-   FIELD_SET(0,DE_CONTROL,ROP2_SOURCE,PATTERN)|
-   FIELD_SET(0,DE_CONTROL,ROP_SELECT,ROP2)|
-   FIELD_VALUE(0,DE_CONTROL,ROP,rop);//dpr0xc
-#if 0
-   /* dump registers */
-   int i;
-   inf_msg(x,y,w,h = %d,%d,%d,%d\n,x,y,width,height);
-   for(i=0x04;i=0x44;i+=4){
-   inf_msg(dpr%02x = %08x\n,i,read_dpr(accel,i));
-   }
-   inf_msg(deCtrl = %08x\n,deCtrl);
-#endif
-
-   write_dpr(accel,DE_CONTROL,deCtrl);
-   return 0;
-}
-
 int hw_fillrect(struct lynx_accel * accel,
u32 base,u32 pitch,u32 Bpp,
u32 x,u32 y,u32 width,u32 height,
--
2.3.2
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RESEND 4/5] staging: sm750fb: Fix __iomem pointer types

2015-03-18 Thread Lorenzo Stoakes
This patch annotates pointers as referring to I/O mapped memory where they ought
to be, removes now unnecessary ugly casts, eliminates an incorrect deref on I/O
mapped memory by using iowrite16 instead, and updates the pointer arithmetic
accordingly to take into account that the pointers are now byte-sized. This
fixes the following sparse warnings:-

drivers/staging/sm750fb/sm750_cursor.c:113:19: warning: cast removes address 
space of expression
drivers/staging/sm750fb/sm750_cursor.c:204:19: warning: cast removes address 
space of expression

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/sm750_cursor.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750_cursor.c 
b/drivers/staging/sm750fb/sm750_cursor.c
index 6cceef1..c2ff3bd 100644
--- a/drivers/staging/sm750fb/sm750_cursor.c
+++ b/drivers/staging/sm750fb/sm750_cursor.c
@@ -98,7 +98,7 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
int i,j,count,pitch,offset;
u8 color,mask,opr;
u16 data;
-   u16 * pbuffer,*pstart;
+   void __iomem * pbuffer,*pstart;

/*  in byte*/
pitch = cursor-w  3;
@@ -106,11 +106,11 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
/* in byte  */
count = pitch * cursor-h;

-   /* in ushort */
-   offset = cursor-maxW * 2 / 8 / 2;
+   /* in byte */
+   offset = cursor-maxW * 2 / 8;

data = 0;
-   pstart = (u16 *)cursor-vstart;
+   pstart = cursor-vstart;
pbuffer = pstart;

 /*
@@ -161,7 +161,7 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
}
}
 #endif
-   *pbuffer = data;
+   iowrite16(data, pbuffer);

/* assume pitch is 1,2,4,8,...*/
 #if 0
@@ -174,7 +174,7 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
pstart += offset;
pbuffer = pstart;
}else{
-   pbuffer++;
+   pbuffer += sizeof(u16);
}

}
@@ -189,7 +189,7 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
int i,j,count,pitch,offset;
u8 color, mask;
u16 data;
-   u16 * pbuffer,*pstart;
+   void __iomem * pbuffer,*pstart;

/*  in byte*/
pitch = cursor-w  3;
@@ -197,11 +197,11 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
/* in byte  */
count = pitch * cursor-h;

-   /* in ushort */
-   offset = cursor-maxW * 2 / 8 / 2;
+   /* in byte */
+   offset = cursor-maxW * 2 / 8;

data = 0;
-   pstart = (u16 *)cursor-vstart;
+   pstart = cursor-vstart;
pbuffer = pstart;

for(i=0;icount;i++)
@@ -234,7 +234,7 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
data |= ((color  (1j))?1:2)(j*2);
}
 #endif
-   *pbuffer = data;
+   iowrite16(data, pbuffer);

/* assume pitch is 1,2,4,8,...*/
if(!(i(pitch-1)))
@@ -244,7 +244,7 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
pstart += offset;
pbuffer = pstart;
}else{
-   pbuffer++;
+   pbuffer += sizeof(u16);
}

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


[PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset

2015-03-18 Thread Lorenzo Stoakes
This patch uses memset_io instead of memset when using memset on __iomem
qualified pointers. This fixes the following sparse warnings:-

drivers/staging/sm750fb/sm750.c:489:17: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:490:17: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:501:17: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:502:17: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:833:5: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:1154:9: warning: incorrect type in argument 1 
(different address spaces)

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/sm750.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index aa0888c..3e36b6a 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -486,8 +486,8 @@ static int lynxfb_resume(struct pci_dev* pdev)
par = info-par;
crtc = par-crtc;
cursor = crtc-cursor;
-   memset(cursor-vstart, 0x0, cursor-size);
-   memset(crtc-vScreen,0x0,crtc-vidmem_size);
+   memset_io(cursor-vstart, 0x0, cursor-size);
+   memset_io(crtc-vScreen,0x0,crtc-vidmem_size);
lynxfb_ops_set_par(info);
fb_set_suspend(info, 0);
}
@@ -498,8 +498,8 @@ static int lynxfb_resume(struct pci_dev* pdev)
par = info-par;
crtc = par-crtc;
cursor = crtc-cursor;
-   memset(cursor-vstart, 0x0, cursor-size);
-   memset(crtc-vScreen,0x0,crtc-vidmem_size);
+   memset_io(cursor-vstart, 0x0, cursor-size);
+   memset_io(crtc-vScreen,0x0,crtc-vidmem_size);
lynxfb_ops_set_par(info);
fb_set_suspend(info, 0);
}
@@ -830,7 +830,7 @@ static int lynxfb_set_fbinfo(struct fb_info* info,int index)


 crtc-cursor.share = share;
-memset(crtc-cursor.vstart, 0, crtc-cursor.size);
+memset_io(crtc-cursor.vstart, 0, crtc-cursor.size);
 if(!g_hwcursor){
 lynxfb_ops.fb_cursor = NULL;
 crtc-cursor.disable(crtc-cursor);
@@ -1151,7 +1151,7 @@ static int lynxfb_pci_probe(struct pci_dev * pdev,
}
 #endif

-   memset(share-pvMem,0,share-vidmem_size);
+   memset_io(share-pvMem,0,share-vidmem_size);

pr_info(sm%3x mmio address = %p\n,share-devid,share-pvReg);

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


[PATCH RESEND 2/5] staging: sm750fb: Make internal functions static

2015-03-18 Thread Lorenzo Stoakes
This patch declares externally unavailable functions static. This fixes
the following sparse warnings:-

drivers/staging/sm750fb/ddk750_swi2c.c:223:6: warning: symbol 'swI2CStart' was 
not declared. Should it be static?
drivers/staging/sm750fb/ddk750_swi2c.c:234:6: warning: symbol 'swI2CStop' was 
not declared. Should it be static?
drivers/staging/sm750fb/ddk750_swi2c.c:252:6: warning: symbol 'swI2CWriteByte' 
was not declared. Should it be static?
drivers/staging/sm750fb/ddk750_swi2c.c:320:15: warning: symbol 'swI2CReadByte' 
was not declared. Should it be static?
drivers/staging/sm750fb/ddk750_swi2c.c:361:6: warning: symbol 
'swI2CInit_SM750LE' was not declared. Should it be static?
drivers/staging/sm750fb/ddk750_hwi2c.c:63:6: warning: symbol 'hwI2CWaitTXDone' 
was not declared. Should it be static?
drivers/staging/sm750fb/ddk750_hwi2c.c:93:14: warning: symbol 'hwI2CWriteData' 
was not declared. Should it be static?
drivers/staging/sm750fb/ddk750_hwi2c.c:160:14: warning: symbol 'hwI2CReadData' 
was not declared. Should it be static?

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/ddk750_hwi2c.c |  6 +++---
 drivers/staging/sm750fb/ddk750_swi2c.c | 10 +-
 drivers/staging/sm750fb/sm750_accel.c  |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_hwi2c.c 
b/drivers/staging/sm750fb/ddk750_hwi2c.c
index 84dfb6f..7826376 100644
--- a/drivers/staging/sm750fb/ddk750_hwi2c.c
+++ b/drivers/staging/sm750fb/ddk750_hwi2c.c
@@ -60,7 +60,7 @@ void hwI2CClose(void)
 }


-long hwI2CWaitTXDone(void)
+static long hwI2CWaitTXDone(void)
 {
 unsigned int timeout;

@@ -90,7 +90,7 @@ long hwI2CWaitTXDone(void)
  *  Return Value:
  *  Total number of bytes those are actually written.
  */
-unsigned int hwI2CWriteData(
+static unsigned int hwI2CWriteData(
 unsigned char deviceAddress,
 unsigned int length,
 unsigned char *pBuffer
@@ -157,7 +157,7 @@ unsigned int hwI2CWriteData(
  *  Return Value:
  *  Total number of actual bytes read from the slave device
  */
-unsigned int hwI2CReadData(
+static unsigned int hwI2CReadData(
 unsigned char deviceAddress,
 unsigned int length,
 unsigned char *pBuffer
diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c 
b/drivers/staging/sm750fb/ddk750_swi2c.c
index 1249759..516f5bb 100644
--- a/drivers/staging/sm750fb/ddk750_swi2c.c
+++ b/drivers/staging/sm750fb/ddk750_swi2c.c
@@ -220,7 +220,7 @@ static void swI2CAck(void)
 /*
  *  This function sends the start command to the slave device
  */
-void swI2CStart(void)
+static void swI2CStart(void)
 {
 /* Start I2C */
 swI2CSDA(1);
@@ -231,7 +231,7 @@ void swI2CStart(void)
 /*
  *  This function sends the stop command to the slave device
  */
-void swI2CStop(void)
+static void swI2CStop(void)
 {
 /* Stop the I2C */
 swI2CSCL(1);
@@ -249,7 +249,7 @@ void swI2CStop(void)
  *   0   - Success
  *  -1   - Fail to write byte
  */
-long swI2CWriteByte(unsigned char data)
+static long swI2CWriteByte(unsigned char data)
 {
 unsigned char value = data;
 int i;
@@ -317,7 +317,7 @@ long swI2CWriteByte(unsigned char data)
  *  Return Value:
  *  One byte data read from the Slave device
  */
-unsigned char swI2CReadByte(unsigned char ack)
+static unsigned char swI2CReadByte(unsigned char ack)
 {
 int i;
 unsigned char data = 0;
@@ -358,7 +358,7 @@ unsigned char swI2CReadByte(unsigned char ack)
  *  -1   - Fail to initialize the i2c
  *   0   - Success
  */
-long swI2CInit_SM750LE(
+static long swI2CInit_SM750LE(
 unsigned char i2cClkGPIO,
 unsigned char i2cDataGPIO
 )
--
2.3.2
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset

2015-03-18 Thread Lorenzo Stoakes
On 18 March 2015 at 10:59, Dan Carpenter dan.carpen...@oracle.com wrote:
 Btw, sorry for coming down hard on you.  You're a newbie and expected to
 make these mistakes.  Your patches are good and appreciated.

Thanks and no problem, I expect to receive robust criticism given the
high standards in the kernel and see it as a means to improve my
contributions :)


 Call it a v2 patch.  Put a note under the --- cut off line:
 v2: updated to apply to latest linux-next

 http://kernelnewbies.org/PatchTipsAndTricks


Great, thanks, will do! Very useful link!

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset

2015-03-18 Thread Lorenzo Stoakes
On 18 March 2015 at 10:50, Vitaly Kuznetsov vkuzn...@redhat.com wrote:
 ERROR is reported by scripts/checkpatch.pl (spaces are missing after
 ','). This coding style problem was there before your patch but I don't
 think it makes sense to preserve it.

[snip]

 WARNING: please, no spaces at the start of a line
 #137: FILE: drivers/staging/sm750fb/sm750.c:833:

[snip]

Hi Vitaly, these style issues have vexed me and I was not sure whether
to make changes or preserve all the obvious errors so as not to blend
the two changes inappropriately, however it does indeed make sense to
fix these on the lines I'm changing, will fix these!

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 6/6] staging: sm750fb: Remove spinlock helper function

2015-03-18 Thread Lorenzo Stoakes
On 18 March 2015 at 07:52, Sudip Mukherjee sudipm.mukher...@gmail.com wrote:
 your series is not applying anymore to linux-next.
 looks like some patches came from the Outreachy and were already
 applied.
 please redo it against staging-testing.

Will do that now! I think at this point it'll be easier for me to
resend the whole series to make it clear which is applicable right
now.

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset

2015-03-18 Thread Lorenzo Stoakes
On 18 March 2015 at 10:52, Dan Carpenter dan.carpen...@oracle.com wrote:
 I often say don't resend because something is minor and I don't want
 to slow you down but since you were resending it anyway then please fix
 it.  Also changelogs are really easy to fix.  In mutt, you can do it
 without leaving your email client.  So I have revised my earlier
 statement, please fix it.  :)

Will do!

I have experimented with mutt, I tend to just use git send-email
directly at the moment and edit patch files manually and use the gmail
web interface for reading/discussion, I am sure I will learn to do
things a little more sanely in time, the hard way :)

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset

2015-03-18 Thread Lorenzo Stoakes
On 18 March 2015 at 10:17, Dan Carpenter dan.carpen...@oracle.com wrote:
 Why is there a RESEND in the subject.

To avoid confusion (and Sudip explicitly mentioned there might be
some), and in addition I had to update my patch series to take into
account that it no longer applied due to another patch which applies
the ANSI C function prototype fixes having already been applied.

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset

2015-03-18 Thread Lorenzo Stoakes
On 18 March 2015 at 10:18, Dan Carpenter dan.carpen...@oracle.com wrote:

 This changelog still sucks.  It doesn't describe the effect of this
 behavior change for the user.  It doesn't even make it clear that you
 are aware that this is a behavior change.

 It doesn't say to me that you have asked yourself if the sparse
 annotations are correct.  Many times they are wrong.

My understanding, which as a new contributor is of course limited and
likely simply wrong in many aspects, is - these memset's are referring
to I/O mapped memory, which as far as I can tell is actually the case
here, so in order to make it explicit that this is the case and we
know it is, we use memset_io. As far as I understand the pointers
simply have a modifier applied which marks them as I/O mapped memory
for the purposes of sparse checking whether they are used consistently
as such and are not treated like they are a normal kernel pointer.

In this case the cursor-vstart and crtc-vScreen pointers, looking
through the source, explicitly refer to memory which is I/O mapped,
and is annotated as __iomem accordingly throughout.

I will update the message accordingly, obviously if I'm
misunderstanding something let me know.

 We have had this discussion before but you still sent the same exact
 bad changelog.

Actually you said:-

 When I see a patch like this, then I worry, What if the Sparse
 annotations are wrong?  The patch description doesn't say anything about
 that.  After review then I think the annotations are correct so that's
 fine.

And:-

 Yes.  The patch is correct.  I wasn't asking you to redo it.  From later
 patches it's actually clear that you know that this change is a bugfix
 and a behavior change.  But we get a lot of patches where people just
 randomly change things to please Sparse and it maybe silences a warning
 but it's not correct.  I can think of a few recentish examples where
 people used standard struct types which hold __iomem or __user pointers
 but they used them in non-standard ways so the pointers were actually
 normal kernel pointers.

So it wasn't clear *to me* you wanted me to change that, given you
asked me *not* to redo it explicitly (which I assumed applied to the
message too) - apologies if I misinterpreted this!

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RESEND v2 1/5] staging: sm750fb: Use memset_io instead of memset

2015-03-18 Thread Lorenzo Stoakes
This patch takes into account that cursor-vstart, crtc-vScreen and
share-pvMem are pointers to memory-mapped I/O and thus we should use memset_io
to make this explicit. In addition, some architectures require special treatment
of memory-mapped I/O so the previous code could actually break without this
change.

This fixes the following sparse warnings:-

drivers/staging/sm750fb/sm750.c:489:17: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:490:17: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:501:17: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:502:17: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:833:5: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:1154:9: warning: incorrect type in argument 1 
(different address spaces)

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
v2: Whitespace fixups, updated commit message

 drivers/staging/sm750fb/sm750.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index aa0888c..3e36b6a 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -486,8 +486,8 @@ static int lynxfb_resume(struct pci_dev* pdev)
par = info-par;
crtc = par-crtc;
cursor = crtc-cursor;
-   memset(cursor-vstart, 0x0, cursor-size);
-   memset(crtc-vScreen,0x0,crtc-vidmem_size);
+   memset_io(cursor-vstart, 0x0, cursor-size);
+   memset_io(crtc-vScreen, 0x0, crtc-vidmem_size);
lynxfb_ops_set_par(info);
fb_set_suspend(info, 0);
}
@@ -498,8 +498,8 @@ static int lynxfb_resume(struct pci_dev* pdev)
par = info-par;
crtc = par-crtc;
cursor = crtc-cursor;
-   memset(cursor-vstart, 0x0, cursor-size);
-   memset(crtc-vScreen,0x0,crtc-vidmem_size);
+   memset_io(cursor-vstart, 0x0, cursor-size);
+   memset_io(crtc-vScreen, 0x0, crtc-vidmem_size);
lynxfb_ops_set_par(info);
fb_set_suspend(info, 0);
}
@@ -830,7 +830,7 @@ static int lynxfb_set_fbinfo(struct fb_info* info,int index)


 crtc-cursor.share = share;
-memset(crtc-cursor.vstart, 0, crtc-cursor.size);
+   memset_io(crtc-cursor.vstart, 0, crtc-cursor.size);
 if(!g_hwcursor){
 lynxfb_ops.fb_cursor = NULL;
 crtc-cursor.disable(crtc-cursor);
@@ -1151,7 +1151,7 @@ static int lynxfb_pci_probe(struct pci_dev * pdev,
}
 #endif

-   memset(share-pvMem,0,share-vidmem_size);
+   memset_io(share-pvMem, 0, share-vidmem_size);

pr_info(sm%3x mmio address = %p\n,share-devid,share-pvReg);

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


Re: [PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset

2015-03-18 Thread Lorenzo Stoakes
On 18 March 2015 at 11:25, Dan Carpenter dan.carpen...@oracle.com wrote:
 Could you read your patches again and find other similar white space
 issues.

Done.

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RESEND v2 4/5] staging: sm750fb: Fix __iomem pointer types

2015-03-18 Thread Lorenzo Stoakes
This patch annotates pointers as referring to I/O mapped memory where they ought
to be, removes now unnecessary ugly casts, eliminates an incorrect deref on I/O
mapped memory by using iowrite16 instead, and updates the pointer arithmetic
accordingly to take into account that the pointers are now byte-sized. This
fixes the following sparse warnings:-

drivers/staging/sm750fb/sm750_cursor.c:113:19: warning: cast removes address 
space of expression
drivers/staging/sm750fb/sm750_cursor.c:204:19: warning: cast removes address 
space of expression

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
v2: Whitespace fixups

 drivers/staging/sm750fb/sm750_cursor.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750_cursor.c 
b/drivers/staging/sm750fb/sm750_cursor.c
index 6cceef1..c2ff3bd 100644
--- a/drivers/staging/sm750fb/sm750_cursor.c
+++ b/drivers/staging/sm750fb/sm750_cursor.c
@@ -98,7 +98,7 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
int i,j,count,pitch,offset;
u8 color,mask,opr;
u16 data;
-   u16 * pbuffer,*pstart;
+   void __iomem *pbuffer, *pstart;

/*  in byte*/
pitch = cursor-w  3;
@@ -106,11 +106,11 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
/* in byte  */
count = pitch * cursor-h;

-   /* in ushort */
-   offset = cursor-maxW * 2 / 8 / 2;
+   /* in byte */
+   offset = cursor-maxW * 2 / 8;

data = 0;
-   pstart = (u16 *)cursor-vstart;
+   pstart = cursor-vstart;
pbuffer = pstart;

 /*
@@ -161,7 +161,7 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
}
}
 #endif
-   *pbuffer = data;
+   iowrite16(data, pbuffer);

/* assume pitch is 1,2,4,8,...*/
 #if 0
@@ -174,7 +174,7 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
pstart += offset;
pbuffer = pstart;
}else{
-   pbuffer++;
+   pbuffer += sizeof(u16);
}

}
@@ -189,7 +189,7 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
int i,j,count,pitch,offset;
u8 color, mask;
u16 data;
-   u16 * pbuffer,*pstart;
+   void __iomem *pbuffer, *pstart;

/*  in byte*/
pitch = cursor-w  3;
@@ -197,11 +197,11 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
/* in byte  */
count = pitch * cursor-h;

-   /* in ushort */
-   offset = cursor-maxW * 2 / 8 / 2;
+   /* in byte */
+   offset = cursor-maxW * 2 / 8;

data = 0;
-   pstart = (u16 *)cursor-vstart;
+   pstart = cursor-vstart;
pbuffer = pstart;

for(i=0;icount;i++)
@@ -234,7 +234,7 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
data |= ((color  (1j))?1:2)(j*2);
}
 #endif
-   *pbuffer = data;
+   iowrite16(data, pbuffer);

/* assume pitch is 1,2,4,8,...*/
if(!(i(pitch-1)))
@@ -244,7 +244,7 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
pstart += offset;
pbuffer = pstart;
}else{
-   pbuffer++;
+   pbuffer += sizeof(u16);
}

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


Re: [PATCH RESEND 1/5] staging: sm750fb: Use memset_io instead of memset

2015-03-18 Thread Lorenzo Stoakes
On 18 March 2015 at 10:59, Dan Carpenter dan.carpen...@oracle.com wrote:
 Call it a v2 patch.  Put a note under the --- cut off line:
 v2: updated to apply to latest linux-next

 http://kernelnewbies.org/PatchTipsAndTricks

Since each changed patch in the resend already incorporates changes to
update to apply to the latest linux-next, I instead referenced
whitespace/description changes (let me know if this isn't usually
something you'd reference) to avoid confusion, as otherwise I'd have
to resend other patches unchanged with just a v2 applied, then
additionally update the ones that need changes.

Let me know if you'd like this done differently!

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging/sm75fb: Declare static functions as such

2015-03-16 Thread Lorenzo Stoakes
On 16 March 2015 at 10:51, Ricardo Ribalda Delgado
ricardo.riba...@gmail.com wrote:
 This patch fixes this sparse warning

Hi Ricardo,

I currently have a patch series awaiting the final ok which includes
fixes for these warnings
(http://lkml.iu.edu/hypermail/linux/kernel/1503.1/02535.html),
apologies but assuming there isn't something hideously wrong with my
series I suspect they supersedes this patch :(

It's really easy to accidentally submit a patch that has already been
covered elsewhere; I, as a rather new kernel contributor, always find
I have to search quite a bit to be *sure* that it's not been covered
already.

Additionally, your subject line is 'staging/sm75fb: Declare static
functions as such' which ought to be 'staging: sm750fb: Declare static
functions as such' - there's a typo in the device name and I think the
convention is always to use colons in subject lines.

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 6/6] staging: sm750fb: Remove spinlock helper function

2015-03-12 Thread Lorenzo Stoakes
This patch removes the unnecessary spinlock helper function and instead
calls spin_lock and spin_unlock directly.

This does *not* resolve sparse warnings about context imbalances but these are
spurious.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/sm750.c | 47 +
 1 file changed, 24 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 3e36b6a..217795e 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -56,23 +56,6 @@ static char * g_settings = NULL;
 static int g_dualview = 0;
 static char * g_option = NULL;
 
-/* if not use spin_lock,system will die if user load driver
- * and immediatly unload driver frequently (dual)*/
-static inline void myspin_lock(spinlock_t * sl){
-   struct lynx_share * share;
-   share = container_of(sl,struct lynx_share,slock);
-   if(share-dual){
-   spin_lock(sl);
-   }
-}
-
-static inline void myspin_unlock(spinlock_t * sl){
-   struct lynx_share * share;
-   share = container_of(sl,struct lynx_share,slock);
-   if(share-dual){
-   spin_unlock(sl);
-   }
-}
 static const struct fb_videomode lynx750_ext[] = {
/*  1024x600-60 VESA[1.71:1]*/
{NULL,  60, 1024, 600, 20423, 144,  40, 18, 1, 104, 3,
@@ -209,13 +192,19 @@ static void lynxfb_ops_fillrect(struct fb_info* 
info,const struct fb_fillrect* r
color = (Bpp == 
1)?region-color:((u32*)info-pseudo_palette)[region-color];
rop = ( region-rop != ROP_COPY ) ? HW_ROP2_XOR:HW_ROP2_COPY;
 
-   myspin_lock(share-slock);
+   /* if not use spin_lock,system will die if user load driver
+* and immediatly unload driver frequently (dual)*/
+   if (share-dual)
+   spin_lock(share-slock);
+
share-accel.de_fillrect(share-accel,
base,pitch,Bpp,
region-dx,region-dy,

region-width,region-height,
color,rop);
-   myspin_unlock(share-slock);
+
+   if (share-dual)
+   spin_unlock(share-slock);
 }
 
 static void lynxfb_ops_copyarea(struct fb_info * info,const struct fb_copyarea 
* region)
@@ -233,12 +222,18 @@ static void lynxfb_ops_copyarea(struct fb_info * 
info,const struct fb_copyarea *
pitch = info-fix.line_length;
Bpp = info-var.bits_per_pixel  3;
 
-   myspin_lock(share-slock);
+   /* if not use spin_lock,system will die if user load driver
+* and immediatly unload driver frequently (dual)*/
+   if (share-dual)
+   spin_lock(share-slock);
+
share-accel.de_copyarea(share-accel,

base,pitch,region-sx,region-sy,

base,pitch,Bpp,region-dx,region-dy,

region-width,region-height,HW_ROP2_COPY);
-   myspin_unlock(share-slock);
+
+   if (share-dual)
+   spin_unlock(share-slock);
 }
 
 static void lynxfb_ops_imageblit(struct fb_info*info,const struct fb_image* 
image)
@@ -272,14 +267,20 @@ static void lynxfb_ops_imageblit(struct 
fb_info*info,const struct fb_image* imag
}
return;
 _do_work:
-   myspin_lock(share-slock);
+   /* if not use spin_lock,system will die if user load driver
+* and immediatly unload driver frequently (dual)*/
+   if (share-dual)
+   spin_lock(share-slock);
+
share-accel.de_imageblit(share-accel,
image-data,image-width3,0,
base,pitch,Bpp,
image-dx,image-dy,
image-width,image-height,
fgcol,bgcol,HW_ROP2_COPY);
-   myspin_unlock(share-slock);
+
+   if (share-dual)
+   spin_unlock(share-slock);
 }
 
 static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,
-- 
2.3.2

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


Re: [PATCH v2 6/6] staging: sm750fb: Remove spinlock helper function

2015-03-11 Thread Lorenzo Stoakes
On 11 March 2015 at 14:58, Sudip Mukherjee sudipm.mukher...@gmail.com wrote:

 tested the whole series on hardware, looks ok.


Great!

 now it depends on Greg if he wants to accept patches with such big
 commit logs, and another problem he will face is to get some patches from
 this thread and some from the old thread.
 (while testing i faced this problem to maintain the sequence of
  patches)

I am more than happy to resend the whole series as necessary if that
makes it easier for Greg or anyone else :) I have previously
resubmitted an entire patch series only for people to find the v2
resubmits of unchanged code to be confusing. I am absolutely happy to
do whatever works for Greg of course!

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 3/6] staging: sm750fb: Make internal functions static

2015-03-11 Thread Lorenzo Stoakes
This patch declares externally unavailable functions static. This fixes
the following sparse warnings:-

drivers/staging/sm750fb/ddk750_swi2c.c:223:6: warning: symbol 'swI2CStart' was 
not declared. Should it be static?
drivers/staging/sm750fb/ddk750_swi2c.c:234:6: warning: symbol 'swI2CStop' was 
not declared. Should it be static?
drivers/staging/sm750fb/ddk750_swi2c.c:252:6: warning: symbol 'swI2CWriteByte' 
was not declared. Should it be static?
drivers/staging/sm750fb/ddk750_swi2c.c:320:15: warning: symbol 'swI2CReadByte' 
was not declared. Should it be static?
drivers/staging/sm750fb/ddk750_swi2c.c:361:6: warning: symbol 
'swI2CInit_SM750LE' was not declared. Should it be static?
drivers/staging/sm750fb/ddk750_hwi2c.c:63:6: warning: symbol 'hwI2CWaitTXDone' 
was not declared. Should it be static?
drivers/staging/sm750fb/ddk750_hwi2c.c:93:14: warning: symbol 'hwI2CWriteData' 
was not declared. Should it be static?
drivers/staging/sm750fb/ddk750_hwi2c.c:160:14: warning: symbol 'hwI2CReadData' 
was not declared. Should it be static?

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/ddk750_hwi2c.c |  6 +++---
 drivers/staging/sm750fb/ddk750_swi2c.c | 10 +-
 drivers/staging/sm750fb/sm750_accel.c  |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_hwi2c.c 
b/drivers/staging/sm750fb/ddk750_hwi2c.c
index 84dfb6f..7826376 100644
--- a/drivers/staging/sm750fb/ddk750_hwi2c.c
+++ b/drivers/staging/sm750fb/ddk750_hwi2c.c
@@ -60,7 +60,7 @@ void hwI2CClose(void)
 }
 
 
-long hwI2CWaitTXDone(void)
+static long hwI2CWaitTXDone(void)
 {
 unsigned int timeout;
 
@@ -90,7 +90,7 @@ long hwI2CWaitTXDone(void)
  *  Return Value:
  *  Total number of bytes those are actually written.
  */
-unsigned int hwI2CWriteData(
+static unsigned int hwI2CWriteData(
 unsigned char deviceAddress,
 unsigned int length,
 unsigned char *pBuffer
@@ -157,7 +157,7 @@ unsigned int hwI2CWriteData(
  *  Return Value:
  *  Total number of actual bytes read from the slave device
  */
-unsigned int hwI2CReadData(
+static unsigned int hwI2CReadData(
 unsigned char deviceAddress,
 unsigned int length,
 unsigned char *pBuffer
diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c 
b/drivers/staging/sm750fb/ddk750_swi2c.c
index 1249759..516f5bb 100644
--- a/drivers/staging/sm750fb/ddk750_swi2c.c
+++ b/drivers/staging/sm750fb/ddk750_swi2c.c
@@ -220,7 +220,7 @@ static void swI2CAck(void)
 /*
  *  This function sends the start command to the slave device
  */
-void swI2CStart(void)
+static void swI2CStart(void)
 {
 /* Start I2C */
 swI2CSDA(1);
@@ -231,7 +231,7 @@ void swI2CStart(void)
 /*
  *  This function sends the stop command to the slave device
  */
-void swI2CStop(void)
+static void swI2CStop(void)
 {
 /* Stop the I2C */
 swI2CSCL(1);
@@ -249,7 +249,7 @@ void swI2CStop(void)
  *   0   - Success
  *  -1   - Fail to write byte
  */
-long swI2CWriteByte(unsigned char data)
+static long swI2CWriteByte(unsigned char data)
 {
 unsigned char value = data;
 int i;
@@ -317,7 +317,7 @@ long swI2CWriteByte(unsigned char data)
  *  Return Value:
  *  One byte data read from the Slave device
  */
-unsigned char swI2CReadByte(unsigned char ack)
+static unsigned char swI2CReadByte(unsigned char ack)
 {
 int i;
 unsigned char data = 0;
@@ -358,7 +358,7 @@ unsigned char swI2CReadByte(unsigned char ack)
  *  -1   - Fail to initialize the i2c
  *   0   - Success
  */
-long swI2CInit_SM750LE(
+static long swI2CInit_SM750LE(
 unsigned char i2cClkGPIO,
 unsigned char i2cDataGPIO
 )
-- 
2.3.2

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


Re: [PATCH v2 4/6] staging: sm750fb: Remove unused function

2015-03-11 Thread Lorenzo Stoakes
On 11 March 2015 at 10:57, Sudip Mukherjee sudipm.mukher...@gmail.com wrote:
 but function prototype still remains in sm750_accel.h

No it doesn't, v2 of patch 3 in the series no longer puts it there :)

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/6] staging: sm750fb: Use memset_io instead of memset

2015-03-11 Thread Lorenzo Stoakes
On 11 March 2015 at 10:35, Sudip Mukherjee
 i think i will better check v2 of your series on hardware

This is incoming in just a moment (though I only v2 patches in the
series I've changed which I think is the right way to make
modifications with a patch series.)

 , and while
 you are preparing that v2 keep in mind the changelog should not exceed
 72 characters. in your this series for all patches it was more than
 that.

I will update the messages in the changed patches accordingly, I'm not
sure this is worth a resend of all previous patches for however? I do
see quite a few patches in the log that exceed this.

Additionally, I suspect it would make the patches less readable to
wrap sparse warning lines so I think those ought to sit outside of
this limit.

I am more than happy to change these though if these ought to be kept
*strictly* to a 72 character limit throughout?

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 4/6] staging: sm750fb: Remove unused function

2015-03-11 Thread Lorenzo Stoakes
This patch removes the unused hw712_fillrect function. This patch fixes
the following sparse warning:-

drivers/staging/sm750fb/sm750_accel.c:95:5: warning: symbol 'hw712_fillrect' 
was not declared. Should it be static?

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/sm750_accel.c | 78 ---
 1 file changed, 78 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750_accel.c 
b/drivers/staging/sm750fb/sm750_accel.c
index 6521c3b..c5a3726 100644
--- a/drivers/staging/sm750fb/sm750_accel.c
+++ b/drivers/staging/sm750fb/sm750_accel.c
@@ -89,84 +89,6 @@ void hw_set2dformat(struct lynx_accel * accel,int fmt)
write_dpr(accel,DE_STRETCH_FORMAT,reg);
 }
 
-/* seems sm712 RectFill command is broken,so need use BitBlt to
- * replace it. */
-
-int hw712_fillrect(struct lynx_accel * accel,
-   u32 base,u32 pitch,u32 Bpp,
-   u32 x,u32 y,u32 width,u32 height,
-   u32 color,u32 rop)
-{
-   u32 deCtrl;
-   if(accel-de_wait() != 0)
-   {
-   /* int time wait and always busy,seems hardware
-* got something error */
-   pr_debug(%s:De engine always bussy\n,__func__);
-   return -1;
-   }
-   /* 24bpp 2d acceleration still not work,we already support 2d on
-* both 8/16/32 bpp now, so there is no harm if we disable 2d on
-* 24bpp for current stage. */
-#if 0
-   if(Bpp == 3){
-   width *= 3;
-   x *= 3;
-   write_dpr(accel,DE_PITCH,
-   FIELD_VALUE(0,DE_PITCH,DESTINATION,pitch)|
-   FIELD_VALUE(0,DE_PITCH,SOURCE,pitch));//dpr10
-   }
-   else
-#endif
-   {
-   write_dpr(accel,DE_PITCH,
-   FIELD_VALUE(0,DE_PITCH,DESTINATION,pitch/Bpp)|
-   FIELD_VALUE(0,DE_PITCH,SOURCE,pitch/Bpp));//dpr10
-
-   }
-
-   write_dpr(accel,DE_FOREGROUND,color);//DPR14
-   write_dpr(accel,DE_MONO_PATTERN_HIGH,~0);//DPR34
-   write_dpr(accel,DE_MONO_PATTERN_LOW,~0);//DPR38
-
-   write_dpr(accel,DE_WINDOW_SOURCE_BASE,base);//dpr44
-   write_dpr(accel,DE_WINDOW_DESTINATION_BASE,base);//dpr40
-
-
-   write_dpr(accel,DE_WINDOW_WIDTH,
-   FIELD_VALUE(0,DE_WINDOW_WIDTH,DESTINATION,pitch/Bpp)|
-   FIELD_VALUE(0,DE_WINDOW_WIDTH,SOURCE,pitch/Bpp));//dpr3c
-
-
-   write_dpr(accel,DE_DESTINATION,
-   FIELD_SET(0,DE_DESTINATION,WRAP,DISABLE)|
-   FIELD_VALUE(0,DE_DESTINATION,X,x)|
-   FIELD_VALUE(0,DE_DESTINATION,Y,y));//dpr4
-
-   write_dpr(accel,DE_DIMENSION,
-   FIELD_VALUE(0,DE_DIMENSION,X,width)|
-   FIELD_VALUE(0,DE_DIMENSION,Y_ET,height));//dpr8
-
-   deCtrl =
-   FIELD_SET(0,DE_CONTROL,STATUS,START)|
-   FIELD_SET(0,DE_CONTROL,COMMAND,BITBLT)|
-   FIELD_SET(0,DE_CONTROL,ROP2_SOURCE,PATTERN)|
-   FIELD_SET(0,DE_CONTROL,ROP_SELECT,ROP2)|
-   FIELD_VALUE(0,DE_CONTROL,ROP,rop);//dpr0xc
-#if 0
-   /* dump registers */
-   int i;
-   inf_msg(x,y,w,h = %d,%d,%d,%d\n,x,y,width,height);
-   for(i=0x04;i=0x44;i+=4){
-   inf_msg(dpr%02x = %08x\n,i,read_dpr(accel,i));
-   }
-   inf_msg(deCtrl = %08x\n,deCtrl);
-#endif
-
-   write_dpr(accel,DE_CONTROL,deCtrl);
-   return 0;
-}
-
 int hw_fillrect(struct lynx_accel * accel,
u32 base,u32 pitch,u32 Bpp,
u32 x,u32 y,u32 width,u32 height,
-- 
2.3.2

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


Re: [PATCH 1/6] staging: sm750fb: Use memset_io instead of memset

2015-03-11 Thread Lorenzo Stoakes
On 11 March 2015 at 08:54, Dan Carpenter dan.carpen...@oracle.com wrote:
 When I see a patch like this, then I worry, What if the Sparse
 annotations are wrong?  The patch description doesn't say anything about
 that.  After review then I think the annotations are correct so that's
 fine.

How do you mean? I was careful to check what sparse was referring to,
then investigate how memset should be used with pointers with a
__iomem qualifier. I'd like to be able to improve my patch
descriptions going forward as best I can :)

 Btw, do you have this hardware?  Are you able to test these changes?

Unfortunately not, I am trying to keep these changes as simple code
fixes that ought not to affect actual hardware behaviour as I can
(though of course you can never be entirely sure that's the case!)

I suspect that Sudip must have some real hardware, is this the case
Sudip? If it isn't too presumptuous of me to ask, perhaps you might be
able to check patches that are successfully merged into
staging-testing?

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/6] staging: sm750fb: Make internal functions static

2015-03-11 Thread Lorenzo Stoakes
On 11 March 2015 at 09:30, Sudip Mukherjee
 this is introducing a build warning, better remove this from your patch
 and send a separate patch to remove the function as this function is
 not used anywhere.

Hi Sudip,

I didn't realise I'd included the move to static in this patch. In a
later patch I expose this function in the header file. I'll update
this patch not to touch hw712_fillrect then remove it in a later patch
altogether.

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 4/6] staging: sm750fb: Expose hw712_fillrect externally

2015-03-11 Thread Lorenzo Stoakes
On 11 March 2015 at 09:37, Sudip Mukherjee sudipm.mukher...@gmail.com wrote:
 in your previous patch 3/6 you made it static now you are again
 removing the static keyword. may i ask why you changed it in 3/6 if you
 again change it back to original in this patch?

There's no good reason, it's just a mistake :) I'll fix it shortly.

 anyways, like Dan said, delete this function, its not used anywhere.
 it will not be used also, i missed removing this function from the
 vendor crude drver.

Will do!

Best,
-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: sm750fb: Cleanup the type of mmio750

2015-03-10 Thread Lorenzo Stoakes
This patch assigns the more appropriate void* type to the mmio750 variable
eliminating an unnecessary volatile qualifier in the process. Additionally it
updates parameter types as necessary where those parameters interact with
mmio750 and removes unnecessary casts.

As a consequence, this patch fixes the following sparse warning:-

drivers/staging/sm750fb/ddk750_help.c:12:17: warning: incorrect type in 
assignment (different address spaces)

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com

---
 drivers/staging/sm750fb/ddk750_chip.h |  4 +++-
 drivers/staging/sm750fb/ddk750_help.c |  4 ++--
 drivers/staging/sm750fb/ddk750_help.h | 10 +-
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.h 
b/drivers/staging/sm750fb/ddk750_chip.h
index 1c78875..d067b06 100644
--- a/drivers/staging/sm750fb/ddk750_chip.h
+++ b/drivers/staging/sm750fb/ddk750_chip.h
@@ -3,6 +3,8 @@
 #define DEFAULT_INPUT_CLOCK 14318181 /* Default reference clock */
 #define SM750LE_REVISION_ID (char)0xfe
 
+#include linux/io.h
+
 /* This is all the chips recognized by this library */
 typedef enum _logical_chip_type_t
 {
@@ -70,7 +72,7 @@ logical_chip_type_t getChipType(void);
 unsigned int calcPllValue(unsigned int request,pll_value_t *pll);
 unsigned int calcPllValue2(unsigned int,pll_value_t *);
 unsigned int formatPllReg(pll_value_t *pPLL);
-void ddk750_set_mmio(volatile unsigned char *,unsigned short,char);
+void ddk750_set_mmio(void __iomem *,unsigned short,char);
 unsigned int ddk750_getVMSize(void);
 int ddk750_initHw(initchip_param_t *);
 unsigned int getPllValue(clock_type_t clockType, pll_value_t *pPLL);
diff --git a/drivers/staging/sm750fb/ddk750_help.c 
b/drivers/staging/sm750fb/ddk750_help.c
index cc00d2b..c68ff3b 100644
--- a/drivers/staging/sm750fb/ddk750_help.c
+++ b/drivers/staging/sm750fb/ddk750_help.c
@@ -2,12 +2,12 @@
 //#include ddk750_chip.h
 #include ddk750_help.h
 
-volatile unsigned char __iomem * mmio750 = NULL;
+void __iomem * mmio750 = NULL;
 char revId750 = 0;
 unsigned short devId750 = 0;
 
 /* after driver mapped io registers, use this function first */
-void ddk750_set_mmio(volatile unsigned char * addr,unsigned short devId,char 
revId)
+void ddk750_set_mmio(void __iomem * addr,unsigned short devId,char revId)
 {
mmio750 = addr;
devId750 = devId;
diff --git a/drivers/staging/sm750fb/ddk750_help.h 
b/drivers/staging/sm750fb/ddk750_help.h
index 4fc93b5..07c8264 100644
--- a/drivers/staging/sm750fb/ddk750_help.h
+++ b/drivers/staging/sm750fb/ddk750_help.h
@@ -12,14 +12,14 @@
 #if 0
 /* if 718 big endian turned on,be aware that don't use this driver for general 
use,only for ppc big-endian */
 #warning big endian on target cpu and enable nature big endian support of 718 
capability !
-#define PEEK32(addr)   __raw_readl((void __iomem 
*)(mmio750)+(addr))
-#define POKE32(addr,data)  __raw_writel((data),(void 
__iomem*)(mmio750)+(addr))
+#define PEEK32(addr)   __raw_readl(mmio750 + addr)
+#define POKE32(addr,data)  __raw_writel(data, mmio750 + addr)
 #else /* software control endianess */
-#define PEEK32(addr) readl((addr)+mmio750)
-#define POKE32(addr,data) writel((data),(addr)+mmio750)
+#define PEEK32(addr) readl(addr + mmio750)
+#define POKE32(addr,data) writel(data, addr + mmio750)
 #endif
 
-extern volatile unsigned  char __iomem * mmio750;
+extern void __iomem * mmio750;
 extern char revId750;
 extern unsigned short devId750;
 #else
-- 
2.3.2

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


Re: [PATCH] staging: sm750fb: Cleanup the type of mmio750

2015-03-10 Thread Lorenzo Stoakes
On 10 March 2015 at 12:36, Sudip Mukherjee sudipm.mukher...@gmail.com wrote:
 but it is introducing two new build warnings:

 drivers/staging/sm750fb/sm750_hw.c: In function ‘hw_sm750_map’:
 drivers/staging/sm750fb/sm750_hw.c:67:2: warning: passing argument 1 of 
 ‘ddk750_set_mmio’ discards ‘volatile’ qualifier from pointer target type 
 [enabled by default]
 In file included from drivers/staging/sm750fb/ddk750_mode.h:4:0,
 from drivers/staging/sm750fb/ddk750.h:15,
 from drivers/staging/sm750fb/sm750_hw.c:24:

 and

 drivers/staging/sm750fb/ddk750_chip.h:77:6: note: expected ‘void *’ but 
 argument is of type ‘volatile unsigned char *’

 care to make another patch to solve these two new warnings, and send this 
 patch and the new one in a series and while sending mark the version number 
 in the subject.

I think the second warning is simply additional information attached
to the 1st to give context?

I noticed this issue but felt changing the type of this field would
sit outside the purview of this patch as then I'm not only changing
the type of mmio750 and code that *directly* interacts with this
variable, but also code that indirectly interacts with it, so I felt
that should perhaps be a separate patch.

I'd love to additionally provide some further patches to help out with
issues here too, incidentally! I will try to prepare some further
patches tonight in this vein.

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: sm750fb: Cleanup the type of mmio750

2015-03-10 Thread Lorenzo Stoakes
On 10 March 2015 at 13:06, Dan Carpenter dan.carpen...@oracle.com wrote:

 You should have said that in the patch description or under the ---
 cut off.  But anyway, it's not ok.  And we'll need to redo this patch.
 Breaking up patches into logical changes is sort of tricky because
 everything touches everything else so the patch gets larger and larger.


Major apologies, I am still getting used to kernel development! I'll
be careful to not make such assumptions in future when it comes to
warnings/errors.

[snip]

 But maybe it's only one line larger than the patch you just send?  In
 that case just fold it in and don't do the temporary casting.

 The next patch after that could get rid of all the ramaining volatile
 keywords.

It seems that we can in fact fix this problem with a single additional
change, I will submit a v2 shortly.

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: sm750fb: Cleanup the type of mmio750

2015-03-10 Thread Lorenzo Stoakes
This patch assigns the more appropriate void* type to the mmio750 variable
eliminating an unnecessary volatile qualifier in the process. Additionally it
updates parameter types as necessary where those parameters interact with
mmio750, removes unnecessary casts and updates the type of the
lynx_share-pvReg field which is passed to the ddk750_set_mmio method.

As a consequence, this patch fixes the following sparse warning:-

drivers/staging/sm750fb/ddk750_help.c:12:17: warning: incorrect type in 
assignment (different address spaces)

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com

---
 drivers/staging/sm750fb/ddk750_chip.h |  4 +++-
 drivers/staging/sm750fb/ddk750_help.c |  4 ++--
 drivers/staging/sm750fb/ddk750_help.h | 10 +-
 drivers/staging/sm750fb/sm750.h   |  2 +-
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.h 
b/drivers/staging/sm750fb/ddk750_chip.h
index 1c78875..d067b06 100644
--- a/drivers/staging/sm750fb/ddk750_chip.h
+++ b/drivers/staging/sm750fb/ddk750_chip.h
@@ -3,6 +3,8 @@
 #define DEFAULT_INPUT_CLOCK 14318181 /* Default reference clock */
 #define SM750LE_REVISION_ID (char)0xfe
 
+#include linux/io.h
+
 /* This is all the chips recognized by this library */
 typedef enum _logical_chip_type_t
 {
@@ -70,7 +72,7 @@ logical_chip_type_t getChipType(void);
 unsigned int calcPllValue(unsigned int request,pll_value_t *pll);
 unsigned int calcPllValue2(unsigned int,pll_value_t *);
 unsigned int formatPllReg(pll_value_t *pPLL);
-void ddk750_set_mmio(volatile unsigned char *,unsigned short,char);
+void ddk750_set_mmio(void __iomem *,unsigned short,char);
 unsigned int ddk750_getVMSize(void);
 int ddk750_initHw(initchip_param_t *);
 unsigned int getPllValue(clock_type_t clockType, pll_value_t *pPLL);
diff --git a/drivers/staging/sm750fb/ddk750_help.c 
b/drivers/staging/sm750fb/ddk750_help.c
index cc00d2b..c68ff3b 100644
--- a/drivers/staging/sm750fb/ddk750_help.c
+++ b/drivers/staging/sm750fb/ddk750_help.c
@@ -2,12 +2,12 @@
 //#include ddk750_chip.h
 #include ddk750_help.h
 
-volatile unsigned char __iomem * mmio750 = NULL;
+void __iomem * mmio750 = NULL;
 char revId750 = 0;
 unsigned short devId750 = 0;
 
 /* after driver mapped io registers, use this function first */
-void ddk750_set_mmio(volatile unsigned char * addr,unsigned short devId,char 
revId)
+void ddk750_set_mmio(void __iomem * addr,unsigned short devId,char revId)
 {
mmio750 = addr;
devId750 = devId;
diff --git a/drivers/staging/sm750fb/ddk750_help.h 
b/drivers/staging/sm750fb/ddk750_help.h
index 4fc93b5..07c8264 100644
--- a/drivers/staging/sm750fb/ddk750_help.h
+++ b/drivers/staging/sm750fb/ddk750_help.h
@@ -12,14 +12,14 @@
 #if 0
 /* if 718 big endian turned on,be aware that don't use this driver for general 
use,only for ppc big-endian */
 #warning big endian on target cpu and enable nature big endian support of 718 
capability !
-#define PEEK32(addr)   __raw_readl((void __iomem 
*)(mmio750)+(addr))
-#define POKE32(addr,data)  __raw_writel((data),(void 
__iomem*)(mmio750)+(addr))
+#define PEEK32(addr)   __raw_readl(mmio750 + addr)
+#define POKE32(addr,data)  __raw_writel(data, mmio750 + addr)
 #else /* software control endianess */
-#define PEEK32(addr) readl((addr)+mmio750)
-#define POKE32(addr,data) writel((data),(addr)+mmio750)
+#define PEEK32(addr) readl(addr + mmio750)
+#define POKE32(addr,data) writel(data, addr + mmio750)
 #endif
 
-extern volatile unsigned  char __iomem * mmio750;
+extern void __iomem * mmio750;
 extern char revId750;
 extern unsigned short devId750;
 #else
diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h
index 711676c..376df5f 100644
--- a/drivers/staging/sm750fb/sm750.h
+++ b/drivers/staging/sm750fb/sm750.h
@@ -63,7 +63,7 @@ struct lynx_share{
resource_size_t vidreg_start;
resource_size_t vidmem_size;
resource_size_t vidreg_size;
-   volatile unsigned char __iomem * pvReg;
+   void __iomem * pvReg;
unsigned char __iomem * pvMem;
/* locks*/
spinlock_t slock;
-- 
2.3.2

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


[PATCH 6/6] staging: sm750fb: Spinlock and unlock in the same block

2015-03-10 Thread Lorenzo Stoakes
This patch combines spinlock locks and unlocks together in the same block rather
than occurring in separate blocks preventing a possible deadlock. This fixes the
following sparse warnings:-

drivers/staging/sm750fb/sm750.c:218:22: warning: context imbalance in 
'lynxfb_ops_fillrect' - different lock contexts for basic block
drivers/staging/sm750fb/sm750.c:241:22: warning: context imbalance in 
'lynxfb_ops_copyarea' - different lock contexts for basic block
drivers/staging/sm750fb/sm750.c:282:22: warning: context imbalance in 
'lynxfb_ops_imageblit' - different lock contexts for basic block

Unfortunately this change involves code (and comment) duplication.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/sm750.c | 76 +++--
 1 file changed, 43 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 3e36b6a..58c7518 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -56,23 +56,6 @@ static char * g_settings = NULL;
 static int g_dualview = 0;
 static char * g_option = NULL;
 
-/* if not use spin_lock,system will die if user load driver
- * and immediatly unload driver frequently (dual)*/
-static inline void myspin_lock(spinlock_t * sl){
-   struct lynx_share * share;
-   share = container_of(sl,struct lynx_share,slock);
-   if(share-dual){
-   spin_lock(sl);
-   }
-}
-
-static inline void myspin_unlock(spinlock_t * sl){
-   struct lynx_share * share;
-   share = container_of(sl,struct lynx_share,slock);
-   if(share-dual){
-   spin_unlock(sl);
-   }
-}
 static const struct fb_videomode lynx750_ext[] = {
/*  1024x600-60 VESA[1.71:1]*/
{NULL,  60, 1024, 600, 20423, 144,  40, 18, 1, 104, 3,
@@ -209,13 +192,22 @@ static void lynxfb_ops_fillrect(struct fb_info* 
info,const struct fb_fillrect* r
color = (Bpp == 
1)?region-color:((u32*)info-pseudo_palette)[region-color];
rop = ( region-rop != ROP_COPY ) ? HW_ROP2_XOR:HW_ROP2_COPY;
 
-   myspin_lock(share-slock);
-   share-accel.de_fillrect(share-accel,
-   base,pitch,Bpp,
-   region-dx,region-dy,
-   
region-width,region-height,
-   color,rop);
-   myspin_unlock(share-slock);
+   /* if not use spin_lock,system will die if user load driver
+* and immediatly unload driver frequently (dual)*/
+   if (share-dual) {
+   spin_lock(share-slock);
+   share-accel.de_fillrect(share-accel,
+   base,pitch,Bpp,
+   region-dx,region-dy,
+   region-width,region-height,
+   color,rop);
+   spin_unlock(share-slock);
+   } else
+   share-accel.de_fillrect(share-accel,
+   base,pitch,Bpp,
+   region-dx,region-dy,
+   region-width,region-height,
+   color,rop);
 }
 
 static void lynxfb_ops_copyarea(struct fb_info * info,const struct fb_copyarea 
* region)
@@ -233,12 +225,20 @@ static void lynxfb_ops_copyarea(struct fb_info * 
info,const struct fb_copyarea *
pitch = info-fix.line_length;
Bpp = info-var.bits_per_pixel  3;
 
-   myspin_lock(share-slock);
-   share-accel.de_copyarea(share-accel,
-   
base,pitch,region-sx,region-sy,
-   
base,pitch,Bpp,region-dx,region-dy,
-   
region-width,region-height,HW_ROP2_COPY);
-   myspin_unlock(share-slock);
+   /* if not use spin_lock,system will die if user load driver
+* and immediatly unload driver frequently (dual)*/
+   if (share-dual) {
+   spin_lock(share-slock);
+   share-accel.de_copyarea(share-accel,
+   base,pitch,region-sx,region-sy,
+   base,pitch,Bpp,region-dx,region-dy,
+   
region-width,region-height,HW_ROP2_COPY);
+   spin_unlock(share-slock);
+   } else
+   share-accel.de_copyarea(share-accel,
+   base,pitch,region-sx,region-sy,
+   base,pitch,Bpp,region-dx,region-dy,
+   
region-width,region-height,HW_ROP2_COPY);
 }
 
 static void lynxfb_ops_imageblit(struct fb_info*info,const struct fb_image* 
image)
@@ -272,14 +272,24 @@ static void

[PATCH 2/6] staging: sm750fb: Fix non-ANSI function declarations

2015-03-10 Thread Lorenzo Stoakes
Fixes Function declarations which expect no parameters to have a parameter list 
consisting of void. This fixes the following sparse warnings:-

drivers/staging/sm750fb/sm750_hw.c:584:23: warning: non-ANSI function 
declaration of function 'hw_sm750le_deWait'
drivers/staging/sm750fb/sm750_hw.c:601:21: warning: non-ANSI function 
declaration of function 'hw_sm750_deWait'
9,13d7
drivers/staging/sm750fb/ddk750_chip.c:14:33: warning: non-ANSI function 
declaration of function 'getChipType'
drivers/staging/sm750fb/ddk750_chip.c:94:27: warning: non-ANSI function 
declaration of function 'getChipClock'
drivers/staging/sm750fb/ddk750_chip.c:235:31: warning: non-ANSI function 
declaration of function 'ddk750_getVMSize'
drivers/staging/sm750fb/ddk750_power.c:18:27: warning: non-ANSI function 
declaration of function 'getPowerMode'
drivers/staging/sm750fb/ddk750_display.c:276:24: warning: non-ANSI function 
declaration of function 'ddk750_initDVIDisp'
19,22d12
drivers/staging/sm750fb/ddk750_sii164.c:37:34: warning: non-ANSI function 
declaration of function 'sii164GetVendorID'
drivers/staging/sm750fb/ddk750_sii164.c:54:34: warning: non-ANSI function 
declaration of function 'sii164GetDeviceID'
drivers/staging/sm750fb/ddk750_dvi.c:65:31: warning: non-ANSI function 
declaration of function 'dviGetVendorID'
drivers/staging/sm750fb/ddk750_dvi.c:85:31: warning: non-ANSI function 
declaration of function 'dviGetDeviceID'

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/ddk750_chip.c| 6 +++---
 drivers/staging/sm750fb/ddk750_display.c | 2 +-
 drivers/staging/sm750fb/ddk750_dvi.c | 4 ++--
 drivers/staging/sm750fb/ddk750_power.c   | 2 +-
 drivers/staging/sm750fb/ddk750_sii164.c  | 4 ++--
 drivers/staging/sm750fb/sm750_hw.c   | 4 ++--
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.c 
b/drivers/staging/sm750fb/ddk750_chip.c
index b71169e..3c77207 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -11,7 +11,7 @@ typedef struct _pllcalparam{
 pllcalparam;
 
 
-logical_chip_type_t getChipType()
+logical_chip_type_t getChipType(void)
 {
unsigned short physicalID;
char physicalRev;
@@ -91,7 +91,7 @@ unsigned int getPllValue(clock_type_t clockType, pll_value_t 
*pPLL)
 }
 
 
-unsigned int getChipClock()
+unsigned int getChipClock(void)
 {
 pll_value_t pll;
 #if 1
@@ -232,7 +232,7 @@ void setMasterClock(unsigned int frequency)
 }
 
 
-unsigned int ddk750_getVMSize()
+unsigned int ddk750_getVMSize(void)
 {
unsigned int reg;
unsigned int data;
diff --git a/drivers/staging/sm750fb/ddk750_display.c 
b/drivers/staging/sm750fb/ddk750_display.c
index a282a94..c84196a 100644
--- a/drivers/staging/sm750fb/ddk750_display.c
+++ b/drivers/staging/sm750fb/ddk750_display.c
@@ -273,7 +273,7 @@ void ddk750_setLogicalDispOut(disp_output_t output)
 }
 
 
-int ddk750_initDVIDisp()
+int ddk750_initDVIDisp(void)
 {
 /* Initialize DVI. If the dviInit fail and the VendorID or the DeviceID are
not zeroed, then set the failure flag. If it is zeroe, it might mean
diff --git a/drivers/staging/sm750fb/ddk750_dvi.c 
b/drivers/staging/sm750fb/ddk750_dvi.c
index 1c083e7..f5932bb 100644
--- a/drivers/staging/sm750fb/ddk750_dvi.c
+++ b/drivers/staging/sm750fb/ddk750_dvi.c
@@ -62,7 +62,7 @@ int dviInit(
  *  Output:
  *  Vendor ID
  */
-unsigned short dviGetVendorID()
+unsigned short dviGetVendorID(void)
 {
 dvi_ctrl_device_t *pCurrentDviCtrl;
 
@@ -82,7 +82,7 @@ unsigned short dviGetVendorID()
  *  Output:
  *  Device ID
  */
-unsigned short dviGetDeviceID()
+unsigned short dviGetDeviceID(void)
 {
 dvi_ctrl_device_t *pCurrentDviCtrl;
 
diff --git a/drivers/staging/sm750fb/ddk750_power.c 
b/drivers/staging/sm750fb/ddk750_power.c
index 98dfcbd..cbb9767 100644
--- a/drivers/staging/sm750fb/ddk750_power.c
+++ b/drivers/staging/sm750fb/ddk750_power.c
@@ -15,7 +15,7 @@ void ddk750_setDPMS(DPMS_t state)
}
 }
 
-unsigned int getPowerMode()
+unsigned int getPowerMode(void)
 {
if(getChipType() == SM750LE)
return 0;
diff --git a/drivers/staging/sm750fb/ddk750_sii164.c 
b/drivers/staging/sm750fb/ddk750_sii164.c
index faf8250..bdd7742 100644
--- a/drivers/staging/sm750fb/ddk750_sii164.c
+++ b/drivers/staging/sm750fb/ddk750_sii164.c
@@ -34,7 +34,7 @@ static char *gDviCtrlChipName = Silicon Image SiI 164;
  *  Output:
  *  Vendor ID
  */
-unsigned short sii164GetVendorID()
+unsigned short sii164GetVendorID(void)
 {
 unsigned short vendorID;
 
@@ -51,7 +51,7 @@ unsigned short sii164GetVendorID()
  *  Output:
  *  Device ID
  */
-unsigned short sii164GetDeviceID()
+unsigned short sii164GetDeviceID(void)
 {
 unsigned short deviceID;
 
diff --git a/drivers/staging/sm750fb/sm750_hw.c 
b/drivers/staging/sm750fb/sm750_hw.c
index c44a50b..3050847 100644
--- a/drivers/staging/sm750fb/sm750_hw.c
+++ b/drivers/staging/sm750fb/sm750_hw.c

[PATCH 5/6] staging: sm750fb: Fix __iomem pointer types

2015-03-10 Thread Lorenzo Stoakes
This patch annotates pointers as referring to I/O mapped memory where they ought
to be, removes now unnecessary ugly casts, eliminates an incorrect deref on I/O
mapped memory by using iowrite16 instead, and updates the pointer arithmetic
accordingly to take into account that the pointers are now byte-sized. This
fixes the following sparse warnings:-

drivers/staging/sm750fb/sm750_cursor.c:113:19: warning: cast removes address 
space of expression
drivers/staging/sm750fb/sm750_cursor.c:204:19: warning: cast removes address 
space of expression

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/sm750_cursor.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750_cursor.c 
b/drivers/staging/sm750fb/sm750_cursor.c
index 6cceef1..c2ff3bd 100644
--- a/drivers/staging/sm750fb/sm750_cursor.c
+++ b/drivers/staging/sm750fb/sm750_cursor.c
@@ -98,7 +98,7 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
int i,j,count,pitch,offset;
u8 color,mask,opr;
u16 data;
-   u16 * pbuffer,*pstart;
+   void __iomem * pbuffer,*pstart;
 
/*  in byte*/
pitch = cursor-w  3;
@@ -106,11 +106,11 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
/* in byte  */
count = pitch * cursor-h;
 
-   /* in ushort */
-   offset = cursor-maxW * 2 / 8 / 2;
+   /* in byte */
+   offset = cursor-maxW * 2 / 8;
 
data = 0;
-   pstart = (u16 *)cursor-vstart;
+   pstart = cursor-vstart;
pbuffer = pstart;
 
 /*
@@ -161,7 +161,7 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
}
}
 #endif
-   *pbuffer = data;
+   iowrite16(data, pbuffer);
 
/* assume pitch is 1,2,4,8,...*/
 #if 0
@@ -174,7 +174,7 @@ void hw_cursor_setData(struct lynx_cursor * cursor,
pstart += offset;
pbuffer = pstart;
}else{
-   pbuffer++;
+   pbuffer += sizeof(u16);
}
 
}
@@ -189,7 +189,7 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
int i,j,count,pitch,offset;
u8 color, mask;
u16 data;
-   u16 * pbuffer,*pstart;
+   void __iomem * pbuffer,*pstart;
 
/*  in byte*/
pitch = cursor-w  3;
@@ -197,11 +197,11 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
/* in byte  */
count = pitch * cursor-h;
 
-   /* in ushort */
-   offset = cursor-maxW * 2 / 8 / 2;
+   /* in byte */
+   offset = cursor-maxW * 2 / 8;
 
data = 0;
-   pstart = (u16 *)cursor-vstart;
+   pstart = cursor-vstart;
pbuffer = pstart;
 
for(i=0;icount;i++)
@@ -234,7 +234,7 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
data |= ((color  (1j))?1:2)(j*2);
}
 #endif
-   *pbuffer = data;
+   iowrite16(data, pbuffer);
 
/* assume pitch is 1,2,4,8,...*/
if(!(i(pitch-1)))
@@ -244,7 +244,7 @@ void hw_cursor_setData2(struct lynx_cursor * cursor,
pstart += offset;
pbuffer = pstart;
}else{
-   pbuffer++;
+   pbuffer += sizeof(u16);
}
 
}
-- 
2.3.2

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


[PATCH 4/6] staging: sm750fb: Expose hw712_fillrect externally

2015-03-10 Thread Lorenzo Stoakes
This patch adds a reference to hw712_fillrect which is not used elsewhere in 
the driver,
but appears to be an alternative to the hw_fillrect method. This patch fixes 
the following sparse warning:-

drivers/staging/sm750fb/sm750_accel.c:95:5: warning: symbol 'hw712_fillrect' 
was not declared. Should it be static?

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/sm750_accel.c | 2 +-
 drivers/staging/sm750fb/sm750_accel.h | 7 +++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/sm750fb/sm750_accel.c 
b/drivers/staging/sm750fb/sm750_accel.c
index 4aa763b..6521c3b 100644
--- a/drivers/staging/sm750fb/sm750_accel.c
+++ b/drivers/staging/sm750fb/sm750_accel.c
@@ -92,7 +92,7 @@ void hw_set2dformat(struct lynx_accel * accel,int fmt)
 /* seems sm712 RectFill command is broken,so need use BitBlt to
  * replace it. */
 
-static int hw712_fillrect(struct lynx_accel * accel,
+int hw712_fillrect(struct lynx_accel * accel,
u32 base,u32 pitch,u32 Bpp,
u32 x,u32 y,u32 width,u32 height,
u32 color,u32 rop)
diff --git a/drivers/staging/sm750fb/sm750_accel.h 
b/drivers/staging/sm750fb/sm750_accel.h
index 3ee0bd8..51a9367 100644
--- a/drivers/staging/sm750fb/sm750_accel.h
+++ b/drivers/staging/sm750fb/sm750_accel.h
@@ -238,11 +238,16 @@ void hw_set2dformat(struct lynx_accel * accel,int fmt);
 
 void hw_de_init(struct lynx_accel * accel);
 
+int hw712_fillrect(struct lynx_accel * accel,
+   u32 base,u32 pitch,u32 Bpp,
+   u32 x,u32 y,u32 width,u32 height,
+   u32 color,u32 rop);
+
 int hw_fillrect(struct lynx_accel * accel,
u32 base,u32 pitch,u32 Bpp,
u32 x,u32 y,u32 width,u32 height,
u32 color,u32 rop);
 
 int hw_copyarea(
 struct lynx_accel * accel,
 unsigned int sBase,  /* Address of source: offset in frame buffer */
-- 
2.3.2

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


[PATCH 3/6] staging: sm750fb: Make internal functions static

2015-03-10 Thread Lorenzo Stoakes
This patch declares externally unavailable functions static. This fixes the
following sparse warnings:-

drivers/staging/sm750fb/ddk750_swi2c.c:223:6: warning: symbol 'swI2CStart' was 
not declared. Should it be static?
drivers/staging/sm750fb/ddk750_swi2c.c:234:6: warning: symbol 'swI2CStop' was 
not declared. Should it be static?
drivers/staging/sm750fb/ddk750_swi2c.c:252:6: warning: symbol 'swI2CWriteByte' 
was not declared. Should it be static?
drivers/staging/sm750fb/ddk750_swi2c.c:320:15: warning: symbol 'swI2CReadByte' 
was not declared. Should it be static?
drivers/staging/sm750fb/ddk750_swi2c.c:361:6: warning: symbol 
'swI2CInit_SM750LE' was not declared. Should it be static?
drivers/staging/sm750fb/ddk750_hwi2c.c:63:6: warning: symbol 'hwI2CWaitTXDone' 
was not declared. Should it be static?
drivers/staging/sm750fb/ddk750_hwi2c.c:93:14: warning: symbol 'hwI2CWriteData' 
was not declared. Should it be static?
drivers/staging/sm750fb/ddk750_hwi2c.c:160:14: warning: symbol 'hwI2CReadData' 
was not declared. Should it be static?

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/ddk750_hwi2c.c |  6 +++---
 drivers/staging/sm750fb/ddk750_swi2c.c | 10 +-
 drivers/staging/sm750fb/sm750_accel.c  |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_hwi2c.c 
b/drivers/staging/sm750fb/ddk750_hwi2c.c
index 84dfb6f..7826376 100644
--- a/drivers/staging/sm750fb/ddk750_hwi2c.c
+++ b/drivers/staging/sm750fb/ddk750_hwi2c.c
@@ -60,7 +60,7 @@ void hwI2CClose(void)
 }
 
 
-long hwI2CWaitTXDone(void)
+static long hwI2CWaitTXDone(void)
 {
 unsigned int timeout;
 
@@ -90,7 +90,7 @@ long hwI2CWaitTXDone(void)
  *  Return Value:
  *  Total number of bytes those are actually written.
  */
-unsigned int hwI2CWriteData(
+static unsigned int hwI2CWriteData(
 unsigned char deviceAddress,
 unsigned int length,
 unsigned char *pBuffer
@@ -157,7 +157,7 @@ unsigned int hwI2CWriteData(
  *  Return Value:
  *  Total number of actual bytes read from the slave device
  */
-unsigned int hwI2CReadData(
+static unsigned int hwI2CReadData(
 unsigned char deviceAddress,
 unsigned int length,
 unsigned char *pBuffer
diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c 
b/drivers/staging/sm750fb/ddk750_swi2c.c
index 1249759..516f5bb 100644
--- a/drivers/staging/sm750fb/ddk750_swi2c.c
+++ b/drivers/staging/sm750fb/ddk750_swi2c.c
@@ -220,7 +220,7 @@ static void swI2CAck(void)
 /*
  *  This function sends the start command to the slave device
  */
-void swI2CStart(void)
+static void swI2CStart(void)
 {
 /* Start I2C */
 swI2CSDA(1);
@@ -231,7 +231,7 @@ void swI2CStart(void)
 /*
  *  This function sends the stop command to the slave device
  */
-void swI2CStop(void)
+static void swI2CStop(void)
 {
 /* Stop the I2C */
 swI2CSCL(1);
@@ -249,7 +249,7 @@ void swI2CStop(void)
  *   0   - Success
  *  -1   - Fail to write byte
  */
-long swI2CWriteByte(unsigned char data)
+static long swI2CWriteByte(unsigned char data)
 {
 unsigned char value = data;
 int i;
@@ -317,7 +317,7 @@ long swI2CWriteByte(unsigned char data)
  *  Return Value:
  *  One byte data read from the Slave device
  */
-unsigned char swI2CReadByte(unsigned char ack)
+static unsigned char swI2CReadByte(unsigned char ack)
 {
 int i;
 unsigned char data = 0;
@@ -358,7 +358,7 @@ unsigned char swI2CReadByte(unsigned char ack)
  *  -1   - Fail to initialize the i2c
  *   0   - Success
  */
-long swI2CInit_SM750LE(
+static long swI2CInit_SM750LE(
 unsigned char i2cClkGPIO,
 unsigned char i2cDataGPIO
 )
diff --git a/drivers/staging/sm750fb/sm750_accel.c 
b/drivers/staging/sm750fb/sm750_accel.c
index 6521c3b..4aa763b 100644
--- a/drivers/staging/sm750fb/sm750_accel.c
+++ b/drivers/staging/sm750fb/sm750_accel.c
@@ -92,7 +92,7 @@ void hw_set2dformat(struct lynx_accel * accel,int fmt)
 /* seems sm712 RectFill command is broken,so need use BitBlt to
  * replace it. */
 
-int hw712_fillrect(struct lynx_accel * accel,
+static int hw712_fillrect(struct lynx_accel * accel,
u32 base,u32 pitch,u32 Bpp,
u32 x,u32 y,u32 width,u32 height,
u32 color,u32 rop)
-- 
2.3.2

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


[PATCH 1/6] staging: sm750fb: Use memset_io instead of memset

2015-03-10 Thread Lorenzo Stoakes
This patch uses memset_io instead of memset when using memset on __iomem
qualified pointers. This fixes the following sparse warnings:-

drivers/staging/sm750fb/sm750.c:489:17: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:490:17: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:501:17: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:502:17: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:833:5: warning: incorrect type in argument 1 
(different address spaces)
drivers/staging/sm750fb/sm750.c:1154:9: warning: incorrect type in argument 1 
(different address spaces)

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/sm750.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index aa0888c..3e36b6a 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -486,8 +486,8 @@ static int lynxfb_resume(struct pci_dev* pdev)
par = info-par;
crtc = par-crtc;
cursor = crtc-cursor;
-   memset(cursor-vstart, 0x0, cursor-size);
-   memset(crtc-vScreen,0x0,crtc-vidmem_size);
+   memset_io(cursor-vstart, 0x0, cursor-size);
+   memset_io(crtc-vScreen,0x0,crtc-vidmem_size);
lynxfb_ops_set_par(info);
fb_set_suspend(info, 0);
}
@@ -498,8 +498,8 @@ static int lynxfb_resume(struct pci_dev* pdev)
par = info-par;
crtc = par-crtc;
cursor = crtc-cursor;
-   memset(cursor-vstart, 0x0, cursor-size);
-   memset(crtc-vScreen,0x0,crtc-vidmem_size);
+   memset_io(cursor-vstart, 0x0, cursor-size);
+   memset_io(crtc-vScreen,0x0,crtc-vidmem_size);
lynxfb_ops_set_par(info);
fb_set_suspend(info, 0);
}
@@ -830,7 +830,7 @@ static int lynxfb_set_fbinfo(struct fb_info* info,int index)
 
 
 crtc-cursor.share = share;
-memset(crtc-cursor.vstart, 0, crtc-cursor.size);
+memset_io(crtc-cursor.vstart, 0, crtc-cursor.size);
 if(!g_hwcursor){
 lynxfb_ops.fb_cursor = NULL;
 crtc-cursor.disable(crtc-cursor);
@@ -1151,7 +1151,7 @@ static int lynxfb_pci_probe(struct pci_dev * pdev,
}
 #endif
 
-   memset(share-pvMem,0,share-vidmem_size);
+   memset_io(share-pvMem,0,share-vidmem_size);
 
pr_info(sm%3x mmio address = %p\n,share-devid,share-pvReg);
 
-- 
2.3.2

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


Re: [PATCH v2] staging: sm750fb: Fix sparse warning

2015-03-10 Thread Lorenzo Stoakes
On 10 March 2015 at 15:06, Greg KH gre...@linuxfoundation.org wrote:
 This doesn't apply anymore due to other patches I just took, so can you
 rebase this patch on my latest staging-testing branch of staging.git?

Fixed in v3 of staging: sm750fb: Cleanup the type of mmio75.

 Also, how about someone fixing the real compiler warnings this driver is
 spitting out first, before we worry about sparse warnings?  That's much
 more relevant here as it's keeping the driver from being built in
 linux-next at the moment.

 thanks,

 greg k-h

I am more than happy to take a look at this later today when I have
the opportunity to do so :)

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: sm750fb: Cleanup the type of mmio750

2015-03-10 Thread Lorenzo Stoakes
On 10 March 2015 at 15:04, Greg KH gre...@linuxfoundation.org wrote:
 I can't apply patches that add new build warnings, sorry.  Please fix
 this up in the patch itself.

 greg k-h

Hi Greg,

Apologies for this, I've resolved this issue in v2 of the patch, no
warning messages are added in the updated version of this patch.

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3] staging: sm750fb: Cleanup the type of mmio750

2015-03-10 Thread Lorenzo Stoakes
This patch assigns the more appropriate void* type to the mmio750 variable
eliminating an unnecessary volatile qualifier in the process. Additionally it
updates parameter types as necessary where those parameters interact with
mmio750, removes unnecessary casts and updates the type of the
lynx_share-pvReg field which is passed to the ddk750_set_mmio method.

As a consequence, this patch fixes the following sparse warning:-

drivers/staging/sm750fb/ddk750_help.c:12:17: warning: incorrect type in 
assignment (different address spaces)

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/ddk750_chip.h |  4 +++-
 drivers/staging/sm750fb/ddk750_help.c |  4 ++--
 drivers/staging/sm750fb/ddk750_help.h | 10 +-
 drivers/staging/sm750fb/sm750.h   |  2 +-
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.h 
b/drivers/staging/sm750fb/ddk750_chip.h
index d761b72..04cb0d5 100644
--- a/drivers/staging/sm750fb/ddk750_chip.h
+++ b/drivers/staging/sm750fb/ddk750_chip.h
@@ -5,6 +5,8 @@
 #define SM750LE_REVISION_ID ((unsigned char)0xfe)
 #endif
 
+#include linux/io.h
+
 /* This is all the chips recognized by this library */
 typedef enum _logical_chip_type_t
 {
@@ -72,7 +74,7 @@ logical_chip_type_t getChipType(void);
 unsigned int calcPllValue(unsigned int request,pll_value_t *pll);
 unsigned int calcPllValue2(unsigned int,pll_value_t *);
 unsigned int formatPllReg(pll_value_t *pPLL);
-void ddk750_set_mmio(volatile unsigned char *,unsigned short,char);
+void ddk750_set_mmio(void __iomem *,unsigned short,char);
 unsigned int ddk750_getVMSize(void);
 int ddk750_initHw(initchip_param_t *);
 unsigned int getPllValue(clock_type_t clockType, pll_value_t *pPLL);
diff --git a/drivers/staging/sm750fb/ddk750_help.c 
b/drivers/staging/sm750fb/ddk750_help.c
index cc00d2b..c68ff3b 100644
--- a/drivers/staging/sm750fb/ddk750_help.c
+++ b/drivers/staging/sm750fb/ddk750_help.c
@@ -2,12 +2,12 @@
 //#include ddk750_chip.h
 #include ddk750_help.h
 
-volatile unsigned char __iomem * mmio750 = NULL;
+void __iomem * mmio750 = NULL;
 char revId750 = 0;
 unsigned short devId750 = 0;
 
 /* after driver mapped io registers, use this function first */
-void ddk750_set_mmio(volatile unsigned char * addr,unsigned short devId,char 
revId)
+void ddk750_set_mmio(void __iomem * addr,unsigned short devId,char revId)
 {
mmio750 = addr;
devId750 = devId;
diff --git a/drivers/staging/sm750fb/ddk750_help.h 
b/drivers/staging/sm750fb/ddk750_help.h
index 4fc93b5..07c8264 100644
--- a/drivers/staging/sm750fb/ddk750_help.h
+++ b/drivers/staging/sm750fb/ddk750_help.h
@@ -12,14 +12,14 @@
 #if 0
 /* if 718 big endian turned on,be aware that don't use this driver for general 
use,only for ppc big-endian */
 #warning big endian on target cpu and enable nature big endian support of 718 
capability !
-#define PEEK32(addr)   __raw_readl((void __iomem 
*)(mmio750)+(addr))
-#define POKE32(addr,data)  __raw_writel((data),(void 
__iomem*)(mmio750)+(addr))
+#define PEEK32(addr)   __raw_readl(mmio750 + addr)
+#define POKE32(addr,data)  __raw_writel(data, mmio750 + addr)
 #else /* software control endianess */
-#define PEEK32(addr) readl((addr)+mmio750)
-#define POKE32(addr,data) writel((data),(addr)+mmio750)
+#define PEEK32(addr) readl(addr + mmio750)
+#define POKE32(addr,data) writel(data, addr + mmio750)
 #endif
 
-extern volatile unsigned  char __iomem * mmio750;
+extern void __iomem * mmio750;
 extern char revId750;
 extern unsigned short devId750;
 #else
diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h
index d39968c..5361116 100644
--- a/drivers/staging/sm750fb/sm750.h
+++ b/drivers/staging/sm750fb/sm750.h
@@ -63,7 +63,7 @@ struct lynx_share{
unsigned long vidreg_start;
__u32 vidmem_size;
__u32 vidreg_size;
-   volatile unsigned char __iomem * pvReg;
+   void __iomem * pvReg;
unsigned char __iomem * pvMem;
/* locks*/
spinlock_t slock;
-- 
2.3.2

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


Re: [PATCH] staging: sm750fb: Fix sparse warning

2015-03-10 Thread Lorenzo Stoakes
On 10 March 2015 at 07:42, Sudip Mukherjee sudipm.mukher...@gmail.com wrote:
 only one concern - if Greg first applies the patches i sent yesterday then 
 this patch will not apply, and if this one is applied first then my series 
 will not apply ...

Indeed, I am more than happy to adapt the patch as required if your
patch series is applied first, I will keep an eye out for this,
additionally if you ping me if this occurs I will fix it right away.

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: sm750fb: Fix sparse warning

2015-03-10 Thread Lorenzo Stoakes
On 10 March 2015 at 07:00, Dan Carpenter dan.carpen...@oracle.com wrote:

 No need for the volatile.

Will remove.

 Really mmio750 should be a void __iomem *
 it is declared as unsigned char __iomem * but it's not a char pointer
 that's only to make the pointer math work.  It would work just as well
 as a void and we could remove some ugly casting.

I'm thinking the change to void __iomem * from unsigned char
__iomem * ought to be a separate patch in order to keep this cleanly
focused on solving the sparse warning? Am more than happy to do this
and make the appropriate changes to the macros in ddk750_help.h.

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: sm750fb: Fix sparse warning

2015-03-10 Thread Lorenzo Stoakes
This patch fixes the following sparse warning:-

drivers/staging/sm750fb/ddk750_help.c: warning: incorrect type in assignment 
(different address spaces)

In addition it eliminates an unnecessary volatile.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/ddk750_chip.h | 4 +++-
 drivers/staging/sm750fb/ddk750_help.c | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.h 
b/drivers/staging/sm750fb/ddk750_chip.h
index 1c78875..a4e5bcc 100644
--- a/drivers/staging/sm750fb/ddk750_chip.h
+++ b/drivers/staging/sm750fb/ddk750_chip.h
@@ -3,6 +3,8 @@
 #define DEFAULT_INPUT_CLOCK 14318181 /* Default reference clock */
 #define SM750LE_REVISION_ID (char)0xfe
 
+#include linux/io.h
+
 /* This is all the chips recognized by this library */
 typedef enum _logical_chip_type_t
 {
@@ -70,7 +72,7 @@ logical_chip_type_t getChipType(void);
 unsigned int calcPllValue(unsigned int request,pll_value_t *pll);
 unsigned int calcPllValue2(unsigned int,pll_value_t *);
 unsigned int formatPllReg(pll_value_t *pPLL);
-void ddk750_set_mmio(volatile unsigned char *,unsigned short,char);
+void ddk750_set_mmio(unsigned char __iomem *,unsigned short,char);
 unsigned int ddk750_getVMSize(void);
 int ddk750_initHw(initchip_param_t *);
 unsigned int getPllValue(clock_type_t clockType, pll_value_t *pPLL);
diff --git a/drivers/staging/sm750fb/ddk750_help.c 
b/drivers/staging/sm750fb/ddk750_help.c
index cc00d2b..6ad4dec 100644
--- a/drivers/staging/sm750fb/ddk750_help.c
+++ b/drivers/staging/sm750fb/ddk750_help.c
@@ -7,7 +7,7 @@ char revId750 = 0;
 unsigned short devId750 = 0;
 
 /* after driver mapped io registers, use this function first */
-void ddk750_set_mmio(volatile unsigned char * addr,unsigned short devId,char 
revId)
+void ddk750_set_mmio(unsigned char __iomem * addr,unsigned short devId,char 
revId)
 {
mmio750 = addr;
devId750 = devId;
-- 
2.3.2

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


Re: [PATCH] staging: sm750fb: Fix sparse warning

2015-03-10 Thread Lorenzo Stoakes
On 10 March 2015 at 08:59, Dan Carpenter dan.carpen...@oracle.com wrote:

 The patch is:

 [patch] cleanup the type of mmio750

 silencing a Sparse warning is just a side benifit of using correct
 data types.  The one thing per patch rule also means that you should
 fix a whole problem instead of half a thing per patch.

 regards,
 dan carpenter


Sure, sorry saw the patch as purely a sparse fixup, will adapt to be
an overall mmio750 cleanup and resubmit!

Best,

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: sm750fb: Fix sparse warning

2015-03-09 Thread Lorenzo Stoakes
This patch fixes the following sparse warning:-

drivers/staging/sm750fb/ddk750_help.c: warning: incorrect type in assignment 
(different address spaces)

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/sm750fb/ddk750_chip.h | 4 +++-
 drivers/staging/sm750fb/ddk750_help.c | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.h 
b/drivers/staging/sm750fb/ddk750_chip.h
index 1c78875..a4e5bcc 100644
--- a/drivers/staging/sm750fb/ddk750_chip.h
+++ b/drivers/staging/sm750fb/ddk750_chip.h
@@ -3,6 +3,8 @@
 #define DEFAULT_INPUT_CLOCK 14318181 /* Default reference clock */
 #define SM750LE_REVISION_ID (char)0xfe
 
+#include asm/io.h
+
 /* This is all the chips recognized by this library */
 typedef enum _logical_chip_type_t
 {
@@ -70,7 +72,7 @@ logical_chip_type_t getChipType(void);
 unsigned int calcPllValue(unsigned int request,pll_value_t *pll);
 unsigned int calcPllValue2(unsigned int,pll_value_t *);
 unsigned int formatPllReg(pll_value_t *pPLL);
-void ddk750_set_mmio(volatile unsigned char *,unsigned short,char);
+void ddk750_set_mmio(volatile unsigned char __iomem *,unsigned short,char);
 unsigned int ddk750_getVMSize(void);
 int ddk750_initHw(initchip_param_t *);
 unsigned int getPllValue(clock_type_t clockType, pll_value_t *pPLL);
diff --git a/drivers/staging/sm750fb/ddk750_help.c 
b/drivers/staging/sm750fb/ddk750_help.c
index cc00d2b..6ad4dec 100644
--- a/drivers/staging/sm750fb/ddk750_help.c
+++ b/drivers/staging/sm750fb/ddk750_help.c
@@ -7,7 +7,7 @@ char revId750 = 0;
 unsigned short devId750 = 0;
 
 /* after driver mapped io registers, use this function first */
-void ddk750_set_mmio(volatile unsigned char * addr,unsigned short devId,char 
revId)
+void ddk750_set_mmio(volatile unsigned char __iomem * addr,unsigned short 
devId,char revId)
 {
mmio750 = addr;
devId750 = devId;
-- 
2.3.2

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


Re: [PATCH RESEND 2 1/4] staging: rtl8192u: fix comments

2015-01-25 Thread Lorenzo Stoakes
On 25 January 2015 at 11:51, Greg KH gre...@linuxfoundation.org wrote:

 This patch fails to apply to my staging-testing branch of staging.git,
 so I can't apply it :(

 Please refresh your series and resend.

Apologies Greg, it turns out I clearly lost my mind last weekend and
rebased against the test branch instead of staging-testing as you
actually requested :) I will fix now.

-- 
Lorenzo Stoakes
https:/ljs.io
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RESEND 3 4/4] staging: rtl8192u: Refactor heavy nesting

2015-01-25 Thread Lorenzo Stoakes
This patch fixes warnings raised by checkpatch.pl relating to heavily indented
lines in r8192U_dm.c by refactoring code to achieve the same outcome indented by
one less tab.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index 1893336..ee6b936 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -2566,28 +2566,25 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev)
cck_rx_ver2_sec_index = 
cck_rx_ver2_max_index;
tmp_cck_max_pwdb = cur_cck_pwdb;
cck_rx_ver2_max_index = i;
-   } else if (cur_cck_pwdb == 
tmp_cck_max_pwdb) { /* let sec and min point to the different index */
+   } else if (cur_cck_pwdb == 
tmp_cck_max_pwdb) {
+   /* let sec and min point to the 
different index */
tmp_cck_sec_pwdb = cur_cck_pwdb;
cck_rx_ver2_sec_index = i;
} else if ((cur_cck_pwdb  
tmp_cck_max_pwdb)  (cur_cck_pwdb  tmp_cck_sec_pwdb)) {
tmp_cck_sec_pwdb = cur_cck_pwdb;
cck_rx_ver2_sec_index = i;
-   } else if (cur_cck_pwdb == 
tmp_cck_sec_pwdb) {
-   if (tmp_cck_sec_pwdb == 
tmp_cck_min_pwdb) { /* let sec and min point to the different index */
-   tmp_cck_sec_pwdb = 
cur_cck_pwdb;
-   cck_rx_ver2_sec_index = 
i;
-   } else {
-   /*  This case we don't 
need to set any index */
-   }
+   } else if (cur_cck_pwdb == 
tmp_cck_sec_pwdb  tmp_cck_sec_pwdb == tmp_cck_min_pwdb) {
+   /* let sec and min point to the 
different index */
+   tmp_cck_sec_pwdb = cur_cck_pwdb;
+   cck_rx_ver2_sec_index = i;
+   /* otherwise we don't need to 
set any index */
} else if ((cur_cck_pwdb  
tmp_cck_sec_pwdb)  (cur_cck_pwdb  tmp_cck_min_pwdb)) {
/*  This case we don't need to 
set any index */
-   } else if (cur_cck_pwdb == 
tmp_cck_min_pwdb) {
-   if (tmp_cck_sec_pwdb == 
tmp_cck_min_pwdb) { /*  let sec and min point to the different index */
-   tmp_cck_min_pwdb = 
cur_cck_pwdb;
-   cck_rx_ver2_min_index = 
i;
-   } else {
-   /*  This case we don't 
need to set any index */
-   }
+   } else if (cur_cck_pwdb == 
tmp_cck_min_pwdb  tmp_cck_sec_pwdb == tmp_cck_min_pwdb) {
+   /*  let sec and min point to 
the different index */
+   tmp_cck_min_pwdb = cur_cck_pwdb;
+   cck_rx_ver2_min_index = i;
+   /* otherwise we don't need to 
set any index */
} else if (cur_cck_pwdb  
tmp_cck_min_pwdb) {
tmp_cck_min_pwdb = cur_cck_pwdb;
cck_rx_ver2_min_index = i;
--
2.2.2
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RESEND 3 1/4] staging: rtl8192u: fix comments

2015-01-25 Thread Lorenzo Stoakes
This patch fixes errors raised by checkpatch.pl relating to use of C99 comments
in r8192U_dm.c, and cleans up existing ANSI C comments.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 807 ++-
 1 file changed, 416 insertions(+), 391 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index b3b508c..6112c7d 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -21,9 +21,7 @@ Major Change History:
 #include r8190_rtl8256.h
 #include r819xU_cmdpkt.h
 /*---Define Local Constant---*/
-//
-// Indicate different AP vendor for IOT issue.
-//
+/* Indicate different AP vendor for IOT issue. */
 static u32 edca_setting_DL[HT_IOT_PEER_MAX] =
{ 0x5e4322, 0x5e4322,   0x5e4322,   0x604322,   
0xa44f, 0x5ea44f};
 static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
@@ -36,11 +34,11 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] =


 /*Define global variable-*/
-// Debug variable ?
+/* Debug variable ? */
 dig_t  dm_digtable;
-// Store current software write register content for MAC PHY.
+/* Store current software write register content for MAC PHY. */
 u8 dm_shadow[16][256] = {{0}};
-// For Dynamic Rx Path Selection by Signal Strength
+/* For Dynamic Rx Path Selection by Signal Strength */
 DRxPathSel DM_RxPathSelTable;
 /*Define global variable-*/

@@ -56,24 +54,24 @@ extern  void dm_check_fsync(struct net_device *dev);


 /*-Define local function prototype---*/
-// DM -- Rate Adaptive
+/* DM -- Rate Adaptive */
 static voiddm_check_rate_adaptive(struct net_device *dev);

-// DM -- Bandwidth switch
+/* DM -- Bandwidth switch */
 static voiddm_init_bandwidth_autoswitch(struct net_device *dev);
 static voiddm_bandwidth_autoswitch(struct net_device *dev);

-// DM -- TX power control
-//static   voiddm_initialize_txpower_tracking(struct net_device *dev);
+/* DM -- TX power control */
+/*static   voiddm_initialize_txpower_tracking(struct net_device 
*dev);*/

 static voiddm_check_txpower_tracking(struct net_device *dev);



-//static   voiddm_txpower_reset_recovery(struct net_device *dev);
+/*static   voiddm_txpower_reset_recovery(struct net_device *dev);*/


-// DM -- Dynamic Init Gain by RSSI
+/* DM -- Dynamic Init Gain by RSSI */
 static voiddm_dig_init(struct net_device *dev);
 static voiddm_ctrl_initgain_byrssi(struct net_device *dev);
 static voiddm_ctrl_initgain_byrssi_highpwr(struct net_device *dev);
@@ -84,61 +82,61 @@ static  voiddm_pd_th(struct net_device *dev);
 static voiddm_cs_ratio(struct net_device *dev);

 static void dm_init_ctstoself(struct net_device *dev);
-// DM -- EDCA turbo mode control
+/* DM -- EDCA turbo mode control */
 static voiddm_check_edca_turbo(struct net_device *dev);

-//static   voiddm_gpio_change_rf(struct net_device *dev);
-// DM -- Check PBC
+/*static   voiddm_gpio_change_rf(struct net_device *dev);*/
+/* DM -- Check PBC */
 static void dm_check_pbc_gpio(struct net_device *dev);


-// DM -- Check current RX RF path state
+/* DM -- Check current RX RF path state */
 static voiddm_check_rx_path_selection(struct net_device *dev);
 static void dm_init_rxpath_selection(struct net_device *dev);
 static void dm_rxpath_sel_byrssi(struct net_device *dev);


-// DM -- Fsync for broadcom ap
+/* DM -- Fsync for broadcom ap */
 static void dm_init_fsync(struct net_device *dev);
 static void dm_deInit_fsync(struct net_device *dev);

-//Added by vivi, 20080522
+/* Added by vivi, 20080522 */
 static voiddm_check_txrateandretrycount(struct net_device *dev);

 /*-Define local function prototype---*/

-/*-Define of Tx Power Control For Near/Far Range 
*/   //Add by Jacken 2008/02/18
+/*-Define of Tx Power Control For Near/Far Range 
*/   /*Add by Jacken 2008/02/18 */
 static voiddm_init_dynamic_txpower(struct net_device *dev);
 static voiddm_dynamic_txpower(struct net_device *dev);


-// DM -- For rate adaptive and DIG, we must send RSSI to firmware
+/* DM -- For rate adaptive and DIG, we must send RSSI to firmware */
 static void dm_send_rssi_tofw(struct net_device *dev);
 static voiddm_ctstoself(struct net_device *dev);
 /*---Define function 
prototype*/
-//
-// HW Dynamic mechanism interface.
-//
-
-//
-// Description:
-// Prepare SW resource for HW dynamic

[PATCH RESEND 3 3/4] staging: rtl8192u: remove redundant code

2015-01-25 Thread Lorenzo Stoakes
This patch fixes warnings/errors raised by checkpatch.pl relating to redundant
code in r8192U_dm.c.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 153 ---
 1 file changed, 68 insertions(+), 85 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index 2c3d894..1893336 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -406,9 +406,8 @@ static void dm_check_rate_adaptive(struct net_device *dev)

ratr_value = targetRATR;
RT_TRACE(COMP_RATE, currentRATR = %x, targetRATR = 
%x\n, currentRATR, targetRATR);
-   if (priv-rf_type == RF_1T2R) {
+   if (priv-rf_type == RF_1T2R)
ratr_value = ~(RATE_ALL_OFDM_2SS);
-   }
write_nic_dword(dev, RATR0, ratr_value);
write_nic_byte(dev, UFWP, 1);

@@ -436,9 +435,8 @@ static void dm_bandwidth_autoswitch(struct net_device *dev)
 {
struct r8192_priv *priv = ieee80211_priv(dev);

-   if (priv-CurrentChannelBW == HT_CHANNEL_WIDTH_20 || 
!priv-ieee80211-bandwidth_auto_switch.bautoswitch_enable) {
+   if (priv-CurrentChannelBW == HT_CHANNEL_WIDTH_20 || 
!priv-ieee80211-bandwidth_auto_switch.bautoswitch_enable)
return;
-   }
if (priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz == false) { 
/* If send packets in 40 Mhz in 20/40 */
if (priv-undecorated_smoothed_pwdb = 
priv-ieee80211-bandwidth_auto_switch.threshold_40Mhzto20Mhz)
priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz 
= true;
@@ -532,9 +530,8 @@ static void dm_TXPowerTrackingCallback_TSSI(struct 
net_device *dev)
tx_cmd.Length = 4;
tx_cmd.Value = Value;
rtStatus = SendTxCommandPacket(dev, tx_cmd, 12);
-   if (rtStatus == RT_STATUS_FAILURE) {
+   if (rtStatus == RT_STATUS_FAILURE)
RT_TRACE(COMP_POWER_TRACKING, Set configuration with 
tx cmd queue fail!\n);
-   }
mdelay(1);
/*DbgPrint(hi, vivi, strange\n);*/
for (i = 0; i = 30; i++) {
@@ -574,9 +571,8 @@ static void dm_TXPowerTrackingCallback_TSSI(struct 
net_device *dev)
break;
}

-   for (k = 0; k  5; k++) {
+   for (k = 0; k  5; k++)
Avg_TSSI_Meas_from_driver += tmp_report[k];
-   }

Avg_TSSI_Meas_from_driver = 
Avg_TSSI_Meas_from_driver*100/5;
RT_TRACE(COMP_POWER_TRACKING, 
Avg_TSSI_Meas_from_driver = %d\n, Avg_TSSI_Meas_from_driver);
@@ -599,56 +595,55 @@ static void dm_TXPowerTrackingCallback_TSSI(struct 
net_device *dev)
RT_TRACE(COMP_POWER_TRACKING, 
priv-cck_present_attentuation_difference = %d\n, 
priv-cck_present_attentuation_difference);
RT_TRACE(COMP_POWER_TRACKING, 
priv-cck_present_attentuation = %d\n, priv-cck_present_attentuation);
return;
-   } else {
-   if (Avg_TSSI_Meas_from_driver  TSSI_13dBm - 
E_FOR_TX_POWER_TRACK) {
-   if (priv-rfa_txpowertrackingindex  0) 
{
-   
priv-rfa_txpowertrackingindex--;
-   if 
(priv-rfa_txpowertrackingindex_real  4) {
-   
priv-rfa_txpowertrackingindex_real--;
-   rtl8192_setBBreg(dev, 
rOFDM0_XATxIQImbalance, bMaskDWord, 
priv-txbbgain_table[priv-rfa_txpowertrackingindex_real].txbbgain_value);
-   }
-   }
-   } else {
-   if (priv-rfa_txpowertrackingindex  
36) {
-   
priv-rfa_txpowertrackingindex++;
-   
priv-rfa_txpowertrackingindex_real++;
+   }
+   if (Avg_TSSI_Meas_from_driver  TSSI_13dBm - 
E_FOR_TX_POWER_TRACK) {
+   if (priv-rfa_txpowertrackingindex  0) {
+   priv-rfa_txpowertrackingindex--;
+   if (priv-rfa_txpowertrackingindex_real 
 4) {
+   
priv-rfa_txpowertrackingindex_real--;
rtl8192_setBBreg(dev, 
rOFDM0_XATxIQImbalance, bMaskDWord, 
priv-txbbgain_table[priv-rfa_txpowertrackingindex_real

[PATCH RESEND 3 2/4] staging: rtl8192u: fix whitespace and alignment

2015-01-25 Thread Lorenzo Stoakes
This patch fixes warnings/errors raised by checkpatch.pl relating to whitespace
in r8192U_dm.c, removes inconsistent whitespace, and additionally fixes some
vertical alignment issues.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 1604 +-
 1 file changed, 624 insertions(+), 980 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index 6112c7d..2c3d894 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -22,11 +22,12 @@ Major Change History:
 #include r819xU_cmdpkt.h
 /*---Define Local Constant---*/
 /* Indicate different AP vendor for IOT issue. */
-static u32 edca_setting_DL[HT_IOT_PEER_MAX] =
-   { 0x5e4322, 0x5e4322,   0x5e4322,   0x604322,   
0xa44f, 0x5ea44f};
-static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
-   { 0x5e4322, 0xa44f, 0x5e4322,   0x604322,   
0x5ea44f,   0x5ea44f};
-
+static u32 edca_setting_DL[HT_IOT_PEER_MAX] = {
+   0x5e4322, 0x5e4322, 0x5e4322, 0x604322, 0x00a44f, 0x5ea44f
+};
+static u32 edca_setting_UL[HT_IOT_PEER_MAX] = {
+   0x5e4322, 0x00a44f, 0x5e4322, 0x604322, 0x5ea44f, 0x5ea44f
+};

 #define RTK_UL_EDCA 0xa44f
 #define RTK_DL_EDCA 0x5e4322
@@ -37,7 +38,7 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
 /* Debug variable ? */
 dig_t  dm_digtable;
 /* Store current software write register content for MAC PHY. */
-u8 dm_shadow[16][256] = {{0}};
+u8 dm_shadow[16][256] = { {0} };
 /* For Dynamic Rx Path Selection by Signal Strength */
 DRxPathSel DM_RxPathSelTable;
 /*Define global variable-*/
@@ -66,11 +67,8 @@ static   voiddm_bandwidth_autoswitch(struct 
net_device *dev);

 static voiddm_check_txpower_tracking(struct net_device *dev);

-
-
 /*static   voiddm_txpower_reset_recovery(struct net_device *dev);*/

-
 /* DM -- Dynamic Init Gain by RSSI */
 static voiddm_dig_init(struct net_device *dev);
 static voiddm_ctrl_initgain_byrssi(struct net_device *dev);
@@ -89,13 +87,11 @@ static  voiddm_check_edca_turbo(struct net_device 
*dev);
 /* DM -- Check PBC */
 static void dm_check_pbc_gpio(struct net_device *dev);

-
 /* DM -- Check current RX RF path state */
 static voiddm_check_rx_path_selection(struct net_device *dev);
 static void dm_init_rxpath_selection(struct net_device *dev);
 static void dm_rxpath_sel_byrssi(struct net_device *dev);

-
 /* DM -- Fsync for broadcom ap */
 static void dm_init_fsync(struct net_device *dev);
 static void dm_deInit_fsync(struct net_device *dev);
@@ -109,7 +105,6 @@ static  voiddm_check_txrateandretrycount(struct 
net_device *dev);
 static voiddm_init_dynamic_txpower(struct net_device *dev);
 static voiddm_dynamic_txpower(struct net_device *dev);

-
 /* DM -- For rate adaptive and DIG, we must send RSSI to firmware */
 static void dm_send_rssi_tofw(struct net_device *dev);
 static voiddm_ctstoself(struct net_device *dev);
@@ -148,14 +143,12 @@ void init_hal_dm(struct net_device *dev)

 void deinit_hal_dm(struct net_device *dev)
 {
-
dm_deInit_fsync(dev);
-
 }

-
 #ifdef USB_RX_AGGREGATION_SUPPORT
-void dm_CheckRxAggregation(struct net_device *dev) {
+void dm_CheckRxAggregation(struct net_device *dev)
+{
struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
PRT_HIGH_THROUGHPUT pHTInfo = priv-ieee80211-pHTInfo;
static unsigned longlastTxOkCnt;
@@ -184,14 +177,15 @@ void dm_CheckRxAggregation(struct net_device *dev) {
if ((curTxOkCnt + curRxOkCnt)  1500)
return;

-   if(curTxOkCnt  4*curRxOkCnt) {
+   if (curTxOkCnt  4*curRxOkCnt) {
if (priv-bCurrentRxAggrEnable) {
write_nic_dword(dev, 0x1a8, 0);
priv-bCurrentRxAggrEnable = false;
}
-   }else{
+   } else {
if (!priv-bCurrentRxAggrEnable  
!pHTInfo-bCurrentRT2RTAggregation) {
u32 ulValue;
+
ulValue = (pHTInfo-UsbRxFwAggrEn24) | 
(pHTInfo-UsbRxFwAggrPageNum16) |
(pHTInfo-UsbRxFwAggrPacketNum8) | 
(pHTInfo-UsbRxFwAggrTimeout);
/*
@@ -209,8 +203,6 @@ void dm_CheckRxAggregation(struct net_device *dev) {
 }  /* dm_CheckEdcaTurbo */
 #endif

-
-
 void hal_dm_watchdog(struct net_device *dev)
 {
/*struct r8192_priv *priv = ieee80211_priv(dev);*/
@@ -237,7 +229,6 @@ void hal_dm_watchdog(struct net_device *dev)
 #endif
 }  /* HalDmWatchDog */

-
 /*
  * Decide Rate Adaptive Set according to distance (signal strength)
  * 01/11/2008  MHC Modify input arguments and RATR table 
level.
@@ -246,7 +237,6 @@ void hal_dm_watchdog(struct net_device *dev

[PATCH RESEND 2 1/4] staging: rtl8192u: fix comments

2015-01-18 Thread Lorenzo Stoakes
This patch fixes errors raised by checkpatch.pl relating to use of C99 comments
in r8192U_dm.c, and cleans up existing ANSI C comments.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 811 ++-
 1 file changed, 420 insertions(+), 391 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index b4264e1..c66a901 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -21,9 +21,7 @@ Major Change History:
 #include r8190_rtl8256.h
 #include r819xU_cmdpkt.h
 /*---Define Local Constant---*/
-//
-// Indicate different AP vendor for IOT issue.
-//
+/* Indicate different AP vendor for IOT issue. */
 static u32 edca_setting_DL[HT_IOT_PEER_MAX] =
{ 0x5e4322, 0x5e4322,   0x5e4322,   0x604322,   
0xa44f, 0x5ea44f};
 static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
@@ -36,11 +34,11 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] =


 /*Define global variable-*/
-// Debug variable ?
+/* Debug variable ? */
 dig_t  dm_digtable;
-// Store current software write register content for MAC PHY.
+/* Store current software write register content for MAC PHY. */
 u8 dm_shadow[16][256] = {{0}};
-// For Dynamic Rx Path Selection by Signal Strength
+/* For Dynamic Rx Path Selection by Signal Strength */
 DRxPathSel DM_RxPathSelTable;
 /*Define global variable-*/

@@ -56,24 +54,24 @@ extern  void dm_check_fsync(struct net_device *dev);


 /*-Define local function prototype---*/
-// DM -- Rate Adaptive
+/* DM -- Rate Adaptive */
 static voiddm_check_rate_adaptive(struct net_device *dev);

-// DM -- Bandwidth switch
+/* DM -- Bandwidth switch */
 static voiddm_init_bandwidth_autoswitch(struct net_device *dev);
 static voiddm_bandwidth_autoswitch(struct net_device *dev);

-// DM -- TX power control
-//static   voiddm_initialize_txpower_tracking(struct net_device *dev);
+/* DM -- TX power control */
+/*static   voiddm_initialize_txpower_tracking(struct net_device 
*dev);*/

 static voiddm_check_txpower_tracking(struct net_device *dev);



-//static   voiddm_txpower_reset_recovery(struct net_device *dev);
+/*static   voiddm_txpower_reset_recovery(struct net_device *dev);*/


-// DM -- Dynamic Init Gain by RSSI
+/* DM -- Dynamic Init Gain by RSSI */
 static voiddm_dig_init(struct net_device *dev);
 static voiddm_ctrl_initgain_byrssi(struct net_device *dev);
 static voiddm_ctrl_initgain_byrssi_highpwr(struct net_device *dev);
@@ -84,61 +82,61 @@ static  voiddm_pd_th(struct net_device *dev);
 static voiddm_cs_ratio(struct net_device *dev);

 static void dm_init_ctstoself(struct net_device *dev);
-// DM -- EDCA turbo mode control
+/* DM -- EDCA turbo mode control */
 static voiddm_check_edca_turbo(struct net_device *dev);

-//static   voiddm_gpio_change_rf(struct net_device *dev);
-// DM -- Check PBC
+/*static   voiddm_gpio_change_rf(struct net_device *dev);*/
+/* DM -- Check PBC */
 static void dm_check_pbc_gpio(struct net_device *dev);


-// DM -- Check current RX RF path state
+/* DM -- Check current RX RF path state */
 static voiddm_check_rx_path_selection(struct net_device *dev);
 static void dm_init_rxpath_selection(struct net_device *dev);
 static void dm_rxpath_sel_byrssi(struct net_device *dev);


-// DM -- Fsync for broadcom ap
+/* DM -- Fsync for broadcom ap */
 static void dm_init_fsync(struct net_device *dev);
 static void dm_deInit_fsync(struct net_device *dev);

-//Added by vivi, 20080522
+/* Added by vivi, 20080522 */
 static voiddm_check_txrateandretrycount(struct net_device *dev);

 /*-Define local function prototype---*/

-/*-Define of Tx Power Control For Near/Far Range 
*/   //Add by Jacken 2008/02/18
+/*-Define of Tx Power Control For Near/Far Range 
*/   /*Add by Jacken 2008/02/18 */
 static voiddm_init_dynamic_txpower(struct net_device *dev);
 static voiddm_dynamic_txpower(struct net_device *dev);


-// DM -- For rate adaptive and DIG, we must send RSSI to firmware
+/* DM -- For rate adaptive and DIG, we must send RSSI to firmware */
 static void dm_send_rssi_tofw(struct net_device *dev);
 static voiddm_ctstoself(struct net_device *dev);
 /*---Define function 
prototype*/
-//
-// HW Dynamic mechanism interface.
-//
-
-//
-// Description:
-// Prepare SW resource for HW dynamic

[PATCH RESEND 2 4/4] staging: rtl8192u: Refactor heavy nesting

2015-01-18 Thread Lorenzo Stoakes
This patch fixes warnings raised by checkpatch.pl relating to heavily indented
lines in r8192U_dm.c by refactoring code to achieve the same outcome indented by
one less tab.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index aeb8aa2..f024782 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -2637,28 +2637,25 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev)
cck_rx_ver2_sec_index = 
cck_rx_ver2_max_index;
tmp_cck_max_pwdb = cur_cck_pwdb;
cck_rx_ver2_max_index = i;
-   } else if (cur_cck_pwdb == 
tmp_cck_max_pwdb) { /* let sec and min point to the different index */
+   } else if (cur_cck_pwdb == 
tmp_cck_max_pwdb) {
+   /* let sec and min point to the 
different index */
tmp_cck_sec_pwdb = cur_cck_pwdb;
cck_rx_ver2_sec_index = i;
} else if ((cur_cck_pwdb  
tmp_cck_max_pwdb)  (cur_cck_pwdb  tmp_cck_sec_pwdb)) {
tmp_cck_sec_pwdb = cur_cck_pwdb;
cck_rx_ver2_sec_index = i;
-   } else if (cur_cck_pwdb == 
tmp_cck_sec_pwdb) {
-   if (tmp_cck_sec_pwdb == 
tmp_cck_min_pwdb) { /* let sec and min point to the different index */
-   tmp_cck_sec_pwdb = 
cur_cck_pwdb;
-   cck_rx_ver2_sec_index = 
i;
-   } else {
-   /*  This case we don't 
need to set any index */
-   }
+   } else if (cur_cck_pwdb == 
tmp_cck_sec_pwdb  tmp_cck_sec_pwdb == tmp_cck_min_pwdb) {
+   /* let sec and min point to the 
different index */
+   tmp_cck_sec_pwdb = cur_cck_pwdb;
+   cck_rx_ver2_sec_index = i;
+   /* otherwise we don't need to 
set any index */
} else if ((cur_cck_pwdb  
tmp_cck_sec_pwdb)  (cur_cck_pwdb  tmp_cck_min_pwdb)) {
/*  This case we don't need to 
set any index */
-   } else if (cur_cck_pwdb == 
tmp_cck_min_pwdb) {
-   if (tmp_cck_sec_pwdb == 
tmp_cck_min_pwdb) { /*  let sec and min point to the different index */
-   tmp_cck_min_pwdb = 
cur_cck_pwdb;
-   cck_rx_ver2_min_index = 
i;
-   } else {
-   /*  This case we don't 
need to set any index */
-   }
+   } else if (cur_cck_pwdb == 
tmp_cck_min_pwdb  tmp_cck_sec_pwdb == tmp_cck_min_pwdb) {
+   /*  let sec and min point to 
the different index */
+   tmp_cck_min_pwdb = cur_cck_pwdb;
+   cck_rx_ver2_min_index = i;
+   /* otherwise we don't need to 
set any index */
} else if (cur_cck_pwdb  
tmp_cck_min_pwdb) {
tmp_cck_min_pwdb = cur_cck_pwdb;
cck_rx_ver2_min_index = i;
--
2.2.2
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RESEND 2 3/4] staging: rtl8192u: remove redundant code

2015-01-18 Thread Lorenzo Stoakes
This patch fixes warnings/errors raised by checkpatch.pl relating to redundant
code in r8192U_dm.c.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 165 ---
 1 file changed, 74 insertions(+), 91 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index 0c2fa59..aeb8aa2 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -410,9 +410,8 @@ static void dm_check_rate_adaptive(struct net_device *dev)

ratr_value = targetRATR;
RT_TRACE(COMP_RATE, currentRATR = %x, targetRATR = 
%x\n, currentRATR, targetRATR);
-   if (priv-rf_type == RF_1T2R) {
+   if (priv-rf_type == RF_1T2R)
ratr_value = ~(RATE_ALL_OFDM_2SS);
-   }
write_nic_dword(dev, RATR0, ratr_value);
write_nic_byte(dev, UFWP, 1);

@@ -440,17 +439,15 @@ static void dm_bandwidth_autoswitch(struct net_device 
*dev)
 {
struct r8192_priv *priv = ieee80211_priv(dev);

-   if (priv-CurrentChannelBW == HT_CHANNEL_WIDTH_20 || 
!priv-ieee80211-bandwidth_auto_switch.bautoswitch_enable) {
+   if (priv-CurrentChannelBW == HT_CHANNEL_WIDTH_20 || 
!priv-ieee80211-bandwidth_auto_switch.bautoswitch_enable)
return;
-   } else {
-   if (priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz == 
false) { /* If send packets in 40 Mhz in 20/40 */
-   if (priv-undecorated_smoothed_pwdb = 
priv-ieee80211-bandwidth_auto_switch.threshold_40Mhzto20Mhz)
-   
priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz = true;
-   } else { /* in force send packets in 20 Mhz in 20/40 */
-   if (priv-undecorated_smoothed_pwdb = 
priv-ieee80211-bandwidth_auto_switch.threshold_20Mhzto40Mhz)
-   
priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz = false;
+   if (priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz == false) { 
/* If send packets in 40 Mhz in 20/40 */
+   if (priv-undecorated_smoothed_pwdb = 
priv-ieee80211-bandwidth_auto_switch.threshold_40Mhzto20Mhz)
+   priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz 
= true;
+   } else { /* in force send packets in 20 Mhz in 20/40 */
+   if (priv-undecorated_smoothed_pwdb = 
priv-ieee80211-bandwidth_auto_switch.threshold_20Mhzto40Mhz)
+   priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz 
= false;

-   }
}
 }  /* dm_BandwidthAutoSwitch */

@@ -538,9 +535,8 @@ static void dm_TXPowerTrackingCallback_TSSI(struct 
net_device *dev)
tx_cmd.Length = 4;
tx_cmd.Value = Value;
rtStatus = SendTxCommandPacket(dev, tx_cmd, 12);
-   if (rtStatus == RT_STATUS_FAILURE) {
+   if (rtStatus == RT_STATUS_FAILURE)
RT_TRACE(COMP_POWER_TRACKING, Set configuration with 
tx cmd queue fail!\n);
-   }
mdelay(1);
/*DbgPrint(hi, vivi, strange\n);*/
for (i = 0; i = 30; i++) {
@@ -580,9 +576,8 @@ static void dm_TXPowerTrackingCallback_TSSI(struct 
net_device *dev)
break;
}

-   for (k = 0; k  5; k++) {
+   for (k = 0; k  5; k++)
Avg_TSSI_Meas_from_driver += tmp_report[k];
-   }

Avg_TSSI_Meas_from_driver = 
Avg_TSSI_Meas_from_driver*100/5;
RT_TRACE(COMP_POWER_TRACKING, 
Avg_TSSI_Meas_from_driver = %d\n, Avg_TSSI_Meas_from_driver);
@@ -605,56 +600,55 @@ static void dm_TXPowerTrackingCallback_TSSI(struct 
net_device *dev)
RT_TRACE(COMP_POWER_TRACKING, 
priv-cck_present_attentuation_difference = %d\n, 
priv-cck_present_attentuation_difference);
RT_TRACE(COMP_POWER_TRACKING, 
priv-cck_present_attentuation = %d\n, priv-cck_present_attentuation);
return;
-   } else {
-   if (Avg_TSSI_Meas_from_driver  TSSI_13dBm - 
E_FOR_TX_POWER_TRACK) {
-   if (priv-rfa_txpowertrackingindex  0) 
{
-   
priv-rfa_txpowertrackingindex--;
-   if 
(priv-rfa_txpowertrackingindex_real  4) {
-   
priv-rfa_txpowertrackingindex_real--;
-   rtl8192_setBBreg(dev, 
rOFDM0_XATxIQImbalance, bMaskDWord, 
priv-txbbgain_table[priv-rfa_txpowertrackingindex_real].txbbgain_value

[PATCH RESEND 2 2/4] staging: rtl8192u: fix whitespace and alignment

2015-01-18 Thread Lorenzo Stoakes
This patch fixes warnings/errors raised by checkpatch.pl relating to whitespace
in r8192U_dm.c, removes inconsistent whitespace, and additionally fixes some
vertical alignment issues.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 1697 +-
 1 file changed, 660 insertions(+), 1037 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index c66a901..0c2fa59 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -22,11 +22,12 @@ Major Change History:
 #include r819xU_cmdpkt.h
 /*---Define Local Constant---*/
 /* Indicate different AP vendor for IOT issue. */
-static u32 edca_setting_DL[HT_IOT_PEER_MAX] =
-   { 0x5e4322, 0x5e4322,   0x5e4322,   0x604322,   
0xa44f, 0x5ea44f};
-static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
-   { 0x5e4322, 0xa44f, 0x5e4322,   0x604322,   
0x5ea44f,   0x5ea44f};
-
+static u32 edca_setting_DL[HT_IOT_PEER_MAX] = {
+   0x5e4322, 0x5e4322, 0x5e4322, 0x604322, 0x00a44f, 0x5ea44f
+};
+static u32 edca_setting_UL[HT_IOT_PEER_MAX] = {
+   0x5e4322, 0x00a44f, 0x5e4322, 0x604322, 0x5ea44f, 0x5ea44f
+};

 #define RTK_UL_EDCA 0xa44f
 #define RTK_DL_EDCA 0x5e4322
@@ -37,7 +38,7 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
 /* Debug variable ? */
 dig_t  dm_digtable;
 /* Store current software write register content for MAC PHY. */
-u8 dm_shadow[16][256] = {{0}};
+u8 dm_shadow[16][256] = { {0} };
 /* For Dynamic Rx Path Selection by Signal Strength */
 DRxPathSel DM_RxPathSelTable;
 /*Define global variable-*/
@@ -66,11 +67,8 @@ static   voiddm_bandwidth_autoswitch(struct 
net_device *dev);

 static voiddm_check_txpower_tracking(struct net_device *dev);

-
-
 /*static   voiddm_txpower_reset_recovery(struct net_device *dev);*/

-
 /* DM -- Dynamic Init Gain by RSSI */
 static voiddm_dig_init(struct net_device *dev);
 static voiddm_ctrl_initgain_byrssi(struct net_device *dev);
@@ -89,13 +87,11 @@ static  voiddm_check_edca_turbo(struct net_device 
*dev);
 /* DM -- Check PBC */
 static void dm_check_pbc_gpio(struct net_device *dev);

-
 /* DM -- Check current RX RF path state */
 static voiddm_check_rx_path_selection(struct net_device *dev);
 static void dm_init_rxpath_selection(struct net_device *dev);
 static void dm_rxpath_sel_byrssi(struct net_device *dev);

-
 /* DM -- Fsync for broadcom ap */
 static void dm_init_fsync(struct net_device *dev);
 static void dm_deInit_fsync(struct net_device *dev);
@@ -109,7 +105,6 @@ static  voiddm_check_txrateandretrycount(struct 
net_device *dev);
 static voiddm_init_dynamic_txpower(struct net_device *dev);
 static voiddm_dynamic_txpower(struct net_device *dev);

-
 /* DM -- For rate adaptive and DIG, we must send RSSI to firmware */
 static void dm_send_rssi_tofw(struct net_device *dev);
 static voiddm_ctstoself(struct net_device *dev);
@@ -148,14 +143,12 @@ void init_hal_dm(struct net_device *dev)

 void deinit_hal_dm(struct net_device *dev)
 {
-
dm_deInit_fsync(dev);
-
 }

-
 #ifdef USB_RX_AGGREGATION_SUPPORT
-void dm_CheckRxAggregation(struct net_device *dev) {
+void dm_CheckRxAggregation(struct net_device *dev)
+{
struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
PRT_HIGH_THROUGHPUT pHTInfo = priv-ieee80211-pHTInfo;
static unsigned longlastTxOkCnt;
@@ -184,14 +177,15 @@ void dm_CheckRxAggregation(struct net_device *dev) {
if ((curTxOkCnt + curRxOkCnt)  1500)
return;

-   if(curTxOkCnt  4*curRxOkCnt) {
+   if (curTxOkCnt  4*curRxOkCnt) {
if (priv-bCurrentRxAggrEnable) {
write_nic_dword(dev, 0x1a8, 0);
priv-bCurrentRxAggrEnable = false;
}
-   }else{
+   } else {
if (!priv-bCurrentRxAggrEnable  
!pHTInfo-bCurrentRT2RTAggregation) {
u32 ulValue;
+
ulValue = (pHTInfo-UsbRxFwAggrEn24) | 
(pHTInfo-UsbRxFwAggrPageNum16) |
(pHTInfo-UsbRxFwAggrPacketNum8) | 
(pHTInfo-UsbRxFwAggrTimeout);
/*
@@ -209,8 +203,6 @@ void dm_CheckRxAggregation(struct net_device *dev) {
 }  /* dm_CheckEdcaTurbo */
 #endif

-
-
 void hal_dm_watchdog(struct net_device *dev)
 {
/*struct r8192_priv *priv = ieee80211_priv(dev);*/
@@ -237,7 +229,6 @@ void hal_dm_watchdog(struct net_device *dev)
 #endif
 }  /* HalDmWatchDog */

-
 /*
  * Decide Rate Adaptive Set according to distance (signal strength)
  * 01/11/2008  MHC Modify input arguments and RATR table 
level.
@@ -246,7 +237,6 @@ void hal_dm_watchdog(struct net_device *dev

[PATCH RESEND 4/4] staging: rtl8192u: Refactor heavy nesting

2015-01-10 Thread Lorenzo Stoakes
This patch fixes warnings raised by checkpatch.pl relating to heavily indented
lines in r8192U_dm.c by refactoring code to achieve the same outcome indented by
one less tab.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index ed566bb..bae8511 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -2581,28 +2581,25 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev)
cck_rx_ver2_sec_index = 
cck_rx_ver2_max_index;
tmp_cck_max_pwdb = cur_cck_pwdb;
cck_rx_ver2_max_index = i;
-   } else if (cur_cck_pwdb == 
tmp_cck_max_pwdb) { /* let sec and min point to the different index */
+   } else if (cur_cck_pwdb == 
tmp_cck_max_pwdb) {
+   /* let sec and min point to the 
different index */
tmp_cck_sec_pwdb = cur_cck_pwdb;
cck_rx_ver2_sec_index = i;
} else if ((cur_cck_pwdb  
tmp_cck_max_pwdb)  (cur_cck_pwdb  tmp_cck_sec_pwdb)) {
tmp_cck_sec_pwdb = cur_cck_pwdb;
cck_rx_ver2_sec_index = i;
-   } else if (cur_cck_pwdb == 
tmp_cck_sec_pwdb) {
-   if (tmp_cck_sec_pwdb == 
tmp_cck_min_pwdb) { /* let sec and min point to the different index */
-   tmp_cck_sec_pwdb = 
cur_cck_pwdb;
-   cck_rx_ver2_sec_index = 
i;
-   } else {
-   /*  This case we don't 
need to set any index */
-   }
+   } else if (cur_cck_pwdb == 
tmp_cck_sec_pwdb  tmp_cck_sec_pwdb == tmp_cck_min_pwdb) {
+   /* let sec and min point to the 
different index */
+   tmp_cck_sec_pwdb = cur_cck_pwdb;
+   cck_rx_ver2_sec_index = i;
+   /* otherwise we don't need to 
set any index */
} else if ((cur_cck_pwdb  
tmp_cck_sec_pwdb)  (cur_cck_pwdb  tmp_cck_min_pwdb)) {
/*  This case we don't need to 
set any index */
-   } else if (cur_cck_pwdb == 
tmp_cck_min_pwdb) {
-   if (tmp_cck_sec_pwdb == 
tmp_cck_min_pwdb) { /*  let sec and min point to the different index */
-   tmp_cck_min_pwdb = 
cur_cck_pwdb;
-   cck_rx_ver2_min_index = 
i;
-   } else {
-   /*  This case we don't 
need to set any index */
-   }
+   } else if (cur_cck_pwdb == 
tmp_cck_min_pwdb  tmp_cck_sec_pwdb == tmp_cck_min_pwdb) {
+   /*  let sec and min point to 
the different index */
+   tmp_cck_min_pwdb = cur_cck_pwdb;
+   cck_rx_ver2_min_index = i;
+   /* otherwise we don't need to 
set any index */
} else if (cur_cck_pwdb  
tmp_cck_min_pwdb) {
tmp_cck_min_pwdb = cur_cck_pwdb;
cck_rx_ver2_min_index = i;
--
2.2.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RESEND 2/4] staging: rtl8192u: fix whitespace and alignment

2015-01-10 Thread Lorenzo Stoakes
This patch fixes warnings/errors raised by checkpatch.pl relating to whitespace
in r8192U_dm.c, removes inconsistent whitespace, and additionally fixes some
vertical alignment issues.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 1606 +-
 1 file changed, 625 insertions(+), 981 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index cafc717..862d2ab 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -22,11 +22,12 @@ Major Change History:
 #include r819xU_cmdpkt.h
 /*---Define Local Constant---*/
 /* Indicate different AP vendor for IOT issue. */
-static u32 edca_setting_DL[HT_IOT_PEER_MAX] =
-   { 0x5e4322, 0x5e4322,   0x5e4322,   0x604322,   
0xa44f, 0x5ea44f};
-static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
-   { 0x5e4322, 0xa44f, 0x5e4322,   0x604322,   
0x5ea44f,   0x5ea44f};
-
+static u32 edca_setting_DL[HT_IOT_PEER_MAX] = {
+   0x5e4322, 0x5e4322, 0x5e4322, 0x604322, 0x00a44f, 0x5ea44f
+};
+static u32 edca_setting_UL[HT_IOT_PEER_MAX] = {
+   0x5e4322, 0x00a44f, 0x5e4322, 0x604322, 0x5ea44f, 0x5ea44f
+};

 #define RTK_UL_EDCA 0xa44f
 #define RTK_DL_EDCA 0x5e4322
@@ -37,7 +38,7 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
 /* Debug variable ? */
 dig_t  dm_digtable;
 /* Store current software write register content for MAC PHY. */
-u8 dm_shadow[16][256] = {{0}};
+u8 dm_shadow[16][256] = { {0} };
 /* For Dynamic Rx Path Selection by Signal Strength */
 DRxPathSel DM_RxPathSelTable;
 /*Define global variable-*/
@@ -66,11 +67,8 @@ static   voiddm_bandwidth_autoswitch(struct 
net_device *dev);

 static voiddm_check_txpower_tracking(struct net_device *dev);

-
-
 /*static   voiddm_txpower_reset_recovery(struct net_device *dev);*/

-
 /* DM -- Dynamic Init Gain by RSSI */
 static voiddm_dig_init(struct net_device *dev);
 static voiddm_ctrl_initgain_byrssi(struct net_device *dev);
@@ -89,13 +87,11 @@ static  voiddm_check_edca_turbo(struct net_device 
*dev);
 /* DM -- Check PBC */
 static void dm_check_pbc_gpio(struct net_device *dev);

-
 /* DM -- Check current RX RF path state */
 static voiddm_check_rx_path_selection(struct net_device *dev);
 static void dm_init_rxpath_selection(struct net_device *dev);
 static void dm_rxpath_sel_byrssi(struct net_device *dev);

-
 /* DM -- Fsync for broadcom ap */
 static void dm_init_fsync(struct net_device *dev);
 static void dm_deInit_fsync(struct net_device *dev);
@@ -109,7 +105,6 @@ static  voiddm_check_txrateandretrycount(struct 
net_device *dev);
 static voiddm_init_dynamic_txpower(struct net_device *dev);
 static voiddm_dynamic_txpower(struct net_device *dev);

-
 /* DM -- For rate adaptive and DIG, we must send RSSI to firmware */
 static void dm_send_rssi_tofw(struct net_device *dev);
 static voiddm_ctstoself(struct net_device *dev);
@@ -148,14 +143,12 @@ void init_hal_dm(struct net_device *dev)

 void deinit_hal_dm(struct net_device *dev)
 {
-
dm_deInit_fsync(dev);
-
 }

-
 #ifdef USB_RX_AGGREGATION_SUPPORT
-void dm_CheckRxAggregation(struct net_device *dev) {
+void dm_CheckRxAggregation(struct net_device *dev)
+{
struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
PRT_HIGH_THROUGHPUT pHTInfo = priv-ieee80211-pHTInfo;
static unsigned longlastTxOkCnt;
@@ -184,14 +177,15 @@ void dm_CheckRxAggregation(struct net_device *dev) {
if ((curTxOkCnt + curRxOkCnt)  1500)
return;

-   if(curTxOkCnt  4*curRxOkCnt) {
+   if (curTxOkCnt  4*curRxOkCnt) {
if (priv-bCurrentRxAggrEnable) {
write_nic_dword(dev, 0x1a8, 0);
priv-bCurrentRxAggrEnable = false;
}
-   }else{
+   } else {
if (!priv-bCurrentRxAggrEnable  
!pHTInfo-bCurrentRT2RTAggregation) {
u32 ulValue;
+
ulValue = (pHTInfo-UsbRxFwAggrEn24) | 
(pHTInfo-UsbRxFwAggrPageNum16) |
(pHTInfo-UsbRxFwAggrPacketNum8) | 
(pHTInfo-UsbRxFwAggrTimeout);
/*
@@ -209,8 +203,6 @@ void dm_CheckRxAggregation(struct net_device *dev) {
 }  /* dm_CheckEdcaTurbo */
 #endif

-
-
 void hal_dm_watchdog(struct net_device *dev)
 {
/*struct r8192_priv *priv = ieee80211_priv(dev);*/
@@ -237,7 +229,6 @@ void hal_dm_watchdog(struct net_device *dev)
 #endif
 }  /* HalDmWatchDog */

-
 /*
  * Decide Rate Adaptive Set according to distance (signal strength)
  * 01/11/2008  MHC Modify input arguments and RATR table 
level.
@@ -246,7 +237,6 @@ void hal_dm_watchdog(struct net_device *dev

[PATCH RESEND 3/4] staging: rtl8192u: remove redundant code

2015-01-10 Thread Lorenzo Stoakes
This patch fixes warnings/errors raised by checkpatch.pl relating to redundant
code in r8192U_dm.c.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 176 +--
 1 file changed, 84 insertions(+), 92 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index 862d2ab..ed566bb 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -410,9 +410,9 @@ static void dm_check_rate_adaptive(struct net_device *dev)

ratr_value = targetRATR;
RT_TRACE(COMP_RATE, currentRATR = %x, targetRATR = 
%x\n, currentRATR, targetRATR);
-   if (priv-rf_type == RF_1T2R) {
+   if (priv-rf_type == RF_1T2R)
ratr_value = ~(RATE_ALL_OFDM_2SS);
-   }
+
write_nic_dword(dev, RATR0, ratr_value);
write_nic_byte(dev, UFWP, 1);

@@ -440,18 +440,17 @@ static void dm_bandwidth_autoswitch(struct net_device 
*dev)
 {
struct r8192_priv *priv = ieee80211_priv(dev);

-   if (priv-CurrentChannelBW == HT_CHANNEL_WIDTH_20 || 
!priv-ieee80211-bandwidth_auto_switch.bautoswitch_enable) {
+   if (priv-CurrentChannelBW == HT_CHANNEL_WIDTH_20 || 
!priv-ieee80211-bandwidth_auto_switch.bautoswitch_enable)
return;
-   } else {
-   if (priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz == 
false) { /* If send packets in 40 Mhz in 20/40 */
-   if (priv-undecorated_smoothed_pwdb = 
priv-ieee80211-bandwidth_auto_switch.threshold_40Mhzto20Mhz)
-   
priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz = true;
-   } else { /* in force send packets in 20 Mhz in 20/40 */
-   if (priv-undecorated_smoothed_pwdb = 
priv-ieee80211-bandwidth_auto_switch.threshold_20Mhzto40Mhz)
-   
priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz = false;

-   }
+   if (priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz == false) { 
/* If send packets in 40 Mhz in 20/40 */
+   if (priv-undecorated_smoothed_pwdb = 
priv-ieee80211-bandwidth_auto_switch.threshold_40Mhzto20Mhz)
+   priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz 
= true;
+   } else { /* in force send packets in 20 Mhz in 20/40 */
+   if (priv-undecorated_smoothed_pwdb = 
priv-ieee80211-bandwidth_auto_switch.threshold_20Mhzto40Mhz)
+   priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz 
= false;
}
+
 }  /* dm_BandwidthAutoSwitch */

 /* OFDM default at 0db, index=6. */
@@ -538,9 +537,8 @@ static void dm_TXPowerTrackingCallback_TSSI(struct 
net_device *dev)
tx_cmd.Length = 4;
tx_cmd.Value = Value;
rtStatus = SendTxCommandPacket(dev, tx_cmd, 12);
-   if (rtStatus == RT_STATUS_FAILURE) {
+   if (rtStatus == RT_STATUS_FAILURE)
RT_TRACE(COMP_POWER_TRACKING, Set configuration with 
tx cmd queue fail!\n);
-   }
mdelay(1);
/*DbgPrint(hi, vivi, strange\n);*/
for (i = 0; i = 30; i++) {
@@ -580,9 +578,8 @@ static void dm_TXPowerTrackingCallback_TSSI(struct 
net_device *dev)
break;
}

-   for (k = 0; k  5; k++) {
+   for (k = 0; k  5; k++)
Avg_TSSI_Meas_from_driver += tmp_report[k];
-   }

Avg_TSSI_Meas_from_driver = 
Avg_TSSI_Meas_from_driver*100/5;
RT_TRACE(COMP_POWER_TRACKING, 
Avg_TSSI_Meas_from_driver = %d\n, Avg_TSSI_Meas_from_driver);
@@ -605,56 +602,55 @@ static void dm_TXPowerTrackingCallback_TSSI(struct 
net_device *dev)
RT_TRACE(COMP_POWER_TRACKING, 
priv-cck_present_attentuation_difference = %d\n, 
priv-cck_present_attentuation_difference);
RT_TRACE(COMP_POWER_TRACKING, 
priv-cck_present_attentuation = %d\n, priv-cck_present_attentuation);
return;
-   } else {
-   if (Avg_TSSI_Meas_from_driver  TSSI_13dBm - 
E_FOR_TX_POWER_TRACK) {
-   if (priv-rfa_txpowertrackingindex  0) 
{
-   
priv-rfa_txpowertrackingindex--;
-   if 
(priv-rfa_txpowertrackingindex_real  4) {
-   
priv-rfa_txpowertrackingindex_real--;
-   rtl8192_setBBreg(dev, 
rOFDM0_XATxIQImbalance, bMaskDWord, 
priv-txbbgain_table[priv

[PATCH RESEND 1/4] staging: rtl8192u: fix comments

2015-01-10 Thread Lorenzo Stoakes
This patch fixes errors raised by checkpatch.pl relating to use of C99 comments
in r8192U_dm.c, and cleans up existing ANSI C comments.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 811 ++-
 1 file changed, 420 insertions(+), 391 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index 936565d..cafc717 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -21,9 +21,7 @@ Major Change History:
 #include r8190_rtl8256.h
 #include r819xU_cmdpkt.h
 /*---Define Local Constant---*/
-//
-// Indicate different AP vendor for IOT issue.
-//
+/* Indicate different AP vendor for IOT issue. */
 static u32 edca_setting_DL[HT_IOT_PEER_MAX] =
{ 0x5e4322, 0x5e4322,   0x5e4322,   0x604322,   
0xa44f, 0x5ea44f};
 static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
@@ -36,11 +34,11 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] =


 /*Define global variable-*/
-// Debug variable ?
+/* Debug variable ? */
 dig_t  dm_digtable;
-// Store current software write register content for MAC PHY.
+/* Store current software write register content for MAC PHY. */
 u8 dm_shadow[16][256] = {{0}};
-// For Dynamic Rx Path Selection by Signal Strength
+/* For Dynamic Rx Path Selection by Signal Strength */
 DRxPathSel DM_RxPathSelTable;
 /*Define global variable-*/

@@ -56,24 +54,24 @@ extern  void dm_check_fsync(struct net_device *dev);


 /*-Define local function prototype---*/
-// DM -- Rate Adaptive
+/* DM -- Rate Adaptive */
 static voiddm_check_rate_adaptive(struct net_device *dev);

-// DM -- Bandwidth switch
+/* DM -- Bandwidth switch */
 static voiddm_init_bandwidth_autoswitch(struct net_device *dev);
 static voiddm_bandwidth_autoswitch(struct net_device *dev);

-// DM -- TX power control
-//static   voiddm_initialize_txpower_tracking(struct net_device *dev);
+/* DM -- TX power control */
+/*static   voiddm_initialize_txpower_tracking(struct net_device 
*dev);*/

 static voiddm_check_txpower_tracking(struct net_device *dev);



-//static   voiddm_txpower_reset_recovery(struct net_device *dev);
+/*static   voiddm_txpower_reset_recovery(struct net_device *dev);*/


-// DM -- Dynamic Init Gain by RSSI
+/* DM -- Dynamic Init Gain by RSSI */
 static voiddm_dig_init(struct net_device *dev);
 static voiddm_ctrl_initgain_byrssi(struct net_device *dev);
 static voiddm_ctrl_initgain_byrssi_highpwr(struct net_device *dev);
@@ -84,61 +82,61 @@ static  voiddm_pd_th(struct net_device *dev);
 static voiddm_cs_ratio(struct net_device *dev);

 static void dm_init_ctstoself(struct net_device *dev);
-// DM -- EDCA turbo mode control
+/* DM -- EDCA turbo mode control */
 static voiddm_check_edca_turbo(struct net_device *dev);

-//static   voiddm_gpio_change_rf(struct net_device *dev);
-// DM -- Check PBC
+/*static   voiddm_gpio_change_rf(struct net_device *dev);*/
+/* DM -- Check PBC */
 static void dm_check_pbc_gpio(struct net_device *dev);


-// DM -- Check current RX RF path state
+/* DM -- Check current RX RF path state */
 static voiddm_check_rx_path_selection(struct net_device *dev);
 static void dm_init_rxpath_selection(struct net_device *dev);
 static void dm_rxpath_sel_byrssi(struct net_device *dev);


-// DM -- Fsync for broadcom ap
+/* DM -- Fsync for broadcom ap */
 static void dm_init_fsync(struct net_device *dev);
 static void dm_deInit_fsync(struct net_device *dev);

-//Added by vivi, 20080522
+/* Added by vivi, 20080522 */
 static voiddm_check_txrateandretrycount(struct net_device *dev);

 /*-Define local function prototype---*/

-/*-Define of Tx Power Control For Near/Far Range 
*/   //Add by Jacken 2008/02/18
+/*-Define of Tx Power Control For Near/Far Range 
*/   /*Add by Jacken 2008/02/18 */
 static voiddm_init_dynamic_txpower(struct net_device *dev);
 static voiddm_dynamic_txpower(struct net_device *dev);


-// DM -- For rate adaptive and DIG, we must send RSSI to firmware
+/* DM -- For rate adaptive and DIG, we must send RSSI to firmware */
 static void dm_send_rssi_tofw(struct net_device *dev);
 static voiddm_ctstoself(struct net_device *dev);
 /*---Define function 
prototype*/
-//
-// HW Dynamic mechanism interface.
-//
-
-//
-// Description:
-// Prepare SW resource for HW dynamic

Re: [PATCH v3 2/4] staging: rtl8192u: fix whitespace

2015-01-01 Thread Lorenzo Stoakes
On 1 January 2015 at 06:28, Sudip Mukherjee sudipm.mukher...@gmail.com wrote:

  i may be wrong, but looks like you are doing many different things in the 
  patch, not just whitespace errors.
  marked a few, please see inline -
...
 sorry for not trimming that. I noticed the big size while sending, but at 
 that time the damage has already been done.
 but is it ok if we mention one thing in the commit log and do other things 
 also? shouldn't we atleast mention that in the commit?

Hi Sudip,

I felt that 'additionally it removes inconsistent whitespace
throughout.' covered these cases, given there's a lot I also felt it'd
be more irritating for the community to receive several separate
patches for each individual *sub* type of whitespace removal beyond
those fixing checkpatch.pl messages, of course that kind of separation
could get pretty big and these patches are already big enough as it is
(this file had a lot of issues :)

As someone who's new to kernel development I'd be more than happy to
adjust this if the consensus is towards a different approach, however
I feel this is the least painful means of doing this particular patch
set.

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


Re: [PATCH v2 3/4] staging: rtl8192u: remove redundant code

2015-01-01 Thread Lorenzo Stoakes
On 1 January 2015 at 04:58, Sudip Mukherjee sudipm.mukher...@gmail.com wrote:
 On Thu, Jan 01, 2015 at 10:19:56AM +0530, Sudip Mukherjee wrote:
 but this is just removal of unnecessary braces. this is not removal of 
 redundant code.

Hi Sudip,

Again in the same theme as the whitespace changes I felt I could
fairly reasonably package up a set of similar changes which remove
redundant *symbols* of one kind or another, which though they might
not constitute significant reduction in redundant code could
reasonably come under that header.

Again I'm more than happy to edit the message to describe this change
more correctly and/or split further though, as before, I'm wary of
splitting too much as to cause irritation to reviewers.

 and, missed writing in the last mail.
 your [PATCH v2 2/4] and [PATCH v2 3/4] are same.

Apologies for this, I simply batched up the whole set once again
without checking what would remain the same or not. I don't make this
mistake for the v3 of patch 2 and will be careful to avoid this in
future!

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


[PATCH 1/4] staging: rtl8192u: fix comments

2014-12-31 Thread Lorenzo Stoakes
This patch fixes errors raised by checkpatch.pl relating to use of C99 comments
in r8192U_dm.c.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 841 ++-
 1 file changed, 432 insertions(+), 409 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index 936565d..44f4c38 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -21,14 +21,15 @@ Major Change History:
 #include r8190_rtl8256.h
 #include r819xU_cmdpkt.h
 /*---Define Local Constant---*/
-//
-// Indicate different AP vendor for IOT issue.
-//
-static u32 edca_setting_DL[HT_IOT_PEER_MAX] =
-   { 0x5e4322, 0x5e4322,   0x5e4322,   0x604322,   
0xa44f, 0x5ea44f};
-static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
-   { 0x5e4322, 0xa44f, 0x5e4322,   0x604322,   
0x5ea44f,   0x5ea44f};
-
+/*
+ * Indicate different AP vendor for IOT issue.
+ */
+static u32 edca_setting_DL[HT_IOT_PEER_MAX] = {
+   0x5e4322, 0x5e4322, 0x5e4322, 0x604322, 0xa44f, 0x5ea44f
+};
+static u32 edca_setting_UL[HT_IOT_PEER_MAX] = {
+   0x5e4322, 0xa44f, 0x5e4322, 0x604322, 0x5ea44f, 0x5ea44f
+};

 #define RTK_UL_EDCA 0xa44f
 #define RTK_DL_EDCA 0x5e4322
@@ -36,11 +37,11 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] =


 /*Define global variable-*/
-// Debug variable ?
+/* Debug variable ? */
 dig_t  dm_digtable;
-// Store current software write register content for MAC PHY.
+/* Store current software write register content for MAC PHY. */
 u8 dm_shadow[16][256] = {{0}};
-// For Dynamic Rx Path Selection by Signal Strength
+/* For Dynamic Rx Path Selection by Signal Strength */
 DRxPathSel DM_RxPathSelTable;
 /*Define global variable-*/

@@ -56,24 +57,24 @@ extern  void dm_check_fsync(struct net_device *dev);


 /*-Define local function prototype---*/
-// DM -- Rate Adaptive
+/* DM -- Rate Adaptive */
 static voiddm_check_rate_adaptive(struct net_device *dev);

-// DM -- Bandwidth switch
+/* DM -- Bandwidth switch */
 static voiddm_init_bandwidth_autoswitch(struct net_device *dev);
 static voiddm_bandwidth_autoswitch(struct net_device *dev);

-// DM -- TX power control
-//static   voiddm_initialize_txpower_tracking(struct net_device *dev);
+/* DM -- TX power control */
+/*static   voiddm_initialize_txpower_tracking(struct net_device 
*dev);*/

 static voiddm_check_txpower_tracking(struct net_device *dev);



-//static   voiddm_txpower_reset_recovery(struct net_device *dev);
+/*static   voiddm_txpower_reset_recovery(struct net_device *dev);*/


-// DM -- Dynamic Init Gain by RSSI
+/* DM -- Dynamic Init Gain by RSSI */
 static voiddm_dig_init(struct net_device *dev);
 static voiddm_ctrl_initgain_byrssi(struct net_device *dev);
 static voiddm_ctrl_initgain_byrssi_highpwr(struct net_device *dev);
@@ -84,61 +85,61 @@ static  voiddm_pd_th(struct net_device *dev);
 static voiddm_cs_ratio(struct net_device *dev);

 static void dm_init_ctstoself(struct net_device *dev);
-// DM -- EDCA turbo mode control
+/* DM -- EDCA turbo mode control */
 static voiddm_check_edca_turbo(struct net_device *dev);

-//static   voiddm_gpio_change_rf(struct net_device *dev);
-// DM -- Check PBC
+/*static   voiddm_gpio_change_rf(struct net_device *dev);*/
+/* DM -- Check PBC */
 static void dm_check_pbc_gpio(struct net_device *dev);


-// DM -- Check current RX RF path state
+/* DM -- Check current RX RF path state */
 static voiddm_check_rx_path_selection(struct net_device *dev);
 static void dm_init_rxpath_selection(struct net_device *dev);
 static void dm_rxpath_sel_byrssi(struct net_device *dev);


-// DM -- Fsync for broadcom ap
+/* DM -- Fsync for broadcom ap */
 static void dm_init_fsync(struct net_device *dev);
 static void dm_deInit_fsync(struct net_device *dev);

-//Added by vivi, 20080522
+/* Added by vivi, 20080522 */
 static voiddm_check_txrateandretrycount(struct net_device *dev);

 /*-Define local function prototype---*/

-/*-Define of Tx Power Control For Near/Far Range 
*/   //Add by Jacken 2008/02/18
+/*-Define of Tx Power Control For Near/Far Range 
*/   /*Add by Jacken 2008/02/18 */
 static voiddm_init_dynamic_txpower(struct net_device *dev);
 static voiddm_dynamic_txpower(struct net_device *dev);


-// DM -- For rate adaptive and DIG, we must send RSSI to firmware
+/* DM -- For rate adaptive and DIG, we must send RSSI to firmware */
 static void dm_send_rssi_tofw(struct net_device *dev);
 static voiddm_ctstoself(struct net_device *dev

[PATCH 3/4] staging: rtl8192u: remove redundant code

2014-12-31 Thread Lorenzo Stoakes
This patch fixes warnings/errors raised by checkpatch.pl relating to redundant
code in r8192U_dm.c.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 160 +--
 1 file changed, 77 insertions(+), 83 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index bf141c6..0839ea7 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -412,9 +412,9 @@ static void dm_check_rate_adaptive(struct net_device *dev)

ratr_value = targetRATR;
RT_TRACE(COMP_RATE, currentRATR = %x, targetRATR = 
%x\n, currentRATR, targetRATR);
-   if (priv-rf_type == RF_1T2R) {
+   if (priv-rf_type == RF_1T2R)
ratr_value = ~(RATE_ALL_OFDM_2SS);
-   }
+
write_nic_dword(dev, RATR0, ratr_value);
write_nic_byte(dev, UFWP, 1);

@@ -442,18 +442,17 @@ static void dm_bandwidth_autoswitch(struct net_device 
*dev)
 {
struct r8192_priv *priv = ieee80211_priv(dev);

-   if (priv-CurrentChannelBW == HT_CHANNEL_WIDTH_20 || 
!priv-ieee80211-bandwidth_auto_switch.bautoswitch_enable) {
+   if (priv-CurrentChannelBW == HT_CHANNEL_WIDTH_20 || 
!priv-ieee80211-bandwidth_auto_switch.bautoswitch_enable)
return;
-   } else {
-   if (priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz == 
false) { /* If send packets in 40 Mhz in 20/40 */
-   if (priv-undecorated_smoothed_pwdb = 
priv-ieee80211-bandwidth_auto_switch.threshold_40Mhzto20Mhz)
-   
priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz = true;
-   } else { /* in force send packets in 20 Mhz in 20/40 */
-   if (priv-undecorated_smoothed_pwdb = 
priv-ieee80211-bandwidth_auto_switch.threshold_20Mhzto40Mhz)
-   
priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz = false;

-   }
+   if (priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz == false) { 
/* If send packets in 40 Mhz in 20/40 */
+   if (priv-undecorated_smoothed_pwdb = 
priv-ieee80211-bandwidth_auto_switch.threshold_40Mhzto20Mhz)
+   priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz 
= true;
+   } else { /* in force send packets in 20 Mhz in 20/40 */
+   if (priv-undecorated_smoothed_pwdb = 
priv-ieee80211-bandwidth_auto_switch.threshold_20Mhzto40Mhz)
+   priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz 
= false;
}
+
 }  /* dm_BandwidthAutoSwitch */

 /* OFDM default at 0db, index=6. */
@@ -540,9 +539,9 @@ static void dm_TXPowerTrackingCallback_TSSI(struct 
net_device *dev)
tx_cmd.Length   = 4;
tx_cmd.Value= Value;
rtStatus = SendTxCommandPacket(dev, tx_cmd, 12);
-   if (rtStatus == RT_STATUS_FAILURE) {
+   if (rtStatus == RT_STATUS_FAILURE)
RT_TRACE(COMP_POWER_TRACKING, Set configuration with tx cmd 
queue fail!\n);
-   }
+
mdelay(1);
/*DbgPrint(hi, vivi, strange\n);*/
for (i = 0; i = 30; i++) {
@@ -582,9 +581,8 @@ static void dm_TXPowerTrackingCallback_TSSI(struct 
net_device *dev)
break;
}

-   for (k = 0; k  5; k++) {
+   for (k = 0; k  5; k++)
Avg_TSSI_Meas_from_driver += tmp_report[k];
-   }

Avg_TSSI_Meas_from_driver = Avg_TSSI_Meas_from_driver*100/5;
RT_TRACE(COMP_POWER_TRACKING, Avg_TSSI_Meas_from_driver = 
%d\n, Avg_TSSI_Meas_from_driver);
@@ -607,43 +605,44 @@ static void dm_TXPowerTrackingCallback_TSSI(struct 
net_device *dev)
RT_TRACE(COMP_POWER_TRACKING, 
priv-cck_present_attentuation_difference = %d\n, 
priv-cck_present_attentuation_difference);
RT_TRACE(COMP_POWER_TRACKING, 
priv-cck_present_attentuation = %d\n, priv-cck_present_attentuation);
return;
-   } else {
-   if (Avg_TSSI_Meas_from_driver  TSSI_13dBm - 
E_FOR_TX_POWER_TRACK) {
-   if (priv-rfa_txpowertrackingindex  0) {
-   priv-rfa_txpowertrackingindex--;
-   if (priv-rfa_txpowertrackingindex_real 
 4) {
-   
priv-rfa_txpowertrackingindex_real--;
-   rtl8192_setBBreg(dev, 
rOFDM0_XATxIQImbalance, bMaskDWord, 
priv-txbbgain_table[priv-rfa_txpowertrackingindex_real].txbbgain_value);
-   }
-   }
-   } else {
-   if (priv-rfa_txpowertrackingindex  36

[PATCH 2/4] staging: rtl8192u: fix whitespace

2014-12-31 Thread Lorenzo Stoakes
This patch fixes warnings/errors raised by checkpatch.pl relating to whitespace
in r8192U_dm.c.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 1409 +-
 1 file changed, 530 insertions(+), 879 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index 44f4c38..bf141c6 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -25,7 +25,7 @@ Major Change History:
  * Indicate different AP vendor for IOT issue.
  */
 static u32 edca_setting_DL[HT_IOT_PEER_MAX] = {
-   0x5e4322, 0x5e4322, 0x5e4322, 0x604322, 0xa44f, 0x5ea44f
+   0x5e4322, 0x5e4322, 0x5e4322, 0x604322, 0xa44f, 0x5ea44f
 };
 static u32 edca_setting_UL[HT_IOT_PEER_MAX] = {
0x5e4322, 0xa44f, 0x5e4322, 0x604322, 0x5ea44f, 0x5ea44f
@@ -40,7 +40,7 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] = {
 /* Debug variable ? */
 dig_t  dm_digtable;
 /* Store current software write register content for MAC PHY. */
-u8 dm_shadow[16][256] = {{0}};
+u8 dm_shadow[16][256] = { {0} };
 /* For Dynamic Rx Path Selection by Signal Strength */
 DRxPathSel DM_RxPathSelTable;
 /*Define global variable-*/
@@ -69,11 +69,8 @@ static   voiddm_bandwidth_autoswitch(struct 
net_device *dev);

 static voiddm_check_txpower_tracking(struct net_device *dev);

-
-
 /*static   voiddm_txpower_reset_recovery(struct net_device *dev);*/

-
 /* DM -- Dynamic Init Gain by RSSI */
 static voiddm_dig_init(struct net_device *dev);
 static voiddm_ctrl_initgain_byrssi(struct net_device *dev);
@@ -92,13 +89,11 @@ static  voiddm_check_edca_turbo(struct net_device 
*dev);
 /* DM -- Check PBC */
 static void dm_check_pbc_gpio(struct net_device *dev);

-
 /* DM -- Check current RX RF path state */
 static voiddm_check_rx_path_selection(struct net_device *dev);
 static void dm_init_rxpath_selection(struct net_device *dev);
 static void dm_rxpath_sel_byrssi(struct net_device *dev);

-
 /* DM -- Fsync for broadcom ap */
 static void dm_init_fsync(struct net_device *dev);
 static void dm_deInit_fsync(struct net_device *dev);
@@ -112,7 +107,6 @@ static  voiddm_check_txrateandretrycount(struct 
net_device *dev);
 static voiddm_init_dynamic_txpower(struct net_device *dev);
 static voiddm_dynamic_txpower(struct net_device *dev);

-
 /* DM -- For rate adaptive and DIG, we must send RSSI to firmware */
 static void dm_send_rssi_tofw(struct net_device *dev);
 static voiddm_ctstoself(struct net_device *dev);
@@ -151,14 +145,12 @@ void init_hal_dm(struct net_device *dev)

 void deinit_hal_dm(struct net_device *dev)
 {
-
dm_deInit_fsync(dev);
-
 }

-
 #ifdef USB_RX_AGGREGATION_SUPPORT
-void dm_CheckRxAggregation(struct net_device *dev) {
+void dm_CheckRxAggregation(struct net_device *dev)
+{
struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
PRT_HIGH_THROUGHPUT pHTInfo = priv-ieee80211-pHTInfo;
static unsigned longlastTxOkCnt;
@@ -187,14 +179,15 @@ void dm_CheckRxAggregation(struct net_device *dev) {
if ((curTxOkCnt + curRxOkCnt)  1500)
return;

-   if(curTxOkCnt  4*curRxOkCnt) {
+   if (curTxOkCnt  4*curRxOkCnt) {
if (priv-bCurrentRxAggrEnable) {
write_nic_dword(dev, 0x1a8, 0);
priv-bCurrentRxAggrEnable = false;
}
-   }else{
+   } else {
if (!priv-bCurrentRxAggrEnable  
!pHTInfo-bCurrentRT2RTAggregation) {
u32 ulValue;
+
ulValue = (pHTInfo-UsbRxFwAggrEn24) | 
(pHTInfo-UsbRxFwAggrPageNum16) |
(pHTInfo-UsbRxFwAggrPacketNum8) | 
(pHTInfo-UsbRxFwAggrTimeout);
/*
@@ -212,8 +205,6 @@ void dm_CheckRxAggregation(struct net_device *dev) {
 }  /* dm_CheckEdcaTurbo */
 #endif

-
-
 void hal_dm_watchdog(struct net_device *dev)
 {
/*struct r8192_priv *priv = ieee80211_priv(dev);*/
@@ -240,7 +231,6 @@ void hal_dm_watchdog(struct net_device *dev)
 #endif
 }  /* HalDmWatchDog */

-
 /*
  * Decide Rate Adaptive Set according to distance (signal strength)
  * 01/11/2008  MHC Modify input arguments and RATR table 
level.
@@ -249,7 +239,6 @@ void hal_dm_watchdog(struct net_device *dev)
  */
 void init_rate_adaptive(struct net_device *dev)
 {
-
struct r8192_priv *priv = ieee80211_priv(dev);
prate_adaptive  pra = (prate_adaptive)priv-rate_adaptive;

@@ -262,15 +251,13 @@ void init_rate_adaptive(struct net_device *dev)
pra-low_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M;
pra-low_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M;

-   if(priv-CustomerID == RT_CID_819x_Netcore)
+   if (priv-CustomerID == RT_CID_819x_Netcore)
pra

Re: [PATCH 1/4] staging: rtl8192u: fix comments

2014-12-31 Thread Lorenzo Stoakes
On 31 December 2014 at 19:00, Konrad Zapalowicz bergo.tor...@gmail.com wrote:

 You also fix the line length here which shall be the subject of a
 separate patch as this is not C99 comments related change.


Apologies - I missed this, will prepare a v2 with this separated out
into a different patch. Relatedly, the intent was to fix whitespace
issues rather than line length as I gather a specific line length
limit is still a matter of debate in kernel style? I didn't want to
create additional noise by attempting to address that as well.

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


Re: [PATCH 1/4] staging: rtl8192u: fix comments

2014-12-31 Thread Lorenzo Stoakes
On 31 December 2014 at 19:23, Jeremiah Mahler jmmah...@gmail.com wrote:
 But this change is not related to C99 comments and you didn't
 explain why this change was made in your log message.
 It should probably be in a separate patch.

Absolutely, I am currently fixing this and checking for any other
instances where unrelated changes may have crept in. Apologies for
this, a v2 of this patch set is coming shortly with this fixed.

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


[PATCH v2 1/4] staging: rtl8192u: fix comments

2014-12-31 Thread Lorenzo Stoakes
This patch fixes errors raised by checkpatch.pl relating to use of C99 comments
in r8192U_dm.c and cleans up existing ANSI C comments.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 811 ++-
 1 file changed, 420 insertions(+), 391 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index 936565d..cafc717 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -21,9 +21,7 @@ Major Change History:
 #include r8190_rtl8256.h
 #include r819xU_cmdpkt.h
 /*---Define Local Constant---*/
-//
-// Indicate different AP vendor for IOT issue.
-//
+/* Indicate different AP vendor for IOT issue. */
 static u32 edca_setting_DL[HT_IOT_PEER_MAX] =
{ 0x5e4322, 0x5e4322,   0x5e4322,   0x604322,   
0xa44f, 0x5ea44f};
 static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
@@ -36,11 +34,11 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] =


 /*Define global variable-*/
-// Debug variable ?
+/* Debug variable ? */
 dig_t  dm_digtable;
-// Store current software write register content for MAC PHY.
+/* Store current software write register content for MAC PHY. */
 u8 dm_shadow[16][256] = {{0}};
-// For Dynamic Rx Path Selection by Signal Strength
+/* For Dynamic Rx Path Selection by Signal Strength */
 DRxPathSel DM_RxPathSelTable;
 /*Define global variable-*/

@@ -56,24 +54,24 @@ extern  void dm_check_fsync(struct net_device *dev);


 /*-Define local function prototype---*/
-// DM -- Rate Adaptive
+/* DM -- Rate Adaptive */
 static voiddm_check_rate_adaptive(struct net_device *dev);

-// DM -- Bandwidth switch
+/* DM -- Bandwidth switch */
 static voiddm_init_bandwidth_autoswitch(struct net_device *dev);
 static voiddm_bandwidth_autoswitch(struct net_device *dev);

-// DM -- TX power control
-//static   voiddm_initialize_txpower_tracking(struct net_device *dev);
+/* DM -- TX power control */
+/*static   voiddm_initialize_txpower_tracking(struct net_device 
*dev);*/

 static voiddm_check_txpower_tracking(struct net_device *dev);



-//static   voiddm_txpower_reset_recovery(struct net_device *dev);
+/*static   voiddm_txpower_reset_recovery(struct net_device *dev);*/


-// DM -- Dynamic Init Gain by RSSI
+/* DM -- Dynamic Init Gain by RSSI */
 static voiddm_dig_init(struct net_device *dev);
 static voiddm_ctrl_initgain_byrssi(struct net_device *dev);
 static voiddm_ctrl_initgain_byrssi_highpwr(struct net_device *dev);
@@ -84,61 +82,61 @@ static  voiddm_pd_th(struct net_device *dev);
 static voiddm_cs_ratio(struct net_device *dev);

 static void dm_init_ctstoself(struct net_device *dev);
-// DM -- EDCA turbo mode control
+/* DM -- EDCA turbo mode control */
 static voiddm_check_edca_turbo(struct net_device *dev);

-//static   voiddm_gpio_change_rf(struct net_device *dev);
-// DM -- Check PBC
+/*static   voiddm_gpio_change_rf(struct net_device *dev);*/
+/* DM -- Check PBC */
 static void dm_check_pbc_gpio(struct net_device *dev);


-// DM -- Check current RX RF path state
+/* DM -- Check current RX RF path state */
 static voiddm_check_rx_path_selection(struct net_device *dev);
 static void dm_init_rxpath_selection(struct net_device *dev);
 static void dm_rxpath_sel_byrssi(struct net_device *dev);


-// DM -- Fsync for broadcom ap
+/* DM -- Fsync for broadcom ap */
 static void dm_init_fsync(struct net_device *dev);
 static void dm_deInit_fsync(struct net_device *dev);

-//Added by vivi, 20080522
+/* Added by vivi, 20080522 */
 static voiddm_check_txrateandretrycount(struct net_device *dev);

 /*-Define local function prototype---*/

-/*-Define of Tx Power Control For Near/Far Range 
*/   //Add by Jacken 2008/02/18
+/*-Define of Tx Power Control For Near/Far Range 
*/   /*Add by Jacken 2008/02/18 */
 static voiddm_init_dynamic_txpower(struct net_device *dev);
 static voiddm_dynamic_txpower(struct net_device *dev);


-// DM -- For rate adaptive and DIG, we must send RSSI to firmware
+/* DM -- For rate adaptive and DIG, we must send RSSI to firmware */
 static void dm_send_rssi_tofw(struct net_device *dev);
 static voiddm_ctstoself(struct net_device *dev);
 /*---Define function 
prototype*/
-//
-// HW Dynamic mechanism interface.
-//
-
-//
-// Description:
-// Prepare SW resource for HW dynamic

[PATCH v2 3/4] staging: rtl8192u: remove redundant code

2014-12-31 Thread Lorenzo Stoakes
This patch fixes warnings/errors raised by checkpatch.pl relating to redundant
code in r8192U_dm.c.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 176 +--
 1 file changed, 84 insertions(+), 92 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index 862d2ab..ed566bb 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -410,9 +410,9 @@ static void dm_check_rate_adaptive(struct net_device *dev)

ratr_value = targetRATR;
RT_TRACE(COMP_RATE, currentRATR = %x, targetRATR = 
%x\n, currentRATR, targetRATR);
-   if (priv-rf_type == RF_1T2R) {
+   if (priv-rf_type == RF_1T2R)
ratr_value = ~(RATE_ALL_OFDM_2SS);
-   }
+
write_nic_dword(dev, RATR0, ratr_value);
write_nic_byte(dev, UFWP, 1);

@@ -440,18 +440,17 @@ static void dm_bandwidth_autoswitch(struct net_device 
*dev)
 {
struct r8192_priv *priv = ieee80211_priv(dev);

-   if (priv-CurrentChannelBW == HT_CHANNEL_WIDTH_20 || 
!priv-ieee80211-bandwidth_auto_switch.bautoswitch_enable) {
+   if (priv-CurrentChannelBW == HT_CHANNEL_WIDTH_20 || 
!priv-ieee80211-bandwidth_auto_switch.bautoswitch_enable)
return;
-   } else {
-   if (priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz == 
false) { /* If send packets in 40 Mhz in 20/40 */
-   if (priv-undecorated_smoothed_pwdb = 
priv-ieee80211-bandwidth_auto_switch.threshold_40Mhzto20Mhz)
-   
priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz = true;
-   } else { /* in force send packets in 20 Mhz in 20/40 */
-   if (priv-undecorated_smoothed_pwdb = 
priv-ieee80211-bandwidth_auto_switch.threshold_20Mhzto40Mhz)
-   
priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz = false;

-   }
+   if (priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz == false) { 
/* If send packets in 40 Mhz in 20/40 */
+   if (priv-undecorated_smoothed_pwdb = 
priv-ieee80211-bandwidth_auto_switch.threshold_40Mhzto20Mhz)
+   priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz 
= true;
+   } else { /* in force send packets in 20 Mhz in 20/40 */
+   if (priv-undecorated_smoothed_pwdb = 
priv-ieee80211-bandwidth_auto_switch.threshold_20Mhzto40Mhz)
+   priv-ieee80211-bandwidth_auto_switch.bforced_tx20Mhz 
= false;
}
+
 }  /* dm_BandwidthAutoSwitch */

 /* OFDM default at 0db, index=6. */
@@ -538,9 +537,8 @@ static void dm_TXPowerTrackingCallback_TSSI(struct 
net_device *dev)
tx_cmd.Length = 4;
tx_cmd.Value = Value;
rtStatus = SendTxCommandPacket(dev, tx_cmd, 12);
-   if (rtStatus == RT_STATUS_FAILURE) {
+   if (rtStatus == RT_STATUS_FAILURE)
RT_TRACE(COMP_POWER_TRACKING, Set configuration with 
tx cmd queue fail!\n);
-   }
mdelay(1);
/*DbgPrint(hi, vivi, strange\n);*/
for (i = 0; i = 30; i++) {
@@ -580,9 +578,8 @@ static void dm_TXPowerTrackingCallback_TSSI(struct 
net_device *dev)
break;
}

-   for (k = 0; k  5; k++) {
+   for (k = 0; k  5; k++)
Avg_TSSI_Meas_from_driver += tmp_report[k];
-   }

Avg_TSSI_Meas_from_driver = 
Avg_TSSI_Meas_from_driver*100/5;
RT_TRACE(COMP_POWER_TRACKING, 
Avg_TSSI_Meas_from_driver = %d\n, Avg_TSSI_Meas_from_driver);
@@ -605,56 +602,55 @@ static void dm_TXPowerTrackingCallback_TSSI(struct 
net_device *dev)
RT_TRACE(COMP_POWER_TRACKING, 
priv-cck_present_attentuation_difference = %d\n, 
priv-cck_present_attentuation_difference);
RT_TRACE(COMP_POWER_TRACKING, 
priv-cck_present_attentuation = %d\n, priv-cck_present_attentuation);
return;
-   } else {
-   if (Avg_TSSI_Meas_from_driver  TSSI_13dBm - 
E_FOR_TX_POWER_TRACK) {
-   if (priv-rfa_txpowertrackingindex  0) 
{
-   
priv-rfa_txpowertrackingindex--;
-   if 
(priv-rfa_txpowertrackingindex_real  4) {
-   
priv-rfa_txpowertrackingindex_real--;
-   rtl8192_setBBreg(dev, 
rOFDM0_XATxIQImbalance, bMaskDWord, 
priv-txbbgain_table[priv

[PATCH v2 2/4] staging: rtl8192u: fix whitespace

2014-12-31 Thread Lorenzo Stoakes
This patch fixes warnings/errors raised by checkpatch.pl relating to whitespace
in r8192U_dm.c and additionally it removes inconsistent whitespace throughout.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 1606 +-
 1 file changed, 625 insertions(+), 981 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index cafc717..862d2ab 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -22,11 +22,12 @@ Major Change History:
 #include r819xU_cmdpkt.h
 /*---Define Local Constant---*/
 /* Indicate different AP vendor for IOT issue. */
-static u32 edca_setting_DL[HT_IOT_PEER_MAX] =
-   { 0x5e4322, 0x5e4322,   0x5e4322,   0x604322,   
0xa44f, 0x5ea44f};
-static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
-   { 0x5e4322, 0xa44f, 0x5e4322,   0x604322,   
0x5ea44f,   0x5ea44f};
-
+static u32 edca_setting_DL[HT_IOT_PEER_MAX] = {
+   0x5e4322, 0x5e4322, 0x5e4322, 0x604322, 0xa44f, 0x5ea44f
+};
+static u32 edca_setting_UL[HT_IOT_PEER_MAX] = {
+   0x5e4322, 0xa44f, 0x5e4322, 0x604322, 0x5ea44f, 0x5ea44f
+};

 #define RTK_UL_EDCA 0xa44f
 #define RTK_DL_EDCA 0x5e4322
@@ -37,7 +38,7 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
 /* Debug variable ? */
 dig_t  dm_digtable;
 /* Store current software write register content for MAC PHY. */
-u8 dm_shadow[16][256] = {{0}};
+u8 dm_shadow[16][256] = { {0} };
 /* For Dynamic Rx Path Selection by Signal Strength */
 DRxPathSel DM_RxPathSelTable;
 /*Define global variable-*/
@@ -66,11 +67,8 @@ static   voiddm_bandwidth_autoswitch(struct 
net_device *dev);

 static voiddm_check_txpower_tracking(struct net_device *dev);

-
-
 /*static   voiddm_txpower_reset_recovery(struct net_device *dev);*/

-
 /* DM -- Dynamic Init Gain by RSSI */
 static voiddm_dig_init(struct net_device *dev);
 static voiddm_ctrl_initgain_byrssi(struct net_device *dev);
@@ -89,13 +87,11 @@ static  voiddm_check_edca_turbo(struct net_device 
*dev);
 /* DM -- Check PBC */
 static void dm_check_pbc_gpio(struct net_device *dev);

-
 /* DM -- Check current RX RF path state */
 static voiddm_check_rx_path_selection(struct net_device *dev);
 static void dm_init_rxpath_selection(struct net_device *dev);
 static void dm_rxpath_sel_byrssi(struct net_device *dev);

-
 /* DM -- Fsync for broadcom ap */
 static void dm_init_fsync(struct net_device *dev);
 static void dm_deInit_fsync(struct net_device *dev);
@@ -109,7 +105,6 @@ static  voiddm_check_txrateandretrycount(struct 
net_device *dev);
 static voiddm_init_dynamic_txpower(struct net_device *dev);
 static voiddm_dynamic_txpower(struct net_device *dev);

-
 /* DM -- For rate adaptive and DIG, we must send RSSI to firmware */
 static void dm_send_rssi_tofw(struct net_device *dev);
 static voiddm_ctstoself(struct net_device *dev);
@@ -148,14 +143,12 @@ void init_hal_dm(struct net_device *dev)

 void deinit_hal_dm(struct net_device *dev)
 {
-
dm_deInit_fsync(dev);
-
 }

-
 #ifdef USB_RX_AGGREGATION_SUPPORT
-void dm_CheckRxAggregation(struct net_device *dev) {
+void dm_CheckRxAggregation(struct net_device *dev)
+{
struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
PRT_HIGH_THROUGHPUT pHTInfo = priv-ieee80211-pHTInfo;
static unsigned longlastTxOkCnt;
@@ -184,14 +177,15 @@ void dm_CheckRxAggregation(struct net_device *dev) {
if ((curTxOkCnt + curRxOkCnt)  1500)
return;

-   if(curTxOkCnt  4*curRxOkCnt) {
+   if (curTxOkCnt  4*curRxOkCnt) {
if (priv-bCurrentRxAggrEnable) {
write_nic_dword(dev, 0x1a8, 0);
priv-bCurrentRxAggrEnable = false;
}
-   }else{
+   } else {
if (!priv-bCurrentRxAggrEnable  
!pHTInfo-bCurrentRT2RTAggregation) {
u32 ulValue;
+
ulValue = (pHTInfo-UsbRxFwAggrEn24) | 
(pHTInfo-UsbRxFwAggrPageNum16) |
(pHTInfo-UsbRxFwAggrPacketNum8) | 
(pHTInfo-UsbRxFwAggrTimeout);
/*
@@ -209,8 +203,6 @@ void dm_CheckRxAggregation(struct net_device *dev) {
 }  /* dm_CheckEdcaTurbo */
 #endif

-
-
 void hal_dm_watchdog(struct net_device *dev)
 {
/*struct r8192_priv *priv = ieee80211_priv(dev);*/
@@ -237,7 +229,6 @@ void hal_dm_watchdog(struct net_device *dev)
 #endif
 }  /* HalDmWatchDog */

-
 /*
  * Decide Rate Adaptive Set according to distance (signal strength)
  * 01/11/2008  MHC Modify input arguments and RATR table 
level.
@@ -246,7 +237,6 @@ void hal_dm_watchdog(struct net_device *dev)
  */
 void

[PATCH v2 4/4] staging: rtl8192u: Refactor heavy nesting

2014-12-31 Thread Lorenzo Stoakes
This patch fixes warnings raised by checkpatch.pl relating to heavily indented
lines in r8192U_dm.c. It refactors a couple of else if cases to achieve the same
outcome indented by one fewer tab. It additionally updateds comment positioning
to be consistent across these cases.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index ed566bb..bae8511 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -2581,28 +2581,25 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev)
cck_rx_ver2_sec_index = 
cck_rx_ver2_max_index;
tmp_cck_max_pwdb = cur_cck_pwdb;
cck_rx_ver2_max_index = i;
-   } else if (cur_cck_pwdb == 
tmp_cck_max_pwdb) { /* let sec and min point to the different index */
+   } else if (cur_cck_pwdb == 
tmp_cck_max_pwdb) {
+   /* let sec and min point to the 
different index */
tmp_cck_sec_pwdb = cur_cck_pwdb;
cck_rx_ver2_sec_index = i;
} else if ((cur_cck_pwdb  
tmp_cck_max_pwdb)  (cur_cck_pwdb  tmp_cck_sec_pwdb)) {
tmp_cck_sec_pwdb = cur_cck_pwdb;
cck_rx_ver2_sec_index = i;
-   } else if (cur_cck_pwdb == 
tmp_cck_sec_pwdb) {
-   if (tmp_cck_sec_pwdb == 
tmp_cck_min_pwdb) { /* let sec and min point to the different index */
-   tmp_cck_sec_pwdb = 
cur_cck_pwdb;
-   cck_rx_ver2_sec_index = 
i;
-   } else {
-   /*  This case we don't 
need to set any index */
-   }
+   } else if (cur_cck_pwdb == 
tmp_cck_sec_pwdb  tmp_cck_sec_pwdb == tmp_cck_min_pwdb) {
+   /* let sec and min point to the 
different index */
+   tmp_cck_sec_pwdb = cur_cck_pwdb;
+   cck_rx_ver2_sec_index = i;
+   /* otherwise we don't need to 
set any index */
} else if ((cur_cck_pwdb  
tmp_cck_sec_pwdb)  (cur_cck_pwdb  tmp_cck_min_pwdb)) {
/*  This case we don't need to 
set any index */
-   } else if (cur_cck_pwdb == 
tmp_cck_min_pwdb) {
-   if (tmp_cck_sec_pwdb == 
tmp_cck_min_pwdb) { /*  let sec and min point to the different index */
-   tmp_cck_min_pwdb = 
cur_cck_pwdb;
-   cck_rx_ver2_min_index = 
i;
-   } else {
-   /*  This case we don't 
need to set any index */
-   }
+   } else if (cur_cck_pwdb == 
tmp_cck_min_pwdb  tmp_cck_sec_pwdb == tmp_cck_min_pwdb) {
+   /*  let sec and min point to 
the different index */
+   tmp_cck_min_pwdb = cur_cck_pwdb;
+   cck_rx_ver2_min_index = i;
+   /* otherwise we don't need to 
set any index */
} else if (cur_cck_pwdb  
tmp_cck_min_pwdb) {
tmp_cck_min_pwdb = cur_cck_pwdb;
cck_rx_ver2_min_index = i;
--
2.2.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 2/4] staging: rtl8192u: fix whitespace

2014-12-31 Thread Lorenzo Stoakes
On 31 December 2014 at 21:20, Joe Perches j...@perches.com wrote:

 It'd be nicer to use the same form and indentation
 for both entries.

 Probably be nicer to use:

 static u32 edca_setting_DL[HT_IOT_PEER_MAX] = {
 0x5e4322, 0x5e4322, 0x5e4322, 0x604322, 0x00a44f, 0x5ea44f
 };
 static u32 edca_setting_UL[HT_IOT_PEER_MAX] = {
 0x5e4322, 0x00a44f, 0x5e4322, 0x604322, 0x5ea44f, 0x5ea44f
 };

 so that the entries align too.

Ack... I am a bit of a beginner at the kernel, I think you can tell
;-) I didn't mean for this to have different indentation, in fixing up
other issues I missed this one, will fix. Will also add the 00 prefix,
good idea (+ update the commit message to accommodate.)


 Would it be better to use const?


I think this would be better as a separate patch as that is getting
into changing actual semantics rather than just simple style fixes,
there is a lot that could be improved here in that realm I think :)

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


[PATCH v3 2/4] staging: rtl8192u: fix whitespace

2014-12-31 Thread Lorenzo Stoakes
This patch fixes warnings/errors raised by checkpatch.pl relating to whitespace
in r8192U_dm.c and additionally it removes inconsistent whitespace
throughout.

Additionally some 0x00... padding has been added for alignment to the
edca_setting_* variables.

Signed-off-by: Lorenzo Stoakes lstoa...@gmail.com
---
 drivers/staging/rtl8192u/r8192U_dm.c | 1606 +-
 1 file changed, 625 insertions(+), 981 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index cafc717..862d2ab 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -22,11 +22,12 @@ Major Change History:
 #include r819xU_cmdpkt.h
 /*---Define Local Constant---*/
 /* Indicate different AP vendor for IOT issue. */
-static u32 edca_setting_DL[HT_IOT_PEER_MAX] =
-   { 0x5e4322, 0x5e4322,   0x5e4322,   0x604322,   
0xa44f, 0x5ea44f};
-static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
-   { 0x5e4322, 0xa44f, 0x5e4322,   0x604322,   
0x5ea44f,   0x5ea44f};
-
+static u32 edca_setting_DL[HT_IOT_PEER_MAX] = {
+   0x5e4322, 0x5e4322, 0x5e4322, 0x604322, 0x00a44f, 0x5ea44f
+};
+static u32 edca_setting_UL[HT_IOT_PEER_MAX] = {
+   0x5e4322, 0x00a44f, 0x5e4322, 0x604322, 0x5ea44f, 0x5ea44f
+};

 #define RTK_UL_EDCA 0xa44f
 #define RTK_DL_EDCA 0x5e4322
@@ -37,7 +38,7 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
 /* Debug variable ? */
 dig_t  dm_digtable;
 /* Store current software write register content for MAC PHY. */
-u8 dm_shadow[16][256] = {{0}};
+u8 dm_shadow[16][256] = { {0} };
 /* For Dynamic Rx Path Selection by Signal Strength */
 DRxPathSel DM_RxPathSelTable;
 /*Define global variable-*/
@@ -66,11 +67,8 @@ static   voiddm_bandwidth_autoswitch(struct 
net_device *dev);

 static voiddm_check_txpower_tracking(struct net_device *dev);

-
-
 /*static   voiddm_txpower_reset_recovery(struct net_device *dev);*/

-
 /* DM -- Dynamic Init Gain by RSSI */
 static voiddm_dig_init(struct net_device *dev);
 static voiddm_ctrl_initgain_byrssi(struct net_device *dev);
@@ -89,13 +87,11 @@ static  voiddm_check_edca_turbo(struct net_device 
*dev);
 /* DM -- Check PBC */
 static void dm_check_pbc_gpio(struct net_device *dev);

-
 /* DM -- Check current RX RF path state */
 static voiddm_check_rx_path_selection(struct net_device *dev);
 static void dm_init_rxpath_selection(struct net_device *dev);
 static void dm_rxpath_sel_byrssi(struct net_device *dev);

-
 /* DM -- Fsync for broadcom ap */
 static void dm_init_fsync(struct net_device *dev);
 static void dm_deInit_fsync(struct net_device *dev);
@@ -109,7 +105,6 @@ static  voiddm_check_txrateandretrycount(struct 
net_device *dev);
 static voiddm_init_dynamic_txpower(struct net_device *dev);
 static voiddm_dynamic_txpower(struct net_device *dev);

-
 /* DM -- For rate adaptive and DIG, we must send RSSI to firmware */
 static void dm_send_rssi_tofw(struct net_device *dev);
 static voiddm_ctstoself(struct net_device *dev);
@@ -148,14 +143,12 @@ void init_hal_dm(struct net_device *dev)

 void deinit_hal_dm(struct net_device *dev)
 {
-
dm_deInit_fsync(dev);
-
 }

-
 #ifdef USB_RX_AGGREGATION_SUPPORT
-void dm_CheckRxAggregation(struct net_device *dev) {
+void dm_CheckRxAggregation(struct net_device *dev)
+{
struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
PRT_HIGH_THROUGHPUT pHTInfo = priv-ieee80211-pHTInfo;
static unsigned longlastTxOkCnt;
@@ -184,14 +177,15 @@ void dm_CheckRxAggregation(struct net_device *dev) {
if ((curTxOkCnt + curRxOkCnt)  1500)
return;

-   if(curTxOkCnt  4*curRxOkCnt) {
+   if (curTxOkCnt  4*curRxOkCnt) {
if (priv-bCurrentRxAggrEnable) {
write_nic_dword(dev, 0x1a8, 0);
priv-bCurrentRxAggrEnable = false;
}
-   }else{
+   } else {
if (!priv-bCurrentRxAggrEnable  
!pHTInfo-bCurrentRT2RTAggregation) {
u32 ulValue;
+
ulValue = (pHTInfo-UsbRxFwAggrEn24) | 
(pHTInfo-UsbRxFwAggrPageNum16) |
(pHTInfo-UsbRxFwAggrPacketNum8) | 
(pHTInfo-UsbRxFwAggrTimeout);
/*
@@ -209,8 +203,6 @@ void dm_CheckRxAggregation(struct net_device *dev) {
 }  /* dm_CheckEdcaTurbo */
 #endif

-
-
 void hal_dm_watchdog(struct net_device *dev)
 {
/*struct r8192_priv *priv = ieee80211_priv(dev);*/
@@ -237,7 +229,6 @@ void hal_dm_watchdog(struct net_device *dev)
 #endif
 }  /* HalDmWatchDog */

-
 /*
  * Decide Rate Adaptive Set according to distance (signal strength)
  * 01/11/2008  MHC Modify input arguments and RATR table