Re: [PATCH] Allow automatic kernel taint on unsigned module load to be disabled

2017-08-06 Thread Rusty Russell
Matthew Garrett  writes:
> Distributions may wish to provide kernels that permit loading of
> unsigned modules based on certain policy decisions.

Sorry, that's way too vague to accept this patch.

So I'm guessing a binary module is behind this vagueness.  If you want
some other method than signing to vet modules, please do it in
userspace.  You can do arbitrary things that way...

Cheers,
Rusty.

> Right now that
> results in the kernel being tainted whenever an unsigned module is
> loaded, which may not be desirable. Add a config option to disable that.
>
> Signed-off-by: Matthew Garrett 
> ---
>  init/Kconfig| 13 -
>  kernel/module.c |  2 ++
>  2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/init/Kconfig b/init/Kconfig
> index 8514b25db21c..196860c5d1e5 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -1749,12 +1749,23 @@ config MODULE_SIG
> debuginfo strip done by some packagers (such as rpmbuild) and
> inclusion into an initramfs that wants the module size reduced.
>  
> +config MODULE_UNSIGNED_TAINT
> + bool "Taint the kernel if unsigned modules are loaded"
> + default y
> + depends on MODULE_SIG
> + help
> +   Taint the kernel if an unsigned kernel module is loaded. If this
> +   option is enabled, the kernel will be tainted on an attempt to load
> +   an unsigned module or signed modules for which we don't have a key
> +   even if signature enforcement is disabled.
> +
>  config MODULE_SIG_FORCE
>   bool "Require modules to be validly signed"
>   depends on MODULE_SIG
>   help
> Reject unsigned modules or signed modules for which we don't have a
> -   key.  Without this, such modules will simply taint the kernel.
> +   key. Without this, such modules will be loaded successfully but will
> +   (if MODULE_UNSIGNED_TAINT is set) taint the kernel.
>  
>  config MODULE_SIG_ALL
>   bool "Automatically sign all modules"
> diff --git a/kernel/module.c b/kernel/module.c
> index 40f983cbea81..71f80c8816f2 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -3660,12 +3660,14 @@ static int load_module(struct load_info *info, const 
> char __user *uargs,
>  
>  #ifdef CONFIG_MODULE_SIG
>   mod->sig_ok = info->sig_ok;
> +#ifdef CONFIG_MODULE_UNSIGNED_TAINT
>   if (!mod->sig_ok) {
>   pr_notice_once("%s: module verification failed: signature "
>  "and/or required key missing - tainting "
>  "kernel\n", mod->name);
>   add_taint_module(mod, TAINT_UNSIGNED_MODULE, LOCKDEP_STILL_OK);
>   }
> +#endif
>  #endif
>  
>   /* To avoid stressing percpu allocator, do this once we're unique. */
> -- 
> 2.14.0.rc1.383.gd1ce394fe2-goog


[PATCH 0/2] constify usb_device_id.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Arvind Yadav (2):
  [PATCH 1/2] video: fbdev: smscufx: constify usb_device_id.
  [PATCH 2/2] video: fbdev: udlfb: constify usb_device_id.

 drivers/video/fbdev/smscufx.c | 2 +-
 drivers/video/fbdev/udlfb.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
2.7.4



[PATCH 2/2] video: fbdev: udlfb: constify usb_device_id.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/video/fbdev/udlfb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
index 05ef657..d836e6e 100644
--- a/drivers/video/fbdev/udlfb.c
+++ b/drivers/video/fbdev/udlfb.c
@@ -54,7 +54,7 @@ static const u32 udlfb_info_flags = FBINFO_DEFAULT | 
FBINFO_READS_FAST |
  * which is compatible with all known USB 2.0 era graphics chips and firmware,
  * but allows DisplayLink to increment those for any future incompatible chips
  */
-static struct usb_device_id id_table[] = {
+static const struct usb_device_id id_table[] = {
{.idVendor = 0x17e9,
 .bInterfaceClass = 0xff,
 .bInterfaceSubClass = 0x00,
-- 
2.7.4



[PATCH 1/2] video: fbdev: smscufx: constify usb_device_id.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/video/fbdev/smscufx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 449fcea..2275e80 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -122,7 +122,7 @@ static const u32 smscufx_info_flags = FBINFO_DEFAULT | 
FBINFO_READS_FAST |
FBINFO_VIRTFB | FBINFO_HWACCEL_IMAGEBLIT | FBINFO_HWACCEL_FILLRECT |
FBINFO_HWACCEL_COPYAREA | FBINFO_MISC_ALWAYS_SETPAR;
 
-static struct usb_device_id id_table[] = {
+static const struct usb_device_id id_table[] = {
{USB_DEVICE(0x0424, 0x9d00),},
{USB_DEVICE(0x0424, 0x9d01),},
{},
-- 
2.7.4



[PATCH 1/8] Input: iforce: constify usb_device_id and fix space before '[' error:

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Fix checkpatch.pl error:
ERROR: space prohibited before open square bracket '['.

Signed-off-by: Arvind Yadav 
---
 drivers/input/joystick/iforce/iforce-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/joystick/iforce/iforce-usb.c 
b/drivers/input/joystick/iforce/iforce-usb.c
index db64adf..db5cc35 100644
--- a/drivers/input/joystick/iforce/iforce-usb.c
+++ b/drivers/input/joystick/iforce/iforce-usb.c
@@ -209,7 +209,7 @@ static void iforce_usb_disconnect(struct usb_interface 
*intf)
kfree(iforce);
 }
 
-static struct usb_device_id iforce_usb_ids [] = {
+static const struct usb_device_id iforce_usb_ids[] = {
{ USB_DEVICE(0x044f, 0xa01c) }, /* Thrustmaster Motor Sport GT 
*/
{ USB_DEVICE(0x046d, 0xc281) }, /* Logitech WingMan Force */
{ USB_DEVICE(0x046d, 0xc291) }, /* Logitech WingMan Formula 
Force */
-- 
2.7.4



[PATCH] media: ddbridge: make ddb_info const

2017-08-06 Thread Bhumika Goyal
Make ddb_info structures const as they are only used during a copy
operation.

Signed-off-by: Bhumika Goyal 
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index ec41804..7505e1e 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -2302,7 +2302,7 @@ static int ddb_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
 
 /*** MaxA8 adapters 
***/
 
-static struct ddb_info ddb_ct2_8 = {
+static const struct ddb_info ddb_ct2_8 = {
.type = DDB_OCTOPUS_MAX_CT,
.name = "Digital Devices MAX A8 CT2",
.port_num = 4,
@@ -2311,7 +2311,7 @@ static int ddb_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
.ts_quirks = TS_QUIRK_SERIAL,
 };
 
-static struct ddb_info ddb_c2t2_8 = {
+static const struct ddb_info ddb_c2t2_8 = {
.type = DDB_OCTOPUS_MAX_CT,
.name = "Digital Devices MAX A8 C2T2",
.port_num = 4,
@@ -2320,7 +2320,7 @@ static int ddb_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
.ts_quirks = TS_QUIRK_SERIAL,
 };
 
-static struct ddb_info ddb_isdbt_8 = {
+static const struct ddb_info ddb_isdbt_8 = {
.type = DDB_OCTOPUS_MAX_CT,
.name = "Digital Devices MAX A8 ISDBT",
.port_num = 4,
@@ -2329,7 +2329,7 @@ static int ddb_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
.ts_quirks = TS_QUIRK_SERIAL,
 };
 
-static struct ddb_info ddb_c2t2i_v0_8 = {
+static const struct ddb_info ddb_c2t2i_v0_8 = {
.type = DDB_OCTOPUS_MAX_CT,
.name = "Digital Devices MAX A8 C2T2I V0",
.port_num = 4,
@@ -2338,7 +2338,7 @@ static int ddb_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
.ts_quirks = TS_QUIRK_SERIAL | TS_QUIRK_ALT_OSC,
 };
 
-static struct ddb_info ddb_c2t2i_8 = {
+static const struct ddb_info ddb_c2t2i_8 = {
.type = DDB_OCTOPUS_MAX_CT,
.name = "Digital Devices MAX A8 C2T2I",
.port_num = 4,
-- 
1.9.1



[PATCH] ATM-lanai: Delete an error message for a failed memory allocation in lanai_init_one()

2017-08-06 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 6 Aug 2017 09:42:52 +0200

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

This issue was detected by using the Coccinelle software.

Link: 
http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring 
---
 drivers/atm/lanai.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index 2351dad78ff5..f4cb6c5870bf 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -2562,11 +2562,8 @@ static int lanai_init_one(struct pci_dev *pci,
int result;
 
lanai = kmalloc(sizeof(*lanai), GFP_KERNEL);
-   if (lanai == NULL) {
-   printk(KERN_ERR DEV_LABEL
-  ": couldn't allocate dev_data structure!\n");
+   if (!lanai)
return -ENOMEM;
-   }
 
atmdev = atm_dev_register(DEV_LABEL, >dev, , -1, NULL);
if (atmdev == NULL) {
-- 
2.13.4



[PATCH] drm/amd/powerplay: fix semicolon.cocci warnings

2017-08-06 Thread kbuild test robot
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/vega10_hwmgr.c:2273:61-62: 
Unneeded semicolon


 Remove unneeded semicolon.

Generated by: scripts/coccinelle/misc/semicolon.cocci

Fixes: bdb8cd10b99d ("drm/amd/powerplay: enable ACG feature on vega10.")
CC: Rex Zhu 
Signed-off-by: Fengguang Wu 
---

 vega10_hwmgr.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/vega10_hwmgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/vega10_hwmgr.c
@@ -2270,7 +2270,7 @@ static int vega10_acg_enable(struct pp_h
smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_InitializeAcg);
 
smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_RunAcgBtc);
-   vega10_read_arg_from_smc(hwmgr->smumgr, _btc_response);;
+   vega10_read_arg_from_smc(hwmgr->smumgr, _btc_response);
 
if (1 == agc_btc_response) {
if (1 == data->acg_loop_state)


[PATCH 1/3] ATM-iphase: Adjust 11 function calls together with a variable assignment

2017-08-06 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 5 Aug 2017 21:39:06 +0200

The script "checkpatch.pl" pointed information out like the following.

ERROR: do not use assignment in if condition

Thus fix affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/atm/iphase.c | 57 +++-
 1 file changed, 34 insertions(+), 23 deletions(-)

diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index fc72b763fdd7..472762f70921 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -152,7 +152,8 @@ static void ia_hack_tcq(IADEV *dev) {
 *(u_short *) (dev->seg_ram + dev->host_tcq_wr) = 0;
  } 
  else if (dev->desc_tbl[desc1 -1].timestamp) {
-if (!(iavcc_r = dev->desc_tbl[desc1 -1].iavcc)) { 
+   iavcc_r = dev->desc_tbl[desc1 - 1].iavcc;
+   if (!iavcc_r) {
printk("IA: Fatal err in get_desc\n");
continue;
 }
@@ -617,7 +618,8 @@ static int ia_que_tx (IADEV *iadev) {
num_desc = ia_avail_descs(iadev);
 
while (num_desc && (skb = skb_dequeue(>tx_backlog))) {
-  if (!(vcc = ATM_SKB(skb)->vcc)) {
+   vcc = ATM_SKB(skb)->vcc;
+   if (!vcc) {
  dev_kfree_skb_any(skb);
  printk("ia_que_tx: Null vcc\n");
  break;
@@ -1172,8 +1174,9 @@ static int rx_pkt(struct atm_dev *dev)
atomic_inc(>stats->rx_err);
   goto out_free_desc;
 }
- 
-if (!(skb = atm_alloc_charge(vcc, len, GFP_ATOMIC))) {
+
+   skb = atm_alloc_charge(vcc, len, GFP_ATOMIC);
+   if (!skb) {
if (vcc->vci < 32)
   printk("Drop control packets\n");
   goto out_free_desc;
@@ -1296,7 +1299,8 @@ static void rx_dle_intr(struct atm_dev *dev)
   desc = ATM_DESC(skb);
   free_desc(dev, desc);  

-  if (!(len = skb->len))
+   len = skb->len;
+   if (!len)
   {  
   printk("rx_dle_intr: skb len 0\n");  
  dev_kfree_skb_any(skb);  
@@ -1882,9 +1886,9 @@ static int open_tx(struct atm_vcc *vcc)
 }
 vc->type = CBR;
 vc->status = CRC_APPEND;
-if ((ret = ia_cbr_setup (iadev, vcc)) < 0) { 
-return ret;
-}
+   ret = ia_cbr_setup(iadev, vcc);
+   if (ret < 0)
+   return ret;
} else {
printk("iadev:  Non UBR, ABR and CBR traffic not supported\n");
}
@@ -2293,15 +2297,19 @@ static int reset_sar(struct atm_dev *dev)
unsigned int pci[64];  
  
iadev = INPH_IA_DEV(dev);  
-   for(i=0; i<64; i++)  
- if ((error = pci_read_config_dword(iadev->pci,  
-   i*4, [i])) != PCIBIOS_SUCCESSFUL)  
- return error;  
+   for (i = 0; i < 64; i++) {
+   error = pci_read_config_dword(iadev->pci, i * 4, [i]);
+   if (error != PCIBIOS_SUCCESSFUL)
+   return error;
+   }
+
writel(0, iadev->reg+IPHASE5575_EXT_RESET);  
-   for(i=0; i<64; i++)  
- if ((error = pci_write_config_dword(iadev->pci,  
-   i*4, pci[i])) != PCIBIOS_SUCCESSFUL)  
-   return error;  
+   for (i = 0; i < 64; i++) {
+   error = pci_write_config_dword(iadev->pci, i * 4, pci[i]);
+   if (error != PCIBIOS_SUCCESSFUL)
+   return error;
+   }
+
udelay(5);  
return 0;  
 }  
@@ -2516,9 +2524,10 @@ static int ia_start(struct atm_dev *dev)
 }  
 /* @@@ should release IRQ on error */  
/* enabling memory + master */  
-if ((error = pci_write_config_word(iadev->pci,   
-   PCI_COMMAND,   
-   PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER )))   
+   error = pci_write_config_word(iadev->pci,
+ PCI_COMMAND,
+ PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
+   if (error)
{  
 printk(KERN_ERR DEV_LABEL "(itf %d): can't enable memory+"  
 "master (0x%x)\n",dev->number, error);  
@@ -2569,7 +2578,8 @@ static int ia_start(struct atm_dev *dev)
readl(iadev->reg+IPHASE5575_BUS_CONTROL_REG));) 
 
 phy = 0; /* resolve compiler complaint */
 IF_INIT ( 
-   if ((phy=ia_phy_get(dev,0)) == 0x30)  
+   phy = ia_phy_get(dev, 0);
+   if (phy == 0x30)
printk("IA: pm5346,rev.%d\n",phy&0x0f);  
else  
printk("IA: utopia,rev.%0x\n",phy);) 
@@ -2710,15 +2720,16 @@ static int ia_open(struct atm_vcc *vcc)
ia_vcc = kmalloc(sizeof(*ia_vcc), GFP_KERNEL);  
if (!ia_vcc) return -ENOMEM;  
 

[PATCH 2/3] ATM-iphase: Delete five error messages for a failed memory allocation

2017-08-06 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 5 Aug 2017 22:10:41 +0200

Omit extra messages for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Link: 
http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring 
---
 drivers/atm/iphase.c | 30 +++---
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index 472762f70921..ad4c1b41ba98 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -1623,11 +1623,8 @@ static int rx_init(struct atm_dev *dev)
iadev->rx_free_desc_qhead = NULL;   
 
iadev->rx_open = kzalloc(4 * iadev->num_vc, GFP_KERNEL);
-   if (!iadev->rx_open) {
-   printk(KERN_ERR DEV_LABEL "itf %d couldn't get free page\n",
-   dev->number);  
+   if (!iadev->rx_open)
goto err_free_dle;
-   }  
 
 iadev->rxing = 1;
 iadev->rx_pkt_cnt = 0;
@@ -1982,19 +1979,17 @@ static int tx_init(struct atm_dev *dev)
iadev->tx_buf = kmalloc_array(iadev->num_tx_desc,
  sizeof(*iadev->tx_buf),
  GFP_KERNEL);
-if (!iadev->tx_buf) {
-printk(KERN_ERR DEV_LABEL " couldn't get mem\n");
-   goto err_free_dle;
-}
+   if (!iadev->tx_buf)
+   goto err_free_dle;
+
for (i= 0; i< iadev->num_tx_desc; i++)
{
struct cpcs_trailer *cpcs;
  
cpcs = kmalloc(sizeof(*cpcs), GFP_KERNEL|GFP_DMA);
-if(!cpcs) {
-   printk(KERN_ERR DEV_LABEL " couldn't get freepage\n"); 
-   goto err_free_tx_bufs;
-}
+   if (!cpcs)
+   goto err_free_tx_bufs;
+
iadev->tx_buf[i].cpcs = cpcs;
iadev->tx_buf[i].dma_addr = dma_map_single(>pci->dev,
   cpcs,
@@ -2004,10 +1999,8 @@ static int tx_init(struct atm_dev *dev)
iadev->desc_tbl = kmalloc_array(iadev->num_tx_desc,
sizeof(*iadev->desc_tbl),
GFP_KERNEL);
-   if (!iadev->desc_tbl) {
-   printk(KERN_ERR DEV_LABEL " couldn't get mem\n");
+   if (!iadev->desc_tbl)
goto err_free_all_tx_bufs;
-   }
   
/* Communication Queues base address */  
 i = TX_COMP_Q * iadev->memSize;
@@ -2134,10 +2127,9 @@ static int tx_init(struct atm_dev *dev)
iadev->testTable = kmalloc_array(iadev->num_vc,
 sizeof(*iadev->testTable),
 GFP_KERNEL);
-if (!iadev->testTable) {
-   printk("Get freepage  failed\n");
-  goto err_free_desc_tbl;
-}
+   if (!iadev->testTable)
+   goto err_free_desc_tbl;
+
for(i=0; inum_vc; i++)  
{  
memset((caddr_t)vc, 0, sizeof(*vc));  
-- 
2.13.4



[PATCH 2/7] ALSA: bcd2000: constify usb_device_id.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 sound/usb/bcd2000/bcd2000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/usb/bcd2000/bcd2000.c b/sound/usb/bcd2000/bcd2000.c
index 2ff9d57..7371e5b 100644
--- a/sound/usb/bcd2000/bcd2000.c
+++ b/sound/usb/bcd2000/bcd2000.c
@@ -29,7 +29,7 @@
 #define PREFIX "snd-bcd2000: "
 #define BUFSIZE 64
 
-static struct usb_device_id id_table[] = {
+static const struct usb_device_id id_table[] = {
{ USB_DEVICE(0x1397, 0x00bd) },
{ },
 };
-- 
2.7.4



[PATCH 6/7] ALSA: us122l: constify usb_device_id.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 sound/usb/usx2y/us122l.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index a33e31b2..b49d6e9 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -736,7 +736,7 @@ static int snd_us122l_resume(struct usb_interface *intf)
return err;
 }
 
-static struct usb_device_id snd_us122l_usb_id_table[] = {
+static const struct usb_device_id snd_us122l_usb_id_table[] = {
{
.match_flags =  USB_DEVICE_ID_MATCH_DEVICE,
.idVendor = 0x0644,
-- 
2.7.4



[PATCH] can: c_can_pci: make c_can_pci_data const

2017-08-06 Thread Bhumika Goyal
Make c_can_pci_data structures const as they are only used during
a copy operation.

Signed-off-by: Bhumika Goyal 
---
 drivers/net/can/c_can/c_can_pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/c_can/c_can_pci.c 
b/drivers/net/can/c_can/c_can_pci.c
index cf7c189..70f5659 100644
--- a/drivers/net/can/c_can/c_can_pci.c
+++ b/drivers/net/can/c_can/c_can_pci.c
@@ -252,14 +252,14 @@ static void c_can_pci_remove(struct pci_dev *pdev)
pci_disable_device(pdev);
 }
 
-static struct c_can_pci_data c_can_sta2x11= {
+static const struct c_can_pci_data c_can_sta2x11= {
.type = BOSCH_C_CAN,
.reg_align = C_CAN_REG_ALIGN_32,
.freq = 5200, /* 52 Mhz */
.bar = 0,
 };
 
-static struct c_can_pci_data c_can_pch = {
+static const struct c_can_pci_data c_can_pch = {
.type = BOSCH_C_CAN,
.reg_align = C_CAN_REG_32,
.freq = 5000, /* 50 MHz */
-- 
1.9.1



[PATCH 1/7] ALSA: 6fire: constify usb_device_id.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 sound/usb/6fire/chip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/usb/6fire/chip.c b/sound/usb/6fire/chip.c
index dcddfc3..bc2a24f 100644
--- a/sound/usb/6fire/chip.c
+++ b/sound/usb/6fire/chip.c
@@ -198,7 +198,7 @@ static void usb6fire_chip_disconnect(struct usb_interface 
*intf)
}
 }
 
-static struct usb_device_id device_table[] = {
+static const struct usb_device_id device_table[] = {
{
.match_flags = USB_DEVICE_ID_MATCH_DEVICE,
.idVendor = 0x0ccd,
-- 
2.7.4



[PATCH 2/8] Input: xpad: constify usb_device_id.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/input/joystick/xpad.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 298a6ba..2578a76 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -408,7 +408,7 @@ static const signed short xpad_abs_triggers[] = {
 #define XPAD_XBOXONE_VENDOR(vend) \
{ XPAD_XBOXONE_VENDOR_PROTOCOL(vend, 208) }
 
-static struct usb_device_id xpad_table[] = {
+static const struct usb_device_id xpad_table[] = {
{ USB_INTERFACE_INFO('X', 'B', 0) },/* X-Box USB-IF not approved 
class */
XPAD_XBOX360_VENDOR(0x044f),/* Thrustmaster X-Box 360 
controllers */
XPAD_XBOX360_VENDOR(0x045e),/* Microsoft X-Box 360 
controllers */
-- 
2.7.4



[PATCH 5/8] Input: appletouch: constify usb_device_id.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/input/mouse/appletouch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c
index ef234c9..81a695d 100644
--- a/drivers/input/mouse/appletouch.c
+++ b/drivers/input/mouse/appletouch.c
@@ -125,7 +125,7 @@ static const struct atp_info geyser4_info = {
  *  According to Info.plist Geyser IV is the same as Geyser III.)
  */
 
-static struct usb_device_id atp_table[] = {
+static const struct usb_device_id atp_table[] = {
/* PowerBooks Feb 2005, iBooks G4 */
ATP_DEVICE(0x020e, fountain_info),  /* FOUNTAIN ANSI */
ATP_DEVICE(0x020f, fountain_info),  /* FOUNTAIN ISO */
-- 
2.7.4



[PATCH 6/8] Input: synaptics_usb: constify usb_device_id.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/input/mouse/synaptics_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/mouse/synaptics_usb.c 
b/drivers/input/mouse/synaptics_usb.c
index 6bcc018..cb7d15d 100644
--- a/drivers/input/mouse/synaptics_usb.c
+++ b/drivers/input/mouse/synaptics_usb.c
@@ -525,7 +525,7 @@ static int synusb_reset_resume(struct usb_interface *intf)
return synusb_resume(intf);
 }
 
-static struct usb_device_id synusb_idtable[] = {
+static const struct usb_device_id synusb_idtable[] = {
{ USB_DEVICE_SYNAPTICS(TP, SYNUSB_TOUCHPAD) },
{ USB_DEVICE_SYNAPTICS(INT_TP, SYNUSB_TOUCHPAD) },
{ USB_DEVICE_SYNAPTICS(CPAD,
-- 
2.7.4



[PATCH 8/8] Input: kbtab: constify usb_device_id.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/input/tablet/kbtab.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/tablet/kbtab.c b/drivers/input/tablet/kbtab.c
index 4d9d649..a41c3ff 100644
--- a/drivers/input/tablet/kbtab.c
+++ b/drivers/input/tablet/kbtab.c
@@ -88,7 +88,7 @@ static void kbtab_irq(struct urb *urb)
__func__, retval);
 }
 
-static struct usb_device_id kbtab_ids[] = {
+static const struct usb_device_id kbtab_ids[] = {
{ USB_DEVICE(USB_VENDOR_ID_KBGEAR, 0x1001), .driver_info = 0 },
{ }
 };
-- 
2.7.4



[PATCH 4/8] Input: powermate: constify usb_device_id and fix space before '[' error.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Fix checkpatch.pl error:
ERROR: space prohibited before open square bracket '['.

Signed-off-by: Arvind Yadav 
---
 drivers/input/misc/powermate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/misc/powermate.c b/drivers/input/misc/powermate.c
index 84909a1..056091b 100644
--- a/drivers/input/misc/powermate.c
+++ b/drivers/input/misc/powermate.c
@@ -432,7 +432,7 @@ static void powermate_disconnect(struct usb_interface *intf)
}
 }
 
-static struct usb_device_id powermate_devices [] = {
+static const struct usb_device_id powermate_devices[] = {
{ USB_DEVICE(POWERMATE_VENDOR, POWERMATE_PRODUCT_NEW) },
{ USB_DEVICE(POWERMATE_VENDOR, POWERMATE_PRODUCT_OLD) },
{ USB_DEVICE(CONTOUR_VENDOR, CONTOUR_JOG) },
-- 
2.7.4



[PATCH 7/8] Input: acecad: constify usb_device_idi and fix space before '[' error.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Fix checkpatch.pl error:
ERROR: space prohibited before open square bracket '['.

Signed-off-by: Arvind Yadav 
---
 drivers/input/tablet/acecad.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/tablet/acecad.c b/drivers/input/tablet/acecad.c
index e86e377..77f41a5 100644
--- a/drivers/input/tablet/acecad.c
+++ b/drivers/input/tablet/acecad.c
@@ -260,7 +260,7 @@ static void usb_acecad_disconnect(struct usb_interface 
*intf)
kfree(acecad);
 }
 
-static struct usb_device_id usb_acecad_id_table [] = {
+static const struct usb_device_id usb_acecad_id_table[] = {
{ USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_FLAIR), .driver_info = 
0 },
{ USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_302),   .driver_info = 
1 },
{ }
-- 
2.7.4



[PATCH 3/8] Input: keyspan_remote: constify usb_device_id.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/input/misc/keyspan_remote.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/misc/keyspan_remote.c 
b/drivers/input/misc/keyspan_remote.c
index a3fe4a9..77c47d6 100644
--- a/drivers/input/misc/keyspan_remote.c
+++ b/drivers/input/misc/keyspan_remote.c
@@ -85,7 +85,7 @@ static const unsigned short keyspan_key_table[] = {
 };
 
 /* table of devices that work with this driver */
-static struct usb_device_id keyspan_table[] = {
+static const struct usb_device_id keyspan_table[] = {
{ USB_DEVICE(USB_KEYSPAN_VENDOR_ID, USB_KEYSPAN_PRODUCT_UIA11) },
{ } /* Terminating entry */
 };
-- 
2.7.4



[PATCH 0/8] constify input usb_device_id.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Fix checkpatch.pl error in patch 1,3 and 7:
ERROR: space prohibited before open square bracket '['.

Arvind Yadav (8):
  [PATCH 1/8] Input: iforce: constify usb_device_id and fix space before '[' 
error.
  [PATCH 2/8] Input: xpad: constify usb_device_id.
  [PATCH 3/8] Input: keyspan_remote: constify usb_device_id.
  [PATCH 4/8] Input: powermate: constify usb_device_id and fix space before '[' 
error.
  [PATCH 5/8] Input: appletouch: constify usb_device_id.
  [PATCH 6/8] Input: synaptics_usb: constify usb_device_id.
  [PATCH 7/8] Input: acecad: constify usb_device_id and fix space before '[' 
error.
  [PATCH 8/8] Input: kbtab: constify usb_device_id.

 drivers/input/joystick/iforce/iforce-usb.c | 2 +-
 drivers/input/joystick/xpad.c  | 2 +-
 drivers/input/misc/keyspan_remote.c| 2 +-
 drivers/input/misc/powermate.c | 2 +-
 drivers/input/mouse/appletouch.c   | 2 +-
 drivers/input/mouse/synaptics_usb.c| 2 +-
 drivers/input/tablet/acecad.c  | 2 +-
 drivers/input/tablet/kbtab.c   | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

-- 
2.7.4



[PATCH] ATM-nicstar: Delete an error message for a failed memory allocation in ns_init_card()

2017-08-06 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 6 Aug 2017 10:10:21 +0200

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

This issue was detected by using the Coccinelle software.

Link: 
http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring 
---
 drivers/atm/nicstar.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
index 9588d80f318e..08d5aa8b9524 100644
--- a/drivers/atm/nicstar.c
+++ b/drivers/atm/nicstar.c
@@ -372,9 +372,6 @@ static int ns_init_card(int i, struct pci_dev *pcidev)
 
card = kmalloc(sizeof(*card), GFP_KERNEL);
if (!card) {
-   printk
-   ("nicstar%d: can't allocate memory for device structure.\n",
-i);
error = 2;
ns_init_card_error(card, error);
return error;
-- 
2.13.4



Re: [PATCH V2] staging: ccree: Fix format/argument mismatches

2017-08-06 Thread Gilad Ben-Yossef
On Thu, Aug 3, 2017 at 4:49 PM, Joe Perches  wrote:
> On Thu, 2017-08-03 at 17:09 +0800, kbuild test robot wrote:
>> Hi Joe,
>>
>> [auto build test WARNING on staging/staging-testing]
>> [also build test WARNING on next-20170803]
>> [cannot apply to v4.13-rc3]
>> [if your patch is applied to the wrong git tree, please drop us a note to 
>> help improve the system]
>
> Pretty odd that m32r has ioread32 as _readl and so unsigned long
> Seems silly to have to cast it.

Yes, that does seem silly.

>
> Gilad, is this actually a supported platform for ccree?

Yes, since CryptoCell can be baked into any silicon that can be made
to talk AMBA, even though
I don't know of a specific platform that carries both M32R cores and CryptoCell.

That doesn't seem like a unique problem to ccree though, do other
drivers do this cast?
In that case, maybe we need to add a printk format like for dma addresses.

I wanted to add the M32R kernel mailing list but it seems the arch has
been orphaned and the web site
is a  a maze of twisty little 404s, all alike. Is that thing still alive?


Gilad

-- 
Gilad Ben-Yossef
Chief Coffee Drinker

"If you take a class in large-scale robotics, can you end up in a
situation where the homework eats your dog?"
 -- Jean-Baptiste Queru


[PATCH 0/3] ATM-iphase: Adjustments for some function implementations

2017-08-06 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 6 Aug 2017 08:18:28 +0200

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

Markus Elfring (3):
  Adjust 11 function calls together with a variable assignment
  Delete five error messages for a failed memory allocation
  Adjust four checks for null pointers

 drivers/atm/iphase.c | 95 +++-
 1 file changed, 49 insertions(+), 46 deletions(-)

-- 
2.13.4



[PATCH 3/3] ATM-iphase: Adjust four checks for null pointers

2017-08-06 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 5 Aug 2017 22:30:04 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/atm/iphase.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index ad4c1b41ba98..19782fed572a 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -101,7 +101,7 @@ static void ia_init_rtn_q (IARTN_Q *que)
 static void ia_enque_head_rtn_q (IARTN_Q *que, IARTN_Q * data) 
 {
data->next = NULL;
-   if (que->next == NULL) 
+   if (!que->next)
   que->next = que->tail = data;
else {
   data->next = que->next;
@@ -116,7 +116,7 @@ static int ia_enque_rtn_q (IARTN_Q *que, struct desc_tbl_t 
data) {
   return -ENOMEM;
entry->data = data;
entry->next = NULL;
-   if (que->next == NULL) 
+   if (!que->next)
   que->next = que->tail = entry;
else {
   que->tail->next = entry;
@@ -127,7 +127,7 @@ static int ia_enque_rtn_q (IARTN_Q *que, struct desc_tbl_t 
data) {
 
 static IARTN_Q * ia_deque_rtn_q (IARTN_Q *que) {
IARTN_Q *tmpdata;
-   if (que->next == NULL)
+   if (!que->next)
   return NULL;
tmpdata = que->next;
if ( que->next == que->tail)  
@@ -1321,7 +1321,7 @@ static void rx_dle_intr(struct atm_dev *dev)
   goto INCR_DLE;
   }
   ia_vcc = INPH_IA_VCC(vcc);
-  if (ia_vcc == NULL)
+   if (!ia_vcc)
   {
  atomic_inc(>stats->rx_err);
  atm_return(vcc, skb->truesize);
-- 
2.13.4



[PATCH 4/7] ALSA: usb-audio: constify usb_device_id.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 sound/usb/card.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/usb/card.c b/sound/usb/card.c
index 6640277..3dc36d9 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -486,7 +486,7 @@ static bool get_alias_id(struct usb_device *dev, unsigned 
int *id)
return false;
 }
 
-static struct usb_device_id usb_audio_ids[]; /* defined below */
+static const struct usb_device_id usb_audio_ids[]; /* defined below */
 
 /* look for the corresponding quirk */
 static const struct snd_usb_audio_quirk *
@@ -814,7 +814,7 @@ static int usb_audio_reset_resume(struct usb_interface 
*intf)
 #define usb_audio_reset_resume NULL
 #endif /* CONFIG_PM */
 
-static struct usb_device_id usb_audio_ids [] = {
+static const struct usb_device_id usb_audio_ids [] = {
 #include "quirks-table.h"
 { .match_flags = (USB_DEVICE_ID_MATCH_INT_CLASS | 
USB_DEVICE_ID_MATCH_INT_SUBCLASS),
   .bInterfaceClass = USB_CLASS_AUDIO,
-- 
2.7.4



[PATCH 7/7] ALSA: usbusx2y: constify usb_device_id.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 sound/usb/usx2y/usbusx2y.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c
index 91e0e2a..4569c0e 100644
--- a/sound/usb/usx2y/usbusx2y.c
+++ b/sound/usb/usx2y/usbusx2y.c
@@ -313,7 +313,7 @@ static void usX2Y_unlinkSeq(struct snd_usX2Y_AsyncSeq *S)
 }
 
 
-static struct usb_device_id snd_usX2Y_usb_id_table[] = {
+static const struct usb_device_id snd_usX2Y_usb_id_table[] = {
{
.match_flags =  USB_DEVICE_ID_MATCH_DEVICE,
.idVendor = 0x1604,
-- 
2.7.4



[PATCH 3/7] ALSA: snd-usb-caiaq: constify usb_device_id.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 sound/usb/caiaq/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
index b871ba4..0fb6b1b7 100644
--- a/sound/usb/caiaq/device.c
+++ b/sound/usb/caiaq/device.c
@@ -81,7 +81,7 @@ enum {
DEPTH_32= 3
 };
 
-static struct usb_device_id snd_usb_id_table[] = {
+static const struct usb_device_id snd_usb_id_table[] = {
{
.match_flags =  USB_DEVICE_ID_MATCH_DEVICE,
.idVendor = USB_VID_NATIVEINSTRUMENTS,
-- 
2.7.4



[PATCH 0/7] constify ALSA usb_device_id.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Arvind Yadav (7):
  [PATCH 1/7] ALSA: 6fire: constify usb_device_id.
  [PATCH 2/7] ALSA: bcd2000: constify usb_device_id.
  [PATCH 3/7] ALSA: snd-usb-caiaq: constify usb_device_id.
  [PATCH 4/7] ALSA: usb-audio: constify usb_device_id.
  [PATCH 5/7] ALSA: ua101: constify usb_device_id.
  [PATCH 6/7] ALSA: us122l: constify usb_device_id.
  [PATCH 7/7] ALSA: usbusx2y: constify usb_device_id.

 sound/usb/6fire/chip.c  | 2 +-
 sound/usb/bcd2000/bcd2000.c | 2 +-
 sound/usb/caiaq/device.c| 2 +-
 sound/usb/card.c| 4 ++--
 sound/usb/misc/ua101.c  | 2 +-
 sound/usb/usx2y/us122l.c| 2 +-
 sound/usb/usx2y/usbusx2y.c  | 2 +-
 7 files changed, 8 insertions(+), 8 deletions(-)

-- 
2.7.4



[PATCH 5/7] ALSA: ua101: constify usb_device_id.

2017-08-06 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 sound/usb/misc/ua101.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c
index c19a5dd..b05cd38 100644
--- a/sound/usb/misc/ua101.c
+++ b/sound/usb/misc/ua101.c
@@ -1366,7 +1366,7 @@ static void ua101_disconnect(struct usb_interface 
*interface)
mutex_unlock(_mutex);
 }
 
-static struct usb_device_id ua101_ids[] = {
+static const struct usb_device_id ua101_ids[] = {
{ USB_DEVICE(0x0582, 0x0044) }, /* UA-1000 high speed */
{ USB_DEVICE(0x0582, 0x007d) }, /* UA-101 high speed */
{ USB_DEVICE(0x0582, 0x008d) }, /* UA-101 full speed */
-- 
2.7.4



[PATCH] atm: solos-pci: Delete an error message for a failed memory allocation in fpga_probe()

2017-08-06 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 6 Aug 2017 10:37:31 +0200

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

This issue was detected by using the Coccinelle software.

Link: 
http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring 
---
 drivers/atm/solos-pci.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index 8754793223cd..cb3424a4f91f 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -1293,7 +1293,6 @@ static int fpga_probe(struct pci_dev *dev, const struct 
pci_device_id *id)
card->dma_alignment = 3;
card->dma_bounce = kmalloc(card->nr_ports * BUF_SIZE, 
GFP_KERNEL);
if (!card->dma_bounce) {
-   dev_warn(>dev->dev, "Failed to allocate 
DMA bounce buffers\n");
err = -ENOMEM;
/* Fallback to MMIO doesn't work */
goto out_unmap_both;
-- 
2.13.4



[PATCH 09/12] [media] media: mx2-emmaprp: constify v4l2_m2m_ops structures

2017-08-06 Thread Julia Lawall
The v4l2_m2m_ops structures are only passed as the only
argument to v4l2_m2m_init, which is declared as const.
Thus the v4l2_m2m_ops structures themselves can be const.

Done with the help of Coccinelle.

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct v4l2_m2m_ops i@p = { ... };

@ok1@
identifier r.i;
position p;
@@
v4l2_m2m_init(@p)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct v4l2_m2m_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct v4l2_m2m_ops i = { ... };
// 

Signed-off-by: Julia Lawall 

---
 drivers/media/platform/mx2_emmaprp.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/mx2_emmaprp.c 
b/drivers/media/platform/mx2_emmaprp.c
index 03e47e0..7fd209e 100644
--- a/drivers/media/platform/mx2_emmaprp.c
+++ b/drivers/media/platform/mx2_emmaprp.c
@@ -882,7 +882,7 @@ static int emmaprp_mmap(struct file *file, struct 
vm_area_struct *vma)
.vfl_dir= VFL_DIR_M2M,
 };
 
-static struct v4l2_m2m_ops m2m_ops = {
+static const struct v4l2_m2m_ops m2m_ops = {
.device_run = emmaprp_device_run,
.job_abort  = emmaprp_job_abort,
.lock   = emmaprp_lock,



[PATCH 10/12] [media] vim2m: constify v4l2_m2m_ops structures

2017-08-06 Thread Julia Lawall
The v4l2_m2m_ops structures are only passed as the only
argument to v4l2_m2m_init, which is declared as const.
Thus the v4l2_m2m_ops structures themselves can be const.

Done with the help of Coccinelle.

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct v4l2_m2m_ops i@p = { ... };

@ok1@
identifier r.i;
position p;
@@
v4l2_m2m_init(@p)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct v4l2_m2m_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct v4l2_m2m_ops i = { ... };
// 

Signed-off-by: Julia Lawall 

---
 drivers/media/platform/vim2m.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c
index 970b9b6..afbaa35 100644
--- a/drivers/media/platform/vim2m.c
+++ b/drivers/media/platform/vim2m.c
@@ -983,7 +983,7 @@ static int vim2m_release(struct file *file)
.release= video_device_release_empty,
 };
 
-static struct v4l2_m2m_ops m2m_ops = {
+static const struct v4l2_m2m_ops m2m_ops = {
.device_run = device_run,
.job_ready  = job_ready,
.job_abort  = job_abort,



[PATCH 08/12] [media] m2m-deinterlace: constify v4l2_m2m_ops structures

2017-08-06 Thread Julia Lawall
The v4l2_m2m_ops structures are only passed as the only
argument to v4l2_m2m_init, which is declared as const.
Thus the v4l2_m2m_ops structures themselves can be const.

Done with the help of Coccinelle.

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct v4l2_m2m_ops i@p = { ... };

@ok1@
identifier r.i;
position p;
@@
v4l2_m2m_init(@p)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct v4l2_m2m_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct v4l2_m2m_ops i = { ... };
// 

Signed-off-by: Julia Lawall 

---
 drivers/media/platform/m2m-deinterlace.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/m2m-deinterlace.c 
b/drivers/media/platform/m2m-deinterlace.c
index 980066b..98f6db2 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -988,7 +988,7 @@ static int deinterlace_mmap(struct file *file, struct 
vm_area_struct *vma)
.vfl_dir= VFL_DIR_M2M,
 };
 
-static struct v4l2_m2m_ops m2m_ops = {
+static const struct v4l2_m2m_ops m2m_ops = {
.device_run = deinterlace_device_run,
.job_ready  = deinterlace_job_ready,
.job_abort  = deinterlace_job_abort,



[PATCH] ATM-ENI: Delete an error message for a failed memory allocation in eni_start()

2017-08-06 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 6 Aug 2017 11:15:17 +0200

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

This issue was detected by using the Coccinelle software.

Link: 
http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring 
---
 drivers/atm/eni.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
index ce47eb17901d..d4b11ef940ee 100644
--- a/drivers/atm/eni.c
+++ b/drivers/atm/eni.c
@@ -1849,8 +1849,6 @@ static int eni_start(struct atm_dev *dev)
   sizeof(*eni_dev->free_list),
   GFP_KERNEL);
if (!eni_dev->free_list) {
-   printk(KERN_ERR DEV_LABEL "(itf %d): couldn't get free page\n",
-   dev->number);
error = -ENOMEM;
goto free_irq;
}
-- 
2.13.4



Re: [PATCH v2] mmc: mmci_qcom_dml: include mmci_qcom_dml.h and fix #ifdef

2017-08-06 Thread Arnd Bergmann
On Sun, Aug 6, 2017 at 4:58 AM, Masahiro Yamada
 wrote:
> 2017-08-05 7:10 GMT+09:00 Arnd Bergmann :
>> On Fri, Aug 4, 2017 at 3:34 PM, Masahiro Yamada
>>  wrote:
>>> Include mmci_qcom_dml.h from mmci_qcom_dml.c to fix the following
>>> sparse warnings:
>>>
>>>   CHECK   drivers/mmc/host/mmci_qcom_dml.c
>>> drivers/mmc/host/mmci_qcom_dml.c:57:6: warning: symbol 'dml_start_xfer' was 
>>> not declared. Should it be static?
>>> drivers/mmc/host/mmci_qcom_dml.c:122:5: warning: symbol 'dml_hw_init' was 
>>> not declared. Should it be static?
>>>
>>> Fixing them causes redefintion of dml_start_xfer error, revealing another
>>> problem in the header.  #ifdef CONFIG_MMC_QCOM_DML is wrong because this
>>> driver is tristate.  (CONFIG_MMC_QCOM_DML_MODULE is defined when it is
>>> built as a module)
>>>
>>> Since dml_hw_init() is called from mmci.c, IS_REACHABLE() is needed to
>>> cater to all the combinations.
>>>
>>> Signed-off-by: Masahiro Yamada 
>>
>> I think this is still not a good solution, it will just turn a link error 
>> into
>> an unusable system at runtime when the DML code is a loadable module
>> but not used. Also, the symbols are not exported, so it won't work when both
>> are built as modules.
>> How about linking the DML code into the mmci module and making that
>> Kconfig option a 'bool'?
>
>
> You are right.
> My patch does not solve the root of the problem.
>
> It turned out not so trivial as I had first expected.
>
> I'd like somebody else to take care of it
> because I am not familiar with this driver.

Maybe it's best if Ulf just reverts the broken commit, and then we start
over with reviewing the patch properly.

 Arnd


RE: [PATCH] i2c: mux: rename files to not have superfluous prefixes

2017-08-06 Thread Michael Shych

> -Original Message-
> From: Peter Rosin [mailto:p...@axentia.se]
> Sent: Friday, August 04, 2017 12:08 PM
> To: linux-kernel@vger.kernel.org
> Cc: Peter Rosin ; Wolfram Sang ;
> linux-...@vger.kernel.org; Peter Korsgaard ;
> Michael Hennerich ; Michael Shych
> ; Guenter Roeck 
> Subject: [PATCH] i2c: mux: rename files to not have superfluous prefixes
> 
> Keep the module names intact using extra lines in the Makefile.
> 
> Signed-off-by: Peter Rosin 

Acked-by: Michael Shych 

> ---
>  MAINTAINERS |  8 
>  drivers/i2c/muxes/Makefile  | 13 
> +
>  .../{i2c-arb-gpio-challenge.c => arb-gpio-challenge.c}  |  0
>  drivers/i2c/muxes/{i2c-demux-pinctrl.c => demux-pinctrl.c}  |  0
>  drivers/i2c/muxes/{i2c-mux-gpio.c => gpio.c}|  0
>  drivers/i2c/muxes/{i2c-mux-gpmux.c => gpmux.c}  |  0
>  drivers/i2c/muxes/{i2c-mux-ltc4306.c => ltc4306.c}  |  0
>  drivers/i2c/muxes/{i2c-mux-mlxcpld.c => mlxcpld.c}  |  0
>  drivers/i2c/muxes/{i2c-mux-pca9541.c => pca9541.c}  |  0
>  drivers/i2c/muxes/{i2c-mux-pca954x.c => pca954x.c}  |  0
>  drivers/i2c/muxes/{i2c-mux-pinctrl.c => pinctrl.c}  |  0
>  drivers/i2c/muxes/{i2c-mux-reg.c => reg.c}  |  0
>  12 files changed, 17 insertions(+), 4 deletions(-)  rename
> drivers/i2c/muxes/{i2c-arb-gpio-challenge.c => arb-gpio-challenge.c} (100%)
> rename drivers/i2c/muxes/{i2c-demux-pinctrl.c => demux-pinctrl.c} (100%)
> rename drivers/i2c/muxes/{i2c-mux-gpio.c => gpio.c} (100%)  rename
> drivers/i2c/muxes/{i2c-mux-gpmux.c => gpmux.c} (100%)  rename
> drivers/i2c/muxes/{i2c-mux-ltc4306.c => ltc4306.c} (100%)  rename
> drivers/i2c/muxes/{i2c-mux-mlxcpld.c => mlxcpld.c} (100%)  rename
> drivers/i2c/muxes/{i2c-mux-pca9541.c => pca9541.c} (100%)  rename
> drivers/i2c/muxes/{i2c-mux-pca954x.c => pca954x.c} (100%)  rename
> drivers/i2c/muxes/{i2c-mux-pinctrl.c => pinctrl.c} (100%)  rename
> drivers/i2c/muxes/{i2c-mux-reg.c => reg.c} (100%)
> 
> Hi Wolfram!
> 
> In the light of the rant from Linus the other week [1], I thought this might 
> be
> a good idea?
> 
> Cheers,
> peda
> 
> [1]
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flk
> ml.org%2Flkml%2F2017%2F7%2F12%2F430=02%7C01%7Cmichaelsh%40
> mellanox.com%7C6cbbed292e99475e99d208d4db184a42%7Ca652971c7d2e4
> d9ba6a4d149256f461b%7C0%7C0%7C636374344761668884=k2CK8RQq
> mWOEs3CULrPqOR1uddb1iIawqUTD7%2F4BLiU%3D=0
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 205d3977ac46..46356c87f0c9 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5687,7 +5687,7 @@ GENERIC GPIO I2C MULTIPLEXER DRIVER
>  M:   Peter Korsgaard 
>  L:   linux-...@vger.kernel.org
>  S:   Supported
> -F:   drivers/i2c/muxes/i2c-mux-gpio.c
> +F:   drivers/i2c/muxes/gpio.c
>  F:   include/linux/i2c-mux-gpio.h
>  F:   Documentation/i2c/muxes/i2c-mux-gpio
> 
> @@ -7998,7 +7998,7 @@ M:  Michael Hennerich
> 
>  W:
>   https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F
> %2Fez.analog.com%2Fcommunity%2Flinux-device-
> drivers=02%7C01%7Cmichaelsh%40mellanox.com%7C6cbbed292e9947
> 5e99d208d4db184a42%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7
> C636374344761668884=hehiWQXI5WY2oz1SCBV9TqjWQ3wYPzKuIKes
> K44Ar%2Fg%3D=0
>  L:   linux-...@vger.kernel.org
>  S:   Supported
> -F:   drivers/i2c/muxes/i2c-mux-ltc4306.c
> +F:   drivers/i2c/muxes/ltc4306.c
>  F:   Documentation/devicetree/bindings/i2c/i2c-mux-ltc4306.txt
> 
>  LTP (Linux Test Project)
> @@ -8558,7 +8558,7 @@ M:  Michael Shych 
>  L:   linux-...@vger.kernel.org
>  S:   Supported
>  F:   drivers/i2c/busses/i2c-mlxcpld.c
> -F:   drivers/i2c/muxes/i2c-mux-mlxcpld.c
> +F:   drivers/i2c/muxes/mlxcpld.c
>  F:   Documentation/i2c/busses/i2c-mlxcpld
> 
>  MELLANOX MLXCPLD LED DRIVER
> @@ -10018,7 +10018,7 @@ PCA9541 I2C BUS MASTER SELECTOR DRIVER
>  M:   Guenter Roeck 
>  L:   linux-...@vger.kernel.org
>  S:   Maintained
> -F:   drivers/i2c/muxes/i2c-mux-pca9541.c
> +F:   drivers/i2c/muxes/pca9541.c
> 
>  PCDP - PRIMARY CONSOLE AND DEBUG PORT
>  M:   Khalid Aziz 
> diff --git a/drivers/i2c/muxes/Makefile b/drivers/i2c/muxes/Makefile index
> 4a67d3199877..b9f7a78d7604 100644
> --- a/drivers/i2c/muxes/Makefile
> +++ b/drivers/i2c/muxes/Makefile
> @@ -1,6 +1,19 @@
>  #
>  # Makefile for multiplexer I2C chip drivers.
> 
> +i2c-arb-gpio-challenge-objs  := arb-gpio-challenge.o
> +
> +i2c-demux-pinctrl-objs   := demux-pinctrl.o
> +
> +i2c-mux-gpio-objs:= gpio.o
> +i2c-mux-gpmux-objs   := gpmux.o
> +i2c-mux-ltc4306-objs := ltc4306.o
> +i2c-mux-mlxcpld-objs 

Re: [PATCH 4/5] mtd: block2mtd: Add support for deleting block2mtd mapping

2017-08-06 Thread Richard Weinberger
Pali,

Am 25.07.2017 um 16:24 schrieb Pali Rohár:
> On Friday 21 July 2017 21:56:41 Richard Weinberger wrote:
>> Pali,
>>
>> On Fri, Jun 2, 2017 at 5:43 PM, Pali Rohár  wrote:
>>> This patch allows user to delete block2mtd mapping via parameters file
>>> /sys/module/block2mtd/parameters/block2mtd
>>>
>>> Syntax is "del=device", e.g.:
>>>
>>> $ echo -n del=/dev/loop0 > /sys/module/block2mtd/parameters/block2mtd
>>
>> As I wrote in an earlier mail, I hate this interface.
>> I suggest adding a decent ioctl based interface for dynamic block2mtd's.
> 
> ioctl interface has a problem that cannot be easily used from shell. It
> needs to have another tool which uses it. On the other hand sysfs
> interface can be used from bash script which is better.
> 
> Any idea for better interface without need for ioctl?

No, please use ioctl and add a proper tool to mtd-utils.
in MTD we use ioctl for all non-trivial interfaces. :-)

Thanks,
//richard


drivers/gpu/drm/i915/selftests/i915_gem_request.c:344: error: 'request' may be used uninitialized in this function

2017-08-06 Thread kbuild test robot
Hi Jan,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   0fdd951c9bef93637d5af036851e7a5632fbd6c3
commit: 7e6091209f7f73e2a81943020793b5ad26d645c6 x86/build: Permit building 
with old make versions
date:   2 months ago
config: x86_64-randconfig-v0-08061633 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
git checkout 7e6091209f7f73e2a81943020793b5ad26d645c6
# save the attached .config to linux build tree
make ARCH=x86_64 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All errors (new ones prefixed by >>):

   cc1: warnings being treated as errors
   In file included from drivers/gpu/drm/i915/i915_gem_request.c:1219:
   drivers/gpu/drm/i915/selftests/i915_gem_request.c: In function 
'live_nop_request':
>> drivers/gpu/drm/i915/selftests/i915_gem_request.c:344: error: 'request' may 
>> be used uninitialized in this function

vim +/request +344 drivers/gpu/drm/i915/selftests/i915_gem_request.c

b348090d Chris Wilson 2017-02-13  326  
b348090d Chris Wilson 2017-02-13  327  static int live_nop_request(void *arg)
b348090d Chris Wilson 2017-02-13  328  {
b348090d Chris Wilson 2017-02-13  329   struct drm_i915_private *i915 = arg;
b348090d Chris Wilson 2017-02-13  330   struct intel_engine_cs *engine;
b348090d Chris Wilson 2017-02-13  331   struct live_test t;
b348090d Chris Wilson 2017-02-13  332   unsigned int id;
b348090d Chris Wilson 2017-02-13  333   int err;
b348090d Chris Wilson 2017-02-13  334  
b348090d Chris Wilson 2017-02-13  335   /* Submit various sized batches of 
empty requests, to each engine
b348090d Chris Wilson 2017-02-13  336* (individually), and wait for the 
batch to complete. We can check
b348090d Chris Wilson 2017-02-13  337* the overhead of submitting requests 
to the hardware.
b348090d Chris Wilson 2017-02-13  338*/
b348090d Chris Wilson 2017-02-13  339  
b348090d Chris Wilson 2017-02-13  340   mutex_lock(>drm.struct_mutex);
b348090d Chris Wilson 2017-02-13  341  
b348090d Chris Wilson 2017-02-13  342   for_each_engine(engine, i915, id) {
b348090d Chris Wilson 2017-02-13  343   IGT_TIMEOUT(end_time);
b348090d Chris Wilson 2017-02-13 @344   struct drm_i915_gem_request 
*request;
b348090d Chris Wilson 2017-02-13  345   unsigned long n, prime;
b348090d Chris Wilson 2017-02-13  346   ktime_t times[2] = {};
b348090d Chris Wilson 2017-02-13  347  
b348090d Chris Wilson 2017-02-13  348   err = begin_live_test(, i915, 
__func__, engine->name);
b348090d Chris Wilson 2017-02-13  349   if (err)
b348090d Chris Wilson 2017-02-13  350   goto out_unlock;
b348090d Chris Wilson 2017-02-13  351  
b348090d Chris Wilson 2017-02-13  352   
for_each_prime_number_from(prime, 1, 8192) {
b348090d Chris Wilson 2017-02-13  353   times[1] = 
ktime_get_raw();
b348090d Chris Wilson 2017-02-13  354  
b348090d Chris Wilson 2017-02-13  355   for (n = 0; n < prime; 
n++) {
b348090d Chris Wilson 2017-02-13  356   request = 
i915_gem_request_alloc(engine,
b348090d Chris Wilson 2017-02-13  357   
 i915->kernel_context);
b348090d Chris Wilson 2017-02-13  358   if 
(IS_ERR(request)) {
b348090d Chris Wilson 2017-02-13  359   err = 
PTR_ERR(request);
b348090d Chris Wilson 2017-02-13  360   goto 
out_unlock;
b348090d Chris Wilson 2017-02-13  361   }
b348090d Chris Wilson 2017-02-13  362  
b348090d Chris Wilson 2017-02-13  363   /* This space 
is left intentionally blank.
b348090d Chris Wilson 2017-02-13  364*
b348090d Chris Wilson 2017-02-13  365* We do not 
actually want to perform any
b348090d Chris Wilson 2017-02-13  366* action with 
this request, we just want
b348090d Chris Wilson 2017-02-13  367* to measure 
the latency in allocation
b348090d Chris Wilson 2017-02-13  368* and 
submission of our breadcrumbs -
b348090d Chris Wilson 2017-02-13  369* ensuring 
that the bare request is sufficient
b348090d Chris Wilson 2017-02-13  370* for the 
system to work (i.e. proper HEAD
b348090d Chris Wilson 2017-02-13  371* tracking of 
the rings, interrupt handling,
b348090d Chris Wilson 2017-02-13  372* etc). It 
also gives us the lowest bounds
b348090d Chris Wilson 2017-02-13  373* for latency.
b348090d Chris Wilson 2017-02-13  374*/
b348090d Chris Wilson 2017-02-13  375  
b348090d Chris Wilson 

Re: [PATCH v3 3/5] ACPI: Introduce DMA ranges parsing

2017-08-06 Thread Lorenzo Pieralisi
On Sun, Aug 06, 2017 at 01:12:55PM +0800, kbuild test robot wrote:
> Hi Lorenzo,
> 
> [auto build test ERROR on pm/linux-next]
> [also build test ERROR on v4.13-rc3 next-20170804]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/Lorenzo-Pieralisi/ACPICA-resource_mgr-Allow-_DMA-method-in-walk-resources/20170804-185152
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 
> linux-next
> config: ia64-allnoconfig (attached as .config)
> compiler: ia64-linux-gcc (GCC) 6.2.0
> reproduce:
> wget 
> https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=ia64 
> 
> Note: the 
> linux-review/Lorenzo-Pieralisi/ACPICA-resource_mgr-Allow-_DMA-method-in-walk-resources/20170804-185152
>  HEAD 37e91dddbbeb771d4df0001f716607f1dd8719f8 builds fine.
>   It only hurts bisectibility.

Sigh, it is a silly v2->v3 rebase mistake, a change hunk that should be
in patch 4 ended up in patch 3, series as a whole is fine but this must
be fixed.

Rafael, please let me know the best way to handle this, I think
me sending a v4 is the simplest so that you can just update the branch.

Apologies and thanks.

Lorenzo

> All errors (new ones prefixed by >>):
> 
>drivers/acpi/scan.c: In function 'acpi_dma_configure':
> >> drivers/acpi/scan.c:1451:2: error: implicit declaration of function 
> >> 'iort_dma_setup' [-Werror=implicit-function-declaration]
>  iort_dma_setup(dev, _addr, );
>  ^~
>cc1: some warnings being treated as errors
> 
> vim +/iort_dma_setup +1451 drivers/acpi/scan.c
> 
>   1440
>   1441/**
>   1442 * acpi_dma_configure - Set-up DMA configuration for the device.
>   1443 * @dev: The pointer to the device
>   1444 * @attr: device dma attributes
>   1445 */
>   1446int acpi_dma_configure(struct device *dev, enum dev_dma_attr 
> attr)
>   1447{
>   1448const struct iommu_ops *iommu;
>   1449u64 dma_addr = 0, size = 0;
>   1450
> > 1451iort_dma_setup(dev, _addr, );
>   1452
>   1453iommu = iort_iommu_configure(dev);
>   1454if (IS_ERR(iommu) && PTR_ERR(iommu) == -EPROBE_DEFER)
>   1455return -EPROBE_DEFER;
>   1456
>   1457arch_setup_dma_ops(dev, dma_addr, size,
>   1458iommu, attr == 
> DEV_DMA_COHERENT);
>   1459
>   1460return 0;
>   1461}
>   1462EXPORT_SYMBOL_GPL(acpi_dma_configure);
>   1463
> 
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation




Re: [PATCH 5/5] ubi: Allow to use read-only UBI volume with not enough PEBs

2017-08-06 Thread Richard Weinberger
Pali,

Am 25.07.2017 um 16:27 schrieb Pali Rohár:
>> I fear this is not correct, it will disable a legit self-check of UBI 
>> volumes.
>> If the read-only volume is corrupted/truncated and you miss PEBs, this
>> check will no longer
>> trigger.
>>
>> Especially when dealing with nanddumps, truncation is a common problem.
> 
> Any idea how to fix it? Or how to handle read-only images which are
> marked for auto-resize?

I'd vote for rejecting images that have auto-resize set when the MTD is 
read-only.
In fact, using UBI on top of a read-only MTD is very uncommon and not 
recommended (for NAND).
The auto-resize flag should be also only set when you just have created it 
using mkfs.ubifs.
Why would you inspect such an image with the kernel UBIFS unless you're hunting 
down a bug
in mkfs.ubifs?

Thanks,
//richard


undefined reference to `_GLOBAL_OFFSET_TABLE_'

2017-08-06 Thread kbuild test robot
Hi Nicholas,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   0fdd951c9bef93637d5af036851e7a5632fbd6c3
commit: 799c43415442414b1032580c47684cb709dfed6d kbuild: thin archives make 
default for all archs
date:   5 weeks ago
config: microblaze-allnoconfig (attached as .config)
compiler: microblaze-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 799c43415442414b1032580c47684cb709dfed6d
# save the attached .config to linux build tree
make.cross ARCH=microblaze 

All errors (new ones prefixed by >>):

   mm/slub.o: In function `__slab_free.isra.13':
>> (.text+0x1038): undefined reference to `_GLOBAL_OFFSET_TABLE_'
   scripts/link-vmlinux.sh: line 93: 113680 Segmentation fault  ${LD} 
${LDFLAGS} ${LDFLAGS_vmlinux} -o ${2} -T ${lds} ${objects}

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


.config.gz
Description: application/gzip


Re: [PATCH 0/7] cfag12864b: Fine-tuning for cfag12864b_init()

2017-08-06 Thread SF Markus Elfring
> Date: Sat, 10 Sep 2016 16:17:01 +0200
> 
> Some update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (7):
>   Use kmalloc_array()
>   Delete an error message for a failed kmalloc_array() call
>   Return directly if the driver "ks0108" was not initialized
>   Return directly after a failed get_zeroed_page()
>   Rename jump labels
>   Return an error code only as a constant
>   Adjust two checks for null pointers
> 
>  drivers/auxdisplay/cfag12864b.c | 37 +
>  1 file changed, 13 insertions(+), 24 deletions(-)

Would you like to take another look at change possibilities
for this software module?

Regards,
Markus


Re: [PATCH 00/30] ACPI-processor: Fine-tuning for several function implementations

2017-08-06 Thread SF Markus Elfring
> Date: Tue, 9 Sep 2016 20:15:05 +0200
> 
> Several update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (30):
>   Use kmalloc_array() in acpi_processor_get_performance_states()
>   Improve two size determinations in acpi_processor_get_performance_states()
>   Rename jump labels in acpi_processor_get_performance_states()
>   Delete two unnecessary initialisations in 
> acpi_processor_get_performance_states()
>   Rename jump labels in acpi_processor_preregister_performance()
>   Move a success indication in acpi_processor_preregister_performance()
>   Rename jump labels in acpi_processor_get_psd()
>   Delete two unnecessary initialisations in acpi_processor_get_psd()
>   Improve a size determination in acpi_processor_get_psd()
>   Rename jump labels in acpi_processor_get_performance_control()
>   Delete two unnecessary initialisations in 
> acpi_processor_get_performance_control()
>   Rename jump labels in acpi_processor_ppc_notifier()
>   Delete an unnecessary initialisation in acpi_processor_ppc_notifier()
>   Delete an unnecessary initialisation in 
> acpi_processor_get_performance_info()
>   Delete an unnecessary initialisation in acpi_processor_get_platform_limit()
>   Use kmalloc_array() in acpi_processor_get_throttling_states()
>   Improve another size determination in acpi_processor_get_throttling_states()
>   Rename jump labels in acpi_processor_get_throttling_states()
>   Delete two unnecessary initialisations in 
> acpi_processor_get_throttling_states()
>   Fix jump targets in acpi_processor_get_throttling_info()
>   Rename jump labels in acpi_processor_get_tsd()
>   Delete two unnecessary initialisations in acpi_processor_get_tsd()
>   Improve a size determination in acpi_processor_get_tsd()
>   Rename jump labels in acpi_processor_get_throttling_control()
>   Delete two unnecessary initialisations in 
> acpi_processor_get_throttling_control()
>   Fix jump targets in acpi_processor_reevaluate_tstate()
>   Delete an unnecessary initialisation in acpi_processor_reevaluate_tstate()
>   Rename a jump label in acpi_processor_get_platform_limit()
>   Delete an unnecessary initialisation in acpi_processor_get_platform_limit()
>   Improve jump targets in acpi_processor_update_tsd_coord()
> 
>  drivers/acpi/processor_perflib.c|  87 +--
>  drivers/acpi/processor_throttling.c | 116 
> 
>  2 files changed, 93 insertions(+), 110 deletions(-)

How do you think about to take another look at change possibilities
for these source files?

Regards,
Markus


Re: [PATCH v2] mmc: mmci_qcom_dml: include mmci_qcom_dml.h and fix #ifdef

2017-08-06 Thread Ulf Hansson
On 6 August 2017 at 11:32, Arnd Bergmann  wrote:
> On Sun, Aug 6, 2017 at 4:58 AM, Masahiro Yamada
>  wrote:
>> 2017-08-05 7:10 GMT+09:00 Arnd Bergmann :
>>> On Fri, Aug 4, 2017 at 3:34 PM, Masahiro Yamada
>>>  wrote:
 Include mmci_qcom_dml.h from mmci_qcom_dml.c to fix the following
 sparse warnings:

   CHECK   drivers/mmc/host/mmci_qcom_dml.c
 drivers/mmc/host/mmci_qcom_dml.c:57:6: warning: symbol 'dml_start_xfer' 
 was not declared. Should it be static?
 drivers/mmc/host/mmci_qcom_dml.c:122:5: warning: symbol 'dml_hw_init' was 
 not declared. Should it be static?

 Fixing them causes redefintion of dml_start_xfer error, revealing another
 problem in the header.  #ifdef CONFIG_MMC_QCOM_DML is wrong because this
 driver is tristate.  (CONFIG_MMC_QCOM_DML_MODULE is defined when it is
 built as a module)

 Since dml_hw_init() is called from mmci.c, IS_REACHABLE() is needed to
 cater to all the combinations.

 Signed-off-by: Masahiro Yamada 
>>>
>>> I think this is still not a good solution, it will just turn a link error 
>>> into
>>> an unusable system at runtime when the DML code is a loadable module
>>> but not used. Also, the symbols are not exported, so it won't work when both
>>> are built as modules.
>>> How about linking the DML code into the mmci module and making that
>>> Kconfig option a 'bool'?
>>
>>
>> You are right.
>> My patch does not solve the root of the problem.
>>
>> It turned out not so trivial as I had first expected.
>>
>> I'd like somebody else to take care of it
>> because I am not familiar with this driver.
>
> Maybe it's best if Ulf just reverts the broken commit, and then we start
> over with reviewing the patch properly.

The broken commit is reverted, however I will just drop both the bad
commit and its revert next time I rebase my next branch.

Kind regards
Uffe


Re: [PATCH 00/13] DRBD-receiver: Fine-tuning for six function implementations

2017-08-06 Thread SF Markus Elfring
> Date: Sat, 10 Sep 2016 22:13:22 +0200
> 
> Several update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (13):
>   Use kmalloc_array() in receive_uuids()
>   Delete an error message for a failed kmalloc_array() call
>   Move an assignment in receive_uuids()
>   Improve a size determination in drbd_do_features()
>   Delete an unnecessary initialisation in receive_sizes()
>   Improve a size determination in receive_sizes()
>   Delete an error message for a failed kzalloc() call in receive_sizes()
>   Move an assignment in receive_sizes()
>   Improve determination of sizes in receive_SyncParam()
>   Delete error messages for failed resource allocations in receive_SyncParam()
>   Improve a size determination in receive_protocol()
>   Delete error messages for failed resource allocations in receive_protocol()
>   Improve determination of sizes in receive_Barrier()
> 
>  drivers/block/drbd/drbd_receiver.c | 45 
> --
>  1 file changed, 19 insertions(+), 26 deletions(-)

Would you like to take another look at change possibilities
for this software module?

Regards,
Markus


Re: [PATCH] arm64: dts: rockchip: include opp dtsi for rk3399 firefly

2017-08-06 Thread Heiko Stuebner
Am Donnerstag, 3. August 2017, 15:02:00 CEST schrieb Jianqun Xu:
> Add opp tables for cpu cluster0 and cluster1 by including
> rk3399-opp.dtsi.
> 
> Signed-off-by: Jianqun Xu 

applied for 4.14


Thanks
Heiko


Re: [PATCH v2] mmc: mmci_qcom_dml: include mmci_qcom_dml.h and fix #ifdef

2017-08-06 Thread Srinivas Kandagatla



On 04/08/17 23:10, Arnd Bergmann wrote:

How about linking the DML code into the mmci module and making that
Kconfig option a 'bool'?



Yes, I think making this bool and exporting the two symbols should fix 
this. It does not make sense to make dml helpers a module anyway.


If it sounds okay, I can send a proper patch to fix this.

>cut<---

diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 5755b69..3345384 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -15,7 +15,7 @@ config MMC_ARMMMCI
  If unsure, say N.

 config MMC_QCOM_DML
-   tristate "Qualcomm Data Mover for SD Card Controller"
+   bool "Qualcomm Data Mover for SD Card Controller"
depends on MMC_ARMMMCI && QCOM_BAM_DMA
default y
help
diff --git a/drivers/mmc/host/mmci_qcom_dml.c 
b/drivers/mmc/host/mmci_qcom_dml.c

index 00750c9..e7d9c74 100644
--- a/drivers/mmc/host/mmci_qcom_dml.c
+++ b/drivers/mmc/host/mmci_qcom_dml.c
@@ -97,6 +97,7 @@ void dml_start_xfer(struct mmci_host *host, struct 
mmc_data *data)

/* make sure the dml is configured before dma is triggered */
wmb();
 }
+EXPORT_SYMBOL_GPL(dml_start_xfer);

 static int of_get_dml_pipe_index(struct device_node *np, const char *name)
 {
@@ -175,3 +176,4 @@ int dml_hw_init(struct mmci_host *host, struct 
device_node *np)


return 0;
>cut<---


thanks,
srini


[PATCH 04/12] [media] V4L2: platform: rcar_jpu: constify v4l2_m2m_ops structures

2017-08-06 Thread Julia Lawall
The v4l2_m2m_ops structures are only passed as the only
argument to v4l2_m2m_init, which is declared as const.
Thus the v4l2_m2m_ops structures themselves can be const.

Done with the help of Coccinelle.

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct v4l2_m2m_ops i@p = { ... };

@ok1@
identifier r.i;
position p;
@@
v4l2_m2m_init(@p)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct v4l2_m2m_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct v4l2_m2m_ops i = { ... };
// 

Signed-off-by: Julia Lawall 

---
 drivers/media/platform/rcar_jpu.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/rcar_jpu.c 
b/drivers/media/platform/rcar_jpu.c
index d1746ec..070bac3 100644
--- a/drivers/media/platform/rcar_jpu.c
+++ b/drivers/media/platform/rcar_jpu.c
@@ -1506,7 +1506,7 @@ static void jpu_job_abort(void *priv)
jpu_cleanup(ctx, true);
 }
 
-static struct v4l2_m2m_ops jpu_m2m_ops = {
+static const struct v4l2_m2m_ops jpu_m2m_ops = {
.device_run = jpu_device_run,
.job_ready  = jpu_job_ready,
.job_abort  = jpu_job_abort,



[PATCH 01/12] [media] st-delta: constify v4l2_m2m_ops structures

2017-08-06 Thread Julia Lawall
The v4l2_m2m_ops structures are only passed as the only
argument to v4l2_m2m_init, which is declared as const.
Thus the v4l2_m2m_ops structures themselves can be const.

Done with the help of Coccinelle.

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct v4l2_m2m_ops i@p = { ... };

@ok1@
identifier r.i;
position p;
@@
v4l2_m2m_init(@p)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct v4l2_m2m_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct v4l2_m2m_ops i = { ... };
// 

Signed-off-by: Julia Lawall 

---
 drivers/media/platform/sti/delta/delta-v4l2.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/sti/delta/delta-v4l2.c 
b/drivers/media/platform/sti/delta/delta-v4l2.c
index ff9850e..b2dc3d2 100644
--- a/drivers/media/platform/sti/delta/delta-v4l2.c
+++ b/drivers/media/platform/sti/delta/delta-v4l2.c
@@ -1095,7 +1095,7 @@ static int delta_job_ready(void *priv)
 }
 
 /* mem-to-mem ops */
-static struct v4l2_m2m_ops delta_m2m_ops = {
+static const struct v4l2_m2m_ops delta_m2m_ops = {
.device_run = delta_device_run,
.job_ready  = delta_job_ready,
.job_abort  = delta_job_abort,



[PATCH] hamradio: baycom: make hdlcdrv_ops const

2017-08-06 Thread Bhumika Goyal
Make hdlcdrv_ops structures const as they are only passed to
hdlcdrv_register function. The corresponding argument is of type const,
so make the structures const.

Signed-off-by: Bhumika Goyal 
---
 drivers/net/hamradio/baycom_par.c | 2 +-
 drivers/net/hamradio/baycom_ser_fdx.c | 2 +-
 drivers/net/hamradio/baycom_ser_hdx.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/hamradio/baycom_par.c 
b/drivers/net/hamradio/baycom_par.c
index 92b13b3..e178383 100644
--- a/drivers/net/hamradio/baycom_par.c
+++ b/drivers/net/hamradio/baycom_par.c
@@ -386,7 +386,7 @@ static int baycom_ioctl(struct net_device *dev, struct 
ifreq *ifr,
 
 /* - */
 
-static struct hdlcdrv_ops par96_ops = {
+static const struct hdlcdrv_ops par96_ops = {
.drvname = bc_drvname,
.drvinfo = bc_drvinfo,
.open= par96_open,
diff --git a/drivers/net/hamradio/baycom_ser_fdx.c 
b/drivers/net/hamradio/baycom_ser_fdx.c
index d9a646a..190f66c 100644
--- a/drivers/net/hamradio/baycom_ser_fdx.c
+++ b/drivers/net/hamradio/baycom_ser_fdx.c
@@ -508,7 +508,7 @@ static int baycom_ioctl(struct net_device *dev, struct 
ifreq *ifr,
 
 /* - */
 
-static struct hdlcdrv_ops ser12_ops = {
+static const struct hdlcdrv_ops ser12_ops = {
.drvname = bc_drvname,
.drvinfo = bc_drvinfo,
.open= ser12_open,
diff --git a/drivers/net/hamradio/baycom_ser_hdx.c 
b/drivers/net/hamradio/baycom_ser_hdx.c
index f1c8a9f..3c823c6 100644
--- a/drivers/net/hamradio/baycom_ser_hdx.c
+++ b/drivers/net/hamradio/baycom_ser_hdx.c
@@ -542,7 +542,7 @@ static int baycom_ioctl(struct net_device *dev, struct 
ifreq *ifr,
 
 /* - */
 
-static struct hdlcdrv_ops ser12_ops = {
+static const struct hdlcdrv_ops ser12_ops = {
.drvname = bc_drvname,
.drvinfo = bc_drvinfo,
.open= ser12_open,
-- 
1.9.1



[PATCH 11/12] [media] exynos4-is: constify v4l2_m2m_ops structures

2017-08-06 Thread Julia Lawall
The v4l2_m2m_ops structures are only passed as the only
argument to v4l2_m2m_init, which is declared as const.
Thus the v4l2_m2m_ops structures themselves can be const.

Done with the help of Coccinelle.

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct v4l2_m2m_ops i@p = { ... };

@ok1@
identifier r.i;
position p;
@@
v4l2_m2m_init(@p)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct v4l2_m2m_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct v4l2_m2m_ops i = { ... };
// 

Signed-off-by: Julia Lawall 

---
 drivers/media/platform/exynos4-is/fimc-m2m.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c 
b/drivers/media/platform/exynos4-is/fimc-m2m.c
index d8724fe..9027d0b 100644
--- a/drivers/media/platform/exynos4-is/fimc-m2m.c
+++ b/drivers/media/platform/exynos4-is/fimc-m2m.c
@@ -704,7 +704,7 @@ static int fimc_m2m_release(struct file *file)
.mmap   = v4l2_m2m_fop_mmap,
 };
 
-static struct v4l2_m2m_ops m2m_ops = {
+static const struct v4l2_m2m_ops m2m_ops = {
.device_run = fimc_device_run,
.job_abort  = fimc_job_abort,
 };



[PATCH 00/12] constify v4l2_m2m_ops structures

2017-08-06 Thread Julia Lawall
The v4l2_m2m_ops structures are only passed as the only
argument to v4l2_m2m_init, which is declared as const.
Thus the v4l2_m2m_ops structures themselves can be const.

Done with the help of Coccinelle.

---

 drivers/media/platform/exynos-gsc/gsc-m2m.c |2 +-
 drivers/media/platform/exynos4-is/fimc-m2m.c|2 +-
 drivers/media/platform/m2m-deinterlace.c|2 +-
 drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c |2 +-
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c|2 +-
 drivers/media/platform/mx2_emmaprp.c|2 +-
 drivers/media/platform/rcar_jpu.c   |2 +-
 drivers/media/platform/s5p-g2d/g2d.c|2 +-
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c   |2 +-
 drivers/media/platform/sti/delta/delta-v4l2.c   |2 +-
 drivers/media/platform/ti-vpe/vpe.c |2 +-
 drivers/media/platform/vim2m.c  |2 +-
 12 files changed, 12 insertions(+), 12 deletions(-)


[PATCH 06/12] [media] exynos-gsc: constify v4l2_m2m_ops structures

2017-08-06 Thread Julia Lawall
The v4l2_m2m_ops structures are only passed as the only
argument to v4l2_m2m_init, which is declared as const.
Thus the v4l2_m2m_ops structures themselves can be const.

Done with the help of Coccinelle.

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct v4l2_m2m_ops i@p = { ... };

@ok1@
identifier r.i;
position p;
@@
v4l2_m2m_init(@p)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct v4l2_m2m_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct v4l2_m2m_ops i = { ... };
// 

Signed-off-by: Julia Lawall 

---
 drivers/media/platform/exynos-gsc/gsc-m2m.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c 
b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index 33611a4..2a2994e 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -747,7 +747,7 @@ static int gsc_m2m_mmap(struct file *file, struct 
vm_area_struct *vma)
.mmap   = gsc_m2m_mmap,
 };
 
-static struct v4l2_m2m_ops gsc_m2m_ops = {
+static const struct v4l2_m2m_ops gsc_m2m_ops = {
.device_run = gsc_m2m_device_run,
.job_abort  = gsc_m2m_job_abort,
 };



[PATCH 07/12] [media] bdisp: constify v4l2_m2m_ops structures

2017-08-06 Thread Julia Lawall
The v4l2_m2m_ops structures are only passed as the only
argument to v4l2_m2m_init, which is declared as const.
Thus the v4l2_m2m_ops structures themselves can be const.

Done with the help of Coccinelle.

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct v4l2_m2m_ops i@p = { ... };

@ok1@
identifier r.i;
position p;
@@
v4l2_m2m_init(@p)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct v4l2_m2m_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct v4l2_m2m_ops i = { ... };
// 

Signed-off-by: Julia Lawall 

---
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c 
b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
index 7918b92..939da6d 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
@@ -360,7 +360,7 @@ static void bdisp_device_run(void *priv)
bdisp_job_finish(ctx, VB2_BUF_STATE_ERROR);
 }
 
-static struct v4l2_m2m_ops bdisp_m2m_ops = {
+static const struct v4l2_m2m_ops bdisp_m2m_ops = {
.device_run = bdisp_device_run,
.job_abort  = bdisp_job_abort,
 };



[PATCH 05/12] [media] vcodec: mediatek: constify v4l2_m2m_ops structures

2017-08-06 Thread Julia Lawall
The v4l2_m2m_ops structures are only passed as the only
argument to v4l2_m2m_init, which is declared as const.
Thus the v4l2_m2m_ops structures themselves can be const.

Done with the help of Coccinelle.

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct v4l2_m2m_ops i@p = { ... };

@ok1@
identifier r.i;
position p;
@@
v4l2_m2m_init(@p)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct v4l2_m2m_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct v4l2_m2m_ops i = { ... };
// 

Signed-off-by: Julia Lawall 

---
 drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c 
b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
index f17a86b..226f908 100644
--- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
+++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
@@ -865,7 +865,7 @@ static void mtk_jpeg_job_abort(void *priv)
 {
 }
 
-static struct v4l2_m2m_ops mtk_jpeg_m2m_ops = {
+static const struct v4l2_m2m_ops mtk_jpeg_m2m_ops = {
.device_run = mtk_jpeg_device_run,
.job_ready  = mtk_jpeg_job_ready,
.job_abort  = mtk_jpeg_job_abort,



[PATCH 12/12] [media] mtk-mdp: constify v4l2_m2m_ops structures

2017-08-06 Thread Julia Lawall
The v4l2_m2m_ops structures are only passed as the only
argument to v4l2_m2m_init, which is declared as const.
Thus the v4l2_m2m_ops structures themselves can be const.

Done with the help of Coccinelle.

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct v4l2_m2m_ops i@p = { ... };

@ok1@
identifier r.i;
position p;
@@
v4l2_m2m_init(@p)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct v4l2_m2m_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct v4l2_m2m_ops i = { ... };
// 

Signed-off-by: Julia Lawall 

---
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
index 3038d62..583d477 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
@@ -1225,7 +1225,7 @@ static int mtk_mdp_m2m_release(struct file *file)
.mmap   = v4l2_m2m_fop_mmap,
 };
 
-static struct v4l2_m2m_ops mtk_mdp_m2m_ops = {
+static const struct v4l2_m2m_ops mtk_mdp_m2m_ops = {
.device_run = mtk_mdp_m2m_device_run,
.job_abort  = mtk_mdp_m2m_job_abort,
 };



[PATCH 02/12] [media] media: ti-vpe: vpe: constify v4l2_m2m_ops structures

2017-08-06 Thread Julia Lawall
The v4l2_m2m_ops structures are only passed as the only
argument to v4l2_m2m_init, which is declared as const.
Thus the v4l2_m2m_ops structures themselves can be const.

Done with the help of Coccinelle.

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct v4l2_m2m_ops i@p = { ... };

@ok1@
identifier r.i;
position p;
@@
v4l2_m2m_init(@p)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct v4l2_m2m_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct v4l2_m2m_ops i = { ... };
// 

Signed-off-by: Julia Lawall 

---
 drivers/media/platform/ti-vpe/vpe.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/ti-vpe/vpe.c 
b/drivers/media/platform/ti-vpe/vpe.c
index c471514..2873c22 100644
--- a/drivers/media/platform/ti-vpe/vpe.c
+++ b/drivers/media/platform/ti-vpe/vpe.c
@@ -2430,7 +2430,7 @@ static int vpe_release(struct file *file)
.vfl_dir= VFL_DIR_M2M,
 };
 
-static struct v4l2_m2m_ops m2m_ops = {
+static const struct v4l2_m2m_ops m2m_ops = {
.device_run = device_run,
.job_ready  = job_ready,
.job_abort  = job_abort,



[PATCH 03/12] [media] s5p-g2d: constify v4l2_m2m_ops structures

2017-08-06 Thread Julia Lawall
The v4l2_m2m_ops structures are only passed as the only
argument to v4l2_m2m_init, which is declared as const.
Thus the v4l2_m2m_ops structures themselves can be const.

Done with the help of Coccinelle.

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct v4l2_m2m_ops i@p = { ... };

@ok1@
identifier r.i;
position p;
@@
v4l2_m2m_init(@p)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct v4l2_m2m_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct v4l2_m2m_ops i = { ... };
// 

Signed-off-by: Julia Lawall 

---
 drivers/media/platform/s5p-g2d/g2d.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/s5p-g2d/g2d.c 
b/drivers/media/platform/s5p-g2d/g2d.c
index 81ed5cd..bd655b5 100644
--- a/drivers/media/platform/s5p-g2d/g2d.c
+++ b/drivers/media/platform/s5p-g2d/g2d.c
@@ -611,7 +611,7 @@ static irqreturn_t g2d_isr(int irq, void *prv)
.vfl_dir= VFL_DIR_M2M,
 };
 
-static struct v4l2_m2m_ops g2d_m2m_ops = {
+static const struct v4l2_m2m_ops g2d_m2m_ops = {
.device_run = device_run,
.job_abort  = job_abort,
 };



Re: [PATCH 1/2] arm64: dts: rockchip: Add cpu operating points for RK3328 SoC

2017-08-06 Thread Heiko Stuebner
Am Freitag, 4. August 2017, 11:33:37 CEST schrieb Finley Xiao:
> This patch adds basic OPP entries for RK3328 SoC.
> 
> Signed-off-by: Finley Xiao 

applied for 4.14


Thanks
Heiko


Re: [PATCH 5/5] ubi: Allow to use read-only UBI volume with not enough PEBs

2017-08-06 Thread Pali Rohár
On Sunday 06 August 2017 11:43:25 Richard Weinberger wrote:
> Pali,
> 
> Am 25.07.2017 um 16:27 schrieb Pali Rohár:
> >> I fear this is not correct, it will disable a legit self-check of
> >> UBI volumes. If the read-only volume is corrupted/truncated and
> >> you miss PEBs, this check will no longer
> >> trigger.
> >> 
> >> Especially when dealing with nanddumps, truncation is a common
> >> problem.
> > 
> > Any idea how to fix it? Or how to handle read-only images which are
> > marked for auto-resize?
> 
> I'd vote for rejecting images that have auto-resize set when the MTD
> is read-only. In fact, using UBI on top of a read-only MTD is very
> uncommon and not recommended (for NAND). The auto-resize flag should
> be also only set when you just have created it using mkfs.ubifs. Why
> would you inspect such an image with the kernel UBIFS unless you're
> hunting down a bug in mkfs.ubifs?
> 
> Thanks,
> //richard

E.g. because when I get UBIFS image and I want to unpack it.

IMO UBIFS image which have auto-resize set is also valid UBIFS image and 
kernel should be able to read it too, even in R/O mode.

-- 
Pali Rohár
pali.ro...@gmail.com


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


Re: [PATCH v2] ARM: dts: rockchip: rk322x: add spi node and spi pinctrl

2017-08-06 Thread Heiko Stuebner
Hi,

Am Donnerstag, 3. August 2017, 10:36:49 CEST schrieb Huibin Hong:
> Add spi node and spi pinctrl for rk322x
> 
> Signed-off-by: Huibin Hong 

[...]


> + };
> +
>   wdt: watchdog@110a {
>   compatible = "rockchip,rk322x-wdt", "snps,dw-wdt";

Please make sure a patch actually applies against the mainline tree,
as here the the compatible for the watchdog looks slightly different.

In any case I've fixed that and applied it for 4.14


Heiko


Re: [PATCH] ARM: dts: rockchip: rk3288 add more iommu nodes

2017-08-06 Thread Heiko Stuebner
Am Donnerstag, 3. August 2017, 10:04:03 CEST schrieb Simon Xue:
> Add IEP/ISP/VPU/HEVC iommu nodes
> 
> Signed-off-by: Simon Xue 

applied for 4.14


Thanks
Heiko


Re: [PATCH 00/11] virtio-console: Fine-tuning for 14 function implementations

2017-08-06 Thread SF Markus Elfring
> Date: Wed, 14 Sep 2016 15:43:21 +0200
> 
> Several update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (11):
>   Use kmalloc_array() in init_vqs()
>   Less function calls in init_vqs() after error detection
>   Rename a jump label in init()
>   Rename jump labels in virtcons_probe()
>   Rename jump labels in add_port()
>   Rename a jump label in port_fops_open()
>   Rename a jump label in port_fops_splice_write()
>   Rename jump labels in port_fops_write()
>   Rename a jump label in __send_to_port()
>   Rename jump labels in alloc_buf()
>   Rename a jump label in five functions
> 
>  drivers/char/virtio_console.c | 155 
> --
>  1 file changed, 87 insertions(+), 68 deletions(-)

Would you like to take another look at change possibilities
for this software module?

Regards,
Markus


Re: [PATCH] ARM: dts: rockchip: convert rk3288 device tree files to 64 bits

2017-08-06 Thread Heiko Stuebner
Am Donnerstag, 3. August 2017, 11:21:36 CEST schrieb Tao Huang:
> In order to be able to use more than 4GB of RAM when the LPAE is
> activated, the dts must be converted in 64 bits.
> 
> Signed-off-by: Tao Huang 

applied for 4.14


Thanks
Heiko


Re: [PATCH v2] mmc: mmci_qcom_dml: include mmci_qcom_dml.h and fix #ifdef

2017-08-06 Thread kbuild test robot
Hi Masahiro,

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

url:
https://github.com/0day-ci/linux/commits/Masahiro-Yamada/mmc-mmci_qcom_dml-include-mmci_qcom_dml-h-and-fix-ifdef/20170805-173714
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

>> ERROR: "dml_hw_init" [drivers/mmc/host/mmci.ko] undefined!
>> ERROR: "dml_start_xfer" [drivers/mmc/host/mmci.ko] undefined!

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


.config.gz
Description: application/gzip


Re: [PATCH] ARM: rockchip: select ARCH_DMA_ADDR_T_64BIT for LPAE

2017-08-06 Thread Heiko Stuebner
Am Dienstag, 1. August 2017, 17:55:55 CEST schrieb Tao Huang:
> Rockchip RK3288 has some 64-bit capable DMA and therefore needs
> dma_addr_t to be a 64-bit size. One user is the Mali GPU.
> 
> Signed-off-by: Tao Huang 

applied for 4.14


Thanks
Heiko


Re: [PATCH v3 3/5] ACPI: Introduce DMA ranges parsing

2017-08-06 Thread Rafael J. Wysocki
On Sun, Aug 6, 2017 at 11:42 AM, Lorenzo Pieralisi
 wrote:
> On Sun, Aug 06, 2017 at 01:12:55PM +0800, kbuild test robot wrote:
>> Hi Lorenzo,
>>
>> [auto build test ERROR on pm/linux-next]
>> [also build test ERROR on v4.13-rc3 next-20170804]
>> [if your patch is applied to the wrong git tree, please drop us a note to 
>> help improve the system]
>>
>> url:
>> https://github.com/0day-ci/linux/commits/Lorenzo-Pieralisi/ACPICA-resource_mgr-Allow-_DMA-method-in-walk-resources/20170804-185152
>> base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 
>> linux-next
>> config: ia64-allnoconfig (attached as .config)
>> compiler: ia64-linux-gcc (GCC) 6.2.0
>> reproduce:
>> wget 
>> https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
>> ~/bin/make.cross
>> chmod +x ~/bin/make.cross
>> # save the attached .config to linux build tree
>> make.cross ARCH=ia64
>>
>> Note: the 
>> linux-review/Lorenzo-Pieralisi/ACPICA-resource_mgr-Allow-_DMA-method-in-walk-resources/20170804-185152
>>  HEAD 37e91dddbbeb771d4df0001f716607f1dd8719f8 builds fine.
>>   It only hurts bisectibility.
>
> Sigh, it is a silly v2->v3 rebase mistake, a change hunk that should be
> in patch 4 ended up in patch 3, series as a whole is fine but this must
> be fixed.
>
> Rafael, please let me know the best way to handle this, I think
> me sending a v4 is the simplest so that you can just update the branch.

Please send updates of patches [3/4] and [4/4] alone.

> Apologies and thanks.

No worries.


Re: [PATCH v2] dma-mapping: skip USB devices when configuring DMA during probe

2017-08-06 Thread kbuild test robot
Hi Johan,

[auto build test ERROR on driver-core/driver-core-testing]
[also build test ERROR on v4.13-rc3 next-20170804]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Johan-Hovold/dma-mapping-skip-USB-devices-when-configuring-DMA-during-probe/20170804-155414
config: x86_64-randconfig-a0-08061415 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/base/dma-mapping.o: In function `dma_configure':
>> (.text+0x7de): undefined reference to `usb_bus_type'
   drivers/base/dma-mapping.o: In function `dma_deconfigure':
   (.text+0x8ca): undefined reference to `usb_bus_type'

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


.config.gz
Description: application/gzip


[PATCH 03/18] staging: typec: tcpm: Split tcpm code into tcpm-core.c and tcpm-helpers.c

2017-08-06 Thread Hans de Goede
This is a preparation patch for adding more helpers.

Signed-off-by: Hans de Goede 
---
 drivers/staging/typec/Makefile|  2 +
 drivers/staging/typec/{tcpm.c => tcpm-core.c} | 40 --
 drivers/staging/typec/tcpm-helpers.c  | 60 +++
 3 files changed, 62 insertions(+), 40 deletions(-)
 rename drivers/staging/typec/{tcpm.c => tcpm-core.c} (98%)
 create mode 100644 drivers/staging/typec/tcpm-helpers.c

diff --git a/drivers/staging/typec/Makefile b/drivers/staging/typec/Makefile
index 30a7e29cbc9e..bb7472ec04ab 100644
--- a/drivers/staging/typec/Makefile
+++ b/drivers/staging/typec/Makefile
@@ -1,3 +1,5 @@
 obj-$(CONFIG_TYPEC_TCPM)   += tcpm.o
 obj-$(CONFIG_TYPEC_TCPCI)  += tcpci.o
 obj-y  += fusb302/
+
+tcpm-objs  = tcpm-core.o tcpm-helpers.o
\ No newline at end of file
diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm-core.c
similarity index 98%
rename from drivers/staging/typec/tcpm.c
rename to drivers/staging/typec/tcpm-core.c
index 06bb0e640bcf..9f5adace4309 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/staging/typec/tcpm-core.c
@@ -16,7 +16,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -3533,45 +3532,6 @@ void tcpm_unregister_port(struct tcpm_port *port)
 }
 EXPORT_SYMBOL_GPL(tcpm_unregister_port);
 
-/* Generic (helper) implementations for some tcpc_dev callbacks */
-int tcpm_get_usb2_current_limit_extcon(struct tcpc_dev *tcpc)
-{
-   struct extcon_dev *extcon = tcpc->usb2_extcon;
-   int current_limit = 0;
-   unsigned long timeout;
-
-   if (!extcon)
-   return 0;
-
-   /*
-* USB2 Charger detection may still be in progress when we get here,
-* this can take upto 600ms, wait 800ms max.
-*/
-   timeout = jiffies + msecs_to_jiffies(800);
-   do {
-   if (extcon_get_state(extcon, EXTCON_CHG_USB_SDP) == 1) {
-   current_limit = 500;
-   break;
-   }
-
-   if (extcon_get_state(extcon, EXTCON_CHG_USB_CDP) == 1 ||
-   extcon_get_state(extcon, EXTCON_CHG_USB_ACA) == 1) {
-   current_limit = 1500;
-   break;
-   }
-
-   if (extcon_get_state(extcon, EXTCON_CHG_USB_DCP) == 1) {
-   current_limit = 2000;
-   break;
-   }
-
-   msleep(50);
-   } while (time_before(jiffies, timeout));
-
-   return current_limit;
-}
-EXPORT_SYMBOL_GPL(tcpm_get_usb2_current_limit_extcon);
-
 MODULE_AUTHOR("Guenter Roeck ");
 MODULE_DESCRIPTION("USB Type-C Port Manager");
 MODULE_LICENSE("GPL");
diff --git a/drivers/staging/typec/tcpm-helpers.c 
b/drivers/staging/typec/tcpm-helpers.c
new file mode 100644
index ..0c87ec9936e1
--- /dev/null
+++ b/drivers/staging/typec/tcpm-helpers.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2017 Hans de Goede 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "tcpm.h"
+
+/* Generic (helper) implementations for some tcpc_dev callbacks */
+int tcpm_get_usb2_current_limit_extcon(struct tcpc_dev *tcpc)
+{
+   struct extcon_dev *extcon = tcpc->usb2_extcon;
+   int current_limit = 0;
+   unsigned long timeout;
+
+   if (!extcon)
+   return 0;
+
+   /*
+* USB2 Charger detection may still be in progress when we get here,
+* this can take upto 600ms, wait 800ms max.
+*/
+   timeout = jiffies + msecs_to_jiffies(800);
+   do {
+   if (extcon_get_state(extcon, EXTCON_CHG_USB_SDP) == 1) {
+   current_limit = 500;
+   break;
+   }
+
+   if (extcon_get_state(extcon, EXTCON_CHG_USB_CDP) == 1 ||
+   extcon_get_state(extcon, EXTCON_CHG_USB_ACA) == 1) {
+   current_limit = 1500;
+   break;
+   }
+
+   if (extcon_get_state(extcon, EXTCON_CHG_USB_DCP) == 1) {
+   current_limit = 2000;
+   break;
+   }
+
+   msleep(50);
+   } while (time_before(jiffies, timeout));
+
+   return current_limit;
+}
+EXPORT_SYMBOL_GPL(tcpm_get_usb2_current_limit_extcon);
-- 
2.13.3



[PATCH 07/18] staging: typec: fusb302: Use client->irq as irq if set

2017-08-06 Thread Hans de Goede
The fusb302 is also used on x86 systems where the platform code sets
the irq in client->irq and there is no gpio named fcs,int_n.

Signed-off-by: Hans de Goede 
---
 drivers/staging/typec/fusb302/fusb302.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/typec/fusb302/fusb302.c 
b/drivers/staging/typec/fusb302/fusb302.c
index 8ceaef8ecf17..be454b5ff6c7 100644
--- a/drivers/staging/typec/fusb302/fusb302.c
+++ b/drivers/staging/typec/fusb302/fusb302.c
@@ -1735,9 +1735,13 @@ static int fusb302_probe(struct i2c_client *client,
goto destroy_workqueue;
}
 
-   ret = init_gpio(chip);
-   if (ret < 0)
-   goto destroy_workqueue;
+   if (client->irq) {
+   chip->gpio_int_n_irq = client->irq;
+   } else {
+   ret = init_gpio(chip);
+   if (ret < 0)
+   goto destroy_workqueue;
+   }
 
chip->tcpm_port = tcpm_register_port(>dev, >tcpc_dev);
if (IS_ERR(chip->tcpm_port)) {
-- 
2.13.3



[PATCH 05/18] staging: typec: fusb302: Set max supply voltage to 5V

2017-08-06 Thread Hans de Goede
Anything higher then 5V may damage hardware not capable of it, so
the only sane default here is 5V. If a board is able to handle a
higher voltage that should come from board specific data such as
device-tree and not be hard coded into the fusb302 code.

Signed-off-by: Hans de Goede 
---
 drivers/staging/typec/fusb302/fusb302.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/typec/fusb302/fusb302.c 
b/drivers/staging/typec/fusb302/fusb302.c
index 03a3809d18f0..6baed06a3c0d 100644
--- a/drivers/staging/typec/fusb302/fusb302.c
+++ b/drivers/staging/typec/fusb302/fusb302.c
@@ -1187,9 +1187,9 @@ static const struct tcpc_config fusb302_tcpc_config = {
.nr_src_pdo = ARRAY_SIZE(src_pdo),
.snk_pdo = snk_pdo,
.nr_snk_pdo = ARRAY_SIZE(snk_pdo),
-   .max_snk_mv = 9000,
+   .max_snk_mv = 5000,
.max_snk_ma = 3000,
-   .max_snk_mw = 27000,
+   .max_snk_mw = 15000,
.operating_snk_mw = 2500,
.type = TYPEC_PORT_DRP,
.default_role = TYPEC_SINK,
-- 
2.13.3



[PATCH 15/18] power: supply: bq24190_charger: Get input_current_limit from our supplier

2017-08-06 Thread Hans de Goede
On some devices the USB Type-C port power (USB PD 2.0) negotiation is
done by a separate port-controller IC, while the current limit is
controlled through another (charger) IC.

It has been decided to model this by modelling the external Type-C
power brick (adapter/charger) as a power-supply class device which
supplies the charger-IC, with its voltage-now and current-max representing
the negotiated voltage and max current draw.

This commit adds support for this to the bq24190_charger driver by calling
power_supply_set_input_current_limit_from_supplier helper if the
"input-current-limit-from-supplier" device-property is set.

Note this replaces the functionality to get the current-limit from an
extcon device, which will be removed in a follow-up commit.

Signed-off-by: Hans de Goede 
---
 drivers/power/supply/bq24190_charger.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/power/supply/bq24190_charger.c 
b/drivers/power/supply/bq24190_charger.c
index d78e2c6dc127..1f6424f0772f 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -161,6 +161,7 @@ struct bq24190_dev_info {
charmodel_name[I2C_NAME_SIZE];
boolinitialized;
boolirq_event;
+   boolinput_current_limit_from_supplier;
struct mutexf_reg_lock;
u8  f_reg;
u8  ss_reg;
@@ -1137,6 +1138,14 @@ static int bq24190_charger_property_is_writeable(struct 
power_supply *psy,
return ret;
 }
 
+static void bq24190_charger_external_power_changed(struct power_supply *psy)
+{
+   struct bq24190_dev_info *bdi = power_supply_get_drvdata(psy);
+
+   if (bdi->input_current_limit_from_supplier)
+   power_supply_set_input_current_limit_from_supplier(psy);
+}
+
 static enum power_supply_property bq24190_charger_properties[] = {
POWER_SUPPLY_PROP_CHARGE_TYPE,
POWER_SUPPLY_PROP_HEALTH,
@@ -1165,6 +1174,7 @@ static const struct power_supply_desc 
bq24190_charger_desc = {
.get_property   = bq24190_charger_get_property,
.set_property   = bq24190_charger_set_property,
.property_is_writeable  = bq24190_charger_property_is_writeable,
+   .external_power_changed = bq24190_charger_external_power_changed,
 };
 
 /* Battery power supply property routines */
@@ -1654,6 +1664,10 @@ static int bq24190_probe(struct i2c_client *client,
return -EINVAL;
}
 
+   bdi->input_current_limit_from_supplier =
+   device_property_read_bool(dev,
+ "input-current-limit-from-supplier");
+
/*
 * Devicetree platforms should get extcon via phandle (not yet 
supported).
 * On ACPI platforms, extcon clients may invoke us with:
-- 
2.13.3



[PATCH 09/18] staging: typec: fusb302: Use tcpm_set_current_limit_psy

2017-08-06 Thread Hans de Goede
Register a power_supply and use tcpm_set_current_limit_psy as
set_current_limit so that another driver (e.g. the charger driver) can
pick the limit up and configure the system accordingly.

Signed-off-by: Hans de Goede 
---
 drivers/staging/typec/fusb302/fusb302.c | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/typec/fusb302/fusb302.c 
b/drivers/staging/typec/fusb302/fusb302.c
index 1d8c9b66df2f..e1e08f57af99 100644
--- a/drivers/staging/typec/fusb302/fusb302.c
+++ b/drivers/staging/typec/fusb302/fusb302.c
@@ -854,17 +854,6 @@ static int tcpm_set_vbus(struct tcpc_dev *dev, bool on, 
bool charge)
return ret;
 }
 
-static int tcpm_set_current_limit(struct tcpc_dev *dev, u32 max_ma, u32 mv)
-{
-   struct fusb302_chip *chip = container_of(dev, struct fusb302_chip,
-tcpc_dev);
-
-   fusb302_log(chip, "current limit: %d ma, %d mv (not implemented)",
-   max_ma, mv);
-
-   return 0;
-}
-
 static int fusb302_pd_tx_flush(struct fusb302_chip *chip)
 {
return fusb302_i2c_set_bits(chip, FUSB_REG_CONTROL0,
@@ -1208,7 +1197,7 @@ static void init_tcpc_dev(struct tcpc_dev 
*fusb302_tcpc_dev)
fusb302_tcpc_dev->set_polarity = tcpm_set_polarity;
fusb302_tcpc_dev->set_vconn = tcpm_set_vconn;
fusb302_tcpc_dev->set_vbus = tcpm_set_vbus;
-   fusb302_tcpc_dev->set_current_limit = tcpm_set_current_limit;
+   fusb302_tcpc_dev->set_current_limit = tcpm_set_current_limit_psy;
fusb302_tcpc_dev->set_pd_rx = tcpm_set_pd_rx;
fusb302_tcpc_dev->set_roles = tcpm_set_roles;
fusb302_tcpc_dev->start_drp_toggling = tcpm_start_drp_toggling;
@@ -1733,6 +1722,11 @@ static int fusb302_probe(struct i2c_client *client,
return -EPROBE_DEFER;
}
 
+   ret = tcpm_register_psy(chip->dev, >tcpc_dev,
+   "fusb302-typec-source");
+   if (ret < 0)
+   return ret;
+
ret = fusb302_debugfs_init(chip);
if (ret < 0)
return ret;
-- 
2.13.3



[PATCH 11/18] power: supply: Fix power_supply_am_i_supplied to return -ENODEV when apropriate

2017-08-06 Thread Hans de Goede
Commit 2848e039c562 ("power: supply: Make power_supply_am_i_supplied return
-ENODEV if there are no suppliers") was supposed to make
power_supply_am_i_supplied() return -ENODEV when there are no supplies
which supply the supply passed to it.

But instead it will only return -ENODEV when there are no supplies at
all as data->count++; is incremented on every call of the iterator, rather
then only when __power_supply_is_supplied_by returns true. This commit
fixes this.

Fixes: 2848e039c562 ("power: supply: Make power_supply_am_i_supplied ...")
Signed-off-by: Hans de Goede 
---
 drivers/power/supply/power_supply_core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/power/supply/power_supply_core.c 
b/drivers/power/supply/power_supply_core.c
index 540d3e0aa011..0741fcef3b44 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -314,11 +314,12 @@ static int __power_supply_am_i_supplied(struct device 
*dev, void *_data)
struct power_supply *epsy = dev_get_drvdata(dev);
struct psy_am_i_supplied_data *data = _data;
 
-   data->count++;
-   if (__power_supply_is_supplied_by(epsy, data->psy))
+   if (__power_supply_is_supplied_by(epsy, data->psy)) {
+   data->count++;
if (!epsy->desc->get_property(epsy, POWER_SUPPLY_PROP_ONLINE,
))
return ret.intval;
+   }
 
return 0;
 }
-- 
2.13.3



[PATCH 18/18] i2c-cht-wc: Add device-properties for fusb302 integration

2017-08-06 Thread Hans de Goede
Add device-properties to make the bq24292i controller connected to
the bus get its input-current-limit from the fusb302 Type-C port
controller which is used on boards with the cht-wc PMIC.

Signed-off-by: Hans de Goede 
---
 drivers/i2c/busses/Kconfig  | 5 +
 drivers/i2c/busses/i2c-cht-wc.c | 5 -
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index f20b1f84013a..6de21a81b00b 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -197,6 +197,11 @@ config I2C_CHT_WC
  SMBus controller found in the Intel Cherry Trail Whiskey Cove PMIC
  found on some Intel Cherry Trail systems.
 
+ Note this controller is hooked up to a TI bq24292i charger-IC,
+ combined with a FUSB302 Type-C port-controller as such it is advised
+ to also select CONFIG_CHARGER_BQ24190=m and CONFIG_TYPEC_FUSB302=m
+ (the fusb302 driver currently is in drivers/staging).
+
 config I2C_NFORCE2
tristate "Nvidia nForce2, nForce3 and nForce4"
depends on PCI
diff --git a/drivers/i2c/busses/i2c-cht-wc.c b/drivers/i2c/busses/i2c-cht-wc.c
index ccf0785bcb75..08229fb12615 100644
--- a/drivers/i2c/busses/i2c-cht-wc.c
+++ b/drivers/i2c/busses/i2c-cht-wc.c
@@ -211,8 +211,11 @@ static const struct irq_chip cht_wc_i2c_irq_chip = {
.name   = "cht_wc_ext_chrg_irq_chip",
 };
 
+static const char * const bq24190_suppliers[] = { "fusb302-typec-source" };
+
 static const struct property_entry bq24190_props[] = {
-   PROPERTY_ENTRY_STRING("extcon-name", "cht_wcove_pwrsrc"),
+   PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq24190_suppliers),
+   PROPERTY_ENTRY_BOOL("input-current-limit-from-supplier"),
PROPERTY_ENTRY_BOOL("omit-battery-class"),
PROPERTY_ENTRY_BOOL("disable-reset"),
{ }
-- 
2.13.3



[PATCH 13/18] power: supply: bq24190_charger: Export 5V boost converter as regulator

2017-08-06 Thread Hans de Goede
Register the 5V boost converter as a regulator named
"regulator-bq24190-usb-vbus". Note the name includes "bq24190" because
the bq24190 family is also used on ACPI devices where there are no
device-tree phandles, so regulator_get will fallback to the name and thus
it must be unique on the system.

Signed-off-by: Hans de Goede 
---
 drivers/power/supply/bq24190_charger.c | 121 +
 1 file changed, 121 insertions(+)

diff --git a/drivers/power/supply/bq24190_charger.c 
b/drivers/power/supply/bq24190_charger.c
index d5a707e14526..f25ea9c4acca 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -16,6 +16,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -504,6 +506,121 @@ static int bq24190_sysfs_create_group(struct 
bq24190_dev_info *bdi)
 static inline void bq24190_sysfs_remove_group(struct bq24190_dev_info *bdi) {}
 #endif
 
+#ifdef CONFIG_REGULATOR
+static int bq24190_vbus_enable(struct regulator_dev *dev)
+{
+   struct bq24190_dev_info *bdi = rdev_get_drvdata(dev);
+   int ret;
+
+   ret = pm_runtime_get_sync(bdi->dev);
+   if (ret < 0) {
+   dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret);
+   pm_runtime_put_noidle(bdi->dev);
+   return ret;
+   }
+
+   ret = bq24190_write_mask(bdi, BQ24190_REG_POC,
+BQ24190_REG_POC_CHG_CONFIG_MASK,
+BQ24190_REG_POC_CHG_CONFIG_SHIFT,
+BQ24190_REG_POC_CHG_CONFIG_OTG);
+
+   pm_runtime_mark_last_busy(bdi->dev);
+   pm_runtime_put_autosuspend(bdi->dev);
+
+   return ret;
+}
+
+static int bq24190_vbus_disable(struct regulator_dev *dev)
+{
+   struct bq24190_dev_info *bdi = rdev_get_drvdata(dev);
+   int ret;
+
+   ret = pm_runtime_get_sync(bdi->dev);
+   if (ret < 0) {
+   dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret);
+   pm_runtime_put_noidle(bdi->dev);
+   return ret;
+   }
+
+   ret = bq24190_write_mask(bdi, BQ24190_REG_POC,
+BQ24190_REG_POC_CHG_CONFIG_MASK,
+BQ24190_REG_POC_CHG_CONFIG_SHIFT,
+BQ24190_REG_POC_CHG_CONFIG_CHARGE);
+
+   pm_runtime_mark_last_busy(bdi->dev);
+   pm_runtime_put_autosuspend(bdi->dev);
+
+   return ret;
+}
+
+static int bq24190_vbus_is_enabled(struct regulator_dev *dev)
+{
+   struct bq24190_dev_info *bdi = rdev_get_drvdata(dev);
+   int ret;
+   u8 val;
+
+   ret = pm_runtime_get_sync(bdi->dev);
+   if (ret < 0) {
+   dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret);
+   pm_runtime_put_noidle(bdi->dev);
+   return ret;
+   }
+
+   ret = bq24190_read_mask(bdi, BQ24190_REG_POC,
+   BQ24190_REG_POC_CHG_CONFIG_MASK,
+   BQ24190_REG_POC_CHG_CONFIG_SHIFT, );
+
+   pm_runtime_mark_last_busy(bdi->dev);
+   pm_runtime_put_autosuspend(bdi->dev);
+
+   return ret ? ret : val == BQ24190_REG_POC_CHG_CONFIG_OTG;
+}
+
+static const struct regulator_ops bq24190_vbus_ops = {
+   .enable = bq24190_vbus_enable,
+   .disable = bq24190_vbus_disable,
+   .is_enabled = bq24190_vbus_is_enabled,
+};
+
+static const struct regulator_desc bq24190_vbus_desc = {
+   .name = "regulator-bq24190-usb-vbus",
+   .type = REGULATOR_VOLTAGE,
+   .owner = THIS_MODULE,
+   .ops = _vbus_ops,
+   .fixed_uV = 500,
+   .n_voltages = 1,
+};
+
+static const struct regulator_init_data bq24190_vbus_init_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+};
+
+static int bq24190_register_vbus_regulator(struct bq24190_dev_info *bdi)
+{
+   struct regulator_config cfg = { };
+   struct regulator_dev *reg;
+   int ret = 0;
+
+   cfg.dev = bdi->dev;
+   cfg.init_data = _vbus_init_data;
+   cfg.driver_data = bdi;
+   reg = devm_regulator_register(bdi->dev, _vbus_desc, );
+   if (IS_ERR(reg)) {
+   ret = PTR_ERR(reg);
+   dev_err(bdi->dev, "Can't register regulator: %d\n", ret);
+   }
+
+   return ret;
+}
+#else
+static int bq24190_register_vbus_regulator(struct bq24190_dev_info *bdi)
+{
+   return 0;
+}
+#endif
+
 /*
  * According to the "Host Mode and default Mode" section of the
  * manual, a write to any register causes the bq24190 to switch
@@ -1530,6 +1647,10 @@ static int bq24190_probe(struct i2c_client *client,
goto out_pmrt;
}
 
+   ret = bq24190_register_vbus_regulator(bdi);
+   if (ret < 0)
+   goto out_pmrt;
+
ret = bq24190_hw_init(bdi);
if (ret < 0) {
dev_err(dev, "Hardware init failed\n");
-- 
2.13.3



[PATCH 17/18] platform/x86: intel_cht_int33fe Update fusb302 type string, add properties

2017-08-06 Thread Hans de Goede
The fusb302 driver as merged in staging uses "typec_fusb302" as i2c-id
rather then just "fusb302" and needs us to set a number of device-
properties, adjust the intel_cht_int33fe driver accordingly.

One of the properties set is max-snk-mv which makes the fusb302 driver
negotiate up to 12V charging voltage, which is a bad idea on boards
which are not setup to handle this, so this commit also adds 2 extra
sanity checks to make sure that the expected Whiskey Cove PMIC +
TI bq24292i charger combo, which can handle 12V, is present.

Unfortunately the entire INT33FE device is undocumented, so there is no
other way to ensure doing 12V charging is safe.

Signed-off-by: Hans de Goede 
---
 drivers/platform/x86/Kconfig |  6 -
 drivers/platform/x86/intel_cht_int33fe.c | 39 ++--
 2 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index ef738602f897..2e412a3dacb1 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -793,7 +793,7 @@ config ACPI_CMPC
 
 config INTEL_CHT_INT33FE
tristate "Intel Cherry Trail ACPI INT33FE Driver"
-   depends on X86 && ACPI && I2C
+   depends on X86 && ACPI && I2C && REGULATOR
---help---
  This driver add support for the INT33FE ACPI device found on
  some Intel Cherry Trail devices.
@@ -804,6 +804,10 @@ config INTEL_CHT_INT33FE
  This driver instantiates i2c-clients for these, so that standard
  i2c drivers for these chips can bind to the them.
 
+ If you enable this driver it is advised to also select
+ CONFIG_CHARGER_BQ24190=m, CONFIG_BATTERY_MAX17042=m and
+ CONFIG_TYPEC_FUSB302=m (currently in drivers/staging).
+
 config INTEL_INT0002_VGPIO
tristate "Intel ACPI INT0002 Virtual GPIO driver"
depends on GPIOLIB && ACPI
diff --git a/drivers/platform/x86/intel_cht_int33fe.c 
b/drivers/platform/x86/intel_cht_int33fe.c
index da706e2c4232..69f8ab0d8d55 100644
--- a/drivers/platform/x86/intel_cht_int33fe.c
+++ b/drivers/platform/x86/intel_cht_int33fe.c
@@ -24,9 +24,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define EXPECTED_PTYPE 4
+#define BQ24292I_REGULATOR "regulator-bq24190-usb-vbus"
 
 struct cht_int33fe_data {
struct i2c_client *max17047;
@@ -41,14 +43,24 @@ static const struct property_entry max17047_props[] = {
{ }
 };
 
+static const struct property_entry fusb302_props[] = {
+   PROPERTY_ENTRY_STRING("fcs,extcon-name", "cht_wcove_pwrsrc"),
+   PROPERTY_ENTRY_STRING("fcs,vbus-regulator-name", BQ24292I_REGULATOR),
+   PROPERTY_ENTRY_U32("fcs,max-snk-mv", 12000),
+   PROPERTY_ENTRY_U32("fcs,max-snk-ma", 3000),
+   PROPERTY_ENTRY_U32("fcs,max-snk-mw", 36000),
+   { }
+};
+
 static int cht_int33fe_probe(struct i2c_client *client)
 {
struct device *dev = >dev;
struct i2c_board_info board_info;
struct cht_int33fe_data *data;
+   struct regulator *regulator;
unsigned long long ptyp;
acpi_status status;
-   int fusb302_irq;
+   int ret, fusb302_irq;
 
status = acpi_evaluate_integer(ACPI_HANDLE(dev), "PTYP", NULL, );
if (ACPI_FAILURE(status)) {
@@ -63,6 +75,28 @@ static int cht_int33fe_probe(struct i2c_client *client)
if (ptyp != EXPECTED_PTYPE)
return -ENODEV;
 
+   /* Check presence of INT34D3 (hardware-rev 3) expected for ptype == 4 */
+   if (!acpi_dev_present("INT34D3", "1", 3)) {
+   dev_err(dev, "Error PTYPE == %d, but no INT34D3 device\n",
+   EXPECTED_PTYPE);
+   return -ENODEV;
+   }
+
+   /*
+* We expect the Whiskey Cove PMIC to be paired with a TI bq24292i
+* charger-IC, allowing charging with up to 12V, so we set the fusb302
+* "fcs,max-snk-mv" device property to 12000 mV. Allowing 12V with
+* another charger-IC is not a good idea, so we get the bq24292i vbus
+* regulator here, to ensure that things are as expected.
+* Use regulator_get_optional so that we don't get a dummy-regulator.
+*/
+   regulator = regulator_get_optional(dev, BQ24292I_REGULATOR);
+   if (IS_ERR(regulator)) {
+   ret = PTR_ERR(regulator);
+   return (ret == -ENODEV) ? -EPROBE_DEFER : ret;
+   }
+   regulator_put(regulator);
+
/* The FUSB302 uses the irq at index 1 and is the only irq user */
fusb302_irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(dev), 1);
if (fusb302_irq < 0) {
@@ -84,7 +118,8 @@ static int cht_int33fe_probe(struct i2c_client *client)
return -EPROBE_DEFER; /* Wait for the i2c-adapter to load */
 
memset(_info, 0, sizeof(board_info));
-   strlcpy(board_info.type, "fusb302", I2C_NAME_SIZE);
+   strlcpy(board_info.type, "typec_fusb302", I2C_NAME_SIZE);
+   

[PATCH 12/18] power: supply: Add power_supply_set_input_current_limit_from_supplier helper

2017-08-06 Thread Hans de Goede
On some devices the USB Type-C port power (USB PD 2.0) negotiation is
done by a separate port-controller IC, while the current limit is
controlled through another (charger) IC.

It has been decided to model this by modelling the external Type-C
power brick (adapter/charger) as a power-supply class device which
supplies the charger-IC, with its voltage-now and current-max representing
the negotiated voltage and max current draw.

This commit adds a power_supply_set_input_current_limit_from_supplier
helper function which charger power-supply drivers can call to get
the max-current from their supplier and have this applied
through their set_property call-back to their input-current-limit.

Signed-off-by: Hans de Goede 
---
 drivers/power/supply/power_supply_core.c | 41 
 include/linux/power_supply.h |  2 ++
 2 files changed, 43 insertions(+)

diff --git a/drivers/power/supply/power_supply_core.c 
b/drivers/power/supply/power_supply_core.c
index 0741fcef3b44..3f92574222de 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -375,6 +375,47 @@ int power_supply_is_system_supplied(void)
 }
 EXPORT_SYMBOL_GPL(power_supply_is_system_supplied);
 
+static int __power_supply_get_supplier_max_current(struct device *dev,
+  void *data)
+{
+   union power_supply_propval ret = {0,};
+   struct power_supply *epsy = dev_get_drvdata(dev);
+   struct power_supply *psy = data;
+
+   if (__power_supply_is_supplied_by(epsy, psy))
+   if (!epsy->desc->get_property(epsy,
+ POWER_SUPPLY_PROP_CURRENT_MAX,
+ ))
+   return ret.intval;
+
+   return 0;
+}
+
+int power_supply_set_input_current_limit_from_supplier(struct power_supply 
*psy)
+{
+   union power_supply_propval val = {0,};
+   int curr;
+
+   if (!psy->desc->set_property)
+   return -EINVAL;
+
+   /*
+* This function is not intended for use with a supply with multiple
+* suppliers, we simply pick the first supply to report a non 0
+* max-current.
+*/
+   curr = class_for_each_device(power_supply_class, NULL, psy,
+ __power_supply_get_supplier_max_current);
+   if (curr <= 0)
+   return (curr == 0) ? -ENODEV : curr;
+
+   val.intval = curr;
+
+   return psy->desc->set_property(psy,
+   POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, );
+}
+EXPORT_SYMBOL_GPL(power_supply_set_input_current_limit_from_supplier);
+
 int power_supply_set_battery_charged(struct power_supply *psy)
 {
if (atomic_read(>use_cnt) >= 0 &&
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index de89066b72b1..79e90b3d3288 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -332,6 +332,8 @@ extern int power_supply_get_battery_info(struct 
power_supply *psy,
 struct power_supply_battery_info 
*info);
 extern void power_supply_changed(struct power_supply *psy);
 extern int power_supply_am_i_supplied(struct power_supply *psy);
+extern int power_supply_set_input_current_limit_from_supplier(
+struct power_supply *psy);
 extern int power_supply_set_battery_charged(struct power_supply *psy);
 
 #ifdef CONFIG_POWER_SUPPLY
-- 
2.13.3



[PATCH 06/18] staging: typec: fusb302: Get max snk mv/ma/mw from device-properties

2017-08-06 Thread Hans de Goede
This is board specific info so it should come from board config, such
as devicetree.

I've chosen to prefix these with "fcs," treating them as fusb302 driver
specific. We may want to revisit to replace these with properties which
are part of a (to be written) generic type-c controller devicetree
binding.

Signed-off-by: Hans de Goede 
---
 drivers/staging/typec/TODO  |  5 +
 drivers/staging/typec/fusb302/fusb302.c | 18 +-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/typec/TODO b/drivers/staging/typec/TODO
index bc1f97a2d1bf..98b0dbd5752b 100644
--- a/drivers/staging/typec/TODO
+++ b/drivers/staging/typec/TODO
@@ -11,5 +11,10 @@ tcpm:
 tcpci:
 - Test with real hardware
 
+fusb302:
+- We may want to replace the  "fcs,max-snk-mv", "fcs,max-snk-ma",
+  "fcs,max-snk-mw" and "fcs,operating-snk-mw" device(tree) properties with
+  properties which are part of a generic type-c controller devicetree binding.
+
 Please send patches to Guenter Roeck  and copy
 Heikki Krogerus .
diff --git a/drivers/staging/typec/fusb302/fusb302.c 
b/drivers/staging/typec/fusb302/fusb302.c
index 6baed06a3c0d..8ceaef8ecf17 100644
--- a/drivers/staging/typec/fusb302/fusb302.c
+++ b/drivers/staging/typec/fusb302/fusb302.c
@@ -90,6 +90,7 @@ struct fusb302_chip {
struct i2c_client *i2c_client;
struct tcpm_port *tcpm_port;
struct tcpc_dev tcpc_dev;
+   struct tcpc_config tcpc_config;
 
struct regulator *vbus;
 
@@ -1198,7 +1199,6 @@ static const struct tcpc_config fusb302_tcpc_config = {
 
 static void init_tcpc_dev(struct tcpc_dev *fusb302_tcpc_dev)
 {
-   fusb302_tcpc_dev->config = _tcpc_config;
fusb302_tcpc_dev->init = tcpm_init;
fusb302_tcpc_dev->get_vbus = tcpm_get_vbus;
fusb302_tcpc_dev->set_cc = tcpm_set_cc;
@@ -1684,7 +1684,9 @@ static int fusb302_probe(struct i2c_client *client,
 {
struct fusb302_chip *chip;
struct i2c_adapter *adapter;
+   struct device *dev = >dev;
int ret = 0;
+   u32 val;
 
adapter = to_i2c_adapter(client->dev.parent);
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) {
@@ -1699,8 +1701,22 @@ static int fusb302_probe(struct i2c_client *client,
chip->i2c_client = client;
i2c_set_clientdata(client, chip);
chip->dev = >dev;
+   chip->tcpc_config = fusb302_tcpc_config;
+   chip->tcpc_dev.config = >tcpc_config;
mutex_init(>lock);
 
+   if (device_property_read_u32(dev, "fcs,max-snk-mv", ) == 0)
+   chip->tcpc_config.max_snk_mv = val;
+
+   if (device_property_read_u32(dev, "fcs,max-snk-ma", ) == 0)
+   chip->tcpc_config.max_snk_ma = val;
+
+   if (device_property_read_u32(dev, "fcs,max-snk-mw", ) == 0)
+   chip->tcpc_config.max_snk_mw = val;
+
+   if (device_property_read_u32(dev, "fcs,operating-snk-mw", ) == 0)
+   chip->tcpc_config.operating_snk_mw = val;
+
ret = fusb302_debugfs_init(chip);
if (ret < 0)
return ret;
-- 
2.13.3



[PATCH 04/18] staging: typec: tcpm: Add helpers for exporting current-limit through a psy

2017-08-06 Thread Hans de Goede
Not all type-c port-controller can control the current-limit directly,
in cases where the current limit can not be controlled directly it needs
to be exported so that another driver (e.g. the charger driver) can pick
the limit up and configure the system accordingly.

The power-supply subsys already provides infrastructure for this,
power-supply devices have the notion of being supplied by another
power-supply and have properties through which we can export the
current-limit.

This commits adds 2 helper functions for use by port-controller drivers
which want to export the current-limit info in this way:

int tcpm_register_psy(struct device *dev, struct tcpc_dev *tcpc,
  const char *name);
int tcpm_set_current_limit_psy(struct tcpc_dev *tcpc, u32 max_ma, u32 mv);

Signed-off-by: Hans de Goede 
---
 drivers/staging/typec/tcpm-helpers.c | 66 
 drivers/staging/typec/tcpm.h |  9 +
 2 files changed, 75 insertions(+)

diff --git a/drivers/staging/typec/tcpm-helpers.c 
b/drivers/staging/typec/tcpm-helpers.c
index 0c87ec9936e1..8f7699576878 100644
--- a/drivers/staging/typec/tcpm-helpers.c
+++ b/drivers/staging/typec/tcpm-helpers.c
@@ -20,6 +20,60 @@
 
 #include "tcpm.h"
 
+static int tcpm_psy_get_property(struct power_supply *psy,
+enum power_supply_property psp,
+union power_supply_propval *val)
+{
+   struct tcpc_dev *tcpc = power_supply_get_drvdata(psy);
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   val->intval = tcpc->supply_voltage * 1000; /* mV -> µV */
+   break;
+   case POWER_SUPPLY_PROP_CURRENT_MAX:
+   val->intval = tcpc->current_limit * 1000; /* mA -> µA */
+   break;
+   default:
+   return -ENODATA;
+   }
+
+   return 0;
+}
+
+static enum power_supply_property tcpm_psy_properties[] = {
+   POWER_SUPPLY_PROP_VOLTAGE_NOW,
+   POWER_SUPPLY_PROP_CURRENT_MAX,
+};
+
+int tcpm_register_psy(struct device *dev, struct tcpc_dev *tcpc,
+ const char *name)
+{
+   struct power_supply_config psy_cfg = {};
+   struct power_supply_desc *desc;
+   int ret = 0;
+
+   desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL);
+   if (!desc)
+   return -ENOMEM;
+
+   desc->name  = name;
+   desc->type  = POWER_SUPPLY_TYPE_USB;
+   desc->properties= tcpm_psy_properties;
+   desc->num_properties= ARRAY_SIZE(tcpm_psy_properties);
+   desc->get_property  = tcpm_psy_get_property;
+   psy_cfg.drv_data= tcpc;
+
+   tcpc->psy = devm_power_supply_register(dev, desc, _cfg);
+   if (IS_ERR(tcpc->psy)) {
+   ret = PTR_ERR(tcpc->psy);
+   tcpc->psy = NULL;
+   dev_err(dev, "Error registering power-supply: %d\n", ret);
+   }
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(tcpm_register_psy);
+
 /* Generic (helper) implementations for some tcpc_dev callbacks */
 int tcpm_get_usb2_current_limit_extcon(struct tcpc_dev *tcpc)
 {
@@ -58,3 +112,15 @@ int tcpm_get_usb2_current_limit_extcon(struct tcpc_dev 
*tcpc)
return current_limit;
 }
 EXPORT_SYMBOL_GPL(tcpm_get_usb2_current_limit_extcon);
+
+int tcpm_set_current_limit_psy(struct tcpc_dev *tcpc, u32 max_ma, u32 mv)
+{
+   tcpc->supply_voltage = mv;
+   tcpc->current_limit = max_ma;
+
+   if (tcpc->psy)
+   power_supply_changed(tcpc->psy);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(tcpm_set_current_limit_psy);
diff --git a/drivers/staging/typec/tcpm.h b/drivers/staging/typec/tcpm.h
index 35e8c1e7dba0..1b1475b487b5 100644
--- a/drivers/staging/typec/tcpm.h
+++ b/drivers/staging/typec/tcpm.h
@@ -17,6 +17,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include "pd.h"
 
@@ -129,6 +130,10 @@ struct tcpc_dev {
struct tcpc_mux_dev *mux;
/* Used by tcpm_get_usb2_current_limit_extcon helpers */
struct extcon_dev *usb2_extcon;
+   /* Used by tcpm_set_current_limit_psy helpers */
+   struct power_supply *psy;
+   u32 current_limit;
+   u32 supply_voltage;
 };
 
 struct tcpm_port;
@@ -154,7 +159,11 @@ void tcpm_pd_transmit_complete(struct tcpm_port *port,
 void tcpm_pd_hard_reset(struct tcpm_port *port);
 void tcpm_tcpc_reset(struct tcpm_port *port);
 
+int tcpm_register_psy(struct device *dev, struct tcpc_dev *tcpc,
+ const char *name);
+
 /* Generic (helper) implementations for some tcpc_dev callbacks */
 int tcpm_get_usb2_current_limit_extcon(struct tcpc_dev *tcpc);
+int tcpm_set_current_limit_psy(struct tcpc_dev *tcpc, u32 max_ma, u32 mv);
 
 #endif /* __LINUX_USB_TCPM_H */
-- 
2.13.3



[PATCH 16/18] power: supply: bq24190_charger: Remove extcon handling

2017-08-06 Thread Hans de Goede
Now that drivers/i2c/busses/i2c-cht-wc.c uses
"input-current-limit-from-supplier" instead of "extcon-name" the last
user of the bq24190 extcon code is gone, remove it.

Signed-off-by: Hans de Goede 
---
 drivers/power/supply/bq24190_charger.c | 107 -
 1 file changed, 107 deletions(-)

diff --git a/drivers/power/supply/bq24190_charger.c 
b/drivers/power/supply/bq24190_charger.c
index 1f6424f0772f..0376de6d8e70 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -11,7 +11,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -155,9 +154,6 @@ struct bq24190_dev_info {
struct device   *dev;
struct power_supply *charger;
struct power_supply *battery;
-   struct extcon_dev   *extcon;
-   struct notifier_block   extcon_nb;
-   struct delayed_work extcon_work;
charmodel_name[I2C_NAME_SIZE];
boolinitialized;
boolirq_event;
@@ -1530,75 +1526,6 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, 
void *data)
return IRQ_HANDLED;
 }
 
-static void bq24190_extcon_work(struct work_struct *work)
-{
-   struct bq24190_dev_info *bdi =
-   container_of(work, struct bq24190_dev_info, extcon_work.work);
-   int error, iinlim = 0;
-   u8 v;
-
-   error = pm_runtime_get_sync(bdi->dev);
-   if (error < 0) {
-   dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
-   pm_runtime_put_noidle(bdi->dev);
-   return;
-   }
-
-   if  (extcon_get_state(bdi->extcon, EXTCON_CHG_USB_SDP) == 1)
-   iinlim =  50;
-   else if (extcon_get_state(bdi->extcon, EXTCON_CHG_USB_CDP) == 1 ||
-extcon_get_state(bdi->extcon, EXTCON_CHG_USB_ACA) == 1)
-   iinlim = 150;
-   else if (extcon_get_state(bdi->extcon, EXTCON_CHG_USB_DCP) == 1)
-   iinlim = 200;
-
-   if (iinlim) {
-   error = bq24190_set_field_val(bdi, BQ24190_REG_ISC,
- BQ24190_REG_ISC_IINLIM_MASK,
- BQ24190_REG_ISC_IINLIM_SHIFT,
- bq24190_isc_iinlim_values,
- 
ARRAY_SIZE(bq24190_isc_iinlim_values),
- iinlim);
-   if (error < 0)
-   dev_err(bdi->dev, "Can't set IINLIM: %d\n", error);
-   }
-
-   /* if no charger found and in USB host mode, set OTG 5V boost, else 
normal */
-   if (!iinlim && extcon_get_state(bdi->extcon, EXTCON_USB_HOST) == 1)
-   v = BQ24190_REG_POC_CHG_CONFIG_OTG;
-   else
-   v = BQ24190_REG_POC_CHG_CONFIG_CHARGE;
-
-   error = bq24190_write_mask(bdi, BQ24190_REG_POC,
-  BQ24190_REG_POC_CHG_CONFIG_MASK,
-  BQ24190_REG_POC_CHG_CONFIG_SHIFT,
-  v);
-   if (error < 0)
-   dev_err(bdi->dev, "Can't set CHG_CONFIG: %d\n", error);
-
-   pm_runtime_mark_last_busy(bdi->dev);
-   pm_runtime_put_autosuspend(bdi->dev);
-}
-
-static int bq24190_extcon_event(struct notifier_block *nb, unsigned long event,
-   void *param)
-{
-   struct bq24190_dev_info *bdi =
-   container_of(nb, struct bq24190_dev_info, extcon_nb);
-
-   /*
-* The Power-Good detection may take up to 220ms, sometimes
-* the external charger detection is quicker, and the bq24190 will
-* reset to iinlim based on its own charger detection (which is not
-* hooked up when using external charger detection) resulting in
-* a too low default 500mA iinlim. Delay applying the extcon value
-* for 300ms to avoid this.
-*/
-   queue_delayed_work(system_wq, >extcon_work, msecs_to_jiffies(300));
-
-   return NOTIFY_OK;
-}
-
 static int bq24190_hw_init(struct bq24190_dev_info *bdi)
 {
u8 v;
@@ -1636,7 +1563,6 @@ static int bq24190_probe(struct i2c_client *client,
struct device *dev = >dev;
struct power_supply_config charger_cfg = {}, battery_cfg = {};
struct bq24190_dev_info *bdi;
-   const char *name;
int ret;
 
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
@@ -1668,25 +1594,6 @@ static int bq24190_probe(struct i2c_client *client,
device_property_read_bool(dev,
  "input-current-limit-from-supplier");
 
-   /*
-* Devicetree platforms should get extcon via phandle (not yet 
supported).
-* On ACPI platforms, extcon clients may invoke us with:
-   

[PATCH 10/18] staging: typec: fusb302: Add support for fcs,vbus-regulator-name device-property

2017-08-06 Thread Hans de Goede
On devicetree platforms the fusb302 dt-node will have a vbus regulator
property with a phandle to the regulator.

On ACPI platforms, there are no phandles and we need to get the vbus by a
system wide unique name. Add support for a new "fcs,vbus-regulator-name"
device-property which ACPI platform code can set to pass the name.

Signed-off-by: Hans de Goede 
---
 drivers/staging/typec/fusb302/fusb302.c | 28 ++--
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/typec/fusb302/fusb302.c 
b/drivers/staging/typec/fusb302/fusb302.c
index e1e08f57af99..c3bcc5484ade 100644
--- a/drivers/staging/typec/fusb302/fusb302.c
+++ b/drivers/staging/typec/fusb302/fusb302.c
@@ -1722,6 +1722,28 @@ static int fusb302_probe(struct i2c_client *client,
return -EPROBE_DEFER;
}
 
+   /*
+* Devicetree platforms should get vbus from their dt-node.
+* On ACPI platforms, we need to get the vbus by a system wide unique
+* name, which is set in a device prop by the platform code.
+*/
+   if (device_property_read_string(dev, "fcs,vbus-regulator-name",
+   ) == 0) {
+   /*
+* Use regulator_get_optional so that we can detect if we need
+* to defer the probe rather then getting the dummy-regulator.
+*/
+   chip->vbus = devm_regulator_get_optional(dev, name);
+   if (IS_ERR(chip->vbus)) {
+   ret = PTR_ERR(chip->vbus);
+   return (ret == -ENODEV) ? -EPROBE_DEFER : ret;
+   }
+   } else {
+   chip->vbus = devm_regulator_get(dev, "vbus");
+   if (IS_ERR(chip->vbus))
+   return PTR_ERR(chip->vbus);
+   }
+
ret = tcpm_register_psy(chip->dev, >tcpc_dev,
"fusb302-typec-source");
if (ret < 0)
@@ -1739,12 +1761,6 @@ static int fusb302_probe(struct i2c_client *client,
INIT_DELAYED_WORK(>bc_lvl_handler, fusb302_bc_lvl_handler_work);
init_tcpc_dev(>tcpc_dev);
 
-   chip->vbus = devm_regulator_get(chip->dev, "vbus");
-   if (IS_ERR(chip->vbus)) {
-   ret = PTR_ERR(chip->vbus);
-   goto destroy_workqueue;
-   }
-
if (client->irq) {
chip->gpio_int_n_irq = client->irq;
} else {
-- 
2.13.3



[PATCH 08/18] staging: typec: fusb302: Add support for USB2 charger detection through extcon

2017-08-06 Thread Hans de Goede
The fusb302 port-controller relies on an external device doing USB2
charger-type detection.

The Intel Whiskey Cove PMIC with which the fusb302 is combined on some
X86/ACPI platforms already has a charger-type detection driver which
uses extcon to communicate the detected charger-type.

This commit uses the tcpm_get_usb2_current_limit_extcon helper to enable
USB2 charger detection on these systems. Note that the "fcs,extcon-name"
property name is only for kernel internal use by X86/ACPI platform code
and as such is NOT documented in the devicetree bindings.

Signed-off-by: Hans de Goede 
---
 drivers/staging/typec/fusb302/fusb302.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/staging/typec/fusb302/fusb302.c 
b/drivers/staging/typec/fusb302/fusb302.c
index be454b5ff6c7..1d8c9b66df2f 100644
--- a/drivers/staging/typec/fusb302/fusb302.c
+++ b/drivers/staging/typec/fusb302/fusb302.c
@@ -1201,6 +1201,8 @@ static void init_tcpc_dev(struct tcpc_dev 
*fusb302_tcpc_dev)
 {
fusb302_tcpc_dev->init = tcpm_init;
fusb302_tcpc_dev->get_vbus = tcpm_get_vbus;
+   fusb302_tcpc_dev->get_usb2_current_limit =
+   tcpm_get_usb2_current_limit_extcon;
fusb302_tcpc_dev->set_cc = tcpm_set_cc;
fusb302_tcpc_dev->get_cc = tcpm_get_cc;
fusb302_tcpc_dev->set_polarity = tcpm_set_polarity;
@@ -1685,6 +1687,7 @@ static int fusb302_probe(struct i2c_client *client,
struct fusb302_chip *chip;
struct i2c_adapter *adapter;
struct device *dev = >dev;
+   const char *name;
int ret = 0;
u32 val;
 
@@ -1717,6 +1720,19 @@ static int fusb302_probe(struct i2c_client *client,
if (device_property_read_u32(dev, "fcs,operating-snk-mw", ) == 0)
chip->tcpc_config.operating_snk_mw = val;
 
+   /*
+* Devicetree platforms should get extcon via phandle (not yet
+* supported). On ACPI platforms, we get the name from a device prop.
+* This device prop is for kernel internal use only and is expected
+* to be set by the platform code which also registers the i2c client
+* for the fusb302.
+*/
+   if (device_property_read_string(dev, "fcs,extcon-name", ) == 0) {
+   chip->tcpc_dev.usb2_extcon = extcon_get_extcon_dev(name);
+   if (!chip->tcpc_dev.usb2_extcon)
+   return -EPROBE_DEFER;
+   }
+
ret = fusb302_debugfs_init(chip);
if (ret < 0)
return ret;
-- 
2.13.3



[PATCH 14/18] power: supply: bq24190_charger: Add input_current_limit property

2017-08-06 Thread Hans de Goede
Export the input current limit of the charger as a
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT property on the charger
power_supply class device.

Signed-off-by: Hans de Goede 
---
 drivers/power/supply/bq24190_charger.c | 35 ++
 1 file changed, 35 insertions(+)

diff --git a/drivers/power/supply/bq24190_charger.c 
b/drivers/power/supply/bq24190_charger.c
index f25ea9c4acca..d78e2c6dc127 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -982,6 +982,33 @@ static int bq24190_charger_set_voltage(struct 
bq24190_dev_info *bdi,
ARRAY_SIZE(bq24190_cvc_vreg_values), val->intval);
 }
 
+static int bq24190_charger_get_iinlimit(struct bq24190_dev_info *bdi,
+   union power_supply_propval *val)
+{
+   int iinlimit, ret;
+
+   ret = bq24190_get_field_val(bdi, BQ24190_REG_ISC,
+   BQ24190_REG_ISC_IINLIM_MASK,
+   BQ24190_REG_ISC_IINLIM_SHIFT,
+   bq24190_isc_iinlim_values,
+   ARRAY_SIZE(bq24190_isc_iinlim_values), );
+   if (ret < 0)
+   return ret;
+
+   val->intval = iinlimit;
+   return 0;
+}
+
+static int bq24190_charger_set_iinlimit(struct bq24190_dev_info *bdi,
+   const union power_supply_propval *val)
+{
+   return bq24190_set_field_val(bdi, BQ24190_REG_ISC,
+   BQ24190_REG_ISC_IINLIM_MASK,
+   BQ24190_REG_ISC_IINLIM_SHIFT,
+   bq24190_isc_iinlim_values,
+   ARRAY_SIZE(bq24190_isc_iinlim_values), val->intval);
+}
+
 static int bq24190_charger_get_property(struct power_supply *psy,
enum power_supply_property psp, union power_supply_propval *val)
 {
@@ -1022,6 +1049,9 @@ static int bq24190_charger_get_property(struct 
power_supply *psy,
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX:
ret = bq24190_charger_get_voltage_max(bdi, val);
break;
+   case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
+   ret = bq24190_charger_get_iinlimit(bdi, val);
+   break;
case POWER_SUPPLY_PROP_SCOPE:
val->intval = POWER_SUPPLY_SCOPE_SYSTEM;
ret = 0;
@@ -1073,6 +1103,9 @@ static int bq24190_charger_set_property(struct 
power_supply *psy,
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
ret = bq24190_charger_set_voltage(bdi, val);
break;
+   case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
+   ret = bq24190_charger_set_iinlimit(bdi, val);
+   break;
default:
ret = -EINVAL;
}
@@ -1094,6 +1127,7 @@ static int bq24190_charger_property_is_writeable(struct 
power_supply *psy,
case POWER_SUPPLY_PROP_CHARGE_TYPE:
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
+   case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
ret = 1;
break;
default:
@@ -1113,6 +1147,7 @@ static enum power_supply_property 
bq24190_charger_properties[] = {
POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
+   POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
POWER_SUPPLY_PROP_SCOPE,
POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_MANUFACTURER,
-- 
2.13.3



[PATCH 02/18] staging: typec: tcpm: Add extcon helper functions for USB2 current limit detect

2017-08-06 Thread Hans de Goede
Some type-c port-controllers, such as the fusb302 port-controller, rely
on an external device doing USB2 charger-type detection.

Existing PMIC (and charger) drivers already use extcon to communicate the
detected charger-type from the PMIC (extcon) driver to the charger driver.

Rather then inventing a new API for USB2 charger-type detection
specifically for use with the tcpm code, lets simply re-use the existing
support. This will also allow re-using existing PMIC extcon drivers such
as the axp288 and Intel Whiskey Cove drivers as is on devices where these
are combined with a fusb302 (or in the future another port-controller
which relies on external USB2 charger-type detection).

This commit adds a helper function which tcpc drivers can use to easily
hook into existing PMIC extcon drivers for USB2 charger-type detection:

int tcpm_get_usb2_current_limit_extcon(struct tcpc_dev *tcpc);

Signed-off-by: Hans de Goede 
---
 drivers/staging/typec/tcpm.c | 40 
 drivers/staging/typec/tcpm.h |  6 ++
 2 files changed, 46 insertions(+)

diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
index 9f5adace4309..06bb0e640bcf 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/staging/typec/tcpm.c
@@ -16,6 +16,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3532,6 +3533,45 @@ void tcpm_unregister_port(struct tcpm_port *port)
 }
 EXPORT_SYMBOL_GPL(tcpm_unregister_port);
 
+/* Generic (helper) implementations for some tcpc_dev callbacks */
+int tcpm_get_usb2_current_limit_extcon(struct tcpc_dev *tcpc)
+{
+   struct extcon_dev *extcon = tcpc->usb2_extcon;
+   int current_limit = 0;
+   unsigned long timeout;
+
+   if (!extcon)
+   return 0;
+
+   /*
+* USB2 Charger detection may still be in progress when we get here,
+* this can take upto 600ms, wait 800ms max.
+*/
+   timeout = jiffies + msecs_to_jiffies(800);
+   do {
+   if (extcon_get_state(extcon, EXTCON_CHG_USB_SDP) == 1) {
+   current_limit = 500;
+   break;
+   }
+
+   if (extcon_get_state(extcon, EXTCON_CHG_USB_CDP) == 1 ||
+   extcon_get_state(extcon, EXTCON_CHG_USB_ACA) == 1) {
+   current_limit = 1500;
+   break;
+   }
+
+   if (extcon_get_state(extcon, EXTCON_CHG_USB_DCP) == 1) {
+   current_limit = 2000;
+   break;
+   }
+
+   msleep(50);
+   } while (time_before(jiffies, timeout));
+
+   return current_limit;
+}
+EXPORT_SYMBOL_GPL(tcpm_get_usb2_current_limit_extcon);
+
 MODULE_AUTHOR("Guenter Roeck ");
 MODULE_DESCRIPTION("USB Type-C Port Manager");
 MODULE_LICENSE("GPL");
diff --git a/drivers/staging/typec/tcpm.h b/drivers/staging/typec/tcpm.h
index 01b7d89379a3..35e8c1e7dba0 100644
--- a/drivers/staging/typec/tcpm.h
+++ b/drivers/staging/typec/tcpm.h
@@ -16,6 +16,7 @@
 #define __LINUX_USB_TCPM_H
 
 #include 
+#include 
 #include 
 #include "pd.h"
 
@@ -126,6 +127,8 @@ struct tcpc_dev {
int (*pd_transmit)(struct tcpc_dev *dev, enum tcpm_transmit_type type,
   const struct pd_message *msg);
struct tcpc_mux_dev *mux;
+   /* Used by tcpm_get_usb2_current_limit_extcon helpers */
+   struct extcon_dev *usb2_extcon;
 };
 
 struct tcpm_port;
@@ -151,4 +154,7 @@ void tcpm_pd_transmit_complete(struct tcpm_port *port,
 void tcpm_pd_hard_reset(struct tcpm_port *port);
 void tcpm_tcpc_reset(struct tcpm_port *port);
 
+/* Generic (helper) implementations for some tcpc_dev callbacks */
+int tcpm_get_usb2_current_limit_extcon(struct tcpc_dev *tcpc);
+
 #endif /* __LINUX_USB_TCPM_H */
-- 
2.13.3



[PATCH 01/18] staging: typec: tcpm: Add get_usb2_current_limit tcpc_dev callback

2017-08-06 Thread Hans de Goede
A Rp signalling the default current limit indicates that we're possibly
connected to an USB2 power-source. In some cases the type-c
port-controller may provide the capability to detect the current-limit
for USB2 power-sources (through e.g. BC1.2 detection).

This commit adds an optional get_usb2_current_limit tcpc_dev callback
which allows the port-controller to return the detected current-limit
if the CC pin is pulled up with Rp.

Signed-off-by: Hans de Goede 
---
 drivers/staging/typec/tcpm.c | 5 -
 drivers/staging/typec/tcpm.h | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
index 20eb4ebcf8c3..9f5adace4309 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/staging/typec/tcpm.c
@@ -660,7 +660,10 @@ static u32 tcpm_get_current_limit(struct tcpm_port *port)
break;
case TYPEC_CC_RP_DEF:
default:
-   limit = 0;
+   if (port->tcpc->get_usb2_current_limit)
+   limit = port->tcpc->get_usb2_current_limit(port->tcpc);
+   else
+   limit = 0;
break;
}
 
diff --git a/drivers/staging/typec/tcpm.h b/drivers/staging/typec/tcpm.h
index 19c307d31a5a..01b7d89379a3 100644
--- a/drivers/staging/typec/tcpm.h
+++ b/drivers/staging/typec/tcpm.h
@@ -108,6 +108,7 @@ struct tcpc_dev {
 
int (*init)(struct tcpc_dev *dev);
int (*get_vbus)(struct tcpc_dev *dev);
+   int (*get_usb2_current_limit)(struct tcpc_dev *dev); /* Optional */
int (*set_cc)(struct tcpc_dev *dev, enum typec_cc_status cc);
int (*get_cc)(struct tcpc_dev *dev, enum typec_cc_status *cc1,
  enum typec_cc_status *cc2);
-- 
2.13.3



[PATCH 00/18] Hookup typec power-negotation to the PMIC and charger

2017-08-06 Thread Hans de Goede
Hi All,

This series implements a number of typec changes discussed a while back:

- It exports the negotiated voltage and max-current in the form of a
  power-supply class device which represents the USB Type-C power-brick
  (adapter/charger)
- It adds a power_supply_set_input_current_limit_from_supplier helper
  function which charger drivers can use to get the max-current from
  their supplier
- It adds regulator support to the charger IC on the device I've. The
  exported regulator controls the 5v boost convertor which generates the
  5V USB vbus which gets output when the Type-C port is in host / power-src
  mode
- It adds a bunch of misc. related fixes and glue code to tie everything
  together

One thing which was undecided in the previous discussion was how to make
port-controller drivers hookup to external ICs (e.g. a non Type-C aware PMIC)
to decect the input-current-limit for USB2 power-sources (through e.g. BC1.2
detection). Since a number of existing drivers, including the one for the
PMIC used on the 2 mini laptops I'm working on, already use the extcon
framework to communicate the detected USB2 charger-type, I've decided to
simply hook into this existing code. As this patch set shows this can be
done with zero changes to the existing PMIC/extcon drivers.

With this series the GPD win and GPD pocket mini laptops both fully
support any type of Type-C charging. When hooked up with:
-A -> C cable and plugged into a regular port they charge at 5V 0.5A
-A -> C cable and plugged into a dedictaed charger they charge at 5V 2A
-C -> C cable and plugged into a fixed 5V 3A charger, at 5V 3A
-C -> C cable and plugged into a PD capable charger, which delivers max 12V, 2A
 they charge at 12V, 2A

And when a Type-C to USB-A receptacle (so host mode) cable gets plugged in
the port correctly supplies 5V to any plugged in USB-A peripherals.

Assuming this series gets a favorable review then the question becomes how
to merge this. This series has staging/typec, drivers/power/supply,
drivers/platform/x86 and drivers/i2c patches.

All these patches can be merged indepently, but the drivers/platform/x86
and drivers/i2c glue patches really should not be applied until the other
patches are in place.

Assuming no one nacks the concept of using a power-supply class device which
represents the USB Type-C power-brick, then all the typec and power patches
can be merged indepdently and as soon as they are deemed ready.

The only exception is the "power: supply: bq24190_charger: Remove extcon
handling" patch, which should not be merged until the drivers/i2c patch
removing the extcon handling from the bq24190 i2c-client instantiated there
has been merged.

Please let me know what you think and feel free to merge any patches you
like as is, then I can do a v2 addressing comments in the remaining patches.

Regards,

Hans


Re: [PATCH 09/18] staging: typec: fusb302: Use tcpm_set_current_limit_psy

2017-08-06 Thread Guenter Roeck

On 08/06/2017 05:35 AM, Hans de Goede wrote:

Register a power_supply and use tcpm_set_current_limit_psy as
set_current_limit so that another driver (e.g. the charger driver) can
pick the limit up and configure the system accordingly.

Signed-off-by: Hans de Goede 
---
  drivers/staging/typec/fusb302/fusb302.c | 18 ++
  1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/typec/fusb302/fusb302.c 
b/drivers/staging/typec/fusb302/fusb302.c
index 1d8c9b66df2f..e1e08f57af99 100644
--- a/drivers/staging/typec/fusb302/fusb302.c
+++ b/drivers/staging/typec/fusb302/fusb302.c
@@ -854,17 +854,6 @@ static int tcpm_set_vbus(struct tcpc_dev *dev, bool on, 
bool charge)
return ret;
  }
  
-static int tcpm_set_current_limit(struct tcpc_dev *dev, u32 max_ma, u32 mv)

-{
-   struct fusb302_chip *chip = container_of(dev, struct fusb302_chip,
-tcpc_dev);
-
-   fusb302_log(chip, "current limit: %d ma, %d mv (not implemented)",
-   max_ma, mv);
-
-   return 0;
-}
-


Same comment as before. I think the fusb code should do what 
tcpm_set_current_limit_psy
is doing, ie register with a power supply.


  static int fusb302_pd_tx_flush(struct fusb302_chip *chip)
  {
return fusb302_i2c_set_bits(chip, FUSB_REG_CONTROL0,
@@ -1208,7 +1197,7 @@ static void init_tcpc_dev(struct tcpc_dev 
*fusb302_tcpc_dev)
fusb302_tcpc_dev->set_polarity = tcpm_set_polarity;
fusb302_tcpc_dev->set_vconn = tcpm_set_vconn;
fusb302_tcpc_dev->set_vbus = tcpm_set_vbus;
-   fusb302_tcpc_dev->set_current_limit = tcpm_set_current_limit;
+   fusb302_tcpc_dev->set_current_limit = tcpm_set_current_limit_psy;
fusb302_tcpc_dev->set_pd_rx = tcpm_set_pd_rx;
fusb302_tcpc_dev->set_roles = tcpm_set_roles;
fusb302_tcpc_dev->start_drp_toggling = tcpm_start_drp_toggling;
@@ -1733,6 +1722,11 @@ static int fusb302_probe(struct i2c_client *client,
return -EPROBE_DEFER;
}
  
+	ret = tcpm_register_psy(chip->dev, >tcpc_dev,

+   "fusb302-typec-source");
+   if (ret < 0)
+   return ret;
+
ret = fusb302_debugfs_init(chip);
if (ret < 0)
return ret;





Re: [PATCH 04/18] staging: typec: tcpm: Add helpers for exporting current-limit through a psy

2017-08-06 Thread Guenter Roeck

On 08/06/2017 07:21 AM, Hans de Goede wrote:

Hi,

On 06-08-17 16:13, Guenter Roeck wrote:

On 08/06/2017 05:35 AM, Hans de Goede wrote:

Not all type-c port-controller can control the current-limit directly,
in cases where the current limit can not be controlled directly it needs
to be exported so that another driver (e.g. the charger driver) can pick
the limit up and configure the system accordingly.

The power-supply subsys already provides infrastructure for this,
power-supply devices have the notion of being supplied by another
power-supply and have properties through which we can export the
current-limit.

This commits adds 2 helper functions for use by port-controller drivers
which want to export the current-limit info in this way:

int tcpm_register_psy(struct device *dev, struct tcpc_dev *tcpc,
  const char *name);
int tcpm_set_current_limit_psy(struct tcpc_dev *tcpc, u32 max_ma, u32 mv);

Signed-off-by: Hans de Goede 
---
  drivers/staging/typec/tcpm-helpers.c | 66 
  drivers/staging/typec/tcpm.h |  9 +
  2 files changed, 75 insertions(+)

diff --git a/drivers/staging/typec/tcpm-helpers.c 
b/drivers/staging/typec/tcpm-helpers.c
index 0c87ec9936e1..8f7699576878 100644
--- a/drivers/staging/typec/tcpm-helpers.c
+++ b/drivers/staging/typec/tcpm-helpers.c
@@ -20,6 +20,60 @@
  #include "tcpm.h"
+static int tcpm_psy_get_property(struct power_supply *psy,
+ enum power_supply_property psp,
+ union power_supply_propval *val)
+{
+struct tcpc_dev *tcpc = power_supply_get_drvdata(psy);
+
+switch (psp) {
+case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+val->intval = tcpc->supply_voltage * 1000; /* mV -> µV */
+break;
+case POWER_SUPPLY_PROP_CURRENT_MAX:
+val->intval = tcpc->current_limit * 1000; /* mA -> µA */
+break;
+default:
+return -ENODATA;
+}
+
+return 0;
+}
+
+static enum power_supply_property tcpm_psy_properties[] = {
+POWER_SUPPLY_PROP_VOLTAGE_NOW,
+POWER_SUPPLY_PROP_CURRENT_MAX,
+};
+
+int tcpm_register_psy(struct device *dev, struct tcpc_dev *tcpc,
+  const char *name)


This is misleading since it relies on devm functions, and there is no 
unregister function.


The reliance on devm functions is intentional, that makes cleanup on probe() 
failure for users
of this a lot easier. I guess we could rename this tcpm_initialize_psy(), 
although it does
actually register a psy, so maybe: devm_tcpm_register_psy() to explain why 
there is no
unregister counter-part ?



I don't question the use of devm functions. Yes, I think 
devm_tcpm_register_psy() would be better.


Overall I am not too happy with tying this all into tcpm. The functions are not 
really tcpm
related. Not that I have a better idea how to handle this right now, but 
conceptually it
doesn't seem correct.


Note that no changes are made to the tcpm core in this entire patch-set, with 
the exception
of the first patch which adds the get_usb2_current_limit callback.


Yes, but you are using tcpm data structures. Of this entire series, I think 
only the callback
(renamed to get_usb_current_limit) should really be in tcpm code. Maybe it 
makes sense to find
a way to provide helpers in a generic way, if it turns out that the same code 
is needed by multiple
drivers, but right now they are only used by fusb302 and might as well stay 
there.

Until other drivers need them, we don't really know if the helpers are useful 
for multiple drivers.
I would prefer to add such helpers if and when we have more than one driver 
using them.

Thanks,
Guenter


This really only ties into the port-controller driver, and as such uses 
tcpc_dev to store some
stuff. I could make this more clear by prefixing the helper function names with 
tcpc instead of
tcpm if you think that is better ?

Regards,

Hans





+{
+struct power_supply_config psy_cfg = {};
+struct power_supply_desc *desc;
+int ret = 0;
+
+desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL);
+if (!desc)
+return -ENOMEM;
+
+desc->name= name;
+desc->type= POWER_SUPPLY_TYPE_USB;
+desc->properties= tcpm_psy_properties;
+desc->num_properties= ARRAY_SIZE(tcpm_psy_properties);
+desc->get_property= tcpm_psy_get_property;
+psy_cfg.drv_data= tcpc;
+
+tcpc->psy = devm_power_supply_register(dev, desc, _cfg);
+if (IS_ERR(tcpc->psy)) {
+ret = PTR_ERR(tcpc->psy);
+tcpc->psy = NULL;
+dev_err(dev, "Error registering power-supply: %d\n", ret);
+}
+
+return ret;
+}
+EXPORT_SYMBOL_GPL(tcpm_register_psy);
+
  /* Generic (helper) implementations for some tcpc_dev callbacks */
  int tcpm_get_usb2_current_limit_extcon(struct tcpc_dev *tcpc)
  {
@@ -58,3 +112,15 @@ int tcpm_get_usb2_current_limit_extcon(struct tcpc_dev 
*tcpc)
  return current_limit;
  }
  EXPORT_SYMBOL_GPL(tcpm_get_usb2_current_limit_extcon);
+

Re: [PATCH 01/18] staging: typec: tcpm: Add get_usb2_current_limit tcpc_dev callback

2017-08-06 Thread Guenter Roeck

On 08/06/2017 07:29 AM, Hans de Goede wrote:

Hi,

On 06-08-17 16:18, Guenter Roeck wrote:

On 08/06/2017 05:35 AM, Hans de Goede wrote:

A Rp signalling the default current limit indicates that we're possibly
connected to an USB2 power-source. In some cases the type-c
port-controller may provide the capability to detect the current-limit
for USB2 power-sources (through e.g. BC1.2 detection).

This commit adds an optional get_usb2_current_limit tcpc_dev callback
which allows the port-controller to return the detected current-limit
if the CC pin is pulled up with Rp.

Signed-off-by: Hans de Goede 
---
  drivers/staging/typec/tcpm.c | 5 -
  drivers/staging/typec/tcpm.h | 1 +
  2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
index 20eb4ebcf8c3..9f5adace4309 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/staging/typec/tcpm.c
@@ -660,7 +660,10 @@ static u32 tcpm_get_current_limit(struct tcpm_port *port)
  break;
  case TYPEC_CC_RP_DEF:
  default:
-limit = 0;
+if (port->tcpc->get_usb2_current_limit)


I think this callback should just be get_current_limit.


This is only used in the Rp-def case, which usually indicates being connected
with an A->C cable to a USB-2 device and the intend is for the callback to
implement some USB-2 specific method to detect the supported current-limit,
hence the name. If you prefer to name it just get_current_limit I can
change it for v2, but IMHO the usb2 part of the name is important as this
will not get called when USB-PD negotiation is used, nor when Rp has the Rp15
or Rp30 values.



As you say, it gets called in the Rp-def case, which can be set anytime.
I'd rather have a generic name and explain in tcpm.h as part of the API
description when it is used/called.

Note that it is also called in SNK_DISCOVERY if cc=Rp-def to calculate
and set the initial current limit, even with pd.

Thanks,
Guenter


Regards,

Hans






+limit = port->tcpc->get_usb2_current_limit(port->tcpc);
+else
+limit = 0;
  break;
  }
diff --git a/drivers/staging/typec/tcpm.h b/drivers/staging/typec/tcpm.h
index 19c307d31a5a..01b7d89379a3 100644
--- a/drivers/staging/typec/tcpm.h
+++ b/drivers/staging/typec/tcpm.h
@@ -108,6 +108,7 @@ struct tcpc_dev {
  int (*init)(struct tcpc_dev *dev);
  int (*get_vbus)(struct tcpc_dev *dev);
+int (*get_usb2_current_limit)(struct tcpc_dev *dev); /* Optional */
  int (*set_cc)(struct tcpc_dev *dev, enum typec_cc_status cc);
  int (*get_cc)(struct tcpc_dev *dev, enum typec_cc_status *cc1,
enum typec_cc_status *cc2);









Re: [PATCH 10/18] staging: typec: fusb302: Add support for fcs,vbus-regulator-name device-property

2017-08-06 Thread Hans de Goede

Hi,

On 06-08-17 16:30, Guenter Roeck wrote:

On 08/06/2017 05:35 AM, Hans de Goede wrote:

On devicetree platforms the fusb302 dt-node will have a vbus regulator
property with a phandle to the regulator.

On ACPI platforms, there are no phandles and we need to get the vbus by a
system wide unique name. Add support for a new "fcs,vbus-regulator-name"
device-property which ACPI platform code can set to pass the name.

Signed-off-by: Hans de Goede 
---
  drivers/staging/typec/fusb302/fusb302.c | 28 ++--
  1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/typec/fusb302/fusb302.c 
b/drivers/staging/typec/fusb302/fusb302.c
index e1e08f57af99..c3bcc5484ade 100644
--- a/drivers/staging/typec/fusb302/fusb302.c
+++ b/drivers/staging/typec/fusb302/fusb302.c
@@ -1722,6 +1722,28 @@ static int fusb302_probe(struct i2c_client *client,
  return -EPROBE_DEFER;
  }
+/*
+ * Devicetree platforms should get vbus from their dt-node.
+ * On ACPI platforms, we need to get the vbus by a system wide unique
+ * name, which is set in a device prop by the platform code.
+ */
+if (device_property_read_string(dev, "fcs,vbus-regulator-name",
+) == 0) {


Another property to be documented and approved.


Again this is for kernel internal use on non-dt platforms only, so documenting
it in the devicetree bindings is not necessary.

Also, isn't there a better way to get regulator names for dt- and non-dt 
systems ?
This would apply to every driver supporting both and using regulators, which 
seems
awkward.


While working on this I noticed that it is possible to add a regulator_match
table entry when registering a regulator, but that requires describing this
in regulator_init_data. Which would mean passing regulator_init_data from the
place where it is instantiated to where it gets registered, which would
mean passing a pointer through a device-property, given that this is purely 
kernel
internal that is possible, but not really how device-props are supposed to be 
used.

Also since the regulator-core only adds the mapping when registering the
regulator, this means that if we try to get the regulator before it has been
registered; and there is another regulator with the rather generic "vbus"
name then that will be returned instead.

Basically regulators are practically almost unused on x86 systems. I had to
add CONFIG_REGULATOR=y to my .config which is based on the Fedora 26 kernel
.config, so it has pretty much everything under the sun enabled. So it seems
that we are covering new ground here.

An alternative would be to not use the regulator subsys for this at all, but
it does seem the logical thing to use and using get-by-name is no different
then what we've doing for setting the the "fusb302-typec-source" psy as supplier
for the charger psy class device registered by the bq24190_charger driver.

TL;DR: It seems that on x86, at least for existing devices where we cannot
control the ACPI tables that getting things by name is the thing to do.


+/*
+ * Use regulator_get_optional so that we can detect if we need
+ * to defer the probe rather then getting the dummy-regulator.
+ */


Wouldn't this apply to dt systems as well ?


No because there will be a property named "vbus-supply" in the fusb302
node containing a phandle to the regulator, if the regulator to which the 
phandle
points has not been registered yet regulator_get will automatically return
-EPROBE_DEFER because there is a "vbus-supply" property, only if there is
no such property at all will it return a dummy regulator.


+chip->vbus = devm_regulator_get_optional(dev, name);
+if (IS_ERR(chip->vbus)) {
+ret = PTR_ERR(chip->vbus);
+return (ret == -ENODEV) ? -EPROBE_DEFER : ret;
+}
+} else {
+chip->vbus = devm_regulator_get(dev, "vbus");
+if (IS_ERR(chip->vbus))
+return PTR_ERR(chip->vbus);
+}
+


You might also want to explain why you moved this code.


Right, I did that because it may fail with -EPROBE_DEFER and
I wanted to do that before the register_psy. But as I just
explained the old code could do that too, so I properly should
just put the register_psy later.

Regards,

Hans




  ret = tcpm_register_psy(chip->dev, >tcpc_dev,
  "fusb302-typec-source");
  if (ret < 0)
@@ -1739,12 +1761,6 @@ static int fusb302_probe(struct i2c_client *client,
  INIT_DELAYED_WORK(>bc_lvl_handler, fusb302_bc_lvl_handler_work);
  init_tcpc_dev(>tcpc_dev);
-chip->vbus = devm_regulator_get(chip->dev, "vbus");
-if (IS_ERR(chip->vbus)) {
-ret = PTR_ERR(chip->vbus);
-goto destroy_workqueue;
-}
-
  if (client->irq) {
  chip->gpio_int_n_irq = client->irq;
  } else {





Re: [PATCH 10/18] staging: typec: fusb302: Add support for fcs,vbus-regulator-name device-property

2017-08-06 Thread Guenter Roeck

On 08/06/2017 07:52 AM, Hans de Goede wrote:

Hi,

On 06-08-17 16:30, Guenter Roeck wrote:

On 08/06/2017 05:35 AM, Hans de Goede wrote:

On devicetree platforms the fusb302 dt-node will have a vbus regulator
property with a phandle to the regulator.

On ACPI platforms, there are no phandles and we need to get the vbus by a
system wide unique name. Add support for a new "fcs,vbus-regulator-name"
device-property which ACPI platform code can set to pass the name.

Signed-off-by: Hans de Goede 
---
  drivers/staging/typec/fusb302/fusb302.c | 28 ++--
  1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/typec/fusb302/fusb302.c 
b/drivers/staging/typec/fusb302/fusb302.c
index e1e08f57af99..c3bcc5484ade 100644
--- a/drivers/staging/typec/fusb302/fusb302.c
+++ b/drivers/staging/typec/fusb302/fusb302.c
@@ -1722,6 +1722,28 @@ static int fusb302_probe(struct i2c_client *client,
  return -EPROBE_DEFER;
  }
+/*
+ * Devicetree platforms should get vbus from their dt-node.
+ * On ACPI platforms, we need to get the vbus by a system wide unique
+ * name, which is set in a device prop by the platform code.
+ */
+if (device_property_read_string(dev, "fcs,vbus-regulator-name",
+) == 0) {


Another property to be documented and approved.


Again this is for kernel internal use on non-dt platforms only, so documenting
it in the devicetree bindings is not necessary.


Ok.


Also, isn't there a better way to get regulator names for dt- and non-dt 
systems ?
This would apply to every driver supporting both and using regulators, which 
seems
awkward.


While working on this I noticed that it is possible to add a regulator_match
table entry when registering a regulator, but that requires describing this
in regulator_init_data. Which would mean passing regulator_init_data from the
place where it is instantiated to where it gets registered, which would
mean passing a pointer through a device-property, given that this is purely 
kernel
internal that is possible, but not really how device-props are supposed to be 
used.

Also since the regulator-core only adds the mapping when registering the
regulator, this means that if we try to get the regulator before it has been
registered; and there is another regulator with the rather generic "vbus"
name then that will be returned instead.

Basically regulators are practically almost unused on x86 systems. I had to
add CONFIG_REGULATOR=y to my .config which is based on the Fedora 26 kernel
.config, so it has pretty much everything under the sun enabled. So it seems
that we are covering new ground here.



We have some in hwmon, but they get by with using devm_regulator_get_optional()
for both dt and non-dt systems. Only problem with that is that it returns
-ENODEV if regulators are not configured, which by itself is weird/odd
(and there have been endless discussions about it).


An alternative would be to not use the regulator subsys for this at all, but
it does seem the logical thing to use and using get-by-name is no different
then what we've doing for setting the the "fusb302-typec-source" psy as supplier
for the charger psy class device registered by the bq24190_charger driver.

TL;DR: It seems that on x86, at least for existing devices where we cannot
control the ACPI tables that getting things by name is the thing to do.



Messy :-(. I don't have a better idea, unfortunately.


+/*
+ * Use regulator_get_optional so that we can detect if we need
+ * to defer the probe rather then getting the dummy-regulator.
+ */


Wouldn't this apply to dt systems as well ?


No because there will be a property named "vbus-supply" in the fusb302
node containing a phandle to the regulator, if the regulator to which the 
phandle
points has not been registered yet regulator_get will automatically return
-EPROBE_DEFER because there is a "vbus-supply" property, only if there is
no such property at all will it return a dummy regulator.



More messy. Again, I don't have a better idea, but it is really weird that we
need all this code. There should really be some generic code handling all those
differences.


+chip->vbus = devm_regulator_get_optional(dev, name);
+if (IS_ERR(chip->vbus)) {
+ret = PTR_ERR(chip->vbus);
+return (ret == -ENODEV) ? -EPROBE_DEFER : ret;


This will be stuck in returning -EPROBE_DEFER if the regulator subsystem
is disabled. Is this acceptable ?


+}
+} else {
+chip->vbus = devm_regulator_get(dev, "vbus");
+if (IS_ERR(chip->vbus))
+return PTR_ERR(chip->vbus);
+}
+


You might also want to explain why you moved this code.


Right, I did that because it may fail with -EPROBE_DEFER and
I wanted to do that before the register_psy. But as I just
explained the old code could do that too, so I properly should
just put the register_psy later.


[PATCH v06 34/36] uapi: break dependency loop between and

2017-08-06 Thread Mikko Rapeli
Name structs in linux/hdlc/ioctl.h and forward declare and use them in
linux/if.h. Then include linux/if.h in linux/hdlc/ioctl.h to fix
user space compilation problem:

hdlc/ioctl.h:73:14: error: ‘IFNAMSIZ’ undeclared here (not in a function)
  char master[IFNAMSIZ]; /* Name of master FRAD device */
  ^~~~

This approach for suggested by Frans Klaver 
in lkml message
.

Signed-off-by: Mikko Rapeli 
Cc: Frans Klaver 
Cc: David Miller 
---
 include/uapi/linux/hdlc/ioctl.h | 17 +
 include/uapi/linux/if.h | 23 ---
 2 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/include/uapi/linux/hdlc/ioctl.h b/include/uapi/linux/hdlc/ioctl.h
index 04bc0274a189..717d3edef7d1 100644
--- a/include/uapi/linux/hdlc/ioctl.h
+++ b/include/uapi/linux/hdlc/ioctl.h
@@ -1,6 +1,7 @@
 #ifndef __HDLC_IOCTL_H__
 #define __HDLC_IOCTL_H__
 
+#include 
 
 #define GENERIC_HDLC_VERSION 4 /* For synchronization with sethdlc utility */
 
@@ -36,25 +37,25 @@
 
 #ifndef __ASSEMBLY__
 
-typedef struct {
+typedef struct sync_serial_settings {
unsigned int clock_rate; /* bits per second */
unsigned int clock_type; /* internal, external, TX-internal etc. */
unsigned short loopback;
 } sync_serial_settings;  /* V.35, V.24, X.21 */
 
-typedef struct {
+typedef struct te1_settings {
unsigned int clock_rate; /* bits per second */
unsigned int clock_type; /* internal, external, TX-internal etc. */
unsigned short loopback;
unsigned int slot_map;
 } te1_settings;  /* T1, E1 */
 
-typedef struct {
+typedef struct raw_hdlc_proto {
unsigned short encoding;
unsigned short parity;
 } raw_hdlc_proto;
 
-typedef struct {
+typedef struct fr_proto {
unsigned int t391;
unsigned int t392;
unsigned int n391;
@@ -64,16 +65,16 @@ typedef struct {
unsigned short dce; /* 1 for DCE (network side) operation */
 } fr_proto;
 
-typedef struct {
+typedef struct fr_proto_pvc {
unsigned int dlci;
 } fr_proto_pvc;  /* for creating/deleting FR PVCs */
 
-typedef struct {
+typedef struct fr_proto_pvc_info {
unsigned int dlci;
char master[IFNAMSIZ];  /* Name of master FRAD device */
-}fr_proto_pvc_info;/* for returning PVC information only */
+} fr_proto_pvc_info;   /* for returning PVC information only */
 
-typedef struct {
+typedef struct cisco_proto {
 unsigned int interval;
 unsigned int timeout;
 } cisco_proto;
diff --git a/include/uapi/linux/if.h b/include/uapi/linux/if.h
index 259617a551f2..b57d9cd08ac9 100644
--- a/include/uapi/linux/if.h
+++ b/include/uapi/linux/if.h
@@ -34,6 +34,15 @@
 #defineIFALIASZ256
 #include 
 
+/* Forward declarations to break dependency loop with  */
+struct sync_serial_settings;
+struct ae1_settings;
+struct raw_hdlc_proto;
+struct fr_proto;
+struct fr_proto_pvc;
+struct fr_proto_pvc_info;
+struct cisco_proto;
+
 /* For glibc compatibility. An empty enum does not compile. */
 #if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 || \
 __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0
@@ -206,15 +215,15 @@ struct if_settings {
unsigned int size;  /* Size of the data allocated by the caller */
union {
/* {atm/eth/dsl}_settings anyone ? */
-   raw_hdlc_proto  __user *raw_hdlc;
-   cisco_proto __user *cisco;
-   fr_proto__user *fr;
-   fr_proto_pvc__user *fr_pvc;
-   fr_proto_pvc_info   __user *fr_pvc_info;
+   struct raw_hdlc_proto   __user *raw_hdlc;
+   struct cisco_proto  __user *cisco;
+   struct fr_proto __user *fr;
+   struct fr_proto_pvc __user *fr_pvc;
+   struct fr_proto_pvc_info__user *fr_pvc_info;
 
/* interface settings */
-   sync_serial_settings__user *sync;
-   te1_settings__user *te1;
+   struct sync_serial_settings __user *sync;
+   struct te1_settings __user *te1;
} ifs_ifsu;
 };
 
-- 
2.13.3



[PATCH v06 15/36] uapi linux/socket.h: include sys/socket.h in user space

2017-08-06 Thread Mikko Rapeli
This libc header has sockaddr definition in user space.

Fixes user space compilation errors like these from kernel headers including
only linux/socket.h:

error: field ‘ifru_addr’ has incomplete type
struct sockaddr ifru_addr;
error: field ‘_sockaddr’ has incomplete type
struct sockaddr  _sockaddr;
error: invalid application of ‘sizeof’ to incomplete type ‘struct sockaddr’

With this following uapi headers now compile in user space:

rdma/rdma_user_rxe.h
linux/vm_sockets.h
linux/ncp_fs.h
linux/nfc.h
linux/phonet.h

Signed-off-by: Mikko Rapeli 
Cc: net...@vger.kernel.org
Cc: Dmitry V. Levin 
---
 include/uapi/linux/socket.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/include/uapi/linux/socket.h b/include/uapi/linux/socket.h
index 76ab0c68561e..8a81197cc08b 100644
--- a/include/uapi/linux/socket.h
+++ b/include/uapi/linux/socket.h
@@ -1,6 +1,10 @@
 #ifndef _UAPI_LINUX_SOCKET_H
 #define _UAPI_LINUX_SOCKET_H
 
+#ifndef __KERNEL__
+#include 
+#endif
+
 /*
  * Desired design of maximum size and alignment (see RFC2553)
  */
-- 
2.13.3



[PATCH v06 21/36] uapi linux/kexec.h: use __kernel_size_t instead of size_t

2017-08-06 Thread Mikko Rapeli
Fixes userspace compilation error:

error: unknown type name ‘size_t’
  size_t bufsz;

Signed-off-by: Mikko Rapeli 
Cc: ke...@lists.infradead.org
Cc: Eric Biederman 
---
 include/uapi/linux/kexec.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h
index aae5ebf2022b..f964d83b2757 100644
--- a/include/uapi/linux/kexec.h
+++ b/include/uapi/linux/kexec.h
@@ -51,9 +51,9 @@
  */
 struct kexec_segment {
const void *buf;
-   size_t bufsz;
+   __kernel_size_t bufsz;
const void *mem;
-   size_t memsz;
+   __kernel_size_t memsz;
 };
 
 #endif /* __KERNEL__ */
-- 
2.13.3



[PATCH v06 08/36] uapi asm-generic/shmbuf.h: include fixes

2017-08-06 Thread Mikko Rapeli
Include linux/types.h and asm/msgbuf.h and use __kernel_size_t instead
of size_t.

Fixes userspace compilation errors like:

error: field ‘shm_perm’ has incomplete type
struct ipc64_perm shm_perm; /* operation perms */
error: unknown type name ‘size_t’
error: unknown type name ‘__kernel_time_t’

Signed-off-by: Mikko Rapeli 
Acked-by: Arnd Bergmann 
Cc: H.J. Lu 
Cc: H. Peter Anvin 
---
 include/uapi/asm-generic/shmbuf.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/uapi/asm-generic/shmbuf.h 
b/include/uapi/asm-generic/shmbuf.h
index 7e9fb2f0853b..ae867ad1e5e4 100644
--- a/include/uapi/asm-generic/shmbuf.h
+++ b/include/uapi/asm-generic/shmbuf.h
@@ -1,7 +1,9 @@
 #ifndef __ASM_GENERIC_SHMBUF_H
 #define __ASM_GENERIC_SHMBUF_H
 
+#include 
 #include 
+#include 
 
 /*
  * The shmid64_ds structure for x86 architecture.
@@ -24,7 +26,7 @@
 
 struct shmid64_ds {
struct ipc64_perm   shm_perm;   /* operation perms */
-   size_t  shm_segsz;  /* size of segment (bytes) */
+   __kernel_size_t shm_segsz;  /* size of segment (bytes) */
__kernel_time_t shm_atime;  /* last attach time */
 #if __BITS_PER_LONG != 64
unsigned long   __unused1;
-- 
2.13.3



[PATCH v06 04/36] uapi scsi/scsi_netlink_fc.h: use __u16, __u32 and __u64 from linux/types.h

2017-08-06 Thread Mikko Rapeli
Fixes userspace compilation errors like:

scsi/scsi_netlink_fc.h:60:2: error: expected specifier-qualifier-list before 
‘uint64_t’

Signed-off-by: Mikko Rapeli 
Cc: linux-s...@vger.kernel.org
---
 include/uapi/scsi/scsi_netlink_fc.h | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/uapi/scsi/scsi_netlink_fc.h 
b/include/uapi/scsi/scsi_netlink_fc.h
index cbf76e479761..2493a0f533dc 100644
--- a/include/uapi/scsi/scsi_netlink_fc.h
+++ b/include/uapi/scsi/scsi_netlink_fc.h
@@ -57,14 +57,14 @@
  */
 struct fc_nl_event {
struct scsi_nl_hdr snlh;/* must be 1st element ! */
-   uint64_t seconds;
-   uint64_t vendor_id;
-   uint16_t host_no;
-   uint16_t event_datalen;
-   uint32_t event_num;
-   uint32_t event_code;
-   uint32_t event_data;
-} __attribute__((aligned(sizeof(uint64_t;
+   __u64 seconds;
+   __u64 vendor_id;
+   __u16 host_no;
+   __u16 event_datalen;
+   __u32 event_num;
+   __u32 event_code;
+   __u32 event_data;
+} __attribute__((aligned(sizeof(__u64;
 
 
 #endif /* SCSI_NETLINK_FC_H */
-- 
2.13.3



[PATCH v06 23/36] uapi linux/coda.h: use __kernel_pid_t and add u_short etc definitions for userspace

2017-08-06 Thread Mikko Rapeli
Fixes userspace compilation errors about unknown pid_t, u_short etc types.

Signed-off-by: Mikko Rapeli 
Cc: Jan Harkes 
Cc: codal...@coda.cs.cmu.edu
---
 include/uapi/linux/coda.h | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/coda.h b/include/uapi/linux/coda.h
index 695fade33c64..2985ca00d63b 100644
--- a/include/uapi/linux/coda.h
+++ b/include/uapi/linux/coda.h
@@ -100,7 +100,14 @@ typedef unsigned long long u_quad_t;
 #if defined(__linux__)
 #include 
 #define cdev_t u_quad_t
+
 #ifndef __KERNEL__
+typedef unsigned long u_long;
+typedef unsigned int u_int;
+typedef unsigned short u_short;
+typedef u_long ino_t;
+typedef u_long dev_t;
+typedef void *caddr_t;
 #if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
 #define _UQUAD_T_ 1
 typedef unsigned long long u_quad_t;
@@ -295,8 +302,8 @@ struct coda_statfs {
 struct coda_in_hdr {
 u_int32_t opcode;
 u_int32_t unique;  /* Keep multiple outstanding msgs distinct */
-pid_t pid;
-pid_t pgid;
+__kernel_pid_t pid;
+__kernel_pid_t pgid;
 vuid_t uid;
 };
 
-- 
2.13.3



  1   2   3   4   5   6   7   8   >