[PATCH 2/5] unisys: use simpler kthread_ API

2015-01-21 Thread Devendra Naga
The code does the checks on should_stop variable in the kernel
threads. The uisthread_stop function sets the should_stop and calls
KILL (eventually kill_pid) to stop the thread.

The checking of should_stop variable can be replaced to a call to
kthread_should_stop function and the setting of the should_stop and
a call to KILL can be replaced with kthread_stop function.

Cc: Ken Cox 
Cc: Benjamin Romer 
Signed-off-by: Devendra Naga 
---
 drivers/staging/unisys/uislib/uisthread.c | 20 +++-
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/unisys/uislib/uisthread.c 
b/drivers/staging/unisys/uislib/uisthread.c
index c5c68cb..20a2a1b 100644
--- a/drivers/staging/unisys/uislib/uisthread.c
+++ b/drivers/staging/unisys/uislib/uisthread.c
@@ -41,7 +41,6 @@ int
 uisthread_start(struct uisthread_info *thrinfo,
int (*threadfn)(void *), void *thrcontext, char *name)
 {
-   thrinfo->should_stop = 0;
/* used to stop the thread */
init_completion(&thrinfo->has_stopped);
thrinfo->task = kthread_run(threadfn, thrcontext, name);
@@ -58,24 +57,19 @@ EXPORT_SYMBOL_GPL(uisthread_start);
 void
 uisthread_stop(struct uisthread_info *thrinfo)
 {
-   int ret;
int stopped = 0;
 
if (thrinfo->id == 0)
return; /* thread not running */
 
LOGINF("uisthread_stop stopping id:%d\n", thrinfo->id);
-   thrinfo->should_stop = 1;
-   ret = KILL(thrinfo->id, SIGHUP, 1);
-   if (ret) {
-   LOGERR("unable to signal thread %d\n", ret);
-   } else {
-   /* give up if the thread has NOT died in 1 minute */
-   if (wait_for_completion_timeout(&thrinfo->has_stopped, 60 * HZ))
-   stopped = 1;
-   else
-   LOGERR("timed out trying to signal thread\n");
-   }
+   kthread_stop(thrinfo->task);
+   /* give up if the thread has NOT died in 1 minute */
+   if (wait_for_completion_timeout(&thrinfo->has_stopped, 60 * HZ))
+   stopped = 1;
+   else
+   LOGERR("timed out trying to signal thread\n");
+
if (stopped) {
LOGINF("uisthread_stop stopped id:%d\n", thrinfo->id);
thrinfo->id = 0;
-- 
1.9.3

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


[PATCH 3/5] unisys: use kthread_should_stop in the thread

2015-01-21 Thread Devendra Naga
convert the users of should_stop variable into kthread_should_stop() API.

Cc: Ken Cox 
Cc: Benjamin Romer 
Signed-off-by: Devendra Naga 
---
 drivers/staging/unisys/virthba/virthba.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index 82fcb3b..19d025a 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -1345,6 +1345,8 @@ process_incoming_rsps(void *v)
}
mask = ULTRA_CHANNEL_ENABLE_INTS;
while (1) {
+   if (kthread_should_stop())
+   break;
wait_event_interruptible_timeout(virthbainfo->rsp_queue,
 (atomic_read(&virthbainfo->interrupt_rcvd) == 1),
 usecs_to_jiffies(rsltq_wait_usecs));
@@ -1352,8 +1354,6 @@ process_incoming_rsps(void *v)
/* drain queue */
drain_queue(virthbainfo, dc, cmdrsp);
rc1 = uisqueue_interlocked_or(virthbainfo->flags_addr, mask);
-   if (dc->threadinfo.should_stop)
-   break;
}
 
kfree(cmdrsp);
-- 
1.9.3

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


[RFC PATCH 0/5] unisys: kthread cleanup

2015-01-21 Thread Devendra Naga
The 1st patch (replace kthread_create..) replace the
kthread_create and wake_up_process with a call to
kthread_run.

The 2nd patch changes the library API uisthread_start
and uisthread_stop to use the kthread API.

The 3rd patch and 4th patch checks on kthread_should_stop
instead of checking should_stop variable.

The 5th patch removes the variables should_stop and
KILL as they are no longer required.


All patches applies on next-20150120 cleanly. All the patches are
compile tested on X86_64 allmodconfig.

Devendra Naga (5):
  unisys: replace kthread_create and wake_up_process with kthread_run
  unisys: use simpler kthread_ API
  unisys: use kthread_should_stop in the thread
  unisys: use kthread_should_stop API in the lib thread
  unisys: remove the thread variable and API

 drivers/staging/unisys/include/uisthread.h |  1 -
 drivers/staging/unisys/uislib/uislib.c |  4 ++--
 drivers/staging/unisys/uislib/uisthread.c  | 25 -
 drivers/staging/unisys/virthba/virthba.c   |  4 ++--
 4 files changed, 12 insertions(+), 22 deletions(-)

-- 
1.9.3

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


[PATCH 1/5] unisys: replace kthread_create and wake_up_process with kthread_run

2015-01-21 Thread Devendra Naga
kthread_run calls kthread_create and if the thread is created
it then calls wake_up_process on the corresponding returned
task struct. So the code can be simplified by calling just
kthread_run.

Cc: Ken Cox 
Cc: Benjamin Romer 
Signed-off-by: Devendra Naga 
---
 drivers/staging/unisys/uislib/uisthread.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/uislib/uisthread.c 
b/drivers/staging/unisys/uislib/uisthread.c
index 25adf1a..c5c68cb 100644
--- a/drivers/staging/unisys/uislib/uisthread.c
+++ b/drivers/staging/unisys/uislib/uisthread.c
@@ -44,13 +44,12 @@ uisthread_start(struct uisthread_info *thrinfo,
thrinfo->should_stop = 0;
/* used to stop the thread */
init_completion(&thrinfo->has_stopped);
-   thrinfo->task = kthread_create(threadfn, thrcontext, name, NULL);
+   thrinfo->task = kthread_run(threadfn, thrcontext, name);
if (IS_ERR(thrinfo->task)) {
thrinfo->id = 0;
return 0;   /* failure */
}
thrinfo->id = thrinfo->task->pid;
-   wake_up_process(thrinfo->task);
LOGINF("started thread pid:%d\n", thrinfo->id);
return 1;
 }
-- 
1.9.3

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


[PATCH 4/5] unisys: use kthread_should_stop API in the lib thread

2015-01-21 Thread Devendra Naga
convert the users of should_stop into using kthread_should_stop API.

Cc: Ken Cox 
Cc: Benjamin Romer 
Signed-off-by: Devendra Naga 
---
 drivers/staging/unisys/uislib/uislib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/uislib/uislib.c 
b/drivers/staging/unisys/uislib/uislib.c
index a9eedde..22aa808 100644
--- a/drivers/staging/unisys/uislib/uislib.c
+++ b/drivers/staging/unisys/uislib/uislib.c
@@ -1294,7 +1294,7 @@ static int process_incoming(void *v)
}
}
}
-   if (incoming_ti.should_stop)
+   if (kthread_should_stop())
break;
}
if (new_tail != NULL) {
@@ -1311,7 +1311,7 @@ static int process_incoming(void *v)
* - there is no input waiting on any of the channels
* - we have received a signal to stop this thread
*/
-   if (incoming_ti.should_stop)
+   if (kthread_should_stop())
break;
if (en_smart_wakeup == 0xFF) {
LOGINF("en_smart_wakeup set to 0xff, to force exiting 
process_incoming");
-- 
1.9.3

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


[PATCH 5/5] unisys: remove the thread variable and API

2015-01-21 Thread Devendra Naga
remove the should_stop variable and KILL API as they are
no longer required

Cc: Ken Cox 
Cc: Benjamin Romer 
Signed-off-by: Devendra Naga 
---
 drivers/staging/unisys/include/uisthread.h | 1 -
 drivers/staging/unisys/uislib/uisthread.c  | 2 --
 2 files changed, 3 deletions(-)

diff --git a/drivers/staging/unisys/include/uisthread.h 
b/drivers/staging/unisys/include/uisthread.h
index aa86ade..52c3eb4 100644
--- a/drivers/staging/unisys/include/uisthread.h
+++ b/drivers/staging/unisys/include/uisthread.h
@@ -27,7 +27,6 @@
 struct uisthread_info {
struct task_struct *task;
int id;
-   int should_stop;
struct completion has_stopped;
 };
 
diff --git a/drivers/staging/unisys/uislib/uisthread.c 
b/drivers/staging/unisys/uislib/uisthread.c
index 20a2a1b..d54005d 100644
--- a/drivers/staging/unisys/uislib/uisthread.c
+++ b/drivers/staging/unisys/uislib/uisthread.c
@@ -24,8 +24,6 @@
 #include "uisutils.h"
 #include "uisthread.h"
 
-#define KILL(a, b, c) kill_pid(find_vpid(a), b, c)
-
 /* this is shorter than using __FILE__ (full path name) in
  * debug/info/error messages
  */
-- 
1.9.3

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


Re: [RFC PATCH 0/5] unisys: kthread cleanup

2015-01-21 Thread devendra.aaru
Oops, I have forgotten the RFC before the patches from 1 to 5 also i
have missed two email addresses (i have added them now). I will resend
the whole series again with RFC tag before each PATCH and also proper
cc's.

Sorry

On Wed, Jan 21, 2015 at 3:55 AM, Devendra Naga  wrote:
> The 1st patch (replace kthread_create..) replace the
> kthread_create and wake_up_process with a call to
> kthread_run.
>
> The 2nd patch changes the library API uisthread_start
> and uisthread_stop to use the kthread API.
>
> The 3rd patch and 4th patch checks on kthread_should_stop
> instead of checking should_stop variable.
>
> The 5th patch removes the variables should_stop and
> KILL as they are no longer required.
>
>
> All patches applies on next-20150120 cleanly. All the patches are
> compile tested on X86_64 allmodconfig.
>
> Devendra Naga (5):
>   unisys: replace kthread_create and wake_up_process with kthread_run
>   unisys: use simpler kthread_ API
>   unisys: use kthread_should_stop in the thread
>   unisys: use kthread_should_stop API in the lib thread
>   unisys: remove the thread variable and API
>
>  drivers/staging/unisys/include/uisthread.h |  1 -
>  drivers/staging/unisys/uislib/uislib.c |  4 ++--
>  drivers/staging/unisys/uislib/uisthread.c  | 25 -
>  drivers/staging/unisys/virthba/virthba.c   |  4 ++--
>  4 files changed, 12 insertions(+), 22 deletions(-)
>
> --
> 1.9.3
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RFC PATCH 3/5] unisys: use kthread_should_stop in the thread

2015-01-21 Thread Devendra Naga
convert the users of should_stop variable into kthread_should_stop() API.

Cc: Ken Cox 
Cc: Benjamin Romer 
Signed-off-by: Devendra Naga 
---
 drivers/staging/unisys/virthba/virthba.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index 82fcb3b..19d025a 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -1345,6 +1345,8 @@ process_incoming_rsps(void *v)
}
mask = ULTRA_CHANNEL_ENABLE_INTS;
while (1) {
+   if (kthread_should_stop())
+   break;
wait_event_interruptible_timeout(virthbainfo->rsp_queue,
 (atomic_read(&virthbainfo->interrupt_rcvd) == 1),
 usecs_to_jiffies(rsltq_wait_usecs));
@@ -1352,8 +1354,6 @@ process_incoming_rsps(void *v)
/* drain queue */
drain_queue(virthbainfo, dc, cmdrsp);
rc1 = uisqueue_interlocked_or(virthbainfo->flags_addr, mask);
-   if (dc->threadinfo.should_stop)
-   break;
}
 
kfree(cmdrsp);
-- 
1.9.3

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


[RFC PATCH 0/5] unisys: kthread cleanup

2015-01-21 Thread Devendra Naga
The 1st patch (replace kthread_create..) replace the
kthread_create and wake_up_process with a call to
kthread_run.

The 2nd patch changes the library API uisthread_start
and uisthread_stop to use the kthread API.

The 3rd patch and 4th patch checks on kthread_should_stop
instead of checking should_stop variable.

The 5th patch removes the variables should_stop and
KILL as they are no longer required.


All patches applies on next-20150120 cleanly. All the patches are
compile tested on X86_64 allmodconfig.

Cc: Ken Cox 
Cc: Benjamin Romer 

Devendra Naga (5):
  unisys: replace kthread_create and wake_up_process with kthread_run
  unisys: use simpler kthread_ API
  unisys: use kthread_should_stop in the thread
  unisys: use kthread_should_stop API in the lib thread
  unisys: remove the thread variable and API

 drivers/staging/unisys/include/uisthread.h |  1 -
 drivers/staging/unisys/uislib/uislib.c |  4 ++--
 drivers/staging/unisys/uislib/uisthread.c  | 25 -
 drivers/staging/unisys/virthba/virthba.c   |  4 ++--
 4 files changed, 12 insertions(+), 22 deletions(-)

-- 
1.9.3

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


[RFC PATCH 2/5] unisys: use simpler kthread_ API

2015-01-21 Thread Devendra Naga
The code does the checks on should_stop variable in the kernel
threads. The uisthread_stop function sets the should_stop and calls
KILL (eventually kill_pid) to stop the thread.

The checking of should_stop variable can be replaced to a call to
kthread_should_stop function and the setting of the should_stop and
a call to KILL can be replaced with kthread_stop function.

Cc: Ken Cox 
Cc: Benjamin Romer 
Signed-off-by: Devendra Naga 
---
 drivers/staging/unisys/uislib/uisthread.c | 20 +++-
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/unisys/uislib/uisthread.c 
b/drivers/staging/unisys/uislib/uisthread.c
index c5c68cb..20a2a1b 100644
--- a/drivers/staging/unisys/uislib/uisthread.c
+++ b/drivers/staging/unisys/uislib/uisthread.c
@@ -41,7 +41,6 @@ int
 uisthread_start(struct uisthread_info *thrinfo,
int (*threadfn)(void *), void *thrcontext, char *name)
 {
-   thrinfo->should_stop = 0;
/* used to stop the thread */
init_completion(&thrinfo->has_stopped);
thrinfo->task = kthread_run(threadfn, thrcontext, name);
@@ -58,24 +57,19 @@ EXPORT_SYMBOL_GPL(uisthread_start);
 void
 uisthread_stop(struct uisthread_info *thrinfo)
 {
-   int ret;
int stopped = 0;
 
if (thrinfo->id == 0)
return; /* thread not running */
 
LOGINF("uisthread_stop stopping id:%d\n", thrinfo->id);
-   thrinfo->should_stop = 1;
-   ret = KILL(thrinfo->id, SIGHUP, 1);
-   if (ret) {
-   LOGERR("unable to signal thread %d\n", ret);
-   } else {
-   /* give up if the thread has NOT died in 1 minute */
-   if (wait_for_completion_timeout(&thrinfo->has_stopped, 60 * HZ))
-   stopped = 1;
-   else
-   LOGERR("timed out trying to signal thread\n");
-   }
+   kthread_stop(thrinfo->task);
+   /* give up if the thread has NOT died in 1 minute */
+   if (wait_for_completion_timeout(&thrinfo->has_stopped, 60 * HZ))
+   stopped = 1;
+   else
+   LOGERR("timed out trying to signal thread\n");
+
if (stopped) {
LOGINF("uisthread_stop stopped id:%d\n", thrinfo->id);
thrinfo->id = 0;
-- 
1.9.3

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


[RFC PATCH 1/5] unisys: replace kthread_create and wake_up_process with kthread_run

2015-01-21 Thread Devendra Naga
kthread_run calls kthread_create and if the thread is created
it then calls wake_up_process on the corresponding returned
task struct. So the code can be simplified by calling just
kthread_run.

Cc: Ken Cox 
Cc: Benjamin Romer 
Signed-off-by: Devendra Naga 
---
 drivers/staging/unisys/uislib/uisthread.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/uislib/uisthread.c 
b/drivers/staging/unisys/uislib/uisthread.c
index 25adf1a..c5c68cb 100644
--- a/drivers/staging/unisys/uislib/uisthread.c
+++ b/drivers/staging/unisys/uislib/uisthread.c
@@ -44,13 +44,12 @@ uisthread_start(struct uisthread_info *thrinfo,
thrinfo->should_stop = 0;
/* used to stop the thread */
init_completion(&thrinfo->has_stopped);
-   thrinfo->task = kthread_create(threadfn, thrcontext, name, NULL);
+   thrinfo->task = kthread_run(threadfn, thrcontext, name);
if (IS_ERR(thrinfo->task)) {
thrinfo->id = 0;
return 0;   /* failure */
}
thrinfo->id = thrinfo->task->pid;
-   wake_up_process(thrinfo->task);
LOGINF("started thread pid:%d\n", thrinfo->id);
return 1;
 }
-- 
1.9.3

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


[RFC PATCH 4/5] unisys: use kthread_should_stop API in the lib thread

2015-01-21 Thread Devendra Naga
convert the users of should_stop into using kthread_should_stop API.

Cc: Ken Cox 
Cc: Benjamin Romer 
Signed-off-by: Devendra Naga 
---
 drivers/staging/unisys/uislib/uislib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/uislib/uislib.c 
b/drivers/staging/unisys/uislib/uislib.c
index a9eedde..22aa808 100644
--- a/drivers/staging/unisys/uislib/uislib.c
+++ b/drivers/staging/unisys/uislib/uislib.c
@@ -1294,7 +1294,7 @@ static int process_incoming(void *v)
}
}
}
-   if (incoming_ti.should_stop)
+   if (kthread_should_stop())
break;
}
if (new_tail != NULL) {
@@ -1311,7 +1311,7 @@ static int process_incoming(void *v)
* - there is no input waiting on any of the channels
* - we have received a signal to stop this thread
*/
-   if (incoming_ti.should_stop)
+   if (kthread_should_stop())
break;
if (en_smart_wakeup == 0xFF) {
LOGINF("en_smart_wakeup set to 0xff, to force exiting 
process_incoming");
-- 
1.9.3

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


[RFC PATCH 5/5] unisys: remove the thread variable and API

2015-01-21 Thread Devendra Naga
remove the should_stop variable and KILL API as they are
no longer required

Cc: Ken Cox 
Cc: Benjamin Romer 
Signed-off-by: Devendra Naga 
---
 drivers/staging/unisys/include/uisthread.h | 1 -
 drivers/staging/unisys/uislib/uisthread.c  | 2 --
 2 files changed, 3 deletions(-)

diff --git a/drivers/staging/unisys/include/uisthread.h 
b/drivers/staging/unisys/include/uisthread.h
index aa86ade..52c3eb4 100644
--- a/drivers/staging/unisys/include/uisthread.h
+++ b/drivers/staging/unisys/include/uisthread.h
@@ -27,7 +27,6 @@
 struct uisthread_info {
struct task_struct *task;
int id;
-   int should_stop;
struct completion has_stopped;
 };
 
diff --git a/drivers/staging/unisys/uislib/uisthread.c 
b/drivers/staging/unisys/uislib/uisthread.c
index 20a2a1b..d54005d 100644
--- a/drivers/staging/unisys/uislib/uisthread.c
+++ b/drivers/staging/unisys/uislib/uisthread.c
@@ -24,8 +24,6 @@
 #include "uisutils.h"
 #include "uisthread.h"
 
-#define KILL(a, b, c) kill_pid(find_vpid(a), b, c)
-
 /* this is shorter than using __FILE__ (full path name) in
  * debug/info/error messages
  */
-- 
1.9.3

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


[PATCH] staging: vt6655: fix that open brace { should be on the previous line

2015-01-21 Thread MariamMohamedFawzy
This patch fixes the following checkpatch.pl error:
fix that open brace { should be on the previous line

Signed-off-by: MariamMohamedFawzy 
---
 drivers/staging/vt6655/card.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c
index 47801ca..1cdcf49 100644
--- a/drivers/staging/vt6655/card.c
+++ b/drivers/staging/vt6655/card.c
@@ -68,8 +68,8 @@
 
 /*-  Static Variables  --*/
 
-static const unsigned short cwRXBCNTSFOff[MAX_RATE] =
-{17, 17, 17, 17, 34, 23, 17, 11, 8, 5, 4, 3};
+static const unsigned short cwRXBCNTSFOff[MAX_RATE] = {
+   17, 17, 17, 17, 34, 23, 17, 11, 8, 5, 4, 3};
 
 /*-  Static Functions  --*/
 
-- 
1.9.1

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


[PATCH] staging: dgnc: Fixing a warning of line over 80 characters

2015-01-21 Thread menna_tarek
This patch fixes the following checkpatch.pl warning:
WARNING: line over 80 characters

Signed-off-by: menna_tarek 
---
 drivers/staging/dgnc/dgnc_tty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index f81a375..f43a11b 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1331,7 +1331,7 @@ static int dgnc_block_til_ready(struct tty_struct *tty, 
struct file *file, struc
spin_unlock_irqrestore(&ch->ch_lock, flags);
 
/*
-* Wait for something in the flags to change from the current 
value.
+* Wait for the flags to change from the current value.
 */
if (sleep_on_un_flags)
retval = wait_event_interruptible(un->un_flags_wait,
-- 
1.9.1

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


Re: [PATCH] staging: dgnc: Fixing a warning of line over 80 characters

2015-01-21 Thread Dan Carpenter
On Wed, Jan 21, 2015 at 12:46:59PM +0200, menna_tarek wrote:
> This patch fixes the following checkpatch.pl warning:
> WARNING: line over 80 characters
> 
> Signed-off-by: menna_tarek 

These are supposed to be your actual name that you use to sign legal
documents with correct capitalization etc.  Same for the From header.

regards,
dan carpenter

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


Re: [PATCH] staging: comedi: aio_iiro_16: return input state in async command sample

2015-01-21 Thread Ian Abbott

On 20/01/15 19:00, H Hartley Sweeten wrote:

Modify the sample data returned by the async command to include the current
state of the digital inputs. Otherwise the command needs to be canceled in
order for the user to do an (*insn_bits) operation to check the digital
inputs.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
  drivers/staging/comedi/drivers/aio_iiro_16.c | 33 
  1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c 
b/drivers/staging/comedi/drivers/aio_iiro_16.c
index d8884a3..1c7b325 100644
--- a/drivers/staging/comedi/drivers/aio_iiro_16.c
+++ b/drivers/staging/comedi/drivers/aio_iiro_16.c
@@ -27,11 +27,14 @@
   *
   * The board supports interrupts on change of state of the digital inputs.
   * The sample data returned by the async command indicates which inputs
- * changed state:
+ * changed state and the current state of the inputs:
   *
- * Bit 7 - IRQ Enable (1) / Disable (0)
- * Bit 1 - Input 8-15 Changed State (1 = Changed, 0 = No Change)
- * Bit 0 - Input 0-7 Changed State (1 = Changed, 0 = No Change)
+ * Bit 23 - IRQ Enable (1) / Disable (0)
+ * Bit 17 - Input 8-15 Changed State (1 = Changed, 0 = No Change)
+ * Bit 16 - Input 0-7 Changed State (1 = Changed, 0 = No Change)
+ * Bit 15 - Digital input 15
+ * ...
+ * Bit 0  - Digital input 0


I'm wondering whether it should just indicate the state of the digital 
inputs and not bother with the other stuff.  Any thoughts?


--
-=( Ian Abbott @ MEV Ltd.E-mail:  )=-
-=(  Web: http://www.mev.co.uk/  )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: comedi: addi_apci_1500: rewrite the subdevice support functions

2015-01-21 Thread Ian Abbott

On 20/01/15 19:01, H Hartley Sweeten wrote:

This driver is a mess. It violates the comedi API so much that I doubt
anything actually works.

Drop the addi-data/hwdrv_apci1500.c file and rewrite the subdevice support
functions.

This board has 16 digital inputs (subdevice 0) and 16 digital outputs
(subdevice 1).

It also has three 16-bit timer/counters provided by a Z8536 CIO chip
(subdevice 2). The Z8536 chip is also used to support pattern match
interrupt detection of the first 14 digital input channels.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 


Reviewed-by: Ian Abbott 

--
-=( Ian Abbott @ MEV Ltd.E-mail:  )=-
-=(  Web: http://www.mev.co.uk/  )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: fbtft: fb_agm1264k-fl: add static keyword

2015-01-21 Thread Noralf Trønnes
Add missing static keyword to function reset().
This was detected by the kbuild test robot.

Signed-off-by: Noralf Trønnes 
---
 drivers/staging/fbtft/fb_agm1264k-fl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fbtft/fb_agm1264k-fl.c 
b/drivers/staging/fbtft/fb_agm1264k-fl.c
index 7fe4fa0..9cc7d25 100644
--- a/drivers/staging/fbtft/fb_agm1264k-fl.c
+++ b/drivers/staging/fbtft/fb_agm1264k-fl.c
@@ -89,7 +89,7 @@ static int init_display(struct fbtft_par *par)
return 0;
 }
 
-void reset(struct fbtft_par *par)
+static void reset(struct fbtft_par *par)
 {
if (par->gpio.reset == -1)
return;
-- 
2.2.2

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


[PATCH] staging: vt6656: fix Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)

2015-01-21 Thread Heba Aamer
This patch fixes the following checkpatch.pl warning:
fix Prefer ether_addr_copy() over memcpy() 
if the Ethernet addresses are __aligned(2)

Pahole showed that the 2 structs are aligned to u16

struct vnt_mic_hdr {
u8 id;   /* 0 1 */
u8 tx_priority;  /* 1 1 */
u8 mic_addr2[6]; /* 2 6 */
u8 ccmp_pn[6];   /* 8 6 */
__be16 payload_len;  /*14 2 */
__be16 hlen; /*16 2 */
__le16 frame_control;/*18 2 */
u8 addr1[6]; /*20 6 */
u8 addr2[6]; /*26 6 */
u8 addr3[6]; /*32 6 */
__le16 seq_ctrl; /*38 2 */
u8 addr4[6]; /*40 6 */
u16packing;  /*46 2 */

/* size: 48, cachelines: 1, members: 13 */
/* last cacheline: 48 bytes */
};

struct ieee80211_hdr {
__le16 frame_control;/* 0 2 */
__le16 duration_id;  /* 2 2 */
u8 addr1[6]; /* 4 6 */
u8 addr2[6]; /*10 6 */
u8 addr3[6]; /*16 6 */
__le16 seq_ctrl; /*22 2 */
u8 addr4[6]; /*24 6 */

/* size: 30, cachelines: 1, members: 7 */
/* last cacheline: 30 bytes */
};

Signed-off-by: Heba Aamer 
---
 drivers/staging/vt6656/rxtx.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index bb6a4d4..b74f672 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -738,7 +738,7 @@ static void vnt_fill_txkey(struct vnt_usb_send_context 
*tx_context,
 
mic_hdr->id = 0x59;
mic_hdr->payload_len = cpu_to_be16(payload_len);
-   memcpy(mic_hdr->mic_addr2, hdr->addr2, ETH_ALEN);
+   ether_addr_copy(mic_hdr->mic_addr2, hdr->addr2);
 
ieee80211_get_key_tx_seq(tx_key, &seq);
 
-- 
1.7.9.5

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


Re: [PATCH 0/6] staging: comedi: misc cleanup

2015-01-21 Thread Ian Abbott

On 20/01/15 19:05, H Hartley Sweeten wrote:

Following are a couple random comedi cleanup patches that I have had
hanging around.

H Hartley Sweeten (6):
   staging: comedi: comedidev.h: remove unused "minor bits" information
   staging: comedi: comedidev.h: remove unused "polling" function prototypes
   staging: comedi: comedidev.h: add namespace to the subdevice "runflags"
   staging: comedi: das16: use COMEDI_CB_CANCEL_MASK to see if command is 
running
   staging: comedi: drivers: remove inappropriate COMEDI_CB_EOA events
   staging: comedi: pcl818: introduce pcl818_ai_write_sample()

  drivers/staging/comedi/comedi_fops.c | 30 +--
  drivers/staging/comedi/comedidev.h   | 41 
  drivers/staging/comedi/drivers.c |  2 +-
  drivers/staging/comedi/drivers/adl_pci9111.c |  2 +-
  drivers/staging/comedi/drivers/adl_pci9118.c |  4 +-
  drivers/staging/comedi/drivers/adv_pci1710.c | 12 +++---
  drivers/staging/comedi/drivers/cb_pcidas.c   |  2 +-
  drivers/staging/comedi/drivers/cb_pcidas64.c |  2 +-
  drivers/staging/comedi/drivers/das16.c   |  2 +-
  drivers/staging/comedi/drivers/das16m1.c |  2 +-
  drivers/staging/comedi/drivers/das1800.c |  2 +-
  drivers/staging/comedi/drivers/das800.c  |  2 +-
  drivers/staging/comedi/drivers/dt3000.c  |  2 +-
  drivers/staging/comedi/drivers/gsc_hpdi.c|  4 +-
  drivers/staging/comedi/drivers/me4000.c  |  4 +-
  drivers/staging/comedi/drivers/ni_at_a2150.c |  4 +-
  drivers/staging/comedi/drivers/ni_labpc_common.c |  6 +--
  drivers/staging/comedi/drivers/ni_mio_common.c   |  7 ++--
  drivers/staging/comedi/drivers/ni_pcidio.c   |  4 +-
  drivers/staging/comedi/drivers/pcl812.c  |  2 +-
  drivers/staging/comedi/drivers/pcl818.c  | 49 +++-
  drivers/staging/comedi/drivers/quatech_daqp_cs.c |  5 +--
  22 files changed, 81 insertions(+), 109 deletions(-)



Reviewed-by: Ian Abbott 

--
-=( Ian Abbott @ MEV Ltd.E-mail:  )=-
-=(  Web: http://www.mev.co.uk/  )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/2] Replacing ERR by dev_err

2015-01-21 Thread Ahmad Hassan
This patch set removes the macro ERR from emxx_udc.h and accordingly
emxx_udc.c occurrences of ERR changes to dev_err

Ahmad Hassan (2):
  staging: emxx_udc: Replace ERR by dev_err
  staging: emxx_udc: remove macro ERR

 drivers/staging/emxx_udc/emxx_udc.c | 80 ++---
 drivers/staging/emxx_udc/emxx_udc.h |  1 -
 2 files changed, 40 insertions(+), 41 deletions(-)

-- 
2.2.1

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


[PATCH 1/2] staging: emxx_udc: Replace ERR by dev_err

2015-01-21 Thread Ahmad Hassan
Replaced all occurences of ERR with dev_err.
The device passed to dev_err is udc->dev.

Signed-off-by: Ahmad Hassan 
---
 drivers/staging/emxx_udc/emxx_udc.c | 80 ++---
 1 file changed, 40 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/emxx_udc/emxx_udc.c 
b/drivers/staging/emxx_udc/emxx_udc.c
index eb178fc..e7aaad4 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -115,7 +115,7 @@ static void _nbu2ss_dump_register(struct nbu2ss_udc *udc)
pr_info("=== %s()\n", __func__);
 
if (udc == NULL) {
-   ERR("%s udc == NULL\n", __func__);
+   dev_err(udc->dev,"%s udc == NULL\n", __func__);
return;
}
 
@@ -808,7 +808,7 @@ static int _nbu2ss_ep0_out_transfer(
return 0;   /* Short Packet Transfer End */
 
if (req->req.actual > req->req.length) {
-   ERR(" *** Overrun Error\n");
+   dev_err(udc->dev," *** Overrun Error\n");
return -EOVERFLOW;
}
 
@@ -1026,8 +1026,8 @@ static int _nbu2ss_epn_out_transfer(
}
 
if (req->req.actual > req->req.length) {
-   ERR(" *** Overrun Error\n");
-   ERR(" *** actual = %d, length = %d\n",
+   dev_err(udc->dev," *** Overrun Error\n");
+   dev_err(udc->dev," *** actual = %d, length = %d\n",
req->req.actual, req->req.length);
result = -EOVERFLOW;
}
@@ -1638,7 +1638,7 @@ static int std_req_get_status(struct nbu2ss_udc *udc)
_nbu2ss_ep0_in_transfer(udc, &udc->ep[0], &udc->ep0_req);
 
} else {
-   ERR("*** Error GET_STATUS\n");
+   dev_err(udc->dev,"*** Error GET_STATUS\n");
}
 
return result;
@@ -2258,7 +2258,7 @@ static int _nbu2ss_pullup(struct nbu2ss_udc *udc, int 
is_on)
u32 reg_dt;
 
if (!udc) {
-   ERR("%s, bad param\n", __func__);
+   dev_err(udc->dev,"%s, bad param\n", __func__);
return -EINVAL;
}
 
@@ -2350,7 +2350,7 @@ static int _nbu2ss_enable_controller(struct nbu2ss_udc 
*udc)
waitcnt++;
udelay(1);  /* 1us wait */
if (waitcnt == EPC_PLL_LOCK_COUNT) {
-   ERR("*** Reset Cancel failed\n");
+   dev_err(udc->dev,"*** Reset Cancel failed\n");
return -EINVAL;
}
};
@@ -2612,13 +2612,13 @@ static int nbu2ss_ep_enable(
struct nbu2ss_udc   *udc;
 
if ((_ep == NULL) || (desc == NULL)) {
-   ERR(" *** %s, bad param\n", __func__);
+   dev_err(udc->dev," *** %s, bad param\n", __func__);
return -EINVAL;
}
 
ep = container_of(_ep, struct nbu2ss_ep, ep);
if ((ep == NULL) || (ep->udc == NULL)) {
-   ERR(" *** %s, ep == NULL !!\n", __func__);
+   dev_err(udc->dev," *** %s, ep == NULL !!\n", __func__);
return -EINVAL;
}
 
@@ -2626,7 +2626,7 @@ static int nbu2ss_ep_enable(
if ((ep_type == USB_ENDPOINT_XFER_CONTROL)
|| (ep_type == USB_ENDPOINT_XFER_ISOC)) {
 
-   ERR(" *** %s, bat bmAttributes\n", __func__);
+   dev_err(udc->dev," *** %s, bat bmAttributes\n", __func__);
return -EINVAL;
}
 
@@ -2637,7 +2637,7 @@ static int nbu2ss_ep_enable(
if ((udc->driver == NULL)
|| (udc->gadget.speed == USB_SPEED_UNKNOWN)) {
 
-   ERR(" *** %s, udc !!\n", __func__);
+   dev_err(udc->dev," *** %s, udc !!\n", __func__);
return -ESHUTDOWN;
}
 
@@ -2672,13 +2672,13 @@ static int nbu2ss_ep_disable(struct usb_ep *_ep)
unsigned long   flags;
 
if (_ep == NULL) {
-   ERR(" *** %s, bad param\n", __func__);
+   dev_err(udc->dev," *** %s, bad param\n", __func__);
return -EINVAL;
}
 
ep = container_of(_ep, struct nbu2ss_ep, ep);
if ((ep == NULL) || (ep->udc == NULL)) {
-   ERR(" *** %s, ep == NULL !!\n", __func__);
+   dev_err(udc->dev," *** %s, ep == NULL !!\n", __func__);
return -EINVAL;
}
 
@@ -2742,10 +2742,10 @@ static int nbu2ss_ep_queue(
/* catch various bogus parameters */
if ((_ep == NULL) || (_req == NULL)) {
if (_ep == NULL)
-   ERR("*** %s --- _ep == NULL\n", __func__);
+   dev_err(udc->dev,"*** %s --- _ep == NULL\n", __func__);
 
if (_req == NULL)
-   ERR("*** %s --- _req == NULL\n", __func__);
+   dev_err(udc->dev,"*** %s --- _req == NULL\n", __func__);
 
return -EINVAL;
}
@@ -2756,13 +2756,13 @@ static int nbu2ss_ep_queue(
 || !list_e

[PATCH 2/2] staging: emxx_udc: remove macro ERR

2015-01-21 Thread Ahmad Hassan
Removed ERR macro since it is not used anymore in the emxx_udc.c file.

Signed-off-by: Ahmad Hassan 
---
 drivers/staging/emxx_udc/emxx_udc.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/emxx_udc/emxx_udc.h 
b/drivers/staging/emxx_udc/emxx_udc.h
index ee1b80d..0758cd5 100644
--- a/drivers/staging/emxx_udc/emxx_udc.h
+++ b/drivers/staging/emxx_udc/emxx_udc.h
@@ -644,6 +644,5 @@ typedef volatile union {
 } USB_REG_ACCESS;
 
 /*-*/
-#define ERR(stuff...)  printk(KERN_ERR "udc: " stuff)
 
 #endif  /* _LINUX_EMXX_H */
-- 
2.2.1

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


Re: [PATCH 00/28] staging: comedi: adv_pci1710: driver cleanup

2015-01-21 Thread Ian Abbott

On 20/01/15 21:52, H Hartley Sweeten wrote:

Following is the initial cleanup of the comedi adv_pci1710 driver.

H Hartley Sweeten (28):
   staging: comedi: adv_pci1710: change boardinfo 'n_counter' to 'has_counter'
   staging: comedi: adv_pci1710: simplify digital input and output boardinfo
   staging: comedi: adv_pci1710: rename boardinfo 'have_irq'
   staging: comedi: adv_pci1710: remove boardinfo 'ai_maxdata'
   staging: comedi: adv_pci1710: remove boardinfo 'ao_maxdata'
   staging: comedi: adv_pci1710: change boardinfo 'n_aichand' to 'has_diff_ai'
   staging: comedi: adv_pci1710: remove boardinfo 'ai_ns_min'
   staging: comedi: adv_pci1710: change boardinfo 'fifo_half_size' to 
'has_large_fifo'
   staging: comedi: adv_pci1710: change boardinfo 'n_aochan' to 'has_ao'
   staging: comedi: adv_pci1710: use comedi_subdevice 'readback'
   staging: comedi: adv_pci1710: tidy up pci1720_insn_write_ao()
   staging: comedi: adv_pci1710: tidy up pci171x_insn_write_ao()
   staging: comedi: adv_pci1710: tidy up counter subdevice init
   staging: comedi: adv_pci1710: tidy up digital input and output subdevice init
   staging: comedi: adv_pci1710: tidy up analog output subdevice init
   staging: comedi: adv_pci1710: tidy up analog input subdevice init
   staging: comedi: adv_pci1710: rename 'this_board' local variables
   staging: comedi: adv_pci1710: remove function separation comments
   staging: comedi: adv_pci1710: update the MODULE_DESCRIPTION
   staging: comedi: adv_pci1710: remove boardinfo 'rangelist_ao'
   staging: comedi: adv_pci1710: refactor boardinfo 'cardtype'
   staging: comedi: adv_pci1710: clarify the 'act_chanlist'
   staging: comedi: adv_pci1710: tidy up setup_channel_list()
   staging: comedi: adv_pci1710: introduce pci171x_ai_read_sample()
   staging: comedi: adv_pci1710: do comedi_handle_events() in common code patch
   staging: comedi: adv_pci1710: remove 'turn' param from move_block_from_fifo()
   staging: comedi: adv_pci1710: transfer all ai samples in one step
   staging: comedi: adv_pci1710: absorb move_block_from_fifo()

  drivers/staging/comedi/drivers/adv_pci1710.c | 657 +++
  1 file changed, 264 insertions(+), 393 deletions(-)



Reviewed-by: Ian Abbott 

--
-=( Ian Abbott @ MEV Ltd.E-mail:  )=-
-=(  Web: http://www.mev.co.uk/  )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8712: fix Missing a blank line after declarations

2015-01-21 Thread Lin Kassem
This patch fixes the following checkpatch.pl warning:
fix Missing a blank line after declarations

Signed-off-by: Lin Kassem 
---
 drivers/staging/rtl8712/drv_types.h |2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/rtl8712/drv_types.h 
b/drivers/staging/rtl8712/drv_types.h
index 3d0a98b..9bc300c 100644
--- a/drivers/staging/rtl8712/drv_types.h
+++ b/drivers/staging/rtl8712/drv_types.h
@@ -129,6 +129,7 @@ struct dvobj_priv {
struct _adapter *padapter;
u32 nr_endpoint;
u8   ishighspeed;
+
uint(*inirp_init)(struct _adapter *adapter);
uint(*inirp_deinit)(struct _adapter *adapter);
struct usb_device *pusbdev;
@@ -166,6 +167,7 @@ struct _adapter {
 pid_t evtThread;
struct task_struct *xmitThread;
pid_t recvThread;
+
uint(*dvobj_init)(struct _adapter *adapter);
void (*dvobj_deinit)(struct _adapter *adapter);
struct net_device *pnetdev;
-- 
1.7.9.5

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


Re: [PATCH 1/2] staging: emxx_udc: Replace ERR by dev_err

2015-01-21 Thread Jeremiah Mahler
Ahmad,

On Wed, Jan 21, 2015 at 01:55:11PM -0900, Ahmad Hassan wrote:
[...]
>   if (udc == NULL) {
> - ERR("%s udc == NULL\n", __func__);
> + dev_err(udc->dev,"%s udc == NULL\n", __func__);
  ^

Always check your patches with checkpatch.pl before submitting them.

There are a bunch of "space required after ','" errors in this patch.

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


Re: [PATCH 0/2] mmc: rtsx: add check before sending request

2015-01-21 Thread Ulf Hansson
On 14 January 2015 at 04:09,   wrote:
> From: Micky Ching 
>
> Add check before sending request can make request return faster.
> - finish request if no card exist
>   This can make request finish faster, especial for some sdio card,
>   when card removed, there still a lot of command pending,
>   if we check card exist and stop request, the card will disappear
>   faster in user space.
>
> - check sg_count before long data xfer
>   modify sg_count type unsigned -> int, because dma_map_sg() return
>   int, and this value can be negative to indicate some error occurs.
>
> Micky Ching (2):
>   mmc: rtsx: finish request if no card exist
>   mmc: rtsx: check sg_count before long data xfer
>
>  drivers/mmc/host/rtsx_pci_sdmmc.c | 20 
>  1 file changed, 16 insertions(+), 4 deletions(-)
>
> --
> 1.9.1
>

Thanks! Applied for next.

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


Re: [PATCH 2/2] staging: emxx_udc: remove macro ERR

2015-01-21 Thread Tobias Klauser
On 2015-01-21 at 23:56:06 +0100, Ahmad Hassan  wrote:
> Removed ERR macro since it is not used anymore in the emxx_udc.c file.
> 
> Signed-off-by: Ahmad Hassan 
> ---
>  drivers/staging/emxx_udc/emxx_udc.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/staging/emxx_udc/emxx_udc.h 
> b/drivers/staging/emxx_udc/emxx_udc.h
> index ee1b80d..0758cd5 100644
> --- a/drivers/staging/emxx_udc/emxx_udc.h
> +++ b/drivers/staging/emxx_udc/emxx_udc.h
> @@ -644,6 +644,5 @@ typedef volatile union {
>  } USB_REG_ACCESS;
>  
>  /*-*/

While at it, you could also remove the line above.

> -#define ERR(stuff...)printk(KERN_ERR "udc: " stuff)
>  
>  #endif  /* _LINUX_EMXX_H */
> -- 
> 2.2.1
> 
> ___
> devel mailing list
> de...@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 55/69] staging: unisys: get rid of LOGWRN() macro and uisklog.h

2015-01-21 Thread Romer, Benjamin M
On Fri, 2015-01-09 at 17:40 -0800, Greg KH wrote:
> On Fri, Dec 05, 2014 at 05:09:30PM -0500, Benjamin Romer wrote:
> > Get rid of LOGWRN() and all related macros, and call pr_warn() directly 
> > instead.
> 
> Side note, are you setting pr_fmt() properly so that everything is
> "unified" with these messages?  No driver subsystem should ever use a
> pr_* call unless it is at startup / shutdown where there is no hardware
> involved.  I think that's not the case here so use the correct dev_*
> versions instead.
> 
> thanks,
> 
> greg k-h

Greg,

You're absolutely right that almost all of the messages being output in
our code aren't useful from a user's perspective, so what I'd like to do
is to just remove all of the logging macros in one set of patches, and
then re-introduce a small number of properly-coded error messages in
appropriate spots in a later set of patches.

Would that be okay? If so, is it alright to take out one set of macros
per patch, or is that too much at once?

Thanks!

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


[PATCH] staging: vt6656: fix Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)

2015-01-21 Thread Lin Kassem
This patch fixes the following checkpatch.pl warning:
fix Prefer ether_addr_copy() over memcpy() 
if the Ethernet addresses are __aligned(2)

Pahole showed that the 2 structs are aligned to u16

struct ieee80211_hdr {
__le16 frame_control;/* 0 2 */
__le16 duration_id;  /* 2 2 */
u8 addr1[6]; /* 4 6 */
u8 addr2[6]; /*10 6 */
u8 addr3[6]; /*16 6 */
__le16 seq_ctrl; /*22 2 */
u8 addr4[6]; /*24 6 */

/* size: 30, cachelines: 1, members: 7 */
/* last cacheline: 30 bytes */
};

struct vnt_mic_hdr {
u8 id;   /* 0 1 */
u8 tx_priority;  /* 1 1 */
u8 mic_addr2[6]; /* 2 6 */
u8 ccmp_pn[6];   /* 8 6 */
__be16 payload_len;  /*14 2 */
__be16 hlen; /*16 2 */
__le16 frame_control;/*18 2 */
u8 addr1[6]; /*20 6 */
u8 addr2[6]; /*26 6 */
u8 addr3[6]; /*32 6 */
__le16 seq_ctrl; /*38 2 */
u8 addr4[6]; /*40 6 */
u16packing;  /*46 2 */

/* size: 48, cachelines: 1, members: 13 */
/* last cacheline: 48 bytes */
};

Signed-off-by: Lin Kassem 
---
 drivers/staging/vt6656/rxtx.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index bb6a4d4..c202147 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -749,7 +749,7 @@ static void vnt_fill_txkey(struct vnt_usb_send_context 
*tx_context,
else
mic_hdr->hlen = cpu_to_be16(22);
 
-   memcpy(mic_hdr->addr1, hdr->addr1, ETH_ALEN);
+   ether_addr_copy(mic_hdr->addr1, hdr->addr1);
memcpy(mic_hdr->addr2, hdr->addr2, ETH_ALEN);
memcpy(mic_hdr->addr3, hdr->addr3, ETH_ALEN);
 
-- 
1.7.9.5

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


Here is the Bank Draft RefNo: 972 7742 431 002626

2015-01-21 Thread United nation

Kindly open the attachment and contact him for your bank darft. Contact Person 
: Dr.Jim Ovia.
Bank Name : Zenith Bank Plc
Email: zenithbank-ng-...@cd2.com
Personal Phone:  +234-814-820-2663


DRAFT.rtf
Description: RTF file
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 55/69] staging: unisys: get rid of LOGWRN() macro and uisklog.h

2015-01-21 Thread Dan Carpenter
Generally "delete code" patches are easy to review.  But sometimes you
have to change formatting and remove variables and curly braces.

$ grep LOG drivers/staging/unisys/ -R | wc -l
415

There isn't a firm rule on way a patch is just too big and annoying to
review.  Probably break it up into:

[patch 1/x] delete LOGINF()
[patch 2/x] delete LOGERR()
...

regards,
dan carpenter

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


Re: [PATCH] staging: vt6656: fix Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)

2015-01-21 Thread Joe Perches
On Wed, 2015-01-21 at 18:44 +0200, Lin Kassem wrote:
> This patch fixes the following checkpatch.pl warning:
> fix Prefer ether_addr_copy() over memcpy() 
> if the Ethernet addresses are __aligned(2)
> 
> Pahole showed that the 2 structs are aligned to u16
[]
> diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
[]
> @@ -749,7 +749,7 @@ static void vnt_fill_txkey(struct vnt_usb_send_context 
> *tx_context,
>   else
>   mic_hdr->hlen = cpu_to_be16(22);
>  
> - memcpy(mic_hdr->addr1, hdr->addr1, ETH_ALEN);
> + ether_addr_copy(mic_hdr->addr1, hdr->addr1);
>   memcpy(mic_hdr->addr2, hdr->addr2, ETH_ALEN);
>   memcpy(mic_hdr->addr3, hdr->addr3, ETH_ALEN);
>  

Why would you modify only one of these?
Please modify all 4.


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


Re: [PATCH v8 2/4] fpga manager: add sysfs interface document

2015-01-21 Thread One Thousand Gnomes
On Thu, 15 Jan 2015 22:54:46 +0200
Pantelis Antoniou  wrote:

> Hi Alan,
> 
> > On Jan 15, 2015, at 22:45 , One Thousand Gnomes 
> >  wrote:
> > 
> > On Thu, 15 Jan 2015 11:47:26 -0700
> > Jason Gunthorpe  wrote:
> >> It is a novel idea, my concern would be that embedding the FPGA in the
> >> DT makes it permanent unswappable kernel memory.
> >> Not having the kernel hold the FPGA is best for many uses.
> > 
> > If you have a filesysytem before the FPGA is set up then it belongs in
> > the file system. As you presumably loaded the kernel from somewhere there
> > ought to be a file system (even an initrd).
> > 
> 
> Request firmware does not imply keeping it around. You can always re-request
> when reloading (although there’s a nasty big of caching that needs to be
> resolved with the firmware loader).

Which comes down to the same thing. Unless you can prove that there is a
path to recover the firmware file that does not have any dependancies
upon the firmware executing (and those can be subtle and horrid at times)
you need to keep it around for suspend/resume at least and potentially
any unexpected error/reset.

> One of the ideas rolling about is to put the device tree overlay blob in
> an EEPROM and then load it from there (not from the filesystem).

That's a fine example of one you can probably always get to and avoid
caching. However if its in eeprom you don't need request_firmware anyway !

> Can we please not use ioctls if possible. Configfs seems to work just fine
> for configuration and for any other higher speed API we should use 
> read/write/mmap.

You don't have the needed state in configfs as far as I can see.

> Ioctls are a pain for scripting and interpreted languages usually.

You can do ioctls in perl just fine if you are mad (and if you are
using perl you are ;-) ) while python has a complete explicit fcntl.ioctl
model.

> Making the API handle partial reconfiguration from day one might be pushing 
> tricky.
> I don’t remember any case where I came across a need for it.

Agreed - I don't see the point in adding it until someone needs it and can
describe what is needed accurately.

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


Re: [PATCH v8 2/4] fpga manager: add sysfs interface document

2015-01-21 Thread Pantelis Antoniou
Hi Alan,

> On Jan 21, 2015, at 18:01 , One Thousand Gnomes  
> wrote:
> 
> On Thu, 15 Jan 2015 22:54:46 +0200
> Pantelis Antoniou  wrote:
> 
>> Hi Alan,
>> 
>>> On Jan 15, 2015, at 22:45 , One Thousand Gnomes 
>>>  wrote:
>>> 
>>> On Thu, 15 Jan 2015 11:47:26 -0700
>>> Jason Gunthorpe  wrote:
 It is a novel idea, my concern would be that embedding the FPGA in the
 DT makes it permanent unswappable kernel memory.
 Not having the kernel hold the FPGA is best for many uses.
>>> 
>>> If you have a filesysytem before the FPGA is set up then it belongs in
>>> the file system. As you presumably loaded the kernel from somewhere there
>>> ought to be a file system (even an initrd).
>>> 
>> 
>> Request firmware does not imply keeping it around. You can always re-request
>> when reloading (although there’s a nasty big of caching that needs to be
>> resolved with the firmware loader).
> 
> Which comes down to the same thing. Unless you can prove that there is a
> path to recover the firmware file that does not have any dependancies
> upon the firmware executing (and those can be subtle and horrid at times)
> you need to keep it around for suspend/resume at least and potentially
> any unexpected error/reset.
> 

In that case the only safe place to put it is in the kernel image itself, which
is something the firmware loader already supports.

>> One of the ideas rolling about is to put the device tree overlay blob in
>> an EEPROM and then load it from there (not from the filesystem).
> 
> That's a fine example of one you can probably always get to and avoid
> caching. However if its in eeprom you don't need request_firmware anyway !
> 

Sure, I never said that request_firmware is the only way to get hold of a blob.
It just happens to be the most convenient one for the kernel (when the blob
resides somewhere on a filesystem).

>> Can we please not use ioctls if possible. Configfs seems to work just fine
>> for configuration and for any other higher speed API we should use 
>> read/write/mmap.
> 
> You don't have the needed state in configfs as far as I can see.
> 

Sure, but there’s no reason for it not to be there.

>> Ioctls are a pain for scripting and interpreted languages usually.
> 
> You can do ioctls in perl just fine if you are mad (and if you are
> using perl you are ;-) ) while python has a complete explicit fcntl.ioctl
> model.
> 

Sure, it can be made to work, but it is a pain.

>> Making the API handle partial reconfiguration from day one might be pushing 
>> tricky.
>> I don’t remember any case where I came across a need for it.
> 
> Agreed - I don't see the point in adding it until someone needs it and can
> describe what is needed accurately.
> 

/me nods.

> Alan

Regards

— Pantelis

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


RE: [PATCH] staging: comedi: aio_iiro_16: return input state in async command sample

2015-01-21 Thread Hartley Sweeten
On Wednesday, January 21, 2015 4:00 AM, Ian Abbott wrote:
> On 20/01/15 19:00, H Hartley Sweeten wrote:
>> Modify the sample data returned by the async command to include the current
>> state of the digital inputs. Otherwise the command needs to be canceled in
>> order for the user to do an (*insn_bits) operation to check the digital
>> inputs.
>>
>> Signed-off-by: H Hartley Sweeten 
>> Cc: Ian Abbott 
>> Cc: Greg Kroah-Hartman 
>> ---
>>   drivers/staging/comedi/drivers/aio_iiro_16.c | 33 
>> 
>>   1 file changed, 24 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c 
>> b/drivers/staging/comedi/drivers/aio_iiro_16.c
>> index d8884a3..1c7b325 100644
>> --- a/drivers/staging/comedi/drivers/aio_iiro_16.c
>> +++ b/drivers/staging/comedi/drivers/aio_iiro_16.c
>> @@ -27,11 +27,14 @@
>>*
>>* The board supports interrupts on change of state of the digital inputs.
>>* The sample data returned by the async command indicates which inputs
>> - * changed state:
>> + * changed state and the current state of the inputs:
>>*
>> - *  Bit 7 - IRQ Enable (1) / Disable (0)
>> - *  Bit 1 - Input 8-15 Changed State (1 = Changed, 0 = No Change)
>> - *  Bit 0 - Input 0-7 Changed State (1 = Changed, 0 = No Change)
>> + *  Bit 23 - IRQ Enable (1) / Disable (0)
>> + *  Bit 17 - Input 8-15 Changed State (1 = Changed, 0 = No Change)
>> + *  Bit 16 - Input 0-7 Changed State (1 = Changed, 0 = No Change)
>> + *  Bit 15 - Digital input 15
>> + *  ...
>> + *  Bit 0  - Digital input 0
>
> I'm wondering whether it should just indicate the state of the digital 
> inputs and not bother with the other stuff.  Any thoughts?

If just the state of the inputs is returned is would get the sample size back
down to 16-bits.

But, I can see use cases where the user would want to know which 8-bit
"port" had the change of input. One port might be connected to inputs
that have low-priority handling and the other port has higher priority.
Knowing which port changed state would allow the users app to handle
them appropriately without needing to keep the previous state.

Regardless, I'm good either way as long as the input states are returned
so that the command does not need to be canceled in order to get them.

Regards,
Hartley

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


Re: [PATCH] staging: rtl8712: fix Missing a blank line after declarations

2015-01-21 Thread Joe Perches
On Wed, 2015-01-21 at 16:41 +0200, Lin Kassem wrote:
> This patch fixes the following checkpatch.pl warning:
> fix Missing a blank line after declarations

False positives.  Unnecessary changes.

> diff --git a/drivers/staging/rtl8712/drv_types.h 
> b/drivers/staging/rtl8712/drv_types.h
[]
> @@ -129,6 +129,7 @@ struct dvobj_priv {
>   struct _adapter *padapter;
>   u32 nr_endpoint;
>   u8   ishighspeed;
> +
>   uint(*inirp_init)(struct _adapter *adapter);
>   uint(*inirp_deinit)(struct _adapter *adapter);
>   struct usb_device *pusbdev;
> @@ -166,6 +167,7 @@ struct _adapter {
>pid_t evtThread;
>   struct task_struct *xmitThread;
>   pid_t recvThread;
> +
>   uint(*dvobj_init)(struct _adapter *adapter);
>   void (*dvobj_deinit)(struct _adapter *adapter);
>   struct net_device *pnetdev;



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


Re: [PATCH] staging: comedi: aio_iiro_16: return input state in async command sample

2015-01-21 Thread Ian Abbott

On 21/01/15 16:36, Hartley Sweeten wrote:

On Wednesday, January 21, 2015 4:00 AM, Ian Abbott wrote:

On 20/01/15 19:00, H Hartley Sweeten wrote:

Modify the sample data returned by the async command to include the current
state of the digital inputs. Otherwise the command needs to be canceled in
order for the user to do an (*insn_bits) operation to check the digital
inputs.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
   drivers/staging/comedi/drivers/aio_iiro_16.c | 33 

   1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c 
b/drivers/staging/comedi/drivers/aio_iiro_16.c
index d8884a3..1c7b325 100644
--- a/drivers/staging/comedi/drivers/aio_iiro_16.c
+++ b/drivers/staging/comedi/drivers/aio_iiro_16.c
@@ -27,11 +27,14 @@
*
* The board supports interrupts on change of state of the digital inputs.
* The sample data returned by the async command indicates which inputs
- * changed state:
+ * changed state and the current state of the inputs:
*
- * Bit 7 - IRQ Enable (1) / Disable (0)
- * Bit 1 - Input 8-15 Changed State (1 = Changed, 0 = No Change)
- * Bit 0 - Input 0-7 Changed State (1 = Changed, 0 = No Change)
+ * Bit 23 - IRQ Enable (1) / Disable (0)
+ * Bit 17 - Input 8-15 Changed State (1 = Changed, 0 = No Change)
+ * Bit 16 - Input 0-7 Changed State (1 = Changed, 0 = No Change)
+ * Bit 15 - Digital input 15
+ * ...
+ * Bit 0  - Digital input 0


I'm wondering whether it should just indicate the state of the digital
inputs and not bother with the other stuff.  Any thoughts?


If just the state of the inputs is returned is would get the sample size back
down to 16-bits.

But, I can see use cases where the user would want to know which 8-bit
"port" had the change of input. One port might be connected to inputs
that have low-priority handling and the other port has higher priority.
Knowing which port changed state would allow the users app to handle
them appropriately without needing to keep the previous state.

Regardless, I'm good either way as long as the input states are returned
so that the command does not need to be canceled in order to get them.


I suppose the extra bits can be useful for detecting short pulses where 
the state of the digital inputs recorded by the interrupt handler call 
is unchanged since the previous call.  Having only two "changed state" 
bits is kind of limited for that purpose, but better than nothing I 
suppose!  I don't really care either way, so:


Reviewed-by: Ian Abbott 

--
-=( Ian Abbott @ MEV Ltd.E-mail:  )=-
-=(  Web: http://www.mev.co.uk/  )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [RFC PATCH 0/5] unisys: kthread cleanup

2015-01-21 Thread Romer, Benjamin M
On Wed, 2015-01-21 at 04:03 -0500, Devendra Naga wrote:
> The 1st patch (replace kthread_create..) replace the
> kthread_create and wake_up_process with a call to
> kthread_run.
> 
> The 2nd patch changes the library API uisthread_start
> and uisthread_stop to use the kthread API.
> 
> The 3rd patch and 4th patch checks on kthread_should_stop
> instead of checking should_stop variable.
> 
> The 5th patch removes the variables should_stop and
> KILL as they are no longer required.
> 
> 
> All patches applies on next-20150120 cleanly. All the patches are
> compile tested on X86_64 allmodconfig.
> 

Hi,

I've built and tested your set of patches on an s-Par guest, and with
the changes I get a kernel oops during boot, but I haven't determined
the cause yet. I'll let you know what I find. :)

-- Ben

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


Re: [PATCH] staging: lustre: fix sparse warnings related to lock context imbalance

2015-01-21 Thread Loïc Pefferkorn
On Sat, Jan 17, 2015 at 03:29:01PM -0800, Greg KH wrote:
> On Sat, Dec 13, 2014 at 03:58:46PM +0100, Loïc Pefferkorn wrote:
> > > >>> Don't hide "implementation of locks" in functions like this, it only
> > > >>> causes problems.  This code has layers of layers of layers of
> > > >>> abstractions due to it wanting to be originally ported to other
> > > >>> operating systems and lots of different kernel versions of Linux 
> > > >>> itself.
> > > >>> Unwinding and removing those layers is a good thing to do, don't paper
> > > >>> over the nonsense by putting sparse markings on pointless functions.
> > > >>> 
> > > >>> thanks,
> > > >>> 
> > > >>> greg k-h
> > > >> 
> > > >> 
> > > >> Cheers, Andreas
> > > > 
> > > > Hello,
> > > > 
> > > > Thanks for your answer. The annotations look like the best thing to do?
> > > 
> > > Yes, the annotations still make sense.
> > > 
> > > Cheers, Andreas
> > 
> > Hello guys,
> > 
> > I believe this patch is still relevant, and can be applied against 
> > next-20141212.
> 
> If so, please resend, as I don't have it in my queue anymore.
> 
> thanks,
> 
> greg k-h
> 

Hi Greg,

Done: https://lkml.org/lkml/2015/1/20/841

-- 
Cheers,
Loïc
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/3] Drivers: hv: vmbus: avoid double kfree for device_obj

2015-01-21 Thread Vitaly Kuznetsov
On driver shutdown device_obj is being freed twice:
1) In vmbus_free_channels()
2) vmbus_device_release() (which is being triggered by device_unregister() in
   vmbus_device_unregister().
This double kfree leads to the following sporadic crash on driver unload:

[   23.469876] general protection fault:  [#1] SMP
[   23.470036] Modules linked in: hv_vmbus(-)
[   23.470036] CPU: 2 PID: 213 Comm: rmmod Not tainted 3.19.0-rc5_bug923184+ 
#488
[   23.470036] Hardware name: Microsoft Corporation Virtual Machine/Virtual 
Machine, BIOS 090006  05/23/2012
[   23.470036] task: 880036ef1cb0 ti: 880036ce8000 task.ti: 
880036ce8000
[   23.470036] RIP: 0010:[]  [] 
__kmalloc_node_track_caller+0xdb/0x1e0
[   23.470036] RSP: 0018:880036cebcc8  EFLAGS: 00010246
...

When this crash does not happen on driver unload the similar one is expected if
we try to load hv_vmbus again.

Remove kfree from vmbus_free_channels() as freeing it from
vmbus_device_release() seems right.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/channel_mgmt.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 877a944..0141a3d 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -259,7 +259,6 @@ void vmbus_free_channels(void)
 
list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
vmbus_device_unregister(channel->device_obj);
-   kfree(channel->device_obj);
free_channel(channel);
}
 }
-- 
1.9.3

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


[PATCH 2/3] Drivers: hv: vmbus: introduce vmbus_acpi_remove

2015-01-21 Thread Vitaly Kuznetsov
In case we do request_resource() in vmbus_acpi_add() we need to tear it down
to be able to load the driver again. Otherwise the following crash in oberved
when hv_vmbus unload/load sequence is performed on Generation2 instance:

[   38.165701] BUG: unable to handle kernel paging request at a00075a0
[   38.166315] IP: [] __request_resource+0x2f/0x50
[   38.166315] PGD 1f34067 PUD 1f35063 PMD 3f723067 PTE 0
[   38.166315] Oops:  [#1] SMP
[   38.166315] Modules linked in: hv_vmbus(+) [last unloaded: hv_vmbus]
[   38.166315] CPU: 0 PID: 267 Comm: modprobe Not tainted 3.19.0-rc5_bug923184+ 
#486
[   38.166315] Hardware name: Microsoft Corporation Virtual Machine/Virtual 
Machine, BIOS Hyper-V UEFI Release v1.0 11/26/2012
[   38.166315] task: 88003f401cb0 ti: 88003f60c000 task.ti: 
88003f60c000
[   38.166315] RIP: 0010:[]  [] 
__request_resource+0x2f/0x50
[   38.166315] RSP: 0018:88003f60fb58  EFLAGS: 00010286
...

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/vmbus_drv.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 4d6b269..b06cb87 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -902,6 +902,15 @@ acpi_walk_err:
return ret_val;
 }
 
+static int vmbus_acpi_remove(struct acpi_device *device)
+{
+   int ret = 0;
+
+   if (hyperv_mmio.start && hyperv_mmio.end)
+   ret = release_resource(&hyperv_mmio);
+   return ret;
+}
+
 static const struct acpi_device_id vmbus_acpi_device_ids[] = {
{"VMBUS", 0},
{"VMBus", 0},
@@ -914,6 +923,7 @@ static struct acpi_driver vmbus_acpi_driver = {
.ids = vmbus_acpi_device_ids,
.ops = {
.add = vmbus_acpi_add,
+   .remove = vmbus_acpi_remove,
},
 };
 
-- 
1.9.3

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


[PATCH 3/3] Drivers: hv: vmbus: teardown hv_vmbus_con workqueue and vmbus_connection pages on shutdown

2015-01-21 Thread Vitaly Kuznetsov
We need to destroy hv_vmbus_con on module shutdown, otherwise the following
crash is sometimes observed:

[   76.569845] hv_vmbus: Hyper-V Host Build:9600-6.3-17-0.17039; Vmbus 
version:3.0
[   82.598859] BUG: unable to handle kernel paging request at a0003480
[   82.599287] IP: [] 0xa0003480
[   82.599287] PGD 1f34067 PUD 1f35063 PMD 3f72d067 PTE 0
[   82.599287] Oops: 0010 [#1] SMP
[   82.599287] Modules linked in: [last unloaded: hv_vmbus]
[   82.599287] CPU: 0 PID: 26 Comm: kworker/0:1 Not tainted 
3.19.0-rc5_bug923184+ #488
[   82.599287] Hardware name: Microsoft Corporation Virtual Machine/Virtual 
Machine, BIOS Hyper-V UEFI Release v1.0 11/26/2012
[   82.599287] Workqueue: hv_vmbus_con 0xa0003480
[   82.599287] task: 88007b6ddfa0 ti: 88007f8f8000 task.ti: 
88007f8f8000
[   82.599287] RIP: 0010:[]  [] 
0xa0003480
[   82.599287] RSP: 0018:88007f8fbe00  EFLAGS: 00010202
...

To avoid memory leaks we need to free monitor_pages and int_page for
vmbus_connection. Implement vmbus_disconnect() function by separating cleanup
path from vmbus_connect().

As we use hv_vmbus_con to release channels (see free_channel() in 
channel_mgmt.c)
we need to make sure the work was done before we remove the queue, do that with
drain_workqueue(). We also need to avoid handling messages  which can 
(potentially)
create new channels, so set vmbus_connection.conn_state = DISCONNECTED at the 
very
beginning of vmbus_exit() and check for that in vmbus_onmessage_work().

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/connection.c   | 17 -
 drivers/hv/hyperv_vmbus.h |  1 +
 drivers/hv/vmbus_drv.c|  6 ++
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index e206619..2fce0c7 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -214,10 +214,21 @@ int vmbus_connect(void)
 
 cleanup:
pr_err("Unable to connect to host\n");
+
vmbus_connection.conn_state = DISCONNECTED;
+   vmbus_disconnect();
+
+   kfree(msginfo);
+
+   return ret;
+}
 
-   if (vmbus_connection.work_queue)
+void vmbus_disconnect(void)
+{
+   if (vmbus_connection.work_queue) {
+   drain_workqueue(vmbus_connection.work_queue);
destroy_workqueue(vmbus_connection.work_queue);
+   }
 
if (vmbus_connection.int_page) {
free_pages((unsigned long)vmbus_connection.int_page, 0);
@@ -228,10 +239,6 @@ cleanup:
free_pages((unsigned long)vmbus_connection.monitor_pages[1], 0);
vmbus_connection.monitor_pages[0] = NULL;
vmbus_connection.monitor_pages[1] = NULL;
-
-   kfree(msginfo);
-
-   return ret;
 }
 
 /*
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index c386d8d..e01c13e 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -671,6 +671,7 @@ void vmbus_free_channels(void);
 /* Connection interface */
 
 int vmbus_connect(void);
+void vmbus_disconnect(void);
 
 int vmbus_post_msg(void *buffer, size_t buflen);
 
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index b06cb87..e647505 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -572,6 +572,10 @@ static void vmbus_onmessage_work(struct work_struct *work)
 {
struct onmessage_work_context *ctx;
 
+   /* Do not process messages if we're in DISCONNECTED state */
+   if (vmbus_connection.conn_state == DISCONNECTED)
+   return;
+
ctx = container_of(work, struct onmessage_work_context,
   work);
vmbus_onmessage(&ctx->msg);
@@ -969,11 +973,13 @@ cleanup:
 
 static void __exit vmbus_exit(void)
 {
+   vmbus_connection.conn_state = DISCONNECTED;
hv_remove_vmbus_irq();
vmbus_free_channels();
bus_unregister(&hv_bus);
hv_cleanup();
acpi_bus_unregister_driver(&vmbus_acpi_driver);
+   vmbus_disconnect();
 }
 
 
-- 
1.9.3

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


[PATCH 0/3] Drivers: hv: vmbus: fix crashes on hv_vmbus load/unload path

2015-01-21 Thread Vitaly Kuznetsov
It is possible (since 93e5bd06a953: "Drivers: hv: Make the vmbus driver
unloadable") to unload hv_vmbus driver if no other devices are connected.
1aec169673d7: "x86: Hyperv: Cleanup the irq mess" fixed doulble interrupt
gate setup. However, if we try to unload hv_vmbus and then load it back
crashes in different places of vmbus driver occur on both unload and second
load paths. Address those I saw in my testing.

Not everything is fixed though. MCE was hit once on Generation2 instance and
I neither understand what caused it nor do I know the way to reproduce it.
Anyway, here is the log:

[  204.846255] mce: [Hardware Error]: CPU 0: Machine Check Exception: 4 Bank 0: 
b200c0020001
[  204.846675] mce: [Hardware Error]: TSC 6b5cd64bc8 
[  204.846675] mce: [Hardware Error]: PROCESSOR 0:306e4 TIME 1421944123 SOCKET 
0 APIC 0 microcode 
[  204.846675] mce: [Hardware Error]: Run the above through 'mcelog --ascii'
[  204.846675] mce: [Hardware Error]: Machine check: Processor context corrupt
[  204.846675] Kernel panic - not syncing: Fatal Machine check
[  204.846675] Kernel Offset: 0x0 from 0x8100 (relocation range: 
0x8000-0x9fff)
[  204.846675] Rebooting in 30 seconds..
[  204.846675] ACPI MEMORY or I/O RESET_REG.

Vitaly Kuznetsov (3):
  Drivers: hv: vmbus: avoid double kfree for device_obj
  Drivers: hv: vmbus: introduce vmbus_acpi_remove
  Drivers: hv: vmbus: teardown hv_vmbus_con workqueue and
vmbus_connection pages on shutdown

 drivers/hv/channel_mgmt.c |  1 -
 drivers/hv/connection.c   | 17 -
 drivers/hv/hyperv_vmbus.h |  1 +
 drivers/hv/vmbus_drv.c| 16 
 4 files changed, 29 insertions(+), 6 deletions(-)

-- 
1.9.3

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


Re: [PATCH] staging: iio: tsl2x7x_core: fix format string warnings

2015-01-21 Thread Jonathan Cameron
On 20/01/15 09:27, Asaf Vertz wrote:
> Fixed the following warnings (reported by cppcheck):
> [drivers/staging/iio/light/tsl2x7x_core.c:1150]: (warning) %d in format 
> string (no. 1)
> requires 'int' but the argument type is 'unsigned int'.
> [drivers/staging/iio/light/tsl2x7x_core.c:1150]: (warning) %d in format 
> string (no. 2)
> requires 'int' but the argument type is 'unsigned int'.
> [drivers/staging/iio/light/tsl2x7x_core.c:1150]: (warning) %d in format 
> string (no. 3)
> requires 'int' but the argument type is 'unsigned int'.
> 
> Signed-off-by: Asaf Vertz 
Applied to the togreg branch of iio.git.  Initially pushed out as
testing for the autobuilders to play.

Thanks,

Jonathan
> ---
>  drivers/staging/iio/light/tsl2x7x_core.c |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x_core.c 
> b/drivers/staging/iio/light/tsl2x7x_core.c
> index 423f96b..4a5dc26 100644
> --- a/drivers/staging/iio/light/tsl2x7x_core.c
> +++ b/drivers/staging/iio/light/tsl2x7x_core.c
> @@ -1147,7 +1147,7 @@ static ssize_t tsl2x7x_luxtable_show(struct device *dev,
>   int offset = 0;
>  
>   while (i < (TSL2X7X_MAX_LUX_TABLE_SIZE * 3)) {
> - offset += snprintf(buf + offset, PAGE_SIZE, "%d,%d,%d,",
> + offset += snprintf(buf + offset, PAGE_SIZE, "%u,%u,%u,",
>   chip->tsl2x7x_device_lux[i].ratio,
>   chip->tsl2x7x_device_lux[i].ch0,
>   chip->tsl2x7x_device_lux[i].ch1);
> 

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


Re: [PATCH v8 2/4] fpga manager: add sysfs interface document

2015-01-21 Thread Jason Gunthorpe
On Wed, Jan 21, 2015 at 06:33:12PM +0200, Pantelis Antoniou wrote:
> Hi Alan,
> 
> > On Jan 21, 2015, at 18:01 , One Thousand Gnomes 
> >  wrote:
> > 
> > On Thu, 15 Jan 2015 22:54:46 +0200
> > Pantelis Antoniou  wrote:
> > 
> >> Hi Alan,
> >> 
> >>> On Jan 15, 2015, at 22:45 , One Thousand Gnomes 
> >>>  wrote:
> >>> 
> >>> On Thu, 15 Jan 2015 11:47:26 -0700
> >>> Jason Gunthorpe  wrote:
>  It is a novel idea, my concern would be that embedding the FPGA in the
>  DT makes it permanent unswappable kernel memory.
>  Not having the kernel hold the FPGA is best for many uses.
> >>> 
> >>> If you have a filesysytem before the FPGA is set up then it belongs in
> >>> the file system. As you presumably loaded the kernel from somewhere there
> >>> ought to be a file system (even an initrd).
> >>> 
> >> 
> >> Request firmware does not imply keeping it around. You can always 
> >> re-request
> >> when reloading (although there’s a nasty big of caching that needs to be
> >> resolved with the firmware loader).
> > 
> > Which comes down to the same thing. Unless you can prove that there is a
> > path to recover the firmware file that does not have any dependancies
> > upon the firmware executing (and those can be subtle and horrid at times)
> > you need to keep it around for suspend/resume at least and potentially
> > any unexpected error/reset.
> > 
> 
> In that case the only safe place to put it is in the kernel image itself, 
> which
> is something the firmware loader already supports.

My point is that the current firmware layer is overly cautious and
FPGAs are very big. My current project on small Xilinx device has a
10MB programming file. The biggest Xilinx device today has a max
bitfile size around 122MB.

So keeping that much memory pinned in the kernel when I can prove it
is uncessary for my system (either because there is no suspend/resume
possibility, or because I know the CPU can always access the
filesytem) is very undesirable.

Other systems might have to take the ram hit.

Since it seems like the kernel has no way to know, we probably have
have a way to tell it not to cache the bitfile.

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


Re: [PATCH v8 2/4] fpga manager: add sysfs interface document

2015-01-21 Thread Pantelis Antoniou
Hi Jason,

> On Jan 21, 2015, at 22:27 , Jason Gunthorpe  
> wrote:
> 
> On Wed, Jan 21, 2015 at 06:33:12PM +0200, Pantelis Antoniou wrote:
>> Hi Alan,
>> 
>>> On Jan 21, 2015, at 18:01 , One Thousand Gnomes 
>>>  wrote:
>>> 
>>> On Thu, 15 Jan 2015 22:54:46 +0200
>>> Pantelis Antoniou  wrote:
>>> 
 Hi Alan,
 
> On Jan 15, 2015, at 22:45 , One Thousand Gnomes 
>  wrote:
> 
> On Thu, 15 Jan 2015 11:47:26 -0700
> Jason Gunthorpe  wrote:
>> It is a novel idea, my concern would be that embedding the FPGA in the
>> DT makes it permanent unswappable kernel memory.
>> Not having the kernel hold the FPGA is best for many uses.
> 
> If you have a filesysytem before the FPGA is set up then it belongs in
> the file system. As you presumably loaded the kernel from somewhere there
> ought to be a file system (even an initrd).
> 
 
 Request firmware does not imply keeping it around. You can always 
 re-request
 when reloading (although there’s a nasty big of caching that needs to be
 resolved with the firmware loader).
>>> 
>>> Which comes down to the same thing. Unless you can prove that there is a
>>> path to recover the firmware file that does not have any dependancies
>>> upon the firmware executing (and those can be subtle and horrid at times)
>>> you need to keep it around for suspend/resume at least and potentially
>>> any unexpected error/reset.
>>> 
>> 
>> In that case the only safe place to put it is in the kernel image itself, 
>> which
>> is something the firmware loader already supports.
> 
> My point is that the current firmware layer is overly cautious and
> FPGAs are very big. My current project on small Xilinx device has a
> 10MB programming file. The biggest Xilinx device today has a max
> bitfile size around 122MB.
> 
> So keeping that much memory pinned in the kernel when I can prove it
> is uncessary for my system (either because there is no suspend/resume
> possibility, or because I know the CPU can always access the
> filesytem) is very undesirable.
> 
> Other systems might have to take the ram hit.
> 
> Since it seems like the kernel has no way to know, we probably have
> have a way to tell it not to cache the bitfile.
> 

The firmware loader was not originally meant to handle these cases, but
I’m sure it’s not an insurmountable obstacle.

> Jason

Regards

— Pantelis

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


[PATCH] checkpatch: Add types for other OS typedefs

2015-01-21 Thread Joe Perches
bsd and sysv use different typedefs for unsigned types.

These are in types.h but not in checkpatch, so add them
to checkpatch's ability to know types.

This can avoid false positives for code like:

void foo(void)
{
int x;
uint y;

[...];
}

where checkpatch incorrectly emits a warning for
"missing a blank line after declarations".

Signed-off-by: Joe Perches 
---
 scripts/checkpatch.pl | 8 
 1 file changed, 8 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 41223c9..fadb47d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -339,6 +339,11 @@ our $UTF8  = qr{
| $NON_ASCII_UTF8
 }x;
 
+our $typeOtherOSTypedefs = qr{(?x:
+   u_(?:char|short|int|long) |  # bsd
+   u(?:nchar|short|int|long)# sysv
+)};
+
 our $typeTypedefs = qr{(?x:
(?:__)?(?:u|s|be|le)(?:8|16|32|64)|
atomic_t
@@ -475,6 +480,7 @@ sub build_types {
(?:$Modifier\s+|const\s+)*
(?:
(?:typeof|__typeof__)\s*\([^\)]*\)|
+   (?:$typeOtherOSTypedefs\b)|
(?:$typeTypedefs\b)|
(?:${all}\b)
)
@@ -492,6 +498,7 @@ sub build_types {
(?:
(?:typeof|__typeof__)\s*\([^\)]*\)|
(?:$typeTypedefs\b)|
+   (?:$typeOtherOSTypedefs\b)|
(?:${allWithAttr}\b)
)
(?:\s+$Modifier|\s+const)*
@@ -3152,6 +3159,7 @@ sub process {
$line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ &&
$line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ &&
$line !~ /\b$typeTypedefs\b/ &&
+   $line !~ /\b$typeOtherOSTypedefs\b/ &&
$line !~ /\b__bitwise(?:__|)\b/) {
WARN("NEW_TYPEDEFS",
 "do not add new typedefs\n" . $herecurr);


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


[PATCH 2/6] staging: comedi: ni_labpc_cs: remove unnecessary includes

2015-01-21 Thread H Hartley Sweeten
This driver includes a number of unnecessary headers. Remove them.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_labpc_cs.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c 
b/drivers/staging/comedi/drivers/ni_labpc_cs.c
index d58f1f9..ece0010 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_cs.c
+++ b/drivers/staging/comedi/drivers/ni_labpc_cs.c
@@ -54,19 +54,15 @@ NI manuals:
 */
 
 #include 
-#include "../comedidev.h"
-
-#include 
 
-#include "8253.h"
-#include "8255.h"
-#include "comedi_fc.h"
-#include "ni_labpc.h"
+#include "../comedidev.h"
 
 #include 
 #include 
 #include 
 
+#include "ni_labpc.h"
+
 static const struct labpc_boardinfo labpc_cs_boards[] = {
{
.name   = "daqcard-1200",
-- 
2.0.3

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


[PATCH 0/6] staging: comedi: ni_labpc: misc cleanup

2015-01-21 Thread H Hartley Sweeten
A couple misc patches for the ni_labpc drivers.

H Hartley Sweeten (6):
  staging: comedi: ni_labpc_common: move comedi_alloc_devpriv() to common code
  staging: comedi: ni_labpc_cs: remove unnecessary includes
  staging: comedi: ni_labpc: remove unnecessary private data validation
  staging: comedi: ni_labpc_common: use DIV_ROUND_UP to round divisor values
  staging: comedi: ni_labpc_common: use DIV_ROUND_CLOSEST to round divisor 
values
  staging: comedi: ni_labpc_common: use the cfc_check_trigger_arg_*() helpers

 drivers/staging/comedi/drivers/ni_labpc.c| 11 +-
 drivers/staging/comedi/drivers/ni_labpc_common.c | 47 +++-
 drivers/staging/comedi/drivers/ni_labpc_cs.c | 15 ++--
 drivers/staging/comedi/drivers/ni_labpc_pci.c|  5 ---
 4 files changed, 25 insertions(+), 53 deletions(-)

-- 
2.0.3

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


[PATCH 4/6] staging: comedi: ni_labpc_common: use DIV_ROUND_UP to round divisor values

2015-01-21 Thread H Hartley Sweeten
Use the DIV_ROUND_UP macro to clarify the (((n) + (d) - 1) / (d)) calculations.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_labpc_common.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c 
b/drivers/staging/comedi/drivers/ni_labpc_common.c
index 3cd200a..c494c53 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_common.c
+++ b/drivers/staging/comedi/drivers/ni_labpc_common.c
@@ -406,10 +406,10 @@ static void labpc_adc_timing(struct comedi_device *dev, 
struct comedi_cmd *cmd,
(scan_period + (base_period / 2)) / base_period;
break;
case CMDF_ROUND_UP:
-   devpriv->divisor_a0 =
-   (convert_period + (base_period - 1)) / base_period;
-   devpriv->divisor_b1 =
-   (scan_period + (base_period - 1)) / base_period;
+   devpriv->divisor_a0 = DIV_ROUND_UP(convert_period,
+  base_period);
+   devpriv->divisor_b1 = DIV_ROUND_UP(scan_period,
+  base_period);
break;
case CMDF_ROUND_DOWN:
devpriv->divisor_a0 = convert_period / base_period;
-- 
2.0.3

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


[PATCH 6/6] staging: comedi: ni_labpc_common: use the cfc_check_trigger_arg_*() helpers

2015-01-21 Thread H Hartley Sweeten
For aesthetics, use the helper functions to check the min/max divisor values.
Remove the const int local variables and open code the values.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_labpc_common.c | 25 
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c 
b/drivers/staging/comedi/drivers/ni_labpc_common.c
index 77a7856..b88ee26 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_common.c
+++ b/drivers/staging/comedi/drivers/ni_labpc_common.c
@@ -368,10 +368,6 @@ static void labpc_adc_timing(struct comedi_device *dev, 
struct comedi_cmd *cmd,
 enum scan_mode mode)
 {
struct labpc_private *devpriv = dev->private;
-   /* max value for 16 bit counter in mode 2 */
-   const int max_counter_value = 0x1;
-   /* min value for 16 bit counter in mode 2 */
-   const int min_counter_value = 2;
unsigned int base_period;
unsigned int scan_period;
unsigned int convert_period;
@@ -388,11 +384,10 @@ static void labpc_adc_timing(struct comedi_device *dev, 
struct comedi_cmd *cmd,
 * clock speed on convert and scan counters)
 */
devpriv->divisor_b0 = (scan_period - 1) /
-   (I8254_OSC_BASE_2MHZ * max_counter_value) + 1;
-   if (devpriv->divisor_b0 < min_counter_value)
-   devpriv->divisor_b0 = min_counter_value;
-   if (devpriv->divisor_b0 > max_counter_value)
-   devpriv->divisor_b0 = max_counter_value;
+   (I8254_OSC_BASE_2MHZ * 0x1) + 1;
+
+   cfc_check_trigger_arg_min(&devpriv->divisor_b0, 2);
+   cfc_check_trigger_arg_max(&devpriv->divisor_b0, 0x1);
 
base_period = I8254_OSC_BASE_2MHZ * devpriv->divisor_b0;
 
@@ -417,14 +412,10 @@ static void labpc_adc_timing(struct comedi_device *dev, 
struct comedi_cmd *cmd,
break;
}
/*  make sure a0 and b1 values are acceptable */
-   if (devpriv->divisor_a0 < min_counter_value)
-   devpriv->divisor_a0 = min_counter_value;
-   if (devpriv->divisor_a0 > max_counter_value)
-   devpriv->divisor_a0 = max_counter_value;
-   if (devpriv->divisor_b1 < min_counter_value)
-   devpriv->divisor_b1 = min_counter_value;
-   if (devpriv->divisor_b1 > max_counter_value)
-   devpriv->divisor_b1 = max_counter_value;
+   cfc_check_trigger_arg_min(&devpriv->divisor_a0, 2);
+   cfc_check_trigger_arg_max(&devpriv->divisor_a0, 0x1);
+   cfc_check_trigger_arg_min(&devpriv->divisor_b1, 2);
+   cfc_check_trigger_arg_max(&devpriv->divisor_b1, 0x1);
/*  write corrected timings to command */
labpc_set_ai_convert_period(cmd, mode,
base_period * devpriv->divisor_a0);
-- 
2.0.3

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


[PATCH 5/6] staging: comedi: ni_labpc_common: use DIV_ROUND_CLOSEST to round divisor values

2015-01-21 Thread H Hartley Sweeten
Use the DIV_ROUND_CLOSEST macro to clarify the (((x) + ((divisor) / 2)) / 
(divisor))
calculations.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_labpc_common.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c 
b/drivers/staging/comedi/drivers/ni_labpc_common.c
index c494c53..77a7856 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_common.c
+++ b/drivers/staging/comedi/drivers/ni_labpc_common.c
@@ -400,10 +400,10 @@ static void labpc_adc_timing(struct comedi_device *dev, 
struct comedi_cmd *cmd,
switch (cmd->flags & CMDF_ROUND_MASK) {
default:
case CMDF_ROUND_NEAREST:
-   devpriv->divisor_a0 =
-   (convert_period + (base_period / 2)) / base_period;
-   devpriv->divisor_b1 =
-   (scan_period + (base_period / 2)) / base_period;
+   devpriv->divisor_a0 = DIV_ROUND_CLOSEST(convert_period,
+   base_period);
+   devpriv->divisor_b1 = DIV_ROUND_CLOSEST(scan_period,
+   base_period);
break;
case CMDF_ROUND_UP:
devpriv->divisor_a0 = DIV_ROUND_UP(convert_period,
-- 
2.0.3

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


[PATCH 1/6] staging: comedi: ni_labpc_common: move comedi_alloc_devpriv() to common code

2015-01-21 Thread H Hartley Sweeten
The ni_labpc_common module is used by the ni_labpc, ni_labpc_pci, and 
ni_labpc_cs
drivers to provide the common code support. Those drivers currently all call
comedi_alloc_devpriv() to allocate the private data before calling the common
attach function.

For aesthetics, move the private data allocation into the common code.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_labpc.c| 5 -
 drivers/staging/comedi/drivers/ni_labpc_common.c | 6 +-
 drivers/staging/comedi/drivers/ni_labpc_cs.c | 5 -
 drivers/staging/comedi/drivers/ni_labpc_pci.c| 5 -
 4 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_labpc.c 
b/drivers/staging/comedi/drivers/ni_labpc.c
index 59da404..e7b25e8 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -84,15 +84,10 @@ static const struct labpc_boardinfo labpc_boards[] = {
 
 static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
-   struct labpc_private *devpriv;
unsigned int irq = it->options[1];
unsigned int dma_chan = it->options[2];
int ret;
 
-   devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
-   if (!devpriv)
-   return -ENOMEM;
-
ret = comedi_request_region(dev, it->options[0], 0x20);
if (ret)
return ret;
diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c 
b/drivers/staging/comedi/drivers/ni_labpc_common.c
index 8fb5c1f..3cd200a 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_common.c
+++ b/drivers/staging/comedi/drivers/ni_labpc_common.c
@@ -1215,11 +1215,15 @@ int labpc_common_attach(struct comedi_device *dev,
unsigned int irq, unsigned long isr_flags)
 {
const struct labpc_boardinfo *board = dev->board_ptr;
-   struct labpc_private *devpriv = dev->private;
+   struct labpc_private *devpriv;
struct comedi_subdevice *s;
int ret;
int i;
 
+   devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
+   if (!devpriv)
+   return -ENOMEM;
+
if (dev->mmio) {
devpriv->read_byte = labpc_readb;
devpriv->write_byte = labpc_writeb;
diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c 
b/drivers/staging/comedi/drivers/ni_labpc_cs.c
index 0a8b322..d58f1f9 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_cs.c
+++ b/drivers/staging/comedi/drivers/ni_labpc_cs.c
@@ -80,7 +80,6 @@ static int labpc_auto_attach(struct comedi_device *dev,
 unsigned long context)
 {
struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
-   struct labpc_private *devpriv;
int ret;
 
/* The ni_labpc driver needs the board_ptr */
@@ -96,10 +95,6 @@ static int labpc_auto_attach(struct comedi_device *dev,
if (!link->irq)
return -EINVAL;
 
-   devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
-   if (!devpriv)
-   return -ENOMEM;
-
return labpc_common_attach(dev, link->irq, IRQF_SHARED);
 }
 
diff --git a/drivers/staging/comedi/drivers/ni_labpc_pci.c 
b/drivers/staging/comedi/drivers/ni_labpc_pci.c
index a9f408a..0407ff6 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_pci.c
+++ b/drivers/staging/comedi/drivers/ni_labpc_pci.c
@@ -79,7 +79,6 @@ static int labpc_pci_auto_attach(struct comedi_device *dev,
 {
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
const struct labpc_boardinfo *board = NULL;
-   struct labpc_private *devpriv;
int ret;
 
if (context < ARRAY_SIZE(labpc_pci_boards))
@@ -101,10 +100,6 @@ static int labpc_pci_auto_attach(struct comedi_device *dev,
if (!dev->mmio)
return -ENOMEM;
 
-   devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
-   if (!devpriv)
-   return -ENOMEM;
-
return labpc_common_attach(dev, pcidev->irq, IRQF_SHARED);
 }
 
-- 
2.0.3

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


[PATCH 3/6] staging: comedi: ni_labpc: remove unnecessary private data validation

2015-01-21 Thread H Hartley Sweeten
The labpc_free_dma_chan() function validates the private data. Remove the
unnecessary validation in labpc_datach().

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_labpc.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_labpc.c 
b/drivers/staging/comedi/drivers/ni_labpc.c
index e7b25e8..a916047 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -104,11 +104,7 @@ static int labpc_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
 
 static void labpc_detach(struct comedi_device *dev)
 {
-   struct labpc_private *devpriv = dev->private;
-
-   if (devpriv)
-   labpc_free_dma_chan(dev);
-
+   labpc_free_dma_chan(dev);
comedi_legacy_detach(dev);
 }
 
-- 
2.0.3

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


[PATCH 0/2] staging: comedi: vmk80xx: misc cleanup

2015-01-21 Thread H Hartley Sweeten
A couple cleanup patches for the vmk80xx driver.

H Hartley Sweeten (2):
  staging: comedi: vmk80xx: GPCT_RESET is not an (*insn_config) instruction
  staging: comedi: vmk80xx: tidy up vmk80xx_cnt_insn_config()

 drivers/staging/comedi/drivers/vmk80xx.c | 46 ++--
 1 file changed, 20 insertions(+), 26 deletions(-)

-- 
2.0.3

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


[PATCH 1/2] staging: comedi: vmk80xx: GPCT_RESET is not an (*insn_config) instruction

2015-01-21 Thread H Hartley Sweeten
The data[0] parameter to (*insn_config) functions is the "configuration 
instruction"
that should be handled. These are defined by the enum configuration_ids in 
comedi.h.

This driver is currently checking the data[0] value to be INSN_CONFIG_RESET or
GPCT_RESET in order to reset a counter channel. GPCT_RESET is defined as 0x0001
which would match the configuration instruction INSN_CONFIG_DIO_OUTPUT. That 
doesn't
make any sense for a counter.

Remove GPCT_RESET from the insn_cmd test.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/vmk80xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/vmk80xx.c 
b/drivers/staging/comedi/drivers/vmk80xx.c
index 5312e0f..d200ad5 100644
--- a/drivers/staging/comedi/drivers/vmk80xx.c
+++ b/drivers/staging/comedi/drivers/vmk80xx.c
@@ -558,7 +558,7 @@ static int vmk80xx_cnt_insn_config(struct comedi_device 
*dev,
int n;
 
insn_cmd = data[0];
-   if (insn_cmd != INSN_CONFIG_RESET && insn_cmd != GPCT_RESET)
+   if (insn_cmd != INSN_CONFIG_RESET)
return -EINVAL;
 
down(&devpriv->limit_sem);
-- 
2.0.3

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


[PATCH 2/2] staging: comedi: vmk80xx: tidy up vmk80xx_cnt_insn_config()

2015-01-21 Thread H Hartley Sweeten
Tidy up this (*insn_config) function to follow the normal format in
comedi drivers.

INSN_CONFIG_RESET instructions do not have any extra parameters (insn->n is
always 1) so the for loop used to write the packet doesn't make any sense.
Remove it and just write the single packet.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/vmk80xx.c | 46 ++--
 1 file changed, 20 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/comedi/drivers/vmk80xx.c 
b/drivers/staging/comedi/drivers/vmk80xx.c
index d200ad5..eb76460 100644
--- a/drivers/staging/comedi/drivers/vmk80xx.c
+++ b/drivers/staging/comedi/drivers/vmk80xx.c
@@ -551,41 +551,35 @@ static int vmk80xx_cnt_insn_config(struct comedi_device 
*dev,
   unsigned int *data)
 {
struct vmk80xx_private *devpriv = dev->private;
-   unsigned int insn_cmd;
-   int chan;
+   unsigned int chan = CR_CHAN(insn->chanspec);
int cmd;
int reg;
-   int n;
-
-   insn_cmd = data[0];
-   if (insn_cmd != INSN_CONFIG_RESET)
-   return -EINVAL;
+   int ret;
 
down(&devpriv->limit_sem);
-
-   chan = CR_CHAN(insn->chanspec);
-
-   if (devpriv->model == VMK8055_MODEL) {
-   if (!chan) {
-   cmd = VMK8055_CMD_RST_CNT1;
-   reg = VMK8055_CNT1_REG;
+   switch (data[0]) {
+   case INSN_CONFIG_RESET:
+   if (devpriv->model == VMK8055_MODEL) {
+   if (!chan) {
+   cmd = VMK8055_CMD_RST_CNT1;
+   reg = VMK8055_CNT1_REG;
+   } else {
+   cmd = VMK8055_CMD_RST_CNT2;
+   reg = VMK8055_CNT2_REG;
+   }
+   devpriv->usb_tx_buf[reg] = 0x00;
} else {
-   cmd = VMK8055_CMD_RST_CNT2;
-   reg = VMK8055_CNT2_REG;
+   cmd = VMK8061_CMD_RST_CNT;
}
-
-   devpriv->usb_tx_buf[reg] = 0x00;
-   } else {
-   cmd = VMK8061_CMD_RST_CNT;
+   ret = vmk80xx_write_packet(dev, cmd);
+   break;
+   default:
+   ret = -EINVAL;
+   break;
}
-
-   for (n = 0; n < insn->n; n++)
-   if (vmk80xx_write_packet(dev, cmd))
-   break;
-
up(&devpriv->limit_sem);
 
-   return n;
+   return ret ? ret : insn->n;
 }
 
 static int vmk80xx_cnt_insn_write(struct comedi_device *dev,
-- 
2.0.3

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


Re: [PATCH] staging: rts5028: use msecs_to_jiffies for timeouts

2015-01-21 Thread 敬锐
the title should be 5208.

On 01/19/2015 03:25 PM, Nicholas Mc Guire wrote:
> This is only an API consolidation and should make things more readable
>
> Signed-off-by: Nicholas Mc Guire 
> ---
>
> Converting milliseconds to jiffies by val * HZ / 1000 is technically
> not wrong but msecs_to_jiffies(val) is the cleaner solution and handles
> corner cases correctly.
>
> This patch was only compile tested with x86_64_defconfig + CONFIG_STAGING=y,
> CONFIG_RTS5208=m
>
> Patch is against 3.19.0-rc4 -next-20150116
>
>   drivers/staging/rts5208/rtsx_transport.c |   12 ++--
>   1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/staging/rts5208/rtsx_transport.c 
> b/drivers/staging/rts5208/rtsx_transport.c
> index 756a968..dab1995 100644
> --- a/drivers/staging/rts5208/rtsx_transport.c
> +++ b/drivers/staging/rts5208/rtsx_transport.c
> @@ -271,7 +271,7 @@ int rtsx_send_cmd(struct rtsx_chip *chip, u8 card, int 
> timeout)
>   
>   /* Wait for TRANS_OK_INT */
>   timeleft = wait_for_completion_interruptible_timeout(
> - &trans_done, timeout * HZ / 1000);
> + &trans_done, msecs_to_jiffies(timeout));
>   if (timeleft <= 0) {
>   dev_dbg(rtsx_dev(chip), "chip->int_reg = 0x%x\n",
>   chip->int_reg);
> @@ -431,7 +431,7 @@ static int rtsx_transfer_sglist_adma_partial(struct 
> rtsx_chip *chip, u8 card,
>   spin_unlock_irq(&rtsx->reg_lock);
>   
>   timeleft = wait_for_completion_interruptible_timeout(
> - &trans_done, timeout * HZ / 1000);
> + &trans_done, msecs_to_jiffies(timeout));
>   if (timeleft <= 0) {
>   dev_dbg(rtsx_dev(chip), "Timeout (%s %d)\n",
>   __func__, __LINE__);
> @@ -455,7 +455,7 @@ static int rtsx_transfer_sglist_adma_partial(struct 
> rtsx_chip *chip, u8 card,
>   init_completion(&trans_done);
>   spin_unlock_irq(&rtsx->reg_lock);
>   timeleft = wait_for_completion_interruptible_timeout(
> - &trans_done, timeout * HZ / 1000);
> + &trans_done, msecs_to_jiffies(timeout));
>   if (timeleft <= 0) {
>   dev_dbg(rtsx_dev(chip), "Timeout (%s %d)\n",
>   __func__, __LINE__);
> @@ -575,7 +575,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip 
> *chip, u8 card,
>   spin_unlock_irq(&rtsx->reg_lock);
>   
>   timeleft = wait_for_completion_interruptible_timeout(
> - &trans_done, timeout * HZ / 1000);
> + &trans_done, msecs_to_jiffies(timeout));
>   if (timeleft <= 0) {
>   dev_dbg(rtsx_dev(chip), "Timeout (%s %d)\n",
>   __func__, __LINE__);
> @@ -602,7 +602,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip 
> *chip, u8 card,
>   init_completion(&trans_done);
>   spin_unlock_irq(&rtsx->reg_lock);
>   timeleft = wait_for_completion_interruptible_timeout(
> - &trans_done, timeout * HZ / 1000);
> + &trans_done, msecs_to_jiffies(timeout));
>   if (timeleft <= 0) {
>   dev_dbg(rtsx_dev(chip), "Timeout (%s %d)\n",
>   __func__, __LINE__);
> @@ -688,7 +688,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 
> card, void *buf,
>   
>   /* Wait for TRANS_OK_INT */
>   timeleft = wait_for_completion_interruptible_timeout(
> - &trans_done, timeout * HZ / 1000);
> + &trans_done, msecs_to_jiffies(timeout));
>   if (timeleft <= 0) {
>   dev_dbg(rtsx_dev(chip), "Timeout (%s %d)\n",
>   __func__, __LINE__);
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


BANK TRANSFER NOTIFICATION

2015-01-21 Thread ALPHA BANK PLC
RE: RELEASE/TRANSFER NOTICE OF YOUR APPROVED FUNDS ($800,000.00USD)
COMPENSATION FUND FROM UNITED NATION, WORLD BANK,EUROPEAN UNION AND
AFRICA UNION. YOU ARE TO CONTACT THE FUNDS TRANSFER MANAGER MR ERIC MOORE
FOR MORE INFORMATION'S ON HOW YOU CAN RECEIVED YOUR FUND AND FORWARD TO
HIM YOUR
FULL DETAILS FOR QUICK ONLINE TRANSFER.

FULL NAME:
COMPLETE ADDRESS:
PHONE NUMBER:

MR ERIC MOORE
MANAGING DIRECTOR
FUNDS TRANSFER DIRECTOR

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


Re: [PATCH 55/69] staging: unisys: get rid of LOGWRN() macro and uisklog.h

2015-01-21 Thread Greg KH
On Wed, Jan 21, 2015 at 06:53:31PM +0300, Dan Carpenter wrote:
> Generally "delete code" patches are easy to review.  But sometimes you
> have to change formatting and remove variables and curly braces.
> 
> $ grep LOG drivers/staging/unisys/ -R | wc -l
> 415
> 
> There isn't a firm rule on way a patch is just too big and annoying to
> review.  Probably break it up into:
> 
> [patch 1/x] delete LOGINF()
> [patch 2/x] delete LOGERR()
> ...

Yes, this would be best.

Always remember, what would you like to have to review if you were the
receiver of patches?

thanks,

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


[PATCH] staging: rtl8712: remove unused function

2015-01-21 Thread Sudip Mukherjee
mp_query_drv_var() was only being used by
oid_rt_pro_query_dr_variable_hdl() but after commit
 mp_query_drv_var() became
unused. so it is safe to remove it.

Signed-off-by: Sudip Mukherjee 
---
 drivers/staging/rtl8712/rtl871x_mp_ioctl.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c 
b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c
index 49fa1d1..0b54612 100644
--- a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c
+++ b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c
@@ -704,13 +704,6 @@ uint oid_rt_get_thermal_meter_hdl(struct oid_par_priv 
*poid_par_priv)
return RNDIS_STATUS_SUCCESS;
 }
 
-/*--*/
-static u32 mp_query_drv_var(struct _adapter *padapter, u8 offset, u32 var)
-{
-   return var;
-}
-
-/**/
 uint oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv)
 {
struct _adapter *Adapter = (struct _adapter *)
-- 
1.8.1.2

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


[PATCH v2 1/9] mfd: rtsx: replace TAB by SPC after #define

2015-01-21 Thread micky_ching
From: Micky Ching 

Re-format coding-style, using uniform SPC after "#define" keyword
instead of mixing using TAB and SPC.

Signed-off-by: Micky Ching 
---
 include/linux/mfd/rtsx_pci.h | 254 +--
 1 file changed, 127 insertions(+), 127 deletions(-)

diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
index 0c12628..a9c2a14 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -175,9 +175,9 @@
 /* CARD_SHARE_MODE */
 #define CARD_SHARE_MASK0x0F
 #define CARD_SHARE_MULTI_LUN   0x00
-#defineCARD_SHARE_NORMAL   0x00
-#defineCARD_SHARE_48_SD0x04
-#defineCARD_SHARE_48_MS0x08
+#define CARD_SHARE_NORMAL  0x00
+#define CARD_SHARE_48_SD   0x04
+#define CARD_SHARE_48_MS   0x08
 /* CARD_SHARE_MODE for barossa */
 #define CARD_SHARE_BAROSSA_SD  0x01
 #define CARD_SHARE_BAROSSA_MS  0x02
@@ -249,76 +249,76 @@
 #define CD_AUTO_DISABLE0x40
 
 /* SD_STAT1 */
-#defineSD_CRC7_ERR 0x80
-#defineSD_CRC16_ERR0x40
-#defineSD_CRC_WRITE_ERR0x20
-#defineSD_CRC_WRITE_ERR_MASK   0x1C
-#defineGET_CRC_TIME_OUT0x02
-#defineSD_TUNING_COMPARE_ERR   0x01
+#define SD_CRC7_ERR0x80
+#define SD_CRC16_ERR   0x40
+#define SD_CRC_WRITE_ERR   0x20
+#define SD_CRC_WRITE_ERR_MASK  0x1C
+#define GET_CRC_TIME_OUT   0x02
+#define SD_TUNING_COMPARE_ERR  0x01
 
 /* SD_STAT2 */
-#defineSD_RSP_80CLK_TIMEOUT0x01
+#define SD_RSP_80CLK_TIMEOUT   0x01
 
 /* SD_BUS_STAT */
-#defineSD_CLK_TOGGLE_EN0x80
-#defineSD_CLK_FORCE_STOP   0x40
-#defineSD_DAT3_STATUS  0x10
-#defineSD_DAT2_STATUS  0x08
-#defineSD_DAT1_STATUS  0x04
-#defineSD_DAT0_STATUS  0x02
-#defineSD_CMD_STATUS   0x01
+#define SD_CLK_TOGGLE_EN   0x80
+#define SD_CLK_FORCE_STOP  0x40
+#define SD_DAT3_STATUS 0x10
+#define SD_DAT2_STATUS 0x08
+#define SD_DAT1_STATUS 0x04
+#define SD_DAT0_STATUS 0x02
+#define SD_CMD_STATUS  0x01
 
 /* SD_PAD_CTL */
-#defineSD_IO_USING_1V8 0x80
-#defineSD_IO_USING_3V3 0x7F
-#defineTYPE_A_DRIVING  0x00
-#defineTYPE_B_DRIVING  0x01
-#defineTYPE_C_DRIVING  0x02
-#defineTYPE_D_DRIVING  0x03
+#define SD_IO_USING_1V80x80
+#define SD_IO_USING_3V30x7F
+#define TYPE_A_DRIVING 0x00
+#define TYPE_B_DRIVING 0x01
+#define TYPE_C_DRIVING 0x02
+#define TYPE_D_DRIVING 0x03
 
 /* SD_SAMPLE_POINT_CTL */
-#defineDDR_FIX_RX_DAT  0x00
-#defineDDR_VAR_RX_DAT  0x80
-#defineDDR_FIX_RX_DAT_EDGE 0x00
-#defineDDR_FIX_RX_DAT_14_DELAY 0x40
-#defineDDR_FIX_RX_CMD  0x00
-#defineDDR_VAR_RX_CMD  0x20
-#defineDDR_FIX_RX_CMD_POS_EDGE 0x00
-#defineDDR_FIX_RX_CMD_14_DELAY 0x10
-#defineSD20_RX_POS_EDGE0x00
-#defineSD20_RX_14_DELAY0x08
+#define DDR_FIX_RX_DAT 0x00
+#define DDR_VAR_RX_DAT 0x80
+#define DDR_FIX_RX_DAT_EDGE0x00
+#define DDR_FIX_RX_DAT_14_DELAY0x40
+#define DDR_FIX_RX_CMD 0x00
+#define DDR_VAR_RX_CMD 0x20
+#define DDR_FIX_RX_CMD_POS_EDGE0x00
+#define DDR_FIX_RX_CMD_14_DELAY0x10
+#define SD20_RX_POS_EDGE   0x00
+#define SD20_RX_14_DELAY   0x08
 #define SD20_RX_SEL_MASK   0x08
 
 /* SD_PUSH_POINT_CTL */
-#defineDDR_FIX_TX_CMD_DAT  0x00
-#defineDDR_VAR_TX_CMD_DAT  0x80
-#defineDDR_FIX_TX_DAT_14_TSU   0x00
-#defineDDR_FIX_TX_DAT_12_TSU   0x40
-#defineDDR_FIX_TX_CMD_NEG_EDGE 0x00
-#defineDDR_FIX_TX_CMD_14_AHEAD 0x20
-#defineSD20_TX_NEG_EDGE0x00
-#defineSD20_TX_14_AHEAD0x10
+#define DDR_FIX_TX_CMD_DAT 0x00
+#define DDR_VAR_TX_CMD_DAT 0x80
+#define DDR_FIX_TX_DAT_14_TSU  0x00
+#define DDR_FIX_TX_DAT_12_TSU  0x40
+#define DDR_FIX_TX_CMD_NEG_EDGE0x00
+#define DDR_FIX_TX_CMD_14_AHEAD0x20
+#define SD20_TX_NEG_EDGE

[PATCH v2 3/9] mfd: rtsx: update PETXCFG address

2015-01-21 Thread micky_ching
From: Micky Ching 

PETXCFG is defined at 0xFF03, the old 0xFE49 not used any more.

Signed-off-by: Micky Ching 
---
 drivers/mfd/rts5227.c| 6 ++
 drivers/mfd/rts5249.c| 6 ++
 include/linux/mfd/rtsx_pci.h | 2 +-
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c
index 3240740..1f387d4 100644
--- a/drivers/mfd/rts5227.c
+++ b/drivers/mfd/rts5227.c
@@ -118,11 +118,9 @@ static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)
rts5227_fill_driving(pcr, OUTPUT_3V3);
/* Configure force_clock_req */
if (pcr->flags & PCR_REVERSE_SOCKET)
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
-   AUTOLOAD_CFG_BASE + 3, 0xB8, 0xB8);
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB8, 0xB8);
else
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
-   AUTOLOAD_CFG_BASE + 3, 0xB8, 0x88);
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB8, 0x88);
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PM_CTRL3, 0x10, 0x00);
 
return rtsx_pci_send_cmd(pcr, 100);
diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
index cf425cc..225ad55 100644
--- a/drivers/mfd/rts5249.c
+++ b/drivers/mfd/rts5249.c
@@ -116,11 +116,9 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)
/* Configure driving */
rts5249_fill_driving(pcr, OUTPUT_3V3);
if (pcr->flags & PCR_REVERSE_SOCKET)
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
-   AUTOLOAD_CFG_BASE + 3, 0xB0, 0xB0);
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB0, 0xB0);
else
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
-   AUTOLOAD_CFG_BASE + 3, 0xB0, 0x80);
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB0, 0x80);
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PM_CTRL3, 0x10, 0x00);
 
return rtsx_pci_send_cmd(pcr, 100);
diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
index e81f2bb..87cff60 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -572,7 +572,6 @@
 #define MSGTXDATA2 0xFE46
 #define MSGTXDATA3 0xFE47
 #define MSGTXCTL   0xFE48
-#define PETXCFG0xFE49
 #define LTR_CTL0xFE4A
 #define OBFF_CFG   0xFE4C
 
@@ -606,6 +605,7 @@
 #define DUMMY_REG_RESET_0  0xFE90
 
 #define AUTOLOAD_CFG_BASE  0xFF00
+#define PETXCFG0xFF03
 
 #define PM_CTRL1   0xFF44
 #define PM_CTRL2   0xFF45
-- 
1.9.1

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


[PATCH v2 5/9] mfd: rtsx: update phy register

2015-01-21 Thread micky_ching
From: Micky Ching 

update phy register value and using direct value instead of macros.
It is much easier to debug using constant value than a lot of macros.
We usually need compare the value directly to check the configure.

Signed-off-by: Micky Ching 
---
 drivers/mfd/rts5249.c|  55 --
 include/linux/mfd/rtsx_pci.h | 109 ++-
 2 files changed, 85 insertions(+), 79 deletions(-)

diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
index 2fe2854..d8072f6 100644
--- a/drivers/mfd/rts5249.c
+++ b/drivers/mfd/rts5249.c
@@ -132,57 +132,62 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
if (err < 0)
return err;
 
-   err = rtsx_pci_write_phy_register(pcr, PHY_REG_REV,
-   PHY_REG_REV_RESV | PHY_REG_REV_RXIDLE_LATCHED |
-   PHY_REG_REV_P1_EN | PHY_REG_REV_RXIDLE_EN |
-   PHY_REG_REV_RX_PWST | PHY_REG_REV_CLKREQ_DLY_TIMER_1_0 |
-   PHY_REG_REV_STOP_CLKRD | PHY_REG_REV_STOP_CLKWR);
+   err = rtsx_pci_write_phy_register(pcr, PHY_REV,
+   PHY_REV_RESV | PHY_REV_RXIDLE_LATCHED |
+   PHY_REV_P1_EN | PHY_REV_RXIDLE_EN |
+   PHY_REV_CLKREQ_TX_EN | PHY_REV_RX_PWST |
+   PHY_REV_CLKREQ_DT_1_0 | PHY_REV_STOP_CLKRD |
+   PHY_REV_STOP_CLKWR);
if (err < 0)
return err;
 
msleep(1);
 
err = rtsx_pci_write_phy_register(pcr, PHY_BPCR,
-   PHY_BPCR_IBRXSEL | PHY_BPCR_IBTXSEL |
-   PHY_BPCR_IB_FILTER | PHY_BPCR_CMIRROR_EN);
+   PHY_BPCR_IBRXSEL | PHY_BPCR_IBTXSEL |
+   PHY_BPCR_IB_FILTER | PHY_BPCR_CMIRROR_EN);
if (err < 0)
return err;
+
err = rtsx_pci_write_phy_register(pcr, PHY_PCR,
-   PHY_PCR_FORCE_CODE | PHY_PCR_OOBS_CALI_50 |
-   PHY_PCR_OOBS_VCM_08 | PHY_PCR_OOBS_SEN_90 |
-   PHY_PCR_RSSI_EN);
+   PHY_PCR_FORCE_CODE | PHY_PCR_OOBS_CALI_50 |
+   PHY_PCR_OOBS_VCM_08 | PHY_PCR_OOBS_SEN_90 |
+   PHY_PCR_RSSI_EN | PHY_PCR_RX10K);
if (err < 0)
return err;
+
err = rtsx_pci_write_phy_register(pcr, PHY_RCR2,
-   PHY_RCR2_EMPHASE_EN | PHY_RCR2_NADJR |
-   PHY_RCR2_CDR_CP_10 | PHY_RCR2_CDR_SR_2 |
-   PHY_RCR2_FREQSEL_12 | PHY_RCR2_CPADJEN |
-   PHY_RCR2_CDR_SC_8 | PHY_RCR2_CALIB_LATE);
+   PHY_RCR2_EMPHASE_EN | PHY_RCR2_NADJR |
+   PHY_RCR2_CDR_SR_2 | PHY_RCR2_FREQSEL_12 |
+   PHY_RCR2_CDR_SC_12P | PHY_RCR2_CALIB_LATE);
if (err < 0)
return err;
+
err = rtsx_pci_write_phy_register(pcr, PHY_FLD4,
-   PHY_FLD4_FLDEN_SEL | PHY_FLD4_REQ_REF |
-   PHY_FLD4_RXAMP_OFF | PHY_FLD4_REQ_ADDA |
-   PHY_FLD4_BER_COUNT | PHY_FLD4_BER_TIMER |
-   PHY_FLD4_BER_CHK_EN);
+   PHY_FLD4_FLDEN_SEL | PHY_FLD4_REQ_REF |
+   PHY_FLD4_RXAMP_OFF | PHY_FLD4_REQ_ADDA |
+   PHY_FLD4_BER_COUNT | PHY_FLD4_BER_TIMER |
+   PHY_FLD4_BER_CHK_EN);
if (err < 0)
return err;
-   err = rtsx_pci_write_phy_register(pcr, PHY_RDR, PHY_RDR_RXDSEL_1_9);
+   err = rtsx_pci_write_phy_register(pcr, PHY_RDR,
+   PHY_RDR_RXDSEL_1_9 | PHY_SSC_AUTO_PWD);
if (err < 0)
return err;
err = rtsx_pci_write_phy_register(pcr, PHY_RCR1,
-   PHY_RCR1_ADP_TIME | PHY_RCR1_VCO_COARSE);
+   PHY_RCR1_ADP_TIME_4 | PHY_RCR1_VCO_COARSE);
if (err < 0)
return err;
err = rtsx_pci_write_phy_register(pcr, PHY_FLD3,
-   PHY_FLD3_TIMER_4 | PHY_FLD3_TIMER_6 |
-   PHY_FLD3_RXDELINK);
+   PHY_FLD3_TIMER_4 | PHY_FLD3_TIMER_6 |
+   PHY_FLD3_RXDELINK);
if (err < 0)
return err;
+
return rtsx_pci_write_phy_register(pcr, PHY_TUNE,
-   PHY_TUNE_TUNEREF_1_0 | PHY_TUNE_VBGSEL_1252 |
-   PHY_TUNE_SDBUS_33 | PHY_TUNE_TUNED18 |
-   PHY_TUNE_TUNED12);
+   PHY_TUNE_TUNEREF_1_0 | PHY_TUNE_VBGSEL_1252 |
+   PHY_TUNE_SDBUS_33 | PHY_TUNE_TUNED18 |
+   PHY_TUNE_TUNED12 | PHY_TUNE_TUNEA12);
 }
 
 static int rts5249_turn_on_led(struct rtsx_pcr *pcr)
diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
index 87cff60..0103210 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -630,16 +630,47 @@
 
 /* Phy register */
 #define PHY_PCR0x00
+#define   PHY_PCR_FORCE_CODE   0xB000
+#define   PHY_PCR_OOBS_CALI_50 0x0800
+#define   PHY_PCR_OOBS_VCM_

[PATCH v2 8/9] mfd: rtsx: add support for rts525A

2015-01-21 Thread micky_ching
From: Micky Ching 

add support for new chip rts525A.

Signed-off-by: Micky Ching 
---
 drivers/mfd/rts5249.c| 104 ++-
 drivers/mfd/rtsx_pcr.c   |  13 --
 drivers/mfd/rtsx_pcr.h   |   1 +
 include/linux/mfd/rtsx_pci.h |  15 +++
 4 files changed, 129 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
index 97dde92..134e03f 100644
--- a/drivers/mfd/rts5249.c
+++ b/drivers/mfd/rts5249.c
@@ -97,7 +97,7 @@ static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, 
u8 pm_state)
rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0);
 
if (pm_state == HOST_ENTER_S3) {
-   if (PCI_PID(pcr) == 0x524A)
+   if (PCI_PID(pcr) == 0x524A || PCI_PID(pcr) == 0x525A)
rtsx_pci_write_register(pcr, RTS524A_PM_CTRL3,
D3_DELINK_MODE_EN, D3_DELINK_MODE_EN);
else if (PCI_PID(pcr) == 0x5249)
@@ -485,3 +485,105 @@ void rts524a_init_params(struct rtsx_pcr *pcr)
pcr->ops = &rts524a_pcr_ops;
 }
 
+static int rts525a_card_power_on(struct rtsx_pcr *pcr, int card)
+{
+   rtsx_pci_write_register(pcr, LDO_VCC_CFG1,
+   LDO_VCC_TUNE_MASK, LDO_VCC_3V3);
+   return rtsx_base_card_power_on(pcr, card);
+}
+
+static int rts525a_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
+{
+   switch (voltage) {
+   case OUTPUT_3V3:
+   rtsx_pci_write_register(pcr, LDO_CONFIG2,
+   LDO_D3318_MASK, LDO_D3318_33V);
+   rtsx_pci_write_register(pcr, SD_PAD_CTL, SD_IO_USING_1V8, 0);
+   break;
+   case OUTPUT_1V8:
+   rtsx_pci_write_register(pcr, LDO_CONFIG2,
+   LDO_D3318_MASK, LDO_D3318_18V);
+   rtsx_pci_write_register(pcr, SD_PAD_CTL, SD_IO_USING_1V8,
+   SD_IO_USING_1V8);
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   rtsx_pci_init_cmd(pcr);
+   rts5249_fill_driving(pcr, voltage);
+   return rtsx_pci_send_cmd(pcr, 100);
+}
+
+static int rts525a_optimize_phy(struct rtsx_pcr *pcr)
+{
+   int err;
+
+   err = rtsx_pci_write_register(pcr, RTS524A_PM_CTRL3,
+   D3_DELINK_MODE_EN, 0x00);
+   if (err < 0)
+   return err;
+
+   rtsx_pci_write_phy_register(pcr, _PHY_FLD0,
+   _PHY_FLD0_CLK_REQ_20C | _PHY_FLD0_RX_IDLE_EN |
+   _PHY_FLD0_BIT_ERR_RSTN | _PHY_FLD0_BER_COUNT |
+   _PHY_FLD0_BER_TIMER | _PHY_FLD0_CHECK_EN);
+
+   rtsx_pci_write_phy_register(pcr, _PHY_ANA03,
+   _PHY_ANA03_TIMER_MAX | _PHY_ANA03_OOBS_DEB_EN |
+   _PHY_CMU_DEBUG_EN);
+
+   if (is_version(pcr, 0x525A, IC_VER_A))
+   rtsx_pci_write_phy_register(pcr, _PHY_REV0,
+   _PHY_REV0_FILTER_OUT | _PHY_REV0_CDR_BYPASS_PFD |
+   _PHY_REV0_CDR_RX_IDLE_BYPASS);
+
+   return 0;
+}
+
+static int rts525a_extra_init_hw(struct rtsx_pcr *pcr)
+{
+   rts5249_extra_init_hw(pcr);
+
+   rtsx_pci_write_register(pcr, PCLK_CTL, PCLK_MODE_SEL, PCLK_MODE_SEL);
+   if (is_version(pcr, 0x525A, IC_VER_A)) {
+   rtsx_pci_write_register(pcr, L1SUB_CONFIG2,
+   L1SUB_AUTO_CFG, L1SUB_AUTO_CFG);
+   rtsx_pci_write_register(pcr, RREF_CFG,
+   RREF_VBGSEL_MASK, RREF_VBGSEL_1V25);
+   rtsx_pci_write_register(pcr, LDO_VIO_CFG,
+   LDO_VIO_TUNE_MASK, LDO_VIO_1V7);
+   rtsx_pci_write_register(pcr, LDO_DV12S_CFG,
+   LDO_D12_TUNE_MASK, LDO_D12_TUNE_DF);
+   rtsx_pci_write_register(pcr, LDO_AV12S_CFG,
+   LDO_AV12S_TUNE_MASK, LDO_AV12S_TUNE_DF);
+   rtsx_pci_write_register(pcr, LDO_VCC_CFG0,
+   LDO_VCC_LMTVTH_MASK, LDO_VCC_LMTVTH_2A);
+   rtsx_pci_write_register(pcr, OOBS_CONFIG,
+   OOBS_AUTOK_DIS | OOBS_VAL_MASK, 0x89);
+   }
+
+   return 0;
+}
+
+static const struct pcr_ops rts525a_pcr_ops = {
+   .fetch_vendor_settings = rtsx_base_fetch_vendor_settings,
+   .extra_init_hw = rts525a_extra_init_hw,
+   .optimize_phy = rts525a_optimize_phy,
+   .turn_on_led = rtsx_base_turn_on_led,
+   .turn_off_led = rtsx_base_turn_off_led,
+   .enable_auto_blink = rtsx_base_enable_auto_blink,
+   .disable_auto_blink = rtsx_base_disable_auto_blink,
+   .card_power_on = rts525a_card_power_on,
+   .card_power_off = rtsx_base_card_power_off,
+   .switch_output_voltage = rts525a_switch_output_voltage,
+   .force_power_down = rtsx_base_force_power_down,
+};
+
+void rts525a_init_params(struct rtsx_pcr *pcr)
+{
+   rts5249_init_params(pcr);
+
+   pcr->ops = &rts525a_pcr_ops;
+}
+
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
index 69467c6..681e1a6 100644
-

[PATCH v2 6/9] mfd: rtsx: remove LCTLR defination

2015-01-21 Thread micky_ching
From: Micky Ching 

To enable/disable ASPM we should find LINK CONTROL register
in PCI config space. All old chip use 0x80 address, but new
chip may use another address, so we using pci_find_capability()
to get LINK CONTROL address.

rtsx_gops.c was removed, we consider to put some common operations
to this file, but the actual thing is, only a group of chips
are in common ops1, and another group of chips in common ops2,
it is hard to decide put which ops into generic ops file.

Signed-off-by: Micky Ching 
---
 drivers/mfd/Makefile |  2 +-
 drivers/mfd/rts5227.c|  2 +-
 drivers/mfd/rts5249.c|  3 +--
 drivers/mfd/rtsx_gops.c  | 37 -
 drivers/mfd/rtsx_pcr.c   | 23 ++-
 include/linux/mfd/rtsx_pci.h | 10 +-
 6 files changed, 22 insertions(+), 55 deletions(-)
 delete mode 100644 drivers/mfd/rtsx_gops.c

diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 53467e2..2cd7e74 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -13,7 +13,7 @@ obj-$(CONFIG_MFD_CROS_EC) += cros_ec.o
 obj-$(CONFIG_MFD_CROS_EC_I2C)  += cros_ec_i2c.o
 obj-$(CONFIG_MFD_CROS_EC_SPI)  += cros_ec_spi.o
 
-rtsx_pci-objs  := rtsx_pcr.o rtsx_gops.o rts5209.o rts5229.o 
rtl8411.o rts5227.o rts5249.o
+rtsx_pci-objs  := rtsx_pcr.o rts5209.o rts5229.o rtl8411.o 
rts5227.o rts5249.o
 obj-$(CONFIG_MFD_RTSX_PCI) += rtsx_pci.o
 obj-$(CONFIG_MFD_RTSX_USB) += rtsx_usb.o
 
diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c
index 1f387d4..0c02831 100644
--- a/drivers/mfd/rts5227.c
+++ b/drivers/mfd/rts5227.c
@@ -130,7 +130,7 @@ static int rts5227_optimize_phy(struct rtsx_pcr *pcr)
 {
int err;
 
-   err = rtsx_gops_pm_reset(pcr);
+   err = rtsx_pci_write_register(pcr, PM_CTRL3, D3_DELINK_MODE_EN, 0x00);
if (err < 0)
return err;
 
diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
index d8072f6..3977946 100644
--- a/drivers/mfd/rts5249.c
+++ b/drivers/mfd/rts5249.c
@@ -119,7 +119,6 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB0, 0xB0);
else
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB0, 0x80);
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PM_CTRL3, 0x10, 0x00);
 
return rtsx_pci_send_cmd(pcr, 100);
 }
@@ -128,7 +127,7 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
 {
int err;
 
-   err = rtsx_gops_pm_reset(pcr);
+   err = rtsx_pci_write_register(pcr, PM_CTRL3, D3_DELINK_MODE_EN, 0x00);
if (err < 0)
return err;
 
diff --git a/drivers/mfd/rtsx_gops.c b/drivers/mfd/rtsx_gops.c
deleted file mode 100644
index b1a98c6..000
--- a/drivers/mfd/rtsx_gops.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Driver for Realtek PCI-Express card reader
- *
- * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see .
- *
- * Author:
- *   Micky Ching 
- */
-
-#include 
-#include "rtsx_pcr.h"
-
-int rtsx_gops_pm_reset(struct rtsx_pcr *pcr)
-{
-   int err;
-
-   /* init aspm */
-   rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, 0xFF, 0x00);
-   err = rtsx_pci_update_cfg_byte(pcr, LCTLR, ~LCTLR_ASPM_CTL_MASK, 0x00);
-   if (err < 0)
-   return err;
-
-   /* reset PM_CTRL3 before send buffer cmd */
-   return rtsx_pci_write_register(pcr, PM_CTRL3, D3_DELINK_MODE_EN, 0x00);
-}
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
index 30f7ca8..717bfd7 100644
--- a/drivers/mfd/rtsx_pcr.c
+++ b/drivers/mfd/rtsx_pcr.c
@@ -63,6 +63,18 @@ static const struct pci_device_id rtsx_pci_ids[] = {
 
 MODULE_DEVICE_TABLE(pci, rtsx_pci_ids);
 
+static inline void rtsx_pci_enable_aspm(struct rtsx_pcr *pcr)
+{
+   rtsx_pci_update_cfg_byte(pcr, pcr->pcie_cap + PCI_EXP_LNKCTL,
+   0xFC, pcr->aspm_en);
+}
+
+static inline void rtsx_pci_disable_aspm(struct rtsx_pcr *pcr)
+{
+   rtsx_pci_update_cfg_byte(pcr, pcr->pcie_cap + PCI_EXP_LNKCTL,
+   0xFC, 0);
+}
+
 void rtsx_pci_start_run(struct rtsx_pcr *pcr)
 {
/* If pci device removed, don't queue idle work any more */
@@ -75,7 +87,8 @@ void rtsx_pci_start_run(struct rtsx_pcr *pcr)
pcr->ops->enable_auto_blink(pcr);
 
   

[PATCH v2 2/9] mfd: rtsx: place register address and values togather

2015-01-21 Thread micky_ching
From: Micky Ching 

It is more readable to place register address and values define
togather. The values define add two leading space indicate belong
to the register address defined above.

Signed-off-by: Micky Ching 
---
 include/linux/mfd/rtsx_pci.h | 836 +++
 1 file changed, 369 insertions(+), 467 deletions(-)

diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
index a9c2a14..e81f2bb 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -28,74 +28,72 @@
 
 #define MAX_RW_REG_CNT 1024
 
-/* PCI Operation Register Address */
 #define RTSX_HCBAR 0x00
 #define RTSX_HCBCTLR   0x04
+#define   STOP_CMD (0x01 << 28)
+#define   READ_REG_CMD 0
+#define   WRITE_REG_CMD1
+#define   CHECK_REG_CMD2
+
 #define RTSX_HDBAR 0x08
+#define   SG_INT   0x04
+#define   SG_END   0x02
+#define   SG_VALID 0x01
+#define   SG_NO_OP 0x00
+#define   SG_TRANS_DATA(0x02 << 4)
+#define   SG_LINK_DESC (0x03 << 4)
 #define RTSX_HDBCTLR   0x0C
+#define   SDMA_MODE0x00
+#define   ADMA_MODE(0x02 << 26)
+#define   STOP_DMA (0x01 << 28)
+#define   TRIG_DMA (0x01 << 31)
+
 #define RTSX_HAIMR 0x10
-#define RTSX_BIPR  0x14
-#define RTSX_BIER  0x18
+#define   HAIMR_TRANS_START(0x01 << 31)
+#define   HAIMR_READ   0x00
+#define   HAIMR_WRITE  (0x01 << 30)
+#define   HAIMR_READ_START (HAIMR_TRANS_START | HAIMR_READ)
+#define   HAIMR_WRITE_START(HAIMR_TRANS_START | HAIMR_WRITE)
+#define   HAIMR_TRANS_END  (HAIMR_TRANS_START)
 
-/* Host command buffer control register */
-#define STOP_CMD   (0x01 << 28)
-
-/* Host data buffer control register */
-#define SDMA_MODE  0x00
-#define ADMA_MODE  (0x02 << 26)
-#define STOP_DMA   (0x01 << 28)
-#define TRIG_DMA   (0x01 << 31)
-
-/* Host access internal memory register */
-#define HAIMR_TRANS_START  (0x01 << 31)
-#define HAIMR_READ 0x00
-#define HAIMR_WRITE(0x01 << 30)
-#define HAIMR_READ_START   (HAIMR_TRANS_START | HAIMR_READ)
-#define HAIMR_WRITE_START  (HAIMR_TRANS_START | HAIMR_WRITE)
-#define HAIMR_TRANS_END(HAIMR_TRANS_START)
-
-/* Bus interrupt pending register */
-#define CMD_DONE_INT   (1 << 31)
-#define DATA_DONE_INT  (1 << 30)
-#define TRANS_OK_INT   (1 << 29)
-#define TRANS_FAIL_INT (1 << 28)
-#define XD_INT (1 << 27)
-#define MS_INT (1 << 26)
-#define SD_INT (1 << 25)
-#define GPIO0_INT  (1 << 24)
-#define OC_INT (1 << 23)
-#define SD_WRITE_PROTECT   (1 << 19)
-#define XD_EXIST   (1 << 18)
-#define MS_EXIST   (1 << 17)
-#define SD_EXIST   (1 << 16)
-#define DELINK_INT GPIO0_INT
-#define MS_OC_INT  (1 << 23)
-#define SD_OC_INT  (1 << 22)
+#define RTSX_BIPR  0x14
+#define   CMD_DONE_INT (1 << 31)
+#define   DATA_DONE_INT(1 << 30)
+#define   TRANS_OK_INT (1 << 29)
+#define   TRANS_FAIL_INT   (1 << 28)
+#define   XD_INT   (1 << 27)
+#define   MS_INT   (1 << 26)
+#define   SD_INT   (1 << 25)
+#define   GPIO0_INT(1 << 24)
+#define   OC_INT   (1 << 23)
+#define   SD_WRITE_PROTECT (1 << 19)
+#define   XD_EXIST (1 << 18)
+#define   MS_EXIST (1 << 17)
+#define   SD_EXIST (1 << 16)
+#define   DELINK_INT   GPIO0_INT
+#define   MS_OC_INT(1 << 23)
+#define   SD_OC_INT(1 << 22)
 
 #define CARD_INT   (XD_INT | MS_INT | SD_INT)
 #define NEED_COMPLETE_INT  (DATA_DONE_INT | TRANS_OK_INT | TRANS_FAIL_INT)
 #define RTSX_INT   (CMD_DONE_INT | NEED_COMPLETE_INT | \
CARD_INT | GPIO0_INT | OC_INT)
-
 #define CARD_EXIST (XD_EXIST | MS_EXIST | SD_EXIST)
 
-/* Bus interrupt enable register */
-#define CMD_DONE_INT_EN(1 << 31)
-#define DATA_DONE_INT_EN   (1 << 30)
-#define TRANS_OK_INT_EN(1 << 29)
-#defi

[PATCH v2 0/9] mfd: rtsx: add support for new rts524A and rts525A

2015-01-21 Thread micky_ching
From: Micky Ching 

v2:
- remove debug info when access failed.
- using macro list for phy register init.
- rename function for multi chip prefix with rtsx_base_
- save pcie_cap offset when init chip, not calling pci_find_capacity()
  every time.
- add pcr->ops: write_phy/read_phy for special chip.

This patchset including re-format some coding-style and add two new chip
rts524A and rts525A.


Micky Ching (9):
  mfd: rtsx: replace TAB by SPC after #define
  mfd: rtsx: place register address and values togather
  mfd: rtsx: update PETXCFG address
  mfd: rtsx: update driving settings
  mfd: rtsx: update phy register
  mfd: rtsx: remove LCTLR defination
  mfd: rtsx: add support for rts524A
  mfd: rtsx: add support for rts525A
  mfd: rtsx: using pcr_dbg replace dev_dbg

 drivers/mfd/Makefile |2 +-
 drivers/mfd/rtl8411.c|   11 +-
 drivers/mfd/rts5209.c|4 +-
 drivers/mfd/rts5227.c|   12 +-
 drivers/mfd/rts5229.c|4 +-
 drivers/mfd/rts5249.c|  368 +++---
 drivers/mfd/rtsx_gops.c  |   37 --
 drivers/mfd/rtsx_pcr.c   |  110 +++--
 drivers/mfd/rtsx_pcr.h   |8 +
 include/linux/mfd/rtsx_pci.h | 1109 ++
 10 files changed, 966 insertions(+), 699 deletions(-)
 delete mode 100644 drivers/mfd/rtsx_gops.c

-- 
1.9.1

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


[PATCH v2 4/9] mfd: rtsx: update driving settings

2015-01-21 Thread micky_ching
From: Micky Ching 

update card drive settings, This setting can be used for rts5249
rts524A and rts525A.

Signed-off-by: Micky Ching 
---
 drivers/mfd/rts5249.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
index 225ad55..2fe2854 100644
--- a/drivers/mfd/rts5249.c
+++ b/drivers/mfd/rts5249.c
@@ -36,16 +36,16 @@ static u8 rts5249_get_ic_version(struct rtsx_pcr *pcr)
 static void rts5249_fill_driving(struct rtsx_pcr *pcr, u8 voltage)
 {
u8 driving_3v3[4][3] = {
-   {0x11, 0x11, 0x11},
+   {0x11, 0x11, 0x18},
{0x55, 0x55, 0x5C},
-   {0x99, 0x99, 0x92},
-   {0x99, 0x99, 0x92},
+   {0xFF, 0xFF, 0xFF},
+   {0x96, 0x96, 0x96},
};
u8 driving_1v8[4][3] = {
+   {0xC4, 0xC4, 0xC4},
{0x3C, 0x3C, 0x3C},
-   {0xB3, 0xB3, 0xB3},
{0xFE, 0xFE, 0xFE},
-   {0xC4, 0xC4, 0xC4},
+   {0xB3, 0xB3, 0xB3},
};
u8 (*driving)[3], drive_sel;
 
@@ -341,7 +341,7 @@ void rts5249_init_params(struct rtsx_pcr *pcr)
 
pcr->flags = 0;
pcr->card_drive_sel = RTSX_CARD_DRIVE_DEFAULT;
-   pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_C;
+   pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B;
pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B;
pcr->aspm_en = ASPM_L1_EN;
pcr->tx_initial_phase = SET_CLOCK_PHASE(1, 29, 16);
-- 
1.9.1

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


[PATCH v2 7/9] mfd: rtsx: add support for rts524A

2015-01-21 Thread micky_ching
From: Micky Ching 

add support for new chip rts524A.

Signed-off-by: Micky Ching 
---
 drivers/mfd/rts5249.c| 186 ---
 drivers/mfd/rtsx_pcr.c   |  25 +-
 drivers/mfd/rtsx_pcr.h   |   7 ++
 include/linux/mfd/rtsx_pci.h | 125 -
 4 files changed, 310 insertions(+), 33 deletions(-)

diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
index 3977946..97dde92 100644
--- a/drivers/mfd/rts5249.c
+++ b/drivers/mfd/rts5249.c
@@ -65,15 +65,17 @@ static void rts5249_fill_driving(struct rtsx_pcr *pcr, u8 
voltage)
0xFF, driving[drive_sel][2]);
 }
 
-static void rts5249_fetch_vendor_settings(struct rtsx_pcr *pcr)
+static void rtsx_base_fetch_vendor_settings(struct rtsx_pcr *pcr)
 {
u32 reg;
 
rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®);
dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
 
-   if (!rtsx_vendor_setting_valid(reg))
+   if (!rtsx_vendor_setting_valid(reg)) {
+   pcr_dbg(pcr, "skip fetch vendor setting\n");
return;
+   }
 
pcr->aspm_en = rtsx_reg_to_aspm(reg);
pcr->sd30_drive_sel_1v8 = rtsx_reg_to_sd30_drive_sel_1v8(reg);
@@ -87,15 +89,21 @@ static void rts5249_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
pcr->flags |= PCR_REVERSE_SOCKET;
 }
 
-static void rts5249_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
+static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
 {
/* Set relink_time to 0 */
rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, 0xFF, 0);
rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, 0xFF, 0);
rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0);
 
-   if (pm_state == HOST_ENTER_S3)
-   rtsx_pci_write_register(pcr, PM_CTRL3, 0x10, 0x10);
+   if (pm_state == HOST_ENTER_S3) {
+   if (PCI_PID(pcr) == 0x524A)
+   rtsx_pci_write_register(pcr, RTS524A_PM_CTRL3,
+   D3_DELINK_MODE_EN, D3_DELINK_MODE_EN);
+   else if (PCI_PID(pcr) == 0x5249)
+   rtsx_pci_write_register(pcr, PM_CTRL3,
+   D3_DELINK_MODE_EN, D3_DELINK_MODE_EN);
+   }
 
rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03);
 }
@@ -104,6 +112,8 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)
 {
rtsx_pci_init_cmd(pcr);
 
+   /* Rest L1SUB Config */
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, L1SUB_CONFIG3, 0xFF, 0x00);
/* Configure GPIO as output */
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, GPIO_CTL, 0x02, 0x02);
/* Reset ASPM state to default value */
@@ -189,27 +199,27 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
PHY_TUNE_TUNED12 | PHY_TUNE_TUNEA12);
 }
 
-static int rts5249_turn_on_led(struct rtsx_pcr *pcr)
+static int rtsx_base_turn_on_led(struct rtsx_pcr *pcr)
 {
return rtsx_pci_write_register(pcr, GPIO_CTL, 0x02, 0x02);
 }
 
-static int rts5249_turn_off_led(struct rtsx_pcr *pcr)
+static int rtsx_base_turn_off_led(struct rtsx_pcr *pcr)
 {
return rtsx_pci_write_register(pcr, GPIO_CTL, 0x02, 0x00);
 }
 
-static int rts5249_enable_auto_blink(struct rtsx_pcr *pcr)
+static int rtsx_base_enable_auto_blink(struct rtsx_pcr *pcr)
 {
return rtsx_pci_write_register(pcr, OLT_LED_CTL, 0x08, 0x08);
 }
 
-static int rts5249_disable_auto_blink(struct rtsx_pcr *pcr)
+static int rtsx_base_disable_auto_blink(struct rtsx_pcr *pcr)
 {
return rtsx_pci_write_register(pcr, OLT_LED_CTL, 0x08, 0x00);
 }
 
-static int rts5249_card_power_on(struct rtsx_pcr *pcr, int card)
+static int rtsx_base_card_power_on(struct rtsx_pcr *pcr, int card)
 {
int err;
 
@@ -236,7 +246,7 @@ static int rts5249_card_power_on(struct rtsx_pcr *pcr, int 
card)
return 0;
 }
 
-static int rts5249_card_power_off(struct rtsx_pcr *pcr, int card)
+static int rtsx_base_card_power_off(struct rtsx_pcr *pcr, int card)
 {
rtsx_pci_init_cmd(pcr);
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_PWR_CTL,
@@ -246,22 +256,31 @@ static int rts5249_card_power_off(struct rtsx_pcr *pcr, 
int card)
return rtsx_pci_send_cmd(pcr, 100);
 }
 
-static int rts5249_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
+static int rtsx_base_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
 {
int err;
+   u16 append;
 
-   if (voltage == OUTPUT_3V3) {
-   err = rtsx_pci_write_phy_register(pcr, PHY_TUNE, 0x4FC0 | 0x24);
-   if (err < 0)
-   return err;
-   } else if (voltage == OUTPUT_1V8) {
-   err = rtsx_pci_write_phy_register(pcr, PHY_BACR, 0x3C02);
+   switch (voltage) {
+   case OUTPUT_3V3:
+   err = rtsx_pci_update_phy(pcr, PHY_TUNE, 0xFC3F, 0x03C0);
if (err < 0)
return err;
- 

[PATCH v2 9/9] mfd: rtsx: using pcr_dbg replace dev_dbg

2015-01-21 Thread micky_ching
From: Micky Ching 

pcr_dbg is a wrapper of dev_dbg, which can save some code,
and help to enable/disable debug message static.

Signed-off-by: Micky Ching 
---
 drivers/mfd/rtl8411.c  | 11 +--
 drivers/mfd/rts5209.c  |  4 ++--
 drivers/mfd/rts5227.c  |  4 ++--
 drivers/mfd/rts5229.c  |  4 ++--
 drivers/mfd/rts5249.c  |  4 ++--
 drivers/mfd/rtsx_pcr.c | 49 ++---
 6 files changed, 35 insertions(+), 41 deletions(-)

diff --git a/drivers/mfd/rtl8411.c b/drivers/mfd/rtl8411.c
index fdd34c8..b3ae659 100644
--- a/drivers/mfd/rtl8411.c
+++ b/drivers/mfd/rtl8411.c
@@ -53,7 +53,7 @@ static void rtl8411_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
u8 reg3 = 0;
 
rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®1);
-   dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg1);
+   pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg1);
 
if (!rtsx_vendor_setting_valid(reg1))
return;
@@ -65,7 +65,7 @@ static void rtl8411_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
pcr->card_drive_sel |= rtsx_reg_to_card_drive_sel(reg1);
 
rtsx_pci_read_config_byte(pcr, PCR_SETTING_REG3, ®3);
-   dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG3, reg3);
+   pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG3, reg3);
pcr->sd30_drive_sel_3v3 = rtl8411_reg_to_sd30_drive_sel_3v3(reg3);
 }
 
@@ -74,7 +74,7 @@ static void rtl8411b_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
u32 reg = 0;
 
rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®);
-   dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
+   pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
 
if (!rtsx_vendor_setting_valid(reg))
return;
@@ -260,9 +260,8 @@ static unsigned int rtl8411_cd_deglitch(struct rtsx_pcr 
*pcr)
rtsx_pci_write_register(pcr, CARD_PWR_CTL,
BPP_POWER_MASK, BPP_POWER_OFF);
 
-   dev_dbg(&(pcr->pci->dev),
-   "After CD deglitch, card_exist = 0x%x\n",
-   card_exist);
+   pcr_dbg(pcr, "After CD deglitch, card_exist = 0x%x\n",
+   card_exist);
}
 
if (card_exist & MS_EXIST) {
diff --git a/drivers/mfd/rts5209.c b/drivers/mfd/rts5209.c
index cb04174..373e253 100644
--- a/drivers/mfd/rts5209.c
+++ b/drivers/mfd/rts5209.c
@@ -38,7 +38,7 @@ static void rts5209_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
u32 reg;
 
rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®);
-   dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
+   pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
 
if (rts5209_vendor_setting1_valid(reg)) {
if (rts5209_reg_check_ms_pmos(reg))
@@ -47,7 +47,7 @@ static void rts5209_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
}
 
rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG2, ®);
-   dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
+   pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
 
if (rts5209_vendor_setting2_valid(reg)) {
pcr->sd30_drive_sel_1v8 =
diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c
index 0c02831..ce012d7 100644
--- a/drivers/mfd/rts5227.c
+++ b/drivers/mfd/rts5227.c
@@ -63,7 +63,7 @@ static void rts5227_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
u32 reg;
 
rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®);
-   dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
+   pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
 
if (!rtsx_vendor_setting_valid(reg))
return;
@@ -74,7 +74,7 @@ static void rts5227_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
pcr->card_drive_sel |= rtsx_reg_to_card_drive_sel(reg);
 
rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG2, ®);
-   dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
+   pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
pcr->sd30_drive_sel_3v3 = rtsx_reg_to_sd30_drive_sel_3v3(reg);
if (rtsx_reg_check_reverse_socket(reg))
pcr->flags |= PCR_REVERSE_SOCKET;
diff --git a/drivers/mfd/rts5229.c b/drivers/mfd/rts5229.c
index 6353f5d..ace4538 100644
--- a/drivers/mfd/rts5229.c
+++ b/drivers/mfd/rts5229.c
@@ -38,7 +38,7 @@ static void rts5229_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
u32 reg;
 
rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®);
-   dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
+   pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
 
if (!rtsx_vendor_setting_valid(reg))
return;
@@ -50,7 +50,7 @@ static void rts5229_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
pcr->card_drive_sel |= rtsx_reg_to_card_dr

Re: [PATCH v2 0/9] mfd: rtsx: add support for new rts524A and rts525A

2015-01-21 Thread Lee Jones
Have you reworked all of these patches?

If not, why haven't my Acks been carried forward?

Please [RESEND] with the Acks applied.

> From: Micky Ching 
> 
> v2:
> - remove debug info when access failed.
> - using macro list for phy register init.
> - rename function for multi chip prefix with rtsx_base_
> - save pcie_cap offset when init chip, not calling pci_find_capacity()
>   every time.
> - add pcr->ops: write_phy/read_phy for special chip.
> 
> This patchset including re-format some coding-style and add two new chip
> rts524A and rts525A.
> 
> 
> Micky Ching (9):
>   mfd: rtsx: replace TAB by SPC after #define
>   mfd: rtsx: place register address and values togather
>   mfd: rtsx: update PETXCFG address
>   mfd: rtsx: update driving settings
>   mfd: rtsx: update phy register
>   mfd: rtsx: remove LCTLR defination
>   mfd: rtsx: add support for rts524A
>   mfd: rtsx: add support for rts525A
>   mfd: rtsx: using pcr_dbg replace dev_dbg
> 
>  drivers/mfd/Makefile |2 +-
>  drivers/mfd/rtl8411.c|   11 +-
>  drivers/mfd/rts5209.c|4 +-
>  drivers/mfd/rts5227.c|   12 +-
>  drivers/mfd/rts5229.c|4 +-
>  drivers/mfd/rts5249.c|  368 +++---
>  drivers/mfd/rtsx_gops.c  |   37 --
>  drivers/mfd/rtsx_pcr.c   |  110 +++--
>  drivers/mfd/rtsx_pcr.h   |8 +
>  include/linux/mfd/rtsx_pci.h | 1109 
> ++
>  10 files changed, 966 insertions(+), 699 deletions(-)
>  delete mode 100644 drivers/mfd/rtsx_gops.c
> 

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RESEND PATCH v2 5/9] mfd: rtsx: update phy register

2015-01-21 Thread micky_ching
From: Micky Ching 

update phy register value and using direct value instead of macros.
It is much easier to debug using constant value than a lot of macros.
We usually need compare the value directly to check the configure.

Signed-off-by: Micky Ching 
---
 drivers/mfd/rts5249.c|  55 --
 include/linux/mfd/rtsx_pci.h | 109 ++-
 2 files changed, 85 insertions(+), 79 deletions(-)

diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
index 2fe2854..d8072f6 100644
--- a/drivers/mfd/rts5249.c
+++ b/drivers/mfd/rts5249.c
@@ -132,57 +132,62 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
if (err < 0)
return err;
 
-   err = rtsx_pci_write_phy_register(pcr, PHY_REG_REV,
-   PHY_REG_REV_RESV | PHY_REG_REV_RXIDLE_LATCHED |
-   PHY_REG_REV_P1_EN | PHY_REG_REV_RXIDLE_EN |
-   PHY_REG_REV_RX_PWST | PHY_REG_REV_CLKREQ_DLY_TIMER_1_0 |
-   PHY_REG_REV_STOP_CLKRD | PHY_REG_REV_STOP_CLKWR);
+   err = rtsx_pci_write_phy_register(pcr, PHY_REV,
+   PHY_REV_RESV | PHY_REV_RXIDLE_LATCHED |
+   PHY_REV_P1_EN | PHY_REV_RXIDLE_EN |
+   PHY_REV_CLKREQ_TX_EN | PHY_REV_RX_PWST |
+   PHY_REV_CLKREQ_DT_1_0 | PHY_REV_STOP_CLKRD |
+   PHY_REV_STOP_CLKWR);
if (err < 0)
return err;
 
msleep(1);
 
err = rtsx_pci_write_phy_register(pcr, PHY_BPCR,
-   PHY_BPCR_IBRXSEL | PHY_BPCR_IBTXSEL |
-   PHY_BPCR_IB_FILTER | PHY_BPCR_CMIRROR_EN);
+   PHY_BPCR_IBRXSEL | PHY_BPCR_IBTXSEL |
+   PHY_BPCR_IB_FILTER | PHY_BPCR_CMIRROR_EN);
if (err < 0)
return err;
+
err = rtsx_pci_write_phy_register(pcr, PHY_PCR,
-   PHY_PCR_FORCE_CODE | PHY_PCR_OOBS_CALI_50 |
-   PHY_PCR_OOBS_VCM_08 | PHY_PCR_OOBS_SEN_90 |
-   PHY_PCR_RSSI_EN);
+   PHY_PCR_FORCE_CODE | PHY_PCR_OOBS_CALI_50 |
+   PHY_PCR_OOBS_VCM_08 | PHY_PCR_OOBS_SEN_90 |
+   PHY_PCR_RSSI_EN | PHY_PCR_RX10K);
if (err < 0)
return err;
+
err = rtsx_pci_write_phy_register(pcr, PHY_RCR2,
-   PHY_RCR2_EMPHASE_EN | PHY_RCR2_NADJR |
-   PHY_RCR2_CDR_CP_10 | PHY_RCR2_CDR_SR_2 |
-   PHY_RCR2_FREQSEL_12 | PHY_RCR2_CPADJEN |
-   PHY_RCR2_CDR_SC_8 | PHY_RCR2_CALIB_LATE);
+   PHY_RCR2_EMPHASE_EN | PHY_RCR2_NADJR |
+   PHY_RCR2_CDR_SR_2 | PHY_RCR2_FREQSEL_12 |
+   PHY_RCR2_CDR_SC_12P | PHY_RCR2_CALIB_LATE);
if (err < 0)
return err;
+
err = rtsx_pci_write_phy_register(pcr, PHY_FLD4,
-   PHY_FLD4_FLDEN_SEL | PHY_FLD4_REQ_REF |
-   PHY_FLD4_RXAMP_OFF | PHY_FLD4_REQ_ADDA |
-   PHY_FLD4_BER_COUNT | PHY_FLD4_BER_TIMER |
-   PHY_FLD4_BER_CHK_EN);
+   PHY_FLD4_FLDEN_SEL | PHY_FLD4_REQ_REF |
+   PHY_FLD4_RXAMP_OFF | PHY_FLD4_REQ_ADDA |
+   PHY_FLD4_BER_COUNT | PHY_FLD4_BER_TIMER |
+   PHY_FLD4_BER_CHK_EN);
if (err < 0)
return err;
-   err = rtsx_pci_write_phy_register(pcr, PHY_RDR, PHY_RDR_RXDSEL_1_9);
+   err = rtsx_pci_write_phy_register(pcr, PHY_RDR,
+   PHY_RDR_RXDSEL_1_9 | PHY_SSC_AUTO_PWD);
if (err < 0)
return err;
err = rtsx_pci_write_phy_register(pcr, PHY_RCR1,
-   PHY_RCR1_ADP_TIME | PHY_RCR1_VCO_COARSE);
+   PHY_RCR1_ADP_TIME_4 | PHY_RCR1_VCO_COARSE);
if (err < 0)
return err;
err = rtsx_pci_write_phy_register(pcr, PHY_FLD3,
-   PHY_FLD3_TIMER_4 | PHY_FLD3_TIMER_6 |
-   PHY_FLD3_RXDELINK);
+   PHY_FLD3_TIMER_4 | PHY_FLD3_TIMER_6 |
+   PHY_FLD3_RXDELINK);
if (err < 0)
return err;
+
return rtsx_pci_write_phy_register(pcr, PHY_TUNE,
-   PHY_TUNE_TUNEREF_1_0 | PHY_TUNE_VBGSEL_1252 |
-   PHY_TUNE_SDBUS_33 | PHY_TUNE_TUNED18 |
-   PHY_TUNE_TUNED12);
+   PHY_TUNE_TUNEREF_1_0 | PHY_TUNE_VBGSEL_1252 |
+   PHY_TUNE_SDBUS_33 | PHY_TUNE_TUNED18 |
+   PHY_TUNE_TUNED12 | PHY_TUNE_TUNEA12);
 }
 
 static int rts5249_turn_on_led(struct rtsx_pcr *pcr)
diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
index 87cff60..0103210 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -630,16 +630,47 @@
 
 /* Phy register */
 #define PHY_PCR0x00
+#define   PHY_PCR_FORCE_CODE   0xB000
+#define   PHY_PCR_OOBS_CALI_50 0x0800
+#define   PHY_PCR_OOBS_VCM_

[RESEND PATCH v2 0/9] mfd: rtsx: add support for new rts524A and rts525A

2015-01-21 Thread micky_ching
From: Micky Ching 

resend:
- add lee jones ack for some patch.
v2:
- remove debug info when access failed.
- using macro list for phy register init.
- rename function for multi chip prefix with rtsx_base_
- save pcie_cap offset when init chip, not calling pci_find_capacity()
  every time.
- add pcr->ops: write_phy/read_phy for special chip.

This patchset including re-format some coding-style and add two new chip
rts524A and rts525A.


Micky Ching (9):
  mfd: rtsx: replace TAB by SPC after #define
  mfd: rtsx: place register address and values togather
  mfd: rtsx: update PETXCFG address
  mfd: rtsx: update driving settings
  mfd: rtsx: update phy register
  mfd: rtsx: remove LCTLR defination
  mfd: rtsx: add support for rts524A
  mfd: rtsx: add support for rts525A
  mfd: rtsx: using pcr_dbg replace dev_dbg

 drivers/mfd/Makefile |2 +-
 drivers/mfd/rtl8411.c|   11 +-
 drivers/mfd/rts5209.c|4 +-
 drivers/mfd/rts5227.c|   12 +-
 drivers/mfd/rts5229.c|4 +-
 drivers/mfd/rts5249.c|  368 +++---
 drivers/mfd/rtsx_gops.c  |   37 --
 drivers/mfd/rtsx_pcr.c   |  109 +++--
 drivers/mfd/rtsx_pcr.h   |8 +
 include/linux/mfd/rtsx_pci.h | 1109 ++
 10 files changed, 965 insertions(+), 699 deletions(-)
 delete mode 100644 drivers/mfd/rtsx_gops.c

-- 
1.9.1

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


[RESEND PATCH v2 4/9] mfd: rtsx: update driving settings

2015-01-21 Thread micky_ching
From: Micky Ching 

update card drive settings, This setting can be used for rts5249
rts524A and rts525A.

Signed-off-by: Micky Ching 
Acked-by: Lee Jones 
---
 drivers/mfd/rts5249.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
index 225ad55..2fe2854 100644
--- a/drivers/mfd/rts5249.c
+++ b/drivers/mfd/rts5249.c
@@ -36,16 +36,16 @@ static u8 rts5249_get_ic_version(struct rtsx_pcr *pcr)
 static void rts5249_fill_driving(struct rtsx_pcr *pcr, u8 voltage)
 {
u8 driving_3v3[4][3] = {
-   {0x11, 0x11, 0x11},
+   {0x11, 0x11, 0x18},
{0x55, 0x55, 0x5C},
-   {0x99, 0x99, 0x92},
-   {0x99, 0x99, 0x92},
+   {0xFF, 0xFF, 0xFF},
+   {0x96, 0x96, 0x96},
};
u8 driving_1v8[4][3] = {
+   {0xC4, 0xC4, 0xC4},
{0x3C, 0x3C, 0x3C},
-   {0xB3, 0xB3, 0xB3},
{0xFE, 0xFE, 0xFE},
-   {0xC4, 0xC4, 0xC4},
+   {0xB3, 0xB3, 0xB3},
};
u8 (*driving)[3], drive_sel;
 
@@ -341,7 +341,7 @@ void rts5249_init_params(struct rtsx_pcr *pcr)
 
pcr->flags = 0;
pcr->card_drive_sel = RTSX_CARD_DRIVE_DEFAULT;
-   pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_C;
+   pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B;
pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B;
pcr->aspm_en = ASPM_L1_EN;
pcr->tx_initial_phase = SET_CLOCK_PHASE(1, 29, 16);
-- 
1.9.1

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


[RESEND PATCH v2 9/9] mfd: rtsx: using pcr_dbg replace dev_dbg

2015-01-21 Thread micky_ching
From: Micky Ching 

pcr_dbg is a wrapper of dev_dbg, which can save some code,
and help to enable/disable debug message static.

Signed-off-by: Micky Ching 
Acked-by: Lee Jones 
---
 drivers/mfd/rtl8411.c  | 11 +--
 drivers/mfd/rts5209.c  |  4 ++--
 drivers/mfd/rts5227.c  |  4 ++--
 drivers/mfd/rts5229.c  |  4 ++--
 drivers/mfd/rts5249.c  |  4 ++--
 drivers/mfd/rtsx_pcr.c | 49 ++---
 6 files changed, 35 insertions(+), 41 deletions(-)

diff --git a/drivers/mfd/rtl8411.c b/drivers/mfd/rtl8411.c
index fdd34c8..b3ae659 100644
--- a/drivers/mfd/rtl8411.c
+++ b/drivers/mfd/rtl8411.c
@@ -53,7 +53,7 @@ static void rtl8411_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
u8 reg3 = 0;
 
rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®1);
-   dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg1);
+   pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg1);
 
if (!rtsx_vendor_setting_valid(reg1))
return;
@@ -65,7 +65,7 @@ static void rtl8411_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
pcr->card_drive_sel |= rtsx_reg_to_card_drive_sel(reg1);
 
rtsx_pci_read_config_byte(pcr, PCR_SETTING_REG3, ®3);
-   dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG3, reg3);
+   pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG3, reg3);
pcr->sd30_drive_sel_3v3 = rtl8411_reg_to_sd30_drive_sel_3v3(reg3);
 }
 
@@ -74,7 +74,7 @@ static void rtl8411b_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
u32 reg = 0;
 
rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®);
-   dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
+   pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
 
if (!rtsx_vendor_setting_valid(reg))
return;
@@ -260,9 +260,8 @@ static unsigned int rtl8411_cd_deglitch(struct rtsx_pcr 
*pcr)
rtsx_pci_write_register(pcr, CARD_PWR_CTL,
BPP_POWER_MASK, BPP_POWER_OFF);
 
-   dev_dbg(&(pcr->pci->dev),
-   "After CD deglitch, card_exist = 0x%x\n",
-   card_exist);
+   pcr_dbg(pcr, "After CD deglitch, card_exist = 0x%x\n",
+   card_exist);
}
 
if (card_exist & MS_EXIST) {
diff --git a/drivers/mfd/rts5209.c b/drivers/mfd/rts5209.c
index cb04174..373e253 100644
--- a/drivers/mfd/rts5209.c
+++ b/drivers/mfd/rts5209.c
@@ -38,7 +38,7 @@ static void rts5209_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
u32 reg;
 
rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®);
-   dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
+   pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
 
if (rts5209_vendor_setting1_valid(reg)) {
if (rts5209_reg_check_ms_pmos(reg))
@@ -47,7 +47,7 @@ static void rts5209_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
}
 
rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG2, ®);
-   dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
+   pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
 
if (rts5209_vendor_setting2_valid(reg)) {
pcr->sd30_drive_sel_1v8 =
diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c
index 0c02831..ce012d7 100644
--- a/drivers/mfd/rts5227.c
+++ b/drivers/mfd/rts5227.c
@@ -63,7 +63,7 @@ static void rts5227_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
u32 reg;
 
rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®);
-   dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
+   pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
 
if (!rtsx_vendor_setting_valid(reg))
return;
@@ -74,7 +74,7 @@ static void rts5227_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
pcr->card_drive_sel |= rtsx_reg_to_card_drive_sel(reg);
 
rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG2, ®);
-   dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
+   pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
pcr->sd30_drive_sel_3v3 = rtsx_reg_to_sd30_drive_sel_3v3(reg);
if (rtsx_reg_check_reverse_socket(reg))
pcr->flags |= PCR_REVERSE_SOCKET;
diff --git a/drivers/mfd/rts5229.c b/drivers/mfd/rts5229.c
index 6353f5d..ace4538 100644
--- a/drivers/mfd/rts5229.c
+++ b/drivers/mfd/rts5229.c
@@ -38,7 +38,7 @@ static void rts5229_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
u32 reg;
 
rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®);
-   dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
+   pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
 
if (!rtsx_vendor_setting_valid(reg))
return;
@@ -50,7 +50,7 @@ static void rts5229_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
pcr->card_drive_sel |

[RESEND PATCH v2 2/9] mfd: rtsx: place register address and values togather

2015-01-21 Thread micky_ching
From: Micky Ching 

It is more readable to place register address and values define
togather. The values define add two leading space indicate belong
to the register address defined above.

Signed-off-by: Micky Ching 
Acked-by: Lee Jones 
---
 include/linux/mfd/rtsx_pci.h | 836 +++
 1 file changed, 369 insertions(+), 467 deletions(-)

diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
index a9c2a14..e81f2bb 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -28,74 +28,72 @@
 
 #define MAX_RW_REG_CNT 1024
 
-/* PCI Operation Register Address */
 #define RTSX_HCBAR 0x00
 #define RTSX_HCBCTLR   0x04
+#define   STOP_CMD (0x01 << 28)
+#define   READ_REG_CMD 0
+#define   WRITE_REG_CMD1
+#define   CHECK_REG_CMD2
+
 #define RTSX_HDBAR 0x08
+#define   SG_INT   0x04
+#define   SG_END   0x02
+#define   SG_VALID 0x01
+#define   SG_NO_OP 0x00
+#define   SG_TRANS_DATA(0x02 << 4)
+#define   SG_LINK_DESC (0x03 << 4)
 #define RTSX_HDBCTLR   0x0C
+#define   SDMA_MODE0x00
+#define   ADMA_MODE(0x02 << 26)
+#define   STOP_DMA (0x01 << 28)
+#define   TRIG_DMA (0x01 << 31)
+
 #define RTSX_HAIMR 0x10
-#define RTSX_BIPR  0x14
-#define RTSX_BIER  0x18
+#define   HAIMR_TRANS_START(0x01 << 31)
+#define   HAIMR_READ   0x00
+#define   HAIMR_WRITE  (0x01 << 30)
+#define   HAIMR_READ_START (HAIMR_TRANS_START | HAIMR_READ)
+#define   HAIMR_WRITE_START(HAIMR_TRANS_START | HAIMR_WRITE)
+#define   HAIMR_TRANS_END  (HAIMR_TRANS_START)
 
-/* Host command buffer control register */
-#define STOP_CMD   (0x01 << 28)
-
-/* Host data buffer control register */
-#define SDMA_MODE  0x00
-#define ADMA_MODE  (0x02 << 26)
-#define STOP_DMA   (0x01 << 28)
-#define TRIG_DMA   (0x01 << 31)
-
-/* Host access internal memory register */
-#define HAIMR_TRANS_START  (0x01 << 31)
-#define HAIMR_READ 0x00
-#define HAIMR_WRITE(0x01 << 30)
-#define HAIMR_READ_START   (HAIMR_TRANS_START | HAIMR_READ)
-#define HAIMR_WRITE_START  (HAIMR_TRANS_START | HAIMR_WRITE)
-#define HAIMR_TRANS_END(HAIMR_TRANS_START)
-
-/* Bus interrupt pending register */
-#define CMD_DONE_INT   (1 << 31)
-#define DATA_DONE_INT  (1 << 30)
-#define TRANS_OK_INT   (1 << 29)
-#define TRANS_FAIL_INT (1 << 28)
-#define XD_INT (1 << 27)
-#define MS_INT (1 << 26)
-#define SD_INT (1 << 25)
-#define GPIO0_INT  (1 << 24)
-#define OC_INT (1 << 23)
-#define SD_WRITE_PROTECT   (1 << 19)
-#define XD_EXIST   (1 << 18)
-#define MS_EXIST   (1 << 17)
-#define SD_EXIST   (1 << 16)
-#define DELINK_INT GPIO0_INT
-#define MS_OC_INT  (1 << 23)
-#define SD_OC_INT  (1 << 22)
+#define RTSX_BIPR  0x14
+#define   CMD_DONE_INT (1 << 31)
+#define   DATA_DONE_INT(1 << 30)
+#define   TRANS_OK_INT (1 << 29)
+#define   TRANS_FAIL_INT   (1 << 28)
+#define   XD_INT   (1 << 27)
+#define   MS_INT   (1 << 26)
+#define   SD_INT   (1 << 25)
+#define   GPIO0_INT(1 << 24)
+#define   OC_INT   (1 << 23)
+#define   SD_WRITE_PROTECT (1 << 19)
+#define   XD_EXIST (1 << 18)
+#define   MS_EXIST (1 << 17)
+#define   SD_EXIST (1 << 16)
+#define   DELINK_INT   GPIO0_INT
+#define   MS_OC_INT(1 << 23)
+#define   SD_OC_INT(1 << 22)
 
 #define CARD_INT   (XD_INT | MS_INT | SD_INT)
 #define NEED_COMPLETE_INT  (DATA_DONE_INT | TRANS_OK_INT | TRANS_FAIL_INT)
 #define RTSX_INT   (CMD_DONE_INT | NEED_COMPLETE_INT | \
CARD_INT | GPIO0_INT | OC_INT)
-
 #define CARD_EXIST (XD_EXIST | MS_EXIST | SD_EXIST)
 
-/* Bus interrupt enable register */
-#define CMD_DONE_INT_EN(1 << 31)
-#define DATA_DONE_INT_EN   (1 << 30)
-#define TRANS_OK_INT_EN   

[RESEND PATCH v2 1/9] mfd: rtsx: replace TAB by SPC after #define

2015-01-21 Thread micky_ching
From: Micky Ching 

Re-format coding-style, using uniform SPC after "#define" keyword
instead of mixing using TAB and SPC.

Signed-off-by: Micky Ching 
Acked-by: Lee Jones 
---
 include/linux/mfd/rtsx_pci.h | 254 +--
 1 file changed, 127 insertions(+), 127 deletions(-)

diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
index 0c12628..a9c2a14 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -175,9 +175,9 @@
 /* CARD_SHARE_MODE */
 #define CARD_SHARE_MASK0x0F
 #define CARD_SHARE_MULTI_LUN   0x00
-#defineCARD_SHARE_NORMAL   0x00
-#defineCARD_SHARE_48_SD0x04
-#defineCARD_SHARE_48_MS0x08
+#define CARD_SHARE_NORMAL  0x00
+#define CARD_SHARE_48_SD   0x04
+#define CARD_SHARE_48_MS   0x08
 /* CARD_SHARE_MODE for barossa */
 #define CARD_SHARE_BAROSSA_SD  0x01
 #define CARD_SHARE_BAROSSA_MS  0x02
@@ -249,76 +249,76 @@
 #define CD_AUTO_DISABLE0x40
 
 /* SD_STAT1 */
-#defineSD_CRC7_ERR 0x80
-#defineSD_CRC16_ERR0x40
-#defineSD_CRC_WRITE_ERR0x20
-#defineSD_CRC_WRITE_ERR_MASK   0x1C
-#defineGET_CRC_TIME_OUT0x02
-#defineSD_TUNING_COMPARE_ERR   0x01
+#define SD_CRC7_ERR0x80
+#define SD_CRC16_ERR   0x40
+#define SD_CRC_WRITE_ERR   0x20
+#define SD_CRC_WRITE_ERR_MASK  0x1C
+#define GET_CRC_TIME_OUT   0x02
+#define SD_TUNING_COMPARE_ERR  0x01
 
 /* SD_STAT2 */
-#defineSD_RSP_80CLK_TIMEOUT0x01
+#define SD_RSP_80CLK_TIMEOUT   0x01
 
 /* SD_BUS_STAT */
-#defineSD_CLK_TOGGLE_EN0x80
-#defineSD_CLK_FORCE_STOP   0x40
-#defineSD_DAT3_STATUS  0x10
-#defineSD_DAT2_STATUS  0x08
-#defineSD_DAT1_STATUS  0x04
-#defineSD_DAT0_STATUS  0x02
-#defineSD_CMD_STATUS   0x01
+#define SD_CLK_TOGGLE_EN   0x80
+#define SD_CLK_FORCE_STOP  0x40
+#define SD_DAT3_STATUS 0x10
+#define SD_DAT2_STATUS 0x08
+#define SD_DAT1_STATUS 0x04
+#define SD_DAT0_STATUS 0x02
+#define SD_CMD_STATUS  0x01
 
 /* SD_PAD_CTL */
-#defineSD_IO_USING_1V8 0x80
-#defineSD_IO_USING_3V3 0x7F
-#defineTYPE_A_DRIVING  0x00
-#defineTYPE_B_DRIVING  0x01
-#defineTYPE_C_DRIVING  0x02
-#defineTYPE_D_DRIVING  0x03
+#define SD_IO_USING_1V80x80
+#define SD_IO_USING_3V30x7F
+#define TYPE_A_DRIVING 0x00
+#define TYPE_B_DRIVING 0x01
+#define TYPE_C_DRIVING 0x02
+#define TYPE_D_DRIVING 0x03
 
 /* SD_SAMPLE_POINT_CTL */
-#defineDDR_FIX_RX_DAT  0x00
-#defineDDR_VAR_RX_DAT  0x80
-#defineDDR_FIX_RX_DAT_EDGE 0x00
-#defineDDR_FIX_RX_DAT_14_DELAY 0x40
-#defineDDR_FIX_RX_CMD  0x00
-#defineDDR_VAR_RX_CMD  0x20
-#defineDDR_FIX_RX_CMD_POS_EDGE 0x00
-#defineDDR_FIX_RX_CMD_14_DELAY 0x10
-#defineSD20_RX_POS_EDGE0x00
-#defineSD20_RX_14_DELAY0x08
+#define DDR_FIX_RX_DAT 0x00
+#define DDR_VAR_RX_DAT 0x80
+#define DDR_FIX_RX_DAT_EDGE0x00
+#define DDR_FIX_RX_DAT_14_DELAY0x40
+#define DDR_FIX_RX_CMD 0x00
+#define DDR_VAR_RX_CMD 0x20
+#define DDR_FIX_RX_CMD_POS_EDGE0x00
+#define DDR_FIX_RX_CMD_14_DELAY0x10
+#define SD20_RX_POS_EDGE   0x00
+#define SD20_RX_14_DELAY   0x08
 #define SD20_RX_SEL_MASK   0x08
 
 /* SD_PUSH_POINT_CTL */
-#defineDDR_FIX_TX_CMD_DAT  0x00
-#defineDDR_VAR_TX_CMD_DAT  0x80
-#defineDDR_FIX_TX_DAT_14_TSU   0x00
-#defineDDR_FIX_TX_DAT_12_TSU   0x40
-#defineDDR_FIX_TX_CMD_NEG_EDGE 0x00
-#defineDDR_FIX_TX_CMD_14_AHEAD 0x20
-#defineSD20_TX_NEG_EDGE0x00
-#defineSD20_TX_14_AHEAD0x10
+#define DDR_FIX_TX_CMD_DAT 0x00
+#define DDR_VAR_TX_CMD_DAT 0x80
+#define DDR_FIX_TX_DAT_14_TSU  0x00
+#define DDR_FIX_TX_DAT_12_TSU  0x40
+#define DDR_FIX_TX_CMD_NEG_EDGE0x00
+#define DDR_FIX_TX_CMD_14_AHEAD0x20
+#define SD2

[RESEND PATCH v2 8/9] mfd: rtsx: add support for rts525A

2015-01-21 Thread micky_ching
From: Micky Ching 

add support for new chip rts525A.

Signed-off-by: Micky Ching 
---
 drivers/mfd/rts5249.c| 104 ++-
 drivers/mfd/rtsx_pcr.c   |  13 --
 drivers/mfd/rtsx_pcr.h   |   1 +
 include/linux/mfd/rtsx_pci.h |  15 +++
 4 files changed, 129 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
index 97dde92..134e03f 100644
--- a/drivers/mfd/rts5249.c
+++ b/drivers/mfd/rts5249.c
@@ -97,7 +97,7 @@ static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, 
u8 pm_state)
rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0);
 
if (pm_state == HOST_ENTER_S3) {
-   if (PCI_PID(pcr) == 0x524A)
+   if (PCI_PID(pcr) == 0x524A || PCI_PID(pcr) == 0x525A)
rtsx_pci_write_register(pcr, RTS524A_PM_CTRL3,
D3_DELINK_MODE_EN, D3_DELINK_MODE_EN);
else if (PCI_PID(pcr) == 0x5249)
@@ -485,3 +485,105 @@ void rts524a_init_params(struct rtsx_pcr *pcr)
pcr->ops = &rts524a_pcr_ops;
 }
 
+static int rts525a_card_power_on(struct rtsx_pcr *pcr, int card)
+{
+   rtsx_pci_write_register(pcr, LDO_VCC_CFG1,
+   LDO_VCC_TUNE_MASK, LDO_VCC_3V3);
+   return rtsx_base_card_power_on(pcr, card);
+}
+
+static int rts525a_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
+{
+   switch (voltage) {
+   case OUTPUT_3V3:
+   rtsx_pci_write_register(pcr, LDO_CONFIG2,
+   LDO_D3318_MASK, LDO_D3318_33V);
+   rtsx_pci_write_register(pcr, SD_PAD_CTL, SD_IO_USING_1V8, 0);
+   break;
+   case OUTPUT_1V8:
+   rtsx_pci_write_register(pcr, LDO_CONFIG2,
+   LDO_D3318_MASK, LDO_D3318_18V);
+   rtsx_pci_write_register(pcr, SD_PAD_CTL, SD_IO_USING_1V8,
+   SD_IO_USING_1V8);
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   rtsx_pci_init_cmd(pcr);
+   rts5249_fill_driving(pcr, voltage);
+   return rtsx_pci_send_cmd(pcr, 100);
+}
+
+static int rts525a_optimize_phy(struct rtsx_pcr *pcr)
+{
+   int err;
+
+   err = rtsx_pci_write_register(pcr, RTS524A_PM_CTRL3,
+   D3_DELINK_MODE_EN, 0x00);
+   if (err < 0)
+   return err;
+
+   rtsx_pci_write_phy_register(pcr, _PHY_FLD0,
+   _PHY_FLD0_CLK_REQ_20C | _PHY_FLD0_RX_IDLE_EN |
+   _PHY_FLD0_BIT_ERR_RSTN | _PHY_FLD0_BER_COUNT |
+   _PHY_FLD0_BER_TIMER | _PHY_FLD0_CHECK_EN);
+
+   rtsx_pci_write_phy_register(pcr, _PHY_ANA03,
+   _PHY_ANA03_TIMER_MAX | _PHY_ANA03_OOBS_DEB_EN |
+   _PHY_CMU_DEBUG_EN);
+
+   if (is_version(pcr, 0x525A, IC_VER_A))
+   rtsx_pci_write_phy_register(pcr, _PHY_REV0,
+   _PHY_REV0_FILTER_OUT | _PHY_REV0_CDR_BYPASS_PFD |
+   _PHY_REV0_CDR_RX_IDLE_BYPASS);
+
+   return 0;
+}
+
+static int rts525a_extra_init_hw(struct rtsx_pcr *pcr)
+{
+   rts5249_extra_init_hw(pcr);
+
+   rtsx_pci_write_register(pcr, PCLK_CTL, PCLK_MODE_SEL, PCLK_MODE_SEL);
+   if (is_version(pcr, 0x525A, IC_VER_A)) {
+   rtsx_pci_write_register(pcr, L1SUB_CONFIG2,
+   L1SUB_AUTO_CFG, L1SUB_AUTO_CFG);
+   rtsx_pci_write_register(pcr, RREF_CFG,
+   RREF_VBGSEL_MASK, RREF_VBGSEL_1V25);
+   rtsx_pci_write_register(pcr, LDO_VIO_CFG,
+   LDO_VIO_TUNE_MASK, LDO_VIO_1V7);
+   rtsx_pci_write_register(pcr, LDO_DV12S_CFG,
+   LDO_D12_TUNE_MASK, LDO_D12_TUNE_DF);
+   rtsx_pci_write_register(pcr, LDO_AV12S_CFG,
+   LDO_AV12S_TUNE_MASK, LDO_AV12S_TUNE_DF);
+   rtsx_pci_write_register(pcr, LDO_VCC_CFG0,
+   LDO_VCC_LMTVTH_MASK, LDO_VCC_LMTVTH_2A);
+   rtsx_pci_write_register(pcr, OOBS_CONFIG,
+   OOBS_AUTOK_DIS | OOBS_VAL_MASK, 0x89);
+   }
+
+   return 0;
+}
+
+static const struct pcr_ops rts525a_pcr_ops = {
+   .fetch_vendor_settings = rtsx_base_fetch_vendor_settings,
+   .extra_init_hw = rts525a_extra_init_hw,
+   .optimize_phy = rts525a_optimize_phy,
+   .turn_on_led = rtsx_base_turn_on_led,
+   .turn_off_led = rtsx_base_turn_off_led,
+   .enable_auto_blink = rtsx_base_enable_auto_blink,
+   .disable_auto_blink = rtsx_base_disable_auto_blink,
+   .card_power_on = rts525a_card_power_on,
+   .card_power_off = rtsx_base_card_power_off,
+   .switch_output_voltage = rts525a_switch_output_voltage,
+   .force_power_down = rtsx_base_force_power_down,
+};
+
+void rts525a_init_params(struct rtsx_pcr *pcr)
+{
+   rts5249_init_params(pcr);
+
+   pcr->ops = &rts525a_pcr_ops;
+}
+
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
index e6d97ad..4c47f94 100644
-

[RESEND PATCH v2 7/9] mfd: rtsx: add support for rts524A

2015-01-21 Thread micky_ching
From: Micky Ching 

add support for new chip rts524A.

Signed-off-by: Micky Ching 
---
 drivers/mfd/rts5249.c| 186 ---
 drivers/mfd/rtsx_pcr.c   |  25 +-
 drivers/mfd/rtsx_pcr.h   |   7 ++
 include/linux/mfd/rtsx_pci.h | 125 -
 4 files changed, 310 insertions(+), 33 deletions(-)

diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
index 3977946..97dde92 100644
--- a/drivers/mfd/rts5249.c
+++ b/drivers/mfd/rts5249.c
@@ -65,15 +65,17 @@ static void rts5249_fill_driving(struct rtsx_pcr *pcr, u8 
voltage)
0xFF, driving[drive_sel][2]);
 }
 
-static void rts5249_fetch_vendor_settings(struct rtsx_pcr *pcr)
+static void rtsx_base_fetch_vendor_settings(struct rtsx_pcr *pcr)
 {
u32 reg;
 
rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®);
dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
 
-   if (!rtsx_vendor_setting_valid(reg))
+   if (!rtsx_vendor_setting_valid(reg)) {
+   pcr_dbg(pcr, "skip fetch vendor setting\n");
return;
+   }
 
pcr->aspm_en = rtsx_reg_to_aspm(reg);
pcr->sd30_drive_sel_1v8 = rtsx_reg_to_sd30_drive_sel_1v8(reg);
@@ -87,15 +89,21 @@ static void rts5249_fetch_vendor_settings(struct rtsx_pcr 
*pcr)
pcr->flags |= PCR_REVERSE_SOCKET;
 }
 
-static void rts5249_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
+static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
 {
/* Set relink_time to 0 */
rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, 0xFF, 0);
rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, 0xFF, 0);
rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0);
 
-   if (pm_state == HOST_ENTER_S3)
-   rtsx_pci_write_register(pcr, PM_CTRL3, 0x10, 0x10);
+   if (pm_state == HOST_ENTER_S3) {
+   if (PCI_PID(pcr) == 0x524A)
+   rtsx_pci_write_register(pcr, RTS524A_PM_CTRL3,
+   D3_DELINK_MODE_EN, D3_DELINK_MODE_EN);
+   else if (PCI_PID(pcr) == 0x5249)
+   rtsx_pci_write_register(pcr, PM_CTRL3,
+   D3_DELINK_MODE_EN, D3_DELINK_MODE_EN);
+   }
 
rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03);
 }
@@ -104,6 +112,8 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)
 {
rtsx_pci_init_cmd(pcr);
 
+   /* Rest L1SUB Config */
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, L1SUB_CONFIG3, 0xFF, 0x00);
/* Configure GPIO as output */
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, GPIO_CTL, 0x02, 0x02);
/* Reset ASPM state to default value */
@@ -189,27 +199,27 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
PHY_TUNE_TUNED12 | PHY_TUNE_TUNEA12);
 }
 
-static int rts5249_turn_on_led(struct rtsx_pcr *pcr)
+static int rtsx_base_turn_on_led(struct rtsx_pcr *pcr)
 {
return rtsx_pci_write_register(pcr, GPIO_CTL, 0x02, 0x02);
 }
 
-static int rts5249_turn_off_led(struct rtsx_pcr *pcr)
+static int rtsx_base_turn_off_led(struct rtsx_pcr *pcr)
 {
return rtsx_pci_write_register(pcr, GPIO_CTL, 0x02, 0x00);
 }
 
-static int rts5249_enable_auto_blink(struct rtsx_pcr *pcr)
+static int rtsx_base_enable_auto_blink(struct rtsx_pcr *pcr)
 {
return rtsx_pci_write_register(pcr, OLT_LED_CTL, 0x08, 0x08);
 }
 
-static int rts5249_disable_auto_blink(struct rtsx_pcr *pcr)
+static int rtsx_base_disable_auto_blink(struct rtsx_pcr *pcr)
 {
return rtsx_pci_write_register(pcr, OLT_LED_CTL, 0x08, 0x00);
 }
 
-static int rts5249_card_power_on(struct rtsx_pcr *pcr, int card)
+static int rtsx_base_card_power_on(struct rtsx_pcr *pcr, int card)
 {
int err;
 
@@ -236,7 +246,7 @@ static int rts5249_card_power_on(struct rtsx_pcr *pcr, int 
card)
return 0;
 }
 
-static int rts5249_card_power_off(struct rtsx_pcr *pcr, int card)
+static int rtsx_base_card_power_off(struct rtsx_pcr *pcr, int card)
 {
rtsx_pci_init_cmd(pcr);
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_PWR_CTL,
@@ -246,22 +256,31 @@ static int rts5249_card_power_off(struct rtsx_pcr *pcr, 
int card)
return rtsx_pci_send_cmd(pcr, 100);
 }
 
-static int rts5249_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
+static int rtsx_base_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
 {
int err;
+   u16 append;
 
-   if (voltage == OUTPUT_3V3) {
-   err = rtsx_pci_write_phy_register(pcr, PHY_TUNE, 0x4FC0 | 0x24);
-   if (err < 0)
-   return err;
-   } else if (voltage == OUTPUT_1V8) {
-   err = rtsx_pci_write_phy_register(pcr, PHY_BACR, 0x3C02);
+   switch (voltage) {
+   case OUTPUT_3V3:
+   err = rtsx_pci_update_phy(pcr, PHY_TUNE, 0xFC3F, 0x03C0);
if (err < 0)
return err;
- 

[RESEND PATCH v2 6/9] mfd: rtsx: remove LCTLR defination

2015-01-21 Thread micky_ching
From: Micky Ching 

To enable/disable ASPM we should find LINK CONTROL register
in PCI config space. All old chip use 0x80 address, but new
chip may use another address, so we using pci_find_capability()
to get LINK CONTROL address.

rtsx_gops.c was removed, we consider to put some common operations
to this file, but the actual thing is, only a group of chips
are in common ops1, and another group of chips in common ops2,
it is hard to decide put which ops into generic ops file.

Signed-off-by: Micky Ching 
---
 drivers/mfd/Makefile |  2 +-
 drivers/mfd/rts5227.c|  2 +-
 drivers/mfd/rts5249.c|  3 +--
 drivers/mfd/rtsx_gops.c  | 37 -
 drivers/mfd/rtsx_pcr.c   | 22 +-
 include/linux/mfd/rtsx_pci.h | 10 +-
 6 files changed, 21 insertions(+), 55 deletions(-)
 delete mode 100644 drivers/mfd/rtsx_gops.c

diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 53467e2..2cd7e74 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -13,7 +13,7 @@ obj-$(CONFIG_MFD_CROS_EC) += cros_ec.o
 obj-$(CONFIG_MFD_CROS_EC_I2C)  += cros_ec_i2c.o
 obj-$(CONFIG_MFD_CROS_EC_SPI)  += cros_ec_spi.o
 
-rtsx_pci-objs  := rtsx_pcr.o rtsx_gops.o rts5209.o rts5229.o 
rtl8411.o rts5227.o rts5249.o
+rtsx_pci-objs  := rtsx_pcr.o rts5209.o rts5229.o rtl8411.o 
rts5227.o rts5249.o
 obj-$(CONFIG_MFD_RTSX_PCI) += rtsx_pci.o
 obj-$(CONFIG_MFD_RTSX_USB) += rtsx_usb.o
 
diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c
index 1f387d4..0c02831 100644
--- a/drivers/mfd/rts5227.c
+++ b/drivers/mfd/rts5227.c
@@ -130,7 +130,7 @@ static int rts5227_optimize_phy(struct rtsx_pcr *pcr)
 {
int err;
 
-   err = rtsx_gops_pm_reset(pcr);
+   err = rtsx_pci_write_register(pcr, PM_CTRL3, D3_DELINK_MODE_EN, 0x00);
if (err < 0)
return err;
 
diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
index d8072f6..3977946 100644
--- a/drivers/mfd/rts5249.c
+++ b/drivers/mfd/rts5249.c
@@ -119,7 +119,6 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB0, 0xB0);
else
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB0, 0x80);
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PM_CTRL3, 0x10, 0x00);
 
return rtsx_pci_send_cmd(pcr, 100);
 }
@@ -128,7 +127,7 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
 {
int err;
 
-   err = rtsx_gops_pm_reset(pcr);
+   err = rtsx_pci_write_register(pcr, PM_CTRL3, D3_DELINK_MODE_EN, 0x00);
if (err < 0)
return err;
 
diff --git a/drivers/mfd/rtsx_gops.c b/drivers/mfd/rtsx_gops.c
deleted file mode 100644
index b1a98c6..000
--- a/drivers/mfd/rtsx_gops.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Driver for Realtek PCI-Express card reader
- *
- * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see .
- *
- * Author:
- *   Micky Ching 
- */
-
-#include 
-#include "rtsx_pcr.h"
-
-int rtsx_gops_pm_reset(struct rtsx_pcr *pcr)
-{
-   int err;
-
-   /* init aspm */
-   rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, 0xFF, 0x00);
-   err = rtsx_pci_update_cfg_byte(pcr, LCTLR, ~LCTLR_ASPM_CTL_MASK, 0x00);
-   if (err < 0)
-   return err;
-
-   /* reset PM_CTRL3 before send buffer cmd */
-   return rtsx_pci_write_register(pcr, PM_CTRL3, D3_DELINK_MODE_EN, 0x00);
-}
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
index 30f7ca8..81b9c2c 100644
--- a/drivers/mfd/rtsx_pcr.c
+++ b/drivers/mfd/rtsx_pcr.c
@@ -63,6 +63,18 @@ static const struct pci_device_id rtsx_pci_ids[] = {
 
 MODULE_DEVICE_TABLE(pci, rtsx_pci_ids);
 
+static inline void rtsx_pci_enable_aspm(struct rtsx_pcr *pcr)
+{
+   rtsx_pci_update_cfg_byte(pcr, pcr->pcie_cap + PCI_EXP_LNKCTL,
+   0xFC, pcr->aspm_en);
+}
+
+static inline void rtsx_pci_disable_aspm(struct rtsx_pcr *pcr)
+{
+   rtsx_pci_update_cfg_byte(pcr, pcr->pcie_cap + PCI_EXP_LNKCTL,
+   0xFC, 0);
+}
+
 void rtsx_pci_start_run(struct rtsx_pcr *pcr)
 {
/* If pci device removed, don't queue idle work any more */
@@ -75,7 +87,7 @@ void rtsx_pci_start_run(struct rtsx_pcr *pcr)
pcr->ops->enable_auto_blink(pcr);
 

[RESEND PATCH v2 3/9] mfd: rtsx: update PETXCFG address

2015-01-21 Thread micky_ching
From: Micky Ching 

PETXCFG is defined at 0xFF03, the old 0xFE49 not used any more.

Signed-off-by: Micky Ching 
Acked-by: Lee Jones 
---
 drivers/mfd/rts5227.c| 6 ++
 drivers/mfd/rts5249.c| 6 ++
 include/linux/mfd/rtsx_pci.h | 2 +-
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c
index 3240740..1f387d4 100644
--- a/drivers/mfd/rts5227.c
+++ b/drivers/mfd/rts5227.c
@@ -118,11 +118,9 @@ static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)
rts5227_fill_driving(pcr, OUTPUT_3V3);
/* Configure force_clock_req */
if (pcr->flags & PCR_REVERSE_SOCKET)
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
-   AUTOLOAD_CFG_BASE + 3, 0xB8, 0xB8);
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB8, 0xB8);
else
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
-   AUTOLOAD_CFG_BASE + 3, 0xB8, 0x88);
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB8, 0x88);
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PM_CTRL3, 0x10, 0x00);
 
return rtsx_pci_send_cmd(pcr, 100);
diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
index cf425cc..225ad55 100644
--- a/drivers/mfd/rts5249.c
+++ b/drivers/mfd/rts5249.c
@@ -116,11 +116,9 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)
/* Configure driving */
rts5249_fill_driving(pcr, OUTPUT_3V3);
if (pcr->flags & PCR_REVERSE_SOCKET)
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
-   AUTOLOAD_CFG_BASE + 3, 0xB0, 0xB0);
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB0, 0xB0);
else
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
-   AUTOLOAD_CFG_BASE + 3, 0xB0, 0x80);
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB0, 0x80);
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PM_CTRL3, 0x10, 0x00);
 
return rtsx_pci_send_cmd(pcr, 100);
diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
index e81f2bb..87cff60 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -572,7 +572,6 @@
 #define MSGTXDATA2 0xFE46
 #define MSGTXDATA3 0xFE47
 #define MSGTXCTL   0xFE48
-#define PETXCFG0xFE49
 #define LTR_CTL0xFE4A
 #define OBFF_CFG   0xFE4C
 
@@ -606,6 +605,7 @@
 #define DUMMY_REG_RESET_0  0xFE90
 
 #define AUTOLOAD_CFG_BASE  0xFF00
+#define PETXCFG0xFF03
 
 #define PM_CTRL1   0xFF44
 #define PM_CTRL2   0xFF45
-- 
1.9.1

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


[patch] staging: lustre: remove the CFS_HOP() macro

2015-01-21 Thread Dan Carpenter
CFS_HOP() is a terrible macro.  It chops the struct member name in half
so that it's not possible to use tools like grep or to search for how
a function pointer is used.

I removed a couple calls to:

LASSERT(CFS_HOP(hs, put_locked) != NULL);

because they isn't a need for them.  Anyway dereferencing a NULL pointer
generates a pretty good stack trace already without adding extra debug
code.

Signed-off-by: Dan Carpenter 
---
Btw, the block layer people made a change so lustre fs is BROKEN again
in yesterday's linux-next.

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
index 375586b..808e494 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
@@ -454,25 +454,23 @@ cfs_hash_bkt_size(struct cfs_hash *hs)
   hs->hs_extra_bytes;
 }
 
-#define CFS_HOP(hs, op)   (hs)->hs_ops->hs_ ## op
-
 static inline unsigned
 cfs_hash_id(struct cfs_hash *hs, const void *key, unsigned mask)
 {
-   return CFS_HOP(hs, hash)(hs, key, mask);
+   return hs->hs_ops->hs_hash(hs, key, mask);
 }
 
 static inline void *
 cfs_hash_key(struct cfs_hash *hs, struct hlist_node *hnode)
 {
-   return CFS_HOP(hs, key)(hnode);
+   return hs->hs_ops->hs_key(hnode);
 }
 
 static inline void
 cfs_hash_keycpy(struct cfs_hash *hs, struct hlist_node *hnode, void *key)
 {
-   if (CFS_HOP(hs, keycpy) != NULL)
-   CFS_HOP(hs, keycpy)(hnode, key);
+if (hs->hs_ops->hs_keycpy)
+   hs->hs_ops->hs_keycpy(hnode, key);
 }
 
 /**
@@ -481,42 +479,38 @@ cfs_hash_keycpy(struct cfs_hash *hs, struct hlist_node 
*hnode, void *key)
 static inline int
 cfs_hash_keycmp(struct cfs_hash *hs, const void *key, struct hlist_node *hnode)
 {
-   return CFS_HOP(hs, keycmp)(key, hnode);
+   return hs->hs_ops->hs_keycmp(key, hnode);
 }
 
 static inline void *
 cfs_hash_object(struct cfs_hash *hs, struct hlist_node *hnode)
 {
-   return CFS_HOP(hs, object)(hnode);
+   return hs->hs_ops->hs_object(hnode);
 }
 
 static inline void
 cfs_hash_get(struct cfs_hash *hs, struct hlist_node *hnode)
 {
-   return CFS_HOP(hs, get)(hs, hnode);
+   return hs->hs_ops->hs_get(hs, hnode);
 }
 
 static inline void
 cfs_hash_put_locked(struct cfs_hash *hs, struct hlist_node *hnode)
 {
-   LASSERT(CFS_HOP(hs, put_locked) != NULL);
-
-   return CFS_HOP(hs, put_locked)(hs, hnode);
+   return hs->hs_ops->hs_put_locked(hs, hnode);
 }
 
 static inline void
 cfs_hash_put(struct cfs_hash *hs, struct hlist_node *hnode)
 {
-   LASSERT(CFS_HOP(hs, put) != NULL);
-
-   return CFS_HOP(hs, put)(hs, hnode);
+   return hs->hs_ops->hs_put(hs, hnode);
 }
 
 static inline void
 cfs_hash_exit(struct cfs_hash *hs, struct hlist_node *hnode)
 {
-   if (CFS_HOP(hs, exit))
-   CFS_HOP(hs, exit)(hs, hnode);
+   if (hs->hs_ops->hs_exit)
+   hs->hs_ops->hs_exit(hs, hnode);
 }
 
 static inline void cfs_hash_lock(struct cfs_hash *hs, int excl)
diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c 
b/drivers/staging/lustre/lustre/libcfs/hash.c
index 2d1e672..3e9891a 100644
--- a/drivers/staging/lustre/lustre/libcfs/hash.c
+++ b/drivers/staging/lustre/lustre/libcfs/hash.c
@@ -1580,7 +1580,7 @@ cfs_hash_for_each_relax(struct cfs_hash *hs, 
cfs_hash_for_each_cb_t func,
 
stop_on_change = cfs_hash_with_rehash_key(hs) ||
 !cfs_hash_with_no_itemref(hs) ||
-CFS_HOP(hs, put_locked) == NULL;
+hs->hs_ops->hs_put_locked == NULL;
cfs_hash_lock(hs, 0);
LASSERT(!cfs_hash_is_rehashing(hs));
 
@@ -1635,9 +1635,9 @@ cfs_hash_for_each_nolock(struct cfs_hash *hs,
!cfs_hash_with_no_itemref(hs))
return -EOPNOTSUPP;
 
-   if (CFS_HOP(hs, get) == NULL ||
-   (CFS_HOP(hs, put) == NULL &&
-CFS_HOP(hs, put_locked) == NULL))
+   if (hs->hs_ops->hs_get == NULL ||
+   (hs->hs_ops->hs_put == NULL &&
+hs->hs_ops->hs_put_locked == NULL))
return -EOPNOTSUPP;
 
cfs_hash_for_each_enter(hs);
@@ -1667,9 +1667,9 @@ cfs_hash_for_each_empty(struct cfs_hash *hs,
if (cfs_hash_with_no_lock(hs))
return -EOPNOTSUPP;
 
-   if (CFS_HOP(hs, get) == NULL ||
-   (CFS_HOP(hs, put) == NULL &&
-CFS_HOP(hs, put_locked) == NULL))
+   if (hs->hs_ops->hs_get == NULL ||
+   (hs->hs_ops->hs_put == NULL &&
+hs->hs_ops->hs_put_locked == NULL))
return -EOPNOTSUPP;
 
cfs_hash_for_each_enter(hs);
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel