Re: [PATCH] staging: android: ion: fix wrong init of dma_buf_export_info

2015-02-25 Thread Dan Carpenter
Reviewed-by: Dan Carpenter 

regards,
dan carpenter

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


Caro usuário,

2015-02-25 Thread ADMIN
Caro usuário,

Esta é para informá-lo que alguém estava tentando entrar sua conta
email de um local diferente {IP:37. 187.138.129
França: 24/02/2015 02:36 GTM}

Se você não estiver por favor siga as instruções abaixo para atualizar e
Verifique apenas 12 horas de sua conta para fazer isso fim de manter
seu endereço de e-mail está ativo.

Email:
SENHA:
RE-CONTRASENA:
Data de nascimento:


Este e-mail é sujeito à fiscalização obrigatória,
Não-conformidade resultaria na suspensão da sua conta de e-mail
eletrônico.

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


Re: doubt about sm7xxfb

2015-02-25 Thread Sudip Mukherjee
On Wed, Feb 11, 2015 at 02:33:51PM +0800, Greg Kroah-Hartman wrote:
> On Wed, Feb 11, 2015 at 11:58:18AM +0530, Sudip Mukherjee wrote:
> 
> Ok, that makes sense, I was thinking this was a "new" driver, instead of
> a vendor driver crud.
Hi Greg,
The SM750 driver is almost ready for staging, it now compiles without any error 
with today's linux-next and is working properly , ok,  there are lots of 
warning when compiling and checkpatch will give lots of complaints.
But in total it is creating 34 files and the size of the patch is 360K. So 
should i send it with mail, just the way we send other patches or should i send 
you a git pull request?

regards
sudip

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


[patch] Staging: lustre: missing curly braces in ll_setattr_raw()

2015-02-25 Thread Dan Carpenter
>From the indenting, it looks like curly braces were intended here.

Signed-off-by: Dan Carpenter 
---
This is not tested, and it changes how the code works.  Please review
it a bit carefully.  Sometimes people just do weird indenting for no
reason.

diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 0c1b583..ba97d9e 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -1432,7 +1432,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr 
*attr, bool hsm_import)
 
if (attr->ia_valid & (ATTR_SIZE |
  ATTR_ATIME | ATTR_ATIME_SET |
- ATTR_MTIME | ATTR_MTIME_SET))
+ ATTR_MTIME | ATTR_MTIME_SET)) {
/* For truncate and utimes sending attributes to OSTs, setting
 * mtime/atime to the past will be performed under PW [0:EOF]
 * extent lock (new_size:EOF for truncate).  It may seem
@@ -1444,6 +1444,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr 
*attr, bool hsm_import)
rc = ll_setattr_ost(inode, attr);
if (attr->ia_valid & ATTR_SIZE)
up_write(&lli->lli_trunc_sem);
+   }
 out:
if (op_data) {
if (op_data->op_ioepoch) {
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: emxx_udc: fix warnings

2015-02-25 Thread Matteo Semenzato
From: Matteo Semenzato 

This patch fixes the following warning:
__aligned(size) is preferred over __attribute__((aligned(size)))

Signed-off-by: Matteo Semenzato 
---
 drivers/staging/emxx_udc/emxx_udc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/emxx_udc/emxx_udc.h 
b/drivers/staging/emxx_udc/emxx_udc.h
index 202e2dc..6f90d5e 100644
--- a/drivers/staging/emxx_udc/emxx_udc.h
+++ b/drivers/staging/emxx_udc/emxx_udc.h
@@ -535,7 +535,7 @@ typedef struct _T_FC_REGS {
 
u8 Reserved1200[0x1000-0x200];  /* Reserved */
 
-} __attribute__ ((aligned(32))) T_FC_REGS, *PT_FC_REGS;
+} __aligned(32) T_FC_REGS, *PT_FC_REGS;
 
 
 
-- 
2.3.0

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


Re: [PATCH v3 34/36] staging: comedi: amplc_dio200_common: convert driver to use the comedi_8254 module

2015-02-25 Thread Ian Abbott

On 24/02/2015 17:38, H Hartley Sweeten wrote:

Convert this driver to use the comedi_8254 module to provide the 8254 timer 
support.

Add 'clock_src' and 'gate_src' members to the comedi_8254 data for convienence.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
v3: As pointed out by Ian Abbott, fix the 'offset' used for the timer on PCIe 
boards.
 No change to the rest of the series.

  drivers/staging/comedi/Kconfig |   1 +
  .../staging/comedi/drivers/amplc_dio200_common.c   | 295 +++--
  drivers/staging/comedi/drivers/comedi_8254.h   |   4 +
  3 files changed, 99 insertions(+), 201 deletions(-)


Reviewed-by: Ian Abbott 

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


RE: [PATCH 1/2] Drivers: hv: hv_balloon: report offline pages as being used

2015-02-25 Thread KY Srinivasan


> -Original Message-
> From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com]
> Sent: Thursday, February 19, 2015 8:27 AM
> To: KY Srinivasan; de...@linuxdriverproject.org
> Cc: Haiyang Zhang; linux-ker...@vger.kernel.org; Dexuan Cui
> Subject: [PATCH 1/2] Drivers: hv: hv_balloon: report offline pages as being
> used
> 
> When hot-added memory pages are not brought online or when some
> memory blocks
> are sent offline the subsequent ballooning process kills the guest with OOM
> killer. This happens as we don't report these pages as neither used nor free
> and apparently host algorythm considers them as being unused. Keep track
> of
> all online/offline operations and report all currently offline pages as being
> used so host won't try to balloon them out.
> 
> Signed-off-by: Vitaly Kuznetsov 
> ---
>  drivers/hv/hv_balloon.c | 33 -
>  1 file changed, 24 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
> index a095b70..e4b4454 100644
> --- a/drivers/hv/hv_balloon.c
> +++ b/drivers/hv/hv_balloon.c
> @@ -503,6 +503,8 @@ struct hv_dynmem_device {
>* Number of pages we have currently ballooned out.
>*/
>   unsigned int num_pages_ballooned;
> + unsigned int num_pages_onlined;
> + unsigned int num_pages_added;
> 
>   /*
>* State to manage the ballooning (up) operation.
> @@ -556,12 +558,15 @@ static void post_status(struct hv_dynmem_device
> *dm);
>  static int hv_memory_notifier(struct notifier_block *nb, unsigned long val,
> void *v)
>  {
> + struct memory_notify *mem = (struct memory_notify *)v;
> +
>   switch (val) {
>   case MEM_GOING_ONLINE:
>   mutex_lock(&dm_device.ha_region_mutex);
>   break;
> 
>   case MEM_ONLINE:
> + dm_device.num_pages_onlined += mem->nr_pages;
>   case MEM_CANCEL_ONLINE:

Why are we not adjusting num_pages_onlined when we cancel the online
Operation.

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


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

2015-02-25 Thread Lee Jones
On Wed, 25 Feb 2015, micky_ch...@realsil.com.cn wrote:

> From: Micky Ching 
> 
> add support for new chip rts524A.
> 
> Signed-off-by: Micky Ching 
> ---
>  drivers/mfd/rts5249.c| 186 
> ---
>  drivers/mfd/rtsx_pcr.c   |  25 +-
>  drivers/mfd/rtsx_pcr.h   |   7 ++
>  include/linux/mfd/rtsx_pci.h | 132 +-
>  4 files changed, 318 insertions(+), 32 deletions(-)

Acked-by: Lee Jones 

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

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

2015-02-25 Thread Lee Jones
On Wed, 25 Feb 2015, micky_ch...@realsil.com.cn wrote:

> From: Micky Ching 
> 
> add support for new chip rts525A.
> 
> Signed-off-by: Micky Ching 
> ---
>  drivers/mfd/rts5249.c| 103 
> +++
>  drivers/mfd/rtsx_pcr.c   |  13 --
>  drivers/mfd/rtsx_pcr.h   |   1 +
>  include/linux/mfd/rtsx_pci.h |  15 +++
>  4 files changed, 129 insertions(+), 3 deletions(-)

Acked-by: Lee Jones 

> diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
> index 32be803..d1ff32f 100644
> --- a/drivers/mfd/rts5249.c
> +++ b/drivers/mfd/rts5249.c
> @@ -487,3 +487,106 @@ void rts524a_init_params(struct rtsx_pcr *pcr)
>   pcr->ops = &rts524a_pcr_ops;
>  }
>  
> +static int rts525a_card_power_on(struct rtsx_pcr *pcr, int card)
> +{
> + rtsx_pci_write_register(pcr, LDO_VCC_CFG1,
> + LDO_VCC_TUNE_MASK, LDO_VCC_3V3);
> + return rtsx_base_card_power_on(pcr, card);
> +}
> +
> +static int rts525a_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
> +{
> + switch (voltage) {
> + case OUTPUT_3V3:
> + rtsx_pci_write_register(pcr, LDO_CONFIG2,
> + LDO_D3318_MASK, LDO_D3318_33V);
> + rtsx_pci_write_register(pcr, SD_PAD_CTL, SD_IO_USING_1V8, 0);
> + break;
> + case OUTPUT_1V8:
> + rtsx_pci_write_register(pcr, LDO_CONFIG2,
> + LDO_D3318_MASK, LDO_D3318_18V);
> + rtsx_pci_write_register(pcr, SD_PAD_CTL, SD_IO_USING_1V8,
> + SD_IO_USING_1V8);
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + rtsx_pci_init_cmd(pcr);
> + rts5249_fill_driving(pcr, voltage);
> + return rtsx_pci_send_cmd(pcr, 100);
> +}
> +
> +static int rts525a_optimize_phy(struct rtsx_pcr *pcr)
> +{
> + int err;
> +
> + err = rtsx_pci_write_register(pcr, RTS524A_PM_CTRL3,
> + D3_DELINK_MODE_EN, 0x00);
> + if (err < 0)
> + return err;
> +
> + rtsx_pci_write_phy_register(pcr, _PHY_FLD0,
> + _PHY_FLD0_CLK_REQ_20C | _PHY_FLD0_RX_IDLE_EN |
> + _PHY_FLD0_BIT_ERR_RSTN | _PHY_FLD0_BER_COUNT |
> + _PHY_FLD0_BER_TIMER | _PHY_FLD0_CHECK_EN);
> +
> + rtsx_pci_write_phy_register(pcr, _PHY_ANA03,
> + _PHY_ANA03_TIMER_MAX | _PHY_ANA03_OOBS_DEB_EN |
> + _PHY_CMU_DEBUG_EN);
> +
> + if (is_version(pcr, 0x525A, IC_VER_A))
> + rtsx_pci_write_phy_register(pcr, _PHY_REV0,
> + _PHY_REV0_FILTER_OUT | _PHY_REV0_CDR_BYPASS_PFD |
> + _PHY_REV0_CDR_RX_IDLE_BYPASS);
> +
> + return 0;
> +}
> +
> +static int rts525a_extra_init_hw(struct rtsx_pcr *pcr)
> +{
> + rts5249_extra_init_hw(pcr);
> +
> + rtsx_pci_write_register(pcr, PCLK_CTL, PCLK_MODE_SEL, PCLK_MODE_SEL);
> + if (is_version(pcr, 0x525A, IC_VER_A)) {
> + rtsx_pci_write_register(pcr, L1SUB_CONFIG2,
> + L1SUB_AUTO_CFG, L1SUB_AUTO_CFG);
> + rtsx_pci_write_register(pcr, RREF_CFG,
> + RREF_VBGSEL_MASK, RREF_VBGSEL_1V25);
> + rtsx_pci_write_register(pcr, LDO_VIO_CFG,
> + LDO_VIO_TUNE_MASK, LDO_VIO_1V7);
> + rtsx_pci_write_register(pcr, LDO_DV12S_CFG,
> + LDO_D12_TUNE_MASK, LDO_D12_TUNE_DF);
> + rtsx_pci_write_register(pcr, LDO_AV12S_CFG,
> + LDO_AV12S_TUNE_MASK, LDO_AV12S_TUNE_DF);
> + rtsx_pci_write_register(pcr, LDO_VCC_CFG0,
> + LDO_VCC_LMTVTH_MASK, LDO_VCC_LMTVTH_2A);
> + rtsx_pci_write_register(pcr, OOBS_CONFIG,
> + OOBS_AUTOK_DIS | OOBS_VAL_MASK, 0x89);
> + }
> +
> + return 0;
> +}
> +
> +static const struct pcr_ops rts525a_pcr_ops = {
> + .fetch_vendor_settings = rtsx_base_fetch_vendor_settings,
> + .extra_init_hw = rts525a_extra_init_hw,
> + .optimize_phy = rts525a_optimize_phy,
> + .turn_on_led = rtsx_base_turn_on_led,
> + .turn_off_led = rtsx_base_turn_off_led,
> + .enable_auto_blink = rtsx_base_enable_auto_blink,
> + .disable_auto_blink = rtsx_base_disable_auto_blink,
> + .card_power_on = rts525a_card_power_on,
> + .card_power_off = rtsx_base_card_power_off,
> + .switch_output_voltage = rts525a_switch_output_voltage,
> + .force_power_down = rtsx_base_force_power_down,
> +};
> +
> +void rts525a_init_params(struct rtsx_pcr *pcr)
> +{
> + rts5249_init_params(pcr);
> +
> + pcr->reg_pm_ctrl3 = RTS524A_PM_CTRL3;
> + pcr->ops = &rts525a_pcr_ops;
> +}
> +
> diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
> index e6d97ad..433cb41 100644
> --- a/drivers/mfd/rtsx_pcr.c
> +++ b/drivers/mfd/rtsx_pcr.c
> @@ -59,6 +59,7 @@ static const struct pci_device_id rtsx_pci_ids[] = {
>   { PCI_DEVICE(0x10EC, 0x5287), PCI_CLASS_OTHERS << 16, 0xFF },
>   { PCI_DEVICE(0x10EC, 0x5286), PCI_CLASS_OTHERS << 16, 0xFF }

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

2015-02-25 Thread Lee Jones
On Wed, 25 Feb 2015, micky_ch...@realsil.com.cn wrote:

> From: Micky Ching 
> 
> Re-format coding-style, using uniform SPC after "#define" keyword
> instead of mixing using TAB and SPC.
> 
> Signed-off-by: Micky Ching 
> Acked-by: Lee Jones 
> ---
>  include/linux/mfd/rtsx_pci.h | 254 
> +--
>  1 file changed, 127 insertions(+), 127 deletions(-)

Applied, thanks.

> diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
> index 0c12628..a9c2a14 100644
> --- a/include/linux/mfd/rtsx_pci.h
> +++ b/include/linux/mfd/rtsx_pci.h
> @@ -175,9 +175,9 @@
>  /* CARD_SHARE_MODE */
>  #define CARD_SHARE_MASK  0x0F
>  #define CARD_SHARE_MULTI_LUN 0x00
> -#define  CARD_SHARE_NORMAL   0x00
> -#define  CARD_SHARE_48_SD0x04
> -#define  CARD_SHARE_48_MS0x08
> +#define CARD_SHARE_NORMAL0x00
> +#define CARD_SHARE_48_SD 0x04
> +#define CARD_SHARE_48_MS 0x08
>  /* CARD_SHARE_MODE for barossa */
>  #define CARD_SHARE_BAROSSA_SD0x01
>  #define CARD_SHARE_BAROSSA_MS0x02
> @@ -249,76 +249,76 @@
>  #define CD_AUTO_DISABLE  0x40
>  
>  /* SD_STAT1 */
> -#define  SD_CRC7_ERR 0x80
> -#define  SD_CRC16_ERR0x40
> -#define  SD_CRC_WRITE_ERR0x20
> -#define  SD_CRC_WRITE_ERR_MASK   0x1C
> -#define  GET_CRC_TIME_OUT0x02
> -#define  SD_TUNING_COMPARE_ERR   0x01
> +#define SD_CRC7_ERR  0x80
> +#define SD_CRC16_ERR 0x40
> +#define SD_CRC_WRITE_ERR 0x20
> +#define SD_CRC_WRITE_ERR_MASK0x1C
> +#define GET_CRC_TIME_OUT 0x02
> +#define SD_TUNING_COMPARE_ERR0x01
>  
>  /* SD_STAT2 */
> -#define  SD_RSP_80CLK_TIMEOUT0x01
> +#define SD_RSP_80CLK_TIMEOUT 0x01
>  
>  /* SD_BUS_STAT */
> -#define  SD_CLK_TOGGLE_EN0x80
> -#define  SD_CLK_FORCE_STOP   0x40
> -#define  SD_DAT3_STATUS  0x10
> -#define  SD_DAT2_STATUS  0x08
> -#define  SD_DAT1_STATUS  0x04
> -#define  SD_DAT0_STATUS  0x02
> -#define  SD_CMD_STATUS   0x01
> +#define SD_CLK_TOGGLE_EN 0x80
> +#define SD_CLK_FORCE_STOP0x40
> +#define SD_DAT3_STATUS   0x10
> +#define SD_DAT2_STATUS   0x08
> +#define SD_DAT1_STATUS   0x04
> +#define SD_DAT0_STATUS   0x02
> +#define SD_CMD_STATUS0x01
>  
>  /* SD_PAD_CTL */
> -#define  SD_IO_USING_1V8 0x80
> -#define  SD_IO_USING_3V3 0x7F
> -#define  TYPE_A_DRIVING  0x00
> -#define  TYPE_B_DRIVING  0x01
> -#define  TYPE_C_DRIVING  0x02
> -#define  TYPE_D_DRIVING  0x03
> +#define SD_IO_USING_1V8  0x80
> +#define SD_IO_USING_3V3  0x7F
> +#define TYPE_A_DRIVING   0x00
> +#define TYPE_B_DRIVING   0x01
> +#define TYPE_C_DRIVING   0x02
> +#define TYPE_D_DRIVING   0x03
>  
>  /* SD_SAMPLE_POINT_CTL */
> -#define  DDR_FIX_RX_DAT  0x00
> -#define  DDR_VAR_RX_DAT  0x80
> -#define  DDR_FIX_RX_DAT_EDGE 0x00
> -#define  DDR_FIX_RX_DAT_14_DELAY 0x40
> -#define  DDR_FIX_RX_CMD  0x00
> -#define  DDR_VAR_RX_CMD  0x20
> -#define  DDR_FIX_RX_CMD_POS_EDGE 0x00
> -#define  DDR_FIX_RX_CMD_14_DELAY 0x10
> -#define  SD20_RX_POS_EDGE0x00
> -#define  SD20_RX_14_DELAY0x08
> +#define DDR_FIX_RX_DAT   0x00
> +#define DDR_VAR_RX_DAT   0x80
> +#define DDR_FIX_RX_DAT_EDGE  0x00
> +#define DDR_FIX_RX_DAT_14_DELAY  0x40
> +#define DDR_FIX_RX_CMD   0x00
> +#define DDR_VAR_RX_CMD   0x20
> +#define DDR_FIX_RX_CMD_POS_EDGE  0x00
> +#define DDR_FIX_RX_CMD_14_DELAY  0x10
> +#define SD20_RX_POS_EDGE 0x00
> +#define SD20_RX_14_DELAY 0x08
>  #define SD20_RX_SEL_MASK 0x08
>  
>  /* SD_PUSH_POINT_CTL */
> -#define  DDR_FIX_TX_CMD_DAT  0x00
> -#define  DDR_VAR_TX_CMD_DAT  0x80
> -#define  DDR_FIX_TX_DAT_14_TSU   0x00
> -#define  DDR_FIX_TX_DAT_12_TSU   0x40
> -#define  DDR_FIX_TX_CMD_NEG_EDGE 0x00
> -#define  DDR_FIX_TX_CMD_14_AHEAD 0x20
> -#define  SD20_TX_NEG_EDGE0x00
> -#define  SD20_TX_14_AHEAD0x10
> +#define DDR_FIX_TX_CMD

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

2015-02-25 Thread Lee Jones
On Wed, 25 Feb 2015, micky_ch...@realsil.com.cn wrote:

> From: Micky Ching 
> 
> Update some phy register name and value for rts5249,
> the updated value makes chip more stable on some platform.
> 
> Signed-off-by: Micky Ching 
> ---
>  drivers/mfd/rts5249.c|  29 +++-
>  include/linux/mfd/rtsx_pci.h | 109 
> ++-
>  2 files changed, 72 insertions(+), 66 deletions(-)

Acked-by: Lee Jones 

> diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
> index 2fe2854..8de8220 100644
> --- a/drivers/mfd/rts5249.c
> +++ b/drivers/mfd/rts5249.c
> @@ -132,11 +132,12 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
>   if (err < 0)
>   return err;
>  
> - err = rtsx_pci_write_phy_register(pcr, PHY_REG_REV,
> - PHY_REG_REV_RESV | PHY_REG_REV_RXIDLE_LATCHED |
> - PHY_REG_REV_P1_EN | PHY_REG_REV_RXIDLE_EN |
> - PHY_REG_REV_RX_PWST | PHY_REG_REV_CLKREQ_DLY_TIMER_1_0 |
> - PHY_REG_REV_STOP_CLKRD | PHY_REG_REV_STOP_CLKWR);
> + err = rtsx_pci_write_phy_register(pcr, PHY_REV,
> + PHY_REV_RESV | PHY_REV_RXIDLE_LATCHED |
> + PHY_REV_P1_EN | PHY_REV_RXIDLE_EN |
> + PHY_REV_CLKREQ_TX_EN | PHY_REV_RX_PWST |
> + PHY_REV_CLKREQ_DT_1_0 | PHY_REV_STOP_CLKRD |
> + PHY_REV_STOP_CLKWR);
>   if (err < 0)
>   return err;
>  
> @@ -147,19 +148,21 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
>   PHY_BPCR_IB_FILTER | PHY_BPCR_CMIRROR_EN);
>   if (err < 0)
>   return err;
> +
>   err = rtsx_pci_write_phy_register(pcr, PHY_PCR,
>   PHY_PCR_FORCE_CODE | PHY_PCR_OOBS_CALI_50 |
>   PHY_PCR_OOBS_VCM_08 | PHY_PCR_OOBS_SEN_90 |
> - PHY_PCR_RSSI_EN);
> + PHY_PCR_RSSI_EN | PHY_PCR_RX10K);
>   if (err < 0)
>   return err;
> +
>   err = rtsx_pci_write_phy_register(pcr, PHY_RCR2,
>   PHY_RCR2_EMPHASE_EN | PHY_RCR2_NADJR |
> - PHY_RCR2_CDR_CP_10 | PHY_RCR2_CDR_SR_2 |
> - PHY_RCR2_FREQSEL_12 | PHY_RCR2_CPADJEN |
> - PHY_RCR2_CDR_SC_8 | PHY_RCR2_CALIB_LATE);
> + PHY_RCR2_CDR_SR_2 | PHY_RCR2_FREQSEL_12 |
> + PHY_RCR2_CDR_SC_12P | PHY_RCR2_CALIB_LATE);
>   if (err < 0)
>   return err;
> +
>   err = rtsx_pci_write_phy_register(pcr, PHY_FLD4,
>   PHY_FLD4_FLDEN_SEL | PHY_FLD4_REQ_REF |
>   PHY_FLD4_RXAMP_OFF | PHY_FLD4_REQ_ADDA |
> @@ -167,11 +170,12 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
>   PHY_FLD4_BER_CHK_EN);
>   if (err < 0)
>   return err;
> - err = rtsx_pci_write_phy_register(pcr, PHY_RDR, PHY_RDR_RXDSEL_1_9);
> + err = rtsx_pci_write_phy_register(pcr, PHY_RDR,
> + PHY_RDR_RXDSEL_1_9 | PHY_SSC_AUTO_PWD);
>   if (err < 0)
>   return err;
>   err = rtsx_pci_write_phy_register(pcr, PHY_RCR1,
> - PHY_RCR1_ADP_TIME | PHY_RCR1_VCO_COARSE);
> + PHY_RCR1_ADP_TIME_4 | PHY_RCR1_VCO_COARSE);
>   if (err < 0)
>   return err;
>   err = rtsx_pci_write_phy_register(pcr, PHY_FLD3,
> @@ -179,10 +183,11 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
>   PHY_FLD3_RXDELINK);
>   if (err < 0)
>   return err;
> +
>   return rtsx_pci_write_phy_register(pcr, PHY_TUNE,
>   PHY_TUNE_TUNEREF_1_0 | PHY_TUNE_VBGSEL_1252 |
>   PHY_TUNE_SDBUS_33 | PHY_TUNE_TUNED18 |
> - PHY_TUNE_TUNED12);
> + PHY_TUNE_TUNED12 | PHY_TUNE_TUNEA12);
>  }
>  
>  static int rts5249_turn_on_led(struct rtsx_pcr *pcr)
> diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
> index 87cff60..0103210 100644
> --- a/include/linux/mfd/rtsx_pci.h
> +++ b/include/linux/mfd/rtsx_pci.h
> @@ -630,16 +630,47 @@
>  
>  /* Phy register */
>  #define PHY_PCR  0x00
> +#define   PHY_PCR_FORCE_CODE 0xB000
> +#define   PHY_PCR_OOBS_CALI_50   0x0800
> +#define   PHY_PCR_OOBS_VCM_080x0200
> +#define   PHY_PCR_OOBS_SEN_900x0040
> +#define   PHY_PCR_RSSI_EN0x0002
> +#define   PHY_PCR_RX10K  0x0001
> +
>  #define PHY_RCR0 0x01
>  #define PHY_RCR1 0x02
> +#define   PHY_RCR1_ADP_TIME_40x0400
> +#define   PHY_RCR1_VCO_COARSE0x001F
> +
>  #define PHY_RCR2 0x03
> +#define   PHY_RCR2_EMPHASE_EN0x8000
> +#define   PHY_RCR2_NADJR 0x4000
> +#define   PHY_RCR2_CDR_SR_2  0x0100
> +#define   PHY

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

2015-02-25 Thread Lee Jones
On Wed, 25 Feb 2015, micky_ch...@realsil.com.cn wrote:

> From: Micky Ching 
> 
> PETXCFG is defined at 0xFF03, the old 0xFE49 not used any more.
> 
> Signed-off-by: Micky Ching 
> Acked-by: Lee Jones 
> ---
>  drivers/mfd/rts5227.c| 6 ++
>  drivers/mfd/rts5249.c| 6 ++
>  include/linux/mfd/rtsx_pci.h | 2 +-
>  3 files changed, 5 insertions(+), 9 deletions(-)

Applied, thanks.

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

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


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

2015-02-25 Thread Lee Jones
On Wed, 25 Feb 2015, micky_ch...@realsil.com.cn wrote:

> From: Micky Ching 
> 
> add support for new chip rts525A.
> 
> Signed-off-by: Micky Ching 
> ---
>  drivers/mfd/rts5249.c| 103 
> +++
>  drivers/mfd/rtsx_pcr.c   |  13 --
>  drivers/mfd/rtsx_pcr.h   |   1 +
>  include/linux/mfd/rtsx_pci.h |  15 +++
>  4 files changed, 129 insertions(+), 3 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
> index 32be803..d1ff32f 100644
> --- a/drivers/mfd/rts5249.c
> +++ b/drivers/mfd/rts5249.c
> @@ -487,3 +487,106 @@ void rts524a_init_params(struct rtsx_pcr *pcr)
>   pcr->ops = &rts524a_pcr_ops;
>  }
>  
> +static int rts525a_card_power_on(struct rtsx_pcr *pcr, int card)
> +{
> + rtsx_pci_write_register(pcr, LDO_VCC_CFG1,
> + LDO_VCC_TUNE_MASK, LDO_VCC_3V3);
> + return rtsx_base_card_power_on(pcr, card);
> +}
> +
> +static int rts525a_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
> +{
> + switch (voltage) {
> + case OUTPUT_3V3:
> + rtsx_pci_write_register(pcr, LDO_CONFIG2,
> + LDO_D3318_MASK, LDO_D3318_33V);
> + rtsx_pci_write_register(pcr, SD_PAD_CTL, SD_IO_USING_1V8, 0);
> + break;
> + case OUTPUT_1V8:
> + rtsx_pci_write_register(pcr, LDO_CONFIG2,
> + LDO_D3318_MASK, LDO_D3318_18V);
> + rtsx_pci_write_register(pcr, SD_PAD_CTL, SD_IO_USING_1V8,
> + SD_IO_USING_1V8);
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + rtsx_pci_init_cmd(pcr);
> + rts5249_fill_driving(pcr, voltage);
> + return rtsx_pci_send_cmd(pcr, 100);
> +}
> +
> +static int rts525a_optimize_phy(struct rtsx_pcr *pcr)
> +{
> + int err;
> +
> + err = rtsx_pci_write_register(pcr, RTS524A_PM_CTRL3,
> + D3_DELINK_MODE_EN, 0x00);
> + if (err < 0)
> + return err;
> +
> + rtsx_pci_write_phy_register(pcr, _PHY_FLD0,
> + _PHY_FLD0_CLK_REQ_20C | _PHY_FLD0_RX_IDLE_EN |
> + _PHY_FLD0_BIT_ERR_RSTN | _PHY_FLD0_BER_COUNT |
> + _PHY_FLD0_BER_TIMER | _PHY_FLD0_CHECK_EN);
> +
> + rtsx_pci_write_phy_register(pcr, _PHY_ANA03,
> + _PHY_ANA03_TIMER_MAX | _PHY_ANA03_OOBS_DEB_EN |
> + _PHY_CMU_DEBUG_EN);
> +
> + if (is_version(pcr, 0x525A, IC_VER_A))
> + rtsx_pci_write_phy_register(pcr, _PHY_REV0,
> + _PHY_REV0_FILTER_OUT | _PHY_REV0_CDR_BYPASS_PFD |
> + _PHY_REV0_CDR_RX_IDLE_BYPASS);
> +
> + return 0;
> +}
> +
> +static int rts525a_extra_init_hw(struct rtsx_pcr *pcr)
> +{
> + rts5249_extra_init_hw(pcr);
> +
> + rtsx_pci_write_register(pcr, PCLK_CTL, PCLK_MODE_SEL, PCLK_MODE_SEL);
> + if (is_version(pcr, 0x525A, IC_VER_A)) {
> + rtsx_pci_write_register(pcr, L1SUB_CONFIG2,
> + L1SUB_AUTO_CFG, L1SUB_AUTO_CFG);
> + rtsx_pci_write_register(pcr, RREF_CFG,
> + RREF_VBGSEL_MASK, RREF_VBGSEL_1V25);
> + rtsx_pci_write_register(pcr, LDO_VIO_CFG,
> + LDO_VIO_TUNE_MASK, LDO_VIO_1V7);
> + rtsx_pci_write_register(pcr, LDO_DV12S_CFG,
> + LDO_D12_TUNE_MASK, LDO_D12_TUNE_DF);
> + rtsx_pci_write_register(pcr, LDO_AV12S_CFG,
> + LDO_AV12S_TUNE_MASK, LDO_AV12S_TUNE_DF);
> + rtsx_pci_write_register(pcr, LDO_VCC_CFG0,
> + LDO_VCC_LMTVTH_MASK, LDO_VCC_LMTVTH_2A);
> + rtsx_pci_write_register(pcr, OOBS_CONFIG,
> + OOBS_AUTOK_DIS | OOBS_VAL_MASK, 0x89);
> + }
> +
> + return 0;
> +}
> +
> +static const struct pcr_ops rts525a_pcr_ops = {
> + .fetch_vendor_settings = rtsx_base_fetch_vendor_settings,
> + .extra_init_hw = rts525a_extra_init_hw,
> + .optimize_phy = rts525a_optimize_phy,
> + .turn_on_led = rtsx_base_turn_on_led,
> + .turn_off_led = rtsx_base_turn_off_led,
> + .enable_auto_blink = rtsx_base_enable_auto_blink,
> + .disable_auto_blink = rtsx_base_disable_auto_blink,
> + .card_power_on = rts525a_card_power_on,
> + .card_power_off = rtsx_base_card_power_off,
> + .switch_output_voltage = rts525a_switch_output_voltage,
> + .force_power_down = rtsx_base_force_power_down,
> +};
> +
> +void rts525a_init_params(struct rtsx_pcr *pcr)
> +{
> + rts5249_init_params(pcr);
> +
> + pcr->reg_pm_ctrl3 = RTS524A_PM_CTRL3;
> + pcr->ops = &rts525a_pcr_ops;
> +}
> +
> diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
> index e6d97ad..433cb41 100644
> --- a/drivers/mfd/rtsx_pcr.c
> +++ b/drivers/mfd/rtsx_pcr.c
> @@ -59,6 +59,7 @@ static const struct pci_device_id rtsx_pci_ids[] = {
>   { PCI_DEVICE(0x10EC, 0x5287), PCI_CLASS_OTHERS << 16, 0xFF },
>   { PCI_DEVICE(0x10EC, 0x5286), PCI_CLASS_OTHERS << 16, 0xFF },
> 

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

2015-02-25 Thread Lee Jones
On Wed, 25 Feb 2015, micky_ch...@realsil.com.cn wrote:

> From: Micky Ching 
> 
> add support for new chip rts524A.
> 
> Signed-off-by: Micky Ching 
> ---
>  drivers/mfd/rts5249.c| 186 
> ---
>  drivers/mfd/rtsx_pcr.c   |  25 +-
>  drivers/mfd/rtsx_pcr.h   |   7 ++
>  include/linux/mfd/rtsx_pci.h | 132 +-
>  4 files changed, 318 insertions(+), 32 deletions(-)

Applied, thanks.

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

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

2015-02-25 Thread Lee Jones
On Wed, 25 Feb 2015, micky_ch...@realsil.com.cn wrote:

> From: Micky Ching 
> 
> update card drive settings, This setting can be used for rts5249
> rts524A and rts525A.
> 
> Signed-off-by: Micky Ching 
> Acked-by: Lee Jones 
> ---
>  drivers/mfd/rts5249.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)

Applied, thanks.

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

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


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

2015-02-25 Thread Lee Jones
On Wed, 25 Feb 2015, micky_ch...@realsil.com.cn wrote:

> From: Micky Ching 
> 
> It is more readable to place register address and values define
> togather. The values define add two leading space indicate belong
> to the register address defined above.
> 
> Signed-off-by: Micky Ching 
> Acked-by: Lee Jones 
> ---
>  include/linux/mfd/rtsx_pci.h | 836 
> +++
>  1 file changed, 369 insertions(+), 467 deletions(-)

Applied, thanks.

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

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

2015-02-25 Thread Lee Jones
On Wed, 25 Feb 2015, micky_ch...@realsil.com.cn wrote:

> From: Micky Ching 
> 
> pcr_dbg is a wrapper of dev_dbg, which can save some code,
> and help to enable/disable debug message static.
> 
> Signed-off-by: Micky Ching 
> Acked-by: Lee Jones 
> ---
>  drivers/mfd/rtl8411.c  | 11 +--
>  drivers/mfd/rts5209.c  |  4 ++--
>  drivers/mfd/rts5227.c  |  4 ++--
>  drivers/mfd/rts5229.c  |  4 ++--
>  drivers/mfd/rts5249.c  |  4 ++--
>  drivers/mfd/rtsx_pcr.c | 49 ++---
>  6 files changed, 35 insertions(+), 41 deletions(-)

Applied, thanks.

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

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

2015-02-25 Thread Lee Jones
On Wed, 25 Feb 2015, micky_ch...@realsil.com.cn wrote:

> From: Micky Ching 
> 
> Update some phy register name and value for rts5249,
> the updated value makes chip more stable on some platform.
> 
> Signed-off-by: Micky Ching 
> ---
>  drivers/mfd/rts5249.c|  29 +++-
>  include/linux/mfd/rtsx_pci.h | 109 
> ++-
>  2 files changed, 72 insertions(+), 66 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
> index 2fe2854..8de8220 100644
> --- a/drivers/mfd/rts5249.c
> +++ b/drivers/mfd/rts5249.c
> @@ -132,11 +132,12 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
>   if (err < 0)
>   return err;
>  
> - err = rtsx_pci_write_phy_register(pcr, PHY_REG_REV,
> - PHY_REG_REV_RESV | PHY_REG_REV_RXIDLE_LATCHED |
> - PHY_REG_REV_P1_EN | PHY_REG_REV_RXIDLE_EN |
> - PHY_REG_REV_RX_PWST | PHY_REG_REV_CLKREQ_DLY_TIMER_1_0 |
> - PHY_REG_REV_STOP_CLKRD | PHY_REG_REV_STOP_CLKWR);
> + err = rtsx_pci_write_phy_register(pcr, PHY_REV,
> + PHY_REV_RESV | PHY_REV_RXIDLE_LATCHED |
> + PHY_REV_P1_EN | PHY_REV_RXIDLE_EN |
> + PHY_REV_CLKREQ_TX_EN | PHY_REV_RX_PWST |
> + PHY_REV_CLKREQ_DT_1_0 | PHY_REV_STOP_CLKRD |
> + PHY_REV_STOP_CLKWR);
>   if (err < 0)
>   return err;
>  
> @@ -147,19 +148,21 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
>   PHY_BPCR_IB_FILTER | PHY_BPCR_CMIRROR_EN);
>   if (err < 0)
>   return err;
> +
>   err = rtsx_pci_write_phy_register(pcr, PHY_PCR,
>   PHY_PCR_FORCE_CODE | PHY_PCR_OOBS_CALI_50 |
>   PHY_PCR_OOBS_VCM_08 | PHY_PCR_OOBS_SEN_90 |
> - PHY_PCR_RSSI_EN);
> + PHY_PCR_RSSI_EN | PHY_PCR_RX10K);
>   if (err < 0)
>   return err;
> +
>   err = rtsx_pci_write_phy_register(pcr, PHY_RCR2,
>   PHY_RCR2_EMPHASE_EN | PHY_RCR2_NADJR |
> - PHY_RCR2_CDR_CP_10 | PHY_RCR2_CDR_SR_2 |
> - PHY_RCR2_FREQSEL_12 | PHY_RCR2_CPADJEN |
> - PHY_RCR2_CDR_SC_8 | PHY_RCR2_CALIB_LATE);
> + PHY_RCR2_CDR_SR_2 | PHY_RCR2_FREQSEL_12 |
> + PHY_RCR2_CDR_SC_12P | PHY_RCR2_CALIB_LATE);
>   if (err < 0)
>   return err;
> +
>   err = rtsx_pci_write_phy_register(pcr, PHY_FLD4,
>   PHY_FLD4_FLDEN_SEL | PHY_FLD4_REQ_REF |
>   PHY_FLD4_RXAMP_OFF | PHY_FLD4_REQ_ADDA |
> @@ -167,11 +170,12 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
>   PHY_FLD4_BER_CHK_EN);
>   if (err < 0)
>   return err;
> - err = rtsx_pci_write_phy_register(pcr, PHY_RDR, PHY_RDR_RXDSEL_1_9);
> + err = rtsx_pci_write_phy_register(pcr, PHY_RDR,
> + PHY_RDR_RXDSEL_1_9 | PHY_SSC_AUTO_PWD);
>   if (err < 0)
>   return err;
>   err = rtsx_pci_write_phy_register(pcr, PHY_RCR1,
> - PHY_RCR1_ADP_TIME | PHY_RCR1_VCO_COARSE);
> + PHY_RCR1_ADP_TIME_4 | PHY_RCR1_VCO_COARSE);
>   if (err < 0)
>   return err;
>   err = rtsx_pci_write_phy_register(pcr, PHY_FLD3,
> @@ -179,10 +183,11 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
>   PHY_FLD3_RXDELINK);
>   if (err < 0)
>   return err;
> +
>   return rtsx_pci_write_phy_register(pcr, PHY_TUNE,
>   PHY_TUNE_TUNEREF_1_0 | PHY_TUNE_VBGSEL_1252 |
>   PHY_TUNE_SDBUS_33 | PHY_TUNE_TUNED18 |
> - PHY_TUNE_TUNED12);
> + PHY_TUNE_TUNED12 | PHY_TUNE_TUNEA12);
>  }
>  
>  static int rts5249_turn_on_led(struct rtsx_pcr *pcr)
> diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
> index 87cff60..0103210 100644
> --- a/include/linux/mfd/rtsx_pci.h
> +++ b/include/linux/mfd/rtsx_pci.h
> @@ -630,16 +630,47 @@
>  
>  /* Phy register */
>  #define PHY_PCR  0x00
> +#define   PHY_PCR_FORCE_CODE 0xB000
> +#define   PHY_PCR_OOBS_CALI_50   0x0800
> +#define   PHY_PCR_OOBS_VCM_080x0200
> +#define   PHY_PCR_OOBS_SEN_900x0040
> +#define   PHY_PCR_RSSI_EN0x0002
> +#define   PHY_PCR_RX10K  0x0001
> +
>  #define PHY_RCR0 0x01
>  #define PHY_RCR1 0x02
> +#define   PHY_RCR1_ADP_TIME_40x0400
> +#define   PHY_RCR1_VCO_COARSE0x001F
> +
>  #define PHY_RCR2 0x03
> +#define   PHY_RCR2_EMPHASE_EN0x8000
> +#define   PHY_RCR2_NADJR 0x4000
> +#define   PHY_RCR2_CDR_SR_2  0x0100
> +#define   PHY_RCR

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

2015-02-25 Thread Lee Jones
On Wed, 25 Feb 2015, micky_ch...@realsil.com.cn wrote:

> From: Micky Ching 
> 
> To enable/disable ASPM we should find LINK CONTROL register
> in PCI config space. All old chip use 0x80 address, but new
> chip may use another address, so we using pci_find_capability()
> to get LINK CONTROL address.
> 
> rtsx_gops.c was removed, we consider to put some common operations
> to this file, but the actual thing is, only a group of chips
> are in common ops1, and another group of chips in common ops2,
> it is hard to decide put which ops into generic ops file.
> 
> Signed-off-by: Micky Ching 
> Acked-by: Lee Jones 
> ---
>  drivers/mfd/Makefile |  2 +-
>  drivers/mfd/rts5227.c|  2 +-
>  drivers/mfd/rts5249.c|  3 +--
>  drivers/mfd/rtsx_gops.c  | 37 -
>  drivers/mfd/rtsx_pcr.c   | 22 +-
>  include/linux/mfd/rtsx_pci.h | 10 +-
>  6 files changed, 21 insertions(+), 55 deletions(-)
>  delete mode 100644 drivers/mfd/rtsx_gops.c

Applied, thanks.

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

Re: doubt about sm7xxfb

2015-02-25 Thread Greg Kroah-Hartman
On Wed, Feb 25, 2015 at 06:00:02PM +0530, Sudip Mukherjee wrote:
> On Wed, Feb 11, 2015 at 02:33:51PM +0800, Greg Kroah-Hartman wrote:
> > On Wed, Feb 11, 2015 at 11:58:18AM +0530, Sudip Mukherjee wrote:
> > 
> > Ok, that makes sense, I was thinking this was a "new" driver, instead of
> > a vendor driver crud.
> Hi Greg,
> The SM750 driver is almost ready for staging, it now compiles without
> any error with today's linux-next and is working properly , ok,  there
> are lots of warning when compiling and checkpatch will give lots of
> complaints.
> But in total it is creating 34 files and the size of the patch is
> 360K. So should i send it with mail, just the way we send other
> patches or should i send you a git pull request?

through email, like all other patches get sent please.

thanks,

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


[PATCH 3/3] Hal8188ERateAdaptive.c : Expression is always false because 'else if' condition matches previous condition at line 404.

2015-02-25 Thread Ameen Ali
else if at line 406 has the same condition as the else if at line 404.
i chosed 0x5 because it's half 0xb  (just a rate controller)
Signed-off-by : Ameen Ali 
---
 drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c 
b/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c
index 3c651d5..944cf7b 100644
--- a/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c
+++ b/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c
@@ -403,7 +403,7 @@ static int odm_ARFBRefresh_8188E(struct odm_dm_struct 
*dm_odm, struct odm_ra_inf
pRaInfo->PTModeSS = 3;
else if (pRaInfo->HighestRate > 0x0b)
pRaInfo->PTModeSS = 2;
-   else if (pRaInfo->HighestRate > 0x0b)
+   else if (pRaInfo->HighestRate > 0x5)
pRaInfo->PTModeSS = 1;
else
pRaInfo->PTModeSS = 0;
-- 
2.1.0

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


Re: [patch] Staging: lustre: missing curly braces in ll_setattr_raw()

2015-02-25 Thread Drokin, Oleg
Ah! 
Nice catch.
I am not sure how I missed that while making 
178ba1e0d00aca671f9a8f5f41d28fc0fe717752, it's also strange that this never 
triggered any ill effects in any of my testing.

Thanks!

On Feb 25, 2015, at 8:20 AM, Dan Carpenter wrote:

> From the indenting, it looks like curly braces were intended here.
> 
> Signed-off-by: Dan Carpenter 
> ---
> This is not tested, and it changes how the code works.  Please review
> it a bit carefully.  Sometimes people just do weird indenting for no
> reason.
> 
> diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
> b/drivers/staging/lustre/lustre/llite/llite_lib.c
> index 0c1b583..ba97d9e 100644
> --- a/drivers/staging/lustre/lustre/llite/llite_lib.c
> +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
> @@ -1432,7 +1432,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr 
> *attr, bool hsm_import)
> 
>   if (attr->ia_valid & (ATTR_SIZE |
> ATTR_ATIME | ATTR_ATIME_SET |
> -   ATTR_MTIME | ATTR_MTIME_SET))
> +   ATTR_MTIME | ATTR_MTIME_SET)) {
>   /* For truncate and utimes sending attributes to OSTs, setting
>* mtime/atime to the past will be performed under PW [0:EOF]
>* extent lock (new_size:EOF for truncate).  It may seem
> @@ -1444,6 +1444,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr 
> *attr, bool hsm_import)
>   rc = ll_setattr_ost(inode, attr);
>   if (attr->ia_valid & ATTR_SIZE)
>   up_write(&lli->lli_trunc_sem);
> + }
> out:
>   if (op_data) {
>   if (op_data->op_ioepoch) {

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


Re: [PATCH 1/2] Drivers: hv: hv_balloon: report offline pages as being used

2015-02-25 Thread Vitaly Kuznetsov
KY Srinivasan  writes:

>> -Original Message-
>> From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com]
>> Sent: Thursday, February 19, 2015 8:27 AM
>> To: KY Srinivasan; de...@linuxdriverproject.org
>> Cc: Haiyang Zhang; linux-ker...@vger.kernel.org; Dexuan Cui
>> Subject: [PATCH 1/2] Drivers: hv: hv_balloon: report offline pages as being
>> used
>> 
>> When hot-added memory pages are not brought online or when some
>> memory blocks
>> are sent offline the subsequent ballooning process kills the guest with OOM
>> killer. This happens as we don't report these pages as neither used nor free
>> and apparently host algorythm considers them as being unused. Keep track
>> of
>> all online/offline operations and report all currently offline pages as being
>> used so host won't try to balloon them out.
>> 
>> Signed-off-by: Vitaly Kuznetsov 
>> ---
>>  drivers/hv/hv_balloon.c | 33 -
>>  1 file changed, 24 insertions(+), 9 deletions(-)
>> 
>> diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
>> index a095b70..e4b4454 100644
>> --- a/drivers/hv/hv_balloon.c
>> +++ b/drivers/hv/hv_balloon.c
>> @@ -503,6 +503,8 @@ struct hv_dynmem_device {
>>   * Number of pages we have currently ballooned out.
>>   */
>>  unsigned int num_pages_ballooned;
>> +unsigned int num_pages_onlined;
>> +unsigned int num_pages_added;
>> 
>>  /*
>>   * State to manage the ballooning (up) operation.
>> @@ -556,12 +558,15 @@ static void post_status(struct hv_dynmem_device
>> *dm);
>>  static int hv_memory_notifier(struct notifier_block *nb, unsigned long val,
>>void *v)
>>  {
>> +struct memory_notify *mem = (struct memory_notify *)v;
>> +
>>  switch (val) {
>>  case MEM_GOING_ONLINE:
>>  mutex_lock(&dm_device.ha_region_mutex);
>>  break;
>> 
>>  case MEM_ONLINE:
>> +dm_device.num_pages_onlined += mem->nr_pages;
>>  case MEM_CANCEL_ONLINE:
>
> Why are we not adjusting num_pages_onlined when we cancel the online
> Operation.

Because we didn't increase the number yet.

To my understanding, events come in the following order:
1) MEM_GOING_ONLINE - we just take the lock
2) MEM_ONLINE - and we increase nr_pages and drop the lock
   or
   MEM_CANCEL_ONLINE - we just drop the lock (mem never was online so
  nr_pages wasn't increased)
3) MEM_GOING_OFFLINE - we do nothing
4) MEM_OFFLINE - and we decrease nr_pages
   or 
   MEM_CANCEL_OFFLINE - we do nothing (mem is still online, no need to
   adjust nr_pages)

>
> K. Y

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


RE: [PATCH v3 34/36] staging: comedi: amplc_dio200_common: convert driver to use the comedi_8254 module

2015-02-25 Thread Hartley Sweeten
On Wednesday, February 25, 2015 7:22 AM, Ian Abbott wrote:
> On 24/02/2015 17:38, H Hartley Sweeten wrote:
>> Convert this driver to use the comedi_8254 module to provide the 8254 timer 
>> support.
>>
>> Add 'clock_src' and 'gate_src' members to the comedi_8254 data for 
>> convienence.
>>
>> Signed-off-by: H Hartley Sweeten 
>> Cc: Ian Abbott 
>> Cc: Greg Kroah-Hartman 
>> ---
>> v3: As pointed out by Ian Abbott, fix the 'offset' used for the timer on 
>> PCIe boards.
>>  No change to the rest of the series.
>>
>>   drivers/staging/comedi/Kconfig |   1 +
>>   .../staging/comedi/drivers/amplc_dio200_common.c   | 295 
>> +++--
>>   drivers/staging/comedi/drivers/comedi_8254.h   |   4 +
>>   3 files changed, 99 insertions(+), 201 deletions(-)
>
> Reviewed-by: Ian Abbott 

Thanks for your help reviewing this series.

Regards,
Hartley

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


RE: [PATCH] comedi: Change error return code for if statement in the function,cb_pcimdas_ai_rinsn

2015-02-25 Thread Hartley Sweeten
On Tuesday, February 24, 2015 9:13 PM, Nicholas Krause wrote:
> This changes us using the incorrect error,-ETIMEOUT when checking if
> the channel we are allocating to on the device structure pointer passed 
> to this function is greater then the maximum available channels for this 
> device to the correct error for a channel being out of range,-ECHRNG.
>
> Signed-off-by: Nicholas Krause 
> ---
>  drivers/staging/comedi/drivers/cb_pcimdas.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c 
> b/drivers/staging/comedi/drivers/cb_pcimdas.c
> index 70dd2c9..d91a6f3 100644
> --- a/drivers/staging/comedi/drivers/cb_pcimdas.c
> +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
> @@ -121,7 +121,7 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device *dev,
>   maxchans = s->n_chan;
>  
>   if (chan > (maxchans - 1))
> - return -ETIMEDOUT;  /* *** Wrong error code. Fixme. */
> + return -ECHRNG;
>  
>   /* configure for sw initiated read */
>   d = inb(devpriv->BADR3 + 5);

Hmm... This isn't quite right...

The 16 single-ended / 8 differential analog input channels on this board is
set with a switch on the PCB. The state of the switch should be read when
the driver is attached and the subdevice initialized with the correct number
of channels. The core will then validate the "chan" number before calling
the (*insn_read) operation.

Regards,
Hartley

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


Re: [PATCH 2/2] iio: jsa1212: Constify struct regmap_config

2015-02-25 Thread Jonathan Cameron
On 24/02/15 09:41, Krzysztof Kozlowski wrote:
> The regmap_config struct may be const because it is not modified by the
> driver and regmap_init() accepts pointer to const.
> 
> Signed-off-by: Krzysztof Kozlowski 
Applied to the togreg branch of iio.git.  I'm having another of my periodic
days in a clean room (with a very dirty laptop), so will be a day or two before
I'm back home and can push out as testing for the autobuilders to play.

On the plus side, the machine I'm working on isn't running so lots of time
for patch review...

Jonathan
> ---
>  drivers/iio/light/jsa1212.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/light/jsa1212.c b/drivers/iio/light/jsa1212.c
> index 29de7e7d9562..3a3af89beaf9 100644
> --- a/drivers/iio/light/jsa1212.c
> +++ b/drivers/iio/light/jsa1212.c
> @@ -308,7 +308,7 @@ static bool jsa1212_is_volatile_reg(struct device *dev, 
> unsigned int reg)
>   }
>  }
>  
> -static struct regmap_config jsa1212_regmap_config = {
> +static const struct regmap_config jsa1212_regmap_config = {
>   .name =  JSA1212_REGMAP_NAME,
>   .reg_bits = 8,
>   .val_bits = 8,
> 

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


Re: [PATCH 1/2] staging:iio:hmc5843: Constify register tables and struct regmap_config

2015-02-25 Thread Jonathan Cameron
On 24/02/15 09:41, Krzysztof Kozlowski wrote:
> The regmap_access_table and regmap_config structures may be const
> because they are not modified by the driver and regmap_init() accepts
> pointer to const.
> 
> Signed-off-by: Krzysztof Kozlowski 
Applied to the togreg branch of iio.git. Note I ended up hand applying
this due to DOS line endings and some fuzz.

Jonathan
> ---
>  drivers/staging/iio/magnetometer/hmc5843_i2c.c | 8 
>  drivers/staging/iio/magnetometer/hmc5843_spi.c | 8 
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/iio/magnetometer/hmc5843_i2c.c 
> b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
> index 6acd614cdbc6..8346cf81fc2e 100644
> --- a/drivers/staging/iio/magnetometer/hmc5843_i2c.c
> +++ b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
> @@ -22,7 +22,7 @@ static const struct regmap_range hmc5843_readable_ranges[] 
> = {
>   regmap_reg_range(0, HMC5843_ID_END),
>  };
>  
> -static struct regmap_access_table hmc5843_readable_table = {
> +static const struct regmap_access_table hmc5843_readable_table = {
>   .yes_ranges = hmc5843_readable_ranges,
>   .n_yes_ranges = ARRAY_SIZE(hmc5843_readable_ranges),
>  };
> @@ -31,7 +31,7 @@ static const struct regmap_range hmc5843_writable_ranges[] 
> = {
>   regmap_reg_range(0, HMC5843_MODE_REG),
>  };
>  
> -static struct regmap_access_table hmc5843_writable_table = {
> +static const struct regmap_access_table hmc5843_writable_table = {
>   .yes_ranges = hmc5843_writable_ranges,
>   .n_yes_ranges = ARRAY_SIZE(hmc5843_writable_ranges),
>  };
> @@ -40,12 +40,12 @@ static const struct regmap_range 
> hmc5843_volatile_ranges[] = {
>   regmap_reg_range(HMC5843_DATA_OUT_MSB_REGS, HMC5843_STATUS_REG),
>  };
>  
> -static struct regmap_access_table hmc5843_volatile_table = {
> +static const struct regmap_access_table hmc5843_volatile_table = {
>   .yes_ranges = hmc5843_volatile_ranges,
>   .n_yes_ranges = ARRAY_SIZE(hmc5843_volatile_ranges),
>  };
>  
> -static struct regmap_config hmc5843_i2c_regmap_config = {
> +static const struct regmap_config hmc5843_i2c_regmap_config = {
>   .reg_bits = 8,
>   .val_bits = 8,
>  
> diff --git a/drivers/staging/iio/magnetometer/hmc5843_spi.c 
> b/drivers/staging/iio/magnetometer/hmc5843_spi.c
> index 98c4b57101c9..8e658f736e1f 100644
> --- a/drivers/staging/iio/magnetometer/hmc5843_spi.c
> +++ b/drivers/staging/iio/magnetometer/hmc5843_spi.c
> @@ -19,7 +19,7 @@ static const struct regmap_range hmc5843_readable_ranges[] 
> = {
>   regmap_reg_range(0, HMC5843_ID_END),
>  };
>  
> -static struct regmap_access_table hmc5843_readable_table = {
> +static const struct regmap_access_table hmc5843_readable_table = {
>   .yes_ranges = hmc5843_readable_ranges,
>   .n_yes_ranges = ARRAY_SIZE(hmc5843_readable_ranges),
>  };
> @@ -28,7 +28,7 @@ static const struct regmap_range hmc5843_writable_ranges[] 
> = {
>   regmap_reg_range(0, HMC5843_MODE_REG),
>  };
>  
> -static struct regmap_access_table hmc5843_writable_table = {
> +static const struct regmap_access_table hmc5843_writable_table = {
>   .yes_ranges = hmc5843_writable_ranges,
>   .n_yes_ranges = ARRAY_SIZE(hmc5843_writable_ranges),
>  };
> @@ -37,12 +37,12 @@ static const struct regmap_range 
> hmc5843_volatile_ranges[] = {
>   regmap_reg_range(HMC5843_DATA_OUT_MSB_REGS, HMC5843_STATUS_REG),
>  };
>  
> -static struct regmap_access_table hmc5843_volatile_table = {
> +static const struct regmap_access_table hmc5843_volatile_table = {
>   .yes_ranges = hmc5843_volatile_ranges,
>   .n_yes_ranges = ARRAY_SIZE(hmc5843_volatile_ranges),
>  };
>  
> -static struct regmap_config hmc5843_spi_regmap_config = {
> +static const struct regmap_config hmc5843_spi_regmap_config = {
>   .reg_bits = 8,
>   .val_bits = 8,
>  
> 

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


RE: [PATCH] comedi: Change error return code for if statement in the function, cb_pcimdas_ai_rinsn

2015-02-25 Thread Nicholas Krause


On February 25, 2015 1:03:14 PM EST, Hartley Sweeten 
 wrote:
>On Tuesday, February 24, 2015 9:13 PM, Nicholas Krause wrote:
>> This changes us using the incorrect error,-ETIMEOUT when checking if
>> the channel we are allocating to on the device structure pointer
>passed 
>> to this function is greater then the maximum available channels for
>this 
>> device to the correct error for a channel being out of range,-ECHRNG.
>>
>> Signed-off-by: Nicholas Krause 
>> ---
>>  drivers/staging/comedi/drivers/cb_pcimdas.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c
>b/drivers/staging/comedi/drivers/cb_pcimdas.c
>> index 70dd2c9..d91a6f3 100644
>> --- a/drivers/staging/comedi/drivers/cb_pcimdas.c
>> +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
>> @@ -121,7 +121,7 @@ static int cb_pcimdas_ai_rinsn(struct
>comedi_device *dev,
>>  maxchans = s->n_chan;
>>  
>>  if (chan > (maxchans - 1))
>> -return -ETIMEDOUT;  /* *** Wrong error code. Fixme. */
>> +return -ECHRNG;
>>  
>>  /* configure for sw initiated read */
>>  d = inb(devpriv->BADR3 + 5);
>
>Hmm... This isn't quite right...
>
>The 16 single-ended / 8 differential analog input channels on this
>board is
>set with a switch on the PCB. The state of the switch should be read
>when
>the driver is attached and the subdevice initialized with the correct
>number
>of channels. The core will then validate the "chan" number before
>calling
>the (*insn_read) operation.
>
>Regards,
>Hartley
Hartley, 
If that is the case then why is the check  for max channels here.  I  can send 
in a v2 removing this check as it seems unneeded based on my understanding and 
your response to this patch. 
Nick 

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 1/2] Drivers: hv: hv_balloon: report offline pages as being used

2015-02-25 Thread KY Srinivasan


> -Original Message-
> From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com]
> Sent: Wednesday, February 25, 2015 8:56 AM
> To: KY Srinivasan
> Cc: de...@linuxdriverproject.org; Haiyang Zhang; linux-
> ker...@vger.kernel.org; Dexuan Cui
> Subject: Re: [PATCH 1/2] Drivers: hv: hv_balloon: report offline pages as
> being used
> 
> KY Srinivasan  writes:
> 
> >> -Original Message-
> >> From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com]
> >> Sent: Thursday, February 19, 2015 8:27 AM
> >> To: KY Srinivasan; de...@linuxdriverproject.org
> >> Cc: Haiyang Zhang; linux-ker...@vger.kernel.org; Dexuan Cui
> >> Subject: [PATCH 1/2] Drivers: hv: hv_balloon: report offline pages as
> >> being used
> >>
> >> When hot-added memory pages are not brought online or when some
> >> memory blocks are sent offline the subsequent ballooning process
> >> kills the guest with OOM killer. This happens as we don't report
> >> these pages as neither used nor free and apparently host algorythm
> >> considers them as being unused. Keep track of all online/offline
> >> operations and report all currently offline pages as being used so
> >> host won't try to balloon them out.
> >>
> >> Signed-off-by: Vitaly Kuznetsov 
> >> ---
> >>  drivers/hv/hv_balloon.c | 33 -
> >>  1 file changed, 24 insertions(+), 9 deletions(-)
> >>
> >> diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index
> >> a095b70..e4b4454 100644
> >> --- a/drivers/hv/hv_balloon.c
> >> +++ b/drivers/hv/hv_balloon.c
> >> @@ -503,6 +503,8 @@ struct hv_dynmem_device {
> >> * Number of pages we have currently ballooned out.
> >> */
> >>unsigned int num_pages_ballooned;
> >> +  unsigned int num_pages_onlined;
> >> +  unsigned int num_pages_added;
> >>
> >>/*
> >> * State to manage the ballooning (up) operation.
> >> @@ -556,12 +558,15 @@ static void post_status(struct
> hv_dynmem_device
> >> *dm);  static int hv_memory_notifier(struct notifier_block *nb,
> >> unsigned long val,
> >>  void *v)
> >>  {
> >> +  struct memory_notify *mem = (struct memory_notify *)v;
> >> +
> >>switch (val) {
> >>case MEM_GOING_ONLINE:
> >>mutex_lock(&dm_device.ha_region_mutex);
> >>break;
> >>
> >>case MEM_ONLINE:
> >> +  dm_device.num_pages_onlined += mem->nr_pages;
> >>case MEM_CANCEL_ONLINE:
> >
> > Why are we not adjusting num_pages_onlined when we cancel the online
> > Operation.
> 
> Because we didn't increase the number yet.

Thanks; my mistake.

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


[PATCH 4/7] staging: comedi: cb_pcimdas: provide analog output range table

2015-02-25 Thread H Hartley Sweeten
The analog output range is not programmable. The DAC ranges are
jumper-settable on the board. For aesthetics, provide a range table
for the user with all possible ranges.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c 
b/drivers/staging/comedi/drivers/cb_pcimdas.c
index b0cc4f5..94da819 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -137,6 +137,19 @@ static const struct comedi_lrange cb_pcimdas_ai_uni_range 
= {
 };
 
 /*
+ * The Analog Output range is not programmable. The DAC ranges are
+ * jumper-settable on the board. The settings are not software-readable.
+ */
+static const struct comedi_lrange cb_pcimdas_ao_range = {
+   4, {
+   BIP_RANGE(10),
+   BIP_RANGE(5),
+   UNI_RANGE(10),
+   UNI_RANGE(5)
+   }
+};
+
+/*
  * this structure is for data unique to this hardware driver.  If
  * several hardware drivers keep similar information in this structure,
  * feel free to suggest moving the variable to the struct comedi_device
@@ -306,8 +319,7 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev,
s->subdev_flags = SDF_WRITABLE;
s->n_chan = 2;
s->maxdata = 0xfff;
-   /* ranges are hardware settable, but not software readable. */
-   s->range_table = &range_unknown;
+   s->range_table = &cb_pcimdas_ao_range;
s->insn_write = cb_pcimdas_ao_insn_write;
 
ret = comedi_alloc_subdev_readback(s);
-- 
2.3.0

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


[PATCH 1/7] staging: comedi: cb_pcimdas: fix analog input channel configuration

2015-02-25 Thread H Hartley Sweeten
The hardware uses a switch on the board to set the number of analog
input channels to either 16 single-ended or 8 differential channels.
Currently the switch setting is checked for every (*insn_read) operation
to validate the channel number.

Check the switch setting during the driver attach and initialize the
subdevice accordingly. This allows the core to handle the validation.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c 
b/drivers/staging/comedi/drivers/cb_pcimdas.c
index 70dd2c9..ddaa61c 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -109,20 +109,10 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device *dev,
unsigned int d;
int chan = CR_CHAN(insn->chanspec);
unsigned short chanlims;
-   int maxchans;
int ret;
 
/*  only support sw initiated reads from a single channel */
 
-   /* check channel number */
-   if ((inb(devpriv->BADR3 + 2) & 0x20) == 0)  /* differential mode */
-   maxchans = s->n_chan / 2;
-   else
-   maxchans = s->n_chan;
-
-   if (chan > (maxchans - 1))
-   return -ETIMEDOUT;  /* *** Wrong error code. Fixme. */
-
/* configure for sw initiated read */
d = inb(devpriv->BADR3 + 5);
if ((d & 0x03) > 0) {   /* only reset if needed. */
@@ -181,6 +171,20 @@ static int cb_pcimdas_ao_insn_write(struct comedi_device 
*dev,
return insn->n;
 }
 
+static bool cb_pcimdas_is_ai_se(struct comedi_device *dev)
+{
+   struct cb_pcimdas_private *devpriv = dev->private;
+   unsigned int status;
+
+   /*
+* The number of Analog Input channels is set with the
+* Analog Input Mode Switch on the board. The board can
+* have 16 single-ended or 8 differential channels.
+*/
+   status = inb(devpriv->BADR3 + 2);
+   return status & 0x20;
+}
+
 static int cb_pcimdas_auto_attach(struct comedi_device *dev,
unsigned long context_unused)
 {
@@ -209,8 +213,14 @@ static int cb_pcimdas_auto_attach(struct comedi_device 
*dev,
/* dev->read_subdev=s; */
/*  analog input subdevice */
s->type = COMEDI_SUBD_AI;
-   s->subdev_flags = SDF_READABLE | SDF_GROUND;
-   s->n_chan = 16;
+   s->subdev_flags = SDF_READABLE;
+   if (cb_pcimdas_is_ai_se(dev)) {
+   s->subdev_flags |= SDF_GROUND;
+   s->n_chan   = 16;
+   } else {
+   s->subdev_flags |= SDF_DIFF;
+   s->n_chan   = 8;
+   }
s->maxdata = 0x;
s->range_table = &range_unknown;
s->len_chanlist = 1;/*  This is the maximum chanlist length that */
-- 
2.3.0

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


[PATCH 3/7] staging: comedi: cb_pcimdas: define the register map

2015-02-25 Thread H Hartley Sweeten
Add defines for the registers and bits. Use the defines to remove the
"magic" numbers.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c 
b/drivers/staging/comedi/drivers/cb_pcimdas.c
index 5d08ca4..b0cc4f5 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -50,29 +50,73 @@
 #include "plx9052.h"
 #include "8255.h"
 
-/* Registers for the PCIM-DAS1602/16 and PCIe-DAS1602/16 */
-
-/* DAC Offsets */
-#define ADC_TRIG 0
-#define DAC0_OFFSET 2
-#define DAC1_OFFSET 4
-
-/* AI and Counter Constants */
-#define MUX_LIMITS 0
-#define MAIN_CONN_DIO 1
-#define ADC_STAT 2
-#define ADC_CONV_STAT 3
-#define ADC_INT 4
-#define ADC_PACER 5
-#define BURST_MODE 6
-#define PROG_GAIN 7
-#define CLK8254_1_DATA 8
-#define CLK8254_2_DATA 9
-#define CLK8254_3_DATA 10
-#define CLK8254_CONTROL 11
-#define USER_COUNTER 12
-#define RESID_COUNT_H 13
-#define RESID_COUNT_L 14
+/*
+ * PCI Bar 1 Register map
+ * see plx9052.h for register and bit defines
+ */
+
+/*
+ * PCI Bar 2 Register map (devpriv->daqio)
+ */
+#define PCIMDAS_AI_REG 0x00
+#define PCIMDAS_AI_SOFTTRIG_REG0x00
+#define PCIMDAS_AO_REG(x)  (0x02 + ((x) * 2))
+
+/*
+ * PCI Bar 3 Register map (devpriv->BADR3)
+ */
+#define PCIMDAS_MUX_REG0x00
+#define PCIMDAS_MUX(_lo, _hi)  ((_lo) | ((_hi) << 4))
+#define PCIMDAS_DI_DO_REG  0x01
+#define PCIMDAS_STATUS_REG 0x02
+#define PCIMDAS_STATUS_EOC BIT(7)
+#define PCIMDAS_STATUS_UB  BIT(6)
+#define PCIMDAS_STATUS_MUX BIT(5)
+#define PCIMDAS_STATUS_CLK BIT(4)
+#define PCIMDAS_STATUS_TO_CURR_MUX(x)  ((x) & 0xf)
+#define PCIMDAS_CONV_STATUS_REG0x03
+#define PCIMDAS_CONV_STATUS_EOCBIT(7)
+#define PCIMDAS_CONV_STATUS_EOBBIT(6)
+#define PCIMDAS_CONV_STATUS_EOABIT(5)
+#define PCIMDAS_CONV_STATUS_FNEBIT(4)
+#define PCIMDAS_CONV_STATUS_FHFBIT(3)
+#define PCIMDAS_CONV_STATUS_OVERRUNBIT(2)
+#define PCIMDAS_IRQ_REG0x04
+#define PCIMDAS_IRQ_INTE   BIT(7)
+#define PCIMDAS_IRQ_INTBIT(6)
+#define PCIMDAS_IRQ_OVERRUNBIT(4)
+#define PCIMDAS_IRQ_EOABIT(3)
+#define PCIMDAS_IRQ_EOA_INT_SELBIT(2)
+#define PCIMDAS_IRQ_INTSEL(x)  ((x) << 0)
+#define PCIMDAS_IRQ_INTSEL_EOC PCIMDAS_IRQ_INTSEL(0)
+#define PCIMDAS_IRQ_INTSEL_FNE PCIMDAS_IRQ_INTSEL(1)
+#define PCIMDAS_IRQ_INTSEL_EOB PCIMDAS_IRQ_INTSEL(2)
+#define PCIMDAS_IRQ_INTSEL_FHF_EOA PCIMDAS_IRQ_INTSEL(3)
+#define PCIMDAS_PACER_REG  0x05
+#define PCIMDAS_PACER_GATE_STATUS  BIT(6)
+#define PCIMDAS_PACER_GATE_POL BIT(5)
+#define PCIMDAS_PACER_GATE_LATCH   BIT(4)
+#define PCIMDAS_PACER_GATE_EN  BIT(3)
+#define PCIMDAS_PACER_EXT_PACER_POLBIT(2)
+#define PCIMDAS_PACER_SRC(x)   ((x) << 0)
+#define PCIMDAS_PACER_SRC_POLLED   PCIMDAS_PACER_SRC(0)
+#define PCIMDAS_PACER_SRC_EXT  PCIMDAS_PACER_SRC(2)
+#define PCIMDAS_PACER_SRC_INT  PCIMDAS_PACER_SRC(3)
+#define PCIMDAS_PACER_SRC_MASK (3 << 0)
+#define PCIMDAS_BURST_REG  0x06
+#define PCIMDAS_BURST_BME  BIT(1)
+#define PCIMDAS_BURST_CONV_EN  BIT(0)
+#define PCIMDAS_GAIN_REG   0x07
+#define PCIMDAS_8254_BASE  0x08
+#define PCIMDAS_USER_CNTR_REG  0x0c
+#define PCIMDAS_USER_CNTR_CTR1_CLK_SEL BIT(0)
+#define PCIMDAS_RESIDUE_MSB_REG0x0d
+#define PCIMDAS_RESIDUE_LSB_REG0x0e
+
+/*
+ * PCI Bar 4 Register map (dev->iobase)
+ */
+#define PCIMDAS_8255_BASE  0x00
 
 static const struct comedi_lrange cb_pcimdas_ai_bip_range = {
4, {
@@ -112,8 +156,8 @@ static int cb_pcimdas_ai_eoc(struct comedi_device *dev,
struct cb_pcimdas_private *devpriv = dev->private;
unsigned int status;
 
-   status = inb(devpriv->BADR3 + 2);
-   if ((status & 0x80) == 0)
+   status = inb(devpriv->BADR3 + PCIMDAS_STATUS_REG);
+   if ((status & PCIMDAS_STATUS_EOC) == 0)
return 0;
return -EBUSY;
 }
@@ -127,35 +171,31 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device *dev,
unsigned int range = CR_RANGE(insn->chanspec);
int n;
unsigned int d;
-   unsigned short chanlims;
int ret;
 
/*  only support sw initiated reads from a single channel */
 
/* configure for sw initiated read */
-   d = inb(devpriv->BADR3 + 5);
-   if ((d & 0x03) > 0) {   /* only reset if needed. */
-   d = d & 0xfd;
-   outb(d, devpriv->BADR3 + 5);

[PATCH 2/7] staging: comedi: cb_pcimdas: support analog input programmable ranges

2015-02-25 Thread H Hartley Sweeten
The hardware uses a switch on the board to select if the analog inputs
are bipolar or uinipolar. The gain is programmable to allow the following
input ranges:

  Gain  Bipolar   Unipolar
0   +/-10V0 to 10V
1   +/-5V 0 to 5V
2   +/-2.5V   0 to 2.5V
3   +/-1.25V  0 to 1.25V

Add the necessary code to the driver to allow the user to select the
desired range.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c 
b/drivers/staging/comedi/drivers/cb_pcimdas.c
index ddaa61c..5d08ca4 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -74,6 +74,24 @@
 #define RESID_COUNT_H 13
 #define RESID_COUNT_L 14
 
+static const struct comedi_lrange cb_pcimdas_ai_bip_range = {
+   4, {
+   BIP_RANGE(10),
+   BIP_RANGE(5),
+   BIP_RANGE(2.5),
+   BIP_RANGE(1.25)
+   }
+};
+
+static const struct comedi_lrange cb_pcimdas_ai_uni_range = {
+   4, {
+   UNI_RANGE(10),
+   UNI_RANGE(5),
+   UNI_RANGE(2.5),
+   UNI_RANGE(1.25)
+   }
+};
+
 /*
  * this structure is for data unique to this hardware driver.  If
  * several hardware drivers keep similar information in this structure,
@@ -105,9 +123,10 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device *dev,
   struct comedi_insn *insn, unsigned int *data)
 {
struct cb_pcimdas_private *devpriv = dev->private;
+   unsigned int chan = CR_CHAN(insn->chanspec);
+   unsigned int range = CR_RANGE(insn->chanspec);
int n;
unsigned int d;
-   int chan = CR_CHAN(insn->chanspec);
unsigned short chanlims;
int ret;
 
@@ -123,8 +142,8 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device *dev,
/* set bursting off, conversions on */
outb(0x01, devpriv->BADR3 + 6);
 
-   /* set range to 10V. UP/BP is controlled by a switch on the board */
-   outb(0x00, devpriv->BADR3 + 7);
+   /* set range */
+   outb(range, devpriv->BADR3 + 7);
 
/*
 * write channel limits to multiplexer, set Low (bits 0-3) and
@@ -185,6 +204,20 @@ static bool cb_pcimdas_is_ai_se(struct comedi_device *dev)
return status & 0x20;
 }
 
+static bool cb_pcimdas_is_ai_uni(struct comedi_device *dev)
+{
+   struct cb_pcimdas_private *devpriv = dev->private;
+   unsigned int status;
+
+   /*
+* The Analog Input range polarity is set with the
+* Analog Input Polarity Switch on the board. The
+* inputs can be set to Unipolar or Bipolar ranges.
+*/
+   status = inb(devpriv->BADR3 + 2);
+   return status & 0x40;
+}
+
 static int cb_pcimdas_auto_attach(struct comedi_device *dev,
unsigned long context_unused)
 {
@@ -222,7 +255,8 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev,
s->n_chan   = 8;
}
s->maxdata = 0x;
-   s->range_table = &range_unknown;
+   s->range_table  = cb_pcimdas_is_ai_uni(dev) ? &cb_pcimdas_ai_uni_range
+   : &cb_pcimdas_ai_bip_range;
s->len_chanlist = 1;/*  This is the maximum chanlist length that */
/*  the board can handle */
s->insn_read = cb_pcimdas_ai_rinsn;
-- 
2.3.0

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


[PATCH 6/7] staging: comedi: cb_pcimdas: add main connector digital input/output

2015-02-25 Thread H Hartley Sweeten
Add subdevices for the 4 digital input and 4 digital output channels on
the main connector of the board.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c 
b/drivers/staging/comedi/drivers/cb_pcimdas.c
index 00ba404..cef6872 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -243,6 +243,36 @@ static int cb_pcimdas_ao_insn_write(struct comedi_device 
*dev,
return insn->n;
 }
 
+static int cb_pcimdas_di_insn_read(struct comedi_device *dev,
+  struct comedi_subdevice *s,
+  struct comedi_insn *insn,
+  unsigned int *data)
+{
+   struct cb_pcimdas_private *devpriv = dev->private;
+   unsigned int val;
+
+   val = inb(devpriv->BADR3 + PCIMDAS_DI_DO_REG);
+
+   data[1] = val & 0x0f;
+
+   return insn->n;
+}
+
+static int cb_pcimdas_do_insn_write(struct comedi_device *dev,
+   struct comedi_subdevice *s,
+   struct comedi_insn *insn,
+   unsigned int *data)
+{
+   struct cb_pcimdas_private *devpriv = dev->private;
+
+   if (comedi_dio_update_state(s, data))
+   outb(s->state, devpriv->BADR3 + PCIMDAS_DI_DO_REG);
+
+   data[1] = s->state;
+
+   return insn->n;
+}
+
 static bool cb_pcimdas_is_ai_se(struct comedi_device *dev)
 {
struct cb_pcimdas_private *devpriv = dev->private;
@@ -291,7 +321,7 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev,
devpriv->BADR3 = pci_resource_start(pcidev, 3);
dev->iobase = pci_resource_start(pcidev, 4);
 
-   ret = comedi_alloc_subdevices(dev, 3);
+   ret = comedi_alloc_subdevices(dev, 5);
if (ret)
return ret;
 
@@ -330,6 +360,24 @@ static int cb_pcimdas_auto_attach(struct comedi_device 
*dev,
if (ret)
return ret;
 
+   /* Digital Input subdevice (main connector) */
+   s = &dev->subdevices[3];
+   s->type = COMEDI_SUBD_DI;
+   s->subdev_flags = SDF_READABLE;
+   s->n_chan   = 4;
+   s->maxdata  = 1;
+   s->range_table  = &range_digital;
+   s->insn_read= cb_pcimdas_di_insn_read;
+
+   /* Digital Output subdevice (main connector) */
+   s = &dev->subdevices[4];
+   s->type = COMEDI_SUBD_DO;
+   s->subdev_flags = SDF_WRITABLE;
+   s->n_chan   = 4;
+   s->maxdata  = 1;
+   s->range_table  = &range_digital;
+   s->insn_write   = cb_pcimdas_do_insn_write;
+
return 0;
 }
 
-- 
2.3.0

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


[PATCH 0/7] staging: comedi: cb_pcimdas: enhance driver

2015-02-25 Thread H Hartley Sweeten
Fix the analog input subdevice single-ended/differential channel
configuration and add support for the programmable ranges.

Define, and use, the register map to remove the "magic" numbers.

Provide a range table for the analog output subdevice.

Tidy up the (*auto_attach) and add subdevices for the main connector
digtial input/output pins as well as the 8254 timer.

PATCH 7/7 depends on:
  "[PATCH v2 00/36] staging: comedi: cleanup 8254 timer code"

H Hartley Sweeten (7):
  staging: comedi: cb_pcimdas: fix analog input channel configuration
  staging: comedi: cb_pcimdas: support analog input programmable ranges
  staging: comedi: cb_pcimdas: define the register map
  staging: comedi: cb_pcimdas: provide analog output range table
  staging: comedi: cb_pcimdas: tidy up cb_pcimdas_auto_attach()
  staging: comedi: cb_pcimdas: add main connector digital input/output
  staging: comedi: cb_pcimdas: add 8254 timer (pacer) support

 drivers/staging/comedi/drivers/cb_pcimdas.c | 367 ++--
 1 file changed, 288 insertions(+), 79 deletions(-)

-- 
2.3.0

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


[PATCH 5/7] staging: comedi: cb_pcimdas: tidy up cb_pcimdas_auto_attach()

2015-02-25 Thread H Hartley Sweeten
For aesthetics, add some whitespace to the subdevice init.

Remove the unnecessary comments as well as the initialization of the
analog input subdevice 'len_chanlist'. That member is only used by
subdevices that support async commands.

For aesthetics, rename the analog input subdevice (*insn_read) function.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c 
b/drivers/staging/comedi/drivers/cb_pcimdas.c
index 94da819..00ba404 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -175,9 +175,10 @@ static int cb_pcimdas_ai_eoc(struct comedi_device *dev,
return -EBUSY;
 }
 
-static int cb_pcimdas_ai_rinsn(struct comedi_device *dev,
-  struct comedi_subdevice *s,
-  struct comedi_insn *insn, unsigned int *data)
+static int cb_pcimdas_ai_insn_read(struct comedi_device *dev,
+  struct comedi_subdevice *s,
+  struct comedi_insn *insn,
+  unsigned int *data)
 {
struct cb_pcimdas_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec);
@@ -271,7 +272,7 @@ static bool cb_pcimdas_is_ai_uni(struct comedi_device *dev)
 }
 
 static int cb_pcimdas_auto_attach(struct comedi_device *dev,
-   unsigned long context_unused)
+ unsigned long context_unused)
 {
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
struct cb_pcimdas_private *devpriv;
@@ -294,10 +295,9 @@ static int cb_pcimdas_auto_attach(struct comedi_device 
*dev,
if (ret)
return ret;
 
+   /* Analog Input subdevice */
s = &dev->subdevices[0];
-   /* dev->read_subdev=s; */
-   /*  analog input subdevice */
-   s->type = COMEDI_SUBD_AI;
+   s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE;
if (cb_pcimdas_is_ai_se(dev)) {
s->subdev_flags |= SDF_GROUND;
@@ -306,28 +306,26 @@ static int cb_pcimdas_auto_attach(struct comedi_device 
*dev,
s->subdev_flags |= SDF_DIFF;
s->n_chan   = 8;
}
-   s->maxdata = 0x;
+   s->maxdata  = 0x;
s->range_table  = cb_pcimdas_is_ai_uni(dev) ? &cb_pcimdas_ai_uni_range
: &cb_pcimdas_ai_bip_range;
-   s->len_chanlist = 1;/*  This is the maximum chanlist length that */
-   /*  the board can handle */
-   s->insn_read = cb_pcimdas_ai_rinsn;
+   s->insn_read= cb_pcimdas_ai_insn_read;
 
+   /* Analog Output subdevice */
s = &dev->subdevices[1];
-   /*  analog output subdevice */
-   s->type = COMEDI_SUBD_AO;
-   s->subdev_flags = SDF_WRITABLE;
-   s->n_chan = 2;
-   s->maxdata = 0xfff;
-   s->range_table = &cb_pcimdas_ao_range;
-   s->insn_write = cb_pcimdas_ao_insn_write;
+   s->type = COMEDI_SUBD_AO;
+   s->subdev_flags = SDF_WRITABLE;
+   s->n_chan   = 2;
+   s->maxdata  = 0xfff;
+   s->range_table  = &cb_pcimdas_ao_range;
+   s->insn_write   = cb_pcimdas_ao_insn_write;
 
ret = comedi_alloc_subdev_readback(s);
if (ret)
return ret;
 
+   /* Digital I/O subdevice */
s = &dev->subdevices[2];
-   /* digital i/o subdevice */
ret = subdev_8255_init(dev, s, NULL, PCIMDAS_8255_BASE);
if (ret)
return ret;
-- 
2.3.0

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


[PATCH 7/7] staging: comedi: cb_pcimdas: add 8254 timer (pacer) support

2015-02-25 Thread H Hartley Sweeten
The hardware has an 8254 timer/counter. Channe; 0 is available as a
generic counter/timer with the clock, gate, and output signals all
availabe on the main 37 pin connector. Channels 1 and 2 are used for
the pacer.

Add support for the 8254 timer.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c 
b/drivers/staging/comedi/drivers/cb_pcimdas.c
index cef6872..acb7740 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -47,6 +47,7 @@
 
 #include "../comedidev.h"
 
+#include "comedi_8254.h"
 #include "plx9052.h"
 #include "8255.h"
 
@@ -273,6 +274,57 @@ static int cb_pcimdas_do_insn_write(struct comedi_device 
*dev,
return insn->n;
 }
 
+static int cb_pcimdas_counter_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
+{
+   struct cb_pcimdas_private *devpriv = dev->private;
+   unsigned int ctrl;
+
+   switch (data[0]) {
+   case INSN_CONFIG_SET_CLOCK_SRC:
+   switch (data[1]) {
+   case 0: /* internal 100 kHz clock */
+   ctrl = PCIMDAS_USER_CNTR_CTR1_CLK_SEL;
+   break;
+   case 1: /* external clk on pin 21 */
+   ctrl = 0;
+   break;
+   default:
+   return -EINVAL;
+   }
+   outb(ctrl, devpriv->BADR3 + PCIMDAS_USER_CNTR_REG);
+   break;
+   case INSN_CONFIG_GET_CLOCK_SRC:
+   ctrl = inb(devpriv->BADR3 + PCIMDAS_USER_CNTR_REG);
+   if (ctrl & PCIMDAS_USER_CNTR_CTR1_CLK_SEL) {
+   data[1] = 0;
+   data[2] = I8254_OSC_BASE_100KHZ;
+   } else {
+   data[1] = 1;
+   data[2] = 0;
+   }
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   return insn->n;
+}
+
+static unsigned int cb_pcimdas_pacer_clk(struct comedi_device *dev)
+{
+   struct cb_pcimdas_private *devpriv = dev->private;
+   unsigned int status;
+
+   /* The Pacer Clock jumper selects a 10 MHz or 1 MHz clock */
+   status = inb(devpriv->BADR3 + PCIMDAS_STATUS_REG);
+   if (status & PCIMDAS_STATUS_CLK)
+   return I8254_OSC_BASE_10MHZ;
+   return I8254_OSC_BASE_1MHZ;
+}
+
 static bool cb_pcimdas_is_ai_se(struct comedi_device *dev)
 {
struct cb_pcimdas_private *devpriv = dev->private;
@@ -321,7 +373,13 @@ static int cb_pcimdas_auto_attach(struct comedi_device 
*dev,
devpriv->BADR3 = pci_resource_start(pcidev, 3);
dev->iobase = pci_resource_start(pcidev, 4);
 
-   ret = comedi_alloc_subdevices(dev, 5);
+   dev->pacer = comedi_8254_init(devpriv->BADR3 + PCIMDAS_8254_BASE,
+ cb_pcimdas_pacer_clk(dev),
+ I8254_IO8, 0);
+   if (!dev->pacer)
+   return -ENOMEM;
+
+   ret = comedi_alloc_subdevices(dev, 6);
if (ret)
return ret;
 
@@ -378,6 +436,16 @@ static int cb_pcimdas_auto_attach(struct comedi_device 
*dev,
s->range_table  = &range_digital;
s->insn_write   = cb_pcimdas_do_insn_write;
 
+   /* Counter subdevice (8254) */
+   s = &dev->subdevices[5];
+   comedi_8254_subdevice_init(s, dev->pacer);
+
+   dev->pacer->insn_config = cb_pcimdas_counter_insn_config;
+
+   /* counters 1 and 2 are used internally for the pacer */
+   comedi_8254_set_busy(dev->pacer, 1, true);
+   comedi_8254_set_busy(dev->pacer, 2, true);
+
return 0;
 }
 
-- 
2.3.0

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


Re: [PATCH v4 11/20] power_supply: Change ownership from driver to core

2015-02-25 Thread Sebastian Reichel
Hi,

On Mon, Feb 23, 2015 at 12:47:32PM +0100, Krzysztof Kozlowski wrote:
> Change the ownership of power_supply structure from each driver
> implementing the class to the power supply core.
> 
> The patch changes power_supply_register() function thus all drivers
> implementing power supply class are adjusted.
> 
> Each driver provides the implementation of power supply. However it
> should not be the owner of power supply class instance because it is
> exposed by core to other subsystems with power_supply_get_by_name().
> These other subsystems have no knowledge when the driver will unregister
> the power supply. This leads to several issues when driver is unbound -
> mostly because user of power supply accesses freed memory.
> 
> Instead let the core own the instance of struct 'power_supply'.  Other
> users of this power supply will still access valid memory because it
> will be freed when device reference count reaches 0. Currently this
> means "it will leak" but power_supply_put() call in next patches will
> solve it.
> 
> This solves invalid memory references in following race condition
> scenario:
> 
> Thread 1: charger manager
> Thread 2: power supply driver, used by charger manager
> 
> THREAD 1 (charger manager) THREAD 2 (power supply driver)
> == ==
> psy = power_supply_get_by_name()
>Driver unbind, .remove
>  power_supply_unregister()
>  Device fully removed
> psy->get_property()
> 
> The 'get_property' call is executed in invalid context because the driver was
> unbound and struct 'power_supply' memory was freed.
> 
> This could be observed easily with charger manager driver (here compiled
> with max17040 fuel gauge):
> 
> $ cat /sys/devices/virtual/power_supply/cm-battery/capacity &
> $ echo "1-0036" > /sys/bus/i2c/drivers/max17040/unbind
> [   55.725123] Unable to handle kernel NULL pointer dereference at virtual 
> address 
> [   55.732584] pgd = d98d4000
> [   55.734060] [] *pgd=5afa2831, *pte=, *ppte=
> [   55.740318] Internal error: Oops: 8007 [#1] PREEMPT SMP ARM
> [   55.746210] Modules linked in:
> [   55.749259] CPU: 1 PID: 2936 Comm: cat Tainted: GW   
> 3.19.0-rc1-next-20141226-00048-gf79f475f3c44-dirty #1496
> [   55.760190] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
> [   55.766270] task: d9b76f00 ti: daf54000 task.ti: daf54000
> [   55.771647] PC is at 0x0
> [   55.774182] LR is at charger_get_property+0x2f4/0x36c
> [   55.779201] pc : [<>]lr : []psr: 6013
> [   55.779201] sp : daf55e90  ip : 0003  fp : 
> [   55.790657] r10:   r9 : c06e2878  r8 : d9b26c68
> [   55.795865] r7 : dad81610  r6 : daec7410  r5 : daf55ebc  r4 : 
> [   55.802367] r3 :   r2 : daf55ebc  r1 : 002a  r0 : d9b26c68
> [   55.808879] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment 
> user
> [   55.815994] Control: 10c5387d  Table: 598d406a  DAC: 0015
> [   55.821723] Process cat (pid: 2936, stack limit = 0xdaf54210)
> [   55.827451] Stack: (0xdaf55e90 to 0xdaf56000)
> [   55.831795] 5e80: 6013 c01459c4 
> 002a c06f8ef8
> [   55.839956] 5ea0: db651000 c06f8ef8 daebac00 c04cb668 daebac08 c0346864 
>  c01459c4
> [   55.848115] 5ec0: d99eaa80 c06f8ef8 0fff 1000 db651000 c027f25c 
> c027f240 d99eaa80
> [   55.856274] 5ee0: d9a06c00 c0146218 daf55f18 1000 d99eaa80 db4c18c0 
> 0001 0001
> [   55.864468] 5f00: daf55f80 c0144c78 c0144c54 c0107f90 00015000 d99eaab0 
>  
> [   55.872603] 5f20: 51c7  db4c18c0 c04a9370 00015000 1000 
> daf55f80 1000
> [   55.880763] 5f40: daf54000 00015000  c00e53dc db4c18c0 c00e548c 
> 000d 8124
> [   55.888937] 5f60: 0001   db4c18c0 db4c18c0 1000 
> 00015000 c00e5550
> [   55.897099] 5f80:   1000 1000 00015000 0003 
> 0003 c000f364
> [   55.905239] 5fa0:  c000f1a0 1000 00015000 0003 00015000 
> 1000 0001333c
> [   55.913399] 5fc0: 1000 00015000 0003 0003 0002  
>  
> [   55.921560] 5fe0: 7fffe000 be999850 a225 b6f3c19c 6010 0003 
>  
> [   55.929744] [] (charger_get_property) from [] 
> (power_supply_show_property+0x48/0x20c)
> [   55.939286] [] (power_supply_show_property) from [] 
> (dev_attr_show+0x1c/0x48)
> [   55.948130] [] (dev_attr_show) from [] 
> (sysfs_kf_seq_show+0x84/0x104)
> [   55.956298] [] (sysfs_kf_seq_show) from [] 
> (kernfs_seq_show+0x24/0x28)
> [   55.964536] [] (kernfs_seq_show) from [] 
> (seq_read+0x1b0/0x484)
> [   55.972172] [] (seq_read) from [] 
> (__vfs_read+0x18/0x4c)
> [   55.979188] [] (__vfs_read) from [] 
> (vfs_read+0x7c/0x100)
> [   55.986304] [] (vfs_read) from [] (SyS_read+0x40/0x8

Re: [PATCH v4 11/20] power_supply: Change ownership from driver to core

2015-02-25 Thread Darren Hart
On Thu, Feb 26, 2015 at 01:45:22AM +0100, Sebastian Reichel wrote:
> Hi,
> 
> On Mon, Feb 23, 2015 at 12:47:32PM +0100, Krzysztof Kozlowski wrote:
> > Change the ownership of power_supply structure from each driver
> > implementing the class to the power supply core.
> > 
> > The patch changes power_supply_register() function thus all drivers
> > implementing power supply class are adjusted.
> > 
> > Each driver provides the implementation of power supply. However it
> > should not be the owner of power supply class instance because it is
> > exposed by core to other subsystems with power_supply_get_by_name().
> > These other subsystems have no knowledge when the driver will unregister
> > the power supply. This leads to several issues when driver is unbound -
> > mostly because user of power supply accesses freed memory.
> > 
> > Instead let the core own the instance of struct 'power_supply'.  Other
> > users of this power supply will still access valid memory because it
> > will be freed when device reference count reaches 0. Currently this
> > means "it will leak" but power_supply_put() call in next patches will
> > solve it.
> > 
> > This solves invalid memory references in following race condition
> > scenario:
> > 
> > Thread 1: charger manager
> > Thread 2: power supply driver, used by charger manager
> > 
> > THREAD 1 (charger manager) THREAD 2 (power supply driver)
> > == ==
> > psy = power_supply_get_by_name()
> >Driver unbind, .remove
> >  power_supply_unregister()
> >  Device fully removed
> > psy->get_property()
> > 
> > The 'get_property' call is executed in invalid context because the driver 
> > was
> > unbound and struct 'power_supply' memory was freed.
> > 
> > This could be observed easily with charger manager driver (here compiled
> > with max17040 fuel gauge):
> > 
> > $ cat /sys/devices/virtual/power_supply/cm-battery/capacity &
> > $ echo "1-0036" > /sys/bus/i2c/drivers/max17040/unbind
> > [   55.725123] Unable to handle kernel NULL pointer dereference at virtual 
> > address 
> > [   55.732584] pgd = d98d4000
> > [   55.734060] [] *pgd=5afa2831, *pte=, *ppte=
> > [   55.740318] Internal error: Oops: 8007 [#1] PREEMPT SMP ARM
> > [   55.746210] Modules linked in:
> > [   55.749259] CPU: 1 PID: 2936 Comm: cat Tainted: GW   
> > 3.19.0-rc1-next-20141226-00048-gf79f475f3c44-dirty #1496
> > [   55.760190] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
> > [   55.766270] task: d9b76f00 ti: daf54000 task.ti: daf54000
> > [   55.771647] PC is at 0x0
> > [   55.774182] LR is at charger_get_property+0x2f4/0x36c
> > [   55.779201] pc : [<>]lr : []psr: 6013
> > [   55.779201] sp : daf55e90  ip : 0003  fp : 
> > [   55.790657] r10:   r9 : c06e2878  r8 : d9b26c68
> > [   55.795865] r7 : dad81610  r6 : daec7410  r5 : daf55ebc  r4 : 
> > [   55.802367] r3 :   r2 : daf55ebc  r1 : 002a  r0 : d9b26c68
> > [   55.808879] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment 
> > user
> > [   55.815994] Control: 10c5387d  Table: 598d406a  DAC: 0015
> > [   55.821723] Process cat (pid: 2936, stack limit = 0xdaf54210)
> > [   55.827451] Stack: (0xdaf55e90 to 0xdaf56000)
> > [   55.831795] 5e80: 6013 c01459c4 
> > 002a c06f8ef8
> > [   55.839956] 5ea0: db651000 c06f8ef8 daebac00 c04cb668 daebac08 c0346864 
> >  c01459c4
> > [   55.848115] 5ec0: d99eaa80 c06f8ef8 0fff 1000 db651000 c027f25c 
> > c027f240 d99eaa80
> > [   55.856274] 5ee0: d9a06c00 c0146218 daf55f18 1000 d99eaa80 db4c18c0 
> > 0001 0001
> > [   55.864468] 5f00: daf55f80 c0144c78 c0144c54 c0107f90 00015000 d99eaab0 
> >  
> > [   55.872603] 5f20: 51c7  db4c18c0 c04a9370 00015000 1000 
> > daf55f80 1000
> > [   55.880763] 5f40: daf54000 00015000  c00e53dc db4c18c0 c00e548c 
> > 000d 8124
> > [   55.888937] 5f60: 0001   db4c18c0 db4c18c0 1000 
> > 00015000 c00e5550
> > [   55.897099] 5f80:   1000 1000 00015000 0003 
> > 0003 c000f364
> > [   55.905239] 5fa0:  c000f1a0 1000 00015000 0003 00015000 
> > 1000 0001333c
> > [   55.913399] 5fc0: 1000 00015000 0003 0003 0002  
> >  
> > [   55.921560] 5fe0: 7fffe000 be999850 a225 b6f3c19c 6010 0003 
> >  
> > [   55.929744] [] (charger_get_property) from [] 
> > (power_supply_show_property+0x48/0x20c)
> > [   55.939286] [] (power_supply_show_property) from [] 
> > (dev_attr_show+0x1c/0x48)
> > [   55.948130] [] (dev_attr_show) from [] 
> > (sysfs_kf_seq_show+0x84/0x104)
> > [   55.956298] [] (sysfs_kf_seq_show) from [] 
> > (kernfs_seq_show+0x2

[PATCH] Implement Hyper-V netvsc_get_channels() ethool op

2015-02-25 Thread Andrew Schwartzmeyer
This adds support for reporting the combined channels count of the
hv_netvsc driver via 'ethtool --show-channels'.

Signed-off-by: Andrew Schwartzmeyer 
---
 drivers/net/hyperv/netvsc_drv.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 15d82eda0baf..7106e3f88bde 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -687,6 +687,27 @@ static void netvsc_get_drvinfo(struct net_device *net,
strlcpy(info->fw_version, "N/A", sizeof(info->fw_version));
 }
 
+static int netvsc_get_channels_combined_count(struct net_device *net)
+{
+   struct net_device_context *net_device_ctx = netdev_priv(net);
+   struct hv_device *dev = net_device_ctx->device_ctx;
+   struct netvsc_device *nvdev = hv_get_drvdata(dev);
+
+   if (!nvdev)
+   return 0;
+   return nvdev->num_chn;
+}
+
+static void netvsc_get_channels(struct net_device *net,
+   struct ethtool_channels *channel)
+{
+   int ret;
+
+   ret = netvsc_get_channels_combined_count(net);
+   if (ret > 0)
+   channel->combined_count = ret;
+}
+
 static int netvsc_change_mtu(struct net_device *ndev, int mtu)
 {
struct net_device_context *ndevctx = netdev_priv(ndev);
@@ -760,6 +781,7 @@ static void netvsc_poll_controller(struct net_device *net)
 static const struct ethtool_ops ethtool_ops = {
.get_drvinfo= netvsc_get_drvinfo,
.get_link   = ethtool_op_get_link,
+   .get_channels   = netvsc_get_channels,
 };
 
 static const struct net_device_ops device_ops = {
-- 
2.3.0

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