build failure next-20121126

2012-11-26 Thread H Hartley Sweeten
Hello all,

I was just trying a allyesconfig build of next-20121126 and got this:

  CC  fs/cifs/cifs_debug.o
In function 'copy_from_user',
inlined from 'cifs_security_flags_proc_write' at fs/cifs/cifs_debug.c:593:
/home/bigguiness/src/git/linux-next/arch/x86/include/asm/uaccess_32.h:211: 
error: call to 'copy_from_user_overflow' declared with attribute error: 
copy_from_user() buffer size is not provably correct
make[2]: *** [fs/cifs/cifs_debug.o] Error 1
make[1]: *** [fs/cifs] Error 2
make: *** [fs] Error 2

I'm not sure if this is a known issue...

Regards,
Hartley

--
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/


build failure next-20121126

2012-11-26 Thread H Hartley Sweeten
Hello all,

Another build failure with next-20121126:

  CC  security/integrity/evm/evm_secfs.o
In function 'copy_from_user',
inlined from 'evm_write_key' at security/integrity/evm/evm_secfs.c:71:
/home/bigguiness/src/git/linux-next/arch/x86/include/asm/uaccess_32.h:211: 
error: call to 'copy_from_user_overflow' declared with attribute error: 
copy_from_user() buffer size is not provably correct
make[3]: *** [security/integrity/evm/evm_secfs.o] Error 1
make[2]: *** [security/integrity/evm] Error 2
make[1]: *** [security/integrity] Error 2
make: *** [security] Error 2

Regards,
Hartley

--
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/3] backlight: ep93xx_bl: fix section mismatch

2013-03-18 Thread H Hartley Sweeten
On Friday, March 15, 2013 7:20 PM, Ryan Mallon wrote:
> On 16/03/13 12:03, H Hartley Sweeten wrote:
>
>> Remove the __init tag from ep93xxbl_probe() to fix the section
>> mismatch warning.
>> 
>> Signed-off-by: H Hartley Sweeten 
>> Cc: Ryan Mallon 
>> Cc: Richard Purdie 
>> Cc: Florian Tobias Schandinat 
>
>
> There is a patch for this already queued in Andrew Morton's tree.

Ah, missed that one. Please drop patch 1/3.

The other two, as well as the compile bug fix for ep93xx_fb.c should still
be ok. The bug fix patch is probably valid for stable as appropriate.

[PATCH] video: ep93xx_fb: include  for devm_ioremap()
[PATCH 2/3] video: ep93xx-fb.c: fix section mismatch and use 
module_platform_driver
[PATCH 3/3] misc: ep93xx_pwm.c: fix section mismatch and use 
module_platform_driver

Thanks,
Hartley



RE: [PATCH] Staging: comedi: serial2002: fixed consistent spacing issue

2013-03-20 Thread H Hartley Sweeten
On Wednesday, March 20, 2013 9:04 AM, Joe Perches wrote:
> On Wed, 2013-03-20 at 15:29 +, Al Viro wrote:
>> On Wed, Mar 20, 2013 at 03:47:53PM +0300, Dan Carpenter wrote:
>> 
>>> The original code here needs to broken up into functions so it isn't
>>> squashed up against the 80 character limit.
>> 
>> I'd say what needs to be done to the original code...
>
> All good things, thanks for taking the time to write it Al.
> Not that I'm ever touching comedi code, but Hartley is, so
> I'm adding him to cc just in case he didn't see it...

I saw it.

I haven't touched this driver yet because I haven't worked out
a clean way to fix the sparse warnings in it.

I'll get to it eventually. :-)

Regards,
Hartley

--
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 08/10] staging/xgifb: Remove unnecessary bitshifts in XGI_SetCRT1ModeRegs

2013-02-04 Thread H Hartley Sweeten
On Monday, February 04, 2013 5:59 AM, Dan Carpenter wrote:
> On Sun, Feb 03, 2013 at 10:54:37PM +0100, Peter Huewe wrote:
>> Since data can only be 0x, 0x0035 or 0x0048 we can simply skip the
>> bit shifting and masking as data & 0xFF is always equal to data and
>> data & 0xFF00 is always 0.
>> So we simply use data and 0 directly and save the assignment.
>> 
>> Signed-off-by: Peter Huewe 
>> ---
>>  drivers/staging/xgifb/vb_setmode.c |6 ++
>>  1 files changed, 2 insertions(+), 4 deletions(-)
>> 
>> diff --git a/drivers/staging/xgifb/vb_setmode.c 
>> b/drivers/staging/xgifb/vb_setmode.c
>> index 6f366f4..1ff1178 100644
>> --- a/drivers/staging/xgifb/vb_setmode.c
>> +++ b/drivers/staging/xgifb/vb_setmode.c
>> @@ -1083,10 +1083,8 @@ static void XGI_SetCRT1ModeRegs(struct 
>> xgi_hw_device_info *HwDeviceExtension,
>>  data = 0x0048;
>>  }
>>  
>> -data2 = data & 0x00FF;
>> -xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data2);
>> -data2 = (data & 0xFF00) >> 8;
>> -xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, data2);
>> +xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data);
>> +xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, 0);
>
> This patch is fine.
>
> This is a fairly common pattern where people do:
>
>   write_a_char(data & 0xff);
>   write_a_char((data >> 8) & 0xff);
>
> It feels there should be a macro to do the shift and mask but I'm
> not sure what it would look like.

How about...

#define LOBYTE(x)   ((x) & 0xff)
#define HIBYTE(x)   (((x) >> 8) & 0xff)

And for completeness...

#define LOWORD  ((x) & 0x)
#define HIWORD  (((x) >> 16) & 0x)

There are a couple uses of these defines in the kernel already.
sound/synth/emux/emux_synth.c also has LO_BYTE and HI_BYTE
that do the same thing.

Of course these are probably not endian safe.

Regards,
Hartley

--
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 01/11] pcmcia/ds.h: introduce helper for pcmcia_driver module boilerplate

2013-02-06 Thread H Hartley Sweeten
Introduce the module_pcmcia_driver() macro which is a convenience macro
for pcmcia driver modules. It is intended to be used by pcmcia drivers
with init/exit sections that do nothing but register/unregister the
pcmcia driver.

Signed-off-by: H Hartley Sweeten 
---
 include/pcmcia/ds.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h
index 3bbbd78..2d56e42 100644
--- a/include/pcmcia/ds.h
+++ b/include/pcmcia/ds.h
@@ -65,6 +65,18 @@ struct pcmcia_driver {
 int pcmcia_register_driver(struct pcmcia_driver *driver);
 void pcmcia_unregister_driver(struct pcmcia_driver *driver);
 
+/**
+ * module_pcmcia_driver() - Helper macro for registering a pcmcia driver
+ * @__pcmcia_driver: pcmcia_driver struct
+ *
+ * Helper macro for pcmcia drivers which do not do anything special in module
+ * init/exit. This eliminates a lot of boilerplate. Each module may only use
+ * this macro once, and calling it replaces module_init() and module_exit().
+ */
+#define module_pcmcia_driver(__pcmcia_driver) \
+   module_driver(__pcmcia_driver, pcmcia_register_driver, \
+   pcmcia_unregister_driver)
+
 /* for struct resource * array embedded in struct pcmcia_device */
 enum {
PCMCIA_IOPORT_0,
-- 
1.8.1.1.293.gfe73786

--
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 00/11] cleanup pcmcia driver module boilerplate

2013-02-06 Thread H Hartley Sweeten
Introduce a new helper macro to remove the module boilerplate code
in pcmcia drivers.

Use the new macro throughout the tree where possible.

H Hartley Sweeten (11):
  pcmcia/ds.h: introduce helper for pcmcia_driver module boilerplate
  drivers/ata: use module_pcmcia_driver() in pcmcia drivers
  drivers/bluetooth: use module_pcmcia_driver() in pcmcia drivers
  drivers/isdn: use module_pcmcia_driver() in pcmcia drivers
  drivers/mmc: use module_pcmcia_driver() in pcmcia drivers
  drivers/net: use module_pcmcia_driver() in pcmcia drivers
  drivers/parport: use module_pcmcia_driver() in pcmcia drivers
  drivers/scsi: use module_pcmcia_driver() in pcmcia drivers
  drivers/tty: use module_pcmcia_driver() in pcmcia drivers
  drivers/usb: use module_pcmcia_driver() in pcmcia drivers
  sound/pcmcia: use module_pcmcia_driver() in pcmcia drivers

 drivers/ata/pata_pcmcia.c  | 14 +-
 drivers/bluetooth/bluecard_cs.c| 15 +--
 drivers/bluetooth/bt3c_cs.c| 15 +--
 drivers/bluetooth/btuart_cs.c  | 15 +--
 drivers/bluetooth/dtl1_cs.c| 15 +--
 drivers/isdn/hardware/avm/avm_cs.c | 14 +-
 drivers/isdn/hisax/avma1_cs.c  | 14 +-
 drivers/isdn/hisax/elsa_cs.c   | 14 +-
 drivers/isdn/hisax/sedlbauer_cs.c  | 14 +-
 drivers/isdn/hisax/teles_cs.c  | 14 +-
 drivers/mmc/host/sdricoh_cs.c  | 20 +---
 drivers/net/arcnet/com20020_cs.c   | 14 +-
 drivers/net/can/sja1000/ems_pcmcia.c   | 13 +
 drivers/net/can/sja1000/peak_pcmcia.c  | 13 +
 drivers/net/ethernet/3com/3c574_cs.c   | 14 +-
 drivers/net/ethernet/3com/3c589_cs.c   | 14 +-
 drivers/net/ethernet/8390/axnet_cs.c   | 14 +-
 drivers/net/ethernet/8390/pcnet_cs.c   | 14 +-
 drivers/net/ethernet/amd/nmclan_cs.c   | 14 +-
 drivers/net/ethernet/fujitsu/fmvj18x_cs.c  | 14 +-
 drivers/net/ethernet/smsc/smc91c92_cs.c| 14 +-
 drivers/net/ethernet/xircom/xirc2ps_cs.c   | 16 +---
 drivers/net/wireless/airo_cs.c | 14 +-
 drivers/net/wireless/atmel_cs.c| 14 +-
 drivers/net/wireless/b43/pcmcia.c  |  4 
 drivers/net/wireless/hostap/hostap_cs.c| 15 +--
 drivers/net/wireless/libertas/if_cs.c  | 25 +
 drivers/net/wireless/orinoco/orinoco_cs.c  | 16 +---
 drivers/net/wireless/orinoco/spectrum_cs.c | 16 +---
 drivers/net/wireless/wl3501_cs.c   | 14 +-
 drivers/parport/parport_cs.c   | 14 +-
 drivers/scsi/pcmcia/aha152x_stub.c | 14 +-
 drivers/scsi/pcmcia/fdomain_stub.c | 14 +-
 drivers/scsi/pcmcia/nsp_cs.c   | 17 +
 drivers/scsi/pcmcia/qlogic_stub.c  | 13 +
 drivers/scsi/pcmcia/sym53c500_cs.c | 16 +---
 drivers/tty/serial/8250/serial_cs.c| 14 +-
 drivers/usb/host/sl811_cs.c| 15 +--
 include/pcmcia/ds.h| 12 
 sound/pcmcia/pdaudiocf/pdaudiocf.c | 15 +--
 sound/pcmcia/vx/vxpocket.c | 14 +-
 41 files changed, 55 insertions(+), 539 deletions(-)

-- 
1.8.1.1.293.gfe73786

--
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 03/11] drivers/bluetooth: use module_pcmcia_driver() in pcmcia drivers

2013-02-06 Thread H Hartley Sweeten
Use the new module_pcmcia_driver() macro to remove the boilerplate
module init/exit code in the pcmcia drivers.

Signed-off-by: H Hartley Sweeten 
---
 drivers/bluetooth/bluecard_cs.c | 15 +--
 drivers/bluetooth/bt3c_cs.c | 15 +--
 drivers/bluetooth/btuart_cs.c   | 15 +--
 drivers/bluetooth/dtl1_cs.c | 15 +--
 4 files changed, 4 insertions(+), 56 deletions(-)

diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index 0d26851..6c3e3d4 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -934,17 +934,4 @@ static struct pcmcia_driver bluecard_driver = {
.remove = bluecard_detach,
.id_table   = bluecard_ids,
 };
-
-static int __init init_bluecard_cs(void)
-{
-   return pcmcia_register_driver(&bluecard_driver);
-}
-
-
-static void __exit exit_bluecard_cs(void)
-{
-   pcmcia_unregister_driver(&bluecard_driver);
-}
-
-module_init(init_bluecard_cs);
-module_exit(exit_bluecard_cs);
+module_pcmcia_driver(bluecard_driver);
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 7ffd3f4..a1aaa3b 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -760,17 +760,4 @@ static struct pcmcia_driver bt3c_driver = {
.remove = bt3c_detach,
.id_table   = bt3c_ids,
 };
-
-static int __init init_bt3c_cs(void)
-{
-   return pcmcia_register_driver(&bt3c_driver);
-}
-
-
-static void __exit exit_bt3c_cs(void)
-{
-   pcmcia_unregister_driver(&bt3c_driver);
-}
-
-module_init(init_bt3c_cs);
-module_exit(exit_bt3c_cs);
+module_pcmcia_driver(bt3c_driver);
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index 35a553a..beb262f 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -688,17 +688,4 @@ static struct pcmcia_driver btuart_driver = {
.remove = btuart_detach,
.id_table   = btuart_ids,
 };
-
-static int __init init_btuart_cs(void)
-{
-   return pcmcia_register_driver(&btuart_driver);
-}
-
-
-static void __exit exit_btuart_cs(void)
-{
-   pcmcia_unregister_driver(&btuart_driver);
-}
-
-module_init(init_btuart_cs);
-module_exit(exit_btuart_cs);
+module_pcmcia_driver(btuart_driver);
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index 036cb36..33f3a69 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -628,17 +628,4 @@ static struct pcmcia_driver dtl1_driver = {
.remove = dtl1_detach,
.id_table   = dtl1_ids,
 };
-
-static int __init init_dtl1_cs(void)
-{
-   return pcmcia_register_driver(&dtl1_driver);
-}
-
-
-static void __exit exit_dtl1_cs(void)
-{
-   pcmcia_unregister_driver(&dtl1_driver);
-}
-
-module_init(init_dtl1_cs);
-module_exit(exit_dtl1_cs);
+module_pcmcia_driver(dtl1_driver);
-- 
1.8.1.1.293.gfe73786

--
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 02/11] drivers/ata: use module_pcmcia_driver() in pcmcia drivers

2013-02-06 Thread H Hartley Sweeten
Use the new module_pcmcia_driver() macro to remove the boilerplate
module init/exit code in the pcmcia drivers.

Signed-off-by: H Hartley Sweeten 
---
 drivers/ata/pata_pcmcia.c | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c
index 958238d..40254f4 100644
--- a/drivers/ata/pata_pcmcia.c
+++ b/drivers/ata/pata_pcmcia.c
@@ -387,21 +387,9 @@ static struct pcmcia_driver pcmcia_driver = {
.probe  = pcmcia_init_one,
.remove = pcmcia_remove_one,
 };
-
-static int __init pcmcia_init(void)
-{
-   return pcmcia_register_driver(&pcmcia_driver);
-}
-
-static void __exit pcmcia_exit(void)
-{
-   pcmcia_unregister_driver(&pcmcia_driver);
-}
+module_pcmcia_driver(pcmcia_driver);
 
 MODULE_AUTHOR("Alan Cox");
 MODULE_DESCRIPTION("low-level driver for PCMCIA ATA");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
-
-module_init(pcmcia_init);
-module_exit(pcmcia_exit);
-- 
1.8.1.1.293.gfe73786

--
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 04/11] drivers/isdn: use module_pcmcia_driver() in pcmcia drivers

2013-02-06 Thread H Hartley Sweeten
Use the new module_pcmcia_driver() macro to remove the boilerplate
module init/exit code in the pcmcia drivers.

Signed-off-by: H Hartley Sweeten 
---
 drivers/isdn/hardware/avm/avm_cs.c | 14 +-
 drivers/isdn/hisax/avma1_cs.c  | 14 +-
 drivers/isdn/hisax/elsa_cs.c   | 14 +-
 drivers/isdn/hisax/sedlbauer_cs.c  | 14 +-
 drivers/isdn/hisax/teles_cs.c  | 14 +-
 5 files changed, 5 insertions(+), 65 deletions(-)

diff --git a/drivers/isdn/hardware/avm/avm_cs.c 
b/drivers/isdn/hardware/avm/avm_cs.c
index c21353d..62b8030 100644
--- a/drivers/isdn/hardware/avm/avm_cs.c
+++ b/drivers/isdn/hardware/avm/avm_cs.c
@@ -163,16 +163,4 @@ static struct pcmcia_driver avmcs_driver = {
.remove = avmcs_detach,
.id_table = avmcs_ids,
 };
-
-static int __init avmcs_init(void)
-{
-   return pcmcia_register_driver(&avmcs_driver);
-}
-
-static void __exit avmcs_exit(void)
-{
-   pcmcia_unregister_driver(&avmcs_driver);
-}
-
-module_init(avmcs_init);
-module_exit(avmcs_exit);
+module_pcmcia_driver(avmcs_driver);
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c
index 4e676bc..baad94e 100644
--- a/drivers/isdn/hisax/avma1_cs.c
+++ b/drivers/isdn/hisax/avma1_cs.c
@@ -159,16 +159,4 @@ static struct pcmcia_driver avma1cs_driver = {
.remove = avma1cs_detach,
.id_table   = avma1cs_ids,
 };
-
-static int __init init_avma1_cs(void)
-{
-   return pcmcia_register_driver(&avma1cs_driver);
-}
-
-static void __exit exit_avma1_cs(void)
-{
-   pcmcia_unregister_driver(&avma1cs_driver);
-}
-
-module_init(init_avma1_cs);
-module_exit(exit_avma1_cs);
+module_pcmcia_driver(avma1cs_driver);
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c
index ebe5691..40f6fad 100644
--- a/drivers/isdn/hisax/elsa_cs.c
+++ b/drivers/isdn/hisax/elsa_cs.c
@@ -215,16 +215,4 @@ static struct pcmcia_driver elsa_cs_driver = {
.suspend= elsa_suspend,
.resume = elsa_resume,
 };
-
-static int __init init_elsa_cs(void)
-{
-   return pcmcia_register_driver(&elsa_cs_driver);
-}
-
-static void __exit exit_elsa_cs(void)
-{
-   pcmcia_unregister_driver(&elsa_cs_driver);
-}
-
-module_init(init_elsa_cs);
-module_exit(exit_elsa_cs);
+module_pcmcia_driver(elsa_cs_driver);
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c 
b/drivers/isdn/hisax/sedlbauer_cs.c
index 90f8129..92ef62d 100644
--- a/drivers/isdn/hisax/sedlbauer_cs.c
+++ b/drivers/isdn/hisax/sedlbauer_cs.c
@@ -206,16 +206,4 @@ static struct pcmcia_driver sedlbauer_driver = {
.suspend= sedlbauer_suspend,
.resume = sedlbauer_resume,
 };
-
-static int __init init_sedlbauer_cs(void)
-{
-   return pcmcia_register_driver(&sedlbauer_driver);
-}
-
-static void __exit exit_sedlbauer_cs(void)
-{
-   pcmcia_unregister_driver(&sedlbauer_driver);
-}
-
-module_init(init_sedlbauer_cs);
-module_exit(exit_sedlbauer_cs);
+module_pcmcia_driver(sedlbauer_driver);
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c
index f2476ff..b8dd149 100644
--- a/drivers/isdn/hisax/teles_cs.c
+++ b/drivers/isdn/hisax/teles_cs.c
@@ -197,16 +197,4 @@ static struct pcmcia_driver teles_cs_driver = {
.suspend= teles_suspend,
.resume = teles_resume,
 };
-
-static int __init init_teles_cs(void)
-{
-   return pcmcia_register_driver(&teles_cs_driver);
-}
-
-static void __exit exit_teles_cs(void)
-{
-   pcmcia_unregister_driver(&teles_cs_driver);
-}
-
-module_init(init_teles_cs);
-module_exit(exit_teles_cs);
+module_pcmcia_driver(teles_cs_driver);
-- 
1.8.1.1.293.gfe73786

--
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 07/11] drivers/parport: use module_pcmcia_driver() in pcmcia drivers

2013-02-06 Thread H Hartley Sweeten
Use the new module_pcmcia_driver() macro to remove the boilerplate
module init/exit code in the pcmcia drivers.

Signed-off-by: H Hartley Sweeten 
---
 drivers/parport/parport_cs.c | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c
index 067ad51..e9b52e4 100644
--- a/drivers/parport/parport_cs.c
+++ b/drivers/parport/parport_cs.c
@@ -193,16 +193,4 @@ static struct pcmcia_driver parport_cs_driver = {
.remove = parport_detach,
.id_table   = parport_ids,
 };
-
-static int __init init_parport_cs(void)
-{
-   return pcmcia_register_driver(&parport_cs_driver);
-}
-
-static void __exit exit_parport_cs(void)
-{
-   pcmcia_unregister_driver(&parport_cs_driver);
-}
-
-module_init(init_parport_cs);
-module_exit(exit_parport_cs);
+module_pcmcia_driver(parport_cs_driver);
-- 
1.8.1.1.293.gfe73786

--
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 08/11] drivers/scsi: use module_pcmcia_driver() in pcmcia drivers

2013-02-06 Thread H Hartley Sweeten
Use the new module_pcmcia_driver() macro to remove the boilerplate
module init/exit code in the pcmcia drivers.

Signed-off-by: H Hartley Sweeten 
Cc: "Juergen E. Fischer" 
Cc: "James E.J. Bottomley" 
Cc: YOKOTA Hiroshi 
Cc: linux-s...@vger.kernel.org
---
 drivers/scsi/pcmcia/aha152x_stub.c | 14 +-
 drivers/scsi/pcmcia/fdomain_stub.c | 14 +-
 drivers/scsi/pcmcia/nsp_cs.c   | 17 +
 drivers/scsi/pcmcia/qlogic_stub.c  | 13 +
 drivers/scsi/pcmcia/sym53c500_cs.c | 16 +---
 5 files changed, 5 insertions(+), 69 deletions(-)

diff --git a/drivers/scsi/pcmcia/aha152x_stub.c 
b/drivers/scsi/pcmcia/aha152x_stub.c
index 7d1609f..df82a34 100644
--- a/drivers/scsi/pcmcia/aha152x_stub.c
+++ b/drivers/scsi/pcmcia/aha152x_stub.c
@@ -220,16 +220,4 @@ static struct pcmcia_driver aha152x_cs_driver = {
.id_table   = aha152x_ids,
.resume = aha152x_resume,
 };
-
-static int __init init_aha152x_cs(void)
-{
-   return pcmcia_register_driver(&aha152x_cs_driver);
-}
-
-static void __exit exit_aha152x_cs(void)
-{
-   pcmcia_unregister_driver(&aha152x_cs_driver);
-}
-
-module_init(init_aha152x_cs);
-module_exit(exit_aha152x_cs);
+module_pcmcia_driver(aha152x_cs_driver);
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c 
b/drivers/scsi/pcmcia/fdomain_stub.c
index 714b248..ba84769 100644
--- a/drivers/scsi/pcmcia/fdomain_stub.c
+++ b/drivers/scsi/pcmcia/fdomain_stub.c
@@ -194,16 +194,4 @@ static struct pcmcia_driver fdomain_cs_driver = {
.id_table   = fdomain_ids,
.resume = fdomain_resume,
 };
-
-static int __init init_fdomain_cs(void)
-{
-   return pcmcia_register_driver(&fdomain_cs_driver);
-}
-
-static void __exit exit_fdomain_cs(void)
-{
-   pcmcia_unregister_driver(&fdomain_cs_driver);
-}
-
-module_init(init_fdomain_cs);
-module_exit(exit_fdomain_cs);
+module_pcmcia_driver(fdomain_cs_driver);
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index b61a753..76ca00c 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -1773,19 +1773,4 @@ static struct pcmcia_driver nsp_driver = {
.suspend= nsp_cs_suspend,
.resume = nsp_cs_resume,
 };
-
-static int __init nsp_cs_init(void)
-{
-   return pcmcia_register_driver(&nsp_driver);
-}
-
-static void __exit nsp_cs_exit(void)
-{
-   pcmcia_unregister_driver(&nsp_driver);
-}
-
-
-module_init(nsp_cs_init)
-module_exit(nsp_cs_exit)
-
-/* end */
+module_pcmcia_driver(nsp_driver);
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c 
b/drivers/scsi/pcmcia/qlogic_stub.c
index bcaf89f..8d4fdc2 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -300,19 +300,8 @@ static struct pcmcia_driver qlogic_cs_driver = {
.id_table   = qlogic_ids,
.resume = qlogic_resume,
 };
-
-static int __init init_qlogic_cs(void)
-{
-   return pcmcia_register_driver(&qlogic_cs_driver);
-}
-
-static void __exit exit_qlogic_cs(void)
-{
-   pcmcia_unregister_driver(&qlogic_cs_driver);
-}
+module_pcmcia_driver(qlogic_cs_driver);
 
 MODULE_AUTHOR("Tom Zerucha, Michael Griffith");
 MODULE_DESCRIPTION("Driver for the PCMCIA Qlogic FAS SCSI controllers");
 MODULE_LICENSE("GPL");
-module_init(init_qlogic_cs);
-module_exit(exit_qlogic_cs);
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c 
b/drivers/scsi/pcmcia/sym53c500_cs.c
index f5b5273..55b0b2b 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -881,18 +881,4 @@ static struct pcmcia_driver sym53c500_cs_driver = {
.id_table   = sym53c500_ids,
.resume = sym53c500_resume,
 };
-
-static int __init
-init_sym53c500_cs(void)
-{
-   return pcmcia_register_driver(&sym53c500_cs_driver);
-}
-
-static void __exit
-exit_sym53c500_cs(void)
-{
-   pcmcia_unregister_driver(&sym53c500_cs_driver);
-}
-
-module_init(init_sym53c500_cs);
-module_exit(exit_sym53c500_cs);
+module_pcmcia_driver(sym53c500_cs_driver);
-- 
1.8.1.1.293.gfe73786

--
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 11/11] sound/pcmcia: use module_pcmcia_driver() in pcmcia drivers

2013-02-06 Thread H Hartley Sweeten
Use the new module_pcmcia_driver() macro to remove the boilerplate
module init/exit code in the pcmcia drivers.

Signed-off-by: H Hartley Sweeten 
---
 sound/pcmcia/pdaudiocf/pdaudiocf.c | 15 +--
 sound/pcmcia/vx/vxpocket.c | 14 +-
 2 files changed, 2 insertions(+), 27 deletions(-)

diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c 
b/sound/pcmcia/pdaudiocf/pdaudiocf.c
index f9b5229..8f489de 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf.c
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c
@@ -295,18 +295,5 @@ static struct pcmcia_driver pdacf_cs_driver = {
.suspend= pdacf_suspend,
.resume = pdacf_resume,
 #endif
-
 };
-
-static int __init init_pdacf(void)
-{
-   return pcmcia_register_driver(&pdacf_cs_driver);
-}
-
-static void __exit exit_pdacf(void)
-{
-   pcmcia_unregister_driver(&pdacf_cs_driver);
-}
-
-module_init(init_pdacf);
-module_exit(exit_pdacf);
+module_pcmcia_driver(pdacf_cs_driver);
diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c
index 8f93504..d4db7ec 100644
--- a/sound/pcmcia/vx/vxpocket.c
+++ b/sound/pcmcia/vx/vxpocket.c
@@ -367,16 +367,4 @@ static struct pcmcia_driver vxp_cs_driver = {
.resume = vxp_resume,
 #endif
 };
-
-static int __init init_vxpocket(void)
-{
-   return pcmcia_register_driver(&vxp_cs_driver);
-}
-
-static void __exit exit_vxpocket(void)
-{
-   pcmcia_unregister_driver(&vxp_cs_driver);
-}
-
-module_init(init_vxpocket);
-module_exit(exit_vxpocket);
+module_pcmcia_driver(vxp_cs_driver);
-- 
1.8.1.1.293.gfe73786

--
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 06/11] drivers/net: use module_pcmcia_driver() in pcmcia drivers

2013-02-06 Thread H Hartley Sweeten
Use the new module_pcmcia_driver() macro to remove the boilerplate
module init/exit code in the pcmcia drivers.

Add a comment in drivers/net/wireless/b43/pcmcia.c about why that
driver does not use the new macro.

Signed-off-by: H Hartley Sweeten 
---
 drivers/net/arcnet/com20020_cs.c   | 14 +-
 drivers/net/can/sja1000/ems_pcmcia.c   | 13 +
 drivers/net/can/sja1000/peak_pcmcia.c  | 13 +
 drivers/net/ethernet/3com/3c574_cs.c   | 14 +-
 drivers/net/ethernet/3com/3c589_cs.c   | 14 +-
 drivers/net/ethernet/8390/axnet_cs.c   | 14 +-
 drivers/net/ethernet/8390/pcnet_cs.c   | 14 +-
 drivers/net/ethernet/amd/nmclan_cs.c   | 14 +-
 drivers/net/ethernet/fujitsu/fmvj18x_cs.c  | 14 +-
 drivers/net/ethernet/smsc/smc91c92_cs.c| 14 +-
 drivers/net/ethernet/xircom/xirc2ps_cs.c   | 16 +---
 drivers/net/wireless/airo_cs.c | 14 +-
 drivers/net/wireless/atmel_cs.c| 14 +-
 drivers/net/wireless/b43/pcmcia.c  |  4 
 drivers/net/wireless/hostap/hostap_cs.c| 15 +--
 drivers/net/wireless/libertas/if_cs.c  | 25 +
 drivers/net/wireless/orinoco/orinoco_cs.c  | 16 +---
 drivers/net/wireless/orinoco/spectrum_cs.c | 16 +---
 drivers/net/wireless/wl3501_cs.c   | 14 +-
 19 files changed, 22 insertions(+), 250 deletions(-)

diff --git a/drivers/net/arcnet/com20020_cs.c b/drivers/net/arcnet/com20020_cs.c
index 5bed4c4..74dc187 100644
--- a/drivers/net/arcnet/com20020_cs.c
+++ b/drivers/net/arcnet/com20020_cs.c
@@ -333,16 +333,4 @@ static struct pcmcia_driver com20020_cs_driver = {
.suspend= com20020_suspend,
.resume = com20020_resume,
 };
-
-static int __init init_com20020_cs(void)
-{
-   return pcmcia_register_driver(&com20020_cs_driver);
-}
-
-static void __exit exit_com20020_cs(void)
-{
-   pcmcia_unregister_driver(&com20020_cs_driver);
-}
-
-module_init(init_com20020_cs);
-module_exit(exit_com20020_cs);
+module_pcmcia_driver(com20020_cs_driver);
diff --git a/drivers/net/can/sja1000/ems_pcmcia.c 
b/drivers/net/can/sja1000/ems_pcmcia.c
index 5c2f3fb..321c27e 100644
--- a/drivers/net/can/sja1000/ems_pcmcia.c
+++ b/drivers/net/can/sja1000/ems_pcmcia.c
@@ -316,15 +316,4 @@ static struct pcmcia_driver ems_pcmcia_driver = {
.remove = ems_pcmcia_remove,
.id_table = ems_pcmcia_tbl,
 };
-
-static int __init ems_pcmcia_init(void)
-{
-   return pcmcia_register_driver(&ems_pcmcia_driver);
-}
-module_init(ems_pcmcia_init);
-
-static void __exit ems_pcmcia_exit(void)
-{
-   pcmcia_unregister_driver(&ems_pcmcia_driver);
-}
-module_exit(ems_pcmcia_exit);
+module_pcmcia_driver(ems_pcmcia_driver);
diff --git a/drivers/net/can/sja1000/peak_pcmcia.c 
b/drivers/net/can/sja1000/peak_pcmcia.c
index 1a7020b..0a707f7 100644
--- a/drivers/net/can/sja1000/peak_pcmcia.c
+++ b/drivers/net/can/sja1000/peak_pcmcia.c
@@ -740,15 +740,4 @@ static struct pcmcia_driver pcan_driver = {
.remove = pcan_remove,
.id_table = pcan_table,
 };
-
-static int __init pcan_init(void)
-{
-   return pcmcia_register_driver(&pcan_driver);
-}
-module_init(pcan_init);
-
-static void __exit pcan_exit(void)
-{
-   pcmcia_unregister_driver(&pcan_driver);
-}
-module_exit(pcan_exit);
+module_pcmcia_driver(pcan_driver);
diff --git a/drivers/net/ethernet/3com/3c574_cs.c 
b/drivers/net/ethernet/3com/3c574_cs.c
index ffd8de2..6fc994f 100644
--- a/drivers/net/ethernet/3com/3c574_cs.c
+++ b/drivers/net/ethernet/3com/3c574_cs.c
@@ -1165,16 +1165,4 @@ static struct pcmcia_driver tc574_driver = {
.suspend= tc574_suspend,
.resume = tc574_resume,
 };
-
-static int __init init_tc574(void)
-{
-   return pcmcia_register_driver(&tc574_driver);
-}
-
-static void __exit exit_tc574(void)
-{
-   pcmcia_unregister_driver(&tc574_driver);
-}
-
-module_init(init_tc574);
-module_exit(exit_tc574);
+module_pcmcia_driver(tc574_driver);
diff --git a/drivers/net/ethernet/3com/3c589_cs.c 
b/drivers/net/ethernet/3com/3c589_cs.c
index a556c01..078480a 100644
--- a/drivers/net/ethernet/3com/3c589_cs.c
+++ b/drivers/net/ethernet/3com/3c589_cs.c
@@ -928,16 +928,4 @@ static struct pcmcia_driver tc589_driver = {
.suspend= tc589_suspend,
.resume = tc589_resume,
 };
-
-static int __init init_tc589(void)
-{
-   return pcmcia_register_driver(&tc589_driver);
-}
-
-static void __exit exit_tc589(void)
-{
-   pcmcia_unregister_driver(&tc589_driver);
-}
-
-module_init(init_tc589);
-module_exit(exit_tc589);
+module_pcmcia_driver(tc589_driver);
diff --git a/drivers/net/ethernet/8390/axnet_cs.c 
b/drivers/net/ethernet/8390/axnet_cs.c
index e1b3941..d801c141 100644
--- a/drivers/net/ethernet/8390/axnet_cs.c
+++ b/drivers

[PATCH 05/11] drivers/mmc: use module_pcmcia_driver() in pcmcia drivers

2013-02-06 Thread H Hartley Sweeten
Use the new module_pcmcia_driver() macro to remove the boilerplate
module init/exit code in the pcmcia drivers.

Signed-off-by: H Hartley Sweeten 
---
 drivers/mmc/host/sdricoh_cs.c | 20 +---
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/mmc/host/sdricoh_cs.c b/drivers/mmc/host/sdricoh_cs.c
index 7009f17..50adbd1 100644
--- a/drivers/mmc/host/sdricoh_cs.c
+++ b/drivers/mmc/host/sdricoh_cs.c
@@ -543,25 +543,7 @@ static struct pcmcia_driver sdricoh_driver = {
.suspend = sdricoh_pcmcia_suspend,
.resume = sdricoh_pcmcia_resume,
 };
-
-/*\
- *   *
- * Driver init/exit  *
- *   *
-\*/
-
-static int __init sdricoh_drv_init(void)
-{
-   return pcmcia_register_driver(&sdricoh_driver);
-}
-
-static void __exit sdricoh_drv_exit(void)
-{
-   pcmcia_unregister_driver(&sdricoh_driver);
-}
-
-module_init(sdricoh_drv_init);
-module_exit(sdricoh_drv_exit);
+module_pcmcia_driver(sdricoh_driver);
 
 module_param(switchlocked, uint, 0444);
 
-- 
1.8.1.1.293.gfe73786

--
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 09/11] drivers/tty: use module_pcmcia_driver() in pcmcia drivers

2013-02-06 Thread H Hartley Sweeten
Use the new module_pcmcia_driver() macro to remove the boilerplate
module init/exit code in the pcmcia drivers.

Signed-off-by: H Hartley Sweeten 
Cc: Greg Kroah-Hartman 
Cc: Jiri Slaby 
Cc: linux-ser...@vger.kernel.org
---
 drivers/tty/serial/8250/serial_cs.c | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/tty/serial/8250/serial_cs.c 
b/drivers/tty/serial/8250/serial_cs.c
index b7d48b3..1b74b88 100644
--- a/drivers/tty/serial/8250/serial_cs.c
+++ b/drivers/tty/serial/8250/serial_cs.c
@@ -852,18 +852,6 @@ static struct pcmcia_driver serial_cs_driver = {
.suspend= serial_suspend,
.resume = serial_resume,
 };
-
-static int __init init_serial_cs(void)
-{
-   return pcmcia_register_driver(&serial_cs_driver);
-}
-
-static void __exit exit_serial_cs(void)
-{
-   pcmcia_unregister_driver(&serial_cs_driver);
-}
-
-module_init(init_serial_cs);
-module_exit(exit_serial_cs);
+module_pcmcia_driver(serial_cs_driver);
 
 MODULE_LICENSE("GPL");
-- 
1.8.1.1.293.gfe73786

--
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 10/11] drivers/usb: use module_pcmcia_driver() in pcmcia drivers

2013-02-06 Thread H Hartley Sweeten
Use the new module_pcmcia_driver() macro to remove the boilerplate
module init/exit code in the pcmcia drivers.

Signed-off-by: H Hartley Sweeten 
Cc: Greg Kroah-Hartman 
Cc: linux-...@vger.kernel.org
---
 drivers/usb/host/sl811_cs.c | 15 +--
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c
index 3b6f50e..469564e 100644
--- a/drivers/usb/host/sl811_cs.c
+++ b/drivers/usb/host/sl811_cs.c
@@ -200,17 +200,4 @@ static struct pcmcia_driver sl811_cs_driver = {
.remove = sl811_cs_detach,
.id_table   = sl811_ids,
 };
-
-/**/
-
-static int __init init_sl811_cs(void)
-{
-   return pcmcia_register_driver(&sl811_cs_driver);
-}
-module_init(init_sl811_cs);
-
-static void __exit exit_sl811_cs(void)
-{
-   pcmcia_unregister_driver(&sl811_cs_driver);
-}
-module_exit(exit_sl811_cs);
+module_pcmcia_driver(sl811_cs_driver);
-- 
1.8.1.1.293.gfe73786

--
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: [Q]staging/comedi: Considation of *_find_boardinfo possible?

2013-01-29 Thread H Hartley Sweeten
On Tuesday, January 29, 2013 4:42 PM, Peter Hüwe wrote:
> Hi,
>
> while analyzing the comedi drivers, I noticed that quite a lot of them use a 
> more or less similar find_boardinfo function.



> The names and the exact implementation differ slightly, but in most cases it 
> boils down to:
>   unsigned int i;
>
>   for (i = 0; i < ARRAY_SIZE(__BOARD_ARRAY__); i++)
>   if (pcidev->device == __BOARD_ARRAY__[i].device_id)
>   return &__BOARD_ARRAY__[i];
>   return NULL;
>
> unfortunately the __BOARD_ARRAY__ is always of a different type (but all 
> contain the device_id field) and size.
>
>
> ---> is there a way to consolidate these functions into one function (which 
> can operate on the different types) ?  It's almost a bit like 'templates'.
> Maybe with some gcc extensions or kernel magic functions ?
>
> I already thought about passing a void pointer to the __BOARD_ARRAY__ and the 
> size of one element of the __BOARD_ARRAY__ and doing pointer calculations - 
> but I guess there must be a better way.
>
> Or is the only option to write a macro ?

As you noticed, the problem is the driver specific definition of the struct used
to hold the boardinfo.

In drivers.c, the comedi_recognize() function actually access the boardinfo
in order to support the COMEDI_DEVCONFIG ioctl. There is a comment above
it giving a description of how it works.

There might be a way to do this in a generic way. The problem is that the
drivers use different names for "common" information and the data is
packed in the structs differently so accessing it generically is a bit 
difficult,
if not impossible.

I have been trying to remove as much of this boardinfo stuff from the drivers
as possible. For now I think the current implementation is fairly clean.

For the PnP bus drivers that use the auto_attach mechanism I have some ideas
to get rid of the find_boardinfo functions but I need to work out the kinks 
first.

Please wait on "fixing" any of this until a good solution is worked out.

Thanks,
Hartley

--
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 -next] staging: comedi: ISA DMA drivers should depend on ISA_DMA_API

2013-01-30 Thread H Hartley Sweeten
On Wednesday, January 30, 2013 5:00 AM, Geert Uytterhoeven wrote:

> m68k allmodconfig:



> Make PCL816, PCL818, DAS16, DAS1800, DT282X, and NI_AT_A2150 depend on
> ISA_DMA_API to fix this.
>
> Signed-off-by: Geert Uytterhoeven 

Looks like we have the first fallout from Greg's patch to enable comedi for
all architectures... :-)

Reviewed-by: H Hartley Sweeten 



RE: [Q]staging/comedi: Considation of *_find_boardinfo possible?

2013-01-30 Thread H Hartley Sweeten
On Wednesday, January 30, 2013 4:04 AM, Ian Abbott wrote:
> One way is to enumerate the possible indices of the custom board array 
> as a set of enum constants, initialize the custom board array using 
> designated element initializers (indexed by the enum constants) and 
> include the same enum constant in the 'driver_data' member of the struct 
> pci_device_id elements of the module's PCI device table.  Then the 
> module's PCI driver's probe function can index directly into the custom 
> board array without searching.

Ian,

The method you describe is what I was also considering. The only
problem is it will introduce a lot of churn in the drivers.

I'm hoping to eliminate all the unnecessary boardinfo's from the
drivers before going down this path.

> The missing link in the above is passing the index from the 
> 'driver_data' through to the modules' comedi_driver's 'auto_attach' 
> function. The 'comedi_pci_auto_config()' function does not currently 
> have a parameter for passing this information, but the underlying 
> 'comedi_auto_config()' function does.  Either the existing 
> 'comedi_pci_auto_config()' function could be extended, or a separate 
> extended version of the function could be added (maybe as an inline 
> function in comedidev.h), or the modules could call 
> 'comedi_auto_config()' directly.
>
> We have posted patches to add extra context to 
> 'comedi_pci_auto_config()' before, but they weren't applied because we 
> didn't have a clear use case for them.  Now we have, but I wouldn't mind 
> leaving the existing function alone and adding a new one.

Yah, that was the intention of my patches. They just weren't clear. Also,
my patches changed the type on the 'context' which appears to not be
needed.

> The nice thing is that it's all under the control of the individual drivers.
>
> Here's some code to illustrate what I'm on about in the above description:
>
> struct foobar_board {
>   const char *name;
>   unsigned int ai_chans;
>   unsigned int ai_bits;
> };

I would also like to make a common "boardinfo" struct that the comedi
core can then use in the comedi_recognize() and comedi_report_boards()
functions to remove the need for the pointer math. Something like:

struct comedi_board {
const char *name;
const void *private;
};

The comedi_driver then could be changed to:

+   const struct comedi_board *boards;
-   /* number of elements in board_name and board_id arrays */
-   unsigned int num_names;
-   const char *const *board_name;
-   /* offset in bytes from one board name pointer to the next */
-   int offset;
};

The board_ptr in comedi_device would then change to:

+   const struct comedi_board *board_ptr;
-   const void *board_ptr;

The comedi_board() helper would also need changed:

static inline const void *comedi_board(const struct comedi_device *dev)
{
+   return (dev->board_ptr) ? dev->board_ptr->private : NULL;
-   return dev->board_ptr;
}

It still returns the driver specific boardinfo as a const void *.

The common comedi_board would also allow removing the board_name
from the comedi_device. A helper function could just fetch it:

static const char *comedi_board_name(struct comedi_device *dev)
{
return (dev->board_ptr) ? dev->board_ptr->name : 
dev->driver->driver_name;
}

> enum foobar_board_nums {
>   bn_foo,
>   bn_bar,
>   bn_baz
> };
>
> static const struct foobar_board foobar_boards[] = {
>   [bn_foo] = {
>   .name = "foo",
>   .ai_chans = 4,
>   .ai_bits = 12,
>   },
>   [bn_bar] = {
>   .name = "bar",
>   .ai_chans = 4,
>   .ai_bits = 16,
>   },
>   [bn_baz] = {
>   .name = "baz",
>   .ai_chans = 8,
>   .ai_bits = 16,
>   },
> };

Using the common comedi_board would change this a bit:

static const struct foobar_board[] = {
[bn_foo] = {
.ai_chans = 4,
.ai_bits = 12,
},
[bn_bar] = {
.ai_chans = 4,
.ai_bits = 16,
},
[bn_baz] = {
.ai_chans = 8,
.ai_bits = 16,
},
};

static const struct comedi_board foobar_boards[] = {
[bn_foo] = {
.name = "foo",
.private = &foorbar_info[bn_foo],
},
[bn_bar] = {
.name = "bar",
.private = &foorbar_info[bn_bar],
},
[bn_baz] = {
.name = "baz",
.private = &foorbar_info[bn_baz],
},
};

Any other "common" information that the comedi core needs to
access could be added to comedi_board. All the driver specific
information stays in the private struct.

> static int foobar_auto_attach(struct comedi_device *dev,
> unsigned long context_bn)
> {
>   struct pci_dev *pcidev = comedi_to_pci_dev(dev);
>   struct fooba

RE: [-next] staging/comedi regressions

2013-03-14 Thread H Hartley Sweeten
On Thursday, March 14, 2013 12:33 PM, Geert Uytterhoeven wrote:
> On Tue, Mar 12, 2013 at 11:21 PM, Greg Kroah-Hartman 
>  wrote:
>> On Tue, Mar 12, 2013 at 11:13:50PM +0100, Geert Uytterhoeven wrote:
>>> m68k/allmodconfig:
>>>
>>> drivers/staging/comedi/drivers/ni_atmio.c: In function 
>>> ‘ni_isapnp_find_board’:
>>> drivers/staging/comedi/drivers/ni_atmio.c:353: error: ‘n_ni_boards’
>>> undeclared (first use in this function)
>>> drivers/staging/comedi/drivers/ni_atmio.c:353: error: (Each undeclared
>>> identifier is reported only once
>>> drivers/staging/comedi/drivers/ni_atmio.c:353: error: for each
>>> function it appears in.)
>>> drivers/staging/comedi/drivers/ni_atmio.c: In function ‘ni_getboardtype’:
>>> drivers/staging/comedi/drivers/ni_atmio.c:391: error: ‘n_ni_boards’
>>> undeclared (first use in this function)
>>> drivers/staging/comedi/drivers/ni_atmio.c: In function ‘ni_atmio_attach’:
>>> drivers/staging/comedi/drivers/ni_atmio.c:470: error: ‘boardtype’
>>> undeclared (first use in this function)
>>>
>>> http://kisskb.ellerman.id.au/kisskb/buildresult/8392062/
>>
>> Hartley already fixed it, this will show up in the next linux-next tree
>> as I commited the fix a few hours ago.
>
> Thanks, but now it fails differently:
>
> http://kisskb.ellerman.id.au/kisskb/buildresult/8398995/
> drivers/staging/comedi/drivers/ni_atmio.c:472:2: error: expected ';'
> before 'printk'
>
> There's a semicolon missing on the previous line.

Grrr... Sorry about that.

Patch coming in a minute.

Regards,
Hartley



RE: [PATCH] staging: comedi: drivers: ni_atmio.c: Add a missing semicolon

2013-03-15 Thread H Hartley Sweeten
On Friday, March 15, 2013 2:41 AM, Ian Abbott wrote:
> On 2013-03-15 08:14, Kumar Amit Mehta wrote:
>> fix a missing end-of-statement by adding a semicolon.
>>
>> Signed-off-by: Kumar Amit Mehta 
>> ---
>>   drivers/staging/comedi/drivers/ni_atmio.c |2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/comedi/drivers/ni_atmio.c 
>> b/drivers/staging/comedi/drivers/ni_atmio.c
>> index 279f2cd..37372a1 100644
>> --- a/drivers/staging/comedi/drivers/ni_atmio.c
>> +++ b/drivers/staging/comedi/drivers/ni_atmio.c
>> @@ -467,7 +467,7 @@ static int ni_atmio_attach(struct comedi_device *dev,
>>  return -EIO;
>>
>>  dev->board_ptr = ni_boards + board;
>> -boardtype = comedi_board(dev)
>> +boardtype = comedi_board(dev);
>>
>>  printk(" %s", boardtype->name);
>>  dev->board_name = boardtype->name;
>
> Ironically, that was introduced by a patch titled "staging: comedi: 
> ni_atmio: fix build errors". :-)

My only excuse is that the coffee machine was broken...

Actually, I just realized that this driver as well as the others that depend
on ISAPNP were not being compiled on my Debian 6.0 64bit system . I
hacked my config to build the ones that depend on ISA but missed the
ISAPNP ones.

Sorry about the trouble.

Hartley

--
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 10/10] drivers: misc: use module_platform_driver_probe()

2013-03-15 Thread H Hartley Sweeten
On Thursday, March 14, 2013 6:58 AM, Arnd Bergmann wrote:
> On Thursday 14 March 2013, Fabio Porcedda wrote:
>> This patch converts the drivers to use the
>> module_platform_driver_probe() macro which makes the code smaller and
>> a bit simpler.
>> 
>> Signed-off-by: Fabio Porcedda 
>> Cc: Greg Kroah-Hartman 
>> Cc: Arnd Bergmann 
>> ---
>>  drivers/misc/atmel_pwm.c  | 12 +---
>>  drivers/misc/ep93xx_pwm.c | 13 +
>>  2 files changed, 2 insertions(+), 23 deletions(-)
>
> The patch itself seems fine, but there are two issues around it:
>
> * The PWM drivers should really get moved to drivers/pwm and converted to the 
> new
>   PWM subsystem. I don't know if Hartley or Hans-Christian have plans to do
>   that already.

Arnd,

Ill look at converting the ep93xx pwm driver to the PWM subsystem. The only 
issue is
the current driver exposes a sysfs interface that I think is not available in 
that subsystem.

>* Regarding the use of module_platform_driver_probe, I'm a little worried about
>  the interactions with deferred probing. I don't think there are any 
> regressions,
>  but we should probably make people aware that one cannot return -EPROBE_DEFER
>  from a platform_driver_probe function.

The ep93xx pwm driver does not need to use platform_driver_probe(). It can be 
changed
to use module_platform_driver() by just moving the .probe to the 
platform_driver. This
driver was added before module_platform_driver() was available and I used the
platform_driver_probe() thinking it would save a couple lines of code.

I'll change this in a bit. Right now I'm trying to work out why kernel 3.8 is 
not booting
on the ep93xx. I had 3.6.6 on my development board and 3.7 works fine but 3.8 
hangs
without uncompressing the kernel.

Regards,
Hartley



--
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] video: ep93xx_fb: include for devm_ioremap()

2013-03-15 Thread H Hartley Sweeten
commit be867814 "drivers/video/ep93xx-fb.c: use devm_ functions"

Introduced a build error:

drivers/video/ep93xx-fb.c: In function 'ep93xxfb_probe':
drivers/video/ep93xx-fb.c:532: error: implicit declaration of function 
'devm_ioremap'
drivers/video/ep93xx-fb.c:533: warning: assignment makes pointer from integer 
without a cast

Include  to pickup the declaration of 'devm_ioremap'.

Signed-off-by: H Hartley Sweeten 
Cc: 
Cc: Florian Tobias Schandinat 
Cc: Ryan Mallon 
Cc: Damien Cassou 

---
 drivers/video/ep93xx-fb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/video/ep93xx-fb.c b/drivers/video/ep93xx-fb.c
index 3f2519d..e06cd5d 100644
--- a/drivers/video/ep93xx-fb.c
+++ b/drivers/video/ep93xx-fb.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
-- 
1.8.1.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/3] backlight: ep93xx_bl: fix section mismatch

2013-03-15 Thread H Hartley Sweeten
Remove the __init tag from ep93xxbl_probe() to fix the section
mismatch warning.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Richard Purdie 
Cc: Florian Tobias Schandinat 
---
 drivers/video/backlight/ep93xx_bl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/backlight/ep93xx_bl.c 
b/drivers/video/backlight/ep93xx_bl.c
index ef3e21e..17b8abb 100644
--- a/drivers/video/backlight/ep93xx_bl.c
+++ b/drivers/video/backlight/ep93xx_bl.c
@@ -60,7 +60,7 @@ static const struct backlight_ops ep93xxbl_ops = {
.get_brightness = ep93xxbl_get_brightness,
 };
 
-static int __init ep93xxbl_probe(struct platform_device *dev)
+static int ep93xxbl_probe(struct platform_device *dev)
 {
struct ep93xxbl *ep93xxbl;
struct backlight_device *bl;
@@ -145,7 +145,6 @@ static struct platform_driver ep93xxbl_driver = {
.suspend= ep93xxbl_suspend,
.resume = ep93xxbl_resume,
 };
-
 module_platform_driver(ep93xxbl_driver);
 
 MODULE_DESCRIPTION("EP93xx Backlight Driver");
-- 
1.8.1.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 3/3] misc: ep93xx_pwm.c: fix section mismatch and use module_platform_driver

2013-03-15 Thread H Hartley Sweeten
Remove the __init tags from the ep93xx_pwm_probe() and
ep93xx_pwm_remove() functions to fix the section mismatch
warnings.

Use module_platform_driver() to remove the init/exit boilerplate.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Arnd Bergmann 
Cc: Greg Kroah-Hartman 
---
 drivers/misc/ep93xx_pwm.c | 21 +
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/misc/ep93xx_pwm.c b/drivers/misc/ep93xx_pwm.c
index 16d7179..4a674f6 100644
--- a/drivers/misc/ep93xx_pwm.c
+++ b/drivers/misc/ep93xx_pwm.c
@@ -269,7 +269,7 @@ static const struct attribute_group ep93xx_pwm_sysfs_files 
= {
.attrs  = ep93xx_pwm_attrs,
 };
 
-static int __init ep93xx_pwm_probe(struct platform_device *pdev)
+static int ep93xx_pwm_probe(struct platform_device *pdev)
 {
struct ep93xx_pwm *pwm;
struct resource *res;
@@ -339,7 +339,7 @@ fail_no_mem:
return err;
 }
 
-static int __exit ep93xx_pwm_remove(struct platform_device *pdev)
+static int ep93xx_pwm_remove(struct platform_device *pdev)
 {
struct ep93xx_pwm *pwm = platform_get_drvdata(pdev);
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -362,21 +362,10 @@ static struct platform_driver ep93xx_pwm_driver = {
.name   = "ep93xx-pwm",
.owner  = THIS_MODULE,
},
-   .remove = __exit_p(ep93xx_pwm_remove),
+   .probe  = ep93xx_pwm_probe,
+   .remove = ep93xx_pwm_remove,
 };
-
-static int __init ep93xx_pwm_init(void)
-{
-   return platform_driver_probe(&ep93xx_pwm_driver, ep93xx_pwm_probe);
-}
-
-static void __exit ep93xx_pwm_exit(void)
-{
-   platform_driver_unregister(&ep93xx_pwm_driver);
-}
-
-module_init(ep93xx_pwm_init);
-module_exit(ep93xx_pwm_exit);
+module_platform_driver(ep93xx_pwm_driver);
 
 MODULE_AUTHOR("Matthieu Crapet , "
  "H Hartley Sweeten ");
-- 
1.8.1.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 0/3] cleanup some arm/ep93xx drivers

2013-03-15 Thread H Hartley Sweeten
Fix a couple section mismatch warnings and convert two of the ep93xx
drivers to use module_platform_driver.

H Hartley Sweeten (3):
  backlight: ep93xx_bl: fix section mismatch
  video: ep93xx-fb.c: fix section mismatch and use module_platform_driver
  misc: ep93xx_pwm.c: fix section mismatch and use module_platform_driver

 drivers/misc/ep93xx_pwm.c           | 21 +
 drivers/video/backlight/ep93xx_bl.c |  3 +--
 drivers/video/ep93xx-fb.c           | 18 +++---
 3 files changed, 9 insertions(+), 33 deletions(-)

-- 
1.8.1.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/3] video: ep93xx-fb.c: fix section mismatch and use module_platform_driver

2013-03-15 Thread H Hartley Sweeten
Remove the __init tags from the ep93xxfb_calc_fbsize() and
ep93xxfb_alloc_videomem() functions to fix the section mismatch
warnings.

Use module_platform_driver() to remove the init/exit boilerplate.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Florian Tobias Schandinat 
---
 drivers/video/ep93xx-fb.c | 18 +++---
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/video/ep93xx-fb.c b/drivers/video/ep93xx-fb.c
index e06cd5d..ee1ee54 100644
--- a/drivers/video/ep93xx-fb.c
+++ b/drivers/video/ep93xx-fb.c
@@ -419,7 +419,7 @@ static struct fb_ops ep93xxfb_ops = {
.fb_mmap= ep93xxfb_mmap,
 };
 
-static int __init ep93xxfb_calc_fbsize(struct ep93xxfb_mach_info *mach_info)
+static int ep93xxfb_calc_fbsize(struct ep93xxfb_mach_info *mach_info)
 {
int i, fb_size = 0;
 
@@ -441,7 +441,7 @@ static int __init ep93xxfb_calc_fbsize(struct 
ep93xxfb_mach_info *mach_info)
return fb_size;
 }
 
-static int __init ep93xxfb_alloc_videomem(struct fb_info *info)
+static int ep93xxfb_alloc_videomem(struct fb_info *info)
 {
struct ep93xx_fbi *fbi = info->par;
char __iomem *virt_addr;
@@ -627,19 +627,7 @@ static struct platform_driver ep93xxfb_driver = {
.owner  = THIS_MODULE,
},
 };
-
-static int ep93xxfb_init(void)
-{
-   return platform_driver_register(&ep93xxfb_driver);
-}
-
-static void __exit ep93xxfb_exit(void)
-{
-   platform_driver_unregister(&ep93xxfb_driver);
-}
-
-module_init(ep93xxfb_init);
-module_exit(ep93xxfb_exit);
+module_platform_driver(ep93xxfb_driver);
 
 MODULE_DESCRIPTION("EP93XX Framebuffer Driver");
 MODULE_ALIAS("platform:ep93xx-fb");
-- 
1.8.1.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/


RE: [PATCH] staging: comedi: remove pointer math for subdevice access

2012-09-04 Thread H Hartley Sweeten
On Tuesday, September 04, 2012 11:34 AM, Greg KH wrote:
> On Mon, Aug 20, 2012 at 04:59:16PM -0700, H Hartley Sweeten wrote:
>> Convert all the comedi_subdevice pointer access from pointer
>> math to array access.
>> 
>> Signed-off-by: H Hartley Sweeten 
>> Cc: Dan Carpenter 
>> Cc: Ian Abbott 
>
> This patch doesn't seem to apply, care to break it up into smaller
> pieces, and also fold in your "fix the build" patch as well?  That way
> we have a chance to get it applied :)

Not a problem. Thanks!

Hartley

--
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/3] staging: comedi: addi-data: remove some unnecessary files

2012-09-04 Thread H Hartley Sweeten
Remove a couple of the addi-data files that are either not built under any
configuration or are unnecessary due to code duplication in another file.

H Hartley Sweeten (3):
  staging: comedi: addi_apci_all.c: remove unused file
  staging: comedi: amcc_s5933_58.h: remove unused file
  staging: comedi: addi_amcc_S5920.[ch]: remove unnecessary files

 .../comedi/drivers/addi-data/addi_amcc_S5920.c | 195 -
 .../comedi/drivers/addi-data/addi_amcc_S5920.h |  27 --
 .../comedi/drivers/addi-data/amcc_s5933_58.h   | 453 -
 .../comedi/drivers/addi-data/hwdrv_apci3200.c  |  12 +-
 drivers/staging/comedi/drivers/addi_apci_all.c |  18 -
 5 files changed, 7 insertions(+), 698 deletions(-)
 delete mode 100644 drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.c
 delete mode 100644 drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.h
 delete mode 100644 drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h
 delete mode 100644 drivers/staging/comedi/drivers/addi_apci_all.c

-- 
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 1/3] staging: comedi: addi_apci_all.c: remove unused file

2012-09-04 Thread H Hartley Sweeten
The Makefile for the comedi subsystem does not compile this file
for any .config selection. This file would allow building one big
driver to support all the addi-data cards.

The addi-data drivers are a big enough mess as-is. Just remove this
file.

Signed-off-by: H Hartley Sweeten 
Cc: Iam Abbott 
Cc: Greg-Kroah Hartman 
---
 drivers/staging/comedi/drivers/addi_apci_all.c | 18 --
 1 file changed, 18 deletions(-)
 delete mode 100644 drivers/staging/comedi/drivers/addi_apci_all.c

diff --git a/drivers/staging/comedi/drivers/addi_apci_all.c 
b/drivers/staging/comedi/drivers/addi_apci_all.c
deleted file mode 100644
index aeb1b26..000
--- a/drivers/staging/comedi/drivers/addi_apci_all.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#define CONFIG_APCI_035  1
-#define CONFIG_APCI_1032 1
-#define CONFIG_APCI_1500 1
-#define CONFIG_APCI_1516 1
-#define CONFIG_APCI_1564 1
-#define CONFIG_APCI_16XX 1
-#define CONFIG_APCI_1710 1
-#define CONFIG_APCI_2016 1
-#define CONFIG_APCI_2032 1
-#define CONFIG_APCI_2200 1
-#define CONFIG_APCI_3001 1
-#define CONFIG_APCI_3120 1
-#define CONFIG_APCI_3200 1
-#define CONFIG_APCI_3300 1
-#define CONFIG_APCI_3501 1
-#define CONFIG_APCI_3XXX 1
-
-#include "addi-data/addi_common.c"
-- 
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 3/3] staging: comedi: addi_amcc_S5920.[ch]: remove unnecessary files

2012-09-04 Thread H Hartley Sweeten
The addi_amcc_S5920.c file only has the function i_AddiHeaderRW_ReadEeprom()
in it. The addi_amcc_S5920.h file has a prototype for this function and a
couple defines for the magic numbers used when accessing the eeprom.

The .c file is not actually built by any .config selection, or by an

The .h file is only #include'd by the hwdrv_apci3200.c file. That file
actually has a local version of the i_AddiHeaderRW_ReadEeprom() function
that is identical to the one in the .c file.

Just move the #define's from the .h file into hwdrv_apci3200.c and remove
the addi_amcc_S5920.[ch] files.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 .../comedi/drivers/addi-data/addi_amcc_S5920.c | 195 -
 .../comedi/drivers/addi-data/addi_amcc_S5920.h |  27 ---
 .../comedi/drivers/addi-data/hwdrv_apci3200.c  |  12 +-
 3 files changed, 7 insertions(+), 227 deletions(-)
 delete mode 100644 drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.c
 delete mode 100644 drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.h

diff --git a/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.c 
b/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.c
deleted file mode 100644
index b973095..000
--- a/drivers/staging/comedi/drivers/addi-data/addi_amcc_S5920.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/**
-@verbatim
-
-Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
-
-   ADDI-DATA GmbH
-   Dieselstrasse 3
-   D-77833 Ottersweier
-   Tel: +19(0)7223/9493-0
-   Fax: +49(0)7223/9493-92
-   http://www.addi-data.com
-   i...@addi-data.com
-
-This program is free software; you can redistribute it and/or modify it under 
the terms of the GNU General Public License as published by the Free Software 
Foundation; either version 2 of the License, or (at your option) any later 
version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along with 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple 
Place, Suite 330, Boston, MA 02111-1307 USA
-
-You should also find the complete GPL in the COPYING file accompanying this 
source code.
-
-@endverbatim
-*/
-/*
-  +---+
-  | (C) ADDI-DATA GmbH  Dieselstraße 3   D-77833 Ottersweier  |
-  +---+
-  | Tel : +49 (0) 7223/9493-0 | email: i...@addi-data.com |
-  | Fax : +49 (0) 7223/9493-92| Internet : http://www.addi-data.com   |
-  +---+---+
-  | Project : ADDI HEADER READ WRITER | Compiler   : Visual C++   |
-  | Module name : S5920.cpp   | Version: 6.0  |
-  +---+---+
-  | Author : E. LIBS  Date : 02/05/2002   |
-  +---+
-  | Description   : DLL with the S5920 PCI Controller functions   |
-  +---+
-  | UPDATE'S  |
-  +---+
-  |   Date   |   Author  |  Description of updates|
-  +--+---++
-  | 28/08/02 | LIBS Eric | Add return codes each time a function of the   |
-  |  |   | Addi Library is called |
-  +---+
-  | 31/07/03 | KRAUTH J. | Changes for the MSX-Box|
-  +---+
-*/
-
-#include "addi_amcc_S5920.h"
-
-/*++*/
-/*| Function   Name   : int i_AddiHeaderRW_ReadEeprom  
|*/
-/*|   (inti_NbOfWordsToRead,   
|*/
-/*|unsigned int dw_PCIBoardEepromAddress,  
   |*/
-/*|unsigned short   w_EepromStartAddress,  
  |*/
-/*|unsigned short * pw_DataRead)   
   |*/
-/*++*/
-/*| Task  : Read word from the 5920 eeprom.
|*/
-/*+-

[PATCH 2/3] staging: comedi: amcc_s5933_58.h: remove unused file

2012-09-04 Thread H Hartley Sweeten
Nothing in the comedi subsystem references this header file. It's
actually almost a straight copy of the addi_amcc_s5933.h file anyway.
Just remove the file.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 .../comedi/drivers/addi-data/amcc_s5933_58.h   | 453 -
 1 file changed, 453 deletions(-)
 delete mode 100644 drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h

diff --git a/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h 
b/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h
deleted file mode 100644
index c26c28c..000
--- a/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h
+++ /dev/null
@@ -1,453 +0,0 @@
-/*
-   Modified by umesh on 16th may 2001
-   Modified by sarath on 22nd may 2001
-*/
-
-/*
-comedi/drivers/amcc_s5933_v_58.h
-
-Stuff for AMCC S5933 PCI Controller
-
-Author: Michal Dobes 
-
-Inspirated from general-purpose AMCC S5933 PCI Matchmaker driver
-made by Andrea Cisternino  
-and as result of espionage from MITE code made by David A. Schleef.
-Thanks to AMCC for their on-line documentation and bus master DMA
-example.
-*/
-
-#ifndef _AMCC_S5933_H_
-#define _AMCC_S5933_H_
-
-#include 
-#include "../../comedidev.h"
-
-/***Added by sarath for compatibility with APCI3120
-
-*/
-
-#define FIFO_ADVANCE_ON_BYTE_2 0x2000  /*  written on base0 */
-
-#define AMWEN_ENABLE 0x02  /*  added for step 6 dma 
written on base2 */
-#define A2P_FIFO_WRITE_ENABLE0x01
-
-#define AGCSTS_TC_ENABLE  0x1000   /*  Added for transfer 
count enable bit */
-
-/* ADDON RELATED ADDITIONS */
-/* Constant */
-#define APCI3120_ENABLE_TRANSFER_ADD_ON_LOW   0x00
-#define APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH  0x1200
-#define APCI3120_A2P_FIFO_MANAGEMENT  0x04000400L
-#define APCI3120_AMWEN_ENABLE 0x02
-#define APCI3120_A2P_FIFO_WRITE_ENABLE0x01
-#define APCI3120_FIFO_ADVANCE_ON_BYTE_2   0x2000L
-#define APCI3120_ENABLE_WRITE_TC_INT  0x4000L
-#define APCI3120_CLEAR_WRITE_TC_INT   0x0004L
-#define APCI3120_DISABLE_AMWEN_AND_A2P_FIFO_WRITE 0x0
-#define APCI3120_DISABLE_BUS_MASTER_ADD_ON0x0
-#define APCI3120_DISABLE_BUS_MASTER_PCI   0x0
-
- /*  ADD_ON ::: this needed since apci supports 16 bit interface to add on */
-#define APCI3120_ADD_ON_AGCSTS_LOW   0x3C
-#define APCI3120_ADD_ON_AGCSTS_HIGH  APCI3120_ADD_ON_AGCSTS_LOW + 2
-#define APCI3120_ADD_ON_MWAR_LOW 0x24
-#define APCI3120_ADD_ON_MWAR_HIGHAPCI3120_ADD_ON_MWAR_LOW + 2
-#define APCI3120_ADD_ON_MWTC_LOW 0x058
-#define APCI3120_ADD_ON_MWTC_HIGHAPCI3120_ADD_ON_MWTC_LOW + 2
-
-/* AMCC */
-#define APCI3120_AMCC_OP_MCSR0x3C
-#define APCI3120_AMCC_OP_REG_INTCSR  0x38
-
-/***from here all upward definitions are added by sarath */
-
-//
-/* AMCC Operation Register Offsets - PCI*/
-//
-
-#define AMCC_OP_REG_OMB1 0x00
-#define AMCC_OP_REG_OMB2 0x04
-#define AMCC_OP_REG_OMB3 0x08
-#define AMCC_OP_REG_OMB4 0x0c
-#define AMCC_OP_REG_IMB1 0x10
-#define AMCC_OP_REG_IMB2 0x14
-#define AMCC_OP_REG_IMB3 0x18
-#define AMCC_OP_REG_IMB4 0x1c
-#define AMCC_OP_REG_FIFO 0x20
-#define AMCC_OP_REG_MWAR 0x24
-#define AMCC_OP_REG_MWTC 0x28
-#define AMCC_OP_REG_MRAR 0x2c
-#define AMCC_OP_REG_MRTC 0x30
-#define AMCC_OP_REG_MBEF 0x34
-#define AMCC_OP_REG_INTCSR   0x38
-#define  AMCC_OP_REG_INTCSR_SRC  (AMCC_OP_REG_INTCSR + 2)  /* int source */
-#define  AMCC_OP_REG_INTCSR_FEC  (AMCC_OP_REG_INTCSR + 3)  /* FIFO ctrl */
-#define AMCC_OP_REG_MCSR 0x3c
-#define  AMCC_OP_REG_MCSR_NVDATA (AMCC_OP_REG_MCSR + 2)/* Data in byte 
2 */
-#define  AMCC_OP_REG_MCSR_NVCMD  (AMCC_OP_REG_MCSR + 3)/* Command in 
byte 3 */
-
-#define AMCC_FIFO_DEPTH_DWORD  8
-#define AMCC_FIFO_DEPTH_BYTES  (8 * sizeof (u32))
-
-//
-/* AMCC Operation Registers Size - PCI  */
-//
-
-#define AMCC_OP_REG_SIZE64 /* in bytes */
-
-//
-/* AMCC Operation Register Offsets - Add-on */
-//
-
-#define AMCC_OP_REG_AIMB1 0x00
-#define AMCC_OP_REG_AIMB2   

RE: [PATCH 03/16] ARM: ep93xx: move platform_data definitions

2012-09-11 Thread H Hartley Sweeten
On Tuesday, September 11, 2012 6:00 AM, Arnd Bergmann wrote:
> Platform data for device drivers should be defined in
> include/linux/platform_data/*.h, not in the architecture
> and platform specific directories.
>
> This moves such data out of the ep93xx include directories
>
> Signed-off-by: Arnd Bergmann 
> Cc: Grant Likely 
> Cc: Hartley Sweeten 
> Cc: Ryan Mallon 
> Cc: Jeff Garzik  (supporter:SERIAL ATA
> Cc: Vinod Koul 
> Cc: Dan Williams 
> Cc: Dmitry Torokhov  (maintainer:INPUT
> Cc: Florian Tobias Schandinat 
> Cc: Liam Girdwood 
> Cc: Mark Brown 
> Cc: Jaroslav Kysela 
> Cc: Takashi Iwai 
> Cc: Mika Westerberg 
> Cc: Axel Lin 
> ---
>  Documentation/spi/ep93xx_spi |2 +-
>  arch/arm/mach-ep93xx/core.c  |6 
> +++---
>  arch/arm/mach-ep93xx/dma.c   |2 +-
>  arch/arm/mach-ep93xx/edb93xx.c   |4 ++--
>  arch/arm/mach-ep93xx/simone.c|2 +-
>  arch/arm/mach-ep93xx/snappercl15.c   |2 +-
>  arch/arm/mach-ep93xx/vision_ep9307.c |4 ++--
>  drivers/ata/pata_ep93xx.c|2 +-
>  drivers/dma/ep93xx_dma.c |2 +-
>  drivers/input/keyboard/ep93xx_keypad.c   |2 +-
>  drivers/spi/spi-ep93xx.c |4 ++--
>  drivers/video/ep93xx-fb.c|2 +-
>  .../mach/dma.h => include/linux/platform_data/dma-ep93xx.h   |0
>  .../linux/platform_data/keypad-ep93xx.h  |0
>  .../ep93xx_spi.h => include/linux/platform_data/spi-ep93xx.h |0
>  .../mach/fb.h => include/linux/platform_data/video-ep93xx.h  |0
>  sound/soc/ep93xx/ep93xx-ac97.c   |2 +-
>  sound/soc/ep93xx/ep93xx-i2s.c|2 +-
>  sound/soc/ep93xx/ep93xx-pcm.c|2 +-
>  19 files changed, 20 insertions(+), 20 deletions(-)
>  rename arch/arm/mach-ep93xx/include/mach/dma.h => 
> include/linux/platform_data/dma-ep93xx.h (100%)
>  rename arch/arm/mach-ep93xx/include/mach/ep93xx_keypad.h => 
> include/linux/platform_data/keypad-ep93xx.h (100%)
>  rename arch/arm/mach-ep93xx/include/mach/ep93xx_spi.h => 
> include/linux/platform_data/spi-ep93xx.h (100%)
>  rename arch/arm/mach-ep93xx/include/mach/fb.h => 
> include/linux/platform_data/video-ep93xx.h (100%)

Acked-by: H Hartley Sweeten 

Arnd,

What about gpio-ep93xx.h? It does not have any platform_data in
it but the gpio driver (driver/gpio/gpio-ep93xx.c) does include it
from the mach-* directory.

Regards,
Hartley

--
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: staging tree closed for 3.7

2012-09-26 Thread H Hartley Sweeten
On Wednesday, September 26, 2012 10:57 AM, Greg Kroah-Hartman wrote:
> On Wed, Sep 26, 2012 at 10:56:06AM -0700, Greg Kroah-Hartman wrote:
>> 
>> With 3.6 about to be released, I've now closed the 3.7 staging-next tree
>> for new features / cleanups.  It's bug-fixes only now until 3.7-rc1 is
>> out.
>
> Oh, and if I've missed any patches that people have sent me already,
> please let me know, because I don't have them anymore.

Greg,

What about my "staging: comedi: drivers: use comedi_fc.h cmdtest helpers"?

It's quite large but does have decent diffstat:
46 files changed, 766 insertions(+), 1997 deletions(-)

If it doesn't apply due to conflicts, or you would rather just wait
until 3.7-rc1, it's not a problem.

I have updated the patch to fix the typo Ian pointed out and to remove
the Reported-by signoff from Dan if you would like me to repost it.

Regards,
Hartley

--
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 v2 10/11] spi: spi-ep93xx: convert to the queued driver infrastructure

2013-07-08 Thread H Hartley Sweeten
The SPI core provides infrastructure for standard message queueing. Use
that instead of handling it in the driver.

Signed-off-by: H Hartley Sweeten 
Acked-by: Mika Westerberg 
Cc: Ryan Mallon 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 165 ++-
 1 file changed, 19 insertions(+), 146 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index 2e64806..4c9a50c 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -26,7 +26,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -70,19 +69,13 @@
 
 /**
  * struct ep93xx_spi - EP93xx SPI controller structure
- * @lock: spinlock that protects concurrent accesses to fields @running,
- *@current_msg and @msg_queue
  * @pdev: pointer to platform device
  * @clk: clock for the controller
  * @regs_base: pointer to ioremap()'d registers
  * @sspdr_phys: physical address of the SSPDR register
  * @min_rate: minimum clock rate (in Hz) supported by the controller
  * @max_rate: maximum clock rate (in Hz) supported by the controller
- * @running: is the queue running
- * @wq: workqueue used by the driver
- * @msg_work: work that is queued for the driver
  * @wait: wait here until given transfer is completed
- * @msg_queue: queue for the messages
  * @current_msg: message that is currently processed (or %NULL if none)
  * @tx: current byte in transfer to transmit
  * @rx: current byte in transfer to receive
@@ -96,30 +89,15 @@
  * @tx_sgt: sg table for TX transfers
  * @zeropage: dummy page used as RX buffer when only TX buffer is passed in by
  *the client
- *
- * This structure holds EP93xx SPI controller specific information. When
- * @running is %true, driver accepts transfer requests from protocol drivers.
- * @current_msg is used to hold pointer to the message that is currently
- * processed. If @current_msg is %NULL, it means that no processing is going
- * on.
- *
- * Most of the fields are only written once and they can be accessed without
- * taking the @lock. Fields that are accessed concurrently are: @current_msg,
- * @running, and @msg_queue.
  */
 struct ep93xx_spi {
-   spinlock_t  lock;
const struct platform_device*pdev;
struct clk  *clk;
void __iomem*regs_base;
unsigned long   sspdr_phys;
unsigned long   min_rate;
unsigned long   max_rate;
-   boolrunning;
-   struct workqueue_struct *wq;
-   struct work_struct  msg_work;
struct completion   wait;
-   struct list_headmsg_queue;
struct spi_message  *current_msg;
size_t  tx;
size_t  rx;
@@ -230,7 +208,7 @@ static int ep93xx_spi_calc_divisors(const struct ep93xx_spi 
*espi,
/*
 * Make sure that max value is between values supported by the
 * controller. Note that minimum value is already checked in
-* ep93xx_spi_transfer().
+* ep93xx_spi_transfer_one_message().
 */
rate = clamp(rate, espi->min_rate, espi->max_rate);
 
@@ -306,54 +284,6 @@ static int ep93xx_spi_setup(struct spi_device *spi)
 }
 
 /**
- * ep93xx_spi_transfer() - queue message to be transferred
- * @spi: target SPI device
- * @msg: message to be transferred
- *
- * This function is called by SPI device drivers when they are going to 
transfer
- * a new message. It simply puts the message in the queue and schedules
- * workqueue to perform the actual transfer later on.
- *
- * Returns %0 on success and negative error in case of failure.
- */
-static int ep93xx_spi_transfer(struct spi_device *spi, struct spi_message *msg)
-{
-   struct ep93xx_spi *espi = spi_master_get_devdata(spi->master);
-   struct spi_transfer *t;
-   unsigned long flags;
-
-   if (!msg || !msg->complete)
-   return -EINVAL;
-
-   /* first validate each transfer */
-   list_for_each_entry(t, &msg->transfers, transfer_list) {
-   if (t->speed_hz && t->speed_hz < espi->min_rate)
-   return -EINVAL;
-   }
-
-   /*
-* Now that we own the message, let's initialize it so that it is
-* suitable for us. We use @msg->status to signal whether there was
-* error in transfer and @msg->state is used to hold pointer to the
-* current transfer (or %NULL if no active current transfer).
-*/
-   msg->state = NULL;
-   msg->status = 0;
-   msg->actual_length = 0;
-
-   spin_lock_irqsave(&espi->lock, flags);
-   if (!espi->running) {
-   spin_unlock_irqrestore(&espi->lock, flags);
-  

RE: [PATCH v2 09/11] spi: spi-ep93xx: move the clock divider calcs into ep93xx_spi_chip_setup()

2013-07-08 Thread H Hartley Sweeten
On Monday, July 08, 2013 5:10 AM, Mark Brown wrote:
> On Tue, Jul 02, 2013 at 10:10:29AM -0700, H Hartley Sweeten wrote:
>> The divider values stored in the per chip data are only used to set the
>> registers in the hardware to generate the desired SPI clock. Since these
>> are calculated per transfer based on the t->speed_hz there is no reason
>> keep them in the per chip data.
>
> Applied, thanks.  I don't seem to have been sent patch 10?

Thanks.

Looks like I fat-fingered the To: address on patches 10 and 11 of the series.

I'll repost them in just a sec.

Regards,
Hartley
--
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 v2 11/11] spi: spi-ep93xx: use master->cur_msg for in-flight message

2013-07-08 Thread H Hartley Sweeten
Instead of carrying the in-flight message in the driver private
data, use the cur_msg pointer that is already setup by the core.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Mika Westerberg 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 88 ++--
 1 file changed, 48 insertions(+), 40 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index 4c9a50c..e85834d 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -76,7 +76,6 @@
  * @min_rate: minimum clock rate (in Hz) supported by the controller
  * @max_rate: maximum clock rate (in Hz) supported by the controller
  * @wait: wait here until given transfer is completed
- * @current_msg: message that is currently processed (or %NULL if none)
  * @tx: current byte in transfer to transmit
  * @rx: current byte in transfer to receive
  * @fifo_level: how full is FIFO (%0..%SPI_FIFO_SIZE - %1). Receiving one
@@ -98,7 +97,6 @@ struct ep93xx_spi {
unsigned long   min_rate;
unsigned long   max_rate;
struct completion   wait;
-   struct spi_message  *current_msg;
size_t  tx;
size_t  rx;
size_t  fifo_level;
@@ -378,7 +376,7 @@ static void ep93xx_do_read(struct ep93xx_spi *espi, struct 
spi_transfer *t)
 
 /**
  * ep93xx_spi_read_write() - perform next RX/TX transfer
- * @espi: ep93xx SPI controller struct
+ * @master: spi_master struct
  *
  * This function transfers next bytes (or half-words) to/from RX/TX FIFOs. If
  * called several times, the whole transfer will be completed. Returns
@@ -387,9 +385,10 @@ static void ep93xx_do_read(struct ep93xx_spi *espi, struct 
spi_transfer *t)
  * When this function is finished, RX FIFO should be empty and TX FIFO should 
be
  * full.
  */
-static int ep93xx_spi_read_write(struct ep93xx_spi *espi)
+static int ep93xx_spi_read_write(struct spi_master *master)
 {
-   struct spi_message *msg = espi->current_msg;
+   struct ep93xx_spi *espi = spi_master_get_devdata(master);
+   struct spi_message *msg = master->cur_msg;
struct spi_transfer *t = msg->state;
 
/* read as long as RX FIFO has frames in it */
@@ -410,13 +409,15 @@ static int ep93xx_spi_read_write(struct ep93xx_spi *espi)
return -EINPROGRESS;
 }
 
-static void ep93xx_spi_pio_transfer(struct ep93xx_spi *espi)
+static void ep93xx_spi_pio_transfer(struct spi_master *master)
 {
+   struct ep93xx_spi *espi = spi_master_get_devdata(master);
+
/*
 * Now everything is set up for the current transfer. We prime the TX
 * FIFO, enable interrupts, and wait for the transfer to complete.
 */
-   if (ep93xx_spi_read_write(espi)) {
+   if (ep93xx_spi_read_write(master)) {
ep93xx_spi_enable_interrupts(espi);
wait_for_completion(&espi->wait);
}
@@ -424,7 +425,7 @@ static void ep93xx_spi_pio_transfer(struct ep93xx_spi *espi)
 
 /**
  * ep93xx_spi_dma_prepare() - prepares a DMA transfer
- * @espi: ep93xx SPI controller struct
+ * @master: spi_master struct
  * @dir: DMA transfer direction
  *
  * Function configures the DMA, maps the buffer and prepares the DMA
@@ -432,9 +433,11 @@ static void ep93xx_spi_pio_transfer(struct ep93xx_spi 
*espi)
  * in case of failure.
  */
 static struct dma_async_tx_descriptor *
-ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum dma_transfer_direction 
dir)
+ep93xx_spi_dma_prepare(struct spi_master *master,
+  enum dma_transfer_direction dir)
 {
-   struct spi_transfer *t = espi->current_msg->state;
+   struct ep93xx_spi *espi = spi_master_get_devdata(master);
+   struct spi_transfer *t = master->cur_msg->state;
struct dma_async_tx_descriptor *txd;
enum dma_slave_buswidth buswidth;
struct dma_slave_config conf;
@@ -527,15 +530,16 @@ ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum 
dma_transfer_direction dir)
 
 /**
  * ep93xx_spi_dma_finish() - finishes with a DMA transfer
- * @espi: ep93xx SPI controller struct
+ * @master: spi_master struct
  * @dir: DMA transfer direction
  *
  * Function finishes with the DMA transfer. After this, the DMA buffer is
  * unmapped.
  */
-static void ep93xx_spi_dma_finish(struct ep93xx_spi *espi,
+static void ep93xx_spi_dma_finish(struct spi_master *master,
  enum dma_transfer_direction dir)
 {
+   struct ep93xx_spi *espi = spi_master_get_devdata(master);
struct dma_chan *chan;
struct sg_table *sgt;
 
@@ -555,21 +559,22 @@ static void ep93xx_spi_dma_callback(void *callback_param)
complete(callback_param);
 }
 
-static void ep93xx_spi_dma_transfer(struct ep93xx_spi *espi)
+static void ep93xx_spi_dma_transfer(struct spi_master *master)
 {
-   struct spi_mess

Q: Kconfig option VIRT_TO_BUS

2012-11-12 Thread H Hartley Sweeten
Hello all,

Does anyone know what the Kconfig option VIRT_TO_BUS does?
There are a number of "depends on" that option but it does not
seem to directly enable any code in the kernel.

Thanks for any reply.

Regards,
Hartley
--
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: Q: Kconfig option VIRT_TO_BUS

2012-11-12 Thread H Hartley Sweeten
On Monday, November 12, 2012 11:41 AM, Bjorn Helgaas wrote:
> On Mon, Nov 12, 2012 at 9:18 AM, H Hartley Sweeten wrote:
>> Does anyone know what the Kconfig option VIRT_TO_BUS does?
>> There are a number of "depends on" that option but it does not
>> seem to directly enable any code in the kernel.
>
> virt_to_bus() is a deprecated interface for converting a kernel
> virtual address to a bus address.  It's deprecated because it's
> impossible to implement correctly when there are multiple bus address
> spaces, because you don't know which bus address space the caller has
> in mind.

Thanks for the info.

So if a driver does not use virt_to_bus() then the "depends on VIRT_TO_BUS" 
is not necessary. Correct?

Thanks,
Hartley
--
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/3] HID: introduce, and use, module_hid_driver

2012-12-17 Thread H Hartley Sweeten
Introduce, and use, the helper macro module_hid_driver to allow removing
the init/exit boilerplate code from the HID drivers.

H Hartley Sweeten (3):
  HID: introduce helper for hid_driver boilerplate
  HID: hid.h: remove unused hid_generic_{init,exit} prototypes
  HID: Use module_hid_driver macro

 drivers/hid/hid-a4tech.c   | 13 +
 drivers/hid/hid-apple.c| 19 +--
 drivers/hid/hid-aureal.c   | 13 +
 drivers/hid/hid-axff.c | 14 +-
 drivers/hid/hid-belkin.c   | 13 +
 drivers/hid/hid-cherry.c   | 13 +
 drivers/hid/hid-chicony.c  | 13 +
 drivers/hid/hid-cypress.c  | 13 +
 drivers/hid/hid-dr.c   | 13 +
 drivers/hid/hid-elecom.c   | 13 +
 drivers/hid/hid-emsff.c| 13 +
 drivers/hid/hid-ezkey.c| 13 +
 drivers/hid/hid-gaff.c | 13 +
 drivers/hid/hid-generic.c  | 14 +-
 drivers/hid/hid-gyration.c | 13 +
 drivers/hid/hid-holtek-kbd.c   | 13 +
 drivers/hid/hid-holtekff.c | 15 +--
 drivers/hid/hid-icade.c| 19 +--
 drivers/hid/hid-kensington.c   | 13 +
 drivers/hid/hid-keytouch.c | 13 +
 drivers/hid/hid-kye.c  | 13 +
 drivers/hid/hid-lcpower.c  | 13 +
 drivers/hid/hid-lenovo-tpkbd.c | 14 +-
 drivers/hid/hid-lg.c   | 13 +
 drivers/hid/hid-magicmouse.c   | 19 +--
 drivers/hid/hid-microsoft.c| 13 +
 drivers/hid/hid-monterey.c | 13 +
 drivers/hid/hid-multitouch.c   | 14 +-
 drivers/hid/hid-ntrig.c| 13 +
 drivers/hid/hid-ortek.c| 13 +
 drivers/hid/hid-petalynx.c | 13 +
 drivers/hid/hid-picolcd_core.c | 13 +
 drivers/hid/hid-pl.c   | 13 +
 drivers/hid/hid-primax.c   | 13 +
 drivers/hid/hid-prodikeys.c| 19 +--
 drivers/hid/hid-ps3remote.c| 13 +
 drivers/hid/hid-roccat-lua.c   | 14 +-
 drivers/hid/hid-saitek.c   | 13 +
 drivers/hid/hid-samsung.c  | 13 +
 drivers/hid/hid-sensor-hub.c   | 14 +-
 drivers/hid/hid-sjoy.c | 13 +
 drivers/hid/hid-sony.c | 13 +
 drivers/hid/hid-speedlink.c| 13 +
 drivers/hid/hid-sunplus.c  | 13 +
 drivers/hid/hid-tivo.c | 13 +
 drivers/hid/hid-tmff.c | 13 +
 drivers/hid/hid-topseed.c  | 13 +
 drivers/hid/hid-twinhan.c  | 13 +
 drivers/hid/hid-uclogic.c  | 13 +
 drivers/hid/hid-wacom.c| 18 +-
 drivers/hid/hid-waltop.c   | 13 +
 drivers/hid/hid-wiimote-core.c | 19 +--
 drivers/hid/hid-zpff.c | 13 +
 drivers/hid/hid-zydacron.c | 13 +
 include/linux/hid.h| 15 ---
 55 files changed, 66 insertions(+), 694 deletions(-)

-- 
1.8.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/


[PATCH 1/3] HID: introduce helper for hid_driver boilerplate

2012-12-17 Thread H Hartley Sweeten
Introduce the module_hid_driver macro which is a convenience macro
for HID driver modules similar to module_usb_driver. It is intended
to be used by drivers with init/exit sections that do nothing but
register/unregister the HID driver.

Signed-off-by: H Hartley Sweeten 
Cc: Jiri Kosina 
---
 include/linux/hid.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/include/linux/hid.h b/include/linux/hid.h
index 7330a0f..d6c71a6 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -700,6 +700,18 @@ extern int __must_check __hid_register_driver(struct 
hid_driver *,
 
 extern void hid_unregister_driver(struct hid_driver *);
 
+/**
+ * module_hid_driver() - Helper macro for registering a HID driver
+ * @__hid_driver: hid_driver struct
+ *
+ * Helper macro for HID drivers which do not do anything special in module
+ * init/exit. This eliminates a lot of boilerplate. Each module may only
+ * use this macro once, and calling it replaces module_init() and module_exit()
+ */
+#define module_hid_driver(__hid_driver) \
+   module_driver(__hid_driver, hid_register_driver, \
+ hid_unregister_driver)
+
 extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct 
hid_usage *, __s32);
 extern void hidinput_report_event(struct hid_device *hid, struct hid_report 
*report);
 extern int hidinput_connect(struct hid_device *hid, unsigned int force);
-- 
1.8.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/


[PATCH 2/3] HID: hid.h: remove unused hid_generic_{init,exit} prototypes

2012-12-17 Thread H Hartley Sweeten
These functions are not defined. Remove the extern declarations.

Signed-off-by: H Hartley Sweeten 
Cc: Jiri Kosina 
---
 include/linux/hid.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/linux/hid.h b/include/linux/hid.h
index d6c71a6..828726c 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -884,9 +884,6 @@ static inline int hid_hw_power(struct hid_device *hdev, int 
level)
 int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
int interrupt);
 
-extern int hid_generic_init(void);
-extern void hid_generic_exit(void);
-
 /* HID quirks API */
 u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct);
 int usbhid_quirks_init(char **quirks_param);
-- 
1.8.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/


[PATCH 3/3] HID: Use module_hid_driver macro

2012-12-17 Thread H Hartley Sweeten
Use the new module_hid_driver macro in all HID drivers that have
a simple register/unregister init/exit.

This also converts the hid drivers that test for a failure of
hid_register_driver() and report the failure. Using module_hid_driver
in those drivers removes the failure message.

Signed-off-by: H Hartley Sweeten 
Cc: Jiri Kosina 
---
 drivers/hid/hid-a4tech.c   | 13 +
 drivers/hid/hid-apple.c| 19 +--
 drivers/hid/hid-aureal.c   | 13 +
 drivers/hid/hid-axff.c | 14 +-
 drivers/hid/hid-belkin.c   | 13 +
 drivers/hid/hid-cherry.c   | 13 +
 drivers/hid/hid-chicony.c  | 13 +
 drivers/hid/hid-cypress.c  | 13 +
 drivers/hid/hid-dr.c   | 13 +
 drivers/hid/hid-elecom.c   | 13 +
 drivers/hid/hid-emsff.c| 13 +
 drivers/hid/hid-ezkey.c| 13 +
 drivers/hid/hid-gaff.c | 13 +
 drivers/hid/hid-generic.c  | 14 +-
 drivers/hid/hid-gyration.c | 13 +
 drivers/hid/hid-holtek-kbd.c   | 13 +
 drivers/hid/hid-holtekff.c | 15 +--
 drivers/hid/hid-icade.c| 19 +--
 drivers/hid/hid-kensington.c   | 13 +
 drivers/hid/hid-keytouch.c | 13 +
 drivers/hid/hid-kye.c  | 13 +
 drivers/hid/hid-lcpower.c  | 13 +
 drivers/hid/hid-lenovo-tpkbd.c | 14 +-
 drivers/hid/hid-lg.c   | 13 +
 drivers/hid/hid-magicmouse.c   | 19 +--
 drivers/hid/hid-microsoft.c| 13 +
 drivers/hid/hid-monterey.c | 13 +
 drivers/hid/hid-multitouch.c   | 14 +-
 drivers/hid/hid-ntrig.c| 13 +
 drivers/hid/hid-ortek.c| 13 +
 drivers/hid/hid-petalynx.c | 13 +
 drivers/hid/hid-picolcd_core.c | 13 +
 drivers/hid/hid-pl.c   | 13 +
 drivers/hid/hid-primax.c   | 13 +
 drivers/hid/hid-prodikeys.c| 19 +--
 drivers/hid/hid-ps3remote.c| 13 +
 drivers/hid/hid-roccat-lua.c   | 14 +-
 drivers/hid/hid-saitek.c   | 13 +
 drivers/hid/hid-samsung.c  | 13 +
 drivers/hid/hid-sensor-hub.c   | 14 +-
 drivers/hid/hid-sjoy.c | 13 +
 drivers/hid/hid-sony.c | 13 +
 drivers/hid/hid-speedlink.c| 13 +
 drivers/hid/hid-sunplus.c  | 13 +
 drivers/hid/hid-tivo.c | 13 +
 drivers/hid/hid-tmff.c | 13 +
 drivers/hid/hid-topseed.c  | 13 +
 drivers/hid/hid-twinhan.c  | 13 +
 drivers/hid/hid-uclogic.c  | 13 +
 drivers/hid/hid-wacom.c| 18 +-
 drivers/hid/hid-waltop.c   | 13 +
 drivers/hid/hid-wiimote-core.c | 19 +--
 drivers/hid/hid-zpff.c | 13 +
 drivers/hid/hid-zydacron.c | 13 +
 54 files changed, 54 insertions(+), 691 deletions(-)

diff --git a/drivers/hid/hid-a4tech.c b/drivers/hid/hid-a4tech.c
index 0a23988..7c5507e 100644
--- a/drivers/hid/hid-a4tech.c
+++ b/drivers/hid/hid-a4tech.c
@@ -146,17 +146,6 @@ static struct hid_driver a4_driver = {
.probe = a4_probe,
.remove = a4_remove,
 };
+module_hid_driver(a4_driver);
 
-static int __init a4_init(void)
-{
-   return hid_register_driver(&a4_driver);
-}
-
-static void __exit a4_exit(void)
-{
-   hid_unregister_driver(&a4_driver);
-}
-
-module_init(a4_init);
-module_exit(a4_exit);
 MODULE_LICENSE("GPL");
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index d0f7662..320a958 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -555,23 +555,6 @@ static struct hid_driver apple_driver = {
.input_mapping = apple_input_mapping,
.input_mapped = apple_input_mapped,
 };
+module_hid_driver(apple_driver);
 
-static int __init apple_init(void)
-{
-   int ret;
-
-   ret = hid_register_driver(&apple_driver);
-   if (ret)
-   pr_err("can't register apple driver\n");
-
-   return ret;
-}
-
-static void __exit apple_exit(void)
-{
-   hid_unregister_driver(&apple_driver);
-}
-
-module_init(apple_init);
-module_exit(apple_exit);
 MODULE_LICENSE("GPL");
diff --git a/drivers/hid/hid-aureal.c b/drivers/hid/hid-aureal.c
index 7968187..340ba9d 100644
--- a/drivers/hid/hid-aureal.c
+++ b/drivers/hid/hid-aureal.c
@@ -37,17 +37,6 @@ static struct hid_driver aureal_driver = {
.id_table = aureal_devices,
.report_fixup = aureal_report_fixup,
 };
+module_hid_driver(aureal_driver);
 
-static int __init aureal_init(void)
-{
-   return hid_register_driver(&aureal_driver);
-}
-
-static void __exit aureal_exi

RE: [PATCH] Staging: comedi: drivers: replaced printk with dev_dbg

2012-11-15 Thread H Hartley Sweeten
On Thursday, November 15, 2012 9:28 AM, Arpith Easow Alexander wrote:
> On Tue, Nov 13, 2012 at 11:52:52AM -0800, Greg KH wrote:
>> So a macro called dbgcm tests a variable called dbgcm?  Gotta love c at
>> times...
>> 
>> Just delete the macro, and the variable, and call dev_dbg() directly
>> please.
>
> Ok. Done. (Attached both changes).

Arpith,

You have two patches attached to this message. Please repost them patch as 
[PATCH v2 1/2] and [PATCH v2 2/2] and include the patches inline. It makes
them easier to review and apply.

Thanks!
Hartley

--
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 v4] pwm: add sysfs interface

2013-06-19 Thread H Hartley Sweeten
On Tuesday, June 11, 2013 12:48 PM, Thierry Reding wrote:
>
> I'm tempted to take your v5 patch and make a note to clean that up
> separately at some point (along with similar changes for the DEBUG_FS
> support).

Thierry,

So you want a v6 of this patch or are you ok with v5?

Thanks,
Hartley

--
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] pwm: add sysfs interface

2013-05-29 Thread H Hartley Sweeten
Add a simple sysfs interface to the PWM framework.

  /sys/class/pwm/
  `-- pwmchipN/  for each PWM chip
  |-- export (w/o) ask the kernel to export a PWM to userspace
  |-- npwm   (r/o) number of PWM in pwmchipN
  |-- pwmN/  for each exported PWM
  |   |-- duty_ns(r/w) duty cycle (in nanoseconds)
  |   |-- enable (r/w) enable/disable PWM
  |   |-- period_ns  (r/w) period (in nanoseconds)
  |   `-- polarity   (r/w) polarity of PWM
  `-- unexport   (w/o) return a PWM to the kernel

Signed-off-by: H Hartley Sweeten 
Cc: Thierry Reding 
Cc: Lars Poeschel 
---
This is based on previous work by Lars Poeshel.

 drivers/pwm/Kconfig |   6 +
 drivers/pwm/Makefile|   1 +
 drivers/pwm/core.c  |  25 +++-
 drivers/pwm/pwm-sysfs.c | 357 
 include/linux/pwm.h |  28 
 5 files changed, 415 insertions(+), 2 deletions(-)
 create mode 100644 drivers/pwm/pwm-sysfs.c

diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index 115b644..61a53b5 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -28,6 +28,12 @@ menuconfig PWM
 
 if PWM
 
+config PWM_SYSFS
+   bool "/sys/class/pwm/... (sysfs interface)"
+   depends on SYSFS
+   help
+ Say Y here to provide a sysfs interface to control PWMs.
+
 config PWM_AB8500
tristate "AB8500 PWM support"
depends on AB8500_CORE && ARCH_U8500
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
index 94ba21e..fb92e1d 100644
--- a/drivers/pwm/Makefile
+++ b/drivers/pwm/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_PWM)  += core.o
+obj-$(CONFIG_PWM_SYSFS)+= pwm-sysfs.o
 obj-$(CONFIG_PWM_AB8500)   += pwm-ab8500.o
 obj-$(CONFIG_PWM_ATMEL_TCB)+= pwm-atmel-tcb.o
 obj-$(CONFIG_PWM_BFIN) += pwm-bfin.o
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 32221cb..f67465c 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -274,6 +274,8 @@ int pwmchip_add(struct pwm_chip *chip)
if (IS_ENABLED(CONFIG_OF))
of_pwmchip_add(chip);
 
+   pwmchip_sysfs_export(chip);
+
 out:
mutex_unlock(&pwm_lock);
return ret;
@@ -310,6 +312,8 @@ int pwmchip_remove(struct pwm_chip *chip)
 
free_pwms(chip);
 
+   pwmchip_sysfs_unexport(chip);
+
 out:
mutex_unlock(&pwm_lock);
return ret;
@@ -402,10 +406,19 @@ EXPORT_SYMBOL_GPL(pwm_free);
  */
 int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
 {
+   int err;
+
if (!pwm || duty_ns < 0 || period_ns <= 0 || duty_ns > period_ns)
return -EINVAL;
 
-   return pwm->chip->ops->config(pwm->chip, pwm, duty_ns, period_ns);
+   err = pwm->chip->ops->config(pwm->chip, pwm, duty_ns, period_ns);
+   if (err)
+   return err;
+
+   pwm->duty = duty_ns;
+   pwm->period = period_ns;
+
+   return 0;
 }
 EXPORT_SYMBOL_GPL(pwm_config);
 
@@ -418,6 +431,8 @@ EXPORT_SYMBOL_GPL(pwm_config);
  */
 int pwm_set_polarity(struct pwm_device *pwm, enum pwm_polarity polarity)
 {
+   int err;
+
if (!pwm || !pwm->chip->ops)
return -EINVAL;
 
@@ -427,7 +442,13 @@ int pwm_set_polarity(struct pwm_device *pwm, enum 
pwm_polarity polarity)
if (test_bit(PWMF_ENABLED, &pwm->flags))
return -EBUSY;
 
-   return pwm->chip->ops->set_polarity(pwm->chip, pwm, polarity);
+   err = pwm->chip->ops->set_polarity(pwm->chip, pwm, polarity);
+   if (err)
+   return err;
+
+   pwm->polarity = polarity;
+
+   return 0;
 }
 EXPORT_SYMBOL_GPL(pwm_set_polarity);
 
diff --git a/drivers/pwm/pwm-sysfs.c b/drivers/pwm/pwm-sysfs.c
new file mode 100644
index 000..6a2bf76
--- /dev/null
+++ b/drivers/pwm/pwm-sysfs.c
@@ -0,0 +1,357 @@
+/*
+ * A simple sysfs interface for the generic PWM framework
+ *
+ * Copyright (C) 2013 H Hartley Sweeten 
+ *
+ * Based on previous work by Lars Poeschel 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct pwm_export {
+   struct device dev;
+   struct pwm_device *pwm;
+};
+
+static struct pwm_export *dev_to_pwm_export(struct device *dev)
+{
+   return container_of(dev, struct pwm_export, dev);
+}
+
+static struct pwm_device *dev_to_pwm_device(struct device *dev)
+{
+   struct pwm_exp

RE: [PATCH 00/14] misc/ep93xx_pwm: cleanup driver for conversion to PWM framework

2013-05-29 Thread H Hartley Sweeten
On Tuesday, May 28, 2013 4:42 AM, Lars Poeschel wrote:
> On Tuesday 28 May 2013 at 13:00:12, Thierry Reding wrote:
>> I've added Lars Poeschel on Cc, who's done some work on a sysfs
>> interface for the PWM subsystem already. It's undergone some review
>> already[0] and I think he's working on a v2 now.
>> 
>> Thierry
>> 
>> [0]: http://marc.info/?l=linux-kernel&m=136499756101273&w=2
>
> I currently do not have the time to work on a v2 of the pwm sysfs patch but 
> I will do it as soon as possible - if not someone else will do. 
> Unfortunately my current involvements in other project will not allow me to 
> do so for at least next two months.
> I received some off-list reactions to my patches from users asking for pwm 
> sysfs, so there is definitely a need for it!
> If you decide to take attempt 2) (which is preferable) I recommend you to 
> take a look at what I have done and Thierrys review comments. I took the 
> gpiolib way and the result got rejected for very good reasons.

I just posted a PWM sysfs interface patch based on the previous work by
Lars. Hopefully I addressed all of Thierrys review comments.

I still need to add the Documentation and the ABI doc for the sysfs but I
want to make sure the interface looks acceptable.

I also spotted a couple checkpatch.pl issues after I posted the patch. These
are already fixed for v2.

Thanks,
Hartley

--
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] pwm: add sysfs interface

2013-05-30 Thread H Hartley Sweeten
On Wednesday, May 29, 2013 7:02 PM, Ryan Mallon wrote:
> On 30/05/13 07:08, H Hartley Sweeten wrote:
>> Add a simple sysfs interface to the PWM framework.
>>
>>   /sys/class/pwm/
>>   `-- pwmchipN/  for each PWM chip
>>   |-- export (w/o) ask the kernel to export a PWM to userspace
>>   |-- npwm   (r/o) number of PWM in pwmchipN
>>   |-- pwmN/  for each exported PWM
>>   |   |-- duty_ns(r/w) duty cycle (in nanoseconds)
>>   |   |-- enable (r/w) enable/disable PWM
>>   |   |-- period_ns  (r/w) period (in nanoseconds)
>>   |   `-- polarity   (r/w) polarity of PWM
>>   `-- unexport   (w/o) return a PWM to the kernel
>>
>> Signed-off-by: H Hartley Sweeten 
>> Cc: Thierry Reding 
>> Cc: Lars Poeschel 
>> ---
>> This is based on previous work by Lars Poeshel.
>
> Some comments below.
>
> You will also fail to get this past Greg KH unless you add documentation
> for the new sysfs interface to Documentation/ABI/stable/.

I'm working on the documentation now. I wanted to get the implementation
out for review.

>>
>>  drivers/pwm/Kconfig |   6 +
>>  drivers/pwm/Makefile|   1 +
>>  drivers/pwm/core.c  |  25 +++-
>>  drivers/pwm/pwm-sysfs.c | 357 
>> 
>>  include/linux/pwm.h |  28 
>>  5 files changed, 415 insertions(+), 2 deletions(-)
>>  create mode 100644 drivers/pwm/pwm-sysfs.c
>>
>> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
>> index 115b644..61a53b5 100644
>> --- a/drivers/pwm/Kconfig
>> +++ b/drivers/pwm/Kconfig
>> @@ -28,6 +28,12 @@ menuconfig PWM
>>
>>  if PWM
>>
>> +config PWM_SYSFS
>> +bool "/sys/class/pwm/... (sysfs interface)"
>> +depends on SYSFS
>> +help
>> +  Say Y here to provide a sysfs interface to control PWMs.
>> +
>>  config PWM_AB8500
>>  tristate "AB8500 PWM support"
>>  depends on AB8500_CORE && ARCH_U8500
>> diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
>> index 94ba21e..fb92e1d 100644
>> --- a/drivers/pwm/Makefile
>> +++ b/drivers/pwm/Makefile
>> @@ -1,4 +1,5 @@
>>  obj-$(CONFIG_PWM)   += core.o
>> +obj-$(CONFIG_PWM_SYSFS) += pwm-sysfs.o
>>  obj-$(CONFIG_PWM_AB8500)+= pwm-ab8500.o
>>  obj-$(CONFIG_PWM_ATMEL_TCB) += pwm-atmel-tcb.o
>>  obj-$(CONFIG_PWM_BFIN)  += pwm-bfin.o
>> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
>> index 32221cb..f67465c 100644
>> --- a/drivers/pwm/core.c
>> +++ b/drivers/pwm/core.c
>> @@ -274,6 +274,8 @@ int pwmchip_add(struct pwm_chip *chip)
>>  if (IS_ENABLED(CONFIG_OF))
>>  of_pwmchip_add(chip);
>>
>> +pwmchip_sysfs_export(chip);
>> +
>>  out:
>>  mutex_unlock(&pwm_lock);
>>  return ret;
>> @@ -310,6 +312,8 @@ int pwmchip_remove(struct pwm_chip *chip)
>>
>>  free_pwms(chip);
>>
>> +pwmchip_sysfs_unexport(chip);
>> +
>>  out:
>>  mutex_unlock(&pwm_lock);
>>  return ret;
>> @@ -402,10 +406,19 @@ EXPORT_SYMBOL_GPL(pwm_free);
>>   */
>>  int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
>>  {
>> +int err;
>> +
>>  if (!pwm || duty_ns < 0 || period_ns <= 0 || duty_ns > period_ns)
>>  return -EINVAL;
>>
>> -return pwm->chip->ops->config(pwm->chip, pwm, duty_ns, period_ns);
>> +err = pwm->chip->ops->config(pwm->chip, pwm, duty_ns, period_ns);
>> +if (err)
>> +return err;
>> +
>> +pwm->duty = duty_ns;
>> +pwm->period = period_ns;
>> +
>> +return 0;
>>  }
>>  EXPORT_SYMBOL_GPL(pwm_config);
>>
>> @@ -418,6 +431,8 @@ EXPORT_SYMBOL_GPL(pwm_config);
>>   */
>>  int pwm_set_polarity(struct pwm_device *pwm, enum pwm_polarity polarity)
>>  {
>> +int err;
>> +
>>  if (!pwm || !pwm->chip->ops)
>>  return -EINVAL;
>>
>> @@ -427,7 +442,13 @@ int pwm_set_polarity(struct pwm_device *pwm, enum 
>> pwm_polarity polarity)
>>  if (test_bit(PWMF_ENABLED, &pwm->flags))
>>  return -EBUSY;
>>
>> -return pwm->chip->ops->set_polarity(pwm->chip, pwm, polarity);
>> +err = pwm->chip->ops->set_polarity(pwm->chip, pwm, polarity);
>> +if (err)
>> +return err;
>> +
>> + 

[PATCH v2] pwm: add sysfs interface

2013-05-30 Thread H Hartley Sweeten
Add a simple sysfs interface to the generic PWM framework.

  /sys/class/pwm/
  `-- pwmchipN/  for each PWM chip
  |-- export (w/o) ask the kernel to export a PWM channel
  |-- npwn   (r/o) number of PWM channels in this PWM chip
  |-- pwmX/  for each exported PWM channel (per PWM chip)
  |   |-- duty_ns(r/w) duty cycle (in nanoseconds)
  |   |-- enable (r/w) enable/disable PWM
  |   |-- period_ns  (r/w) period (in nanoseconds)
  |   `-- polarity   (r/w) polarity of PWM
  `-- unexport   (w/o) return a PWM channel to the kernel

Signed-off-by: H Hartley Sweeten 
Cc: Thierry Reding 
Cc: Lars Poeschel 
Cc: Ryan Mallon 
Cc: Rob Landley 
---
v2: * add API documentation and update Documentation/pwm.txt
* fix some issues pointed out by Ryan Mallon
* add the pwm attributes to dev.groups so they are created
  when the device is registered for the exported PWM.

 Documentation/ABI/testing/sysfs-class-pwm |  80 +++
 Documentation/pwm.txt |  39 
 drivers/pwm/Kconfig   |  12 +
 drivers/pwm/Makefile  |   1 +
 drivers/pwm/core.c|  25 ++-
 drivers/pwm/pwm-sysfs.c   | 350 ++
 include/linux/pwm.h   |  28 +++
 7 files changed, 533 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-class-pwm
 create mode 100644 drivers/pwm/pwm-sysfs.c

diff --git a/Documentation/ABI/testing/sysfs-class-pwm 
b/Documentation/ABI/testing/sysfs-class-pwm
new file mode 100644
index 000..eaa4e1f
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-pwm
@@ -0,0 +1,80 @@
+What:  /sys/class/pwm/
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   The pwm/ class sub-directory belongs to the Generic PWM
+   Framework and provides a sysfs interface for using PWM
+   channels.
+
+What:  /sys/class/pwm/pwmchipN/
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   A /sys/class/pwm/pwmchipN directory is created for each
+   probed PWM controller/chip where N is the base of the
+   PWM chip.
+
+What:  /sys/class/pwm/pwmchipN/npwm
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   The number of PWM channels supported by the PWM chip.
+
+What:  /sys/class/pwm/pwmchipN/export
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Exports a PWM channel from the PWM chip for sysfs control.
+   Value is between 0 and /sys/class/pwm/pwmchipN/npwm - 1.
+
+What:  /sys/class/pwm/pwmchipN/unexport
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Unexports a PWM channel.
+
+What:  /sys/class/pwm/pwmchipN/pwmX
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   A /sys/class/pwm/pwmchipN/pwmX directory is created for
+   each exported PWM channel where X is the PWM channel number.
+
+What:  /sys/class/pwm/pwmchipN/pwmX/period_ns
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Sets the PWM period in nanoseconds.
+
+What:  /sys/class/pwm/pwmchipN/pwmX/duty_ns
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Sets the PWM duty cycle in nanoseconds, default is half the
+   /sys/class/pwm/pwmchipN/pwmX/period_ns.
+
+What:  /sys/class/pwm/pwmchipN/pwmX/polarity
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Sets the output polarity of the PWM.
+   0 is normal polarity
+   1 is inversed polarity
+
+What:  /sys/class/pwm/pwmchipN/pwmX/enable
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Enables/disables the PWM.
+   0 is disabled
+   1 is enabled
diff --git a/Documentation/pwm.txt b/Documentation/pwm.txt
index 7d2b4c9..b58526d 100644
--- a/Documentation/pwm.txt
+++ b/Documentation/pwm.txt
@@ -45,6 +45,45 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int 
period_ns);
 
 To start/stop toggling the PWM output use pwm_enable()/pwm_disable().
 
+Using PWMs with the sysfs interface
+---
+
+You have to enable CONFIG_PWM_SYSFS in your kernel configuration to use
+the sysfs interface. It is exposed at /sys/class/pwm/. Each probed PWM
+controller/chip will be exported as pwmchipN, where N is the base of the
+PWM chip. Inside the directory you will find:
+
+npwm - The

RE: [PATCH v2] pwm: add sysfs interface

2013-05-30 Thread H Hartley Sweeten
On Thursday, May 30, 2013 12:30 PM, H Hartley Sweeten wrote:
> Add a simple sysfs interface to the generic PWM framework.
>
>   /sys/class/pwm/
>   `-- pwmchipN/  for each PWM chip
>   |-- export (w/o) ask the kernel to export a PWM channel
>   |-- npwn   (r/o) number of PWM channels in this PWM chip
>   |-- pwmX/  for each exported PWM channel (per PWM chip)
>   |   |-- duty_ns(r/w) duty cycle (in nanoseconds)
>   |   |-- enable (r/w) enable/disable PWM
>   |   |-- period_ns  (r/w) period (in nanoseconds)
>   |   `-- polarity   (r/w) polarity of PWM
>   `-- unexport   (w/o) return a PWM channel to the kernel
>
> Signed-off-by: H Hartley Sweeten 
> Cc: Thierry Reding 
> Cc: Lars Poeschel 
> Cc: Ryan Mallon 
> Cc: Rob Landley 
> ---
> v2: * add API documentation and update Documentation/pwm.txt
> * fix some issues pointed out by Ryan Mallon
> * add the pwm attributes to dev.groups so they are created
>   when the device is registered for the exported PWM.
>
>  Documentation/ABI/testing/sysfs-class-pwm |  80 +++
>  Documentation/pwm.txt |  39 
>  drivers/pwm/Kconfig   |  12 +
>  drivers/pwm/Makefile  |   1 +
>  drivers/pwm/core.c|  25 ++-
>  drivers/pwm/pwm-sysfs.c   | 350 
> ++
>  include/linux/pwm.h   |  28 +++
>  7 files changed, 533 insertions(+), 2 deletions(-)
>  create mode 100644 Documentation/ABI/testing/sysfs-class-pwm
>  create mode 100644 drivers/pwm/pwm-sysfs.c



> diff --git a/drivers/pwm/pwm-sysfs.c b/drivers/pwm/pwm-sysfs.c



> +void pwmchip_sysfs_export(struct pwm_chip *chip)
> +{
> + /*
> +  * If device_create() fails the pwm_chip is still usable by
> +  * the kernel its just not exported.
> +  */
> + chip->dev = device_create(&pwm_class, chip->dev, MKDEV(0, 0), chip,
> +   "pwmchip%d", chip->base);
> +}

I just realized this will not work.

chip->dev is initialized by the PWM driver before calling pwmchip_add().

I'll post a v3 shortly.

Regards,
Hartley

N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�&j:+v���zZ+��+zf���h���~i���z��w���?�&�)ߢf��^jǫy�m��@A�a���
0��h���i

[PATCH v3] pwm: add sysfs interface

2013-05-30 Thread H Hartley Sweeten
Add a simple sysfs interface to the generic PWM framework.

  /sys/class/pwm/
  `-- pwmchipN/  for each PWM chip
  |-- export (w/o) ask the kernel to export a PWM channel
  |-- npwn   (r/o) number of PWM channels in this PWM chip
  |-- pwmX/  for each exported PWM channel
  |   |-- duty_ns(r/w) duty cycle (in nanoseconds)
  |   |-- enable (r/w) enable/disable PWM
  |   |-- period_ns  (r/w) period (in nanoseconds)
  |   `-- polarity   (r/w) polarity of PWM
  `-- unexport   (w/o) return a PWM channel to the kernel

Signed-off-by: H Hartley Sweeten 
Cc: Thierry Reding 
Cc: Lars Poeschel 
Cc: Ryan Mallon 
Cc: Rob Landley 
---
v3: * fix an issue with the export/unexport of the PWM chip
v2: * add API documentation and update Documentation/pwm.txt
* fix some issues pointed out by Ryan Mallon
* add the pwm attributes to dev.groups so they are created
  when the device is registered for the exported PWM
v1: * Based on previous work by Lars Poecshel

 Documentation/ABI/testing/sysfs-class-pwm |  80 +++
 Documentation/pwm.txt |  39 
 drivers/pwm/Kconfig   |  12 +
 drivers/pwm/Makefile  |   1 +
 drivers/pwm/core.c|  25 ++-
 drivers/pwm/pwm-sysfs.c   | 358 ++
 include/linux/pwm.h   |  28 +++
 7 files changed, 541 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-class-pwm
 create mode 100644 drivers/pwm/pwm-sysfs.c

diff --git a/Documentation/ABI/testing/sysfs-class-pwm 
b/Documentation/ABI/testing/sysfs-class-pwm
new file mode 100644
index 000..eaa4e1f
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-pwm
@@ -0,0 +1,80 @@
+What:  /sys/class/pwm/
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   The pwm/ class sub-directory belongs to the Generic PWM
+   Framework and provides a sysfs interface for using PWM
+   channels.
+
+What:  /sys/class/pwm/pwmchipN/
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   A /sys/class/pwm/pwmchipN directory is created for each
+   probed PWM controller/chip where N is the base of the
+   PWM chip.
+
+What:  /sys/class/pwm/pwmchipN/npwm
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   The number of PWM channels supported by the PWM chip.
+
+What:  /sys/class/pwm/pwmchipN/export
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Exports a PWM channel from the PWM chip for sysfs control.
+   Value is between 0 and /sys/class/pwm/pwmchipN/npwm - 1.
+
+What:  /sys/class/pwm/pwmchipN/unexport
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Unexports a PWM channel.
+
+What:  /sys/class/pwm/pwmchipN/pwmX
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   A /sys/class/pwm/pwmchipN/pwmX directory is created for
+   each exported PWM channel where X is the PWM channel number.
+
+What:  /sys/class/pwm/pwmchipN/pwmX/period_ns
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Sets the PWM period in nanoseconds.
+
+What:  /sys/class/pwm/pwmchipN/pwmX/duty_ns
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Sets the PWM duty cycle in nanoseconds, default is half the
+   /sys/class/pwm/pwmchipN/pwmX/period_ns.
+
+What:  /sys/class/pwm/pwmchipN/pwmX/polarity
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Sets the output polarity of the PWM.
+   0 is normal polarity
+   1 is inversed polarity
+
+What:  /sys/class/pwm/pwmchipN/pwmX/enable
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Enables/disables the PWM.
+   0 is disabled
+   1 is enabled
diff --git a/Documentation/pwm.txt b/Documentation/pwm.txt
index 7d2b4c9..b58526d 100644
--- a/Documentation/pwm.txt
+++ b/Documentation/pwm.txt
@@ -45,6 +45,45 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int 
period_ns);
 
 To start/stop toggling the PWM output use pwm_enable()/pwm_disable().
 
+Using PWMs with the sysfs interface
+---
+
+You have to enable CONFIG_PWM_SYSFS in your kernel configuration to use
+the sysfs interface. It is exposed at /sys/class/pwm/. Each probed PWM
+controller/chip will be exported as pwmchipN

RE: [PATCH v3] pwm: add sysfs interface

2013-06-10 Thread H Hartley Sweeten
Ping?

-Original Message-
From: H Hartley Sweeten
Sent: Thursday, May 30, 2013 2:31 PM
To: Linux Kernel
Cc: linux-...@vger.kernel.org; linux-...@vger.kernel.org; 
thierry.red...@gmail.com; poesc...@lemonage.de; Ryan Mallon; r...@landley.net; 
H Hartley Sweeten
Subject: [PATCH v3] pwm: add sysfs interface

Add a simple sysfs interface to the generic PWM framework.

  /sys/class/pwm/
  `-- pwmchipN/  for each PWM chip
  |-- export (w/o) ask the kernel to export a PWM channel
  |-- npwn   (r/o) number of PWM channels in this PWM chip
  |-- pwmX/  for each exported PWM channel
  |   |-- duty_ns(r/w) duty cycle (in nanoseconds)
  |   |-- enable (r/w) enable/disable PWM
  |   |-- period_ns  (r/w) period (in nanoseconds)
  |   `-- polarity   (r/w) polarity of PWM
  `-- unexport   (w/o) return a PWM channel to the kernel

Signed-off-by: H Hartley Sweeten 
Cc: Thierry Reding 
Cc: Lars Poeschel 
Cc: Ryan Mallon 
Cc: Rob Landley 
---
v3: * fix an issue with the export/unexport of the PWM chip
v2: * add API documentation and update Documentation/pwm.txt
* fix some issues pointed out by Ryan Mallon
* add the pwm attributes to dev.groups so they are created
  when the device is registered for the exported PWM
v1: * Based on previous work by Lars Poecshel

 Documentation/ABI/testing/sysfs-class-pwm |  80 +++
 Documentation/pwm.txt |  39 
 drivers/pwm/Kconfig   |  12 +
 drivers/pwm/Makefile  |   1 +
 drivers/pwm/core.c|  25 ++-
 drivers/pwm/pwm-sysfs.c   | 358 ++
 include/linux/pwm.h   |  28 +++
 7 files changed, 541 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-class-pwm
 create mode 100644 drivers/pwm/pwm-sysfs.c

diff --git a/Documentation/ABI/testing/sysfs-class-pwm 
b/Documentation/ABI/testing/sysfs-class-pwm
new file mode 100644
index 000..eaa4e1f
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-pwm
@@ -0,0 +1,80 @@
+What:  /sys/class/pwm/
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   The pwm/ class sub-directory belongs to the Generic PWM
+   Framework and provides a sysfs interface for using PWM
+   channels.
+
+What:  /sys/class/pwm/pwmchipN/
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   A /sys/class/pwm/pwmchipN directory is created for each
+   probed PWM controller/chip where N is the base of the
+   PWM chip.
+
+What:  /sys/class/pwm/pwmchipN/npwm
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   The number of PWM channels supported by the PWM chip.
+
+What:  /sys/class/pwm/pwmchipN/export
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Exports a PWM channel from the PWM chip for sysfs control.
+   Value is between 0 and /sys/class/pwm/pwmchipN/npwm - 1.
+
+What:  /sys/class/pwm/pwmchipN/unexport
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Unexports a PWM channel.
+
+What:  /sys/class/pwm/pwmchipN/pwmX
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   A /sys/class/pwm/pwmchipN/pwmX directory is created for
+   each exported PWM channel where X is the PWM channel number.
+
+What:  /sys/class/pwm/pwmchipN/pwmX/period_ns
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Sets the PWM period in nanoseconds.
+
+What:  /sys/class/pwm/pwmchipN/pwmX/duty_ns
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Sets the PWM duty cycle in nanoseconds, default is half the
+   /sys/class/pwm/pwmchipN/pwmX/period_ns.
+
+What:  /sys/class/pwm/pwmchipN/pwmX/polarity
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Sets the output polarity of the PWM.
+   0 is normal polarity
+   1 is inversed polarity
+
+What:  /sys/class/pwm/pwmchipN/pwmX/enable
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Enables/disables the PWM.
+   0 is disabled
+   1 is enabled
diff --git a/Documentation/pwm.txt b/Documentation/pwm.txt
index 7d2b4c9..b58526d 100644
--- a/Documentation/pwm.txt
+++ b/Documentation/pwm.txt
@@ -45,6 +45,45 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int 
period_ns);

 To start/stop toggling

RE: [PATCH v3] pwm: add sysfs interface

2013-06-10 Thread H Hartley Sweeten
On Monday, June 10, 2013 12:00 PM, Thierry Reding wrote:
> On Thu, May 30, 2013 at 02:30:39PM -0700, H Hartley Sweeten wrote:
>> Add a simple sysfs interface to the generic PWM framework.
>
> Sorry for taking so long to review this.

Not a problem. Thanks for the review.

>>   /sys/class/pwm/
>>   `-- pwmchipN/  for each PWM chip
>>   |-- export (w/o) ask the kernel to export a PWM channel
>>   |-- npwn   (r/o) number of PWM channels in this PWM chip
>
> "npwm"?

Fat-fingered that. Fixed.

>>   |-- pwmX/  for each exported PWM channel
>>   |   |-- duty_ns(r/w) duty cycle (in nanoseconds)
>>   |   |-- enable (r/w) enable/disable PWM
>>   |   |-- period_ns  (r/w) period (in nanoseconds)
>
> I'm not sure if we need the _ns suffix. If the documentation already
> specifies that it should be in nanoseconds, shouldn't that be enough?

In the earlier review of Lars Poeschel's patch I think you said you wanted the
attributes to match the variable names.

But, "duty' and "period" are probably close enough. Fixed.

>> diff --git a/Documentation/ABI/testing/sysfs-class-pwm 
>> b/Documentation/ABI/testing/sysfs-class-pwm
> [...]
>> +What:   /sys/class/pwm/pwmchipN/pwmX/polarity
>> +Date:   May 2013
>> +KernelVersion:  3.11
>> +Contact:H Hartley Sweeten 
>> +Description:
>> +Sets the output polarity of the PWM.
>> +0 is normal polarity
>> +1 is inversed polarity
>
>I think this was discussed before, and I think it makes sense to use the
>string representation here. polarity = 0 or polarity = 1 aren't very
>intuitive notations in my opinion.

You did mention that before. I overlooked it.

I'll change this.

>> diff --git a/Documentation/pwm.txt b/Documentation/pwm.txt
> [...]
>> +The PWM channels are PWM chip specific from 0 to npwn-1.
>
>"npwm-1". "channels are PWM chip specific" sounds a bit confusing. Maybe
>something like "The PWM channels are numbered using a per-chip index
>from 0 to npwm-1." is more precise?

Ok.

>> +When a PWM channel is exported a pwmX directory will be created in the
>> +pwmchipN directory it is associated with, where X is the channel number
>> +that was exported.
>
>"..., where X is the number of the channel that was exported."?

Ok.

>> The following properties will then be available:
>> +
>> +period_ns - The total period of the PWM (read/write).
>
> "PWM signal"?

OK.

>> +Value is in nanoseconds and is the sum of the active and inactive
>> +time of the PWM. If duty_ns is zero when this property is written
>> +it will be automatically set to half the period_ns.
>
> I'm not sure that's the best approach. How about deferring the PWM
> configuration until both values have been set? Or only configure the PWM
> channel when it has been enabled, and refuse to enable unless both the
> period and the duty cycle have been set?

See below.

>> diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
>> index 94ba21e..fb92e1d 100644
>> --- a/drivers/pwm/Makefile
>> +++ b/drivers/pwm/Makefile
>> @@ -1,4 +1,5 @@
>>  obj-$(CONFIG_PWM)   += core.o
>> +obj-$(CONFIG_PWM_SYSFS) += pwm-sysfs.o
>
> I'd prefer this to simple be named sysfs.[co] in order to differentiate
> it from drivers and make it consistent with the naming of core.[co].

Ok.

>> diff --git a/drivers/pwm/pwm-sysfs.c b/drivers/pwm/pwm-sysfs.c
> [...]
>> +static struct pwm_device *dev_to_pwm_device(struct device *dev)
>> +{
>> +struct pwm_export *pwm_export = dev_to_pwm_export(dev);
>
> Maybe drop the pwm_ prefix on the variable name?

Ok.

>> +static ssize_t pwm_period_ns_store(struct device *dev,
>> +   struct device_attribute *attr,
>> +   const char *buf, size_t size)
>> +{
>> +struct pwm_device *pwm = dev_to_pwm_device(dev);
>> +unsigned int duty = pwm->duty;
>> +unsigned int val;
>> +int ret;
>> +
>> +ret = kstrtouint(buf, 0, &val);
>> +if (ret)
>> +return ret;
>> +
>> +/* if not set, default to 50% duty cycle */
>> +if (duty == 0)
>> +duty = val / 2;
>
> How does this differentiate between the case where the user explicitly
> sets the duty cycle to 0 to "disable" the PWM?

It doesn't.

Actually, looking at pwm_config() a duty_ns value of 0 is allowed so this
check is not necess

[PATCH v4] pwm: add sysfs interface

2013-06-10 Thread H Hartley Sweeten
Add a simple sysfs interface to the generic PWM framework.

  /sys/class/pwm/
  `-- pwmchipN/  for each PWM chip
  |-- export (w/o) ask the kernel to export a PWM channel
  |-- npwm   (r/o) number of PWM channels in this PWM chip
  |-- pwmX/  for each exported PWM channel
  |   |-- duty   (r/w) duty cycle (in nanoseconds)
  |   |-- enable (r/w) enable/disable PWM
  |   |-- period (r/w) period (in nanoseconds)
  |   `-- polarity   (r/w) polarity of PWM (normal/inversed)
  `-- unexport   (w/o) return a PWM channel to the kernel

Signed-off-by: H Hartley Sweeten 
Cc: Thierry Reding 
Cc: Lars Poeschel 
Cc: Ryan Mallon 
Cc: Rob Landley 
---
v4: * address a number of issues pointed out by Thierry Reding
  - fix some typos and wording issues in the Documentation
  - rename the new source file to sysfs.c
  - rename some of the variables in sysfs.c to clarify them
  - fix the period store so it does not change the duty cycle
  - change the polarity attribute to use a string representation
  - add a warning message is the pwmchip_sysfs_export() fails
v3: * fix an issue with the export/unexport of the PWM chip
v2: * add API documentation and update Documentation/pwm.txt
* fix some issues pointed out by Ryan Mallon
* add the pwm attributes to dev.groups so they are created
  when the device is registered for the exported PWM
v1: * Based on previous work by Lars Poecshel

 Documentation/ABI/testing/sysfs-class-pwm |  78 +++
 Documentation/pwm.txt |  36 +++
 drivers/pwm/Kconfig   |  12 +
 drivers/pwm/Makefile  |   1 +
 drivers/pwm/core.c|  25 ++-
 drivers/pwm/sysfs.c   | 351 ++
 include/linux/pwm.h   |  29 ++-
 7 files changed, 529 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-class-pwm
 create mode 100644 drivers/pwm/sysfs.c

diff --git a/Documentation/ABI/testing/sysfs-class-pwm 
b/Documentation/ABI/testing/sysfs-class-pwm
new file mode 100644
index 000..cb3d034
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-pwm
@@ -0,0 +1,78 @@
+What:  /sys/class/pwm/
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   The pwm/ class sub-directory belongs to the Generic PWM
+   Framework and provides a sysfs interface for using PWM
+   channels.
+
+What:  /sys/class/pwm/pwmchipN/
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   A /sys/class/pwm/pwmchipN directory is created for each
+   probed PWM controller/chip where N is the base of the
+   PWM chip.
+
+What:  /sys/class/pwm/pwmchipN/npwm
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   The number of PWM channels supported by the PWM chip.
+
+What:  /sys/class/pwm/pwmchipN/export
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Exports a PWM channel from the PWM chip for sysfs control.
+   Value is between 0 and /sys/class/pwm/pwmchipN/npwm - 1.
+
+What:  /sys/class/pwm/pwmchipN/unexport
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Unexports a PWM channel.
+
+What:  /sys/class/pwm/pwmchipN/pwmX
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   A /sys/class/pwm/pwmchipN/pwmX directory is created for
+   each exported PWM channel where X is the exported PWM
+   channel number.
+
+What:  /sys/class/pwm/pwmchipN/pwmX/period
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Sets the PWM period in nanoseconds.
+
+What:  /sys/class/pwm/pwmchipN/pwmX/duty
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Sets the PWM duty cycle in nanoseconds.
+
+What:  /sys/class/pwm/pwmchipN/pwmX/polarity
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Sets the output polarity of the PWM to "normal" or "inversed".
+
+What:  /sys/class/pwm/pwmchipN/pwmX/enable
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Enables/disables the PWM.
+   0 is disabled
+   1 is enabled
diff --git a/Documentation/pwm.txt b/Documentation/pwm.txt
index 7d2b4c9..95589b1 100644
--- a/Documentation/pwm.txt
+++ b/Documentation/pwm.txt
@@ -45,6 +45,42 @@ int pwm_config(struct pwm_device *pwm, int dut

RE: [PATCH v4] pwm: add sysfs interface

2013-06-11 Thread H Hartley Sweeten
On Tuesday, June 11, 2013 4:29 AM, Ryan Mallon wrote:
> On 11/06/13 20:14, Thierry Reding wrote:
>> On Mon, Jun 10, 2013 at 04:12:07PM -0700, H Hartley Sweeten wrote:
>> [...]
>>> +What:  /sys/class/pwm/pwmchipN/pwmX/duty
>>> +Date:  May 2013
>>> +KernelVersion: 3.11
>>> +Contact:   H Hartley Sweeten 
>>> +Description:
>>> +   Sets the PWM duty cycle in nanoseconds.
>> 
>> Sorry, I should've been more specific before. I'd like this to be named
>> duty_cycle. We now have the pwm_{set,get}_duty_cycle() accessors and I'd
>> like to eventually use the spelled-out form consistently.

Ok. I'll change this.

>>> +config PWM_SYSFS
>>> +   bool "/sys/class/pwm/... (sysfs interface)"
>>> +   depends on SYSFS
>>> +   help
>>> + Say Y here to provide a sysfs interface to control PWMs.
>>> +
>>> + For every instance of a PWM device there is a pwmchipN directory
>>> + created in /sys/class/pwm. Use the export attribute to request
>>> + a PWM to be accessible from userspace and the unexport attribute
>>> + to return the PWM to the kernel. Each exported PWM will have a
>>> + pwmX directory in the pwmchipN it is associated with.
>> 
>> I have a small quibble with this. Introducing options like this make it
>> increasingly difficult to compile-test all the various combinations, so
>> I'd like to see this converted to a form that will play well with the
>> IS_ENABLED() macro. We already have the same issue with DEBUG_FS, only
>> to a lesser degree because it doesn't have an additional PWM-specific
>> Kconfig option.
>> 
>> In order not to burden you with too much work, one option for now would
>> be to unconditionally build the sysfs.c file and use something along
>> these lines in pwmchip_sysfs_{,un}export():
>> 
>>  if (!IS_ENABLED(CONFIG_PWM_SYSFS))
>>  return;
>> 
>> Which should allow the compiler to throw away all PWM_SYSFS-related
>> code in that file, leaving an empty function.
>
>
> Won't that also cause the compiler to spew a bunch of warnings about
> unreachable code in the !CONFIG_PWM_SYSFS case? We have the
> unreachable() macro, but that isn't supported nicely by all compilers.
>
> If CONFIG_SYSFS is not enabled and sysfs.c is using functions that now
> do not exist, that will cause compile errors, since the compiler will
> still attempt to compile all of the code, even though it will remove
> most of it after doing so.
>
> Also, any functions that are extern will also end up generating empty
> functions in the kernel binary (static linkage functions should
> disappear completely). This is obviously very negligible in size,
> but using a proper Kconfig option results in zero size if the option
> is compiled out.
>
>> It's not the optimal
>> solution, which would require the sysfs code to go into core.c and be
>> conditionalized there, but it's good enough. I can always go and clean
>> up that code later (maybe doing the same for DEBUG_FS while at it).
>>
>> The big advantage of this is that we get full compile coverage of the
>> sysfs interface, whether it's enabled or not. Calling an empty function
>> once when the chip is registered is an acceptable overhead.
>
> Why not just make CONFIG_PWM_SYSFS default y, so that if CONFIG_SYSFS is
> enabled (which should be true for the vast majority of test configs) that
> pwm sysfs is also enabled?
>
> The IS_ENABLED method just seems very messy for a very small gain.

How about removing the Kconfig option and just doing:

obj-$(CONFIG_SYSFS) += sysfs.o

This way the PWM sysfs interface is always compiled and included in the build
as long as CONFIG_SYSFS is enabled. The check in the header would change to

#ifdef CONFIG_SYSFS
void pwmchip_sysfs_export(struct pwm_chip *chip);
void pwmchip_sysfs_unexport(struct pwm_chip *chip);
#else
static inline void pwmchip_sysfs_export(struct pwm_chip *chip)
{
}

static inline void pwmchip_sysfs_unexport(struct pwm_chip *chip)
{
}
#endif /* CONFIG_SYSFS */

So, no IS_ENABLED or #ifdef'ery in the source file.

I'll make the change and post a v5 shortly.

Regards,
Hartley

--
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 v4] pwm: add sysfs interface

2013-06-11 Thread H Hartley Sweeten
On Tuesday, June 11, 2013 9:09 AM, H Hartley Sweeten wrote:
> On Tuesday, June 11, 2013 4:29 AM, Ryan Mallon wrote:
>> On 11/06/13 20:14, Thierry Reding wrote:
>>> On Mon, Jun 10, 2013 at 04:12:07PM -0700, H Hartley Sweeten wrote:
>>>> +config PWM_SYSFS
>>>> +  bool "/sys/class/pwm/... (sysfs interface)"
>>>> +  depends on SYSFS
>>>> +  help
>>>> +Say Y here to provide a sysfs interface to control PWMs.
>>>> +
>>>> +For every instance of a PWM device there is a pwmchipN directory
>>>> +created in /sys/class/pwm. Use the export attribute to request
>>>> +a PWM to be accessible from userspace and the unexport attribute
>>>> +to return the PWM to the kernel. Each exported PWM will have a
>>>> +pwmX directory in the pwmchipN it is associated with.
>>> 
>>> I have a small quibble with this. Introducing options like this make it
>>> increasingly difficult to compile-test all the various combinations, so
>>> I'd like to see this converted to a form that will play well with the
>>> IS_ENABLED() macro. We already have the same issue with DEBUG_FS, only
>>> to a lesser degree because it doesn't have an additional PWM-specific
>>> Kconfig option.
>
> How about removing the Kconfig option and just doing:
>
> obj-$(CONFIG_SYSFS)   += sysfs.o
>
> This way the PWM sysfs interface is always compiled and included in the build
> as long as CONFIG_SYSFS is enabled. The check in the header would change to

That didn't work. As Ryan pointed out we get undefined references due to
sysfs.c being compiled but not core.c when CONFIG_PWM is not enabled.

I'll change the PWM_SYSFS to a hidden option and repost the patch to see if
that is acceptable. Like Ryan mentioned, most test configs have CONFIG_SYSFS
enabled so as long as CONFIG_PWM is enabled we also get the sysfs interface.

Regards,
Hartley


--
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 v5] pwm: add sysfs interface

2013-06-11 Thread H Hartley Sweeten
Add a simple sysfs interface to the generic PWM framework.

  /sys/class/pwm/
  `-- pwmchipN/   for each PWM chip
  |-- export  (w/o) ask the kernel to export a PWM channel
  |-- npwm(r/o) number of PWM channels in this PWM chip
  |-- pwmX/   for each exported PWM channel
  |   |-- duty_cycle  (r/w) duty cycle (in nanoseconds)
  |   |-- enable  (r/w) enable/disable PWM
  |   |-- period  (r/w) period (in nanoseconds)
  |   `-- polarity(r/w) polarity of PWM (normal/inversed)
  `-- unexport(w/o) return a PWM channel to the kernel

Signed-off-by: H Hartley Sweeten 
Cc: Thierry Reding 
Cc: Lars Poeschel 
Cc: Ryan Mallon 
Cc: Rob Landley 
---
v5: * rename the 'duty' attribute to 'duty_cycle'
* make the Kconfig option hidden and enabled when CONFIG_SYSFS
  is enabled
* use sysfs_streq() in pwm_polarity_store()
v4: * address a number of issues pointed out by Thierry Reding
  - fix some typos and wording issues in the Documentation
  - rename the new source file to sysfs.c
  - rename some of the variables in sysfs.c to clarify them
  - fix the period store so it does not change the duty cycle
  - change the polarity attribute to use a string representation
  - add a warning message is the pwmchip_sysfs_export() fails
v3: * fix an issue with the export/unexport of the PWM chip
v2: * add API documentation and update Documentation/pwm.txt
* fix some issues pointed out by Ryan Mallon
* add the pwm attributes to dev.groups so they are created
  when the device is registered for the exported PWM
v1: * Based on previous work by Lars Poecshel

 Documentation/ABI/testing/sysfs-class-pwm |  79 +++
 Documentation/pwm.txt |  37 
 drivers/pwm/Kconfig   |   4 +
 drivers/pwm/Makefile  |   1 +
 drivers/pwm/core.c|  25 ++-
 drivers/pwm/sysfs.c   | 352 ++
 include/linux/pwm.h   |  29 ++-
 7 files changed, 524 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-class-pwm
 create mode 100644 drivers/pwm/sysfs.c

diff --git a/Documentation/ABI/testing/sysfs-class-pwm 
b/Documentation/ABI/testing/sysfs-class-pwm
new file mode 100644
index 000..c479d77
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-pwm
@@ -0,0 +1,79 @@
+What:  /sys/class/pwm/
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   The pwm/ class sub-directory belongs to the Generic PWM
+   Framework and provides a sysfs interface for using PWM
+   channels.
+
+What:  /sys/class/pwm/pwmchipN/
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   A /sys/class/pwm/pwmchipN directory is created for each
+   probed PWM controller/chip where N is the base of the
+   PWM chip.
+
+What:  /sys/class/pwm/pwmchipN/npwm
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   The number of PWM channels supported by the PWM chip.
+
+What:  /sys/class/pwm/pwmchipN/export
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Exports a PWM channel from the PWM chip for sysfs control.
+   Value is between 0 and /sys/class/pwm/pwmchipN/npwm - 1.
+
+What:  /sys/class/pwm/pwmchipN/unexport
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Unexports a PWM channel.
+
+What:  /sys/class/pwm/pwmchipN/pwmX
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   A /sys/class/pwm/pwmchipN/pwmX directory is created for
+   each exported PWM channel where X is the exported PWM
+   channel number.
+
+What:  /sys/class/pwm/pwmchipN/pwmX/period
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Sets the PWM signal period in nanoseconds.
+
+What:  /sys/class/pwm/pwmchipN/pwmX/duty_cycle
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Sets the PWM signal duty cycle in nanoseconds.
+
+What:  /sys/class/pwm/pwmchipN/pwmX/polarity
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Sets the output polarity of the PWM signal to "normal" or
+   "inversed".
+
+What:  /sys/class/pwm/pwmchipN/pwmX/enable
+Date:  May 2013
+KernelVersion: 3.11
+Contact:   H Hartley Sweeten 
+Description:
+   Enable/disable the PWM signal.
+ 

RE: [PATCH v4] pwm: add sysfs interface

2013-06-11 Thread H Hartley Sweeten
On Tuesday, June 11, 2013 11:35 AM, Thierry Reding wrote:
> On Tue, Jun 11, 2013 at 11:47:23AM -0500, H Hartley Sweeten wrote:
>> On Tuesday, June 11, 2013 9:09 AM, H Hartley Sweeten wrote:
>>> On Tuesday, June 11, 2013 4:29 AM, Ryan Mallon wrote:
>>>> On 11/06/13 20:14, Thierry Reding wrote:
>>>>> On Mon, Jun 10, 2013 at 04:12:07PM -0700, H Hartley Sweeten wrote:
>>>>>> +config PWM_SYSFS
>>>>>> +bool "/sys/class/pwm/... (sysfs interface)"
>>>>>> +depends on SYSFS
>>>>>> +help
>>>>>> +  Say Y here to provide a sysfs interface to control PWMs.
>>>>>> +
>>>>>> +  For every instance of a PWM device there is a pwmchipN 
>>>>>> directory
>>>>>> +  created in /sys/class/pwm. Use the export attribute to request
>>>>>> +  a PWM to be accessible from userspace and the unexport 
>>>>>> attribute
>>>>>> +  to return the PWM to the kernel. Each exported PWM will have a
>>>>>> +  pwmX directory in the pwmchipN it is associated with.
>>>>> 
>>>>> I have a small quibble with this. Introducing options like this make it
>>>>> increasingly difficult to compile-test all the various combinations, so
>>>>> I'd like to see this converted to a form that will play well with the
>>>>> IS_ENABLED() macro. We already have the same issue with DEBUG_FS, only
>>>>> to a lesser degree because it doesn't have an additional PWM-specific
>>>>> Kconfig option.
>>>
>>> How about removing the Kconfig option and just doing:
>>>
>>> obj-$(CONFIG_SYSFS) += sysfs.o
>>>
>>> This way the PWM sysfs interface is always compiled and included in the 
>>> build
>>> as long as CONFIG_SYSFS is enabled. The check in the header would change to
>> 
>> That didn't work. As Ryan pointed out we get undefined references due to
>> sysfs.c being compiled but not core.c when CONFIG_PWM is not enabled.
>
> Why not add dummies for the missing functions? It was my impression that
> we had dummies for all of them already, but if not they should certainly
> be added to match what other subsystems do.

I just looked it over and the undefined reference was for pwm_set_polarity().
The dummy for that function is missing.

The other problem with this approach is the sysfs.c file gets compiled whenever
CONFIG_SYSFS is enabled even if CONFIG_PWM is not enabled.

Hartley
--
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 3/8] spi: spi-ep93xx: always handle transfer specific settings

2013-07-01 Thread H Hartley Sweeten
On Monday, July 01, 2013 3:28 AM, Mark Brown wrote:
> On Fri, Jun 28, 2013 at 11:43:34AM -0700, H Hartley Sweeten wrote:
>> __spi_async(), which starts every SPI message transfer, initializes
>> the bits_per_word and max speed for every transfer in the message.
>> Since the conditional test in ep93xx_spi_process_transfer() will
>> always succeed just remove it and always call ep93xx_spi_chip_setup()
>> to configure the hardware for each transfer in the message.
>
> Applied, thanks.

Mark,

I was going to redo this series based on the comments I have received
so far. Did you already apply this one? Should I push it to the front of my
patchset?

Regards,
Hartley

--
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/8] spi: spi-ep93xx: use read,write instead of __raw_* variants

2013-07-01 Thread H Hartley Sweeten
On Monday, July 01, 2013 3:58 AM, Mark Brown wrote:
> On Sat, Jun 29, 2013 at 09:15:09AM +1000, Ryan Mallon wrote:
>> On 29/06/13 04:42, H Hartley Sweeten wrote:
>
>>> -static inline u8
>>> -ep93xx_spi_read_u8(const struct ep93xx_spi *spi, u16 reg)
>>> -{
>>> -   return __raw_readb(spi->regs_base + reg);
>>> -}
>
>> Is there a particular reason to drop these functions? It's basically just
>> bike-shedding, but they can make the code more readable at very little
>> cost. Even dropping the inline (which is preferred nowdays) the compiler
>> will still inline these, and it would also make this patch much smaller
>> to keep them.
>
> I tend to agree, it's much more normal to have the base + reg in a
> function than not.

OK. I will redo this one to just remove the __raw_.

Regards,
Hartley

--
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/8] spi: spi-ep93xx: use bits_per_word_mask

2013-07-01 Thread H Hartley Sweeten
On Sunday, June 30, 2013 9:14 AM, Mika Westerberg wrote:
> On Fri, Jun 28, 2013 at 11:43:07AM -0700, H Hartley Sweeten wrote:
>> This driver supports 16 to 4 bits per work. Set the bits_per_word_mask
>> to allows the spi core to handle validation.
>> 
>> Signed-off-by: H Hartley Sweeten 
>> Cc: Ryan Mallon 
>> Cc: Mika Westerberg 
>> Cc: Mark Brown 
>> Cc: Grant Likely 
>> ---
>>  drivers/spi/spi-ep93xx.c | 11 +--
>>  1 file changed, 1 insertion(+), 10 deletions(-)
>> 
>> diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
>> index c633cd0..93ae7b6 100644
>> --- a/drivers/spi/spi-ep93xx.c
>> +++ b/drivers/spi/spi-ep93xx.c
>> @@ -272,12 +272,6 @@ static int ep93xx_spi_setup(struct spi_device *spi)
>>  struct ep93xx_spi *espi = spi_master_get_devdata(spi->master);
>>  struct ep93xx_spi_chip *chip;
>>  
>> -if (spi->bits_per_word < 4 || spi->bits_per_word > 16) {
>> -dev_err(&espi->pdev->dev, "invalid bits per word %d\n",
>> -spi->bits_per_word);
>> -return -EINVAL;
>> -}
>> -
>>  chip = spi_get_ctldata(spi);
>>  if (!chip) {
>>  dev_dbg(&espi->pdev->dev, "initial setup for %s\n",
>> @@ -341,10 +335,6 @@ static int ep93xx_spi_transfer(struct spi_device *spi, 
>> struct spi_message *msg)
>>  
>>  /* first validate each transfer */
>>  list_for_each_entry(t, &msg->transfers, transfer_list) {
>> -if (t->bits_per_word) {
>> -if (t->bits_per_word < 4 || t->bits_per_word > 16)
>> -return -EINVAL;
>> -}
>>  if (t->speed_hz && t->speed_hz < espi->min_rate)
>>  return -EINVAL;
>>  }
>> @@ -1022,6 +1012,7 @@ static int ep93xx_spi_probe(struct platform_device 
>> *pdev)
>>  master->bus_num = pdev->id;
>>  master->num_chipselect = info->num_chipselect;
>>  master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
>> +master->bits_per_word_mask = 0xfff8;/* 16 to 4 bits per word */
>
> Please use SPI_BPW_RANGE_MASK(4, 16) here.

I thought there was a macro for this, just couldn't find it. I'll fix this.

Thanks, 
Hartley

--
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/8] spi: spi-ep93xx: use bits_per_word_mask

2013-07-01 Thread H Hartley Sweeten
On Monday, July 01, 2013 11:23 AM, H Hartley Sweeten wrote:
> On Sunday, June 30, 2013 9:14 AM, Mika Westerberg wrote:
>> Please use SPI_BPW_RANGE_MASK(4, 16) here.
>
> I thought there was a macro for this, just couldn't find it. I'll fix this.

Doh... This patch is already in linux-next.

I'll need to rebase this series.

Regards,
Hartley
--
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 v2 0/4] usb: ohci-ep93xx: do a bit of housecleaning

2013-07-01 Thread H Hartley Sweeten
Tidy up this driver a bit.

v2: redo patch 4 based on suggestions from Alan Stern

H Hartley Sweeten (4):
  usb: ohci-ep93xx: use devm_ioremap_resource()
  usb: ohci-ep93xx: use platform_get_irq()
  usb: ohci-ep93xx: use devm_clk_get()
  usb: ohci-ep93xx: tidy up driver (*probe) and (*remove)

 drivers/usb/host/ohci-ep93xx.c | 137 -
 1 file changed, 52 insertions(+), 85 deletions(-)

-- 
1.8.1.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 v2 1/4] usb: ohci-ep93xx: use devm_ioremap_resource()

2013-07-01 Thread H Hartley Sweeten
Use devm_ioremap_resource() to make the code a bit cleaner and
simpler.

Signed-off-by: H Hartley Sweeten 
Acked-by: Alan Stern 
Cc: Lennert Buytenhek 
Cc: Greg Kroah-Hartman 
---
 drivers/usb/host/ohci-ep93xx.c | 35 ++-
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index 8704e9f..4e12f67 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -43,38 +43,37 @@ static void ep93xx_stop_hc(struct device *dev)
 static int usb_hcd_ep93xx_probe(const struct hc_driver *driver,
 struct platform_device *pdev)
 {
-   int retval;
struct usb_hcd *hcd;
+   struct resource *res;
+   int retval;
 
if (pdev->resource[1].flags != IORESOURCE_IRQ) {
dev_dbg(&pdev->dev, "resource[1] is not IORESOURCE_IRQ\n");
return -ENOMEM;
}
 
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!res)
+   return -ENXIO;
+
hcd = usb_create_hcd(driver, &pdev->dev, "ep93xx");
if (hcd == NULL)
return -ENOMEM;
 
-   hcd->rsrc_start = pdev->resource[0].start;
-   hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1;
-   if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
-   usb_put_hcd(hcd);
-   retval = -EBUSY;
-   goto err1;
-   }
+   hcd->rsrc_start = res->start;
+   hcd->rsrc_len = resource_size(res);
 
-   hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
-   if (hcd->regs == NULL) {
-   dev_dbg(&pdev->dev, "ioremap failed\n");
-   retval = -ENOMEM;
-   goto err2;
+   hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+   if (IS_ERR(hcd->regs)) {
+   retval = PTR_ERR(hcd->regs);
+   goto err_put_hcd;
}
 
usb_host_clock = clk_get(&pdev->dev, NULL);
if (IS_ERR(usb_host_clock)) {
dev_dbg(&pdev->dev, "clk_get failed\n");
retval = PTR_ERR(usb_host_clock);
-   goto err3;
+   goto err_put_hcd;
}
 
ep93xx_start_hc(&pdev->dev);
@@ -86,11 +85,7 @@ static int usb_hcd_ep93xx_probe(const struct hc_driver 
*driver,
return retval;
 
ep93xx_stop_hc(&pdev->dev);
-err3:
-   iounmap(hcd->regs);
-err2:
-   release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
-err1:
+err_put_hcd:
usb_put_hcd(hcd);
 
return retval;
@@ -102,8 +97,6 @@ static void usb_hcd_ep93xx_remove(struct usb_hcd *hcd,
usb_remove_hcd(hcd);
ep93xx_stop_hc(&pdev->dev);
clk_put(usb_host_clock);
-   iounmap(hcd->regs);
-   release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
usb_put_hcd(hcd);
 }
 
-- 
1.8.1.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 v2 4/4] usb: ohci-ep93xx: tidy up driver (*probe) and (*remove)

2013-07-01 Thread H Hartley Sweeten
Merge the usb_hcd_ep93xx_probe() into ohci_hcd_ep93xx_drv_probe() and
the usb_hcd_ep93xx_remove() into ohci_hcd_ep93xx_drv_remove(). As Alan
Stern pointed out, there is no reason for them to be separate.

Also, as Alan Stern suggested, eliminate the ep93xx_start_hc() and
ep93xx_stop_hc() routines and simply call clk_enable() and clk_disable()
directly. The extra level of redirection does not add any clarity.

Signed-off-by: H Hartley Sweeten 
Cc: Alan Stern 
Cc: Lennert Buytenhek 
Cc: Greg Kroah-Hartman 
---
 drivers/usb/host/ohci-ep93xx.c | 128 +
 1 file changed, 52 insertions(+), 76 deletions(-)

diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index 28fa6b8..84a20d5 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -30,74 +30,6 @@
 
 static struct clk *usb_host_clock;
 
-static void ep93xx_start_hc(struct device *dev)
-{
-   clk_enable(usb_host_clock);
-}
-
-static void ep93xx_stop_hc(struct device *dev)
-{
-   clk_disable(usb_host_clock);
-}
-
-static int usb_hcd_ep93xx_probe(const struct hc_driver *driver,
-struct platform_device *pdev)
-{
-   struct usb_hcd *hcd;
-   struct resource *res;
-   int irq;
-   int retval;
-
-   irq = platform_get_irq(pdev, 0);
-   if (irq < 0)
-   return irq;
-
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!res)
-   return -ENXIO;
-
-   hcd = usb_create_hcd(driver, &pdev->dev, "ep93xx");
-   if (hcd == NULL)
-   return -ENOMEM;
-
-   hcd->rsrc_start = res->start;
-   hcd->rsrc_len = resource_size(res);
-
-   hcd->regs = devm_ioremap_resource(&pdev->dev, res);
-   if (IS_ERR(hcd->regs)) {
-   retval = PTR_ERR(hcd->regs);
-   goto err_put_hcd;
-   }
-
-   usb_host_clock = devm_clk_get(&pdev->dev, NULL);
-   if (IS_ERR(usb_host_clock)) {
-   retval = PTR_ERR(usb_host_clock);
-   goto err_put_hcd;
-   }
-
-   ep93xx_start_hc(&pdev->dev);
-
-   ohci_hcd_init(hcd_to_ohci(hcd));
-
-   retval = usb_add_hcd(hcd, irq, 0);
-   if (retval == 0)
-   return retval;
-
-   ep93xx_stop_hc(&pdev->dev);
-err_put_hcd:
-   usb_put_hcd(hcd);
-
-   return retval;
-}
-
-static void usb_hcd_ep93xx_remove(struct usb_hcd *hcd,
-   struct platform_device *pdev)
-{
-   usb_remove_hcd(hcd);
-   ep93xx_stop_hc(&pdev->dev);
-   usb_put_hcd(hcd);
-}
-
 static int ohci_ep93xx_start(struct usb_hcd *hcd)
 {
struct ohci_hcd *ohci = hcd_to_ohci(hcd);
@@ -138,15 +70,57 @@ static struct hc_driver ohci_ep93xx_hc_driver = {
.start_port_reset   = ohci_start_port_reset,
 };
 
-extern int usb_disabled(void);
-
 static int ohci_hcd_ep93xx_drv_probe(struct platform_device *pdev)
 {
+   struct usb_hcd *hcd;
+   struct resource *res;
+   int irq;
int ret;
 
-   ret = -ENODEV;
-   if (!usb_disabled())
-   ret = usb_hcd_ep93xx_probe(&ohci_ep93xx_hc_driver, pdev);
+   if (usb_disabled())
+   return -ENODEV;
+
+   irq = platform_get_irq(pdev, 0);
+   if (irq < 0)
+   return irq;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!res)
+   return -ENXIO;
+
+   hcd = usb_create_hcd(&ohci_ep93xx_hc_driver, &pdev->dev, "ep93xx");
+   if (!hcd)
+   return -ENOMEM;
+
+   hcd->rsrc_start = res->start;
+   hcd->rsrc_len = resource_size(res);
+
+   hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+   if (IS_ERR(hcd->regs)) {
+   ret = PTR_ERR(hcd->regs);
+   goto err_put_hcd;
+   }
+
+   usb_host_clock = devm_clk_get(&pdev->dev, NULL);
+   if (IS_ERR(usb_host_clock)) {
+   ret = PTR_ERR(usb_host_clock);
+   goto err_put_hcd;
+   }
+
+   clk_enable(usb_host_clock);
+
+   ohci_hcd_init(hcd_to_ohci(hcd));
+
+   ret = usb_add_hcd(hcd, irq, 0);
+   if (ret)
+   goto err_clk_disable;
+
+   return 0;
+
+err_clk_disable:
+   clk_disable(usb_host_clock);
+err_put_hcd:
+   usb_put_hcd(hcd);
 
return ret;
 }
@@ -155,7 +129,9 @@ static int ohci_hcd_ep93xx_drv_remove(struct 
platform_device *pdev)
 {
struct usb_hcd *hcd = platform_get_drvdata(pdev);
 
-   usb_hcd_ep93xx_remove(hcd, pdev);
+   usb_remove_hcd(hcd);
+   clk_disable(usb_host_clock);
+   usb_put_hcd(hcd);
 
return 0;
 }
@@ -170,7 +146,7 @@ static int ohci_hcd_ep93xx_drv_suspend(struct 
platform_device *pdev, pm_message_
msleep(5);
ohci->next_statechange = jiffies;
 
-   ep93xx_stop_hc(&pdev->dev);
+   clk_disable(usb_host_c

[PATCH v2 2/4] usb: ohci-ep93xx: use platform_get_irq()

2013-07-01 Thread H Hartley Sweeten
Use platform_get_irq() instead of accessing the platform_device
resources directly.

Signed-off-by: H Hartley Sweeten 
Acked-by: Alan Stern 
Cc: Lennert Buytenhek 
Cc: Greg Kroah-Hartman 
---
 drivers/usb/host/ohci-ep93xx.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index 4e12f67..b4f5e64 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -45,12 +45,12 @@ static int usb_hcd_ep93xx_probe(const struct hc_driver 
*driver,
 {
struct usb_hcd *hcd;
struct resource *res;
+   int irq;
int retval;
 
-   if (pdev->resource[1].flags != IORESOURCE_IRQ) {
-   dev_dbg(&pdev->dev, "resource[1] is not IORESOURCE_IRQ\n");
-   return -ENOMEM;
-   }
+   irq = platform_get_irq(pdev, 0);
+   if (irq < 0)
+   return irq;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
@@ -80,7 +80,7 @@ static int usb_hcd_ep93xx_probe(const struct hc_driver 
*driver,
 
ohci_hcd_init(hcd_to_ohci(hcd));
 
-   retval = usb_add_hcd(hcd, pdev->resource[1].start, 0);
+   retval = usb_add_hcd(hcd, irq, 0);
if (retval == 0)
return retval;
 
-- 
1.8.1.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 v2 3/4] usb: ohci-ep93xx: use devm_clk_get()

2013-07-01 Thread H Hartley Sweeten
Use devm_clk_get() to make the code a bit cleaner and simpler.

This also fixes a bug where a clk_put() is not done if usb_add_hcd()
fails.

Signed-off-by: H Hartley Sweeten 
Acked-by: Alan Stern 
Cc: Lennert Buytenhek 
Cc: Greg Kroah-Hartman 
---
 drivers/usb/host/ohci-ep93xx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index b4f5e64..28fa6b8 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -69,9 +69,8 @@ static int usb_hcd_ep93xx_probe(const struct hc_driver 
*driver,
goto err_put_hcd;
}
 
-   usb_host_clock = clk_get(&pdev->dev, NULL);
+   usb_host_clock = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(usb_host_clock)) {
-   dev_dbg(&pdev->dev, "clk_get failed\n");
retval = PTR_ERR(usb_host_clock);
goto err_put_hcd;
}
@@ -96,7 +95,6 @@ static void usb_hcd_ep93xx_remove(struct usb_hcd *hcd,
 {
usb_remove_hcd(hcd);
ep93xx_stop_hc(&pdev->dev);
-   clk_put(usb_host_clock);
usb_put_hcd(hcd);
 }
 
-- 
1.8.1.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 v2 00/11] spi: spi-ep93xx: tidy up and convert to queued driver infrastructure

2013-07-02 Thread H Hartley Sweeten
Do a bit of housekeeping in this driver and convert it to use the
SPI queued driver infrastructure.

v2: rebased on next-20130702
address some comments from Ryan Mallon and Mika Westerberg
added a couple more cleanup patches

Patch 1/11 was already applied by Mark Brown. It is included here only for
completeness.

H Hartley Sweeten (11):
  spi: spi-ep93xx: always handle transfer specific settings
  spi: spi-ep93xx: use read,write instead of __raw_* variants
  spi: spi-ep93xx: remove bits_per_word() helper
  spi: spi-ep93xx: get platform resources early in (*probe)
  spi: spi-ep93xx: use devm_clk_get()
  spi: spi-ep93xx: remove dev_err() for kzalloc() failure
  spi: spi-ep93xx: remove 'dss' from per chip private data
  spi: spi-ep93xx: don't bother calculating the divisors in ep93xx_spi_setup()
  spi: spi-ep93xx: move the clock divider calcs into ep93xx_spi_chip_setup()
  spi: spi-ep93xx: convert to the queued driver infrastructure
  spi: spi-ep93xx: use master->cur_msg for in-flight message

 drivers/spi/spi-ep93xx.c | 437 ++-
 1 file changed, 127 insertions(+), 310 deletions(-)

-- 
1.8.1.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 v2 01/11] spi: spi-ep93xx: always handle transfer specific settings

2013-07-02 Thread H Hartley Sweeten
__spi_async(), which starts every SPI message transfer, initializes
the bits_per_word and max speed for every transfer in the message.
Since the conditional test in ep93xx_spi_process_transfer() will
always succeed just remove it and always call ep93xx_spi_chip_setup()
to configure the hardware for each transfer in the message.

Remove the redundant ep93xx_spi_chp_setup() in ep93xx_spi_process_transfer()
which just initializes the hardware to the "default" based on the SPI
device.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Mika Westerberg 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 43 ++-
 1 file changed, 10 insertions(+), 33 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index cad30b8..11e2b99 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -708,38 +708,20 @@ static void ep93xx_spi_process_transfer(struct ep93xx_spi 
*espi,
struct spi_transfer *t)
 {
struct ep93xx_spi_chip *chip = spi_get_ctldata(msg->spi);
+   int err;
 
msg->state = t;
 
-   /*
-* Handle any transfer specific settings if needed. We use
-* temporary chip settings here and restore original later when
-* the transfer is finished.
-*/
-   if (t->speed_hz || t->bits_per_word) {
-   struct ep93xx_spi_chip tmp_chip = *chip;
-
-   if (t->speed_hz) {
-   int err;
-
-   err = ep93xx_spi_calc_divisors(espi, &tmp_chip,
-  t->speed_hz);
-   if (err) {
-   dev_err(&espi->pdev->dev,
-   "failed to adjust speed\n");
-   msg->status = err;
-   return;
-   }
-   }
+   err = ep93xx_spi_calc_divisors(espi, chip, t->speed_hz);
+   if (err) {
+   dev_err(&espi->pdev->dev, "failed to adjust speed\n");
+   msg->status = err;
+   return;
+   }
 
-   if (t->bits_per_word)
-   tmp_chip.dss = bits_per_word_to_dss(t->bits_per_word);
+   chip->dss = bits_per_word_to_dss(t->bits_per_word);
 
-   /*
-* Set up temporary new hw settings for this transfer.
-*/
-   ep93xx_spi_chip_setup(espi, &tmp_chip);
-   }
+   ep93xx_spi_chip_setup(espi, chip);
 
espi->rx = 0;
espi->tx = 0;
@@ -783,9 +765,6 @@ static void ep93xx_spi_process_transfer(struct ep93xx_spi 
*espi,
ep93xx_spi_cs_control(msg->spi, true);
}
}
-
-   if (t->speed_hz || t->bits_per_word)
-   ep93xx_spi_chip_setup(espi, chip);
 }
 
 /*
@@ -838,10 +817,8 @@ static void ep93xx_spi_process_message(struct ep93xx_spi 
*espi,
espi->fifo_level = 0;
 
/*
-* Update SPI controller registers according to spi device and assert
-* the chipselect.
+* Assert the chipselect.
 */
-   ep93xx_spi_chip_setup(espi, spi_get_ctldata(msg->spi));
ep93xx_spi_cs_control(msg->spi, true);
 
list_for_each_entry(t, &msg->transfers, transfer_list) {
-- 
1.8.1.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 v2 02/11] spi: spi-ep93xx: use read,write instead of __raw_* variants

2013-07-02 Thread H Hartley Sweeten
The memory resource used by this driver is ioremap()'d and the normal
read,write calls can be used instead of the __raw_* variants.

Also, remove the inline tag on the helper functions and let the compiler
decide if they are inlined.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Mika Westerberg 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index 11e2b99..d7eccfc 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -158,28 +158,26 @@ struct ep93xx_spi_chip {
 /* converts bits per word to CR0.DSS value */
 #define bits_per_word_to_dss(bpw)  ((bpw) - 1)
 
-static inline void
-ep93xx_spi_write_u8(const struct ep93xx_spi *espi, u16 reg, u8 value)
+static void ep93xx_spi_write_u8(const struct ep93xx_spi *espi,
+   u16 reg, u8 value)
 {
-   __raw_writeb(value, espi->regs_base + reg);
+   writeb(value, espi->regs_base + reg);
 }
 
-static inline u8
-ep93xx_spi_read_u8(const struct ep93xx_spi *spi, u16 reg)
+static u8 ep93xx_spi_read_u8(const struct ep93xx_spi *spi, u16 reg)
 {
-   return __raw_readb(spi->regs_base + reg);
+   return readb(spi->regs_base + reg);
 }
 
-static inline void
-ep93xx_spi_write_u16(const struct ep93xx_spi *espi, u16 reg, u16 value)
+static void ep93xx_spi_write_u16(const struct ep93xx_spi *espi,
+u16 reg, u16 value)
 {
-   __raw_writew(value, espi->regs_base + reg);
+   writew(value, espi->regs_base + reg);
 }
 
-static inline u16
-ep93xx_spi_read_u16(const struct ep93xx_spi *spi, u16 reg)
+static u16 ep93xx_spi_read_u16(const struct ep93xx_spi *spi, u16 reg)
 {
-   return __raw_readw(spi->regs_base + reg);
+   return readw(spi->regs_base + reg);
 }
 
 static int ep93xx_spi_enable(const struct ep93xx_spi *espi)
-- 
1.8.1.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 v2 03/11] spi: spi-ep93xx: remove bits_per_word() helper

2013-07-02 Thread H Hartley Sweeten
Check t->bits_per_word directly and remove the inline helper function.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Mika Westerberg 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index d7eccfc..d5e6420 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -429,17 +429,9 @@ static void ep93xx_spi_chip_setup(const struct ep93xx_spi 
*espi,
ep93xx_spi_write_u16(espi, SSPCR0, cr0);
 }
 
-static inline int bits_per_word(const struct ep93xx_spi *espi)
-{
-   struct spi_message *msg = espi->current_msg;
-   struct spi_transfer *t = msg->state;
-
-   return t->bits_per_word;
-}
-
 static void ep93xx_do_write(struct ep93xx_spi *espi, struct spi_transfer *t)
 {
-   if (bits_per_word(espi) > 8) {
+   if (t->bits_per_word > 8) {
u16 tx_val = 0;
 
if (t->tx_buf)
@@ -458,7 +450,7 @@ static void ep93xx_do_write(struct ep93xx_spi *espi, struct 
spi_transfer *t)
 
 static void ep93xx_do_read(struct ep93xx_spi *espi, struct spi_transfer *t)
 {
-   if (bits_per_word(espi) > 8) {
+   if (t->bits_per_word > 8) {
u16 rx_val;
 
rx_val = ep93xx_spi_read_u16(espi, SSPDR);
@@ -544,7 +536,7 @@ ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum 
dma_transfer_direction dir)
size_t len = t->len;
int i, ret, nents;
 
-   if (bits_per_word(espi) > 8)
+   if (t->bits_per_word > 8)
buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES;
else
buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE;
-- 
1.8.1.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 v2 05/11] spi: spi-ep93xx: use devm_clk_get()

2013-07-02 Thread H Hartley Sweeten
Use devm_clk_get() so that the clk_put() happens automatically when
the last reference to this driver is dropped.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Mika Westerberg 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index c2660c2..c1a610e 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -1021,7 +1021,7 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
 
espi = spi_master_get_devdata(master);
 
-   espi->clk = clk_get(&pdev->dev, NULL);
+   espi->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(espi->clk)) {
dev_err(&pdev->dev, "unable to get spi clock\n");
error = PTR_ERR(espi->clk);
@@ -1044,14 +1044,14 @@ static int ep93xx_spi_probe(struct platform_device 
*pdev)
espi->regs_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(espi->regs_base)) {
error = PTR_ERR(espi->regs_base);
-   goto fail_put_clock;
+   goto fail_release_master;
}
 
error = devm_request_irq(&pdev->dev, irq, ep93xx_spi_interrupt,
0, "ep93xx-spi", espi);
if (error) {
dev_err(&pdev->dev, "failed to request irq\n");
-   goto fail_put_clock;
+   goto fail_release_master;
}
 
if (info->use_dma && ep93xx_spi_setup_dma(espi))
@@ -1085,8 +1085,6 @@ fail_free_queue:
destroy_workqueue(espi->wq);
 fail_free_dma:
ep93xx_spi_release_dma(espi);
-fail_put_clock:
-   clk_put(espi->clk);
 fail_release_master:
spi_master_put(master);
 
@@ -1122,7 +1120,6 @@ static int ep93xx_spi_remove(struct platform_device *pdev)
spin_unlock_irq(&espi->lock);
 
ep93xx_spi_release_dma(espi);
-   clk_put(espi->clk);
 
spi_unregister_master(master);
return 0;
-- 
1.8.1.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 v2 04/11] spi: spi-ep93xx: get platform resources early in (*probe)

2013-07-02 Thread H Hartley Sweeten
Get the platform resources early in the (*probe) to minimize the number
of goto's in the error path.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Mika Westerberg 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 26 --
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index d5e6420..c2660c2 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -991,6 +991,18 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
 
info = pdev->dev.platform_data;
 
+   irq = platform_get_irq(pdev, 0);
+   if (irq < 0) {
+   dev_err(&pdev->dev, "failed to get irq resources\n");
+   return -EBUSY;
+   }
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!res) {
+   dev_err(&pdev->dev, "unable to get iomem resource\n");
+   return -ENODEV;
+   }
+
master = spi_alloc_master(&pdev->dev, sizeof(*espi));
if (!master) {
dev_err(&pdev->dev, "failed to allocate spi master\n");
@@ -1027,20 +1039,6 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
espi->min_rate = clk_get_rate(espi->clk) / (254 * 256);
espi->pdev = pdev;
 
-   irq = platform_get_irq(pdev, 0);
-   if (irq < 0) {
-   error = -EBUSY;
-   dev_err(&pdev->dev, "failed to get irq resources\n");
-   goto fail_put_clock;
-   }
-
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!res) {
-   dev_err(&pdev->dev, "unable to get iomem resource\n");
-   error = -ENODEV;
-   goto fail_put_clock;
-   }
-
espi->sspdr_phys = res->start + SSPDR;
 
espi->regs_base = devm_ioremap_resource(&pdev->dev, res);
-- 
1.8.1.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 v2 07/11] spi: spi-ep93xx: remove 'dss' from per chip private data

2013-07-02 Thread H Hartley Sweeten
This value is only needed to set the bits per word for each transfer
of a message. There is no reason to set the value in ep93xx_spi_enable()
because ep93xx_spi_process_transfer() sets it again for each transfer.

Just pass the t->bits_per_word directly to ep93xx_spi_chip_setup() in
ep93xx_spi_process_transfer() and remove 'dss' from the per chip private
data.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Mika Westerberg 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index 34aade1..cc2a240 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -139,7 +139,6 @@ struct ep93xx_spi {
  * @rate: max rate in hz this chip supports
  * @div_cpsr: cpsr (pre-scaler) divider
  * @div_scr: scr divider
- * @dss: bits per word (4 - 16 bits)
  * @ops: private chip operations
  *
  * This structure is used to store hardware register specific settings for each
@@ -151,7 +150,6 @@ struct ep93xx_spi_chip {
unsigned long   rate;
u8  div_cpsr;
u8  div_scr;
-   u8  dss;
struct ep93xx_spi_chip_ops  *ops;
 };
 
@@ -329,8 +327,6 @@ static int ep93xx_spi_setup(struct spi_device *spi)
chip->rate = spi->max_speed_hz;
}
 
-   chip->dss = bits_per_word_to_dss(spi->bits_per_word);
-
ep93xx_spi_cs_control(spi, false);
return 0;
 }
@@ -407,22 +403,25 @@ static void ep93xx_spi_cleanup(struct spi_device *spi)
  * ep93xx_spi_chip_setup() - configures hardware according to given @chip
  * @espi: ep93xx SPI controller struct
  * @chip: chip specific settings
+ * @bits_per_word: transfer bits_per_word
  *
  * This function sets up the actual hardware registers with settings given in
  * @chip. Note that no validation is done so make sure that callers validate
  * settings before calling this.
  */
 static void ep93xx_spi_chip_setup(const struct ep93xx_spi *espi,
- const struct ep93xx_spi_chip *chip)
+ const struct ep93xx_spi_chip *chip,
+ u8 bits_per_word)
 {
+   u8 dss = bits_per_word_to_dss(bits_per_word);
u16 cr0;
 
cr0 = chip->div_scr << SSPCR0_SCR_SHIFT;
cr0 |= (chip->spi->mode & (SPI_CPHA|SPI_CPOL)) << SSPCR0_MODE_SHIFT;
-   cr0 |= chip->dss;
+   cr0 |= dss;
 
dev_dbg(&espi->pdev->dev, "setup: mode %d, cpsr %d, scr %d, dss %d\n",
-   chip->spi->mode, chip->div_cpsr, chip->div_scr, chip->dss);
+   chip->spi->mode, chip->div_cpsr, chip->div_scr, dss);
dev_dbg(&espi->pdev->dev, "setup: cr0 %#x", cr0);
 
ep93xx_spi_write_u8(espi, SSPCPSR, chip->div_cpsr);
@@ -709,9 +708,7 @@ static void ep93xx_spi_process_transfer(struct ep93xx_spi 
*espi,
return;
}
 
-   chip->dss = bits_per_word_to_dss(t->bits_per_word);
-
-   ep93xx_spi_chip_setup(espi, chip);
+   ep93xx_spi_chip_setup(espi, chip, t->bits_per_word);
 
espi->rx = 0;
espi->tx = 0;
-- 
1.8.1.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 v2 08/11] spi: spi-ep93xx: don't bother calculating the divisors in ep93xx_spi_setup()

2013-07-02 Thread H Hartley Sweeten
The divisors needed to generate the SPI clock are calculated per
transfer based on the t->speed_hz. There is no reason to calculate
them in ep93xx_spi_setup().

Signed-off-by: H Hartley Sweeten 
Acked-by: Mika Westerberg 
Cc: Ryan Mallon 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 14 --
 1 file changed, 14 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index cc2a240..6cdfc40 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -136,7 +136,6 @@ struct ep93xx_spi {
 /**
  * struct ep93xx_spi_chip - SPI device hardware settings
  * @spi: back pointer to the SPI device
- * @rate: max rate in hz this chip supports
  * @div_cpsr: cpsr (pre-scaler) divider
  * @div_scr: scr divider
  * @ops: private chip operations
@@ -147,7 +146,6 @@ struct ep93xx_spi {
  */
 struct ep93xx_spi_chip {
const struct spi_device *spi;
-   unsigned long   rate;
u8  div_cpsr;
u8  div_scr;
struct ep93xx_spi_chip_ops  *ops;
@@ -315,18 +313,6 @@ static int ep93xx_spi_setup(struct spi_device *spi)
spi_set_ctldata(spi, chip);
}
 
-   if (spi->max_speed_hz != chip->rate) {
-   int err;
-
-   err = ep93xx_spi_calc_divisors(espi, chip, spi->max_speed_hz);
-   if (err != 0) {
-   spi_set_ctldata(spi, NULL);
-   kfree(chip);
-   return err;
-   }
-   chip->rate = spi->max_speed_hz;
-   }
-
ep93xx_spi_cs_control(spi, false);
return 0;
 }
-- 
1.8.1.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 v2 09/11] spi: spi-ep93xx: move the clock divider calcs into ep93xx_spi_chip_setup()

2013-07-02 Thread H Hartley Sweeten
The divider values stored in the per chip data are only used to set the
registers in the hardware to generate the desired SPI clock. Since these
are calculated per transfer based on the t->speed_hz there is no reason
keep them in the per chip data.

Move the ep93xx_spi_calc_divisors() call into ep93xx_spi_chip_setup()
and return the dividers thru pointers. Remove the divider values from
the per chip data structure.

Signed-off-by: H Hartley Sweeten 
Acked-by: Mika Westerberg 
Cc: Ryan Mallon 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 57 +---
 1 file changed, 25 insertions(+), 32 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index 6cdfc40..2e64806 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -136,18 +136,10 @@ struct ep93xx_spi {
 /**
  * struct ep93xx_spi_chip - SPI device hardware settings
  * @spi: back pointer to the SPI device
- * @div_cpsr: cpsr (pre-scaler) divider
- * @div_scr: scr divider
  * @ops: private chip operations
- *
- * This structure is used to store hardware register specific settings for each
- * SPI device. Settings are written to hardware by function
- * ep93xx_spi_chip_setup().
  */
 struct ep93xx_spi_chip {
const struct spi_device *spi;
-   u8  div_cpsr;
-   u8  div_scr;
struct ep93xx_spi_chip_ops  *ops;
 };
 
@@ -224,17 +216,13 @@ static void ep93xx_spi_disable_interrupts(const struct 
ep93xx_spi *espi)
 /**
  * ep93xx_spi_calc_divisors() - calculates SPI clock divisors
  * @espi: ep93xx SPI controller struct
- * @chip: divisors are calculated for this chip
  * @rate: desired SPI output clock rate
- *
- * Function calculates cpsr (clock pre-scaler) and scr divisors based on
- * given @rate and places them to @chip->div_cpsr and @chip->div_scr. If,
- * for some reason, divisors cannot be calculated nothing is stored and
- * %-EINVAL is returned.
+ * @div_cpsr: pointer to return the cpsr (pre-scaler) divider
+ * @div_scr: pointer to return the scr divider
  */
 static int ep93xx_spi_calc_divisors(const struct ep93xx_spi *espi,
-   struct ep93xx_spi_chip *chip,
-   unsigned long rate)
+   unsigned long rate,
+   u8 *div_cpsr, u8 *div_scr)
 {
unsigned long spi_clk_rate = clk_get_rate(espi->clk);
int cpsr, scr;
@@ -257,8 +245,8 @@ static int ep93xx_spi_calc_divisors(const struct ep93xx_spi 
*espi,
for (cpsr = 2; cpsr <= 254; cpsr += 2) {
for (scr = 0; scr <= 255; scr++) {
if ((spi_clk_rate / (cpsr * (scr + 1))) <= rate) {
-   chip->div_scr = (u8)scr;
-   chip->div_cpsr = (u8)cpsr;
+   *div_scr = (u8)scr;
+   *div_cpsr = (u8)cpsr;
return 0;
}
}
@@ -389,29 +377,35 @@ static void ep93xx_spi_cleanup(struct spi_device *spi)
  * ep93xx_spi_chip_setup() - configures hardware according to given @chip
  * @espi: ep93xx SPI controller struct
  * @chip: chip specific settings
+ * @speed_hz: transfer speed
  * @bits_per_word: transfer bits_per_word
- *
- * This function sets up the actual hardware registers with settings given in
- * @chip. Note that no validation is done so make sure that callers validate
- * settings before calling this.
  */
-static void ep93xx_spi_chip_setup(const struct ep93xx_spi *espi,
- const struct ep93xx_spi_chip *chip,
- u8 bits_per_word)
+static int ep93xx_spi_chip_setup(const struct ep93xx_spi *espi,
+const struct ep93xx_spi_chip *chip,
+u32 speed_hz, u8 bits_per_word)
 {
u8 dss = bits_per_word_to_dss(bits_per_word);
+   u8 div_cpsr = 0;
+   u8 div_scr = 0;
u16 cr0;
+   int err;
+
+   err = ep93xx_spi_calc_divisors(espi, speed_hz, &div_cpsr, &div_scr);
+   if (err)
+   return err;
 
-   cr0 = chip->div_scr << SSPCR0_SCR_SHIFT;
+   cr0 = div_scr << SSPCR0_SCR_SHIFT;
cr0 |= (chip->spi->mode & (SPI_CPHA|SPI_CPOL)) << SSPCR0_MODE_SHIFT;
cr0 |= dss;
 
dev_dbg(&espi->pdev->dev, "setup: mode %d, cpsr %d, scr %d, dss %d\n",
-   chip->spi->mode, chip->div_cpsr, chip->div_scr, dss);
+   chip->spi->mode, div_cpsr, div_scr, dss);
dev_dbg(&espi->pdev->dev, "setup: cr0 %#x", cr0);
 
-   ep93xx_spi_write_u8(espi, SSPCPSR, chip->div_cpsr);
+   ep93xx_spi_write_u8(espi, SSPCPSR, div_cpsr);
ep93xx_spi_write_u16(espi, 

[PATCH v2 06/11] spi: spi-ep93xx: remove dev_err() for kzalloc() failure

2013-07-02 Thread H Hartley Sweeten
The kzalloc() failure will have already output a message.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Mika Westerberg 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index c1a610e..34aade1 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -1004,10 +1004,8 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
}
 
master = spi_alloc_master(&pdev->dev, sizeof(*espi));
-   if (!master) {
-   dev_err(&pdev->dev, "failed to allocate spi master\n");
+   if (!master)
return -ENOMEM;
-   }
 
master->setup = ep93xx_spi_setup;
master->transfer = ep93xx_spi_transfer;
-- 
1.8.1.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/


RE: [PATCH v2 05/11] spi: spi-ep93xx: use devm_clk_get()

2013-07-03 Thread H Hartley Sweeten
On Wednesday, July 03, 2013 11:21 AM, Mark Brown wrote:
> On Tue, Jul 02, 2013 at 10:08:21AM -0700, H Hartley Sweeten wrote:
>> Use devm_clk_get() so that the clk_put() happens automatically when
>> the last reference to this driver is dropped.
>
> This doesn't apply against current code - always submit against the
> relevant development tree, in this case topic/ep93xx.  I've applied it
> with a manual fixup.

Sorry about the trouble. Thanks for fixing it.

Regards,
Hartley

--
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 v2 05/11] spi: spi-ep93xx: use devm_clk_get()

2013-07-03 Thread H Hartley Sweeten
On Wednesday, July 03, 2013 11:21 AM, Mark Brown wrote:
> On Tue, Jul 02, 2013 at 10:08:21AM -0700, H Hartley Sweeten wrote:
>> Use devm_clk_get() so that the clk_put() happens automatically when
>> the last reference to this driver is dropped.
>
> This doesn't apply against current code - always submit against the
> relevant development tree, in this case topic/ep93xx.  I've applied it
> with a manual fixup.

Hello Mark,

It appears your topic/ep93xx branch is missing this:

commit 24778be20f87d5aadb19624fc768b3159fa43efc
Author: Stephen Warren 
Date:   Tue May 21 20:36:35 2013 -0600

spi: convert drivers to use bits_per_word_mask

This commit is in linux-next which is what the patch series was based on.
I'm not sure what branch you applied that patch to.

If you need to drop my previous patches that you applied to topic/ep93xx
in order to sync things up please let me know how to proceed. There are
four more patches pending for spi-ep93xx to finish the cleanup and convert
it to the SPI queued driver infrastructure.

These are the relevant commits in topic/spi-ep93xx:

kernel / pub/scm/linux/kernel/git/broonie/spi / topic/ep93xx / drivers / spi / 
spi-ep93xx.c

3051c43  spi: spi-ep93xx: use devm_clk_get() by H Hartley Sweeten - 28 hours 
ago topic/ep93xx
e5ae625  spi: spi-ep93xx: remove 'dss' from per chip private data by H Hartley 
Sweeten - 28 hours ago
4af59ef  spi: spi-ep93xx: remove dev_err() for kzalloc() failure by H Hartley 
Sweeten - 28 hours ago
8b9d957  spi: spi-ep93xx: get platform resources early in (*probe) by H Hartley 
Sweeten - 28 hours ago
c6b7f14  spi: spi-ep93xx: remove bits_per_word() helper by H Hartley Sweeten - 
28 hours ago
75c7444  spi: spi-ep93xx: use read,write instead of __raw_* variants by H 
Hartley Sweeten - 28 hours ago
eb41eeb  spi: spi-ep93xx: always handle transfer specific settings by H Hartley 
Sweeten - 5 days ago

Sorry about the trouble. I don't have your tree pulled so I was starting
from linux-next under the assumption that it was current to your tree.

Regards,
Hartley

--
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/8] spi: spi-ep93xx: tidy up and convert to queued driver infrastructure

2013-06-28 Thread H Hartley Sweeten
Do a bit of housecleaning in this driver and convert it to use the
SPI queued driver infrastructure.

H Hartley Sweeten (8):
  spi: spi-ep93xx: use read,write instead of __raw_* variants
  spi: spi-ep93xx: use bits_per_word_mask
  spi: spi-ep93xx: always handle transfer specific settings
  spi: spi-ep93xx: remove bits_per_word() helper
  spi: spi-ep93xx: remove 'dss' from per chip private data
  spi: spi-ep93xx: don't bother calculating the divisors in ep93xx_spi_setup()
  spi: spi-ep93xx: move the clock divider calcs into ep93xx_spi_chip_setup()
  spi: spi-ep93xx: convert to the queued driver infrastructure

 drivers/spi/spi-ep93xx.c | 366 ++-
 1 file changed, 75 insertions(+), 291 deletions(-)

-- 
1.8.1.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/8] spi: spi-ep93xx: use read,write instead of __raw_* variants

2013-06-28 Thread H Hartley Sweeten
The memory resource used by this driver is ioremap()'d and the normal
read,write calls can be used instead of the __raw_* variants.

Remove the inline read,write helpers and just do the read,write
directly in the callers.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Mika Westerberg 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 64 +++-
 1 file changed, 20 insertions(+), 44 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index d7bac60..c633cd0 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -158,30 +158,6 @@ struct ep93xx_spi_chip {
 /* converts bits per word to CR0.DSS value */
 #define bits_per_word_to_dss(bpw)  ((bpw) - 1)
 
-static inline void
-ep93xx_spi_write_u8(const struct ep93xx_spi *espi, u16 reg, u8 value)
-{
-   __raw_writeb(value, espi->regs_base + reg);
-}
-
-static inline u8
-ep93xx_spi_read_u8(const struct ep93xx_spi *spi, u16 reg)
-{
-   return __raw_readb(spi->regs_base + reg);
-}
-
-static inline void
-ep93xx_spi_write_u16(const struct ep93xx_spi *espi, u16 reg, u16 value)
-{
-   __raw_writew(value, espi->regs_base + reg);
-}
-
-static inline u16
-ep93xx_spi_read_u16(const struct ep93xx_spi *spi, u16 reg)
-{
-   return __raw_readw(spi->regs_base + reg);
-}
-
 static int ep93xx_spi_enable(const struct ep93xx_spi *espi)
 {
u8 regval;
@@ -191,9 +167,9 @@ static int ep93xx_spi_enable(const struct ep93xx_spi *espi)
if (err)
return err;
 
-   regval = ep93xx_spi_read_u8(espi, SSPCR1);
+   regval = readb(espi->regs_base + SSPCR1);
regval |= SSPCR1_SSE;
-   ep93xx_spi_write_u8(espi, SSPCR1, regval);
+   writeb(regval, espi->regs_base + SSPCR1);
 
return 0;
 }
@@ -202,9 +178,9 @@ static void ep93xx_spi_disable(const struct ep93xx_spi 
*espi)
 {
u8 regval;
 
-   regval = ep93xx_spi_read_u8(espi, SSPCR1);
+   regval = readb(espi->regs_base + SSPCR1);
regval &= ~SSPCR1_SSE;
-   ep93xx_spi_write_u8(espi, SSPCR1, regval);
+   writeb(regval, espi->regs_base + SSPCR1);
 
clk_disable(espi->clk);
 }
@@ -213,18 +189,18 @@ static void ep93xx_spi_enable_interrupts(const struct 
ep93xx_spi *espi)
 {
u8 regval;
 
-   regval = ep93xx_spi_read_u8(espi, SSPCR1);
+   regval = readb(espi->regs_base + SSPCR1);
regval |= (SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE);
-   ep93xx_spi_write_u8(espi, SSPCR1, regval);
+   writeb(regval, espi->regs_base + SSPCR1);
 }
 
 static void ep93xx_spi_disable_interrupts(const struct ep93xx_spi *espi)
 {
u8 regval;
 
-   regval = ep93xx_spi_read_u8(espi, SSPCR1);
+   regval = readb(espi->regs_base + SSPCR1);
regval &= ~(SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE);
-   ep93xx_spi_write_u8(espi, SSPCR1, regval);
+   writeb(regval, espi->regs_base + SSPCR1);
 }
 
 /**
@@ -437,8 +413,8 @@ static void ep93xx_spi_chip_setup(const struct ep93xx_spi 
*espi,
chip->spi->mode, chip->div_cpsr, chip->div_scr, chip->dss);
dev_dbg(&espi->pdev->dev, "setup: cr0 %#x", cr0);
 
-   ep93xx_spi_write_u8(espi, SSPCPSR, chip->div_cpsr);
-   ep93xx_spi_write_u16(espi, SSPCR0, cr0);
+   writeb(chip->div_cpsr, espi->regs_base + SSPCPSR);
+   writew(cr0, espi->regs_base + SSPCR0);
 }
 
 static inline int bits_per_word(const struct ep93xx_spi *espi)
@@ -456,14 +432,14 @@ static void ep93xx_do_write(struct ep93xx_spi *espi, 
struct spi_transfer *t)
 
if (t->tx_buf)
tx_val = ((u16 *)t->tx_buf)[espi->tx];
-   ep93xx_spi_write_u16(espi, SSPDR, tx_val);
+   writew(tx_val, espi->regs_base + SSPDR);
espi->tx += sizeof(tx_val);
} else {
u8 tx_val = 0;
 
if (t->tx_buf)
tx_val = ((u8 *)t->tx_buf)[espi->tx];
-   ep93xx_spi_write_u8(espi, SSPDR, tx_val);
+   writeb(tx_val, espi->regs_base + SSPDR);
espi->tx += sizeof(tx_val);
}
 }
@@ -473,14 +449,14 @@ static void ep93xx_do_read(struct ep93xx_spi *espi, 
struct spi_transfer *t)
if (bits_per_word(espi) > 8) {
u16 rx_val;
 
-   rx_val = ep93xx_spi_read_u16(espi, SSPDR);
+   rx_val = readw(espi->regs_base + SSPDR);
if (t->rx_buf)
((u16 *)t->rx_buf)[espi->rx] = rx_val;
espi->rx += sizeof(rx_val);
} else {
u8 rx_val;
 
-   rx_val = ep93xx_spi_read_u8(espi, SSPDR);
+   rx_val = readb(espi->regs_base + SSPDR);
if (t->rx_buf)
((u8 *)t->rx_buf)[espi->rx] = rx_val;
espi->rx += sizeof(r

[PATCH 2/8] spi: spi-ep93xx: use bits_per_word_mask

2013-06-28 Thread H Hartley Sweeten
This driver supports 16 to 4 bits per work. Set the bits_per_word_mask
to allows the spi core to handle validation.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Mika Westerberg 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index c633cd0..93ae7b6 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -272,12 +272,6 @@ static int ep93xx_spi_setup(struct spi_device *spi)
struct ep93xx_spi *espi = spi_master_get_devdata(spi->master);
struct ep93xx_spi_chip *chip;
 
-   if (spi->bits_per_word < 4 || spi->bits_per_word > 16) {
-   dev_err(&espi->pdev->dev, "invalid bits per word %d\n",
-   spi->bits_per_word);
-   return -EINVAL;
-   }
-
chip = spi_get_ctldata(spi);
if (!chip) {
dev_dbg(&espi->pdev->dev, "initial setup for %s\n",
@@ -341,10 +335,6 @@ static int ep93xx_spi_transfer(struct spi_device *spi, 
struct spi_message *msg)
 
/* first validate each transfer */
list_for_each_entry(t, &msg->transfers, transfer_list) {
-   if (t->bits_per_word) {
-   if (t->bits_per_word < 4 || t->bits_per_word > 16)
-   return -EINVAL;
-   }
if (t->speed_hz && t->speed_hz < espi->min_rate)
return -EINVAL;
}
@@ -1022,6 +1012,7 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
master->bus_num = pdev->id;
master->num_chipselect = info->num_chipselect;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
+   master->bits_per_word_mask = 0xfff8;/* 16 to 4 bits per word */
 
platform_set_drvdata(pdev, master);
 
-- 
1.8.1.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 3/8] spi: spi-ep93xx: always handle transfer specific settings

2013-06-28 Thread H Hartley Sweeten
__spi_async(), which starts every SPI message transfer, initializes
the bits_per_word and max speed for every transfer in the message.
Since the conditional test in ep93xx_spi_process_transfer() will
always succeed just remove it and always call ep93xx_spi_chip_setup()
to configure the hardware for each transfer in the message.

Remove the redundant ep93xx_spi_chp_setup() in ep93xx_spi_process_transfer()
which just initializes the hardware to the "default" based on the SPI
device.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Mika Westerberg 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 43 ++-
 1 file changed, 10 insertions(+), 33 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index 93ae7b6..bcfd35a 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -684,38 +684,20 @@ static void ep93xx_spi_process_transfer(struct ep93xx_spi 
*espi,
struct spi_transfer *t)
 {
struct ep93xx_spi_chip *chip = spi_get_ctldata(msg->spi);
+   int err;
 
msg->state = t;
 
-   /*
-* Handle any transfer specific settings if needed. We use
-* temporary chip settings here and restore original later when
-* the transfer is finished.
-*/
-   if (t->speed_hz || t->bits_per_word) {
-   struct ep93xx_spi_chip tmp_chip = *chip;
-
-   if (t->speed_hz) {
-   int err;
-
-   err = ep93xx_spi_calc_divisors(espi, &tmp_chip,
-  t->speed_hz);
-   if (err) {
-   dev_err(&espi->pdev->dev,
-   "failed to adjust speed\n");
-   msg->status = err;
-   return;
-   }
-   }
+   err = ep93xx_spi_calc_divisors(espi, chip, t->speed_hz);
+   if (err) {
+   dev_err(&espi->pdev->dev, "failed to adjust speed\n");
+   msg->status = err;
+   return;
+   }
 
-   if (t->bits_per_word)
-   tmp_chip.dss = bits_per_word_to_dss(t->bits_per_word);
+   chip->dss = bits_per_word_to_dss(t->bits_per_word);
 
-   /*
-* Set up temporary new hw settings for this transfer.
-*/
-   ep93xx_spi_chip_setup(espi, &tmp_chip);
-   }
+   ep93xx_spi_chip_setup(espi, chip);
 
espi->rx = 0;
espi->tx = 0;
@@ -759,9 +741,6 @@ static void ep93xx_spi_process_transfer(struct ep93xx_spi 
*espi,
ep93xx_spi_cs_control(msg->spi, true);
}
}
-
-   if (t->speed_hz || t->bits_per_word)
-   ep93xx_spi_chip_setup(espi, chip);
 }
 
 /*
@@ -814,10 +793,8 @@ static void ep93xx_spi_process_message(struct ep93xx_spi 
*espi,
espi->fifo_level = 0;
 
/*
-* Update SPI controller registers according to spi device and assert
-* the chipselect.
+* Assert the chipselect.
 */
-   ep93xx_spi_chip_setup(espi, spi_get_ctldata(msg->spi));
ep93xx_spi_cs_control(msg->spi, true);
 
list_for_each_entry(t, &msg->transfers, transfer_list) {
-- 
1.8.1.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 4/8] spi: spi-ep93xx: remove bits_per_word() helper

2013-06-28 Thread H Hartley Sweeten
This inline helper function is only used to determine the bus width
of the current transfer (8 or 16 bit). Add a bool flag to the private
structure and set it appropriately for each transfer.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Mika Westerberg 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index bcfd35a..4fab3bb 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -116,6 +116,7 @@ struct ep93xx_spi {
unsigned long   min_rate;
unsigned long   max_rate;
boolrunning;
+   boolword_xfer;
struct workqueue_struct *wq;
struct work_struct  msg_work;
struct completion   wait;
@@ -407,17 +408,9 @@ static void ep93xx_spi_chip_setup(const struct ep93xx_spi 
*espi,
writew(cr0, espi->regs_base + SSPCR0);
 }
 
-static inline int bits_per_word(const struct ep93xx_spi *espi)
-{
-   struct spi_message *msg = espi->current_msg;
-   struct spi_transfer *t = msg->state;
-
-   return t->bits_per_word;
-}
-
 static void ep93xx_do_write(struct ep93xx_spi *espi, struct spi_transfer *t)
 {
-   if (bits_per_word(espi) > 8) {
+   if (espi->word_xfer) {
u16 tx_val = 0;
 
if (t->tx_buf)
@@ -436,7 +429,7 @@ static void ep93xx_do_write(struct ep93xx_spi *espi, struct 
spi_transfer *t)
 
 static void ep93xx_do_read(struct ep93xx_spi *espi, struct spi_transfer *t)
 {
-   if (bits_per_word(espi) > 8) {
+   if (espi->word_xfer) {
u16 rx_val;
 
rx_val = readw(espi->regs_base + SSPDR);
@@ -522,7 +515,7 @@ ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum 
dma_transfer_direction dir)
size_t len = t->len;
int i, ret, nents;
 
-   if (bits_per_word(espi) > 8)
+   if (espi->word_xfer)
buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES;
else
buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE;
@@ -699,6 +692,7 @@ static void ep93xx_spi_process_transfer(struct ep93xx_spi 
*espi,
 
ep93xx_spi_chip_setup(espi, chip);
 
+   espi->word_xfer = (t->bits_per_word > 8) ? true : false;
espi->rx = 0;
espi->tx = 0;
 
-- 
1.8.1.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 5/8] spi: spi-ep93xx: remove 'dss' from per chip private data

2013-06-28 Thread H Hartley Sweeten
This value is only needed to set the bits per word for each transfer
of a message. There is no reason to set the value in ep93xx_spi_enable()
because ep93xx_spi_process_transfer() sets it again for each transfer.

Just pass the t->bits_per_word directly to ep93xx_spi_chip_setup() in
ep93xx_spi_process_transfer() and remove 'dss' from the per chip private
data.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Mika Westerberg 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 20 +++-
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index 4fab3bb..cb22c89 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -140,7 +140,6 @@ struct ep93xx_spi {
  * @rate: max rate in hz this chip supports
  * @div_cpsr: cpsr (pre-scaler) divider
  * @div_scr: scr divider
- * @dss: bits per word (4 - 16 bits)
  * @ops: private chip operations
  *
  * This structure is used to store hardware register specific settings for each
@@ -152,13 +151,9 @@ struct ep93xx_spi_chip {
unsigned long   rate;
u8  div_cpsr;
u8  div_scr;
-   u8  dss;
struct ep93xx_spi_chip_ops  *ops;
 };
 
-/* converts bits per word to CR0.DSS value */
-#define bits_per_word_to_dss(bpw)  ((bpw) - 1)
-
 static int ep93xx_spi_enable(const struct ep93xx_spi *espi)
 {
u8 regval;
@@ -308,8 +303,6 @@ static int ep93xx_spi_setup(struct spi_device *spi)
chip->rate = spi->max_speed_hz;
}
 
-   chip->dss = bits_per_word_to_dss(spi->bits_per_word);
-
ep93xx_spi_cs_control(spi, false);
return 0;
 }
@@ -386,22 +379,25 @@ static void ep93xx_spi_cleanup(struct spi_device *spi)
  * ep93xx_spi_chip_setup() - configures hardware according to given @chip
  * @espi: ep93xx SPI controller struct
  * @chip: chip specific settings
+ * @bits_per_word: transfer bits_per_word
  *
  * This function sets up the actual hardware registers with settings given in
  * @chip. Note that no validation is done so make sure that callers validate
  * settings before calling this.
  */
 static void ep93xx_spi_chip_setup(const struct ep93xx_spi *espi,
- const struct ep93xx_spi_chip *chip)
+ const struct ep93xx_spi_chip *chip,
+ u8 bits_per_word)
 {
u16 cr0;
 
cr0 = chip->div_scr << SSPCR0_SCR_SHIFT;
cr0 |= (chip->spi->mode & (SPI_CPHA|SPI_CPOL)) << SSPCR0_MODE_SHIFT;
-   cr0 |= chip->dss;
+   cr0 |= (bits_per_word - 1);
 
dev_dbg(&espi->pdev->dev, "setup: mode %d, cpsr %d, scr %d, dss %d\n",
-   chip->spi->mode, chip->div_cpsr, chip->div_scr, chip->dss);
+   chip->spi->mode, chip->div_cpsr, chip->div_scr,
+   bits_per_word - 1);
dev_dbg(&espi->pdev->dev, "setup: cr0 %#x", cr0);
 
writeb(chip->div_cpsr, espi->regs_base + SSPCPSR);
@@ -688,9 +684,7 @@ static void ep93xx_spi_process_transfer(struct ep93xx_spi 
*espi,
return;
}
 
-   chip->dss = bits_per_word_to_dss(t->bits_per_word);
-
-   ep93xx_spi_chip_setup(espi, chip);
+   ep93xx_spi_chip_setup(espi, chip, t->bits_per_word);
 
espi->word_xfer = (t->bits_per_word > 8) ? true : false;
espi->rx = 0;
-- 
1.8.1.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 6/8] spi: spi-ep93xx: don't bother calculating the divisors in ep93xx_spi_setup()

2013-06-28 Thread H Hartley Sweeten
The divisors needed to generate the SPI clock are calculated per
transfer based on the t->speed_hz. There is no reason to calculate
them in ep93xx_spi_setup().

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Mika Westerberg 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 14 --
 1 file changed, 14 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index cb22c89..2f2d51a 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -137,7 +137,6 @@ struct ep93xx_spi {
 /**
  * struct ep93xx_spi_chip - SPI device hardware settings
  * @spi: back pointer to the SPI device
- * @rate: max rate in hz this chip supports
  * @div_cpsr: cpsr (pre-scaler) divider
  * @div_scr: scr divider
  * @ops: private chip operations
@@ -148,7 +147,6 @@ struct ep93xx_spi {
  */
 struct ep93xx_spi_chip {
const struct spi_device *spi;
-   unsigned long   rate;
u8  div_cpsr;
u8  div_scr;
struct ep93xx_spi_chip_ops  *ops;
@@ -291,18 +289,6 @@ static int ep93xx_spi_setup(struct spi_device *spi)
spi_set_ctldata(spi, chip);
}
 
-   if (spi->max_speed_hz != chip->rate) {
-   int err;
-
-   err = ep93xx_spi_calc_divisors(espi, chip, spi->max_speed_hz);
-   if (err != 0) {
-   spi_set_ctldata(spi, NULL);
-   kfree(chip);
-   return err;
-   }
-   chip->rate = spi->max_speed_hz;
-   }
-
ep93xx_spi_cs_control(spi, false);
return 0;
 }
-- 
1.8.1.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 7/8] spi: spi-ep93xx: move the clock divider calcs into ep93xx_spi_chip_setup()

2013-06-28 Thread H Hartley Sweeten
The divider values stored in the per chip data are only used to set the
registers in the hardware to generate the desired SPI clock. Since these
are calculated per transfer based on the t->speed_hz there is no reason
keep them in the per chip data.

Move the ep93xx_spi_calc_divisors() call into ep93xx_spi_chip_setup()
and return the dividers thru pointers. Remove the divider values from
the per chip data structure.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Mika Westerberg 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 58 +---
 1 file changed, 25 insertions(+), 33 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index 2f2d51a..56305d3 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -137,18 +137,10 @@ struct ep93xx_spi {
 /**
  * struct ep93xx_spi_chip - SPI device hardware settings
  * @spi: back pointer to the SPI device
- * @div_cpsr: cpsr (pre-scaler) divider
- * @div_scr: scr divider
  * @ops: private chip operations
- *
- * This structure is used to store hardware register specific settings for each
- * SPI device. Settings are written to hardware by function
- * ep93xx_spi_chip_setup().
  */
 struct ep93xx_spi_chip {
const struct spi_device *spi;
-   u8  div_cpsr;
-   u8  div_scr;
struct ep93xx_spi_chip_ops  *ops;
 };
 
@@ -200,17 +192,13 @@ static void ep93xx_spi_disable_interrupts(const struct 
ep93xx_spi *espi)
 /**
  * ep93xx_spi_calc_divisors() - calculates SPI clock divisors
  * @espi: ep93xx SPI controller struct
- * @chip: divisors are calculated for this chip
  * @rate: desired SPI output clock rate
- *
- * Function calculates cpsr (clock pre-scaler) and scr divisors based on
- * given @rate and places them to @chip->div_cpsr and @chip->div_scr. If,
- * for some reason, divisors cannot be calculated nothing is stored and
- * %-EINVAL is returned.
+ * @div_cpsr: pointer to return the cpsr (pre-scaler) divider
+ * @div_scr: pointer to return the scr divider
  */
 static int ep93xx_spi_calc_divisors(const struct ep93xx_spi *espi,
-   struct ep93xx_spi_chip *chip,
-   unsigned long rate)
+   unsigned long rate,
+   u8 *div_cpsr, u8 *div_scr)
 {
unsigned long spi_clk_rate = clk_get_rate(espi->clk);
int cpsr, scr;
@@ -233,8 +221,8 @@ static int ep93xx_spi_calc_divisors(const struct ep93xx_spi 
*espi,
for (cpsr = 2; cpsr <= 254; cpsr += 2) {
for (scr = 0; scr <= 255; scr++) {
if ((spi_clk_rate / (cpsr * (scr + 1))) <= rate) {
-   chip->div_scr = (u8)scr;
-   chip->div_cpsr = (u8)cpsr;
+   *div_scr = (u8)scr;
+   *div_cpsr = (u8)cpsr;
return 0;
}
}
@@ -365,29 +353,34 @@ static void ep93xx_spi_cleanup(struct spi_device *spi)
  * ep93xx_spi_chip_setup() - configures hardware according to given @chip
  * @espi: ep93xx SPI controller struct
  * @chip: chip specific settings
+ * @speed_hz: transfer speed
  * @bits_per_word: transfer bits_per_word
- *
- * This function sets up the actual hardware registers with settings given in
- * @chip. Note that no validation is done so make sure that callers validate
- * settings before calling this.
  */
-static void ep93xx_spi_chip_setup(const struct ep93xx_spi *espi,
- const struct ep93xx_spi_chip *chip,
- u8 bits_per_word)
+static int ep93xx_spi_chip_setup(const struct ep93xx_spi *espi,
+struct ep93xx_spi_chip *chip,
+u32 speed_hz, u8 bits_per_word)
 {
+   u8 div_cpsr = 0;
+   u8 div_scr = 0;
u16 cr0;
+   int err;
+
+   err = ep93xx_spi_calc_divisors(espi, speed_hz, &div_cpsr, &div_scr);
+   if (err)
+   return err;
 
-   cr0 = chip->div_scr << SSPCR0_SCR_SHIFT;
+   cr0 = div_scr << SSPCR0_SCR_SHIFT;
cr0 |= (chip->spi->mode & (SPI_CPHA|SPI_CPOL)) << SSPCR0_MODE_SHIFT;
cr0 |= (bits_per_word - 1);
 
dev_dbg(&espi->pdev->dev, "setup: mode %d, cpsr %d, scr %d, dss %d\n",
-   chip->spi->mode, chip->div_cpsr, chip->div_scr,
-   bits_per_word - 1);
+   chip->spi->mode, div_cpsr, div_scr, bits_per_word - 1);
dev_dbg(&espi->pdev->dev, "setup: cr0 %#x", cr0);
 
-   writeb(chip->div_cpsr, espi->regs_base + SSPCPSR);
+   writeb(div_cpsr, espi->regs_base + SSPCPSR);
writew(cr0, espi->regs_b

[PATCH 8/8] spi: spi-ep93xx: convert to the queued driver infrastructure

2013-06-28 Thread H Hartley Sweeten
The SPI core provides infrastructure for standard message queueing. Use
that instead of handling it in the driver.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Mika Westerberg 
Cc: Mark Brown 
Cc: Grant Likely 
---
 drivers/spi/spi-ep93xx.c | 164 ++-
 1 file changed, 19 insertions(+), 145 deletions(-)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index 56305d3..93dad1e 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -26,7 +26,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -70,19 +69,13 @@
 
 /**
  * struct ep93xx_spi - EP93xx SPI controller structure
- * @lock: spinlock that protects concurrent accesses to fields @running,
- *@current_msg and @msg_queue
  * @pdev: pointer to platform device
  * @clk: clock for the controller
  * @regs_base: pointer to ioremap()'d registers
  * @sspdr_phys: physical address of the SSPDR register
  * @min_rate: minimum clock rate (in Hz) supported by the controller
  * @max_rate: maximum clock rate (in Hz) supported by the controller
- * @running: is the queue running
- * @wq: workqueue used by the driver
- * @msg_work: work that is queued for the driver
  * @wait: wait here until given transfer is completed
- * @msg_queue: queue for the messages
  * @current_msg: message that is currently processed (or %NULL if none)
  * @tx: current byte in transfer to transmit
  * @rx: current byte in transfer to receive
@@ -96,31 +89,16 @@
  * @tx_sgt: sg table for TX transfers
  * @zeropage: dummy page used as RX buffer when only TX buffer is passed in by
  *the client
- *
- * This structure holds EP93xx SPI controller specific information. When
- * @running is %true, driver accepts transfer requests from protocol drivers.
- * @current_msg is used to hold pointer to the message that is currently
- * processed. If @current_msg is %NULL, it means that no processing is going
- * on.
- *
- * Most of the fields are only written once and they can be accessed without
- * taking the @lock. Fields that are accessed concurrently are: @current_msg,
- * @running, and @msg_queue.
  */
 struct ep93xx_spi {
-   spinlock_t  lock;
const struct platform_device*pdev;
struct clk  *clk;
void __iomem*regs_base;
unsigned long   sspdr_phys;
unsigned long   min_rate;
unsigned long   max_rate;
-   boolrunning;
boolword_xfer;
-   struct workqueue_struct *wq;
-   struct work_struct  msg_work;
struct completion   wait;
-   struct list_headmsg_queue;
struct spi_message  *current_msg;
size_t  tx;
size_t  rx;
@@ -206,7 +184,7 @@ static int ep93xx_spi_calc_divisors(const struct ep93xx_spi 
*espi,
/*
 * Make sure that max value is between values supported by the
 * controller. Note that minimum value is already checked in
-* ep93xx_spi_transfer().
+* ep93xx_spi_transfer_one_message().
 */
rate = clamp(rate, espi->min_rate, espi->max_rate);
 
@@ -282,54 +260,6 @@ static int ep93xx_spi_setup(struct spi_device *spi)
 }
 
 /**
- * ep93xx_spi_transfer() - queue message to be transferred
- * @spi: target SPI device
- * @msg: message to be transferred
- *
- * This function is called by SPI device drivers when they are going to 
transfer
- * a new message. It simply puts the message in the queue and schedules
- * workqueue to perform the actual transfer later on.
- *
- * Returns %0 on success and negative error in case of failure.
- */
-static int ep93xx_spi_transfer(struct spi_device *spi, struct spi_message *msg)
-{
-   struct ep93xx_spi *espi = spi_master_get_devdata(spi->master);
-   struct spi_transfer *t;
-   unsigned long flags;
-
-   if (!msg || !msg->complete)
-   return -EINVAL;
-
-   /* first validate each transfer */
-   list_for_each_entry(t, &msg->transfers, transfer_list) {
-   if (t->speed_hz && t->speed_hz < espi->min_rate)
-   return -EINVAL;
-   }
-
-   /*
-* Now that we own the message, let's initialize it so that it is
-* suitable for us. We use @msg->status to signal whether there was
-* error in transfer and @msg->state is used to hold pointer to the
-* current transfer (or %NULL if no active current transfer).
-*/
-   msg->state = NULL;
-   msg->status = 0;
-   msg->actual_length = 0;
-
-   spin_lock_irqsave(&espi->lock, flags);
-   if (!espi->running) {
-   spi

Q: mmc au size

2013-06-28 Thread H Hartley Sweeten
Hello Chris,

I have a question concerning the "au" size of a SD Card.

I have an old Kingston 64MB SD-Card and lately I have noticed this
kernel message when I use the card:

mmc0: SD Status: Invalid Allocation Unit size.

This is due to the following commit:

commit b63b5e819d5b21ae493c17c356018ffa98d3ee1c
Author: Alan Cox 
Date:   Mon Jul 2 18:55:13 2012 +0100

mmc: core: correct invalid error checking


>From the "SD Specifications, Part 1, Physical Layer Specification",

* AU_SIZE
This 4-bit field indicates AU Size and the value can be selected from
16 KB.

  AU_SIZE  Value Definition
  ---  
0h Not Defined
1h 16 KB
2h 32 KB
3h 64 KB
4h 128 KB
5h 256 KB
6h 512 KB
7h 1 MB
8h 2 MB
9h 4 MB
Ah 8 MB
Bh 12 MB
Ch 16 MB
Dh 24 MB
Eh 32 MB
Fh 64 MB

Also in the specification is this note:

Sector: is the unit that is related to the erase commands. Its size
is the number of blocks that will be erased in one portion. The size
of a sector is fixed for each device. The information about the sector
size (in blocks) is stored in the CSD. Note that if the card specifies
AU size, sector size should be ignored.

And this:

* SECTOR_SIZE
This field is fixed to 7Fh, which indicates 64 KBytes. This value does
not relate to erase operations. High Capacity and Extended Capacity
cards indicate memory boundary by AU size and this field should not
be used.


So, if an au size of 0 is reported wouldn't the erase size be the
sector size? If nothing else I think the test needs to be adjusted to
not report the error for an au size of 0.

Regards,
Hartley
--
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 3/8] spi: spi-ep93xx: always handle transfer specific settings

2013-06-28 Thread H Hartley Sweeten
On Friday, June 28, 2013 4:18 PM, Ryan Mallon wrote:
> On 29/06/13 04:43, H Hartley Sweeten wrote:
>> __spi_async(), which starts every SPI message transfer, initializes
>> the bits_per_word and max speed for every transfer in the message.
>> Since the conditional test in ep93xx_spi_process_transfer() will
>> always succeed just remove it and always call ep93xx_spi_chip_setup()
>> to configure the hardware for each transfer in the message.
>> 
>> Remove the redundant ep93xx_spi_chp_setup() in ep93xx_spi_process_transfer()
>> which just initializes the hardware to the "default" based on the SPI
>> device.
>> 
>> Signed-off-by: H Hartley Sweeten 
>> Cc: Ryan Mallon 
>> Cc: Mika Westerberg 
>> Cc: Mark Brown 
>> Cc: Grant Likely 
>> ---
>
>
>> +err = ep93xx_spi_calc_divisors(espi, chip, t->speed_hz);
>> +if (err) {
>> +dev_err(&espi->pdev->dev, "failed to adjust speed\n");
>
>
> Printing out the speed it was trying to set might be useful here?

Technically I don't think this can ever happen.

The minimum and maximum possible speeds are determined during the probe.

espi->max_rate = clk_get_rate(espi->clk) / 2;
espi->min_rate = clk_get_rate(espi->clk) / (254 * 256);

Each transfer is validated to make sure the speed is greater than the
minimum.

if (t->speed_hz < espi->min_rate)
return -EINVAL;

Then the rate is clamped to the min/max rates.

rate = clamp(rate, espi->min_rate, espi->max_rate);

The calculations for the div_csr and div_cpsr values needed to produce
the desired rate should always succeed.

Patch 7/8 actually replaces that dev_err() message with a more generic
one. In reality, even the new message, and the error checking, could
probably be removed.

Regards,
Hartley

N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�&j:+v���zZ+��+zf���h���~i���z��w���?�&�)ߢf��^jǫy�m��@A�a���
0��h���i

Q: mmc au size

2013-06-28 Thread H Hartley Sweeten
Hello all,

I have a question concerning the "au" size of a SD Card.

I have an old Kingston 64MB SD-Card and lately I have noticed this
kernel message when I use the card:

mmc0: SD Status: Invalid Allocation Unit size.

This is due to the following commit:

commit b63b5e819d5b21ae493c17c356018ffa98d3ee1c
Author: Alan Cox 
Date:   Mon Jul 2 18:55:13 2012 +0100

    mmc: core: correct invalid error checking


>From the "SD Specifications, Part 1, Physical Layer Specification",

* AU_SIZE
This 4-bit field indicates AU Size and the value can be selected from
16 KB.

  AU_SIZE  Value Definition
  ---  
    0h     Not Defined
    1h     16 KB
    2h     32 KB
    3h     64 KB
    4h     128 KB
    5h     256 KB
    6h     512 KB
    7h     1 MB
    8h     2 MB
    9h     4 MB
    Ah     8 MB
    Bh     12 MB
    Ch     16 MB
    Dh     24 MB
    Eh     32 MB
    Fh     64 MB

Also in the specification is this note:

Sector: is the unit that is related to the erase commands. Its size
is the number of blocks that will be erased in one portion. The size
of a sector is fixed for each device. The information about the sector
size (in blocks) is stored in the CSD. Note that if the card specifies
AU size, sector size should be ignored.

And this:

* SECTOR_SIZE
This field is fixed to 7Fh, which indicates 64 KBytes. This value does
not relate to erase operations. High Capacity and Extended Capacity
cards indicate memory boundary by AU size and this field should not
be used.


So, if an au size of 0 is reported wouldn't the erase size be the
sector size? If nothing else I think the test needs to be adjusted to
not report the error for an au size of 0.

Regards,
Hartley
--
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/4] usb: ohci-ep93xx: do a bit of house cleaning

2013-06-28 Thread H Hartley Sweeten
Tidy up this driver a bit.

H Hartley Sweeten (4):
  usb: ohci-ep93xx: use devm_ioremap_resource()
  usb: ohci-ep93xx: use platform_get_irq()
  usb: ohci-ep93xx: use devm_clk_get()
  usb: ohci-ep93xx: tidy up ohci_hcd_ep93xx_drv_probe()

 drivers/usb/host/ohci-ep93xx.c | 60 --
 1 file changed, 23 insertions(+), 37 deletions(-)

-- 
1.8.1.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/4] usb: ohci-ep93xx: use devm_ioremap_resource()

2013-06-28 Thread H Hartley Sweeten
Use devm_ioremap_resource() to make the code a bit cleaner and
simpler.

Signed-off-by: H Hartley Sweeten 
Cc: Alan Stern 
Cc: Lennert Buytenhek 
Cc: Greg Kroah-Hartman 
---
 drivers/usb/host/ohci-ep93xx.c | 35 ++-
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index 8704e9f..4e12f67 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -43,38 +43,37 @@ static void ep93xx_stop_hc(struct device *dev)
 static int usb_hcd_ep93xx_probe(const struct hc_driver *driver,
 struct platform_device *pdev)
 {
-   int retval;
struct usb_hcd *hcd;
+   struct resource *res;
+   int retval;
 
if (pdev->resource[1].flags != IORESOURCE_IRQ) {
dev_dbg(&pdev->dev, "resource[1] is not IORESOURCE_IRQ\n");
return -ENOMEM;
}
 
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!res)
+   return -ENXIO;
+
hcd = usb_create_hcd(driver, &pdev->dev, "ep93xx");
if (hcd == NULL)
return -ENOMEM;
 
-   hcd->rsrc_start = pdev->resource[0].start;
-   hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1;
-   if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
-   usb_put_hcd(hcd);
-   retval = -EBUSY;
-   goto err1;
-   }
+   hcd->rsrc_start = res->start;
+   hcd->rsrc_len = resource_size(res);
 
-   hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
-   if (hcd->regs == NULL) {
-   dev_dbg(&pdev->dev, "ioremap failed\n");
-   retval = -ENOMEM;
-   goto err2;
+   hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+   if (IS_ERR(hcd->regs)) {
+   retval = PTR_ERR(hcd->regs);
+   goto err_put_hcd;
}
 
usb_host_clock = clk_get(&pdev->dev, NULL);
if (IS_ERR(usb_host_clock)) {
dev_dbg(&pdev->dev, "clk_get failed\n");
retval = PTR_ERR(usb_host_clock);
-   goto err3;
+   goto err_put_hcd;
}
 
ep93xx_start_hc(&pdev->dev);
@@ -86,11 +85,7 @@ static int usb_hcd_ep93xx_probe(const struct hc_driver 
*driver,
return retval;
 
ep93xx_stop_hc(&pdev->dev);
-err3:
-   iounmap(hcd->regs);
-err2:
-   release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
-err1:
+err_put_hcd:
usb_put_hcd(hcd);
 
return retval;
@@ -102,8 +97,6 @@ static void usb_hcd_ep93xx_remove(struct usb_hcd *hcd,
usb_remove_hcd(hcd);
ep93xx_stop_hc(&pdev->dev);
clk_put(usb_host_clock);
-   iounmap(hcd->regs);
-   release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
usb_put_hcd(hcd);
 }
 
-- 
1.8.1.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/4] usb: ohci-ep93xx: use platform_get_irq()

2013-06-28 Thread H Hartley Sweeten
Use platform_get_irq() instead of accessing the platform_device
resources directly.

Signed-off-by: H Hartley Sweeten 
Cc: Alan Stern 
Cc: Lennert Buytenhek 
Cc: Greg Kroah-Hartman 
---
 drivers/usb/host/ohci-ep93xx.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index 4e12f67..b4f5e64 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -45,12 +45,12 @@ static int usb_hcd_ep93xx_probe(const struct hc_driver 
*driver,
 {
struct usb_hcd *hcd;
struct resource *res;
+   int irq;
int retval;
 
-   if (pdev->resource[1].flags != IORESOURCE_IRQ) {
-   dev_dbg(&pdev->dev, "resource[1] is not IORESOURCE_IRQ\n");
-   return -ENOMEM;
-   }
+   irq = platform_get_irq(pdev, 0);
+   if (irq < 0)
+   return irq;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
@@ -80,7 +80,7 @@ static int usb_hcd_ep93xx_probe(const struct hc_driver 
*driver,
 
ohci_hcd_init(hcd_to_ohci(hcd));
 
-   retval = usb_add_hcd(hcd, pdev->resource[1].start, 0);
+   retval = usb_add_hcd(hcd, irq, 0);
if (retval == 0)
return retval;
 
-- 
1.8.1.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 3/4] usb: ohci-ep93xx: use devm_clk_get()

2013-06-28 Thread H Hartley Sweeten
Use devm_clk_get() to make the code a bit cleaner and simpler.

This also fixes a bug where a clk_put() is not done if usb_add_hcd()
fails.

Signed-off-by: H Hartley Sweeten 
Cc: Alan Stern 
Cc: Lennert Buytenhek 
Cc: Greg Kroah-Hartman 
---
 drivers/usb/host/ohci-ep93xx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index b4f5e64..28fa6b8 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -69,9 +69,8 @@ static int usb_hcd_ep93xx_probe(const struct hc_driver 
*driver,
goto err_put_hcd;
}
 
-   usb_host_clock = clk_get(&pdev->dev, NULL);
+   usb_host_clock = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(usb_host_clock)) {
-   dev_dbg(&pdev->dev, "clk_get failed\n");
retval = PTR_ERR(usb_host_clock);
goto err_put_hcd;
}
@@ -96,7 +95,6 @@ static void usb_hcd_ep93xx_remove(struct usb_hcd *hcd,
 {
usb_remove_hcd(hcd);
ep93xx_stop_hc(&pdev->dev);
-   clk_put(usb_host_clock);
usb_put_hcd(hcd);
 }
 
-- 
1.8.1.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 4/4] usb: ohci-ep93xx: tidy up ohci_hcd_ep93xx_drv_probe()

2013-06-28 Thread H Hartley Sweeten
Refactor the function a bit to remove the need for the local variable.

The extern prototype of usb_disabled() is not needed.

Signed-off-by: H Hartley Sweeten 
Cc: Alan Stern 
Cc: Lennert Buytenhek 
Cc: Greg Kroah-Hartman 
---
 drivers/usb/host/ohci-ep93xx.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index 28fa6b8..bdc2908 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -138,17 +138,12 @@ static struct hc_driver ohci_ep93xx_hc_driver = {
.start_port_reset   = ohci_start_port_reset,
 };
 
-extern int usb_disabled(void);
-
 static int ohci_hcd_ep93xx_drv_probe(struct platform_device *pdev)
 {
-   int ret;
-
-   ret = -ENODEV;
-   if (!usb_disabled())
-   ret = usb_hcd_ep93xx_probe(&ohci_ep93xx_hc_driver, pdev);
+   if (usb_disabled())
+   return -ENODEV;
 
-   return ret;
+   return usb_hcd_ep93xx_probe(&ohci_ep93xx_hc_driver, pdev);
 }
 
 static int ohci_hcd_ep93xx_drv_remove(struct platform_device *pdev)
-- 
1.8.1.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/


RE: [PATCH] gpio: (gpio-pca953x) move header to linux/platform_data/

2013-08-16 Thread H Hartley Sweeten
On Friday, August 16, 2013 8:02 AM, Vivien Didelot wrote:
> Hi Linus,
>
> You wrote:
> > But:
>>
>>>  drivers/gpio/gpio-pca953x.c |  2 +-
>> (...)
>>> diff --git a/drivers/gpio/gpio-pca953x.c
>>> b/drivers/gpio/gpio-pca953x.c
>>> index 426c51d..8804aec 100644
>>> --- a/drivers/gpio/gpio-pca953x.c
>>> +++ b/drivers/gpio/gpio-pca953x.c
>>> @@ -18,7 +18,7 @@
>>>  #include 
>>>  #include 
>>>  #include 
>>> -#include 
>>> +#include 
>> 
>> Why does the GPIO driver need platform data from the
>> I2C driver???
>> 
>> Can't this just be made to go away?
>
> I didn't dig that much in the driver, but I cannot imagine
> another way to pass, for instance, the setup callback.
>
> What would be a good alternative for you?

I think the confusion here is because the pca953x.h header was initially
placed in linux/i2c.

This device is an I2C connected GPIO expander. The pca953x.h header has
the information needed for the platform to hook up to the device. It doesn't
really expose the fact that it's an I2C driver.

Just by 2 cents...
Hartley
--
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] gpio: (gpio-pca953x) move header to linux/platform_data/

2013-07-31 Thread H Hartley Sweeten
On Wednesday, July 31, 2013 1:57 PM, Vivien Didelot wrote:
>
> This patch moves the pca953x.h header from include/linux/i2c to
> include/linux/platform_data and updates existing support accordingly.
>
> Signed-off-by: Vivien Didelot 
> ---



arch/arm/mach-ep93xx/vision_ep9307.c|  2 +-

For the ep93xx change:

Acked-by: H Hartley Sweeten 

Thanks
--
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] ASoC: ep93xx: fix build of ep93xx-ac97.c

2013-07-19 Thread H Hartley Sweeten
Fix the build of this driver. It was broken by:

Commit 453807f3006757a5661c4000262d7d9284b5214c
ASoC: ep93xx: Use ep93xx_dma_params instead of ep93xx_pcm_dma_params

The removed struct ep93xx_pcm_dma_params use the member 'dma_port' to
select the dma channel. The struct ep93xx_dma_data uses the member
'port'.

Signed-off-by: H Hartley Sweeten 
Cc: Ryan Mallon 
Cc: Lars-Peter Clausen 
Cc: Mark Brown 
Cc: Liam Girdwood 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
---
 sound/soc/cirrus/ep93xx-ac97.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/cirrus/ep93xx-ac97.c b/sound/soc/cirrus/ep93xx-ac97.c
index ac73c60..04491f0 100644
--- a/sound/soc/cirrus/ep93xx-ac97.c
+++ b/sound/soc/cirrus/ep93xx-ac97.c
@@ -102,13 +102,13 @@ static struct ep93xx_ac97_info *ep93xx_ac97_info;
 
 static struct ep93xx_dma_data ep93xx_ac97_pcm_out = {
.name   = "ac97-pcm-out",
-   .dma_port   = EP93XX_DMA_AAC1,
+   .port   = EP93XX_DMA_AAC1,
.direction  = DMA_MEM_TO_DEV,
 };
 
 static struct ep93xx_dma_data ep93xx_ac97_pcm_in = {
.name   = "ac97-pcm-in",
-   .dma_port   = EP93XX_DMA_AAC1,
+   .port   = EP93XX_DMA_AAC1,
.direction  = DMA_DEV_TO_MEM,
 };
 
-- 
1.8.3.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/


  1   2   3   4   5   >