All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/7] extcon: Make static analyzer happy about union assignment
@ 2018-08-27 15:35 ` Andy Shevchenko
  2018-08-27 15:35   ` [PATCH v1 2/7] extcon: Switch to use kasprintf() instead of open coded Andy Shevchenko
                     ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Andy Shevchenko @ 2018-08-27 15:35 UTC (permalink / raw)
  To: MyungJoo Ham, Chanwoo Choi, linux-kernel, Hans de Goede; +Cc: Andy Shevchenko

When assign unions we need to supply non-scalar value, otherwise
static analyzer is not happy:

CHECK   drivers/extcon/extcon.c
drivers/extcon/extcon.c:631:22: warning: cast to non-scalar

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/extcon/extcon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index b9d27c8fe57e..c21650a92689 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -628,7 +628,7 @@ int extcon_get_property(struct extcon_dev *edev, unsigned int id,
 	unsigned long flags;
 	int index, ret = 0;
 
-	*prop_val = (union extcon_property_value)(0);
+	*prop_val = (union extcon_property_value){0};
 
 	if (!edev)
 		return -EINVAL;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 2/7] extcon: Switch to use kasprintf() instead of open coded
  2018-08-27 15:35 ` [PATCH v1 1/7] extcon: Make static analyzer happy about union assignment Andy Shevchenko
@ 2018-08-27 15:35   ` Andy Shevchenko
  2018-08-29  9:40     ` David Laight
  2018-08-27 15:35   ` [PATCH v1 3/7] extcon: cht-wc: Return from default case to avoid warnings Andy Shevchenko
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2018-08-27 15:35 UTC (permalink / raw)
  To: MyungJoo Ham, Chanwoo Choi, linux-kernel, Hans de Goede; +Cc: Andy Shevchenko

Switch to use kasprintf() instead of open coded variant.
No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/extcon/extcon.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index c21650a92689..5ab0498be652 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -1123,7 +1123,6 @@ int extcon_dev_register(struct extcon_dev *edev)
 			(unsigned long)atomic_inc_return(&edev_no));
 
 	if (edev->max_supported) {
-		char buf[10];
 		char *str;
 		struct extcon_cable *cable;
 
@@ -1137,9 +1136,7 @@ int extcon_dev_register(struct extcon_dev *edev)
 		for (index = 0; index < edev->max_supported; index++) {
 			cable = &edev->cables[index];
 
-			snprintf(buf, 10, "cable.%d", index);
-			str = kzalloc(strlen(buf) + 1,
-				      GFP_KERNEL);
+			str = kasprintf(GFP_KERNEL, "cable.%d", index);
 			if (!str) {
 				for (index--; index >= 0; index--) {
 					cable = &edev->cables[index];
@@ -1149,7 +1146,6 @@ int extcon_dev_register(struct extcon_dev *edev)
 
 				goto err_alloc_cables;
 			}
-			strcpy(str, buf);
 
 			cable->edev = edev;
 			cable->cable_index = index;
@@ -1172,7 +1168,6 @@ int extcon_dev_register(struct extcon_dev *edev)
 	}
 
 	if (edev->max_supported && edev->mutually_exclusive) {
-		char buf[80];
 		char *name;
 
 		/* Count the size of mutually_exclusive array */
@@ -1197,9 +1192,8 @@ int extcon_dev_register(struct extcon_dev *edev)
 		}
 
 		for (index = 0; edev->mutually_exclusive[index]; index++) {
-			sprintf(buf, "0x%x", edev->mutually_exclusive[index]);
-			name = kzalloc(strlen(buf) + 1,
-				       GFP_KERNEL);
+			name = kasprintf(GFP_KERNEL, "0x%x",
+					 edev->mutually_exclusive[index]);
 			if (!name) {
 				for (index--; index >= 0; index--) {
 					kfree(edev->d_attrs_muex[index].attr.
@@ -1210,7 +1204,6 @@ int extcon_dev_register(struct extcon_dev *edev)
 				ret = -ENOMEM;
 				goto err_muex;
 			}
-			strcpy(name, buf);
 			sysfs_attr_init(&edev->d_attrs_muex[index].attr);
 			edev->d_attrs_muex[index].attr.name = name;
 			edev->d_attrs_muex[index].attr.mode = 0000;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 3/7] extcon: cht-wc: Return from default case to avoid warnings
  2018-08-27 15:35 ` [PATCH v1 1/7] extcon: Make static analyzer happy about union assignment Andy Shevchenko
  2018-08-27 15:35   ` [PATCH v1 2/7] extcon: Switch to use kasprintf() instead of open coded Andy Shevchenko
@ 2018-08-27 15:35   ` Andy Shevchenko
  2018-08-27 15:35   ` [PATCH v1 4/7] extcon: cht-wc: Fix definition names according to spec Andy Shevchenko
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2018-08-27 15:35 UTC (permalink / raw)
  To: MyungJoo Ham, Chanwoo Choi, linux-kernel, Hans de Goede; +Cc: Andy Shevchenko

When we have first case to fall through it's not enough to put
single comment there to satisfy compiler. Instead of doing that,
return fall back value directly from default case.

This to avoid following warnings:

drivers/extcon/extcon-intel-cht-wc.c: In function ‘cht_wc_extcon_get_charger’:
include/linux/device.h:1420:2: warning: this statement may fall through [-Wimplicit-fallthrough=]
  _dev_warn(dev, dev_fmt(fmt), ##__VA_ARGS__)
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/extcon/extcon-intel-cht-wc.c:148:3: note: in expansion of macro ‘dev_warn’
   dev_warn(ext->dev,
   ^~~~~~~~
drivers/extcon/extcon-intel-cht-wc.c:152:2: note: here
  case CHT_WC_USBSRC_TYPE_SDP:
  ^~~~

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/extcon/extcon-intel-cht-wc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/extcon/extcon-intel-cht-wc.c b/drivers/extcon/extcon-intel-cht-wc.c
index 5e1dd2772278..bdb67878179e 100644
--- a/drivers/extcon/extcon-intel-cht-wc.c
+++ b/drivers/extcon/extcon-intel-cht-wc.c
@@ -156,7 +156,7 @@ static int cht_wc_extcon_get_charger(struct cht_wc_extcon_data *ext,
 		dev_warn(ext->dev,
 			"Unhandled charger type %d, defaulting to SDP\n",
 			 ret);
-		/* Fall through, treat as SDP */
+		return EXTCON_CHG_USB_SDP;
 	case CHT_WC_USBSRC_TYPE_SDP:
 	case CHT_WC_USBSRC_TYPE_FLOAT_DP_DN:
 	case CHT_WC_USBSRC_TYPE_OTHER:
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 4/7] extcon: cht-wc: Fix definition names according to spec
  2018-08-27 15:35 ` [PATCH v1 1/7] extcon: Make static analyzer happy about union assignment Andy Shevchenko
  2018-08-27 15:35   ` [PATCH v1 2/7] extcon: Switch to use kasprintf() instead of open coded Andy Shevchenko
  2018-08-27 15:35   ` [PATCH v1 3/7] extcon: cht-wc: Return from default case to avoid warnings Andy Shevchenko
@ 2018-08-27 15:35   ` Andy Shevchenko
  2018-08-27 15:35   ` [PATCH v1 5/7] extcon: cht-wc: Correct USBID bit field handling Andy Shevchenko
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2018-08-27 15:35 UTC (permalink / raw)
  To: MyungJoo Ham, Chanwoo Choi, linux-kernel, Hans de Goede; +Cc: Andy Shevchenko

There is no suffix MASK in the spec and other small spelling fixes.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/extcon/extcon-intel-cht-wc.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/extcon/extcon-intel-cht-wc.c b/drivers/extcon/extcon-intel-cht-wc.c
index bdb67878179e..71b1126dbb0b 100644
--- a/drivers/extcon/extcon-intel-cht-wc.c
+++ b/drivers/extcon/extcon-intel-cht-wc.c
@@ -32,10 +32,10 @@
 #define CHT_WC_CHGRCTRL0_EMRGCHREN	BIT(1)
 #define CHT_WC_CHGRCTRL0_EXTCHRDIS	BIT(2)
 #define CHT_WC_CHGRCTRL0_SWCONTROL	BIT(3)
-#define CHT_WC_CHGRCTRL0_TTLCK_MASK	BIT(4)
-#define CHT_WC_CHGRCTRL0_CCSM_OFF_MASK	BIT(5)
-#define CHT_WC_CHGRCTRL0_DBPOFF_MASK	BIT(6)
-#define CHT_WC_CHGRCTRL0_WDT_NOKICK	BIT(7)
+#define CHT_WC_CHGRCTRL0_TTLCK		BIT(4)
+#define CHT_WC_CHGRCTRL0_CCSM_OFF	BIT(5)
+#define CHT_WC_CHGRCTRL0_DBPOFF		BIT(6)
+#define CHT_WC_CHGRCTRL0_CHR_WDT_NOKICK	BIT(7)
 
 #define CHT_WC_CHGRCTRL1		0x5e17
 
@@ -52,7 +52,7 @@
 #define CHT_WC_USBSRC_TYPE_ACA		4
 #define CHT_WC_USBSRC_TYPE_SE1		5
 #define CHT_WC_USBSRC_TYPE_MHL		6
-#define CHT_WC_USBSRC_TYPE_FLOAT_DP_DN	7
+#define CHT_WC_USBSRC_TYPE_FLOATING	7
 #define CHT_WC_USBSRC_TYPE_OTHER	8
 #define CHT_WC_USBSRC_TYPE_DCP_EXTPHY	9
 
@@ -61,7 +61,7 @@
 #define CHT_WC_PWRSRC_STS		0x6e1e
 #define CHT_WC_PWRSRC_VBUS		BIT(0)
 #define CHT_WC_PWRSRC_DC		BIT(1)
-#define CHT_WC_PWRSRC_BAT		BIT(2)
+#define CHT_WC_PWRSRC_BATT		BIT(2)
 #define CHT_WC_PWRSRC_ID_GND		BIT(3)
 #define CHT_WC_PWRSRC_ID_FLOAT		BIT(4)
 
@@ -158,7 +158,7 @@ static int cht_wc_extcon_get_charger(struct cht_wc_extcon_data *ext,
 			 ret);
 		return EXTCON_CHG_USB_SDP;
 	case CHT_WC_USBSRC_TYPE_SDP:
-	case CHT_WC_USBSRC_TYPE_FLOAT_DP_DN:
+	case CHT_WC_USBSRC_TYPE_FLOATING:
 	case CHT_WC_USBSRC_TYPE_OTHER:
 		return EXTCON_CHG_USB_SDP;
 	case CHT_WC_USBSRC_TYPE_CDP:
@@ -279,7 +279,7 @@ static int cht_wc_extcon_sw_control(struct cht_wc_extcon_data *ext, bool enable)
 {
 	int ret, mask, val;
 
-	mask = CHT_WC_CHGRCTRL0_SWCONTROL | CHT_WC_CHGRCTRL0_CCSM_OFF_MASK;
+	mask = CHT_WC_CHGRCTRL0_SWCONTROL | CHT_WC_CHGRCTRL0_CCSM_OFF;
 	val = enable ? mask : 0;
 	ret = regmap_update_bits(ext->regmap, CHT_WC_CHGRCTRL0, mask, val);
 	if (ret)
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 5/7] extcon: cht-wc: Correct USBID bit field handling
  2018-08-27 15:35 ` [PATCH v1 1/7] extcon: Make static analyzer happy about union assignment Andy Shevchenko
                     ` (2 preceding siblings ...)
  2018-08-27 15:35   ` [PATCH v1 4/7] extcon: cht-wc: Fix definition names according to spec Andy Shevchenko
@ 2018-08-27 15:35   ` Andy Shevchenko
  2018-08-27 15:35   ` [PATCH v1 6/7] extcon: cht-wc: Convert to use SPDX identifier Andy Shevchenko
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2018-08-27 15:35 UTC (permalink / raw)
  To: MyungJoo Ham, Chanwoo Choi, linux-kernel, Hans de Goede; +Cc: Andy Shevchenko

USBID is 2-bit bit field according to specification. Make it clear.

No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/extcon/extcon-intel-cht-wc.c | 32 +++++++++++++++++-----------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/drivers/extcon/extcon-intel-cht-wc.c b/drivers/extcon/extcon-intel-cht-wc.c
index 71b1126dbb0b..ad1fd70e4023 100644
--- a/drivers/extcon/extcon-intel-cht-wc.c
+++ b/drivers/extcon/extcon-intel-cht-wc.c
@@ -62,8 +62,11 @@
 #define CHT_WC_PWRSRC_VBUS		BIT(0)
 #define CHT_WC_PWRSRC_DC		BIT(1)
 #define CHT_WC_PWRSRC_BATT		BIT(2)
-#define CHT_WC_PWRSRC_ID_GND		BIT(3)
-#define CHT_WC_PWRSRC_ID_FLOAT		BIT(4)
+#define CHT_WC_PWRSRC_USBID_MASK	GENMASK(4, 3)
+#define CHT_WC_PWRSRC_USBID_SHIFT	3
+#define CHT_WC_PWRSRC_RID_ACA		0
+#define CHT_WC_PWRSRC_RID_GND		1
+#define CHT_WC_PWRSRC_RID_FLOAT		2
 
 #define CHT_WC_VBUS_GPIO_CTLO		0x6e2d
 #define CHT_WC_VBUS_GPIO_CTLO_OUTPUT	BIT(0)
@@ -104,16 +107,20 @@ struct cht_wc_extcon_data {
 
 static int cht_wc_extcon_get_id(struct cht_wc_extcon_data *ext, int pwrsrc_sts)
 {
-	if (pwrsrc_sts & CHT_WC_PWRSRC_ID_GND)
+	switch ((pwrsrc_sts & CHT_WC_PWRSRC_USBID_MASK) >> CHT_WC_PWRSRC_USBID_SHIFT) {
+	case CHT_WC_PWRSRC_RID_GND:
 		return USB_ID_GND;
-	if (pwrsrc_sts & CHT_WC_PWRSRC_ID_FLOAT)
+	case CHT_WC_PWRSRC_RID_FLOAT:
 		return USB_ID_FLOAT;
-
-	/*
-	 * Once we have iio support for the gpadc we should read the USBID
-	 * gpadc channel here and determine ACA role based on that.
-	 */
-	return USB_ID_FLOAT;
+	case CHT_WC_PWRSRC_RID_ACA:
+	default:
+		/*
+		 * Once we have IIO support for the GPADC we should read
+		 * the USBID GPADC channel here and determine ACA role
+		 * based on that.
+		 */
+		return USB_ID_FLOAT;
+	}
 }
 
 static int cht_wc_extcon_get_charger(struct cht_wc_extcon_data *ext,
@@ -292,6 +299,7 @@ static int cht_wc_extcon_probe(struct platform_device *pdev)
 {
 	struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent);
 	struct cht_wc_extcon_data *ext;
+	unsigned long mask = ~(CHT_WC_PWRSRC_VBUS | CHT_WC_PWRSRC_USBID_MASK);
 	int irq, ret;
 
 	irq = platform_get_irq(pdev, 0);
@@ -352,9 +360,7 @@ static int cht_wc_extcon_probe(struct platform_device *pdev)
 	}
 
 	/* Unmask irqs */
-	ret = regmap_write(ext->regmap, CHT_WC_PWRSRC_IRQ_MASK,
-			   (int)~(CHT_WC_PWRSRC_VBUS | CHT_WC_PWRSRC_ID_GND |
-				  CHT_WC_PWRSRC_ID_FLOAT));
+	ret = regmap_write(ext->regmap, CHT_WC_PWRSRC_IRQ_MASK, mask);
 	if (ret) {
 		dev_err(ext->dev, "Error writing irq-mask: %d\n", ret);
 		goto disable_sw_control;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 6/7] extcon: cht-wc: Convert to use SPDX identifier
  2018-08-27 15:35 ` [PATCH v1 1/7] extcon: Make static analyzer happy about union assignment Andy Shevchenko
                     ` (3 preceding siblings ...)
  2018-08-27 15:35   ` [PATCH v1 5/7] extcon: cht-wc: Correct USBID bit field handling Andy Shevchenko
@ 2018-08-27 15:35   ` Andy Shevchenko
  2018-08-27 15:35   ` [PATCH v1 7/7] extcon: int3496: " Andy Shevchenko
  2018-08-29  7:06   ` [PATCH v1 1/7] extcon: Make static analyzer happy about union assignment Chanwoo Choi
  6 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2018-08-27 15:35 UTC (permalink / raw)
  To: MyungJoo Ham, Chanwoo Choi, linux-kernel, Hans de Goede; +Cc: Andy Shevchenko

Convert driver to use SPDX identifier.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/extcon/extcon-intel-cht-wc.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/extcon/extcon-intel-cht-wc.c b/drivers/extcon/extcon-intel-cht-wc.c
index ad1fd70e4023..5ef215297101 100644
--- a/drivers/extcon/extcon-intel-cht-wc.c
+++ b/drivers/extcon/extcon-intel-cht-wc.c
@@ -1,18 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Extcon charger detection driver for Intel Cherrytrail Whiskey Cove PMIC
  * Copyright (C) 2017 Hans de Goede <hdegoede@redhat.com>
  *
  * Based on various non upstream patches to support the CHT Whiskey Cove PMIC:
  * Copyright (C) 2013-2015 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 <linux/extcon-provider.h>
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 7/7] extcon: int3496: Convert to use SPDX identifier
  2018-08-27 15:35 ` [PATCH v1 1/7] extcon: Make static analyzer happy about union assignment Andy Shevchenko
                     ` (4 preceding siblings ...)
  2018-08-27 15:35   ` [PATCH v1 6/7] extcon: cht-wc: Convert to use SPDX identifier Andy Shevchenko
@ 2018-08-27 15:35   ` Andy Shevchenko
  2018-08-29  7:06   ` [PATCH v1 1/7] extcon: Make static analyzer happy about union assignment Chanwoo Choi
  6 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2018-08-27 15:35 UTC (permalink / raw)
  To: MyungJoo Ham, Chanwoo Choi, linux-kernel, Hans de Goede; +Cc: Andy Shevchenko

Convert driver to use SPDX identifier.

While here, fix MODULE_LICENSE() string to be the same as license text states.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/extcon/extcon-intel-int3496.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/extcon/extcon-intel-int3496.c b/drivers/extcon/extcon-intel-int3496.c
index fd24debe58a3..80c9abcc3f97 100644
--- a/drivers/extcon/extcon-intel-int3496.c
+++ b/drivers/extcon/extcon-intel-int3496.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Intel INT3496 ACPI device extcon driver
  *
@@ -7,15 +8,6 @@
  *
  * Copyright (c) 2014, Intel Corporation.
  * Author: David Cohen <david.a.cohen@linux.intel.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * 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 <linux/acpi.h>
@@ -192,4 +184,4 @@ module_platform_driver(int3496_driver);
 
 MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
 MODULE_DESCRIPTION("Intel INT3496 ACPI device extcon driver");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 1/7] extcon: Make static analyzer happy about union assignment
  2018-08-27 15:35 ` [PATCH v1 1/7] extcon: Make static analyzer happy about union assignment Andy Shevchenko
                     ` (5 preceding siblings ...)
  2018-08-27 15:35   ` [PATCH v1 7/7] extcon: int3496: " Andy Shevchenko
@ 2018-08-29  7:06   ` Chanwoo Choi
  6 siblings, 0 replies; 9+ messages in thread
From: Chanwoo Choi @ 2018-08-29  7:06 UTC (permalink / raw)
  To: Andy Shevchenko, MyungJoo Ham, linux-kernel, Hans de Goede

Hi,

On 2018년 08월 28일 00:35, Andy Shevchenko wrote:
> When assign unions we need to supply non-scalar value, otherwise
> static analyzer is not happy:
> 
> CHECK   drivers/extcon/extcon.c
> drivers/extcon/extcon.c:631:22: warning: cast to non-scalar
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/extcon/extcon.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
> index b9d27c8fe57e..c21650a92689 100644
> --- a/drivers/extcon/extcon.c
> +++ b/drivers/extcon/extcon.c
> @@ -628,7 +628,7 @@ int extcon_get_property(struct extcon_dev *edev, unsigned int id,
>  	unsigned long flags;
>  	int index, ret = 0;
>  
> -	*prop_val = (union extcon_property_value)(0);
> +	*prop_val = (union extcon_property_value){0};
>  
>  	if (!edev)
>  		return -EINVAL;
> 

Applied all patches of this series. Thanks.

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH v1 2/7] extcon: Switch to use kasprintf() instead of open coded
  2018-08-27 15:35   ` [PATCH v1 2/7] extcon: Switch to use kasprintf() instead of open coded Andy Shevchenko
@ 2018-08-29  9:40     ` David Laight
  0 siblings, 0 replies; 9+ messages in thread
From: David Laight @ 2018-08-29  9:40 UTC (permalink / raw)
  To: 'Andy Shevchenko',
	MyungJoo Ham, Chanwoo Choi, linux-kernel, Hans de Goede

From: Andy Shevchenko
> Sent: 27 August 2018 16:36
> 
> Switch to use kasprintf() instead of open coded variant.
> No functional change intended.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/extcon/extcon.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
> index c21650a92689..5ab0498be652 100644
> --- a/drivers/extcon/extcon.c
> +++ b/drivers/extcon/extcon.c
> @@ -1123,7 +1123,6 @@ int extcon_dev_register(struct extcon_dev *edev)
>  			(unsigned long)atomic_inc_return(&edev_no));
> 
>  	if (edev->max_supported) {
> -		char buf[10];
>  		char *str;
>  		struct extcon_cable *cable;
> 
> @@ -1137,9 +1136,7 @@ int extcon_dev_register(struct extcon_dev *edev)
>  		for (index = 0; index < edev->max_supported; index++) {
>  			cable = &edev->cables[index];
> 
> -			snprintf(buf, 10, "cable.%d", index);
> -			str = kzalloc(strlen(buf) + 1,
> -				      GFP_KERNEL);
> +			str = kasprintf(GFP_KERNEL, "cable.%d", index);

Hmmm... Why now just allocate the space for the string in the
'extcon_cable' structure.
(Then work out how to stop gcc complaining there isn't room
for 4G cables ...)

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-08-29  9:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20180827153615epcas5p212a6279a5d5c3cbfc2608cbf34c2803d@epcas5p2.samsung.com>
2018-08-27 15:35 ` [PATCH v1 1/7] extcon: Make static analyzer happy about union assignment Andy Shevchenko
2018-08-27 15:35   ` [PATCH v1 2/7] extcon: Switch to use kasprintf() instead of open coded Andy Shevchenko
2018-08-29  9:40     ` David Laight
2018-08-27 15:35   ` [PATCH v1 3/7] extcon: cht-wc: Return from default case to avoid warnings Andy Shevchenko
2018-08-27 15:35   ` [PATCH v1 4/7] extcon: cht-wc: Fix definition names according to spec Andy Shevchenko
2018-08-27 15:35   ` [PATCH v1 5/7] extcon: cht-wc: Correct USBID bit field handling Andy Shevchenko
2018-08-27 15:35   ` [PATCH v1 6/7] extcon: cht-wc: Convert to use SPDX identifier Andy Shevchenko
2018-08-27 15:35   ` [PATCH v1 7/7] extcon: int3496: " Andy Shevchenko
2018-08-29  7:06   ` [PATCH v1 1/7] extcon: Make static analyzer happy about union assignment Chanwoo Choi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.