[PATCH 3/5] x86: mce: Split timer init

2012-07-18 Thread Chen Gong
From: Thomas Gleixner 

Split timer init function into the init and the start part, so the
start part can replace the open coded version in CPU_DOWN_FAILED.

Signed-off-by: Thomas Gleixner 
Acked-by: Borislav Petkov 
---
 arch/x86/kernel/cpu/mcheck/mce.c |   25 +
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index da27c5d..9bc425f 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1554,23 +1554,28 @@ static void __mcheck_cpu_init_vendor(struct cpuinfo_x86 
*c)
}
 }
 
-static void __mcheck_cpu_init_timer(void)
+static void mce_start_timer(unsigned int cpu, struct timer_list *t)
 {
-   struct timer_list *t = &__get_cpu_var(mce_timer);
unsigned long iv = check_interval * HZ;
 
-   setup_timer(t, mce_timer_fn, smp_processor_id());
+   __this_cpu_write(mce_next_interval, iv);
 
-   if (mce_ignore_ce)
+   if (mce_ignore_ce || !iv)
return;
 
-   __this_cpu_write(mce_next_interval, iv);
-   if (!iv)
-   return;
t->expires = round_jiffies(jiffies + iv);
add_timer_on(t, smp_processor_id());
 }
 
+static void __mcheck_cpu_init_timer(void)
+{
+   struct timer_list *t = &__get_cpu_var(mce_timer);
+   unsigned int cpu = smp_processor_id();
+
+   setup_timer(t, mce_timer_fn, cpu);
+   mce_start_timer(cpu, t);
+}
+
 /* Handle unconfigured int18 (should never happen) */
 static void unexpected_machine_check(struct pt_regs *regs, long error_code)
 {
@@ -2275,12 +2280,8 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned 
long action, void *hcpu)
break;
case CPU_DOWN_FAILED:
case CPU_DOWN_FAILED_FROZEN:
-   if (!mce_ignore_ce && check_interval) {
-   t->expires = round_jiffies(jiffies +
-   per_cpu(mce_next_interval, cpu));
-   add_timer_on(t, cpu);
-   }
smp_call_function_single(cpu, mce_reenable_cpu, , 1);
+   mce_start_timer(cpu, t);
break;
case CPU_POST_DEAD:
/* intentionally ignoring frozen here */
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux-next: manual merge of the random tree with the mfd tree

2012-07-18 Thread Stephen Rothwell
Hi Theodore,

Today's linux-next merge of the random tree got a conflict in
drivers/mfd/ab3100-core.c between commit 7f0f07ce25b6 ("mfd: Use devm
allocation for ab3100-core") from the mfd tree and commit 627574db8b21
("random: remove rand_initialize_irq()") from the random tree.

I fixed it up (see below) and can carry the fix as necessary.
-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/mfd/ab3100-core.c
index 4276aab,1287645..000
--- a/drivers/mfd/ab3100-core.c
+++ b/drivers/mfd/ab3100-core.c
@@@ -931,13 -929,10 +929,11 @@@ static int __devinit ab3100_probe(struc
if (err)
goto exit_no_setup;
  
 -  err = request_threaded_irq(client->irq, NULL, ab3100_irq_handler,
 -  IRQF_ONESHOT, "ab3100-core", ab3100);
 +  err = devm_request_threaded_irq(>dev,
 +  client->irq, NULL, ab3100_irq_handler,
 +  IRQF_ONESHOT, "ab3100-core", ab3100);
if (err)
goto exit_no_irq;
-   /* This real unpredictable IRQ is of course sampled for entropy */
-   rand_initialize_irq(client->irq);
  
err = abx500_register_ops(>dev, _ops);
if (err)


pgpCppQnHUOEA.pgp
Description: PGP signature


[PATCH 4/5] x86: mce: Remove the frozen cases in the hotplug code

2012-07-18 Thread Chen Gong
From: Thomas Gleixner 

No point in having double cases if we can simply mask the FROZEN bit
out.

Signed-off-by: Thomas Gleixner 
---
 arch/x86/kernel/cpu/mcheck/mce.c |   12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 9bc425f..eff73e7 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -2260,34 +2260,32 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned 
long action, void *hcpu)
unsigned int cpu = (unsigned long)hcpu;
struct timer_list *t = _cpu(mce_timer, cpu);
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
mce_device_create(cpu);
if (threshold_cpu_callback)
threshold_cpu_callback(action, cpu);
break;
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
if (threshold_cpu_callback)
threshold_cpu_callback(action, cpu);
mce_device_remove(cpu);
break;
case CPU_DOWN_PREPARE:
-   case CPU_DOWN_PREPARE_FROZEN:
del_timer_sync(t);
smp_call_function_single(cpu, mce_disable_cpu, , 1);
break;
case CPU_DOWN_FAILED:
-   case CPU_DOWN_FAILED_FROZEN:
smp_call_function_single(cpu, mce_reenable_cpu, , 1);
mce_start_timer(cpu, t);
break;
-   case CPU_POST_DEAD:
+   }
+
+   if (action == CPU_POST_DEAD) {
/* intentionally ignoring frozen here */
cmci_rediscover(cpu);
-   break;
}
+
return NOTIFY_OK;
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/5] x86: mce: Serialize mce injection

2012-07-18 Thread Chen Gong
From: Thomas Gleixner 

raise_mce() fiddles with global state, but lacks any kind of
serialization.

Add a mutex around the raise_mce() call, so concurrent writers do not
stomp on each other toes.

Signed-off-by: Thomas Gleixner 
---
 arch/x86/kernel/cpu/mcheck/mce-inject.c |4 
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/kernel/cpu/mcheck/mce-inject.c 
b/arch/x86/kernel/cpu/mcheck/mce-inject.c
index 753746f..ddc72f8 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-inject.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-inject.c
@@ -78,6 +78,7 @@ static void raise_exception(struct mce *m, struct pt_regs 
*pregs)
 }
 
 static cpumask_var_t mce_inject_cpumask;
+static DEFINE_MUTEX(mce_inject_mutex);
 
 static int mce_raise_notify(unsigned int cmd, struct pt_regs *regs)
 {
@@ -229,7 +230,10 @@ static ssize_t mce_write(struct file *filp, const char 
__user *ubuf,
 * so do it a jiffie or two later everywhere.
 */
schedule_timeout(2);
+
+   mutex_lock(_inject_mutex);
raise_mce();
+   mutex_unlock(_inject_mutex);
return usize;
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/5] x86: mce: Disable preemption when calling raise_local()

2012-07-18 Thread Chen Gong
From: Thomas Gleixner 

raise_mce() has a code path which does not disable preemption when the
raise_local() is called. The per cpu variable access in raise_local()
depends on preemption being disabled to be functional. So that code
path was either never tested or never tested with CONFIG_DEBUG_PREEMPT
enabled.

Add the missing preempt_disable/enable() pair around the call.

Signed-off-by: Thomas Gleixner 
---
 arch/x86/kernel/cpu/mcheck/mce-inject.c |4 
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/kernel/cpu/mcheck/mce-inject.c 
b/arch/x86/kernel/cpu/mcheck/mce-inject.c
index fc4beb3..753746f 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-inject.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-inject.c
@@ -194,7 +194,11 @@ static void raise_mce(struct mce *m)
put_online_cpus();
} else
 #endif
+   {
+   preempt_disable();
raise_local();
+   preempt_enable();
+   }
 }
 
 /* Error injection interface */
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH 0/5 V2] x86: mce: Bugfixes, cleanups and a new CMCI poll version

2012-07-18 Thread Chen Gong
[PATCH 1/5] x86: mce: Disable preemption when calling raise_local()
[PATCH 2/5] x86: mce: Serialize mce injection
[PATCH 3/5] x86: mce: Split timer init
[PATCH 4/5] x86: mce: Remove the frozen cases in the hotplug code
[PATCH 5/5] x86: mce: Add cmci poll mode

The following series fixes a few interesting bugs (found by review in
context of the CMCI poll effort) and a cleanup to the timer/hotplug
code followed by a consolidated version of the CMCI poll
implementation. This series is based on Linus' tree.

  git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git

Thanks Boris to point out how to use git to commit correct authorship :-).
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC PATCH v4 11/13] memory-hotplug : free memmap of sparse-vmemmap

2012-07-18 Thread Wen Congyang
At 07/18/2012 06:16 PM, Yasuaki Ishimatsu Wrote:
> All pages of virtual mapping in removed memory cannot be freed, since some 
> pages
> used as PGD/PUD includes not only removed memory but also other memory. So the
> patch checks whether page can be freed or not.
> 
> How to check whether page can be freed or not?
>  1. When removing memory, the page structs of the revmoved memory are filled
> with 0FD.
>  2. All page structs are filled with 0xFD on PT/PMD, PT/PMD can be cleared.
> In this case, the page used as PT/PMD can be freed.
> 
> Applying patch, __remove_section() of CONFIG_SPARSEMEM_VMEMMAP is integrated
> into one. So __remove_section() of CONFIG_SPARSEMEM_VMEMMAP is deleted.
> 
> CC: David Rientjes 
> CC: Jiang Liu 
> CC: Len Brown 
> CC: Benjamin Herrenschmidt 
> CC: Paul Mackerras  
> CC: Christoph Lameter 
> Cc: Minchan Kim 
> CC: Andrew Morton 
> CC: KOSAKI Motohiro  
> CC: Wen Congyang 
> Signed-off-by: Yasuaki Ishimatsu 
> 
> ---
>  arch/x86/mm/init_64.c |  121 
> ++
>  include/linux/mm.h|2 
>  mm/memory_hotplug.c   |   19 ---
>  mm/sparse.c   |5 +-
>  4 files changed, 128 insertions(+), 19 deletions(-)
> 
> Index: linux-3.5-rc6/include/linux/mm.h
> ===
> --- linux-3.5-rc6.orig/include/linux/mm.h 2012-07-18 18:01:28.0 
> +0900
> +++ linux-3.5-rc6/include/linux/mm.h  2012-07-18 18:03:05.551168773 +0900
> @@ -1588,6 +1588,8 @@ int vmemmap_populate(struct page *start_
>  void vmemmap_populate_print_last(void);
>  void register_page_bootmem_memmap(unsigned long section_nr, struct page *map,
> unsigned long size);
> +void vmemmap_kfree(struct page *memmpa, unsigned long nr_pages);
> +void vmemmap_free_bootmem(struct page *memmpa, unsigned long nr_pages);
>  
>  enum mf_flags {
>   MF_COUNT_INCREASED = 1 << 0,
> Index: linux-3.5-rc6/mm/sparse.c
> ===
> --- linux-3.5-rc6.orig/mm/sparse.c2012-07-18 17:59:25.0 +0900
> +++ linux-3.5-rc6/mm/sparse.c 2012-07-18 18:03:05.553168749 +0900
> @@ -614,12 +614,13 @@ static inline struct page *kmalloc_secti
>   /* This will make the necessary allocations eventually. */
>   return sparse_mem_map_populate(pnum, nid);
>  }
> -static void __kfree_section_memmap(struct page *memmap, unsigned long 
> nr_pages)
> +static void __kfree_section_memmap(struct page *page, unsigned long nr_pages)
>  {
> - return; /* XXX: Not implemented yet */
> + vmemmap_kfree(page, nr_pages);
>  }
>  static void free_map_bootmem(struct page *page, unsigned long nr_pages)
>  {
> + vmemmap_free_bootmem(page, nr_pages);
>  }
>  #else
>  static struct page *__kmalloc_section_memmap(unsigned long nr_pages)
> Index: linux-3.5-rc6/arch/x86/mm/init_64.c
> ===
> --- linux-3.5-rc6.orig/arch/x86/mm/init_64.c  2012-07-18 18:01:28.0 
> +0900
> +++ linux-3.5-rc6/arch/x86/mm/init_64.c   2012-07-18 18:03:05.564168611 
> +0900
> @@ -978,6 +978,127 @@ vmemmap_populate(struct page *start_page
>   return 0;
>  }
>  
> +#define PAGE_INUSE 0xFD
> +
> +unsigned long find_and_clear_pte_page(unsigned long addr, unsigned long end,
> + struct page **pp, int *page_size)
> +{
> + pgd_t *pgd;
> + pud_t *pud;
> + pmd_t *pmd;
> + pte_t *pte;
> + void *page_addr;
> + unsigned long next;
> +
> + *pp = NULL;
> +
> + pgd = pgd_offset_k(addr);
> + if (pgd_none(*pgd))
> + return pgd_addr_end(addr, end);
> +
> + pud = pud_offset(pgd, addr);
> + if (pud_none(*pud))
> + return pud_addr_end(addr,end);
> +
> + if (!cpu_has_pse) {
> + next = (addr + PAGE_SIZE) & PAGE_MASK;
> + pmd = pmd_offset(pud, addr);
> + if (pmd_none(*pmd))
> + return next;
> +
> + pte = pte_offset_kernel(pmd, addr);
> + if (pte_none(*pte))
> + return next;
> +
> + *page_size = PAGE_SIZE;
> + *pp = pte_page(*pte);
> + } else {
> + next = pmd_addr_end(addr, end);
> +
> + pmd = pmd_offset(pud, addr);
> + if (pmd_none(*pmd))
> + return next;
> +
> + *page_size = PMD_SIZE;
> + *pp = pmd_page(*pmd);
> + }
> +
> + /*
> +  * Removed page structs are filled with 0xFD.
> +  */
> + memset((void *)addr, PAGE_INUSE, next - addr);
> +
> + page_addr = page_address(*pp);
> +
> + /*
> +  * Check the page is filled with 0xFD or not.
> +  * memchr_inv() returns the address. In this case, we cannot
> +  * clear PTE/PUD entry, since the page is used by other.
> +  * So we cannot also free the page.
> +  *
> +  * memchr_inv() returns NULL. In this case, we can clear

[PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling

2012-07-18 Thread xufengzhang.main
When "Invalid Stream Identifier" ERROR happens after process the
received DATA chunks, this ERROR chunk is enqueued into outqueue
before SACK chunk, so when bundling ERROR chunk with SACK chunk,
the ERROR chunk is always placed first in the packet because of
the chunk's position in the outqueue.
This violates sctp specification:
RFC 4960 6.5. Stream Identifier and Stream Sequence Number
...The endpoint may bundle the ERROR chunk in the same
packet as the SACK as long as the ERROR follows the SACK.
So we must place SACK first when bundling "Invalid Stream Identifier"
ERROR and SACK in one packet.
Although we can do that by enqueue SACK chunk into outqueue before
ERROR chunk, it will violate the side-effect interpreter processing.
It's easy to do this job when dequeue chunks from the outqueue,
by this way, we introduce a flag 'has_isi_err' which indicate
whether or not the "Invalid Stream Identifier" ERROR happens.

Signed-off-by: Xufeng Zhang 
---
 include/net/sctp/structs.h |2 ++
 net/sctp/output.c  |   26 ++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 88949a9..5adf4de 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -842,6 +842,8 @@ struct sctp_packet {
has_sack:1, /* This packet contains a SACK chunk. */
has_auth:1, /* This packet contains an AUTH chunk */
has_data:1, /* This packet contains at least 1 DATA chunk */
+   has_isi_err:1,  /* This packet contains a "Invalid Stream
+* Identifier" ERROR chunk */
ipfragok:1, /* So let ip fragment this packet */
malloced:1; /* Is it malloced? */
 };
diff --git a/net/sctp/output.c b/net/sctp/output.c
index 817174e..77fb1ae 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -79,6 +79,7 @@ static void sctp_packet_reset(struct sctp_packet *packet)
packet->has_sack = 0;
packet->has_data = 0;
packet->has_auth = 0;
+   packet->has_isi_err = 0;
packet->ipfragok = 0;
packet->auth = NULL;
 }
@@ -267,6 +268,7 @@ static sctp_xmit_t sctp_packet_bundle_sack(struct 
sctp_packet *pkt,
 sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet,
 struct sctp_chunk *chunk)
 {
+   struct sctp_chunk *lchunk;
sctp_xmit_t retval = SCTP_XMIT_OK;
__u16 chunk_len = WORD_ROUND(ntohs(chunk->chunk_hdr->length));
 
@@ -316,7 +318,31 @@ sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet 
*packet,
packet->has_cookie_echo = 1;
break;
 
+   case SCTP_CID_ERROR:
+   if (chunk->subh.err_hdr->cause & SCTP_ERROR_INV_STRM)
+   packet->has_isi_err = 1;
+   break;
+
case SCTP_CID_SACK:
+   /* RFC 4960
+* 6.5 Stream Identifier and Stream Sequence Number
+* The endpoint may bundle the ERROR chunk in the same
+* packet as the SACK as long as the ERROR follows the SACK.
+*/
+   if (packet->has_isi_err) {
+   if (list_is_singular(>chunk_list))
+   list_add(>list, >chunk_list);
+   else {
+   lchunk = list_first_entry(>chunk_list,
+   struct sctp_chunk, list);
+   list_add(>list, >list);
+   }
+   packet->size += chunk_len;
+   chunk->transport = packet->transport;
+   packet->has_sack = 1;
+   goto finish;
+   }
+
packet->has_sack = 1;
break;
 
-- 
1.7.0.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Question about tps65090 mfd driver

2012-07-18 Thread Joonyoung Shim
Hi, Venu.

2012/7/18 Venu Byravarasu :
> Yes, you are right.
> it was a mistake.
> Will send a patch soon.

I saw your patch about this from https://lkml.org/lkml/2012/7/18/232
because i doesn't subcribe linux-kernel ML yet.

The tps65090 mfd driver has two mfd_cells for "tps65090-pmic" and
"tps65090-regulator". I can find tps65090-regulator driver but cannot find
tps65090-pmic driver.

Is there any reason to exist two mfd_cells?

And one more question.

struct tps65090_platform_data {
int irq_base;
int num_subdevs;
struct tps65090_subdev_info *subdevs;
}

This is  platform data struct for tps65090 mfd driver, but num_subdevs
and subdevs are not used in the mfd driver. How do you handle platform
data of tps65090 mfd driver and regulator driver?

Thanks.

>
> Thanks,
> Venu
>
>
>> -Original Message-
>> From: Joonyoung Shim [mailto:dofm...@gmail.com]
>> Sent: Wednesday, July 18, 2012 6:14 PM
>> To: Venu Byravarasu
>> Cc: sa...@linux.intel.com; linux-kernel@vger.kernel.org
>> Subject: Question about tps65090 mfd driver
>>
>> Hi,
>>
>> I have one question about tps65090 mfd driver.
>> There are following codes in the drivers/mfd/tps65090.c
>>
>> ...
>> static struct mfd_cell tps65090s[] = {
>>   {
>>   .name = "tps65910-pmic",
>>   },
>>   {
>>   .name = "tps65910-regulator",
>>   },
>> };
>> ...
>>
>> I know tps65090 and tps65910 have each different regulator driver.
>>
>> drivers/regulator/tps65090-regulator.c
>> drivers/regulator/tps65910-regulator.c
>>
>> So, i wonder whether it is right that tps65090 mfd driver has tps65910-xxx.
>>
>> Thanks.
>>
>> --
>> - Joonyoung Shim



-- 
- Joonyoung Shim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 1/4] ACPI: Add acpi_pr_() interfaces

2012-07-18 Thread Moore, Robert
>> I wouldn't have a problem renaming a few of those to
>> something like:
>>
>> #define ACPI_INFO(plist) acpi_old_info plist
>> #define ACPI_WARNING(plist)  acpi_old_warning plist
>> #define ACPI_ERROR(plist)acpi_old_error plist
>>
>> The acpi folk might though.
>
>Hi Joe,
>
>ACPI CA is being developed by Intel as OS-neutral code, and is used by
>multiple OSes including Linux.  So, I am not sure how easy to make such
>changes.  I am copying to Lin Ming.


Please don't even consider doing something like this. As we continue to develop 
and maintain the ACPICA code, these kinds of OS-specific divergences from the 
base ACPICA code cause us all kinds of grief, including the accidental creation 
of new bugs as it becomes more and more difficult to integrate the base ACPICA 
code back into Linux.

In fact, we have a major project this year (and probably far into next year) to 
continue to minimize (i.e., fix) this type of Linux/ACPICA divergence -- of 
which many have crept in over the years that ACPICA has been present in the 
Linux kernel.

Bob
















>-Original Message-
>From: linux-acpi-ow...@vger.kernel.org [mailto:linux-acpi-
>ow...@vger.kernel.org] On Behalf Of Toshi Kani
>Sent: Wednesday, July 18, 2012 3:08 PM
>To: Joe Perches; Lin, Ming M
>Cc: l...@kernel.org; linux-a...@vger.kernel.org; linux-
>ker...@vger.kernel.org; bhelg...@google.com;
>isimatu.yasu...@jp.fujitsu.com; liu...@gmail.com;
>srivatsa.b...@linux.vnet.ibm.com; pra...@redhat.com; imamm...@redhat.com;
>vijaymohan.pandarat...@hp.com
>Subject: Re: [PATCH 1/4] ACPI: Add acpi_pr_() interfaces
>
>On Wed, 2012-07-18 at 14:54 -0700, Joe Perches wrote:
>> On Wed, 2012-07-18 at 15:41 -0600, Toshi Kani wrote:
>> > On Wed, 2012-07-18 at 14:21 -0700, Joe Perches wrote:
>> > > On Wed, 2012-07-18 at 14:40 -0600, Toshi Kani wrote:
>> > > > This patch introduces acpi_pr_(), where  is a message
>> > > > level such as err/warn/info, to support improved logging messages
>> > > > for ACPI, esp. in hotplug operations.  acpi_pr_() appends
>> > > > "ACPI" prefix and ACPI object path to the messages.  This improves
>> > > > diagnostics in hotplug operations since it identifies an object
>that
>> > > > caused an issue in a log file.
>> []
>> > > I'd be tempted to instead make the calls more like
>> > > other _ uses and rename these to
>> > > acpi_ and change the existing acpi_info to
>> > > another name.
>> []
>> > I agree with you.  Unfortunately, the ACPI CA (ACPI FW interpreter)
>> > already uses them for its internal-use as follows, so I needed to come
>> > up with some other name...  Hence, acpi_pr_.
>> >
>> > /*
>> >  * Error reporting. Callers module and line number are inserted by
>AE_INFO,
>> >  * the plist contains a set of parens to allow variable-length lists.
>> >  * These macros are used for both the debug and non-debug versions of
>the code.
>> >  */
>> > #define ACPI_INFO(plist)acpi_info plist
>> > #define ACPI_WARNING(plist) acpi_warning plist
>> > #define ACPI_EXCEPTION(plist)   acpi_exception plist
>> > #define ACPI_ERROR(plist)   acpi_error plist
>> > #define ACPI_DEBUG_OBJECT(obj,l,i)
>acpi_ex_do_debug_object(obj,l,i)
>>
>> I wouldn't have a problem renaming a few of those to
>> something like:
>>
>> #define ACPI_INFO(plist) acpi_old_info plist
>> #define ACPI_WARNING(plist)  acpi_old_warning plist
>> #define ACPI_ERROR(plist)acpi_old_error plist
>>
>> The acpi folk might though.
>
>Hi Joe,
>
>ACPI CA is being developed by Intel as OS-neutral code, and is used by
>multiple OSes including Linux.  So, I am not sure how easy to make such
>changes.  I am copying to Lin Ming.
>
>
>> > > Other than that, seems fine to me.
>> > Great!  Can I consider it as Ack? :)
>>
>> Fix the kfree first.
>
>Please see my other email.  Do you think the check should be added
>despite of the warning message?
>
>
>> I rarely ack stuff as other people generally have to
>> pick up the changes and I think acks are overrated.
>
>That's fair enough.
>
>Thanks!
>-Toshi
>
>
>> cheers, Joe
>>
>
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-acpi" 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-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux-next: manual merge of the arm-soc tree with the i2c-embedded tree

2012-07-18 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the arm-soc tree got a conflict in
drivers/i2c/busses/i2c-nomadik.c between commit 235602146ec9
("i2c-nomadik: turn the platform driver to an amba driver") from the
i2c-embedded tree and commit 98582d9562b4 ("ARM: ux500: Remove unused i2c
platform_data initialisation code") from the arm-soc tree.

Just context changes.  I fixed it up (see below) and can carry the fix as
necessary.
-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/i2c/busses/i2c-nomadik.c
index e6b93f3,a92440d..000
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@@ -969,12 -965,12 +969,11 @@@ static int nmk_i2c_probe(struct amba_de
adap->owner = THIS_MODULE;
adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
adap->algo  = _i2c_algo;
-   adap->timeout   = pdata->timeout ? msecs_to_jiffies(pdata->timeout) :
-   msecs_to_jiffies(2);
+   adap->timeout   = msecs_to_jiffies(pdata->timeout);
 +  adap->nr = atomic_read(_id);
snprintf(adap->name, sizeof(adap->name),
 -   "Nomadik I2C%d at %lx", pdev->id, (unsigned long)res->start);
 -
 -  /* fetch the controller id */
 -  adap->nr= pdev->id;
 +   "Nomadik I2C%d at %pR", adap->nr, >res);
 +  atomic_inc(_id);
  
/* fetch the controller configuration from machine */
dev->cfg.clk_freq = pdata->clk_freq;


pgp2ZvNRxyCRx.pgp
Description: PGP signature


Re: [PATCH 0/21] ACPI / PM: Switch ACPI bus type and drivers to dev_pm_ops

2012-07-18 Thread Len Brown

> The patchset has been tested on Toshiba Portege R500 and more testing is in
> the works.  If there are no objections, I'd like to push if for 3.6 through
> the linux-pm tree.

Good plan.  Would need to merge w/ my tree only if we run into conflicts.

Acked-by: Len Brown 

thanks,
Len Brown, Intel Open Source Technology Center
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 1/1] Add Wondermedia Technologies (wmt) to docs/devicetree/vendor-bindings.txt

2012-07-18 Thread Tony Prisk
Given that there have been no replies to this thread, and the restart patch has
now been accepted using 'wmt' as the vendor namespace - would it be safe to
assume we should formalize this in the vendor-bindings.txt?

I'd like to try and have basic device tree support added for the next merge
window (or this one if it all goes well :) ), but it relies on the vendor 
binding being
formalized.

Regards,

Tony P

> -Original Message-
> From: linux-arm-kernel-boun...@lists.infradead.org 
> [mailto:linux-arm-kernel-boun...@lists.infradead.org] On Behalf Of Alexey
> Charkov
> Sent: Wednesday, 18 July 2012 1:31 a.m.
> To: vt8500-wm8505-linux-ker...@googlegroups.com
> Cc: Tony Prisk; devicetree-disc...@lists.ozlabs.org; Russell King; 
> linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org
> Subject: Re: [PATCH 1/1] Add Wondermedia Technologies (wmt) to 
> docs/devicetree/vendor-bindings.txt
> 
> 2012/7/17 Arnd Bergmann :
> > It would also be helpful to describe why the specific string is used here.
> > Normally we use the stock ticker symbol and "wmt" refers to Wal-Mart,
> > which would be unlikely but not impossible to produce their own hardware
> > in the future. The same thing applies to "via", which is VIACOM. The symbol
> > for VIA technologies is "2388.TW", but that is not particularly descriptive
> > or well-known.
> >
> > Maybe someone on the devicetree-discuss mailing list has a better
> > suggestion. I think using "via" is probably the best compromise, as
> > it's a well-known name and most of the components of the wondermedia
> > chips were first made by VIA anyway.
> 
> In fact, "wmt" is the name that the vendor itself uses in their GPL
> code (they also use mach-wmt as the arch-specific folder name). I
> believe that we could just as well use the full "wondermedia" word to
> avoid possible confusion, in case "wmt" is unacceptable for any
> reason.
> 
> Best,
> Alexey
> 
> ___
> linux-arm-kernel mailing list
> linux-arm-ker...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


3.5-rc7 - can no longer wake up from suspend to RAM

2012-07-18 Thread Tomasz Chmielewski
After upgrading to 3.5-rc7, my laptop no longer wakes up reliable from suspend 
to RAM. 3.4.x worked fine.

It did wake up once after a several minute pause; there were a couple of:

BUG: soft lockup - CPU#0 stuck for 23s! [pm-suspend:5522]

in dmesg.


See below for more details.


Jul 18 01:30:19 s9 kernel: [57626.175125] NMI watchdog: enabled on all CPUs, 
permanently consumes one hw-PMU counter.
Jul 18 01:32:04 s9 kernel: [57731.634693] wlan0: deauthenticating from 
00:27:22:44:ee:4f by local choice (reason=3)
Jul 18 01:32:04 s9 kernel: [57731.657099] cfg80211: All devices are 
disconnected, going to restore regulatory settings
Jul 18 01:32:04 s9 kernel: [57731.657113] cfg80211: Restoring regulatory 
settings
Jul 18 01:32:04 s9 kernel: [57731.657125] cfg80211: Calling CRDA to update 
world regulatory domain
Jul 18 01:32:04 s9 kernel: [57731.681986] cfg80211: Ignoring regulatory request 
Set by core since the driver uses its own custom regulatory domain
Jul 18 01:32:04 s9 kernel: [57731.681999] cfg80211: World regulatory domain 
updated:
Jul 18 01:32:04 s9 kernel: [57731.682004] cfg80211:   (start_freq - end_freq @ 
bandwidth), (max_antenna_gain, max_eirp)
Jul 18 01:32:04 s9 kernel: [57731.682010] cfg80211:   (2402000 KHz - 2472000 
KHz @ 4 KHz), (300 mBi, 2000 mBm)
Jul 18 01:32:04 s9 kernel: [57731.682015] cfg80211:   (2457000 KHz - 2482000 
KHz @ 2 KHz), (300 mBi, 2000 mBm)
Jul 18 01:32:04 s9 kernel: [57731.682020] cfg80211:   (2474000 KHz - 2494000 
KHz @ 2 KHz), (300 mBi, 2000 mBm)
Jul 18 01:32:04 s9 kernel: [57731.682025] cfg80211:   (517 KHz - 525 
KHz @ 4 KHz), (300 mBi, 2000 mBm)
Jul 18 01:32:04 s9 kernel: [57731.682030] cfg80211:   (5735000 KHz - 5835000 
KHz @ 4 KHz), (300 mBi, 2000 mBm)
Jul 18 01:32:08 s9 kernel: [57734.569995] PM: Syncing filesystems ... done.
Jul 18 01:32:08 s9 kernel: [57734.775422] PM: Preparing system for mem sleep
Jul 18 01:34:47 s9 kernel: [57734.826480] Freezing user space processes ... 
(elapsed 0.01 seconds) done.
Jul 18 01:34:47 s9 kernel: [57734.842461] Freezing remaining freezable tasks 
... (elapsed 0.01 seconds) done.
Jul 18 01:34:47 s9 kernel: [57734.858455] PM: Entering mem sleep
Jul 18 01:34:47 s9 kernel: [57734.858529] Suspending console(s) (use 
no_console_suspend to debug)
Jul 18 01:34:47 s9 kernel: [57734.874842] sd 0:0:0:0: [sda] Synchronizing SCSI 
cache
Jul 18 01:34:47 s9 kernel: [57734.876600] sd 0:0:0:0: [sda] Stopping disk
Jul 18 01:34:47 s9 kernel: [57735.413906] PM: suspend of devices complete after 
539.681 msecs
Jul 18 01:34:47 s9 kernel: [57735.413911] PM: suspend devices took 0.556 seconds
Jul 18 01:34:47 s9 kernel: [57735.414084] PM: late suspend of devices complete 
after 0.170 msecs
Jul 18 01:34:47 s9 kernel: [57735.414337] xhci_hcd :03:00.0: wake-up 
capability enabled by ACPI
Jul 18 01:34:47 s9 kernel: [57735.429990] r8169 :02:00.0: wake-up 
capability enabled by ACPI
Jul 18 01:34:47 s9 kernel: [57735.509829] PM: noirq suspend of devices complete 
after 95.815 msecs
Jul 18 01:34:47 s9 kernel: [57735.510162] ACPI: Preparing to enter system sleep 
state S3
Jul 18 01:34:47 s9 kernel: [57735.529924] PM: Saving platform NVS memory
Jul 18 01:34:47 s9 kernel: [57735.533712] Disabling non-boot CPUs ...
Jul 18 01:34:47 s9 kernel: [57735.534399] Broke affinity for irq 49
Jul 18 01:34:47 s9 kernel: [57735.637654] CPU 1 is now offline
Jul 18 01:34:47 s9 kernel: [57735.741579] CPU 2 is now offline
Jul 18 01:34:47 s9 kernel: [57735.742343] Broke affinity for irq 9
Jul 18 01:34:47 s9 kernel: [57735.742362] Broke affinity for irq 16
Jul 18 01:34:47 s9 kernel: [57735.845486] CPU 3 is now offline
Jul 18 01:34:47 s9 kernel: [57735.845973] Extended CMOS year: 2000
Jul 18 01:34:47 s9 kernel: [57735.847433] ACPI: Low-level resume complete
Jul 18 01:34:47 s9 kernel: [57735.847480] PM: Restoring platform NVS memory
Jul 18 01:34:47 s9 kernel: [57735.848340] Extended CMOS year: 2000
Jul 18 01:34:47 s9 kernel: [57735.848387] Enabling non-boot CPUs ...
Jul 18 01:34:47 s9 kernel: [57735.848486] Booting Node 0 Processor 1 APIC 0x1
Jul 18 01:34:47 s9 kernel: [57762.066656] BUG: soft lockup - CPU#0 stuck for 
23s! [pm-suspend:5522]
Jul 18 01:34:47 s9 kernel: [57762.066656] Modules linked in: msr uas 
usb_storage easy_slow_down_manager(O) ip6table_filter ip6_tables ebtable_nat 
ebtables dm_crypt ipt_MASQUERADE iptable_nat nf_nat nf_conntrack_ipv4 
nf_defrag_ipv4 xt_state nf_conntrack ipt_REJECT snd_hda_codec_hdmi 
snd_hda_codec_realtek xt_CHECKSUM iptable_mangle xt_tcpudp iptable_filter 
ip_tables x_tables bridge stp llc arc4 bnep rfcomm snd_hda_intel parport_pc 
snd_hda_codec ppdev snd_hwdep snd_pcm samsung_laptop kvm_intel kvm snd_seq_midi 
snd_rawmidi snd_seq_midi_event snd_seq microcode snd_timer snd_seq_device 
iwlwifi psmouse serio_raw mac80211 snd lpc_ich cfg80211 btusb bluetooth 
soundcore snd_page_alloc binfmt_misc mei mac_hid coretemp lp parport 
ghash_clmulni_intel aesni_intel cryptd aes_x86_64 i915 drm_kms_helper r8169 

linux-next: manual merge of the staging tree with the target-merge tree

2012-07-18 Thread Stephen Rothwell
Hi Greg,

Today's linux-next merge of the staging tree got a conflict in
drivers/staging/Kconfig between commit d0146d396bfa ("tcm_vhost: Initial
merge for vhost level target fabric driver") from the target-merge tree
and commit 15a4bc17b7f4 ("Staging: add CSR Wifi "os helper" module") from
the staging tree.

Just context changes.  I fixed it up (see below) and can carry the fix as
necessary.
-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/staging/Kconfig
index 67ec9fe,e3402d5..000
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@@ -132,6 -132,8 +132,10 @@@ source "drivers/staging/ipack/Kconfig
  
  source "drivers/staging/gdm72xx/Kconfig"
  
+ source "drivers/staging/csr/Kconfig"
+ 
+ source "drivers/staging/omap-thermal/Kconfig"
+ 
 +source "drivers/vhost/Kconfig.tcm"
 +
  endif # STAGING


pgpvbZrW3BS2L.pgp
Description: PGP signature


Re: PM: Summary of changes for v3.6

2012-07-18 Thread Len Brown

> The disappeared from Len's tree for a little while after the 3.5 merge
> window, which is why they started appearing other places.  Now that
> they have returned to Len's tree, hopefully to stay, they should be
> considered the official version.

Yes, they are staged for 3.6 in my tree.

The intent was to push them for 3.5, but some unrelated patches
exploded and stopped that push.  I then had to re-merge my tree
to push only the bug-fixes to 3.5, which is why the feature
patches went away for a bit.

thanks,
-Len



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RESEND 9/9] x86: OLPC: move s/r-related EC cmds to EC driver

2012-07-18 Thread Andres Salomon

The new EC driver calls platform-specific suspend and resume hooks; run
XO-1-specific EC commands from there, rather than deep in s/r code.  If we
attempt to run EC commands after the new EC driver has suspended, it is
refused by the ec->suspended checks.

Signed-off-by: Andres Salomon 
---
 arch/x86/platform/olpc/olpc-xo1-pm.c |   15 
 arch/x86/platform/olpc/olpc.c|   43 -
 2 files changed, 36 insertions(+), 22 deletions(-)

diff --git a/arch/x86/platform/olpc/olpc-xo1-pm.c 
b/arch/x86/platform/olpc/olpc-xo1-pm.c
index 8054b64..d75582d 100644
--- a/arch/x86/platform/olpc/olpc-xo1-pm.c
+++ b/arch/x86/platform/olpc/olpc-xo1-pm.c
@@ -52,16 +52,11 @@ EXPORT_SYMBOL_GPL(olpc_xo1_pm_wakeup_clear);
 static int xo1_power_state_enter(suspend_state_t pm_state)
 {
unsigned long saved_sci_mask;
-   int r;
 
/* Only STR is supported */
if (pm_state != PM_SUSPEND_MEM)
return -EINVAL;
 
-   r = olpc_ec_cmd(EC_SET_SCI_INHIBIT, NULL, 0, NULL, 0);
-   if (r)
-   return r;
-
/*
 * Save SCI mask (this gets lost since PM1_EN is used as a mask for
 * wakeup events, which is not necessarily the same event set)
@@ -77,16 +72,6 @@ static int xo1_power_state_enter(suspend_state_t pm_state)
/* Restore SCI mask (using dword access to CS5536_PM1_EN) */
outl(saved_sci_mask, acpi_base + CS5536_PM1_STS);
 
-   /* Tell the EC to stop inhibiting SCIs */
-   olpc_ec_cmd(EC_SET_SCI_INHIBIT_RELEASE, NULL, 0, NULL, 0);
-
-   /*
-* Tell the wireless module to restart USB communication.
-* Must be done twice.
-*/
-   olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0);
-   olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0);
-
return 0;
 }
 
diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c
index ed41b43..2737608 100644
--- a/arch/x86/platform/olpc/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
@@ -263,11 +263,6 @@ int olpc_ec_sci_query(u16 *sci_value)
 }
 EXPORT_SYMBOL_GPL(olpc_ec_sci_query);
 
-static int olpc_ec_suspend(struct platform_device *pdev)
-{
-   return olpc_ec_mask_write(ec_wakeup_mask);
-}
-
 static bool __init check_ofw_architecture(struct device_node *root)
 {
const char *olpc_arch;
@@ -339,9 +334,40 @@ static int olpc_xo1_ec_probe(struct platform_device *pdev)
 
return 0;
 }
+static int olpc_xo1_ec_suspend(struct platform_device *pdev)
+{
+   olpc_ec_mask_write(ec_wakeup_mask);
+
+   /*
+* Squelch SCIs while suspended.  This is a fix for
+* .
+*/
+   return olpc_ec_cmd(EC_SET_SCI_INHIBIT, NULL, 0, NULL, 0);
+}
+
+static int olpc_xo1_ec_resume(struct platform_device *pdev)
+{
+   /* Tell the EC to stop inhibiting SCIs */
+   olpc_ec_cmd(EC_SET_SCI_INHIBIT_RELEASE, NULL, 0, NULL, 0);
+
+   /*
+* Tell the wireless module to restart USB communication.
+* Must be done twice.
+*/
+   olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0);
+   olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0);
+
+   return 0;
+}
 
 static struct olpc_ec_driver ec_xo1_driver = {
-   .suspend = olpc_ec_suspend,
+   .probe = olpc_xo1_ec_probe,
+   .suspend = olpc_xo1_ec_suspend,
+   .resume = olpc_xo1_ec_resume,
+   .ec_cmd = olpc_xo1_ec_cmd,
+};
+
+static struct olpc_ec_driver ec_xo1_5_driver = {
.probe = olpc_xo1_ec_probe,
.ec_cmd = olpc_xo1_ec_cmd,
 };
@@ -354,7 +380,10 @@ static int __init olpc_init(void)
return 0;
 
/* register the XO-1 and 1.5-specific EC handler */
-   olpc_ec_driver_register(_xo1_driver, NULL);
+   if (olpc_platform_info.boardrev < olpc_board_pre(0xd0)) /* XO-1 */
+   olpc_ec_driver_register(_xo1_driver, NULL);
+   else
+   olpc_ec_driver_register(_xo1_5_driver, NULL);
platform_device_register_simple("olpc-ec", -1, NULL, 0);
 
/* assume B1 and above models always have a DCON */
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RESEND 8/9] Platform: OLPC: move global variables into priv struct

2012-07-18 Thread Andres Salomon
Populate olpc_ec_priv with variables that were previously global.  This
makes things a tad bit clearer, IMO.

Signed-off-by: Andres Salomon 
---
 drivers/platform/olpc/olpc-ec.c |   48 ++
 1 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index 1a15a79..0f9f859 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -31,6 +31,12 @@ struct ec_cmd_desc {
 
 struct olpc_ec_priv {
struct olpc_ec_driver *drv;
+   struct work_struct worker;
+   struct mutex cmd_lock;
+
+   /* Pending EC commands */
+   struct list_head cmd_q;
+   spinlock_t cmd_q_lock;
 
struct dentry *dbgfs_dir;
 
@@ -46,16 +52,9 @@ struct olpc_ec_priv {
bool suspended;
 };
 
-static void olpc_ec_worker(struct work_struct *w);
-
-static DECLARE_WORK(ec_worker, olpc_ec_worker);
-static LIST_HEAD(ec_cmd_q);
-static DEFINE_SPINLOCK(ec_cmd_q_lock);
-
 static struct olpc_ec_driver *ec_driver;
 static struct olpc_ec_priv *ec_priv;
 static void *ec_cb_arg;
-static DEFINE_MUTEX(ec_cb_lock);
 
 void olpc_ec_driver_register(struct olpc_ec_driver *drv, void *arg)
 {
@@ -66,49 +65,51 @@ EXPORT_SYMBOL_GPL(olpc_ec_driver_register);
 
 static void olpc_ec_worker(struct work_struct *w)
 {
+   struct olpc_ec_priv *ec = container_of(w, struct olpc_ec_priv, worker);
struct ec_cmd_desc *desc = NULL;
unsigned long flags;
 
/* Grab the first pending command from the queue */
-   spin_lock_irqsave(_cmd_q_lock, flags);
-   if (!list_empty(_cmd_q)) {
-   desc = list_first_entry(_cmd_q, struct ec_cmd_desc, node);
+   spin_lock_irqsave(>cmd_q_lock, flags);
+   if (!list_empty(>cmd_q)) {
+   desc = list_first_entry(>cmd_q, struct ec_cmd_desc, node);
list_del(>node);
}
-   spin_unlock_irqrestore(_cmd_q_lock, flags);
+   spin_unlock_irqrestore(>cmd_q_lock, flags);
 
/* Do we actually have anything to do? */
if (!desc)
return;
 
/* Protect the EC hw with a mutex; only run one cmd at a time */
-   mutex_lock(_cb_lock);
+   mutex_lock(>cmd_lock);
desc->err = ec_driver->ec_cmd(desc->cmd, desc->inbuf, desc->inlen,
desc->outbuf, desc->outlen, ec_cb_arg);
-   mutex_unlock(_cb_lock);
+   mutex_unlock(>cmd_lock);
 
/* Finished, wake up olpc_ec_cmd() */
complete(>finished);
 
/* Run the worker thread again in case there are more cmds pending */
-   schedule_work(_worker);
+   schedule_work(>worker);
 }
 
 /*
  * Throw a cmd descripter onto the list.  We now have SMP OLPC machines, so
  * locking is pretty critical.
  */
-static void queue_ec_descriptor(struct ec_cmd_desc *desc)
+static void queue_ec_descriptor(struct ec_cmd_desc *desc,
+   struct olpc_ec_priv *ec)
 {
unsigned long flags;
 
INIT_LIST_HEAD(>node);
 
-   spin_lock_irqsave(_cmd_q_lock, flags);
-   list_add_tail(>node, _cmd_q);
-   spin_unlock_irqrestore(_cmd_q_lock, flags);
+   spin_lock_irqsave(>cmd_q_lock, flags);
+   list_add_tail(>node, >cmd_q);
+   spin_unlock_irqrestore(>cmd_q_lock, flags);
 
-   schedule_work(_worker);
+   schedule_work(>worker);
 }
 
 int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf, size_t outlen)
@@ -137,7 +138,7 @@ int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 
*outbuf, size_t outlen)
desc.err = 0;
init_completion();
 
-   queue_ec_descriptor();
+   queue_ec_descriptor(, ec);
 
/* Timeouts must be handled in the platform-specific EC hook */
wait_for_completion();
@@ -266,7 +267,14 @@ static int olpc_ec_probe(struct platform_device *pdev)
ec = kzalloc(sizeof(*ec), GFP_KERNEL);
if (!ec)
return -ENOMEM;
+
ec->drv = ec_driver;
+   INIT_WORK(>worker, olpc_ec_worker);
+   mutex_init(>cmd_lock);
+
+   INIT_LIST_HEAD(>cmd_q);
+   spin_lock_init(>cmd_q_lock);
+
ec_priv = ec;
platform_set_drvdata(pdev, ec);
 
-- 
1.7.2.5


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RESEND 7/9] Platform: OLPC: move debugfs support from x86 EC driver

2012-07-18 Thread Andres Salomon

There's nothing about the debugfs interface for the EC driver that is
architecture-specific, so move it into the arch-independent driver.

The code is mostly unchanged with the exception of renamed variables, coding
style changes, and API updates.

Signed-off-by: Andres Salomon 
---
 arch/x86/platform/olpc/olpc.c   |   97 
 drivers/platform/olpc/olpc-ec.c |  117 +++
 2 files changed, 117 insertions(+), 97 deletions(-)

diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c
index 4590096..ed41b43 100644
--- a/arch/x86/platform/olpc/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
@@ -19,7 +19,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -31,15 +30,6 @@
 struct olpc_platform_t olpc_platform_info;
 EXPORT_SYMBOL_GPL(olpc_platform_info);
 
-/* debugfs interface to EC commands */
-#define EC_MAX_CMD_ARGS (5 + 1)/* cmd byte + 5 args */
-#define EC_MAX_CMD_REPLY (8)
-
-static struct dentry *ec_debugfs_dir;
-static DEFINE_MUTEX(ec_debugfs_cmd_lock);
-static unsigned char ec_debugfs_resp[EC_MAX_CMD_REPLY];
-static unsigned int ec_debugfs_resp_bytes;
-
 /* EC event mask to be applied during suspend (defining wakeup sources). */
 static u16 ec_wakeup_mask;
 
@@ -273,91 +263,6 @@ int olpc_ec_sci_query(u16 *sci_value)
 }
 EXPORT_SYMBOL_GPL(olpc_ec_sci_query);
 
-static ssize_t ec_debugfs_cmd_write(struct file *file, const char __user *buf,
-   size_t size, loff_t *ppos)
-{
-   int i, m;
-   unsigned char ec_cmd[EC_MAX_CMD_ARGS];
-   unsigned int ec_cmd_int[EC_MAX_CMD_ARGS];
-   char cmdbuf[64];
-   int ec_cmd_bytes;
-
-   mutex_lock(_debugfs_cmd_lock);
-
-   size = simple_write_to_buffer(cmdbuf, sizeof(cmdbuf), ppos, buf, size);
-
-   m = sscanf(cmdbuf, "%x:%u %x %x %x %x %x", _cmd_int[0],
-  _debugfs_resp_bytes,
-  _cmd_int[1], _cmd_int[2], _cmd_int[3],
-  _cmd_int[4], _cmd_int[5]);
-   if (m < 2 || ec_debugfs_resp_bytes > EC_MAX_CMD_REPLY) {
-   /* reset to prevent overflow on read */
-   ec_debugfs_resp_bytes = 0;
-
-   printk(KERN_DEBUG "olpc-ec: bad ec cmd:  "
-  "cmd:response-count [arg1 [arg2 ...]]\n");
-   size = -EINVAL;
-   goto out;
-   }
-
-   /* convert scanf'd ints to char */
-   ec_cmd_bytes = m - 2;
-   for (i = 0; i <= ec_cmd_bytes; i++)
-   ec_cmd[i] = ec_cmd_int[i];
-
-   printk(KERN_DEBUG "olpc-ec: debugfs cmd 0x%02x with %d args "
-  "%02x %02x %02x %02x %02x, want %d returns\n",
-  ec_cmd[0], ec_cmd_bytes, ec_cmd[1], ec_cmd[2], ec_cmd[3],
-  ec_cmd[4], ec_cmd[5], ec_debugfs_resp_bytes);
-
-   olpc_ec_cmd(ec_cmd[0], (ec_cmd_bytes == 0) ? NULL : _cmd[1],
-   ec_cmd_bytes, ec_debugfs_resp, ec_debugfs_resp_bytes);
-
-   printk(KERN_DEBUG "olpc-ec: response "
-  "%02x %02x %02x %02x %02x %02x %02x %02x (%d bytes expected)\n",
-  ec_debugfs_resp[0], ec_debugfs_resp[1], ec_debugfs_resp[2],
-  ec_debugfs_resp[3], ec_debugfs_resp[4], ec_debugfs_resp[5],
-  ec_debugfs_resp[6], ec_debugfs_resp[7], ec_debugfs_resp_bytes);
-
-out:
-   mutex_unlock(_debugfs_cmd_lock);
-   return size;
-}
-
-static ssize_t ec_debugfs_cmd_read(struct file *file, char __user *buf,
-  size_t size, loff_t *ppos)
-{
-   unsigned int i, r;
-   char *rp;
-   char respbuf[64];
-
-   mutex_lock(_debugfs_cmd_lock);
-   rp = respbuf;
-   rp += sprintf(rp, "%02x", ec_debugfs_resp[0]);
-   for (i = 1; i < ec_debugfs_resp_bytes; i++)
-   rp += sprintf(rp, ", %02x", ec_debugfs_resp[i]);
-   mutex_unlock(_debugfs_cmd_lock);
-   rp += sprintf(rp, "\n");
-
-   r = rp - respbuf;
-   return simple_read_from_buffer(buf, size, ppos, respbuf, r);
-}
-
-static const struct file_operations ec_debugfs_genops = {
-   .write   = ec_debugfs_cmd_write,
-   .read= ec_debugfs_cmd_read,
-};
-
-static void setup_debugfs(void)
-{
-   ec_debugfs_dir = debugfs_create_dir("olpc-ec", 0);
-   if (ec_debugfs_dir == ERR_PTR(-ENODEV))
-   return;
-
-   debugfs_create_file("cmd", 0600, ec_debugfs_dir, NULL,
-   _debugfs_genops);
-}
-
 static int olpc_ec_suspend(struct platform_device *pdev)
 {
return olpc_ec_mask_write(ec_wakeup_mask);
@@ -470,8 +375,6 @@ static int __init olpc_init(void)
return r;
}
 
-   setup_debugfs();
-
return 0;
 }
 
diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index a3d32c2..1a15a79 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -6,6 +6,7 @@
  * Licensed under the GPL v2 or later.
  */
 #include 
+#include 
 #include 
 

[PATCH RESEND 6/9] x86: OLPC: switch over to using new EC driver on x86

2012-07-18 Thread Andres Salomon

This uses the new EC driver framework in drivers/platform/olpc.  The
XO-1 and XO-1.5-specific code is still in arch/x86, but the generic stuff
(including a new workqueue; no more running EC commands with IRQs disabled!)
can be shared with other architectures.

Signed-off-by: Andres Salomon 
---
 arch/x86/include/asm/olpc.h |5 ---
 arch/x86/platform/olpc/olpc.c   |   53 ---
 drivers/platform/olpc/olpc-ec.c |5 ---
 3 files changed, 27 insertions(+), 36 deletions(-)

diff --git a/arch/x86/include/asm/olpc.h b/arch/x86/include/asm/olpc.h
index 5b28f3e..72f9adf6 100644
--- a/arch/x86/include/asm/olpc.h
+++ b/arch/x86/include/asm/olpc.h
@@ -100,11 +100,6 @@ extern void olpc_xo1_pm_wakeup_clear(u16 value);
 
 extern int pci_olpc_init(void);
 
-/* EC related functions */
-
-extern int olpc_ec_cmd_x86(unsigned char cmd, unsigned char *inbuf,
-   size_t inlen, unsigned char *outbuf, size_t outlen);
-
 /* SCI source values */
 
 #define EC_SCI_SRC_EMPTY   0x00
diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c
index a3fa180..4590096 100644
--- a/arch/x86/platform/olpc/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -32,8 +31,6 @@
 struct olpc_platform_t olpc_platform_info;
 EXPORT_SYMBOL_GPL(olpc_platform_info);
 
-static DEFINE_SPINLOCK(ec_lock);
-
 /* debugfs interface to EC commands */
 #define EC_MAX_CMD_ARGS (5 + 1)/* cmd byte + 5 args */
 #define EC_MAX_CMD_REPLY (8)
@@ -126,16 +123,13 @@ static int __wait_on_obf(unsigned int line, unsigned int 
port, int desired)
  * .  Unfortunately, while
  * OpenFirmware's source is available, the EC's is not.
  */
-int olpc_ec_cmd_x86(unsigned char cmd, unsigned char *inbuf, size_t inlen,
-   unsigned char *outbuf,  size_t outlen)
+static int olpc_xo1_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
+   size_t outlen, void *arg)
 {
-   unsigned long flags;
int ret = -EIO;
int i;
int restarts = 0;
 
-   spin_lock_irqsave(_lock, flags);
-
/* Clear OBF */
for (i = 0; i < 10 && (obf_status(0x6c) == 1); i++)
inb(0x68);
@@ -199,10 +193,8 @@ restart:
 
ret = 0;
 err:
-   spin_unlock_irqrestore(_lock, flags);
return ret;
 }
-EXPORT_SYMBOL_GPL(olpc_ec_cmd_x86);
 
 void olpc_ec_wakeup_set(u16 value)
 {
@@ -366,7 +358,7 @@ static void setup_debugfs(void)
_debugfs_genops);
 }
 
-static int olpc_ec_suspend(void)
+static int olpc_ec_suspend(struct platform_device *pdev)
 {
return olpc_ec_mask_write(ec_wakeup_mask);
 }
@@ -425,8 +417,28 @@ static int __init add_xo1_platform_devices(void)
return 0;
 }
 
-static struct syscore_ops olpc_syscore_ops = {
+static int olpc_xo1_ec_probe(struct platform_device *pdev)
+{
+   /* get the EC revision */
+   olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0,
+   (unsigned char *) _platform_info.ecver, 1);
+
+   /* EC version 0x5f adds support for wide SCI mask */
+   if (olpc_platform_info.ecver >= 0x5f)
+   olpc_platform_info.flags |= OLPC_F_EC_WIDE_SCI;
+
+   pr_info("OLPC board revision %s%X (EC=%x)\n",
+   ((olpc_platform_info.boardrev & 0xf) < 8) ? "pre" : "",
+   olpc_platform_info.boardrev >> 4,
+   olpc_platform_info.ecver);
+
+   return 0;
+}
+
+static struct olpc_ec_driver ec_xo1_driver = {
.suspend = olpc_ec_suspend,
+   .probe = olpc_xo1_ec_probe,
+   .ec_cmd = olpc_xo1_ec_cmd,
 };
 
 static int __init olpc_init(void)
@@ -436,16 +448,14 @@ static int __init olpc_init(void)
if (!olpc_ofw_present() || !platform_detect())
return 0;
 
-   spin_lock_init(_lock);
+   /* register the XO-1 and 1.5-specific EC handler */
+   olpc_ec_driver_register(_xo1_driver, NULL);
+   platform_device_register_simple("olpc-ec", -1, NULL, 0);
 
/* assume B1 and above models always have a DCON */
if (olpc_board_at_least(olpc_board(0xb1)))
olpc_platform_info.flags |= OLPC_F_DCON;
 
-   /* get the EC revision */
-   olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0,
-   (unsigned char *) _platform_info.ecver, 1);
-
 #ifdef CONFIG_PCI_OLPC
/* If the VSA exists let it emulate PCI, if not emulate in kernel.
 * XO-1 only. */
@@ -453,14 +463,6 @@ static int __init olpc_init(void)
!cs5535_has_vsa2())
x86_init.pci.arch_init = pci_olpc_init;
 #endif
-   /* EC version 0x5f adds support for wide SCI mask */
-   if (olpc_platform_info.ecver >= 0x5f)
-   olpc_platform_info.flags |= OLPC_F_EC_WIDE_SCI;
-
-   printk(KERN_INFO "OLPC board revision %s%X (EC=%x)\n",
-   ((olpc_platform_info.boardrev 

[PATCH RESEND 5/9] Platform: OLPC: add a suspended flag to the EC driver

2012-07-18 Thread Andres Salomon

A problem we've noticed on XO-1.75 is when we suspend in the middle of
an EC command.  Don't allow that.

In the process, create a private object for the generic EC driver to use;
we have a framework for passing around a struct, use that rather than a
proliferation of global variables.

Signed-off-by: Andres Salomon 
---
 drivers/platform/olpc/olpc-ec.c |   46 ++-
 1 files changed, 45 insertions(+), 1 deletions(-)

diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index d00523c..cfba41f 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -27,6 +28,21 @@ struct ec_cmd_desc {
void *priv;
 };
 
+struct olpc_ec_priv {
+   struct olpc_ec_driver *drv;
+
+   /*
+* Running an EC command while suspending means we don't always finish
+* the command before the machine suspends.  This means that the EC
+* is expecting the command protocol to finish, but we after a period
+* of time (while the OS is asleep) the EC times out and restarts its
+* idle loop.  Meanwhile, the OS wakes up, thinks it's still in the
+* middle of the command protocol, starts throwing random things at
+* the EC... and everyone's uphappy.
+*/
+   bool suspended;
+};
+
 static void olpc_ec_worker(struct work_struct *w);
 
 static DECLARE_WORK(ec_worker, olpc_ec_worker);
@@ -34,6 +50,7 @@ static LIST_HEAD(ec_cmd_q);
 static DEFINE_SPINLOCK(ec_cmd_q_lock);
 
 static struct olpc_ec_driver *ec_driver;
+static struct olpc_ec_priv *ec_priv;
 static void *ec_cb_arg;
 static DEFINE_MUTEX(ec_cb_lock);
 
@@ -93,6 +110,7 @@ static void queue_ec_descriptor(struct ec_cmd_desc *desc)
 
 int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf, size_t outlen)
 {
+   struct olpc_ec_priv *ec = ec_priv;
struct ec_cmd_desc desc;
 
/* XXX: this will be removed in later patches */
@@ -104,6 +122,13 @@ int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 
*outbuf, size_t outlen)
if (WARN_ON(!ec_driver || !ec_driver->ec_cmd))
return -ENODEV;
 
+   if (!ec)
+   return -ENOMEM;
+
+   /* Suspending in the middle of a command hoses things really badly */
+   if (WARN_ON(ec->suspended))
+   return -EBUSY;
+
might_sleep();
 
desc.cmd = cmd;
@@ -126,11 +151,19 @@ EXPORT_SYMBOL_GPL(olpc_ec_cmd);
 
 static int olpc_ec_probe(struct platform_device *pdev)
 {
+   struct olpc_ec_priv *ec;
int err;
 
if (!ec_driver)
return -ENODEV;
 
+   ec = kzalloc(sizeof(*ec), GFP_KERNEL);
+   if (!ec)
+   return -ENOMEM;
+   ec->drv = ec_driver;
+   ec_priv = ec;
+   platform_set_drvdata(pdev, ec);
+
err = ec_driver->probe ? ec_driver->probe(pdev) : 0;
 
return err;
@@ -139,12 +172,23 @@ static int olpc_ec_probe(struct platform_device *pdev)
 static int olpc_ec_suspend(struct device *dev)
 {
struct platform_device *pdev = to_platform_device(dev);
-   return ec_driver->suspend ? ec_driver->suspend(pdev) : 0;
+   struct olpc_ec_priv *ec = platform_get_drvdata(pdev);
+   int err = 0;
+
+   if (ec_driver->suspend)
+   err = ec_driver->suspend(pdev);
+   if (!err)
+   ec->suspended = true;
+
+   return err;
 }
 
 static int olpc_ec_resume(struct device *dev)
 {
struct platform_device *pdev = to_platform_device(dev);
+   struct olpc_ec_priv *ec = platform_get_drvdata(pdev);
+
+   ec->suspended = false;
return ec_driver->resume ? ec_driver->resume(pdev) : 0;
 }
 
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RESEND 4/9] Platform: OLPC: turn EC driver into a platform_driver

2012-07-18 Thread Andres Salomon

The 1.75-based OLPC EC driver already does this; let's do it for all EC
drivers.  This gives us nice suspend/resume hooks, amongst other things.

We want to run the EC's suspend hooks later than other drivers (which may
be setting wakeup masks or be running EC commands).  We also want to run
the EC's resume hooks earlier than other drivers (which may want to run EC
commands).

Signed-off-by: Andres Salomon 
---
 drivers/platform/olpc/olpc-ec.c |   48 +++
 include/linux/olpc-ec.h |6 +
 2 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index 44e6a4f..d00523c 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -122,3 +123,50 @@ int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 
*outbuf, size_t outlen)
return desc.err;
 }
 EXPORT_SYMBOL_GPL(olpc_ec_cmd);
+
+static int olpc_ec_probe(struct platform_device *pdev)
+{
+   int err;
+
+   if (!ec_driver)
+   return -ENODEV;
+
+   err = ec_driver->probe ? ec_driver->probe(pdev) : 0;
+
+   return err;
+}
+
+static int olpc_ec_suspend(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   return ec_driver->suspend ? ec_driver->suspend(pdev) : 0;
+}
+
+static int olpc_ec_resume(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   return ec_driver->resume ? ec_driver->resume(pdev) : 0;
+}
+
+static const struct dev_pm_ops olpc_ec_pm_ops = {
+   .suspend_late = olpc_ec_suspend,
+   .resume_early = olpc_ec_resume,
+};
+
+static struct platform_driver olpc_ec_plat_driver = {
+   .probe = olpc_ec_probe,
+   .driver = {
+   .name = "olpc-ec",
+   .pm = _ec_pm_ops,
+   },
+};
+
+static int __init olpc_ec_init_module(void)
+{
+   return platform_driver_register(_ec_plat_driver);
+}
+
+module_init(olpc_ec_init_module);
+
+MODULE_AUTHOR("Andres Salomon ");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/olpc-ec.h b/include/linux/olpc-ec.h
index 231e96f..5bb6e76 100644
--- a/include/linux/olpc-ec.h
+++ b/include/linux/olpc-ec.h
@@ -14,7 +14,13 @@
 #define EC_SCI_QUERY   0x84
 #define EC_EXT_SCI_QUERY   0x85
 
+struct platform_device;
+
 struct olpc_ec_driver {
+   int (*probe)(struct platform_device *);
+   int (*suspend)(struct platform_device *);
+   int (*resume)(struct platform_device *);
+
int (*ec_cmd)(u8, u8 *, size_t, u8 *, size_t, void *);
 };
 
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RESEND 3/9] Platform: OLPC: allow EC cmd to be overridden, and create a workqueue to call it

2012-07-18 Thread Andres Salomon

This provides a new API allows different OLPC architectures to override the
EC driver.  x86 and ARM OLPC machines use completely different EC backends.

The olpc_ec_cmd is synchronous, and waits for the workqueue to send the
command to the EC.  Multiple callers can run olpc_ec_cmd() at once, and
they will by serialized and sleep while only one executes on the EC at a time.

We don't provide an unregister function, as that doesn't make sense within
the context of OLPC machines - there's only ever 1 EC, it's critical to
functionality, and it certainly not hotpluggable.

Signed-off-by: Andres Salomon 
---
 drivers/platform/olpc/olpc-ec.c |  112 ++-
 include/linux/olpc-ec.h |6 ++
 2 files changed, 116 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index 4202603..44e6a4f 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -5,12 +5,120 @@
  *
  * Licensed under the GPL v2 or later.
  */
+#include 
+#include 
+#include 
+#include 
 #include 
+#include 
+#include 
 #include 
 
+struct ec_cmd_desc {
+   u8 cmd;
+   u8 *inbuf, *outbuf;
+   size_t inlen, outlen;
+
+   int err;
+   struct completion finished;
+   struct list_head node;
+
+   void *priv;
+};
+
+static void olpc_ec_worker(struct work_struct *w);
+
+static DECLARE_WORK(ec_worker, olpc_ec_worker);
+static LIST_HEAD(ec_cmd_q);
+static DEFINE_SPINLOCK(ec_cmd_q_lock);
+
+static struct olpc_ec_driver *ec_driver;
+static void *ec_cb_arg;
+static DEFINE_MUTEX(ec_cb_lock);
+
+void olpc_ec_driver_register(struct olpc_ec_driver *drv, void *arg)
+{
+   ec_driver = drv;
+   ec_cb_arg = arg;
+}
+EXPORT_SYMBOL_GPL(olpc_ec_driver_register);
+
+static void olpc_ec_worker(struct work_struct *w)
+{
+   struct ec_cmd_desc *desc = NULL;
+   unsigned long flags;
+
+   /* Grab the first pending command from the queue */
+   spin_lock_irqsave(_cmd_q_lock, flags);
+   if (!list_empty(_cmd_q)) {
+   desc = list_first_entry(_cmd_q, struct ec_cmd_desc, node);
+   list_del(>node);
+   }
+   spin_unlock_irqrestore(_cmd_q_lock, flags);
+
+   /* Do we actually have anything to do? */
+   if (!desc)
+   return;
+
+   /* Protect the EC hw with a mutex; only run one cmd at a time */
+   mutex_lock(_cb_lock);
+   desc->err = ec_driver->ec_cmd(desc->cmd, desc->inbuf, desc->inlen,
+   desc->outbuf, desc->outlen, ec_cb_arg);
+   mutex_unlock(_cb_lock);
+
+   /* Finished, wake up olpc_ec_cmd() */
+   complete(>finished);
+
+   /* Run the worker thread again in case there are more cmds pending */
+   schedule_work(_worker);
+}
+
+/*
+ * Throw a cmd descripter onto the list.  We now have SMP OLPC machines, so
+ * locking is pretty critical.
+ */
+static void queue_ec_descriptor(struct ec_cmd_desc *desc)
+{
+   unsigned long flags;
+
+   INIT_LIST_HEAD(>node);
+
+   spin_lock_irqsave(_cmd_q_lock, flags);
+   list_add_tail(>node, _cmd_q);
+   spin_unlock_irqrestore(_cmd_q_lock, flags);
+
+   schedule_work(_worker);
+}
+
 int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf, size_t outlen)
 {
-   /* Currently a stub; this will be expanded upon later. */
-   return olpc_ec_cmd_x86(cmd, inbuf, inlen, outbuf, outlen);
+   struct ec_cmd_desc desc;
+
+   /* XXX: this will be removed in later patches */
+   /* Are we using old-style callers? */
+   if (!ec_driver || !ec_driver->ec_cmd)
+   return olpc_ec_cmd_x86(cmd, inbuf, inlen, outbuf, outlen);
+
+   /* Ensure a driver and ec hook have been registered */
+   if (WARN_ON(!ec_driver || !ec_driver->ec_cmd))
+   return -ENODEV;
+
+   might_sleep();
+
+   desc.cmd = cmd;
+   desc.inbuf = inbuf;
+   desc.outbuf = outbuf;
+   desc.inlen = inlen;
+   desc.outlen = outlen;
+   desc.err = 0;
+   init_completion();
+
+   queue_ec_descriptor();
+
+   /* Timeouts must be handled in the platform-specific EC hook */
+   wait_for_completion();
+
+   /* The worker thread dequeues the cmd; no need to do anything here */
+   return desc.err;
 }
 EXPORT_SYMBOL_GPL(olpc_ec_cmd);
diff --git a/include/linux/olpc-ec.h b/include/linux/olpc-ec.h
index 6d4e426..231e96f 100644
--- a/include/linux/olpc-ec.h
+++ b/include/linux/olpc-ec.h
@@ -14,8 +14,14 @@
 #define EC_SCI_QUERY   0x84
 #define EC_EXT_SCI_QUERY   0x85
 
+struct olpc_ec_driver {
+   int (*ec_cmd)(u8, u8 *, size_t, u8 *, size_t, void *);
+};
+
 #ifdef CONFIG_OLPC
 
+extern void olpc_ec_driver_register(struct olpc_ec_driver *drv, void *arg);
+
 extern int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
size_t outlen);
 
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a 

[PATCH RESEND 2/9] drivers: OLPC: update various drivers to include olpc-ec.h

2012-07-18 Thread Andres Salomon

Switch over to using olpc-ec.h in multiple steps, so as not to break builds.
This covers every driver that calls olpc_ec_cmd().

Signed-off-by: Andres Salomon 
---
 arch/x86/include/asm/olpc.h|1 -
 arch/x86/platform/olpc/olpc-xo1-pm.c   |1 +
 arch/x86/platform/olpc/olpc-xo1-sci.c  |1 +
 arch/x86/platform/olpc/olpc-xo15-sci.c |1 +
 arch/x86/platform/olpc/olpc.c  |1 +
 drivers/net/wireless/libertas/if_usb.c |1 +
 drivers/platform/x86/xo1-rfkill.c  |3 +--
 drivers/power/olpc_battery.c   |1 +
 drivers/staging/olpc_dcon/olpc_dcon.c  |1 +
 9 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/olpc.h b/arch/x86/include/asm/olpc.h
index 513e999..5b28f3e 100644
--- a/arch/x86/include/asm/olpc.h
+++ b/arch/x86/include/asm/olpc.h
@@ -4,7 +4,6 @@
 #define _ASM_X86_OLPC_H
 
 #include 
-#include 
 
 struct olpc_platform_t {
int flags;
diff --git a/arch/x86/platform/olpc/olpc-xo1-pm.c 
b/arch/x86/platform/olpc/olpc-xo1-pm.c
index 0ce8616c..8054b64 100644
--- a/arch/x86/platform/olpc/olpc-xo1-pm.c
+++ b/arch/x86/platform/olpc/olpc-xo1-pm.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/arch/x86/platform/olpc/olpc-xo1-sci.c 
b/arch/x86/platform/olpc/olpc-xo1-sci.c
index 04b8c73..63d4aa4 100644
--- a/arch/x86/platform/olpc/olpc-xo1-sci.c
+++ b/arch/x86/platform/olpc/olpc-xo1-sci.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/arch/x86/platform/olpc/olpc-xo15-sci.c 
b/arch/x86/platform/olpc/olpc-xo15-sci.c
index 23e5b9d..9899fef 100644
--- a/arch/x86/platform/olpc/olpc-xo15-sci.c
+++ b/arch/x86/platform/olpc/olpc-xo15-sci.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c
index 796e199..a3fa180 100644
--- a/arch/x86/platform/olpc/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/drivers/net/wireless/libertas/if_usb.c 
b/drivers/net/wireless/libertas/if_usb.c
index cd3b0d4..a9828b1 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef CONFIG_OLPC
 #include 
diff --git a/drivers/platform/x86/xo1-rfkill.c 
b/drivers/platform/x86/xo1-rfkill.c
index b57ad86..1da13ed 100644
--- a/drivers/platform/x86/xo1-rfkill.c
+++ b/drivers/platform/x86/xo1-rfkill.c
@@ -12,8 +12,7 @@
 #include 
 #include 
 #include 
-
-#include 
+#include 
 
 static bool card_blocked;
 
diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c
index 7385092..eaf917d 100644
--- a/drivers/power/olpc_battery.c
+++ b/drivers/power/olpc_battery.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 
diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c 
b/drivers/staging/olpc_dcon/olpc_dcon.c
index 992275c..2c4bd74 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RESEND 1/9] Platform: OLPC: add a stub to drivers/platform/ for the OLPC EC driver

2012-07-18 Thread Andres Salomon

The OLPC EC driver has outgrown arch/x86/platform/.  It's time to both
share common code amongst different architectures, as well as move it out
of arch/x86/.  The XO-1.75 is ARM-based, and the EC driver shares a lot of
code with the x86 code.

Signed-off-by: Andres Salomon 
---
 arch/x86/include/asm/olpc.h |   19 +++
 arch/x86/platform/olpc/olpc.c   |4 ++--
 drivers/platform/Makefile   |1 +
 drivers/platform/olpc/olpc-ec.c |   16 
 include/linux/olpc-ec.h |   29 +
 5 files changed, 51 insertions(+), 18 deletions(-)
 create mode 100644 drivers/platform/olpc/olpc-ec.c
 create mode 100644 include/linux/olpc-ec.h

diff --git a/arch/x86/include/asm/olpc.h b/arch/x86/include/asm/olpc.h
index 87bdbca..513e999 100644
--- a/arch/x86/include/asm/olpc.h
+++ b/arch/x86/include/asm/olpc.h
@@ -4,6 +4,7 @@
 #define _ASM_X86_OLPC_H
 
 #include 
+#include 
 
 struct olpc_platform_t {
int flags;
@@ -102,22 +103,8 @@ extern int pci_olpc_init(void);
 
 /* EC related functions */
 
-extern int olpc_ec_cmd(unsigned char cmd, unsigned char *inbuf, size_t inlen,
-   unsigned char *outbuf, size_t outlen);
-
-/* EC commands */
-
-#define EC_FIRMWARE_REV0x08
-#define EC_WRITE_SCI_MASK  0x1b
-#define EC_WAKE_UP_WLAN0x24
-#define EC_WLAN_LEAVE_RESET0x25
-#define EC_READ_EB_MODE0x2a
-#define EC_SET_SCI_INHIBIT 0x32
-#define EC_SET_SCI_INHIBIT_RELEASE 0x34
-#define EC_WLAN_ENTER_RESET0x35
-#define EC_WRITE_EXT_SCI_MASK  0x38
-#define EC_SCI_QUERY   0x84
-#define EC_EXT_SCI_QUERY   0x85
+extern int olpc_ec_cmd_x86(unsigned char cmd, unsigned char *inbuf,
+   size_t inlen, unsigned char *outbuf, size_t outlen);
 
 /* SCI source values */
 
diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c
index a4bee53..796e199 100644
--- a/arch/x86/platform/olpc/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
@@ -125,7 +125,7 @@ static int __wait_on_obf(unsigned int line, unsigned int 
port, int desired)
  * .  Unfortunately, while
  * OpenFirmware's source is available, the EC's is not.
  */
-int olpc_ec_cmd(unsigned char cmd, unsigned char *inbuf, size_t inlen,
+int olpc_ec_cmd_x86(unsigned char cmd, unsigned char *inbuf, size_t inlen,
unsigned char *outbuf,  size_t outlen)
 {
unsigned long flags;
@@ -201,7 +201,7 @@ err:
spin_unlock_irqrestore(_lock, flags);
return ret;
 }
-EXPORT_SYMBOL_GPL(olpc_ec_cmd);
+EXPORT_SYMBOL_GPL(olpc_ec_cmd_x86);
 
 void olpc_ec_wakeup_set(u16 value)
 {
diff --git a/drivers/platform/Makefile b/drivers/platform/Makefile
index 782953a..b17c16c 100644
--- a/drivers/platform/Makefile
+++ b/drivers/platform/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_X86)  += x86/
+obj-$(CONFIG_OLPC) += olpc/
diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
new file mode 100644
index 000..4202603
--- /dev/null
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -0,0 +1,16 @@
+/*
+ * Generic driver for the OLPC Embedded Controller.
+ *
+ * Copyright (C) 2011-2012 One Laptop per Child Foundation.
+ *
+ * Licensed under the GPL v2 or later.
+ */
+#include 
+#include 
+
+int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf, size_t outlen)
+{
+   /* Currently a stub; this will be expanded upon later. */
+   return olpc_ec_cmd_x86(cmd, inbuf, inlen, outbuf, outlen);
+}
+EXPORT_SYMBOL_GPL(olpc_ec_cmd);
diff --git a/include/linux/olpc-ec.h b/include/linux/olpc-ec.h
new file mode 100644
index 000..6d4e426
--- /dev/null
+++ b/include/linux/olpc-ec.h
@@ -0,0 +1,29 @@
+#ifndef _LINUX_OLPC_EC_H
+#define _LINUX_OLPC_EC_H
+
+/* XO-1 EC commands */
+#define EC_FIRMWARE_REV0x08
+#define EC_WRITE_SCI_MASK  0x1b
+#define EC_WAKE_UP_WLAN0x24
+#define EC_WLAN_LEAVE_RESET0x25
+#define EC_READ_EB_MODE0x2a
+#define EC_SET_SCI_INHIBIT 0x32
+#define EC_SET_SCI_INHIBIT_RELEASE 0x34
+#define EC_WLAN_ENTER_RESET0x35
+#define EC_WRITE_EXT_SCI_MASK  0x38
+#define EC_SCI_QUERY   0x84
+#define EC_EXT_SCI_QUERY   0x85
+
+#ifdef CONFIG_OLPC
+
+extern int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
+   size_t outlen);
+
+#else
+
+static inline int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
+   size_t outlen) { return -ENODEV; }
+
+#endif /* CONFIG_OLPC */
+
+#endif /* _LINUX_OLPC_EC_H */
-- 
1.7.2.5

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

[PATCH RESEND 0/9] OLPC: create a generic OLPC EC driver

2012-07-18 Thread Andres Salomon
The OLPC EC (Embedded Controller) code that is currently upstream is
x86-only, originally written for the XO-1.  Since then, we've had the
XO-1.5 (also x86), and XO-1.75 (arm-based) enter mass production.  The
1.75 uses a vastly different EC protocol, and future hardware revisions
are likely to change it even further.

However, the drivers do share quite a bit of code, so it makes sense to
have a platform-agnostic driver that calls into platform-specific hooks
for each XO's EC driver.  This is the first stab and creating such a
beast (with further patches pending).  Aside from the lack of code
duplication, this is helpful for fixing bugs in one place (for example,
we fixed an EC suspend/resume bug in 1.75 that I've just seen happen on
1.5 without these patches.  With these patches, the problem goes away).

These patches are against Linus's current HEAD; let me know if they
don't apply somewhere, and I'll happily redo them against the -next
tree.  I'm assuming that these changes (which touch places like x86,
wireless, and staging) should go through either the x86 tree, or
through akpm's tree.

Alternatively, if the reviews are positive and I can get SOBs from the
relevant maintainers, I can set up a platform-olpc tree somewhere and
request a pull from Linus.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux-next: build failure after merge of the tty tree

2012-07-18 Thread Stephen Rothwell
Hi Greg,

After merging the tty tree, today's linux-next build (x86_64 allmodconfig)
failed like this:

drivers/char/pcmcia/synclink_cs.c: In function 'shutdown':
drivers/char/pcmcia/synclink_cs.c:1347:27: error: invalid type argument of '->' 
(have 'struct ktermios')
drivers/char/pcmcia/synclink_cs.c: In function 'mgslpc_program_hw':
drivers/char/pcmcia/synclink_cs.c:1388:45: error: invalid type argument of '->' 
(have 'struct ktermios')
drivers/char/pcmcia/synclink_cs.c: In function 'mgslpc_change_params':
drivers/char/pcmcia/synclink_cs.c:1401:14: error: wrong type argument to unary 
exclamation mark
drivers/char/pcmcia/synclink_cs.c:1408:22: error: invalid type argument of '->' 
(have 'struct ktermios')
drivers/char/pcmcia/synclink_cs.c: In function 'mgslpc_throttle':
drivers/char/pcmcia/synclink_cs.c:1731:19: error: invalid type argument of '->' 
(have 'struct ktermios')
drivers/char/pcmcia/synclink_cs.c: In function 'mgslpc_unthrottle':
drivers/char/pcmcia/synclink_cs.c:1760:19: error: invalid type argument of '->' 
(have 'struct ktermios')
drivers/char/pcmcia/synclink_cs.c: In function 'mgslpc_set_termios':
drivers/char/pcmcia/synclink_cs.c:2296:19: error: invalid type argument of '->' 
(have 'struct ktermios')
drivers/char/pcmcia/synclink_cs.c:2297:10: error: invalid type argument of '->' 
(have 'struct ktermios')
drivers/char/pcmcia/synclink_cs.c:2305:20: error: invalid type argument of '->' 
(have 'struct ktermios')
drivers/char/pcmcia/synclink_cs.c:2314:18: error: invalid type argument of '->' 
(have 'struct ktermios')
drivers/char/pcmcia/synclink_cs.c:2316:22: error: invalid type argument of '->' 
(have 'struct ktermios')
drivers/char/pcmcia/synclink_cs.c:2327:20: error: invalid type argument of '->' 
(have 'struct ktermios')

Caused by commit adc8d746caa6 ("tty: move the termios object into the
tty").  Grep and build testing are your friends ...

I have used the tty tree from next-20120712 again for today.
-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au


pgpv4xugnQ5aS.pgp
Description: PGP signature


Re: [PATCH 6/9] x86: OLPC: switch over to using new EC driver on x86

2012-07-18 Thread Andres Salomon
Damnit, my mailer mangled the resend.  Okay, 3rd time's a charm..
(sorry for the noise!)

On Wed, 18 Jul 2012 21:28:27 -0700
Andres Salomon  wrote:

> This uses the new EC driver framework in drivers/platform/olpc.  The
> XO-1 and XO-1.5-specific code is still in arch/x86, but the generic
> stuff (including a new workqueue; no more running EC commands with
> IRQs disabled!) can be shared with other architectures.
> 
> Signed-off-by: Andres Salomon 
> ---
>  arch/x86/include/asm/olpc.h |5 ---
>  arch/x86/platform/olpc/olpc.c   |   53
> ---
> drivers/platform/olpc/olpc-ec.c |5 --- 3 files changed, 27
> insertions(+), 36 deletions(-)
> 
> diff --git a/arch/x86/include/asm/olpc.h b/arch/x86/include/asm/olpc.h
> index 5b28f3e..72f9adf6 100644
> --- a/arch/x86/include/asm/olpc.h
> +++ b/arch/x86/include/asm/olpc.h
> @@ -100,11 +100,6 @@ extern void olpc_xo1_pm_wakeup_clear(u16 value);
>  
>  extern int pci_olpc_init(void);
>  
> -/* EC related functions */
> -
> -extern int olpc_ec_cmd_x86(unsigned char cmd, unsigned char *inbuf,
> - size_t inlen, unsigned char *outbuf, size_t outlen);
> -
>  /* SCI source values */
>  
>  #define EC_SCI_SRC_EMPTY 0x00
> diff --git a/arch/x86/platform/olpc/olpc.c
> b/arch/x86/platform/olpc/olpc.c index a3fa180..4590096 100644
> --- a/arch/x86/platform/olpc/olpc.c
> +++ b/arch/x86/platform/olpc/olpc.c
> @@ -14,7 +14,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> @@ -32,8 +31,6 @@
>  struct olpc_platform_t olpc_platform_info;
>  EXPORT_SYMBOL_GPL(olpc_platform_info);
>  
> -static DEFINE_SPINLOCK(ec_lock);
> -
>  /* debugfs interface to EC commands */
>  #define EC_MAX_CMD_ARGS (5 + 1)  /* cmd byte + 5 args */
>  #define EC_MAX_CMD_REPLY (8)
> @@ -126,16 +123,13 @@ static int __wait_on_obf(unsigned int line,
> unsigned int port, int desired)
>   * .  Unfortunately,
> while
>   * OpenFirmware's source is available, the EC's is not.
>   */
> -int olpc_ec_cmd_x86(unsigned char cmd, unsigned char *inbuf, size_t
> inlen,
> - unsigned char *outbuf,  size_t outlen)
> +static int olpc_xo1_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8
> *outbuf,
> + size_t outlen, void *arg)
>  {
> - unsigned long flags;
>   int ret = -EIO;
>   int i;
>   int restarts = 0;
>  
> - spin_lock_irqsave(_lock, flags);
> -
>   /* Clear OBF */
>   for (i = 0; i < 10 && (obf_status(0x6c) == 1); i++)
>   inb(0x68);
> @@ -199,10 +193,8 @@ restart:
>  
>   ret = 0;
>  err:
> - spin_unlock_irqrestore(_lock, flags);
>   return ret;
>  }
> -EXPORT_SYMBOL_GPL(olpc_ec_cmd_x86);
>  
>  void olpc_ec_wakeup_set(u16 value)
>  {
> @@ -366,7 +358,7 @@ static void setup_debugfs(void)
>   _debugfs_genops);
>  }
>  
> -static int olpc_ec_suspend(void)
> +static int olpc_ec_suspend(struct platform_device *pdev)
>  {
>   return olpc_ec_mask_write(ec_wakeup_mask);
>  }
> @@ -425,8 +417,28 @@ static int __init add_xo1_platform_devices(void)
>   return 0;
>  }
>  
> -static struct syscore_ops olpc_syscore_ops = {
> +static int olpc_xo1_ec_probe(struct platform_device *pdev)
> +{
> + /* get the EC revision */
> + olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0,
> + (unsigned char *) _platform_info.ecver,
> 1); +
> + /* EC version 0x5f adds support for wide SCI mask */
> + if (olpc_platform_info.ecver >= 0x5f)
> + olpc_platform_info.flags |= OLPC_F_EC_WIDE_SCI;
> +
> + pr_info("OLPC board revision %s%X (EC=%x)\n",
> + ((olpc_platform_info.boardrev & 0xf) < 8) ?
> "pre" : "",
> + olpc_platform_info.boardrev >> 4,
> + olpc_platform_info.ecver);
> +
> + return 0;
> +}
> +
> +static struct olpc_ec_driver ec_xo1_driver = {
>   .suspend = olpc_ec_suspend,
> + .probe = olpc_xo1_ec_probe,
> + .ec_cmd = olpc_xo1_ec_cmd,
>  };
>  
>  static int __init olpc_init(void)
> @@ -436,16 +448,14 @@ static int __init olpc_init(void)
>   if (!olpc_ofw_present() || !platform_detect())
>   return 0;
>  
> - spin_lock_init(_lock);
> + /* register the XO-1 and 1.5-specific EC handler */
> + olpc_ec_driver_register(_xo1_driver, NULL);
> + platform_device_register_simple("olpc-ec", -1, NULL, 0);
>  
>   /* assume B1 and above models always have a DCON */
>   if (olpc_board_at_least(olpc_board(0xb1)))
>   olpc_platform_info.flags |= OLPC_F_DCON;
>  
> - /* get the EC revision */
> - olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0,
> - (unsigned char *) _platform_info.ecver,
> 1); -
>  #ifdef CONFIG_PCI_OLPC
>   /* If the VSA exists let it emulate PCI, if not emulate in
> kernel.
>* XO-1 only. */
> @@ -453,14 +463,6 @@ static int __init olpc_init(void)
>   !cs5535_has_vsa2())
>   

[GIT] Networking

2012-07-18 Thread David Miller

Ok, we should be good to go now.

1) We have to statically initialize the init_net device list head
   rather than do so in an initcall, otherwise netprio_cgroup crashes
   if it's built statically rather than modular (Mark D. Rustad)

2) Fix SKB null oopser in CIPSO ipv4 option processing (Paul Moore)

3) Qlogic maintainers update (Anirban Chakraborty)

Please pull, thanks a lot.

The following changes since commit a018540141a931f5299a866907b27886916b4374:

  Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (2012-07-17 
08:44:51 -0700)

are available in the git repository at:


  git://git.kernel.org/pub/scm/linux/kernel/git/davem/net master

for you to fetch changes up to 734b65417b24d6eea3e3d7457e1f11493890ee1d:

  net: Statically initialize init_net.dev_base_head (2012-07-18 13:32:27 -0700)


Anirban Chakraborty (1):
  MAINTAINERS: Changes in qlcnic and qlge maintainers list

Paul Moore (1):
  cipso: don't follow a NULL pointer when setsockopt() is called

Rustad, Mark D (1):
  net: Statically initialize init_net.dev_base_head

 MAINTAINERS  |3 +--
 net/core/dev.c   |3 ++-
 net/core/net_namespace.c |4 +++-
 net/ipv4/cipso_ipv4.c|6 --
 4 files changed, 10 insertions(+), 6 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/9] Platform: OLPC: turn EC driver into a platform_driver

2012-07-18 Thread Andres Salomon
The 1.75-based OLPC EC driver already does this; let's do it for all EC
drivers.  This gives us nice suspend/resume hooks, amongst other things.

We want to run the EC's suspend hooks later than other drivers (which may
be setting wakeup masks or be running EC commands).  We also want to run
the EC's resume hooks earlier than other drivers (which may want to run EC
commands).

Signed-off-by: Andres Salomon 
---
 drivers/platform/olpc/olpc-ec.c |   48 +++
 include/linux/olpc-ec.h |6 +
 2 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index 44e6a4f..d00523c 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -122,3 +123,50 @@ int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 
*outbuf, size_t outlen)
return desc.err;
 }
 EXPORT_SYMBOL_GPL(olpc_ec_cmd);
+
+static int olpc_ec_probe(struct platform_device *pdev)
+{
+   int err;
+
+   if (!ec_driver)
+   return -ENODEV;
+
+   err = ec_driver->probe ? ec_driver->probe(pdev) : 0;
+
+   return err;
+}
+
+static int olpc_ec_suspend(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   return ec_driver->suspend ? ec_driver->suspend(pdev) : 0;
+}
+
+static int olpc_ec_resume(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   return ec_driver->resume ? ec_driver->resume(pdev) : 0;
+}
+
+static const struct dev_pm_ops olpc_ec_pm_ops = {
+   .suspend_late = olpc_ec_suspend,
+   .resume_early = olpc_ec_resume,
+};
+
+static struct platform_driver olpc_ec_plat_driver = {
+   .probe = olpc_ec_probe,
+   .driver = {
+   .name = "olpc-ec",
+   .pm = _ec_pm_ops,
+   },
+};
+
+static int __init olpc_ec_init_module(void)
+{
+   return platform_driver_register(_ec_plat_driver);
+}
+
+module_init(olpc_ec_init_module);
+
+MODULE_AUTHOR("Andres Salomon ");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/olpc-ec.h b/include/linux/olpc-ec.h
index 231e96f..5bb6e76 100644
--- a/include/linux/olpc-ec.h
+++ b/include/linux/olpc-ec.h
@@ -14,7 +14,13 @@
 #define EC_SCI_QUERY   0x84
 #define EC_EXT_SCI_QUERY   0x85
 
+struct platform_device;
+
 struct olpc_ec_driver {
+   int (*probe)(struct platform_device *);
+   int (*suspend)(struct platform_device *);
+   int (*resume)(struct platform_device *);
+
int (*ec_cmd)(u8, u8 *, size_t, u8 *, size_t, void *);
 };
 
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 9/9] x86: OLPC: move s/r-related EC cmds to EC driver

2012-07-18 Thread Andres Salomon
The new EC driver calls platform-specific suspend and resume hooks; run
XO-1-specific EC commands from there, rather than deep in s/r code.  If
we attempt to run EC commands after the new EC driver has suspended, it
is refused by the ec->suspended checks.

Signed-off-by: Andres Salomon 
---
 arch/x86/platform/olpc/olpc-xo1-pm.c |   15 
 arch/x86/platform/olpc/olpc.c|   43
- 2 files changed, 36 insertions(+), 22
deletions(-)

diff --git a/arch/x86/platform/olpc/olpc-xo1-pm.c
b/arch/x86/platform/olpc/olpc-xo1-pm.c index 8054b64..d75582d 100644
--- a/arch/x86/platform/olpc/olpc-xo1-pm.c
+++ b/arch/x86/platform/olpc/olpc-xo1-pm.c
@@ -52,16 +52,11 @@ EXPORT_SYMBOL_GPL(olpc_xo1_pm_wakeup_clear);
 static int xo1_power_state_enter(suspend_state_t pm_state)
 {
unsigned long saved_sci_mask;
-   int r;
 
/* Only STR is supported */
if (pm_state != PM_SUSPEND_MEM)
return -EINVAL;
 
-   r = olpc_ec_cmd(EC_SET_SCI_INHIBIT, NULL, 0, NULL, 0);
-   if (r)
-   return r;
-
/*
 * Save SCI mask (this gets lost since PM1_EN is used as a
mask for
 * wakeup events, which is not necessarily the same event set)
@@ -77,16 +72,6 @@ static int xo1_power_state_enter(suspend_state_t
pm_state) /* Restore SCI mask (using dword access to CS5536_PM1_EN) */
outl(saved_sci_mask, acpi_base + CS5536_PM1_STS);
 
-   /* Tell the EC to stop inhibiting SCIs */
-   olpc_ec_cmd(EC_SET_SCI_INHIBIT_RELEASE, NULL, 0, NULL, 0);
-
-   /*
-* Tell the wireless module to restart USB communication.
-* Must be done twice.
-*/
-   olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0);
-   olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0);
-
return 0;
 }
 
diff --git a/arch/x86/platform/olpc/olpc.c
b/arch/x86/platform/olpc/olpc.c index ed41b43..2737608 100644
--- a/arch/x86/platform/olpc/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
@@ -263,11 +263,6 @@ int olpc_ec_sci_query(u16 *sci_value)
 }
 EXPORT_SYMBOL_GPL(olpc_ec_sci_query);
 
-static int olpc_ec_suspend(struct platform_device *pdev)
-{
-   return olpc_ec_mask_write(ec_wakeup_mask);
-}
-
 static bool __init check_ofw_architecture(struct device_node *root)
 {
const char *olpc_arch;
@@ -339,9 +334,40 @@ static int olpc_xo1_ec_probe(struct
platform_device *pdev) 
return 0;
 }
+static int olpc_xo1_ec_suspend(struct platform_device *pdev)
+{
+   olpc_ec_mask_write(ec_wakeup_mask);
+
+   /*
+* Squelch SCIs while suspended.  This is a fix for
+* .
+*/
+   return olpc_ec_cmd(EC_SET_SCI_INHIBIT, NULL, 0, NULL, 0);
+}
+
+static int olpc_xo1_ec_resume(struct platform_device *pdev)
+{
+   /* Tell the EC to stop inhibiting SCIs */
+   olpc_ec_cmd(EC_SET_SCI_INHIBIT_RELEASE, NULL, 0, NULL, 0);
+
+   /*
+* Tell the wireless module to restart USB communication.
+* Must be done twice.
+*/
+   olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0);
+   olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0);
+
+   return 0;
+}
 
 static struct olpc_ec_driver ec_xo1_driver = {
-   .suspend = olpc_ec_suspend,
+   .probe = olpc_xo1_ec_probe,
+   .suspend = olpc_xo1_ec_suspend,
+   .resume = olpc_xo1_ec_resume,
+   .ec_cmd = olpc_xo1_ec_cmd,
+};
+
+static struct olpc_ec_driver ec_xo1_5_driver = {
.probe = olpc_xo1_ec_probe,
.ec_cmd = olpc_xo1_ec_cmd,
 };
@@ -354,7 +380,10 @@ static int __init olpc_init(void)
return 0;
 
/* register the XO-1 and 1.5-specific EC handler */
-   olpc_ec_driver_register(_xo1_driver, NULL);
+   if (olpc_platform_info.boardrev <
olpc_board_pre(0xd0))   /* XO-1 */
+   olpc_ec_driver_register(_xo1_driver, NULL);
+   else
+   olpc_ec_driver_register(_xo1_5_driver, NULL);
platform_device_register_simple("olpc-ec", -1, NULL, 0);
 
/* assume B1 and above models always have a DCON */
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 8/9] Platform: OLPC: move global variables into priv struct

2012-07-18 Thread Andres Salomon
Populate olpc_ec_priv.

Signed-off-by: Andres Salomon 
---
 drivers/platform/olpc/olpc-ec.c |   48
++ 1 files changed, 28
insertions(+), 20 deletions(-)

diff --git a/drivers/platform/olpc/olpc-ec.c
b/drivers/platform/olpc/olpc-ec.c index 1a15a79..0f9f859 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -31,6 +31,12 @@ struct ec_cmd_desc {
 
 struct olpc_ec_priv {
struct olpc_ec_driver *drv;
+   struct work_struct worker;
+   struct mutex cmd_lock;
+
+   /* Pending EC commands */
+   struct list_head cmd_q;
+   spinlock_t cmd_q_lock;
 
struct dentry *dbgfs_dir;
 
@@ -46,16 +52,9 @@ struct olpc_ec_priv {
bool suspended;
 };
 
-static void olpc_ec_worker(struct work_struct *w);
-
-static DECLARE_WORK(ec_worker, olpc_ec_worker);
-static LIST_HEAD(ec_cmd_q);
-static DEFINE_SPINLOCK(ec_cmd_q_lock);
-
 static struct olpc_ec_driver *ec_driver;
 static struct olpc_ec_priv *ec_priv;
 static void *ec_cb_arg;
-static DEFINE_MUTEX(ec_cb_lock);
 
 void olpc_ec_driver_register(struct olpc_ec_driver *drv, void *arg)
 {
@@ -66,49 +65,51 @@ EXPORT_SYMBOL_GPL(olpc_ec_driver_register);
 
 static void olpc_ec_worker(struct work_struct *w)
 {
+   struct olpc_ec_priv *ec = container_of(w, struct olpc_ec_priv,
worker); struct ec_cmd_desc *desc = NULL;
unsigned long flags;
 
/* Grab the first pending command from the queue */
-   spin_lock_irqsave(_cmd_q_lock, flags);
-   if (!list_empty(_cmd_q)) {
-   desc = list_first_entry(_cmd_q, struct ec_cmd_desc,
node);
+   spin_lock_irqsave(>cmd_q_lock, flags);
+   if (!list_empty(>cmd_q)) {
+   desc = list_first_entry(>cmd_q, struct
ec_cmd_desc, node); list_del(>node);
}
-   spin_unlock_irqrestore(_cmd_q_lock, flags);
+   spin_unlock_irqrestore(>cmd_q_lock, flags);
 
/* Do we actually have anything to do? */
if (!desc)
return;
 
/* Protect the EC hw with a mutex; only run one cmd at a time
*/
-   mutex_lock(_cb_lock);
+   mutex_lock(>cmd_lock);
desc->err = ec_driver->ec_cmd(desc->cmd, desc->inbuf,
desc->inlen, desc->outbuf, desc->outlen, ec_cb_arg);
-   mutex_unlock(_cb_lock);
+   mutex_unlock(>cmd_lock);
 
/* Finished, wake up olpc_ec_cmd() */
complete(>finished);
 
/* Run the worker thread again in case there are more cmds
pending */
-   schedule_work(_worker);
+   schedule_work(>worker);
 }
 
 /*
  * Throw a cmd descripter onto the list.  We now have SMP OLPC
machines, so
  * locking is pretty critical.
  */
-static void queue_ec_descriptor(struct ec_cmd_desc *desc)
+static void queue_ec_descriptor(struct ec_cmd_desc *desc,
+   struct olpc_ec_priv *ec)
 {
unsigned long flags;
 
INIT_LIST_HEAD(>node);
 
-   spin_lock_irqsave(_cmd_q_lock, flags);
-   list_add_tail(>node, _cmd_q);
-   spin_unlock_irqrestore(_cmd_q_lock, flags);
+   spin_lock_irqsave(>cmd_q_lock, flags);
+   list_add_tail(>node, >cmd_q);
+   spin_unlock_irqrestore(>cmd_q_lock, flags);
 
-   schedule_work(_worker);
+   schedule_work(>worker);
 }
 
 int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf, size_t
outlen) @@ -137,7 +138,7 @@ int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t
inlen, u8 *outbuf, size_t outlen) desc.err = 0;
init_completion();
 
-   queue_ec_descriptor();
+   queue_ec_descriptor(, ec);
 
/* Timeouts must be handled in the platform-specific EC hook */
wait_for_completion();
@@ -266,7 +267,14 @@ static int olpc_ec_probe(struct platform_device
*pdev) ec = kzalloc(sizeof(*ec), GFP_KERNEL);
if (!ec)
return -ENOMEM;
+
ec->drv = ec_driver;
+   INIT_WORK(>worker, olpc_ec_worker);
+   mutex_init(>cmd_lock);
+
+   INIT_LIST_HEAD(>cmd_q);
+   spin_lock_init(>cmd_q_lock);
+
ec_priv = ec;
platform_set_drvdata(pdev, ec);
 
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 7/9] Platform: OLPC: move debugfs support from x86 EC driver

2012-07-18 Thread Andres Salomon
There's nothing about the debugfs interface for the EC driver that is
architecture-specific, so move it into the arch-independent driver.

The code is mostly unchanged with the exception of renamed variables,
coding style changes, and API updates.

Signed-off-by: Andres Salomon 
---
 arch/x86/platform/olpc/olpc.c   |   97 
 drivers/platform/olpc/olpc-ec.c |  117
+++ 2 files changed, 117
insertions(+), 97 deletions(-)

diff --git a/arch/x86/platform/olpc/olpc.c
b/arch/x86/platform/olpc/olpc.c index 4590096..ed41b43 100644
--- a/arch/x86/platform/olpc/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
@@ -19,7 +19,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -31,15 +30,6 @@
 struct olpc_platform_t olpc_platform_info;
 EXPORT_SYMBOL_GPL(olpc_platform_info);
 
-/* debugfs interface to EC commands */
-#define EC_MAX_CMD_ARGS (5 + 1)/* cmd byte + 5 args */
-#define EC_MAX_CMD_REPLY (8)
-
-static struct dentry *ec_debugfs_dir;
-static DEFINE_MUTEX(ec_debugfs_cmd_lock);
-static unsigned char ec_debugfs_resp[EC_MAX_CMD_REPLY];
-static unsigned int ec_debugfs_resp_bytes;
-
 /* EC event mask to be applied during suspend (defining wakeup
sources). */ static u16 ec_wakeup_mask;
 
@@ -273,91 +263,6 @@ int olpc_ec_sci_query(u16 *sci_value)
 }
 EXPORT_SYMBOL_GPL(olpc_ec_sci_query);
 
-static ssize_t ec_debugfs_cmd_write(struct file *file, const char
__user *buf,
-   size_t size, loff_t *ppos)
-{
-   int i, m;
-   unsigned char ec_cmd[EC_MAX_CMD_ARGS];
-   unsigned int ec_cmd_int[EC_MAX_CMD_ARGS];
-   char cmdbuf[64];
-   int ec_cmd_bytes;
-
-   mutex_lock(_debugfs_cmd_lock);
-
-   size = simple_write_to_buffer(cmdbuf, sizeof(cmdbuf), ppos,
buf, size); -
-   m = sscanf(cmdbuf, "%x:%u %x %x %x %x %x", _cmd_int[0],
-  _debugfs_resp_bytes,
-  _cmd_int[1], _cmd_int[2], _cmd_int[3],
-  _cmd_int[4], _cmd_int[5]);
-   if (m < 2 || ec_debugfs_resp_bytes > EC_MAX_CMD_REPLY) {
-   /* reset to prevent overflow on read */
-   ec_debugfs_resp_bytes = 0;
-
-   printk(KERN_DEBUG "olpc-ec: bad ec cmd:  "
-  "cmd:response-count [arg1 [arg2 ...]]\n");
-   size = -EINVAL;
-   goto out;
-   }
-
-   /* convert scanf'd ints to char */
-   ec_cmd_bytes = m - 2;
-   for (i = 0; i <= ec_cmd_bytes; i++)
-   ec_cmd[i] = ec_cmd_int[i];
-
-   printk(KERN_DEBUG "olpc-ec: debugfs cmd 0x%02x with %d args "
-  "%02x %02x %02x %02x %02x, want %d returns\n",
-  ec_cmd[0], ec_cmd_bytes, ec_cmd[1], ec_cmd[2],
ec_cmd[3],
-  ec_cmd[4], ec_cmd[5], ec_debugfs_resp_bytes);
-
-   olpc_ec_cmd(ec_cmd[0], (ec_cmd_bytes == 0) ? NULL : _cmd[1],
-   ec_cmd_bytes, ec_debugfs_resp,
ec_debugfs_resp_bytes); -
-   printk(KERN_DEBUG "olpc-ec: response "
-  "%02x %02x %02x %02x %02x %02x %02x %02x (%d bytes
expected)\n",
-  ec_debugfs_resp[0], ec_debugfs_resp[1],
ec_debugfs_resp[2],
-  ec_debugfs_resp[3], ec_debugfs_resp[4],
ec_debugfs_resp[5],
-  ec_debugfs_resp[6], ec_debugfs_resp[7],
ec_debugfs_resp_bytes); -
-out:
-   mutex_unlock(_debugfs_cmd_lock);
-   return size;
-}
-
-static ssize_t ec_debugfs_cmd_read(struct file *file, char __user *buf,
-  size_t size, loff_t *ppos)
-{
-   unsigned int i, r;
-   char *rp;
-   char respbuf[64];
-
-   mutex_lock(_debugfs_cmd_lock);
-   rp = respbuf;
-   rp += sprintf(rp, "%02x", ec_debugfs_resp[0]);
-   for (i = 1; i < ec_debugfs_resp_bytes; i++)
-   rp += sprintf(rp, ", %02x", ec_debugfs_resp[i]);
-   mutex_unlock(_debugfs_cmd_lock);
-   rp += sprintf(rp, "\n");
-
-   r = rp - respbuf;
-   return simple_read_from_buffer(buf, size, ppos, respbuf, r);
-}
-
-static const struct file_operations ec_debugfs_genops = {
-   .write   = ec_debugfs_cmd_write,
-   .read= ec_debugfs_cmd_read,
-};
-
-static void setup_debugfs(void)
-{
-   ec_debugfs_dir = debugfs_create_dir("olpc-ec", 0);
-   if (ec_debugfs_dir == ERR_PTR(-ENODEV))
-   return;
-
-   debugfs_create_file("cmd", 0600, ec_debugfs_dir, NULL,
-   _debugfs_genops);
-}
-
 static int olpc_ec_suspend(struct platform_device *pdev)
 {
return olpc_ec_mask_write(ec_wakeup_mask);
@@ -470,8 +375,6 @@ static int __init olpc_init(void)
return r;
}
 
-   setup_debugfs();
-
return 0;
 }
 
diff --git a/drivers/platform/olpc/olpc-ec.c
b/drivers/platform/olpc/olpc-ec.c index a3d32c2..1a15a79 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -6,6 +6,7 @@
  * Licensed under the GPL v2 or later.
  */
 #include 
+#include 
 #include 
 

[PATCH 6/9] x86: OLPC: switch over to using new EC driver on x86

2012-07-18 Thread Andres Salomon
This uses the new EC driver framework in drivers/platform/olpc.  The
XO-1 and XO-1.5-specific code is still in arch/x86, but the generic
stuff (including a new workqueue; no more running EC commands with IRQs
disabled!) can be shared with other architectures.

Signed-off-by: Andres Salomon 
---
 arch/x86/include/asm/olpc.h |5 ---
 arch/x86/platform/olpc/olpc.c   |   53
--- drivers/platform/olpc/olpc-ec.c
|5 --- 3 files changed, 27 insertions(+), 36 deletions(-)

diff --git a/arch/x86/include/asm/olpc.h b/arch/x86/include/asm/olpc.h
index 5b28f3e..72f9adf6 100644
--- a/arch/x86/include/asm/olpc.h
+++ b/arch/x86/include/asm/olpc.h
@@ -100,11 +100,6 @@ extern void olpc_xo1_pm_wakeup_clear(u16 value);
 
 extern int pci_olpc_init(void);
 
-/* EC related functions */
-
-extern int olpc_ec_cmd_x86(unsigned char cmd, unsigned char *inbuf,
-   size_t inlen, unsigned char *outbuf, size_t outlen);
-
 /* SCI source values */
 
 #define EC_SCI_SRC_EMPTY   0x00
diff --git a/arch/x86/platform/olpc/olpc.c
b/arch/x86/platform/olpc/olpc.c index a3fa180..4590096 100644
--- a/arch/x86/platform/olpc/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -32,8 +31,6 @@
 struct olpc_platform_t olpc_platform_info;
 EXPORT_SYMBOL_GPL(olpc_platform_info);
 
-static DEFINE_SPINLOCK(ec_lock);
-
 /* debugfs interface to EC commands */
 #define EC_MAX_CMD_ARGS (5 + 1)/* cmd byte + 5 args */
 #define EC_MAX_CMD_REPLY (8)
@@ -126,16 +123,13 @@ static int __wait_on_obf(unsigned int line,
unsigned int port, int desired)
  * .  Unfortunately, while
  * OpenFirmware's source is available, the EC's is not.
  */
-int olpc_ec_cmd_x86(unsigned char cmd, unsigned char *inbuf, size_t
inlen,
-   unsigned char *outbuf,  size_t outlen)
+static int olpc_xo1_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
+   size_t outlen, void *arg)
 {
-   unsigned long flags;
int ret = -EIO;
int i;
int restarts = 0;
 
-   spin_lock_irqsave(_lock, flags);
-
/* Clear OBF */
for (i = 0; i < 10 && (obf_status(0x6c) == 1); i++)
inb(0x68);
@@ -199,10 +193,8 @@ restart:
 
ret = 0;
 err:
-   spin_unlock_irqrestore(_lock, flags);
return ret;
 }
-EXPORT_SYMBOL_GPL(olpc_ec_cmd_x86);
 
 void olpc_ec_wakeup_set(u16 value)
 {
@@ -366,7 +358,7 @@ static void setup_debugfs(void)
_debugfs_genops);
 }
 
-static int olpc_ec_suspend(void)
+static int olpc_ec_suspend(struct platform_device *pdev)
 {
return olpc_ec_mask_write(ec_wakeup_mask);
 }
@@ -425,8 +417,28 @@ static int __init add_xo1_platform_devices(void)
return 0;
 }
 
-static struct syscore_ops olpc_syscore_ops = {
+static int olpc_xo1_ec_probe(struct platform_device *pdev)
+{
+   /* get the EC revision */
+   olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0,
+   (unsigned char *) _platform_info.ecver,
1); +
+   /* EC version 0x5f adds support for wide SCI mask */
+   if (olpc_platform_info.ecver >= 0x5f)
+   olpc_platform_info.flags |= OLPC_F_EC_WIDE_SCI;
+
+   pr_info("OLPC board revision %s%X (EC=%x)\n",
+   ((olpc_platform_info.boardrev & 0xf) < 8) ?
"pre" : "",
+   olpc_platform_info.boardrev >> 4,
+   olpc_platform_info.ecver);
+
+   return 0;
+}
+
+static struct olpc_ec_driver ec_xo1_driver = {
.suspend = olpc_ec_suspend,
+   .probe = olpc_xo1_ec_probe,
+   .ec_cmd = olpc_xo1_ec_cmd,
 };
 
 static int __init olpc_init(void)
@@ -436,16 +448,14 @@ static int __init olpc_init(void)
if (!olpc_ofw_present() || !platform_detect())
return 0;
 
-   spin_lock_init(_lock);
+   /* register the XO-1 and 1.5-specific EC handler */
+   olpc_ec_driver_register(_xo1_driver, NULL);
+   platform_device_register_simple("olpc-ec", -1, NULL, 0);
 
/* assume B1 and above models always have a DCON */
if (olpc_board_at_least(olpc_board(0xb1)))
olpc_platform_info.flags |= OLPC_F_DCON;
 
-   /* get the EC revision */
-   olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0,
-   (unsigned char *) _platform_info.ecver,
1); -
 #ifdef CONFIG_PCI_OLPC
/* If the VSA exists let it emulate PCI, if not emulate in
kernel.
 * XO-1 only. */
@@ -453,14 +463,6 @@ static int __init olpc_init(void)
!cs5535_has_vsa2())
x86_init.pci.arch_init = pci_olpc_init;
 #endif
-   /* EC version 0x5f adds support for wide SCI mask */
-   if (olpc_platform_info.ecver >= 0x5f)
-   olpc_platform_info.flags |= OLPC_F_EC_WIDE_SCI;
-
-   printk(KERN_INFO "OLPC board revision %s%X (EC=%x)\n",
-   ((olpc_platform_info.boardrev & 

[PATCH 5/9] Platform: OLPC: add a suspended flag to the EC driver

2012-07-18 Thread Andres Salomon
A problem we've noticed on XO-1.75 is when we suspend in the middle of
an EC command.  Don't allow that.

In the process, create a private object for the generic EC driver to
use; we have a framework for passing around a struct, use that rather
than a proliferation of global variables.

Signed-off-by: Andres Salomon 
---
 drivers/platform/olpc/olpc-ec.c |   46
++- 1 files changed, 45
insertions(+), 1 deletions(-)

diff --git a/drivers/platform/olpc/olpc-ec.c
b/drivers/platform/olpc/olpc-ec.c index d00523c..cfba41f 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -27,6 +28,21 @@ struct ec_cmd_desc {
void *priv;
 };
 
+struct olpc_ec_priv {
+   struct olpc_ec_driver *drv;
+
+   /*
+* Running an EC command while suspending means we don't
always finish
+* the command before the machine suspends.  This means that
the EC
+* is expecting the command protocol to finish, but we after a
period
+* of time (while the OS is asleep) the EC times out and
restarts its
+* idle loop.  Meanwhile, the OS wakes up, thinks it's still
in the
+* middle of the command protocol, starts throwing random
things at
+* the EC... and everyone's uphappy.
+*/
+   bool suspended;
+};
+
 static void olpc_ec_worker(struct work_struct *w);
 
 static DECLARE_WORK(ec_worker, olpc_ec_worker);
@@ -34,6 +50,7 @@ static LIST_HEAD(ec_cmd_q);
 static DEFINE_SPINLOCK(ec_cmd_q_lock);
 
 static struct olpc_ec_driver *ec_driver;
+static struct olpc_ec_priv *ec_priv;
 static void *ec_cb_arg;
 static DEFINE_MUTEX(ec_cb_lock);
 
@@ -93,6 +110,7 @@ static void queue_ec_descriptor(struct ec_cmd_desc
*desc) 
 int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf, size_t
outlen) {
+   struct olpc_ec_priv *ec = ec_priv;
struct ec_cmd_desc desc;
 
/* XXX: this will be removed in later patches */
@@ -104,6 +122,13 @@ int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen,
u8 *outbuf, size_t outlen) if (WARN_ON(!ec_driver
|| !ec_driver->ec_cmd)) return -ENODEV;
 
+   if (!ec)
+   return -ENOMEM;
+
+   /* Suspending in the middle of a command hoses things really
badly */
+   if (WARN_ON(ec->suspended))
+   return -EBUSY;
+
might_sleep();
 
desc.cmd = cmd;
@@ -126,11 +151,19 @@ EXPORT_SYMBOL_GPL(olpc_ec_cmd);
 
 static int olpc_ec_probe(struct platform_device *pdev)
 {
+   struct olpc_ec_priv *ec;
int err;
 
if (!ec_driver)
return -ENODEV;
 
+   ec = kzalloc(sizeof(*ec), GFP_KERNEL);
+   if (!ec)
+   return -ENOMEM;
+   ec->drv = ec_driver;
+   ec_priv = ec;
+   platform_set_drvdata(pdev, ec);
+
err = ec_driver->probe ? ec_driver->probe(pdev) : 0;
 
return err;
@@ -139,12 +172,23 @@ static int olpc_ec_probe(struct platform_device
*pdev) static int olpc_ec_suspend(struct device *dev)
 {
struct platform_device *pdev = to_platform_device(dev);
-   return ec_driver->suspend ? ec_driver->suspend(pdev) : 0;
+   struct olpc_ec_priv *ec = platform_get_drvdata(pdev);
+   int err = 0;
+
+   if (ec_driver->suspend)
+   err = ec_driver->suspend(pdev);
+   if (!err)
+   ec->suspended = true;
+
+   return err;
 }
 
 static int olpc_ec_resume(struct device *dev)
 {
struct platform_device *pdev = to_platform_device(dev);
+   struct olpc_ec_priv *ec = platform_get_drvdata(pdev);
+
+   ec->suspended = false;
return ec_driver->resume ? ec_driver->resume(pdev) : 0;
 }
 
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/9] Platform: OLPC: allow EC cmd to be overridden, and create a workqueue to call it

2012-07-18 Thread Andres Salomon
This provides a new API allows different OLPC architectures to override the
EC driver.  x86 and ARM OLPC machines use completely different EC backends.

The olpc_ec_cmd is synchronous, and waits for the workqueue to send the
command to the EC.  Multiple callers can run olpc_ec_cmd() at once, and
they will by serialized and sleep while only one executes on the EC at a time.

We don't provide an unregister function, as that doesn't make sense within
the context of OLPC machines - there's only ever 1 EC, it's critical to
functionality, and it certainly not hotpluggable.

Signed-off-by: Andres Salomon 
---
 drivers/platform/olpc/olpc-ec.c |  112 ++-
 include/linux/olpc-ec.h |6 ++
 2 files changed, 116 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index 4202603..44e6a4f 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -5,12 +5,120 @@
  *
  * Licensed under the GPL v2 or later.
  */
+#include 
+#include 
+#include 
+#include 
 #include 
+#include 
+#include 
 #include 
 
+struct ec_cmd_desc {
+   u8 cmd;
+   u8 *inbuf, *outbuf;
+   size_t inlen, outlen;
+
+   int err;
+   struct completion finished;
+   struct list_head node;
+
+   void *priv;
+};
+
+static void olpc_ec_worker(struct work_struct *w);
+
+static DECLARE_WORK(ec_worker, olpc_ec_worker);
+static LIST_HEAD(ec_cmd_q);
+static DEFINE_SPINLOCK(ec_cmd_q_lock);
+
+static struct olpc_ec_driver *ec_driver;
+static void *ec_cb_arg;
+static DEFINE_MUTEX(ec_cb_lock);
+
+void olpc_ec_driver_register(struct olpc_ec_driver *drv, void *arg)
+{
+   ec_driver = drv;
+   ec_cb_arg = arg;
+}
+EXPORT_SYMBOL_GPL(olpc_ec_driver_register);
+
+static void olpc_ec_worker(struct work_struct *w)
+{
+   struct ec_cmd_desc *desc = NULL;
+   unsigned long flags;
+
+   /* Grab the first pending command from the queue */
+   spin_lock_irqsave(_cmd_q_lock, flags);
+   if (!list_empty(_cmd_q)) {
+   desc = list_first_entry(_cmd_q, struct ec_cmd_desc, node);
+   list_del(>node);
+   }
+   spin_unlock_irqrestore(_cmd_q_lock, flags);
+
+   /* Do we actually have anything to do? */
+   if (!desc)
+   return;
+
+   /* Protect the EC hw with a mutex; only run one cmd at a time */
+   mutex_lock(_cb_lock);
+   desc->err = ec_driver->ec_cmd(desc->cmd, desc->inbuf, desc->inlen,
+   desc->outbuf, desc->outlen, ec_cb_arg);
+   mutex_unlock(_cb_lock);
+
+   /* Finished, wake up olpc_ec_cmd() */
+   complete(>finished);
+
+   /* Run the worker thread again in case there are more cmds pending */
+   schedule_work(_worker);
+}
+
+/*
+ * Throw a cmd descripter onto the list.  We now have SMP OLPC machines, so
+ * locking is pretty critical.
+ */
+static void queue_ec_descriptor(struct ec_cmd_desc *desc)
+{
+   unsigned long flags;
+
+   INIT_LIST_HEAD(>node);
+
+   spin_lock_irqsave(_cmd_q_lock, flags);
+   list_add_tail(>node, _cmd_q);
+   spin_unlock_irqrestore(_cmd_q_lock, flags);
+
+   schedule_work(_worker);
+}
+
 int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf, size_t outlen)
 {
-   /* Currently a stub; this will be expanded upon later. */
-   return olpc_ec_cmd_x86(cmd, inbuf, inlen, outbuf, outlen);
+   struct ec_cmd_desc desc;
+
+   /* XXX: this will be removed in later patches */
+   /* Are we using old-style callers? */
+   if (!ec_driver || !ec_driver->ec_cmd)
+   return olpc_ec_cmd_x86(cmd, inbuf, inlen, outbuf, outlen);
+
+   /* Ensure a driver and ec hook have been registered */
+   if (WARN_ON(!ec_driver || !ec_driver->ec_cmd))
+   return -ENODEV;
+
+   might_sleep();
+
+   desc.cmd = cmd;
+   desc.inbuf = inbuf;
+   desc.outbuf = outbuf;
+   desc.inlen = inlen;
+   desc.outlen = outlen;
+   desc.err = 0;
+   init_completion();
+
+   queue_ec_descriptor();
+
+   /* Timeouts must be handled in the platform-specific EC hook */
+   wait_for_completion();
+
+   /* The worker thread dequeues the cmd; no need to do anything here */
+   return desc.err;
 }
 EXPORT_SYMBOL_GPL(olpc_ec_cmd);
diff --git a/include/linux/olpc-ec.h b/include/linux/olpc-ec.h
index 6d4e426..231e96f 100644
--- a/include/linux/olpc-ec.h
+++ b/include/linux/olpc-ec.h
@@ -14,8 +14,14 @@
 #define EC_SCI_QUERY   0x84
 #define EC_EXT_SCI_QUERY   0x85
 
+struct olpc_ec_driver {
+   int (*ec_cmd)(u8, u8 *, size_t, u8 *, size_t, void *);
+};
+
 #ifdef CONFIG_OLPC
 
+extern void olpc_ec_driver_register(struct olpc_ec_driver *drv, void *arg);
+
 extern int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
size_t outlen);
 
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a 

Re: [Bug 3.4.5] reiserfs: mutex_destroy called with locked mutex

2012-07-18 Thread Al Viro
On Wed, Jul 18, 2012 at 03:37:52PM -0700, Linus Torvalds wrote:
> On Wed, Jul 18, 2012 at 2:33 PM, Al Viro  wrote:
> >
> >  The only questions
> > are "is this the WARN_ON() Knut had stepped on" (and I agree with your
> > scenario now) and "is it critical enough to shove it into the tree
> > less than a week before -final".  Up to you...
> 
> 
> I agree that it isn't critical. Even the lockdep thing is just a
> warning, and is apparently quite hard to trigger.
> 
> Will you hold on to the patch in your VFS tree, and we can just merge
> it for 3.6?

Sure, no problem...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/9] drivers: OLPC: update various drivers to include olpc-ec.h

2012-07-18 Thread Andres Salomon
Switch over to using olpc-ec.h in multiple steps, so as not to break
builds. This covers every driver that calls olpc_ec_cmd().

Signed-off-by: Andres Salomon 
---
 arch/x86/include/asm/olpc.h|1 -
 arch/x86/platform/olpc/olpc-xo1-pm.c   |1 +
 arch/x86/platform/olpc/olpc-xo1-sci.c  |1 +
 arch/x86/platform/olpc/olpc-xo15-sci.c |1 +
 arch/x86/platform/olpc/olpc.c  |1 +
 drivers/net/wireless/libertas/if_usb.c |1 +
 drivers/platform/x86/xo1-rfkill.c  |3 +--
 drivers/power/olpc_battery.c   |1 +
 drivers/staging/olpc_dcon/olpc_dcon.c  |1 +
 9 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/olpc.h b/arch/x86/include/asm/olpc.h
index 513e999..5b28f3e 100644
--- a/arch/x86/include/asm/olpc.h
+++ b/arch/x86/include/asm/olpc.h
@@ -4,7 +4,6 @@
 #define _ASM_X86_OLPC_H
 
 #include 
-#include 
 
 struct olpc_platform_t {
int flags;
diff --git a/arch/x86/platform/olpc/olpc-xo1-pm.c
b/arch/x86/platform/olpc/olpc-xo1-pm.c index 0ce8616c..8054b64 100644
--- a/arch/x86/platform/olpc/olpc-xo1-pm.c
+++ b/arch/x86/platform/olpc/olpc-xo1-pm.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/arch/x86/platform/olpc/olpc-xo1-sci.c
b/arch/x86/platform/olpc/olpc-xo1-sci.c index 04b8c73..63d4aa4 100644
--- a/arch/x86/platform/olpc/olpc-xo1-sci.c
+++ b/arch/x86/platform/olpc/olpc-xo1-sci.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/arch/x86/platform/olpc/olpc-xo15-sci.c
b/arch/x86/platform/olpc/olpc-xo15-sci.c index 23e5b9d..9899fef 100644
--- a/arch/x86/platform/olpc/olpc-xo15-sci.c
+++ b/arch/x86/platform/olpc/olpc-xo15-sci.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/arch/x86/platform/olpc/olpc.c
b/arch/x86/platform/olpc/olpc.c index 796e199..a3fa180 100644
--- a/arch/x86/platform/olpc/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/drivers/net/wireless/libertas/if_usb.c
b/drivers/net/wireless/libertas/if_usb.c index cd3b0d4..a9828b1 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef CONFIG_OLPC
 #include 
diff --git a/drivers/platform/x86/xo1-rfkill.c
b/drivers/platform/x86/xo1-rfkill.c index b57ad86..1da13ed 100644
--- a/drivers/platform/x86/xo1-rfkill.c
+++ b/drivers/platform/x86/xo1-rfkill.c
@@ -12,8 +12,7 @@
 #include 
 #include 
 #include 
-
-#include 
+#include 
 
 static bool card_blocked;
 
diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c
index 7385092..eaf917d 100644
--- a/drivers/power/olpc_battery.c
+++ b/drivers/power/olpc_battery.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 
diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c
b/drivers/staging/olpc_dcon/olpc_dcon.c index 992275c..2c4bd74 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/9] Platform: OLPC: add a stub to drivers/platform/ for the OLPC EC driver

2012-07-18 Thread Andres Salomon
The OLPC EC driver has outgrown arch/x86/platform/.  It's time to both
share common code amongst different architectures, as well as move it out
of arch/x86/.  The XO-1.75 is ARM-based, and the EC driver shares a lot of
code with the x86 code.

Signed-off-by: Andres Salomon 
---
 arch/x86/include/asm/olpc.h |   19 +++
 arch/x86/platform/olpc/olpc.c   |4 ++--
 drivers/platform/Makefile   |1 +
 drivers/platform/olpc/olpc-ec.c |   16 
 include/linux/olpc-ec.h |   29 +
 5 files changed, 51 insertions(+), 18 deletions(-)
 create mode 100644 drivers/platform/olpc/olpc-ec.c
 create mode 100644 include/linux/olpc-ec.h

diff --git a/arch/x86/include/asm/olpc.h b/arch/x86/include/asm/olpc.h
index 87bdbca..513e999 100644
--- a/arch/x86/include/asm/olpc.h
+++ b/arch/x86/include/asm/olpc.h
@@ -4,6 +4,7 @@
 #define _ASM_X86_OLPC_H
 
 #include 
+#include 
 
 struct olpc_platform_t {
int flags;
@@ -102,22 +103,8 @@ extern int pci_olpc_init(void);
 
 /* EC related functions */
 
-extern int olpc_ec_cmd(unsigned char cmd, unsigned char *inbuf, size_t inlen,
-   unsigned char *outbuf, size_t outlen);
-
-/* EC commands */
-
-#define EC_FIRMWARE_REV0x08
-#define EC_WRITE_SCI_MASK  0x1b
-#define EC_WAKE_UP_WLAN0x24
-#define EC_WLAN_LEAVE_RESET0x25
-#define EC_READ_EB_MODE0x2a
-#define EC_SET_SCI_INHIBIT 0x32
-#define EC_SET_SCI_INHIBIT_RELEASE 0x34
-#define EC_WLAN_ENTER_RESET0x35
-#define EC_WRITE_EXT_SCI_MASK  0x38
-#define EC_SCI_QUERY   0x84
-#define EC_EXT_SCI_QUERY   0x85
+extern int olpc_ec_cmd_x86(unsigned char cmd, unsigned char *inbuf,
+   size_t inlen, unsigned char *outbuf, size_t outlen);
 
 /* SCI source values */
 
diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c
index a4bee53..796e199 100644
--- a/arch/x86/platform/olpc/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
@@ -125,7 +125,7 @@ static int __wait_on_obf(unsigned int line, unsigned int 
port, int desired)
  * .  Unfortunately, while
  * OpenFirmware's source is available, the EC's is not.
  */
-int olpc_ec_cmd(unsigned char cmd, unsigned char *inbuf, size_t inlen,
+int olpc_ec_cmd_x86(unsigned char cmd, unsigned char *inbuf, size_t inlen,
unsigned char *outbuf,  size_t outlen)
 {
unsigned long flags;
@@ -201,7 +201,7 @@ err:
spin_unlock_irqrestore(_lock, flags);
return ret;
 }
-EXPORT_SYMBOL_GPL(olpc_ec_cmd);
+EXPORT_SYMBOL_GPL(olpc_ec_cmd_x86);
 
 void olpc_ec_wakeup_set(u16 value)
 {
diff --git a/drivers/platform/Makefile b/drivers/platform/Makefile
index 782953a..b17c16c 100644
--- a/drivers/platform/Makefile
+++ b/drivers/platform/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_X86)  += x86/
+obj-$(CONFIG_OLPC) += olpc/
diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
new file mode 100644
index 000..4202603
--- /dev/null
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -0,0 +1,16 @@
+/*
+ * Generic driver for the OLPC Embedded Controller.
+ *
+ * Copyright (C) 2011-2012 One Laptop per Child Foundation.
+ *
+ * Licensed under the GPL v2 or later.
+ */
+#include 
+#include 
+
+int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf, size_t outlen)
+{
+   /* Currently a stub; this will be expanded upon later. */
+   return olpc_ec_cmd_x86(cmd, inbuf, inlen, outbuf, outlen);
+}
+EXPORT_SYMBOL_GPL(olpc_ec_cmd);
diff --git a/include/linux/olpc-ec.h b/include/linux/olpc-ec.h
new file mode 100644
index 000..6d4e426
--- /dev/null
+++ b/include/linux/olpc-ec.h
@@ -0,0 +1,29 @@
+#ifndef _LINUX_OLPC_EC_H
+#define _LINUX_OLPC_EC_H
+
+/* XO-1 EC commands */
+#define EC_FIRMWARE_REV0x08
+#define EC_WRITE_SCI_MASK  0x1b
+#define EC_WAKE_UP_WLAN0x24
+#define EC_WLAN_LEAVE_RESET0x25
+#define EC_READ_EB_MODE0x2a
+#define EC_SET_SCI_INHIBIT 0x32
+#define EC_SET_SCI_INHIBIT_RELEASE 0x34
+#define EC_WLAN_ENTER_RESET0x35
+#define EC_WRITE_EXT_SCI_MASK  0x38
+#define EC_SCI_QUERY   0x84
+#define EC_EXT_SCI_QUERY   0x85
+
+#ifdef CONFIG_OLPC
+
+extern int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
+   size_t outlen);
+
+#else
+
+static inline int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
+   size_t outlen) { return -ENODEV; }
+
+#endif /* CONFIG_OLPC */
+
+#endif /* _LINUX_OLPC_EC_H */
-- 
1.7.2.5

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

Re: potential NULL dereference in futex_wait_requeue_pi()

2012-07-18 Thread Darren Hart


On 07/18/2012 11:01 AM, Dave Jones wrote:
> On Wed, Jul 18, 2012 at 09:03:22AM -0700, Darren Hart wrote:
>  
>  > > This will oops if pi_mutex is NULL.
>  > > 
>  > >   2374  rt_mutex_unlock(pi_mutex);
>  > >   2375  } else if (ret == -EINTR) {
>  > 
>  > Nice Dan, thanks for taking a closer look. This appears to be a simple 
> fix, can
>  > you try the following:
>  > 
>  > 
>  > futex: Test for pi_mutex on fault in futex_wait_requeue_pi
>  > 
>  > If fixup_pi_state_owner() faults, pi_mutex may be NULL. Test
>  > for pi_mutex != NULL before testing the owner against current
>  > and possibly unlocking it.
>  > 
>  > Signed-off-by: Darren Hart 
>  > CC: Dave Jones 
>  > CC: Dan Carpenter 
>  > CC: Thomas Gleixner 
>  > 
>  > diff --git a/kernel/futex.c b/kernel/futex.c
>  > index e2b0fb9..05018bf 100644
>  > --- a/kernel/futex.c
>  > +++ b/kernel/futex.c
>  > @@ -2370,7 +2370,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, 
> unsigned int flags,
>  > * fault, unlock the rt_mutex and return the fault to userspace.
>  > */
>  >if (ret == -EFAULT) {
>  > -  if (rt_mutex_owner(pi_mutex) == current)
>  > +  if (pi_mutex && rt_mutex_owner(pi_mutex) == current)
>  >rt_mutex_unlock(pi_mutex);
>  >} else if (ret == -EINTR) {
>  >/*
> 
> Doesn't fix the oops for me unfortunatly.  It looks like it happens further 
> up,
> so this might be a spearate bug after all.
> 
> I added this..
> 
> @@ -2344,7 +2351,13 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, 
> unsigned int flags,
>  * the pi_state.
>  */
> WARN_ON(!_state);
> +
> pi_mutex = _state->pi_mutex;
> +   if (pi_mutex == NULL) {
> +   ret = -EINVAL;
> +   goto out;
> +   }
> +
> ret = rt_mutex_finish_proxy_lock(pi_mutex, to, _waiter, 1);
> 
> 
> But that didn't seem to fix it either.  Somehow we still do this ..
> 
> 
> BUG: unable to handle kernel NULL pointer dereference at 0028

I was hunting for a lock->owner-> dereference in that path, as I think
owner can be at 0x28, but it doesn't work with your trace below.

> IP: [] __lock_acquire+0x5e/0x1ae0
> 
>   lock_acquire+0xad/0x220
>   _raw_spin_lock+0x46/0x80
>   rt_mutex_finish_proxy_lock+0x34/0xe0
>   futex_wait_requeue_pi.constprop.20+0x2e5/0x400
>   do_futex+0xea/0xa20
>   sys_futex+0x107/0x1a0
>   system_call_fastpath+0x1a/0x1f
> 
> Ah, could it somehow be that we have a pi_mutex here, but it hasn't been 
> initialised ?
> 
> The code: line fingers this as the failure in kernel/lockdep.c
> 
> if (lock->key == &__lockdep_no_validate__)
> 3f9e:   49 8b 07mov(%r15),%rax
> 
> r15 (lock) is somehow '0x28' here, which is why the NULL check I added didn't 
> trigger.

OK, so for debug a < 0xc000 check might be useful.

> 
> This isn't helped by the fact that there seems to be another unrelated bug in 
> futexes
> that trinity triggers.  If you want to try this, running it with "-c futex" 
> will reproduce
> it very quickly.

Gave it a shot on the laptop (stock Fedora 17 kernel)... first it killed
my external display and reverted to the internal screen (nice trick
that) then it just locked up hard. Took about 2 seconds for the first, a
few more for the second. All unprivileged... nasty test case you have
here. I was considering adding fuzz testing to futextest, but I believe
you have it covered rather nicely here :-)

I'll start in on some instrumentation and further analysis after the
morning meetings (ugh).

-- 
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/9] OLPC: create a generic OLPC EC driver

2012-07-18 Thread Andres Salomon
The OLPC EC (Embedded Controller) code that is currently upstream is
x86-only, originally written for the XO-1.  Since then, we've had the
XO-1.5 (also x86), and XO-1.75 (arm-based) enter mass production.  The
1.75 uses a vastly different EC protocol, and future hardware revisions
are likely to change it even further.

However, the drivers do share quite a bit of code, so it makes sense to
have a platform-agnostic driver that calls into platform-specific hooks
for each XO's EC driver.  This is the first stab and creating such a
beast (with further patches pending).  Aside from the lack of code
duplication, this is helpful for fixing bugs in one place (for example,
we fixed an EC suspend/resume bug in 1.75 that I've just seen happen on
1.5 without these patches.  With these patches, the problem goes away).

These patches are against Linus's current HEAD; let me know if they
don't apply somewhere, and I'll happily redo them against the -next
tree.  I'm assuming that these changes (which touch places like x86,
wireless, and staging) should go through either the x86 tree, or
through akpm's tree.

Alternatively, if the reviews are positive and I can get SOBs from the
relevant maintainers, I can set up a platform-olpc tree somewhere and
request a pull from Linus.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


USB enumeration post-resume NOT persistent yet "persist" --> swapped devices nodes --> root partition reference broken

2012-07-18 Thread Andreas Mohr
Hi,

Yesterday I was surprised to see that with *another* external USB disk
happening to be connected before boot,
the system booted with root partition device sdb1 assigned rather than sda1.
Not thinking much, I then proceeded putting the system into suspend,
only to be even more surprised to then end up with swapped device nodes
post-resume and the system killed
(I *know* that device nodes ended up jumbled since the root device contains
"root" plus "swap" partition device node, whereas the "other" USB device
contains one partition only,
and the set of partition device nodes as still successfully looked up via
ls -l /dev/sd*
ended up exactly reversed after system resume).
I attempted to get dmesg off this system, however not even plain sector writing
of my /tmp/dmesg.log to a new USB device worked since "dd" segfaulted.
Also, no network access of course.

http://lists.linux-foundation.org/pipermail/linux-pm/2009-November/023101.html
talks about this case, and mentions Documentation/usb/persist.txt
as the most authoritative document.

The thing is, /sys persist nodes *are* all set to 1 for any affected
device (at least as observed after the subsequent fresh boot).

The plausibility of the previous killed boot having had "persist"
attribute set as well for all devices is VERY high
(there were no changes/updates in system software configuration done,
thus settings should have been identical).

Thus I'm highly puzzled as to why with USB persistence *activated*
it still decided to jumble device nodes on this system resume.
Content of the pathological dmesg log didn't contain any mentioning
of any "persistence" mechanism activity, BTW, AFAIR.

Device identification *is* as unique as it gets:

# lsusb 
Bus 001 Device 005: ID 174c:55aa ASMedia Technology Inc. 
Bus 001 Device 002: ID 152d:0601 JMicron Technology Corp. / JMicron USA 
Technology Corp. 
Bus 001 Device 004: ID 064e:d101 Suyin Corp. Acer CrystalEye Webcam
Bus 003 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle 
(HCI mode)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

andinet sys # find . -name "*persist*"
./devices/pci:00/:00:1c.2/:03:00.0/ieee80211/phy0/rfkill1/persistent
./devices/pci:00/:00:1d.1/usb3/3-2/3-2:1.0/bluetooth/hci0/rfkill0/persistent
./devices/pci:00/:00:1d.1/usb3/3-2/power/persist
./devices/pci:00/:00:1d.7/usb1/1-1/power/persist
./devices/pci:00/:00:1d.7/usb1/1-2/power/persist
./devices/pci:00/:00:1d.7/usb1/1-5/power/persist
andinet sys # cat ./devices/pci:00/:00:1d.7/usb1/1-2/product
TS32GSSD18M-M
andinet sys # cat ./devices/pci:00/:00:1d.7/usb1/1-2/power/persist
1
andinet sys # cat ./devices/pci:00/:00:1d.7/usb1/1-5/product
Acer Crystal Eye webcam
andinet sys # cat ./devices/pci:00/:00:1d.7/usb1/1-5/power/persist
1
andinet sys # cat ./devices/pci:00/:00:1d.7/usb1/1-1/product
MEDION HDDrive-n-GO
andinet sys # cat ./devices/pci:00/:00:1d.7/usb1/1-1/power/persist
1

(TS32GSSD18M-M is USB-connected root partition SSD)


Netbook Acer Aspire One A110L.
Running 3.5.0-rc7+ here (yes ma'am, bleeding edge tester :).
Was the first time to attempt resume with an additional device remaining
connected, IIRC - that -rc7 thing likely doesn't play much of a role here.
A bit hesitant to (dis-)prove the bug's "regression flag" with another version
since random possibly succeeding I/O accesses to incompatible devices
are not necessarily my thing (or is this safe to attempt again? Any more
specific session info one would need?).

So, again, possibly USB persistence is bug-broken?

Posted to linux-usb (discussion) and lkml (kernel bug?).

Thanks,

Andreas Mohr
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] Drivers: hv: Change the hex constant to a decimal constant

2012-07-18 Thread Jeff Garzik

On 07/18/2012 06:57 PM, K. Y. Srinivasan wrote:
The hex constant chosen for HV_LINUX_GUEST_ID_HI was offensive, update 
to use

the decimal equivalent instead.

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Haiyang Zhang 


Acked-by: Jeff Garzik 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RT 00/12] [ANNOUNCE] 3.0.36-rt58-rc1 stable review

2012-07-18 Thread Mike Galbraith
On Wed, 2012-07-18 at 18:39 -0400, Steven Rostedt wrote:

> Please test the patches too.

Your hotplug stress test script made x3550 M3 box fall over.  It took a
bit, but down she went.  64 core test box fell over quickly, but that's
very far from virgin source.. seems to be the same though.

[  255.016043] CPU 1 MCA<0>Kernel panic - not syncing: Watchdog detected hard 
LOCKUP on cpu 7
Pid: 9914, comm: migration/7 Not tainted 3.0.36-rt57 #49
Call Trace:
   [] panic+0x9b/0x1b0
 [] watchdog_overflow_callback+0xd7/0xe0
 [] __perf_event_overflow+0x9d/0x240
 [] ? perf_event_update_userpage+0x9b/0xe0
 [] perf_event_overflow+0x14/0x20
 [] intel_pmu_handle_irq+0x177/0x230
 [] perf_event_nmi_handler+0x39/0xc0
 [] notifier_call_chain+0x4d/0x70
 [] __atomic_notifier_call_chain+0x43/0x60
 [] atomic_notifier_call_chain+0x11/0x20
 [] notify_die+0x2e/0x30
 [] default_do_nmi+0x39/0x200
 [] do_nmi+0x78/0x80
 [] nmi+0x20/0x30
 [] ? stop_machine_cpu_stop+0x6a/0xe0
 <>  [] cpu_stopper_thread+0xf4/0x1d0
 [] ? wait_for_stop_done+0xa0/0xa0
 [] ? __schedule+0x2c7/0x630
 [] ? cpu_stop_queue_work+0x70/0x70
 [] ? cpu_stop_queue_work+0x70/0x70
 [] kthread+0xa6/0xb0
 [] ? do_exit+0x278/0x450
 [] ? __switch_to+0xf2/0x370
 [] ? finish_task_switch+0x55/0xd0
 [] kernel_thread_helper+0x4/0x10
 [] ? __init_kthread_worker+0x50/0x50
 [] ? gs_change+0x13/0x13


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH v3 6/6] mmc: dw_mmc: add samsung exynos5250 specific extentions

2012-07-18 Thread Seungwon Jeon
Hi,

This version does not seems to consider previous reviews fully.
Could you check the comments below?

July 12, 2012, Thomas Abraham  wrote:
> The instantiation of the Synopsis Designware controller on Exynos5250
> include extension for SDR and DDR specific tx/rx phase shift timing
> and CIU internal divider. In addition to that, the option to skip the
> command hold stage is also introduced. Add support for these Exynos5250
> specfic extenstions.
> 
> Signed-off-by: Abhilash Kesavan 
> Signed-off-by: Thomas Abraham 
> ---
>  .../devicetree/bindings/mmc/synposis-dw-mshc.txt   |   38 ++-
>  drivers/mmc/host/dw_mmc-pltfm.c|   15 +++
>  drivers/mmc/host/dw_mmc.c  |   40 
> +++-
>  drivers/mmc/host/dw_mmc.h  |   14 +++
>  include/linux/mmc/dw_mmc.h |6 +++
>  5 files changed, 110 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mmc/synposis-dw-mshc.txt
> b/Documentation/devicetree/bindings/mmc/synposis-dw-mshc.txt
> index 3acd6c9..69d78c1 100644
> --- a/Documentation/devicetree/bindings/mmc/synposis-dw-mshc.txt
> +++ b/Documentation/devicetree/bindings/mmc/synposis-dw-mshc.txt
> @@ -7,6 +7,8 @@ Required Properties:
> 
>  * compatible: should be one of the following
>   - snps,dw-mshc: for controllers compliant with synopsis dw-mshc.
> + - samsung,exynos5250-dw-mshc: for controllers with Samsung
> +   Exynos5250 specific extentions.
> 
>  * reg: physical base address of the dw-mshc controller and size of its memory
>region.
> @@ -74,13 +76,45 @@ Aliases:
>the following format 'mshc{n}' where n is a unique number for the alias.
> 
> 
> +Samsung Exynos4/5 specific properties:
> +
> +Some of the variants of Exynos4 (such as Exynos4412) and Exynos5 SoC's
> +includes few extensions to the Synopsis Designware Mobile Storage Host
> +Controller. The following properties are used to describe those extensions.
> +
> +* samsung,dw-mshc-sdr-timing: Specifies the value of CUI clock divider, CIU
> +  clock phase shift value in transmit mode and CIU clock phase shift value in
> +  receive mode for single data rate mode operation. Refer notes of the valid
> +  values below.
> +
> +* samsung,dw-mshc-ddr-timing: Specifies the value of CUI clock divider, CIU
> +  clock phase shift value in transmit mode and CIU clock phase shift value in
> +  receive mode for double data rate mode operation. Refer notes of the valid
> +  values below. The order of the cells should be
> +
> +- First Cell:CIU clock divider value (applicable only for Exynos5
> + SoC's, should be zero for Exynos4 SoC's)
> +- Second Cell:   CIU clock phase shift value for tx mode.
> +- Third Cell:CIU clock phase shift value for rx mode.
> +
> +  Valid values for SDR and DDR CIU clock timing for Exynos5250:
> +
> +- valid values for CIU clock divider, tx phase shift and rx phase shift
> +  is 0 to 7.
> +
> +- When CIU clock divider value is set to 3, all possible 8 phase shift
> +  values can be used.
> +
> +- If CIU clock divider value is 0 (that is divide by 1), both tx and rx
> +  phase shift clocks should be 0.
> +
>  Example:
> 
>The MSHC controller node can be split into two portions, SoC specific and
>board specific portions as listed below.
> 
>   dwmmc0@1220 {
> - compatible = "snps,dw-mshc";
> + compatible = "samsung,exynos5250-dw-mshc";
>   reg = <0x1220 0x1000>;
>   interrupts = <0 75 0>;
>   #address-cells = <1>;
> @@ -94,6 +128,8 @@ Example:
>   no-write-protect;
>   fifo-depth = <0x80>;
>   card-detect-delay = <200>;
> + samsung,dw-mshc-sdr-timing = <2 3 3>;
> + samsung,dw-mshc-ddr-timing = <1 2 3>;
> 
>   slot@0 {
>   reg = <0>;
> diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c
> index 8d24f6d..900f412 100644
> --- a/drivers/mmc/host/dw_mmc-pltfm.c
> +++ b/drivers/mmc/host/dw_mmc-pltfm.c
> @@ -27,9 +27,24 @@ static struct dw_mci_drv_data synopsis_drv_data = {
>   .ctrl_type  = DW_MCI_TYPE_SYNOPSIS,
>  };
> 
> +static unsigned long exynos5250_dwmmc_caps[4] = {
> + MMC_CAP_UHS_DDR50 | MMC_CAP_1_8V_DDR |
> + MMC_CAP_8_BIT_DATA | MMC_CAP_CMD23,
> + MMC_CAP_CMD23,
> + MMC_CAP_CMD23,
> + MMC_CAP_CMD23,
> +};
> +
Kyungmin Park has already pointed .
It's not still proper place for board specific caps.
If I'm incorrect, please let me know.
And why MMC_CAP_CMD23 is default caps for all channel of hosts?

> +static struct dw_mci_drv_data exynos5250_drv_data = {
> + .ctrl_type  = DW_MCI_TYPE_EXYNOS5250,
> + .caps   = exynos5250_dwmmc_caps,
> +};
> +
>  static const struct of_device_id dw_mci_pltfm_match[] = {
>   { .compatible = "snps,dw-mshc",
>   

Re: [PATCH] alarmtimer: add .remove_dev hook to put device

2012-07-18 Thread John Stultz

On 07/18/2012 06:23 PM, Shawn Guo wrote:

On 19 July 2012 07:23, John Stultz  wrote:

Actually, this change opens up a bunch of other races, as any caller of
alarmtimer_get_rtcdev() could have the rtcdevice removed under it.

We'll need to have proper reference counting w/ get/put calls, probably also
adding a alarmtimer_put_rtcdev() interface.

So for now I'm dropping this from my tree.  Do you think you might be able
to take another stab at this?


No.  You can take the patch as a bug report and fix it yourself in the
best way you can think of :)

Ok. I'll try to find some time to do that.

Thanks!
-john

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/5] ubi: Limit amount of reserved eraseblocks for bad PEB handling

2012-07-18 Thread Artem Bityutskiy
On Wed, 2012-07-18 at 22:55 +0300, Shmulik Ladkani wrote:
> However, if you DO NOT mark it bad, but instead go into RO mode, you
> should be able to later re-attach because the good_peb_count would fit
> (no shortage of PEBs). 

Yeah, you are right, I'll return to the original patch.

-- 
Best Regards,
Artem Bityutskiy


signature.asc
Description: This is a digitally signed message part


[PATCH 2/2] regulator: mc13892: Make mc13892_powermisc_rmw() lock protected

2012-07-18 Thread Axel Lin
Then we can remove lock/unlock around the caller.

Signed-off-by: Axel Lin 
---
 drivers/regulator/mc13892-regulator.c |   22 --
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/regulator/mc13892-regulator.c 
b/drivers/regulator/mc13892-regulator.c
index b388b74..9d4296b 100644
--- a/drivers/regulator/mc13892-regulator.c
+++ b/drivers/regulator/mc13892-regulator.c
@@ -305,9 +305,10 @@ static int mc13892_powermisc_rmw(struct 
mc13xxx_regulator_priv *priv, u32 mask,
 
BUG_ON(val & ~mask);
 
+   mc13xxx_lock(priv->mc13xxx);
ret = mc13xxx_reg_read(mc13892, MC13892_POWERMISC, );
if (ret)
-   return ret;
+   goto out;
 
/* Update the stored state for Power Gates. */
priv->powermisc_pwgt_state =
@@ -320,14 +321,16 @@ static int mc13892_powermisc_rmw(struct 
mc13xxx_regulator_priv *priv, u32 mask,
valread = (valread & ~MC13892_POWERMISC_PWGTSPI_M) |
priv->powermisc_pwgt_state;
 
-   return mc13xxx_reg_write(mc13892, MC13892_POWERMISC, valread);
+   ret = mc13xxx_reg_write(mc13892, MC13892_POWERMISC, valread);
+out:
+   mc13xxx_unlock(priv->mc13xxx);
+   return ret;
 }
 
 static int mc13892_gpo_regulator_enable(struct regulator_dev *rdev)
 {
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
int id = rdev_get_id(rdev);
-   int ret;
u32 en_val = mc13892_regulators[id].enable_bit;
u32 mask = mc13892_regulators[id].enable_bit;
 
@@ -340,18 +343,13 @@ static int mc13892_gpo_regulator_enable(struct 
regulator_dev *rdev)
if (id == MC13892_GPO4)
mask |= MC13892_POWERMISC_GPO4ADINEN;
 
-   mc13xxx_lock(priv->mc13xxx);
-   ret = mc13892_powermisc_rmw(priv, mask, en_val);
-   mc13xxx_unlock(priv->mc13xxx);
-
-   return ret;
+   return mc13892_powermisc_rmw(priv, mask, en_val);
 }
 
 static int mc13892_gpo_regulator_disable(struct regulator_dev *rdev)
 {
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
int id = rdev_get_id(rdev);
-   int ret;
u32 dis_val = 0;
 
dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id);
@@ -360,12 +358,8 @@ static int mc13892_gpo_regulator_disable(struct 
regulator_dev *rdev)
if (id == MC13892_PWGT1SPI || id == MC13892_PWGT2SPI)
dis_val = mc13892_regulators[id].enable_bit;
 
-   mc13xxx_lock(priv->mc13xxx);
-   ret = mc13892_powermisc_rmw(priv, mc13892_regulators[id].enable_bit,
+   return mc13892_powermisc_rmw(priv, mc13892_regulators[id].enable_bit,
dis_val);
-   mc13xxx_unlock(priv->mc13xxx);
-
-   return ret;
 }
 
 static int mc13892_gpo_regulator_is_enabled(struct regulator_dev *rdev)
-- 
1.7.9.5



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] regulator: mc13783: Make mc13783_powermisc_rmw() lock protected

2012-07-18 Thread Axel Lin
Then we can remove lock/unlock around the caller.

Signed-off-by: Axel Lin 
---
 drivers/regulator/mc13783-regulator.c |   22 --
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/regulator/mc13783-regulator.c 
b/drivers/regulator/mc13783-regulator.c
index 4932e34..2587ea1 100644
--- a/drivers/regulator/mc13783-regulator.c
+++ b/drivers/regulator/mc13783-regulator.c
@@ -238,9 +238,10 @@ static int mc13783_powermisc_rmw(struct 
mc13xxx_regulator_priv *priv, u32 mask,
 
BUG_ON(val & ~mask);
 
+   mc13xxx_lock(priv->mc13xxx);
ret = mc13xxx_reg_read(mc13783, MC13783_REG_POWERMISC, );
if (ret)
-   return ret;
+   goto out;
 
/* Update the stored state for Power Gates. */
priv->powermisc_pwgt_state =
@@ -253,7 +254,10 @@ static int mc13783_powermisc_rmw(struct 
mc13xxx_regulator_priv *priv, u32 mask,
valread = (valread & ~MC13783_REG_POWERMISC_PWGTSPI_M) |
priv->powermisc_pwgt_state;
 
-   return mc13xxx_reg_write(mc13783, MC13783_REG_POWERMISC, valread);
+   ret = mc13xxx_reg_write(mc13783, MC13783_REG_POWERMISC, valread);
+out:
+   mc13xxx_unlock(priv->mc13xxx);
+   return ret;
 }
 
 static int mc13783_gpo_regulator_enable(struct regulator_dev *rdev)
@@ -261,7 +265,6 @@ static int mc13783_gpo_regulator_enable(struct 
regulator_dev *rdev)
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
int id = rdev_get_id(rdev);
-   int ret;
u32 en_val = mc13xxx_regulators[id].enable_bit;
 
dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id);
@@ -271,12 +274,8 @@ static int mc13783_gpo_regulator_enable(struct 
regulator_dev *rdev)
id == MC13783_REG_PWGT2SPI)
en_val = 0;
 
-   mc13xxx_lock(priv->mc13xxx);
-   ret = mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit,
+   return mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit,
en_val);
-   mc13xxx_unlock(priv->mc13xxx);
-
-   return ret;
 }
 
 static int mc13783_gpo_regulator_disable(struct regulator_dev *rdev)
@@ -284,7 +283,6 @@ static int mc13783_gpo_regulator_disable(struct 
regulator_dev *rdev)
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
int id = rdev_get_id(rdev);
-   int ret;
u32 dis_val = 0;
 
dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id);
@@ -294,12 +292,8 @@ static int mc13783_gpo_regulator_disable(struct 
regulator_dev *rdev)
id == MC13783_REG_PWGT2SPI)
dis_val = mc13xxx_regulators[id].enable_bit;
 
-   mc13xxx_lock(priv->mc13xxx);
-   ret = mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit,
+   return mc13783_powermisc_rmw(priv, mc13xxx_regulators[id].enable_bit,
dis_val);
-   mc13xxx_unlock(priv->mc13xxx);
-
-   return ret;
 }
 
 static int mc13783_gpo_regulator_is_enabled(struct regulator_dev *rdev)
-- 
1.7.9.5



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 14/17] [ARM] pxa: remove IRQF_SAMPLE_RANDOM which is now a no-op

2012-07-18 Thread Haojian Zhuang
On Wed, Jul 18, 2012 at 5:32 AM, Theodore Ts'o  wrote:
> With the changes in the random tree, IRQF_SAMPLE_RANDOM is now a
> no-op; interrupt randomness is now collected unconditionally in a very
> low-overhead fashion; see commit 775f4b297b.  The IRQF_SAMPLE_RANDOM
> flag was scheduled to be removed in 2009 on the
> feature-removal-schedule, so this patch is preparation for the final
> removal of this flag.
>
> Signed-off-by: "Theodore Ts'o" 
> Cc: Eric Miao 
> Cc: Russell King 
> Cc: Haojian Zhuang 
> ---

Acked-by: Haojian Zhuang 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 11/17] pxa25x_udc: remove IRQF_SAMPLE_RANDOM which is now a no-op

2012-07-18 Thread Haojian Zhuang
On Wed, Jul 18, 2012 at 5:32 AM, Theodore Ts'o  wrote:
> With the changes in the random tree, IRQF_SAMPLE_RANDOM is now a
> no-op; interrupt randomness is now collected unconditionally in a very
> low-overhead fashion; see commit 775f4b297b.  The IRQF_SAMPLE_RANDOM
> flag was scheduled to be removed in 2009 on the
> feature-removal-schedule, so this patch is preparation for the final
> removal of this flag.
>
> Signed-off-by: "Theodore Ts'o" 
> Cc: Eric Miao 
> Cc: Russell King 
> Cc: Haojian Zhuang 
> ---
>  drivers/usb/gadget/pxa25x_udc.c | 12 
>  1 file changed, 4 insertions(+), 8 deletions(-)
>
Acked-by: Haojian Zhuang 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] hugetlb/cgroup: Simplify pre_destroy callback

2012-07-18 Thread Aneesh Kumar K.V
Andrew Morton  writes:

> On Wed, 18 Jul 2012 11:04:09 +0530
> "Aneesh Kumar K.V"  wrote:
>
>> From: "Aneesh Kumar K.V" 
>> 
>> Since we cannot fail in hugetlb_cgroup_move_parent, we don't really
>> need to check whether cgroup have any change left after that. Also skip
>> those hstates for which we don't have any charge in this cgroup.
>> 
>> ...
>>
>> +for_each_hstate(h) {
>> +/*
>> + * if we don't have any charge, skip this hstate
>> + */
>> +idx = hstate_index(h);
>> +if (res_counter_read_u64(_cg->hugepage[idx], RES_USAGE) == 0)
>> +continue;
>> +spin_lock(_lock);
>> +list_for_each_entry(page, >hugepage_activelist, lru)
>> +hugetlb_cgroup_move_parent(idx, cgroup, page);
>> +spin_unlock(_lock);
>> +VM_BUG_ON(res_counter_read_u64(_cg->hugepage[idx], 
>> RES_USAGE));
>> +}
>>  out:
>>  return ret;
>>  }
>
> This looks fishy.
>
> We test RES_USAGE before taking hugetlb_lock.  What prevents some other
> thread from increasing RES_USAGE after that test?
>
> After walking the list we test RES_USAGE after dropping hugetlb_lock. 
> What prevents another thread from incrementing RES_USAGE before that
> test, triggering the BUG?

IIUC core cgroup will prevent a new task getting added to the cgroup
when we are in pre_destroy. Since we already check that the cgroup doesn't
have any task, the RES_USAGE cannot increase in pre_destroy.

-aneesh

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Crash when IO is being submitted and block size is changed

2012-07-18 Thread Mikulas Patocka


On Tue, 17 Jul 2012, Jeff Moyer wrote:

> Mikulas Patocka  writes:
> 
> > On Thu, 28 Jun 2012, Jan Kara wrote:
> >
> >> On Wed 27-06-12 23:04:09, Mikulas Patocka wrote:
> >> > The kernel crashes when IO is being submitted to a block device and 
> >> > block 
> >> > size of that device is changed simultaneously.
> >>   Nasty ;-)
> >> 
> >> > To reproduce the crash, apply this patch:
> >> > 
> >> > --- linux-3.4.3-fast.orig/fs/block_dev.c 2012-06-27 20:24:07.0 
> >> > +0200
> >> > +++ linux-3.4.3-fast/fs/block_dev.c 2012-06-27 20:28:34.0 +0200
> >> > @@ -28,6 +28,7 @@
> >> >  #include 
> >> >  #include 
> >> >  #include  
> >> > +#include 
> >> >  #include "internal.h"
> >> >  struct bdev_inode {
> >> > @@ -203,6 +204,7 @@ blkdev_get_blocks(struct inode *inode, s
> >> >  
> >> >  bh->b_bdev = I_BDEV(inode);
> >> >  bh->b_blocknr = iblock;
> >> > +msleep(1000);
> >> >  bh->b_size = max_blocks << inode->i_blkbits;
> >> >  if (max_blocks)
> >> >  set_buffer_mapped(bh);
> >> > 
> >> > Use some device with 4k blocksize, for example a ramdisk.
> >> > Run "dd if=/dev/ram0 of=/dev/null bs=4k count=1 iflag=direct"
> >> > While it is sleeping in the msleep function, run "blockdev --setbsz 2048 
> >> > /dev/ram0" on the other console.
> >> > You get a BUG at fs/direct-io.c:1013 - BUG_ON(this_chunk_bytes == 0);
> >> > 
> >> > 
> >> > One may ask "why would anyone do this - submit I/O and change block size 
> >> > simultaneously?" - the problem is that udev and lvm can scan and read 
> >> > all 
> >> > block devices anytime - so anytime you change block device size, there 
> >> > may 
> >> > be some i/o to that device in flight and the crash may happen. That BUG 
> >> > actually happened in production environment because of lvm scanning 
> >> > block 
> >> > devices and some other software changing block size at the same time.
> >> > 
> >>   Yeah, it's nasty and neither solution looks particularly appealing. One
> >> idea that came to my mind is: I'm trying to solve some races between direct
> >> IO, buffered IO, hole punching etc. by a new mapping interval lock. I'm not
> >> sure if it will go anywhere yet but if it does, we can fix the above race
> >> by taking the mapping lock for the whole block device around setting block
> >> size thus effectivelly disallowing any IO to it.
> >> 
> >>Honza
> >> -- 
> >> Jan Kara 
> >> SUSE Labs, CR
> >> 
> >
> > Hi
> >
> > This is the patch that fixes this crash: it takes a rw-semaphore around 
> > all direct-IO path.
> >
> > (note that if someone is concerned about performance, the rw-semaphore 
> > could be made per-cpu --- take it for read on the current CPU and take it 
> > for write on all CPUs).
> 
> Here we go again.  :-)  I believe we had at one point tried taking a rw
> semaphore around GUP inside of the direct I/O code path to fix the fork
> vs. GUP race (that still exists today).  When testing that, the overhead
> of the semaphore was *way* too high to be considered an acceptable
> solution.  I've CC'd Larry Woodman, Andrea, and Kosaki Motohiro who all
> worked on that particular bug.  Hopefully they can give better
> quantification of the slowdown than my poor memory.
> 
> Cheers,
> Jeff

Both down_read and up_read together take 82 ticks on Core2, 69 ticks on 
AMD K10, 62 ticks on UltraSparc2 if the target is in L1 cache. So, if 
percpu rw_semaphores were used, it would slow down only by this amount.

I hope that Linux developers are not so obsessed with performance that 
they want a fast crashing kernel rather than a slow reliable kernel. Note 
that anything that changes a device block size (for example mounting a 
filesystem with non-default block size) may trigger a crash if lvm or udev 
reads the device simultaneously; the crash really happened in business 
environment).

Mikulas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Re: [RFC][PATCH 2/4 v4] ftrace/x86: Add save_regs for i386 function calls

2012-07-18 Thread Masami Hiramatsu
(2012/07/19 0:59), Steven Rostedt wrote:
> On Fri, 2012-07-13 at 14:47 -0400, Steven Rostedt wrote:
> 
> Masami, can you give your Reviewed-by tag for this version? Or is there
> something else needing to be fixed?

No, that is OK for me. I've just missed that...

Reviewed-by: Masami Hiramatsu 

Thank you!

> 
> Thanks!
> 
> -- Steve
> 
>> From: Steven Rostedt 
>> Date: Tue, 5 Jun 2012 20:00:11 -0400
>> Subject: [PATCH] ftrace/x86: Add save_regs for i386 function calls
>>
>> Add saving full regs for function tracing on i386.
>> The saving of regs was influenced by patches sent out by
>> Masami Hiramatsu.
>>
>> Cc: Masami Hiramatsu 
>> Signed-off-by: Steven Rostedt 
>> ---
>>  arch/x86/include/asm/ftrace.h |2 -
>>  arch/x86/kernel/entry_32.S|   68 
>> +
>>  arch/x86/kernel/ftrace.c  |4 --
>>  3 files changed, 68 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
>> index a847501..a6cae0c 100644
>> --- a/arch/x86/include/asm/ftrace.h
>> +++ b/arch/x86/include/asm/ftrace.h
>> @@ -40,10 +40,8 @@
>>  
>>  #ifdef CONFIG_DYNAMIC_FTRACE
>>  #define ARCH_SUPPORTS_FTRACE_OPS 1
>> -#ifdef CONFIG_X86_64
>>  #define ARCH_SUPPORTS_FTRACE_SAVE_REGS
>>  #endif
>> -#endif
>>  
>>  #ifndef __ASSEMBLY__
>>  extern void mcount(void);
>> diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
>> index 5da11d1..46caa56 100644
>> --- a/arch/x86/kernel/entry_32.S
>> +++ b/arch/x86/kernel/entry_32.S
>> @@ -1123,6 +1123,7 @@ ftrace_call:
>>  popl %edx
>>  popl %ecx
>>  popl %eax
>> +ftrace_ret:
>>  #ifdef CONFIG_FUNCTION_GRAPH_TRACER
>>  .globl ftrace_graph_call
>>  ftrace_graph_call:
>> @@ -1134,6 +1135,73 @@ ftrace_stub:
>>  ret
>>  END(ftrace_caller)
>>  
>> +ENTRY(ftrace_regs_caller)
>> +pushf   /* push flags before compare (in cs location) */
>> +cmpl $0, function_trace_stop
>> +jne ftrace_restore_flags
>> +
>> +/*
>> + * i386 does not save SS and ESP when coming from kernel.
>> + * Instead, to get sp, >sp is used (see ptrace.h).
>> + * Unfortunately, that means eflags must be at the same location
>> + * as the current return ip is. We move the return ip into the
>> + * ip location, and move flags into the return ip location.
>> + */
>> +pushl 4(%esp)   /* save return ip into ip slot */
>> +subl $MCOUNT_INSN_SIZE, (%esp)  /* Adjust ip */
>> +
>> +pushl $0/* Load 0 into orig_ax */
>> +pushl %gs
>> +pushl %fs
>> +pushl %es
>> +pushl %ds
>> +pushl %eax
>> +pushl %ebp
>> +pushl %edi
>> +pushl %esi
>> +pushl %edx
>> +pushl %ecx
>> +pushl %ebx
>> +
>> +movl 13*4(%esp), %eax   /* Get the saved flags */
>> +movl %eax, 14*4(%esp)   /* Move saved flags into regs->flags location */
>> +/* clobbering return ip */
>> +movl $__KERNEL_CS,13*4(%esp)
>> +
>> +movl 12*4(%esp), %eax   /* Load ip (1st parameter) */
>> +movl 0x4(%ebp), %edx/* Load parent ip (2cd parameter) */
>> +lea  (%esp), %ecx
>> +pushl %ecx  /* Save pt_regs as 4th parameter */
>> +leal function_trace_op, %ecx /* Save ftrace_pos in 3rd parameter */
>> +
>> +GLOBAL(ftrace_regs_call)
>> +call ftrace_stub
>> +
>> +addl $4, %esp   /* Skip pt_regs */
>> +movl 14*4(%esp), %eax   /* Move flags back into cs */
>> +movl %eax, 13*4(%esp)   /* Needed to keep addl from modifying flags */
>> +movl 12*4(%esp), %eax   /* Get return ip from regs->ip */
>> +addl $MCOUNT_INSN_SIZE, %eax
>> +movl %eax, 14*4(%esp)   /* Put return ip back for ret */
>> +
>> +popl %ebx
>> +popl %ecx
>> +popl %edx
>> +popl %esi
>> +popl %edi
>> +popl %ebp
>> +popl %eax
>> +popl %ds
>> +popl %es
>> +popl %fs
>> +popl %gs
>> +addl $8, %esp   /* Skip orig_ax and ip */
>> +popf/* Pop flags at end (no addl to corrupt flags) 
>> */
>> +jmp ftrace_ret
>> +
>> +ftrace_restore_flags:
>> +popf
>> +jmp  ftrace_stub
>>  #else /* ! CONFIG_DYNAMIC_FTRACE */
>>  
>>  ENTRY(mcount)
>> diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
>> index b90eb1a..1d41402 100644
>> --- a/arch/x86/kernel/ftrace.c
>> +++ b/arch/x86/kernel/ftrace.c
>> @@ -206,7 +206,6 @@ static int
>>  ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
>> unsigned const char *new_code);
>>  
>> -#ifdef ARCH_SUPPORTS_FTRACE_SAVE_REGS
>>  /*
>>   * Should never be called:
>>   *  As it is only called by __ftrace_replace_code() which is called by
>> @@ -221,7 +220,6 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned 
>> long old_addr,
>>  WARN_ON(1);
>>  return -EINVAL;
>>  }
>> -#endif
>>  
>>  int ftrace_update_ftrace_func(ftrace_func_t func)
>>  {
>> @@ -237,7 +235,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
>>  
>>  ret = 

RE: 0xB16B00B5? Really? (was Re: Move hyperv out of the drivers/staging/ directory)

2012-07-18 Thread KY Srinivasan


> -Original Message-
> From: Paolo Bonzini [mailto:paolo.bonz...@gmail.com] On Behalf Of Paolo
> Bonzini
> Sent: Friday, July 13, 2012 6:23 AM
> To: KY Srinivasan
> Cc: Greg KH; de...@linuxdriverproject.org; linux-kernel@vger.kernel.org;
> virtualizat...@lists.osdl.org
> Subject: 0xB16B00B5? Really? (was Re: Move hyperv out of the drivers/staging/
> directory)
> 
> Il 04/10/2011 21:34, Greg KH ha scritto:
> > diff --git a/drivers/staging/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
> > similarity index 99%
> > rename from drivers/staging/hv/hyperv_vmbus.h
> > rename to drivers/hv/hyperv_vmbus.h
> > index 3d2d836..8261cb6 100644
> > --- a/drivers/staging/hv/hyperv_vmbus.h
> > +++ b/drivers/hv/hyperv_vmbus.h
> > @@ -28,8 +28,7 @@
> >  #include 
> >  #include 
> >  #include 
> > -
> > -#include "hyperv.h"
> > +#include 
> >
> >  /*
> >   * The below CPUID leaves are present if
> VersionAndFeatures.HypervisorPresent
> 
> git's rename detection snips away this gem:
> 
> +#define HV_LINUX_GUEST_ID_LO 0x
> +#define HV_LINUX_GUEST_ID_HI 0xB16B00B5
> +#define HV_LINUX_GUEST_ID(((u64)HV_LINUX_GUEST_ID_HI
> << 32) | \
> +HV_LINUX_GUEST_ID_LO)
> 
> Somone was trying to be funny, I guess.
> 
> KY, I suppose you have access to Hyper-V code or can ask someone who does.
> Is this signature actually used in the Hyper-V host code?

Paolo,

As I noted earlier, this is just a guest ID that needs to be registered with the
hypervisor.  Thanks  for reporting this issue and on behalf of Microsoft, I 
would
like to  apologize for this offensive string. I have submitted a patch to fix 
this issue. 

Regards,

K. Y  
 



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] PM / Sleep: call early resume handlers when suspend_noirq fails

2012-07-18 Thread Colin Cross
Commit cf579dfb82550e34de7ccf3ef090d8b834ccd3a9 (PM / Sleep: Introduce
"late suspend" and "early resume" of devices) introduced a bug where
suspend_late handlers would be called, but if dpm_suspend_noirq returned
an error the early_resume handlers would never be called.  All devices
would end up on the dpm_late_early_list, and would never be resumed
again.

Fix it by calling dpm_resume_early when dpm_suspend_noirq returns
an error.

Signed-off-by: Colin Cross 
---
 drivers/base/power/main.c |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 9cb845e..742fcbe 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -989,8 +989,16 @@ static int dpm_suspend_late(pm_message_t state)
 int dpm_suspend_end(pm_message_t state)
 {
int error = dpm_suspend_late(state);
+   if (error)
+   return error;
 
-   return error ? : dpm_suspend_noirq(state);
+   error = dpm_suspend_noirq(state);
+   if (error) {
+   dpm_resume_early(state);
+   return error;
+   }
+
+   return 0;
 }
 EXPORT_SYMBOL_GPL(dpm_suspend_end);
 
-- 
1.7.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 90/90] staging: comedi: s526: remove unused variables in the private data

2012-07-18 Thread H Hartley Sweeten
The 'data' and 'pci_dev' variables in the private data are not used.
They appear to be cut-and-paste from the skel driver. Remove them.

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

diff --git a/drivers/staging/comedi/drivers/s526.c 
b/drivers/staging/comedi/drivers/s526.c
index 358380f..737a194 100644
--- a/drivers/staging/comedi/drivers/s526.c
+++ b/drivers/staging/comedi/drivers/s526.c
@@ -206,15 +206,7 @@ static const struct s526_board s526_boards[] = {
struct.
 */
 struct s526_private {
-
-   int data;
-
-   /* would be useful for a PCI device */
-   struct pci_dev *pci_dev;
-
-   /* Used for AO readback */
unsigned int ao_readback[2];
-
struct s526GPCTConfig s526_gpct_config[4];
unsigned short s526_ai_config;
 };
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 89/90] staging: comedi: aio_iiro_16: remove the private data

2012-07-18 Thread H Hartley Sweeten
The private data is not used by this driver. Remove the struct,
devpriv macro, and the allocation.

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

diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c 
b/drivers/staging/comedi/drivers/aio_iiro_16.c
index 16f28f6..ba1e3bb 100644
--- a/drivers/staging/comedi/drivers/aio_iiro_16.c
+++ b/drivers/staging/comedi/drivers/aio_iiro_16.c
@@ -57,14 +57,6 @@ static const struct aio_iiro_16_board aio_iiro_16_boards[] = 
{
 .do_ = 16},
 };
 
-struct aio_iiro_16_private {
-   int data;
-   struct pci_dev *pci_dev;
-   unsigned int ao_readback[2];
-};
-
-#definedevpriv ((struct aio_iiro_16_private *) dev->private)
-
 static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
   struct comedi_subdevice *s,
   struct comedi_insn *insn,
@@ -116,9 +108,6 @@ static int aio_iiro_16_attach(struct comedi_device *dev,
 
dev->iobase = iobase;
 
-   if (alloc_private(dev, sizeof(struct aio_iiro_16_private)) < 0)
-   return -ENOMEM;
-
ret = comedi_alloc_subdevices(dev, 2);
if (ret)
return ret;
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 88/90] staging: comedi: rtd520: store the pci_dev in the comedi_device

2012-07-18 Thread H Hartley Sweeten
Use the hw_dev pointer in the comedi_device struct to hold the
pci_dev instead of carrying it in the private data.

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

diff --git a/drivers/staging/comedi/drivers/rtd520.c 
b/drivers/staging/comedi/drivers/rtd520.c
index d1753e2..112fdc3 100644
--- a/drivers/staging/comedi/drivers/rtd520.c
+++ b/drivers/staging/comedi/drivers/rtd520.c
@@ -310,9 +310,6 @@ struct rtdPrivate {
int transCount; /* # to transfer data. 0->1/2FIFO */
int flags;  /* flag event modes */
 
-   /* PCI device info */
-   struct pci_dev *pci_dev;
-
/* channel list info */
/* chanBipolar tracks whether a channel is bipolar (and needs +2048) */
unsigned char chanBipolar[RTD_MAX_CHANLIST / 8];/* bit array */
@@ -1620,6 +1617,7 @@ static int rtd_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
 {  /* board name and options flags */
const struct rtdBoard *thisboard;
struct rtdPrivate *devpriv;
+   struct pci_dev *pcidev;
struct comedi_subdevice *s;
int ret;
resource_size_t physLas1;   /* data area */
@@ -1644,14 +1642,15 @@ static int rtd_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
return -ENOMEM;
devpriv = dev->private;
 
-   devpriv->pci_dev = rtd_find_pci(dev, it);
-   if (!devpriv->pci_dev)
+   pcidev = rtd_find_pci(dev, it);
+   if (!pcidev)
return -EIO;
+   comedi_set_hw_dev(dev, >dev);
thisboard = comedi_board(dev);
 
dev->board_name = thisboard->name;
 
-   ret = comedi_pci_enable(devpriv->pci_dev, DRV_NAME);
+   ret = comedi_pci_enable(pcidev, DRV_NAME);
if (ret < 0) {
printk(KERN_INFO "Failed to enable PCI device and request 
regions.\n");
return ret;
@@ -1661,9 +1660,9 @@ static int rtd_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
 * Initialize base addresses
 */
/* Get the physical address from PCI config */
-   dev->iobase = pci_resource_start(devpriv->pci_dev, LAS0_PCIINDEX);
-   physLas1 = pci_resource_start(devpriv->pci_dev, LAS1_PCIINDEX);
-   physLcfg = pci_resource_start(devpriv->pci_dev, LCFG_PCIINDEX);
+   dev->iobase = pci_resource_start(pcidev, LAS0_PCIINDEX);
+   physLas1 = pci_resource_start(pcidev, LAS1_PCIINDEX);
+   physLcfg = pci_resource_start(pcidev, LCFG_PCIINDEX);
/* Now have the kernel map this into memory */
/* ASSUME page aligned */
devpriv->las0 = ioremap_nocache(dev->iobase, LAS0_PCISIZE);
@@ -1678,16 +1677,16 @@ static int rtd_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
u16 revision;
/*uint32_t epld_version; */
 
-   pci_read_config_word(devpriv->pci_dev, PCI_REVISION_ID,
+   pci_read_config_word(pcidev, PCI_REVISION_ID,
 );
DPRINTK("%s: PCI revision %d.\n", dev->board_name, revision);
 
-   pci_read_config_byte(devpriv->pci_dev,
+   pci_read_config_byte(pcidev,
 PCI_LATENCY_TIMER, _latency);
if (pci_latency < 32) {
printk(KERN_INFO "%s: PCI latency changed from %d to 
%d\n",
   dev->board_name, pci_latency, 32);
-   pci_write_config_byte(devpriv->pci_dev,
+   pci_write_config_byte(pcidev,
  PCI_LATENCY_TIMER, 32);
} else {
DPRINTK("rtd520: PCI latency = %d\n", pci_latency);
@@ -1790,15 +1789,15 @@ static int rtd_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
/* TODO: set user out source ??? */
 
/* check if our interrupt is available and get it */
-   ret = request_irq(devpriv->pci_dev->irq, rtd_interrupt,
+   ret = request_irq(pcidev->irq, rtd_interrupt,
  IRQF_SHARED, DRV_NAME, dev);
 
if (ret < 0) {
printk("Could not get interrupt! (%u)\n",
-  devpriv->pci_dev->irq);
+  pcidev->irq);
return ret;
}
-   dev->irq = devpriv->pci_dev->irq;
+   dev->irq = pcidev->irq;
printk(KERN_INFO "( irq=%u )", dev->irq);
 
ret = rtd520_probe_fifo_depth(dev);
@@ -1820,7 +1819,7 @@ static int rtd_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
 
for (index = 0; index < DMA_CHAIN_COUNT; index++) {
devpriv->dma0Buff[index] =
-   pci_alloc_consistent(devpriv->pci_dev,
+   

[PATCH 87/90] staging: comedi: rtd520: remove the '#if 0' code in the attach

2012-07-18 Thread H Hartley Sweeten
This driver has code #if 0'ed out that would allow cleaning up
the attach if there was an error. The comedi core currently
calls the detach function to do this if the attach fails.

Remove the #if 0'ed out code.

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

diff --git a/drivers/staging/comedi/drivers/rtd520.c 
b/drivers/staging/comedi/drivers/rtd520.c
index aeccae9..d1753e2 100644
--- a/drivers/staging/comedi/drivers/rtd520.c
+++ b/drivers/staging/comedi/drivers/rtd520.c
@@ -1886,52 +1886,6 @@ static int rtd_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
printk("\ncomedi%d: rtd520 driver attached.\n", dev->minor);
 
return 1;
-
-#if 0
-   /* hit an error, clean up memory and return ret */
-/* rtd_attach_die_error: */
-#ifdef USE_DMA
-   for (index = 0; index < DMA_CHAIN_COUNT; index++) {
-   if (NULL != devpriv->dma0Buff[index]) { /* free buffer memory */
-   pci_free_consistent(devpriv->pci_dev,
-   sizeof(u16) * devpriv->fifoLen / 2,
-   devpriv->dma0Buff[index],
-   devpriv->dma0BuffPhysAddr[index]);
-   devpriv->dma0Buff[index] = NULL;
-   }
-   }
-   if (NULL != devpriv->dma0Chain) {
-   pci_free_consistent(devpriv->pci_dev,
-   sizeof(struct plx_dma_desc)
-   * DMA_CHAIN_COUNT,
-   devpriv->dma0Chain,
-   devpriv->dma0ChainPhysAddr);
-   devpriv->dma0Chain = NULL;
-   }
-#endif /* USE_DMA */
-   /* subdevices and priv are freed by the core */
-   if (dev->irq) {
-   writel(readl(devpriv->lcfg + LCFG_ITCSR) &
-   ~(ICS_PLIE | ICS_DMA0_E | ICS_DMA1_E),
-   devpriv->lcfg + LCFG_ITCSR);
-   free_irq(dev->irq, dev);
-   }
-
-   /* release all regions that were allocated */
-   if (devpriv->las0)
-   iounmap(devpriv->las0);
-
-   if (devpriv->las1)
-   iounmap(devpriv->las1);
-
-   if (devpriv->lcfg)
-   iounmap(devpriv->lcfg);
-
-   if (devpriv->pci_dev)
-   pci_dev_put(devpriv->pci_dev);
-
-   return ret;
-#endif
 }
 
 static void rtd_detach(struct comedi_device *dev)
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 86/90] staging: comedi: rtd520: remove 'got_regions' from private data

2012-07-18 Thread H Hartley Sweeten
The 'got_regions' variable in the private data is used as a flag
for the detach to know if the pci device has been enabled.

Typically the dev->iobase variable is used to indicate this in
all the other comedi drivers. Do the same here for consistancy.

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

diff --git a/drivers/staging/comedi/drivers/rtd520.c 
b/drivers/staging/comedi/drivers/rtd520.c
index 02be4dd..aeccae9 100644
--- a/drivers/staging/comedi/drivers/rtd520.c
+++ b/drivers/staging/comedi/drivers/rtd520.c
@@ -312,7 +312,6 @@ struct rtdPrivate {
 
/* PCI device info */
struct pci_dev *pci_dev;
-   int got_regions;/* non-zero if PCI regions owned */
 
/* channel list info */
/* chanBipolar tracks whether a channel is bipolar (and needs +2048) */
@@ -1623,7 +1622,6 @@ static int rtd_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
struct rtdPrivate *devpriv;
struct comedi_subdevice *s;
int ret;
-   resource_size_t physLas0;   /* configuration */
resource_size_t physLas1;   /* data area */
resource_size_t physLcfg;   /* PLX9080 */
 #ifdef USE_DMA
@@ -1658,18 +1656,17 @@ static int rtd_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
printk(KERN_INFO "Failed to enable PCI device and request 
regions.\n");
return ret;
}
-   devpriv->got_regions = 1;
 
/*
 * Initialize base addresses
 */
/* Get the physical address from PCI config */
-   physLas0 = pci_resource_start(devpriv->pci_dev, LAS0_PCIINDEX);
+   dev->iobase = pci_resource_start(devpriv->pci_dev, LAS0_PCIINDEX);
physLas1 = pci_resource_start(devpriv->pci_dev, LAS1_PCIINDEX);
physLcfg = pci_resource_start(devpriv->pci_dev, LCFG_PCIINDEX);
/* Now have the kernel map this into memory */
/* ASSUME page aligned */
-   devpriv->las0 = ioremap_nocache(physLas0, LAS0_PCISIZE);
+   devpriv->las0 = ioremap_nocache(dev->iobase, LAS0_PCISIZE);
devpriv->las1 = ioremap_nocache(physLas1, LAS1_PCISIZE);
devpriv->lcfg = ioremap_nocache(physLcfg, LCFG_PCISIZE);
 
@@ -2000,7 +1997,7 @@ static void rtd_detach(struct comedi_device *dev)
if (devpriv->lcfg)
iounmap(devpriv->lcfg);
if (devpriv->pci_dev) {
-   if (devpriv->got_regions)
+   if (dev->iobase)
comedi_pci_disable(devpriv->pci_dev);
pci_dev_put(devpriv->pci_dev);
}
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 84/90] staging: comedi: me_daq: store the pci_dev in the comedi_device

2012-07-18 Thread H Hartley Sweeten
Use the hw_dev pointer in the comedi_device struct to hold the
pci_dev instead of carrying it in the private data.

Since the pci_dev was the only thing in the private data, remove
the struct, the devpriv macro, and it's allocation.

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

diff --git a/drivers/staging/comedi/drivers/me_daq.c 
b/drivers/staging/comedi/drivers/me_daq.c
index cd66af9..8c6f8b9 100644
--- a/drivers/staging/comedi/drivers/me_daq.c
+++ b/drivers/staging/comedi/drivers/me_daq.c
@@ -233,7 +233,6 @@ static const struct me_board me_boards[] = {
 
 /* Private data structure */
 struct me_private_data {
-   struct pci_dev *pci_device;
void __iomem *plx_regbase;  /* PLX configuration base address */
void __iomem *me_regbase;   /* Base address of the Meilhaus card */
unsigned long plx_regbase_size; /* Size of PLX configuration space */
@@ -662,7 +661,7 @@ static int me_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
pci_device = me_find_pci_dev(dev, it);
if (!pci_device)
return -EIO;
-   dev_private->pci_device = pci_device;
+   comedi_set_hw_dev(dev, _device->dev);
board = (struct me_board *)dev->board_ptr;
 
/* Enable PCI device and request PCI regions */
@@ -799,6 +798,8 @@ static int me_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
 
 static void me_detach(struct comedi_device *dev)
 {
+   struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
if (dev_private) {
if (dev_private->me_regbase) {
me_reset(dev);
@@ -806,11 +807,11 @@ static void me_detach(struct comedi_device *dev)
}
if (dev_private->plx_regbase)
iounmap(dev_private->plx_regbase);
-   if (dev_private->pci_device) {
-   if (dev_private->plx_regbase_size)
-   comedi_pci_disable(dev_private->pci_device);
-   pci_dev_put(dev_private->pci_device);
-   }
+   }
+   if (pcidev) {
+   if (dev_private->plx_regbase_size)
+   comedi_pci_disable(pcidev);
+   pci_dev_put(pcidev);
}
 }
 
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 85/90] staging: comedi: rtd520: remove the debug print of the pci addresses

2012-07-18 Thread H Hartley Sweeten
This is just noise.

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

diff --git a/drivers/staging/comedi/drivers/rtd520.c 
b/drivers/staging/comedi/drivers/rtd520.c
index 9998d6b..02be4dd 100644
--- a/drivers/staging/comedi/drivers/rtd520.c
+++ b/drivers/staging/comedi/drivers/rtd520.c
@@ -1676,10 +1676,6 @@ static int rtd_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
if (!devpriv->las0 || !devpriv->las1 || !devpriv->lcfg)
return -ENOMEM;
 
-
-   DPRINTK("%s: LAS0=%llx, LAS1=%llx, CFG=%llx.\n", dev->board_name,
-   (unsigned long long)physLas0, (unsigned long long)physLas1,
-   (unsigned long long)physLcfg);
{   /* The RTD driver does this */
unsigned char pci_latency;
u16 revision;
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 83/90] staging: comedi: me_daq: cleanup "find pci device" code

2012-07-18 Thread H Hartley Sweeten
Cleanup the "find pci device" code so that it follows the style
of the other comedi pci drivers.

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

diff --git a/drivers/staging/comedi/drivers/me_daq.c 
b/drivers/staging/comedi/drivers/me_daq.c
index dc0fbbd..cd66af9 100644
--- a/drivers/staging/comedi/drivers/me_daq.c
+++ b/drivers/staging/comedi/drivers/me_daq.c
@@ -231,8 +231,6 @@ static const struct me_board me_boards[] = {
 }
 };
 
-#define me_board_nbr (sizeof(me_boards)/sizeof(struct me_board))
-
 /* Private data structure */
 struct me_private_data {
struct pci_dev *pci_device;
@@ -613,49 +611,34 @@ static int me_reset(struct comedi_device *dev)
 static struct pci_dev *me_find_pci_dev(struct comedi_device *dev,
   struct comedi_devconfig *it)
 {
-   struct pci_dev *pci_device = NULL;
+   const struct me_board *board;
+   struct pci_dev *pcidev = NULL;
+   int bus = it->options[0];
+   int slot = it->options[1];
int i;
 
-   /* Probe the device to determine what device in the series it is. */
-   for_each_pci_dev(pci_device) {
-   if (pci_device->vendor == PCI_VENDOR_ID_MEILHAUS) {
-   for (i = 0; i < me_board_nbr; i++) {
-   if (me_boards[i].device_id ==
-   pci_device->device) {
-   /*
-* was a particular bus/slot requested?
-*/
-   if ((it->options[0] != 0)
-   || (it->options[1] != 0)) {
-   /*
-* are we on the wrong bus/slot?
-*/
-   if (pci_device->bus->number !=
-   it->options[0]
-   ||
-   PCI_SLOT(pci_device->devfn)
-   != it->options[1]) {
-   continue;
-   }
-   }
-
-   dev->board_ptr = me_boards + i;
-   goto found;
-   }
-   }
+   for_each_pci_dev(pcidev) {
+   if (bus || slot) {
+   if (pcidev->bus->number != bus ||
+   PCI_SLOT(pcidev->devfn) != slot)
+   continue;
}
-   }
+   if (pcidev->vendor != PCI_VENDOR_ID_MEILHAUS)
+   continue;
 
-   printk(KERN_ERR
-  "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
-  dev->minor, it->options[0], it->options[1]);
-   return NULL;
+   for (i = 0; i < ARRAY_SIZE(me_boards); i++) {
+   board = _boards[i];
+   if (board->device_id != pcidev->device)
+   continue;
 
-found:
-   printk(KERN_INFO "comedi%d: found %s at PCI bus %d, slot %d\n",
-  dev->minor, me_boards[i].name,
-  pci_device->bus->number, PCI_SLOT(pci_device->devfn));
-   return pci_device;
+   dev->board_ptr = board;
+   return pcidev;
+   }
+   }
+   dev_err(dev->class_dev,
+   "No supported board found! (req. bus %d, slot %d)\n",
+   bus, slot);
+   return NULL;
 }
 
 static int me_attach(struct comedi_device *dev, struct comedi_devconfig *it)
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 82/90] staging: comedi: me_daq: factor out the "find pci device" code

2012-07-18 Thread H Hartley Sweeten
Factor the "find pci device" code out of the attach function.

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

diff --git a/drivers/staging/comedi/drivers/me_daq.c 
b/drivers/staging/comedi/drivers/me_daq.c
index 1803d66..dc0fbbd 100644
--- a/drivers/staging/comedi/drivers/me_daq.c
+++ b/drivers/staging/comedi/drivers/me_daq.c
@@ -610,23 +610,11 @@ static int me_reset(struct comedi_device *dev)
return 0;
 }
 
-static int me_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static struct pci_dev *me_find_pci_dev(struct comedi_device *dev,
+  struct comedi_devconfig *it)
 {
struct pci_dev *pci_device = NULL;
-   struct comedi_subdevice *subdevice;
-   struct me_board *board;
-   resource_size_t plx_regbase_tmp;
-   unsigned long plx_regbase_size_tmp;
-   resource_size_t me_regbase_tmp;
-   unsigned long me_regbase_size_tmp;
-   resource_size_t swap_regbase_tmp;
-   unsigned long swap_regbase_size_tmp;
-   resource_size_t regbase_tmp;
-   int result, error, i;
-
-   /* Allocate private memory */
-   if (alloc_private(dev, sizeof(struct me_private_data)) < 0)
-   return -ENOMEM;
+   int i;
 
/* Probe the device to determine what device in the series it is. */
for_each_pci_dev(pci_device) {
@@ -652,9 +640,6 @@ static int me_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
}
 
dev->board_ptr = me_boards + i;
-   board =
-   (struct me_board *)dev->board_ptr;
-   dev_private->pci_device = pci_device;
goto found;
}
}
@@ -664,12 +649,38 @@ static int me_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
printk(KERN_ERR
   "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
   dev->minor, it->options[0], it->options[1]);
-   return -EIO;
+   return NULL;
 
 found:
printk(KERN_INFO "comedi%d: found %s at PCI bus %d, slot %d\n",
   dev->minor, me_boards[i].name,
   pci_device->bus->number, PCI_SLOT(pci_device->devfn));
+   return pci_device;
+}
+
+static int me_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{
+   struct pci_dev *pci_device;
+   struct comedi_subdevice *subdevice;
+   struct me_board *board;
+   resource_size_t plx_regbase_tmp;
+   unsigned long plx_regbase_size_tmp;
+   resource_size_t me_regbase_tmp;
+   unsigned long me_regbase_size_tmp;
+   resource_size_t swap_regbase_tmp;
+   unsigned long swap_regbase_size_tmp;
+   resource_size_t regbase_tmp;
+   int result, error;
+
+   /* Allocate private memory */
+   if (alloc_private(dev, sizeof(struct me_private_data)) < 0)
+   return -ENOMEM;
+
+   pci_device = me_find_pci_dev(dev, it);
+   if (!pci_device)
+   return -EIO;
+   dev_private->pci_device = pci_device;
+   board = (struct me_board *)dev->board_ptr;
 
/* Enable PCI device and request PCI regions */
if (comedi_pci_enable(pci_device, ME_DRIVER_NAME) < 0) {
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 80/90] staging: comedi: ke_counter: store the pci_dev in the comedi_device

2012-07-18 Thread H Hartley Sweeten
Use the hw_dev pointer in the comedi_device struct to hold the
pci_dev instead of carrying it in the private data.

Since the pci_dev was the only thing in the private data, remove
the struct, the devpriv macro, and it's allocation.

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

diff --git a/drivers/staging/comedi/drivers/ke_counter.c 
b/drivers/staging/comedi/drivers/ke_counter.c
index 78eb8d4..4153977 100644
--- a/drivers/staging/comedi/drivers/ke_counter.c
+++ b/drivers/staging/comedi/drivers/ke_counter.c
@@ -64,15 +64,6 @@ static const struct cnt_board_struct cnt_boards[] = {
 
 #define cnt_board_nbr (sizeof(cnt_boards)/sizeof(struct cnt_board_struct))
 
-/*-- device private structure ---*/
-
-struct cnt_device_private {
-
-   struct pci_dev *pcidev;
-};
-
-#define devpriv ((struct cnt_device_private *)dev->private)
-
 /*-- counter write --*/
 
 /* This should be used only for resetting the counters; maybe it is better
@@ -164,15 +155,10 @@ static int cnt_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
unsigned long io_base;
int error;
 
-   /* allocate device private structure */
-   error = alloc_private(dev, sizeof(struct cnt_device_private));
-   if (error < 0)
-   return error;
-
pcidev = cnt_find_pci_dev(dev, it);
if (!pcidev)
return -EIO;
-   devpriv->pcidev = pcidev;
+   comedi_set_hw_dev(dev, >dev);
board = comedi_board(dev);
 
dev->board_name = board->name;
@@ -219,10 +205,12 @@ static int cnt_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
 
 static void cnt_detach(struct comedi_device *dev)
 {
-   if (devpriv && devpriv->pcidev) {
+   struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+   if (pcidev) {
if (dev->iobase)
-   comedi_pci_disable(devpriv->pcidev);
-   pci_dev_put(devpriv->pcidev);
+   comedi_pci_disable(pcidev);
+   pci_dev_put(pcidev);
}
 }
 
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 81/90] staging: comedi: ke_counter: remove the cnt_board_nbr macro

2012-07-18 Thread H Hartley Sweeten
This macro is an open-coded version of ARRAY_SIZE(). Use that
instead.

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

diff --git a/drivers/staging/comedi/drivers/ke_counter.c 
b/drivers/staging/comedi/drivers/ke_counter.c
index 4153977..d4e9292 100644
--- a/drivers/staging/comedi/drivers/ke_counter.c
+++ b/drivers/staging/comedi/drivers/ke_counter.c
@@ -62,8 +62,6 @@ static const struct cnt_board_struct cnt_boards[] = {
 .cnt_bits = 24}
 };
 
-#define cnt_board_nbr (sizeof(cnt_boards)/sizeof(struct cnt_board_struct))
-
 /*-- counter write --*/
 
 /* This should be used only for resetting the counters; maybe it is better
@@ -132,7 +130,7 @@ static struct pci_dev *cnt_find_pci_dev(struct 
comedi_device *dev,
if (pcidev->vendor != PCI_VENDOR_ID_KOLTER)
continue;
 
-   for (i = 0; i < cnt_board_nbr; i++) {
+   for (i = 0; i < ARRAY_SIZE(cnt_boards); i++) {
board = _boards[i];
if (board->device_id != pcidev->device)
continue;
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 79/90] staging: comedi: ke_counter: minor cleanup of cnt_attach()

2012-07-18 Thread H Hartley Sweeten
Cleanup the attach function a bit to follow the style of
the other comedi pci drivers.

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

diff --git a/drivers/staging/comedi/drivers/ke_counter.c 
b/drivers/staging/comedi/drivers/ke_counter.c
index 826e6c2..78eb8d4 100644
--- a/drivers/staging/comedi/drivers/ke_counter.c
+++ b/drivers/staging/comedi/drivers/ke_counter.c
@@ -158,9 +158,9 @@ static struct pci_dev *cnt_find_pci_dev(struct 
comedi_device *dev,
 
 static int cnt_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
-   struct pci_dev *pci_device;
+   const struct cnt_board_struct *board;
+   struct pci_dev *pcidev;
struct comedi_subdevice *subdevice;
-   struct cnt_board_struct *board;
unsigned long io_base;
int error;
 
@@ -169,16 +169,16 @@ static int cnt_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
if (error < 0)
return error;
 
-   pci_device = cnt_find_pci_dev(dev, it);
-   if (!pci_device)
+   pcidev = cnt_find_pci_dev(dev, it);
+   if (!pcidev)
return -EIO;
-   devpriv->pcidev = pci_device;
-   board = (struct cnt_board_struct *)dev->board_ptr;
+   devpriv->pcidev = pcidev;
+   board = comedi_board(dev);
 
dev->board_name = board->name;
 
/* enable PCI device and request regions */
-   error = comedi_pci_enable(pci_device, CNT_DRIVER_NAME);
+   error = comedi_pci_enable(pcidev, CNT_DRIVER_NAME);
if (error < 0) {
printk(KERN_WARNING "comedi%d: "
   "failed to enable PCI device and request regions!\n",
@@ -187,7 +187,7 @@ static int cnt_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
}
 
/* read register base address [PCI_BASE_ADDRESS #0] */
-   io_base = pci_resource_start(pci_device, 0);
+   io_base = pci_resource_start(pcidev, 0);
dev->iobase = io_base;
 
error = comedi_alloc_subdevices(dev, 1);
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 78/90] staging: comedi: ke_counter: cleanup "find pci device" code

2012-07-18 Thread H Hartley Sweeten
Cleanup the "find pci device" code so that it follows the style
of the other comedi pci drivers.

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

diff --git a/drivers/staging/comedi/drivers/ke_counter.c 
b/drivers/staging/comedi/drivers/ke_counter.c
index f0b8652..826e6c2 100644
--- a/drivers/staging/comedi/drivers/ke_counter.c
+++ b/drivers/staging/comedi/drivers/ke_counter.c
@@ -125,49 +125,35 @@ static int cnt_rinsn(struct comedi_device *dev,
 static struct pci_dev *cnt_find_pci_dev(struct comedi_device *dev,
struct comedi_devconfig *it)
 {
-   struct cnt_board_struct *board;
-   struct pci_dev *pci_device = NULL;
+   const struct cnt_board_struct *board;
+   struct pci_dev *pcidev = NULL;
+   int bus = it->options[0];
+   int slot = it->options[1];
int i;
 
/* Probe the device to determine what device in the series it is. */
-   for_each_pci_dev(pci_device) {
-   if (pci_device->vendor == PCI_VENDOR_ID_KOLTER) {
-   for (i = 0; i < cnt_board_nbr; i++) {
-   if (cnt_boards[i].device_id ==
-   pci_device->device) {
-   /* was a particular bus/slot requested? 
*/
-   if ((it->options[0] != 0)
-   || (it->options[1] != 0)) {
-   /* are we on the wrong 
bus/slot? */
-   if (pci_device->bus->number !=
-   it->options[0]
-   ||
-   PCI_SLOT(pci_device->devfn)
-   != it->options[1]) {
-   continue;
-   }
-   }
-
-   dev->board_ptr = cnt_boards + i;
-   board =
-   (struct cnt_board_struct *)
-   dev->board_ptr;
-   goto found;
-   }
-   }
+   for_each_pci_dev(pcidev) {
+   if (bus || slot) {
+   if (pcidev->bus->number != bus ||
+   PCI_SLOT(pcidev->devfn) != slot)
+   continue;
+   }
+   if (pcidev->vendor != PCI_VENDOR_ID_KOLTER)
+   continue;
+
+   for (i = 0; i < cnt_board_nbr; i++) {
+   board = _boards[i];
+   if (board->device_id != pcidev->device)
+   continue;
+
+   dev->board_ptr = board;
+   return pcidev;
}
}
-   printk(KERN_WARNING
-  "comedi%d: no supported board found! (req. bus/slot: %d/%d)\n",
-  dev->minor, it->options[0], it->options[1]);
+   dev_err(dev->class_dev,
+   "No supported board found! (req. bus %d, slot %d)\n",
+   bus, slot);
return NULL;
-
-found:
-   printk(KERN_INFO
-  "comedi%d: found %s at PCI bus %d, slot %d\n", dev->minor,
-  board->name, pci_device->bus->number,
-  PCI_SLOT(pci_device->devfn));
-   return pci_device;
 }
 
 static int cnt_attach(struct comedi_device *dev, struct comedi_devconfig *it)
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 77/90] staging: comedi: ke_counter: factor out the "find pci device" code

2012-07-18 Thread H Hartley Sweeten
Factor the "find pci device" code out of the attach function.

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

diff --git a/drivers/staging/comedi/drivers/ke_counter.c 
b/drivers/staging/comedi/drivers/ke_counter.c
index 019e91a..f0b8652 100644
--- a/drivers/staging/comedi/drivers/ke_counter.c
+++ b/drivers/staging/comedi/drivers/ke_counter.c
@@ -122,18 +122,12 @@ static int cnt_rinsn(struct comedi_device *dev,
return 1;
 }
 
-static int cnt_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static struct pci_dev *cnt_find_pci_dev(struct comedi_device *dev,
+   struct comedi_devconfig *it)
 {
-   struct comedi_subdevice *subdevice;
-   struct pci_dev *pci_device = NULL;
struct cnt_board_struct *board;
-   unsigned long io_base;
-   int error, i;
-
-   /* allocate device private structure */
-   error = alloc_private(dev, sizeof(struct cnt_device_private));
-   if (error < 0)
-   return error;
+   struct pci_dev *pci_device = NULL;
+   int i;
 
/* Probe the device to determine what device in the series it is. */
for_each_pci_dev(pci_device) {
@@ -166,14 +160,35 @@ static int cnt_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
printk(KERN_WARNING
   "comedi%d: no supported board found! (req. bus/slot: %d/%d)\n",
   dev->minor, it->options[0], it->options[1]);
-   return -EIO;
+   return NULL;
 
 found:
printk(KERN_INFO
   "comedi%d: found %s at PCI bus %d, slot %d\n", dev->minor,
   board->name, pci_device->bus->number,
   PCI_SLOT(pci_device->devfn));
+   return pci_device;
+}
+
+static int cnt_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{
+   struct pci_dev *pci_device;
+   struct comedi_subdevice *subdevice;
+   struct cnt_board_struct *board;
+   unsigned long io_base;
+   int error;
+
+   /* allocate device private structure */
+   error = alloc_private(dev, sizeof(struct cnt_device_private));
+   if (error < 0)
+   return error;
+
+   pci_device = cnt_find_pci_dev(dev, it);
+   if (!pci_device)
+   return -EIO;
devpriv->pcidev = pci_device;
+   board = (struct cnt_board_struct *)dev->board_ptr;
+
dev->board_name = board->name;
 
/* enable PCI device and request regions */
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 76/90] staging: comedi: dyna_pci10xx: fix detach

2012-07-18 Thread H Hartley Sweeten
The detach for this driver is missing the check to make sure
that the pci device is enabled before disabling it.

It's also missing the pci_dev_put().

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

diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c 
b/drivers/staging/comedi/drivers/dyna_pci10xx.c
index 6821f87..064be9a 100644
--- a/drivers/staging/comedi/drivers/dyna_pci10xx.c
+++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c
@@ -346,7 +346,9 @@ static void dyna_pci10xx_detach(struct comedi_device *dev)
if (devpriv)
mutex_destroy(>mutex);
if (pcidev) {
-   comedi_pci_disable(pcidev);
+   if (dev->iobase)
+   comedi_pci_disable(pcidev);
+   pci_dev_put(pcidev);
}
 }
 
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 75/90] staging: comedi: dyna_pci10xx: store the pci_dev in the comedi_device

2012-07-18 Thread H Hartley Sweeten
Use the hw_dev pointer in the comedi_device struct to hold the
pci_dev instead of carrying it in the private data.

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

diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c 
b/drivers/staging/comedi/drivers/dyna_pci10xx.c
index e7086b1..6821f87 100644
--- a/drivers/staging/comedi/drivers/dyna_pci10xx.c
+++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c
@@ -100,10 +100,7 @@ static const struct boardtype boardtypes[] = {
 };
 
 struct dyna_pci10xx_private {
-   struct pci_dev *pci_dev;/*  ptr to PCI device */
struct mutex mutex;
-
-   /* device base address registers */
unsigned long BADR3;
 };
 
@@ -273,7 +270,7 @@ static int dyna_pci10xx_attach(struct comedi_device *dev,
pcidev = dyna_pci10xx_find_pci_dev(dev, it);
if (!pcidev)
return -EIO;
-   devpriv->pci_dev = pcidev;
+   comedi_set_hw_dev(dev, >dev);
 
dev->board_name = thisboard->name;
dev->irq = 0;
@@ -344,9 +341,12 @@ static int dyna_pci10xx_attach(struct comedi_device *dev,
 
 static void dyna_pci10xx_detach(struct comedi_device *dev)
 {
-   if (devpriv && devpriv->pci_dev) {
-   comedi_pci_disable(devpriv->pci_dev);
+   struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+   if (devpriv)
mutex_destroy(>mutex);
+   if (pcidev) {
+   comedi_pci_disable(pcidev);
}
 }
 
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 74/90] staging: comedi: dyna_pci10xx: use dev->iobase

2012-07-18 Thread H Hartley Sweeten
Use dev->iobase to hold one of the pci base addresses used
by the driver instead of carrying it in the private data.

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

diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c 
b/drivers/staging/comedi/drivers/dyna_pci10xx.c
index 95ee422..e7086b1 100644
--- a/drivers/staging/comedi/drivers/dyna_pci10xx.c
+++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c
@@ -104,7 +104,7 @@ struct dyna_pci10xx_private {
struct mutex mutex;
 
/* device base address registers */
-   unsigned long BADR2, BADR3;
+   unsigned long BADR3;
 };
 
 #define thisboard ((const struct boardtype *)dev->board_ptr)
@@ -132,11 +132,11 @@ static int dyna_pci10xx_insn_read_ai(struct comedi_device 
*dev,
for (n = 0; n < insn->n; n++) {
/* trigger conversion */
smp_mb();
-   outw_p(0x + range + chan, devpriv->BADR2 + 2);
+   outw_p(0x + range + chan, dev->iobase + 2);
udelay(10);
/* read data */
for (counter = 0; counter < READ_TIMEOUT; counter++) {
-   d = inw_p(devpriv->BADR2);
+   d = inw_p(dev->iobase);
 
/* check if read is successful if the EOC bit is set */
if (d & (1 << 15))
@@ -172,7 +172,7 @@ static int dyna_pci10xx_insn_write_ao(struct comedi_device 
*dev,
for (n = 0; n < insn->n; n++) {
smp_mb();
/* trigger conversion and write data */
-   outw_p(data[n], devpriv->BADR2);
+   outw_p(data[n], dev->iobase);
udelay(10);
}
mutex_unlock(>mutex);
@@ -288,7 +288,7 @@ static int dyna_pci10xx_attach(struct comedi_device *dev,
 
printk(KERN_INFO "comedi: dyna_pci10xx: device found!\n");
 
-   devpriv->BADR2 = pci_resource_start(pcidev, 2);
+   dev->iobase = pci_resource_start(pcidev, 2);
devpriv->BADR3 = pci_resource_start(pcidev, 3);
 
ret = comedi_alloc_subdevices(dev, 4);
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 73/90] staging: comedi: dyna_pci10xx: remove unused bars from the private data

2012-07-18 Thread H Hartley Sweeten
All of the pci device base address registers are saved in the private
data but only bar2 and bar3 are used by the driver. Remove the others.

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

diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c 
b/drivers/staging/comedi/drivers/dyna_pci10xx.c
index 24c5cd2..95ee422 100644
--- a/drivers/staging/comedi/drivers/dyna_pci10xx.c
+++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c
@@ -104,7 +104,7 @@ struct dyna_pci10xx_private {
struct mutex mutex;
 
/* device base address registers */
-   unsigned long BADR0, BADR1, BADR2, BADR3, BADR4, BADR5;
+   unsigned long BADR2, BADR3;
 };
 
 #define thisboard ((const struct boardtype *)dev->board_ptr)
@@ -288,13 +288,8 @@ static int dyna_pci10xx_attach(struct comedi_device *dev,
 
printk(KERN_INFO "comedi: dyna_pci10xx: device found!\n");
 
-   /* initialize device base address registers */
-   devpriv->BADR0 = pci_resource_start(pcidev, 0);
-   devpriv->BADR1 = pci_resource_start(pcidev, 1);
devpriv->BADR2 = pci_resource_start(pcidev, 2);
devpriv->BADR3 = pci_resource_start(pcidev, 3);
-   devpriv->BADR4 = pci_resource_start(pcidev, 4);
-   devpriv->BADR5 = pci_resource_start(pcidev, 5);
 
ret = comedi_alloc_subdevices(dev, 4);
if (ret)
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 72/90] staging: comedi: dyna_pci10xx: remove 'valid' from the private data

2012-07-18 Thread H Hartley Sweeten
This variable is set at the end of the attach but never used
in the driver. Remove it.

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

diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c 
b/drivers/staging/comedi/drivers/dyna_pci10xx.c
index 82002c4..24c5cd2 100644
--- a/drivers/staging/comedi/drivers/dyna_pci10xx.c
+++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c
@@ -101,7 +101,6 @@ static const struct boardtype boardtypes[] = {
 
 struct dyna_pci10xx_private {
struct pci_dev *pci_dev;/*  ptr to PCI device */
-   char valid; /*  card is usable */
struct mutex mutex;
 
/* device base address registers */
@@ -342,8 +341,6 @@ static int dyna_pci10xx_attach(struct comedi_device *dev,
s->state = 0;
s->insn_bits = dyna_pci10xx_do_insn_bits;
 
-   devpriv->valid = 1;
-
printk(KERN_INFO "comedi: dyna_pci10xx: %s - device setup completed!\n",
thisboard->name);
 
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 71/90] staging: comedi: dyna_pci10xx: remove the 'start_stop_sem' mutex

2012-07-18 Thread H Hartley Sweeten
The comedi core already has a mutex protecting the attach/detach
of the comedi drivers.

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

diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c 
b/drivers/staging/comedi/drivers/dyna_pci10xx.c
index bd804f1..82002c4 100644
--- a/drivers/staging/comedi/drivers/dyna_pci10xx.c
+++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c
@@ -45,8 +45,6 @@
 
 #define READ_TIMEOUT 50
 
-static DEFINE_MUTEX(start_stop_sem);
-
 static const struct comedi_lrange range_pci1050_ai = { 3, {
  BIP_RANGE(10),
  BIP_RANGE(5),
@@ -267,20 +265,15 @@ static int dyna_pci10xx_attach(struct comedi_device *dev,
struct comedi_subdevice *s;
int ret;
 
-   mutex_lock(_stop_sem);
-
if (alloc_private(dev, sizeof(struct dyna_pci10xx_private)) < 0) {
printk(KERN_ERR "comedi: dyna_pci10xx: "
"failed to allocate memory!\n");
-   mutex_unlock(_stop_sem);
return -ENOMEM;
}
 
pcidev = dyna_pci10xx_find_pci_dev(dev, it);
-   if (!pcidev) {
-   mutex_unlock(_stop_sem);
+   if (!pcidev)
return -EIO;
-   }
devpriv->pci_dev = pcidev;
 
dev->board_name = thisboard->name;
@@ -289,7 +282,6 @@ static int dyna_pci10xx_attach(struct comedi_device *dev,
if (comedi_pci_enable(pcidev, DRV_NAME)) {
printk(KERN_ERR "comedi: dyna_pci10xx: "
"failed to enable PCI device and request regions!");
-   mutex_unlock(_stop_sem);
return -EIO;
}
 
@@ -306,10 +298,8 @@ static int dyna_pci10xx_attach(struct comedi_device *dev,
devpriv->BADR5 = pci_resource_start(pcidev, 5);
 
ret = comedi_alloc_subdevices(dev, 4);
-   if (ret) {
-   mutex_unlock(_stop_sem);
+   if (ret)
return ret;
-   }
 
/* analog input */
s = dev->subdevices + 0;
@@ -353,7 +343,6 @@ static int dyna_pci10xx_attach(struct comedi_device *dev,
s->insn_bits = dyna_pci10xx_do_insn_bits;
 
devpriv->valid = 1;
-   mutex_unlock(_stop_sem);
 
printk(KERN_INFO "comedi: dyna_pci10xx: %s - device setup completed!\n",
thisboard->name);
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 68/90] staging: comedi: dt3000: store the pci_dev in the comedi_device

2012-07-18 Thread H Hartley Sweeten
Use the hw_dev pointer in the comedi_device struct to hold the
pci_dev instead of carrying it in the private data.

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

diff --git a/drivers/staging/comedi/drivers/dt3000.c 
b/drivers/staging/comedi/drivers/dt3000.c
index 3937e87..a6fe6c9 100644
--- a/drivers/staging/comedi/drivers/dt3000.c
+++ b/drivers/staging/comedi/drivers/dt3000.c
@@ -248,8 +248,6 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
 #define DT3000_CHANNEL_MODE_DI 1
 
 struct dt3k_private {
-
-   struct pci_dev *pci_dev;
void __iomem *io_addr;
unsigned int lock;
unsigned int ao_readback[2];
@@ -817,7 +815,7 @@ static int dt3000_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
pcidev = dt3000_find_pci_dev(dev, it);
if (!pcidev)
return -EIO;
-   devpriv->pci_dev = pcidev;
+   comedi_set_hw_dev(dev, >dev);
 
ret = comedi_pci_enable(pcidev, "dt3000");
if (ret < 0)
@@ -900,17 +898,19 @@ static int dt3000_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
 
 static void dt3000_detach(struct comedi_device *dev)
 {
+   struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
if (dev->irq)
free_irq(dev->irq, dev);
if (devpriv) {
-   if (devpriv->pci_dev) {
-   if (dev->iobase)
-   comedi_pci_disable(devpriv->pci_dev);
-   pci_dev_put(devpriv->pci_dev);
-   }
if (devpriv->io_addr)
iounmap(devpriv->io_addr);
}
+   if (pcidev) {
+   if (dev->iobase)
+   comedi_pci_disable(pcidev);
+   pci_dev_put(pcidev);
+   }
 }
 
 static struct comedi_driver dt3000_driver = {
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 67/90] staging: comedi: dt3000: remove 'phys_addr' from the private data

2012-07-18 Thread H Hartley Sweeten
The 'phys_addr' variable in the private data is simply used as
a flag for the detach function to know that the pci device has
been enabled. Use the 'dev->iobase' variable instead as is more
typical for other comedi pci drivers.

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

diff --git a/drivers/staging/comedi/drivers/dt3000.c 
b/drivers/staging/comedi/drivers/dt3000.c
index 92558e7..3937e87 100644
--- a/drivers/staging/comedi/drivers/dt3000.c
+++ b/drivers/staging/comedi/drivers/dt3000.c
@@ -250,7 +250,6 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
 struct dt3k_private {
 
struct pci_dev *pci_dev;
-   resource_size_t phys_addr;
void __iomem *io_addr;
unsigned int lock;
unsigned int ao_readback[2];
@@ -824,8 +823,8 @@ static int dt3000_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
if (ret < 0)
return ret;
 
-   devpriv->phys_addr = pci_resource_start(pcidev, 0);
-   devpriv->io_addr = ioremap(devpriv->phys_addr, DT3000_SIZE);
+   dev->iobase = pci_resource_start(pcidev, 0);
+   devpriv->io_addr = ioremap(dev->iobase, DT3000_SIZE);
if (!devpriv->io_addr)
return -ENOMEM;
 
@@ -905,7 +904,7 @@ static void dt3000_detach(struct comedi_device *dev)
free_irq(dev->irq, dev);
if (devpriv) {
if (devpriv->pci_dev) {
-   if (devpriv->phys_addr)
+   if (dev->iobase)
comedi_pci_disable(devpriv->pci_dev);
pci_dev_put(devpriv->pci_dev);
}
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 66/90] staging: comedi: dt3000: move the setup_pci() code into the attach

2012-07-18 Thread H Hartley Sweeten
The setup_pci() function simply calls comedi_pci_enable() to enable
the device then ioremaps the pci address. Move the code directly
into the attach function as is more typical for the comedi pci
drivers.

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

diff --git a/drivers/staging/comedi/drivers/dt3000.c 
b/drivers/staging/comedi/drivers/dt3000.c
index 10b43a2..92558e7 100644
--- a/drivers/staging/comedi/drivers/dt3000.c
+++ b/drivers/staging/comedi/drivers/dt3000.c
@@ -774,28 +774,6 @@ static int dt3k_mem_insn_read(struct comedi_device *dev,
return i;
 }
 
-static int setup_pci(struct comedi_device *dev)
-{
-   resource_size_t addr;
-   int ret;
-
-   ret = comedi_pci_enable(devpriv->pci_dev, "dt3000");
-   if (ret < 0)
-   return ret;
-
-   addr = pci_resource_start(devpriv->pci_dev, 0);
-   devpriv->phys_addr = addr;
-   devpriv->io_addr = ioremap(devpriv->phys_addr, DT3000_SIZE);
-   if (!devpriv->io_addr)
-   return -ENOMEM;
-#if DEBUG
-   printk("0x%08llx mapped to %p, ",
-  (unsigned long long)devpriv->phys_addr, devpriv->io_addr);
-#endif
-
-   return 0;
-}
-
 static struct pci_dev *dt3000_find_pci_dev(struct comedi_device *dev,
   struct comedi_devconfig *it)
 {
@@ -842,10 +820,15 @@ static int dt3000_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
return -EIO;
devpriv->pci_dev = pcidev;
 
-   ret = setup_pci(dev);
+   ret = comedi_pci_enable(pcidev, "dt3000");
if (ret < 0)
return ret;
 
+   devpriv->phys_addr = pci_resource_start(pcidev, 0);
+   devpriv->io_addr = ioremap(devpriv->phys_addr, DT3000_SIZE);
+   if (!devpriv->io_addr)
+   return -ENOMEM;
+
dev->board_name = this_board->name;
 
if (request_irq(pcidev->irq, dt3k_interrupt, IRQF_SHARED,
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 65/90] staging: comedi: dt3000: cleanup "find pci device" code

2012-07-18 Thread H Hartley Sweeten
The "find pci device" code for this driver was split between
two functions which could cause the driver to walk the pci
bus multiple times while looking for a match.

Consolidate the functions into the format that is more
standard for the comedi pci drivers.

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

diff --git a/drivers/staging/comedi/drivers/dt3000.c 
b/drivers/staging/comedi/drivers/dt3000.c
index d1d99a3..10b43a2 100644
--- a/drivers/staging/comedi/drivers/dt3000.c
+++ b/drivers/staging/comedi/drivers/dt3000.c
@@ -159,7 +159,6 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
 },
 };
 
-#define n_dt3k_boards sizeof(dt3k_boardtypes)/sizeof(struct dt3k_boardtype)
 #define this_board ((const struct dt3k_boardtype *)dev->board_ptr)
 
 #define DT3000_SIZE(4*0x1000)
@@ -797,87 +796,65 @@ static int setup_pci(struct comedi_device *dev)
return 0;
 }
 
-static struct pci_dev *dt_pci_find_device(struct pci_dev *from, int *board)
+static struct pci_dev *dt3000_find_pci_dev(struct comedi_device *dev,
+  struct comedi_devconfig *it)
 {
+   struct pci_dev *pcidev = NULL;
+   int bus = it->options[0];
+   int slot = it->options[1];
int i;
 
-   for (from = pci_get_device(PCI_VENDOR_ID_DT, PCI_ANY_ID, from);
-from != NULL;
-from = pci_get_device(PCI_VENDOR_ID_DT, PCI_ANY_ID, from)) {
-   for (i = 0; i < n_dt3k_boards; i++) {
-   if (from->device == dt3k_boardtypes[i].device_id) {
-   *board = i;
-   return from;
-   }
+   for_each_pci_dev(pcidev) {
+   if (bus || slot) {
+   if (bus != pcidev->bus->number ||
+   slot != PCI_SLOT(pcidev->devfn))
+   continue;
}
-   printk
-   ("unknown Data Translation PCI device found with 
device_id=0x%04x\n",
-from->device);
-   }
-   *board = -1;
-   return from;
-}
-
-static int dt_pci_probe(struct comedi_device *dev, int bus, int slot)
-{
-   int board;
-   int ret;
-   struct pci_dev *pcidev;
-
-   pcidev = NULL;
-   while ((pcidev = dt_pci_find_device(pcidev, )) != NULL) {
-   if ((bus == 0 && slot == 0) ||
-   (pcidev->bus->number == bus &&
-PCI_SLOT(pcidev->devfn) == slot)) {
-   break;
+   if (pcidev->vendor != PCI_VENDOR_ID_DT)
+   continue;
+   for (i = 0; i < ARRAY_SIZE(dt3k_boardtypes); i++) {
+   if (dt3k_boardtypes[i].device_id != pcidev->device)
+   continue;
+   dev->board_ptr = dt3k_boardtypes + i;
+   return pcidev;
}
}
-   devpriv->pci_dev = pcidev;
-
-   if (board >= 0)
-   dev->board_ptr = dt3k_boardtypes + board;
-
-   if (!devpriv->pci_dev)
-   return 0;
-
-   ret = setup_pci(dev);
-   if (ret < 0)
-   return ret;
-
-   return 1;
+   dev_err(dev->class_dev,
+   "No supported board found! (req. bus %d, slot %d)\n",
+   bus, slot);
+   return NULL;
 }
 
 static int dt3000_attach(struct comedi_device *dev, struct comedi_devconfig 
*it)
 {
+   struct pci_dev *pcidev;
struct comedi_subdevice *s;
-   int bus, slot;
int ret = 0;
 
dev_dbg(dev->class_dev, "dt3000:\n");
-   bus = it->options[0];
-   slot = it->options[1];
 
ret = alloc_private(dev, sizeof(struct dt3k_private));
if (ret < 0)
return ret;
 
-   ret = dt_pci_probe(dev, bus, slot);
+   pcidev = dt3000_find_pci_dev(dev, it);
+   if (!pcidev)
+   return -EIO;
+   devpriv->pci_dev = pcidev;
+
+   ret = setup_pci(dev);
if (ret < 0)
return ret;
-   if (ret == 0) {
-   dev_warn(dev->class_dev, "no DT board found\n");
-   return -ENODEV;
-   }
 
dev->board_name = this_board->name;
 
-   if (request_irq(devpriv->pci_dev->irq, dt3k_interrupt, IRQF_SHARED,
+   if (request_irq(pcidev->irq, dt3k_interrupt, IRQF_SHARED,
"dt3000", dev)) {
dev_err(dev->class_dev, "unable to allocate IRQ %u\n",
-   devpriv->pci_dev->irq);
+   pcidev->irq);
return -EINVAL;
}
-   dev->irq = devpriv->pci_dev->irq;
+   dev->irq = pcidev->irq;
 
ret = comedi_alloc_subdevices(dev, 4);
if (ret)
-- 
1.7.11

--
To unsubscribe from this list: send the line 

[PATCH 64/90] staging: comedi: daqboard2000: void *plx should be a void __iomem *

2012-07-18 Thread H Hartley Sweeten
The private data variable 'plx' is an ioremap'ed pci resource and
should be a void __iomem *. This quiets a number of sparse warnings
about "different address spaces".

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

diff --git a/drivers/staging/comedi/drivers/daqboard2000.c 
b/drivers/staging/comedi/drivers/daqboard2000.c
index ba61e32..ef28385 100644
--- a/drivers/staging/comedi/drivers/daqboard2000.c
+++ b/drivers/staging/comedi/drivers/daqboard2000.c
@@ -318,7 +318,7 @@ struct daqboard2000_private {
card_daqboard_2000
} card;
void *daq;
-   void *plx;
+   void __iomem *plx;
unsigned int ao_readback[2];
 };
 
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 63/90] staging: comedi: daqboard2000: store the pci_dev in the comedi_device

2012-07-18 Thread H Hartley Sweeten
Use the hw_dev pointer in the comedi_device struct to hold the
pci_dev instead of carrying it in the private data.

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

diff --git a/drivers/staging/comedi/drivers/daqboard2000.c 
b/drivers/staging/comedi/drivers/daqboard2000.c
index 1d94b58..ba61e32 100644
--- a/drivers/staging/comedi/drivers/daqboard2000.c
+++ b/drivers/staging/comedi/drivers/daqboard2000.c
@@ -317,7 +317,6 @@ struct daqboard2000_private {
enum {
card_daqboard_2000
} card;
-   struct pci_dev *pci_dev;
void *daq;
void *plx;
unsigned int ao_readback[2];
@@ -751,7 +750,7 @@ static int daqboard2000_attach(struct comedi_device *dev,
pcidev = daqboard2000_find_pci_dev(dev, it);
if (!pcidev)
return -EIO;
-   devpriv->pci_dev = pcidev;
+   comedi_set_hw_dev(dev, >dev);
 
result = comedi_pci_enable(pcidev, "daqboard2000");
if (result < 0) {
@@ -833,6 +832,8 @@ out:
 
 static void daqboard2000_detach(struct comedi_device *dev)
 {
+   struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
if (dev->subdevices)
subdev_8255_cleanup(dev, dev->subdevices + 2);
if (dev->irq)
@@ -842,11 +843,11 @@ static void daqboard2000_detach(struct comedi_device *dev)
iounmap(devpriv->daq);
if (devpriv->plx)
iounmap(devpriv->plx);
-   if (devpriv->pci_dev) {
-   if (dev->iobase)
-   comedi_pci_disable(devpriv->pci_dev);
-   pci_dev_put(devpriv->pci_dev);
-   }
+   }
+   if (pcidev) {
+   if (dev->iobase)
+   comedi_pci_disable(pcidev);
+   pci_dev_put(pcidev);
}
 }
 
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 62/90] staging: comedi: daqboard2000: remove 'got_regions' from private data

2012-07-18 Thread H Hartley Sweeten
The 'got_regions' variable in the private data is used as a flag
for the detach to know if the pci device has been enabled.

Typically the dev->iobase variable is used to indicate this in
all the other comedi drivers. Do the same here for consistancy.

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

diff --git a/drivers/staging/comedi/drivers/daqboard2000.c 
b/drivers/staging/comedi/drivers/daqboard2000.c
index eb07466..1d94b58 100644
--- a/drivers/staging/comedi/drivers/daqboard2000.c
+++ b/drivers/staging/comedi/drivers/daqboard2000.c
@@ -320,7 +320,6 @@ struct daqboard2000_private {
struct pci_dev *pci_dev;
void *daq;
void *plx;
-   int got_regions;
unsigned int ao_readback[2];
 };
 
@@ -760,11 +759,11 @@ static int daqboard2000_attach(struct comedi_device *dev,
"failed to enable PCI device and request regions\n");
return -EIO;
}
-   devpriv->got_regions = 1;
+   dev->iobase = pci_resource_start(pcidev, 2);
+
devpriv->plx =
ioremap(pci_resource_start(pcidev, 0), DAQBOARD2000_PLX_SIZE);
-   devpriv->daq =
-   ioremap(pci_resource_start(pcidev, 2), DAQBOARD2000_DAQ_SIZE);
+   devpriv->daq = ioremap(dev->iobase, DAQBOARD2000_DAQ_SIZE);
if (!devpriv->plx || !devpriv->daq)
return -ENOMEM;
 
@@ -844,7 +843,7 @@ static void daqboard2000_detach(struct comedi_device *dev)
if (devpriv->plx)
iounmap(devpriv->plx);
if (devpriv->pci_dev) {
-   if (devpriv->got_regions)
+   if (dev->iobase)
comedi_pci_disable(devpriv->pci_dev);
pci_dev_put(devpriv->pci_dev);
}
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 61/90] staging: comedi: daqboard2000: cleanup "find pci device" code

2012-07-18 Thread H Hartley Sweeten
The "find pci device" code for this driver was quite a bit
different from the other comedi pci drivers. Clean it up so
it follows the format of the other drivers.

Use for_each_pci_dev() instead of open-coding the loop using
pci_get_device().

Check for a specific bus/slot then the vendor/device ids.

The loop checking for the matching boardinfo was creating an
"id" based on the subsystem_device and subsystem_vendor info
from the pci_dev. The vendor id was already checked so just
check against the subsystem_device.

Only return the pci_dev if a matching boardinfo is found.

Consolidate the dev_err messages when a device is not found
into a single message.

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

diff --git a/drivers/staging/comedi/drivers/daqboard2000.c 
b/drivers/staging/comedi/drivers/daqboard2000.c
index fe2f39c..eb07466 100644
--- a/drivers/staging/comedi/drivers/daqboard2000.c
+++ b/drivers/staging/comedi/drivers/daqboard2000.c
@@ -120,8 +120,10 @@ Configuration options:
 
 #include "8255.h"
 
-#define DAQBOARD2000_SUBSYSTEM_IDS20x00021616  /* Daqboard/2000 - 2 
Dacs */
-#define DAQBOARD2000_SUBSYSTEM_IDS40x00041616  /* Daqboard/2000 - 4 
Dacs */
+#define PCI_VENDOR_ID_IOTECH   0x1616
+
+#define DAQBOARD2000_SUBSYSTEM_IDS20x0002  /* Daqboard/2000 - 2 Dacs */
+#define DAQBOARD2000_SUBSYSTEM_IDS40x0004  /* Daqboard/2000 - 4 Dacs */
 
 #define DAQBOARD2000_DAQ_SIZE  0x1002
 #define DAQBOARD2000_PLX_SIZE  0x100
@@ -709,47 +711,29 @@ static struct pci_dev *daqboard2000_find_pci_dev(struct 
comedi_device *dev,
struct pci_dev *pcidev = NULL;
int bus = it->options[0];
int slot = it->options[1];
+   int i;
 
-   for (pcidev = pci_get_device(0x1616, 0x0409, NULL);
-pcidev != NULL; pcidev = pci_get_device(0x1616, 0x0409, pcidev)) {
+   for_each_pci_dev(pcidev) {
if (bus || slot) {
-   /* requested particular bus/slot */
-   if (pcidev->bus->number != bus ||
-   PCI_SLOT(pcidev->devfn) != slot) {
+   if (bus != pcidev->bus->number ||
+   slot != PCI_SLOT(pcidev->devfn))
continue;
-   }
}
-   break;  /* found one */
-   }
-   if (!pcidev) {
-   if (bus || slot)
-   dev_err(dev->class_dev,
-   "no daqboard2000 found at bus/slot: %d/%d\n",
-   bus, slot);
-   else
-   dev_err(dev->class_dev, "no daqboard2000 found\n");
-   return NULL;
-   } else {
-   u32 id;
-   int i;
+   if (pcidev->vendor != PCI_VENDOR_ID_IOTECH ||
+   pcidev->device != 0x0409)
+   continue;
 
-   id = ((u32) pcidev->
- subsystem_device << 16) | pcidev->subsystem_vendor;
for (i = 0; i < ARRAY_SIZE(boardtypes); i++) {
-   if (boardtypes[i].id == id) {
-   dev_dbg(dev->class_dev, "%s\n",
-   boardtypes[i].name);
-   dev->board_ptr = boardtypes + i;
-   }
-   }
-   if (!dev->board_ptr) {
-   printk
-   (" unknown subsystem id %08x (pretend it is an 
ids2)",
-id);
-   dev->board_ptr = boardtypes;
+   if (boardtypes[i].id != pcidev->subsystem_device)
+   continue;
+   dev->board_ptr = boardtypes + i;
+   return pcidev;
}
-   return pcidev;
}
+   dev_err(dev->class_dev,
+   "No supported board found! (req. bus %d, slot %d)\n",
+   bus, slot);
+   return NULL;
 }
 
 static int daqboard2000_attach(struct comedi_device *dev,
@@ -886,7 +870,7 @@ static void __devexit daqboard2000_pci_remove(struct 
pci_dev *dev)
 }
 
 static DEFINE_PCI_DEVICE_TABLE(daqboard2000_pci_table) = {
-   { PCI_DEVICE(0x1616, 0x0409) },
+   { PCI_DEVICE(PCI_VENDOR_ID_IOTECH, 0x0409) },
{ 0 }
 };
 MODULE_DEVICE_TABLE(pci, daqboard2000_pci_table);
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 60/90] staging: comedi: daqboard2000: factor out the "find pci device" code

2012-07-18 Thread H Hartley Sweeten
Factor the "find pci device" code out of the attach function.

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

diff --git a/drivers/staging/comedi/drivers/daqboard2000.c 
b/drivers/staging/comedi/drivers/daqboard2000.c
index 8455cb9..fe2f39c 100644
--- a/drivers/staging/comedi/drivers/daqboard2000.c
+++ b/drivers/staging/comedi/drivers/daqboard2000.c
@@ -703,48 +703,38 @@ static int daqboard2000_8255_cb(int dir, int port, int 
data,
return result;
 }
 
-static int daqboard2000_attach(struct comedi_device *dev,
-  struct comedi_devconfig *it)
+static struct pci_dev *daqboard2000_find_pci_dev(struct comedi_device *dev,
+struct comedi_devconfig *it)
 {
-   int result = 0;
-   struct comedi_subdevice *s;
-   struct pci_dev *card = NULL;
-   void *aux_data;
-   unsigned int aux_len;
-   int bus, slot;
-
-   bus = it->options[0];
-   slot = it->options[1];
+   struct pci_dev *pcidev = NULL;
+   int bus = it->options[0];
+   int slot = it->options[1];
 
-   result = alloc_private(dev, sizeof(struct daqboard2000_private));
-   if (result < 0)
-   return -ENOMEM;
-
-   for (card = pci_get_device(0x1616, 0x0409, NULL);
-card != NULL; card = pci_get_device(0x1616, 0x0409, card)) {
+   for (pcidev = pci_get_device(0x1616, 0x0409, NULL);
+pcidev != NULL; pcidev = pci_get_device(0x1616, 0x0409, pcidev)) {
if (bus || slot) {
/* requested particular bus/slot */
-   if (card->bus->number != bus ||
-   PCI_SLOT(card->devfn) != slot) {
+   if (pcidev->bus->number != bus ||
+   PCI_SLOT(pcidev->devfn) != slot) {
continue;
}
}
break;  /* found one */
}
-   if (!card) {
+   if (!pcidev) {
if (bus || slot)
dev_err(dev->class_dev,
"no daqboard2000 found at bus/slot: %d/%d\n",
bus, slot);
else
dev_err(dev->class_dev, "no daqboard2000 found\n");
-   return -EIO;
+   return NULL;
} else {
u32 id;
int i;
-   devpriv->pci_dev = card;
-   id = ((u32) card->
- subsystem_device << 16) | card->subsystem_vendor;
+
+   id = ((u32) pcidev->
+ subsystem_device << 16) | pcidev->subsystem_vendor;
for (i = 0; i < ARRAY_SIZE(boardtypes); i++) {
if (boardtypes[i].id == id) {
dev_dbg(dev->class_dev, "%s\n",
@@ -758,9 +748,29 @@ static int daqboard2000_attach(struct comedi_device *dev,
 id);
dev->board_ptr = boardtypes;
}
+   return pcidev;
}
+}
+
+static int daqboard2000_attach(struct comedi_device *dev,
+  struct comedi_devconfig *it)
+{
+   struct pci_dev *pcidev;
+   struct comedi_subdevice *s;
+   void *aux_data;
+   unsigned int aux_len;
+   int result;
+
+   result = alloc_private(dev, sizeof(struct daqboard2000_private));
+   if (result < 0)
+   return -ENOMEM;
+
+   pcidev = daqboard2000_find_pci_dev(dev, it);
+   if (!pcidev)
+   return -EIO;
+   devpriv->pci_dev = pcidev;
 
-   result = comedi_pci_enable(card, "daqboard2000");
+   result = comedi_pci_enable(pcidev, "daqboard2000");
if (result < 0) {
dev_err(dev->class_dev,
"failed to enable PCI device and request regions\n");
@@ -768,9 +778,9 @@ static int daqboard2000_attach(struct comedi_device *dev,
}
devpriv->got_regions = 1;
devpriv->plx =
-   ioremap(pci_resource_start(card, 0), DAQBOARD2000_PLX_SIZE);
+   ioremap(pci_resource_start(pcidev, 0), DAQBOARD2000_PLX_SIZE);
devpriv->daq =
-   ioremap(pci_resource_start(card, 2), DAQBOARD2000_DAQ_SIZE);
+   ioremap(pci_resource_start(pcidev, 2), DAQBOARD2000_DAQ_SIZE);
if (!devpriv->plx || !devpriv->daq)
return -ENOMEM;
 
@@ -783,7 +793,7 @@ static int daqboard2000_attach(struct comedi_device *dev,
/*
   u8 interrupt;
   Windows code does restore interrupts, but since we don't use them...
-  pci_read_config_byte(card, PCI_INTERRUPT_LINE, );
+  pci_read_config_byte(pcidev, PCI_INTERRUPT_LINE, );
   printk("Interrupt before is: %x\n", interrupt);
 

[PATCH 59/90] staging: comedi: contec_pci_dio: remove the private data

2012-07-18 Thread H Hartley Sweeten
The private data is no longer needed by this driver. Remove the
struct, devpriv macro, and the allocation.

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

diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c 
b/drivers/staging/comedi/drivers/contec_pci_dio.c
index 5578c2c..944cfee 100644
--- a/drivers/staging/comedi/drivers/contec_pci_dio.c
+++ b/drivers/staging/comedi/drivers/contec_pci_dio.c
@@ -57,12 +57,6 @@ static const struct contec_board contec_boards[] = {
 
 #define thisboard ((const struct contec_board *)dev->board_ptr)
 
-struct contec_private {
-   int data;
-};
-
-#define devpriv ((struct contec_private *)dev->private)
-
 static int contec_do_insn_bits(struct comedi_device *dev,
   struct comedi_subdevice *s,
   struct comedi_insn *insn, unsigned int *data)
@@ -130,9 +124,6 @@ static int contec_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
 
dev->board_name = thisboard->name;
 
-   if (alloc_private(dev, sizeof(struct contec_private)) < 0)
-   return -ENOMEM;
-
ret = comedi_alloc_subdevices(dev, 2);
if (ret)
return ret;
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 58/90] staging: comedi: contec_pci_dio: store the pci_dev in the comedi_device

2012-07-18 Thread H Hartley Sweeten
Use the hw_dev pointer in the comedi_device struct to hold the
pci_dev instead of carrying it in the private data.

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

diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c 
b/drivers/staging/comedi/drivers/contec_pci_dio.c
index b75a8af..5578c2c 100644
--- a/drivers/staging/comedi/drivers/contec_pci_dio.c
+++ b/drivers/staging/comedi/drivers/contec_pci_dio.c
@@ -59,9 +59,6 @@ static const struct contec_board contec_boards[] = {
 
 struct contec_private {
int data;
-
-   struct pci_dev *pci_dev;
-
 };
 
 #define devpriv ((struct contec_private *)dev->private)
@@ -143,7 +140,7 @@ static int contec_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
pcidev = contec_find_pci_dev(dev, it);
if (!pcidev)
return -EIO;
-   devpriv->pci_dev = pcidev;
+   comedi_set_hw_dev(dev, >dev);
 
if (comedi_pci_enable(pcidev, "contec_pci_dio")) {
printk("error enabling PCI device and request regions!\n");
@@ -176,10 +173,12 @@ static int contec_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
 
 static void contec_detach(struct comedi_device *dev)
 {
-   if (devpriv && devpriv->pci_dev) {
+   struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+   if (pcidev) {
if (dev->iobase)
-   comedi_pci_disable(devpriv->pci_dev);
-   pci_dev_put(devpriv->pci_dev);
+   comedi_pci_disable(pcidev);
+   pci_dev_put(pcidev);
}
 }
 
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 57/90] staging: comedi: contec_pci_dio: cleanup "find pci device" code

2012-07-18 Thread H Hartley Sweeten
Add a couple local variables and reorder the tests to make
to make the more concise.

Change the printk to a dev_err when no match is found and reword
the message.

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

diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c 
b/drivers/staging/comedi/drivers/contec_pci_dio.c
index e4d37fc..b75a8af 100644
--- a/drivers/staging/comedi/drivers/contec_pci_dio.c
+++ b/drivers/staging/comedi/drivers/contec_pci_dio.c
@@ -101,22 +101,25 @@ static struct pci_dev *contec_find_pci_dev(struct 
comedi_device *dev,
   struct comedi_devconfig *it)
 {
struct pci_dev *pcidev = NULL;
+   int bus = it->options[0];
+   int slot = it->options[1];
 
for_each_pci_dev(pcidev) {
-   if (pcidev->vendor == PCI_VENDOR_ID_CONTEC &&
-   pcidev->device == PCI_DEVICE_ID_PIO1616L) {
-   if (it->options[0] || it->options[1]) {
-   /* Check bus and slot. */
-   if (it->options[0] != pcidev->bus->number ||
-   it->options[1] != PCI_SLOT(pcidev->devfn)) {
-   continue;
-   }
-   }
-   dev->board_ptr = contec_boards + 0;
-   return pcidev;
+   if (bus || slot) {
+   if (bus != pcidev->bus->number ||
+   slot != PCI_SLOT(pcidev->devfn))
+   continue;
}
+   if (pcidev->vendor != PCI_VENDOR_ID_CONTEC ||
+   pcidev->device != PCI_DEVICE_ID_PIO1616L)
+   continue;
+
+   dev->board_ptr = contec_boards + 0;
+   return pcidev;
}
-   printk("card not present!\n");
+   dev_err(dev->class_dev,
+   "No supported board found! (req. bus %d, slot %d)\n",
+   bus, slot);
return NULL;
 }
 
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 56/90] staging: comedi: contec_pci_dio: factor out the "find pci device" code

2012-07-18 Thread H Hartley Sweeten
Factor the "find pci device" code out of the attach function.

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

diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c 
b/drivers/staging/comedi/drivers/contec_pci_dio.c
index ee769e0..e4d37fc 100644
--- a/drivers/staging/comedi/drivers/contec_pci_dio.c
+++ b/drivers/staging/comedi/drivers/contec_pci_dio.c
@@ -97,22 +97,10 @@ static int contec_di_insn_bits(struct comedi_device *dev,
return insn->n;
 }
 
-static int contec_attach(struct comedi_device *dev, struct comedi_devconfig 
*it)
+static struct pci_dev *contec_find_pci_dev(struct comedi_device *dev,
+  struct comedi_devconfig *it)
 {
struct pci_dev *pcidev = NULL;
-   struct comedi_subdevice *s;
-   int ret;
-
-   printk("comedi%d: contec: ", dev->minor);
-
-   dev->board_name = thisboard->name;
-
-   if (alloc_private(dev, sizeof(struct contec_private)) < 0)
-   return -ENOMEM;
-
-   ret = comedi_alloc_subdevices(dev, 2);
-   if (ret)
-   return ret;
 
for_each_pci_dev(pcidev) {
if (pcidev->vendor == PCI_VENDOR_ID_CONTEC &&
@@ -124,43 +112,63 @@ static int contec_attach(struct comedi_device *dev, 
struct comedi_devconfig *it)
continue;
}
}
-   devpriv->pci_dev = pcidev;
-   if (comedi_pci_enable(pcidev, "contec_pci_dio")) {
-   printk
-   ("error enabling PCI device and request 
regions!\n");
-   return -EIO;
-   }
-   dev->iobase = pci_resource_start(pcidev, 0);
-   printk(" base addr %lx ", dev->iobase);
-
dev->board_ptr = contec_boards + 0;
+   return pcidev;
+   }
+   }
+   printk("card not present!\n");
+   return NULL;
+}
 
-   s = dev->subdevices + 0;
+static int contec_attach(struct comedi_device *dev, struct comedi_devconfig 
*it)
+{
+   struct pci_dev *pcidev;
+   struct comedi_subdevice *s;
+   int ret;
 
-   s->type = COMEDI_SUBD_DI;
-   s->subdev_flags = SDF_READABLE;
-   s->n_chan = 16;
-   s->maxdata = 1;
-   s->range_table = _digital;
-   s->insn_bits = contec_di_insn_bits;
+   printk("comedi%d: contec: ", dev->minor);
 
-   s = dev->subdevices + 1;
-   s->type = COMEDI_SUBD_DO;
-   s->subdev_flags = SDF_WRITABLE;
-   s->n_chan = 16;
-   s->maxdata = 1;
-   s->range_table = _digital;
-   s->insn_bits = contec_do_insn_bits;
+   dev->board_name = thisboard->name;
 
-   printk("attached\n");
+   if (alloc_private(dev, sizeof(struct contec_private)) < 0)
+   return -ENOMEM;
 
-   return 1;
-   }
+   ret = comedi_alloc_subdevices(dev, 2);
+   if (ret)
+   return ret;
+
+   pcidev = contec_find_pci_dev(dev, it);
+   if (!pcidev)
+   return -EIO;
+   devpriv->pci_dev = pcidev;
+
+   if (comedi_pci_enable(pcidev, "contec_pci_dio")) {
+   printk("error enabling PCI device and request regions!\n");
+   return -EIO;
}
+   dev->iobase = pci_resource_start(pcidev, 0);
+   printk(" base addr %lx ", dev->iobase);
 
-   printk("card not present!\n");
+   s = dev->subdevices + 0;
+
+   s->type = COMEDI_SUBD_DI;
+   s->subdev_flags = SDF_READABLE;
+   s->n_chan = 16;
+   s->maxdata = 1;
+   s->range_table = _digital;
+   s->insn_bits = contec_di_insn_bits;
+
+   s = dev->subdevices + 1;
+   s->type = COMEDI_SUBD_DO;
+   s->subdev_flags = SDF_WRITABLE;
+   s->n_chan = 16;
+   s->maxdata = 1;
+   s->range_table = _digital;
+   s->insn_bits = contec_do_insn_bits;
+
+   printk("attached\n");
 
-   return -EIO;
+   return 1;
 }
 
 static void contec_detach(struct comedi_device *dev)
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 55/90] staging: comedi: cb_pcimdas: store the pci_dev in the comedi_device

2012-07-18 Thread H Hartley Sweeten
Use the hw_dev pointer in the comedi_device struct to hold the
pci_dev instead of carrying it in the private data.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c 
b/drivers/staging/comedi/drivers/cb_pcimdas.c
index ce08533..c632a89 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -130,9 +130,6 @@ static const struct cb_pcimdas_board cb_pcimdas_boards[] = {
  * struct.
  */
 struct cb_pcimdas_private {
-   /*  would be useful for a PCI device */
-   struct pci_dev *pci_dev;
-
/* base addresses */
unsigned long BADR3;
 
@@ -210,7 +207,7 @@ static int cb_pcimdas_attach(struct comedi_device *dev,
pcidev = cb_pcimdas_find_pci_dev(dev, it);
if (!pcidev)
return -EIO;
-   devpriv->pci_dev = pcidev;
+   comedi_set_hw_dev(dev, >dev);
 
/*  Warn about non-tested features */
switch (thisboard->device_id) {
@@ -228,18 +225,18 @@ static int cb_pcimdas_attach(struct comedi_device *dev,
return -EIO;
}
 
-   dev->iobase = pci_resource_start(devpriv->pci_dev, 2);
-   devpriv->BADR3 = pci_resource_start(devpriv->pci_dev, 3);
-   iobase_8255 = pci_resource_start(devpriv->pci_dev, 4);
+   dev->iobase = pci_resource_start(pcidev, 2);
+   devpriv->BADR3 = pci_resource_start(pcidev, 3);
+   iobase_8255 = pci_resource_start(pcidev, 4);
 
 /* Dont support IRQ yet */
 /*  get irq */
-/* if(request_irq(devpriv->pci_dev->irq, cb_pcimdas_interrupt, IRQF_SHARED, 
"cb_pcimdas", dev )) */
+/* if(request_irq(pcidev->irq, cb_pcimdas_interrupt, IRQF_SHARED, 
"cb_pcimdas", dev )) */
 /* { */
-/* printk(" unable to allocate irq %u\n", devpriv->pci_dev->irq); */
+/* printk(" unable to allocate irq %u\n", pcidev->irq); */
 /* return -EINVAL; */
 /* } */
-/* dev->irq = devpriv->pci_dev->irq; */
+/* dev->irq = pcidev->irq; */
 
/* Initialize dev->board_name */
dev->board_name = thisboard->name;
@@ -283,14 +280,14 @@ static int cb_pcimdas_attach(struct comedi_device *dev,
 
 static void cb_pcimdas_detach(struct comedi_device *dev)
 {
+   struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
if (dev->irq)
free_irq(dev->irq, dev);
-   if (devpriv) {
-   if (devpriv->pci_dev) {
-   if (dev->iobase)
-   comedi_pci_disable(devpriv->pci_dev);
-   pci_dev_put(devpriv->pci_dev);
-   }
+   if (pcidev) {
+   if (dev->iobase)
+   comedi_pci_disable(pcidev);
+   pci_dev_put(pcidev);
}
 }
 
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 54/90] staging: comedi: cb_pcimdas: remove BADR0 from the private data

2012-07-18 Thread H Hartley Sweeten
The pci resource bar 0 address is only used as a "flag" to
let the datach function know that the pci device has been
enabled. Use dev->iobase in the detach instead and remove
BADR0 from the private data.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c 
b/drivers/staging/comedi/drivers/cb_pcimdas.c
index 4312e9b..ce08533 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -56,7 +56,6 @@ See http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf 
for more details.
 /* Registers for the PCIM-DAS1602/16 */
 
 /* sizes of io regions (bytes) */
-#define BADR0_SIZE 2   /* ?? */
 #define BADR3_SIZE 16
 
 /* DAC Offsets */
@@ -135,7 +134,6 @@ struct cb_pcimdas_private {
struct pci_dev *pci_dev;
 
/* base addresses */
-   unsigned long BADR0;
unsigned long BADR3;
 
/* Used for AO readback */
@@ -230,7 +228,6 @@ static int cb_pcimdas_attach(struct comedi_device *dev,
return -EIO;
}
 
-   devpriv->BADR0 = pci_resource_start(devpriv->pci_dev, 0);
dev->iobase = pci_resource_start(devpriv->pci_dev, 2);
devpriv->BADR3 = pci_resource_start(devpriv->pci_dev, 3);
iobase_8255 = pci_resource_start(devpriv->pci_dev, 4);
@@ -290,7 +287,7 @@ static void cb_pcimdas_detach(struct comedi_device *dev)
free_irq(dev->irq, dev);
if (devpriv) {
if (devpriv->pci_dev) {
-   if (devpriv->BADR0)
+   if (dev->iobase)
comedi_pci_disable(devpriv->pci_dev);
pci_dev_put(devpriv->pci_dev);
}
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 53/90] staging: comedi: cb_pcimdas: remove BADR2 from the private data

2012-07-18 Thread H Hartley Sweeten
The pci resource bar 2 address is the primary i/o address used
by this device. Store it in dev->iobase and remove it from the
private data.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c 
b/drivers/staging/comedi/drivers/cb_pcimdas.c
index c8df680..4312e9b 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -57,7 +57,6 @@ See http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf 
for more details.
 
 /* sizes of io regions (bytes) */
 #define BADR0_SIZE 2   /* ?? */
-#define BADR2_SIZE 6
 #define BADR3_SIZE 16
 
 /* DAC Offsets */
@@ -137,7 +136,6 @@ struct cb_pcimdas_private {
 
/* base addresses */
unsigned long BADR0;
-   unsigned long BADR2;
unsigned long BADR3;
 
/* Used for AO readback */
@@ -233,7 +231,7 @@ static int cb_pcimdas_attach(struct comedi_device *dev,
}
 
devpriv->BADR0 = pci_resource_start(devpriv->pci_dev, 0);
-   devpriv->BADR2 = pci_resource_start(devpriv->pci_dev, 2);
+   dev->iobase = pci_resource_start(devpriv->pci_dev, 2);
devpriv->BADR3 = pci_resource_start(devpriv->pci_dev, 3);
iobase_8255 = pci_resource_start(devpriv->pci_dev, 4);
 
@@ -344,7 +342,7 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device *dev,
/* convert n samples */
for (n = 0; n < insn->n; n++) {
/* trigger conversion */
-   outw(0, devpriv->BADR2 + 0);
+   outw(0, dev->iobase + 0);
 
 #define TIMEOUT 1000   /* typically takes 5 loops on a lightly loaded 
Pentium 100MHz, */
/* this is likely to be 100 loops on a 2GHz machine, so set 
1000 as the limit. */
@@ -360,7 +358,7 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device *dev,
return -ETIMEDOUT;
}
/* read data */
-   d = inw(devpriv->BADR2 + 0);
+   d = inw(dev->iobase + 0);
 
/* mangle the data as necessary */
/* d ^= 1<<(thisboard->ai_bits-1); // 16 bit data from ADC, so 
no mangle needed. */
@@ -384,10 +382,10 @@ static int cb_pcimdas_ao_winsn(struct comedi_device *dev,
for (i = 0; i < insn->n; i++) {
switch (chan) {
case 0:
-   outw(data[i] & 0x0FFF, devpriv->BADR2 + DAC0_OFFSET);
+   outw(data[i] & 0x0FFF, dev->iobase + DAC0_OFFSET);
break;
case 1:
-   outw(data[i] & 0x0FFF, devpriv->BADR2 + DAC1_OFFSET);
+   outw(data[i] & 0x0FFF, dev->iobase + DAC1_OFFSET);
break;
default:
return -1;
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC] Simplifying kernel configuration for distro issues

2012-07-18 Thread Steven Yong
On Sat, Jul 14, 2012 at 4:37 AM, Linus Torvalds
 wrote:
> In addition to the "minimal distro settings", we might also have a few
> "common platform" settings, so that you could basically do a "hey, I
> have a modern PC laptop, make it pick the obvious stuff that a normal
> person needs, like USB storage, FAT/VFAT support, the core power
> management etc".

I am a normal user who is trying to compile newer kernel, to me,
minimal settings for "common platform" is more important than minimal
settings for "distro", minimal settings for distro is for sure
important though, thanks for bringing this RFC up for the benefits of
normal users.

But instead of selecting distro myself, can the minimal settings be
auto-selected by checking my current distro?

Steven
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 52/90] staging: comedi: cb_pcimdas: remove BADR4 from the private data

2012-07-18 Thread H Hartley Sweeten
The pci resource bar 4 address is only needed to initialize the
8255 subdevice. Use a local variable to hold it and remove it
from the private data.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c 
b/drivers/staging/comedi/drivers/cb_pcimdas.c
index 3902c85bc..c8df680 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -59,7 +59,6 @@ See http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf 
for more details.
 #define BADR0_SIZE 2   /* ?? */
 #define BADR2_SIZE 6
 #define BADR3_SIZE 16
-#define BADR4_SIZE 4
 
 /* DAC Offsets */
 #define ADC_TRIG 0
@@ -140,7 +139,6 @@ struct cb_pcimdas_private {
unsigned long BADR0;
unsigned long BADR2;
unsigned long BADR3;
-   unsigned long BADR4;
 
/* Used for AO readback */
unsigned int ao_readback[2];
@@ -204,6 +202,7 @@ static int cb_pcimdas_attach(struct comedi_device *dev,
 {
struct pci_dev *pcidev;
struct comedi_subdevice *s;
+   unsigned long iobase_8255;
int ret;
 
 /*
@@ -236,7 +235,7 @@ static int cb_pcimdas_attach(struct comedi_device *dev,
devpriv->BADR0 = pci_resource_start(devpriv->pci_dev, 0);
devpriv->BADR2 = pci_resource_start(devpriv->pci_dev, 2);
devpriv->BADR3 = pci_resource_start(devpriv->pci_dev, 3);
-   devpriv->BADR4 = pci_resource_start(devpriv->pci_dev, 4);
+   iobase_8255 = pci_resource_start(devpriv->pci_dev, 4);
 
 /* Dont support IRQ yet */
 /*  get irq */
@@ -280,7 +279,7 @@ static int cb_pcimdas_attach(struct comedi_device *dev,
s = dev->subdevices + 2;
/* digital i/o subdevice */
if (thisboard->has_dio)
-   subdev_8255_init(dev, s, NULL, devpriv->BADR4);
+   subdev_8255_init(dev, s, NULL, iobase_8255);
else
s->type = COMEDI_SUBD_UNUSED;
 
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 51/90] staging: comedi: cb_pcimdas: remove BADR1 from the private data

2012-07-18 Thread H Hartley Sweeten
The pci resource bar 1 address is not used in the driver. Remove
it from the private data.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c 
b/drivers/staging/comedi/drivers/cb_pcimdas.c
index 9e4bac1..3902c85bc 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -57,7 +57,6 @@ See http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf 
for more details.
 
 /* sizes of io regions (bytes) */
 #define BADR0_SIZE 2   /* ?? */
-#define BADR1_SIZE 4
 #define BADR2_SIZE 6
 #define BADR3_SIZE 16
 #define BADR4_SIZE 4
@@ -139,7 +138,6 @@ struct cb_pcimdas_private {
 
/* base addresses */
unsigned long BADR0;
-   unsigned long BADR1;
unsigned long BADR2;
unsigned long BADR3;
unsigned long BADR4;
@@ -236,7 +234,6 @@ static int cb_pcimdas_attach(struct comedi_device *dev,
}
 
devpriv->BADR0 = pci_resource_start(devpriv->pci_dev, 0);
-   devpriv->BADR1 = pci_resource_start(devpriv->pci_dev, 1);
devpriv->BADR2 = pci_resource_start(devpriv->pci_dev, 2);
devpriv->BADR3 = pci_resource_start(devpriv->pci_dev, 3);
devpriv->BADR4 = pci_resource_start(devpriv->pci_dev, 4);
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 50/90] staging: comedi: cb_pcimdas: cleanup the private data

2012-07-18 Thread H Hartley Sweeten
Remove the unused variables from the private data.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c 
b/drivers/staging/comedi/drivers/cb_pcimdas.c
index 3400067..9e4bac1 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -134,8 +134,6 @@ static const struct cb_pcimdas_board cb_pcimdas_boards[] = {
  * struct.
  */
 struct cb_pcimdas_private {
-   int data;
-
/*  would be useful for a PCI device */
struct pci_dev *pci_dev;
 
@@ -148,13 +146,6 @@ struct cb_pcimdas_private {
 
/* Used for AO readback */
unsigned int ao_readback[2];
-
-   /*  Used for DIO */
-   unsigned short int port_a;  /*  copy of BADR4+0 */
-   unsigned short int port_b;  /*  copy of BADR4+1 */
-   unsigned short int port_c;  /*  copy of BADR4+2 */
-   unsigned short int dio_mode;/*  copy of BADR4+3 */
-
 };
 
 /*
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 49/90] staging: comedi: cb_pcimdas: remove the debug print of the pci bars

2012-07-18 Thread H Hartley Sweeten
Remove the dev_dbg output of the pci addresses. It's just add noise.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c 
b/drivers/staging/comedi/drivers/cb_pcimdas.c
index 1b6ebb7..3400067 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -250,12 +250,6 @@ static int cb_pcimdas_attach(struct comedi_device *dev,
devpriv->BADR3 = pci_resource_start(devpriv->pci_dev, 3);
devpriv->BADR4 = pci_resource_start(devpriv->pci_dev, 4);
 
-   dev_dbg(dev->class_dev, "devpriv->BADR0 = 0x%lx\n", devpriv->BADR0);
-   dev_dbg(dev->class_dev, "devpriv->BADR1 = 0x%lx\n", devpriv->BADR1);
-   dev_dbg(dev->class_dev, "devpriv->BADR2 = 0x%lx\n", devpriv->BADR2);
-   dev_dbg(dev->class_dev, "devpriv->BADR3 = 0x%lx\n", devpriv->BADR3);
-   dev_dbg(dev->class_dev, "devpriv->BADR4 = 0x%lx\n", devpriv->BADR4);
-
 /* Dont support IRQ yet */
 /*  get irq */
 /* if(request_irq(devpriv->pci_dev->irq, cb_pcimdas_interrupt, IRQF_SHARED, 
"cb_pcimdas", dev )) */
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 48/90] staging: comedi: cb_pcimdas: cleanup "find pci device" code

2012-07-18 Thread H Hartley Sweeten
Add a couple local variables to make the tests more concise.

Reorder the tests to make the for() loop checking for a
matching boardtype quicker.

Use ARRAY_SIZE() to determine the number of boards instead
of the hard-coded '1'.

Drop the dev_dbg for a match. It's just add noise.

Reword the dev_err when no match is found.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c 
b/drivers/staging/comedi/drivers/cb_pcimdas.c
index 8999a72..1b6ebb7 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -122,8 +122,6 @@ static const struct cb_pcimdas_board cb_pcimdas_boards[] = {
 },
 };
 
-#define N_BOARDS 1 /*  Max number of boards supported */
-
 /*
  * Useful for shorthand access to the particular board structure
  */
@@ -179,36 +177,30 @@ static struct pci_dev *cb_pcimdas_find_pci_dev(struct 
comedi_device *dev,
   struct comedi_devconfig *it)
 {
struct pci_dev *pcidev = NULL;
-   int index;
+   int bus = it->options[0];
+   int slot = it->options[1];
+   int i;
 
for_each_pci_dev(pcidev) {
-   /*  is it not a computer boards card? */
+   if (bus || slot) {
+   if (bus != pcidev->bus->number ||
+   slot != PCI_SLOT(pcidev->devfn))
+   continue;
+   }
if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS)
continue;
-   /*  loop through cards supported by this driver */
-   for (index = 0; index < N_BOARDS; index++) {
-   if (cb_pcimdas_boards[index].device_id !=
-   pcidev->device)
+
+   for (i = 0; i < ARRAY_SIZE(cb_pcimdas_boards); i++) {
+   if (cb_pcimdas_boards[i].device_id != pcidev->device)
continue;
-   /*  was a particular bus/slot requested? */
-   if (it->options[0] || it->options[1]) {
-   /*  are we on the wrong bus/slot? */
-   if (pcidev->bus->number != it->options[0] ||
-   PCI_SLOT(pcidev->devfn) != it->options[1]) {
-   continue;
-   }
-   }
-   dev->board_ptr = cb_pcimdas_boards + index;
-   dev_dbg(dev->class_dev,
-   "Found %s on bus %i, slot %i\n",
-   cb_pcimdas_boards[index].name,
-   pcidev->bus->number,
-   PCI_SLOT(pcidev->devfn));
+
+   dev->board_ptr = cb_pcimdas_boards + i;
return pcidev;
}
}
dev_err(dev->class_dev,
-   "No supported ComputerBoards/MeasurementComputing card found on 
requested position\n");
+   "No supported board found! (req. bus %d, slot %d)\n",
+   bus, slot);
return NULL;
 }
 
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 47/90] staging: comedi: cb_pcimdas: factor out the "find pci device" code

2012-07-18 Thread H Hartley Sweeten
Factor the "find pci device" code out of the attach function.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c 
b/drivers/staging/comedi/drivers/cb_pcimdas.c
index 2977f2d..8999a72 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -175,30 +175,11 @@ static int cb_pcimdas_ao_rinsn(struct comedi_device *dev,
   struct comedi_subdevice *s,
   struct comedi_insn *insn, unsigned int *data);
 
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board.  If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
- */
-static int cb_pcimdas_attach(struct comedi_device *dev,
-struct comedi_devconfig *it)
+static struct pci_dev *cb_pcimdas_find_pci_dev(struct comedi_device *dev,
+  struct comedi_devconfig *it)
 {
-   struct comedi_subdevice *s;
struct pci_dev *pcidev = NULL;
int index;
-   int ret;
-   /* int i; */
-
-/*
- * Allocate the private structure area.
- */
-   if (alloc_private(dev, sizeof(struct cb_pcimdas_private)) < 0)
-   return -ENOMEM;
-
-/*
- * Probe the device to determine what device in the series it is.
- */
 
for_each_pci_dev(pcidev) {
/*  is it not a computer boards card? */
@@ -217,21 +198,43 @@ static int cb_pcimdas_attach(struct comedi_device *dev,
continue;
}
}
-   devpriv->pci_dev = pcidev;
dev->board_ptr = cb_pcimdas_boards + index;
-   goto found;
+   dev_dbg(dev->class_dev,
+   "Found %s on bus %i, slot %i\n",
+   cb_pcimdas_boards[index].name,
+   pcidev->bus->number,
+   PCI_SLOT(pcidev->devfn));
+   return pcidev;
}
}
-
dev_err(dev->class_dev,
"No supported ComputerBoards/MeasurementComputing card found on 
requested position\n");
-   return -EIO;
+   return NULL;
+}
 
-found:
+/*
+ * Attach is called by the Comedi core to configure the driver
+ * for a particular board.  If you specified a board_name array
+ * in the driver structure, dev->board_ptr contains that
+ * address.
+ */
+static int cb_pcimdas_attach(struct comedi_device *dev,
+struct comedi_devconfig *it)
+{
+   struct pci_dev *pcidev;
+   struct comedi_subdevice *s;
+   int ret;
 
-   dev_dbg(dev->class_dev, "Found %s on bus %i, slot %i\n",
-   cb_pcimdas_boards[index].name, pcidev->bus->number,
-   PCI_SLOT(pcidev->devfn));
+/*
+ * Allocate the private structure area.
+ */
+   if (alloc_private(dev, sizeof(struct cb_pcimdas_private)) < 0)
+   return -ENOMEM;
+
+   pcidev = cb_pcimdas_find_pci_dev(dev, it);
+   if (!pcidev)
+   return -EIO;
+   devpriv->pci_dev = pcidev;
 
/*  Warn about non-tested features */
switch (thisboard->device_id) {
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 46/90] staging: comedi: cb_pcidio: remove the private data

2012-07-18 Thread H Hartley Sweeten
The private data is no longer needed by this driver. Remove the
struct, devpriv macro, and the allocation.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcidio.c 
b/drivers/staging/comedi/drivers/cb_pcidio.c
index f30f6da..e370d0d 100644
--- a/drivers/staging/comedi/drivers/cb_pcidio.c
+++ b/drivers/staging/comedi/drivers/cb_pcidio.c
@@ -90,23 +90,6 @@ static const struct pcidio_board pcidio_boards[] = {
  */
 #define thisboard ((const struct pcidio_board *)dev->board_ptr)
 
-/* this structure is for data unique to this hardware driver.  If
-   several hardware drivers keep similar information in this structure,
-   feel free to suggest moving the variable to the struct comedi_device 
struct.  */
-struct pcidio_private {
-   int data;   /*  currently unused */
-
-   /* used for DO readback, currently unused */
-   unsigned int do_readback[4];/* up to 4 unsigned int suffice to hold 
96 bits for PCI-DIO96 */
-
-};
-
-/*
- * most drivers define the following macro to make it easy to
- * access the private structure.
- */
-#define devpriv ((struct pcidio_private *)dev->private)
-
 static struct pci_dev *pcidio_find_pci_dev(struct comedi_device *dev,
   struct comedi_devconfig *it)
 {
@@ -143,13 +126,6 @@ static int pcidio_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
int i;
int ret;
 
-/*
- * Allocate the private structure area.  alloc_private() is a
- * convenient macro defined in comedidev.h.
- */
-   if (alloc_private(dev, sizeof(struct pcidio_private)) < 0)
-   return -ENOMEM;
-
pcidev = pcidio_find_pci_dev(dev, it);
if (!pcidev)
return -EIO;
-- 
1.7.11

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   6   7   8   9   10   >