Re: [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe()

2016-07-03 Thread SF Markus Elfring
>> A few update suggestions were taken into account
>> from static source code analysis.
>>
>> Markus Elfring (2):
>>   Return directly after a failed kzalloc()
>>   Remove two OOM messages
>>
>>  drivers/input/serio/at32psif.c | 10 +++---
>>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> What possible rationale is there for including this "references" header?
> 566abcd9.1060...@users.sourceforge.net

Do any more software developers dare to reconsider source code
also around a jump label like "out"?


> This message id is for your message:
>   "Source code review around jump label usage"
> sent December 11, 2015!

Can such an association with a bit of background information
be occasionally useful for clarification of corresponding
implementation details?

Regards,
Markus


undefined reference to `bad_dma_ops'

2016-07-03 Thread kbuild test robot
Hi,

It's probably a bug fix that unveils the link errors.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   4f302921c1458d790ae21147f7043f4e6b6a1085
commit: 420520766a796d3607639ba1e4fb1aadeadd [media] media: Kconfig: add 
dependency of HAS_DMA
date:   5 months ago
config: m32r-allyesconfig (attached as .config)
compiler: m32r-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 420520766a796d3607639ba1e4fb1aadeadd
# save the attached .config to linux build tree
make.cross ARCH=m32r 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `hisi_sas_slot_task_free':
>> (.text+0x219238): undefined reference to `bad_dma_ops'
   drivers/built-in.o: In function `hisi_sas_slot_task_free':
   (.text+0x21923c): undefined reference to `bad_dma_ops'
   drivers/built-in.o: In function `hisi_sas_free':
   hisi_sas_main.c:(.text+0x2194cc): undefined reference to `bad_dma_ops'
   hisi_sas_main.c:(.text+0x2194d0): undefined reference to `bad_dma_ops'
   hisi_sas_main.c:(.text+0x219530): undefined reference to `bad_dma_ops'
   drivers/built-in.o:hisi_sas_main.c:(.text+0x219534): more undefined 
references to `bad_dma_ops' follow
   drivers/built-in.o: In function `hisi_sas_slot_task_free':
   (.text+0x219260): undefined reference to `dma_pool_free'
   drivers/built-in.o: In function `hisi_sas_slot_task_free':
   (.text+0x219260): relocation truncated to fit: R_M32R_26_PCREL_RELA against 
undefined symbol `dma_pool_free'
   drivers/built-in.o: In function `hisi_sas_slot_task_free':
   (.text+0x219278): undefined reference to `dma_pool_free'
   drivers/built-in.o: In function `hisi_sas_slot_task_free':
   (.text+0x219278): relocation truncated to fit: R_M32R_26_PCREL_RELA against 
undefined symbol `dma_pool_free'
   drivers/built-in.o: In function `hisi_sas_slot_task_free':
   (.text+0x21928c): undefined reference to `dma_pool_free'
   drivers/built-in.o: In function `hisi_sas_slot_task_free':
   (.text+0x21928c): relocation truncated to fit: R_M32R_26_PCREL_RELA against 
undefined symbol `dma_pool_free'
   drivers/built-in.o: In function `hisi_sas_free':
   hisi_sas_main.c:(.text+0x219560): undefined reference to `dma_pool_destroy'
   hisi_sas_main.c:(.text+0x219560): relocation truncated to fit: 
R_M32R_26_PCREL_RELA against undefined symbol `dma_pool_destroy'
   hisi_sas_main.c:(.text+0x21956c): undefined reference to `dma_pool_destroy'
   hisi_sas_main.c:(.text+0x21956c): relocation truncated to fit: 
R_M32R_26_PCREL_RELA against undefined symbol `dma_pool_destroy'
   hisi_sas_main.c:(.text+0x219574): undefined reference to `dma_pool_destroy'
   hisi_sas_main.c:(.text+0x219574): relocation truncated to fit: 
R_M32R_26_PCREL_RELA against undefined symbol `dma_pool_destroy'
   drivers/built-in.o: In function `hisi_sas_probe':
   (.text+0x219fa4): undefined reference to `dma_pool_create'
   drivers/built-in.o: In function `hisi_sas_probe':
   (.text+0x219fa4): relocation truncated to fit: R_M32R_26_PCREL_RELA against 
undefined symbol `dma_pool_create'
   drivers/built-in.o: In function `hisi_sas_probe':
   (.text+0x219fcc): undefined reference to `dma_pool_create'
   drivers/built-in.o: In function `hisi_sas_probe':
   (.text+0x219fcc): relocation truncated to fit: R_M32R_26_PCREL_RELA against 
undefined symbol `dma_pool_create'
   drivers/built-in.o: In function `hisi_sas_probe':
   (.text+0x21a0fc): undefined reference to `dma_pool_create'
   drivers/built-in.o: In function `hisi_sas_probe':
   (.text+0x21a0fc): relocation truncated to fit: R_M32R_26_PCREL_RELA against 
undefined symbol `dma_pool_create'
   drivers/built-in.o: In function `hisi_sas_task_exec.isra.9':
   hisi_sas_main.c:(.text+0x21a834): undefined reference to `dma_pool_alloc'
   hisi_sas_main.c:(.text+0x21a834): relocation truncated to fit: 
R_M32R_26_PCREL_RELA against undefined symbol `dma_pool_alloc'
   hisi_sas_main.c:(.text+0x21a860): undefined reference to `dma_pool_alloc'
   hisi_sas_main.c:(.text+0x21a860): additional relocation overflows omitted 
from the output
   hisi_sas_main.c:(.text+0x21a990): undefined reference to `dma_pool_free'
   hisi_sas_main.c:(.text+0x21a9a8): undefined reference to `dma_pool_free'
   hisi_sas_main.c:(.text+0x21a9c8): undefined reference to `dma_pool_free'
   drivers/built-in.o: In function `prep_smp_v1_hw':
   hisi_sas_v1_hw.c:(.text+0x21b660): undefined reference to `bad_dma_ops'
   hisi_sas_v1_hw.c:(.text+0x21b668): undefined reference to `bad_dma_ops'
   drivers/built-in.o: In function `slot_complete_v1_hw':
   hisi_sas_v1_hw.c:(.text+0x21c80c): undefined reference to `bad_dma_ops'
   hisi_sas_v1_hw.c:(.text+0x21c810): undefined reference to `bad_dma_ops'
   drivers/built-in.o: In function `prep_ssp_v1_hw':
   hisi_sas_v1_hw.c:(.text+0x21ba0c): undefined reference to `dma_po

[GIT PULL] overlayfs fixes for 4.7-rc5

2016-07-03 Thread Miklos Szeredi
Hi Linus,

Please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git overlayfs-linus

This contains fixes for a dentry leak, a regression in 4.6 noticed by Docker
users and missing write access checking in truncate.

Thanks,
Miklos

---
Miklos Szeredi (2):
  ovl: fix dentry leak for default_permissions
  ovl: get_write_access() in truncate

Vivek Goyal (1):
  ovl: warn instead of error if d_type is not supported

---
 fs/overlayfs/inode.c | 29 ++---
 fs/overlayfs/super.c | 12 +++-
 2 files changed, 33 insertions(+), 8 deletions(-)


[GIT PULL] fuse fix for 4.7-rc5

2016-07-03 Thread Miklos Szeredi
Hi Linus,

Please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse.git for-linus

This makes sure not userspace filesystems are broken by the parallel lookups and
readdir feature.

Thanks,
Miklos

---
Miklos Szeredi (1):
  fuse: serialize dirops by default

---
 fs/fuse/dir.c |  4 
 fs/fuse/fuse_i.h  |  9 +
 fs/fuse/inode.c   | 19 ++-
 include/uapi/linux/fuse.h |  7 ++-
 4 files changed, 37 insertions(+), 2 deletions(-)


[tip:perf/urgent] perf/x86: Fix 32-bit perf user callgraph collection

2016-07-03 Thread tip-bot for Josh Poimboeuf
Commit-ID:  fc18822510721fe694d273c5211c71ea52796d76
Gitweb: http://git.kernel.org/tip/fc18822510721fe694d273c5211c71ea52796d76
Author: Josh Poimboeuf 
AuthorDate: Fri, 1 Jul 2016 23:02:05 -0500
Committer:  Ingo Molnar 
CommitDate: Sun, 3 Jul 2016 10:43:00 +0200

perf/x86: Fix 32-bit perf user callgraph collection

A basic perf callgraph record operation causes an immediate panic on a
32-bit kernel compiled with CONFIG_CC_STACKPROTECTOR=y:

  $ perf record -g ls
  Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: 
c0404fbd

  CPU: 0 PID: 998 Comm: ls Not tainted 4.7.0-rc5+ #1
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.9.1-1.fc24 
04/01/2014
   c0dd5967 ff7afe1c 0086 f41dbc2c c07445a0 464c457f f41dbca8 f41dbc44
   c05646f4 f41dbca8 464c457f f41dbca8 464c457f f41dbc54 c04625be c0ce56fc
   c0404fbd f41dbc88 c0404fbd b74668f0 f41dc000  c000 
  Call Trace:
   [] dump_stack+0x58/0x78
   [] panic+0x8e/0x1c6
   [] __stack_chk_fail+0x1e/0x30
   [] ? perf_callchain_user+0x22d/0x230
   [] perf_callchain_user+0x22d/0x230
   [] get_perf_callchain+0x1ff/0x270
   [] perf_callchain+0x78/0x90
   [] perf_prepare_sample+0x24b/0x370
   [] perf_event_output_forward+0x24/0x70
   [] __perf_event_overflow+0xa0/0x210
   [] ? cpu_clock_event_read+0x43/0x50
   [] perf_swevent_hrtimer+0x101/0x180
   [] ? kmap_atomic_prot+0x35/0x140
   [] ? get_page_from_freelist+0x279/0x950
   [] ? vma_interval_tree_remove+0x158/0x230
   [] ? wp_page_copy.isra.82+0x2f4/0x630
   [] ? page_add_file_rmap+0x1d/0x50
   [] ? unlock_page+0x61/0x80
   [] ? filemap_map_pages+0x305/0x320
   [] ? handle_mm_fault+0xb7f/0x1560
   [] ? timerqueue_del+0x1b/0x70
   [] ? __remove_hrtimer+0x2e/0x60
   [] __hrtimer_run_queues+0xcb/0x2a0
   [] ? __perf_event_overflow+0x210/0x210
   [] hrtimer_interrupt+0x8a/0x180
   [] local_apic_timer_interrupt+0x32/0x60
   [] smp_apic_timer_interrupt+0x33/0x50
   [] apic_timer_interrupt+0x34/0x3c
  Kernel Offset: disabled
  ---[ end Kernel panic - not syncing: stack-protector: Kernel stack is 
corrupted in: c0404fbd

The panic is caused by the fact that perf_callchain_user() mistakenly
assumes it's 64-bit only and ends up corrupting the stack.

Signed-off-by: Josh Poimboeuf 
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Cc: sta...@vger.kernel.org # v4.5+
Fixes: 75925e1ad7f5 ("perf/x86: Optimize stack walk user accesses")
Link: 
http://lkml.kernel.org/r/1a547f5077ec30f75f9b57074837c3c80df86e5e.1467432113.git.jpoim...@redhat.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/events/core.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 33787ee..26ced53 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -2319,7 +2319,7 @@ void
 perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs 
*regs)
 {
struct stack_frame frame;
-   const void __user *fp;
+   const unsigned long __user *fp;
 
if (perf_guest_cbs && perf_guest_cbs->is_in_guest()) {
/* TODO: We don't support guest os callchain now */
@@ -2332,7 +2332,7 @@ perf_callchain_user(struct perf_callchain_entry_ctx 
*entry, struct pt_regs *regs
if (regs->flags & (X86_VM_MASK | PERF_EFLAGS_VM))
return;
 
-   fp = (void __user *)regs->bp;
+   fp = (unsigned long __user *)regs->bp;
 
perf_callchain_store(entry, regs->ip);
 
@@ -2345,16 +2345,17 @@ perf_callchain_user(struct perf_callchain_entry_ctx 
*entry, struct pt_regs *regs
pagefault_disable();
while (entry->nr < entry->max_stack) {
unsigned long bytes;
+
frame.next_frame = NULL;
frame.return_address = 0;
 
-   if (!access_ok(VERIFY_READ, fp, 16))
+   if (!access_ok(VERIFY_READ, fp, sizeof(*fp) * 2))
break;
 
-   bytes = __copy_from_user_nmi(&frame.next_frame, fp, 8);
+   bytes = __copy_from_user_nmi(&frame.next_frame, fp, 
sizeof(*fp));
if (bytes != 0)
break;
-   bytes = __copy_from_user_nmi(&frame.return_address, fp+8, 8);
+   bytes = __copy_from_user_nmi(&frame.return_address, fp + 1, 
sizeof(*fp));
if (bytes != 0)
break;
 


[tip:perf/urgent] perf/x86/intel: Update event constraints when HT is off

2016-07-03 Thread tip-bot for Stephane Eranian
Commit-ID:  9010ae4a8dee29e5886e86682799dde0eee7f447
Gitweb: http://git.kernel.org/tip/9010ae4a8dee29e5886e86682799dde0eee7f447
Author: Stephane Eranian 
AuthorDate: Fri, 1 Jul 2016 15:22:22 -0700
Committer:  Ingo Molnar 
CommitDate: Sun, 3 Jul 2016 10:39:53 +0200

perf/x86/intel: Update event constraints when HT is off

This patch updates the event constraints for non-PEBS mode for
Intel Broadwell and Skylake processors. When HT is off, each
CPU gets 8 generic counters. However, not all events can be
programmed on any of the 8 counters.  This patch adds the
constraints for the MEM_* events which can only be measured on the
bottom 4 counters. The constraints are also valid when HT is off
because, then, there are only 4 generic counters and they are the
bottom counters.

Signed-off-by: Stephane Eranian 
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Cc: kan.li...@intel.com
Link: 
http://lkml.kernel.org/r/1467411742-13245-1-git-send-email-eran...@google.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/events/intel/core.c | 29 +
 1 file changed, 29 insertions(+)

diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 7c66695..9b4f9d3 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -115,6 +115,10 @@ static struct event_constraint 
intel_snb_event_constraints[] __read_mostly =
INTEL_UEVENT_CONSTRAINT(0x04a3, 0xf), /* 
CYCLE_ACTIVITY.CYCLES_NO_DISPATCH */
INTEL_UEVENT_CONSTRAINT(0x02a3, 0x4), /* 
CYCLE_ACTIVITY.CYCLES_L1D_PENDING */
 
+   /*
+* When HT is off these events can only run on the bottom 4 counters
+* When HT is on, they are impacted by the HT bug and require EXCL 
access
+*/
INTEL_EXCLEVT_CONSTRAINT(0xd0, 0xf), /* MEM_UOPS_RETIRED.* */
INTEL_EXCLEVT_CONSTRAINT(0xd1, 0xf), /* MEM_LOAD_UOPS_RETIRED.* */
INTEL_EXCLEVT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* 
*/
@@ -139,6 +143,10 @@ static struct event_constraint 
intel_ivb_event_constraints[] __read_mostly =
INTEL_UEVENT_CONSTRAINT(0x0ca3, 0x4), /* 
CYCLE_ACTIVITY.STALLS_L1D_PENDING */
INTEL_UEVENT_CONSTRAINT(0x01c0, 0x2), /* INST_RETIRED.PREC_DIST */
 
+   /*
+* When HT is off these events can only run on the bottom 4 counters
+* When HT is on, they are impacted by the HT bug and require EXCL 
access
+*/
INTEL_EXCLEVT_CONSTRAINT(0xd0, 0xf), /* MEM_UOPS_RETIRED.* */
INTEL_EXCLEVT_CONSTRAINT(0xd1, 0xf), /* MEM_LOAD_UOPS_RETIRED.* */
INTEL_EXCLEVT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* 
*/
@@ -182,6 +190,16 @@ struct event_constraint intel_skl_event_constraints[] = {
FIXED_EVENT_CONSTRAINT(0x003c, 1),  /* CPU_CLK_UNHALTED.CORE */
FIXED_EVENT_CONSTRAINT(0x0300, 2),  /* CPU_CLK_UNHALTED.REF */
INTEL_UEVENT_CONSTRAINT(0x1c0, 0x2),/* INST_RETIRED.PREC_DIST */
+
+   /*
+* when HT is off, these can only run on the bottom 4 counters
+*/
+   INTEL_EVENT_CONSTRAINT(0xd0, 0xf),  /* MEM_INST_RETIRED.* */
+   INTEL_EVENT_CONSTRAINT(0xd1, 0xf),  /* MEM_LOAD_RETIRED.* */
+   INTEL_EVENT_CONSTRAINT(0xd2, 0xf),  /* MEM_LOAD_L3_HIT_RETIRED.* */
+   INTEL_EVENT_CONSTRAINT(0xcd, 0xf),  /* MEM_TRANS_RETIRED.* */
+   INTEL_EVENT_CONSTRAINT(0xc6, 0xf),  /* FRONTEND_RETIRED.* */
+
EVENT_CONSTRAINT_END
 };
 
@@ -250,6 +268,10 @@ static struct event_constraint 
intel_hsw_event_constraints[] = {
/* CYCLE_ACTIVITY.CYCLES_NO_EXECUTE */
INTEL_UEVENT_CONSTRAINT(0x04a3, 0xf),
 
+   /*
+* When HT is off these events can only run on the bottom 4 counters
+* When HT is on, they are impacted by the HT bug and require EXCL 
access
+*/
INTEL_EXCLEVT_CONSTRAINT(0xd0, 0xf), /* MEM_UOPS_RETIRED.* */
INTEL_EXCLEVT_CONSTRAINT(0xd1, 0xf), /* MEM_LOAD_UOPS_RETIRED.* */
INTEL_EXCLEVT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* 
*/
@@ -264,6 +286,13 @@ struct event_constraint intel_bdw_event_constraints[] = {
FIXED_EVENT_CONSTRAINT(0x0300, 2),  /* CPU_CLK_UNHALTED.REF */
INTEL_UEVENT_CONSTRAINT(0x148, 0x4),/* L1D_PEND_MISS.PENDING */
INTEL_UBIT_EVENT_CONSTRAINT(0x8a3, 0x4),/* 
CYCLE_ACTIVITY.CYCLES_L1D_MISS */
+   /*
+* when HT is off, these can only run on the bottom 4 counters
+*/
+   INTEL_EVENT_CONSTRAINT(0xd0, 0xf),  /* MEM_INST_RETIRED.* */
+   INTEL_EVENT_CONSTRAINT(0xd1, 0xf),  /* MEM_LOAD_RETIRED.* */
+   INTEL_EVENT_CONSTRAINT(0xd2, 0xf),  /* MEM_LOAD_L3_HIT_RETIRED.* */
+   INTEL_EVENT_CONSTRAINT(0xcd, 0xf),  /* MEM_TRANS_RETIRED.* */
EVENT_CONSTRAINT_END
 };
 


Re: [PATCH 1/4] net: ethernet: ti: davinci_cpdma: split descs num between all channels

2016-07-03 Thread Ivan Khoronzhuk


On 01.07.16 23:35, David Miller wrote:

From: Ivan Khoronzhuk 
Date: Thu, 30 Jun 2016 22:04:35 +0300


@@ -720,7 +763,7 @@ unlock_ret:
  }
  EXPORT_SYMBOL_GPL(cpdma_chan_submit);

-bool cpdma_check_free_tx_desc(struct cpdma_chan *chan)
+inline bool cpdma_check_free_desc(struct cpdma_chan *chan)
  {


This needs to be marked static.


Yes. Will correct it.

--
Regards,
Ivan Khoronzhuk


Re: [PATCHv4 1/1] thermal: core: call thermal_zone_device_update() after mode update

2016-07-03 Thread Peter Feuerer
Hi,

23. Juni 2016 06:52 Uhr, "Darren Hart"  schrieb:
> On Wed, Jun 22, 2016 at 08:03:18AM -0700, Eduardo Valentin wrote:
> 
>> Because several drivers do the following pattern:
>> .set_mode()
>> ...
>> local_data->mode = new_mode;
>> thermal_zone_device_update(tz);
>> 
>> makes sense to simply do the thermal_zone_device_update()
>> in thermal core, after setting the new mode.
>> 
>> Also, this patch also remove deadlocks on drivers that
>> call thermal_zone_device_update() on .set_mode(),
>> as .set_mode() is now called always with tz->lock held.
>> 
>> Cc: "Rafael J. Wysocki" 
>> Cc: Len Brown 
>> Cc: linux-a...@vger.kernel.org
>> Cc: "Lee, Chun-Yi" 
>> Cc: Darren Hart 
>> Cc: Zhang Rui 
>> Cc: Keerthy 
>> Cc: linux-kernel@vger.kernel.org
>> Cc: linux-o...@vger.kernel.org
>> Cc: platform-driver-...@vger.kernel.org
>> Cc: linux...@vger.kernel.org
>> Signed-off-by: Eduardo Valentin 
> 
> +Peter Feuerer 
> 
> Peter, any concerns regarding the acerhdf driver?

Yes, please see below.



>> ---
>> Hello,
>> 
>> V3->V4:
>> - ti-soc: Removed extra locking from TI SoC in set_mode
>> - ACPI: Kept the update on check as it is called on other places
>> 
>> BR,
>> 
>> Eduardo
>> 
>> drivers/acpi/thermal.c | 1 -
>> drivers/platform/x86/acerhdf.c | 1 -
>> drivers/thermal/imx_thermal.c | 1 -
>> drivers/thermal/of-thermal.c | 5 -
>> drivers/thermal/thermal_sysfs.c | 1 +

This file does not exist in Linus git master branch.  Which git repo / branch 
do you base your changes on?  Or are there any patches I need to apply first?


>> drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 5 -
>> 6 files changed, 1 insertion(+), 13 deletions(-)
>> 
>> diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
>> index 82707f9..03c3460 100644
>> --- a/drivers/acpi/thermal.c
>> +++ b/drivers/acpi/thermal.c
>> @@ -581,7 +581,6 @@ static int thermal_set_mode(struct thermal_zone_device 
>> *thermal,
>> ACPI_DEBUG_PRINT((ACPI_DB_INFO,
>> "%s kernel ACPI thermal control\n",
>> tz->tz_enabled ? "Enable" : "Disable"));
>> - acpi_thermal_check(tz);
>> }
>> return 0;
>> }
>> diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
>> index 460fa67..aee33ba 100644
>> --- a/drivers/platform/x86/acerhdf.c
>> +++ b/drivers/platform/x86/acerhdf.c
>> @@ -405,7 +405,6 @@ static inline void acerhdf_enable_kernelmode(void)
>> kernelmode = 1;
>> 
>> thz_dev->polling_delay = interval*1000;
>> - thermal_zone_device_update(thz_dev);

This call is used to inform the thermal zone about the changed polling_delay 
from 0 (polling disabled) to some user defined interval at runtime - not 
initialization time.
>From just reading your patch I don't understand, how this is intended to work 
>afterwards.  - I'm clearly missing some further info / patches to give my ok.


>> pr_notice("kernel mode fan control ON\n");
>> }
>> 
>> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
>> index c5547bd..a413eb6 100644
>> --- a/drivers/thermal/imx_thermal.c
>> +++ b/drivers/thermal/imx_thermal.c
>> @@ -246,7 +246,6 @@ static int imx_set_mode(struct thermal_zone_device *tz,
>> }
>> 
>> data->mode = mode;
>> - thermal_zone_device_update(tz);
>> 
>> return 0;
>> }
>> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
>> index b8e509c..95c47da 100644
>> --- a/drivers/thermal/of-thermal.c
>> +++ b/drivers/thermal/of-thermal.c
>> @@ -282,17 +282,12 @@ static int of_thermal_set_mode(struct 
>> thermal_zone_device *tz,
>> {
>> struct __thermal_zone *data = tz->devdata;
>> 
>> - mutex_lock(&tz->lock);
>> -
>> if (mode == THERMAL_DEVICE_ENABLED)
>> tz->polling_delay = data->polling_delay;
>> else
>> tz->polling_delay = 0;
>> 
>> - mutex_unlock(&tz->lock);
>> -
>> data->mode = mode;
>> - thermal_zone_device_update(tz);
>> 
>> return 0;
>> }
>> diff --git a/drivers/thermal/thermal_sysfs.c 
>> b/drivers/thermal/thermal_sysfs.c
>> index 743df50..3d0dc30 100644
>> --- a/drivers/thermal/thermal_sysfs.c
>> +++ b/drivers/thermal/thermal_sysfs.c
>> @@ -100,6 +100,7 @@ mode_store(struct device *dev, struct device_attribute 
>> *attr,
>> mutex_lock(&tz->lock);
>> result = tz->ops->set_mode(tz, mode);
>> mutex_unlock(&tz->lock);
>> + thermal_zone_device_update(tz);
>> 
>> if (result)
>> return result;
>> diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
>> b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
>> index 15c0a9a..5dce053 100644
>> --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
>> +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
>> @@ -193,19 +193,14 @@ static int ti_thermal_set_mode(struct 
>> thermal_zone_device *thermal,
>> return 0;
>> }
>> 
>> - mutex_lock(&data->ti_thermal->lock);
>> -
>> if (mode == THERMAL_DEVICE_ENABLED)
>> data->ti_thermal->polling_delay = FAST_TEMP_MONITORING_RATE;
>> else
>> data->ti_thermal->polling_delay = 0;
>> 
>> - mutex_unlock(&data->ti_thermal->lock);
>> -
>> data->mode = mode;
>> ti_bandgap_write_update_interval(bgp, data->sensor_id,
>> d

Re: [PATCH v2] drivers:iio:light:isl29125: added macros for sensing range

2016-07-03 Thread Jonathan Cameron
On 27/06/16 16:37, Bijosh Thykkoottathil wrote:
> Added macros for sensing range as the corresponding magic numbers
> were used at multiple places.
>- ISL29125_SENSING_RANGE_0 for 375 lux full range
>- ISL29125_SENSING_RANGE_1 for 10k lux full range
> 
> Signed-off-by: Bijosh Thykkoottathil 
Applied to the togreg branch of iio.git. Initially pushed out
as testing for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/light/isl29125.c | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c
> index e2945a2..d0aa802 100644
> --- a/drivers/iio/light/isl29125.c
> +++ b/drivers/iio/light/isl29125.c
> @@ -44,6 +44,9 @@
>  #define ISL29125_MODE_B 0x3
>  #define ISL29125_MODE_RGB 0x5
>  
> +#define ISL29125_SENSING_RANGE_0 5722   /* 375 lux full range */
> +#define ISL29125_SENSING_RANGE_1 152590 /* 10k lux full range */
> +
>  #define ISL29125_MODE_RANGE BIT(3)
>  
>  #define ISL29125_STATUS_CONV BIT(1)
> @@ -140,9 +143,9 @@ static int isl29125_read_raw(struct iio_dev *indio_dev,
>   case IIO_CHAN_INFO_SCALE:
>   *val = 0;
>   if (data->conf1 & ISL29125_MODE_RANGE)
> - *val2 = 152590; /* 10k lux full range */
> + *val2 = ISL29125_SENSING_RANGE_1; /*10k lux full range*/
>   else
> - *val2 = 5722; /* 375 lux full range */
> + *val2 = ISL29125_SENSING_RANGE_0; /*375 lux full range*/
>   return IIO_VAL_INT_PLUS_MICRO;
>   }
>   return -EINVAL;
> @@ -158,9 +161,9 @@ static int isl29125_write_raw(struct iio_dev *indio_dev,
>   case IIO_CHAN_INFO_SCALE:
>   if (val != 0)
>   return -EINVAL;
> - if (val2 == 152590)
> + if (val2 == ISL29125_SENSING_RANGE_1)
>   data->conf1 |= ISL29125_MODE_RANGE;
> - else if (val2 == 5722)
> + else if (val2 == ISL29125_SENSING_RANGE_0)
>   data->conf1 &= ~ISL29125_MODE_RANGE;
>   else
>   return -EINVAL;
> 



Re: [PATCH v2 3/4] iio: potentiometer: mcp4531: Add device tree binding

2016-07-03 Thread Jonathan Cameron
On 27/06/16 06:30, Florian Vaussard wrote:
> Hi Peter,
> 
> Le 27. 06. 16 à 00:12, Peter Rosin a écrit :
>> Hi Florian,
>>
>> On 2016-06-26 22:22, Florian Vaussard wrote:
>>> This patch adds the necessary device tree binding to allow DT probing of
>>> currently supported parts.
>>>
>>> Signed-off-by: Florian Vaussard 
>>> ---
>>>  drivers/iio/potentiometer/mcp4531.c | 273 
>>> +++-
>>>  1 file changed, 272 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/iio/potentiometer/mcp4531.c 
>>> b/drivers/iio/potentiometer/mcp4531.c
>>> index 2251173..bf7b853 100644
>>> --- a/drivers/iio/potentiometer/mcp4531.c
>>> +++ b/drivers/iio/potentiometer/mcp4531.c
>>> @@ -31,6 +31,8 @@
>>>  #include 
>>>  #include 
>>>  #include 
>>> +#include 
>>> +#include 
>>>  
>>>  #include 
>>>  
>>> @@ -188,12 +190,275 @@ static const struct iio_info mcp4531_info = {
>>> .driver_module = THIS_MODULE,
>>>  };
>>>  
>>> +#ifdef CONFIG_OF
>>> +static const struct of_device_id mcp4531_of_match[] = {
>>> +   {
>>> +   .compatible = "microchip,mcp4531-502",
>>> +   .data = &mcp4531_cfg[MCP453x_502]
>>> +   },
>>
>> All this vertical whitespace makes this unreadable. I'd be
>> happier with either ignoring the 80 char rule, or skipping
>> the leading tab. I.e.
>>
>>  { .compatible = "microchip,mcp4531-502", .data = 
>> &mcp4531_cfg[MCP453x_502] },
>>  { .compatible = "microchip,mcp4531-103", .data = 
>> &mcp4531_cfg[MCP453x_103] },
>>  { .compatible = "microchip,mcp4531-503", .data = 
>> &mcp4531_cfg[MCP453x_503] },
>>  ...
>>
>> or
>>
>> { .compatible = "microchip,mcp4531-502", .data = &mcp4531_cfg[MCP453x_502] },
>> { .compatible = "microchip,mcp4531-103", .data = &mcp4531_cfg[MCP453x_103] },
>> { .compatible = "microchip,mcp4531-503", .data = &mcp4531_cfg[MCP453x_503] },
>> ...
>>
>> Or perhaps using a macro?
>>
>> #define MCP4531_COMPATIBLE(of_compatible, cfg) { \
>>  .compatible = of_compatible,\
>>  .data = &mcp4531_cfg[cfg],  \
>> }
>>
>> and then
>>
>>  MCP4531_COMPATIBLE("microchip,mcp4531-502", MCP453x_502),
>>  MCP4531_COMPATIBLE("microchip,mcp4531-103", MCP453x_103),
>>  MCP4531_COMPATIBLE("microchip,mcp4531-503", MCP453x_503),
>>  ...
>>
>> Pick any of those, and you have my ack. Maybe Jonathan has an opinion
>> on which is best?
>>
> 
> The macro is my preferred one, as it makes things easier to read. Jonathan?
I'm fine with any of the options (or indeed the original line break heavy
approach). Take your pick!

Jonathan
> 
> Thanks for the suggestion!
> 
> Best,
> Florian
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



Re: [PATCH v4 10/29] x86/die: Don't try to recover from an OOPS on a non-default stack

2016-07-03 Thread Borislav Petkov
On Sat, Jul 02, 2016 at 01:34:51PM -0500, Josh Poimboeuf wrote:
> The existing 'object_is_on_stack()' can probably be used:
> 
>   if (!object_is_on_stack(current_top_of_stack()))
>   panic("...");
> 
> Though that function isn't quite accurately named.  It should really
> have 'task_stack' in its name, like 'object_is_on_task_stack()'.  Or
> even better, something more concise like 'on_task_stack()'.

So I'm obviously missing something here:

object_is_on_stack() uses task_stack_page(current) -> task_struct.stack
while current_stack_pointer() reads %rsp directly.

I'm guessing %rsp and task_struct.stack are in sync?

-- 
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.


Re: [RFC PATCH] media: s5p-mfc - remove vidioc_g_crop

2016-07-03 Thread Hans Verkuil
Hi Nicolas,

On 07/02/2016 10:29 PM, Nicolas Dufresne wrote:
> 
> Le 30 juin 2016 5:35 PM, "Shuah Khan"  > a écrit :
>>
>> Remove vidioc_g_crop() from s5p-mfc decoder. Without its s_crop counterpart
>> g_crop is not useful. Delete it.
> 
> G_CROP tell the userspace which portion of the output is to be displayed. 
> Example,  1920x1080 inside a buffer of 1920x1088. It can be
> implemented using G_SELECTION too, which emulate G_CROP. removing this 
> without implementing G_SEKECTION will break certain software like
> GStreamer v4l2 based decoder.

Sorry, but this is not correct.

G_CROP for VIDEO_OUTPUT returns the output *compose* rectangle, not the output
crop rectangle.

Don't blame me, this is how it was defined in V4L2. The problem is that for 
video
output (esp. m2m devices) you usually want to set the crop rectangle, and that's
why the selection API was added so you can unambiguously set the crop and 
compose
rectangles for both capture and output.

Unfortunately, the exynos drivers were written before the G/S_SELECTION API was
created, and the crop ioctls in the video output drivers actually set the output
crop rectangle instead of the compose rectangle :-(

This is a known inconsistency.

You are right though that we can't remove g_crop here, I had forgotten about the
buffer padding.

What should happen here is that g_selection support is added to s5p-mfc, and
have that return the proper rectangles. The g_crop can be kept, and a comment
should be added that it returns the wrong thing, but that that is needed for
backwards compat.

The gstreamer code should use g/s_selection if available. It should check how it
is using g/s_crop for video output devices today and remember that for output
devices g/s_crop is really g/s_compose, except for the exynos drivers.

It's why I recommend the selection API since it doesn't have these problems.

I think I should do another push towards implementing the selection API in all
drivers. There aren't many left.

Regards,

Hans


Re: [PATCH v4 1/3] Documentation: DT: Add iproc-static-adc binding

2016-07-03 Thread Jonathan Cameron
On 28/06/16 22:06, Rob Herring wrote:
> On Tue, Jun 28, 2016 at 01:10:34PM +0530, Raveendra Padasalagi wrote:
>> The patch adds devicetree binding document for broadcom's
>> iproc-static-adc controller driver.
>>
>> Signed-off-by: Raveendra Padasalagi 
>> Reviewed-by: Ray Jui 
>> Reviewed-by: Scott Branden 
>> ---
>>  .../bindings/iio/adc/brcm,iproc-static-adc.txt | 41 
>> ++
>>  1 file changed, 41 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
> 
> Acked-by: Rob Herring 
Thanks Rob for your review (sometimes I think I don't express often enough
how helpful device tree binding reviews are in general!)

Applied to the togreg branch of iio.git - initially pushed out as testing for
the autobuilders to ignore it completely ;)

Jonathan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



Re: [PATCH v4 2/3] iio: Add driver for Broadcom iproc-static-adc

2016-07-03 Thread Jonathan Cameron
On 28/06/16 08:40, Raveendra Padasalagi wrote:
> This patch adds basic driver implementation for Broadcom's
> static adc controller used in iProc SoC's family.
> 
> Signed-off-by: Raveendra Padasalagi 
> Reviewed-by: Ray Jui 
> Reviewed-by: Scott Branden 
Looks good to me.

Applied to the togreg branch of iio.git -- initially pushed out as
testing for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/adc/Kconfig |  12 +
>  drivers/iio/adc/Makefile|   1 +
>  drivers/iio/adc/bcm_iproc_adc.c | 644 
> 
>  3 files changed, 657 insertions(+)
>  create mode 100644 drivers/iio/adc/bcm_iproc_adc.c
> 
> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index 25378c5..1de31bd 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -153,6 +153,18 @@ config AXP288_ADC
> To compile this driver as a module, choose M here: the module will be
> called axp288_adc.
>  
> +config BCM_IPROC_ADC
> + tristate "Broadcom IPROC ADC driver"
> + depends on ARCH_BCM_IPROC || COMPILE_TEST
> + depends on MFD_SYSCON
> + default ARCH_BCM_CYGNUS
> + help
> +   Say Y here if you want to add support for the Broadcom static
> +   ADC driver.
> +
> +   Broadcom iProc ADC driver. Broadcom iProc ADC controller has 8
> +   channels. The driver allows the user to read voltage values.
> +
>  config BERLIN2_ADC
>   tristate "Marvell Berlin2 ADC driver"
>   depends on ARCH_BERLIN
> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
> index 38638d4..0ba0d50 100644
> --- a/drivers/iio/adc/Makefile
> +++ b/drivers/iio/adc/Makefile
> @@ -16,6 +16,7 @@ obj-$(CONFIG_AD799X) += ad799x.o
>  obj-$(CONFIG_AT91_ADC) += at91_adc.o
>  obj-$(CONFIG_AT91_SAMA5D2_ADC) += at91-sama5d2_adc.o
>  obj-$(CONFIG_AXP288_ADC) += axp288_adc.o
> +obj-$(CONFIG_BCM_IPROC_ADC) += bcm_iproc_adc.o
>  obj-$(CONFIG_BERLIN2_ADC) += berlin2-adc.o
>  obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o
>  obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o
> diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
> new file mode 100644
> index 000..21d38c8
> --- /dev/null
> +++ b/drivers/iio/adc/bcm_iproc_adc.c
> @@ -0,0 +1,644 @@
> +/*
> + * Copyright 2016 Broadcom
> + *
> + * 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 (the "GPL").
> + *
> + * 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 version 2 (GPLv2) for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * version 2 (GPLv2) along with this source code.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +/* Below Register's are common to IPROC ADC and Touchscreen IP */
> +#define IPROC_REGCTL10x00
> +#define IPROC_REGCTL20x04
> +#define IPROC_INTERRUPT_THRES0x08
> +#define IPROC_INTERRUPT_MASK 0x0c
> +#define IPROC_INTERRUPT_STATUS   0x10
> +#define IPROC_ANALOG_CONTROL 0x1c
> +#define IPROC_CONTROLLER_STATUS  0x14
> +#define IPROC_AUX_DATA   0x20
> +#define IPROC_SOFT_BYPASS_CONTROL0x38
> +#define IPROC_SOFT_BYPASS_DATA   0x3C
> +
> +/* IPROC ADC Channel register offsets */
> +#define IPROC_ADC_CHANNEL_REGCTL10x800
> +#define IPROC_ADC_CHANNEL_REGCTL20x804
> +#define IPROC_ADC_CHANNEL_STATUS 0x808
> +#define IPROC_ADC_CHANNEL_INTERRUPT_STATUS   0x80c
> +#define IPROC_ADC_CHANNEL_INTERRUPT_MASK 0x810
> +#define IPROC_ADC_CHANNEL_DATA   0x814
> +#define IPROC_ADC_CHANNEL_OFFSET 0x20
> +
> +/* Bit definitions for IPROC_REGCTL2 */
> +#define IPROC_ADC_AUXIN_SCAN_ENA BIT(0)
> +#define IPROC_ADC_PWR_LDOBIT(5)
> +#define IPROC_ADC_PWR_ADCBIT(4)
> +#define IPROC_ADC_PWR_BG BIT(3)
> +#define IPROC_ADC_CONTROLLER_EN  BIT(17)
> +
> +/* Bit definitions for IPROC_INTERRUPT_MASK and IPROC_INTERRUPT_STATUS */
> +#define IPROC_ADC_AUXDATA_RDY_INTR   BIT(3)
> +#define IPROC_ADC_INTR   9
> +#define IPROC_ADC_INTR_MASK  (0xFF << IPROC_ADC_INTR)
> +
> +/* Bit definitions for IPROC_ANALOG_CONTROL */
> +#define IPROC_ADC_CHANNEL_SEL11
> +#define IPROC_ADC_CHANNEL_SEL_MASK   (0x7 << IPROC_ADC_CHANNEL_SEL)
> +
> +/* Bit definitions for IPROC_ADC_CHANNEL_REGCTL1 */
> +#define IPROC_ADC_CHANNEL_ROUNDS 0x2
> +#define IPROC_ADC_CHANNEL_ROUNDS_MASK(0x3F << 
> IPROC_ADC_CHANNEL_

Re: [PATCH v4 3/3] ARM:dts-Add dt node for Broadcom iproc-static-adc

2016-07-03 Thread Jonathan Cameron
On 28/06/16 08:40, Raveendra Padasalagi wrote:
> This patch adds DT node for Broadcom's iproc-static-adc
> controller driver.
> 
> Signed-off-by: Raveendra Padasalagi 
> Reviewed-by: Ray Jui 
> Reviewed-by: Scott Branden 
Driver is working its way towards just making the next merge window...

Guessing this will go through the relevant path to the arm-soc tree
as normal.

Thanks,

Jonathan
> ---
>  arch/arm/boot/dts/bcm-cygnus.dtsi | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi 
> b/arch/arm/boot/dts/bcm-cygnus.dtsi
> index b42fe55..fabc9f3 100644
> --- a/arch/arm/boot/dts/bcm-cygnus.dtsi
> +++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
> @@ -366,5 +366,16 @@
>   interrupts = ;
>   status = "disabled";
>   };
> +
> + adc: adc@180a6000 {
> + compatible = "brcm,iproc-static-adc";
> + #io-channel-cells = <1>;
> + io-channel-ranges;
> + adc-syscon = <&ts_adc_syscon>;
> + clocks = <&asiu_clks BCM_CYGNUS_ASIU_ADC_CLK>;
> + clock-names = "tsc_clk";
> + interrupts = ;
> + status = "disabled";
> + };
>   };
>  };
> 



Re: [PATCH v3 2/2] iio: adc: max1363: Add device tree binding

2016-07-03 Thread Jonathan Cameron
On 30/06/16 08:43, Florian Vaussard wrote:
> This patch adds the necessary device tree binding to allow DT probing of
> currently supported parts.
> 
> Signed-off-by: Florian Vaussard 
Applied.  Thanks.

Jonathan
> ---
>  drivers/iio/adc/max1363.c | 61 
> ++-
>  1 file changed, 60 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c
> index b5d28c0..c3e4c3c 100644
> --- a/drivers/iio/adc/max1363.c
> +++ b/drivers/iio/adc/max1363.c
> @@ -25,6 +25,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  
>  #include 
>  #include 
> @@ -1516,6 +1518,56 @@ done:
>   return IRQ_HANDLED;
>  }
>  
> +#ifdef CONFIG_OF
> +
> +#define MAX1363_COMPATIBLE(of_compatible, cfg) { \
> + .compatible = of_compatible,\
> + .data = &max1363_chip_info_tbl[cfg],\
> +}
> +
> +static const struct of_device_id max1363_of_match[] = {
> + MAX1363_COMPATIBLE("maxim,max1361", max1361),
> + MAX1363_COMPATIBLE("maxim,max1362", max1362),
> + MAX1363_COMPATIBLE("maxim,max1363", max1363),
> + MAX1363_COMPATIBLE("maxim,max1364", max1364),
> + MAX1363_COMPATIBLE("maxim,max1036", max1036),
> + MAX1363_COMPATIBLE("maxim,max1037", max1037),
> + MAX1363_COMPATIBLE("maxim,max1038", max1038),
> + MAX1363_COMPATIBLE("maxim,max1039", max1039),
> + MAX1363_COMPATIBLE("maxim,max1136", max1136),
> + MAX1363_COMPATIBLE("maxim,max1137", max1137),
> + MAX1363_COMPATIBLE("maxim,max1138", max1138),
> + MAX1363_COMPATIBLE("maxim,max1139", max1139),
> + MAX1363_COMPATIBLE("maxim,max1236", max1236),
> + MAX1363_COMPATIBLE("maxim,max1237", max1237),
> + MAX1363_COMPATIBLE("maxim,max1238", max1238),
> + MAX1363_COMPATIBLE("maxim,max1239", max1239),
> + MAX1363_COMPATIBLE("maxim,max11600", max11600),
> + MAX1363_COMPATIBLE("maxim,max11601", max11601),
> + MAX1363_COMPATIBLE("maxim,max11602", max11602),
> + MAX1363_COMPATIBLE("maxim,max11603", max11603),
> + MAX1363_COMPATIBLE("maxim,max11604", max11604),
> + MAX1363_COMPATIBLE("maxim,max11605", max11605),
> + MAX1363_COMPATIBLE("maxim,max11606", max11606),
> + MAX1363_COMPATIBLE("maxim,max11607", max11607),
> + MAX1363_COMPATIBLE("maxim,max11608", max11608),
> + MAX1363_COMPATIBLE("maxim,max11609", max11609),
> + MAX1363_COMPATIBLE("maxim,max11610", max11610),
> + MAX1363_COMPATIBLE("maxim,max11611", max11611),
> + MAX1363_COMPATIBLE("maxim,max11612", max11612),
> + MAX1363_COMPATIBLE("maxim,max11613", max11613),
> + MAX1363_COMPATIBLE("maxim,max11614", max11614),
> + MAX1363_COMPATIBLE("maxim,max11615", max11615),
> + MAX1363_COMPATIBLE("maxim,max11616", max11616),
> + MAX1363_COMPATIBLE("maxim,max11617", max11617),
> + MAX1363_COMPATIBLE("maxim,max11644", max11644),
> + MAX1363_COMPATIBLE("maxim,max11645", max11645),
> + MAX1363_COMPATIBLE("maxim,max11646", max11646),
> + MAX1363_COMPATIBLE("maxim,max11647", max11647),
> + { /* sentinel */ }
> +};
> +#endif
> +
>  static int max1363_probe(struct i2c_client *client,
>const struct i2c_device_id *id)
>  {
> @@ -1523,6 +1575,7 @@ static int max1363_probe(struct i2c_client *client,
>   struct max1363_state *st;
>   struct iio_dev *indio_dev;
>   struct regulator *vref;
> + const struct of_device_id *match;
>  
>   indio_dev = devm_iio_device_alloc(&client->dev,
> sizeof(struct max1363_state));
> @@ -1549,7 +1602,12 @@ static int max1363_probe(struct i2c_client *client,
>   /* this is only used for device removal purposes */
>   i2c_set_clientdata(client, indio_dev);
>  
> - st->chip_info = &max1363_chip_info_tbl[id->driver_data];
> + match = of_match_device(of_match_ptr(max1363_of_match),
> + &client->dev);
> + if (match)
> + st->chip_info = of_device_get_match_data(&client->dev);
> + else
> + st->chip_info = &max1363_chip_info_tbl[id->driver_data];
>   st->client = client;
>  
>   st->vref_uv = st->chip_info->int_vref_mv * 1000;
> @@ -1692,6 +1750,7 @@ MODULE_DEVICE_TABLE(i2c, max1363_id);
>  static struct i2c_driver max1363_driver = {
>   .driver = {
>   .name = "max1363",
> + .of_match_table = of_match_ptr(max1363_of_match),
>   },
>   .probe = max1363_probe,
>   .remove = max1363_remove,
> 



Re: [PATCH v3 1/2] iio: adc: max1363: Add device tree binding documentation

2016-07-03 Thread Jonathan Cameron
On 30/06/16 08:43, Florian Vaussard wrote:
> Add the device tree documentation for all the supported parts. Mandatory
> binding is the compatible string and the slave I2C address.
> 
> Optional properties can be used to specify the Vcc / Vref regulators, as
> well as the IRQ line if available.
> 
> Acked-by: Rob Herring 
> Signed-off-by: Florian Vaussard 
Really small point, but typically author sign off goes first then acks etc
that are gained at any intermediate states, then the sign off of whoever takes
the patch and applies it (here, that's me).  So it kind of communicates some
idea of when in the process various tags were obtained.  It's not a rule
set in stone though so I'll be lazy and leave this as it is.

Anyhow, great and applied to the togreg branch of iio.git initially pushed
out as testing for the autobuilders to poke it (or not in the case of this
docume

Jonathan
> ---
>  .../devicetree/bindings/iio/adc/max1363.txt| 63 
> ++
>  1 file changed, 63 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/adc/max1363.txt
> 
> diff --git a/Documentation/devicetree/bindings/iio/adc/max1363.txt 
> b/Documentation/devicetree/bindings/iio/adc/max1363.txt
> new file mode 100644
> index 000..94a9011
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/adc/max1363.txt
> @@ -0,0 +1,63 @@
> +* Maxim 1x3x/136x/116xx Analog to Digital Converter (ADC)
> +
> +The node for this driver must be a child node of a I2C controller, hence
> +all mandatory properties for your controller must be specified. See 
> directory:
> +
> +Documentation/devicetree/bindings/i2c
> +
> +for more details.
> +
> +Required properties:
> +  - compatible: Should be one of
> + "maxim,max1361"
> + "maxim,max1362"
> + "maxim,max1363"
> + "maxim,max1364"
> + "maxim,max1036"
> + "maxim,max1037"
> + "maxim,max1038"
> + "maxim,max1039"
> + "maxim,max1136"
> + "maxim,max1137"
> + "maxim,max1138"
> + "maxim,max1139"
> + "maxim,max1236"
> + "maxim,max1237"
> + "maxim,max1238"
> + "maxim,max1239"
> + "maxim,max11600"
> + "maxim,max11601"
> + "maxim,max11602"
> + "maxim,max11603"
> + "maxim,max11604"
> + "maxim,max11605"
> + "maxim,max11606"
> + "maxim,max11607"
> + "maxim,max11608"
> + "maxim,max11609"
> + "maxim,max11610"
> + "maxim,max11611"
> + "maxim,max11612"
> + "maxim,max11613"
> + "maxim,max11614"
> + "maxim,max11615"
> + "maxim,max11616"
> + "maxim,max11617"
> + "maxim,max11644"
> + "maxim,max11645"
> + "maxim,max11646"
> + "maxim,max11647"
> +  - reg: Should contain the ADC I2C address
> +
> +Optional properties:
> +  - vcc-supply: phandle to the regulator that provides power to the ADC.
> +  - vref-supply: phandle to the regulator for ADC reference voltage.
> +  - interrupts: IRQ line for the ADC. If not used the driver will use
> +polling.
> +
> +Example:
> +adc: max11644@36 {
> + compatible = "maxim,max11644";
> + reg = <0x36>;
> + vref-supply = <&adc_vref>;
> +};
> 



Re: [3/3] hwmon: iio_hwmon: defer probe when no channel is found

2016-07-03 Thread Jonathan Cameron
On 30/06/16 15:51, Guenter Roeck wrote:
> On 06/30/2016 06:59 AM, Jonathan Cameron wrote:
>>
>>
>> On 30 June 2016 04:47:25 BST, Guenter Roeck  wrote:
>>> On Tue, Jun 28, 2016 at 10:18:17AM +0200, Quentin Schulz wrote:
 iio_channel_get_all returns -ENODEV when it cannot find either
>>> phandles and
 properties in the Device Tree or channels whose consumer_dev_name
>>> matches
 iio_hwmon in iio_map_list. The iio_map_list is filled in by iio
>>> drivers
 which might be probed after iio_hwmon.

 It is better to defer the probe of iio_hwmon if such error is
>>> returned by
 iio_channel_get_all in order to let a chance to iio drivers to expose
 channels in iio_map_list.

 Signed-off-by: Quentin Schulz 
 ---
   drivers/hwmon/iio_hwmon.c | 5 -
   1 file changed, 4 insertions(+), 1 deletion(-)

 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
 index b550ba5..c0da4d9 100644
 --- a/drivers/hwmon/iio_hwmon.c
 +++ b/drivers/hwmon/iio_hwmon.c
 @@ -73,8 +73,11 @@ static int iio_hwmon_probe(struct platform_device
>>> *pdev)
   name = dev->of_node->name;

   channels = iio_channel_get_all(dev);
 -if (IS_ERR(channels))
 +if (IS_ERR(channels)) {
 +if (PTR_ERR(channels) == -ENODEV)
 +return -EPROBE_DEFER;
>>>
>>> The problem, as I see it, is with iio, which should return
>>> -EPROBE_DEFER
>>> in this situation.
>> Agreed. New fangled stuff this deferred probing :)
>>>
>>> We can not convert -ENODEV to -EPROBE_DEFER without risking that the
>>> channels are _really_ not there, which would result in endless
>>> "deferred"
>>> messages.
>> Hmm not entirely sure how we prevent that happening wherever it is done..
>>
> 
> Outch. Better at the source, though. I didn't look at the iio code recently,
> but can you detect the defer situation at least with devicetree ?
> 
> For non-devicetree situations, the only option I can think of would be
> to replace the module initcall with a later initcall. That should solve
> the problem if both iio_hwmon and and underlying drivers are built
> into the kernel. If iio_hwmon is modular, the only real option I can
> see is to make sure that all drivers it needs are loaded first.
> 
> Does this make sense ?
I think we need to look in a couple of directions.  Firstly, investigate doing
something similar to gpio and basically move the setup of maps much earlier.
This will replace drivers presenting their own maps

The other direction is to get userspace (i.e. configfs) setup of these maps
working so for cases where it's a bit less hardware defined (i.e. using an
accelerometer as an input device) we can do once we know all devices relevant
are present and instantiate new instances on the fly.

Anyhow, neither is trivial unfortunately.

J
> 
> Guenter
> 
>>>
>>> Guenter
>>>
   return PTR_ERR(channels);
 +}

   st = devm_kzalloc(dev, sizeof(*st), GFP_KERNEL);
   if (st == NULL) {
>>> -- 
>>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>>> the body of a message to majord...@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
> 
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



Re: [PATCH v3 1/4] iio: potentiometer: mcp4531: Add support for MCP454x, MCP456x, MCP464x and MCP466x

2016-07-03 Thread Jonathan Cameron
On 30/06/16 08:34, Florian Vaussard wrote:
> This patch adds support for MCP454x, MCP456x, MCP464x and MCP466x parts.
> The main difference with currently supported parts (MCP453x and alike) is
> the addition of a non-volatile memory in order to recall the wiper setting
> at power-on. This feature is currently not supported and only the
> volatile memory is used to set the wiper.
> 
> Acked-by: Peter Rosin 
> Signed-off-by: Florian Vaussard 
Applied to the togreg branch of iio.git - initially pushed out as
testing for all the usual boring reasons (like reviewers aren't
perfect ;)

Jonathan
> ---
>  drivers/iio/potentiometer/Kconfig   |  6 ++--
>  drivers/iio/potentiometer/mcp4531.c | 72 
> +
>  2 files changed, 76 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/potentiometer/Kconfig 
> b/drivers/iio/potentiometer/Kconfig
> index 0941c8d4..55c2414 100644
> --- a/drivers/iio/potentiometer/Kconfig
> +++ b/drivers/iio/potentiometer/Kconfig
> @@ -49,8 +49,10 @@ config MCP4531
>   depends on I2C
>   help
> Say yes here to build support for the Microchip
> -   MCP4531, MCP4532, MCP4551, MCP4552,
> -   MCP4631, MCP4632, MCP4651, MCP4652
> +   MCP4531, MCP4532, MCP4541, MCP4542,
> +   MCP4551, MCP4552, MCP4561, MCP4562,
> +   MCP4631, MCP4632, MCP4641, MCP4642,
> +   MCP4651, MCP4652, MCP4661, MCP4662
> digital potentiomenter chips.
>  
> To compile this driver as a module, choose M here: the
> diff --git a/drivers/iio/potentiometer/mcp4531.c 
> b/drivers/iio/potentiometer/mcp4531.c
> index 3b72e1a..2251173 100644
> --- a/drivers/iio/potentiometer/mcp4531.c
> +++ b/drivers/iio/potentiometer/mcp4531.c
> @@ -8,12 +8,20 @@
>   * DEVID #Wipers #Positions  Resistor Opts (kOhm)i2c address
>   * mcp4531   1   129 5, 10, 50, 100  010111x
>   * mcp4532   1   129 5, 10, 50, 100  01011xx
> + * mcp4541   1   129 5, 10, 50, 100  010111x
> + * mcp4542   1   129 5, 10, 50, 100  01011xx
>   * mcp4551   1   257 5, 10, 50, 100  010111x
>   * mcp4552   1   257 5, 10, 50, 100  01011xx
> + * mcp4561   1   257 5, 10, 50, 100  010111x
> + * mcp4562   1   257 5, 10, 50, 100  01011xx
>   * mcp4631   2   129 5, 10, 50, 100  0101xxx
>   * mcp4632   2   129 5, 10, 50, 100  01011xx
> + * mcp4641   2   129 5, 10, 50, 100  0101xxx
> + * mcp4642   2   129 5, 10, 50, 100  01011xx
>   * mcp4651   2   257 5, 10, 50, 100  0101xxx
>   * mcp4652   2   257 5, 10, 50, 100  01011xx
> + * mcp4661   2   257 5, 10, 50, 100  0101xxx
> + * mcp4662   2   257 5, 10, 50, 100  01011xx
>   *
>   * 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
> @@ -37,18 +45,34 @@ enum mcp4531_type {
>   MCP453x_103,
>   MCP453x_503,
>   MCP453x_104,
> + MCP454x_502,
> + MCP454x_103,
> + MCP454x_503,
> + MCP454x_104,
>   MCP455x_502,
>   MCP455x_103,
>   MCP455x_503,
>   MCP455x_104,
> + MCP456x_502,
> + MCP456x_103,
> + MCP456x_503,
> + MCP456x_104,
>   MCP463x_502,
>   MCP463x_103,
>   MCP463x_503,
>   MCP463x_104,
> + MCP464x_502,
> + MCP464x_103,
> + MCP464x_503,
> + MCP464x_104,
>   MCP465x_502,
>   MCP465x_103,
>   MCP465x_503,
>   MCP465x_104,
> + MCP466x_502,
> + MCP466x_103,
> + MCP466x_503,
> + MCP466x_104,
>  };
>  
>  static const struct mcp4531_cfg mcp4531_cfg[] = {
> @@ -56,18 +80,34 @@ static const struct mcp4531_cfg mcp4531_cfg[] = {
>   [MCP453x_103] = { .wipers = 1, .max_pos = 128, .kohms =  10, },
>   [MCP453x_503] = { .wipers = 1, .max_pos = 128, .kohms =  50, },
>   [MCP453x_104] = { .wipers = 1, .max_pos = 128, .kohms = 100, },
> + [MCP454x_502] = { .wipers = 1, .max_pos = 128, .kohms =   5, },
> + [MCP454x_103] = { .wipers = 1, .max_pos = 128, .kohms =  10, },
> + [MCP454x_503] = { .wipers = 1, .max_pos = 128, .kohms =  50, },
> + [MCP454x_104] = { .wipers = 1, .max_pos = 128, .kohms = 100, },
>   [MCP455x_502] = { .wipers = 1, .max_pos = 256, .kohms =   5, },
>   [MCP455x_103] = { .wipers = 1, .max_pos = 256, .kohms =  10, },
>   [MCP455x_503] = { .wipers = 1, .max_pos = 256, .kohms =  50, },
>   [MCP455x_104] = { .wipers = 1, .max_pos = 256, .kohms = 100, },
> + [MCP456x_502] = { .wipers = 1, .max_pos = 256, .kohms =   5, },
> + [MCP456x_103] = { .wipers = 1, .max_pos = 256, .kohms =  10, },
> + [MCP456x_503] = { .wipers = 1, .max_pos = 256, .kohms =  50, },
> + [MCP456x_104] =

Re: [PATCH v3 2/4] iio: potentiometer: mcp4531: Add device tree binding documentation

2016-07-03 Thread Jonathan Cameron
On 01/07/16 03:19, Rob Herring wrote:
> On Thu, Jun 30, 2016 at 09:34:49AM +0200, Florian Vaussard wrote:
>> Add the device tree documentation for all the supported parts. Apart the
>> compatible string and standard I2C binding, no other binding is currently
>> needed.
>>
>> Signed-off-by: Florian Vaussard 
>> ---
>>  .../devicetree/bindings/i2c/trivial-devices.txt| 64 
>> ++
>>  1 file changed, 64 insertions(+)
> 
> Acked-by: Rob Herring 
Applied. Thanks

Jonathan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



Re: [PATCH v3 3/4] iio: potentiometer: mcp4531: Add device tree binding

2016-07-03 Thread Jonathan Cameron
On 30/06/16 09:09, Florian Vaussard wrote:
> 
> 
> Le 30. 06. 16 à 09:46, Peter Rosin a écrit :
>>
>>
>> On June 30, 2016 9:34:50 AM GMT+02:00, Florian Vaussard 
>>  wrote:
>>> This patch adds the necessary device tree binding to allow DT probing
>>> of
>>> currently supported parts.
>>>
>>> Signed-off-by: Florian Vaussard 
>>
>> Acked-by: Peter Rosin 
>>
> 
> Thanks for your reviews Peter,
> 
Applied and thanks to Peter seconded.

Good little patch set.

Thanks,

Jonathan
> Best,
> Florian
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



Re: [PATCH v3 4/4] iio: potentiometer: Fix typo in Kconfig

2016-07-03 Thread Jonathan Cameron
On 30/06/16 08:34, Florian Vaussard wrote:
> Fix s/potentiomenter/potentiometer/.
> 
> Suggested-by: Peter Meerwald-Stadler 
> Signed-off-by: Florian Vaussard 
Applied.
> ---
>  drivers/iio/potentiometer/Kconfig | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/potentiometer/Kconfig 
> b/drivers/iio/potentiometer/Kconfig
> index 55c2414..2e9da1c 100644
> --- a/drivers/iio/potentiometer/Kconfig
> +++ b/drivers/iio/potentiometer/Kconfig
> @@ -10,7 +10,7 @@ config DS1803
>   depends on I2C
>   help
> Say yes here to build support for the Maxim Integrated DS1803
> -   digital potentiomenter chip.
> +   digital potentiometer chip.
>  
> To compile this driver as a module, choose M here: the
> module will be called ds1803.
> @@ -39,7 +39,7 @@ config MCP4131
> MCP4241, MCP4242,
> MCP4251, MCP4252,
> MCP4261, MCP4262,
> -   digital potentiomenter chips.
> +   digital potentiometer chips.
>  
> To compile this driver as a module, choose M here: the
> module will be called mcp4131.
> @@ -53,7 +53,7 @@ config MCP4531
> MCP4551, MCP4552, MCP4561, MCP4562,
> MCP4631, MCP4632, MCP4641, MCP4642,
> MCP4651, MCP4652, MCP4661, MCP4662
> -   digital potentiomenter chips.
> +   digital potentiometer chips.
>  
> To compile this driver as a module, choose M here: the
> module will be called mcp4531.
> 



Re: [PATCH 1/3] mfd: add support for Allwinner SoCs ADC

2016-07-03 Thread Jonathan Cameron
On 28/06/16 09:18, Quentin Schulz wrote:
> The Allwinner SoCs all have an ADC that can also act as a touchscreen
> controller and a thermal sensor. For now, only the ADC and the thermal
> sensor drivers are probed by the MFD, the touchscreen controller support
> will be added later.
> 
> Signed-off-by: Quentin Schulz 
The code looks fine to me. The 'controversial' bit of this is listing
iio-hwmon as an mfd child to get it to probe as a result of this being
present.  My immediately thought is that it should be separately
described in the devicetree and hence instantiated outside of this driver.

Perhaps you could describe your reasoning for doing it this way?

Thanks,

Jonathan
> ---
>  drivers/mfd/Kconfig |  14 +++
>  drivers/mfd/Makefile|   2 +
>  drivers/mfd/sunxi-gpadc-mfd.c   | 188 
> 
>  include/linux/mfd/sunxi-gpadc-mfd.h |  14 +++
>  4 files changed, 218 insertions(+)
>  create mode 100644 drivers/mfd/sunxi-gpadc-mfd.c
>  create mode 100644 include/linux/mfd/sunxi-gpadc-mfd.h
> 
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index eea61e3..1663db9 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -82,6 +82,20 @@ config MFD_ATMEL_FLEXCOM
> by the probe function of this MFD driver according to a device tree
> property.
>  
> +config MFD_SUNXI_ADC
> + tristate "ADC MFD core driver for sunxi platforms"
> + select MFD_CORE
> + select REGMAP_MMIO
> + help
> +   Select this to get support for Allwinner SoCs (A10, A13 and A31) ADC.
> +   This driver will only map the hardware interrupt and registers, you
> +   have to select individual drivers based on this MFD to be able to use
> +   the ADC or the thermal sensor. This will try to probe the ADC driver
> +   sunxi-gpadc-iio and the hwmon driver iio_hwmon.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called sunxi-gpadc-mfd.
> +
>  config MFD_ATMEL_HLCDC
>   tristate "Atmel HLCDC (High-end LCD Controller)"
>   select MFD_CORE
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index 5eaa6465d..b280d0a 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -199,6 +199,8 @@ obj-$(CONFIG_MFD_DLN2)+= dln2.o
>  obj-$(CONFIG_MFD_RT5033) += rt5033.o
>  obj-$(CONFIG_MFD_SKY81452)   += sky81452.o
>  
> +obj-$(CONFIG_MFD_SUNXI_ADC)  += sunxi-gpadc-mfd.o
> +
>  intel-soc-pmic-objs  := intel_soc_pmic_core.o intel_soc_pmic_crc.o
>  intel-soc-pmic-$(CONFIG_INTEL_PMC_IPC)   += intel_soc_pmic_bxtwc.o
>  obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o
> diff --git a/drivers/mfd/sunxi-gpadc-mfd.c b/drivers/mfd/sunxi-gpadc-mfd.c
> new file mode 100644
> index 000..710e297
> --- /dev/null
> +++ b/drivers/mfd/sunxi-gpadc-mfd.c
> @@ -0,0 +1,188 @@
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define SUNXI_IRQ_FIFO_DATA  0
> +#define SUNXI_IRQ_TEMP_DATA  1
> +
> +static struct resource adc_resources[] = {
> + {
> + .name   = "FIFO_DATA_PENDING",
> + .start  = SUNXI_IRQ_FIFO_DATA,
> + .end= SUNXI_IRQ_FIFO_DATA,
> + .flags  = IORESOURCE_IRQ,
> + }, {
> + .name   = "TEMP_DATA_PENDING",
> + .start  = SUNXI_IRQ_TEMP_DATA,
> + .end= SUNXI_IRQ_TEMP_DATA,
> + .flags  = IORESOURCE_IRQ,
> + },
> +};
> +
> +static const struct regmap_irq sunxi_gpadc_mfd_regmap_irq[] = {
> + REGMAP_IRQ_REG(SUNXI_IRQ_FIFO_DATA, 0, BIT(16)),
> + REGMAP_IRQ_REG(SUNXI_IRQ_TEMP_DATA, 0, BIT(18)),
> +};
> +
> +static const struct regmap_irq_chip sunxi_gpadc_mfd_regmap_irq_chip = {
> + .name = "sunxi_gpadc_mfd_irq_chip",
> + .status_base = TP_INT_FIFOS,
> + .ack_base = TP_INT_FIFOS,
> + .mask_base = TP_INT_FIFOC,
> + .init_ack_masked = true,
> + .mask_invert = true,
> + .irqs = sunxi_gpadc_mfd_regmap_irq,
> + .num_irqs = ARRAY_SIZE(sunxi_gpadc_mfd_regmap_irq),
> + .num_regs = 1,
> +};
> +
> +static struct mfd_cell sun4i_gpadc_mfd_cells[] = {
> + {
> + .name   = "sun4i-a10-gpadc-iio",
> + .resources = adc_resources,
> + .num_resources = ARRAY_SIZE(adc_resources),
> + }, {
> + .name = "iio_hwmon",
> + }
> +};
> +
> +static struct mfd_cell sun5i_gpadc_mfd_cells[] = {
> + {
> + .name   = "sun5i-a13-gpadc-iio",
> + .resources = adc_resources,
> + .num_resources = ARRAY_SIZE(adc_resources),
> + }, {
> + .name = "iio_hwmon",
> + },
> +};
> +
> +static struct mfd_cell sun6i_gpadc_mfd_cells[] = {
> + {
> + .name   = "sun6i-a31-gpadc-iio",
> + .resources = adc_resources,
> + .num_resources = ARRAY_SIZE(adc_resources),
> + }, {
> + .name = "iio_hwmon",
Interesting to pro

core.c:undefined reference to `fpu_save'

2016-07-03 Thread kbuild test robot
Hi,

It's probably a bug fix that unveils the link errors.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   4f302921c1458d790ae21147f7043f4e6b6a1085
commit: c60f169202c7643991a8b4bfeea60e06843d5b5a 
arch/mn10300/kernel/fpu-nofpu.c: needs asm/elf.h
date:   4 months ago
config: mn10300-allnoconfig (attached as .config)
compiler: am33_2.0-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout c60f169202c7643991a8b4bfeea60e06843d5b5a
# save the attached .config to linux build tree
make.cross ARCH=mn10300 

All errors (new ones prefixed by >>):

   kernel/built-in.o: In function `.L412':
>> core.c:(.sched.text+0x257): undefined reference to `fpu_save'

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


.config.gz
Description: Binary data


Re: [PATCH v4 14/22] sh: SH7751 core dtsi

2016-07-03 Thread Yoshinori Sato
On Fri, 01 Jul 2016 17:57:00 +0900,
Geert Uytterhoeven wrote:
> 
> Hi Sato-san,
> 
> On Wed, Jun 29, 2016 at 3:40 PM, Yoshinori Sato
>  wrote:
> > SH7751 core and internal peripheral define.
> 
> Thanks for your patch!
> 
> > Changes v4
> > - remove unneeded #address-cells and #size-cells
> > - add missing dt-binding link
> 
> Please move changelog information below the three dashes...
> 
> >
> > Signed-off-by: Yoshinori Sato 
> > ---
> 
> ... i.e. here.

OK.

> > --- /dev/null
> > +++ b/arch/sh/boot/dts/include/dt-bindings
> > @@ -0,0 +1 @@
> > +../../../../../include/dt-bindings
> > \ No newline at end of file
> 
> Missing newline.

This file is symbolic link.
I think not need newline.

> > --- /dev/null
> > +++ b/arch/sh/boot/dts/sh7751.dtsi
> 
> > +   oclk: oscillator {
> > +#clock-cells = <0>;
> > +compatible = "fixed-clock";
> > +clock-frequency = <0>;
> > +};
> > +   cpg: cpg@ffc0 {
> 
> clock-controller@ffc0

OK.

> > \ No newline at end of file
> 
> Missing newline.

OK.

> Gr{oetje,eeting}s,
> 
> Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds

-- 
Yoshinori Sato



Re: [PATCH v4 21/22] sh: Renesas RTS7751R2Dplus (a,k.a R2Dplus) IRQCHIP Driver

2016-07-03 Thread Yoshinori Sato
On Fri, 01 Jul 2016 10:53:13 +0900,
Rob Herring wrote:
> 
> On Wed, Jun 29, 2016 at 10:41:06PM +0900, Yoshinori Sato wrote:
> > Changes v4
> > - split patch.
> > - remove unneeded #address
> 
> Actually, I think #address-cells is supposed to be set for 
> interrupt-map. It defines the size of the first field.

OK. reverted it.
Thanks.

> Rob

-- 
Yoshinori Sato



Re: [PATCH v4 19/22] sh: IO-DATA HDL-U (a,k.a landisk) IRQCHIP driver

2016-07-03 Thread Yoshinori Sato
On Fri, 01 Jul 2016 10:48:53 +0900,
Rob Herring wrote:
> 
> On Wed, Jun 29, 2016 at 10:41:04PM +0900, Yoshinori Sato wrote:
> > Changes v4
> > - split patches
> > - remove unneeded line
> > - example update
> > 
> > Signed-off-by: Yoshinori Sato 
> > ---
> >  .../interrupt-controller/iodata-landisk.txt| 31 ++
> >  drivers/irqchip/Makefile   |  2 +-
> >  drivers/irqchip/irq-io-landisk.c   | 72 
> > ++
> >  3 files changed, 104 insertions(+), 1 deletion(-)
> >  create mode 100644 
> > Documentation/devicetree/bindings/interrupt-controller/iodata-landisk.txt
> >  create mode 100644 drivers/irqchip/irq-io-landisk.c
> > 
> > diff --git 
> > a/Documentation/devicetree/bindings/interrupt-controller/iodata-landisk.txt 
> > b/Documentation/devicetree/bindings/interrupt-controller/iodata-landisk.txt
> > new file mode 100644
> > index 000..cf461dc
> > --- /dev/null
> > +++ 
> > b/Documentation/devicetree/bindings/interrupt-controller/iodata-landisk.txt
> > @@ -0,0 +1,31 @@
> > +DT bindings for the I/O DATA HDL-U interrupt controller
> > +
> > +Required properties:
> > +
> > +  - compatible: has to be "iodata,landisk-intc".
> > +
> > +  - reg: Base address and length of interrupt controller register.
> > +
> > +  - interrupt-controller: Identifies the node as an interrupt controller.
> > +
> > +  - #interrupt-cells: has to be <1>: an interrupt index.
> > +
> > +  - interrupt-map: Interrupt mapping on parent controller.
> 
> interrupt-controller and interrupt-map are supposed to be mutually 
> exclusive, so you should probably drop interrupt-controller.

Yes. This logic is not interrupt controller.
Remove this line.

> Rob
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Yoshinori Sato



Re: [PATCH RESEND v2] mfd: sm501: Add device property

2016-07-03 Thread Yoshinori Sato
On Fri, 01 Jul 2016 17:59:11 +0900,
Lee Jones wrote:
> 
> On Fri, 01 Jul 2016, Yoshinori Sato wrote:
> 
> > On Thu, 30 Jun 2016 16:48:00 +0900,
> > Lee Jones wrote:
> > > 
> > > On Thu, 30 Jun 2016, Yoshinori Sato wrote:
> > > 
> > > > Signed-off-by: Yoshinori Sato 
> > > > ---
> > > >  Documentation/devicetree/bindings/mfd/sm501.txt | 45 
> > > > +
> > > >  drivers/mfd/sm501.c |  9 +
> > > >  2 files changed, 54 insertions(+)
> > > >  create mode 100644 Documentation/devicetree/bindings/mfd/sm501.txt
> 
> [...]
> 
> > > > diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
> > > > index 65cd0d2..e2e3f9b 100644
> > > > --- a/drivers/mfd/sm501.c
> > > > +++ b/drivers/mfd/sm501.c
> 
> [...]
> 
> > > > @@ -1377,6 +1378,8 @@ static int sm501_plat_probe(struct 
> > > > platform_device *dev)
> > > >  {
> > > > struct sm501_devdata *sm;
> > > > int ret;
> > > > +   struct sm501_platdata private_platdata;
> > > > +   struct sm501_initdata private_initdata;
> > > >  
> > > > sm = kzalloc(sizeof(struct sm501_devdata), GFP_KERNEL);
> > > > if (sm == NULL) {
> > > > @@ -1388,6 +1391,12 @@ static int sm501_plat_probe(struct 
> > > > platform_device *dev)
> > > > sm->dev = &dev->dev;
> > > > sm->pdev_id = dev->id;
> > > > sm->platdata = dev_get_platdata(&dev->dev);
> > > > +   if (!sm->platdata) {
> > > > +   of_property_read_u32(dev->dev.of_node, "smi,devices",
> > > > +(u32 *)&private_initdata.devices);
> > > > +   private_platdata.init = &private_initdata;
> > > > +   sm->platdata = &private_platdata;
> > > > +   }
> > > 
> > > I've asked about this 3 times now.
> > > 
> > > What consumes this platform data?
> > > 
> > > It also looks ugly and fragile.
> > 
> > It's appropriate to use dev.of_node, isn't it?
> > If it's misunderstood, I'm sorry.
> 
> Yes, that's acceptable.
> 
> I'm talking about the whole process of allocating an entire platform
> structure (on the stack, which will most likely be wiped when we
> return from probe()) just to populate this one, undocumented
> property.
> 
> Hold up ... I've just taken a look at the driver myself.  What a
> mess.  It appears this driver pre-dates the MFD API and does
> everything I hate.
> 
> First step is to see if the Device Tree guys like your new property.
> Please document it in bindings/display/sm501fb.txt, as suggested by
> Rob, so they can review it.  Don't forget to CC me too.
> 
> We can look at the C code changes later.

OK.
Thanks comment.

> -- 
> Lee Jones
> Linaro STMicroelectronics Landing Team Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog

-- 
Yoshinori Sato



Re: [PATCH 2/3] iio: adc: add support for Allwinner SoCs ADC

2016-07-03 Thread Jonathan Cameron
On 28/06/16 09:18, Quentin Schulz wrote:
> The Allwinner SoCs all have an ADC that can also act as a touchscreen
> controller and a thermal sensor. This patch adds the ADC driver which is
> based on the MFD for the same SoCs ADC.
> 
> This also registers the thermal adc channel in the iio map array so
> iio_hwmon could use it without modifying the Device Tree.
> 
> This driver probes on three different platform_device_id to take into
> account slight differences between Allwinner SoCs ADCs.
> 
> Signed-off-by: Quentin Schulz 
Hi Quentin.

I'm a bit in two minds about some of this.  That temperature sensor is
so obviously meant for hwmon purposes, I'm tempted to suggest it might
actually make sense to put it directly in hwmon rather than using the
bridge.  That obviously makes it less flexible in some ways (i.e. for
use within the thermal subsystem at some point).

Guenter, what do you think?

I'm guessing detailed docs for this part aren't avaiable publicly? :(

So the rest of my comments are kind of predicated on me having roughtly
understood how this device works from the structure of the driver.

The temperature sensor is really effectively as separate ADC?
The main interest in this is for key detection?

Anyhow, if the data flow for the temperatures sensor is not synced with
the other ADC channels, adding buffered (pushed) output from the driver in
future will be fiddly and with a 250Hz device you'll probably want it.
Basically IIO buffered supports assumes each iio device will sample data
at a particular frequency. If channels are not synchronized in that fashion
then you have to register multiple devices or only pick a subset of channels
to export.

For the key detection you have already observed that IIO needs some
additions to be able to have consumers of what we term 'events' e.g. threshold
interrupts.

Looking at the lradc-keys driver in tree, it looks like we only really have
really simple threshold interrups - configured to detect a very low voltage?
+ only one per channel.

So not too nasty a case, but you are right some work is needed in IIO as
we simply don't have a means of passing these on as yet or configuring them
from in kernel consumers.
If we take the easy route and don't demux incoming events then it shouldn't
be too hard to add (demux can follow later).  Hence any client device can try
to enable events it wants, but may get events that other client devices wanted
as well.

Config interface should be much the same as the write support for channels.
Data flow marginally harder, but pretty much a list of callbacks within
iio_push_event.

Not trivial, but not too tricky either.

The events subsystem has a few 'limitations' we need to address long term
but as this is in kernel interface only, we can do this now and fix stuff
up in future without any ABI breakage. (limitations are things like only
one event of a given type and direction per channel - main challenge on
that is finding a way of doing it without abi breakage).

Anyhow, sounds fun - wish I had the time to do it myself!

Otherwise, your remove is never going to work as indio_dev is always NULL.

Jonathan

> ---
>  drivers/iio/adc/Kconfig   |  12 ++
>  drivers/iio/adc/Makefile  |   1 +
>  drivers/iio/adc/sunxi-gpadc-iio.c | 371 
> ++
>  3 files changed, 384 insertions(+)
>  create mode 100644 drivers/iio/adc/sunxi-gpadc-iio.c
> 
> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index 82c718c..b7b566a 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -328,6 +328,18 @@ config NAU7802
> To compile this driver as a module, choose M here: the
> module will be called nau7802.
>  
> +config SUNXI_ADC
> + tristate "ADC driver for sunxi platforms"
> + depends on IIO
> + depends on MFD_SUNXI_ADC
> + help
> +   Say yes here to build support for Allwinner SoCs (A10, A13 and A31)
> +   SoCs ADC. This ADC provides 4 channels which can be used as an ADC or
> +   as a touchscreen input and one channel for thermal sensor.
> +
> +  To compile this driver as a module, choose M here: the
> +  module will be called sunxi-gpadc-iio.
> +
>  config PALMAS_GPADC
>   tristate "TI Palmas General Purpose ADC"
>   depends on MFD_PALMAS
> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
> index 0cb7921..2996a5b 100644
> --- a/drivers/iio/adc/Makefile
> +++ b/drivers/iio/adc/Makefile
> @@ -32,6 +32,7 @@ obj-$(CONFIG_MCP3422) += mcp3422.o
>  obj-$(CONFIG_MEN_Z188_ADC) += men_z188_adc.o
>  obj-$(CONFIG_MXS_LRADC) += mxs-lradc.o
>  obj-$(CONFIG_NAU7802) += nau7802.o
> +obj-$(CONFIG_SUNXI_ADC) += sunxi-gpadc-iio.o
>  obj-$(CONFIG_PALMAS_GPADC) += palmas_gpadc.o
>  obj-$(CONFIG_QCOM_SPMI_IADC) += qcom-spmi-iadc.o
>  obj-$(CONFIG_QCOM_SPMI_VADC) += qcom-spmi-vadc.o
> diff --git a/drivers/iio/adc/sunxi-gpadc-iio.c 
> b/drivers/iio/adc/sunxi-gpadc-iio.c
> new file mode 100644
> index 00

Re: [PATCH 1/2] iio: sun4i-lradc: Add binding documentation

2016-07-03 Thread Jonathan Cameron
On 02/07/16 14:35, Alexandre Belloni wrote:
> On 02/07/2016 at 17:12:55 +0800, Chen-Yu Tsai wrote :
>> Hi,
>>
>> On Sat, Jul 2, 2016 at 5:00 AM, Alexandre Belloni
>>  wrote:
>>> Document the bindings for the Allwinner LRADC.
>>
>> We already have Documentation/devicetree/bindings/input/sun4i-lradc-keys.txt
>> and I'm pretty sure Hans (CC-ed) argued that this is not a generic ADC
>> block.
>>
>> Any plans to reconcile the different bindings?
>>
> 
> Yes, I already submitted an adc-keys driver that can work with any ADC:
> https://lkml.org/lkml/2016/7/1/670
> 
> I agree that because it is not yet handling interrupts and is polling
> the ADC, it is not as good as sun4i-lradc-keys yet. My plan is to solve
> that but it require significant work in iio.
> 
As I'm having fun confusing the two drivers submitted for different
ADCs on the A10 this morning - here is the relevant bit of text I stuck
in my review for the other driver...

 For the key detection you have already observed that IIO needs some
 additions to be able to have consumers of what we term 'events' e.g. threshold
 interrupts.
 
 Looking at the lradc-keys driver in tree, it looks like we only really have
 really simple threshold interrups - configured to detect a very low voltage?
 + only one per channel.
 
 So not too nasty a case, but you are right some work is needed in IIO as
 we simply don't have a means of passing these on as yet or configuring them
 from in kernel consumers.
 If we take the easy route and don't demux incoming events then it shouldn't
 be too hard to add (demux can follow later).  Hence any client device can try
 to enable events it wants, but may get events that other client devices wanted
 as well.
 
 Config interface should be much the same as the write support for channels.
 Data flow marginally harder, but pretty much a list of callbacks within
 iio_push_event.
 
 Not trivial, but not too tricky either.
 
 The events subsystem has a few 'limitations' we need to address long term
 but as this is in kernel interface only, we can do this now and fix stuff
 up in future without any ABI breakage. (limitations are things like only
 one event of a given type and direction per channel - main challenge on
 that is finding a way of doing it without abi breakage).
 
 Anyhow, sounds fun - wish I had the time to do it myself!
Jonathan
 



Re: [PATCH RFC 0/7] support clk setting during kernel early boot

2016-07-03 Thread Fabio Estevam
Hi Stefan,

On Sat, Jul 2, 2016 at 8:12 PM, Stefan Agner  wrote:

> I found that remark interesting, and agree here with Stephen, critical
> clks should be already on and everything else should be controlled from
> drivers.
>
> With that in mind I went on and looked again what is currently (after
> the parents enable patchset) still wrong on i.MX 7. Turned out to be not
> that much, and I think it should be fixable with that:
> https://lkml.org/lkml/2016/7/2/138

If I only applied your patch against linux-next I still get:
http://pastebin.com/zx7kAzfd


Re: [PATCH 2/2] iio: adc: sun4i_lradc: new driver

2016-07-03 Thread Jonathan Cameron
On 01/07/16 22:00, Alexandre Belloni wrote:
> Add an IIO driver for the Allwinner LRADC.
To avoid idiots (i.e. me) confusing this with the touch screen ADC
could you expand a little on the description in future patches.

A few general bits and bobs inline.

Jonathan
> 
> Signed-off-by: Alexandre Belloni 
> ---
>  drivers/iio/adc/Kconfig   |  10 ++
>  drivers/iio/adc/Makefile  |   3 +-
>  drivers/iio/adc/sun4i_lradc.c | 329 
> ++
>  3 files changed, 341 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/iio/adc/sun4i_lradc.c
> 
> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index 25378c5882e2..55fb07bbe9a9 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -384,6 +384,16 @@ config ROCKCHIP_SARADC
> To compile this driver as a module, choose M here: the
> module will be called rockchip_saradc.
>  
> +config SUN4I_LRADC
> + tristate "Allwinner LRADC driver"
> + depends on ARCH_SUNXI || COMPILE_TEST
> + select IIO_TRIGGER
> + help
> +   Say yes here to build support for the LRADC found on Allwinner SoCs.
> +
> +   To compile this driver as a module, choose M here: the module will be
> +   called sun4i_lradc.
> +
>  config TI_ADC081C
>   tristate "Texas Instruments ADC081C/ADC101C/ADC121C family"
>   depends on I2C
> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
> index 38638d46f972..a3b165af6bde 100644
> --- a/drivers/iio/adc/Makefile
> +++ b/drivers/iio/adc/Makefile
> @@ -1,4 +1,4 @@
> -#
> +
>  # Makefile for IIO ADC drivers
>  #
>  
> @@ -37,6 +37,7 @@ obj-$(CONFIG_PALMAS_GPADC) += palmas_gpadc.o
>  obj-$(CONFIG_QCOM_SPMI_IADC) += qcom-spmi-iadc.o
>  obj-$(CONFIG_QCOM_SPMI_VADC) += qcom-spmi-vadc.o
>  obj-$(CONFIG_ROCKCHIP_SARADC) += rockchip_saradc.o
> +obj-$(CONFIG_SUN4I_LRADC) += sun4i_lradc.o
>  obj-$(CONFIG_TI_ADC081C) += ti-adc081c.o
>  obj-$(CONFIG_TI_ADC0832) += ti-adc0832.o
>  obj-$(CONFIG_TI_ADC128S052) += ti-adc128s052.o
> diff --git a/drivers/iio/adc/sun4i_lradc.c b/drivers/iio/adc/sun4i_lradc.c
> new file mode 100644
> index ..9789dcc28621
> --- /dev/null
> +++ b/drivers/iio/adc/sun4i_lradc.c
> @@ -0,0 +1,329 @@
> +/*
> + * Driver for the LRADC present on the  Allwinner sun4i
> + *
> + * Copyright 2016 Free Electrons
> + *
> + * 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.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define SUN4I_LRADC_CTRL 0x00
> +#define SUN4I_LRADC_INTC 0x04
> +#define SUN4I_LRADC_INTS 0x08
> +#define SUN4I_LRADC_DATA00x0c
> +#define SUN4I_LRADC_DATA10x10
> +
Please prefix all defines (far too likely some of these might in future
turn up in a header this driver is including).
> +/* LRADC_CTRL bits */
> +#define FIRST_CONVERT_DLY(x) ((x) << 24) /* 8 bits */
> +#define CHAN_SELECT(x)   ((x) << 22) /* 2 bits */
> +#define CONTINUE_TIME_SEL(x) ((x) << 16) /* 4 bits */
> +#define KEY_MODE_SEL(x)  ((x) << 12) /* 2 bits */
> +#define LEVELA_B_CNT(x)  ((x) << 8)  /* 4 bits */
> +#define LRADC_HOLD_ENBIT(6)
> +#define LEVELB_VOL(x)((x) << 4)  /* 2 bits */
> +#define LRADC_SAMPLE_RATE(x) ((x) << 2)  /* 2 bits */
> +#define LRADC_EN BIT(0)
> +
> +/* LRADC_INTC and LRADC_INTS bits */
> +#define CHAN1_KEYUP_IRQ  BIT(12)
> +#define CHAN1_ALRDY_HOLD_IRQ BIT(11)
> +#define CHAN1_HOLD_IRQ   BIT(10)
> +#define  CHAN1_KEYDOWN_IRQ   BIT(9)
> +#define CHAN1_DATA_IRQ   BIT(8)
> +#define CHAN0_KEYUP_IRQ  BIT(4)
> +#define CHAN0_ALRDY_HOLD_IRQ BIT(3)
> +#define CHAN0_HOLD_IRQ   BIT(2)
> +#define  CHAN0_KEYDOWN_IRQ   BIT(1)
> +#define CHAN0_DATA_IRQ   BIT(0)
> +
> +#define NUM_CHANS2
> +#define NUM_TRIGGERS 4
? Interesting, but not present here.
> +
> +struct sun4i_lradc_state {
> + void __iomem *base;
> + struct regulator *vref_supply;
> + u32 vref_mv;
> + struct completion data_ok[NUM_CHANS];
> + u32 last_event;
> + spinlock_t lock;
> +};
> +
> +#define SUN4I_LRADC_CHANNEL(chan) {  \
> + .type = IIO_VOLTAGE,\
> + .indexed = 1,  

Re: [PATCH v5 5/8] spi: add support for ACPI reconfigure notifications

2016-07-03 Thread Mark Brown
On Fri, Jul 01, 2016 at 11:19:09PM +0300, Octavian Purdila wrote:
> This patch adds supports for SPI device enumeration and removal via
> ACPI reconfiguration notifications that are send as a result of an
> ACPI table load or unload operation.

Acked-by: Mark Brown 


signature.asc
Description: PGP signature


[RFC PATCH 0/3] doc-rst: customize HTML (RTD) theme

2016-07-03 Thread Markus Heiser
From: Markus Heiser 

The default layout of the RTD HTML theme has some tweaks, discussed in the
linux-doc ML [1][2].

This series adds a boilerplate to customize HTML themes and it fix the tweaks
(mainly) for tables, captions and inline literals.

Since there is no (vast) table in Jon's docs-next yet, this RFC has to be tested
with Mauro's docs-next branch which includes the linux_tv doc (see chapter
"Media Bus Formats" for vast tables). If you don't like merge it all just for a
test, pull it from my linux_tv_migration branch at:

  https://github.com/return42/linux.git linux_tv_migration

Any comments are welcome

  -- Markus --

[1] http://article.gmane.org/gmane.linux.kernel/2216509
[2] 
http://article.gmane.org/gmane.linux.drivers.video-input-infrastructure/101099


Markus Heiser (3):
  doc-rst: boilerplate HTML theme customization
  doc-rst: customize RTD theme, table & full width
  doc-rst: customize RTD theme, captions & inline literal

 Documentation/conf.py   |  9 -
 Documentation/sphinx-static/theme_overrides.css | 53 +
 2 files changed, 61 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/sphinx-static/theme_overrides.css

-- 
docs-next/sphinx-4.8



[RFC PATCH 1/3] doc-rst: boilerplate HTML theme customization

2016-07-03 Thread Markus Heiser
From: Markus Heiser 
To: Jonathan Corbet 
To: Mauro Carvalho Chehab 
Cc: Hans Verkuil 
Cc: Daniel Vetter 
Cc: Airlie 
Cc: Likely 
Cc: Dunlap 
Cc: Packard 
Cc: linux-...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org

Implements the minimal boilerplate for Sphinx HTML theme customization.

Signed-off-by: Markus Heiser 
---
 Documentation/conf.py   | 9 -
 Documentation/sphinx-static/theme_overrides.css | 9 +
 2 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/sphinx-static/theme_overrides.css

diff --git a/Documentation/conf.py b/Documentation/conf.py
index 792b633..f35748b 100644
--- a/Documentation/conf.py
+++ b/Documentation/conf.py
@@ -176,7 +176,14 @@ except ImportError:
 # Add any paths that contain custom static files (such as style sheets) here,
 # relative to this directory. They are copied after the builtin static files,
 # so a file named "default.css" will overwrite the builtin "default.css".
-#html_static_path = ['_static']
+
+html_static_path = ['sphinx-static']
+
+html_context = {
+'css_files': [
+'_static/theme_overrides.css',
+],
+}
 
 # Add any extra paths that contain custom files (such as robots.txt or
 # .htaccess) here, relative to this directory. These files are copied
diff --git a/Documentation/sphinx-static/theme_overrides.css 
b/Documentation/sphinx-static/theme_overrides.css
new file mode 100644
index 000..4d670db
--- /dev/null
+++ b/Documentation/sphinx-static/theme_overrides.css
@@ -0,0 +1,9 @@
+/* -*- coding: utf-8; mode: css -*-
+ *
+ * Sphinx HTML theme customization
+ *
+ */
+
+@media screen {
+
+}
-- 
docs-next/sphinx-4.8



[RFC PATCH 3/3] doc-rst: customize RTD theme, captions & inline literal

2016-07-03 Thread Markus Heiser
From: Markus Heiser 
To: Jonathan Corbet 
To: Mauro Carvalho Chehab 
Cc: Hans Verkuil 
Cc: Daniel Vetter 
Cc: Airlie 
Cc: Likely 
Cc: Dunlap 
Cc: Packard 
Cc: linux-...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org

The layout of (table) captions in the RTD theme is a bit ugly and the
bordered, red colored of inline literals is a bit to gaudy. The
requirements has been discussed in the ML [1].

captions:

  - captions should have 100% (not 85%) font size
  - hide the permalink symbol as long as link is not hovered

inline literal:

  - drop the borderbox and red color

[1] 
http://article.gmane.org/gmane.linux.drivers.video-input-infrastructure/101099

Signed-off-by: Markus Heiser 
---
 Documentation/sphinx-static/theme_overrides.css | 25 +
 1 file changed, 25 insertions(+)

diff --git a/Documentation/sphinx-static/theme_overrides.css 
b/Documentation/sphinx-static/theme_overrides.css
index ea06799..c97d842 100644
--- a/Documentation/sphinx-static/theme_overrides.css
+++ b/Documentation/sphinx-static/theme_overrides.css
@@ -25,4 +25,29 @@
 .wy-table-responsive { overflow: auto; }
 .rst-content table.docutils caption { text-align: left; font-size: 100%; }
 
+/* captions:
+ *
+ *   - captions should have 100% (not 85%) font size
+ *   - hide the permalink symbol as long as link is not hovered
+ */
+
+caption, .wy-table caption, .rst-content table.field-list caption {
+font-size: 100%;
+}
+caption a.headerlink { opacity: 0; }
+caption a.headerlink:hover { opacity: 1; }
+
+/* inline literal: drop the borderbox and red color */
+
+code, .rst-content tt, .rst-content code {
+color: inherit;
+border: none;
+background: inherit;
+font-size: 85%;
+}
+
+.rst-content tt.literal,.rst-content tt.literal,.rst-content code.literal {
+color: inherit;
+}
+
 }
-- 
docs-next/sphinx-4.8



[RFC PATCH 2/3] doc-rst: customize RTD theme, table & full width

2016-07-03 Thread Markus Heiser
From: Markus Heiser 
To: Jonathan Corbet 
To: Mauro Carvalho Chehab 
Cc: Hans Verkuil 
Cc: Daniel Vetter 
Cc: Airlie 
Cc: Likely 
Cc: Dunlap 
Cc: Packard 
Cc: linux-...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org

The default table layout of the RTD theme does not fit for vast tables,
like the ones we have in the linux_tv project. This has been discussed
on the ML [1].

The RTD theme is a two column layout, with a navigation column on the
left and a content column on the right:

content column

 RTD theme's default is 800px as max width for the content, but we have
 tables with tons of columns, which need the full width of the
 view-port (BTW: *full width* is what DocBook's HTML is).

table

   - sequences of whitespace should collapse into a single whitespace.
   - make the overflow auto (scrollbar if needed)
   - align caption "left" ("center" is unsuitable on vast tables)

[1] http://article.gmane.org/gmane.linux.kernel/2216509

Signed-off-by: Markus Heiser 
---
 Documentation/sphinx-static/theme_overrides.css | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/Documentation/sphinx-static/theme_overrides.css 
b/Documentation/sphinx-static/theme_overrides.css
index 4d670db..ea06799 100644
--- a/Documentation/sphinx-static/theme_overrides.css
+++ b/Documentation/sphinx-static/theme_overrides.css
@@ -1,9 +1,28 @@
 /* -*- coding: utf-8; mode: css -*-
  *
- * Sphinx HTML theme customization
+ * Sphinx HTML theme customization: read the doc
  *
  */
 
 @media screen {
 
+/* content column
+ *
+ * RTD theme's default is 800px as max width for the content, but we have
+ * tables with tons of columns, which need the full width of the view-port.
+ */
+
+.wy-nav-content{max-width: none; }
+
+/* table:
+ *
+ *   - Sequences of whitespace should collapse into a single whitespace.
+ *   - make the overflow auto (scrollbar if needed)
+ *   - align caption "left" ("center" is unsuitable on vast tables)
+ */
+
+.wy-table-responsive table td { white-space: normal; }
+.wy-table-responsive { overflow: auto; }
+.rst-content table.docutils caption { text-align: left; font-size: 100%; }
+
 }
-- 
docs-next/sphinx-4.8



Re: [PATCH 2/3] iio: adc: add support for Allwinner SoCs ADC

2016-07-03 Thread Jonathan Cameron
On 03/07/16 12:54, Jonathan Cameron wrote:
> On 28/06/16 09:18, Quentin Schulz wrote:
>> The Allwinner SoCs all have an ADC that can also act as a touchscreen
>> controller and a thermal sensor. This patch adds the ADC driver which is
>> based on the MFD for the same SoCs ADC.
>>
>> This also registers the thermal adc channel in the iio map array so
>> iio_hwmon could use it without modifying the Device Tree.
>>
>> This driver probes on three different platform_device_id to take into
>> account slight differences between Allwinner SoCs ADCs.
>>
>> Signed-off-by: Quentin Schulz 
> Hi Quentin.
> 
> I'm a bit in two minds about some of this.  That temperature sensor is
> so obviously meant for hwmon purposes, I'm tempted to suggest it might
> actually make sense to put it directly in hwmon rather than using the
> bridge.  That obviously makes it less flexible in some ways (i.e. for
> use within the thermal subsystem at some point).
> 
> Guenter, what do you think?
> 
> I'm guessing detailed docs for this part aren't avaiable publicly? :(
> 
> So the rest of my comments are kind of predicated on me having roughtly
> understood how this device works from the structure of the driver.
> 
> The temperature sensor is really effectively as separate ADC?
> The main interest in this is for key detection?
Ah, I'm talking garbage, wrong ADC for the chip...  I'd crossed the two
threads.  Ignore that stuff.
> 
> Anyhow, if the data flow for the temperatures sensor is not synced with
> the other ADC channels, adding buffered (pushed) output from the driver in
> future will be fiddly and with a 250Hz device you'll probably want it.
> Basically IIO buffered supports assumes each iio device will sample data
> at a particular frequency. If channels are not synchronized in that fashion
> then you have to register multiple devices or only pick a subset of channels
> to export.
> 
> For the key detection you have already observed that IIO needs some
> additions to be able to have consumers of what we term 'events' e.g. threshold
> interrupts.
> 
> Looking at the lradc-keys driver in tree, it looks like we only really have
> really simple threshold interrups - configured to detect a very low voltage?
> + only one per channel.
> 
> So not too nasty a case, but you are right some work is needed in IIO as
> we simply don't have a means of passing these on as yet or configuring them
> from in kernel consumers.
> If we take the easy route and don't demux incoming events then it shouldn't
> be too hard to add (demux can follow later).  Hence any client device can try
> to enable events it wants, but may get events that other client devices wanted
> as well.
> 
> Config interface should be much the same as the write support for channels.
> Data flow marginally harder, but pretty much a list of callbacks within
> iio_push_event.
> 
> Not trivial, but not too tricky either.
> 
> The events subsystem has a few 'limitations' we need to address long term
> but as this is in kernel interface only, we can do this now and fix stuff
> up in future without any ABI breakage. (limitations are things like only
> one event of a given type and direction per channel - main challenge on
> that is finding a way of doing it without abi breakage).
> 
> Anyhow, sounds fun - wish I had the time to do it myself!
> 
> Otherwise, your remove is never going to work as indio_dev is always NULL.
> 
> Jonathan
> 
>> ---
>>  drivers/iio/adc/Kconfig   |  12 ++
>>  drivers/iio/adc/Makefile  |   1 +
>>  drivers/iio/adc/sunxi-gpadc-iio.c | 371 
>> ++
>>  3 files changed, 384 insertions(+)
>>  create mode 100644 drivers/iio/adc/sunxi-gpadc-iio.c
>>
>> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
>> index 82c718c..b7b566a 100644
>> --- a/drivers/iio/adc/Kconfig
>> +++ b/drivers/iio/adc/Kconfig
>> @@ -328,6 +328,18 @@ config NAU7802
>>To compile this driver as a module, choose M here: the
>>module will be called nau7802.
>>  
>> +config SUNXI_ADC
>> +tristate "ADC driver for sunxi platforms"
>> +depends on IIO
>> +depends on MFD_SUNXI_ADC
>> +help
>> +  Say yes here to build support for Allwinner SoCs (A10, A13 and A31)
>> +  SoCs ADC. This ADC provides 4 channels which can be used as an ADC or
>> +  as a touchscreen input and one channel for thermal sensor.
>> +
>> +  To compile this driver as a module, choose M here: the
>> +  module will be called sunxi-gpadc-iio.
>> +
>>  config PALMAS_GPADC
>>  tristate "TI Palmas General Purpose ADC"
>>  depends on MFD_PALMAS
>> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
>> index 0cb7921..2996a5b 100644
>> --- a/drivers/iio/adc/Makefile
>> +++ b/drivers/iio/adc/Makefile
>> @@ -32,6 +32,7 @@ obj-$(CONFIG_MCP3422) += mcp3422.o
>>  obj-$(CONFIG_MEN_Z188_ADC) += men_z188_adc.o
>>  obj-$(CONFIG_MXS_LRADC) += mxs-lradc.o
>>  obj-$(CONFIG_NAU7802) += nau7802.o
>> +obj-$(CONFIG_SUNXI_A

Re: [RFC] mips: Add MXU context switching support

2016-07-03 Thread PrasannaKumar Muralidharan
Will be great if someone could review this. Thanks in advance.


Re: [PATCH 1/2] input: adc-keys: add DT binding documentation

2016-07-03 Thread Jonathan Cameron
On 01/07/16 22:30, Alexandre Belloni wrote:
> Add documentation for ADC keys
> 
> Signed-off-by: Alexandre Belloni 
Clean looking binding to me - one comment inline.

Jonathan
> ---
> Cc: Rob Herring 
> Cc: devicet...@vger.kernel.org
> 
>  .../devicetree/bindings/input/adc-keys.txt | 45 
> ++
>  1 file changed, 45 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/adc-keys.txt
> 
> diff --git a/Documentation/devicetree/bindings/input/adc-keys.txt 
> b/Documentation/devicetree/bindings/input/adc-keys.txt
> new file mode 100644
> index ..873476bb4eab
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/adc-keys.txt
> @@ -0,0 +1,45 @@
> +Allwinner sun4i low res adc attached tablet keys
What is allwinner specific in here?  Looks pretty general purpose to me!
> +
> +
> +Required properties:
> + - compatible: "adc-keys"
> + - io-channels: Phandle to an ADC channel
> + - io-channel-names = "buttons";
> + - voltage-keyup-mvolt: Voltage at which all the keys are considered up.
> +
> +Each key is represented as a sub-node of "adc-keys":
> +
> +Required subnode-properties:
> + - label: Descriptive name of the key.
> + - linux,code: Keycode to emit.
> + - voltage-mvolt: Voltage adc input when this key is pressed.
> +
> +Example:
> +
> +#include 
> +
> + adc-keys {
> + compatible = "adc-keys";
> + io-channels = <&lradc 0>;
> + io-channel-names = "buttons";
> + voltage-keyup-mvolt = <2000>;
> +
> + button@1500 {
> + label = "Volume Up";
> + linux,code = ;
> + voltage-mvolt = <1500>;
> + };
> +
> + button@1000 {
> + label = "Volume Down";
> + linux,code = ;
> + voltage-mvolt = <1000>;
> + };
> +
> + button@500 {
> + label = "Enter";
> + linux,code = ;
> + voltage-mvolt = <500>;
> + };
> + };
> +
> 



Re: [PATCH 2/2] input: add ADC resistor ladder driver

2016-07-03 Thread Jonathan Cameron
On 01/07/16 22:30, Alexandre Belloni wrote:
> A common way of multiplexing buttons on a single input in cheap devices is
> to use a resistor ladder on an ADC. This driver supports that configuration
> by polling an ADC channel provided by IIO.
> 
> Signed-off-by: Alexandre Belloni 
I like this a lot.  It's small elegant and does what it says on the tin.

Even when we do extend IIO to output threshold events, we'll still want the
polled version as there are plenty of ADCs out there without threshold
interrupts.

Next step add the iio event push support needed to interrupt drive this.
*cross fingers* :)

We may also want to do a full pushed mode at some point for self clocking
/ hardware sequencer equiped ADCs.  Easy enough to add when someone wants
it.

Jonathan
> ---
>  drivers/input/keyboard/Kconfig|  15 +++
>  drivers/input/keyboard/Makefile   |   1 +
>  drivers/input/keyboard/adc-keys.c | 209 
> ++
>  3 files changed, 225 insertions(+)
>  create mode 100644 drivers/input/keyboard/adc-keys.c
> 
> diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
> index 509608c95994..ba20808f31e0 100644
> --- a/drivers/input/keyboard/Kconfig
> +++ b/drivers/input/keyboard/Kconfig
> @@ -12,6 +12,21 @@ menuconfig INPUT_KEYBOARD
>  
>  if INPUT_KEYBOARD
>  
> +config KEYBOARD_ADC
> + tristate "ADC ladder Buttons"
> + depends on IIO || COMPILE_TEST
> + select INPUT_POLLDEV
> + help
> +   This driver implements support for buttons connected
> +   to an ADC using a resistor ladder.
> +
> +   Say Y here if your device has such buttons connected to an ADC.  Your
> +   board-specific setup logic must also provide a configuration data
> +   saying mapping voltages to buttons.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called adc_keys.
> +
>  config KEYBOARD_ADP5520
>   tristate "Keypad Support for ADP5520 PMIC"
>   depends on PMIC_ADP5520
> diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
> index 1d416ddf84e4..d9f4cfcf3410 100644
> --- a/drivers/input/keyboard/Makefile
> +++ b/drivers/input/keyboard/Makefile
> @@ -4,6 +4,7 @@
>  
>  # Each configuration option enables a list of files.
>  
> +obj-$(CONFIG_KEYBOARD_ADC)   += adc-keys.o
>  obj-$(CONFIG_KEYBOARD_ADP5520)   += adp5520-keys.o
>  obj-$(CONFIG_KEYBOARD_ADP5588)   += adp5588-keys.o
>  obj-$(CONFIG_KEYBOARD_ADP5589)   += adp5589-keys.o
> diff --git a/drivers/input/keyboard/adc-keys.c 
> b/drivers/input/keyboard/adc-keys.c
> new file mode 100644
> index ..ba6ee91272b2
> --- /dev/null
> +++ b/drivers/input/keyboard/adc-keys.c
> @@ -0,0 +1,209 @@
> +/* Input driver for resistor ladder connected on ADC
> + *
> + * Copyright (c) 2016 Alexandre Belloni
> + *
> + * 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.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +struct adc_keys_button {
> + u32 voltage;
> + u32 keycode;
> +};
> +
> +struct adc_keys_state {
> + struct iio_channel *channel;
> + u32 num_keys;
> + u32 last_key;
> + u32 keyup_voltage;
> + struct adc_keys_button *map;
> +};
> +
> +static void adc_keys_poll(struct input_polled_dev *dev)
> +{
> + struct adc_keys_state *st = dev->private;
> + int i, value, ret;
> + u32 diff, closest = 0x;
> + int keycode = 0;
> +
> + ret = iio_read_channel_processed(st->channel, &value);
> + if (ret < 0) {
> + if (st->last_key) {
> + input_report_key(dev->input, st->last_key, 0);
> + input_sync(dev->input);
> + st->last_key = 0;
> + }
> + return;
> + }
> +
> + for (i = 0; i < st->num_keys; i++) {
> + diff = abs(st->map[i].voltage - value);
> + if (diff < closest) {
> + closest = diff;
> + keycode = st->map[i].keycode;
> + }
> + }
> +
> + if (abs(st->keyup_voltage - value) < closest) {
> + input_report_key(dev->input, st->last_key, 0);
> + st->last_key = 0;
> + } else {
> + if (st->last_key && st->last_key != keycode)
> + input_report_key(dev->input, st->last_key, 0);
> + input_report_key(dev->input, keycode, 1);
> + st->last_key = keycode;
> + }
> +
> + input_sync(dev->input);
> +}
> +
> +static int adc_keys_load_dt_keymap(struct device *dev,
> +struct adc_keys_state *st)
> +{
> + struct device_node *pp, *np = dev->of_node;
> + int i;
> +
> + st->num_keys = of_get_child_count(np);
>

[PATCH] tracing: Have HIST_TRIGGERS select TRACING

2016-07-03 Thread Tom Zanussi
The kbuild test robot reported a compile error if HIST_TRIGGERS was
enabled but nothing else that selected TRACING was configured in.

HIST_TRIGGERS should directly select it and not rely on anything else
to do it.

Signed-off-by: Tom Zanussi 
---
 kernel/trace/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index fafeaf8..f4b86e8 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -542,6 +542,7 @@ config HIST_TRIGGERS
bool "Histogram triggers"
depends on ARCH_HAVE_NMI_SAFE_CMPXCHG
select TRACING_MAP
+   select TRACING
default n
help
  Hist triggers allow one or more arbitrary trace event fields
-- 
1.9.3


Re: [PATCHv3] mvsas:Fix possible NULL pointer deference in mvs_dev_found_notify

2016-07-03 Thread Luis de Bethencourt
On 02/07/16 20:05, James Bottomley wrote:
> On Sat, 2016-07-02 at 19:16 +0100, Luis de Bethencourt wrote:
>> On 02/07/16 18:00, Nicholas Krause wrote:
>>> This adds properly checking after the call to mvs_find_dev_mvi
>>>  due to this function being able to return a NULL pointer and
>>> if this does arise we will deference it in mvs_alloc_dev due
>>> to this function never checking if a NULL pointer is given as
>>> it's input argument. Signed-off-by: Nicholas Krause <
>>> xerofo...@gmail.com>
>>> ---
>>> v3 - Make logic simpler on error path by returning -1 directly
>>> if mvs_find_dev_mvi returns NULL.
>>> v2 - Fix NULL pointer deferenece in error path by calling 
>>> spin_unlock_irqrestore on the now NULL pointer, as returned
>>>
>>>
>>>  drivers/scsi/mvsas/mv_sas.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/drivers/scsi/mvsas/mv_sas.c
>>> b/drivers/scsi/mvsas/mv_sas.c
>>> index 5b9fcff..dffab01 100644
>>> --- a/drivers/scsi/mvsas/mv_sas.c
>>> +++ b/drivers/scsi/mvsas/mv_sas.c
>>> @@ -1194,6 +1194,8 @@ int mvs_dev_found_notify(struct domain_device
>>> *dev, int lock)
>>> struct mvs_device *mvi_device;
>>>  
>>> mvi = mvs_find_dev_mvi(dev);
>>> +   if (!mvi)
>>> +   return -1;
>>>  
>>> if (lock)
>>> spin_lock_irqsave(&mvi->lock, flags);
>>>
>>
>> This looks better :)
>>
>> Checking the value of mvi makes sense if mvs_find_dev_mvi() can
>> return NULL.
> 
> Which it can't, if you actually look at the function.  For this to
> happen, we'd have to be receiving a discovery event for a non-existent
> port on the adapter, meaning the system was so corrupted that operation
> shouldn't be continuing.
> 
> Nick is a known bogus patch submitter.  If you want to review them,
> that's your choice (and perhaps some might be useful), but it's not
> unreasonable of me to expect the review will be thorough enough to turn
> up issues like this.
> 
> James

I had my suspicions about mvfs_find_dev_mvi() returning NULL. Which is why
I said "if it can return NULL". Unfortunately I assumed the base of the patch
was properly considered, because I didn't knew about Nick.

I just searched around and now understand what you mean about his bogus
patches.

Sorry I wasn't thorough enough on my review, I know the above isn't an
excuse. Lesson learned.

In a related note, why is mvi initialized to NULL in mvfs_find_dev_mvi() if
it is going to be overwritten? Curious.

Thanks and apologies,
Luis

> 
> 
>> Reviewed-by: Luis de Bethencourt 
>>
>> Thanks,
>> Luis
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-scsi"
>> in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
> 



[patch v2 2/2] f2fs: fix to avoid data update racing between GC and DIO

2016-07-03 Thread Chao Yu
From: Chao Yu 

Datas in file can be operated by GC and DIO simultaneously, so we will
face race case as below:

For write case:
Thread AThread B
- generic_file_direct_write
 - invalidate_inode_pages2_range
 - f2fs_direct_IO
  - do_blockdev_direct_IO
   - do_direct_IO
- get_more_blocks
- f2fs_gc
 - do_garbage_collect
  - gc_data_segment
   - move_data_page
- do_write_data_page
migrate data block to new block 
address
   - dio_bio_submit
   update user data to old block address

For read case:
Thread AThread B
- generic_file_direct_write
 - invalidate_inode_pages2_range
 - f2fs_direct_IO
  - do_blockdev_direct_IO
   - do_direct_IO
- get_more_blocks
- f2fs_balance_fs
 - f2fs_gc
  - do_garbage_collect
   - gc_data_segment
- move_data_page
 - do_write_data_page
 migrate data block to new block 
address
  - write_checkpoint
   - do_checkpoint
- clear_prefree_segments
 - f2fs_issue_discard
 discard old block adress
   - dio_bio_submit
   update user buffer from obsolete block address

In order to fix this, for one file, we should let DIO and GC getting exclusion
against with each other.

Signed-off-by: Chao Yu 
---
 fs/f2fs/data.c  | 11 +++
 fs/f2fs/f2fs.h  |  2 ++
 fs/f2fs/gc.c| 19 +++
 fs/f2fs/super.c |  2 ++
 4 files changed, 34 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index ba4963f..3a03285 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1701,8 +1701,10 @@ static ssize_t f2fs_direct_IO(struct kiocb *iocb, struct 
iov_iter *iter)
 {
struct address_space *mapping = iocb->ki_filp->f_mapping;
struct inode *inode = mapping->host;
+   struct f2fs_inode_info *fi = F2FS_I(inode);
size_t count = iov_iter_count(iter);
loff_t offset = iocb->ki_pos;
+   bool is_write = (iov_iter_rw(iter) == WRITE);
int err;
 
err = check_direct_IO(inode, iter, offset);
@@ -1716,7 +1718,16 @@ static ssize_t f2fs_direct_IO(struct kiocb *iocb, struct 
iov_iter *iter)
 
trace_f2fs_direct_IO_enter(inode, offset, count, iov_iter_rw(iter));
 
+   if (is_write)
+   mutex_lock(&fi->dio_mutex);
+   else
+   down_read(&fi->dio_rwsem);
err = blockdev_direct_IO(iocb, inode, iter, get_data_block_dio);
+   if (is_write)
+   mutex_unlock(&fi->dio_mutex);
+   else
+   up_read(&fi->dio_rwsem);
+
if (iov_iter_rw(iter) == WRITE) {
if (err > 0)
set_inode_flag(inode, FI_UPDATE_WRITE);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index bd82b6d..ac3410a 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -474,6 +474,8 @@ struct f2fs_inode_info {
struct list_head inmem_pages;   /* inmemory pages managed by f2fs */
struct mutex inmem_lock;/* lock for inmemory pages */
struct extent_tree *extent_tree;/* cached extent_tree entry */
+   struct mutex dio_mutex; /* avoid racing between write dio and 
gc */
+   struct rw_semaphore dio_rwsem;  /* avoid racing between read dio and gc 
*/
 };
 
 static inline void get_extent_info(struct extent_info *ext,
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index c2c4ac3..a15ae8a 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -744,12 +744,31 @@ next_step:
/* phase 3 */
inode = find_gc_inode(gc_list, dni.ino);
if (inode) {
+   struct f2fs_inode_info *fi = F2FS_I(inode);
+   bool locked = false;
+
+   if (S_ISREG(inode->i_mode)) {
+   if (!mutex_trylock(&fi->dio_mutex))
+   continue;
+   if (!down_write_trylock(&fi->dio_rwsem)) {
+   mutex_unlock(&fi->dio_mutex);
+   continue;
+   }
+   locked = true;
+   }
+
start_bidx = start_bidx_of_node(nofs, inode)
+ ofs_in_node;
if (f2fs_encrypted_in

[PATCH 3/4] f2fs: fix to redirty page if fail to gc data page

2016-07-03 Thread Chao Yu
From: Chao Yu 

If we fail to move data page during foreground GC, we should give another
chance to writeback that page which was set dirty previously by writer.

Signed-off-by: Chao Yu 
---
 fs/f2fs/gc.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index d888490..b744465 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -653,12 +653,23 @@ static void move_data_page(struct inode *inode, block_t 
bidx, int gc_type)
.page = page,
.encrypted_page = NULL,
};
+   bool is_dirty = PageDirty(page);
+   int err;
+
+retry:
set_page_dirty(page);
f2fs_wait_on_page_writeback(page, DATA, true);
if (clear_page_dirty_for_io(page))
inode_dec_dirty_pages(inode);
+
set_cold_data(page);
-   do_write_data_page(&fio);
+
+   err = do_write_data_page(&fio);
+   if (err == -ENOMEM && is_dirty) {
+   congestion_wait(BLK_RW_ASYNC, HZ/50);
+   goto retry;
+   }
+
clear_cold_data(page);
}
 out:
-- 
2.7.2



[PATCH 1/4] f2fs: fix to avoid reading out encrypted data in page cache

2016-07-03 Thread Chao Yu
From: Chao Yu 

For encrypted inode, if user overwrites data of the inode, f2fs will read
encrypted data into page cache, and then do the decryption.

However reader can race with overwriter, and it will see encrypted data
which has not been decrypted by overwriter yet. Fix it by moving decrypting
work to background and keep page non-uptodated until data is decrypted.

Thread AThread B
- f2fs_file_write_iter
 - __generic_file_write_iter
  - generic_perform_write
   - f2fs_write_begin
- f2fs_submit_page_bio
- generic_file_read_iter
 - do_generic_file_read
  - lock_page_killable
  - unlock_page
  - copy_page_to_iter
  hit the encrypted data in updated page
- lock_page
- fscrypt_decrypt_page

Signed-off-by: Chao Yu 
---
 fs/f2fs/data.c | 90 ++
 1 file changed, 47 insertions(+), 43 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 3a03285..2bfb4f1 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -955,6 +955,37 @@ out:
return ret;
 }
 
+struct bio *f2fs_grab_bio(struct inode *inode, block_t blkaddr,
+   unsigned nr_pages)
+{
+   struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
+   struct fscrypt_ctx *ctx = NULL;
+   struct block_device *bdev = sbi->sb->s_bdev;
+   struct bio *bio;
+
+   if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) {
+   ctx = fscrypt_get_ctx(inode, GFP_NOFS);
+   if (IS_ERR(ctx))
+   return ERR_CAST(ctx);
+
+   /* wait the page to be moved by cleaning */
+   f2fs_wait_on_encrypted_page_writeback(sbi, blkaddr);
+   }
+
+   bio = bio_alloc(GFP_KERNEL, min_t(int, nr_pages, BIO_MAX_PAGES));
+   if (!bio) {
+   if (ctx)
+   fscrypt_release_ctx(ctx);
+   return ERR_PTR(-ENOMEM);
+   }
+   bio->bi_bdev = bdev;
+   bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(blkaddr);
+   bio->bi_end_io = f2fs_read_end_io;
+   bio->bi_private = ctx;
+
+   return bio;
+}
+
 /*
  * This function was originally taken from fs/mpage.c, and customized for f2fs.
  * Major change was from block_size == page_size in f2fs by default.
@@ -973,7 +1004,6 @@ static int f2fs_mpage_readpages(struct address_space 
*mapping,
sector_t last_block;
sector_t last_block_in_file;
sector_t block_nr;
-   struct block_device *bdev = inode->i_sb->s_bdev;
struct f2fs_map_blocks map;
 
map.m_pblk = 0;
@@ -1048,31 +1078,9 @@ submit_and_realloc:
bio = NULL;
}
if (bio == NULL) {
-   struct fscrypt_ctx *ctx = NULL;
-
-   if (f2fs_encrypted_inode(inode) &&
-   S_ISREG(inode->i_mode)) {
-
-   ctx = fscrypt_get_ctx(inode, GFP_NOFS);
-   if (IS_ERR(ctx))
-   goto set_error_page;
-
-   /* wait the page to be moved by cleaning */
-   f2fs_wait_on_encrypted_page_writeback(
-   F2FS_I_SB(inode), block_nr);
-   }
-
-   bio = bio_alloc(GFP_KERNEL,
-   min_t(int, nr_pages, BIO_MAX_PAGES));
-   if (!bio) {
-   if (ctx)
-   fscrypt_release_ctx(ctx);
+   bio = f2fs_grab_bio(inode, block_nr, nr_pages);
+   if (IS_ERR(bio))
goto set_error_page;
-   }
-   bio->bi_bdev = bdev;
-   bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(block_nr);
-   bio->bi_end_io = f2fs_read_end_io;
-   bio->bi_private = ctx;
}
 
if (bio_add_page(bio, page, blocksize, 0) < blocksize)
@@ -1622,18 +1630,21 @@ repeat:
if (blkaddr == NEW_ADDR) {
zero_user_segment(page, 0, PAGE_SIZE);
} else {
-   struct f2fs_io_info fio = {
-   .sbi = sbi,
-   .type = DATA,
-   .rw = READ_SYNC,
-   .old_blkaddr = blkaddr,
-   .new_blkaddr = blkaddr,
-   .page = page,
-   .encrypted_page = NULL,
-   };
-   err = f2fs_submit_page_bio(&fio);
-   if (err)
+   struct bio *bio;
+
+   bio = f

[PATCH 2/4] f2fs: fix to detect truncation prior rather than EIO during read

2016-07-03 Thread Chao Yu
From: Chao Yu 

In procedure of synchonized read, after sending out the read request, reader
will try to lock the page for waiting device to finish the read jobs and
unlock the page, but meanwhile, truncater will race with reader, so after
reader get lock of the page, it should check page's mapping to detect
whether someone has truncated the page in advance, then reader has the
chance to do the retry if truncation was done, otherwise read can be failed
due to previous condition check.

Signed-off-by: Chao Yu 
---
 fs/f2fs/data.c | 16 
 fs/f2fs/gc.c   |  4 ++--
 fs/f2fs/node.c |  6 +++---
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 2bfb4f1..1a4700c 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -500,14 +500,14 @@ repeat:
 
/* wait for read completion */
lock_page(page);
-   if (unlikely(!PageUptodate(page))) {
-   f2fs_put_page(page, 1);
-   return ERR_PTR(-EIO);
-   }
if (unlikely(page->mapping != mapping)) {
f2fs_put_page(page, 1);
goto repeat;
}
+   if (unlikely(!PageUptodate(page))) {
+   f2fs_put_page(page, 1);
+   return ERR_PTR(-EIO);
+   }
return page;
 }
 
@@ -1647,14 +1647,14 @@ repeat:
__submit_bio(sbi, READ_SYNC, bio, DATA);
 
lock_page(page);
-   if (unlikely(!PageUptodate(page))) {
-   err = -EIO;
-   goto fail;
-   }
if (unlikely(page->mapping != mapping)) {
f2fs_put_page(page, 1);
goto repeat;
}
+   if (unlikely(!PageUptodate(page))) {
+   err = -EIO;
+   goto fail;
+   }
}
 out_update:
SetPageUptodate(page);
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index a15ae8a..d888490 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -593,11 +593,11 @@ static void move_encrypted_block(struct inode *inode, 
block_t bidx)
/* write page */
lock_page(fio.encrypted_page);
 
-   if (unlikely(!PageUptodate(fio.encrypted_page))) {
+   if (unlikely(fio.encrypted_page->mapping != META_MAPPING(fio.sbi))) {
err = -EIO;
goto put_page_out;
}
-   if (unlikely(fio.encrypted_page->mapping != META_MAPPING(fio.sbi))) {
+   if (unlikely(!PageUptodate(fio.encrypted_page))) {
err = -EIO;
goto put_page_out;
}
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 729fb1e..69171ce 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1146,13 +1146,13 @@ repeat:
 
lock_page(page);
 
-   if (unlikely(!PageUptodate(page)))
-   goto out_err;
-
if (unlikely(page->mapping != NODE_MAPPING(sbi))) {
f2fs_put_page(page, 1);
goto repeat;
}
+
+   if (unlikely(!PageUptodate(page)))
+   goto out_err;
 page_hit:
if(unlikely(nid != nid_of_node(page))) {
f2fs_bug_on(sbi, 1);
-- 
2.7.2



[PATCH 4/4] f2fs: add nodiscard mount option

2016-07-03 Thread Chao Yu
From: Chao Yu 

This patch adds 'nodiscard' mount option.

Signed-off-by: Chao Yu 
---
 Documentation/filesystems/f2fs.txt | 4 +++-
 fs/f2fs/super.c| 4 
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/Documentation/filesystems/f2fs.txt 
b/Documentation/filesystems/f2fs.txt
index 3a5ce24..ecd8080 100644
--- a/Documentation/filesystems/f2fs.txt
+++ b/Documentation/filesystems/f2fs.txt
@@ -109,7 +109,9 @@ background_gc=%s   Turn on/off cleaning operations, 
namely garbage
 disable_roll_forward   Disable the roll-forward recovery routine
 norecovery Disable the roll-forward recovery routine, mounted read-
only (i.e., -o ro,disable_roll_forward)
-discardIssue discard/TRIM commands when a segment is cleaned.
+discard/nodiscard  Enable/disable real-time discard in f2fs, if discard is
+   enabled, f2fs will issue discard/TRIM commands when a
+  segment is cleaned.
 no_heapDisable heap-style segment allocation which finds free
segments for data from the beginning of main area, while
   for node from the end of main area.
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 512bbb4..7b9b0c9 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -76,6 +76,7 @@ enum {
Opt_disable_roll_forward,
Opt_norecovery,
Opt_discard,
+   Opt_nodiscard,
Opt_noheap,
Opt_user_xattr,
Opt_nouser_xattr,
@@ -106,6 +107,7 @@ static match_table_t f2fs_tokens = {
{Opt_disable_roll_forward, "disable_roll_forward"},
{Opt_norecovery, "norecovery"},
{Opt_discard, "discard"},
+   {Opt_nodiscard, "nodiscard"},
{Opt_noheap, "no_heap"},
{Opt_user_xattr, "user_xattr"},
{Opt_nouser_xattr, "nouser_xattr"},
@@ -426,6 +428,8 @@ static int parse_options(struct super_block *sb, char 
*options)
"the device does not support discard");
}
break;
+   case Opt_nodiscard:
+   clear_opt(sbi, DISCARD);
case Opt_noheap:
set_opt(sbi, NOHEAP);
break;
-- 
2.7.2



Re: [PATCH v4 10/29] x86/die: Don't try to recover from an OOPS on a non-default stack

2016-07-03 Thread Andy Lutomirski
On Sat, Jul 2, 2016 at 11:34 AM, Josh Poimboeuf  wrote:
> On Sat, Jul 02, 2016 at 07:24:41PM +0200, Borislav Petkov wrote:
>> On Sun, Jun 26, 2016 at 02:55:32PM -0700, Andy Lutomirski wrote:
>> > It's not going to work, because the scheduler will explode if we try
>> > to schedule when running on an IST stack or similar.
>> >
>> > This will matter when we let kernel stack overflows (which are #DF)
>> > call die().
>> >
>> > Signed-off-by: Andy Lutomirski 
>> > ---
>> >  arch/x86/kernel/dumpstack.c | 3 +++
>> >  1 file changed, 3 insertions(+)
>> >
>> > diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
>> > index ef8017ca5ba9..352f022cfd5b 100644
>> > --- a/arch/x86/kernel/dumpstack.c
>> > +++ b/arch/x86/kernel/dumpstack.c
>> > @@ -245,6 +245,9 @@ void oops_end(unsigned long flags, struct pt_regs 
>> > *regs, int signr)
>> > return;
>> > if (in_interrupt())
>> > panic("Fatal exception in interrupt");
>> > +   if (((current_stack_pointer() ^ (current_top_of_stack() - 1))
>> > +& ~(THREAD_SIZE - 1)) != 0)
>>
>> Ugh, that's hard to parse. You could remove the "!= 0" at least to
>> shorten it a bit and have one less braces level.
>>
>> Or maybe even do something like that to make it a bit more readable:
>>
>> if ((current_stack_pointer() ^ (current_top_of_stack() - 1))
>> &
>>  ~(THREAD_SIZE - 1))
>> panic("Fatal exception on non-default stack");
>>
>> Meh.
>
> A helper function would be even better.
>
> The existing 'object_is_on_stack()' can probably be used:
>
> if (!object_is_on_stack(current_top_of_stack()))
> panic("...");
>
> Though that function isn't quite accurately named.  It should really
> have 'task_stack' in its name, like 'object_is_on_task_stack()'.  Or
> even better, something more concise like 'on_task_stack()'.
>

Given that the very next patch deletes this code, I vote for leaving
it alone.  Or I could fold the patches together.

--Andy


Re: [PATCH 1/6] x86: fix duplicated X86_BUG(9) macro

2016-07-03 Thread Andy Lutomirski
On Jul 1, 2016 9:47 AM, "Borislav Petkov"  wrote:
>
> On Fri, Jul 01, 2016 at 09:30:37AM -0700, Andy Lutomirski wrote:
> > I put the ifdef there to prevent anyone from accidentally using it in
> > a 64-bit code path, not to save a bit.  We could put in the middle of
> > the list to make the mistake much less likely to be repeated, I
> > suppose.
>
> Well, if someone does, someone will notice pretty soon, no?

Dunno.  ESPFIX was broken under KVM for years and no one notices.

>
> I just don't see the reason to worry but maybe I'm missing it.
>
> And we can call it X86_BUG_ESPFIX_X86_32 or so too...

We could do that, too, I guess.  But the current solution is only two
extra lines of code.  We could reorder the things so that it's in the
middle instead of at the end, I suppose.

--Andy


Re: [PATCH] capabilities: add capability cgroup controller

2016-07-03 Thread Topi Miettinen
On 06/27/16 19:49, Serge E. Hallyn wrote:
> Quoting Tejun Heo (t...@kernel.org):
>> Hello,
>>
>> On Mon, Jun 27, 2016 at 3:10 PM, Topi Miettinen  wrote:
>>> I'll have to study these more. But from what I saw so far, it looks to
>>> me that a separate tool would be needed to read taskstats and if that
>>> tool is not taken by distros, the users would not be any wiser, right?
>>> With cgroup (or /proc), no new tools would be needed.
>>
>> That is a factor but shouldn't be a deciding factor in designing our
>> user-facing interfaces. Please also note that kernel source tree
>> already has tools/ subdirectory which contains userland tools which
>> are distributed along with the kernel.
> 
> And, if you take audit+cgroup approach then no tools are needed.  So long
> as you can have audit print out the cgroups for a task as part of the
> capability audit record.
> 

The attached patch would make any uses of capabilities generate audit
messages. It works for simple tests as you can see from the commit
message, but unfortunately the call to audit_cgroup_list() deadlocks the
system when booting a full blown OS. There's no deadlock when the call
is removed.

I guess that in some cases, cgroup_mutex and/or css_set_lock could be
already held earlier before entering audit_cgroup_list(). Holding the
locks is however required by task_cgroup_from_root(). Is there any way
to avoid this? For example, only print some kind of cgroup ID numbers
(are there unique and stable IDs, available without locks?) for those
cgroups where the task is registered in the audit message?

I could remove the cgroup part from the audit message entirely, but then
knowing which capabilities were used in what cgroup gets much more
difficult. The rest of the patch would be useful without it and of
course simpler.

In my earlier versions a per-task cap_used variable summarized all uses
of capabilities, but it was not clear when to reset the variable (fork?
exec? capset?), so it's gone for now. This was also used to rate limit
printing audit messages by only acting when each capability was first
used by the task, but now all uses of capabilities trigger audit
logging. Could that become a problem? I think it only makes sense to
summarize capability use per cgroup (via taskstats).

-Topi

>From 2d5248f91998873174dbcbcafe87e5b30c3858aa Mon Sep 17 00:00:00 2001
From: Topi Miettinen 
Date: Sat, 2 Jul 2016 16:25:20 +0300
Subject: [PATCH] capabilities: audit capability use

There are many basic ways to control processes, including capabilities,
cgroups and resource limits. However, there are far fewer ways to find
out useful values for the limits, except blind trial and error.

Currently, there is no way to know which capabilities are actually used.
Even the source code is only implicit, in-depth knowledge of each
capability must be used when analyzing a program to judge which
capabilities the program will exercise.

Generate an audit message when capabilities are used. This can then be
used to configure capability sets for services by a software developer,
maintainer or system administrator.

Test case demonstrating basic capability monitoring with the new
message type 1330 and how the cgroups are displayed (boot to rdshell):

BusyBox v1.22.1 (Debian 1:1.22.0-19) built-in shell (ash)
Enter 'help' for a list of built-in commands.

(initramfs) cd /sys/fs
(initramfs) mount -t cgroup2 cgroup cgroup
[   16.503902] audit_printk_skb: 4026 callbacks suppressed
[   16.505059] audit: type=1330 audit(1467543885.733:469): cap_used=21 pid=214 auid=4294967295 uid=0 gid=0 ses=4294967295 cgroups=
[   16.506845] audit: type=1330 audit(1467543885.733:469): cap_used=21 pid=214 auid=4294967295 uid=0 gid=0 ses=4294967295 cgroups=
[   16.509234] audit: type=1300 audit(1467543885.733:469): arch=c03e syscall=165 success=yes exit=0 a0=7ffc2f394e2d a1=7ffc2f394e34 a2=7ffc2f394e25 a3=8000 items=0 ppid=213 pid=214 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=ttyS0 ses=4294967295 comm="mount" exe="/bin/mount" key=(null)
[   16.510134] audit: type=1327 audit(1467543885.733:469): proctitle=6D6F756E74002D74006367726F757032006367726F7570006367726F7570
(initramfs) cd cgroup
(initramfs) mkdir test; cd test
[   16.533829] audit: type=1330 audit(1467543885.765:470): cap_used=1 pid=215 auid=4294967295 uid=0 gid=0 ses=4294967295 cgroups=:/;
[   16.536587] audit: type=1300 audit(1467543885.765:470): arch=c03e syscall=83 success=yes exit=0 a0=7ffe4f0bfe29 a1=1ff a2=0 a3=1e2 items=0 ppid=213 pid=215 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=ttyS0 ses=4294967295 comm="mkdir" exe="/bin/mkdir" key=(null)
[   16.537263] audit: type=1327 audit(1467543885.765:470): proctitle=6D6B6469720074657374
(initramfs) echo $$ >cgroup.procs
(initramfs) mknod /dev/z_$$ c 1 2
[   16.571516] audit: type=1330 audit(1467543885.801:471): cap_used=27 pid=216 auid=4294967295 uid=0 gid=0 ses=4294967295 cgroups=:/test;
[   16.572812] audit: type=1300 aud

Re: [PATCH] Exchange the Assignments of `MEMORYs' and `CFGs/IOs' in Designware PCIe Driver

2016-07-03 Thread Pratyush Anand
On Tue, Jun 28, 2016 at 1:42 PM, dongbo (E)  wrote:
>
> From: Dong Bo 
>
> In designware PCIe driver, the iatu0 is used for both CFG and IO accesses.
> When sending CFGs to peripherals (e.g. lspci), iatu0 frequently switches
> between CFG and IO alternatively.
>
> A MEMORY probably be sent as an IOs by mistake. Considering the following
> configurations:
> MEMORY  ->  BASE_ADDR: 0xb410, LIMIT: 0xb4100FFF, TYPE=mem
> CFG ->  BASE_ADDR: 0xb400, LIMIT: 0xb4000FFF, TYPE=cfg
> IO  ->  BASE_ADDR: 0x, LIMIT: 0xFFFE, TYPE=io
>
> Suppose PCIe has just completed a CFG access, to switch back to IO, it set
> the BASE_ADDR to 0x, LIMIT 0xFFFE and TYPE to io. When another
> CFG comes, the BASE_ADDR is set to 0xb400 to switch to CFG. At this
> moment, a MEMORY access shows up, since it matches with iatu0
> (due to 0xb400 <= MEMORY BASE_ADDR <= MEMORY LIMIE <= 0xFFF), it
> is treated as an IO access by mistake, then sent to perpheral.
>
> This patch fixes the problem by exchanging the assignments of `MEMORYs'
> and `CFGs/IOs', which assigning MEMEORYs to iatu0, CFGs and IOs to iatu1.


Had a re-thought on it. While it will fix wrong memory access in your
case, it can still cause issues with IO access for some other
platform.

Can you please test [1] and check it that works for you. You will need
to define num-viewport in your device tree file.

~Pratyush

[1] 
https://github.com/pratyushanand/linux/commit/131b83ea7db0834d77ee5df65c6696bccbf8a1ce


[PATCH] befs: make consistent use of befs_error()

2016-07-03 Thread Luis de Bethencourt
befs_error() is used in potential errors that could happen in befs to
provide informational log messages. befs_debug() is silent when
CONFIG_BEFS_DEBUG=no, and very verbose when switched on, which is why it is
used for general debugging but not for errors.

Fix a few cases where the befs debug utility usage isn't following the
expected pattern. To make sure we have consistent information in the logs.

Signed-off-by: Luis de Bethencourt 
---

Hi again :)

While playing with the file system and reading the logs I realized that there
were a few inconsistent uses of the debug utilities. Cleaning this for proper
logging.

befs_debug() is a really nice way to see how the internals of the file system
operate, but very verbose, we don't want to hide errors in the noise.

Thanks,
Luis

 fs/befs/btree.c  | 6 --
 fs/befs/datastream.c | 5 -
 fs/befs/linuxvfs.c   | 2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/fs/befs/btree.c b/fs/befs/btree.c
index 307645f9..679f69d 100644
--- a/fs/befs/btree.c
+++ b/fs/befs/btree.c
@@ -301,7 +301,8 @@ befs_btree_find(struct super_block *sb, const 
befs_data_stream *ds,
kfree(this_node);
 
if (res != BEFS_BT_MATCH) {
-   befs_debug(sb, "<--- %s Key %s not found", __func__, key);
+   befs_error(sb, "<--- %s Key %s not found", __func__, key);
+   befs_debug(sb, "<--- %s ERROR", __func__);
*value = 0;
return BEFS_BT_NOT_FOUND;
}
@@ -358,7 +359,8 @@ befs_find_key(struct super_block *sb, struct 
befs_btree_node *node,
 
eq = befs_compare_strings(thiskey, keylen, findkey, findkey_len);
if (eq < 0) {
-   befs_debug(sb, "<--- %s %s not found", __func__, findkey);
+   befs_error(sb, "<--- %s %s not found", __func__, findkey);
+   befs_debug(sb, "<--- %s ERROR", __func__);
return BEFS_BT_NOT_FOUND;
}
 
diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c
index 26cc417..740fabc 100644
--- a/fs/befs/datastream.c
+++ b/fs/befs/datastream.c
@@ -275,6 +275,8 @@ befs_find_brun_direct(struct super_block *sb, const 
befs_data_stream *data,
}
}
 
+   befs_error(sb, "%s failed to find file block %lu", __func__,
+  (unsigned long)blockno);
befs_debug(sb, "---> %s ERROR", __func__);
return BEFS_ERR;
 }
@@ -328,9 +330,10 @@ befs_find_brun_indirect(struct super_block *sb,
for (i = 0; i < indirect.len; i++) {
indirblock = sb_bread(sb, indirblockno + i);
if (indirblock == NULL) {
-   befs_debug(sb, "---> %s failed to read "
+   befs_error(sb, "---> %s failed to read "
   "disk block %lu from the indirect brun",
   __func__, (unsigned long)indirblockno + i);
+   befs_debug(sb, "<--- %s ERROR", __func__);
return BEFS_ERR;
}
 
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 619b998..6527764 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -187,7 +187,7 @@ befs_lookup(struct inode *dir, struct dentry *dentry, 
unsigned int flags)
return ERR_PTR(-ENOENT);
 
} else if (ret != BEFS_OK || offset == 0) {
-   befs_warning(sb, "<--- %s Error", __func__);
+   befs_error(sb, "<--- %s Error", __func__);
return ERR_PTR(-ENODATA);
}
 
-- 
2.5.1



[PATCH 2/2] net: ethernet: bcmgenet: use phy_ethtool_{get|set}_link_ksettings

2016-07-03 Thread Philippe Reynes
There are two generics functions phy_ethtool_{get|set}_link_ksettings,
so we can use them instead of defining the same code in the driver.

Signed-off-by: Philippe Reynes 
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c |   28 +--
 1 files changed, 2 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c 
b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 8d4f849..76ed6df 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -450,30 +450,6 @@ static inline void bcmgenet_rdma_ring_writel(struct 
bcmgenet_priv *priv,
genet_dma_ring_regs[r]);
 }
 
-static int bcmgenet_get_settings(struct net_device *dev,
-struct ethtool_cmd *cmd)
-{
-   if (!netif_running(dev))
-   return -EINVAL;
-
-   if (!dev->phydev)
-   return -ENODEV;
-
-   return phy_ethtool_gset(dev->phydev, cmd);
-}
-
-static int bcmgenet_set_settings(struct net_device *dev,
-struct ethtool_cmd *cmd)
-{
-   if (!netif_running(dev))
-   return -EINVAL;
-
-   if (!dev->phydev)
-   return -ENODEV;
-
-   return phy_ethtool_sset(dev->phydev, cmd);
-}
-
 static int bcmgenet_set_rx_csum(struct net_device *dev,
netdev_features_t wanted)
 {
@@ -977,8 +953,6 @@ static struct ethtool_ops bcmgenet_ethtool_ops = {
.get_strings= bcmgenet_get_strings,
.get_sset_count = bcmgenet_get_sset_count,
.get_ethtool_stats  = bcmgenet_get_ethtool_stats,
-   .get_settings   = bcmgenet_get_settings,
-   .set_settings   = bcmgenet_set_settings,
.get_drvinfo= bcmgenet_get_drvinfo,
.get_link   = ethtool_op_get_link,
.get_msglevel   = bcmgenet_get_msglevel,
@@ -990,6 +964,8 @@ static struct ethtool_ops bcmgenet_ethtool_ops = {
.nway_reset = bcmgenet_nway_reset,
.get_coalesce   = bcmgenet_get_coalesce,
.set_coalesce   = bcmgenet_set_coalesce,
+   .get_link_ksettings = phy_ethtool_get_link_ksettings,
+   .set_link_ksettings = phy_ethtool_set_link_ksettings,
 };
 
 /* Power down the unimac, based on mode. */
-- 
1.7.4.4



[PATCH 1/2] net: ethernet: bcmgenet: use phydev from struct net_device

2016-07-03 Thread Philippe Reynes
The private structure contain a pointer to phydev, but the structure
net_device already contain such pointer. So we can remove the pointer
phy in the private structure, and update the driver to use the
one contained in struct net_device.

Signed-off-by: Philippe Reynes 
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c |   45 ++-
 drivers/net/ethernet/broadcom/genet/bcmgenet.h |1 -
 drivers/net/ethernet/broadcom/genet/bcmmii.c   |   24 ++---
 3 files changed, 31 insertions(+), 39 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c 
b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 5414563..8d4f849 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -453,29 +453,25 @@ static inline void bcmgenet_rdma_ring_writel(struct 
bcmgenet_priv *priv,
 static int bcmgenet_get_settings(struct net_device *dev,
 struct ethtool_cmd *cmd)
 {
-   struct bcmgenet_priv *priv = netdev_priv(dev);
-
if (!netif_running(dev))
return -EINVAL;
 
-   if (!priv->phydev)
+   if (!dev->phydev)
return -ENODEV;
 
-   return phy_ethtool_gset(priv->phydev, cmd);
+   return phy_ethtool_gset(dev->phydev, cmd);
 }
 
 static int bcmgenet_set_settings(struct net_device *dev,
 struct ethtool_cmd *cmd)
 {
-   struct bcmgenet_priv *priv = netdev_priv(dev);
-
if (!netif_running(dev))
return -EINVAL;
 
-   if (!priv->phydev)
+   if (!dev->phydev)
return -ENODEV;
 
-   return phy_ethtool_sset(priv->phydev, cmd);
+   return phy_ethtool_sset(dev->phydev, cmd);
 }
 
 static int bcmgenet_set_rx_csum(struct net_device *dev,
@@ -941,7 +937,7 @@ static int bcmgenet_get_eee(struct net_device *dev, struct 
ethtool_eee *e)
e->eee_active = p->eee_active;
e->tx_lpi_timer = bcmgenet_umac_readl(priv, UMAC_EEE_LPI_TIMER);
 
-   return phy_ethtool_get_eee(priv->phydev, e);
+   return phy_ethtool_get_eee(dev->phydev, e);
 }
 
 static int bcmgenet_set_eee(struct net_device *dev, struct ethtool_eee *e)
@@ -958,7 +954,7 @@ static int bcmgenet_set_eee(struct net_device *dev, struct 
ethtool_eee *e)
if (!p->eee_enabled) {
bcmgenet_eee_enable_set(dev, false);
} else {
-   ret = phy_init_eee(priv->phydev, 0);
+   ret = phy_init_eee(dev->phydev, 0);
if (ret) {
netif_err(priv, hw, dev, "EEE initialization failed\n");
return ret;
@@ -968,14 +964,12 @@ static int bcmgenet_set_eee(struct net_device *dev, 
struct ethtool_eee *e)
bcmgenet_eee_enable_set(dev, true);
}
 
-   return phy_ethtool_set_eee(priv->phydev, e);
+   return phy_ethtool_set_eee(dev->phydev, e);
 }
 
 static int bcmgenet_nway_reset(struct net_device *dev)
 {
-   struct bcmgenet_priv *priv = netdev_priv(dev);
-
-   return genphy_restart_aneg(priv->phydev);
+   return genphy_restart_aneg(dev->phydev);
 }
 
 /* standard ethtool support functions. */
@@ -1002,12 +996,13 @@ static struct ethtool_ops bcmgenet_ethtool_ops = {
 static int bcmgenet_power_down(struct bcmgenet_priv *priv,
enum bcmgenet_power_mode mode)
 {
+   struct net_device *ndev = priv->dev;
int ret = 0;
u32 reg;
 
switch (mode) {
case GENET_POWER_CABLE_SENSE:
-   phy_detach(priv->phydev);
+   phy_detach(ndev->phydev);
break;
 
case GENET_POWER_WOL_MAGIC:
@@ -1068,7 +1063,6 @@ static void bcmgenet_power_up(struct bcmgenet_priv *priv,
 /* ioctl handle special commands that are not present in ethtool. */
 static int bcmgenet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-   struct bcmgenet_priv *priv = netdev_priv(dev);
int val = 0;
 
if (!netif_running(dev))
@@ -1078,10 +1072,10 @@ static int bcmgenet_ioctl(struct net_device *dev, 
struct ifreq *rq, int cmd)
case SIOCGMIIPHY:
case SIOCGMIIREG:
case SIOCSMIIREG:
-   if (!priv->phydev)
+   if (!dev->phydev)
val = -ENODEV;
else
-   val = phy_mii_ioctl(priv->phydev, rq, cmd);
+   val = phy_mii_ioctl(dev->phydev, rq, cmd);
break;
 
default:
@@ -2464,6 +2458,7 @@ static void bcmgenet_irq_task(struct work_struct *work)
 {
struct bcmgenet_priv *priv = container_of(
work, struct bcmgenet_priv, bcmgenet_irq_work);
+   struct net_device *ndev = priv->dev;
 
netif_dbg(priv, intr, priv->dev, "%s\n", __func__);
 
@@ -2476,7 +2471,7 @@ static void bcmgenet_irq_task(struct work_struct *work)
 
/* Link UP/DOWN event */
if (priv->irq0_stat & UMAC_IRQ_LINK_EVENT) {
-  

undefined reference to `printk'

2016-07-03 Thread kbuild test robot
Hi,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   4f302921c1458d790ae21147f7043f4e6b6a1085
commit: 5d2acfc7b974bbd3858b4dd3f2cdc6362dd8843a kconfig: make allnoconfig 
disable options behind EMBEDDED and EXPERT
date:   2 years, 3 months ago
config: m32r-allnoconfig (attached as .config)
compiler: m32r-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 5d2acfc7b974bbd3858b4dd3f2cdc6362dd8843a
# save the attached .config to linux build tree
make.cross ARCH=m32r 

All errors (new ones prefixed by >>):

   arch/m32r/kernel/built-in.o: In function `default_eit_handler':
>> (.text+0x3f8): undefined reference to `printk'
   arch/m32r/kernel/built-in.o: In function `default_eit_handler':
   (.text+0x3f8): relocation truncated to fit: R_M32R_26_PCREL_RELA against 
undefined symbol `printk'

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


.config.gz
Description: Binary data


Re: [PATCH 2/3] iio: adc: add support for Allwinner SoCs ADC

2016-07-03 Thread Guenter Roeck

On 07/03/2016 04:54 AM, Jonathan Cameron wrote:

On 28/06/16 09:18, Quentin Schulz wrote:

The Allwinner SoCs all have an ADC that can also act as a touchscreen
controller and a thermal sensor. This patch adds the ADC driver which is
based on the MFD for the same SoCs ADC.

This also registers the thermal adc channel in the iio map array so
iio_hwmon could use it without modifying the Device Tree.

This driver probes on three different platform_device_id to take into
account slight differences between Allwinner SoCs ADCs.

Signed-off-by: Quentin Schulz 

Hi Quentin.

I'm a bit in two minds about some of this.  That temperature sensor is
so obviously meant for hwmon purposes, I'm tempted to suggest it might
actually make sense to put it directly in hwmon rather than using the
bridge.  That obviously makes it less flexible in some ways (i.e. for
use within the thermal subsystem at some point).

Guenter, what do you think?



With the upcoming new hwmon API, thermal registration is handled in the
hwmon core, so that should not be an issue. Besides, other hwmon sensors
already register with the thermal subsystem as well.

This is difficult to evaluate without datasheet; I am not sure if
the chip supports limits or trip points. If it supports trip points,
thermal may be a better target.

Overall it does look like the temperature sensor would warrant
a separate driver. Only question is thermal or hwmon.

Guenter


I'm guessing detailed docs for this part aren't avaiable publicly? :(

So the rest of my comments are kind of predicated on me having roughtly
understood how this device works from the structure of the driver.

The temperature sensor is really effectively as separate ADC?
The main interest in this is for key detection?

Anyhow, if the data flow for the temperatures sensor is not synced with
the other ADC channels, adding buffered (pushed) output from the driver in
future will be fiddly and with a 250Hz device you'll probably want it.
Basically IIO buffered supports assumes each iio device will sample data
at a particular frequency. If channels are not synchronized in that fashion
then you have to register multiple devices or only pick a subset of channels
to export.

For the key detection you have already observed that IIO needs some
additions to be able to have consumers of what we term 'events' e.g. threshold
interrupts.

Looking at the lradc-keys driver in tree, it looks like we only really have
really simple threshold interrups - configured to detect a very low voltage?
+ only one per channel.

So not too nasty a case, but you are right some work is needed in IIO as
we simply don't have a means of passing these on as yet or configuring them
from in kernel consumers.
If we take the easy route and don't demux incoming events then it shouldn't
be too hard to add (demux can follow later).  Hence any client device can try
to enable events it wants, but may get events that other client devices wanted
as well.

Config interface should be much the same as the write support for channels.
Data flow marginally harder, but pretty much a list of callbacks within
iio_push_event.

Not trivial, but not too tricky either.

The events subsystem has a few 'limitations' we need to address long term
but as this is in kernel interface only, we can do this now and fix stuff
up in future without any ABI breakage. (limitations are things like only
one event of a given type and direction per channel - main challenge on
that is finding a way of doing it without abi breakage).

Anyhow, sounds fun - wish I had the time to do it myself!

Otherwise, your remove is never going to work as indio_dev is always NULL.

Jonathan


---
  drivers/iio/adc/Kconfig   |  12 ++
  drivers/iio/adc/Makefile  |   1 +
  drivers/iio/adc/sunxi-gpadc-iio.c | 371 ++
  3 files changed, 384 insertions(+)
  create mode 100644 drivers/iio/adc/sunxi-gpadc-iio.c

diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 82c718c..b7b566a 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -328,6 +328,18 @@ config NAU7802
  To compile this driver as a module, choose M here: the
  module will be called nau7802.

+config SUNXI_ADC
+   tristate "ADC driver for sunxi platforms"
+   depends on IIO
+   depends on MFD_SUNXI_ADC
+   help
+ Say yes here to build support for Allwinner SoCs (A10, A13 and A31)
+ SoCs ADC. This ADC provides 4 channels which can be used as an ADC or
+ as a touchscreen input and one channel for thermal sensor.
+
+  To compile this driver as a module, choose M here: the
+  module will be called sunxi-gpadc-iio.
+
  config PALMAS_GPADC
tristate "TI Palmas General Purpose ADC"
depends on MFD_PALMAS
diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
index 0cb7921..2996a5b 100644
--- a/drivers/iio/adc/Makefile
+++ b/drivers/iio/adc/Makefile
@@ -32,6 +32,7 @@ obj-$(

Re: [3/3] hwmon: iio_hwmon: defer probe when no channel is found

2016-07-03 Thread Guenter Roeck

On 07/03/2016 03:47 AM, Jonathan Cameron wrote:

On 30/06/16 15:51, Guenter Roeck wrote:

On 06/30/2016 06:59 AM, Jonathan Cameron wrote:



On 30 June 2016 04:47:25 BST, Guenter Roeck  wrote:

On Tue, Jun 28, 2016 at 10:18:17AM +0200, Quentin Schulz wrote:

iio_channel_get_all returns -ENODEV when it cannot find either

phandles and

properties in the Device Tree or channels whose consumer_dev_name

matches

iio_hwmon in iio_map_list. The iio_map_list is filled in by iio

drivers

which might be probed after iio_hwmon.

It is better to defer the probe of iio_hwmon if such error is

returned by

iio_channel_get_all in order to let a chance to iio drivers to expose
channels in iio_map_list.

Signed-off-by: Quentin Schulz 
---
   drivers/hwmon/iio_hwmon.c | 5 -
   1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
index b550ba5..c0da4d9 100644
--- a/drivers/hwmon/iio_hwmon.c
+++ b/drivers/hwmon/iio_hwmon.c
@@ -73,8 +73,11 @@ static int iio_hwmon_probe(struct platform_device

*pdev)

   name = dev->of_node->name;

   channels = iio_channel_get_all(dev);
-if (IS_ERR(channels))
+if (IS_ERR(channels)) {
+if (PTR_ERR(channels) == -ENODEV)
+return -EPROBE_DEFER;


The problem, as I see it, is with iio, which should return
-EPROBE_DEFER
in this situation.

Agreed. New fangled stuff this deferred probing :)


We can not convert -ENODEV to -EPROBE_DEFER without risking that the
channels are _really_ not there, which would result in endless
"deferred"
messages.

Hmm not entirely sure how we prevent that happening wherever it is done..



Outch. Better at the source, though. I didn't look at the iio code recently,
but can you detect the defer situation at least with devicetree ?

For non-devicetree situations, the only option I can think of would be
to replace the module initcall with a later initcall. That should solve
the problem if both iio_hwmon and and underlying drivers are built
into the kernel. If iio_hwmon is modular, the only real option I can
see is to make sure that all drivers it needs are loaded first.

Does this make sense ?

I think we need to look in a couple of directions.  Firstly, investigate doing
something similar to gpio and basically move the setup of maps much earlier.
This will replace drivers presenting their own maps

The other direction is to get userspace (i.e. configfs) setup of these maps
working so for cases where it's a bit less hardware defined (i.e. using an
accelerometer as an input device) we can do once we know all devices relevant
are present and instantiate new instances on the fly.

Anyhow, neither is trivial unfortunately.



On a higher level, I think it would be better if the iio-hwmon bridge was tied
to chips (and thus to the chip driver), and not be an independent binding.
No idea if/how we can do that, though.

Guenter



[PATCH] relay: Add global mode support for buffer-only channels

2016-07-03 Thread akash . goel
From: Akash Goel 

The following patch added support to use channels with no associated files.
relay: add buffer-only channels; useful for early logging
This is useful when the exact location of relay file is not known or the
the parent directory of relay file is not available, while creating the
channel and the logging has to start right from the boot.

But there was no provision to use global mode with buffer-only channels,
which is added by this patch, without modifying the interface where initially
there will be a dummy invocation of create_buf_file callback through which
kernel client can convey the need of a global buffer.

For the use case where drivers/kernel clients want a simple interface for the
userspace, which enables them to capture data/logs from relay file in order &
without any post processing, support of Global buffer mode is warranted.

Cc: Eduard - Gabriel Munteanu 
Cc: Tom Zanussi 
Cc: Chris Wilson 
Signed-off-by: Akash Goel 
---
 kernel/relay.c | 32 
 1 file changed, 32 insertions(+)

diff --git a/kernel/relay.c b/kernel/relay.c
index 04d7cf3..b267384 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -451,6 +451,16 @@ static struct rchan_buf *relay_open_buf(struct rchan 
*chan, unsigned int cpu)
if (!dentry)
goto free_buf;
relay_set_buf_dentry(buf, dentry);
+   } else {
+   dentry = chan->cb->create_buf_file(NULL, NULL,
+   S_IRUSR, buf,
+   &chan->is_global);
+   /* We did not expected the client to return a valid dentry,
+* was now just looking for the global info from the client.
+* Now onus is on client only to release this dentry pointer.
+*/
+   if (WARN_ON(dentry))
+   goto free_buf;
}
 
buf->cpu = cpu;
@@ -666,6 +676,27 @@ int relay_late_setup_files(struct rchan *chan,
}
chan->has_base_filename = 1;
chan->parent = parent;
+
+   if (chan->is_global) {
+   if (unlikely(!chan->buf[0])) {
+   WARN_ONCE(1, KERN_ERR "CPU 0 has no buffer!\n");
+   mutex_unlock(&relay_channels_mutex);
+   return -EINVAL;
+}
+
+   dentry = relay_create_buf_file(chan, chan->buf[0], 0);
+
+   if (unlikely(!dentry))
+   err = -EINVAL;
+   else if (WARN_ON(!chan->is_global))
+   err = -EINVAL;
+   else
+   relay_set_buf_dentry(chan->buf[0], dentry);
+
+   mutex_unlock(&relay_channels_mutex);
+   return err;
+   }
+
curr_cpu = get_cpu();
/*
 * The CPU hotplug notifier ran before us and created buffers with
@@ -706,6 +737,7 @@ int relay_late_setup_files(struct rchan *chan,
 
return err;
 }
+EXPORT_SYMBOL_GPL(relay_late_setup_files);
 
 /**
  * relay_switch_subbuf - switch to a new sub-buffer
-- 
1.9.2



Re: [PATCH] capabilities: audit capability use

2016-07-03 Thread kbuild test robot
Hi,

[auto build test ERROR on cgroup/for-next]
[also build test ERROR on v4.7-rc5]
[cannot apply to next-20160701]
[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/Topi-Miettinen/capabilities-audit-capability-use/20160703-231120
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git for-next
config: microblaze-mmu_defconfig (attached as .config)
compiler: microblaze-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=microblaze 

All errors (new ones prefixed by >>):

>> kernel/audit.c:1713:6: error: redefinition of 'audit_log_cap_use'
void audit_log_cap_use(int cap)
 ^
   In file included from kernel/audit.c:59:0:
   include/linux/audit.h:574:20: note: previous definition of 
'audit_log_cap_use' was here
static inline void audit_log_cap_use(int cap)
   ^
   kernel/audit.c: In function 'audit_log_cap_use':
>> kernel/audit.c:1730:2: error: implicit declaration of function 
>> 'audit_cgroup_list' [-Werror=implicit-function-declaration]
 audit_cgroup_list(ab);
 ^
   cc1: some warnings being treated as errors

vim +/audit_log_cap_use +1713 kernel/audit.c

  1707  
  1708  if (log)
  1709  audit_log_format(ab, " cap_fe=%d cap_fver=%x",
  1710   name->fcap.fE, name->fcap_ver);
  1711  }
  1712  
> 1713  void audit_log_cap_use(int cap)
  1714  {
  1715  struct audit_context *context = current->audit_context;
  1716  struct audit_buffer *ab;
  1717  kuid_t uid;
  1718  kgid_t gid;
  1719  
  1720  ab = audit_log_start(context, GFP_KERNEL, AUDIT_CAPABILITY);
  1721  audit_log_format(ab, "cap_used=%d", cap);
  1722  current_uid_gid(&uid, &gid);
  1723  audit_log_format(ab, " pid=%d auid=%u uid=%u gid=%u ses=%u",
  1724   task_pid_nr(current),
  1725   from_kuid(&init_user_ns, 
audit_get_loginuid(current)),
  1726   from_kuid(&init_user_ns, uid),
  1727   from_kgid(&init_user_ns, gid),
  1728   audit_get_sessionid(current));
  1729  audit_log_format(ab, " cgroups=");
> 1730  audit_cgroup_list(ab);
  1731  audit_log_end(ab);
  1732  }
  1733  

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


.config.gz
Description: Binary data


[PATCH] Revert "gpiolib: Split GPIO flags parsing and GPIO configuration"

2016-07-03 Thread Johan Hovold
This reverts commit 923b93e451db876d1479d3e4458fce14fec31d1c.

Make sure consumers do not overwrite gpio flags for pins that have
already been claimed.

While adding support for gpio drivers to refuse a request using
unsupported flags, the order of when the requested flag was checked and
the new flags were applied was reversed to that consumers could
overwrite flags for already requested gpios.

This not only affects device-tree setups where two drivers could request
the same gpio using conflicting configurations, but also allowed user
space to clear gpio flags for already claimed pins simply by attempting
to export them through the sysfs interface. By for example clearing the
FLAG_ACTIVE_LOW flag this way, user space could effectively change the
polarity of a signal.

Reverting this change obviously prevents gpio drivers from doing sanity
checks on the flags in their request callbacks. Fortunately only one
recently added driver (gpio-tps65218 in v4.6) appears to do this, and a
follow up patch could restore this functionality through a different
interface.

Cc: stable  # 4.4
Signed-off-by: Johan Hovold 
---
 drivers/gpio/gpiolib-legacy.c |  8 +++
 drivers/gpio/gpiolib.c| 52 +--
 2 files changed, 20 insertions(+), 40 deletions(-)

diff --git a/drivers/gpio/gpiolib-legacy.c b/drivers/gpio/gpiolib-legacy.c
index 3a5c7011ad3b..8b830996fe02 100644
--- a/drivers/gpio/gpiolib-legacy.c
+++ b/drivers/gpio/gpiolib-legacy.c
@@ -28,6 +28,10 @@ int gpio_request_one(unsigned gpio, unsigned long flags, 
const char *label)
if (!desc && gpio_is_valid(gpio))
return -EPROBE_DEFER;
 
+   err = gpiod_request(desc, label);
+   if (err)
+   return err;
+
if (flags & GPIOF_OPEN_DRAIN)
set_bit(FLAG_OPEN_DRAIN, &desc->flags);
 
@@ -37,10 +41,6 @@ int gpio_request_one(unsigned gpio, unsigned long flags, 
const char *label)
if (flags & GPIOF_ACTIVE_LOW)
set_bit(FLAG_ACTIVE_LOW, &desc->flags);
 
-   err = gpiod_request(desc, label);
-   if (err)
-   return err;
-
if (flags & GPIOF_DIR_IN)
err = gpiod_direction_input(desc);
else
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 570771ed19e6..be74bd370f1f 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1352,14 +1352,6 @@ static int __gpiod_request(struct gpio_desc *desc, const 
char *label)
spin_lock_irqsave(&gpio_lock, flags);
}
 done:
-   if (status < 0) {
-   /* Clear flags that might have been set by the caller before
-* requesting the GPIO.
-*/
-   clear_bit(FLAG_ACTIVE_LOW, &desc->flags);
-   clear_bit(FLAG_OPEN_DRAIN, &desc->flags);
-   clear_bit(FLAG_OPEN_SOURCE, &desc->flags);
-   }
spin_unlock_irqrestore(&gpio_lock, flags);
return status;
 }
@@ -2587,28 +2579,13 @@ struct gpio_desc *__must_check 
gpiod_get_optional(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(gpiod_get_optional);
 
-/**
- * gpiod_parse_flags - helper function to parse GPIO lookup flags
- * @desc:  gpio to be setup
- * @lflags:gpio_lookup_flags - returned from of_find_gpio() or
- * of_get_gpio_hog()
- *
- * Set the GPIO descriptor flags based on the given GPIO lookup flags.
- */
-static void gpiod_parse_flags(struct gpio_desc *desc, unsigned long lflags)
-{
-   if (lflags & GPIO_ACTIVE_LOW)
-   set_bit(FLAG_ACTIVE_LOW, &desc->flags);
-   if (lflags & GPIO_OPEN_DRAIN)
-   set_bit(FLAG_OPEN_DRAIN, &desc->flags);
-   if (lflags & GPIO_OPEN_SOURCE)
-   set_bit(FLAG_OPEN_SOURCE, &desc->flags);
-}
 
 /**
  * gpiod_configure_flags - helper function to configure a given GPIO
  * @desc:  gpio whose value will be assigned
  * @con_id:function within the GPIO consumer
+ * @lflags:gpio_lookup_flags - returned from of_find_gpio() or
+ * of_get_gpio_hog()
  * @dflags:gpiod_flags - optional GPIO initialization flags
  *
  * Return 0 on success, -ENOENT if no GPIO has been assigned to the
@@ -2616,10 +2593,17 @@ static void gpiod_parse_flags(struct gpio_desc *desc, 
unsigned long lflags)
  * occurred while trying to acquire the GPIO.
  */
 static int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,
-enum gpiod_flags dflags)
+   unsigned long lflags, enum gpiod_flags dflags)
 {
int status;
 
+   if (lflags & GPIO_ACTIVE_LOW)
+   set_bit(FLAG_ACTIVE_LOW, &desc->flags);
+   if (lflags & GPIO_OPEN_DRAIN)
+   set_bit(FLAG_OPEN_DRAIN, &desc->flags);
+   if (lflags & GPIO_OPEN_SOURCE)
+   set_bit(FLAG_OPEN_SOURCE, &desc->flags);
+
/* No particular flag request, return here... */
if (!(dflags & GPIOD_FLAGS_BIT_DIR_SET)) {
pr_debug("no fla

[PATCH v5 04/22] sh: Use P1SEGADDR

2016-07-03 Thread Yoshinori Sato
FDT address is P1SEG. So not virtual address.

Signed-off-by: Yoshinori Sato 
---
 arch/sh/kernel/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 86f2792..8e3b099 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -254,7 +254,7 @@ void __ref sh_fdt_init(phys_addr_t dt_phys)
 #ifdef CONFIG_USE_BUILTIN_DTB
dt_virt = __dtb_start;
 #else
-   dt_virt = phys_to_virt(dt_phys);
+   dt_virt = (void *)P1SEGADDR(dt_phys);
 #endif
 
if (!dt_virt || !early_init_dt_scan(dt_virt)) {
-- 
2.7.0



[PATCH v5 00/22] sh: LANDISK and R2Dplus convert to device tree

2016-07-03 Thread Yoshinori Sato
SH get devicetree support. But it not working on existing H/W.

IO-DATA HDL-U (aka landisk) currentry supported.
This H/W like SH7751 evalution board. It's a best to use this as a
change base H/W.
RTS7751R2Dplus is QEMU-SH4 target. So easy trying.

Changes V5
- added "#address-cells" before interrupt-map
- remove interrupt-controller of landisk.dts and r2dplus.dts
- Add ".suppress_bind_attrs" to pci driver.
- some cleanup.

Changes V4
- split board depend patch.
- dts cleanup.

Changes V3
- PCI driver update for v4.7.
- New Clock driver. Unified PLL/Divider.
- R2Dplus support.
- Split DTS.
- Some cleanup.

Changes V2
- split DeviceTree suppoty update.
- PCI driver update.
- Some cleanup.

Yoshinori Sato (22):
  sh: Add sh-specific early_init_dt_reserve_memory_arch
  sh: More early unflatten device tree
  sh: set preset_lpj
  sh: Use P1SEGADDR
  sh: command line passing chosen/bootargs in devicetree
  sh: FDT address save before bank change
  sh: Passing FDT address on zImage
  sh: Disable board specific code on device tree mode
  sh: Use GENERIC_IOMAP on device tree mode
  sh: Add board specific initialize of of-generic
  sh: SH7750/51 CPG Driver
  sh: Add PCI host bridge driver for SH7751
  sh: irqchip: SH7751 IRQCHIP Driver
  sh: SH7751 core dtsi
  sh: Move common PCI stuff to arch/sh/kernel
  pci: pci_config_window move to linux/pci.h
  pci: PCI_HOST_GENERIC enable for SH
  sh: Add separate DTB build rule
  sh: IO-DATA HDL-U (a,k.a landisk) IRQCHIP driver
  sh: IO-DATA HDL-U (a,k.a landisk) DeviceTree
  sh: Renesas RTS7751R2Dplus (a,k.a R2Dplus) IRQCHIP Driver
  sh: Renesas RTS7751R2Dplus (a,k.a R2Dplus) DeviceTree

 .../bindings/clock/renesas,sh7750-cpg.txt  |  25 ++
 .../interrupt-controller/iodata-landisk.txt|  31 ++
 .../interrupt-controller/renesas,sh7751-intc.txt   |  25 ++
 .../interrupt-controller/renesas-r2dplus.txt   |  38 +++
 .../devicetree/bindings/pci/sh7751-pci.txt |  37 +++
 arch/sh/Kconfig|   6 +-
 arch/sh/Makefile   |   9 +
 arch/sh/boards/Kconfig |   4 +
 arch/sh/boards/of-generic.c|  88 +-
 arch/sh/boot/compressed/head_32.S  |   5 +-
 arch/sh/boot/dts/Makefile  |   5 +
 arch/sh/boot/dts/include/dt-bindings   |   1 +
 arch/sh/boot/dts/landisk.dts   |  61 
 arch/sh/boot/dts/r2dplus.dts   |  85 +
 arch/sh/boot/dts/sh7751.dtsi   |  83 +
 arch/sh/drivers/Makefile   |   2 +
 arch/sh/drivers/pci/Makefile   |   2 -
 arch/sh/drivers/pci/common.c   | 162 --
 arch/sh/drivers/pci/pci.c  | 320 ---
 arch/sh/include/asm/io.h   |   6 +
 arch/sh/kernel/Makefile|   2 +
 arch/sh/kernel/cpu/Makefile|   8 +-
 arch/sh/kernel/cpu/clock.c |   6 +-
 arch/sh/kernel/cpu/sh4/Makefile|   2 +
 arch/sh/kernel/head_32.S   |   7 +-
 arch/sh/kernel/pci-common.c| 162 ++
 arch/sh/kernel/pci.c   | 342 
 arch/sh/kernel/setup.c |  15 +-
 drivers/clk/Kconfig|   1 +
 drivers/clk/Makefile   |   3 +-
 drivers/clk/sh/Kconfig |   2 +
 drivers/clk/sh/Makefile|   1 +
 drivers/clk/sh/clk-sh7750cpg.c | 344 +
 drivers/irqchip/Kconfig|   5 +
 drivers/irqchip/Makefile   |   1 +
 drivers/irqchip/irq-io-landisk.c   |  72 +
 drivers/irqchip/irq-renesas-r2dplus.c  |  88 ++
 drivers/irqchip/irq-renesas-sh7751.c   | 141 +
 drivers/pci/ecam.h |  17 +-
 drivers/pci/host/Kconfig   |   9 +-
 drivers/pci/host/Makefile  |   1 +
 drivers/pci/host/pci-sh7751.c  | 326 +++
 include/dt-bindings/clock/renesas-sh7750.h |  26 ++
 include/dt-bindings/interrupt-controller/sh_intc.h |   2 +
 include/linux/pci.h|  18 ++
 45 files changed, 2075 insertions(+), 521 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/clock/renesas,sh7750-cpg.txt
 create mode 100644 
Documentation/devicetree/bindings/interrupt-controller/iodata-landisk.txt
 create mode 100644 
Documentation/devicetree/bindings/interrupt-controller/renesas,sh7751-intc.txt
 create mode 100644 
Documentation/devicetree/bindings/interrupt-controller/renesas-r2dplus.txt
 create mode 100644 Documentation/devicetree/bindings/pci/sh7751-pci.txt
 cre

[PATCH v6 12/22] sh: Add PCI host bridge driver for SH7751

2016-07-03 Thread Yoshinori Sato
This is an alternative SH7751 PCI driver.
Existing driver (arch/sh/drivers/pci/pci-sh7751) uses SH specific interface.
But this driver uses common PCI interface. It is more modern and generic.

Signed-off-by: Yoshinori Sato 
---
 .../devicetree/bindings/pci/sh7751-pci.txt |  37 +++
 arch/sh/boards/Kconfig |   1 +
 arch/sh/drivers/Makefile   |   2 +
 drivers/pci/host/Kconfig   |   7 +
 drivers/pci/host/Makefile  |   1 +
 drivers/pci/host/pci-sh7751.c  | 327 +
 6 files changed, 375 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/sh7751-pci.txt
 create mode 100644 drivers/pci/host/pci-sh7751.c

diff --git a/Documentation/devicetree/bindings/pci/sh7751-pci.txt 
b/Documentation/devicetree/bindings/pci/sh7751-pci.txt
new file mode 100644
index 000..2df9af6
--- /dev/null
+++ b/Documentation/devicetree/bindings/pci/sh7751-pci.txt
@@ -0,0 +1,37 @@
+* Renesas SH7751 PCI host interfaces
+
+Required properties:
+  - compatible: "renesas,sh7751-pci" is required.
+And board specific compatible if fixup required.
+  - reg: contain two entries.
+first entry: PCI controller register base address and length.
+second entry: BUS controller register base address and length.
+  - #address-cells: set to <2>
+  - #size-cells: set to <1>
+  - bus-range: PCI bus numbers covered
+  - device_type: set to "pci"
+  - ranges: ranges for the PCI memory and I/O regions.
+  - interrupt-map-mask and interrupt-map: standard PCI properties
+   to define the mapping of the PCI interface to interrupt
+   numbers.
+
+Example:
+   pci: pci-controller@fe20 {
+   compatible = "renesas,sh7751-pci", "iodata,landisk";
+   device_type = "pci";
+   bus-range = <0 0>;
+   #address-cells = <2>;
+   #size-cells = <1>;
+   ranges = <0x0200 0x 0xfd00 0xfd00 
0x 0x0100>,
+<0x0100 0x 0xfe24 0x 
0x 0x0004>;
+   reg = <0xfe20 0x0400>,
+ <0xff80 0x0030>;
+   #interrupt-cells = <1>;
+   interrupt-map-mask = <0x1800 0 7>;
+   interrupt-map = <0x 0 1 &cpldintc 0 0>,
+   <0x0800 0 1 &cpldintc 1 0>,
+   <0x1000 0 1 &cpldintc 2 0>,
+   <0x1800 0 1 &cpldintc 3 0>,
+   <0x1800 0 2 &cpldintc 0 0>;
+   };
+};
diff --git a/arch/sh/boards/Kconfig b/arch/sh/boards/Kconfig
index b6ff9df..cfde921 100644
--- a/arch/sh/boards/Kconfig
+++ b/arch/sh/boards/Kconfig
@@ -14,6 +14,7 @@ config SH_DEVICE_TREE
select GENERIC_CALIBRATE_DELAY
select GENERIC_IOMAP
select COMMON_CLK
+   select SYS_SUPPORTS_PCI
help
  Select Board Described by Device Tree to build a kernel that
  does not hard-code any board-specific knowledge but instead uses
diff --git a/arch/sh/drivers/Makefile b/arch/sh/drivers/Makefile
index e13f06b..382e86f 100644
--- a/arch/sh/drivers/Makefile
+++ b/arch/sh/drivers/Makefile
@@ -4,7 +4,9 @@
 
 obj-y  += dma/
 
+ifndef CONFIG_SH_DEVICE_TREE
 obj-$(CONFIG_PCI)  += pci/
+endif
 obj-$(CONFIG_SUPERHYWAY)   += superhyway/
 obj-$(CONFIG_PUSH_SWITCH)  += push-switch.o
 obj-$(CONFIG_HEARTBEAT)+= heartbeat.o
diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig
index 5d2374e..df60505 100644
--- a/drivers/pci/host/Kconfig
+++ b/drivers/pci/host/Kconfig
@@ -245,4 +245,11 @@ config PCIE_ARMADA_8K
  Designware hardware and therefore the driver re-uses the
  Designware core functions to implement the driver.
 
+config PCI_SH7751
+   bool "Renesas SH7751 On-Chip PCI controller"
+   depends on OF && SUPERH
+   select PCI_HOST_COMMON
+   help
+ Say Y here if you want PCI support on SH7751.
+
 endmenu
diff --git a/drivers/pci/host/Makefile b/drivers/pci/host/Makefile
index 9c8698e..4681e49 100644
--- a/drivers/pci/host/Makefile
+++ b/drivers/pci/host/Makefile
@@ -29,3 +29,4 @@ obj-$(CONFIG_PCIE_QCOM) += pcie-qcom.o
 obj-$(CONFIG_PCI_HOST_THUNDER_ECAM) += pci-thunder-ecam.o
 obj-$(CONFIG_PCI_HOST_THUNDER_PEM) += pci-thunder-pem.o
 obj-$(CONFIG_PCIE_ARMADA_8K) += pcie-armada8k.o
+obj-$(CONFIG_PCI_SH7751) += pci-sh7751.o
diff --git a/drivers/pci/host/pci-sh7751.c b/drivers/pci/host/pci-sh7751.c
new file mode 100644
index 000..21601f1
--- /dev/null
+++ b/drivers/pci/host/pci-sh7751.c
@@ -0,0 +1,327 @@
+/*
+ * SH7751 PCI driver
+ * Copyright (C) 2016 Yoshinori Sato
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "../ecam.h"
+
+#define SH7751_PCICONF10x4   /* PCI Config Reg 1 */
+#define SH7751_PCICONF4

[PATCH v5 19/22] sh: IO-DATA HDL-U (a.k.a landisk) IRQCHIP driver

2016-07-03 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 .../interrupt-controller/iodata-landisk.txt| 31 ++
 drivers/irqchip/Makefile   |  2 +-
 drivers/irqchip/irq-io-landisk.c   | 72 ++
 3 files changed, 104 insertions(+), 1 deletion(-)
 create mode 100644 
Documentation/devicetree/bindings/interrupt-controller/iodata-landisk.txt
 create mode 100644 drivers/irqchip/irq-io-landisk.c

diff --git 
a/Documentation/devicetree/bindings/interrupt-controller/iodata-landisk.txt 
b/Documentation/devicetree/bindings/interrupt-controller/iodata-landisk.txt
new file mode 100644
index 000..cf461dc
--- /dev/null
+++ b/Documentation/devicetree/bindings/interrupt-controller/iodata-landisk.txt
@@ -0,0 +1,31 @@
+DT bindings for the I/O DATA HDL-U interrupt controller
+
+Required properties:
+
+  - compatible: has to be "iodata,landisk-intc".
+
+  - reg: Base address and length of interrupt controller register.
+
+  - #interrupt-cells: has to be <1>: an interrupt index.
+
+  - #address-cells: has to be <0>
+
+  - interrupt-map: Interrupt mapping on parent controller.
+
+Example
+---
+
+   cpldintc: cpld@b000 {
+   compatible = "iodata,landisk-intc";
+   #interrupt-cells = <1>;
+   #address-cells = <0>;
+   reg = <0xb000 8>;
+   interrupt-map=<0 &shintc evt2irq(0x2a0)>,
+ <1 &shintc evt2irq(0x2c0)>,
+ <2 &shintc evt2irq(0x2e0)>,
+ <3 &shintc evt2irq(0x300)>,
+ <4 &shintc evt2irq(0x320)>,
+ <5 &shintc evt2irq(0x340)>,
+ <6 &shintc evt2irq(0x360)>,
+ <7 &shintc evt2irq(0x380)>;
+   };
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 2ab5735..5e225cf 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -69,4 +69,4 @@ obj-$(CONFIG_PIC32_EVIC)  += irq-pic32-evic.o
 obj-$(CONFIG_MVEBU_ODMI)   += irq-mvebu-odmi.o
 obj-$(CONFIG_LS_SCFG_MSI)  += irq-ls-scfg-msi.o
 obj-$(CONFIG_EZNPS_GIC)+= irq-eznps.o
-obj-$(CONFIG_RENESAS_SH_INTC)  += irq-renesas-sh7751.o
+obj-$(CONFIG_RENESAS_SH_INTC)  += irq-renesas-sh7751.o irq-io-landisk.o
diff --git a/drivers/irqchip/irq-io-landisk.c b/drivers/irqchip/irq-io-landisk.c
new file mode 100644
index 000..b7f3b41
--- /dev/null
+++ b/drivers/irqchip/irq-io-landisk.c
@@ -0,0 +1,72 @@
+/*
+ * IO-DATA LANDISK CPLD IRQ driver
+ *
+ * Copyright 2016 Yoshinori Sato 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static void landisk_mask_irq(struct irq_data *data)
+{
+   u8 mask = __raw_readb(data->chip_data + 5);
+
+   mask &= ~(1 << (data->irq - 5));
+   __raw_writeb(mask, data->chip_data + 5);
+}
+
+static void landisk_unmask_irq(struct irq_data *data)
+{
+   u8 mask = __raw_readb(data->chip_data + 5);
+
+   mask |= (1 << (data->irq - 5));
+   __raw_writeb(mask, data->chip_data + 5);
+}
+
+static struct irq_chip cpld_irq_chip = {
+   .name   = "LANDISK-CPLD",
+   .irq_unmask = landisk_unmask_irq,
+   .irq_mask   = landisk_mask_irq,
+};
+
+static int cpld_map(struct irq_domain *d, unsigned int virq,
+   irq_hw_number_t hw_irq_num)
+{
+   irq_set_chip_and_handler(virq, &cpld_irq_chip,
+handle_simple_irq);
+   irq_set_chip_data(virq, d->host_data);
+
+   return 0;
+}
+
+static struct irq_domain_ops irq_ops = {
+   .xlate  = irq_domain_xlate_onecell,
+   .map= cpld_map,
+};
+
+static int __init landisk_intc_of_init(struct device_node *intc,
+   struct device_node *parent)
+{
+   struct irq_domain *domain, *pdomain;
+   int num_irqpin;
+   void *baseaddr;
+
+   baseaddr = of_iomap(intc, 0);
+   pdomain = irq_find_host(parent);
+   of_get_property(intc, "interrupt-map", &num_irqpin);
+   num_irqpin /= sizeof(u32) * 3;
+   domain = irq_domain_create_hierarchy(pdomain, 0, num_irqpin,
+of_node_to_fwnode(intc),
+&irq_ops, baseaddr);
+   if (!domain)
+   panic("%s: unable to create IRQ domain\n", intc->full_name);
+   irq_domain_associate_many(domain, 5, 0, 8);
+   return 0;
+}
+
+IRQCHIP_DECLARE(cpld_intc, "iodata,landisk-intc", landisk_intc_of_init);
-- 
2.7.0



[PATCH v5 21/22] sh: Renesas RTS7751R2Dplus (a.k.a R2Dplus) IRQCHIP Driver

2016-07-03 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 .../interrupt-controller/renesas-r2dplus.txt   | 38 ++
 drivers/irqchip/Makefile   |  2 +-
 drivers/irqchip/irq-renesas-r2dplus.c  | 88 ++
 3 files changed, 127 insertions(+), 1 deletion(-)
 create mode 100644 
Documentation/devicetree/bindings/interrupt-controller/renesas-r2dplus.txt
 create mode 100644 drivers/irqchip/irq-renesas-r2dplus.c

diff --git 
a/Documentation/devicetree/bindings/interrupt-controller/renesas-r2dplus.txt 
b/Documentation/devicetree/bindings/interrupt-controller/renesas-r2dplus.txt
new file mode 100644
index 000..5b74da4
--- /dev/null
+++ b/Documentation/devicetree/bindings/interrupt-controller/renesas-r2dplus.txt
@@ -0,0 +1,38 @@
+DT bindings for the Renesas R0P751RLC0011RL (R2Dplus) interrupt controller
+
+Required properties:
+
+  - compatible: has to be "renesas,r2dplus-intc".
+
+  - reg: Base address and length of interrupt controller register.
+
+  - #interrupt-cells: has to be <1>: an interrupt index.
+
+  - #address-cells: has to be <0>
+
+  - interrupt-map: Interrupt mapping on parent controller.
+
+Example
+---
+
+   fpgaintc: fpga@a400 {
+   compatible = "renesas,r2dplus-intc";
+   #interrupt-cells = <1>;
+   #address-cells = <0>;
+   reg = <0xa400 0x40>;
+   interrupt-map=<0 &shintc evt2irq(0x200)>,
+ <1 &shintc evt2irq(0x220)>,
+ <2 &shintc evt2irq(0x240)>,
+ <3 &shintc evt2irq(0x260)>,
+ <4 &shintc evt2irq(0x280)>,
+ <5 &shintc evt2irq(0x2a0)>,
+ <6 &shintc evt2irq(0x2c0)>,
+ <7 &shintc evt2irq(0x2e0)>,
+ <8 &shintc evt2irq(0x300)>,
+ <9 &shintc evt2irq(0x320)>,
+ <10 &shintc evt2irq(0x340)>,
+ <11 &shintc evt2irq(0x360)>,
+ <12 &shintc evt2irq(0x380)>,
+ <13 &shintc evt2irq(0x3a0)>,
+ <14 &shintc evt2irq(0x3c0)>,
+   };
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 5e225cf..1e0f1c3 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -69,4 +69,4 @@ obj-$(CONFIG_PIC32_EVIC)  += irq-pic32-evic.o
 obj-$(CONFIG_MVEBU_ODMI)   += irq-mvebu-odmi.o
 obj-$(CONFIG_LS_SCFG_MSI)  += irq-ls-scfg-msi.o
 obj-$(CONFIG_EZNPS_GIC)+= irq-eznps.o
-obj-$(CONFIG_RENESAS_SH_INTC)  += irq-renesas-sh7751.o irq-io-landisk.o
+obj-$(CONFIG_RENESAS_SH_INTC)  += irq-renesas-sh7751.o 
irq-io-landisk.o irq-renesas-r2dplus.o
diff --git a/drivers/irqchip/irq-renesas-r2dplus.c 
b/drivers/irqchip/irq-renesas-r2dplus.c
new file mode 100644
index 000..3f80775
--- /dev/null
+++ b/drivers/irqchip/irq-renesas-r2dplus.c
@@ -0,0 +1,88 @@
+/*
+ * Renesas RTS7751R2D+ FPGA IRQ driver
+ *
+ * Copyright 2016 Yoshinori Sato 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static const u16 mask_bit[] = {
+   BIT(11),
+   BIT(9),
+   BIT(8),
+   BIT(12),
+   BIT(10),
+   BIT(6),
+   BIT(5),
+   BIT(4),
+   BIT(7),
+   BIT(14),
+   BIT(13),
+   BIT(0),
+   BIT(15),
+};
+
+static void r2dplus_mask_irq(struct irq_data *data)
+{
+   u16 mask = __raw_readw(data->chip_data);
+
+   mask &= ~mask_bit[data->irq];
+   __raw_writew(mask, data->chip_data);
+}
+
+static void r2dplus_unmask_irq(struct irq_data *data)
+{
+   u16 mask = __raw_readw(data->chip_data);
+
+   mask |= mask_bit[data->irq];
+   __raw_writew(mask, data->chip_data);
+}
+
+static struct irq_chip fpga_irq_chip = {
+   .name   = "R2DPLUS-FPGA",
+   .irq_unmask = r2dplus_unmask_irq,
+   .irq_mask   = r2dplus_mask_irq,
+};
+
+static int fpga_map(struct irq_domain *d, unsigned int virq,
+   irq_hw_number_t hw_irq_num)
+{
+   irq_set_chip_and_handler(virq, &fpga_irq_chip,
+handle_simple_irq);
+   irq_set_chip_data(virq, d->host_data);
+
+   return 0;
+}
+
+static struct irq_domain_ops irq_ops = {
+   .xlate  = irq_domain_xlate_onecell,
+   .map= fpga_map,
+};
+
+static int __init r2dplus_intc_of_init(struct device_node *intc,
+   struct device_node *parent)
+{
+   struct irq_domain *domain, *pdomain;
+   int num_irqpin;
+   void *baseaddr;
+
+   baseaddr = of_iomap(intc, 0);
+   pdomain = irq_find_host(parent);
+   of_get_property(intc, "interrupt-map", &num_irqpin);
+   num_irqpin /= sizeof(u32) * 3;
+   domain = irq_domain_create_hierarchy(pdomain, 0, num_irqpin,
+   

[PATCH v5 15/22] sh: Move common PCI stuff to arch/sh/kernel

2016-07-03 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 arch/sh/drivers/pci/Makefile |   2 -
 arch/sh/drivers/pci/common.c | 162 
 arch/sh/drivers/pci/pci.c| 320 
 arch/sh/kernel/Makefile  |   2 +
 arch/sh/kernel/pci-common.c  | 162 
 arch/sh/kernel/pci.c | 342 +++
 6 files changed, 506 insertions(+), 484 deletions(-)
 delete mode 100644 arch/sh/drivers/pci/common.c
 delete mode 100644 arch/sh/drivers/pci/pci.c
 create mode 100644 arch/sh/kernel/pci-common.c
 create mode 100644 arch/sh/kernel/pci.c

diff --git a/arch/sh/drivers/pci/Makefile b/arch/sh/drivers/pci/Makefile
index 82f0a33..fffbede 100644
--- a/arch/sh/drivers/pci/Makefile
+++ b/arch/sh/drivers/pci/Makefile
@@ -1,8 +1,6 @@
 #
 # Makefile for the PCI specific kernel interface routines under Linux.
 #
-obj-y  += common.o pci.o
-
 obj-$(CONFIG_CPU_SUBTYPE_SH7751)   += pci-sh7751.o ops-sh4.o
 obj-$(CONFIG_CPU_SUBTYPE_SH7751R)  += pci-sh7751.o ops-sh4.o
 obj-$(CONFIG_CPU_SUBTYPE_SH7763)   += pci-sh7780.o ops-sh4.o
diff --git a/arch/sh/drivers/pci/common.c b/arch/sh/drivers/pci/common.c
deleted file mode 100644
index dbf1381..000
--- a/arch/sh/drivers/pci/common.c
+++ /dev/null
@@ -1,162 +0,0 @@
-#include 
-#include 
-#include 
-#include 
-
-/*
- * These functions are used early on before PCI scanning is done
- * and all of the pci_dev and pci_bus structures have been created.
- */
-static struct pci_dev *fake_pci_dev(struct pci_channel *hose,
-   int top_bus, int busnr, int devfn)
-{
-   static struct pci_dev dev;
-   static struct pci_bus bus;
-
-   dev.bus = &bus;
-   dev.sysdata = hose;
-   dev.devfn = devfn;
-   bus.number = busnr;
-   bus.sysdata = hose;
-   bus.ops = hose->pci_ops;
-
-   if(busnr != top_bus)
-   /* Fake a parent bus structure. */
-   bus.parent = &bus;
-   else
-   bus.parent = NULL;
-
-   return &dev;
-}
-
-#define EARLY_PCI_OP(rw, size, type)   \
-int __init early_##rw##_config_##size(struct pci_channel *hose,
\
-   int top_bus, int bus, int devfn, int offset, type value)\
-{  \
-   return pci_##rw##_config_##size(\
-   fake_pci_dev(hose, top_bus, bus, devfn),\
-   offset, value); \
-}
-
-EARLY_PCI_OP(read, byte, u8 *)
-EARLY_PCI_OP(read, word, u16 *)
-EARLY_PCI_OP(read, dword, u32 *)
-EARLY_PCI_OP(write, byte, u8)
-EARLY_PCI_OP(write, word, u16)
-EARLY_PCI_OP(write, dword, u32)
-
-int __init pci_is_66mhz_capable(struct pci_channel *hose,
-   int top_bus, int current_bus)
-{
-   u32 pci_devfn;
-   unsigned short vid;
-   int cap66 = -1;
-   u16 stat;
-
-   printk(KERN_INFO "PCI: Checking 66MHz capabilities...\n");
-
-   for (pci_devfn = 0; pci_devfn < 0xff; pci_devfn++) {
-   if (PCI_FUNC(pci_devfn))
-   continue;
-   if (early_read_config_word(hose, top_bus, current_bus,
-  pci_devfn, PCI_VENDOR_ID, &vid) !=
-   PCIBIOS_SUCCESSFUL)
-   continue;
-   if (vid == 0x)
-   continue;
-
-   /* check 66MHz capability */
-   if (cap66 < 0)
-   cap66 = 1;
-   if (cap66) {
-   early_read_config_word(hose, top_bus, current_bus,
-  pci_devfn, PCI_STATUS, &stat);
-   if (!(stat & PCI_STATUS_66MHZ)) {
-   printk(KERN_DEBUG
-  "PCI: %02x:%02x not 66MHz capable.\n",
-  current_bus, pci_devfn);
-   cap66 = 0;
-   break;
-   }
-   }
-   }
-
-   return cap66 > 0;
-}
-
-static void pcibios_enable_err(unsigned long __data)
-{
-   struct pci_channel *hose = (struct pci_channel *)__data;
-
-   del_timer(&hose->err_timer);
-   printk(KERN_DEBUG "PCI: re-enabling error IRQ.\n");
-   enable_irq(hose->err_irq);
-}
-
-static void pcibios_enable_serr(unsigned long __data)
-{
-   struct pci_channel *hose = (struct pci_channel *)__data;
-
-   del_timer(&hose->serr_timer);
-   printk(KERN_DEBUG "PCI: re-enabling system error IRQ.\n");
-   enable_irq(hose->serr_irq);
-}
-
-void pcibios_enable_timers(struct pci_channel *hose)
-{
-   if (hose->err_irq) {
-   init_timer(&hose->err_timer);
-   hose->err_timer.data = (unsigned long)hose;
-   hose->err_timer.function = pcibios

[PATCH v5 11/22] sh: SH7750/51 CPG Driver

2016-07-03 Thread Yoshinori Sato
Convert SH specific clock framework to CCF.

Signed-off-by: Yoshinori Sato 
Acked-by: Rob Herring 
---
 .../bindings/clock/renesas,sh7750-cpg.txt  |  25 ++
 arch/sh/boards/Kconfig |   1 +
 arch/sh/kernel/cpu/Makefile|   8 +-
 arch/sh/kernel/cpu/clock.c |   6 +-
 drivers/clk/Kconfig|   1 +
 drivers/clk/Makefile   |   3 +-
 drivers/clk/sh/Kconfig |   2 +
 drivers/clk/sh/Makefile|   1 +
 drivers/clk/sh/clk-sh7750cpg.c | 344 +
 9 files changed, 387 insertions(+), 4 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/clock/renesas,sh7750-cpg.txt
 create mode 100644 drivers/clk/sh/Kconfig
 create mode 100644 drivers/clk/sh/Makefile
 create mode 100644 drivers/clk/sh/clk-sh7750cpg.c

diff --git a/Documentation/devicetree/bindings/clock/renesas,sh7750-cpg.txt 
b/Documentation/devicetree/bindings/clock/renesas,sh7750-cpg.txt
new file mode 100644
index 000..e763e2c
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/renesas,sh7750-cpg.txt
@@ -0,0 +1,25 @@
+* Renesas SH7750/51 CPG
+
+Required Properties:
+
+  - compatible: Must be "renesas,sh7750-cpg"
+
+  - clocks: Reference to the parent clocks (xtal or external)
+
+  - #clock-cells: Must be 1
+
+  - reg: Base address and length of the FREQCR
+ and Base address and length of the CLKSTP00 (optional)
+
+  - renesas,mult: PLL1 multiply rate
+
+Example
+---
+
+cpg: cpg@ffc0 {
+compatible = "renesas,sh7750-cpg";
+clocks = <&oclk>;
+#clock-cells = <1>;
+renesas,mult = <12>;
+reg = <0xffc0 32>, <0xfe0a 16>;
+};
diff --git a/arch/sh/boards/Kconfig b/arch/sh/boards/Kconfig
index 9e4ccd0..b6ff9df 100644
--- a/arch/sh/boards/Kconfig
+++ b/arch/sh/boards/Kconfig
@@ -13,6 +13,7 @@ config SH_DEVICE_TREE
select CLKSRC_OF
select GENERIC_CALIBRATE_DELAY
select GENERIC_IOMAP
+   select COMMON_CLK
help
  Select Board Described by Device Tree to build a kernel that
  does not hard-code any board-specific knowledge but instead uses
diff --git a/arch/sh/kernel/cpu/Makefile b/arch/sh/kernel/cpu/Makefile
index accc7ca..22ad0ee 100644
--- a/arch/sh/kernel/cpu/Makefile
+++ b/arch/sh/kernel/cpu/Makefile
@@ -16,6 +16,10 @@ obj-$(CONFIG_ARCH_SHMOBILE)  += shmobile/
 # Common interfaces.
 
 obj-$(CONFIG_SH_ADC)   += adc.o
+ifndef CONFIG_COMMON_CLK
 obj-$(CONFIG_SH_CLK_CPG_LEGACY)+= clock-cpg.o
-
-obj-y  += irq/ init.o clock.o fpu.o pfc.o proc.o
+endif
+ifndef CONFIG_GENERIC_IRQ_CHIP
+obj-y  += irq/
+endif
+obj-y  += init.o clock.o fpu.o pfc.o proc.o
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index 4187cf4..8e66e23 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -22,13 +22,15 @@
 
 int __init clk_init(void)
 {
-   int ret;
+   int ret = 0;
 
+#ifndef CONFIG_COMMON_CLK
ret = arch_clk_init();
if (unlikely(ret)) {
pr_err("%s: CPU clock registration failed.\n", __func__);
return ret;
}
+#endif
 
if (sh_mv.mv_clk_init) {
ret = sh_mv.mv_clk_init();
@@ -39,11 +41,13 @@ int __init clk_init(void)
}
}
 
+#ifndef CONFIG_COMMON_CLK
/* Kick the child clocks.. */
recalculate_root_clocks();
 
/* Enable the necessary init clocks */
clk_enable_init_clocks();
+#endif
 
return ret;
 }
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 98efbfc..60d19d0 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -213,6 +213,7 @@ source "drivers/clk/mvebu/Kconfig"
 source "drivers/clk/qcom/Kconfig"
 source "drivers/clk/renesas/Kconfig"
 source "drivers/clk/samsung/Kconfig"
+source "drivers/clk/sh/Kconfig"
 source "drivers/clk/tegra/Kconfig"
 source "drivers/clk/ti/Kconfig"
 
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index dcc5e69..c4bfbb9 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -86,5 +86,6 @@ obj-$(CONFIG_COMMON_CLK_VERSATILE)+= versatile/
 obj-$(CONFIG_X86)  += x86/
 obj-$(CONFIG_ARCH_ZX)  += zte/
 obj-$(CONFIG_ARCH_ZYNQ)+= zynq/
-obj-$(CONFIG_H8300)+= h8300/
+obj-$(CONFIG_H8300)+= h8300/
 obj-$(CONFIG_ARC_PLAT_AXS10X)  += axs10x/
+obj-$(CONFIG_SUPERH)   += sh/
diff --git a/drivers/clk/sh/Kconfig b/drivers/clk/sh/Kconfig
new file mode 100644
index 000..2090415
--- /dev/null
+++ b/drivers/clk/sh/Kconfig
@@ -0,0 +1,2 @@
+config COMMON_CLK_SH7750
+   bool "CPG driver for SH7750/SH7751"
diff --git a/drivers/clk/sh/Makefile b/drivers/clk/sh/Makefile
new file mode 100644
index 000..7ce4da3
---

[PATCH v5 13/22] sh: irqchip: SH7751 IRQCHIP Driver

2016-07-03 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
Acked-by: Rob Herring 
---
 .../interrupt-controller/renesas,sh7751-intc.txt   |  25 
 arch/sh/Kconfig|   6 +-
 arch/sh/boards/Kconfig |   1 +
 drivers/irqchip/Kconfig|   5 +
 drivers/irqchip/Makefile   |   1 +
 drivers/irqchip/irq-renesas-sh7751.c   | 141 +
 6 files changed, 176 insertions(+), 3 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/interrupt-controller/renesas,sh7751-intc.txt
 create mode 100644 drivers/irqchip/irq-renesas-sh7751.c

diff --git 
a/Documentation/devicetree/bindings/interrupt-controller/renesas,sh7751-intc.txt
 
b/Documentation/devicetree/bindings/interrupt-controller/renesas,sh7751-intc.txt
new file mode 100644
index 000..2bc6f22f
--- /dev/null
+++ 
b/Documentation/devicetree/bindings/interrupt-controller/renesas,sh7751-intc.txt
@@ -0,0 +1,25 @@
+DT bindings for the SH7751 interrupt controller
+
+Required properties:
+
+  - compatible: has to be "renesas,sh7751-intc".
+
+  - reg: Base address and length of interrupt controller register
+ and extend register.
+
+  - interrupt-controller: Identifies the node as an interrupt controller.
+
+  - #interrupt-cells: has to be <2>: an interrupt index and flags, as defined
+in interrupts.txt in this directory.
+
+Example
+---
+
+   shintc: interrupt-controller@ffd0 {
+   compatible = "renesas,sh7751-intc";
+   #interrupt-cells = <2>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   interrupt-controller;
+   reg = <0xffd0 14>, <0xfe08 128>;
+   };
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index d06cac1..fee4333 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -29,7 +29,7 @@ config SUPERH
select ARCH_WANT_IPC_PARSE_VERSION
select HAVE_SYSCALL_TRACEPOINTS
select HAVE_REGS_AND_STACK_ACCESS_API
-   select MAY_HAVE_SPARSE_IRQ
+   select MAY_HAVE_SPARSE_IRQ if !SH_DEVICE_TREE
select IRQ_FORCED_THREADING
select RTC_LIB
select GENERIC_ATOMIC64
@@ -69,7 +69,7 @@ config SUPERH32
select HAVE_MIXED_BREAKPOINTS_REGS
select PERF_EVENTS
select ARCH_HIBERNATION_POSSIBLE if MMU
-   select SPARSE_IRQ
+   select SPARSE_IRQ if !SH_DEVICE_TREE
select HAVE_CC_STACKPROTECTOR
 
 config SUPERH64
@@ -863,7 +863,7 @@ config PCI
depends on SYS_SUPPORTS_PCI
select PCI_DOMAINS
select GENERIC_PCI_IOMAP
-   select NO_GENERIC_PCI_IOPORT_MAP
+   select NO_GENERIC_PCI_IOPORT_MAP if !SH_DEVICE_TREE
help
  Find out whether you have a PCI motherboard. PCI is the name of a
  bus system, i.e. the way the CPU talks to the other stuff inside
diff --git a/arch/sh/boards/Kconfig b/arch/sh/boards/Kconfig
index cfde921..d33ae46 100644
--- a/arch/sh/boards/Kconfig
+++ b/arch/sh/boards/Kconfig
@@ -15,6 +15,7 @@ config SH_DEVICE_TREE
select GENERIC_IOMAP
select COMMON_CLK
select SYS_SUPPORTS_PCI
+   select GENERIC_IRQ_CHIP
help
  Select Board Described by Device Tree to build a kernel that
  does not hard-code any board-specific knowledge but instead uses
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index fa33c50..fd7f842 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -251,6 +251,11 @@ config LS_SCFG_MSI
depends on PCI && PCI_MSI
select PCI_MSI_IRQ_DOMAIN
 
+config RENESAS_SH_INTC
+   def_bool y if SH_DEVICE_TREE
+   select IRQ_DOMAIN
+   select IRQ_DOMAIN_HIERARCHY
+
 config PARTITION_PERCPU
bool
 
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 38853a1..2ab5735 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -69,3 +69,4 @@ obj-$(CONFIG_PIC32_EVIC)  += irq-pic32-evic.o
 obj-$(CONFIG_MVEBU_ODMI)   += irq-mvebu-odmi.o
 obj-$(CONFIG_LS_SCFG_MSI)  += irq-ls-scfg-msi.o
 obj-$(CONFIG_EZNPS_GIC)+= irq-eznps.o
+obj-$(CONFIG_RENESAS_SH_INTC)  += irq-renesas-sh7751.o
diff --git a/drivers/irqchip/irq-renesas-sh7751.c 
b/drivers/irqchip/irq-renesas-sh7751.c
new file mode 100644
index 000..1710978
--- /dev/null
+++ b/drivers/irqchip/irq-renesas-sh7751.c
@@ -0,0 +1,141 @@
+/*
+ * SH7751 interrupt contoller driver
+ *
+ * Copyright 2016 Yoshinori Sato 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static struct sh7751_intc_regs {
+   void *icr;
+   void *ipr;
+   void *intpri00;
+   void *intreq00;
+   void *intmsk00;
+   void *intmskclr00;
+} sh7751_regs;
+
+static const unsigned int ipr_table[] = {
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0 - 7 */
+   0x41, 0xff, 0xff, 0x40, 0xff, 0xff, 0xff, 0xff, /* 8 - 15 */

[PATCH v5 08/22] sh: Disable board specific code on device tree mode

2016-07-03 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 arch/sh/Makefile| 2 ++
 arch/sh/kernel/cpu/sh4/Makefile | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 3b2c8b4..8adffa8 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -132,6 +132,7 @@ core-$(CONFIG_SH_FPU_EMU)   += arch/sh/math-emu/
 
 core-$(CONFIG_USE_BUILTIN_DTB) += arch/sh/boot/dts/
 
+ifneq ($(CONFIG_SH_DEVICE_TREE),y)
 # Mach groups
 machdir-$(CONFIG_SOLUTION_ENGINE)  += mach-se
 machdir-$(CONFIG_SH_HP6XX) += mach-hp6xx
@@ -152,6 +153,7 @@ machdir-$(CONFIG_SH_LANDISK)+= 
mach-landisk
 machdir-$(CONFIG_SH_LBOX_RE2)  += mach-lboxre2
 machdir-$(CONFIG_SH_CAYMAN)+= mach-cayman
 machdir-$(CONFIG_SH_RSK)   += mach-rsk
+endif
 
 ifneq ($(machdir-y),)
 core-y += $(addprefix arch/sh/boards/, \
diff --git a/arch/sh/kernel/cpu/sh4/Makefile b/arch/sh/kernel/cpu/sh4/Makefile
index 3a1dbc7..b822c0c 100644
--- a/arch/sh/kernel/cpu/sh4/Makefile
+++ b/arch/sh/kernel/cpu/sh4/Makefile
@@ -14,6 +14,7 @@ perf-$(CONFIG_CPU_SUBTYPE_SH7750) := perf_event.o
 perf-$(CONFIG_CPU_SUBTYPE_SH7750S) := perf_event.o
 perf-$(CONFIG_CPU_SUBTYPE_SH7091)  := perf_event.o
 
+ifndef CONFIG_OF
 # CPU subtype setup
 obj-$(CONFIG_CPU_SUBTYPE_SH7750)   += setup-sh7750.o
 obj-$(CONFIG_CPU_SUBTYPE_SH7750R)  += setup-sh7750.o
@@ -31,6 +32,7 @@ endif
 
 # Additional clocks by subtype
 clock-$(CONFIG_CPU_SUBTYPE_SH4_202)+= clock-sh4-202.o
+endif
 
 obj-y  += $(clock-y)
 obj-$(CONFIG_PERF_EVENTS)  += $(perf-y)
-- 
2.7.0



[PATCH v5 16/22] pci: pci_config_window move to linux/pci.h

2016-07-03 Thread Yoshinori Sato
Chanegs v4
none

Signed-off-by: Yoshinori Sato 
---
 drivers/pci/ecam.h  | 17 +
 include/linux/pci.h | 18 ++
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/ecam.h b/drivers/pci/ecam.h
index 9878beb..f110091 100644
--- a/drivers/pci/ecam.h
+++ b/drivers/pci/ecam.h
@@ -18,6 +18,7 @@
 
 #include 
 #include 
+#include 
 
 /*
  * struct to hold pci ops and bus shift of the config window
@@ -31,22 +32,6 @@ struct pci_ecam_ops {
struct pci_config_window *);
 };
 
-/*
- * struct to hold the mappings of a config space window. This
- * is expected to be used as sysdata for PCI controllers that
- * use ECAM.
- */
-struct pci_config_window {
-   struct resource res;
-   struct resource busr;
-   void*priv;
-   struct pci_ecam_ops *ops;
-   union {
-   void __iomem*win;   /* 64-bit single mapping */
-   void __iomem**winp; /* 32-bit per-bus mapping */
-   };
-};
-
 /* create and free pci_config_window */
 struct pci_config_window *pci_ecam_create(struct device *dev,
struct resource *cfgres, struct resource *busr,
diff --git a/include/linux/pci.h b/include/linux/pci.h
index b67e4df..398896f 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -2026,6 +2026,24 @@ static inline bool pci_ari_enabled(struct pci_bus *bus)
return bus->self && bus->self->ari_enabled;
 }
 
+/*
+ * struct to hold the mappings of a config space window. This
+ * is expected to be used as sysdata for PCI controllers that
+ * use ECAM.
+ */
+struct pci_ecam_ops;
+
+struct pci_config_window {
+   struct resource res;
+   struct resource busr;
+   void*priv;
+   struct pci_ecam_ops *ops;
+   union {
+   void __iomem*win;   /* 64-bit single mapping */
+   void __iomem**winp; /* 32-bit per-bus mapping */
+   };
+};
+
 /* provide the legacy pci_dma_* API */
 #include 
 
-- 
2.7.0



[PATCH v5 09/22] sh: Use GENERIC_IOMAP on device tree mode

2016-07-03 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 arch/sh/boards/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/sh/boards/Kconfig b/arch/sh/boards/Kconfig
index 5e52d53..9e4ccd0 100644
--- a/arch/sh/boards/Kconfig
+++ b/arch/sh/boards/Kconfig
@@ -12,6 +12,7 @@ config SH_DEVICE_TREE
select OF_EARLY_FLATTREE
select CLKSRC_OF
select GENERIC_CALIBRATE_DELAY
+   select GENERIC_IOMAP
help
  Select Board Described by Device Tree to build a kernel that
  does not hard-code any board-specific knowledge but instead uses
-- 
2.7.0



[PATCH v5 07/22] sh: Passing FDT address on zImage

2016-07-03 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 arch/sh/boot/compressed/head_32.S | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/sh/boot/compressed/head_32.S 
b/arch/sh/boot/compressed/head_32.S
index 3e15032..a980c48 100644
--- a/arch/sh/boot/compressed/head_32.S
+++ b/arch/sh/boot/compressed/head_32.S
@@ -11,10 +11,11 @@
 
.global startup
 startup:
+   /* Save FDT address */
+   mov r4, r13
/* Load initial status register */
mov.l   init_sr, r1
ldc r1, sr
-
/* Move myself to proper location if necessary */
mova1f, r0
mov.l   1f, r2
@@ -83,7 +84,7 @@ l1:
/* Jump to the start of the decompressed kernel */
mov.l   kernel_start_addr, r0
jmp @r0
-   nop
+movr13,r4

.align  2
 bss_start_addr:
-- 
2.7.0



[PATCH v5 05/22] sh: command line passing chosen/bootargs in devicetree

2016-07-03 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 arch/sh/kernel/setup.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 8e3b099..bdf57e5 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -280,6 +280,7 @@ void __init setup_arch(char **cmdline_p)
 #endif
enable_mmu();
 
+#ifndef CONFIG_OF
ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
 
printk(KERN_NOTICE "Boot params:\n"
@@ -301,6 +302,7 @@ void __init setup_arch(char **cmdline_p)
 
if (!MOUNT_ROOT_RDONLY)
root_mountflags &= ~MS_RDONLY;
+#endif
init_mm.start_code = (unsigned long) _text;
init_mm.end_code = (unsigned long) _etext;
init_mm.end_data = (unsigned long) _edata;
@@ -323,9 +325,13 @@ void __init setup_arch(char **cmdline_p)
 #endif
 #endif
 
+#if !defined(CONFIG_OF) || defined(CONFIG_USE_BUILTIN_DTB)
/* Save unparsed command line copy for /proc/cmdline */
memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
*cmdline_p = command_line;
+#else
+   *cmdline_p = boot_command_line;
+#endif
 
parse_early_param();
 
-- 
2.7.0



[PATCH v5 10/22] sh: Add board specific initialize of of-generic

2016-07-03 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 arch/sh/boards/of-generic.c | 64 +
 1 file changed, 64 insertions(+)

diff --git a/arch/sh/boards/of-generic.c b/arch/sh/boards/of-generic.c
index 2d3cda3..4038682 100644
--- a/arch/sh/boards/of-generic.c
+++ b/arch/sh/boards/of-generic.c
@@ -16,9 +16,15 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
+struct model_setup {
+   char *name;
+   void (*fn)(void);
+};
+
 #ifdef CONFIG_SMP
 
 static void dummy_smp_setup(void)
@@ -125,10 +131,61 @@ static void __init sh_of_time_init(void)
clocksource_probe();
 }
 
+#define PA_LED 0xb001  /* LED Control Register */
+#define PA_SHUTDOWN0xb003  /* Shutdown Control Register */
+static void landisk_power_off(void)
+{
+   __raw_writeb(0x01, PA_SHUTDOWN);
+}
+
+static void __init landisk_setup(void)
+{
+   /* LED ON */
+   __raw_writeb(__raw_readb(PA_LED) | 0x03, PA_LED);
+   pm_power_off = landisk_power_off;
+}
+
+#define PA_POWOFF  0xa430  /* Board Power OFF control */
+#define PA_OUTPORT 0xa436  /* LED control */
+static void rts7751r2d_power_off(void)
+{
+   __raw_writew(0x0001, PA_POWOFF);
+}
+
+static void __init r2dplus_setup(void)
+{
+   void __iomem *sm501_reg;
+
+   __raw_writew(0x, PA_OUTPORT);
+   pm_power_off = rts7751r2d_power_off;
+
+   /* sm501 dram configuration:
+* ColSizeX = 11 - External Memory Column Size: 256 words.
+* APX = 1 - External Memory Active to Pre-Charge Delay: 7 clocks.
+* RstX = 1 - External Memory Reset: Normal.
+* Rfsh = 1 - Local Memory Refresh to Command Delay: 12 clocks.
+* BwC =  1 - Local Memory Block Write Cycle Time: 2 clocks.
+* BwP =  1 - Local Memory Block Write to Pre-Charge Delay: 1 clock.
+* AP = 1 - Internal Memory Active to Pre-Charge Delay: 7 clocks.
+* Rst = 1 - Internal Memory Reset: Normal.
+* RA = 1 - Internal Memory Remain in Active State: Do not remain.
+*/
+
+   sm501_reg = (void __iomem *)0xb3e0 + SM501_DRAM_CONTROL;
+   writel(readl(sm501_reg) | 0x00f107c0, sm501_reg);
+}
+
+static const struct model_setup model_setup_table[] __initconst = {
+   { .name = "iodata,HDL-U", .fn = landisk_setup, },
+   { .name = "renesas,RTS7751R2D+", .fn = r2dplus_setup, },
+   {},
+};
+
 static void __init sh_of_setup(char **cmdline_p)
 {
struct device_node *root;
struct device_node *cpu;
+   const struct model_setup *setup;
u32 freq;
 
board_time_init = sh_of_time_init;
@@ -145,6 +202,13 @@ static void __init sh_of_setup(char **cmdline_p)
cpu = of_find_node_by_name(NULL, "cpu");
if (!of_property_read_u32(cpu, "clock-frequency", &freq))
preset_lpj = freq / CONFIG_HZ / 2;
+
+   for (setup = model_setup_table; setup->name; setup++) {
+   if (strcmp(setup->name, sh_mv.mv_name) == 0) {
+   setup->fn();
+   break;
+   }
+   }
 }
 
 static int sh_of_irq_demux(int irq)
-- 
2.7.0



[PATCH v5 22/22] sh: Renesas RTS7751R2Dplus (a,k.a R2Dplus) DeviceTree

2016-07-03 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 arch/sh/boot/dts/Makefile|  1 +
 arch/sh/boot/dts/r2dplus.dts | 85 
 2 files changed, 86 insertions(+)
 create mode 100644 arch/sh/boot/dts/r2dplus.dts

diff --git a/arch/sh/boot/dts/Makefile b/arch/sh/boot/dts/Makefile
index cf5aec4..e059ce2b 100644
--- a/arch/sh/boot/dts/Makefile
+++ b/arch/sh/boot/dts/Makefile
@@ -1,6 +1,7 @@
 obj-$(CONFIG_USE_BUILTIN_DTB) += $(patsubst 
"%",%,$(CONFIG_BUILTIN_DTB_SOURCE)).dtb.o
 
 dtb-y += landisk.dtb
+otb-y += r2dplus.dtb
 
 dtstree:= $(srctree)/$(src)
 clean-files := *.dtb.S
diff --git a/arch/sh/boot/dts/r2dplus.dts b/arch/sh/boot/dts/r2dplus.dts
new file mode 100644
index 000..f9c01f9
--- /dev/null
+++ b/arch/sh/boot/dts/r2dplus.dts
@@ -0,0 +1,85 @@
+/dts-v1/;
+
+#include "sh7751.dtsi"
+
+/ {
+   model = "renesas,RTS7751R2D+";
+   compatible = "renesas,r2dplus";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   interrupt-parent = <&shintc>;
+   chosen {
+   stdout-path = "serial1:115200n8";
+   };
+   aliases {
+   serial1 = &sci1;
+   };
+
+   memory@0c00 {
+   device_type = "memory";
+   reg = <0x0c00 0x400>;
+   };
+
+   fpgaintc: fpga@a400 {
+   compatible = "renesas,r2dplus-intc";
+   #interrupt-cells = <1>;
+   #address-cells = <0>;
+   reg = <0xa400 0x40>;
+   interrupt-map=<0 &shintc evt2irq(0x200)>,
+ <1 &shintc evt2irq(0x220)>,
+ <2 &shintc evt2irq(0x240)>,
+ <3 &shintc evt2irq(0x260)>,
+ <4 &shintc evt2irq(0x280)>,
+ <5 &shintc evt2irq(0x2a0)>,
+ <6 &shintc evt2irq(0x2c0)>,
+ <7 &shintc evt2irq(0x2e0)>,
+ <8 &shintc evt2irq(0x300)>,
+ <9 &shintc evt2irq(0x320)>,
+ <10 &shintc evt2irq(0x340)>,
+ <11 &shintc evt2irq(0x360)>,
+ <12 &shintc evt2irq(0x380)>,
+ <13 &shintc evt2irq(0x3a0)>,
+ <14 &shintc evt2irq(0x3c0)>;
+   };
+
+   ide: ide@b4001000 {
+   compatible = "ata-generic";
+   reg = <0xb4001000 0x10>, <0xb400080c 0x02>;
+   interrupt-parent = <&fpgaintc>;
+   interrupts = <1 0>;
+   reg-shift = <1>;
+   pio-mode = <0>;
+   };
+
+   sm501: display@13e0 {
+   compatible = "smi,sm501";
+   reg = <0x1000 0x13df>, <0x13e0 0x13ff>;
+   interrupt-parent = <&fpgaintc>;
+   interrupts = <4 0>;
+   mode = "640x480-16@60";
+   edid = [00 ff ff ff ff ff ff 00 04 21 00 00 00 00 00 00
+   01 00 01 04 00 00 00 00 08 00 00 00 00 00 00 00
+   00 00 00 20 00 00 01 40 01 00 01 00 01 00 01 00
+   01 00 01 00 01 00 d6 09 80 a0 20 e0 2d 10 10 60
+   a2 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00
+   00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00
+   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fd];
+   smi,devices = <1>;
+   };
+};
+
+&oclk {
+   clock-frequency = <6000>;
+};
+
+&sci1 {
+   status = "ok";
+};
+
+&pci {
+   compatible = "renesas,sh7751-pci", "renesas.r2dplus-pci";
+   interrupt-map-mask = <0x1800 0 7>;
+   interrupt-map = <0x1000 0 1 &fpgaintc 3 0>;
+   status = "ok";
+};
-- 
2.7.0



[PATCH v5 03/22] sh: set preset_lpj

2016-07-03 Thread Yoshinori Sato
Generic callibrate delay required this value.

Signed-off-by: Yoshinori Sato 
---
 arch/sh/boards/of-generic.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/sh/boards/of-generic.c b/arch/sh/boards/of-generic.c
index 3db4294..2d3cda3 100644
--- a/arch/sh/boards/of-generic.c
+++ b/arch/sh/boards/of-generic.c
@@ -128,6 +128,8 @@ static void __init sh_of_time_init(void)
 static void __init sh_of_setup(char **cmdline_p)
 {
struct device_node *root;
+   struct device_node *cpu;
+   u32 freq;
 
board_time_init = sh_of_time_init;
 
@@ -139,6 +141,10 @@ static void __init sh_of_setup(char **cmdline_p)
}
 
sh_of_smp_probe();
+
+   cpu = of_find_node_by_name(NULL, "cpu");
+   if (!of_property_read_u32(cpu, "clock-frequency", &freq))
+   preset_lpj = freq / CONFIG_HZ / 2;
 }
 
 static int sh_of_irq_demux(int irq)
-- 
2.7.0



Re: [PATCH 1/3] mfd: add support for Allwinner SoCs ADC

2016-07-03 Thread Lars-Peter Clausen
On 07/03/2016 01:17 PM, Jonathan Cameron wrote:
> On 28/06/16 09:18, Quentin Schulz wrote:
>> The Allwinner SoCs all have an ADC that can also act as a touchscreen
>> controller and a thermal sensor. For now, only the ADC and the thermal
>> sensor drivers are probed by the MFD, the touchscreen controller support
>> will be added later.
>>
>> Signed-off-by: Quentin Schulz 
> The code looks fine to me. The 'controversial' bit of this is listing
> iio-hwmon as an mfd child to get it to probe as a result of this being
> present.  My immediately thought is that it should be separately
> described in the devicetree and hence instantiated outside of this driver.

The devicetree is a generic description of the hardware. The iio-hwmon
bridge is a software component that translates between two Linux specific
ABIs. In my opinion putting the later in the former is makes no sense, it is
simply not part of the hardware description.

Its quite terrible that we have the bindings in the first place, but I guess
we have to keep them considering they are ABI and there are existing users.
But we should definitely strongly discourage the introduction of new users.

It is policy whether an application wants to access a device using the IIO
or hwmon API. As such it must be managed by userspace, this is not something
that can be done using devicetree nor should it be something that is done on
a driver by driver basis.

- Lars



[PATCH v5 06/22] sh: FDT address save before bank change

2016-07-03 Thread Yoshinori Sato
SH3/4 have register bank of R0-R7.
Preset FDT address assigned bank depend on boot loader.
Before setting a bank because we don't depend on a boot loader, it's evacuated.

Signed-off-by: Yoshinori Sato 
---
 arch/sh/kernel/head_32.S | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/sh/kernel/head_32.S b/arch/sh/kernel/head_32.S
index 974bc15..ef44fe8 100644
--- a/arch/sh/kernel/head_32.S
+++ b/arch/sh/kernel/head_32.S
@@ -58,6 +58,9 @@ ENTRY(empty_zero_page)
  *
  */
 ENTRY(_stext)
+#ifdef CONFIG_OF
+   mov r4, r12 ! Store device tree blob pointer
+#endif
!   Initialize Status Register
mov.l   1f, r0  ! MD=1, RB=0, BL=0, IMASK=0xF
ldc r0, sr
@@ -67,10 +70,6 @@ ENTRY(_stext)
ldc r0, r6_bank
 #endif
 
-#ifdef CONFIG_OF
-   mov r4, r12 ! Store device tree blob pointer in r12
-#endif
-   
/*
 * Prefetch if possible to reduce cache miss penalty.
 *
-- 
2.7.0



[PATCH v5 20/22] sh: IO-DATA HDL-U (a.k.a landisk) DeviceTree

2016-07-03 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 arch/sh/boot/dts/Makefile|  2 ++
 arch/sh/boot/dts/landisk.dts | 61 
 2 files changed, 63 insertions(+)
 create mode 100644 arch/sh/boot/dts/landisk.dts

diff --git a/arch/sh/boot/dts/Makefile b/arch/sh/boot/dts/Makefile
index 38fdc38..cf5aec4 100644
--- a/arch/sh/boot/dts/Makefile
+++ b/arch/sh/boot/dts/Makefile
@@ -1,5 +1,7 @@
 obj-$(CONFIG_USE_BUILTIN_DTB) += $(patsubst 
"%",%,$(CONFIG_BUILTIN_DTB_SOURCE)).dtb.o
 
+dtb-y += landisk.dtb
+
 dtstree:= $(srctree)/$(src)
 clean-files := *.dtb.S
 always := $(dtb-y)
diff --git a/arch/sh/boot/dts/landisk.dts b/arch/sh/boot/dts/landisk.dts
new file mode 100644
index 000..3745ae0
--- /dev/null
+++ b/arch/sh/boot/dts/landisk.dts
@@ -0,0 +1,61 @@
+/dts-v1/;
+
+#include "sh7751.dtsi"
+
+/ {
+   model = "iodata,HDL-U";
+   compatible = "iodata,hdl-u";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   interrupt-parent = <&shintc>;
+   chosen {
+   stdout-path = "serial1:115200n8";
+   };
+   aliases {
+   serial0 = &sci0;
+   serial1 = &sci1;
+   };
+
+   memory@0c00 {
+   device_type = "memory";
+   reg = <0x0c00 0x400>;
+   };
+
+   cpldintc: cpld@b000 {
+   compatible = "iodata,landisk-intc";
+   #interrupt-cells = <1>;
+   #address-cells = <0>;
+   reg = <0xb000 8>;
+   interrupt-map=<0 &shintc evt2irq(0x2a0)>,
+ <1 &shintc evt2irq(0x2c0)>,
+ <2 &shintc evt2irq(0x2e0)>,
+ <3 &shintc evt2irq(0x300)>,
+ <4 &shintc evt2irq(0x320)>,
+ <5 &shintc evt2irq(0x340)>,
+ <6 &shintc evt2irq(0x360)>,
+ <7 &shintc evt2irq(0x380)>;
+   };
+};
+
+&oclk {
+   clock-frequency = <>;
+};
+
+&sci0 {
+   status = "ok";
+};
+
+&sci1 {
+   status = "ok";
+};
+
+&pci {
+   compatible = "renesas,sh7751-pci", "iodata,landisk-pci";
+   interrupt-map-mask = <0x1800 0 7>;
+   interrupt-map = <0x 0 1 &cpldintc 0>,
+   <0x0800 0 1 &cpldintc 1>,
+   <0x1000 0 1 &cpldintc 2>,
+   <0x1000 0 2 &cpldintc 3>,
+   <0x1000 0 3 &cpldintc 0>;
+   status = "ok";
+};
-- 
2.7.0



[PATCH v5 02/22] sh: More early unflatten device tree

2016-07-03 Thread Yoshinori Sato
unflatten required MMU disabled.

Signed-off-by: Yoshinori Sato 
---
 arch/sh/boards/of-generic.c | 6 --
 arch/sh/kernel/setup.c  | 7 +++
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/sh/boards/of-generic.c b/arch/sh/boards/of-generic.c
index 8dbf978..3db4294 100644
--- a/arch/sh/boards/of-generic.c
+++ b/arch/sh/boards/of-generic.c
@@ -129,12 +129,6 @@ static void __init sh_of_setup(char **cmdline_p)
 {
struct device_node *root;
 
-#ifdef CONFIG_USE_BUILTIN_DTB
-   unflatten_and_copy_device_tree();
-#else
-   unflatten_device_tree();
-#endif
-
board_time_init = sh_of_time_init;
 
sh_mv.mv_name = "Unknown SH model";
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 5b9eb70..86f2792 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -271,6 +271,13 @@ void __ref sh_fdt_init(phys_addr_t dt_phys)
 
 void __init setup_arch(char **cmdline_p)
 {
+#ifdef CONFIG_OF
+#ifdef CONFIG_USE_BUILTIN_DTB
+   unflatten_and_copy_device_tree();
+#else
+   unflatten_device_tree();
+#endif
+#endif
enable_mmu();
 
ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
-- 
2.7.0



[PATCH v5 18/22] sh: Add separate DTB build rule

2016-07-03 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 arch/sh/Makefile  | 7 +++
 arch/sh/boot/dts/Makefile | 2 ++
 2 files changed, 9 insertions(+)

diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 8adffa8..a44e630 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -189,6 +189,13 @@ drivers-$(CONFIG_OPROFILE) += arch/sh/oprofile/
 
 boot := arch/sh/boot
 
+%.dtb %.dtb.S %.dtb.o: | scripts
+   $(Q)$(MAKE) $(build)=arch/sh/boot/dts arch/sh/boot/dts/$@
+
+PHONY += dtbs
+dtbs: scripts
+   $(Q)$(MAKE) $(build)=arch/sh/boot/dts
+
 cflags-y   += $(foreach d, $(cpuincdir-y), -Iarch/sh/include/$(d)) \
   $(foreach d, $(machdir-y), -Iarch/sh/include/$(d))
 
diff --git a/arch/sh/boot/dts/Makefile b/arch/sh/boot/dts/Makefile
index e5ce3a0..38fdc38 100644
--- a/arch/sh/boot/dts/Makefile
+++ b/arch/sh/boot/dts/Makefile
@@ -1,3 +1,5 @@
 obj-$(CONFIG_USE_BUILTIN_DTB) += $(patsubst 
"%",%,$(CONFIG_BUILTIN_DTB_SOURCE)).dtb.o
 
+dtstree:= $(srctree)/$(src)
 clean-files := *.dtb.S
+always := $(dtb-y)
-- 
2.7.0



[PATCH v5 01/22] sh: Add sh-specific early_init_dt_reserve_memory_arch

2016-07-03 Thread Yoshinori Sato
sh used P1 address space in early device tree.
So need convert P1 to physical address before reserve memory.

Signed-off-by: Yoshinori Sato 
---
 arch/sh/boards/of-generic.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/arch/sh/boards/of-generic.c b/arch/sh/boards/of-generic.c
index 57d45dc..8dbf978 100644
--- a/arch/sh/boards/of-generic.c
+++ b/arch/sh/boards/of-generic.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -203,3 +204,14 @@ static int __init sh_of_device_init(void)
return 0;
 }
 arch_initcall_sync(sh_of_device_init);
+
+int __init early_init_dt_reserve_memory_arch(phys_addr_t base,
+phys_addr_t size, bool nomap)
+{
+   if (nomap)
+   return memblock_remove(base, size);
+
+   if (base >= P1SEG)
+   base &= ~P1SEG;
+   return memblock_reserve(base, size);
+}
-- 
2.7.0



[PATCH v5 17/22] pci: PCI_HOST_GENERIC enable for SH

2016-07-03 Thread Yoshinori Sato
Changes v4
none

Signed-off-by: Yoshinori Sato 
---
 drivers/pci/host/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig
index df60505..83184eb 100644
--- a/drivers/pci/host/Kconfig
+++ b/drivers/pci/host/Kconfig
@@ -83,7 +83,7 @@ config PCI_HOST_COMMON
 
 config PCI_HOST_GENERIC
bool "Generic PCI host controller"
-   depends on (ARM || ARM64) && OF
+   depends on (ARM || ARM64 || SUPERH) && OF
select PCI_HOST_COMMON
help
  Say Y here if you want to support a simple generic PCI host
-- 
2.7.0



[PATCH v5 14/22] sh: SH7751 core dtsi

2016-07-03 Thread Yoshinori Sato
SH7751 core and internal peripheral define.

Signed-off-by: Yoshinori Sato 
---
 arch/sh/boot/dts/include/dt-bindings   |  1 +
 arch/sh/boot/dts/sh7751.dtsi   | 83 ++
 include/dt-bindings/clock/renesas-sh7750.h | 26 +++
 include/dt-bindings/interrupt-controller/sh_intc.h |  2 +
 4 files changed, 112 insertions(+)
 create mode 12 arch/sh/boot/dts/include/dt-bindings
 create mode 100644 arch/sh/boot/dts/sh7751.dtsi
 create mode 100644 include/dt-bindings/clock/renesas-sh7750.h
 create mode 100644 include/dt-bindings/interrupt-controller/sh_intc.h

diff --git a/arch/sh/boot/dts/include/dt-bindings 
b/arch/sh/boot/dts/include/dt-bindings
new file mode 12
index 000..08c00e4
--- /dev/null
+++ b/arch/sh/boot/dts/include/dt-bindings
@@ -0,0 +1 @@
+../../../../../include/dt-bindings
\ No newline at end of file
diff --git a/arch/sh/boot/dts/sh7751.dtsi b/arch/sh/boot/dts/sh7751.dtsi
new file mode 100644
index 000..713e72e
--- /dev/null
+++ b/arch/sh/boot/dts/sh7751.dtsi
@@ -0,0 +1,83 @@
+/*
+ * Device Tree Source for the SH7751
+ *
+ * Copyright (C) 2016 Yoshinori Sato
+ */
+
+#include 
+#include 
+
+/ {
+   oclk: oscillator {
+#clock-cells = <0>;
+compatible = "fixed-clock";
+clock-frequency = <0>;
+};
+   cpg: clock-controller@ffc0 {
+compatible = "renesas,sh7750-cpg";
+clocks = <&oclk>;
+#clock-cells = <1>;
+   renesas,mult = <12>;
+reg = <0xffc0 32>, <0xfe0a 16>;
+};
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   cpu@0 {
+ compatible = "renesas,sh4", "renesas,sh";
+ clock-frequency = <2>;
+   };
+   };
+   shintc: interrupt-controller@ffd0 {
+   compatible = "renesas,sh7751-intc";
+   #interrupt-cells = <2>;
+   interrupt-controller;
+   reg = <0xffd0 14>, <0xfe08 128>;
+
+   };
+   sci0: serial@ffe0 {
+   compatible = "renesas,sci";
+   reg = <0xffe0 0x20>;
+   interrupts = ,
+,
+,
+;
+   clocks = <&cpg SH7750_CLK_SCI>;
+   clock-names = "fck";
+   status = "disabled";
+   };
+   sci1: serial@ffe8 {
+   compatible = "renesas,scif";
+   reg = <0xffe8 0x100>;
+   interrupts = ,
+,
+,
+;
+   clocks = <&cpg SH7750_CLK_SCIF>;
+   clock-names = "fck";
+   status = "disabled";
+   };
+   tmu: timer@ffd8 {
+   compatible = "renesas,tmu";
+   reg = <0xffd8 12>;
+   interrupts = ,
+,
+;
+   clocks = <&cpg SH7750_CLK_TMU0>;
+   clock-names = "fck";
+   renesas,channels-mask = <0x03>;
+   };
+   pci: pci-controller@fe20 {
+   compatible = "renesas,sh7751-pci";
+   device_type = "pci";
+   bus-range = <0 0>;
+   #address-cells = <2>;
+   #size-cells = <1>;
+   ranges = <0x0200 0x 0xfd00 0xfd00 
0x 0x0100>,
+<0x0100 0x 0xfe24 0x 
0x 0x0004>;
+   reg = <0xfe20 0x0400>, <0xff80 0x0030>;
+   #interrupt-cells = <1>;
+   interrupt-map-mask = <0x1800 0 7>;
+   status = "disabled";
+   };
+};
diff --git a/include/dt-bindings/clock/renesas-sh7750.h 
b/include/dt-bindings/clock/renesas-sh7750.h
new file mode 100644
index 000..546c0b1
--- /dev/null
+++ b/include/dt-bindings/clock/renesas-sh7750.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2016 Yoshinori Sato
+ *
+ * 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.
+ */
+#ifndef __DT_BINDINGS_CLOCK_RENESAS_SH7750_H__
+#define __DT_BINDINGS_CLOCK_RENESAS_SH7750_H__
+
+#define SH7750_CLK_SCI 0
+#define SH7750_CLK_RTC 1
+#define SH7750_CLK_TMU02
+#define SH7750_CLK_TMU13
+#define SH7750_CLK_TMU24
+#define SH7750_CLK_SCIF5
+#define SH7750_CLK_DMAC6
+#define SH7750_CLK_UBC 7
+#define SH7750_CLK_SQ  8
+#define SH7750_CLK_INTC 9
+#define SH7750_CLK_TMU310
+#define SH7750_CLK_TMU411
+#define SH7750_CLK_PCIC12
+
+#endif /* __DT_BINDINGS_CLOCK_RENESAS_CPG_MSSR_H__ */
diff --git a/include/dt-bindings/interru

Re: [RFC 0/1] ARM: print MHz in /proc/cpuinfo

2016-07-03 Thread Russell King - ARM Linux
On Sat, Jul 02, 2016 at 07:58:00PM -0400, Jon Masters wrote:
> Agreed. But we'll still be coming back to ensure this information is
> presented to users. I pointed out to ARM about 3-4 years ago that this
> was going to bite us. It is now biting us, and we will ensure that
> useless data is provided where it is on x86 for identical experience by
> users. That is unless or until x86 users do something else always. Our
> (separate) case will use DMI or ACPI for the same kind of data.

Right, so having read all your email, there's no reason why we couldn't
just print:

cpu MHz  : .999

and be done with it.  Sure, it doesn't reflect the reality, but if people
are going to be idiots with it, why not play their game with it to show
how stupid it is.

I don't buy "it's biting us" - I see no evidence of it actually "biting"
anyone.  No one has reported any failures in the last 20 years due to
this missing - and even so as I've already said, it would _not_ be a
regression because that information has never been provided on 32-bit
ARM.

Moreover, I asked what these applications were that are affected by the
lack of us providing this number.  I'm still waiting to hear that, and
I noticed that even you skipped over providing that information which I
asked for, instead giving a hand-wavey answer based on marketing (spit)
people doing stupid things.

Please, try to come up with a _technical_ justification.  I really don't
want to make decisions based on marketing shite which I completely and
utterly despise.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.


Re: [PATCH 6/6] x86: Fix stray A/D bit setting into non-present PTEs

2016-07-03 Thread Dave Hansen
On 06/30/2016 08:06 PM, Brian Gerst wrote:
>> > It's not like anybody will ever care about 32-bit page tables on
>> > Knights Landing anyway.
> Could this affect a 32-bit guest VM?

This isn't about 32-bit *mode*.  It's about using the the 32-bit 2-level
_paging_ mode that supports only 4GB virtual and 4GB physical addresses.
 That mode also doesn't support the No-eXecute (NX) bit, which basically
everyone needs today for its security benefits.

Even the little Quark CPU supports PAE (64-bit page tables).




Subject: PROBLEM: CPU accounting/scheduling regression in v4.6 CPU scheduling patchset?

2016-07-03 Thread Vladimir Panteleev
Hi,

Since updating my PC to Linux 4.6, I noticed the following problems:

1. CPU-bound tasks which use all CPU cores have a severe impact on
   responsiveness.  For example, the following bash command (which
   simply starts one busyloop per core) is enough to make the machine
   almost completely unresponsive:

   for N in $(seq $(nproc)) ; do while true ; do ; done & ; done

2. Nearly all tasks in the process listing are shown with 0% CPU
   usage, even when they're CPU-bound. The only exceptions are the
   kernel migration and kthreadd tasks, and occasionally the init
   process.

I have bisected the problem to commit
1cf4f629d9d246519a1e76c021806f2a51ddba4d ("cpu/hotplug: Move online
calls to hotplugged cpu"), which is part of Thomas Gleixner's CPU
hotplug refactoring patchset [1]. It introduces both problems
described above.

My system is a GIGABYTE X79S-UP5-WIFI motherboard (F5f BIOS) with an
i7-4960X CPU, running Arch Linux. I've reproduced with both the
distro's kernel config [2], as well as a minimal config for my
system. I can reproduce the problems on the latest rc at the moment,
v4.7-rc5.

Comparing dmesg output before and after 1cf4f629, I see no notable
differences.

I noticed an existing thread "S3 resume regression" [3] referencing
this commit, however it describes a different problem. I also found a
Bugzilla issue for the zero CPU usage problem [4], however it has no
replies.

[1]: https://lkml.org/lkml/2016/2/26/806
[2]: https://aur.archlinux.org/cgit/aur.git/tree/config.x86_64?h=linux-git
[3]: https://lkml.org/lkml/2016/5/11/238
[4]: https://bugzilla.kernel.org/show_bug.cgi?id=120151

Stuff REPORTING-BUGS told me to include:

ver_linux output:
https://dump.v.panteleev.md/616390d43a4c6a3d085acc5eaa390c82/16%3A58%3A08-stdin.txt

/proc/cpuinfo:
https://dump.v.panteleev.md/5dfeba5d7c64028de51d50559b566088/16%3A58%3A49-stdin.txt

/proc/modules:
https://dump.v.panteleev.md/868c0f2b23651be8164975fa5d7e7aab/16%3A59%3A18-stdin.txt

/proc/ioports:
https://dump.v.panteleev.md/5e44aa12cc403dbd783b0273bd3edab4/17%3A01%3A33-stdin.txt

/proc/iomem:
https://dump.v.panteleev.md/110a8fdd0f647fd8d729c54f4f01a3d0/17%3A01%3A49-stdin.txt

"lspci -vvv" output:
https://dump.v.panteleev.md/0c2448fa8a872e34c4555d876b656013/17%3A02%3A18-stdin.txt

/proc/scsi/scsi:
https://dump.v.panteleev.md/6efa007ce74f0bf4ce10ae56690c63de/17%3A02%3A54-stdin.txt

dmesg output:
https://dump.v.panteleev.md/b8a3ba608a914a3d70667dad697dddfb/1467563818.log



[PATCH 4/4] bus: simple-pm-bus: convert bool SIMPLE_PM_BUS to tristate

2016-07-03 Thread Paul Gortmaker
The Kconfig currently controlling compilation of this code is:

config SIMPLE_PM_BUS
bool "Simple Power-Managed Bus Driver"

...meaning that it currently is not being built as a module by anyone.

In removing the orphaned modular support in a previous patch set,
Geert indicated he'd rather see this code converted to tristate.

I normally don't do that because it extends functionality that I
can't easily run time test or even know if the use case makes sense,
but since in this case the author has nominated it as such, we do
the conversion here.

Note that doesn't change the lack of run time testing ; this change
is only tested for sucessful compile and modpost.

Cc: Geert Uytterhoeven 
Cc: Kevin Hilman 
Cc: Simon Horman 
Cc: linux-arm-ker...@lists.infradead.org
Signed-off-by: Paul Gortmaker 
---
 drivers/bus/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig
index 3b205e212337..f4162c76a5f6 100644
--- a/drivers/bus/Kconfig
+++ b/drivers/bus/Kconfig
@@ -109,7 +109,7 @@ config OMAP_OCP2SCP
  OCP2SCP.
 
 config SIMPLE_PM_BUS
-   bool "Simple Power-Managed Bus Driver"
+   tristate "Simple Power-Managed Bus Driver"
depends on OF && PM
depends on ARCH_RENESAS || COMPILE_TEST
help
-- 
2.8.4



[PATCH v2 0/4] bus: remove unused modular code from non-modular drivers

2016-07-03 Thread Paul Gortmaker
The drivers/bus doesn't have a strict maintainer entry, but since
all the changes here are for ARM platforms, I'm Cc'ing arm-kernel
and hoping it makes sense to vector these few changes through the
arm-soc tree.

My ongoing audit looking for non-modular code that needlessly uses
modular macros (vs. built-in equivalents) and/or has dead code
relating to module unloading that can never be executed led to the
creation of these four commits.

Two are of the trivial kind, where we substitute in the non-modular
versions that CPP would have put in place anyway, resulting in no
actual changes, even at the binary output level.

Another is of the kind where there was a ".remove" function
registered into the driver struct.  Being non-modular, these
functions will never be called via a normal module_exit path.

However, since it was possible (but largely pointless, and without
a real use case) to unbind these drivers via sysfs, we explicitly
disallow the unbind as part of the removal of the ".remove" itself.

Finally one is a conversion of a bool to a tristate; not something
I'd do myself by default, but in this case we had a desire from
the original author to have it that way.

For anyone new to the underlying goal of this cleanup, we are trying to
not use module support for code that can never be built as a module since:

 (1) it is easy to accidentally write unused module_exit and remove code
 (2) it can be misleading when reading the source, thinking it can be
 modular when the Makefile and/or Kconfig prohibit it
 (3) it requires the include of the module.h header file which in turn
 includes nearly everything else, thus adding to CPP overhead.
 (4) it gets copied/replicated into other code and spreads like weeds.

Build tested for arm and arm64 on linux-next to ensure no silly typos
that would break compilation crept in.

---

[v2: drop arm-ccn patch; it is being made tristate elsewhere, convert
 simple-pm to tristate, add new patch for new tegra-aconnect driver.]

[v1: 
https://lkml.kernel.org/r/1459113058-14340-1-git-send-email-paul.gortma...@windriver.com
 ]

Cc: Alexandre Courbot 
Cc: Alison Chaiken 
Cc: Brian Norris 
Cc: Florian Fainelli 
Cc: Geert Uytterhoeven 
Cc: Gregory Fong 
Cc: Jon Hunter 
Cc: Kevin Hilman 
Cc: Sascha Hauer 
Cc: Shawn Guo 
Cc: Simon Horman 
Cc: Stephen Warren 
Cc: Thierry Reding 
Cc: Wolfram Sang 
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-te...@vger.kernel.org

Paul Gortmaker (4):
  bus: brcmstb_gisb: make it explicitly non-modular
  bus: imx-weim: make it explicitly non-modular
  bus: tegra-aconnect: make it explicitly non-modular
  bus: simple-pm-bus: convert bool SIMPLE_PM_BUS to tristate

 drivers/bus/Kconfig  |  2 +-
 drivers/bus/brcmstb_gisb.c   |  4 +---
 drivers/bus/imx-weim.c   |  9 ++---
 drivers/bus/tegra-aconnect.c | 22 +-
 4 files changed, 9 insertions(+), 28 deletions(-)

-- 
2.8.4



[PATCH 3/4] bus: tegra-aconnect: make it explicitly non-modular

2016-07-03 Thread Paul Gortmaker
The Kconfig currently controlling compilation of this code is:

drivers/bus/Kconfig:config TEGRA_ACONNECT
drivers/bus/Kconfig:bool "Tegra ACONNECT Bus Driver"

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that
when reading the driver there is no doubt it is builtin-only.

We explicitly disallow a driver unbind, since that doesn't have a
sensible use case anyway, and it allows us to drop the ".remove"
code for non-modular drivers.

Since module_platform_driver() uses the same init level priority as
builtin_platform_driver() the init ordering remains unchanged with
this commit.

Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.

We also delete the MODULE_LICENSE tag etc. since all that information
was (or is now) contained at the top of the file in the comments.

Cc: Stephen Warren 
Cc: Thierry Reding 
Cc: Alexandre Courbot 
Cc: Jon Hunter 
Cc: linux-te...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Signed-off-by: Paul Gortmaker 
---
 drivers/bus/tegra-aconnect.c | 22 +-
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/drivers/bus/tegra-aconnect.c b/drivers/bus/tegra-aconnect.c
index 7e4104b74fa8..f3982946ab8a 100644
--- a/drivers/bus/tegra-aconnect.c
+++ b/drivers/bus/tegra-aconnect.c
@@ -1,6 +1,8 @@
 /*
  * Tegra ACONNECT Bus Driver
  *
+ * Author: Jon Hunter 
+ *
  * Copyright (C) 2016, NVIDIA CORPORATION.  All rights reserved.
  *
  * This file is subject to the terms and conditions of the GNU General Public
@@ -9,7 +11,7 @@
  */
 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -66,15 +68,6 @@ clk_destroy:
return ret;
 }
 
-static int tegra_aconnect_remove(struct platform_device *pdev)
-{
-   pm_runtime_disable(&pdev->dev);
-
-   pm_clk_destroy(&pdev->dev);
-
-   return 0;
-}
-
 static int tegra_aconnect_runtime_resume(struct device *dev)
 {
return pm_clk_resume(dev);
@@ -94,19 +87,14 @@ static const struct of_device_id tegra_aconnect_of_match[] 
= {
{ .compatible = "nvidia,tegra210-aconnect", },
{ }
 };
-MODULE_DEVICE_TABLE(of, tegra_aconnect_of_match);
 
 static struct platform_driver tegra_aconnect_driver = {
.probe = tegra_aconnect_probe,
-   .remove = tegra_aconnect_remove,
.driver = {
.name = "tegra-aconnect",
+   .suppress_bind_attrs = true,
.of_match_table = tegra_aconnect_of_match,
.pm = &tegra_aconnect_pm_ops,
},
 };
-module_platform_driver(tegra_aconnect_driver);
-
-MODULE_DESCRIPTION("NVIDIA Tegra ACONNECT Bus Driver");
-MODULE_AUTHOR("Jon Hunter ");
-MODULE_LICENSE("GPL v2");
+builtin_platform_driver(tegra_aconnect_driver);
-- 
2.8.4



[PATCH 1/4] bus: brcmstb_gisb: make it explicitly non-modular

2016-07-03 Thread Paul Gortmaker
The Kconfig for this driver is currently:

config BRCMSTB_GISB_ARB
bool "Broadcom STB GISB bus arbiter"

...meaning that it currently is not being built as a module by anyone.
Lets remove all modular references, so that when reading the driver
there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit.

Cc: Brian Norris 
Acked-by: Brian Norris 
Cc: Gregory Fong 
Cc: Florian Fainelli 
Acked-by: Florian Fainelli 
Cc: linux-arm-ker...@lists.infradead.org
Signed-off-by: Paul Gortmaker 
---
 drivers/bus/brcmstb_gisb.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/bus/brcmstb_gisb.c b/drivers/bus/brcmstb_gisb.c
index 72fe0a5a8bf3..2616d8208777 100644
--- a/drivers/bus/brcmstb_gisb.c
+++ b/drivers/bus/brcmstb_gisb.c
@@ -13,7 +13,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -438,5 +437,4 @@ static int __init brcm_gisb_driver_init(void)
return platform_driver_probe(&brcmstb_gisb_arb_driver,
 brcmstb_gisb_arb_probe);
 }
-
-module_init(brcm_gisb_driver_init);
+device_initcall(brcm_gisb_driver_init);
-- 
2.8.4



[PATCH 2/4] bus: imx-weim: make it explicitly non-modular

2016-07-03 Thread Paul Gortmaker
The Kconfig currently controlling compilation of this code is:

drivers/bus/Kconfig:config IMX_WEIM
drivers/bus/Kconfig:bool "Freescale EIM DRIVER

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that
when reading the driver there is no doubt it is builtin-only.

Since module_platform_driver() uses the same init level priority as
builtin_platform_driver() the init ordering remains unchanged with
this commit.

Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.

We also delete the MODULE_LICENSE tag etc. since all that information
is already contained at the top of the file in the comments.

Cc: Shawn Guo 
Acked-by: Shawn Guo 
Cc: Alison Chaiken 
Cc: Sascha Hauer 
Cc: Wolfram Sang 
Cc: linux-arm-ker...@lists.infradead.org
Signed-off-by: Paul Gortmaker 
---
 drivers/bus/imx-weim.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c
index 4bd361d64270..cdc75b1b264d 100644
--- a/drivers/bus/imx-weim.c
+++ b/drivers/bus/imx-weim.c
@@ -7,7 +7,7 @@
  * License version 2. This program is licensed "as is" without any
  * warranty of any kind, whether express or implied.
  */
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -57,7 +57,6 @@ static const struct of_device_id weim_id_table[] = {
{ .compatible = "fsl,imx51-weim", .data = &imx51_weim_devtype, },
{ }
 };
-MODULE_DEVICE_TABLE(of, weim_id_table);
 
 static int __init imx_weim_gpr_setup(struct platform_device *pdev)
 {
@@ -209,8 +208,4 @@ static struct platform_driver weim_driver = {
.of_match_table = weim_id_table,
},
 };
-module_platform_driver_probe(weim_driver, weim_probe);
-
-MODULE_AUTHOR("Freescale Semiconductor Inc.");
-MODULE_DESCRIPTION("i.MX EIM Controller Driver");
-MODULE_LICENSE("GPL");
+builtin_platform_driver_probe(weim_driver, weim_probe);
-- 
2.8.4



Re: [PATCH 1/3] mfd: add support for Allwinner SoCs ADC

2016-07-03 Thread Guenter Roeck

On 07/03/2016 09:49 AM, Lars-Peter Clausen wrote:

On 07/03/2016 01:17 PM, Jonathan Cameron wrote:

On 28/06/16 09:18, Quentin Schulz wrote:

The Allwinner SoCs all have an ADC that can also act as a touchscreen
controller and a thermal sensor. For now, only the ADC and the thermal
sensor drivers are probed by the MFD, the touchscreen controller support
will be added later.

Signed-off-by: Quentin Schulz 

The code looks fine to me. The 'controversial' bit of this is listing
iio-hwmon as an mfd child to get it to probe as a result of this being
present.  My immediately thought is that it should be separately
described in the devicetree and hence instantiated outside of this driver.


The devicetree is a generic description of the hardware. The iio-hwmon
bridge is a software component that translates between two Linux specific
ABIs. In my opinion putting the later in the former is makes no sense, it is
simply not part of the hardware description.


Actually, this is where people get it wrong.


Its quite terrible that we have the bindings in the first place, but I guess
we have to keep them considering they are ABI and there are existing users.
But we should definitely strongly discourage the introduction of new users.



I do agree that the _bindings_ are bad.

The ultimate problem is to find bindings which do describe the hardware
in a way that would be acceptable to the devicetree community and is at the
same time useful for software when trying to determine what to do with that
hardware. _This_ is the exceptionally hard problem.

One example would be an adc channel connected to a board voltage. I would assume
that it should be permissible to describe this relationship in a way that can
be _used_ by software to expose that adc channel as voltage, by whatever
means necessary (it be through hwmon or as a regulator or whatever).

Similar, some pin on a chip may be connected to a thermal sensor. I would
assume that it should be permissible to describe that thermal sensor (and its
location) in a way that can be _used_ by software in a meaningful way, either
for it to be reported as hardware monitoring attribute or to be used by the
thermal subsystem as a thermal input channel.

In addition to that, there are various other properties which _do_ describe
the hardware, but are commonly seen as "software". Examples for that would
be voltage or temperature limits (or any other limits, for that matter).
Such limits _are_ part of the hardware description, but are not commonly
accepted as such.


It is policy whether an application wants to access a device using the IIO
or hwmon API. As such it must be managed by userspace, this is not something
that can be done using devicetree nor should it be something that is done on
a driver by driver basis.



Agreed. However, the connections from one chip to another, and the use of a chip
on a board, _is_ part of the hardware description. It is determined by the
schematics as well as the board layout. A well defined hardware description
needs to provide more than "this is an ADC channel" or "this is a thermal 
sensor".

Guenter



[PATCH v2] clk: imx7d: do not set parent of ethernet time/ref clocks

2016-07-03 Thread Stefan Agner
All device trees currently in mainline specify the time clock parent
using the assigned-clocks/assigned-clock-parents method, there is no
need to statically assign the parent in the core clock driver.
Also all current boards provide an Ethernet reference clock for the
PHY externally, hence configuring the internal PHY reference clock.

Furthermore, and the actual driver of this patch, specify ethernet
related parents at that early point in boot leads to a warning:
bad: scheduling from the idle thread!

The reason for the warning is that setting the parent enables the ENET
PLL since we are using CLK_OPS_PARENT_ENABLE. Enabling the ENET PLL can
cause clk_pllv3_wait_lock to sleep. See also:
commit fc8726a2c021 ("clk: core: support clocks which requires parents
enable (part 2)").

Note that setting the ENET AXI root clock parent also requires ENET
PLL to be enabled. However, U-Boot typically leaves the ENET PLL on,
hence when the framework sets the parent of the first clock, it does
not need to wait for the PLL to come up. But because there is currently
no user of that clock, the PLL gets disabled after setting the parent.
Therefore, subsequent reparenting calls of any clock which somehow rely
on the ENET PLL, need to reenable the ENET PLL which leads to a sleep.
Removing those subsequent reparenting calls works around this issue.

Also remove comments. The code is really verbose enough.

Signed-off-by: Stefan Agner 
---
Changes since v1:
- Also remove PHY REF clock

Hi All,

Fabio, thanks for testing v1.

With v2, the warnings should definitly be gone. However, that might
break some boards...

What is the IMX7D_ENET_PHY_REF_ROOT_SRC clock for anyway? It sounds
like it should provide a clock for the PHY. However, there is also
IMX7D_ENET1_REF_ROOT_CLK and IMX7D_ENET2_REF_ROOT_CLK...

Our first design used to use a clock provided by the SoC, by muxing
a pad to CCM_ENET1_REF_CLK and enabling IMX7D_ENET1_REF_ROOT_CLK
it seemd to work just fine, there was no need for
IMX7D_ENET_PHY_REF_ROOT_SRC.

Dong, can you shed some light on this?

Otherwise, in case a board does not work with that change, something
like this should do the same using device tree. You probably would
have to add this to all FEC instances since this seems to be a shared
clock.

pinctrl-names = "default";
pinctrl-0 = <&pinctrl_enet1>;
assigned-clocks = <&clks IMX7D_ENET1_TIME_ROOT_SRC>,
- <&clks IMX7D_ENET1_TIME_ROOT_CLK>;
-   assigned-clock-parents = <&clks IMX7D_PLL_ENET_MAIN_100M_CLK>;
+ <&clks IMX7D_ENET1_TIME_ROOT_CLK>,
+ <&clks IMX7D_ENET_PHY_REF_ROOT_SRC>;
+   assigned-clock-parents = <&clks IMX7D_PLL_ENET_MAIN_100M_CLK>, <0>,
+<&clks IMX7D_PLL_ENET_MAIN_25M_CLK>;
assigned-clock-rates = <0>, <1>;
phy-mode = "rgmii";
phy-handle = <ðphy0>;

--
Stefan

 drivers/clk/imx/clk-imx7d.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/clk/imx/clk-imx7d.c b/drivers/clk/imx/clk-imx7d.c
index 79293ed..6ed4f8f 100644
--- a/drivers/clk/imx/clk-imx7d.c
+++ b/drivers/clk/imx/clk-imx7d.c
@@ -860,16 +860,7 @@ static void __init imx7d_clocks_init(struct device_node 
*ccm_node)
/* use old gpt clk setting, gpt1 root clk must be twice as gpt counter 
freq */
clk_set_parent(clks[IMX7D_GPT1_ROOT_SRC], clks[IMX7D_OSC_24M_CLK]);
 
-   /*
-* init enet clock source:
-*  AXI clock source is 250MHz
-*  Phy refrence clock is 25MHz
-*  1588 time clock source is 100MHz
-*/
clk_set_parent(clks[IMX7D_ENET_AXI_ROOT_SRC], 
clks[IMX7D_PLL_ENET_MAIN_250M_CLK]);
-   clk_set_parent(clks[IMX7D_ENET_PHY_REF_ROOT_SRC], 
clks[IMX7D_PLL_ENET_MAIN_25M_CLK]);
-   clk_set_parent(clks[IMX7D_ENET1_TIME_ROOT_SRC], 
clks[IMX7D_PLL_ENET_MAIN_100M_CLK]);
-   clk_set_parent(clks[IMX7D_ENET2_TIME_ROOT_SRC], 
clks[IMX7D_PLL_ENET_MAIN_100M_CLK]);
 
/* set uart module clock's parent clock source that must be great then 
80MHz */
clk_set_parent(clks[IMX7D_UART1_ROOT_SRC], clks[IMX7D_OSC_24M_CLK]);
-- 
2.9.0



[PATCH] perf/core: Fix the mask in perf_output_sample_regs

2016-07-03 Thread Madhavan Srinivasan
When decoding the perf_regs mask in perf_output_sample_regs(),
we loop through the mask using find_first_bit and find_next_bit functions.
While the exisitng code works fine in most of the case,
the logic is broken for 32bit kernel (Big Endian).
When reading u64 mask using (u32 *)(&val)[0], find_*_bit() assumes it gets
lower 32bits of u64 but instead gets upper 32bits which is wrong.
Proposed fix is to swap the words of the u64 to handle this case.
This is _not_ endianness swap.

Suggested-by: Yury Norov 
Cc: Yury Norov 
Cc: Peter Zijlstra 
Cc: Ingo Molnar 
Cc: Arnaldo Carvalho de Melo 
Cc: Alexander Shishkin 
Cc: Jiri Olsa 
Cc: Michael Ellerman 
Signed-off-by: Madhavan Srinivasan 
---
 include/linux/bitmap.h |  2 ++
 kernel/events/core.c   |  4 +++-
 lib/bitmap.c   | 19 +++
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index e9b0b9ab07e5..d95b422db183 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -188,6 +188,8 @@ extern int bitmap_print_to_pagebuf(bool list, char *buf,
 #define small_const_nbits(nbits) \
(__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
 
+extern void bitmap_from_u64(unsigned long *dst, u64 mask);
+
 static inline void bitmap_zero(unsigned long *dst, unsigned int nbits)
 {
if (small_const_nbits(nbits))
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 9c51ec3f0f44..613fec95ea4c 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5205,8 +5205,10 @@ perf_output_sample_regs(struct perf_output_handle 
*handle,
struct pt_regs *regs, u64 mask)
 {
int bit;
+   DECLARE_BITMAP(_mask, 64);
 
-   for_each_set_bit(bit, (const unsigned long *) &mask,
+   bitmap_from_u64(_mask, mask);
+   for_each_set_bit(bit, _mask,
 sizeof(mask) * BITS_PER_BYTE) {
u64 val;
 
diff --git a/lib/bitmap.c b/lib/bitmap.c
index c66da508cbf7..522f1b4c6078 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -1170,3 +1170,22 @@ void bitmap_copy_le(unsigned long *dst, const unsigned 
long *src, unsigned int n
 }
 EXPORT_SYMBOL(bitmap_copy_le);
 #endif
+
+/*
+ * bitmap_from_u64 - Check and swap words within u64.
+ *  @mask: source bitmap
+ *  @dst:  destination bitmap
+ *
+ * In 32bit Big Endian kernel, when using (u32 *)(&val)[*]
+ * to read u64 mask, we will get wrong word.
+ * That is "(u32 *)(&val)[0]" gets upper 32 bits,
+ * but expected could be lower 32bits of u64.
+ */
+void bitmap_from_u64(unsigned long *dst, u64 mask)
+{
+   dst[0] = mask & ULONG_MAX;
+
+   if (sizeof(mask) > sizeof(unsigned long))
+   dst[1] = mask >> 32;
+}
+EXPORT_SYMBOL(bitmap_from_u64);
-- 
1.9.1



[PATCH] vme: make core vme support explicitly non-modular

2016-07-03 Thread Paul Gortmaker
The Kconfig currently controlling compilation of this code is:

drivers/vme/Kconfig:menuconfig VME_BUS
drivers/vme/Kconfig:bool "VME bridge support"

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that
when reading the driver there is no doubt it is builtin-only.

We replace module.h and moduleparam.h (unused) with init.h and also
export.h ; the latter since this file does export some syms.

Since this is a struct bus_type and not a platform_driver, we don't
have any ".suppress_bind_attrs" to be concerned about when we
drop the ".remove" code from this file.

Since module_init was not in use by this code, the init ordering
remains unchanged with this commit.

Cc: Martyn Welch 
Cc: Manohar Vanga 
Cc: Greg Kroah-Hartman 
Cc: de...@driverdev.osuosl.org
Signed-off-by: Paul Gortmaker 
---
 drivers/vme/vme.c | 27 ++-
 1 file changed, 2 insertions(+), 25 deletions(-)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 37ac0a58e59a..557149f0f88a 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -13,8 +13,8 @@
  * option) any later version.
  */
 
-#include 
-#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -39,7 +39,6 @@ static unsigned int vme_bus_numbers;
 static LIST_HEAD(vme_bus_list);
 static DEFINE_MUTEX(vme_buses_lock);
 
-static void __exit vme_exit(void);
 static int __init vme_init(void);
 
 static struct vme_dev *dev_to_vme_dev(struct device *dev)
@@ -1622,25 +1621,10 @@ static int vme_bus_probe(struct device *dev)
return retval;
 }
 
-static int vme_bus_remove(struct device *dev)
-{
-   int retval = -ENODEV;
-   struct vme_driver *driver;
-   struct vme_dev *vdev = dev_to_vme_dev(dev);
-
-   driver = dev->platform_data;
-
-   if (driver->remove != NULL)
-   retval = driver->remove(vdev);
-
-   return retval;
-}
-
 struct bus_type vme_bus_type = {
.name = "vme",
.match = vme_bus_match,
.probe = vme_bus_probe,
-   .remove = vme_bus_remove,
 };
 EXPORT_SYMBOL(vme_bus_type);
 
@@ -1648,11 +1632,4 @@ static int __init vme_init(void)
 {
return bus_register(&vme_bus_type);
 }
-
-static void __exit vme_exit(void)
-{
-   bus_unregister(&vme_bus_type);
-}
-
 subsys_initcall(vme_init);
-module_exit(vme_exit);
-- 
2.8.4



Re: [PATCH v6 11/11] Input: sur40 - use new V4L2 touch input type

2016-07-03 Thread Florian Echtler
On 30.06.2016 19:38, Nick Dyer wrote:
> Support both V4L2_TCH_FMT_TU08 and V4L2_PIX_FMT_GREY for backwards
> compatibility.
> 
> Note: I have not tested these changes (I have no access to the hardware)
> so not signing off.

I will try to test this ASAP. However, I'm currently ill, so it might
take a while - sorry.

Best, Florian

> ---
>  drivers/input/touchscreen/sur40.c | 121 
> +++---
>  1 file changed, 88 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/sur40.c 
> b/drivers/input/touchscreen/sur40.c
> index 880c40b..9ba68cf 100644
> --- a/drivers/input/touchscreen/sur40.c
> +++ b/drivers/input/touchscreen/sur40.c
> @@ -139,6 +139,27 @@ struct sur40_image_header {
>  #define SUR40_GET_STATE   0xc5 /*  4 bytes state (?) */
>  #define SUR40_GET_SENSORS 0xb1 /*  8 bytes sensors   */
>  
> +static const struct v4l2_pix_format sur40_pix_format[] = {
> + {
> + .pixelformat = V4L2_TCH_FMT_TU08,
> + .width  = SENSOR_RES_X / 2,
> + .height = SENSOR_RES_Y / 2,
> + .field = V4L2_FIELD_NONE,
> + .colorspace = V4L2_COLORSPACE_SRGB,
> + .bytesperline = SENSOR_RES_X / 2,
> + .sizeimage = (SENSOR_RES_X/2) * (SENSOR_RES_Y/2),
> + },
> + {
> + .pixelformat = V4L2_PIX_FMT_GREY,
> + .width  = SENSOR_RES_X / 2,
> + .height = SENSOR_RES_Y / 2,
> + .field = V4L2_FIELD_NONE,
> + .colorspace = V4L2_COLORSPACE_SRGB,
> + .bytesperline = SENSOR_RES_X / 2,
> + .sizeimage = (SENSOR_RES_X/2) * (SENSOR_RES_Y/2),
> + }
> +};
> +
>  /* master device state */
>  struct sur40_state {
>  
> @@ -149,6 +170,7 @@ struct sur40_state {
>   struct v4l2_device v4l2;
>   struct video_device vdev;
>   struct mutex lock;
> + struct v4l2_pix_format pix_fmt;
>  
>   struct vb2_queue queue;
>   struct vb2_alloc_ctx *alloc_ctx;
> @@ -170,7 +192,6 @@ struct sur40_buffer {
>  
>  /* forward declarations */
>  static const struct video_device sur40_video_device;
> -static const struct v4l2_pix_format sur40_video_format;
>  static const struct vb2_queue sur40_queue;
>  static void sur40_process_video(struct sur40_state *sur40);
>  
> @@ -421,7 +442,7 @@ static void sur40_process_video(struct sur40_state *sur40)
>   goto err_poll;
>   }
>  
> - if (le32_to_cpu(img->size) != sur40_video_format.sizeimage) {
> + if (le32_to_cpu(img->size) != sur40->pix_fmt.sizeimage) {
>   dev_err(sur40->dev, "image size mismatch\n");
>   goto err_poll;
>   }
> @@ -432,7 +453,7 @@ static void sur40_process_video(struct sur40_state *sur40)
>  
>   result = usb_sg_init(&sgr, sur40->usbdev,
>   usb_rcvbulkpipe(sur40->usbdev, VIDEO_ENDPOINT), 0,
> - sgt->sgl, sgt->nents, sur40_video_format.sizeimage, 0);
> + sgt->sgl, sgt->nents, sur40->pix_fmt.sizeimage, 0);
>   if (result < 0) {
>   dev_err(sur40->dev, "error %d in usb_sg_init\n", result);
>   goto err_poll;
> @@ -593,13 +614,14 @@ static int sur40_probe(struct usb_interface *interface,
>   goto err_unreg_v4l2;
>   }
>  
> + sur40->pix_fmt = sur40_pix_format[0];
>   sur40->vdev = sur40_video_device;
>   sur40->vdev.v4l2_dev = &sur40->v4l2;
>   sur40->vdev.lock = &sur40->lock;
>   sur40->vdev.queue = &sur40->queue;
>   video_set_drvdata(&sur40->vdev, sur40);
>  
> - error = video_register_device(&sur40->vdev, VFL_TYPE_GRABBER, -1);
> + error = video_register_device(&sur40->vdev, VFL_TYPE_TOUCH, -1);
>   if (error) {
>   dev_err(&interface->dev,
>   "Unable to register video subdevice.");
> @@ -662,10 +684,10 @@ static int sur40_queue_setup(struct vb2_queue *q,
>   alloc_ctxs[0] = sur40->alloc_ctx;
>  
>   if (*nplanes)
> - return sizes[0] < sur40_video_format.sizeimage ? -EINVAL : 0;
> + return sizes[0] < sur40->pix_fmt.sizeimage ? -EINVAL : 0;
>  
>   *nplanes = 1;
> - sizes[0] = sur40_video_format.sizeimage;
> + sizes[0] = sur40->pix_fmt.sizeimage;
>  
>   return 0;
>  }
> @@ -677,7 +699,7 @@ static int sur40_queue_setup(struct vb2_queue *q,
>  static int sur40_buffer_prepare(struct vb2_buffer *vb)
>  {
>   struct sur40_state *sur40 = vb2_get_drv_priv(vb->vb2_queue);
> - unsigned long size = sur40_video_format.sizeimage;
> + unsigned long size = sur40->pix_fmt.sizeimage;
>  
>   if (vb2_plane_size(vb, 0) < size) {
>   dev_err(&sur40->usbdev->dev, "buffer too small (%lu < %lu)\n",
> @@ -751,7 +773,7 @@ static int sur40_vidioc_querycap(struct file *file, void 
> *priv,
>   strlcpy(cap->driver, DRIVER_SHORT, sizeof(cap->driver));
>   strlcpy(cap->card, DRIVER_LONG, sizeof(cap->card));
>   usb_make_path(sur40->usbdev, cap->bus_info, sizeof(cap->bus_info));
> - cap->device_caps = V

[PATCH] PNP: make pnpbios core explicitly non-modular

2016-07-03 Thread Paul Gortmaker
The Kconfig currently controlling compilation of this code is:

config PNPBIOS
bool "Plug and Play BIOS support"

...meaning that it currently is not being built as a module by anyone.

Lets remove the couple traces of modularity, so that when reading the
driver there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit.

Cc: "Rafael J. Wysocki" 
Signed-off-by: Paul Gortmaker 
---
 drivers/pnp/pnpbios/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
index facd43b8516c..b0a3f5e6ac1c 100644
--- a/drivers/pnp/pnpbios/core.c
+++ b/drivers/pnp/pnpbios/core.c
@@ -46,7 +46,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -586,6 +585,6 @@ static int __init pnpbios_thread_init(void)
 }
 
 /* Start the kernel thread later: */
-module_init(pnpbios_thread_init);
+device_initcall(pnpbios_thread_init);
 
 EXPORT_SYMBOL(pnpbios_protocol);
-- 
2.6.1



[PATCH] base: soc: make it explicitly non-modular

2016-07-03 Thread Paul Gortmaker
The Kconfig currently controlling compilation of this code is:

drivers/base/Kconfig:config SOC_BUS
drivers/base/Kconfig:   bool

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that
when reading the driver there is no doubt it is builtin-only.

Since module_init was not in use by this code, the init ordering
remains unchanged with this commit.

Cc: Lee Jones 
Cc: Greg Kroah-Hartman 
Signed-off-by: Paul Gortmaker 
---
 drivers/base/soc.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index 75b98aad6faf..b63f23e6ad61 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -6,7 +6,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -160,11 +159,3 @@ static int __init soc_bus_register(void)
return bus_register(&soc_bus_type);
 }
 core_initcall(soc_bus_register);
-
-static void __exit soc_bus_unregister(void)
-{
-   ida_destroy(&soc_ida);
-
-   bus_unregister(&soc_bus_type);
-}
-module_exit(soc_bus_unregister);
-- 
2.8.4



  1   2   3   >