drivers/clocksource/timer-of.h:35:28: error: field 'clkevt' has incomplete type

2017-09-02 Thread kbuild test robot
Hi Daniel,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   d0d6ab53c9abd7dd1070f43a0455328874127ba8
commit: dc11bae78529526605c5c45c369c9512fd012093 clocksource/drivers: Add 
timer-of common init routine
date:   3 months ago
config: ia64-allyesconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout dc11bae78529526605c5c45c369c9512fd012093
# save the attached .config to linux build tree
make.cross ARCH=ia64 

All errors (new ones prefixed by >>):

   In file included from drivers/clocksource/timer-of.c:25:0:
>> drivers/clocksource/timer-of.h:35:28: error: field 'clkevt' has incomplete 
>> type
 struct clock_event_device clkevt;
   ^~
   In file included from include/linux/clk.h:16:0,
from drivers/clocksource/timer-of.c:18:
   drivers/clocksource/timer-of.h: In function 'to_timer_of':
   include/linux/kernel.h:854:48: error: initialization from incompatible 
pointer type [-Werror=incompatible-pointer-types]
 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
   ^
   drivers/clocksource/timer-of.h:44:9: note: in expansion of macro 
'container_of'
 return container_of(clkevt, struct timer_of, clkevt);
^~~~
   drivers/clocksource/timer-of.c: In function 'timer_irq_init':
   drivers/clocksource/timer-of.c:63:8: error: dereferencing pointer to 
incomplete type 'struct clock_event_device'
 clkevt->irq = of_irq->irq;
   ^~
   cc1: some warnings being treated as errors

vim +/clkevt +35 drivers/clocksource/timer-of.h

32  
33  struct timer_of {
34  unsigned int flags;
  > 35  struct clock_event_device clkevt;
36  struct of_timer_base of_base;
37  struct of_timer_irq  of_irq;
38  struct of_timer_clk  of_clk;
39  void *private_data;
40  };
41  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH][next] IB/core: fix spelling mistake: "aceess" -> "access"

2017-09-02 Thread Leon Romanovsky
On Fri, Sep 01, 2017 at 09:22:14AM +0100, Colin King wrote:
> From: Colin Ian King 
>
> Trivial fix to spelling mistake in WARN message
>
> Signed-off-by: Colin Ian King 
> ---
>  drivers/infiniband/core/uverbs_ioctl_merge.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Thanks,
Reviewed-by: Leon Romanovsky 


signature.asc
Description: PGP signature


Re: [PATCH v7 00/19] simplify crypto wait for async op

2017-09-02 Thread Gilad Ben-Yossef
On Thu, Aug 31, 2017 at 3:31 PM, Harsh Jain  wrote:
> HI Gilad,
>
> I think we need an update in ESP also. Now EBUSY return means driver
> has accepted, Packet should not be dropped in
>
> esp_output_tail() function.

Good catch. You are right and the same holds true for ah_output() in ah4.c.

But I do wonder, the code there now treats -EBUSY as a special case
and returns NET_XMIT_DROP
but if an AEAD or AHASH transformation return some other error, like
-ENOMEM or -EINVAL shouldn't
we return NET_XMIT_DROP in that case too?

Any ideas?

Gilad

>
>
> On Thu, Aug 24, 2017 at 7:48 PM, Gilad Ben-Yossef  wrote:
>> Many users of kernel async. crypto services have a pattern of
>> starting an async. crypto op and than using a completion
>> to wait for it to end.
>>
>> This patch set simplifies this common use case in two ways:
>>
>> First, by separating the return codes of the case where a
>> request is queued to a backlog due to the provider being
>> busy (-EBUSY) from the case the request has failed due
>> to the provider being busy and backlogging is not enabled
>> (-EAGAIN).
>>
>> Next, this change is than built on to create a generic API
>> to wait for a async. crypto operation to complete.
>>
>> The end result is a smaller code base and an API that is
>> easier to use and more difficult to get wrong.
>>
>> The patch set was boot tested on x86_64 and arm64 which
>> at the very least tests the crypto users via testmgr and
>> tcrypt but I do note that I do not have access to some
>> of the HW whose drivers are modified nor do I claim I was
>> able to test all of the corner cases.
>>
>> The patch set is based upon linux-next release tagged
>> next-20170824.
>>
>> Changes from v6:
>> - Fix brown paper bag compile error on marvell/cesa
>>   code.
>>
>> Changes from v5:
>> - Remove redundant new line as spotted by Jonathan
>>   Cameron.
>> - Reworded dm-verity change commit message to better
>>   clarify potential issue averted by change as
>>   pointed out by Mikulas Patocka.
>>
>> Changes from v4:
>> - Rebase on top of latest algif changes from Stephan
>>   Mueller.
>> - Fix typo in ccp patch title.
>>
>> Changes from v3:
>> - Instead of changing the return code to indicate
>>   backlog queueing, change the return code to indicate
>>   transient busy state, as suggested by Herbert Xu.
>>
>> Changes from v2:
>> - Patch title changed from "introduce crypto wait for
>>   async op" to better reflect the current state.
>> - Rebase on top of latest linux-next.
>> - Add a new return code of -EIOCBQUEUED for backlog
>>   queueing, as suggested by Herbert Xu.
>> - Transform more users to the new API.
>> - Update the drbg change to account for new init as
>>   indicated by Stephan Muller.
>>
>> Changes from v1:
>> - Address review comments from Eric Biggers.
>> - Separated out bug fixes of existing code and rebase
>>   on top of that patch set.
>> - Rename 'ecr' to 'wait' in fscrypto code.
>> - Split patch introducing the new API from the change
>>   moving over the algif code which it originated from
>>   to the new API.
>> - Inline crypto_wait_req().
>> - Some code indentation fixes.
>>
>> Gilad Ben-Yossef (19):
>>   crypto: change transient busy return code to -EAGAIN
>>   crypto: ccp: use -EAGAIN for transient busy indication
>>   crypto: remove redundant backlog checks on EBUSY
>>   crypto: marvell/cesa: remove redundant backlog checks on EBUSY
>>   crypto: introduce crypto wait for async op
>>   crypto: move algif to generic async completion
>>   crypto: move pub key to generic async completion
>>   crypto: move drbg to generic async completion
>>   crypto: move gcm to generic async completion
>>   crypto: move testmgr to generic async completion
>>   fscrypt: move to generic async completion
>>   dm: move dm-verity to generic async completion
>>   cifs: move to generic async completion
>>   ima: move to generic async completion
>>   crypto: tcrypt: move to generic async completion
>>   crypto: talitos: move to generic async completion
>>   crypto: qce: move to generic async completion
>>   crypto: mediatek: move to generic async completion
>>   crypto: adapt api sample to use async. op wait
>>
>>  Documentation/crypto/api-samples.rst |  52 ++---
>>  crypto/af_alg.c  |  27 -
>>  crypto/ahash.c   |  12 +--
>>  crypto/algapi.c  |   6 +-
>>  crypto/algif_aead.c  |   8 +-
>>  crypto/algif_hash.c  |  50 +
>>  crypto/algif_skcipher.c  |   9 +-
>>  crypto/api.c |  13 +++
>>  crypto/asymmetric_keys/public_key.c  |  28 +
>>  crypto/cryptd.c  |   4 +-
>>  crypto/cts.c |   6 +-
>>  crypto/drbg.c|  36 ++-
>>  crypto/gcm.c |  32 ++
>>  crypto/lrw.c |   8 +-
>>  crypto/rsa-pkcs1pad.c|  16 +--
>>  crypto/tcrypt.c  |  84 +-

Re: [PATCH] virt/kvm avoids oops by adding parameter checking

2017-09-02 Thread kbuild test robot
Hi nixiaoming,

[auto build test ERROR on v4.13-rc6]
[also build test ERROR on next-20170901]
[cannot apply to kvm/linux-next]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/nixiaoming/virt-kvm-avoids-oops-by-adding-parameter-checking/20170823-203000
config: mips-malta_kvm_defconfig (attached as .config)
compiler: mipsel-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=mips 

All errors (new ones prefixed by >>):

   arch/mips/kvm/../../../virt/kvm/kvm_main.c: In function 
'kvm_flush_remote_tlbs':
>> arch/mips/kvm/../../../virt/kvm/kvm_main.c:248:2: error: ISO C90 forbids 
>> mixed declarations and code [-Werror=declaration-after-statement]
 long dirty_count = smp_load_acquire(&kvm->tlbs_dirty);
 ^~~~
   arch/mips/kvm/../../../virt/kvm/kvm_main.c: In function 
'kvm_write_guest_offset_cached':
   arch/mips/kvm/../../../virt/kvm/kvm_main.c:2025:2: error: ISO C90 forbids 
mixed declarations and code [-Werror=declaration-after-statement]
 gpa_t gpa = ghc->gpa + offset;
 ^
   cc1: all warnings being treated as errors

vim +248 arch/mips/kvm/../../../virt/kvm/kvm_main.c

d9e368d6 drivers/kvm/kvm_main.c Avi Kivity   2007-06-07  238  
a6d51016 virt/kvm/kvm_main.cMario Smarduch   2015-01-15  239  #ifndef 
CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL
49846896 virt/kvm/kvm_main.cRusty Russell2008-12-08  240  void 
kvm_flush_remote_tlbs(struct kvm *kvm)
2e53d63a virt/kvm/kvm_main.cMarcelo Tosatti  2008-02-20  241  {
6f1ad410 virt/kvm/kvm_main.cnixiaoming   2017-08-22  242if (kvm 
== NULL)
6f1ad410 virt/kvm/kvm_main.cnixiaoming   2017-08-22  243
return;
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  244/*
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  245 * Read 
tlbs_dirty before setting KVM_REQ_TLB_FLUSH in
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  246 * 
kvm_make_all_cpus_request.
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  247 */
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13 @248long 
dirty_count = smp_load_acquire(&kvm->tlbs_dirty);
a086f6a1 virt/kvm/kvm_main.cXiao Guangrong   2014-04-17  249  
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  250/*
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  251 * We 
want to publish modifications to the page tables before reading
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  252 * 
mode. Pairs with a memory barrier in arch-specific code.
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  253 * - 
x86: smp_mb__after_srcu_read_unlock in vcpu_enter_guest
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  254 * and 
smp_mb in walk_shadow_page_lockless_begin/end.
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  255 * - 
powerpc: smp_mb in kvmppc_prepare_to_enter.
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  256 *
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  257 * 
There is already an smp_mb__after_atomic() before
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  258 * 
kvm_make_all_cpus_request() reads vcpu->mode. We reuse that
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  259 * 
barrier here.
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  260 */
445b8236 virt/kvm/kvm_main.cTang Chen2014-09-24  261if 
(kvm_make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH))
49846896 virt/kvm/kvm_main.cRusty Russell2008-12-08  262
++kvm->stat.remote_tlb_flush;
a086f6a1 virt/kvm/kvm_main.cXiao Guangrong   2014-04-17  263
cmpxchg(&kvm->tlbs_dirty, dirty_count, 0);
2e53d63a virt/kvm/kvm_main.cMarcelo Tosatti  2008-02-20  264  }
2ba9f0d8 virt/kvm/kvm_main.cAneesh Kumar K.V 2013-10-07  265  
EXPORT_SYMBOL_GPL(kvm_flush_remote_tlbs);
a6d51016 virt/kvm/kvm_main.cMario Smarduch   2015-01-15  266  #endif
2e53d63a virt/kvm/kvm_main.cMarcelo Tosatti  2008-02-20  267  

:: The code at line 248 was first introduced by commit
:: 4ae3cb3a2551b41f22284f713e7d5e2b61a85c1d KVM: Replace smp_mb() with 
smp_load_acquire() in the kvm_flush_remote_tlbs()

:: TO: Lan Tianyu 
:: CC: Paolo Bonzini 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH] virt/kvm avoids oops by adding parameter checking

2017-09-02 Thread kbuild test robot
Hi nixiaoming,

[auto build test ERROR on v4.13-rc6]
[also build test ERROR on next-20170901]
[cannot apply to kvm/linux-next]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/nixiaoming/virt-kvm-avoids-oops-by-adding-parameter-checking/20170823-203000
config: powerpc-ppc64_defconfig (attached as .config)
compiler: powerpc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=powerpc 

All errors (new ones prefixed by >>):

   arch/powerpc/kvm/../../../virt/kvm/kvm_main.c: In function 
'kvm_flush_remote_tlbs':
>> arch/powerpc/kvm/../../../virt/kvm/kvm_main.c:248:2: error: ISO C90 forbids 
>> mixed declarations and code [-Werror=declaration-after-statement]
 long dirty_count = smp_load_acquire(&kvm->tlbs_dirty);
 ^~~~
   arch/powerpc/kvm/../../../virt/kvm/kvm_main.c: In function 
'kvm_write_guest_offset_cached':
   arch/powerpc/kvm/../../../virt/kvm/kvm_main.c:2025:2: error: ISO C90 forbids 
mixed declarations and code [-Werror=declaration-after-statement]
 gpa_t gpa = ghc->gpa + offset;
 ^
   cc1: all warnings being treated as errors

vim +248 arch/powerpc/kvm/../../../virt/kvm/kvm_main.c

d9e368d6 drivers/kvm/kvm_main.c Avi Kivity   2007-06-07  238  
a6d51016 virt/kvm/kvm_main.cMario Smarduch   2015-01-15  239  #ifndef 
CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL
49846896 virt/kvm/kvm_main.cRusty Russell2008-12-08  240  void 
kvm_flush_remote_tlbs(struct kvm *kvm)
2e53d63a virt/kvm/kvm_main.cMarcelo Tosatti  2008-02-20  241  {
6f1ad410 virt/kvm/kvm_main.cnixiaoming   2017-08-22  242if (kvm 
== NULL)
6f1ad410 virt/kvm/kvm_main.cnixiaoming   2017-08-22  243
return;
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  244/*
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  245 * Read 
tlbs_dirty before setting KVM_REQ_TLB_FLUSH in
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  246 * 
kvm_make_all_cpus_request.
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  247 */
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13 @248long 
dirty_count = smp_load_acquire(&kvm->tlbs_dirty);
a086f6a1 virt/kvm/kvm_main.cXiao Guangrong   2014-04-17  249  
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  250/*
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  251 * We 
want to publish modifications to the page tables before reading
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  252 * 
mode. Pairs with a memory barrier in arch-specific code.
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  253 * - 
x86: smp_mb__after_srcu_read_unlock in vcpu_enter_guest
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  254 * and 
smp_mb in walk_shadow_page_lockless_begin/end.
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  255 * - 
powerpc: smp_mb in kvmppc_prepare_to_enter.
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  256 *
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  257 * 
There is already an smp_mb__after_atomic() before
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  258 * 
kvm_make_all_cpus_request() reads vcpu->mode. We reuse that
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  259 * 
barrier here.
4ae3cb3a virt/kvm/kvm_main.cLan Tianyu   2016-03-13  260 */
445b8236 virt/kvm/kvm_main.cTang Chen2014-09-24  261if 
(kvm_make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH))
49846896 virt/kvm/kvm_main.cRusty Russell2008-12-08  262
++kvm->stat.remote_tlb_flush;
a086f6a1 virt/kvm/kvm_main.cXiao Guangrong   2014-04-17  263
cmpxchg(&kvm->tlbs_dirty, dirty_count, 0);
2e53d63a virt/kvm/kvm_main.cMarcelo Tosatti  2008-02-20  264  }
2ba9f0d8 virt/kvm/kvm_main.cAneesh Kumar K.V 2013-10-07  265  
EXPORT_SYMBOL_GPL(kvm_flush_remote_tlbs);
a6d51016 virt/kvm/kvm_main.cMario Smarduch   2015-01-15  266  #endif
2e53d63a virt/kvm/kvm_main.cMarcelo Tosatti  2008-02-20  267  

:: The code at line 248 was first introduced by commit
:: 4ae3cb3a2551b41f22284f713e7d5e2b61a85c1d KVM: Replace smp_mb() with 
smp_load_acquire() in the kvm_flush_remote_tlbs()

:: TO: Lan Tianyu 
:: CC: Paolo Bonzini 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: fs/binfmt_flat.c:828:9: error: void value not ignored as it ought to be

2017-09-02 Thread Randy Dunlap
On 09/02/17 18:48, kbuild test robot wrote:
> Hi Al,
> 
> FYI, the error/warning still remains.
> 
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
> master
> head:   d0d6ab53c9abd7dd1070f43a0455328874127ba8
> commit: 468138d78510688fb5476f98d23f11ac6a63229a binfmt_flat: 
> flat_{get,put}_addr_from_rp() should be able to fail
> date:   9 weeks ago
> config: m32r-mappi.nommu_defconfig (attached as .config)
> compiler: m32r-linux-gcc (GCC) 6.2.0
> reproduce:
> wget 
> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> git checkout 468138d78510688fb5476f98d23f11ac6a63229a
> # save the attached .config to linux build tree
> make.cross ARCH=m32r 
> 
>>> fs/binfmt_flat.c:828:9: error: void value not ignored as it ought to be
> ret = flat_put_addr_at_rp(rp, addr, relval);
> ^

Patch here for m32r and microblaze:
https://lkml.org/lkml/2017/7/30/179

Al, are these OK or is something more needed?


-- 
~Randy


Re: v4.11.12-rt10 - hotplug lockdep splat

2017-09-02 Thread Mike Galbraith
On Thu, 2017-08-31 at 18:18 +0200, Sebastian Andrzej Siewior wrote:
> On 2017-08-23 11:53:44 [+0200], Mike Galbraith wrote:
> > virt box reminded me this morning to report this gripe.
> 
> if you can reproduce it, then this should make it go away:

Missed a spot.  With this on top, lockdep went silent.

kernel/hrtimer/hotplug: don't wake ktimersoftd while holding the hrtimer base 
lock

kernel/hrtimer: don't wakeup a process while holding the hrtimer base lock
missed a path, namely hrtimers_dead_cpu() -> migrate_hrtimer_list().  Defer
raising softirq until after base lock has been released there as well.

Signed-off-by: Mike Galbraith 
---
 kernel/time/hrtimer.c |   19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1779,7 +1779,7 @@ int hrtimers_prepare_cpu(unsigned int cp
 
 #ifdef CONFIG_HOTPLUG_CPU
 
-static void migrate_hrtimer_list(struct hrtimer_clock_base *old_base,
+static int migrate_hrtimer_list(struct hrtimer_clock_base *old_base,
struct hrtimer_clock_base *new_base)
 {
struct hrtimer *timer;
@@ -1809,15 +1809,19 @@ static void migrate_hrtimer_list(struct
}
 #ifdef CONFIG_PREEMPT_RT_BASE
list_splice_tail(&old_base->expired, &new_base->expired);
-   if (!list_empty(&new_base->expired))
-   raise_softirq_irqoff(HRTIMER_SOFTIRQ);
+   /*
+* Tell the caller to raise HRTIMER_SOFTIRQ.  We can't safely
+* acquire ktimersoftd->pi_lock while the base lock is held.
+*/
+   return !list_empty(&new_base->expired);
 #endif
+   return 0;
 }
 
 int hrtimers_dead_cpu(unsigned int scpu)
 {
struct hrtimer_cpu_base *old_base, *new_base;
-   int i;
+   int i, raise = 0;
 
BUG_ON(cpu_online(scpu));
tick_cancel_sched_timer(scpu);
@@ -1833,13 +1837,16 @@ int hrtimers_dead_cpu(unsigned int scpu)
raw_spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING);
 
for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {
-   migrate_hrtimer_list(&old_base->clock_base[i],
-&new_base->clock_base[i]);
+   raise |= migrate_hrtimer_list(&old_base->clock_base[i],
+ &new_base->clock_base[i]);
}
 
raw_spin_unlock(&old_base->lock);
raw_spin_unlock(&new_base->lock);
 
+   if (raise)
+   raise_softirq_irqoff(HRTIMER_SOFTIRQ);
+
/* Check, if we got expired work to do */
__hrtimer_peek_ahead_timers();
local_irq_enable();


[PATCH 06/12] media: rc-sysfs-nodes.rst: better use literals

2017-09-02 Thread Mauro Carvalho Chehab
A literal box provides a better visual when pdf and html output
is generated for things like the output of a sysfs devnode.
It alsod matches other conventions used within the media book.

So, use it.

While here, use literals for protocol names.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/media/uapi/rc/rc-sysfs-nodes.rst | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Documentation/media/uapi/rc/rc-sysfs-nodes.rst 
b/Documentation/media/uapi/rc/rc-sysfs-nodes.rst
index 3476ae29708f..2d01358d5504 100644
--- a/Documentation/media/uapi/rc/rc-sysfs-nodes.rst
+++ b/Documentation/media/uapi/rc/rc-sysfs-nodes.rst
@@ -34,9 +34,9 @@ receiver device where N is the number of the receiver.
 /sys/class/rc/rcN/protocols
 ===
 
-Reading this file returns a list of available protocols, something like:
+Reading this file returns a list of available protocols, something like::
 
-``rc5 [rc6] nec jvc [sony]``
+   rc5 [rc6] nec jvc [sony]
 
 Enabled protocols are shown in [] brackets.
 
@@ -90,11 +90,11 @@ This value may be reset to 0 if the current protocol is 
altered.
 ==
 
 Reading this file returns a list of available protocols to use for the
-wakeup filter, something like:
+wakeup filter, something like::
 
-``rc-5 nec nec-x rc-6-0 rc-6-6a-24 [rc-6-6a-32] rc-6-mce``
+   rc-5 nec nec-x rc-6-0 rc-6-6a-24 [rc-6-6a-32] rc-6-mce
 
-Note that protocol variants are listed, so "nec", "sony", "rc-5", "rc-6"
+Note that protocol variants are listed, so ``nec``, ``sony``, ``rc-5``, 
``rc-6``
 have their different bit length encodings listed if available.
 
 Note that all protocol variants are listed.
-- 
2.13.5



[PATCH 04/12] media: v4l uAPI docs: adjust some tables for PDF output

2017-09-02 Thread Mauro Carvalho Chehab
On tests with Spinx 1.4, some tables are still writing text
outside cells. Adjust those tables.

PS.: As this was revisited several times, I suspect that this
will only be fully fixed if we add tabularcolumns to all tables
at the V4L2 part of the book.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/media/uapi/v4l/colorspaces-defs.rst   | 2 ++
 Documentation/media/uapi/v4l/pixfmt-srggb10p.rst| 2 +-
 Documentation/media/uapi/v4l/v4l2-selection-targets.rst | 2 +-
 Documentation/media/uapi/v4l/vidioc-enum-framesizes.rst | 2 ++
 Documentation/media/uapi/v4l/vidioc-querycap.rst| 2 +-
 Documentation/media/uapi/v4l/vidioc-subscribe-event.rst | 4 ++--
 6 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/Documentation/media/uapi/v4l/colorspaces-defs.rst 
b/Documentation/media/uapi/v4l/colorspaces-defs.rst
index e67ed1e0b3fa..410907fe9415 100644
--- a/Documentation/media/uapi/v4l/colorspaces-defs.rst
+++ b/Documentation/media/uapi/v4l/colorspaces-defs.rst
@@ -76,6 +76,8 @@ whole range, 0-255, dividing the angular value by 1.41. The 
enum
 
 .. c:type:: v4l2_xfer_func
 
+.. tabularcolumns:: |p{5.5cm}|p{12.0cm}|
+
 .. flat-table:: V4L2 Transfer Function
 :header-rows:  1
 :stub-columns: 0
diff --git a/Documentation/media/uapi/v4l/pixfmt-srggb10p.rst 
b/Documentation/media/uapi/v4l/pixfmt-srggb10p.rst
index 86cd07e5bfa3..9e52610aa954 100644
--- a/Documentation/media/uapi/v4l/pixfmt-srggb10p.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-srggb10p.rst
@@ -36,7 +36,7 @@ Each cell is one byte.
 
 .. raw:: latex
 
-\small
+\newline\small
 
 .. tabularcolumns:: |p{2.0cm}|p{1.0cm}|p{1.0cm}|p{1.0cm}|p{1.0cm}|p{10.0cm}|
 
diff --git a/Documentation/media/uapi/v4l/v4l2-selection-targets.rst 
b/Documentation/media/uapi/v4l/v4l2-selection-targets.rst
index cab07de6f4da..87433ec76c6b 100644
--- a/Documentation/media/uapi/v4l/v4l2-selection-targets.rst
+++ b/Documentation/media/uapi/v4l/v4l2-selection-targets.rst
@@ -12,7 +12,7 @@ of the two interfaces they are used.
 
 .. _v4l2-selection-targets-table:
 
-.. tabularcolumns:: |p{5.8cm}|p{1.4cm}|p{6.5cm}|p{1.2cm}|p{1.6cm}|
+.. tabularcolumns:: |p{6.0cm}|p{1.4cm}|p{7.4cm}|p{1.2cm}|p{1.4cm}|
 
 .. flat-table:: Selection target definitions
 :header-rows:  1
diff --git a/Documentation/media/uapi/v4l/vidioc-enum-framesizes.rst 
b/Documentation/media/uapi/v4l/vidioc-enum-framesizes.rst
index 8fcc46d307d5..6de117f163e0 100644
--- a/Documentation/media/uapi/v4l/vidioc-enum-framesizes.rst
+++ b/Documentation/media/uapi/v4l/vidioc-enum-framesizes.rst
@@ -140,6 +140,8 @@ application should zero out all members except for the *IN* 
fields.
 
 .. c:type:: v4l2_frmsizeenum
 
+.. tabularcolumns:: |p{1.4cm}|p{5.9cm}|p{2.3cm}|p{8.0cm}|
+
 .. flat-table:: struct v4l2_frmsizeenum
 :header-rows:  0
 :stub-columns: 0
diff --git a/Documentation/media/uapi/v4l/vidioc-querycap.rst 
b/Documentation/media/uapi/v4l/vidioc-querycap.rst
index 7553b44692b4..66fb1b3d6e6e 100644
--- a/Documentation/media/uapi/v4l/vidioc-querycap.rst
+++ b/Documentation/media/uapi/v4l/vidioc-querycap.rst
@@ -133,7 +133,7 @@ specification the ioctl returns an ``EINVAL`` error code.
 
 
 
-.. tabularcolumns:: |p{6cm}|p{2.2cm}|p{8.8cm}|
+.. tabularcolumns:: |p{6.1cm}|p{2.2cm}|p{8.7cm}|
 
 .. _device-capabilities:
 
diff --git a/Documentation/media/uapi/v4l/vidioc-subscribe-event.rst 
b/Documentation/media/uapi/v4l/vidioc-subscribe-event.rst
index a95cbf2a126d..b521efa53ceb 100644
--- a/Documentation/media/uapi/v4l/vidioc-subscribe-event.rst
+++ b/Documentation/media/uapi/v4l/vidioc-subscribe-event.rst
@@ -40,7 +40,7 @@ Subscribe or unsubscribe V4L2 event. Subscribed events are 
dequeued by
 using the :ref:`VIDIOC_DQEVENT` ioctl.
 
 
-.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
+.. tabularcolumns:: |p{4.6cm}|p{4.4cm}|p{8.7cm}|
 
 .. c:type:: v4l2_event_subscription
 
@@ -73,7 +73,7 @@ using the :ref:`VIDIOC_DQEVENT` ioctl.
 
 
 
-.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
+.. tabularcolumns:: |p{6.8cm}|p{2.2cm}|p{8.5cm}|
 
 .. _event-flags:
 
-- 
2.13.5



[PATCH 10/12] media: v4l2-event.rst: adjust table to fit on PDF output

2017-09-02 Thread Mauro Carvalho Chehab
The tables there don't quite fit on PDF output.

Adjust it by adding a tabularcolumns macro.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/media/kapi/v4l2-event.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/media/kapi/v4l2-event.rst 
b/Documentation/media/kapi/v4l2-event.rst
index 9a5e31546ae3..9938d21ef4d1 100644
--- a/Documentation/media/kapi/v4l2-event.rst
+++ b/Documentation/media/kapi/v4l2-event.rst
@@ -67,6 +67,8 @@ type).
 
 The ops argument allows the driver to specify a number of callbacks:
 
+.. tabularcolumns:: |p{1.5cm}|p{16.0cm}|
+
  ==
 Callback Description
  ==
-- 
2.13.5



[PATCH 09/12] media: docs: don't show ToC for each part on PDF output

2017-09-02 Thread Mauro Carvalho Chehab
The "Table of Contents" of a PDF file is generated only once,
at the beginning fo the output. It doesn't produce it on
each part.

So, don't output this text on each part of the document.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/media/cec-drivers/index.rst  | 4 +++-
 Documentation/media/dvb-drivers/index.rst  | 4 +++-
 Documentation/media/media_kapi.rst | 4 +++-
 Documentation/media/media_uapi.rst | 4 +++-
 Documentation/media/uapi/cec/cec-api.rst   | 5 -
 Documentation/media/uapi/dvb/dvbapi.rst| 4 +++-
 Documentation/media/uapi/mediactl/media-controller.rst | 4 +++-
 Documentation/media/uapi/rc/remote_controllers.rst | 4 +++-
 Documentation/media/uapi/v4l/v4l2.rst  | 4 +++-
 Documentation/media/v4l-drivers/index.rst  | 4 +++-
 10 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/Documentation/media/cec-drivers/index.rst 
b/Documentation/media/cec-drivers/index.rst
index 1c817aa10bb6..7ef204823422 100644
--- a/Documentation/media/cec-drivers/index.rst
+++ b/Documentation/media/cec-drivers/index.rst
@@ -21,7 +21,9 @@ more details.
 
 For more details see the file COPYING in the source distribution of Linux.
 
-.. class:: toc-title
+.. only:: html
+
+.. class:: toc-title
 
 Table of Contents
 
diff --git a/Documentation/media/dvb-drivers/index.rst 
b/Documentation/media/dvb-drivers/index.rst
index ea0da6d63299..376141143ae9 100644
--- a/Documentation/media/dvb-drivers/index.rst
+++ b/Documentation/media/dvb-drivers/index.rst
@@ -19,7 +19,9 @@ more details.
 
 For more details see the file COPYING in the source distribution of Linux.
 
-.. class:: toc-title
+.. only:: html
+
+   .. class:: toc-title
 
Table of Contents
 
diff --git a/Documentation/media/media_kapi.rst 
b/Documentation/media/media_kapi.rst
index bc0638956a43..83da736fad72 100644
--- a/Documentation/media/media_kapi.rst
+++ b/Documentation/media/media_kapi.rst
@@ -20,7 +20,9 @@ more details.
 
 For more details see the file COPYING in the source distribution of Linux.
 
-.. class:: toc-title
+.. only:: html
+
+   .. class:: toc-title
 
 Table of Contents
 
diff --git a/Documentation/media/media_uapi.rst 
b/Documentation/media/media_uapi.rst
index fd8ebe002cd2..28eb35a1f965 100644
--- a/Documentation/media/media_uapi.rst
+++ b/Documentation/media/media_uapi.rst
@@ -14,7 +14,9 @@ any later version published by the Free Software Foundation. 
A copy of
 the license is included in the chapter entitled "GNU Free Documentation
 License".
 
-.. class:: toc-title
+.. only:: html
+
+   .. class:: toc-title
 
 Table of Contents
 
diff --git a/Documentation/media/uapi/cec/cec-api.rst 
b/Documentation/media/uapi/cec/cec-api.rst
index bb018709970c..b68ca9c1d2e0 100644
--- a/Documentation/media/uapi/cec/cec-api.rst
+++ b/Documentation/media/uapi/cec/cec-api.rst
@@ -10,7 +10,10 @@ Part V - Consumer Electronics Control API
 
 This part describes the CEC: Consumer Electronics Control
 
-.. class:: toc-title
+
+.. only:: html
+
+   .. class:: toc-title
 
 Table of Contents
 
diff --git a/Documentation/media/uapi/dvb/dvbapi.rst 
b/Documentation/media/uapi/dvb/dvbapi.rst
index 7d26e98e5a41..18c86b3a3af1 100644
--- a/Documentation/media/uapi/dvb/dvbapi.rst
+++ b/Documentation/media/uapi/dvb/dvbapi.rst
@@ -28,7 +28,9 @@ Part II - Digital TV API
 
 **Version 5.10**
 
-.. class:: toc-title
+.. only:: html
+
+   .. class:: toc-title
 
 Table of Contents
 
diff --git a/Documentation/media/uapi/mediactl/media-controller.rst 
b/Documentation/media/uapi/mediactl/media-controller.rst
index 7ae38d48969e..0eea4f9a07d5 100644
--- a/Documentation/media/uapi/mediactl/media-controller.rst
+++ b/Documentation/media/uapi/mediactl/media-controller.rst
@@ -8,7 +8,9 @@
 Part IV - Media Controller API
 ##
 
-.. class:: toc-title
+.. only:: html
+
+   .. class:: toc-title
 
 Table of Contents
 
diff --git a/Documentation/media/uapi/rc/remote_controllers.rst 
b/Documentation/media/uapi/rc/remote_controllers.rst
index 3e25cc9f65e0..46a8acb82125 100644
--- a/Documentation/media/uapi/rc/remote_controllers.rst
+++ b/Documentation/media/uapi/rc/remote_controllers.rst
@@ -8,7 +8,9 @@
 Part III - Remote Controller API
 
 
-.. class:: toc-title
+.. only:: html
+
+   .. class:: toc-title
 
 Table of Contents
 
diff --git a/Documentation/media/uapi/v4l/v4l2.rst 
b/Documentation/media/uapi/v4l/v4l2.rst
index f52a11c949d3..297c293d4c93 100644
--- a/Documentation/media/uapi/v4l/v4l2.rst
+++ b/Documentation/media/uapi/v4l/v4l2.rst
@@ -11,7 +11,9 @@ This part describes the Video for Linux API version 2 (V4L2 
API) specification.
 
 **Revision 4.5**
 
-.. class:: toc-title
+.. only:: html
+
+   .. class:: toc-title
 
 Table of Contents
 
diff --git a/Documentation/media/v4l-drivers/index.rst 
b/Documentation/media/v

[PATCH 02/12] media: vidioc-querycap: use a more realistic value for KERNEL_VERSION

2017-09-02 Thread Mauro Carvalho Chehab
In the past, V4L2 versions were 0.x.y, but that changed years
ago. Since Kernel 3.1, however, the numbering schema was changed
to match the Kernel version.

However, the presented example still uses the old numerating
schema, with is a misleading information.

So, update it to the new schema.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/media/uapi/v4l/vidioc-querycap.rst | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Documentation/media/uapi/v4l/vidioc-querycap.rst 
b/Documentation/media/uapi/v4l/vidioc-querycap.rst
index 9494af96bae7..7553b44692b4 100644
--- a/Documentation/media/uapi/v4l/vidioc-querycap.rst
+++ b/Documentation/media/uapi/v4l/vidioc-querycap.rst
@@ -92,12 +92,13 @@ specification the ioctl returns an ``EINVAL`` error code.
stack from a newer kernel.
 
The version number is formatted using the ``KERNEL_VERSION()``
-   macro:
+   macro. For example if the media stack corresponds to the V4L2
+   version shipped with Kernel 4.14, it would be equivalent to:
 * - :cspan:`2`
 
``#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))``
 
-   ``__u32 version = KERNEL_VERSION(0, 8, 1);``
+   ``__u32 version = KERNEL_VERSION(4, 14, 0);``
 
``printf ("Version: %u.%u.%u\\n",``
 
-- 
2.13.5



[PATCH 03/12] media: vidioc-g-tuner.rst: Fix table number of cols

2017-09-02 Thread Mauro Carvalho Chehab
The Tuner Audio Matrix table is broken: the first row has 7
columns instead of 6, causing it to be parsed wrong and displayed
very badly on PDF output.

Fix it and adjust the table to look nice at PDF output

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/media/uapi/v4l/vidioc-g-tuner.rst | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/Documentation/media/uapi/v4l/vidioc-g-tuner.rst 
b/Documentation/media/uapi/v4l/vidioc-g-tuner.rst
index 491866484f57..acdd15901a51 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-tuner.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-tuner.rst
@@ -395,20 +395,23 @@ To change the radio frequency the
 
 \scriptsize
 
+.. tabularcolumns:: |p{1.5cm}|p{1.5cm}|p{2.9cm}|p{2.9cm}|p{2.9cm}|p{2.9cm}|
+
 .. _tuner-matrix:
 
 .. flat-table:: Tuner Audio Matrix
 :header-rows:  2
 :stub-columns: 0
+:widths: 7 7 14 14 14 14
 
 * -
-  - :cspan:`5` Selected ``V4L2_TUNER_MODE_``
+  - :cspan:`4` Selected ``V4L2_TUNER_MODE_``
 * - Received ``V4L2_TUNER_SUB_``
   - ``MONO``
   - ``STEREO``
   - ``LANG1``
   - ``LANG2 = SAP``
-  - ``LANG1_LANG2``\  [#f1]_
+  - ``LANG1_LANG2``\ [#f1]_
 * - ``MONO``
   - Mono
   - Mono/Mono
@@ -435,7 +438,7 @@ To change the radio frequency the
   - L+R/SAP (preferred) or L/R or L+R/L+R
 * - ``LANG1 | LANG2``
   - Language 1
-  - Lang1/Lang2 (deprecated [#f2]_) or Lang1/Lang1
+  - Lang1/Lang2 (deprecated\ [#f2]_) or Lang1/Lang1
   - Language 1
   - Language 2
   - Lang1/Lang2 (preferred) or Lang1/Lang1
-- 
2.13.5



[PATCH 00/12] media documentation ReST fixes

2017-09-02 Thread Mauro Carvalho Chehab
This series contain media documentation ReST fixes, mostly related to
table parsing and the corresponding PDF output (tested with Sphinx 1.4).

It also contains a few documentation trivial improvements, from a
few minor issues I noticed when reading the PDF output text on some
places.

Probably the most important one is a regression that was causing the
media book build to return an error, introduced by changeset
70b074df4ed1 ("media: fix pdf build with Spinx 1.6"). 

My plan is to merge this patch series soon via the media tree, 
and send it upstream during this merge window.

Markus, 

Perhaps you could take a look on it. It is related to the usage of cspan
and the corresponding PDF output.

Mauro Carvalho Chehab (12):
  media: v4l uAPI: add descriptions for arguments to all ioctls
  media: vidioc-querycap: use a more realistic value for KERNEL_VERSION
  media: vidioc-g-tuner.rst: Fix table number of cols
  media: v4l uAPI docs: adjust some tables for PDF output
  media: docs: fix PDF build with Sphinx 1.4
  media: rc-sysfs-nodes.rst: better use literals
  media: mc uapi: adjust some table sizes for PDF output
  media: cec uapi: Adjust table sizes for PDF output
  media: docs: don't show ToC for each part on PDF output
  media: v4l2-event.rst: adjust table to fit on PDF output
  media: em28xx-cardlist.rst: update to reflect last changes
  media: docs-rst: cardlists: change their format to flat-tables

 Documentation/media/cec-drivers/index.rst  |   4 +-
 Documentation/media/dvb-drivers/index.rst  |   4 +-
 Documentation/media/kapi/v4l2-event.rst|   2 +
 Documentation/media/media_kapi.rst |   4 +-
 Documentation/media/media_uapi.rst |   4 +-
 Documentation/media/uapi/cec/cec-api.rst   |   5 +-
 .../media/uapi/cec/cec-ioc-adap-g-log-addrs.rst|   7 +-
 Documentation/media/uapi/cec/cec-ioc-dqevent.rst   |   9 +-
 Documentation/media/uapi/cec/cec-ioc-g-mode.rst|   2 +
 Documentation/media/uapi/cec/cec-ioc-receive.rst   |   2 +
 Documentation/media/uapi/dvb/dvbapi.rst|   4 +-
 .../media/uapi/mediactl/media-controller.rst   |   4 +-
 .../uapi/mediactl/media-ioc-enum-entities.rst  |   2 +-
 .../media/uapi/mediactl/media-ioc-g-topology.rst   |   2 +-
 Documentation/media/uapi/mediactl/media-types.rst  |   2 +-
 Documentation/media/uapi/rc/rc-sysfs-nodes.rst |  10 +-
 Documentation/media/uapi/rc/remote_controllers.rst |   4 +-
 Documentation/media/uapi/v4l/colorspaces-defs.rst  |   2 +
 Documentation/media/uapi/v4l/pixfmt-packed-rgb.rst |   6 +-
 Documentation/media/uapi/v4l/pixfmt-packed-yuv.rst |   3 +-
 Documentation/media/uapi/v4l/pixfmt-srggb10p.rst   |   2 +-
 .../media/uapi/v4l/v4l2-selection-targets.rst  |   2 +-
 Documentation/media/uapi/v4l/v4l2.rst  |   4 +-
 .../media/uapi/v4l/vidioc-create-bufs.rst  |   1 +
 Documentation/media/uapi/v4l/vidioc-cropcap.rst|   1 +
 .../media/uapi/v4l/vidioc-dbg-g-chip-info.rst  |   1 +
 .../media/uapi/v4l/vidioc-dbg-g-register.rst   |   1 +
 Documentation/media/uapi/v4l/vidioc-dqevent.rst|   1 +
 .../media/uapi/v4l/vidioc-dv-timings-cap.rst   |   1 +
 .../media/uapi/v4l/vidioc-encoder-cmd.rst  |   2 +-
 .../media/uapi/v4l/vidioc-enum-dv-timings.rst  |   1 +
 Documentation/media/uapi/v4l/vidioc-enum-fmt.rst   |   1 +
 .../media/uapi/v4l/vidioc-enum-frameintervals.rst  |   5 +-
 .../media/uapi/v4l/vidioc-enum-framesizes.rst  |   4 +-
 .../media/uapi/v4l/vidioc-enum-freq-bands.rst  |   1 +
 Documentation/media/uapi/v4l/vidioc-enumaudio.rst  |   1 +
 .../media/uapi/v4l/vidioc-enumaudioout.rst |   1 +
 Documentation/media/uapi/v4l/vidioc-enuminput.rst  |   1 +
 Documentation/media/uapi/v4l/vidioc-enumoutput.rst |   1 +
 Documentation/media/uapi/v4l/vidioc-enumstd.rst|   1 +
 Documentation/media/uapi/v4l/vidioc-expbuf.rst |   1 +
 Documentation/media/uapi/v4l/vidioc-g-audio.rst|   1 +
 Documentation/media/uapi/v4l/vidioc-g-audioout.rst |   1 +
 Documentation/media/uapi/v4l/vidioc-g-crop.rst |   1 +
 Documentation/media/uapi/v4l/vidioc-g-ctrl.rst |   1 +
 .../media/uapi/v4l/vidioc-g-dv-timings.rst |   1 +
 Documentation/media/uapi/v4l/vidioc-g-edid.rst |   1 +
 .../media/uapi/v4l/vidioc-g-enc-index.rst  |   1 +
 .../media/uapi/v4l/vidioc-g-ext-ctrls.rst  |   1 +
 Documentation/media/uapi/v4l/vidioc-g-fbuf.rst |   1 +
 Documentation/media/uapi/v4l/vidioc-g-fmt.rst  |   1 +
 .../media/uapi/v4l/vidioc-g-frequency.rst  |   1 +
 Documentation/media/uapi/v4l/vidioc-g-input.rst|   1 +
 Documentation/media/uapi/v4l/vidioc-g-jpegcomp.rst |   1 +
 .../media/uapi/v4l/vidioc-g-modulator.rst  |   1 +
 Documentation/media/uapi/v4l/vidioc-g-output.rst   |   1 +
 Documentation/media/uapi/v4l/vidioc-g-parm.rst |   1 +
 Documentation/media/uapi/v4l/vidioc-g-priority.rst |   2 +-
 .../media/uapi/v4l/vidioc-g-selection.rst  |   5 +-
 .../med

[PATCH 01/12] media: v4l uAPI: add descriptions for arguments to all ioctls

2017-09-02 Thread Mauro Carvalho Chehab
Several ioctls are missing descriptions for the third argument
of the ioctl() command. They should have a description, as
otherwise the output won't be ok, and will sound like something
is missing.

So, add them.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/media/uapi/v4l/vidioc-create-bufs.rst| 1 +
 Documentation/media/uapi/v4l/vidioc-cropcap.rst| 1 +
 Documentation/media/uapi/v4l/vidioc-dbg-g-chip-info.rst| 1 +
 Documentation/media/uapi/v4l/vidioc-dbg-g-register.rst | 1 +
 Documentation/media/uapi/v4l/vidioc-dqevent.rst| 1 +
 Documentation/media/uapi/v4l/vidioc-dv-timings-cap.rst | 1 +
 Documentation/media/uapi/v4l/vidioc-encoder-cmd.rst| 2 +-
 Documentation/media/uapi/v4l/vidioc-enum-dv-timings.rst| 1 +
 Documentation/media/uapi/v4l/vidioc-enum-fmt.rst   | 1 +
 Documentation/media/uapi/v4l/vidioc-enum-frameintervals.rst| 5 ++---
 Documentation/media/uapi/v4l/vidioc-enum-framesizes.rst| 2 +-
 Documentation/media/uapi/v4l/vidioc-enum-freq-bands.rst| 1 +
 Documentation/media/uapi/v4l/vidioc-enumaudio.rst  | 1 +
 Documentation/media/uapi/v4l/vidioc-enumaudioout.rst   | 1 +
 Documentation/media/uapi/v4l/vidioc-enuminput.rst  | 1 +
 Documentation/media/uapi/v4l/vidioc-enumoutput.rst | 1 +
 Documentation/media/uapi/v4l/vidioc-enumstd.rst| 1 +
 Documentation/media/uapi/v4l/vidioc-expbuf.rst | 1 +
 Documentation/media/uapi/v4l/vidioc-g-audio.rst| 1 +
 Documentation/media/uapi/v4l/vidioc-g-audioout.rst | 1 +
 Documentation/media/uapi/v4l/vidioc-g-crop.rst | 1 +
 Documentation/media/uapi/v4l/vidioc-g-ctrl.rst | 1 +
 Documentation/media/uapi/v4l/vidioc-g-dv-timings.rst   | 1 +
 Documentation/media/uapi/v4l/vidioc-g-edid.rst | 1 +
 Documentation/media/uapi/v4l/vidioc-g-enc-index.rst| 1 +
 Documentation/media/uapi/v4l/vidioc-g-ext-ctrls.rst| 1 +
 Documentation/media/uapi/v4l/vidioc-g-fbuf.rst | 1 +
 Documentation/media/uapi/v4l/vidioc-g-fmt.rst  | 1 +
 Documentation/media/uapi/v4l/vidioc-g-frequency.rst| 1 +
 Documentation/media/uapi/v4l/vidioc-g-input.rst| 1 +
 Documentation/media/uapi/v4l/vidioc-g-jpegcomp.rst | 1 +
 Documentation/media/uapi/v4l/vidioc-g-modulator.rst| 1 +
 Documentation/media/uapi/v4l/vidioc-g-output.rst   | 1 +
 Documentation/media/uapi/v4l/vidioc-g-parm.rst | 1 +
 Documentation/media/uapi/v4l/vidioc-g-priority.rst | 2 +-
 Documentation/media/uapi/v4l/vidioc-g-selection.rst| 5 +
 Documentation/media/uapi/v4l/vidioc-g-sliced-vbi-cap.rst   | 1 +
 Documentation/media/uapi/v4l/vidioc-g-std.rst  | 1 +
 Documentation/media/uapi/v4l/vidioc-g-tuner.rst| 1 +
 Documentation/media/uapi/v4l/vidioc-overlay.rst| 1 +
 Documentation/media/uapi/v4l/vidioc-prepare-buf.rst| 1 +
 Documentation/media/uapi/v4l/vidioc-qbuf.rst   | 1 +
 Documentation/media/uapi/v4l/vidioc-query-dv-timings.rst   | 1 +
 Documentation/media/uapi/v4l/vidioc-querybuf.rst   | 1 +
 Documentation/media/uapi/v4l/vidioc-querycap.rst   | 1 +
 Documentation/media/uapi/v4l/vidioc-queryctrl.rst  | 2 ++
 Documentation/media/uapi/v4l/vidioc-querystd.rst   | 1 +
 Documentation/media/uapi/v4l/vidioc-reqbufs.rst| 2 +-
 Documentation/media/uapi/v4l/vidioc-s-hw-freq-seek.rst | 1 +
 Documentation/media/uapi/v4l/vidioc-streamon.rst   | 2 +-
 Documentation/media/uapi/v4l/vidioc-subdev-enum-frame-interval.rst | 1 +
 Documentation/media/uapi/v4l/vidioc-subdev-enum-frame-size.rst | 1 +
 Documentation/media/uapi/v4l/vidioc-subdev-enum-mbus-code.rst  | 1 +
 Documentation/media/uapi/v4l/vidioc-subdev-g-crop.rst  | 1 +
 Documentation/media/uapi/v4l/vidioc-subdev-g-fmt.rst   | 1 +
 Documentation/media/uapi/v4l/vidioc-subdev-g-frame-interval.rst| 1 +
 Documentation/media/uapi/v4l/vidioc-subdev-g-selection.rst | 1 +
 Documentation/media/uapi/v4l/vidioc-subscribe-event.rst| 1 +
 58 files changed, 60 insertions(+), 12 deletions(-)

diff --git a/Documentation/media/uapi/v4l/vidioc-create-bufs.rst 
b/Documentation/media/uapi/v4l/vidioc-create-bufs.rst
index aaca12fca06e..a39e18d69511 100644
--- a/Documentation/media/uapi/v4l/vidioc-create-bufs.rst
+++ b/Documentation/media/uapi/v4l/vidioc-create-bufs.rst
@@ -26,6 +26,7 @@ Arguments
 File descriptor returned by :ref:`open() `.
 
 ``argp``
+Pointer to st

[PATCH 11/12] media: em28xx-cardlist.rst: update to reflect last changes

2017-09-02 Thread Mauro Carvalho Chehab
There were some new board additions. Update the cardlist
accordingly.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../media/v4l-drivers/em28xx-cardlist.rst  | 210 +++--
 1 file changed, 106 insertions(+), 104 deletions(-)

diff --git a/Documentation/media/v4l-drivers/em28xx-cardlist.rst 
b/Documentation/media/v4l-drivers/em28xx-cardlist.rst
index 76b1d301754c..ef304da61354 100644
--- a/Documentation/media/v4l-drivers/em28xx-cardlist.rst
+++ b/Documentation/media/v4l-drivers/em28xx-cardlist.rst
@@ -1,107 +1,109 @@
 EM28xx cards list
 =
 
-=== 
 
 
==
-Card number Card name  
  Empia Chip   USB IDs
-=== 
 
 
==
-0   Unknown EM2800 video grabber   
  em2800   eb1a:2800
-1   Unknown EM2750/28xx video grabber  
  em2820 or em2840 eb1a:2710, eb1a:2820, eb1a:2821, eb1a:2860, eb1a:2861, 
eb1a:2862, eb1a:2863, eb1a:2870, eb1a:2881, eb1a:2883, eb1a:2868, eb1a:2875
-2   Terratec Cinergy 250 USB   
  em2820 or em2840 0ccd:0036
-3   Pinnacle PCTV USB 2
  em2820 or em2840 2304:0208
-4   Hauppauge WinTV USB 2  
  em2820 or em2840 2040:4200, 2040:4201
-5   MSI VOX USB 2.0
  em2820 or em2840
-6   Terratec Cinergy 200 USB   
  em2800
-7   Leadtek Winfast USB II 
  em2800   0413:6023
-8   Kworld USB2800 
  em2800
-9   Pinnacle Dazzle DVC 90/100/101/107 / Kaiser Baas Video to DVD 
maker  em2820 or em2840 1b80:e302, 1b80:e304, 2304:0207, 2304:021a, 093b:a003
-10  Hauppauge WinTV HVR 900
  em2880   2040:6500
-11  Terratec Hybrid XS 
  em2880
-12  Kworld PVR TV 2800 RF  
  em2820 or em2840
-13  Terratec Prodigy XS
  em2880
-14  SIIG AVTuner-PVR / Pixelview Prolink PlayTV USB 2.0
  em2820 or em2840
-15  V-Gear PocketTV
  em2800
-16  Hauppauge WinTV HVR 950
  em2883   2040:6513, 2040:6517, 2040:651b
-17  Pinnacle PCTV HD Pro Stick 
  em2880   2304:0227
-18  Hauppauge WinTV HVR 900 (R2)   
  em2880   2040:6502
-19  EM2860/SAA711X Reference Design
  em2860
-20  AMD ATI TV Wonder HD 600   
  em2880   0438:b002
-21  eMPIA Technology, Inc. GrabBeeX+ Video Encoder 
  em2800   eb1a:2801
-22  EM2710/EM2750/EM2751 webcam grabber
  em2750   eb1a:2750, eb1a:2751
-23  Huaqi DLCW-130 
  em2750
-24  D-Link DUB-T210 TV Tuner   
  em2820 or em2840 2001:f112
-25  Gadmei UTV310  
  em2820 or em2840
-26  Hercules Smart TV USB 2.0  
  em2820 or em2840
-27  Pinnacle PCTV USB 2 (Philips FM1216ME) 
  em2820 or em2840
-28  Leadtek Winfast USB II Deluxe  
  em2820 or em2840
-29  EM2860/TVP5150 Reference Design
  em2860
-30  Videology 20K14XUSB USB2.0 
  em2820 or em2840
-31  Usbgear VD204v9
  em2821
-32  Supercomp USB 2.0 TV   
  em2821
-33  Elgato Video Capture   
  em2860   0fd9:0033
-34  Terratec Cinergy A Hybrid XS   
  em2860   0ccd:004f
-35  Typhoon DVD Maker

[PATCH 05/12] media: docs: fix PDF build with Sphinx 1.4

2017-09-02 Thread Mauro Carvalho Chehab
changeset 70b074df4ed1 ("media: fix pdf build with Spinx 1.6") caused
a regression at Sphinx 1.4 PDF build: although it produces a full
document in batch mode, it returns errors on interactive mode:

[63]
Runaway argument?
{\relax
! Paragraph ended before \multicolumn was complete.

   \par
l.7703 \hline\end{tabulary}

The error seems to be due to some bug at Sphinx PDF output:
when multicolumns is used, it doesn't accept an empty string.

Just removing the :cpan:`1` and replacing by two empty
columns fix the issue.

Fixes: 70b074df4ed1 ("media: fix pdf build with Spinx 1.6")

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/media/uapi/v4l/pixfmt-packed-rgb.rst | 6 --
 Documentation/media/uapi/v4l/pixfmt-packed-yuv.rst | 3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Documentation/media/uapi/v4l/pixfmt-packed-rgb.rst 
b/Documentation/media/uapi/v4l/pixfmt-packed-rgb.rst
index bb85abcfceb5..4938d9655a41 100644
--- a/Documentation/media/uapi/v4l/pixfmt-packed-rgb.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-packed-rgb.rst
@@ -35,7 +35,8 @@ next to each other in memory.
   - :cspan:`7` Byte 1
   - :cspan:`7` Byte 2
   - :cspan:`7` Byte 3
-* - :cspan:`1`
+* -
+  -
   - 7
   - 6
   - 5
@@ -665,7 +666,8 @@ either the corresponding ARGB or XRGB format, depending on 
the driver.
   - :cspan:`7` Byte 2
 
   - :cspan:`7` Byte 3
-* - :cspan:`1`
+* -
+  -
   - 7
   - 6
   - 5
diff --git a/Documentation/media/uapi/v4l/pixfmt-packed-yuv.rst 
b/Documentation/media/uapi/v4l/pixfmt-packed-yuv.rst
index d6a6e890f5a9..d7644b411ccc 100644
--- a/Documentation/media/uapi/v4l/pixfmt-packed-yuv.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-packed-yuv.rst
@@ -37,7 +37,8 @@ component of each pixel in one 16 or 32 bit word.
   - :cspan:`7` Byte 2
 
   - :cspan:`7` Byte 3
-* - :cspan:`1`
+* -
+  -
   - 7
   - 6
   - 5
-- 
2.13.5



[PATCH 07/12] media: mc uapi: adjust some table sizes for PDF output

2017-09-02 Thread Mauro Carvalho Chehab
Some cells are too small to fit the text written to it.

Increase it. No text changes.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/media/uapi/mediactl/media-ioc-enum-entities.rst | 2 +-
 Documentation/media/uapi/mediactl/media-ioc-g-topology.rst| 2 +-
 Documentation/media/uapi/mediactl/media-types.rst | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/media/uapi/mediactl/media-ioc-enum-entities.rst 
b/Documentation/media/uapi/mediactl/media-ioc-enum-entities.rst
index 0fd329279bef..b59ce149efb5 100644
--- a/Documentation/media/uapi/mediactl/media-ioc-enum-entities.rst
+++ b/Documentation/media/uapi/mediactl/media-ioc-enum-entities.rst
@@ -51,7 +51,7 @@ id's until they get an error.
 
 .. c:type:: media_entity_desc
 
-.. tabularcolumns:: |p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{11.5cm}|
+.. tabularcolumns:: |p{1.5cm}|p{1.7cm}|p{1.6cm}|p{1.5cm}|p{11.2cm}|
 
 .. flat-table:: struct media_entity_desc
 :header-rows:  0
diff --git a/Documentation/media/uapi/mediactl/media-ioc-g-topology.rst 
b/Documentation/media/uapi/mediactl/media-ioc-g-topology.rst
index add8281494f8..997e6b17440d 100644
--- a/Documentation/media/uapi/mediactl/media-ioc-g-topology.rst
+++ b/Documentation/media/uapi/mediactl/media-ioc-g-topology.rst
@@ -46,7 +46,7 @@ other values untouched.
 If the ``topology_version`` remains the same, the ioctl should fill the
 desired arrays with the media graph elements.
 
-.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
+.. tabularcolumns:: |p{1.6cm}|p{3.4cm}|p{12.5cm}|
 
 .. c:type:: media_v2_topology
 
diff --git a/Documentation/media/uapi/mediactl/media-types.rst 
b/Documentation/media/uapi/mediactl/media-types.rst
index 71078565d644..8d64b0c06ebc 100644
--- a/Documentation/media/uapi/mediactl/media-types.rst
+++ b/Documentation/media/uapi/mediactl/media-types.rst
@@ -5,7 +5,7 @@
 Types and flags used to represent the media graph elements
 ==
 
-..  tabularcolumns:: |p{8.0cm}|p{10.5cm}|
+..  tabularcolumns:: |p{8.2cm}|p{10.3cm}|
 
 .. _media-entity-type:
 
-- 
2.13.5



[PATCH 12/12] media: docs-rst: cardlists: change their format to flat-tables

2017-09-02 Thread Mauro Carvalho Chehab
Most tables there don't fit on 80 columns. Some are very big.

While those tables are actually generated via scripts, every
time a new board is added, the entire table could be reformatted.
>From the diffstat PoV, that's bad, as it is hard to see what
happened.

One such example is at changeset 4868f6e1fce6 ("media:
em28xx-cardlist.rst: update to reflect last changes"):

The USB ID for "Plextor ConvertX PX-AV100U" was added to card
number 9, with caused the entire table to be reformatted.

So, instead, use flat-tables. While here, fix PDF output,
by adding tablecolumns to the tables that need it.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../media/v4l-drivers/au0828-cardlist.rst  |  44 +-
 Documentation/media/v4l-drivers/bttv-cardlist.rst  | 849 +
 .../media/v4l-drivers/cx23885-cardlist.rst | 304 +--
 Documentation/media/v4l-drivers/cx88-cardlist.rst  | 469 --
 .../media/v4l-drivers/em28xx-cardlist.rst  | 525 ---
 Documentation/media/v4l-drivers/ivtv-cardlist.rst  | 169 +++-
 .../media/v4l-drivers/saa7134-cardlist.rst | 999 -
 .../media/v4l-drivers/saa7164-cardlist.rst |  84 +-
 .../media/v4l-drivers/tm6000-cardlist.rst  |  99 +-
 .../media/v4l-drivers/usbvision-cardlist.rst   | 349 +--
 10 files changed, 3101 insertions(+), 790 deletions(-)

diff --git a/Documentation/media/v4l-drivers/au0828-cardlist.rst 
b/Documentation/media/v4l-drivers/au0828-cardlist.rst
index 82d2567bc7c1..bb87b7b36a83 100644
--- a/Documentation/media/v4l-drivers/au0828-cardlist.rst
+++ b/Documentation/media/v4l-drivers/au0828-cardlist.rst
@@ -1,13 +1,37 @@
 AU0828 cards list
 =
 
-=== == 
===
-Card number Card name  USB IDs
-=== == 
===
-0   Unknown board
-1   Hauppauge HVR950Q  2040:7200, 2040:7210, 2040:7217, 
2040:721b, 2040:721e, 2040:721f, 2040:7280, 0fd9:0008, 2040:7260, 2040:7213, 
2040:7270
-2   Hauppauge HVR850   2040:7240
-3   DViCO FusionHDTV USB   0fe9:d620
-4   Hauppauge HVR950Q rev xxF8 2040:7201, 2040:7211, 2040:7281
-5   Hauppauge Woodbury 05e1:0480, 2040:8200
-=== == 
===
+.. tabularcolumns:: |p{1.4cm}|p{6.5cm}|p{10.0cm}|
+
+.. flat-table::
+   :header-rows: 1
+   :widths: 2 19 18
+   :stub-columns: 0
+
+   * - Card number
+ - Card name
+ - USB IDs
+
+   * - 0
+ - Unknown board
+ -
+
+   * - 1
+ - Hauppauge HVR950Q
+ - 2040:7200, 2040:7210, 2040:7217, 2040:721b, 2040:721e, 2040:721f, 
2040:7280, 0fd9:0008, 2040:7260, 2040:7213, 2040:7270
+
+   * - 2
+ - Hauppauge HVR850
+ - 2040:7240
+
+   * - 3
+ - DViCO FusionHDTV USB
+ - 0fe9:d620
+
+   * - 4
+ - Hauppauge HVR950Q rev xxF8
+ - 2040:7201, 2040:7211, 2040:7281
+
+   * - 5
+ - Hauppauge Woodbury
+ - 05e1:0480, 2040:8200
diff --git a/Documentation/media/v4l-drivers/bttv-cardlist.rst 
b/Documentation/media/v4l-drivers/bttv-cardlist.rst
index 28a01cd6cf2e..8da27b924e01 100644
--- a/Documentation/media/v4l-drivers/bttv-cardlist.rst
+++ b/Documentation/media/v4l-drivers/bttv-cardlist.rst
@@ -1,174 +1,681 @@
 BTTV cards list
 ===
 
-=== 
=
 
==
-Card number Card name  
   PCI IDs
-=== 
=
 
==
-0*** UNKNOWN/GENERIC ***
-1   MIRO PCTV
-2   Hauppauge (bt848)
-3   STB, Gateway P/N 6000699 (bt848)
-4   Intel Create and Share PCI/ Smart Video Recorder III
-5   Diamond DTV2000
-6   AVerMedia TVPhone
-7   MATRIX-Vision MV-Delta
-8   Lifeview FlyVideo II (Bt848) LR26 / MAXI TV Video PCI2 LR26
-9   IMS/IXmicro TurboTV
-10  Hauppauge (bt878)  
   0070:13eb, 0070:3900, 2636:10b4
-11  MIRO PCTV pro
-12  ADS Technologies Channel Surfer TV (bt848)
-13  AVerMedia TVCapture 98   

[PATCH 08/12] media: cec uapi: Adjust table sizes for PDF output

2017-09-02 Thread Mauro Carvalho Chehab
Several tables at this media book chapter have issues
when PDF is produced. Adjust them.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst | 7 +--
 Documentation/media/uapi/cec/cec-ioc-dqevent.rst  | 9 +
 Documentation/media/uapi/cec/cec-ioc-g-mode.rst   | 2 ++
 Documentation/media/uapi/cec/cec-ioc-receive.rst  | 2 ++
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst 
b/Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst
index b25e003a04d7..84f431a022ad 100644
--- a/Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst
@@ -65,7 +65,7 @@ logical address types are already defined will return with 
error ``EBUSY``.
 
 .. c:type:: cec_log_addrs
 
-.. tabularcolumns:: |p{1.0cm}|p{7.5cm}|p{8.0cm}|
+.. tabularcolumns:: |p{1.0cm}|p{8.0cm}|p{7.5cm}|
 
 .. cssclass:: longtable
 
@@ -148,6 +148,9 @@ logical address types are already defined will return with 
error ``EBUSY``.
 give the CEC framework more information about the device type, even
 though the framework won't use it directly in the CEC message.
 
+
+.. tabularcolumns:: |p{7.8cm}|p{1.0cm}|p{8.7cm}|
+
 .. _cec-log-addrs-flags:
 
 .. flat-table:: Flags for struct cec_log_addrs
@@ -183,7 +186,7 @@ logical address types are already defined will return with 
error ``EBUSY``.
All other messages are ignored.
 
 
-.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
+.. tabularcolumns:: |p{7.8cm}|p{1.0cm}|p{8.7cm}|
 
 .. _cec-versions:
 
diff --git a/Documentation/media/uapi/cec/cec-ioc-dqevent.rst 
b/Documentation/media/uapi/cec/cec-ioc-dqevent.rst
index db615e3405c0..a5c821809cc6 100644
--- a/Documentation/media/uapi/cec/cec-ioc-dqevent.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-dqevent.rst
@@ -87,7 +87,7 @@ it is guaranteed that the state did change in between the two 
events.
this is more than enough.
 
 
-.. tabularcolumns:: |p{1.0cm}|p{4.2cm}|p{2.5cm}|p{8.8cm}|
+.. tabularcolumns:: |p{1.0cm}|p{4.4cm}|p{2.5cm}|p{9.6cm}|
 
 .. c:type:: cec_event
 
@@ -98,10 +98,11 @@ it is guaranteed that the state did change in between the 
two events.
 
 * - __u64
   - ``ts``
-  - :cspan:`1` Timestamp of the event in ns.
+  - :cspan:`1`\ Timestamp of the event in ns.
 
-   The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock. To 
access
-   the same clock from userspace use :c:func:`clock_gettime`.
+   The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock.
+
+   To access the same clock from userspace use :c:func:`clock_gettime`.
 * - __u32
   - ``event``
   - :cspan:`1` The CEC event type, see :ref:`cec-events`.
diff --git a/Documentation/media/uapi/cec/cec-ioc-g-mode.rst 
b/Documentation/media/uapi/cec/cec-ioc-g-mode.rst
index 4d8e0647e832..508e2e325683 100644
--- a/Documentation/media/uapi/cec/cec-ioc-g-mode.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-g-mode.rst
@@ -108,6 +108,8 @@ Available follower modes are:
 
 .. _cec-mode-follower_e:
 
+.. cssclass:: longtable
+
 .. flat-table:: Follower Modes
 :header-rows:  0
 :stub-columns: 0
diff --git a/Documentation/media/uapi/cec/cec-ioc-receive.rst 
b/Documentation/media/uapi/cec/cec-ioc-receive.rst
index 267044f7ac30..0f397c535a4c 100644
--- a/Documentation/media/uapi/cec/cec-ioc-receive.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-receive.rst
@@ -195,6 +195,8 @@ View On' messages from initiator 0xf ('Unregistered') to 
destination 0 ('TV').
valid if the :ref:`CEC_TX_STATUS_ERROR ` status 
bit is set.
 
 
+.. tabularcolumns:: |p{6.2cm}|p{1.0cm}|p{10.3cm}|
+
 .. _cec-msg-flags:
 
 .. flat-table:: Flags for struct cec_msg
-- 
2.13.5



Re: [RFC Part1 PATCH v3 16/17] X86/KVM: Provide support to create Guest and HV shared per-CPU variables

2017-09-02 Thread Brijesh Singh


On 9/1/17 10:21 PM, Andy Lutomirski wrote:
> On Fri, Sep 1, 2017 at 3:52 PM, Brijesh Singh  wrote:
>> Hi Boris,
>>
>> On 08/30/2017 12:46 PM, Borislav Petkov wrote:
>>> On Wed, Aug 30, 2017 at 11:18:42AM -0500, Brijesh Singh wrote:
 I was trying to avoid mixing early and no-early set_memory_decrypted()
 but if
 feedback is: use early_set_memory_decrypted() only if its required
 otherwise
 use set_memory_decrypted() then I can improve the logic in next rev.
 thanks
>>>
>>> Yes, I think you should use the early versions when you're, well,
>>> *early* :-) But get rid of that for_each_possible_cpu() and do it only
>>> on the current CPU, as this is a per-CPU path anyway. If you need to
>>> do it on *every* CPU and very early, then you need a separate function
>>> which is called in kvm_smp_prepare_boot_cpu() as there you're pre-SMP.
>>>
>> I am trying to implement your feedback and now remember why I choose to
>> use early_set_memory_decrypted() and for_each_possible_cpu loop. These
>> percpu variables are static. Hence before clearing the C-bit we must
>> perform the in-place decryption so that original assignment is preserved
>> after we change the C-bit. Tom's SME patch [1] added sme_early_decrypt()
>> -- which can be used to perform the in-place decryption but we do not have
>> similar routine for non-early cases. In order to address your feedback,
>> we have to add similar functions. So far, we have not seen the need for
>> having such functions except this cases. The approach we have right now
>> works just fine and not sure if its worth adding new functions.
>>
>> Thoughts ?
>>
>> [1] Commit :7f8b7e7 x86/mm: Add support for early encryption/decryption of
>> memory
> Shouldn't this be called DEFINE_PER_CPU_UNENCRYPTED?  ISTM the "HV
> shared" bit is incidental.

Thanks for the suggestion, we could call it DEFINE_PER_CPU_UNENCRYPTED.
I will use it in next rev.

-Brijesh



[PATCH] X.509: Fix the buffer overflow in the utility function for OID string

2017-09-02 Thread Lee, Chun-Yi
From: Takashi Iwai 

The sprint_oid() utility function doesn't properly check the buffer
size that it causes that the warning in vsnprintf() be triggered.
For example on v4.1 kernel:

[   49.612536] [ cut here ]
[   49.612543] WARNING: CPU: 0 PID: 2357 at lib/vsprintf.c:1867 
vsnprintf+0x5a7/0x5c0()
...

We can trigger this issue by injecting maliciously crafted x509 cert
in DER format. Just using hex editor to change the length of OID to
over the length of the SEQUENCE container. For example:

0:d=0  hl=4 l= 980 cons: SEQUENCE
4:d=1  hl=4 l= 700 cons:  SEQUENCE
8:d=2  hl=2 l=   3 cons:   cont [ 0 ]
   10:d=3  hl=2 l=   1 prim:INTEGER   :02
   13:d=2  hl=2 l=   9 prim:   INTEGER   :9B47FAF791E7D1E3
   24:d=2  hl=2 l=  13 cons:   SEQUENCE
   26:d=3  hl=2 l=   9 prim:OBJECT:sha256WithRSAEncryption
   37:d=3  hl=2 l=   0 prim:NULL
   39:d=2  hl=2 l= 121 cons:   SEQUENCE
   41:d=3  hl=2 l=  22 cons:SET
   43:d=4  hl=2 l=  20 cons: SEQUENCE  <=== the SEQ length is 20
   45:d=5  hl=2 l=   3 prim:  OBJECT:organizationName
<=== the original length is 3, change the length of OID to over the 
length of SEQUENCE

Pawel Wieczorkiewicz reported this problem and Takashi Iwai provided
patch to fix it by checking the bufsize in sprint_oid().

From: Takashi Iwai 
Reported-by: Pawel Wieczorkiewicz 
Cc: David Howells 
Cc: Rusty Russell 
Cc: Takashi Iwai 
Cc: Pawel Wieczorkiewicz 
Cc: Andrew Morton 
Signed-off-by: "Lee, Chun-Yi" 
Signed-off-by: Takashi Iwai 
---
 lib/oid_registry.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/oid_registry.c b/lib/oid_registry.c
index 318f382..41b9e50 100644
--- a/lib/oid_registry.c
+++ b/lib/oid_registry.c
@@ -142,9 +142,9 @@ int sprint_oid(const void *data, size_t datasize, char 
*buffer, size_t bufsize)
}
ret += count = snprintf(buffer, bufsize, ".%lu", num);
buffer += count;
-   bufsize -= count;
-   if (bufsize == 0)
+   if (bufsize <= count)
return -ENOBUFS;
+   bufsize -= count;
}
 
return ret;
-- 
2.10.2



fs/binfmt_flat.c:828:9: error: void value not ignored as it ought to be

2017-09-02 Thread kbuild test robot
Hi Al,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   d0d6ab53c9abd7dd1070f43a0455328874127ba8
commit: 468138d78510688fb5476f98d23f11ac6a63229a binfmt_flat: 
flat_{get,put}_addr_from_rp() should be able to fail
date:   9 weeks ago
config: m32r-mappi.nommu_defconfig (attached as .config)
compiler: m32r-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 468138d78510688fb5476f98d23f11ac6a63229a
# save the attached .config to linux build tree
make.cross ARCH=m32r 

All errors (new ones prefixed by >>):

   In file included from include/linux/kernel.h:13:0,
from fs/binfmt_flat.c:20:
   fs/binfmt_flat.c: In function 'load_flat_file':
   include/linux/kern_levels.h:4:18: warning: format '%ld' expects argument of 
type 'long int', but argument 2 has type 'u32 {aka unsigned int}' [-Wformat=]
#define KERN_SOH "\001"  /* ASCII Start Of Header */
 ^
   include/linux/printk.h:136:11: note: in definition of macro 'no_printk'
   printk(fmt, ##__VA_ARGS__); \
  ^~~
   include/linux/kern_levels.h:14:20: note: in expansion of macro 'KERN_SOH'
#define KERN_DEBUG KERN_SOH "7" /* debug-level messages */
   ^~~~
   include/linux/printk.h:339:12: note: in expansion of macro 'KERN_DEBUG'
 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
   ^~
   fs/binfmt_flat.c:577:3: note: in expansion of macro 'pr_debug'
  pr_debug("Allocated data+bss+stack (%ld bytes): %lx\n",
  ^~~~
>> fs/binfmt_flat.c:828:9: error: void value not ignored as it ought to be
ret = flat_put_addr_at_rp(rp, addr, relval);
^

vim +828 fs/binfmt_flat.c

   506  
   507  /*
   508   * Check initial limits. This avoids letting people circumvent
   509   * size limits imposed on them by creating programs with large
   510   * arrays in the data or bss.
   511   */
   512  rlim = rlimit(RLIMIT_DATA);
   513  if (rlim >= RLIM_INFINITY)
   514  rlim = ~0;
   515  if (data_len + bss_len > rlim) {
   516  ret = -ENOMEM;
   517  goto err;
   518  }
   519  
   520  /* Flush all traces of the currently running executable */
   521  if (id == 0) {
   522  ret = flush_old_exec(bprm);
   523  if (ret)
   524  goto err;
   525  
   526  /* OK, This is the point of no return */
   527  set_personality(PER_LINUX_32BIT);
   528  setup_new_exec(bprm);
   529  }
   530  
   531  /*
   532   * calculate the extra space we need to map in
   533   */
   534  extra = max_t(unsigned long, bss_len + stack_len,
   535  relocs * sizeof(unsigned long));
   536  
   537  /*
   538   * there are a couple of cases here,  the separate code/data
   539   * case,  and then the fully copied to RAM case which lumps
   540   * it all together.
   541   */
   542  if (!IS_ENABLED(CONFIG_MMU) && !(flags & 
(FLAT_FLAG_RAM|FLAT_FLAG_GZIP))) {
   543  /*
   544   * this should give us a ROM ptr,  but if it doesn't we 
don't
   545   * really care
   546   */
   547  pr_debug("ROM mapping of file (we hope)\n");
   548  
   549  textpos = vm_mmap(bprm->file, 0, text_len, 
PROT_READ|PROT_EXEC,
   550MAP_PRIVATE|MAP_EXECUTABLE, 0);
   551  if (!textpos || IS_ERR_VALUE(textpos)) {
   552  ret = textpos;
   553  if (!textpos)
   554  ret = -ENOMEM;
   555  pr_err("Unable to mmap process text, errno 
%d\n", ret);
   556  goto err;
   557  }
   558  
   559  len = data_len + extra + MAX_SHARED_LIBS * 
sizeof(unsigned long);
   560  len = PAGE_ALIGN(len);
   561  realdatastart = vm_mmap(NULL, 0, len,
   562  PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 0);
   563  
   564  if (realdatastart == 0 || IS_ERR_VALUE(realdatastart)) {
   565  ret = realdatastart;
   566  if (!realdatastart)
   567  ret = -ENOMEM;
   568  pr_err("Unable to allocate RAM for process 
data, "
   569 "errno %d\n", ret);
   570  vm_munmap(textpos, text_len);
   571   

[RFC v2 0/6] PMC/PUNIT IPC driver cleanup

2017-09-02 Thread sathyanarayanan . kuppuswamy
From: Kuppuswamy Sathyanarayanan 

Hi All,

Currently intel_pmc_ipc.c, intel_punit_ipc.c, intel_scu_ipc.c drivers 
implements the same IPC features.
This code duplication could be avoided if we implement the IPC driver as a 
generic library and let custom
device drivers use API provided by generic driver. This patchset mainly 
addresses this issue.

Along with above code duplication issue, This patch-set also addresses 
following issues in intel_pmc_ipc and
intel_punit_ipc drivers. 

1. Intel_pmc_ipc.c driver does not use any resource managed(devm_*) calls.
2. In Intel_pmc_ipc.c driver, dependent devices like PUNIT, Telemetry and iTCO 
are created manually and uses lot of redundant buffer code.
3. Global variable is used to store the IPC device structure and it is used 
across all functions in intel_pmc_ipc.c and intel_punit_ipc.c.

TODO: Cleanup patch for intel_scu_ipc.c will be submitted in next version. I 
submitted this intermediate version, to get the review comments
for other patches.

More info on adapted solution:
--

A generic Intel IPC class driver has been implemented and all common IPC helper 
functions has been moved to this driver. It exposes APIs to create IPC device 
channel, send raw IPC command and simple IPC commands. It also creates device 
attribute to send IPC command from user space.

API for creating a new IPC channel device is,

struct intel_ipc_dev *devm_intel_ipc_dev_create(struct device *dev, const char 
*devname, struct intel_ipc_dev_cfg *cfg, struct intel_ipc_dev_ops *ops)

The IPC channel drivers (PUNIT/PMC/SCU) when creating a new device can 
configure their device params like register mapping, irq, irq-mode, channel 
type,etc  using intel_ipc_dev_cfg and intel_ipc_dev_ops arguments. After a new 
IPC channel device is created, IPC users can use the generic APIs to make IPC 
calls.

For example, after using this new model, IPC call to PMC device will look like,

pmc_ipc_dev = intel_ipc_dev_get(INTEL_PMC_IPC_DEV);
ipc_dev_raw_cmd(pmc_ipc_dev, cmd, PMC_PARAM_LEN, (u32 *)ipc_in, 1, NULL, 0, 0, 
0);

I am still testing the driver in different products. But posted it to get some 
early comments. I also welcome any PMC/PUNIT driver users to check these 
patches in their product.

Changes since v1:
 * Merged devm_* changes in pmc_plat_probe and pmc_pci_probe functions into a
   single patch.
 * Addressed Andy's comment about keeping the library generic by not 
implementing
   the low level reg access calls in intel_ipc_dev.c. This version will start 
using
   the regmap pointer provided by channel drivers instead of fixed memory map.
 * Removed custom IPC APIs in intel_pmc_ipc.c and intel_punit_ipc.c.
 * Cleaned up IPC driver users to use APIs provided by generic library 
(intel_ipc_dev.c).

Kuppuswamy Sathyanarayanan (6):
  platform/x86: intel_pmc_ipc: Use devm_* calls in driver probe function
  platform/x86: intel_pmc_ipc: Use MFD framework to create dependent
devices
  platform/x86: intel_pmc_ipc: Use regmap calls for GCR updates
  platform: x86: Add generic Intel IPC driver
  platform/x86: intel_punit_ipc: Use generic intel ipc device calls
  platform/x86: intel_pmc_ipc: Use generic Intel IPC device calls

 arch/x86/include/asm/intel_pmc_ipc.h|  37 +-
 arch/x86/include/asm/intel_punit_ipc.h  | 125 ++--
 drivers/mfd/intel_soc_pmic_bxtwc.c  |  24 +-
 drivers/platform/x86/Kconfig|  10 +
 drivers/platform/x86/Makefile   |   1 +
 drivers/platform/x86/intel_ipc_dev.c| 473 
 drivers/platform/x86/intel_pmc_ipc.c| 927 +---
 drivers/platform/x86/intel_punit_ipc.c  | 293 +++-
 drivers/platform/x86/intel_telemetry_pltdrv.c   | 202 +++---
 include/linux/mfd/intel_soc_pmic.h  |   2 +
 include/linux/platform_data/x86/intel_ipc_dev.h | 175 +
 11 files changed, 1284 insertions(+), 985 deletions(-)
 create mode 100644 drivers/platform/x86/intel_ipc_dev.c
 create mode 100644 include/linux/platform_data/x86/intel_ipc_dev.h

-- 
2.7.4



[RFC v2 3/6] platform/x86: intel_pmc_ipc: Use regmap calls for GCR updates

2017-09-02 Thread sathyanarayanan . kuppuswamy
From: Kuppuswamy Sathyanarayanan 

Currently, update_no_reboot_bit() function implemented in this driver
uses mutex_lock to protect its register updates. But this function is
called with in atomic context in iTCO_wdt_start() and iTCO_wdt_stop()
functions in iTCO_wdt.c driver, which in turn causes "sleeping into
atomic context" issue. This patch fixes this issue by refactoring the
current GCR read/write/update functions with regmap APIs.

Signed-off-by: Kuppuswamy Sathyanarayanan 

---
 drivers/platform/x86/Kconfig |   1 +
 drivers/platform/x86/intel_pmc_ipc.c | 115 ---
 2 files changed, 40 insertions(+), 76 deletions(-)

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 80b8795..45f4e79 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -1054,6 +1054,7 @@ config PVPANIC
 config INTEL_PMC_IPC
tristate "Intel PMC IPC Driver"
depends on ACPI
+   select REGMAP_MMIO
---help---
This driver provides support for PMC control on some Intel platforms.
The PMC is an ARC processor which defines IPC commands for communication
diff --git a/drivers/platform/x86/intel_pmc_ipc.c 
b/drivers/platform/x86/intel_pmc_ipc.c
index 60a4be6..62f 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -31,9 +31,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -125,7 +127,7 @@ static struct intel_pmc_ipc_dev {
 
/* gcr */
void __iomem *gcr_mem_base;
-   bool has_gcr_regs;
+   struct regmap *gcr_regs;
 
/* Telemetry */
u8 telem_res_inval;
@@ -150,6 +152,14 @@ static char *ipc_err_sources[] = {
"Unsigned kernel",
 };
 
+static struct regmap_config gcr_regmap_config = {
+.reg_bits = 32,
+.reg_stride = 4,
+.val_bits = 32,
+   .fast_io = true,
+   .max_register = PLAT_RESOURCE_GCR_SIZE,
+};
+
 /* Prevent concurrent calls to the PMC */
 static DEFINE_MUTEX(ipclock);
 
@@ -183,21 +193,6 @@ static inline u32 ipc_data_readl(u32 offset)
return readl(ipcdev.ipc_base + IPC_READ_BUFFER + offset);
 }
 
-static inline u64 gcr_data_readq(u32 offset)
-{
-   return readq(ipcdev.gcr_mem_base + offset);
-}
-
-static inline int is_gcr_valid(u32 offset)
-{
-   if (!ipcdev.has_gcr_regs)
-   return -EACCES;
-
-   if (offset > PLAT_RESOURCE_GCR_SIZE)
-   return -EINVAL;
-
-   return 0;
-}
 
 /**
  * intel_pmc_gcr_read() - Read PMC GCR register
@@ -210,21 +205,10 @@ static inline int is_gcr_valid(u32 offset)
  */
 int intel_pmc_gcr_read(u32 offset, u32 *data)
 {
-   int ret;
-
-   mutex_lock(&ipclock);
-
-   ret = is_gcr_valid(offset);
-   if (ret < 0) {
-   mutex_unlock(&ipclock);
-   return ret;
-   }
-
-   *data = readl(ipcdev.gcr_mem_base + offset);
-
-   mutex_unlock(&ipclock);
+   if (!ipcdev.gcr_regs)
+   return -EACCES;
 
-   return 0;
+   return regmap_read(ipcdev.gcr_regs, offset, data);
 }
 EXPORT_SYMBOL_GPL(intel_pmc_gcr_read);
 
@@ -240,21 +224,10 @@ EXPORT_SYMBOL_GPL(intel_pmc_gcr_read);
  */
 int intel_pmc_gcr_write(u32 offset, u32 data)
 {
-   int ret;
-
-   mutex_lock(&ipclock);
-
-   ret = is_gcr_valid(offset);
-   if (ret < 0) {
-   mutex_unlock(&ipclock);
-   return ret;
-   }
-
-   writel(data, ipcdev.gcr_mem_base + offset);
-
-   mutex_unlock(&ipclock);
+   if (!ipcdev.gcr_regs)
+   return -EACCES;
 
-   return 0;
+   return regmap_write(ipcdev.gcr_regs, offset, data);
 }
 EXPORT_SYMBOL_GPL(intel_pmc_gcr_write);
 
@@ -271,33 +244,10 @@ EXPORT_SYMBOL_GPL(intel_pmc_gcr_write);
  */
 int intel_pmc_gcr_update(u32 offset, u32 mask, u32 val)
 {
-   u32 new_val;
-   int ret = 0;
-
-   mutex_lock(&ipclock);
-
-   ret = is_gcr_valid(offset);
-   if (ret < 0)
-   goto gcr_ipc_unlock;
-
-   new_val = readl(ipcdev.gcr_mem_base + offset);
-
-   new_val &= ~mask;
-   new_val |= val & mask;
-
-   writel(new_val, ipcdev.gcr_mem_base + offset);
-
-   new_val = readl(ipcdev.gcr_mem_base + offset);
-
-   /* check whether the bit update is successful */
-   if ((new_val & mask) != (val & mask)) {
-   ret = -EIO;
-   goto gcr_ipc_unlock;
-   }
+   if (!ipcdev.gcr_regs)
+   return -EACCES;
 
-gcr_ipc_unlock:
-   mutex_unlock(&ipclock);
-   return ret;
+   return regmap_update_bits(ipcdev.gcr_regs, offset, mask, val);
 }
 EXPORT_SYMBOL_GPL(intel_pmc_gcr_update);
 
@@ -801,16 +751,24 @@ static int ipc_plat_get_res(struct platform_device *pdev)
 int intel_pmc_s0ix_counter_read(u64 *data)
 {
u64 deep, shlw;
+   int ret;
 
-   if (!ipcdev.has_gcr_regs)
+   if (!ipcdev.gcr_regs)
return -EAC

[RFC v2 4/6] platform: x86: Add generic Intel IPC driver

2017-09-02 Thread sathyanarayanan . kuppuswamy
From: Kuppuswamy Sathyanarayanan 

Currently intel_scu_ipc.c, intel_pmc_ipc.c and intel_punit_ipc.c
redundantly implements the same IPC features and has lot of code
duplication between them. This driver addresses this issue by grouping
the common IPC functionalities under the same driver.

Signed-off-by: Kuppuswamy Sathyanarayanan 

---
 drivers/platform/x86/Kconfig|   8 +
 drivers/platform/x86/Makefile   |   1 +
 drivers/platform/x86/intel_ipc_dev.c| 473 
 include/linux/platform_data/x86/intel_ipc_dev.h | 175 +
 4 files changed, 657 insertions(+)
 create mode 100644 drivers/platform/x86/intel_ipc_dev.c
 create mode 100644 include/linux/platform_data/x86/intel_ipc_dev.h

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 45f4e79..b3c5ff4 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -1140,6 +1140,14 @@ config SILEAD_DMI
  with the OS-image for the device. This option supplies the missing
  information. Enable this for x86 tablets with Silead touchscreens.
 
+config INTEL_IPC_DEV
+   tristate "Intel IPC Device Driver"
+   depends on X86_64
+   ---help---
+ This driver implements core features of Intel IPC device. Devices
+ like PMC, SCU, PUNIT, etc can use interfaces provided by this
+ driver to implement IPC protocol of their respective device.
+
 endif # X86_PLATFORM_DEVICES
 
 config PMC_ATOM
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 91cec17..04e11ce 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -83,3 +83,4 @@ obj-$(CONFIG_PMC_ATOM)+= pmc_atom.o
 obj-$(CONFIG_MLX_PLATFORM) += mlx-platform.o
 obj-$(CONFIG_MLX_CPLD_PLATFORM)+= mlxcpld-hotplug.o
 obj-$(CONFIG_INTEL_TURBO_MAX_3) += intel_turbo_max_3.o
+obj-$(CONFIG_INTEL_IPC_DEV)+= intel_ipc_dev.o
diff --git a/drivers/platform/x86/intel_ipc_dev.c 
b/drivers/platform/x86/intel_ipc_dev.c
new file mode 100644
index 000..99de656
--- /dev/null
+++ b/drivers/platform/x86/intel_ipc_dev.c
@@ -0,0 +1,473 @@
+/*
+ * intel_ipc_dev.c: Intel IPC device class driver
+ *
+ * (C) Copyright 2017 Intel Corporation
+ *
+ * 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; version 2
+ * of the License.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* mutex to sync different ipc devices in same channel */
+static struct mutex channel_lock[IPC_CHANNEL_MAX];
+
+static void ipc_channel_lock_init(void)
+{
+   int i;
+
+   for (i = 0; i < IPC_CHANNEL_MAX; i++)
+   mutex_init(&channel_lock[i]);
+}
+
+static struct class intel_ipc_class = {
+   .name = "intel_ipc",
+   .owner = THIS_MODULE,
+};
+
+static int ipc_dev_lock(struct intel_ipc_dev *ipc_dev)
+{
+   int chan_type;
+
+   if (!ipc_dev || !ipc_dev->cfg)
+   return -ENODEV;
+
+   chan_type = ipc_dev->cfg->chan_type;
+   if (chan_type > IPC_CHANNEL_MAX)
+   return -EINVAL;
+
+   /* acquire channel lock */
+   mutex_lock(&channel_lock[chan_type]);
+
+   /* acquire IPC device lock */
+   mutex_lock(&ipc_dev->lock);
+
+   return 0;
+}
+
+static int ipc_dev_unlock(struct intel_ipc_dev *ipc_dev)
+{
+   int chan_type;
+
+   if (!ipc_dev || !ipc_dev->cfg)
+   return -ENODEV;
+
+   chan_type = ipc_dev->cfg->chan_type;
+   if (chan_type > IPC_CHANNEL_MAX)
+   return -EINVAL;
+
+   /* release IPC device lock */
+   mutex_unlock(&ipc_dev->lock);
+
+   /* release channel lock */
+   mutex_unlock(&channel_lock[chan_type]);
+
+   return 0;
+}
+
+static const char *ipc_dev_err_string(struct intel_ipc_dev *ipc_dev,
+   int error)
+{
+   switch (error) {
+   case IPC_DEV_ERR_NONE:
+   return "No error";
+   case IPC_DEV_ERR_CMD_NOT_SUPPORTED:
+   return "Command not-supported/Invalid";
+   case IPC_DEV_ERR_CMD_NOT_SERVICED:
+   return "Command not-serviced/Invalid param";
+   case IPC_DEV_ERR_UNABLE_TO_SERVICE:
+   return "Unable-to-service/Cmd-timeout";
+   case IPC_DEV_ERR_CMD_INVALID:
+   return "Command-invalid/Cmd-locked";
+   case IPC_DEV_ERR_CMD_FAILED:
+   return "Command-failed/Invalid-VR-id";
+   case IPC_DEV_ERR_EMSECURITY:
+   return "Invalid Battery/VR-Error";
+   case IPC_DEV_ERR_UNSIGNEDKERNEL:
+   return "Unsigned kernel";
+   default:
+   return "Unknown Command";
+   };
+}
+
+/* Helper function to send given command to IPC device */
+static inline void ipc_dev_send_cmd(struct intel_ipc_dev *ipc_dev, u32 cmd)
+{
+   ipc

[RFC v2 6/6] platform/x86: intel_pmc_ipc: Use generic Intel IPC device calls

2017-09-02 Thread sathyanarayanan . kuppuswamy
From: Kuppuswamy Sathyanarayanan 

Removed redundant IPC helper functions and refactored the driver to use
generic IPC device driver APIs.

This patch also cleans-up PMC IPC user drivers to use APIs provided
by generic IPC driver.

Signed-off-by: Kuppuswamy Sathyanarayanan 

---
 arch/x86/include/asm/intel_pmc_ipc.h  |  37 +--
 drivers/mfd/intel_soc_pmic_bxtwc.c|  24 +-
 drivers/platform/x86/intel_pmc_ipc.c  | 364 +-
 drivers/platform/x86/intel_telemetry_pltdrv.c | 114 
 include/linux/mfd/intel_soc_pmic.h|   2 +
 5 files changed, 215 insertions(+), 326 deletions(-)

Changes since v1:
 * Removed custom APIs.
 * Cleaned up PMC IPC user drivers to use APIs provided by generic
   IPC driver.

diff --git a/arch/x86/include/asm/intel_pmc_ipc.h 
b/arch/x86/include/asm/intel_pmc_ipc.h
index fac89eb..9fc7c3c 100644
--- a/arch/x86/include/asm/intel_pmc_ipc.h
+++ b/arch/x86/include/asm/intel_pmc_ipc.h
@@ -1,10 +1,15 @@
 #ifndef _ASM_X86_INTEL_PMC_IPC_H_
 #define  _ASM_X86_INTEL_PMC_IPC_H_
 
+#include 
+
+#define INTEL_PMC_IPC_DEV  "intel_pmc_ipc"
+#define PMC_PARAM_LEN  2
+
 /* Commands */
 #define PMC_IPC_PMIC_ACCESS0xFF
-#definePMC_IPC_PMIC_ACCESS_READ0x0
-#definePMC_IPC_PMIC_ACCESS_WRITE   0x1
+#definePMC_IPC_PMIC_ACCESS_READ0x0
+#definePMC_IPC_PMIC_ACCESS_WRITE   0x1
 #define PMC_IPC_USB_PWR_CTRL   0xF0
 #define PMC_IPC_PMIC_BLACKLIST_SEL 0xEF
 #define PMC_IPC_PHY_CONFIG 0xEE
@@ -28,13 +33,14 @@
 #define PMC_GCR_TELEM_DEEP_S0IX_REG0x78
 #define PMC_GCR_TELEM_SHLW_S0IX_REG0x80
 
+static inline void pmc_cmd_init(u32 *cmd, u32 param1, u32 param2)
+{
+   cmd[0] = param1;
+   cmd[1] = param2;
+}
+
 #if IS_ENABLED(CONFIG_INTEL_PMC_IPC)
 
-int intel_pmc_ipc_simple_command(int cmd, int sub);
-int intel_pmc_ipc_raw_cmd(u32 cmd, u32 sub, u8 *in, u32 inlen,
-   u32 *out, u32 outlen, u32 dptr, u32 sptr);
-int intel_pmc_ipc_command(u32 cmd, u32 sub, u8 *in, u32 inlen,
-   u32 *out, u32 outlen);
 int intel_pmc_s0ix_counter_read(u64 *data);
 int intel_pmc_gcr_read(u32 offset, u32 *data);
 int intel_pmc_gcr_write(u32 offset, u32 data);
@@ -42,23 +48,6 @@ int intel_pmc_gcr_update(u32 offset, u32 mask, u32 val);
 
 #else
 
-static inline int intel_pmc_ipc_simple_command(int cmd, int sub)
-{
-   return -EINVAL;
-}
-
-static inline int intel_pmc_ipc_raw_cmd(u32 cmd, u32 sub, u8 *in, u32 inlen,
-   u32 *out, u32 outlen, u32 dptr, u32 sptr)
-{
-   return -EINVAL;
-}
-
-static inline int intel_pmc_ipc_command(u32 cmd, u32 sub, u8 *in, u32 inlen,
-   u32 *out, u32 outlen)
-{
-   return -EINVAL;
-}
-
 static inline int intel_pmc_s0ix_counter_read(u64 *data)
 {
return -EINVAL;
diff --git a/drivers/mfd/intel_soc_pmic_bxtwc.c 
b/drivers/mfd/intel_soc_pmic_bxtwc.c
index 15bc052..368cbe2 100644
--- a/drivers/mfd/intel_soc_pmic_bxtwc.c
+++ b/drivers/mfd/intel_soc_pmic_bxtwc.c
@@ -268,9 +268,11 @@ static int regmap_ipc_byte_reg_read(void *context, 
unsigned int reg,
 {
int ret;
int i2c_addr;
-   u8 ipc_in[2];
-   u8 ipc_out[4];
+   u8 ipc_in[2] = {0};
+   u8 ipc_out[4] = {0};
struct intel_soc_pmic *pmic = context;
+   u32 cmd[PMC_PARAM_LEN] = {PMC_IPC_PMIC_ACCESS,
+   PMC_IPC_PMIC_ACCESS_READ};
 
if (!pmic)
return -EINVAL;
@@ -284,9 +286,8 @@ static int regmap_ipc_byte_reg_read(void *context, unsigned 
int reg,
 
ipc_in[0] = reg;
ipc_in[1] = i2c_addr;
-   ret = intel_pmc_ipc_command(PMC_IPC_PMIC_ACCESS,
-   PMC_IPC_PMIC_ACCESS_READ,
-   ipc_in, sizeof(ipc_in), (u32 *)ipc_out, 1);
+   ret = ipc_dev_raw_cmd(pmic->ipc_dev, cmd, PMC_PARAM_LEN, (u32 *)ipc_in,
+   1, (u32 *)ipc_out, 1, 0, 0);
if (ret) {
dev_err(pmic->dev, "Failed to read from PMIC\n");
return ret;
@@ -301,8 +302,10 @@ static int regmap_ipc_byte_reg_write(void *context, 
unsigned int reg,
 {
int ret;
int i2c_addr;
-   u8 ipc_in[3];
+   u8 ipc_in[3] = {0};
struct intel_soc_pmic *pmic = context;
+   u32 cmd[PMC_PARAM_LEN] = {PMC_IPC_PMIC_ACCESS,
+   PMC_IPC_PMIC_ACCESS_WRITE};
 
if (!pmic)
return -EINVAL;
@@ -317,9 +320,8 @@ static int regmap_ipc_byte_reg_write(void *context, 
unsigned int reg,
ipc_in[0] = reg;
ipc_in[1] = i2c_addr;
ipc_in[2] = val;
-   ret = intel_pmc_ipc_command(PMC_IPC_PMIC_ACCESS,
-   PMC_IPC_PMIC_ACCESS_WRITE,
-   ipc_in, sizeof(ipc_in), NULL, 0);
+   ret = ipc_dev_raw_cmd(pmic->ipc_dev, cmd, PMC_PARAM_LEN, (u32 *)ipc_in,
+   1, NULL, 0, 0, 0);
if (ret) {
dev_err(pmic->dev, "Failed to write to 

[RFC v2 5/6] platform/x86: intel_punit_ipc: Use generic intel ipc device calls

2017-09-02 Thread sathyanarayanan . kuppuswamy
From: Kuppuswamy Sathyanarayanan 

Removed redundant IPC helper functions and refactored the driver to use
APIs provided by generic IPC driver. This patch also cleans-up PUNIT IPC
user drivers to use APIs provided by generic IPC driver.

Signed-off-by: Kuppuswamy Sathyanarayanan 

---
 arch/x86/include/asm/intel_punit_ipc.h| 125 +--
 drivers/platform/x86/Kconfig  |   1 +
 drivers/platform/x86/intel_punit_ipc.c| 293 +-
 drivers/platform/x86/intel_telemetry_pltdrv.c |  92 
 4 files changed, 212 insertions(+), 299 deletions(-)

Changes since v1:
 * Removed custom APIs.
 * Cleaned up PUNIT IPC user drivers to use APIs provided by generic
   IPC driver.

diff --git a/arch/x86/include/asm/intel_punit_ipc.h 
b/arch/x86/include/asm/intel_punit_ipc.h
index 201eb9d..cf1630c 100644
--- a/arch/x86/include/asm/intel_punit_ipc.h
+++ b/arch/x86/include/asm/intel_punit_ipc.h
@@ -1,10 +1,8 @@
 #ifndef _ASM_X86_INTEL_PUNIT_IPC_H_
 #define  _ASM_X86_INTEL_PUNIT_IPC_H_
 
-/*
- * Three types of 8bit P-Unit IPC commands are supported,
- * bit[7:6]: [00]: BIOS; [01]: GTD; [10]: ISPD.
- */
+#include 
+
 typedef enum {
BIOS_IPC = 0,
GTDRIVER_IPC,
@@ -12,61 +10,60 @@ typedef enum {
RESERVED_IPC,
 } IPC_TYPE;
 
-#define IPC_TYPE_OFFSET6
-#define IPC_PUNIT_BIOS_CMD_BASE(BIOS_IPC << IPC_TYPE_OFFSET)
-#define IPC_PUNIT_GTD_CMD_BASE (GTDDRIVER_IPC << IPC_TYPE_OFFSET)
-#define IPC_PUNIT_ISPD_CMD_BASE(ISPDRIVER_IPC << 
IPC_TYPE_OFFSET)
-#define IPC_PUNIT_CMD_TYPE_MASK(RESERVED_IPC << 
IPC_TYPE_OFFSET)
+#define PUNIT_BIOS_IPC_DEV "punit_bios_ipc"
+#define PUNIT_GTD_IPC_DEV  "punit_gtd_ipc"
+#define PUNIT_ISP_IPC_DEV  "punit_isp_ipc"
+#define PUNIT_PARAM_LEN3
 
 /* BIOS => Pcode commands */
-#define IPC_PUNIT_BIOS_ZERO(IPC_PUNIT_BIOS_CMD_BASE | 0x00)
-#define IPC_PUNIT_BIOS_VR_INTERFACE(IPC_PUNIT_BIOS_CMD_BASE | 0x01)
-#define IPC_PUNIT_BIOS_READ_PCS
(IPC_PUNIT_BIOS_CMD_BASE | 0x02)
-#define IPC_PUNIT_BIOS_WRITE_PCS   (IPC_PUNIT_BIOS_CMD_BASE | 0x03)
-#define IPC_PUNIT_BIOS_READ_PCU_CONFIG (IPC_PUNIT_BIOS_CMD_BASE | 0x04)
-#define IPC_PUNIT_BIOS_WRITE_PCU_CONFIG
(IPC_PUNIT_BIOS_CMD_BASE | 0x05)
-#define IPC_PUNIT_BIOS_READ_PL1_SETTING
(IPC_PUNIT_BIOS_CMD_BASE | 0x06)
-#define IPC_PUNIT_BIOS_WRITE_PL1_SETTING   (IPC_PUNIT_BIOS_CMD_BASE | 0x07)
-#define IPC_PUNIT_BIOS_TRIGGER_VDD_RAM (IPC_PUNIT_BIOS_CMD_BASE | 0x08)
-#define IPC_PUNIT_BIOS_READ_TELE_INFO  (IPC_PUNIT_BIOS_CMD_BASE | 0x09)
-#define IPC_PUNIT_BIOS_READ_TELE_TRACE_CTRL(IPC_PUNIT_BIOS_CMD_BASE | 0x0a)
-#define IPC_PUNIT_BIOS_WRITE_TELE_TRACE_CTRL   (IPC_PUNIT_BIOS_CMD_BASE | 0x0b)
-#define IPC_PUNIT_BIOS_READ_TELE_EVENT_CTRL(IPC_PUNIT_BIOS_CMD_BASE | 0x0c)
-#define IPC_PUNIT_BIOS_WRITE_TELE_EVENT_CTRL   (IPC_PUNIT_BIOS_CMD_BASE | 0x0d)
-#define IPC_PUNIT_BIOS_READ_TELE_TRACE (IPC_PUNIT_BIOS_CMD_BASE | 0x0e)
-#define IPC_PUNIT_BIOS_WRITE_TELE_TRACE
(IPC_PUNIT_BIOS_CMD_BASE | 0x0f)
-#define IPC_PUNIT_BIOS_READ_TELE_EVENT (IPC_PUNIT_BIOS_CMD_BASE | 0x10)
-#define IPC_PUNIT_BIOS_WRITE_TELE_EVENT
(IPC_PUNIT_BIOS_CMD_BASE | 0x11)
-#define IPC_PUNIT_BIOS_READ_MODULE_TEMP
(IPC_PUNIT_BIOS_CMD_BASE | 0x12)
-#define IPC_PUNIT_BIOS_RESERVED
(IPC_PUNIT_BIOS_CMD_BASE | 0x13)
-#define IPC_PUNIT_BIOS_READ_VOLTAGE_OVER   (IPC_PUNIT_BIOS_CMD_BASE | 0x14)
-#define IPC_PUNIT_BIOS_WRITE_VOLTAGE_OVER  (IPC_PUNIT_BIOS_CMD_BASE | 0x15)
-#define IPC_PUNIT_BIOS_READ_RATIO_OVER (IPC_PUNIT_BIOS_CMD_BASE | 0x16)
-#define IPC_PUNIT_BIOS_WRITE_RATIO_OVER
(IPC_PUNIT_BIOS_CMD_BASE | 0x17)
-#define IPC_PUNIT_BIOS_READ_VF_GL_CTRL (IPC_PUNIT_BIOS_CMD_BASE | 0x18)
-#define IPC_PUNIT_BIOS_WRITE_VF_GL_CTRL
(IPC_PUNIT_BIOS_CMD_BASE | 0x19)
-#define IPC_PUNIT_BIOS_READ_FM_SOC_TEMP_THRESH (IPC_PUNIT_BIOS_CMD_BASE | 0x1a)
-#define IPC_PUNIT_BIOS_WRITE_FM_SOC_TEMP_THRESH
(IPC_PUNIT_BIOS_CMD_BASE | 0x1b)
+#define IPC_PUNIT_BIOS_ZERO(0x00)
+#define IPC_PUNIT_BIOS_VR_INTERFACE(0x01)
+#define IPC_PUNIT_BIOS_READ_PCS(0x02)
+#define IPC_PUNIT_BIOS_WRITE_PCS   (0x03)
+#define IPC_PUNIT_BIOS_READ_PCU_CONFIG (0x04)
+#define IPC_PUNIT_BIOS_WRITE_PCU_CONFIG(0x05)
+#define IPC_PUNIT_BIOS_READ_PL1_SETTING(0x06)
+#define IPC_PUNIT_BIOS_WRITE_PL1_SETTING   (0x07)
+#define IPC_PUNIT_BIOS_TRIGGER_VDD_RAM (0x08)
+#define IPC_PUNIT_BIOS_READ_TELE_INFO  (0x09)
+#define IPC_PUNIT_BIOS_READ_TELE_TRACE_CTRL(0x0a)
+#define IPC_PUNIT_BIOS_WRITE_TELE_TRACE_CTRL   (0x0b)
+#de

[RFC v2 2/6] platform/x86: intel_pmc_ipc: Use MFD framework to create dependent devices

2017-09-02 Thread sathyanarayanan . kuppuswamy
From: Kuppuswamy Sathyanarayanan 

Currently, we have lot of repetitive code in dependent device resource
allocation and device creation handling code. This logic can be improved if
we use MFD framework for dependent device creation. This patch adds this
support.

Signed-off-by: Kuppuswamy Sathyanarayanan 

---
 drivers/platform/x86/intel_pmc_ipc.c | 397 +--
 1 file changed, 142 insertions(+), 255 deletions(-)

diff --git a/drivers/platform/x86/intel_pmc_ipc.c 
b/drivers/platform/x86/intel_pmc_ipc.c
index 7f86594..60a4be6 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -87,6 +88,7 @@
 #define PLAT_RESOURCE_ISP_IFACE_INDEX  5
 #define PLAT_RESOURCE_GTD_DATA_INDEX   6
 #define PLAT_RESOURCE_GTD_IFACE_INDEX  7
+#define PLAT_RESOURCE_MEM_MAX_INDEX8
 #define PLAT_RESOURCE_ACPI_IO_INDEX0
 
 /*
@@ -105,8 +107,6 @@
 #define TELEM_SSRAM_SIZE   240
 #define TELEM_PMC_SSRAM_OFFSET 0x1B00
 #define TELEM_PUNIT_SSRAM_OFFSET   0x1A00
-#define TCO_PMC_OFFSET 0x8
-#define TCO_PMC_SIZE   0x4
 
 /* PMC register bit definitions */
 
@@ -123,25 +123,12 @@ static struct intel_pmc_ipc_dev {
int cmd;
struct completion cmd_complete;
 
-   /* The following PMC BARs share the same ACPI device with the IPC */
-   resource_size_t acpi_io_base;
-   int acpi_io_size;
-   struct platform_device *tco_dev;
-
/* gcr */
void __iomem *gcr_mem_base;
bool has_gcr_regs;
 
-   /* punit */
-   struct platform_device *punit_dev;
-
/* Telemetry */
-   resource_size_t telem_pmc_ssram_base;
-   resource_size_t telem_punit_ssram_base;
-   int telem_pmc_ssram_size;
-   int telem_punit_ssram_size;
u8 telem_res_inval;
-   struct platform_device *telemetry_dev;
 } ipcdev;
 
 static char *ipc_err_sources[] = {
@@ -614,44 +601,6 @@ static const struct attribute_group intel_ipc_group = {
.attrs = intel_ipc_attrs,
 };
 
-static struct resource punit_res_array[] = {
-   /* Punit BIOS */
-   {
-   .flags = IORESOURCE_MEM,
-   },
-   {
-   .flags = IORESOURCE_MEM,
-   },
-   /* Punit ISP */
-   {
-   .flags = IORESOURCE_MEM,
-   },
-   {
-   .flags = IORESOURCE_MEM,
-   },
-   /* Punit GTD */
-   {
-   .flags = IORESOURCE_MEM,
-   },
-   {
-   .flags = IORESOURCE_MEM,
-   },
-};
-
-#define TCO_RESOURCE_ACPI_IO   0
-#define TCO_RESOURCE_SMI_EN_IO 1
-#define TCO_RESOURCE_GCR_MEM   2
-static struct resource tco_res[] = {
-   /* ACPI - TCO */
-   {
-   .flags = IORESOURCE_IO,
-   },
-   /* ACPI - SMI */
-   {
-   .flags = IORESOURCE_IO,
-   },
-};
-
 static struct itco_wdt_platform_data tco_info = {
.name = "Apollo Lake SoC",
.version = 5,
@@ -659,237 +608,186 @@ static struct itco_wdt_platform_data tco_info = {
.update_no_reboot_bit = update_no_reboot_bit,
 };
 
-#define TELEMETRY_RESOURCE_PUNIT_SSRAM 0
-#define TELEMETRY_RESOURCE_PMC_SSRAM   1
-static struct resource telemetry_res[] = {
-   /*Telemetry*/
-   {
-   .flags = IORESOURCE_MEM,
-   },
-   {
-   .flags = IORESOURCE_MEM,
-   },
-};
-
-static int ipc_create_punit_device(void)
+static int ipc_create_punit_device(struct platform_device *pdev)
 {
-   struct platform_device *pdev;
-   const struct platform_device_info pdevinfo = {
-   .parent = ipcdev.dev,
-   .name = PUNIT_DEVICE_NAME,
-   .id = -1,
-   .res = punit_res_array,
-   .num_res = ARRAY_SIZE(punit_res_array),
+   struct resource *res;
+   static struct resource punit_res[PLAT_RESOURCE_MEM_MAX_INDEX];
+   static struct mfd_cell punit_cell;
+   int mindex, pindex = 0;
+
+   for (mindex = 0; mindex <= PLAT_RESOURCE_MEM_MAX_INDEX; mindex++) {
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, mindex);
+
+   switch (mindex) {
+   /* Get PUNIT resources */
+   case PLAT_RESOURCE_BIOS_DATA_INDEX:
+   case PLAT_RESOURCE_BIOS_IFACE_INDEX:
+   /* BIOS resources are required, so return error if not
+* available */
+   if (!res) {
+   dev_err(&pdev->dev,
+   "Failed to get punit mem resource %d\n",
+   pindex);
+   return -ENXIO;
+   }
+   case PLAT_RESOURCE_ISP_DATA_INDEX:
+   case PLAT_RESOURCE_ISP_IFACE_INDEX:
+   case PLAT_RESOURCE_GTD_DATA_INDEX:
+   case PLAT_R

[RFC v2 1/6] platform/x86: intel_pmc_ipc: Use devm_* calls in driver probe function

2017-09-02 Thread sathyanarayanan . kuppuswamy
From: Kuppuswamy Sathyanarayanan 

This patch cleans up unnecessary free/alloc calls in ipc_plat_probe(),
ipc_pci_probe() and ipc_plat_get_res() functions by using devm_*
calls.

This patch also adds proper error handling for failure cases in
ipc_pci_probe() function.

Signed-off-by: Kuppuswamy Sathyanarayanan 

---
 drivers/platform/x86/intel_pmc_ipc.c | 87 
 1 file changed, 38 insertions(+), 49 deletions(-)

Changes since v1:
 * Merged devm_* related changes into a single function.
 * Instead of removing free_irq, use devm_free_irq function.


diff --git a/drivers/platform/x86/intel_pmc_ipc.c 
b/drivers/platform/x86/intel_pmc_ipc.c
index bb792a5..7f86594 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -489,42 +489,53 @@ static int ipc_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
 
ret = pci_enable_device(pdev);
if (ret)
-   return ret;
+   goto release_device;
 
ret = pci_request_regions(pdev, "intel_pmc_ipc");
if (ret)
-   return ret;
+   goto disable_device;
 
pci_resource = pci_resource_start(pdev, 0);
len = pci_resource_len(pdev, 0);
if (!pci_resource || !len) {
dev_err(&pdev->dev, "Failed to get resource\n");
-   return -ENOMEM;
+   ret = -ENOMEM;
+   goto free_pci_resources;
}
 
init_completion(&ipcdev.cmd_complete);
 
-   if (request_irq(pdev->irq, ioc, 0, "intel_pmc_ipc", &ipcdev)) {
+   if (devm_request_irq(&pdev->dev, pdev->irq, ioc, 0, "intel_pmc_ipc",
+   &ipcdev)) {
dev_err(&pdev->dev, "Failed to request irq\n");
-   return -EBUSY;
+   ret = -EBUSY;
+   goto free_pci_resources;
}
 
-   ipcdev.ipc_base = ioremap_nocache(pci_resource, len);
+   ipcdev.ipc_base = devm_ioremap_nocache(&pdev->dev, pci_resource, len);
if (!ipcdev.ipc_base) {
dev_err(&pdev->dev, "Failed to ioremap ipc base\n");
-   free_irq(pdev->irq, &ipcdev);
ret = -ENOMEM;
+   goto free_pci_resources;
}
 
+   return 0;
+
+free_pci_resources:
+   pci_release_regions(pdev);
+disable_device:
+   pci_disable_device(pdev);
+release_device:
+   pci_dev_put(pdev);
+
return ret;
 }
 
 static void ipc_pci_remove(struct pci_dev *pdev)
 {
-   free_irq(pdev->irq, &ipcdev);
+   devm_free_irq(&pdev->dev, pdev->irq, &ipcdev);
pci_release_regions(pdev);
pci_dev_put(pdev);
-   iounmap(ipcdev.ipc_base);
ipcdev.dev = NULL;
 }
 
@@ -849,18 +860,16 @@ static int ipc_plat_get_res(struct platform_device *pdev)
dev_err(&pdev->dev, "Failed to get ipc resource\n");
return -ENXIO;
}
-   size = PLAT_RESOURCE_IPC_SIZE + PLAT_RESOURCE_GCR_SIZE;
-
-   if (!request_mem_region(res->start, size, pdev->name)) {
-   dev_err(&pdev->dev, "Failed to request ipc resource\n");
-   return -EBUSY;
-   }
-   addr = ioremap_nocache(res->start, size);
-   if (!addr) {
-   dev_err(&pdev->dev, "I/O memory remapping failed\n");
-   release_mem_region(res->start, size);
-   return -ENOMEM;
+   res->end = (res->start + PLAT_RESOURCE_IPC_SIZE +
+   PLAT_RESOURCE_GCR_SIZE - 1);
+
+   addr = devm_ioremap_resource(&pdev->dev, res);
+   if (IS_ERR(addr)) {
+   dev_err(&pdev->dev,
+   "PMC I/O memory remapping failed\n");
+   return PTR_ERR(addr);
}
+
ipcdev.ipc_base = addr;
 
ipcdev.gcr_mem_base = addr + PLAT_RESOURCE_GCR_OFFSET;
@@ -917,7 +926,6 @@ MODULE_DEVICE_TABLE(acpi, ipc_acpi_ids);
 
 static int ipc_plat_probe(struct platform_device *pdev)
 {
-   struct resource *res;
int ret;
 
ipcdev.dev = &pdev->dev;
@@ -939,61 +947,42 @@ static int ipc_plat_probe(struct platform_device *pdev)
ret = ipc_create_pmc_devices();
if (ret) {
dev_err(&pdev->dev, "Failed to create pmc devices\n");
-   goto err_device;
+   return ret;
}
 
-   if (request_irq(ipcdev.irq, ioc, IRQF_NO_SUSPEND,
-   "intel_pmc_ipc", &ipcdev)) {
+   if (devm_request_irq(&pdev->dev, ipcdev.irq, ioc, IRQF_NO_SUSPEND,
+"intel_pmc_ipc", &ipcdev)) {
dev_err(&pdev->dev, "Failed to request irq\n");
ret = -EBUSY;
-   goto err_irq;
+   goto unregister_devices;
}
 
ret = sysfs_create_group(&pdev->dev.kobj, &intel_ipc_group);
if (ret) {
dev_err(&pdev->dev, "Failed to create sysfs group %d\n",
ret);
-   goto err_sys;
+   goto unregister_de

Re: [PATCH] ACPICA: Check whether ACPI is disabled before getting a table

2017-09-02 Thread kbuild test robot
Hi Borislav,

[auto build test ERROR on pm/linux-next]
[also build test ERROR on v4.13-rc7 next-20170901]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Borislav-Petkov/ACPICA-Check-whether-ACPI-is-disabled-before-getting-a-table/20170823-041359
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 
linux-next
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm64 

All errors (new ones prefixed by >>):

   drivers/acpi/acpica/tbxface.c: In function 'acpi_get_table_header':
>> drivers/acpi/acpica/tbxface.c:254:6: error: 'acpi_disabled' undeclared 
>> (first use in this function)
 if (acpi_disabled)
 ^
   drivers/acpi/acpica/tbxface.c:254:6: note: each undeclared identifier is 
reported only once for each function it appears in

vim +/acpi_disabled +254 drivers/acpi/acpica/tbxface.c

   229  
   230  
/***
   231   *
   232   * FUNCTION:acpi_get_table_header
   233   *
   234   * PARAMETERS:  signature   - ACPI signature of needed table
   235   *  instance- Which instance (for SSDTs)
   236   *  out_table_header- The pointer to the table header 
to fill
   237   *
   238   * RETURN:  Status and pointer to mapped table header
   239   *
   240   * DESCRIPTION: Finds an ACPI table header.
   241   *
   242   * NOTE:Caller is responsible in unmapping the header with
   243   *  acpi_os_unmap_memory
   244   *
   245   
**/
   246  acpi_status
   247  acpi_get_table_header(char *signature,
   248u32 instance, struct acpi_table_header 
*out_table_header)
   249  {
   250  u32 i;
   251  u32 j;
   252  struct acpi_table_header *header;
   253  
 > 254  if (acpi_disabled)
   255  return (AE_ERROR);
   256  
   257  /* Parameter validation */
   258  
   259  if (!signature || !out_table_header) {
   260  return (AE_BAD_PARAMETER);
   261  }
   262  
   263  /* Walk the root table list */
   264  
   265  for (i = 0, j = 0; i < 
acpi_gbl_root_table_list.current_table_count;
   266   i++) {
   267  if (!ACPI_COMPARE_NAME
   268  (&(acpi_gbl_root_table_list.tables[i].signature),
   269   signature)) {
   270  continue;
   271  }
   272  
   273  if (++j < instance) {
   274  continue;
   275  }
   276  
   277  if (!acpi_gbl_root_table_list.tables[i].pointer) {
   278  if ((acpi_gbl_root_table_list.tables[i].flags &
   279   ACPI_TABLE_ORIGIN_MASK) ==
   280  ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL) {
   281  header =
   282  
acpi_os_map_memory(acpi_gbl_root_table_list.
   283 
tables[i].address,
   284 sizeof(struct
   285
acpi_table_header));
   286  if (!header) {
   287  return (AE_NO_MEMORY);
   288  }
   289  
   290  memcpy(out_table_header, header,
   291 sizeof(struct 
acpi_table_header));
   292  acpi_os_unmap_memory(header,
   293   sizeof(struct
   294  
acpi_table_header));
   295  } else {
   296  return (AE_NOT_FOUND);
   297  }
   298  } else {
   299  memcpy(out_table_header,
   300 
acpi_gbl_root_table_list.tables[i].pointer,
   301 sizeof(struct acpi_table_header));
   302  }
   303  return (AE_OK);
   304  }
   305  
   306  return (AE_NOT_FOUND);
   307  }
   308  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/k

[PATCH] kernel: Emphasize the return value of READ_ONCE() is honored

2017-09-02 Thread Boqun Feng
READ_ONCE() is used around in kernel to provide a control dependency,
and to make the control dependency valid, we must 1) make the load of
READ_ONCE() actually happen and 2) make sure compilers take the return
value of READ_ONCE() serious. 1) is already done and commented,
and in current implementation, 2) is also considered done in the
same way as 1): a 'volatile' load.

Whereas, during a recent discussion brought up by Akira Yokosawa on
memory-barriers.txt:

https://marc.info/?l=linux-kernel&m=150052964519882&w=2

, a problem is discovered, which would be triggered if 2) is not
achieved. Moreover, according to Paul Mckenney, using volatile might not
actually give us what we want for 2) depending on compiler writers'
definition of 'volatile'. Therefore it's necessary to emphasize 2) as a
part of the semantics of READ_ONCE(), this not only fits the conceptual
semantics we have been using, but also makes the implementation
requirement more accurate.

In the future, we can either make compiler writers accept our use of
'volatile', or(if that fails) find another way to provide this
guarantee.

Cc: Akira Yokosawa 
Cc: Paul E. McKenney 
Signed-off-by: Boqun Feng 
---
 include/linux/compiler.h | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index eca8ad75e28b..b386dbf8c65c 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -305,6 +305,32 @@ static __always_inline void __write_once_size(volatile 
void *p, void *res, int s
  * mutilate accesses that either do not require ordering or that interact
  * with an explicit memory barrier or atomic instruction that provides the
  * required ordering.
+ *
+ * The return value of READ_ONCE() should be honored by compilers, IOW,
+ * compilers must treat the return value of READ_ONCE() as an unknown value at
+ * compile time, i.e. no optimization should be done based on the value of a
+ * READ_ONCE(). For example, the following code snippet:
+ *
+ * int a = 0;
+ * int x = 0;
+ *
+ * void some_func() {
+ * int t = READ_ONCE(a);
+ * if (!t)
+ * WRITE_ONCE(x, 1);
+ * }
+ *
+ * , should never be optimized as:
+ *
+ * void some_func() {
+ * int t = READ_ONCE(a);
+ * WRITE_ONCE(x, 1);
+ * }
+ *
+ * because the compiler is 'smart' enough to think the value of 'a' is never
+ * changed.
+ *
+ * We provide this guarantee by making READ_ONCE() a *volatile* load.
  */
 
 #define __READ_ONCE(x, check)  \
-- 
2.14.1



[PATCH 1/2] ARM: dts: omap3-evm-37xx: Add common processor module support

2017-09-02 Thread Derald D. Woods
This commit moves common OMAP3-EVM processor module device tree data
to a separate include file. This will allow for 'omap3-evm.dts' to use
device tree data that is unique to the OMAP3530 version of the
processor module, while making use of the work already done for the
'omap3-evm-37xx.dts'.
---
 arch/arm/boot/dts/omap3-evm-37xx.dts  | 209 +
 arch/arm/boot/dts/omap3-evm-processor-common.dtsi | 214 ++
 2 files changed, 215 insertions(+), 208 deletions(-)
 create mode 100644 arch/arm/boot/dts/omap3-evm-processor-common.dtsi

diff --git a/arch/arm/boot/dts/omap3-evm-37xx.dts 
b/arch/arm/boot/dts/omap3-evm-37xx.dts
index c963b31ec3b3..5a4ba0aea447 100644
--- a/arch/arm/boot/dts/omap3-evm-37xx.dts
+++ b/arch/arm/boot/dts/omap3-evm-37xx.dts
@@ -9,146 +9,11 @@
 
 #include "omap36xx.dtsi"
 #include "omap3-evm-common.dtsi"
-
+#include "omap3-evm-processor-common.dtsi"
 
 / {
model = "TI OMAP37XX EVM (TMDSEVM3730)";
compatible = "ti,omap3-evm-37xx", "ti,omap3630", "ti,omap3";
-
-   memory@8000 {
-   device_type = "memory";
-   reg = <0x8000 0x1000>; /* 256 MB */
-   };
-
-   wl12xx_vmmc: wl12xx_vmmc {
-   pinctrl-names = "default";
-   pinctrl-0 = <&wl12xx_gpio>;
-   };
-};
-
-&dss {
-   pinctrl-names = "default";
-   pinctrl-0 = <
-   &dss_dpi_pins1
-   &dss_dpi_pins2
-   >;
-};
-
-&hsusb2_phy {
-   pinctrl-names = "default";
-   pinctrl-0 = <&ehci_phy_pins>;
-};
-
-&omap3_pmx_core {
-   pinctrl-names = "default";
-   pinctrl-0 = <&on_board_gpio_61 &hsusb2_pins>;
-
-   dss_dpi_pins1: pinmux_dss_dpi_pins2 {
-   pinctrl-single,pins = <
-   OMAP3_CORE1_IOPAD(0x20d4, PIN_OUTPUT | MUX_MODE0)   /* 
dss_pclk.dss_pclk */
-   OMAP3_CORE1_IOPAD(0x20d6, PIN_OUTPUT | MUX_MODE0)   /* 
dss_hsync.dss_hsync */
-   OMAP3_CORE1_IOPAD(0x20d8, PIN_OUTPUT | MUX_MODE0)   /* 
dss_vsync.dss_vsync */
-   OMAP3_CORE1_IOPAD(0x20da, PIN_OUTPUT | MUX_MODE0)   /* 
dss_acbias.dss_acbias */
-
-   OMAP3_CORE1_IOPAD(0x20e8, PIN_OUTPUT | MUX_MODE0)   /* 
dss_data6.dss_data6 */
-   OMAP3_CORE1_IOPAD(0x20ea, PIN_OUTPUT | MUX_MODE0)   /* 
dss_data7.dss_data7 */
-   OMAP3_CORE1_IOPAD(0x20ec, PIN_OUTPUT | MUX_MODE0)   /* 
dss_data8.dss_data8 */
-   OMAP3_CORE1_IOPAD(0x20ee, PIN_OUTPUT | MUX_MODE0)   /* 
dss_data9.dss_data9 */
-   OMAP3_CORE1_IOPAD(0x20f0, PIN_OUTPUT | MUX_MODE0)   /* 
dss_data10.dss_data10 */
-   OMAP3_CORE1_IOPAD(0x20f2, PIN_OUTPUT | MUX_MODE0)   /* 
dss_data11.dss_data11 */
-   OMAP3_CORE1_IOPAD(0x20f4, PIN_OUTPUT | MUX_MODE0)   /* 
dss_data12.dss_data12 */
-   OMAP3_CORE1_IOPAD(0x20f6, PIN_OUTPUT | MUX_MODE0)   /* 
dss_data13.dss_data13 */
-   OMAP3_CORE1_IOPAD(0x20f8, PIN_OUTPUT | MUX_MODE0)   /* 
dss_data14.dss_data14 */
-   OMAP3_CORE1_IOPAD(0x20fa, PIN_OUTPUT | MUX_MODE0)   /* 
dss_data15.dss_data15 */
-   OMAP3_CORE1_IOPAD(0x20fc, PIN_OUTPUT | MUX_MODE0)   /* 
dss_data16.dss_data16 */
-   OMAP3_CORE1_IOPAD(0x20fe, PIN_OUTPUT | MUX_MODE0)   /* 
dss_data17.dss_data17 */
-
-   OMAP3_CORE1_IOPAD(0x2100, PIN_OUTPUT | MUX_MODE3)   /* 
dss_data18.dss_data0 */
-   OMAP3_CORE1_IOPAD(0x2102, PIN_OUTPUT | MUX_MODE3)   /* 
dss_data19.dss_data1 */
-   OMAP3_CORE1_IOPAD(0x2104, PIN_OUTPUT | MUX_MODE3)   /* 
dss_data20.dss_data2 */
-   OMAP3_CORE1_IOPAD(0x2106, PIN_OUTPUT | MUX_MODE3)   /* 
dss_data21.dss_data3 */
-   OMAP3_CORE1_IOPAD(0x2108, PIN_OUTPUT | MUX_MODE3)   /* 
dss_data22.dss_data4 */
-   OMAP3_CORE1_IOPAD(0x210a, PIN_OUTPUT | MUX_MODE3)   /* 
dss_data23.dss_data5 */
-   >;
-   };
-
-   mmc1_pins: pinmux_mmc1_pins {
-   pinctrl-single,pins = <
-   OMAP3_CORE1_IOPAD(0x2144, PIN_OUTPUT_PULLUP | 
MUX_MODE0)/* sdmmc1_clk.sdmmc1_clk */
-   OMAP3_CORE1_IOPAD(0x2146, PIN_INPUT_PULLUP | MUX_MODE0) 
/* sdmmc1_cmd.sdmmc1_cmd */
-   OMAP3_CORE1_IOPAD(0x2148, PIN_INPUT_PULLUP | MUX_MODE0) 
/* sdmmc1_dat0.sdmmc1_dat0 */
-   OMAP3_CORE1_IOPAD(0x214a, PIN_INPUT_PULLUP | MUX_MODE0) 
/* sdmmc1_dat1.sdmmc1_dat1 */
-   OMAP3_CORE1_IOPAD(0x214c, PIN_INPUT_PULLUP | MUX_MODE0) 
/* sdmmc1_dat2.sdmmc1_dat2 */
-   OMAP3_CORE1_IOPAD(0x214e, PIN_INPUT_PULLUP | MUX_MODE0) 
/* sdmmc1_dat3.sdmmc1_dat3 */
-   OMAP3_CORE1_IOPAD(0x2150, PIN_INPUT_PULLUP | MUX_MODE0) 
/* sdmmc1_dat4.sdmmc1_dat4 */
-

[PATCH 0/2] Update TMDSEVM3530 support for omap3-evm

2017-09-02 Thread Derald D. Woods
This patch set allows TMDSEVM3530(omap3-evm.dts) to boot using common
processor module data that is shared with 'omap3-evm-37xx.dts'. A new
common file for processor module data is introduced to help facilitate
the updated OMAP3530 support.

Derald D. Woods (2):
  ARM: dts: omap3-evm-37xx: Add common processor module support
  ARM: dts: omap3-evm: Add OMAP3530 specific device tree processor data

 arch/arm/boot/dts/omap3-evm-37xx.dts  | 209 +
 arch/arm/boot/dts/omap3-evm-processor-common.dtsi | 214 ++
 arch/arm/boot/dts/omap3-evm.dts   |  76 +++-
 3 files changed, 287 insertions(+), 212 deletions(-)
 create mode 100644 arch/arm/boot/dts/omap3-evm-processor-common.dtsi

-- 
2.14.1



[PATCH 2/2] ARM: dts: omap3-evm: Add OMAP3530 specific device tree processor data

2017-09-02 Thread Derald D. Woods
This commit allows OMAP3530 variants to use common data that is
available in 'omap3-evm-processor-common.dtsi'. It adds proper pinmux
macros for 'omap3_pmx_core2' on OMAP3430. The Micron NAND chip is also
added for the TMDSEVM3530 processor module.
---
 arch/arm/boot/dts/omap3-evm.dts | 76 ++---
 1 file changed, 72 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/omap3-evm.dts b/arch/arm/boot/dts/omap3-evm.dts
index 99b2bfcd1059..21a3b88aef0c 100644
--- a/arch/arm/boot/dts/omap3-evm.dts
+++ b/arch/arm/boot/dts/omap3-evm.dts
@@ -9,13 +9,81 @@
 
 #include "omap34xx.dtsi"
 #include "omap3-evm-common.dtsi"
+#include "omap3-evm-processor-common.dtsi"
 
 / {
model = "TI OMAP35XX EVM (TMDSEVM3530)";
-   compatible = "ti,omap3-evm", "ti,omap3";
+   compatible = "ti,omap3-evm", "ti,omap3430", "ti,omap3";
+};
+
+&omap3_pmx_core2 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&hsusb2_2_pins>;
+
+   ehci_phy_pins: pinmux_ehci_phy_pins {
+   pinctrl-single,pins = <
+
+   /* EHCI PHY reset GPIO etk_d7.gpio_21 */
+   OMAP3430_CORE2_IOPAD(0x25ea, PIN_OUTPUT | MUX_MODE4)
+
+   /* EHCI VBUS etk_d8.gpio_22 */
+   OMAP3430_CORE2_IOPAD(0x25ec, PIN_OUTPUT | MUX_MODE4)
+   >;
+   };
+
+   /* Used by OHCI and EHCI. OHCI won't work without external phy */
+   hsusb2_2_pins: pinmux_hsusb2_2_pins {
+   pinctrl-single,pins = <
+
+   /* etk_d10.hsusb2_clk */
+   OMAP3430_CORE2_IOPAD(0x25f0, PIN_OUTPUT | MUX_MODE3)
+
+   /* etk_d11.hsusb2_stp */
+   OMAP3430_CORE2_IOPAD(0x25f2, PIN_OUTPUT | MUX_MODE3)
+
+   /* etk_d12.hsusb2_dir */
+   OMAP3430_CORE2_IOPAD(0x25f4, PIN_INPUT_PULLDOWN | MUX_MODE3)
+
+   /* etk_d13.hsusb2_nxt */
+   OMAP3430_CORE2_IOPAD(0x25f6, PIN_INPUT_PULLDOWN | MUX_MODE3)
+
+   /* etk_d14.hsusb2_data0 */
+   OMAP3430_CORE2_IOPAD(0x25f8, PIN_INPUT_PULLDOWN | MUX_MODE3)
+
+   /* etk_d15.hsusb2_data1 */
+   OMAP3430_CORE2_IOPAD(0x25fa, PIN_INPUT_PULLDOWN | MUX_MODE3)
+   >;
+   };
+};
+
+&gpmc {
+   nand@0,0 {
+   compatible = "ti,omap2-nand";
+   reg = <0 0 4>; /* CS0, offset 0, IO size 4 */
+   interrupt-parent = <&gpmc>;
+   interrupts = <0 IRQ_TYPE_NONE>, /* fifoevent */
+<1 IRQ_TYPE_NONE>; /* termcount */
+   linux,mtd-name= "micron,mt29f2g16abdhc";
+   nand-bus-width = <16>;
+   gpmc,device-width = <2>;
+   ti,nand-ecc-opt = "bch8";
+
+   gpmc,sync-clk-ps = <0>;
+   gpmc,cs-on-ns = <0>;
+   gpmc,cs-rd-off-ns = <44>;
+   gpmc,cs-wr-off-ns = <44>;
+   gpmc,adv-on-ns = <6>;
+   gpmc,adv-rd-off-ns = <34>;
+   gpmc,adv-wr-off-ns = <44>;
+   gpmc,we-off-ns = <40>;
+   gpmc,oe-off-ns = <54>;
+   gpmc,access-ns = <64>;
+   gpmc,rd-cycle-ns = <82>;
+   gpmc,wr-cycle-ns = <82>;
+   gpmc,wr-access-ns = <40>;
+   gpmc,wr-data-mux-bus-ns = <0>;
 
-   memory@8000 {
-   device_type = "memory";
-   reg = <0x8000 0x1000>; /* 256 MB */
+   #address-cells = <1>;
+   #size-cells = <1>;
};
 };
-- 
2.14.1



[PATCH] workqueue: Fix flag collision

2017-09-02 Thread Ben Hutchings
Commit 0a94efb5acbb ("workqueue: implicit ordered attribute should be
overridable") introduced a __WQ_ORDERED_EXPLICIT flag but gave it the
same value as __WQ_LEGACY.  I don't believe these were intended to
mean the same thing, so renumber __WQ_ORDERED_EXPLICIT.

Fixes: 0a94efb5acbb ("workqueue: implicit ordered attribute should be ...")
Signed-off-by: Ben Hutchings 
Cc: sta...@vger.kernel.org
---
 include/linux/workqueue.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index db6dc9dc0482..1c49431f3121 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -323,8 +323,8 @@ enum {
 
__WQ_DRAINING   = 1 << 16, /* internal: workqueue is draining */
__WQ_ORDERED= 1 << 17, /* internal: workqueue is ordered */
-   __WQ_ORDERED_EXPLICIT   = 1 << 18, /* internal: 
alloc_ordered_workqueue() */
__WQ_LEGACY = 1 << 18, /* internal: create*_workqueue() */
+   __WQ_ORDERED_EXPLICIT   = 1 << 19, /* internal: 
alloc_ordered_workqueue() */
 
WQ_MAX_ACTIVE   = 512,/* I like 512, better ideas? */
WQ_MAX_UNBOUND_PER_CPU  = 4,  /* 4 * #cpus for unbound wq */


signature.asc
Description: Digital signature


Re: [PATCH 0/3] Add missing types to checkpatch.pl --list-types

2017-09-02 Thread Joe Perches
On Sat, 2017-09-02 at 23:03 +0200, Jean Delvare wrote:
> Oh, btw, is there any purpose in listing a number in front of each
> type?

Not really.  I did that because I wanted a header
and because I had no idea how many of those types
existed and I was too lazy to count.

> It makes it look like one can pass that number instead of the
> type name, however it doesn't work, and I don't think it should as the
> numbering isn't stable and could change with any update of the script.

True.

> Can't we simplify the output and simply print the list of type names?

  If you want.


Re: [I2C] About warning 'DMA-API: device driver maps memory from stack'

2017-09-02 Thread Wolfram Sang
Hi,

nice to see someone else interested in the I2C & DMA topic.

Please check this series which I sent out recently:

"[RFC PATCH v4 0/6] i2c: document DMA handling and add helpers for it"

In that series, I proposed...

> 3. kmalloc data buffer instead of local variables buf in function
> i2c_smbus_xfer_emulated(...)

... this solution. Although I have to check Mauro's general response to
the series first. I'd be interested in what you think of the series,
too.

Kind regards,

   Wolfram



signature.asc
Description: PGP signature


Re: [PATCH 0/3] Add missing types to checkpatch.pl --list-types

2017-09-02 Thread Jean Delvare
Oh, btw, is there any purpose in listing a number in front of each
type? It makes it look like one can pass that number instead of the
type name, however it doesn't work, and I don't think it should as the
numbering isn't stable and could change with any update of the script.

Can't we simplify the output and simply print the list of type names?

Thanks,
-- 
Jean Delvare
SUSE L3 Support


[PATCH 7/7] [media] Mantis: Delete an unnecessary variable initialisation in mantis_pci_probe()

2017-09-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 2 Sep 2017 22:05:22 +0200

The variable "err" will eventually be set to an appropriate value
a bit later. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring 
---
 drivers/media/pci/mantis/mantis_cards.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/mantis/mantis_cards.c 
b/drivers/media/pci/mantis/mantis_cards.c
index 6182ae44dd23..33dd99da0ed8 100644
--- a/drivers/media/pci/mantis/mantis_cards.c
+++ b/drivers/media/pci/mantis/mantis_cards.c
@@ -171,6 +171,6 @@ static int mantis_pci_probe(struct pci_dev *pdev,
struct mantis_pci_drvdata *drvdata;
struct mantis_pci *mantis;
struct mantis_hwconfig *config;
-   int err = 0;
+   int err;
 
mantis = kzalloc(sizeof(*mantis), GFP_KERNEL);
-- 
2.14.1



[PATCH 6/7] [media] Mantis: Improve a size determination in mantis_pci_probe()

2017-09-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 2 Sep 2017 21:56:07 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/pci/mantis/mantis_cards.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/mantis/mantis_cards.c 
b/drivers/media/pci/mantis/mantis_cards.c
index 56a01f6f84c7..6182ae44dd23 100644
--- a/drivers/media/pci/mantis/mantis_cards.c
+++ b/drivers/media/pci/mantis/mantis_cards.c
@@ -173,5 +173,5 @@ static int mantis_pci_probe(struct pci_dev *pdev,
struct mantis_hwconfig *config;
int err = 0;
 
-   mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL);
+   mantis = kzalloc(sizeof(*mantis), GFP_KERNEL);
if (!mantis)
-- 
2.14.1



[PATCH 5/7] [media] Mantis: Delete an error message for a failed memory allocation in mantis_pci_probe()

2017-09-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 2 Sep 2017 21:55:05 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/pci/mantis/mantis_cards.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/pci/mantis/mantis_cards.c 
b/drivers/media/pci/mantis/mantis_cards.c
index cdefffc16d9e..56a01f6f84c7 100644
--- a/drivers/media/pci/mantis/mantis_cards.c
+++ b/drivers/media/pci/mantis/mantis_cards.c
@@ -177,7 +177,5 @@ static int mantis_pci_probe(struct pci_dev *pdev,
-   if (mantis == NULL) {
-   printk(KERN_ERR "%s ERROR: Out of memory\n", __func__);
+   if (!mantis)
return -ENOMEM;
-   }
 
drvdata = (void *)pci_id->driver_data;
mantis->num = devs;
-- 
2.14.1



[PATCH 4/7] [media] Hopper: Delete an unnecessary variable initialisation in hopper_pci_probe()

2017-09-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 2 Sep 2017 21:50:55 +0200

The variable "err" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring 
---
 drivers/media/pci/mantis/hopper_cards.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/mantis/hopper_cards.c 
b/drivers/media/pci/mantis/hopper_cards.c
index 88e5b2a97005..3826be19c156 100644
--- a/drivers/media/pci/mantis/hopper_cards.c
+++ b/drivers/media/pci/mantis/hopper_cards.c
@@ -161,6 +161,6 @@ static int hopper_pci_probe(struct pci_dev *pdev,
struct mantis_pci_drvdata *drvdata;
struct mantis_pci *mantis;
struct mantis_hwconfig *config;
-   int err = 0;
+   int err;
 
mantis = kzalloc(sizeof(*mantis), GFP_KERNEL);
-- 
2.14.1



[PATCH 3/7] [media] Hopper: Adjust a null pointer check in two functions

2017-09-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 2 Sep 2017 21:25:50 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/media/pci/mantis/hopper_cards.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/mantis/hopper_cards.c 
b/drivers/media/pci/mantis/hopper_cards.c
index fe7b40c306f7..88e5b2a97005 100644
--- a/drivers/media/pci/mantis/hopper_cards.c
+++ b/drivers/media/pci/mantis/hopper_cards.c
@@ -72,7 +72,7 @@ static irqreturn_t hopper_irq_handler(int irq, void *dev_id)
struct mantis_ca *ca;
 
mantis = (struct mantis_pci *) dev_id;
-   if (unlikely(mantis == NULL)) {
+   if (unlikely(!mantis)) {
dprintk(MANTIS_ERROR, 1, "Mantis == NULL");
return IRQ_NONE;
}
@@ -164,7 +164,7 @@ static int hopper_pci_probe(struct pci_dev *pdev,
int err = 0;
 
mantis = kzalloc(sizeof(*mantis), GFP_KERNEL);
-   if (mantis == NULL) {
+   if (!mantis) {
err = -ENOMEM;
goto fail0;
}
-- 
2.14.1



[PATCH 2/7] [media] Hopper: Improve a size determination in hopper_pci_probe()

2017-09-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 2 Sep 2017 21:21:22 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/pci/mantis/hopper_cards.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/mantis/hopper_cards.c 
b/drivers/media/pci/mantis/hopper_cards.c
index cc1bb04d8cb4..fe7b40c306f7 100644
--- a/drivers/media/pci/mantis/hopper_cards.c
+++ b/drivers/media/pci/mantis/hopper_cards.c
@@ -163,7 +163,7 @@ static int hopper_pci_probe(struct pci_dev *pdev,
struct mantis_hwconfig *config;
int err = 0;
 
-   mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL);
+   mantis = kzalloc(sizeof(*mantis), GFP_KERNEL);
if (mantis == NULL) {
err = -ENOMEM;
goto fail0;
-- 
2.14.1



[PATCH 1/7] [media] Hopper: Delete an error message for a failed memory allocation in hopper_pci_probe()

2017-09-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 2 Sep 2017 21:19:05 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/pci/mantis/hopper_cards.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/pci/mantis/hopper_cards.c 
b/drivers/media/pci/mantis/hopper_cards.c
index 68b5800030b7..cc1bb04d8cb4 100644
--- a/drivers/media/pci/mantis/hopper_cards.c
+++ b/drivers/media/pci/mantis/hopper_cards.c
@@ -168,4 +168,3 @@ static int hopper_pci_probe(struct pci_dev *pdev,
-   printk(KERN_ERR "%s ERROR: Out of memory\n", __func__);
err = -ENOMEM;
goto fail0;
}
-- 
2.14.1



[PATCH 0/7] [media] Mantis: Adjustments for three function implementations

2017-09-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 2 Sep 2017 22:18:22 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (7):
  Delete an error message for a failed memory allocation in hopper_pci_probe()
  Improve a size determination in hopper_pci_probe()
  Adjust a null pointer check in two functions
  Delete an unnecessary variable initialisation in hopper_pci_probe()
  Delete an error message for a failed memory allocation in mantis_pci_probe()
  Improve a size determination in mantis_pci_probe()
  Delete an unnecessary variable initialisation in mantis_pci_probe()

 drivers/media/pci/mantis/hopper_cards.c | 9 -
 drivers/media/pci/mantis/mantis_cards.c | 8 +++-
 2 files changed, 7 insertions(+), 10 deletions(-)

-- 
2.14.1



[PATCH] serial: sccnxp: Fix error handling in sccnxp_probe()

2017-09-02 Thread Alexey Khoroshilov
sccnxp_probe() returns result of regulator_disable() that may lead
to returning zero, while device is not properly initialized.
Also the driver enables clocks, but it does not disable it.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov 
---
 drivers/tty/serial/sccnxp.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c
index cdd2f942317c..b9c7a904c1ea 100644
--- a/drivers/tty/serial/sccnxp.c
+++ b/drivers/tty/serial/sccnxp.c
@@ -889,7 +889,16 @@ static int sccnxp_probe(struct platform_device *pdev)
goto err_out;
uartclk = 0;
} else {
-   clk_prepare_enable(clk);
+   ret = clk_prepare_enable(clk);
+   if (ret)
+   goto err_out;
+
+   ret = devm_add_action_or_reset(&pdev->dev,
+   (void(*)(void *))clk_disable_unprepare,
+   clk);
+   if (ret)
+   goto err_out;
+
uartclk = clk_get_rate(clk);
}
 
@@ -988,7 +997,7 @@ static int sccnxp_probe(struct platform_device *pdev)
uart_unregister_driver(&s->uart);
 err_out:
if (!IS_ERR(s->regulator))
-   return regulator_disable(s->regulator);
+   regulator_disable(s->regulator);
 
return ret;
 }
-- 
2.7.4



[PATCH v2 2/2] locking/refcounts, x86/asm: Enable CONFIG_ARCH_HAS_REFCOUNT

2017-09-02 Thread Kees Cook
With the section inlining bug fixed for the x86 refcount protection,
we can turn the config back on.

Cc: Mike Galbraith 
Signed-off-by: Kees Cook 
---
 arch/x86/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index eaa8ff41f424..c6acdcdb3fc6 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -56,7 +56,7 @@ config X86
select ARCH_HAS_MMIO_FLUSH
select ARCH_HAS_PMEM_APIif X86_64
# Causing hangs/crashes, see the commit that added this change for 
details.
-   select ARCH_HAS_REFCOUNTif BROKEN
+   select ARCH_HAS_REFCOUNT
select ARCH_HAS_UACCESS_FLUSHCACHE  if X86_64
select ARCH_HAS_SET_MEMORY
select ARCH_HAS_SG_CHAIN
-- 
2.7.4



[PATCH v2 0/2] locking/refcounts, x86/asm: Use unique .text section for refcount exceptions

2017-09-02 Thread Kees Cook
This splits the earlier patch to have the Kconfig enablement separate,
as requested by Ingo.

Thanks!

-Kees



[PATCH v2 1/2] locking/refcounts, x86/asm: Use unique .text section for refcount exceptions

2017-09-02 Thread Kees Cook
Using .text.unlikely for refcount exceptions isn't safe because gcc may
move entire functions into .text.unlikely (e.g. in6_dev_dev()), which
would cause any uses of a protected refcount_t function to stay inline
with the function, triggering the protection unconditionally:

.section.text.unlikely,"ax",@progbits
.type   in6_dev_get, @function
in6_dev_getx:
.LFB4673:
.loc 2 4128 0
.cfi_startproc
...
lock; incl 480(%rbx)
js 111f
.pushsection .text.unlikely
111:lea 480(%rbx), %rcx
112:.byte 0x0f, 0xff
.popsection
113:

This creates a unique .text..refcount section and adds an additional
test to the exception handler to WARN in the case of having none of OF,
SF, nor ZF set so we can see things like this more easily in the future.

The double dot for the section name keeps it out of the TEXT_MAIN macro
namespace (see commit cb87481ee89db ("kbuild: linker script do not match C
names unless LD_DEAD_CODE_DATA_ELIMINATION is configured"), which matches
C names: [a-zA-Z0-9_] but not ".") to avoid collisions and so it can be
put at the end with text.unlikely to keep the cold code together.

Reported-by: Mike Galbraith 
Fixes: 7a46ec0e2f48 ("locking/refcounts, x86/asm: Implement fast refcount 
overflow protection")
Signed-off-by: Kees Cook 
---
This will apply to -tip with fuzz, but since the TEXT_MAIN delta is in -next
and is targeted for stable, it seemed best to diff against -next.
---
 arch/x86/include/asm/refcount.h   | 2 +-
 arch/x86/mm/extable.c | 7 ++-
 include/asm-generic/vmlinux.lds.h | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/refcount.h b/arch/x86/include/asm/refcount.h
index ff871210b9f2..4e44250e7d0d 100644
--- a/arch/x86/include/asm/refcount.h
+++ b/arch/x86/include/asm/refcount.h
@@ -15,7 +15,7 @@
  * back to the regular execution flow in .text.
  */
 #define _REFCOUNT_EXCEPTION\
-   ".pushsection .text.unlikely\n" \
+   ".pushsection .text..refcount\n"\
"111:\tlea %[counter], %%" _ASM_CX "\n" \
"112:\t" ASM_UD0 "\n"   \
ASM_UNREACHABLE \
diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
index c076f710de4c..cf0d74b47ae0 100644
--- a/arch/x86/mm/extable.c
+++ b/arch/x86/mm/extable.c
@@ -66,12 +66,17 @@ bool ex_handler_refcount(const struct exception_table_entry 
*fixup,
 * wrapped around) will be set. Additionally, seeing the refcount
 * reach 0 will set ZF (Zero Flag: result was zero). In each of
 * these cases we want a report, since it's a boundary condition.
-*
+* The SF case is not reported since it indicates post-boundary
+* manipulations below zero or above INT_MAX. And if none of the
+* flags are set, something has gone very wrong, so report it.
 */
if (regs->flags & (X86_EFLAGS_OF | X86_EFLAGS_ZF)) {
bool zero = regs->flags & X86_EFLAGS_ZF;
 
refcount_error_report(regs, zero ? "hit zero" : "overflow");
+   } else if ((regs->flags & X86_EFLAGS_SF) == 0) {
+   /* Report if none of OF, ZF, nor SF are set. */
+   refcount_error_report(regs, "unexpected saturation");
}
 
return true;
diff --git a/include/asm-generic/vmlinux.lds.h 
b/include/asm-generic/vmlinux.lds.h
index 8acfc1e099e1..e549bff87c5b 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -459,6 +459,7 @@
 #define TEXT_TEXT  \
ALIGN_FUNCTION();   \
*(.text.hot TEXT_MAIN .text.fixup .text.unlikely)   \
+   *(.text..refcount)  \
*(.ref.text)\
MEM_KEEP(init.text) \
MEM_KEEP(exit.text) \
-- 
2.7.4



[PATCH v6 03/12] ASoC: add new ac97 bus support

2017-09-02 Thread Robert Jarzmik
Add the new ac97 bus support, with ac97 bus automatic probing.

Signed-off-by: Robert Jarzmik 
Acked-by: Charles Keepax 
---
 sound/Kconfig  | 2 ++
 sound/Makefile | 1 +
 2 files changed, 3 insertions(+)

diff --git a/sound/Kconfig b/sound/Kconfig
index ee2e69a9ecd1..141b145c4195 100644
--- a/sound/Kconfig
+++ b/sound/Kconfig
@@ -80,6 +80,8 @@ source "sound/hda/Kconfig"
 
 source "sound/ppc/Kconfig"
 
+source "sound/ac97/Kconfig"
+
 source "sound/aoa/Kconfig"
 
 source "sound/arm/Kconfig"
diff --git a/sound/Makefile b/sound/Makefile
index 6de45d2c32f7..c03b0bed65d5 100644
--- a/sound/Makefile
+++ b/sound/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_SND_AOA) += aoa/
 
 # This one must be compilable even if sound is configured out
 obj-$(CONFIG_AC97_BUS) += ac97_bus.o
+obj-$(CONFIG_AC97_BUS_NEW) += ac97/
 
 ifeq ($(CONFIG_SND),y)
   obj-y += last.o
-- 
2.11.0



[PATCH v6 02/12] ALSA: ac97: add an ac97 bus

2017-09-02 Thread Robert Jarzmik
AC97 is a bus for sound usage. It enables for a AC97 AC-Link to link one
controller to 0 to 4 AC97 codecs.

The goal of this new implementation is to implement a device/driver
model for AC97, with an automatic scan of the bus and automatic
discovery of AC97 codec devices.

Signed-off-by: Robert Jarzmik 
---
Since RFCv1:
 - Takashi's review
   - changed the codec.h guard ... a better name could be found ...
   - added the AC97_* macros missing parenthesis
   - constantified the id_table in the codec driver structure
   - changed the 4 codecs linked list into an array
   - enabled the ac97 bus to be a module
   - added a slots_available to snd_ac97_controller_register() to have a
 way to prevent scanning and probing of unconnected codecs
   - removed useless ac97 bus index
   - all exported functions begin with snd_ac97_*()
   - change bus operations to controller+slot parameters instead of
 codec device

 - Mark's review
   - changed ac97_digital_controller into ac97_controller
   - rename ac97_digital_controller_*() into ac97_controller_*()
   - add the ac97 ac-link clock to the codec device (ie. the AC'97
 BIT_CLK)

Since RFCv2:
 - more snd_ac97 namespace review
 - change the compat allocation prototype to force the user to provide
   and ac97_codec_device structure pointer

Since v1:
 - took into account all Lars comments

Since v3:
 - took into account Takashi's comments (ac97bus naming and module_exit)

Since v4:
 - took into account Takashi's comments (GPL, mask match on warm reset,
   device_put(), warnings)
---
 include/sound/ac97/codec.h  | 118 +
 include/sound/ac97/compat.h |  20 ++
 include/sound/ac97/controller.h |  85 +++
 sound/ac97/Kconfig  |  19 ++
 sound/ac97/Makefile |   8 +
 sound/ac97/ac97_core.h  |  16 ++
 sound/ac97/bus.c| 539 
 sound/ac97/codec.c  |  15 ++
 sound/ac97/snd_ac97_compat.c| 108 
 9 files changed, 928 insertions(+)
 create mode 100644 include/sound/ac97/codec.h
 create mode 100644 include/sound/ac97/compat.h
 create mode 100644 include/sound/ac97/controller.h
 create mode 100644 sound/ac97/Kconfig
 create mode 100644 sound/ac97/Makefile
 create mode 100644 sound/ac97/ac97_core.h
 create mode 100644 sound/ac97/bus.c
 create mode 100644 sound/ac97/codec.c
 create mode 100644 sound/ac97/snd_ac97_compat.c

diff --git a/include/sound/ac97/codec.h b/include/sound/ac97/codec.h
new file mode 100644
index ..ec04be9ab119
--- /dev/null
+++ b/include/sound/ac97/codec.h
@@ -0,0 +1,118 @@
+/*
+ *  Copyright (C) 2016 Robert Jarzmik 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef __SOUND_AC97_CODEC2_H
+#define __SOUND_AC97_CODEC2_H
+
+#include 
+
+#define AC97_ID(vendor_id1, vendor_id2) \
+   vendor_id1) & 0x) << 16) | ((vendor_id2) & 0x))
+#define AC97_DRIVER_ID(vendor_id1, vendor_id2, mask_id1, mask_id2, _data) \
+   { .id = (((vendor_id1) & 0x) << 16) | ((vendor_id2) & 0x), \
+ .mask = (((mask_id1) & 0x) << 16) | ((mask_id2) & 0x), \
+ .data = (_data) }
+
+struct ac97_controller;
+struct clk;
+
+/**
+ * struct ac97_id - matches a codec device and driver on an ac97 bus
+ * @id: The significant bits if the codec vendor ID1 and ID2
+ * @mask: Bitmask specifying which bits of the id field are significant when
+ *   matching. A driver binds to a device when :
+ *((vendorID1 << 8 | vendorID2) & (mask_id1 << 8 | mask_id2)) == id.
+ * @data: Private data used by the driver.
+ */
+struct ac97_id {
+   unsigned intid;
+   unsigned intmask;
+   void*data;
+};
+
+/**
+ * ac97_codec_device - a ac97 codec
+ * @dev: the core device
+ * @vendor_id: the vendor_id of the codec, as sensed on the AC-link
+ * @num: the codec number, 0 is primary, 1 is first slave, etc ...
+ * @clk: the clock BIT_CLK provided by the codec
+ * @ac97_ctrl: ac97 digital controller on the same AC-link
+ *
+ * This is the device instantiated for each codec living on a AC-link. There 
are
+ * normally 0 to 4 codec devices per AC-link, and all of them are controlled by
+ * an AC97 digital controller.
+ */
+struct ac97_codec_device {
+   struct device   dev;
+   unsigned intvendor_id;
+   unsigned intnum;
+   struct clk  *clk;
+   struct ac97_controller  *ac97_ctrl;
+};
+
+/**
+ * ac97_codec_driver - a ac97 codec driver
+ * @driver: the device driver structure
+ * @probe: the function called when a ac97_codec_device is matched
+ * @remove: the function called when the device is unbound/removed
+ * @shutdown: shutdown function (might be NULL)
+ * @id_table: ac97 vendor_id match table, { } member terminated
+ */
+struct ac97_codec_driver {
+ 

[PATCH v6 00/12] AC97 device/driver model revamp

2017-09-02 Thread Robert Jarzmik
Hi Lars, Mark, Charles, Lee,

This is a revision for Lee, only targetted at wm97xx-core changes suggested by
Lee. I hope I have every concern covered Lee, just le me know if it suits you.

For easier spotting, I included in [1] the diff from the last serie.

I kept Charles ack for patch 6/12 following Lee's review, if you don't agree
Charles, I'll remove it.

Cheers.

--
Robert

Robert Jarzmik (12):
  ALSA: ac97: split out the generic ac97 registers
  ALSA: ac97: add an ac97 bus
  ASoC: add new ac97 bus support
  ASoC: arm: make pxa2xx-ac97-lib ac97 codec agnostic
  Input: wm97xx: split out touchscreen registering
  mfd: wm97xx-core: core support for wm97xx Codec
  Input: wm97xx: add new AC97 bus support
  ASoC: wm9713: add ac97 new bus support
  ASoC: wm9712: add ac97 new bus support
  ASoC: wm9705: add private structure
  ASoC: wm9705: add ac97 new bus support
  ASoC: pxa: switch to new ac97 bus support

 drivers/input/touchscreen/Kconfig   |   2 +-
 drivers/input/touchscreen/wm97xx-core.c | 252 ++-
 drivers/mfd/Kconfig |  14 +
 drivers/mfd/Makefile|   1 +
 drivers/mfd/wm97xx-core.c   | 379 ++
 include/linux/mfd/wm97xx.h  |  25 ++
 include/sound/ac97/codec.h  | 118 +++
 include/sound/ac97/compat.h |  20 ++
 include/sound/ac97/controller.h |  85 +
 include/sound/ac97/regs.h   | 262 
 include/sound/ac97_codec.h  | 239 +-
 include/sound/pxa2xx-lib.h  |  15 +-
 sound/Kconfig   |   2 +
 sound/Makefile  |   1 +
 sound/ac97/Kconfig  |  19 ++
 sound/ac97/Makefile |   8 +
 sound/ac97/ac97_core.h  |  16 +
 sound/ac97/bus.c| 539 
 sound/ac97/codec.c  |  15 +
 sound/ac97/snd_ac97_compat.c| 108 +++
 sound/arm/Kconfig   |   1 -
 sound/arm/pxa2xx-ac97-lib.c |  37 ++-
 sound/arm/pxa2xx-ac97.c |  35 ++-
 sound/soc/codecs/Kconfig|   9 +-
 sound/soc/codecs/wm9705.c   |  61 ++--
 sound/soc/codecs/wm9712.c   |  39 ++-
 sound/soc/codecs/wm9713.c   |  39 ++-
 sound/soc/pxa/Kconfig   |   5 +-
 sound/soc/pxa/pxa2xx-ac97.c |  46 ++-
 29 files changed, 1978 insertions(+), 414 deletions(-)
 create mode 100644 drivers/mfd/wm97xx-core.c
 create mode 100644 include/linux/mfd/wm97xx.h
 create mode 100644 include/sound/ac97/codec.h
 create mode 100644 include/sound/ac97/compat.h
 create mode 100644 include/sound/ac97/controller.h
 create mode 100644 include/sound/ac97/regs.h
 create mode 100644 sound/ac97/Kconfig
 create mode 100644 sound/ac97/Makefile
 create mode 100644 sound/ac97/ac97_core.h
 create mode 100644 sound/ac97/bus.c
 create mode 100644 sound/ac97/codec.c
 create mode 100644 sound/ac97/snd_ac97_compat.c

-- 
2.11.0

[1] Diff from the previous serie
---8>---
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 5ffe4f4dfa10..6d175698a49a 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1635,7 +1635,6 @@ config MFD_WM97xx
select AC97_BUS_COMPAT
depends on AC97_BUS_NEW
help
-
  The WM9705, WM9712 and WM9713 is a highly integrated hi-fi CODEC
  designed for smartphone applications.  As well as audio functionality
  it has on board GPIO and a touchscreen functionality which is
diff --git a/drivers/mfd/wm97xx-core.c b/drivers/mfd/wm97xx-core.c
index 473bbf9510e5..66e477fffd43 100644
--- a/drivers/mfd/wm97xx-core.c
+++ b/drivers/mfd/wm97xx-core.c
@@ -1,7 +1,7 @@
 /*
  * Wolfson WM97xx -- Core device
  *
- * Copyright (C) 2016 Robert Jarzmik
+ * Copyright (C) 2017 Robert Jarzmik
  *
  * 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
@@ -14,14 +14,13 @@
  *  - a GPIO block
  */
 
-#include 
-
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -34,6 +33,7 @@ struct wm97xx_priv {
struct regmap *regmap;
struct snd_ac97 *ac97;
struct device *dev;
+   struct wm97xx_platform_data codec_pdata;
 };
 
 static bool wm97xx_readable_reg(struct device *dev, unsigned int reg)
@@ -108,33 +108,14 @@ static const struct regmap_config wm9705_regmap_config = {
.writeable_reg = wm97xx_writeable_reg,
 };
 
-static int wm9705_register(struct wm97xx_priv *wm97xx,
-  struct wm97xx_pdata *pdata)
-{
-   static struct wm97xx_platform_data codec_pdata;
-   static const struct mfd_cell cells[] = {
-   {
-   .name = "wm9705-codec",
-   .platform_data = &codec_pdata,
-   .pdata_size 

[PATCH v6 01/12] ALSA: ac97: split out the generic ac97 registers

2017-09-02 Thread Robert Jarzmik
Split out from the ac97_codec.h the ac97 generic registers, which can be
used by a codec, typically a generic ac97 codec, and by the ac97 bus, to
scan an ac97 AC-Link.

This split encompasses all the AC97 standard registers, but not the
codec specific ones.

In order to have a clean split between former ac97 bus implementation
and the new coming one in sound/ac97, it is safer to not include any
former ac97 includes, excepting in sound/ac97/compat.c.

Amongst the thing to isolate :
 - don't have the struct snd_ac97 in sound/ac97/* (except compat.c) to not
   be "fooled" by a definition which would come with ac97_codec.h by
   "chance".
 - don't have to have snd_a97_*() functions, as they rely on struct
   snd_ac97.
  - don't want the struct snd_ac97_bus_ops, there is a new one

Signed-off-by: Robert Jarzmik 
---
Since v1: improve commit message to explain better the rationale
Since v2: fixed too long commit line
---
 include/sound/ac97/regs.h  | 262 +
 include/sound/ac97_codec.h | 239 +
 2 files changed, 263 insertions(+), 238 deletions(-)
 create mode 100644 include/sound/ac97/regs.h

diff --git a/include/sound/ac97/regs.h b/include/sound/ac97/regs.h
new file mode 100644
index ..4bb86d379bd5
--- /dev/null
+++ b/include/sound/ac97/regs.h
@@ -0,0 +1,262 @@
+/*
+ *  Copyright (c) by Jaroslav Kysela 
+ *  Universal interface for Audio Codec '97
+ *
+ *  For more details look to AC '97 component specification revision 2.1
+ *  by Intel Corporation (http://developer.intel.com).
+ *
+ *
+ *   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 of the License, 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, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *
+ */
+
+/*
+ *  AC'97 codec registers
+ */
+
+#define AC97_RESET 0x00/* Reset */
+#define AC97_MASTER0x02/* Master Volume */
+#define AC97_HEADPHONE 0x04/* Headphone Volume (optional) */
+#define AC97_MASTER_MONO   0x06/* Master Volume Mono (optional) */
+#define AC97_MASTER_TONE   0x08/* Master Tone (Bass & Treble) 
(optional) */
+#define AC97_PC_BEEP   0x0a/* PC Beep Volume (optinal) */
+#define AC97_PHONE 0x0c/* Phone Volume (optional) */
+#define AC97_MIC   0x0e/* MIC Volume */
+#define AC97_LINE  0x10/* Line In Volume */
+#define AC97_CD0x12/* CD Volume */
+#define AC97_VIDEO 0x14/* Video Volume (optional) */
+#define AC97_AUX   0x16/* AUX Volume (optional) */
+#define AC97_PCM   0x18/* PCM Volume */
+#define AC97_REC_SEL   0x1a/* Record Select */
+#define AC97_REC_GAIN  0x1c/* Record Gain */
+#define AC97_REC_GAIN_MIC  0x1e/* Record Gain MIC (optional) */
+#define AC97_GENERAL_PURPOSE   0x20/* General Purpose (optional) */
+#define AC97_3D_CONTROL0x22/* 3D Control (optional) */
+#define AC97_INT_PAGING0x24/* Audio Interrupt & Paging 
(AC'97 2.3) */
+#define AC97_POWERDOWN 0x26/* Powerdown control / status */
+/* range 0x28-0x3a - AUDIO AC'97 2.0 extensions */
+#define AC97_EXTENDED_ID   0x28/* Extended Audio ID */
+#define AC97_EXTENDED_STATUS   0x2a/* Extended Audio Status and Control */
+#define AC97_PCM_FRONT_DAC_RATE 0x2c   /* PCM Front DAC Rate */
+#define AC97_PCM_SURR_DAC_RATE 0x2e/* PCM Surround DAC Rate */
+#define AC97_PCM_LFE_DAC_RATE  0x30/* PCM LFE DAC Rate */
+#define AC97_PCM_LR_ADC_RATE   0x32/* PCM LR ADC Rate */
+#define AC97_PCM_MIC_ADC_RATE  0x34/* PCM MIC ADC Rate */
+#define AC97_CENTER_LFE_MASTER 0x36/* Center + LFE Master Volume */
+#define AC97_SURROUND_MASTER   0x38/* Surround (Rear) Master Volume */
+#define AC97_SPDIF 0x3a/* S/PDIF control */
+/* range 0x3c-0x58 - MODEM */
+#define AC97_EXTENDED_MID  0x3c/* Extended Modem ID */
+#define AC97_EXTENDED_MSTATUS  0x3e/* Extended Modem Status and Control */
+#define AC97_LINE1_RATE0x40/* Line1 DAC/ADC Rate */
+#define AC97_LINE2_RATE0x42/* Line2 DAC/ADC Rate */
+#define AC97_HANDSET_RATE  0x44/* Handset DAC/ADC Rate */
+#define AC97_LINE1_LEVEL   0x46/* Line1 DAC/ADC Level */
+#define AC97_LINE2_LEVEL   0x48/* Line2 D

[PATCH v6 05/12] Input: wm97xx: split out touchscreen registering

2017-09-02 Thread Robert Jarzmik
wm97xx-core does several things in it initialization :
 - touchscreen input device setup
 - battery device creation

As the wm97xx is actually a multi-function device handling an audio
codec, a touchscreen, a gpio block and an ADC, reshape the probing to
isolate what is truly input/touchscreen specific from the remaining
part.

This is only code shuffling, there is no functional change.

Signed-off-by: Robert Jarzmik 
Acked-by: Dmitry Torokhov 
Acked-by: Charles Keepax 
---
Since v1:
 - took into account Charles's comment
---
 drivers/input/touchscreen/wm97xx-core.c | 196 +++-
 1 file changed, 115 insertions(+), 81 deletions(-)

diff --git a/drivers/input/touchscreen/wm97xx-core.c 
b/drivers/input/touchscreen/wm97xx-core.c
index c9d1c91e1887..39869ffdc4fa 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -581,27 +581,85 @@ static void wm97xx_ts_input_close(struct input_dev *idev)
wm->codec->acc_enable(wm, 0);
 }
 
-static int wm97xx_probe(struct device *dev)
+static int wm97xx_register_touch(struct wm97xx *wm)
 {
-   struct wm97xx *wm;
-   struct wm97xx_pdata *pdata = dev_get_platdata(dev);
-   int ret = 0, id = 0;
+   struct wm97xx_pdata *pdata = dev_get_platdata(wm->dev);
+   int ret;
 
-   wm = kzalloc(sizeof(struct wm97xx), GFP_KERNEL);
-   if (!wm)
+   wm->input_dev = devm_input_allocate_device(wm->dev);
+   if (wm->input_dev == NULL)
return -ENOMEM;
-   mutex_init(&wm->codec_mutex);
 
-   wm->dev = dev;
-   dev_set_drvdata(dev, wm);
-   wm->ac97 = to_ac97_t(dev);
+   /* set up touch configuration */
+   wm->input_dev->name = "wm97xx touchscreen";
+   wm->input_dev->phys = "wm97xx";
+   wm->input_dev->open = wm97xx_ts_input_open;
+   wm->input_dev->close = wm97xx_ts_input_close;
+
+   __set_bit(EV_ABS, wm->input_dev->evbit);
+   __set_bit(EV_KEY, wm->input_dev->evbit);
+   __set_bit(BTN_TOUCH, wm->input_dev->keybit);
+
+   input_set_abs_params(wm->input_dev, ABS_X, abs_x[0], abs_x[1],
+abs_x[2], 0);
+   input_set_abs_params(wm->input_dev, ABS_Y, abs_y[0], abs_y[1],
+abs_y[2], 0);
+   input_set_abs_params(wm->input_dev, ABS_PRESSURE, abs_p[0], abs_p[1],
+abs_p[2], 0);
+
+   input_set_drvdata(wm->input_dev, wm);
+   wm->input_dev->dev.parent = wm->dev;
+
+   ret = input_register_device(wm->input_dev);
+   if (ret)
+   return ret;
+
+   /*
+* register our extended touch device (for machine specific
+* extensions)
+*/
+   wm->touch_dev = platform_device_alloc("wm97xx-touch", -1);
+   if (!wm->touch_dev) {
+   ret = -ENOMEM;
+   goto touch_err;
+   }
+   platform_set_drvdata(wm->touch_dev, wm);
+   wm->touch_dev->dev.parent = wm->dev;
+   wm->touch_dev->dev.platform_data = pdata;
+   ret = platform_device_add(wm->touch_dev);
+   if (ret < 0)
+   goto touch_reg_err;
+
+   return 0;
+touch_reg_err:
+   platform_device_put(wm->touch_dev);
+touch_err:
+   input_unregister_device(wm->input_dev);
+   wm->input_dev = NULL;
+
+   return ret;
+}
+
+static void wm97xx_unregister_touch(struct wm97xx *wm)
+{
+   platform_device_unregister(wm->touch_dev);
+   input_unregister_device(wm->input_dev);
+   wm->input_dev = NULL;
+}
+
+static int _wm97xx_probe(struct wm97xx *wm)
+{
+   int id = 0;
+
+   mutex_init(&wm->codec_mutex);
+   dev_set_drvdata(wm->dev, wm);
 
/* check that we have a supported codec */
id = wm97xx_reg_read(wm, AC97_VENDOR_ID1);
if (id != WM97XX_ID1) {
-   dev_err(dev, "Device with vendor %04x is not a wm97xx\n", id);
-   ret = -ENODEV;
-   goto alloc_err;
+   dev_err(wm->dev,
+   "Device with vendor %04x is not a wm97xx\n", id);
+   return -ENODEV;
}
 
wm->id = wm97xx_reg_read(wm, AC97_VENDOR_ID2);
@@ -629,8 +687,7 @@ static int wm97xx_probe(struct device *dev)
default:
dev_err(wm->dev, "Support for wm97%02x not compiled in.\n",
wm->id & 0xff);
-   ret = -ENODEV;
-   goto alloc_err;
+   return -ENODEV;
}
 
/* set up physical characteristics */
@@ -644,79 +701,58 @@ static int wm97xx_probe(struct device *dev)
wm->gpio[4] = wm97xx_reg_read(wm, AC97_GPIO_STATUS);
wm->gpio[5] = wm97xx_reg_read(wm, AC97_MISC_AFE);
 
-   wm->input_dev = input_allocate_device();
-   if (wm->input_dev == NULL) {
-   ret = -ENOMEM;
-   goto alloc_err;
-   }
-
-   /* set up touch configuration */
-   wm->input_dev->name = "wm97xx touchscreen";
-   wm->input_dev->phys = "wm97xx";
-   wm->input_

[PATCH v6 09/12] ASoC: wm9712: add ac97 new bus support

2017-09-02 Thread Robert Jarzmik
Add support for the new ac97 bus model, where devices are automatically
discovered on AC-Links.

Signed-off-by: Robert Jarzmik 
---
Since v4:
 - added #ifdef spotted by Charles
---
 sound/soc/codecs/Kconfig  |  3 ++-
 sound/soc/codecs/wm9712.c | 39 ++-
 2 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index aebf148d7e4d..f17af3592785 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -206,7 +206,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_WM9081 if I2C
select SND_SOC_WM9090 if I2C
select SND_SOC_WM9705 if SND_SOC_AC97_BUS
-   select SND_SOC_WM9712 if SND_SOC_AC97_BUS
+   select SND_SOC_WM9712 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW)
select SND_SOC_WM9713 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW)
 help
   Normally ASoC codec drivers are only built if a machine driver which
@@ -1087,6 +1087,7 @@ config SND_SOC_WM9705
 config SND_SOC_WM9712
tristate
select REGMAP_AC97
+   select AC97_BUS_COMPAT if AC97_BUS_NEW
 
 config SND_SOC_WM9713
tristate
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c
index 1a3e1797994a..7ebbb48b18c5 100644
--- a/sound/soc/codecs/wm9712.c
+++ b/sound/soc/codecs/wm9712.c
@@ -12,6 +12,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -19,6 +20,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -30,6 +33,7 @@ struct wm9712_priv {
struct snd_ac97 *ac97;
unsigned int hp_mixer[2];
struct mutex lock;
+   struct wm97xx_platform_data *mfd_pdata;
 };
 
 static const struct reg_default wm9712_reg_defaults[] = {
@@ -636,18 +640,25 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec)
struct regmap *regmap;
int ret;
 
-   wm9712->ac97 = snd_soc_new_ac97_codec(codec, WM9712_VENDOR_ID,
-   WM9712_VENDOR_ID_MASK);
-   if (IS_ERR(wm9712->ac97)) {
-   ret = PTR_ERR(wm9712->ac97);
-   dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret);
-   return ret;
-   }
-
-   regmap = regmap_init_ac97(wm9712->ac97, &wm9712_regmap_config);
-   if (IS_ERR(regmap)) {
-   ret = PTR_ERR(regmap);
-   goto err_free_ac97_codec;
+   if (wm9712->mfd_pdata) {
+   wm9712->ac97 = wm9712->mfd_pdata->ac97;
+   regmap = wm9712->mfd_pdata->regmap;
+   } else {
+#ifdef CONFIG_SND_SOC_AC97_BUS
+   wm9712->ac97 = snd_soc_new_ac97_codec(codec, WM9712_VENDOR_ID,
+ WM9712_VENDOR_ID_MASK);
+   if (IS_ERR(wm9712->ac97)) {
+   ret = PTR_ERR(wm9712->ac97);
+   dev_err(codec->dev,
+   "Failed to register AC97 codec: %d\n", ret);
+   return ret;
+   }
+
+   regmap = regmap_init_ac97(wm9712->ac97, &wm9712_regmap_config);
+   if (IS_ERR(regmap)) {
+   ret = PTR_ERR(regmap);
+   goto err_free_ac97_codec;
+#endif
}
 
snd_soc_codec_init_regmap(codec, regmap);
@@ -666,7 +677,8 @@ static int wm9712_soc_remove(struct snd_soc_codec *codec)
struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
 
snd_soc_codec_exit_regmap(codec);
-   snd_soc_free_ac97_codec(wm9712->ac97);
+   if (!wm9712->mfd_pdata)
+   snd_soc_free_ac97_codec(wm9712->ac97);
return 0;
 }
 
@@ -697,6 +709,7 @@ static int wm9712_probe(struct platform_device *pdev)
 
mutex_init(&wm9712->lock);
 
+   wm9712->mfd_pdata = dev_get_platdata(&pdev->dev);
platform_set_drvdata(pdev, wm9712);
 
return snd_soc_register_codec(&pdev->dev,
-- 
2.11.0



[PATCH v6 07/12] Input: wm97xx: add new AC97 bus support

2017-09-02 Thread Robert Jarzmik
This adds support for the new AC97 bus code, which discovers the devices
rather than uses platform data.

As part of this discovery, it enables a multi-function device wm97xx,
which supports touchscreen, battery, ADC and an audio codec. This patch
adds the code to bind the touchscreen "cell" as the touchscreen driver.

This was tested on the pxa architecture with a pxa270 + wm9713 + the
mioa701 touchscreen.

Signed-off-by: Robert Jarzmik 
Acked-by: Charles Keepax 
Acked-by: Dmitry Torokhov 
---
 drivers/input/touchscreen/Kconfig   |  2 +-
 drivers/input/touchscreen/wm97xx-core.c | 56 -
 2 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 033599777651..22257f3e1059 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -725,7 +725,7 @@ config TOUCHSCREEN_WM831X
 
 config TOUCHSCREEN_WM97XX
tristate "Support for WM97xx AC97 touchscreen controllers"
-   depends on AC97_BUS
+   depends on AC97_BUS || AC97_BUS_NEW
help
  Say Y here if you have a Wolfson Microelectronics WM97xx
  touchscreen connected to your system. Note that this option
diff --git a/drivers/input/touchscreen/wm97xx-core.c 
b/drivers/input/touchscreen/wm97xx-core.c
index 39869ffdc4fa..fd714ee881f7 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -766,6 +767,39 @@ static int wm97xx_remove(struct device *dev)
return 0;
 }
 
+static int wm97xx_mfd_probe(struct platform_device *pdev)
+{
+   struct wm97xx *wm;
+   struct wm97xx_platform_data *mfd_pdata = dev_get_platdata(&pdev->dev);
+   int ret;
+
+   wm = devm_kzalloc(&pdev->dev, sizeof(struct wm97xx), GFP_KERNEL);
+   if (!wm)
+   return -ENOMEM;
+
+   wm->dev = &pdev->dev;
+   wm->ac97 = mfd_pdata->ac97;
+
+   ret =  _wm97xx_probe(wm);
+   if (ret)
+   return ret;
+
+   ret = wm97xx_add_battery(wm, mfd_pdata->batt_pdata);
+   if (ret < 0)
+   goto batt_err;
+
+   return ret;
+
+batt_err:
+   wm97xx_unregister_touch(wm);
+   return ret;
+}
+
+static int wm97xx_mfd_remove(struct platform_device *pdev)
+{
+   return wm97xx_remove(&pdev->dev);
+}
+
 static int __maybe_unused wm97xx_suspend(struct device *dev)
 {
struct wm97xx *wm = dev_get_drvdata(dev);
@@ -862,21 +896,41 @@ EXPORT_SYMBOL_GPL(wm97xx_unregister_mach_ops);
 
 static struct device_driver wm97xx_driver = {
.name = "wm97xx-ts",
+#ifdef CONFIG_AC97_BUS
.bus =  &ac97_bus_type,
+#endif
.owner =THIS_MODULE,
.probe =wm97xx_probe,
.remove =   wm97xx_remove,
.pm =   &wm97xx_pm_ops,
 };
 
+static struct platform_driver wm97xx_mfd_driver = {
+   .driver = {
+   .name = "wm97xx-ts",
+   .pm =   &wm97xx_pm_ops,
+   },
+   .probe =wm97xx_mfd_probe,
+   .remove =   wm97xx_mfd_remove,
+};
+
 static int __init wm97xx_init(void)
 {
-   return driver_register(&wm97xx_driver);
+   int ret;
+
+   ret = platform_driver_register(&wm97xx_mfd_driver);
+   if (ret)
+   return ret;
+
+   if (IS_BUILTIN(CONFIG_AC97_BUS))
+   ret =  driver_register(&wm97xx_driver);
+   return ret;
 }
 
 static void __exit wm97xx_exit(void)
 {
driver_unregister(&wm97xx_driver);
+   platform_driver_unregister(&wm97xx_mfd_driver);
 }
 
 module_init(wm97xx_init);
-- 
2.11.0



[PATCH v6 08/12] ASoC: wm9713: add ac97 new bus support

2017-09-02 Thread Robert Jarzmik
Add support for the new ac97 bus model, where devices are automatically
discovered on AC-Links.

Signed-off-by: Robert Jarzmik 
Acked-by: Charles Keepax 
---
 sound/soc/codecs/Kconfig  |  3 ++-
 sound/soc/codecs/wm9713.c | 39 +++
 2 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index e49e9da7f1f6..aebf148d7e4d 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -207,7 +207,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_WM9090 if I2C
select SND_SOC_WM9705 if SND_SOC_AC97_BUS
select SND_SOC_WM9712 if SND_SOC_AC97_BUS
-   select SND_SOC_WM9713 if SND_SOC_AC97_BUS
+   select SND_SOC_WM9713 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW)
 help
   Normally ASoC codec drivers are only built if a machine driver which
   uses them is also built since they are only usable with a machine
@@ -1091,6 +1091,7 @@ config SND_SOC_WM9712
 config SND_SOC_WM9713
tristate
select REGMAP_AC97
+   select AC97_BUS_COMPAT if AC97_BUS_NEW
 
 # Amp
 config SND_SOC_LM4857
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c
index 7e4822185feb..3df2c01d751d 100644
--- a/sound/soc/codecs/wm9713.c
+++ b/sound/soc/codecs/wm9713.c
@@ -17,12 +17,15 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -38,6 +41,7 @@ struct wm9713_priv {
u32 pll_in; /* PLL input frequency */
unsigned int hp_mixer[2];
struct mutex lock;
+   struct wm97xx_platform_data *mfd_pdata;
 };
 
 #define HPL_MIXER 0
@@ -1205,17 +1209,23 @@ static int wm9713_soc_resume(struct snd_soc_codec 
*codec)
 static int wm9713_soc_probe(struct snd_soc_codec *codec)
 {
struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec);
-   struct regmap *regmap;
+   struct regmap *regmap = NULL;
 
-   wm9713->ac97 = snd_soc_new_ac97_codec(codec, WM9713_VENDOR_ID,
-   WM9713_VENDOR_ID_MASK);
-   if (IS_ERR(wm9713->ac97))
-   return PTR_ERR(wm9713->ac97);
-
-   regmap = regmap_init_ac97(wm9713->ac97, &wm9713_regmap_config);
-   if (IS_ERR(regmap)) {
-   snd_soc_free_ac97_codec(wm9713->ac97);
-   return PTR_ERR(regmap);
+   if (wm9713->mfd_pdata) {
+   wm9713->ac97 = wm9713->mfd_pdata->ac97;
+   regmap = wm9713->mfd_pdata->regmap;
+   } else {
+#ifdef CONFIG_SND_SOC_AC97_BUS
+   wm9713->ac97 = snd_soc_new_ac97_codec(codec, WM9713_VENDOR_ID,
+ WM9713_VENDOR_ID_MASK);
+   if (IS_ERR(wm9713->ac97))
+   return PTR_ERR(wm9713->ac97);
+   regmap = regmap_init_ac97(wm9713->ac97, &wm9713_regmap_config);
+   if (IS_ERR(regmap)) {
+   snd_soc_free_ac97_codec(wm9713->ac97);
+   return PTR_ERR(regmap);
+   }
+#endif
}
 
snd_soc_codec_init_regmap(codec, regmap);
@@ -1230,8 +1240,12 @@ static int wm9713_soc_remove(struct snd_soc_codec *codec)
 {
struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec);
 
-   snd_soc_codec_exit_regmap(codec);
-   snd_soc_free_ac97_codec(wm9713->ac97);
+   if (!wm9713->mfd_pdata) {
+   snd_soc_codec_exit_regmap(codec);
+#ifdef CONFIG_SND_SOC_AC97_BUS
+   snd_soc_free_ac97_codec(wm9713->ac97);
+#endif
+   }
return 0;
 }
 
@@ -1262,6 +1276,7 @@ static int wm9713_probe(struct platform_device *pdev)
 
mutex_init(&wm9713->lock);
 
+   wm9713->mfd_pdata = dev_get_platdata(&pdev->dev);
platform_set_drvdata(pdev, wm9713);
 
return snd_soc_register_codec(&pdev->dev,
-- 
2.11.0



[PATCH v6 12/12] ASoC: pxa: switch to new ac97 bus support

2017-09-02 Thread Robert Jarzmik
Switch to the new ac97 bus support in sound/ac97 instead of the legacy
snd_ac97 one.

Signed-off-by: Robert Jarzmik 
---
Since v1: split into 2 patches, the former being XXX ac97 codec agnostic
Since v2: fix driver unregistration
Since v3: added platform driver data for controller removal
---
 sound/arm/Kconfig   |  1 -
 sound/soc/pxa/Kconfig   |  5 ++---
 sound/soc/pxa/pxa2xx-ac97.c | 46 ++---
 3 files changed, 25 insertions(+), 27 deletions(-)

diff --git a/sound/arm/Kconfig b/sound/arm/Kconfig
index 65171f6657a2..f1f25704fe52 100644
--- a/sound/arm/Kconfig
+++ b/sound/arm/Kconfig
@@ -36,7 +36,6 @@ endif # SND_ARM
 
 config SND_PXA2XX_LIB
tristate
-   select SND_AC97_CODEC if SND_PXA2XX_LIB_AC97
select SND_DMAENGINE_PCM
 
 config SND_PXA2XX_LIB_AC97
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig
index 823b5a236d8d..72d652572269 100644
--- a/sound/soc/pxa/Kconfig
+++ b/sound/soc/pxa/Kconfig
@@ -19,13 +19,12 @@ config SND_MMP_SOC
 
 config SND_PXA2XX_AC97
tristate
-   select SND_AC97_CODEC
 
 config SND_PXA2XX_SOC_AC97
tristate
-   select AC97_BUS
+   select AC97_BUS_NEW
select SND_PXA2XX_LIB_AC97
-   select SND_SOC_AC97_BUS
+   select SND_SOC_AC97_BUS_NEW
 
 config SND_PXA2XX_SOC_I2S
tristate
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index b07d64ef49ba..6f0ea3bf9f75 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -27,43 +28,35 @@
 #include 
 #include 
 
-static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97)
+static void pxa2xx_ac97_warm_reset(struct ac97_controller *adrv)
 {
pxa2xx_ac97_try_warm_reset();
 
pxa2xx_ac97_finish_reset();
 }
 
-static void pxa2xx_ac97_cold_reset(struct snd_ac97 *ac97)
+static void pxa2xx_ac97_cold_reset(struct ac97_controller *adrv)
 {
pxa2xx_ac97_try_cold_reset();
 
pxa2xx_ac97_finish_reset();
 }
 
-static unsigned short pxa2xx_ac97_legacy_read(struct snd_ac97 *ac97,
- unsigned short reg)
+static int pxa2xx_ac97_read_actrl(struct ac97_controller *adrv, int slot,
+ unsigned short reg)
 {
-   int ret;
-
-   ret = pxa2xx_ac97_read(ac97->num, reg);
-   if (ret < 0)
-   return 0;
-   else
-   return (unsigned short)(ret & 0x);
+   return pxa2xx_ac97_read(slot, reg);
 }
 
-static void pxa2xx_ac97_legacy_write(struct snd_ac97 *ac97,
-unsigned short reg, unsigned short val)
+static int pxa2xx_ac97_write_actrl(struct ac97_controller *adrv, int slot,
+  unsigned short reg, unsigned short val)
 {
-   int ret;
-
-   ret = pxa2xx_ac97_write(ac97->num, reg, val);
+   return pxa2xx_ac97_write(slot, reg, val);
 }
 
-static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
-   .read   = pxa2xx_ac97_legacy_read,
-   .write  = pxa2xx_ac97_legacy_write,
+static struct ac97_controller_ops pxa2xx_ac97_ops = {
+   .read   = pxa2xx_ac97_read_actrl,
+   .write  = pxa2xx_ac97_write_actrl,
.warm_reset = pxa2xx_ac97_warm_reset,
.reset  = pxa2xx_ac97_cold_reset,
 };
@@ -242,6 +235,8 @@ static const struct snd_soc_component_driver 
pxa_ac97_component = {
 static int pxa2xx_ac97_dev_probe(struct platform_device *pdev)
 {
int ret;
+   struct ac97_controller *ctrl;
+   pxa2xx_audio_ops_t *pdata = pdev->dev.platform_data;
 
if (pdev->id != -1) {
dev_err(&pdev->dev, "PXA2xx has only one AC97 port.\n");
@@ -254,10 +249,13 @@ static int pxa2xx_ac97_dev_probe(struct platform_device 
*pdev)
return ret;
}
 
-   ret = snd_soc_set_ac97_ops(&pxa2xx_ac97_ops);
-   if (ret != 0)
-   return ret;
+   ctrl = snd_ac97_controller_register(&pxa2xx_ac97_ops, &pdev->dev,
+   AC97_SLOTS_AVAILABLE_ALL,
+   pdata->codec_pdata);
+   if (IS_ERR(ctrl))
+   return PTR_ERR(ctrl);
 
+   platform_set_drvdata(pdev, ctrl);
/* Punt most of the init to the SoC probe; we may need the machine
 * driver to do interesting things with the clocking to get us up
 * and running.
@@ -268,8 +266,10 @@ static int pxa2xx_ac97_dev_probe(struct platform_device 
*pdev)
 
 static int pxa2xx_ac97_dev_remove(struct platform_device *pdev)
 {
+   struct ac97_controller *ctrl = platform_get_drvdata(pdev);
+
snd_soc_unregister_component(&pdev->dev);
-   snd_soc_set_ac97_ops(NULL);
+   snd_ac97_controller_unregister(ctrl);
pxa2xx_ac97_hw_remove(pdev);
return 0;
 }
-- 
2.11.0



[PATCH v6 10/12] ASoC: wm9705: add private structure

2017-09-02 Thread Robert Jarzmik
Add a private data structure. This is a preparation for a codec which
would need an another data on top of snd_ac97, which will be the case
when an MFD wm97xx device will probe wm9705.

Signed-off-by: Robert Jarzmik 
Acked-by: Charles Keepax 
---
 sound/soc/codecs/wm9705.c | 36 
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c
index f6d5c0f2aea5..08477d040028 100644
--- a/sound/soc/codecs/wm9705.c
+++ b/sound/soc/codecs/wm9705.c
@@ -24,6 +24,10 @@
 #define WM9705_VENDOR_ID 0x574d4c05
 #define WM9705_VENDOR_ID_MASK 0x
 
+struct wm9705_priv {
+   struct snd_ac97 *ac97;
+};
+
 static const struct reg_default wm9705_reg_defaults[] = {
{ 0x02, 0x8000 },
{ 0x04, 0x8000 },
@@ -292,10 +296,10 @@ static int wm9705_soc_suspend(struct snd_soc_codec *codec)
 
 static int wm9705_soc_resume(struct snd_soc_codec *codec)
 {
-   struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
+   struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec);
int ret;
 
-   ret = snd_ac97_reset(ac97, true, WM9705_VENDOR_ID,
+   ret = snd_ac97_reset(wm9705->ac97, true, WM9705_VENDOR_ID,
WM9705_VENDOR_ID_MASK);
if (ret < 0)
return ret;
@@ -311,38 +315,38 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec)
 
 static int wm9705_soc_probe(struct snd_soc_codec *codec)
 {
-   struct snd_ac97 *ac97;
+   struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec);
struct regmap *regmap;
int ret;
 
-   ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID,
-   WM9705_VENDOR_ID_MASK);
-   if (IS_ERR(ac97)) {
+   wm9705->ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID,
+ WM9705_VENDOR_ID_MASK);
+   if (IS_ERR(wm9705->ac97)) {
dev_err(codec->dev, "Failed to register AC97 codec\n");
-   return PTR_ERR(ac97);
+   return PTR_ERR(wm9705->ac97);
}
 
-   regmap = regmap_init_ac97(ac97, &wm9705_regmap_config);
+   regmap = regmap_init_ac97(wm9705->ac97, &wm9705_regmap_config);
if (IS_ERR(regmap)) {
ret = PTR_ERR(regmap);
goto err_free_ac97_codec;
}
 
-   snd_soc_codec_set_drvdata(codec, ac97);
+   snd_soc_codec_set_drvdata(codec, wm9705->ac97);
snd_soc_codec_init_regmap(codec, regmap);
 
return 0;
 err_free_ac97_codec:
-   snd_soc_free_ac97_codec(ac97);
+   snd_soc_free_ac97_codec(wm9705->ac97);
return ret;
 }
 
 static int wm9705_soc_remove(struct snd_soc_codec *codec)
 {
-   struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
+   struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec);
 
snd_soc_codec_exit_regmap(codec);
-   snd_soc_free_ac97_codec(ac97);
+   snd_soc_free_ac97_codec(wm9705->ac97);
return 0;
 }
 
@@ -364,6 +368,14 @@ static const struct snd_soc_codec_driver 
soc_codec_dev_wm9705 = {
 
 static int wm9705_probe(struct platform_device *pdev)
 {
+   struct wm9705_priv *wm9705;
+
+   wm9705 = devm_kzalloc(&pdev->dev, sizeof(*wm9705), GFP_KERNEL);
+   if (wm9705 == NULL)
+   return -ENOMEM;
+
+   platform_set_drvdata(pdev, wm9705);
+
return snd_soc_register_codec(&pdev->dev,
&soc_codec_dev_wm9705, wm9705_dai, 
ARRAY_SIZE(wm9705_dai));
 }
-- 
2.11.0



[PATCH v6 11/12] ASoC: wm9705: add ac97 new bus support

2017-09-02 Thread Robert Jarzmik
Add support for the new ac97 bus model, where devices are automatically
discovered on AC-Links.

Signed-off-by: Robert Jarzmik 
Acked-by: Charles Keepax 
---
Since v4:
 - added #ifdef spotted by Charles
 - tentatively kept Charles's ack
---
 sound/soc/codecs/Kconfig  |  3 ++-
 sound/soc/codecs/wm9705.c | 37 +
 2 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index f17af3592785..1d69a1c1f896 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -205,7 +205,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_WM8998 if MFD_WM8998
select SND_SOC_WM9081 if I2C
select SND_SOC_WM9090 if I2C
-   select SND_SOC_WM9705 if SND_SOC_AC97_BUS
+   select SND_SOC_WM9705 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW)
select SND_SOC_WM9712 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW)
select SND_SOC_WM9713 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW)
 help
@@ -1083,6 +1083,7 @@ config SND_SOC_WM9090
 config SND_SOC_WM9705
tristate
select REGMAP_AC97
+   select AC97_BUS_COMPAT if AC97_BUS_NEW
 
 config SND_SOC_WM9712
tristate
diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c
index 08477d040028..46b5a77c53e4 100644
--- a/sound/soc/codecs/wm9705.c
+++ b/sound/soc/codecs/wm9705.c
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -18,6 +19,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
@@ -26,6 +29,7 @@
 
 struct wm9705_priv {
struct snd_ac97 *ac97;
+   struct wm97xx_platform_data *mfd_pdata;
 };
 
 static const struct reg_default wm9705_reg_defaults[] = {
@@ -319,17 +323,24 @@ static int wm9705_soc_probe(struct snd_soc_codec *codec)
struct regmap *regmap;
int ret;
 
-   wm9705->ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID,
- WM9705_VENDOR_ID_MASK);
-   if (IS_ERR(wm9705->ac97)) {
-   dev_err(codec->dev, "Failed to register AC97 codec\n");
-   return PTR_ERR(wm9705->ac97);
-   }
-
-   regmap = regmap_init_ac97(wm9705->ac97, &wm9705_regmap_config);
-   if (IS_ERR(regmap)) {
-   ret = PTR_ERR(regmap);
-   goto err_free_ac97_codec;
+   if (wm9705->mfd_pdata) {
+   wm9705->ac97 = wm9705->mfd_pdata->ac97;
+   regmap = wm9705->mfd_pdata->regmap;
+   } else {
+#ifdef CONFIG_SND_SOC_AC97_BUS
+   wm9705->ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID,
+ WM9705_VENDOR_ID_MASK);
+   if (IS_ERR(wm9705->ac97)) {
+   dev_err(codec->dev, "Failed to register AC97 codec\n");
+   return PTR_ERR(wm9705->ac97);
+   }
+
+   regmap = regmap_init_ac97(wm9705->ac97, &wm9705_regmap_config);
+   if (IS_ERR(regmap)) {
+   ret = PTR_ERR(regmap);
+   goto err_free_ac97_codec;
+   }
+#endif
}
 
snd_soc_codec_set_drvdata(codec, wm9705->ac97);
@@ -346,7 +357,8 @@ static int wm9705_soc_remove(struct snd_soc_codec *codec)
struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec);
 
snd_soc_codec_exit_regmap(codec);
-   snd_soc_free_ac97_codec(wm9705->ac97);
+   if (!wm9705->mfd_pdata)
+   snd_soc_free_ac97_codec(wm9705->ac97);
return 0;
 }
 
@@ -374,6 +386,7 @@ static int wm9705_probe(struct platform_device *pdev)
if (wm9705 == NULL)
return -ENOMEM;
 
+   wm9705->mfd_pdata = dev_get_platdata(&pdev->dev);
platform_set_drvdata(pdev, wm9705);
 
return snd_soc_register_codec(&pdev->dev,
-- 
2.11.0



[PATCH v6 06/12] mfd: wm97xx-core: core support for wm97xx Codec

2017-09-02 Thread Robert Jarzmik
The WM9705, WM9712 and WM9713 are highly integrated codecs, with an
audio codec, DAC and ADC, GPIO unit and a touchscreen interface.

Historically the support was spread across drivers/input/touchscreen and
sound/soc/codecs. The sharing was done through ac97 bus sharing. This
model will not withstand the new AC97 bus model, where codecs are
discovered on runtime.

Signed-off-by: Robert Jarzmik 
Acked-by: Charles Keepax 
---
Since v3:
 - added a "depends on AC97_BUS_NEW" Kconfig statement
 - added default values for wm9705, wm9712 per Charles's comment
Since v4:
 - added Charles's ack
Since v5:
 - took into account Lee's comments
---
 drivers/mfd/Kconfig|  14 ++
 drivers/mfd/Makefile   |   1 +
 drivers/mfd/wm97xx-core.c  | 379 +
 include/linux/mfd/wm97xx.h |  25 +++
 4 files changed, 419 insertions(+)
 create mode 100644 drivers/mfd/wm97xx-core.c
 create mode 100644 include/linux/mfd/wm97xx.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 55ecdfb74d31..6d175698a49a 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1628,6 +1628,20 @@ config MFD_WM8994
  core support for the WM8994, in order to use the actual
  functionaltiy of the device other drivers must be enabled.
 
+config MFD_WM97xx
+   tristate "Wolfson Microelectronics WM97xx"
+   select MFD_CORE
+   select REGMAP_AC97
+   select AC97_BUS_COMPAT
+   depends on AC97_BUS_NEW
+   help
+ The WM9705, WM9712 and WM9713 is a highly integrated hi-fi CODEC
+ designed for smartphone applications.  As well as audio functionality
+ it has on board GPIO and a touchscreen functionality which is
+ supported via the relevant subsystems.  This driver provides core
+ support for the WM97xx, in order to use the actual functionaltiy of
+ the device other drivers must be enabled.
+
 config MFD_STW481X
tristate "Support for ST Microelectronics STw481x"
depends on I2C && (ARCH_NOMADIK || COMPILE_TEST)
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 31ce07611a6f..902c2e46f310 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -69,6 +69,7 @@ obj-$(CONFIG_MFD_WM8350)  += wm8350.o
 obj-$(CONFIG_MFD_WM8350_I2C)   += wm8350-i2c.o
 wm8994-objs:= wm8994-core.o wm8994-irq.o wm8994-regmap.o
 obj-$(CONFIG_MFD_WM8994)   += wm8994.o
+obj-$(CONFIG_MFD_WM97xx)   += wm97xx-core.o
 
 obj-$(CONFIG_TPS6105X) += tps6105x.o
 obj-$(CONFIG_TPS65010) += tps65010.o
diff --git a/drivers/mfd/wm97xx-core.c b/drivers/mfd/wm97xx-core.c
new file mode 100644
index ..66e477fffd43
--- /dev/null
+++ b/drivers/mfd/wm97xx-core.c
@@ -0,0 +1,379 @@
+/*
+ * Wolfson WM97xx -- Core device
+ *
+ * Copyright (C) 2017 Robert Jarzmik
+ *
+ * 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 of the License, or
+ * (at your option) any later version.
+ *
+ * Features:
+ *  - an AC97 audio codec
+ *  - a touchscreen driver
+ *  - a GPIO block
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define WM9705_VENDOR_ID 0x574d4c05
+#define WM9712_VENDOR_ID 0x574d4c12
+#define WM9713_VENDOR_ID 0x574d4c13
+#define WM97xx_VENDOR_ID_MASK 0x
+
+struct wm97xx_priv {
+   struct regmap *regmap;
+   struct snd_ac97 *ac97;
+   struct device *dev;
+   struct wm97xx_platform_data codec_pdata;
+};
+
+static bool wm97xx_readable_reg(struct device *dev, unsigned int reg)
+{
+   switch (reg) {
+   case AC97_RESET ... AC97_PCM_SURR_DAC_RATE:
+   case AC97_PCM_LR_ADC_RATE:
+   case AC97_CENTER_LFE_MASTER:
+   case AC97_SPDIF ... AC97_LINE1_LEVEL:
+   case AC97_GPIO_CFG ... 0x5c:
+   case AC97_CODEC_CLASS_REV ... AC97_PCI_SID:
+   case 0x74 ... AC97_VENDOR_ID2:
+   return true;
+   default:
+   return false;
+   }
+}
+
+static bool wm97xx_writeable_reg(struct device *dev, unsigned int reg)
+{
+   switch (reg) {
+   case AC97_VENDOR_ID1:
+   case AC97_VENDOR_ID2:
+   return false;
+   default:
+   return wm97xx_readable_reg(dev, reg);
+   }
+}
+
+static const struct reg_default wm9705_reg_defaults[] = {
+   { 0x02, 0x8000 },
+   { 0x04, 0x8000 },
+   { 0x06, 0x8000 },
+   { 0x0a, 0x8000 },
+   { 0x0c, 0x8008 },
+   { 0x0e, 0x8008 },
+   { 0x10, 0x8808 },
+   { 0x12, 0x8808 },
+   { 0x14, 0x8808 },
+   { 0x16, 0x8808 },
+   { 0x18, 0x8808 },
+   { 0x1a, 0x },
+   { 0x1c, 0x8000 },
+   { 0x20, 0x },
+   { 0x22, 0x },
+   { 0x26, 0x000f },
+   { 0x28, 0x0605 },
+   { 0x2a, 0x },
+   { 0x2c, 0xbb80 },
+   { 0x32, 0xbb80 },
+   { 0x34, 0x2000 },
+  

[PATCH v6 04/12] ASoC: arm: make pxa2xx-ac97-lib ac97 codec agnostic

2017-09-02 Thread Robert Jarzmik
All pxa library functions don't use the input parameters for nothing but
slot number. This simplifies their prototypes, and makes them usable by
both the legacy ac97 bus and the new ac97 bus.

Signed-off-by: Robert Jarzmik 
---
 include/sound/pxa2xx-lib.h  | 15 +--
 sound/arm/pxa2xx-ac97-lib.c | 37 +
 sound/arm/pxa2xx-ac97.c | 35 +++
 sound/soc/pxa/pxa2xx-ac97.c | 32 ++--
 4 files changed, 83 insertions(+), 36 deletions(-)

diff --git a/include/sound/pxa2xx-lib.h b/include/sound/pxa2xx-lib.h
index 6ef629bde164..85352becec7c 100644
--- a/include/sound/pxa2xx-lib.h
+++ b/include/sound/pxa2xx-lib.h
@@ -1,10 +1,13 @@
 #ifndef PXA2XX_LIB_H
 #define PXA2XX_LIB_H
 
+#include 
 #include 
-#include 
 
 /* PCM */
+struct snd_pcm_substream;
+struct snd_pcm_hw_params;
+struct snd_pcm;
 
 extern int __pxa2xx_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params);
@@ -21,12 +24,12 @@ extern void pxa2xx_pcm_free_dma_buffers(struct snd_pcm 
*pcm);
 
 /* AC97 */
 
-extern unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97, unsigned short 
reg);
-extern void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg, 
unsigned short val);
+extern int pxa2xx_ac97_read(int slot, unsigned short reg);
+extern int pxa2xx_ac97_write(int slot, unsigned short reg, unsigned short val);
 
-extern bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97);
-extern bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97);
-extern void pxa2xx_ac97_finish_reset(struct snd_ac97 *ac97);
+extern bool pxa2xx_ac97_try_warm_reset(void);
+extern bool pxa2xx_ac97_try_cold_reset(void);
+extern void pxa2xx_ac97_finish_reset(void);
 
 extern int pxa2xx_ac97_hw_suspend(void);
 extern int pxa2xx_ac97_hw_resume(void);
diff --git a/sound/arm/pxa2xx-ac97-lib.c b/sound/arm/pxa2xx-ac97-lib.c
index 39c3969ac1c7..5950a9e218d9 100644
--- a/sound/arm/pxa2xx-ac97-lib.c
+++ b/sound/arm/pxa2xx-ac97-lib.c
@@ -20,7 +20,6 @@
 #include 
 #include 
 
-#include 
 #include 
 
 #include 
@@ -46,38 +45,41 @@ extern void pxa27x_configure_ac97reset(int reset_gpio, bool 
to_gpio);
  * 1 jiffy timeout if interrupt never comes).
  */
 
-unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
+int pxa2xx_ac97_read(int slot, unsigned short reg)
 {
-   unsigned short val = -1;
+   int val = -ENODEV;
volatile u32 *reg_addr;
 
+   if (slot > 0)
+   return -ENODEV;
+
mutex_lock(&car_mutex);
 
/* set up primary or secondary codec space */
if (cpu_is_pxa25x() && reg == AC97_GPIO_STATUS)
-   reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE;
+   reg_addr = slot ? &SMC_REG_BASE : &PMC_REG_BASE;
else
-   reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE;
+   reg_addr = slot ? &SAC_REG_BASE : &PAC_REG_BASE;
reg_addr += (reg >> 1);
 
/* start read access across the ac97 link */
GSR = GSR_CDONE | GSR_SDONE;
gsr_bits = 0;
-   val = *reg_addr;
+   val = (*reg_addr & 0x);
if (reg == AC97_GPIO_STATUS)
goto out;
if (wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1) <= 0 &&
!((GSR | gsr_bits) & GSR_SDONE)) {
printk(KERN_ERR "%s: read error (ac97_reg=%d GSR=%#lx)\n",
__func__, reg, GSR | gsr_bits);
-   val = -1;
+   val = -ETIMEDOUT;
goto out;
}
 
/* valid data now */
GSR = GSR_CDONE | GSR_SDONE;
gsr_bits = 0;
-   val = *reg_addr;
+   val = (*reg_addr & 0x);
/* but we've just started another cycle... */
wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1);
 
@@ -86,29 +88,32 @@ out:mutex_unlock(&car_mutex);
 }
 EXPORT_SYMBOL_GPL(pxa2xx_ac97_read);
 
-void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
-   unsigned short val)
+int pxa2xx_ac97_write(int slot, unsigned short reg, unsigned short val)
 {
volatile u32 *reg_addr;
+   int ret = 0;
 
mutex_lock(&car_mutex);
 
/* set up primary or secondary codec space */
if (cpu_is_pxa25x() && reg == AC97_GPIO_STATUS)
-   reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE;
+   reg_addr = slot ? &SMC_REG_BASE : &PMC_REG_BASE;
else
-   reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE;
+   reg_addr = slot ? &SAC_REG_BASE : &PAC_REG_BASE;
reg_addr += (reg >> 1);
 
GSR = GSR_CDONE | GSR_SDONE;
gsr_bits = 0;
*reg_addr = val;
if (wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_CDONE, 1) <= 0 &&
-   !((GSR | gsr_bits) & GSR_CDONE))
+   !((GSR | gsr_bits) & GSR_CDONE)) {
printk(KERN_ERR "%s: write error

Re: [PATCH] locking/refcounts, x86/asm: Use unique .text section for refcount exceptions

2017-09-02 Thread Kees Cook
On Sat, Sep 2, 2017 at 3:29 AM, Ingo Molnar  wrote:
>
> * Kees Cook  wrote:
>
>> Using .text.unlikely for refcount exceptions isn't safe because gcc may
>> move entire functions into .text.unlikely (e.g. in6_dev_get()), which
>> would cause any uses of a protected refcount_t function to stay inline
>> with the function, triggering the protection unconditionally:
>>
>> .section.text.unlikely,"ax",@progbits
>> .type   in6_dev_get, @function
>> in6_dev_getx:
>> .LFB4673:
>> .loc 2 4128 0
>> .cfi_startproc
>> ...
>> lock; incl 480(%rbx)
>> js 111f
>> .pushsection .text.unlikely
>> 111:lea 480(%rbx), %rcx
>> 112:.byte 0x0f, 0xff
>> .popsection
>> 113:
>>
>> This creates a unique .text section and adds an additional test to the
>> exception handler to WARN in the case of having none of OF, SF, nor ZF
>> set so we can see things like this more easily in the future.
>>
>> Reported-by: Mike Galbraith 
>> Fixes: 7a46ec0e2f48 ("locking/refcounts, x86/asm: Implement fast refcount 
>> overflow protection")
>> Signed-off-by: Kees Cook 
>> ---
>>  arch/x86/Kconfig  | 2 +-
>>  arch/x86/include/asm/refcount.h   | 2 +-
>>  arch/x86/mm/extable.c | 7 ++-
>>  include/asm-generic/vmlinux.lds.h | 1 +
>>  4 files changed, 9 insertions(+), 3 deletions(-)
>
> Could you please split this into two patches: one that fixes the .unlikely 
> bug,
> the other that re-enables the optimized version?
>
> Should there be any other problem with refcounts this would make any bisection
> result more clear-cut.

Certainly!

-Kees

-- 
Kees Cook
Pixel Security


Re: [PATCH][DEBUG] x86/refcount: split up refcount saturation handling

2017-09-02 Thread Kees Cook
On Sat, Sep 2, 2017 at 3:35 AM, Ingo Molnar  wrote:
>
> * Kees Cook  wrote:
>
>> In support of debugging the problems Mike Galbraith has seen with
>> x86-refcount vs gcc vs network refcounts...
>>
>> This minimizes the differences between unchecked-refcount and x86-refcount
>> by changing the refcount_dec() failure case to not saturate. The reporting
>> of negative values is reduced to pr_warn from WARN to avoid spamming dmesg
>> (which may impact race conditions). Ratelimiting is disabled just to be
>> sure no reports are being dropped.
>>
>> Signed-off-by: Kees Cook 
>> ---
>>  arch/x86/mm/extable.c | 51 
>> ++-
>>  kernel/panic.c|  2 +-
>>  2 files changed, 35 insertions(+), 18 deletions(-)
>
> If this patch is still useful then please include it in your next refcount 
> series.
> Better debuggability is always welcome.

It's not: this is while it seemed like something else was happening.
The most important reporting improvement is included in the final fix
patch.

-Kees

-- 
Kees Cook
Pixel Security


Re: [PATCH 03/11] mux: consumer.h: Add MUX_USB_* state constant defines

2017-09-02 Thread Hans de Goede

Hi,

On 02-09-17 21:06, Guenter Roeck wrote:

On Sat, Sep 02, 2017 at 05:59:14PM +0200, Hans de Goede wrote:

Hi,

On 02-09-17 16:59, Guenter Roeck wrote:

On 09/01/2017 02:48 PM, Hans de Goede wrote:

Add MUX_USB_* state constant defines, which can be used by USB
device/host and Type-C polarity/role/altmode mux drivers and consumers
to ensure that they agree on the meaning of the mux_control_select()
state argument.

Signed-off-by: Hans de Goede 
---
  include/linux/mux/consumer.h | 16 
  1 file changed, 16 insertions(+)

diff --git a/include/linux/mux/consumer.h b/include/linux/mux/consumer.h
index 912dd48a3a5d..e3ec9b4db962 100644
--- a/include/linux/mux/consumer.h
+++ b/include/linux/mux/consumer.h
@@ -15,6 +15,22 @@
  #include 
+/*
+ * Mux state values for USB muxes, used for both USB device/host role muxes
+ * as well as for Type-C polarity/role/altmode muxes.
+ *
+ * MUX_USB_POLARITY_INV may be or-ed together with any other mux-state as
+ * inverted-polarity (Type-C plugged in upside down) can happen with any
+ * other mux-state.
+ */
+#define MUX_USB_POLARITY_INVBIT(0)   /* Polarity inverted bit */
+#define MUX_USB_NONE(1 << 1) /* Mux open / not connected */



Why BIT(0) but (1 << 1) and so on ?


Because the polarity can be or-ed together with any of the other options.
Each option can be selected normal and inverted polarity (connector
inserted upside down).


Ah yes, it is (2 << 1), not (1 << 2).


Ack.


But then why don't the options start > with (0 << 1) ?


Because I somehow thought that would conflict with the polarity
bit which of course it will not, so I will fix this for v2.

Note I used BIT(0) for the flag and not say BIT(8) because the mux subsys 
expects
a mux-driver to declare a max value for the state parameter to 
mux_control_select(),
which is what the MUX_USB_STATES define is for. If I were to use say BIT(8) for
the polarity then the MUX_USB_STATES value would become (256 + 5) even though we
only have 12 unique states.

I'll have to look into the series more closely; 


Thank you.


so far the polarity was
a separate parameter to tcpm_mux_set() and the low level API.


Right, I've kept the polarity as a separate parameter at the tcpm level,
but the mux_control_select() function has only one argument, so I or
the polarity and the alt-mode to mux for together there.

Regards,

Hans




Guenter


Regards,

Hans


+#define MUX_USB_DEVICE(2 << 1) /* USB device mode */
+#define MUX_USB_HOST(3 << 1) /* USB host mode */
+#define MUX_USB_HOST_AND_DP_SRC(4 << 1) /* USB host + 2 lanes Display Port 
*/
+#define MUX_USB_DP_SRC(5 << 1) /* 4 lanes Display Port source */
+#define MUX_USB_STATES(6 << 1)
+
  struct device;
  struct mux_control;





Re: [PATCH 0/3] Add missing types to checkpatch.pl --list-types

2017-09-02 Thread Jean Delvare
Hi Joe,

On Sat, 02 Sep 2017 09:25:29 -0700, Joe Perches wrote:
> On Sat, 2017-09-02 at 17:51 +0200, Jean Delvare wrote:
> > [PATCH 1/3] checkpatch: fix typo in comment
> > [PATCH 2/3] checkpatch: rename variables to avoid confusion
> > [PATCH 3/3] checkpatch: add 6 missing types to --list-types  
> 
> Andrew, can you please pick these up?  Thanks.
> 
> Jean, that's a pretty obscure defect.
> Thanks for handling it.

You're welcome.

> btw:  how or why did you find it?

I wrote a patch which introduces a lot of long lines, and I am fine
with that in this specific case, so I wanted to ask checkpatch to print
everything BUT line-over-80-columns warnings. I used --list-types to
find out the internal name for it... and couldn't see anything matching
in the list. But I knew it had to exist, so looked into the code.

-- 
Jean Delvare
SUSE L3 Support


Re: [PATCH 02/11] mux: core: Add support for getting a mux controller on a non DT platform

2017-09-02 Thread sathya

Hi,


On 09/01/2017 02:48 PM, Hans de Goede wrote:

On non DT platforms we cannot get the mux_chip by pnode. Other subsystems
(regulator, clock, pwm) have the same problem and solve this by allowing
platform / board-setup code to add entries to a lookup table and then use
this table to look things up.

This commit adds support for getting a mux controller on a non DT platform
following this pattern. It is based on a simplified version of the pwm
subsys lookup code, the dev_id and mux_name parts of a lookup table entry
are mandatory in the mux-core implementation.

Signed-off-by: Hans de Goede 
---
  drivers/mux/core.c   | 96 +++-
  include/linux/mux/consumer.h | 11 +
  2 files changed, 106 insertions(+), 1 deletion(-)

diff --git a/drivers/mux/core.c b/drivers/mux/core.c
index 6142493c327b..8864cc745506 100644
--- a/drivers/mux/core.c
+++ b/drivers/mux/core.c
@@ -24,6 +24,9 @@
  #include 
  #include 
  
+static DEFINE_MUTEX(mux_lookup_lock);

+static LIST_HEAD(mux_lookup_list);
+
  /*
   * The idle-as-is "state" is not an actual state that may be selected, it
   * only implies that the state should not be changed. So, use that state
@@ -408,6 +411,23 @@ int mux_control_deselect(struct mux_control *mux)
  }
  EXPORT_SYMBOL_GPL(mux_control_deselect);
  
+static int parent_name_match(struct device *dev, const void *data)

+{
+   const char *parent_name = dev_name(dev->parent);
Device name usually contains id section (devname.id). Did you take this 
into consideration ?

+   const char *name = data;
+
+   return strcmp(parent_name, name) == 0;
+}
+
+static struct mux_chip *mux_chip_get_by_name(const char *name)
+{
+   struct device *dev;
+
+   dev = class_find_device(&mux_class, NULL, name, parent_name_match);
+
+   return dev ? to_mux_chip(dev) : NULL;
+}
+
  static int of_dev_node_match(struct device *dev, const void *data)
  {
return dev->of_node == data;
@@ -479,6 +499,42 @@ static struct mux_control *of_mux_control_get(struct 
device *dev,
  }
  
  /**

+ * mux_add_table() - register PWM device consumers

PWM -> MUX

+ * @table: array of consumers to register
+ * @num: number of consumers in table
+ */
+void mux_add_table(struct mux_lookup *table, size_t num)
+{
+   mutex_lock(&mux_lookup_lock);
+
+   while (num--) {
+   list_add_tail(&table->list, &mux_lookup_list);
+   table++;
+   }
+
+   mutex_unlock(&mux_lookup_lock);
+}
+EXPORT_SYMBOL_GPL(mux_add_table);
+
+/**
+ * mux_remove_table() - unregister PWM device consumers
+ * @table: array of consumers to unregister
+ * @num: number of consumers in table
+ */
+void mux_remove_table(struct mux_lookup *table, size_t num)
+{
+   mutex_lock(&mux_lookup_lock);
+
+   while (num--) {
+   list_del(&table->list);
+   table++;
+   }
+
+   mutex_unlock(&mux_lookup_lock);
+}
+EXPORT_SYMBOL_GPL(mux_remove_table);
+
+/**
   * mux_control_get() - Get the mux-control for a device.
   * @dev: The device that needs a mux-control.
   * @mux_name: The name identifying the mux-control.
@@ -487,11 +543,49 @@ static struct mux_control *of_mux_control_get(struct 
device *dev,
   */
  struct mux_control *mux_control_get(struct device *dev, const char *mux_name)
  {
+   struct mux_lookup *m, *chosen = NULL;
+   const char *dev_id = dev_name(dev);
+   struct mux_chip *mux_chip;
+
/* look up via DT first */
if (IS_ENABLED(CONFIG_OF) && dev->of_node)
return of_mux_control_get(dev, mux_name);
  
-	return ERR_PTR(-ENODEV);

+   /*
+* For non DT we look up the provider in the static table typically
+* provided by board setup code.
+*
+* If a match is found, the provider mux chip is looked up by name
+* and a mux-control is requested using the table provided index.
+*/
+   mutex_lock(&mux_lookup_lock);
+   list_for_each_entry(m, &mux_lookup_list, list) {
+   if (WARN_ON(!m->dev_id || !m->mux_name || !m->provider))
+   continue;
+
+   if (strcmp(m->dev_id, dev_id) == 0 &&
+   strcmp(m->mux_name, mux_name) == 0) {
+   chosen = m;
+   break;
+   }
+   }
+   mutex_unlock(&mux_lookup_lock);
+
+   if (!chosen)
+   return ERR_PTR(-ENODEV);
+
+   mux_chip = mux_chip_get_by_name(chosen->provider);
+   if (!mux_chip)
+   return ERR_PTR(-EPROBE_DEFER);
+
+   if (chosen->index >= mux_chip->controllers) {
+   dev_err(dev, "Mux lookup table index out of bounds %u >= %u\n",
+   chosen->index, mux_chip->controllers);
+   put_device(&mux_chip->dev);
+   return ERR_PTR(-EINVAL);
+   }
+
+   return &mux_chip->mux[chosen->index];
  }
  EXPORT_SYMBOL_GPL(mux_control_get);
  
diff --git a/include/linux/mux/consumer.h b/inclu

Re: [PATCH 03/11] mux: consumer.h: Add MUX_USB_* state constant defines

2017-09-02 Thread Guenter Roeck
On Sat, Sep 02, 2017 at 05:59:14PM +0200, Hans de Goede wrote:
> Hi,
> 
> On 02-09-17 16:59, Guenter Roeck wrote:
> >On 09/01/2017 02:48 PM, Hans de Goede wrote:
> >>Add MUX_USB_* state constant defines, which can be used by USB
> >>device/host and Type-C polarity/role/altmode mux drivers and consumers
> >>to ensure that they agree on the meaning of the mux_control_select()
> >>state argument.
> >>
> >>Signed-off-by: Hans de Goede 
> >>---
> >>  include/linux/mux/consumer.h | 16 
> >>  1 file changed, 16 insertions(+)
> >>
> >>diff --git a/include/linux/mux/consumer.h b/include/linux/mux/consumer.h
> >>index 912dd48a3a5d..e3ec9b4db962 100644
> >>--- a/include/linux/mux/consumer.h
> >>+++ b/include/linux/mux/consumer.h
> >>@@ -15,6 +15,22 @@
> >>  #include 
> >>+/*
> >>+ * Mux state values for USB muxes, used for both USB device/host role muxes
> >>+ * as well as for Type-C polarity/role/altmode muxes.
> >>+ *
> >>+ * MUX_USB_POLARITY_INV may be or-ed together with any other mux-state as
> >>+ * inverted-polarity (Type-C plugged in upside down) can happen with any
> >>+ * other mux-state.
> >>+ */
> >>+#define MUX_USB_POLARITY_INVBIT(0)   /* Polarity inverted bit */
> >>+#define MUX_USB_NONE(1 << 1) /* Mux open / not connected */
> >
> >
> >Why BIT(0) but (1 << 1) and so on ?
> 
> Because the polarity can be or-ed together with any of the other options.
> Each option can be selected normal and inverted polarity (connector
> inserted upside down).
> 
Ah yes, it is (2 << 1), not (1 << 2). But then why don't the options start
with (0 << 1) ?

I'll have to look into the series more closely; so far the polarity was
a separate parameter to tcpm_mux_set() and the low level API.

Guenter

> Regards,
> 
> Hans
> 
> >>+#define MUX_USB_DEVICE(2 << 1) /* USB device mode */
> >>+#define MUX_USB_HOST(3 << 1) /* USB host mode */
> >>+#define MUX_USB_HOST_AND_DP_SRC(4 << 1) /* USB host + 2 lanes Display 
> >>Port */
> >>+#define MUX_USB_DP_SRC(5 << 1) /* 4 lanes Display Port source */
> >>+#define MUX_USB_STATES(6 << 1)
> >>+
> >>  struct device;
> >>  struct mux_control;
> >>
> >


[PATCH 3/3] [media] cx18: Adjust ten checks for null pointers

2017-09-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 2 Sep 2017 19:49:23 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/media/pci/cx18/cx18-driver.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/media/pci/cx18/cx18-driver.c 
b/drivers/media/pci/cx18/cx18-driver.c
index 49fc9b72ada5..c29e8ec880b3 100644
--- a/drivers/media/pci/cx18/cx18-driver.c
+++ b/drivers/media/pci/cx18/cx18-driver.c
@@ -255,7 +255,7 @@ static void request_module_async(struct work_struct *work)
request_module("cx18-alsa");
 
/* Initialize cx18-alsa for this instance of the cx18 device */
-   if (cx18_ext_init != NULL)
+   if (cx18_ext_init)
cx18_ext_init(dev);
 }
 
@@ -291,11 +291,11 @@ int cx18_msleep_timeout(unsigned int msecs, int intr)
 /* Release ioremapped memory */
 static void cx18_iounmap(struct cx18 *cx)
 {
-   if (cx == NULL)
+   if (!cx)
return;
 
/* Release io memory */
-   if (cx->enc_mem != NULL) {
+   if (cx->enc_mem) {
CX18_DEBUG_INFO("releasing enc_mem\n");
iounmap(cx->enc_mem);
cx->enc_mem = NULL;
@@ -649,15 +649,15 @@ static void cx18_process_options(struct cx18 *cx)
CX18_INFO("User specified %s card\n", cx->card->name);
else if (cx->options.cardtype != 0)
CX18_ERR("Unknown user specified type, trying to autodetect 
card\n");
-   if (cx->card == NULL) {
+   if (!cx->card) {
if (cx->pci_dev->subsystem_vendor == CX18_PCI_ID_HAUPPAUGE) {
cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT);
CX18_INFO("Autodetected Hauppauge card\n");
}
}
-   if (cx->card == NULL) {
+   if (!cx->card) {
for (i = 0; (cx->card = cx18_get_card(i)); i++) {
-   if (cx->card->pci_list == NULL)
+   if (!cx->card->pci_list)
continue;
for (j = 0; cx->card->pci_list[j].device; j++) {
if (cx->pci_dev->device !=
@@ -676,7 +676,7 @@ static void cx18_process_options(struct cx18 *cx)
}
 done:
 
-   if (cx->card == NULL) {
+   if (!cx->card) {
cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT);
CX18_ERR("Unknown card: vendor/device: [%04x:%04x]\n",
 cx->pci_dev->vendor, cx->pci_dev->device);
@@ -698,7 +698,7 @@ static int cx18_create_in_workq(struct cx18 *cx)
snprintf(cx->in_workq_name, sizeof(cx->in_workq_name), "%s-in",
 cx->v4l2_dev.name);
cx->in_work_queue = alloc_ordered_workqueue("%s", 0, cx->in_workq_name);
-   if (cx->in_work_queue == NULL) {
+   if (!cx->in_work_queue) {
CX18_ERR("Unable to create incoming mailbox handler thread\n");
return -ENOMEM;
}
@@ -1254,7 +1254,7 @@ static void cx18_cancel_out_work_orders(struct cx18 *cx)
 {
int i;
for (i = 0; i < CX18_MAX_STREAMS; i++)
-   if (&cx->streams[i].video_dev != NULL)
+   if (&cx->streams[i].video_dev)
cancel_work_sync(&cx->streams[i].out_work_order);
 }
 
@@ -1299,7 +1299,7 @@ static void cx18_remove(struct pci_dev *pci_dev)
 
pci_disable_device(cx->pci_dev);
 
-   if (cx->vbi.sliced_mpeg_data[0] != NULL)
+   if (cx->vbi.sliced_mpeg_data[0])
for (i = 0; i < CX18_VBI_FRAMES; i++)
kfree(cx->vbi.sliced_mpeg_data[i]);
 
-- 
2.14.1



[PATCH 2/3] [media] cx18: Improve a size determination in cx18_probe()

2017-09-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 2 Sep 2017 19:42:12 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/pci/cx18/cx18-driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/cx18/cx18-driver.c 
b/drivers/media/pci/cx18/cx18-driver.c
index b267590e0877..49fc9b72ada5 100644
--- a/drivers/media/pci/cx18/cx18-driver.c
+++ b/drivers/media/pci/cx18/cx18-driver.c
@@ -909,5 +909,5 @@ static int cx18_probe(struct pci_dev *pci_dev,
return -ENOMEM;
}
 
-   cx = kzalloc(sizeof(struct cx18), GFP_ATOMIC);
+   cx = kzalloc(sizeof(*cx), GFP_ATOMIC);
if (!cx)
-- 
2.14.1



[PATCH 1/3] [media] cx18: Delete an error message for a failed memory allocation in cx18_probe()

2017-09-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 2 Sep 2017 19:39:56 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/pci/cx18/cx18-driver.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/pci/cx18/cx18-driver.c 
b/drivers/media/pci/cx18/cx18-driver.c
index 8bce49cdad46..b267590e0877 100644
--- a/drivers/media/pci/cx18/cx18-driver.c
+++ b/drivers/media/pci/cx18/cx18-driver.c
@@ -913,8 +913,6 @@ static int cx18_probe(struct pci_dev *pci_dev,
-   if (cx == NULL) {
-   printk(KERN_ERR "cx18: cannot manage card %d, out of memory\n",
-  i);
+   if (!cx)
return -ENOMEM;
-   }
+
cx->pci_dev = pci_dev;
cx->instance = i;
 
-- 
2.14.1



[PATCH 0/3] [media] cx18: Adjustments for seven function implementations

2017-09-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 2 Sep 2017 20:03:45 +0200

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Delete an error message for a failed memory allocation
  Improve a size determination
  Adjust ten checks for null pointers

 drivers/media/pci/cx18/cx18-driver.c | 28 +---
 1 file changed, 13 insertions(+), 15 deletions(-)

-- 
2.14.1



Re: [PATCH] usb: gadget: pch_udc: add checks for dma mapping errors

2017-09-02 Thread Alexey Khoroshilov
On 24.08.2017 04:02, Jack Pham wrote:
> On Thu, Aug 24, 2017 at 01:47:08AM +0300, Alexey Khoroshilov wrote:
>> There are no checks for dma mapping errors in pch_udc.
>> Tha patch adds the checks and error handling code.
>> Compile tested only.
>>
>> Found by Linux Driver Verification project (linuxtesting.org).
>>
>> Signed-off-by: Alexey Khoroshilov 
>> ---
>>  drivers/usb/gadget/udc/pch_udc.c | 15 +--
>>  1 file changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/udc/pch_udc.c 
>> b/drivers/usb/gadget/udc/pch_udc.c
>> index 84dcbcd756f0..a305f8392082 100644
>> --- a/drivers/usb/gadget/udc/pch_udc.c
>> +++ b/drivers/usb/gadget/udc/pch_udc.c
>> @@ -1767,7 +1767,7 @@ static struct usb_request 
>> *pch_udc_alloc_request(struct usb_ep *usbep,
>>  req->req.dma = DMA_ADDR_INVALID;
>>  req->dma = DMA_ADDR_INVALID;
>>  INIT_LIST_HEAD(&req->queue);
>> -if (!ep->dev->dma_addr)
>> +if (ep->dev->dma_addr != DMA_ADDR_INVALID)
>>  return &req->req;
>>  /* ep0 in requests are allocated from data pool here */
>>  dma_desc = dma_pool_alloc(ep->dev->data_requests, gfp,
>> @@ -1879,6 +1879,13 @@ static int pch_udc_pcd_queue(struct usb_ep *usbep, 
>> struct usb_request *usbreq,
>>usbreq->length,
>>DMA_FROM_DEVICE);
>>  }
>> +if (dma_mapping_error(&dev->pdev->dev, req->dma)) {
>> +req->dma = DMA_ADDR_INVALID;
>> +retval = -ENOMEM;
>> +if ((unsigned long)(usbreq->buf) & 0x03)
>> +kfree(req->buf);
>> +goto probe_end;
>> +}
>>  req->dma_mapped = 1;
>>  }
>>  if (usbreq->length > 0) {
>> @@ -2961,6 +2968,10 @@ static int init_dma_pools(struct pch_udc_dev *dev)
>>  dev->dma_addr = dma_map_single(&dev->pdev->dev, ep0out_buf,
>> UDC_EP0OUT_BUFF_SIZE * 4,
>> DMA_FROM_DEVICE);
>> +if (dma_mapping_error(&dev->pdev->dev, dev->dma_addr)) {
>> +dev->dma_addr = DMA_ADDR_INVALID;
>> +return -ENOMEM;
>> +}
> 
> Wouldn't this driver be better off using the
> usb_gadget_{map,unmap}_request() functions provided by UDC core.c?
> dma_mapping_error() is provided for free that way.
> 

I think so, but it requires quite significant rework of the driver.
I would not do that without access to hardware.

--
Alexey



Re: [PATCH 19/25] can/bcm: Replace hrtimer_tasklet with softirq based hrtimer

2017-09-02 Thread Oliver Hartkopp

On 08/31/2017 02:23 PM, Anna-Maria Gleixner wrote:

From: Thomas Gleixner 

Switch the timer to CLOCK_MONOTONIC_SOFT, which executed the timer
callback in softirq context and remove the hrtimer_tasklet.

Signed-off-by: Thomas Gleixner 
Signed-off-by: Anna-Maria Gleixner 
Cc: Oliver Hartkopp 


Acked-by: Oliver Hartkopp 

Thanks,
Oliver


Cc: Marc Kleine-Budde 
Cc: linux-...@vger.kernel.org
---
  net/can/bcm.c |  150 
++
  1 file changed, 49 insertions(+), 101 deletions(-)

--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -102,7 +102,6 @@ struct bcm_op {
unsigned long frames_abs, frames_filtered;
struct bcm_timeval ival1, ival2;
struct hrtimer timer, thrtimer;
-   struct tasklet_struct tsklet, thrtsklet;
ktime_t rx_stamp, kt_ival1, kt_ival2, kt_lastmsg;
int rx_ifindex;
int cfsiz;
@@ -364,25 +363,34 @@ static void bcm_send_to_user(struct bcm_
}
  }
  
-static void bcm_tx_start_timer(struct bcm_op *op)

+static bool bcm_tx_set_expiry(struct bcm_op *op, struct hrtimer *hrt)
  {
+   ktime_t ival;
+
if (op->kt_ival1 && op->count)
-   hrtimer_start(&op->timer,
- ktime_add(ktime_get(), op->kt_ival1),
- HRTIMER_MODE_ABS);
+   ival = op->kt_ival1;
else if (op->kt_ival2)
-   hrtimer_start(&op->timer,
- ktime_add(ktime_get(), op->kt_ival2),
- HRTIMER_MODE_ABS);
+   ival = op->kt_ival2;
+   else
+   return false;
+
+   hrtimer_set_expires(hrt, ktime_add(ktime_get(), ival));
+   return true;
  }
  
-static void bcm_tx_timeout_tsklet(unsigned long data)

+static void bcm_tx_start_timer(struct bcm_op *op)
  {
-   struct bcm_op *op = (struct bcm_op *)data;
+   if (bcm_tx_set_expiry(op, &op->timer))
+   hrtimer_start_expires(&op->timer, HRTIMER_MODE_ABS);
+}
+
+/* bcm_tx_timeout_handler - performs cyclic CAN frame transmissions */
+static enum hrtimer_restart bcm_tx_timeout_handler(struct hrtimer *hrtimer)
+{
+   struct bcm_op *op = container_of(hrtimer, struct bcm_op, timer);
struct bcm_msg_head msg_head;
  
  	if (op->kt_ival1 && (op->count > 0)) {

-
op->count--;
if (!op->count && (op->flags & TX_COUNTEVT)) {
  
@@ -399,22 +407,12 @@ static void bcm_tx_timeout_tsklet(unsign

}
bcm_can_tx(op);
  
-	} else if (op->kt_ival2)

+   } else if (op->kt_ival2) {
bcm_can_tx(op);
+   }
  
-	bcm_tx_start_timer(op);

-}
-
-/*
- * bcm_tx_timeout_handler - performs cyclic CAN frame transmissions
- */
-static enum hrtimer_restart bcm_tx_timeout_handler(struct hrtimer *hrtimer)
-{
-   struct bcm_op *op = container_of(hrtimer, struct bcm_op, timer);
-
-   tasklet_schedule(&op->tsklet);
-
-   return HRTIMER_NORESTART;
+   return bcm_tx_set_expiry(op, &op->timer) ?
+   HRTIMER_RESTART : HRTIMER_NORESTART;
  }
  
  /*

@@ -542,11 +540,18 @@ static void bcm_rx_starttimer(struct bcm
hrtimer_start(&op->timer, op->kt_ival1, HRTIMER_MODE_REL);
  }
  
-static void bcm_rx_timeout_tsklet(unsigned long data)

+/* bcm_rx_timeout_handler - when the (cyclic) CAN frame reception timed out */
+static enum hrtimer_restart bcm_rx_timeout_handler(struct hrtimer *hrtimer)
  {
-   struct bcm_op *op = (struct bcm_op *)data;
+   struct bcm_op *op = container_of(hrtimer, struct bcm_op, timer);
struct bcm_msg_head msg_head;
  
+	/* if user wants to be informed, when cyclic CAN-Messages come back */

+   if ((op->flags & RX_ANNOUNCE_RESUME) && op->last_frames) {
+   /* clear received CAN frames to indicate 'nothing received' */
+   memset(op->last_frames, 0, op->nframes * op->cfsiz);
+   }
+
/* create notification to user */
msg_head.opcode  = RX_TIMEOUT;
msg_head.flags   = op->flags;
@@ -557,25 +562,6 @@ static void bcm_rx_timeout_tsklet(unsign
msg_head.nframes = 0;
  
  	bcm_send_to_user(op, &msg_head, NULL, 0);

-}
-
-/*
- * bcm_rx_timeout_handler - when the (cyclic) CAN frame reception timed out
- */
-static enum hrtimer_restart bcm_rx_timeout_handler(struct hrtimer *hrtimer)
-{
-   struct bcm_op *op = container_of(hrtimer, struct bcm_op, timer);
-
-   /* schedule before NET_RX_SOFTIRQ */
-   tasklet_hi_schedule(&op->tsklet);
-
-   /* no restart of the timer is done here! */
-
-   /* if user wants to be informed, when cyclic CAN-Messages come back */
-   if ((op->flags & RX_ANNOUNCE_RESUME) && op->last_frames) {
-   /* clear received CAN frames to indicate 'nothing received' */
-   memset(op->last_frames, 0, op->nframes * op->cfsiz);
-   }
  
  	return HRTIMER_NORESTART;

  }
@@ -583,14 +569,12 @@ static enum hrtimer_restart bcm_rx_timeo
  /*
   * bcm_rx_do_flus

Re: [PATCH v8 02/28] x86/boot: Relocate definition of the initial state of CR0

2017-09-02 Thread Ricardo Neri
On Thu, 2017-08-31 at 11:51 +0200, Borislav Petkov wrote:
> On Wed, Aug 30, 2017 at 09:04:18PM -0700, Ricardo Neri wrote:
> > Thank you! Is it necessary for me to submit a v9 with these updates?
> > Perhaps I can make these updates in branch for the maintainers to pull
> > when/if this series is ack'ed.
> 
> Don't do anything and let me go through the rest of them first. It is
> too late for this merge window anyway so we can take our time. Once you
> receive full feedback from me (and hopefully others) you can send what
> looks like to be a final v9 with all feedback incorporated. :-)

Sure, I will wait until you (and hopefully others) are done reviewing.

Thanks and BR,
Ricardo



Re: [PATCH v2] PCIe AER: report uncorrectable errors only to the functions that logged the errors

2017-09-02 Thread Bjorn Helgaas
On Fri, Sep 01, 2017 at 11:39:35AM +, Gabriele Paoloni wrote:
> Hi Bjorn
> 
> Many thanks for looking at this
> 
> > -Original Message-
> > From: Bjorn Helgaas [mailto:helg...@kernel.org]
> > Sent: 01 September 2017 05:43
> > To: Gabriele Paoloni
> > Cc: Linuxarm; liudongdong (C); linux-...@vger.kernel.org; linux-
> > ker...@vger.kernel.org
> > Subject: Re: [PATCH v2] PCIe AER: report uncorrectable errors only to
> > the functions that logged the errors
> > 
> > On Thu, Aug 31, 2017 at 03:03:44PM -0500, Bjorn Helgaas wrote:
> > > On Fri, Aug 18, 2017 at 12:02:21PM +0100, Gabriele Paoloni wrote:
> > > > Currently if an uncorrectable error is reported by an EP the AER
> > > > driver walks over all the devices connected to the upstream port
> > > > bus and in turns call the report_error_detected() callback.
> > > > If any of the devices connected to the bus does not implement
> > > > dev->driver->err_handler->error_detected() do_recovery() will fail
> > > > leaving all the bus hierarchy devices unrecovered.
> > > >
> > > > However for non fatal errors the PCIe link should not be considered
> > > > compromised, therefore it makes sense to report the error only to
> > > > all the functions that logged an error.
> > >
> > > Can you include a pointer to the relevant part of the spec here?
> 
> Sure
> According to section "6.2.2.2.2. Non-Fatal Errors" 
> << Non-fatal errors are uncorrectable errors which cause a particular
> transaction to be unreliable but the Link is otherwise fully functional.
> Isolating Non-fatal from Fatal errors provides Requester/Receiver logic
> in a device or system management software the opportunity to recover
> from the error without resetting the components on the Link and
> disturbing other transactions in progress. Devices not associated with
> the transaction in error are not impacted by the error.>>
> 
> I will add it to the commit msg:
> 
> > 
> > Also, I forgot to ask: can you outline the problem this fixes?  I'm
> > curious about why this hasn't been an issue in the past.  My guess is
> > there's something new about your configuration, and the config and the
> > symptoms might help connect this fix to similar problems.
> 
> I already replied about this in the previous patch...
> << In Hi1620 we have some integrated controllers that appear as PCIe EPs
> under the same bus. Some of these controllers (e.g. the SATA 
> controller) are missing the err_handler callbacks.
> 
> If one device reports a non-fatal uncorrectable error with the current
> AER core code the callbacks for all the devices under the same bus will
> be called and, if any of the devices is missing the callback all the
> devices in the subtree are left in error state without recovery... 
> This patch is needed to sort out a situation like this one.>>
> 
> Should I add this to the commit msg?

Thanks for the reminder.  I thought I remembered some details but
hadn't dug them out again.  Yes, I was hoping for something we could
include in the commit message.  I'm still not sure what specifically
is *new* about this situation.  Maybe the particular mix of functions
in a multi-function device?  Maybe the fact that you're seeing more
AER errors than before (or maybe just doing more testing?)

Since this is actually a bug fix, this might be a good opportunity to
open a bugzilla for it.  Then we have a place to attach the complete
"lspci -vv" output, dmesg, etc., that are of interest but too much for
the commit message.

> > > > This patch implements this new behaviour for non fatal errors.
> > > >
> > > > Signed-off-by: Gabriele Paoloni 
> > > > Signed-off-by: Dongdong Liu 
> > > > ---
> > > > Changes from v1:
> > > >- now errors are reported only to the fucntions that logged the
> > error
> > > >  instead of all the functions in the same device.
> > > >- the patch subject has changed to match the new implementation
> > > > ---
> > > >  drivers/pci/pcie/aer/aerdrv_core.c | 9 -
> > > >  1 file changed, 8 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/pci/pcie/aer/aerdrv_core.c
> > b/drivers/pci/pcie/aer/aerdrv_core.c
> > > > index b1303b3..057465ad 100644
> > > > --- a/drivers/pci/pcie/aer/aerdrv_core.c
> > > > +++ b/drivers/pci/pcie/aer/aerdrv_core.c
> > > > @@ -390,7 +390,14 @@ static pci_ers_result_t
> > broadcast_error_message(struct pci_dev *dev,
> > > >  * If the error is reported by an end point, we think 
> > > > this
> > > >  * error is related to the upstream link of the end 
> > > > point.
> > > >  */
> > > > -   pci_walk_bus(dev->bus, cb, &result_data);
> > > > +   if (state == pci_channel_io_normal)
> > > > +   /*
> > > > +* the error is non fatal so the bus is ok, just
> > invoke
> > > > +* the callback for the function that logged the
> > error.
> > > > +*/
> > > > +   cb(dev,

[PATCH] pinctrl: uniphier: include instead of

2017-09-02 Thread Masahiro Yamada
The #includes  is here to use BUILD_BUG_ON_ZERO().

Thanks to commit bc6245e5efd7 ("bug: split BUILD_BUG stuff out into
"), it is now possible to reduce the number of
headers pulled in.

Signed-off-by: Masahiro Yamada 
---

 drivers/pinctrl/uniphier/pinctrl-uniphier.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier.h 
b/drivers/pinctrl/uniphier/pinctrl-uniphier.h
index c075ecb8e5db..0a3d2ac27503 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier.h
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier.h
@@ -17,7 +17,7 @@
 #define __PINCTRL_UNIPHIER_H__
 
 #include 
-#include 
+#include 
 #include 
 #include 
 
-- 
2.7.4



Re: [PATCH v8 06/28] x86/mpx: Do not use SIB.index if its value is 100b and ModRM.mod is not 11b

2017-09-02 Thread Ricardo Neri
On Thu, 2017-08-31 at 21:38 +0200, Borislav Petkov wrote:
> On Fri, Aug 18, 2017 at 05:27:47PM -0700, Ricardo Neri wrote:
> > Section 2.2.1.2 of the Intel 64 and IA-32 Architectures Software
> > Developer's Manual volume 2A states that when ModRM.mod !=11b and
> > ModRM.rm = 100b indexed register-indirect addressing is used. In other
> > words, a SIB byte follows the ModRM byte. In the specific case of
> > SIB.index = 100b, the scale*index portion of the computation of the
> > effective address is null. To signal callers of this particular situation,
> > get_reg_offset() can return -EDOM (-EINVAL continues to indicate that an
> > error when decoding the SIB byte).
> > 
> > An example of this situation can be the following instruction:
> > 
> >8b 4c 23 80   mov -0x80(%rbx,%riz,1),%rcx
> >ModRM:0x4c [mod:1b][reg:1b][rm:100b]
> >SIB:  0x23 [scale:0b][index:100b][base:11b]
> >Displacement: 0x80  (1-byte, as per ModRM.mod = 1b)
> > 
> > The %riz 'register' indicates a null index.
> > 
> > In long mode, a REX prefix may be used. When a REX prefix is present,
> > REX.X adds a fourth bit to the register selection of SIB.index. This gives
> > the ability to refer to all the 16 general purpose registers. When REX.X is
> > 1b and SIB.index is 100b, the index is indicated in %r12. In our example,
> > this would look like:
> > 
> >42 8b 4c 23 80mov -0x80(%rbx,%r12,1),%rcx
> >REX:  0x42 [W:0b][R:0b][X:1b][B:0b]
> >ModRM:0x4c [mod:1b][reg:1b][rm:100b]
> >SIB:  0x23 [scale:0b][.X: 1b, index:100b][.B:0b, base:11b]
> >Displacement: 0x80  (1-byte, as per ModRM.mod = 1b)
> > 
> > %r12 is a valid register to use in the scale*index part of the effective
> > address computation.
> > 
> > Cc: Borislav Petkov 
> > Cc: Andy Lutomirski 
> > Cc: Dave Hansen 
> > Cc: Adam Buchbinder 
> > Cc: Colin Ian King 
> > Cc: Lorenzo Stoakes 
> > Cc: Qiaowei Ren 
> > Cc: Peter Zijlstra 
> > Cc: Nathan Howard 
> > Cc: Adan Hawthorn 
> > Cc: Joe Perches 
> > Cc: Ravi V. Shankar 
> > Cc: x...@kernel.org
> > Signed-off-by: Ricardo Neri 
> > ---
> >  arch/x86/mm/mpx.c | 22 --
> >  1 file changed, 20 insertions(+), 2 deletions(-)
> 
> Reviewed-by: Borislav Petkov 

Thanks for your review!




Re: RFC: Revert move default dialect from CIFS to to SMB3

2017-09-02 Thread Linus Torvalds
On Fri, Sep 1, 2017 at 10:22 PM, Andrew Bartlett  wrote:
>
> My quick research shows:
>
> SMB 2.1 but not SMB3 is on:
>  Windows 7
>  Windows 8
>  Windows 2008
>  Windows 2012
>  Samba 3.6 and earlier (SMB1 only by default)
>
> SMB3 is on:
>  Windows 8.1
>  Windows 2012 R2
>  Windows 10
>  Windows 2016
>  Samba 4.0 and above (released 2012)

But most, if not all, of those SMB3 cases _also_ support SMB2.1,
right?  So the "3.0 _only_" case ends up being a fairly rare case
where things have been explicitly limited, and any previous Linux use
must have had that explicit "vers=3.0" flag anyway?

No?

Anyway, we can't avoid *some* breakage (ie the places that literally
only support 1.0 will have to add the explicit "vers=1.0" to get the
mount).

And I merged the code to add better error reporting yesterday, so
hopefully regardless of the default we choose the breakage is not
nearly as confusing to people any more.

  Linus


Re: printk: what is going on with additional newlines?

2017-09-02 Thread Linus Torvalds
On Fri, Sep 1, 2017 at 11:12 PM, Tetsuo Handa
 wrote:
>
> I just tried to distinguish context using one "unsigned long" value
> by embedding IRQ status into lower bits of "struct task_struct *".
> I can change to distinguish context using multiple "unsigned long" values.

I really really don't think we want to use implicit contexts. I
suspect you'd end up doing something like a per-cpu counter (with
perhaps the CPU number in the low bits or something) and every
exception and sw interrupt etc would increment it.

.. oh, and workqueues etc.

And the end result would be that you'd be very limited in where you
can actually expect buffering to happen.

Which is all a bad design, since just making the buffer explicit is
(a) cheaper and (b) better. Now you can put the buffer on the stack,
you never have to worry about where you need to track context, and you
have no buffering limits (ie you can buffer across any event).

> If my assumption was wrong, isn't it dangerous from stack usage point of
> view that we try to call kmalloc()

I think there might be situations where you want to do that, but since
we're talking _printing_, we also know that the buffering normally is
about a single line.

Sure, some situations might want to buffer more before they print out
(perhaps you want to have guarantees that the register state of an
oops never gets mixed up with anything else, or whatever), and maybe
sometimes you'd want bigger lines.

But I definitely suspect that "single line" is often sufficient. I
mean, that's all that KERN_CONT ever gave you anyway (and not
reliably).

And then a 80 character buffer really isn't any different from having
a structure with a few pointers in it, which we do on the stack all
the time.

  Linus


Re: linux-next: Signed-off-by missing for commit in the rdma tree

2017-09-02 Thread Linus Torvalds
On Fri, Sep 1, 2017 at 5:06 AM, Doug Ledford  wrote:
> On 8/31/2017 5:50 PM, Stephen Rothwell wrote:
>> Hi Doug,
>>
>> Commit
>>
>>   4b9796b0a6fb ("IB/hfi1: Use accessor to determine ring size")
>>
>> is missing a Signed-off-by from its author.
>>
>
> What's the best way to fix this?  I can rebase, but I know Linus hates
> that.  What about git note?

We don't end up using (or forwarding) git notes, so that won't help.

Generally, the answer to missing sign-offs is "don't do that again" if
it's not something major and there isn't a _pattern_ of it happening.

In this case, it's a one-liner patch from a developer who has lots of
other sign-offs, from a company that is very aware of his work and the
GPL, and an active contributor. so it's not like it has any legal
implications.

If it was some big important patch from a more questionable source,
and we'd be worried about covering the legal side, it would be a
different issue. As it is, it falls under "mistakes happen, not a big
deal, try to avoid it in the future".

If it *was* a bigger issue and you really want to make sure that the
chain is there for new contributors etc, rebasing to fix sign-offs
ends up being the best (still bad) solution.

  Linus


Re: [PATCH net-next 0/4] net: dsa: add master interface

2017-09-02 Thread Florian Fainelli
Hi Vivien,

On 08/31/2017 11:37 AM, Vivien Didelot wrote:
> Currently the SoC network interface (called master) to which a switch
> fabric hangs, has its dsa_ptr pointing to a dsa_switch_tree instance.
> 
> This is not quite correct, because this interface is physically wired to
> one of the switch ports (called CPU port), and because in a switch
> fabric with multiple CPU ports, several master interfaces will point to
> several CPU ports of the same dsa_switch_tree.
> 
> This patchset adds a new dsa_master structure to represent the pipe
> between the SoC master interface and its switch CPU port. This structure
> will store specific data such as the master ethtool_ops copy and the
> tagging protocol used to pass frames with the associated slave ports.
> The dsa_ptr is changed to a dsa_master instance, and each DSA slave now
> has a pointer to a master port.
> 
> This is a step forward better control over the CPU conduit and support
> for multiple CPU ports.

Looked briefly over this series and this looks good to me, Andrew has a
valid point about reducing the number of dereferences in hot paths
though. Thanks!

> 
> Vivien Didelot (4):
>   net: dsa: introduce dsa_master
>   net: dsa: move master ethtool ops in dsa_master
>   net: dsa: change dsa_ptr for a dsa_master
>   net: dsa: assign a master to slave ports
> 
>  drivers/net/dsa/b53/b53_common.c |   4 +-
>  drivers/net/dsa/bcm_sf2.c|   8 +--
>  drivers/net/dsa/mt7530.c |   4 +-
>  drivers/net/dsa/mv88e6060.c  |   2 +-
>  drivers/net/dsa/qca8k.c  |   2 +-
>  include/linux/netdevice.h|   4 +-
>  include/net/dsa.h|  42 +--
>  net/dsa/Makefile |   2 +-
>  net/dsa/dsa.c|  34 +
>  net/dsa/dsa2.c   |  38 +-
>  net/dsa/dsa_priv.h   |  24 +++
>  net/dsa/legacy.c |  34 +
>  net/dsa/master.c | 149 
> +++
>  net/dsa/slave.c  | 117 +-
>  net/dsa/tag_brcm.c   |   5 +-
>  net/dsa/tag_dsa.c|   3 +-
>  net/dsa/tag_edsa.c   |   3 +-
>  net/dsa/tag_ksz.c|   5 +-
>  net/dsa/tag_lan9303.c|   6 +-
>  net/dsa/tag_mtk.c|  12 +---
>  net/dsa/tag_qca.c|  12 +---
>  net/dsa/tag_trailer.c|   5 +-
>  22 files changed, 265 insertions(+), 250 deletions(-)
>  create mode 100644 net/dsa/master.c
> 

-- 
Florian


Re: [PATCH net-next 4/4] net: dsa: assign a master to slave ports

2017-09-02 Thread Florian Fainelli


On 09/02/2017 08:34 AM, Andrew Lunn wrote:
> On Thu, Aug 31, 2017 at 02:37:46PM -0400, Vivien Didelot wrote:
>> Because each DSA slave port may use a different DSA master port, add a
>> pointer to a master in the slave structure. This is a preparatory patch
>> for multiple CPU ports.
>>
>> Signed-off-by: Vivien Didelot 
>> ---
>>  net/dsa/dsa_priv.h |  7 ++-
>>  net/dsa/slave.c| 33 ++---
>>  2 files changed, 20 insertions(+), 20 deletions(-)
>>
>> diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
>> index 59f155cbbe87..a8cd6cbe4061 100644
>> --- a/net/dsa/dsa_priv.h
>> +++ b/net/dsa/dsa_priv.h
>> @@ -66,6 +66,8 @@ struct dsa_notifier_vlan_info {
>>  };
>>  
>>  struct dsa_slave_priv {
>> +struct dsa_master *master;
>> +
>>  /* Copy of the master xmit tagging op for faster access in hot path */
>>  struct sk_buff *(*xmit)(struct sk_buff *skb,
>>  struct net_device *dev);
>> @@ -179,9 +181,4 @@ extern const struct dsa_device_ops qca_netdev_ops;
>>  /* tag_trailer.c */
>>  extern const struct dsa_device_ops trailer_netdev_ops;
>>  
>> -static inline struct net_device *dsa_master_netdev(struct dsa_slave_priv *p)
>> -{
>> -return p->dp->ds->dst->master->netdev;
>> -}
>> -
> 
> Hi Vivien
> 
> Why remove this helper, when it could become p->master->netdev ?

Agreed, I would keep the helper at this point to minimize the delta, it
should really identical in terms of code generated.
-- 
Florian


Re: [PATCH 1/2] ARM: dts: Add the CLCD controller to Cygnus.

2017-09-02 Thread Florian Fainelli


On 09/02/2017 08:48 AM, Scott Branden wrote:
> Looks good
> 
> On Sep 1, 2017 7:10 PM, "Florian Fainelli"  > wrote:
> 
> 
> 
> On 08/31/2017 01:16 PM, Scott Branden wrote:
> > Hi Eric,
> >
> > mode is correct, location in file needs to be moved.
> >
> >
> > On 17-08-31 11:54 AM, Eric Anholt wrote:
> >> This doesn't yet enable it on any particular platform, as we still
> >> need a panel driver for bcm911360_entphn.
> >>
> >> Signed-off-by: Eric Anholt mailto:e...@anholt.net>>
> >> ---
> >>
> >> These bits are just carving off a little bit of my 911360_entphn
> panel
> >> series, to reduce conflicts when rebasing (which I just did for
> >> testing pl111 changes for cygnus regressions).  I'm waiting to get my
> >> current RPi panel driver in before working on the 911360 panel again.
> >>
> >>   arch/arm/boot/dts/bcm-cygnus.dtsi | 10 ++
> >>   1 file changed, 10 insertions(+)
> >>
> >> diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi
> >> b/arch/arm/boot/dts/bcm-cygnus.dtsi
> >> index 7c957ea06c66..74f73ff24aec 100644
> >> --- a/arch/arm/boot/dts/bcm-cygnus.dtsi
> >> +++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
> >> @@ -575,6 +575,16 @@
> >>   status = "disabled";
> >>   };
> >>   +clcd: clcd@180a {
> > please place in correct address ordered location in file
> 
> I moved it right above the v3d node to keep the nodes ordered by unit
> address, please check the result here:
> 
> 
> https://github.com/Broadcom/stblinux/commit/4d1e42c6b9d28ce7b74d92258435f9d16834ae75
> 
> 
> 
> 
> With Moved location
> Acked-by: Scott Branden  >

Pushed in place with your tag added, thanks!
-- 
Florian


Re: [PATCH 0/3] Add missing types to checkpatch.pl --list-types

2017-09-02 Thread Joe Perches
On Sat, 2017-09-02 at 17:51 +0200, Jean Delvare wrote:
> [PATCH 1/3] checkpatch: fix typo in comment
> [PATCH 2/3] checkpatch: rename variables to avoid confusion
> [PATCH 3/3] checkpatch: add 6 missing types to --list-types

Andrew, can you please pick these up?  Thanks.

Jean, that's a pretty obscure defect.
Thanks for handling it.

btw:  how or why did you find it?

Acked-by: Joe Perches 



[PATCH v2] platform/x86: intel_cht_int33fe: Work around BIOS bug on some devices

2017-09-02 Thread Hans de Goede
At least one BIOS enumerates the max17047 both through the INT33FE ACPI
device (it is right there in the resources table) as well as through a
separate MAX17047 device.

This commit checks for the max17047 already being enumerated through
a separate MAX17047 ACPI device and if so it uses the i2c-client
instantiated for this and attaches the device-props for the max17047 to
that i2c-client.

Signed-off-by: Hans de Goede 
---
Changes in v2:
-Check acpi_companion HID instead of dev_name
---
 drivers/platform/x86/intel_cht_int33fe.c | 71 +++-
 1 file changed, 61 insertions(+), 10 deletions(-)

diff --git a/drivers/platform/x86/intel_cht_int33fe.c 
b/drivers/platform/x86/intel_cht_int33fe.c
index da706e2c4232..a9cbc4b8ca63 100644
--- a/drivers/platform/x86/intel_cht_int33fe.c
+++ b/drivers/platform/x86/intel_cht_int33fe.c
@@ -34,6 +34,42 @@ struct cht_int33fe_data {
struct i2c_client *pi3usb30532;
 };
 
+/*
+ * Grrr I severly dislike buggy BIOS-es. At least one BIOS enumerates
+ * the max17047 both through the INT33FE ACPI device (it is right there
+ * in the resources table) as well as through a separate MAX17047 device.
+ *
+ * These helpers are used to work around this by checking if an i2c-client
+ * for the max17047 has already been registered.
+ */
+int cht_int33fe_check_for_max17047(struct device *dev, void *data)
+{
+   struct acpi_device *companion = ACPI_COMPANION(dev);
+   struct i2c_client **max17047 = data;
+   const char *hid;
+
+   if (!companion)
+   return 0;
+
+   hid = acpi_device_hid(companion);
+
+   /* The MAX17047 ACPI node doesn't have an UID, so we don't check that */
+   if (strcmp(hid, "MAX17047") == 0) {
+   *max17047 = to_i2c_client(dev);
+   return 1;
+   }
+
+   return 0;
+}
+
+struct i2c_client *cht_int33fe_find_max17047(void)
+{
+   struct i2c_client *max17047 = NULL;
+
+   i2c_for_each_dev(&max17047, cht_int33fe_check_for_max17047);
+   return max17047;
+}
+
 static const char * const max17047_suppliers[] = { "bq24190-charger" };
 
 static const struct property_entry max17047_props[] = {
@@ -46,9 +82,10 @@ static int cht_int33fe_probe(struct i2c_client *client)
struct device *dev = &client->dev;
struct i2c_board_info board_info;
struct cht_int33fe_data *data;
+   struct i2c_client *max17047;
unsigned long long ptyp;
acpi_status status;
-   int fusb302_irq;
+   int ret, fusb302_irq;
 
status = acpi_evaluate_integer(ACPI_HANDLE(dev), "PTYP", NULL, &ptyp);
if (ACPI_FAILURE(status)) {
@@ -75,13 +112,25 @@ static int cht_int33fe_probe(struct i2c_client *client)
if (!data)
return -ENOMEM;
 
-   memset(&board_info, 0, sizeof(board_info));
-   strlcpy(board_info.type, "max17047", I2C_NAME_SIZE);
-   board_info.properties = max17047_props;
-
-   data->max17047 = i2c_acpi_new_device(dev, 1, &board_info);
-   if (!data->max17047)
-   return -EPROBE_DEFER; /* Wait for the i2c-adapter to load */
+   /* Work around BIOS bug, see comment on cht_int33fe_find_max17047 */
+   max17047 = cht_int33fe_find_max17047();
+   if (max17047) {
+   /* Pre-existing i2c-client for the max17047, add device-props */
+   ret = device_add_properties(&max17047->dev, max17047_props);
+   if (ret)
+   return ret;
+   /* And re-probe to get the new device-props applied. */
+   ret = device_reprobe(&max17047->dev);
+   if (ret)
+   dev_warn(dev, "Reprobing max17047 error: %d\n", ret);
+   } else {
+   memset(&board_info, 0, sizeof(board_info));
+   strlcpy(board_info.type, "max17047", I2C_NAME_SIZE);
+   board_info.properties = max17047_props;
+   data->max17047 = i2c_acpi_new_device(dev, 1, &board_info);
+   if (!data->max17047)
+   return -EPROBE_DEFER; /* Wait for i2c-adapter to load */
+   }
 
memset(&board_info, 0, sizeof(board_info));
strlcpy(board_info.type, "fusb302", I2C_NAME_SIZE);
@@ -106,7 +155,8 @@ static int cht_int33fe_probe(struct i2c_client *client)
i2c_unregister_device(data->fusb302);
 
 out_unregister_max17047:
-   i2c_unregister_device(data->max17047);
+   if (data->max17047)
+   i2c_unregister_device(data->max17047);
 
return -EPROBE_DEFER; /* Wait for the i2c-adapter to load */
 }
@@ -117,7 +167,8 @@ static int cht_int33fe_remove(struct i2c_client *i2c)
 
i2c_unregister_device(data->pi3usb30532);
i2c_unregister_device(data->fusb302);
-   i2c_unregister_device(data->max17047);
+   if (data->max17047)
+   i2c_unregister_device(data->max17047);
 
return 0;
 }
-- 
2.13.4



Re: [PATCH net] net: dsa: loop: Do not unregister invalid fixed PHY

2017-09-02 Thread Andrew Lunn
On Sat, Sep 02, 2017 at 08:56:45AM -0700, Florian Fainelli wrote:
> During error injection it was possible to crash in dsa_loop_exit() because of
> an attempt to unregister an invalid PHY. We actually want to the driver 
> probing
> in dsa_loop_init() even though fixed_phy_register() may return an error to
> exercise how DSA deals with such cases, but we should not be crashing during
> driver removal.
> 
> Fixes: 98cd1552ea27 ("net: dsa: Mock-up driver")
> Signed-off-by: Florian Fainelli 

Reviewed-by: Andrew Lunn 

Andrew


Re: [PATCH 03/11] mux: consumer.h: Add MUX_USB_* state constant defines

2017-09-02 Thread Hans de Goede

Hi,

On 02-09-17 16:59, Guenter Roeck wrote:

On 09/01/2017 02:48 PM, Hans de Goede wrote:

Add MUX_USB_* state constant defines, which can be used by USB
device/host and Type-C polarity/role/altmode mux drivers and consumers
to ensure that they agree on the meaning of the mux_control_select()
state argument.

Signed-off-by: Hans de Goede 
---
  include/linux/mux/consumer.h | 16 
  1 file changed, 16 insertions(+)

diff --git a/include/linux/mux/consumer.h b/include/linux/mux/consumer.h
index 912dd48a3a5d..e3ec9b4db962 100644
--- a/include/linux/mux/consumer.h
+++ b/include/linux/mux/consumer.h
@@ -15,6 +15,22 @@
  #include 
+/*
+ * Mux state values for USB muxes, used for both USB device/host role muxes
+ * as well as for Type-C polarity/role/altmode muxes.
+ *
+ * MUX_USB_POLARITY_INV may be or-ed together with any other mux-state as
+ * inverted-polarity (Type-C plugged in upside down) can happen with any
+ * other mux-state.
+ */
+#define MUX_USB_POLARITY_INVBIT(0)   /* Polarity inverted bit */
+#define MUX_USB_NONE(1 << 1) /* Mux open / not connected */



Why BIT(0) but (1 << 1) and so on ?


Because the polarity can be or-ed together with any of the other options.
Each option can be selected normal and inverted polarity (connector
inserted upside down).

Regards,

Hans


+#define MUX_USB_DEVICE(2 << 1) /* USB device mode */
+#define MUX_USB_HOST(3 << 1) /* USB host mode */
+#define MUX_USB_HOST_AND_DP_SRC(4 << 1) /* USB host + 2 lanes Display Port 
*/
+#define MUX_USB_DP_SRC(5 << 1) /* 4 lanes Display Port source */
+#define MUX_USB_STATES(6 << 1)
+
  struct device;
  struct mux_control;





[PATCH net] net: dsa: loop: Do not unregister invalid fixed PHY

2017-09-02 Thread Florian Fainelli
During error injection it was possible to crash in dsa_loop_exit() because of
an attempt to unregister an invalid PHY. We actually want to the driver probing
in dsa_loop_init() even though fixed_phy_register() may return an error to
exercise how DSA deals with such cases, but we should not be crashing during
driver removal.

Fixes: 98cd1552ea27 ("net: dsa: Mock-up driver")
Signed-off-by: Florian Fainelli 
---
 drivers/net/dsa/dsa_loop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c
index fdd8f3872102..8150e3a3c8dd 100644
--- a/drivers/net/dsa/dsa_loop.c
+++ b/drivers/net/dsa/dsa_loop.c
@@ -390,7 +390,7 @@ static void __exit dsa_loop_exit(void)
 
mdio_driver_unregister(&dsa_loop_drv);
for (i = 0; i < NUM_FIXED_PHYS; i++)
-   if (phydevs[i])
+   if (!IS_ERR(phydevs[i]))
fixed_phy_unregister(phydevs[i]);
 }
 module_exit(dsa_loop_exit);
-- 
2.11.0



[PATCH 3/3] checkpatch: add 6 missing types to --list-types

2017-09-02 Thread Jean Delvare
Unlike all other types, LONG_LINE, LONG_LINE_COMMENT and
LONG_LINE_STRING are passed to WARN() through a variable. This causes
the parser in list_types() to miss them and consequently they are not
present in the output of --list-types.

Additionally, types TYPO_SPELLING, FSF_MAILING_ADDRESS and AVOID_BUG
are passed with a variable level, causing the parser to miss them
too.

So modify the regex to also catch these special cases.

Signed-off-by: Jean Delvare 
Fixes: 3beb42eced39 ("checkpatch: add --list-types to show message types to 
show or ignore")
Cc: Andy Whitcroft 
Cc: Joe Perches 
---
 scripts/checkpatch.pl |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- linux-4.13-rc7.orig/scripts/checkpatch.pl   2017-09-02 17:46:45.852024037 
+0200
+++ linux-4.13-rc7/scripts/checkpatch.pl2017-09-02 17:46:55.925163818 
+0200
@@ -145,7 +145,8 @@ sub list_types {
close($script);
 
my @types = ();
-   for ($text =~ /\b(?:(?:CHK|WARN|ERROR)\s*\(\s*"([^"]+)")/g) {
+   # Also catch when type or level is passed through a variable
+   for ($text =~ 
/(?:(?:\bCHK|\bWARN|\bERROR|&\{\$msg_level})\s*\(|\$msg_type\s*=)\s*"([^"]+)"/g)
 {
push (@types, $_);
}
@types = sort(uniq(@types));

-- 
Jean Delvare
SUSE L3 Support


[PATCH 7/7] [media] ov9740: Improve a size determination in ov9740_probe()

2017-09-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 2 Sep 2017 16:46:03 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/i2c/soc_camera/ov9740.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/soc_camera/ov9740.c 
b/drivers/media/i2c/soc_camera/ov9740.c
index f44f5da795f9..755de2289c39 100644
--- a/drivers/media/i2c/soc_camera/ov9740.c
+++ b/drivers/media/i2c/soc_camera/ov9740.c
@@ -935,5 +935,5 @@ static int ov9740_probe(struct i2c_client *client,
return -EINVAL;
}
 
-   priv = devm_kzalloc(&client->dev, sizeof(struct ov9740_priv), 
GFP_KERNEL);
+   priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
-- 
2.14.1



[PATCH 2/3] checkpatch: rename variables to avoid confusion

2017-09-02 Thread Jean Delvare
The variable name "$msg_type" is sometimes used to set the message
type, and sometimes used to set the message level. This works but is
kind of confusing. Use "$msg_level" in the latter case instead, to
make the code clearer.

Signed-off-by: Jean Delvare 
Cc: Andy Whitcroft 
Cc: Joe Perches 
---
 scripts/checkpatch.pl |   32 
 1 file changed, 16 insertions(+), 16 deletions(-)

--- linux-4.13-rc7.orig/scripts/checkpatch.pl   2017-09-02 17:21:04.490467219 
+0200
+++ linux-4.13-rc7/scripts/checkpatch.pl2017-09-02 17:23:28.899502742 
+0200
@@ -2715,10 +2715,10 @@ sub process {
my $typo_fix = $spelling_fix{lc($typo)};
$typo_fix = ucfirst($typo_fix) if ($typo =~ 
/^[A-Z]/);
$typo_fix = uc($typo_fix) if ($typo =~ 
/^[A-Z]+$/);
-   my $msg_type = \&WARN;
-   $msg_type = \&CHK if ($file);
-   if (&{$msg_type}("TYPO_SPELLING",
-"'$typo' may be misspelled - 
perhaps '$typo_fix'?\n" . $herecurr) &&
+   my $msg_level = \&WARN;
+   $msg_level = \&CHK if ($file);
+   if (&{$msg_level}("TYPO_SPELLING",
+ "'$typo' may be misspelled - 
perhaps '$typo_fix'?\n" . $herecurr) &&
$fix) {
$fixed[$fixlinenr] =~ 
s/(^|[^A-Za-z@])($typo)($|[^A-Za-z@])/$1$typo_fix$3/;
}
@@ -2753,10 +2753,10 @@ sub process {
$rawline =~ /\b59\s+Temple\s+Pl/i ||
$rawline =~ /\b51\s+Franklin\s+St/i) {
my $herevet = "$here\n" . cat_vet($rawline) . "\n";
-   my $msg_type = \&ERROR;
-   $msg_type = \&CHK if ($file);
-   &{$msg_type}("FSF_MAILING_ADDRESS",
-"Do not include the paragraph about 
writing to the Free Software Foundation's mailing address from the sample GPL 
notice. The FSF has changed addresses in the past, and may do so again. Linux 
already includes a copy of the GPL.\n" . $herevet)
+   my $msg_level = \&ERROR;
+   $msg_level = \&CHK if ($file);
+   &{$msg_level}("FSF_MAILING_ADDRESS",
+ "Do not include the paragraph about 
writing to the Free Software Foundation's mailing address from the sample GPL 
notice. The FSF has changed addresses in the past, and may do so again. Linux 
already includes a copy of the GPL.\n" . $herevet)
}
 
 # check for Kconfig help text having a real description
@@ -3810,10 +3810,10 @@ sub process {
 
 # avoid BUG() or BUG_ON()
if ($line =~ /\b(?:BUG|BUG_ON)\b/) {
-   my $msg_type = \&WARN;
-   $msg_type = \&CHK if ($file);
-   &{$msg_type}("AVOID_BUG",
-"Avoid crashing the kernel - try using 
WARN_ON & recovery code rather than BUG() or BUG_ON()\n" . $herecurr);
+   my $msg_level = \&WARN;
+   $msg_level = \&CHK if ($file);
+   &{$msg_level}("AVOID_BUG",
+ "Avoid crashing the kernel - try using 
WARN_ON & recovery code rather than BUG() or BUG_ON()\n" . $herecurr);
}
 
 # avoid LINUX_VERSION_CODE
@@ -4339,11 +4339,11 @@ sub process {
 
# messages are ERROR, but ?: are CHK
if ($ok == 0) {
-   my $msg_type = \&ERROR;
-   $msg_type = \&CHK if (($op eq 
'?:' || $op eq '?' || $op eq ':') && $ctx =~ /VxV/);
+   my $msg_level = \&ERROR;
+   $msg_level = \&CHK if (($op eq 
'?:' || $op eq '?' || $op eq ':') && $ctx =~ /VxV/);
 
-   if (&{$msg_type}("SPACING",
-"spaces 
required around that '$op' $at\n" . $hereptr)) {
+   if (&{$msg_level}("SPACING",
+ "spaces 
required around that '$op' $at\n" . $hereptr)) {
$good = 
rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " ";
if (defined 
$fix_elements[$n + 2]) {

$fix_elements[$n + 2] =~ s/^\s+//;

-- 
Jean Delvare
SUSE L3 Support


[PATCH 1/3] checkpatch: fix typo in comment

2017-09-02 Thread Jean Delvare
Signed-off-by: Jean Delvare 
Cc: Andy Whitcroft 
Cc: Joe Perches 
---
 scripts/checkpatch.pl |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-4.13-rc7.orig/scripts/checkpatch.pl   2017-07-30 21:40:36.0 
+0200
+++ linux-4.13-rc7/scripts/checkpatch.pl2017-09-01 15:43:21.562568859 
+0200
@@ -2875,7 +2875,7 @@ sub process {
 #  #defines that are a single string
 #
 # There are 3 different line length message types:
-# LONG_LINE_COMMENTa comment starts before but extends beyond 
$max_linelength
+# LONG_LINE_COMMENTa comment starts before but extends beyond 
$max_line_length
 # LONG_LINE_STRING a string starts before but extends beyond 
$max_line_length
 # LONG_LINEall other lines longer than $max_line_length
 #


-- 
Jean Delvare
SUSE L3 Support


[PATCH 6/7] [media] ov9740: Delete an error message for a failed memory allocation in ov9740_probe()

2017-09-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 2 Sep 2017 16:44:36 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/i2c/soc_camera/ov9740.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/ov9740.c 
b/drivers/media/i2c/soc_camera/ov9740.c
index cc07b7ae5407..f44f5da795f9 100644
--- a/drivers/media/i2c/soc_camera/ov9740.c
+++ b/drivers/media/i2c/soc_camera/ov9740.c
@@ -939,7 +939,5 @@ static int ov9740_probe(struct i2c_client *client,
-   if (!priv) {
-   dev_err(&client->dev, "Failed to allocate private data!\n");
+   if (!priv)
return -ENOMEM;
-   }
 
v4l2_i2c_subdev_init(&priv->subdev, client, &ov9740_subdev_ops);
v4l2_ctrl_handler_init(&priv->hdl, 13);
-- 
2.14.1



[PATCH 5/7] [media] ov9640: Improve a size determination in ov9640_probe()

2017-09-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 2 Sep 2017 16:37:03 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/i2c/soc_camera/ov9640.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/soc_camera/ov9640.c 
b/drivers/media/i2c/soc_camera/ov9640.c
index 0f02f022f3e9..67578f194928 100644
--- a/drivers/media/i2c/soc_camera/ov9640.c
+++ b/drivers/media/i2c/soc_camera/ov9640.c
@@ -675,5 +675,5 @@ static int ov9640_probe(struct i2c_client *client,
return -EINVAL;
}
 
-   priv = devm_kzalloc(&client->dev, sizeof(struct ov9640_priv), 
GFP_KERNEL);
+   priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
-- 
2.14.1



[PATCH 0/3] Add missing types to checkpatch.pl --list-types

2017-09-02 Thread Jean Delvare
[PATCH 1/3] checkpatch: fix typo in comment
[PATCH 2/3] checkpatch: rename variables to avoid confusion
[PATCH 3/3] checkpatch: add 6 missing types to --list-types
---
 scripts/checkpatch.pl |   37 +++--
 1 file changed, 19 insertions(+), 18 deletions(-)
-- 
Jean Delvare
SUSE L3 Support


Re: [PATCH 4.9 01/12] p54: memset(0) whole array

2017-09-02 Thread Joe Perches
On Thu, 2017-08-31 at 09:40 -0700, Joe Perches wrote:
> On Thu, 2017-08-31 at 17:44 +0200, Greg Kroah-Hartman wrote:
> > 4.9-stable review patch.  If anyone has any objections, please let me know.
> > 
> > --
> > 
> > From: Jiri Slaby 
> > 
> > commit 6f17581788206444cbbcdbc107498f85e9765e3d upstream.
> > 
> > gcc 7 complains:
> > drivers/net/wireless/intersil/p54/fwio.c: In function 'p54_scan':
> > drivers/net/wireless/intersil/p54/fwio.c:491:4: warning: 'memset' used with 
> > length equal to number of elements without multiplication by element size 
> > [-Wmemset-elt-size]
> > 
> > Fix that by passing the correct size to memset.
> > 
> > Signed-off-by: Jiri Slaby 
> > Cc: Christian Lamparter 
> > Cc: Kalle Valo 
> > Acked-by: Christian Lamparter 
> > Signed-off-by: Kalle Valo 
> > Signed-off-by: Greg Kroah-Hartman 
> > 
> > ---
> >  drivers/net/wireless/intersil/p54/fwio.c |2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > --- a/drivers/net/wireless/intersil/p54/fwio.c
> > +++ b/drivers/net/wireless/intersil/p54/fwio.c
> > @@ -488,7 +488,7 @@ int p54_scan(struct p54_common *priv, u1
> >  
> > entry += sizeof(__le16);
> > chan->pa_points_per_curve = 8;
> > -   memset(chan->curve_data, 0, sizeof(*chan->curve_data));
> > +   memset(chan->curve_data, 0, sizeof(chan->curve_data));
> > memcpy(chan->curve_data, entry,
> >sizeof(struct p54_pa_curve_data_sample) *
> >min((u8)8, curve_data->points_per_channel));
> > 
> 
> Why is this change correct?
> 
> curve_data is a pointer.
> 
> This now clears the sizeof a pointer and not
> the sizeof struct p54_cal_database

So what happens here?
This change seems clearly incorrect.
For all stable versions.



[PATCH 4/7] [media] ov9640: Delete an error message for a failed memory allocation in ov9640_probe()

2017-09-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 2 Sep 2017 16:34:27 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/i2c/soc_camera/ov9640.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/ov9640.c 
b/drivers/media/i2c/soc_camera/ov9640.c
index 0146d1f7aacb..0f02f022f3e9 100644
--- a/drivers/media/i2c/soc_camera/ov9640.c
+++ b/drivers/media/i2c/soc_camera/ov9640.c
@@ -679,8 +679,5 @@ static int ov9640_probe(struct i2c_client *client,
-   if (!priv) {
-   dev_err(&client->dev,
-   "Failed to allocate memory for private data!\n");
+   if (!priv)
return -ENOMEM;
-   }
 
v4l2_i2c_subdev_init(&priv->subdev, client, &ov9640_subdev_ops);
 
-- 
2.14.1



  1   2   >