From nobody Mon Apr 13 06:39:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E13C5C6FD1F for ; Wed, 22 Mar 2023 14:39:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231593AbjCVOja (ORCPT ); Wed, 22 Mar 2023 10:39:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230381AbjCVOjX (ORCPT ); Wed, 22 Mar 2023 10:39:23 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD70F3347A for ; Wed, 22 Mar 2023 07:39:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679495962; x=1711031962; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TkCkoVN5YuqKJoNk1l2F8kUlVp9keQi4zBudYIi2MhU=; b=UF41KvIoEY+0kbZSVUk9o+T37X/265H7/9qNZVmrYUc0iKbgBJGQkVrY 1d05wjUWEr5RZsReD3/n7YFd2Ol1H13KryT3/qR/ltGtQHOQiCb1ADeaV /qMdSGokGr/6So0UbAW3kc5La4g7ZvTJggn0HFJSB2xzSx5mpIyEp9muK +Wk+qJQC0NjmVH3GzG/wpR0Vpjhu1i/QvvqF3bK79LFbdf0Au3f04Kmj0 NQ+Yr1NhWaHAne0MWF8LXgzd+lKGfUQi0MqXA2VK2GHU5F2lH+elqu8oM jnmRZwLRXyGe2QrXxXOxqhQfy+DUBeH9C3RmQ1UK9jYFwBzU/5HxQnnqg Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="327609288" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="327609288" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 07:39:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="792579428" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="792579428" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 22 Mar 2023 07:39:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9C5E581; Wed, 22 Mar 2023 16:40:06 +0200 (EET) From: Andy Shevchenko To: Bumwoo Lee , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: MyungJoo Ham , Chanwoo Choi Subject: [PATCH v1 01/14] extcon: Fix kernel doc of property fields to avoid warnings Date: Wed, 22 Mar 2023 16:39:52 +0200 Message-Id: <20230322144005.40368-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> References: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Kernel documentation has to be synchronized with a code, otherwise the validator is not happy: Function parameter or member 'usb_propval' not described in 'extcon_ca= ble' Function parameter or member 'chg_propval' not described in 'extcon_ca= ble' Function parameter or member 'jack_propval' not described in 'extcon_c= able' Function parameter or member 'disp_propval' not described in 'extcon_c= able' Describe the fields added in the past. Fixes: 067c1652e7a7 ("extcon: Add the support for extcon property according= to extcon type") Signed-off-by: Andy Shevchenko Acked-by: Bumwoo Lee --- drivers/extcon/extcon.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 3997b39680b7..1bc2639704c2 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -206,6 +206,10 @@ static const struct __extcon_info { * @attr_name: "name" sysfs entry * @attr_state: "state" sysfs entry * @attrs: the array pointing to attr_name and attr_state for attr_g + * @usb_propval: the array of USB connector properties + * @chg_propval: the array of charger connector properties + * @jack_propval: the array of jack connector properties + * @disp_propval: the array of display connector properties */ struct extcon_cable { struct extcon_dev *edev; --=20 2.40.0.1.gaa8946217a0b From nobody Mon Apr 13 06:39:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00D06C76195 for ; Wed, 22 Mar 2023 14:39:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231624AbjCVOjf (ORCPT ); Wed, 22 Mar 2023 10:39:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231395AbjCVOjY (ORCPT ); Wed, 22 Mar 2023 10:39:24 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA08231E19 for ; Wed, 22 Mar 2023 07:39:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679495963; x=1711031963; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AVd04bvZvtiru6UczXNHsDReJQuNasVR+P+brwfuTWw=; b=iJs+32hqHLHVe/Q0/iv6EsW/Qg2zi5zP26kth/g0+ihLppYZxnki0TVn GG2WFf80ESKMtXNyqAktLZiyujYf+jlYEb2KHf+EMsPy38dVqtxJWmHeI C9DhoFep4XKJBgcY/Gxr8UEp82QaPZY1/aQl4Zgu9W07gOkuHjPJY9Bbe o1/1JkzxHOH/VZ5URlaC1Yffx6fwmq9hG5ijQHGe75uPnjp5fXGC+KKIC k8JIm028OjTjQNnfCSHUqoYYCeSeIu4f2EHIJf7iS45OSJIJFDyuzSZQY RNwHdZSp2CXLDqbRq9CdOgktM4QZq5U52pdQyLby+Qcjb+YEpJ+4yJ/hb w==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="327609290" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="327609290" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 07:39:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="792579429" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="792579429" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 22 Mar 2023 07:39:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id A3E0E4FF; Wed, 22 Mar 2023 16:40:06 +0200 (EET) From: Andy Shevchenko To: Bumwoo Lee , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: MyungJoo Ham , Chanwoo Choi Subject: [PATCH v1 02/14] extcon: Fix kernel doc of property capability fields to avoid warnings Date: Wed, 22 Mar 2023 16:39:53 +0200 Message-Id: <20230322144005.40368-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> References: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Kernel documentation has to be synchronized with a code, otherwise the validator is not happy: Function parameter or member 'usb_bits' not described in 'extcon_cable' Function parameter or member 'chg_bits' not described in 'extcon_cable' Function parameter or member 'jack_bits' not described in 'extcon_cabl= e' Function parameter or member 'disp_bits' not described in 'extcon_cabl= e' Describe the fields added in the past. Fixes: ceaa98f442cf ("extcon: Add the support for the capability of each pr= operty") Signed-off-by: Andy Shevchenko Acked-by: Bumwoo Lee --- drivers/extcon/extcon.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 1bc2639704c2..79006ab5334b 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -210,6 +210,10 @@ static const struct __extcon_info { * @chg_propval: the array of charger connector properties * @jack_propval: the array of jack connector properties * @disp_propval: the array of display connector properties + * @usb_bits: the bit array of the USB connector property capabilities + * @chg_bits: the bit array of the charger connector property capabilities + * @jack_bits: the bit array of the jack connector property capabilities + * @disp_bits: the bit array of the display connector property capabiliti= es */ struct extcon_cable { struct extcon_dev *edev; --=20 2.40.0.1.gaa8946217a0b From nobody Mon Apr 13 06:39:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08A28C6FD1C for ; Wed, 22 Mar 2023 14:39:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231610AbjCVOjd (ORCPT ); Wed, 22 Mar 2023 10:39:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231363AbjCVOjY (ORCPT ); Wed, 22 Mar 2023 10:39:24 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A5942A141 for ; Wed, 22 Mar 2023 07:39:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679495963; x=1711031963; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=23K7sqqOvhEB00PQYCJm2SbhNF+B/eu/uGmGRWsjPHU=; b=EB9yC3WMVLvQ/9aXmcV93naILOMzB4Qwh54VB3bmqf7hWgn7w1oV7IIP AdyAf09k03ur3jT7NVdINV5R8OVMXvUjr9IjKdiSbqyV5XzKinq5e61+r CCMgMllyT94xvQslWMbxsS+aMroCqUYnn3ViCkHNs6CExX7hA3zutjMxO e9Vs1xHfrVwiVfXkuu29LDFjpcyb9cb2M3oXoxf+4jWSnx6Px843rt4/Y m7K1QERUQtV50j/NRKexYJfvCeN1NsEtJ8ajlVk+TjGsOt6Kfp8sPt9pG NUJD2RFM8kI2Ce4s1ChHFz13Y4/DOJY7gTLovReh4yCyaCbEjiCt3zJAe Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="327609289" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="327609289" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 07:39:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="792579427" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="792579427" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 22 Mar 2023 07:39:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id AB0C550A; Wed, 22 Mar 2023 16:40:06 +0200 (EET) From: Andy Shevchenko To: Bumwoo Lee , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: MyungJoo Ham , Chanwoo Choi Subject: [PATCH v1 03/14] extcon: Use DECLARE_BITMAP() to declare bit arrays Date: Wed, 22 Mar 2023 16:39:54 +0200 Message-Id: <20230322144005.40368-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> References: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Bit arrays has a specific type helper for the declaration. Use it instead of homegronw equivalent. Signed-off-by: Andy Shevchenko Acked-by: Bumwoo Lee --- drivers/extcon/extcon.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 79006ab5334b..70e9755ba2bc 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -230,10 +230,10 @@ struct extcon_cable { union extcon_property_value jack_propval[EXTCON_PROP_JACK_CNT]; union extcon_property_value disp_propval[EXTCON_PROP_DISP_CNT]; =20 - unsigned long usb_bits[BITS_TO_LONGS(EXTCON_PROP_USB_CNT)]; - unsigned long chg_bits[BITS_TO_LONGS(EXTCON_PROP_CHG_CNT)]; - unsigned long jack_bits[BITS_TO_LONGS(EXTCON_PROP_JACK_CNT)]; - unsigned long disp_bits[BITS_TO_LONGS(EXTCON_PROP_DISP_CNT)]; + DECLARE_BITMAP(usb_bits, EXTCON_PROP_USB_CNT); + DECLARE_BITMAP(chg_bits, EXTCON_PROP_CHG_CNT); + DECLARE_BITMAP(jack_bits, EXTCON_PROP_JACK_CNT); + DECLARE_BITMAP(disp_bits, EXTCON_PROP_DISP_CNT); }; =20 static struct class *extcon_class; --=20 2.40.0.1.gaa8946217a0b From nobody Mon Apr 13 06:39:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B237C6FD1F for ; Wed, 22 Mar 2023 14:39:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231551AbjCVOj1 (ORCPT ); Wed, 22 Mar 2023 10:39:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231308AbjCVOjX (ORCPT ); Wed, 22 Mar 2023 10:39:23 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7797431E19 for ; Wed, 22 Mar 2023 07:39:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679495962; x=1711031962; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kBAOit4snqoHUt4I0yuPk3ujQh2EhLlWYoA5K0fcvog=; b=loTAv2A+xpYkS1pHZbun5wqpCJoYTfmnu9OPP82zwvIXUWubuSp+rMx5 vG//0t9l4MPKVwV1XeRBmAdGZ0VGVGF0HMJAll/R7UbW9Bz4FWa6roSF5 6d743EkyTgcRtZSNj9XIETuP3757cv7dgulYTUYIKqdfWy3ugx4c16CM1 xvwvevpWN0jEZrXRV89eY+NuP71+XDlFo2w64y6CvqWyFoiUh7CWJj3Bj jpHvdC4GzpCTu71JvHt12DDgCczuznTfc5lgFK+pG1w4yy+T/upqcXdKI 7hatze5cP5+ZEY7fgn8/7ma5qlJakfB6KIKNHMb4HuNlkAZXWMpVtKJkG g==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="319622115" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="319622115" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 07:39:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="856116414" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="856116414" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 22 Mar 2023 07:39:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id B24C650B; Wed, 22 Mar 2023 16:40:06 +0200 (EET) From: Andy Shevchenko To: Bumwoo Lee , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: MyungJoo Ham , Chanwoo Choi Subject: [PATCH v1 04/14] extcon: use sysfs_emit() to instead of sprintf() Date: Wed, 22 Mar 2023 16:39:55 +0200 Message-Id: <20230322144005.40368-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> References: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Follow the advice of the Documentation/filesystems/sysfs.rst that show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. Signed-off-by: Andy Shevchenko Acked-by: Bumwoo Lee --- drivers/extcon/extcon.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 70e9755ba2bc..ac84f4aafc69 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -370,12 +370,12 @@ static ssize_t state_show(struct device *dev, struct = device_attribute *attr, struct extcon_dev *edev =3D dev_get_drvdata(dev); =20 if (edev->max_supported =3D=3D 0) - return sprintf(buf, "%u\n", edev->state); + return sysfs_emit(buf, "%u\n", edev->state); =20 for (i =3D 0; i < edev->max_supported; i++) { - count +=3D sprintf(buf + count, "%s=3D%d\n", - extcon_info[edev->supported_cable[i]].name, - !!(edev->state & BIT(i))); + count +=3D sysfs_emit_at(buf, count, "%s=3D%d\n", + extcon_info[edev->supported_cable[i]].name, + !!(edev->state & BIT(i))); } =20 return count; @@ -387,7 +387,7 @@ static ssize_t name_show(struct device *dev, struct dev= ice_attribute *attr, { struct extcon_dev *edev =3D dev_get_drvdata(dev); =20 - return sprintf(buf, "%s\n", edev->name); + return sysfs_emit(buf, "%s\n", edev->name); } static DEVICE_ATTR_RO(name); =20 @@ -398,8 +398,8 @@ static ssize_t cable_name_show(struct device *dev, attr_name); int i =3D cable->cable_index; =20 - return sprintf(buf, "%s\n", - extcon_info[cable->edev->supported_cable[i]].name); + return sysfs_emit(buf, "%s\n", + extcon_info[cable->edev->supported_cable[i]].name); } =20 static ssize_t cable_state_show(struct device *dev, @@ -410,8 +410,8 @@ static ssize_t cable_state_show(struct device *dev, =20 int i =3D cable->cable_index; =20 - return sprintf(buf, "%d\n", - extcon_get_state(cable->edev, cable->edev->supported_cable[i])); + return sysfs_emit(buf, "%d\n", + extcon_get_state(cable->edev, cable->edev->supported_cable[i])); } =20 /** --=20 2.40.0.1.gaa8946217a0b From nobody Mon Apr 13 06:39:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46678C6FD1F for ; Wed, 22 Mar 2023 14:40:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231669AbjCVOjn (ORCPT ); Wed, 22 Mar 2023 10:39:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231451AbjCVOjZ (ORCPT ); Wed, 22 Mar 2023 10:39:25 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C2063347A for ; Wed, 22 Mar 2023 07:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679495964; x=1711031964; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8uevUwjjKvLYeP2DQKzLWRjw88ZIleN4K7KAE0RgZQM=; b=jVCeYsQd6kp9pDOZytt6GIqxERschcuuck54DFg0BTaiwwLHddxC8ZKl 0iwTX8JP4QWi7F3aciWtY3u1O7eU8sx9IdHxPdJL/CcJW2JyLK7wY9Msa cUAFu4xg+96ArNkm4AzOzzH8FzZLe94Xg7Ap7Hqhw4eLcsQAuQmcfVTnh 5ARKlmnthn0nFNf/2fzIrSEXmq8Ik/0NW1EMVJgHvfrxcJBpDNrfTeUtS TOjhlIF4HEP6p0VcBGd459jesKzfoqIT2qEamFiJEHrbnuNC1SiFJU5mx AOkNLKlSRUQQFnwU/783KHHVUcwTj1BEmCqvlucl9fB4Jxu01DLzqCM9c A==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="319622119" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="319622119" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 07:39:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="856116425" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="856116425" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 22 Mar 2023 07:39:22 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id B976F5A7; Wed, 22 Mar 2023 16:40:06 +0200 (EET) From: Andy Shevchenko To: Bumwoo Lee , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: MyungJoo Ham , Chanwoo Choi Subject: [PATCH v1 05/14] extcon: Amend kernel documentation of struct extcon_dev Date: Wed, 22 Mar 2023 16:39:56 +0200 Message-Id: <20230322144005.40368-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> References: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" First of all, the @lock description is missing. Add it. Second, correct the terminator value for the mutual exclusive cabling. Signed-off-by: Andy Shevchenko Acked-by: Bumwoo Lee --- drivers/extcon/extcon.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/extcon/extcon.h b/drivers/extcon/extcon.h index 93b5e0306966..15616446140d 100644 --- a/drivers/extcon/extcon.h +++ b/drivers/extcon/extcon.h @@ -13,8 +13,8 @@ * are disabled. * @mutually_exclusive: Array of mutually exclusive set of cables that can= not * be attached simultaneously. The array should be - * ending with NULL or be NULL (no mutually exclusive - * cables). For example, if it is { 0x7, 0x30, 0}, then, + * ending with 0 or be NULL (no mutually exclusive cables). + * For example, if it is {0x7, 0x30, 0}, then, * {0, 1}, {0, 1, 2}, {0, 2}, {1, 2}, or {4, 5} cannot * be attached simulataneously. {0x7, 0} is equivalent to * {0x3, 0x6, 0x5, 0}. If it is {0xFFFFFFFF, 0}, there @@ -27,7 +27,7 @@ * @nh: Notifier for the state change events from this extcon * @entry: To support list of extcon devices so that users can * search for extcon devices based on the extcon name. - * @lock: + * @lock: Protects device state and serialises device registration * @max_supported: Internal value to store the number of cables. * @extcon_dev_type: Device_type struct to provide attribute_groups * customized for each extcon device. --=20 2.40.0.1.gaa8946217a0b From nobody Mon Apr 13 06:39:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4AE9C6FD1F for ; Wed, 22 Mar 2023 14:39:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231629AbjCVOji (ORCPT ); Wed, 22 Mar 2023 10:39:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbjCVOjZ (ORCPT ); Wed, 22 Mar 2023 10:39:25 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66EA32A141 for ; Wed, 22 Mar 2023 07:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679495964; x=1711031964; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=d4qGUtkkw/1Zx3uos2jaj6d4j/Os0XO1Iz7gJZdoh0U=; b=d4PDK/NkVXq0TApvuKjTPvIgFZXH7HTkvPm9mh3jEyEekbAAfTEEOzOB xjTsA3X1Yb+vtbq8dJy/mhjfZ2gRxhIHZF75Hb25YBAGnx55kHkOKTPXf z+M0aLjXjS5ixCwvRty0aFbIG/3dIYd7A4jjW8jkW+tK0ufBkfU6oqmh+ pOCsneLOEgqRW8cda6TW4smM0/tqIXqtpbBMlmbl8FcxbXDx2ZgsFcUlj DNgpr3bmjrrohdXWBvdzOS2gr30zJaJw2iZ38BZ1U/YdjABLvkeUod8Es Ji6M4eTmDR9JP91dsx93UNiRPp6SqrgyeamR2+Qjuz1gMc5qHmOggVooJ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="327609300" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="327609300" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 07:39:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="792579431" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="792579431" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 22 Mar 2023 07:39:22 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C092C638; Wed, 22 Mar 2023 16:40:06 +0200 (EET) From: Andy Shevchenko To: Bumwoo Lee , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: MyungJoo Ham , Chanwoo Choi Subject: [PATCH v1 06/14] extcon: Allow name to be assigned outside of the framework Date: Wed, 22 Mar 2023 16:39:57 +0200 Message-Id: <20230322144005.40368-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> References: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The documentation states that name of the extcon can be assigned outside of the framework, however code does something different. Fix the code to be aligned with the documentation. Signed-off-by: Andy Shevchenko Acked-by: Bumwoo Lee --- drivers/extcon/extcon.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index ac84f4aafc69..14e66e21597f 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -1269,10 +1269,10 @@ int extcon_dev_register(struct extcon_dev *edev) edev->dev.class =3D extcon_class; edev->dev.release =3D extcon_dev_release; =20 - edev->name =3D dev_name(edev->dev.parent); - if (IS_ERR_OR_NULL(edev->name)) { - dev_err(&edev->dev, - "extcon device name is null\n"); + if (!edev->name) + edev->name =3D dev_name(edev->dev.parent); + if (!edev->name) { + dev_err(&edev->dev, "extcon device name is null\n"); return -EINVAL; } dev_set_name(&edev->dev, "extcon%lu", --=20 2.40.0.1.gaa8946217a0b From nobody Mon Apr 13 06:39:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52DAAC6FD1C for ; Wed, 22 Mar 2023 14:40:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231620AbjCVOkF (ORCPT ); Wed, 22 Mar 2023 10:40:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231598AbjCVOjc (ORCPT ); Wed, 22 Mar 2023 10:39:32 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF7E75FA77 for ; Wed, 22 Mar 2023 07:39:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679495966; x=1711031966; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ORQoLZf18v3gXDfH3BHmV5xqWMBNzteq8nwmowV0t7U=; b=Rrj0Lom1dUQX+g9uN5sc2dK2sm9MBMoTnpbb0NQAzQR3rQr2XRuN/jI4 t/P/6KGxY8EwZ1JIdgR2EUYPbNZYAoehAFYgnEVsn7uZQVoNgl3zeakcE d4ZcJaQengIH0eoeMf8Axr/ouzQfGAuZ9M4qsn0AjKGNe+LiGG1UNXvBG rZ61YXax5TAuoU+AlegkxVwUxGEQ3LDLa3cJVf7iCzcuAYqBVhx3tVHr9 0XbR59l/AvMBF/nqKmNaBygMAIf4wtaXpKHqlR5SVXV7ALtApY8nGQNr4 vYgug7sEdGZfrfrleOmioWFM3nQ/QViZR6rxyqoxC1Yktabln6EFaiZ1M w==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="319622132" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="319622132" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 07:39:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="856116429" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="856116429" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 22 Mar 2023 07:39:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C9E437E5; Wed, 22 Mar 2023 16:40:06 +0200 (EET) From: Andy Shevchenko To: Bumwoo Lee , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: MyungJoo Ham , Chanwoo Choi Subject: [PATCH v1 07/14] extcon: Use unique number for the extcon device ID Date: Wed, 22 Mar 2023 16:39:58 +0200 Message-Id: <20230322144005.40368-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> References: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The use of atomic variable is still racy when we do not control which device has been unregistered and there is a (theoretical) possibility of the overflow that may cause a duplicate extcon device ID number to be allocated next time a device is registered. Replace above mentioned approach by using IDA framework. Signed-off-by: Andy Shevchenko Acked-by: Bumwoo Lee --- drivers/extcon/extcon.c | 15 ++++++++++++--- drivers/extcon/extcon.h | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 14e66e21597f..0d261ec6c473 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -16,6 +16,7 @@ =20 #include #include +#include #include #include #include @@ -238,6 +239,7 @@ struct extcon_cable { =20 static struct class *extcon_class; =20 +static DEFINE_IDA(extcon_dev_ids); static LIST_HEAD(extcon_dev_list); static DEFINE_MUTEX(extcon_dev_list_lock); =20 @@ -1248,7 +1250,6 @@ static int extcon_alloc_groups(struct extcon_dev *ede= v) int extcon_dev_register(struct extcon_dev *edev) { int ret, index =3D 0; - static atomic_t edev_no =3D ATOMIC_INIT(-1); =20 ret =3D create_extcon_class(); if (ret < 0) @@ -1275,8 +1276,14 @@ int extcon_dev_register(struct extcon_dev *edev) dev_err(&edev->dev, "extcon device name is null\n"); return -EINVAL; } - dev_set_name(&edev->dev, "extcon%lu", - (unsigned long)atomic_inc_return(&edev_no)); + + ret =3D ida_simple_get(&extcon_dev_ids, 0, INT_MAX, GFP_KERNEL); + if (ret < 0) + return ret; + + edev->id =3D ret; + + dev_set_name(&edev->dev, "extcon%d", edev->id); =20 ret =3D extcon_alloc_cables(edev); if (ret < 0) @@ -1368,6 +1375,8 @@ void extcon_dev_unregister(struct extcon_dev *edev) return; } =20 + ida_simple_remove(&extcon_dev_ids, edev->id); + device_unregister(&edev->dev); =20 if (edev->mutually_exclusive && edev->max_supported) { diff --git a/drivers/extcon/extcon.h b/drivers/extcon/extcon.h index 15616446140d..877c0860e300 100644 --- a/drivers/extcon/extcon.h +++ b/drivers/extcon/extcon.h @@ -20,6 +20,7 @@ * {0x3, 0x6, 0x5, 0}. If it is {0xFFFFFFFF, 0}, there * can be no simultaneous connections. * @dev: Device of this extcon. + * @id: Unique device ID of this extcon. * @state: Attach/detach state of this extcon. Do not provide at * register-time. * @nh_all: Notifier for the state change events for all supported @@ -46,6 +47,7 @@ struct extcon_dev { =20 /* Internal data. Please do not set. */ struct device dev; + int id; struct raw_notifier_head nh_all; struct raw_notifier_head *nh; struct list_head entry; --=20 2.40.0.1.gaa8946217a0b From nobody Mon Apr 13 06:39:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86CC4C6FD1C for ; Wed, 22 Mar 2023 14:39:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231649AbjCVOjl (ORCPT ); Wed, 22 Mar 2023 10:39:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231422AbjCVOjZ (ORCPT ); Wed, 22 Mar 2023 10:39:25 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0C2F410AB for ; Wed, 22 Mar 2023 07:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679495964; x=1711031964; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fDzjemeuLsru23paImIk8ffwUuduPpzCedRvBa6jMLo=; b=CIsnt/nm5+QJXCD9nc11q3cm7138lGOzoMnEbLnN22aZWxHTOan7ZDjs M0idP2ZoBF63gYNw6hln/xGZNcOLkny3vx2M+lB46sF60YAEFcIBYpSbn B4QE3TjJVCJ4wD0J8Hc/VVDA5lbo9qIatv1ESyKgSk5nv3Su+ryy72MMn VmDg71Km4tmsVsaXzXpf9NWR96zctRhQgeQogaE8oBFZugHz8mmeE8L5J JWCJP4s/Fr/hkMwJnRo0zZFySnB25cnA8W/kbeY5BRk/MHZBRk0cmm1GA beuxywqBbCW9ty9lRS7Q5bSmsDxjfAdx7GiX1h7XAjlhxE0yJ3/XUMMIr A==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="327609304" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="327609304" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 07:39:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="792579434" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="792579434" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 22 Mar 2023 07:39:22 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id CED2C3DD; Wed, 22 Mar 2023 16:40:06 +0200 (EET) From: Andy Shevchenko To: Bumwoo Lee , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: MyungJoo Ham , Chanwoo Choi Subject: [PATCH v1 08/14] extcon: Switch to use kasprintf_strarray() Date: Wed, 22 Mar 2023 16:39:59 +0200 Message-Id: <20230322144005.40368-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> References: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Since we have a generic helper, switch the module to use it. No functional change intended. Signed-off-by: Andy Shevchenko Acked-by: Bumwoo Lee --- drivers/extcon/extcon.c | 25 +++++++++++-------------- drivers/extcon/extcon.h | 1 + 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 0d261ec6c473..a63e7eef02fd 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -23,6 +23,7 @@ #include #include #include +#include #include =20 #include "extcon.h" @@ -1104,19 +1105,17 @@ static int extcon_alloc_cables(struct extcon_dev *e= dev) if (!edev->cables) return -ENOMEM; =20 + edev->cable_names =3D kasprintf_strarray(GFP_KERNEL, "cable", edev->max_s= upported); + if (!edev->cable_names) { + kfree(edev->cables); + return -ENOMEM; + } + for (index =3D 0; index < edev->max_supported; index++) { cable =3D &edev->cables[index]; =20 - str =3D kasprintf(GFP_KERNEL, "cable.%d", index); - if (!str) { - for (index--; index >=3D 0; index--) { - cable =3D &edev->cables[index]; - kfree(cable->attr_g.name); - } - - kfree(edev->cables); - return -ENOMEM; - } + str =3D edev->cable_names[index]; + strreplace(str, '-', '.'); =20 cable->edev =3D edev; cable->cable_index =3D index; @@ -1341,8 +1340,7 @@ int extcon_dev_register(struct extcon_dev *edev) kfree(edev->attrs_muex); } err_alloc_muex: - for (index =3D 0; index < edev->max_supported; index++) - kfree(edev->cables[index].attr_g.name); + kfree_strarray(edev->cable_names, edev->max_supported); if (edev->max_supported) kfree(edev->cables); err_alloc_cables: @@ -1387,8 +1385,7 @@ void extcon_dev_unregister(struct extcon_dev *edev) kfree(edev->attrs_muex); } =20 - for (index =3D 0; index < edev->max_supported; index++) - kfree(edev->cables[index].attr_g.name); + kfree_strarray(edev->cable_names, edev->max_supported); =20 if (edev->max_supported) { kfree(edev->extcon_dev_type.groups); diff --git a/drivers/extcon/extcon.h b/drivers/extcon/extcon.h index 877c0860e300..5624f65ba17a 100644 --- a/drivers/extcon/extcon.h +++ b/drivers/extcon/extcon.h @@ -58,6 +58,7 @@ struct extcon_dev { /* /sys/class/extcon/.../cable.n/... */ struct device_type extcon_dev_type; struct extcon_cable *cables; + char **cable_names; =20 /* /sys/class/extcon/.../mutually_exclusive/... */ struct attribute_group attr_g_muex; --=20 2.40.0.1.gaa8946217a0b From nobody Mon Apr 13 06:39:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 013D7C6FD1C for ; Wed, 22 Mar 2023 14:40:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231682AbjCVOjq (ORCPT ); Wed, 22 Mar 2023 10:39:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231515AbjCVOj0 (ORCPT ); Wed, 22 Mar 2023 10:39:26 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7B31457C6 for ; Wed, 22 Mar 2023 07:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679495964; x=1711031964; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=N33rpjnGQ5ytOuxHzIh25HaIghid6HPaz5R86OU5umw=; b=WTC5LQ6u9ge+YN+DIcNShgymbnWsvNdtEw9GiVHte+8uBX/2q2WxSo5G nnLDpfaXTGtKl26N8p5OJBlQ8HVOPgE6dAQzTHN+WW5LzTIPyBdHjUEzm iMQF8PoU3KImUfQe3kjDGqFua0FwhVn4y6pdo0BR141jJVQovlIxBzfDu q6I1LqpJmBaUPSpTLjdwC1khnRFIZmrkl0GE+YAcZgccMiLOcemYrvAQV yVS2hkQiy8H1WsgrRJ2JFf32FzzTZZ+luPW/RXdimMLHqZu/McllacfIz p2VFO+s5rJwOFVz6bFI+5x0PMcxR2e9v63cnqni9J1bM+wBDQW/tgd0AW Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="319622124" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="319622124" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 07:39:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="856116427" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="856116427" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 22 Mar 2023 07:39:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id DE874942; Wed, 22 Mar 2023 16:40:06 +0200 (EET) From: Andy Shevchenko To: Bumwoo Lee , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: MyungJoo Ham , Chanwoo Choi Subject: [PATCH v1 09/14] extcon: Use device_match_of_node() helper Date: Wed, 22 Mar 2023 16:40:00 +0200 Message-Id: <20230322144005.40368-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> References: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Instead of open coding, use device_match_of_node() helper. Signed-off-by: Andy Shevchenko Acked-by: Bumwoo Lee --- 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 a63e7eef02fd..5cadbfc151e6 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -1411,7 +1411,7 @@ struct extcon_dev *extcon_find_edev_by_node(struct de= vice_node *node) =20 mutex_lock(&extcon_dev_list_lock); list_for_each_entry(edev, &extcon_dev_list, entry) - if (edev->dev.parent && edev->dev.parent->of_node =3D=3D node) + if (edev->dev.parent && device_match_of_node(edev->dev.parent, node)) goto out; edev =3D ERR_PTR(-EPROBE_DEFER); out: --=20 2.40.0.1.gaa8946217a0b From nobody Mon Apr 13 06:39:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E055C76195 for ; Wed, 22 Mar 2023 14:40:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231756AbjCVOjx (ORCPT ); Wed, 22 Mar 2023 10:39:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231523AbjCVOj0 (ORCPT ); Wed, 22 Mar 2023 10:39:26 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F00EC51CAD for ; Wed, 22 Mar 2023 07:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679495965; x=1711031965; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CBCCxTTZs2kCb/p6GUvHy/Ipc4yohpZu5RckL85FL+w=; b=BtBtGPs4sd8XAJa1/i4OUiCKPcb50n+ES0wsgzxtZ4rHVIbVvrEy/fFQ gLNfqal8bP0yjt6fBPlykacRnTtwDkVNjzhVLYWAkYhHRGB3xQQUVzsDJ hrt1UMohuWHwX2VONKn6QgmQjwrh23aJn0A/NFaN7CK0+/BA2u0IQBLHn 7sH0gS8GetdN04b7MtQmeYkDVjBx/wkst3Y/qD+nE7FrySS1iNmheoIgg YKZ0ne1L+LVgzE/Wa9mLd/uaMRNQj73HYyQsVUfyDLhZEKUiDILnYkj6p 5TQh13Awd8FnyzxzcfAQ4I0RdFWDx5GxkxQyaRhm9puFfmhG/z0AGLpoY g==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="327609306" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="327609306" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 07:39:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="792579435" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="792579435" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 22 Mar 2023 07:39:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E3BC480A; Wed, 22 Mar 2023 16:40:06 +0200 (EET) From: Andy Shevchenko To: Bumwoo Lee , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: MyungJoo Ham , Chanwoo Choi Subject: [PATCH v1 10/14] extcon: use dev_of_node(dev) instead of dev->of_node Date: Wed, 22 Mar 2023 16:40:01 +0200 Message-Id: <20230322144005.40368-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> References: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The dev_of_node function should be preferred. In the result we may drop unneeded NULL check of the pointer to the device object. Signed-off-by: Andy Shevchenko Acked-by: Bumwoo Lee --- drivers/extcon/extcon.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 5cadbfc151e6..32e96cb49067 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -1429,21 +1429,17 @@ struct extcon_dev *extcon_find_edev_by_node(struct = device_node *node) */ struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int inde= x) { - struct device_node *node; + struct device_node *node, *np =3D dev_of_node(dev); struct extcon_dev *edev; =20 - if (!dev) - return ERR_PTR(-EINVAL); - - if (!dev->of_node) { + if (!np) { dev_dbg(dev, "device does not have a device node entry\n"); return ERR_PTR(-EINVAL); } =20 - node =3D of_parse_phandle(dev->of_node, "extcon", index); + node =3D of_parse_phandle(np, "extcon", index); if (!node) { - dev_dbg(dev, "failed to get phandle in %pOF node\n", - dev->of_node); + dev_dbg(dev, "failed to get phandle in %pOF node\n", np); return ERR_PTR(-ENODEV); } =20 --=20 2.40.0.1.gaa8946217a0b From nobody Mon Apr 13 06:39:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E107C6FD1F for ; Wed, 22 Mar 2023 14:40:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231602AbjCVOkD (ORCPT ); Wed, 22 Mar 2023 10:40:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231586AbjCVOj3 (ORCPT ); Wed, 22 Mar 2023 10:39:29 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F01E60417 for ; Wed, 22 Mar 2023 07:39:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679495966; x=1711031966; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Nx51SpraYhWhakBAvwZOoAwXLoCLgSQssS6ASOeGoTw=; b=WLtfgnFvk61N0JK5V547On91RTdTA31k1wF8/e3Jg02z+E+9pI2/erlb ddtHevC4sNsdr5bkXNPjUEHFvxgBWoi+tiYKAittvbQ4QAHMChsvknlSf VQ/kb9UMqzEQEs7Cg5fqd7jNoHJZhS5ls0trZBC85jLvIhHVudHUlU0A3 t/d4mIitxyY4CaNtdG8sLlHsuBWVATgz8pDeZMAeZ+K6gPhaIQ8BUyo6z QdBYN23bWlXu/YPEUu5s565OtX3nr4+z5deG1tlo4XqQwo1KbH9RNH11f 5rKonsJERRpj8nu096/QlG6SWLdel8Xlh7KBAQAaJvVKrVq4PJHKyL1Dy g==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="319622135" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="319622135" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 07:39:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="856116431" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="856116431" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 22 Mar 2023 07:39:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id F2061A0D; Wed, 22 Mar 2023 16:40:06 +0200 (EET) From: Andy Shevchenko To: Bumwoo Lee , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: MyungJoo Ham , Chanwoo Choi Subject: [PATCH v1 11/14] extcon: Remove dup device name in the message and unneeded error check Date: Wed, 22 Mar 2023 16:40:02 +0200 Message-Id: <20230322144005.40368-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> References: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The device name is already printed with dev_err(), no need to repeat. The device pointer itself is not supposed to be an error point, drop that check. Signed-off-by: Andy Shevchenko Acked-by: Bumwoo Lee --- drivers/extcon/extcon.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 32e96cb49067..0e04ea185c26 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -1367,9 +1367,8 @@ void extcon_dev_unregister(struct extcon_dev *edev) list_del(&edev->entry); mutex_unlock(&extcon_dev_list_lock); =20 - if (IS_ERR_OR_NULL(get_device(&edev->dev))) { - dev_err(&edev->dev, "Failed to unregister extcon_dev (%s)\n", - dev_name(&edev->dev)); + if (!get_device(&edev->dev)) { + dev_err(&edev->dev, "Failed to unregister extcon_dev\n"); return; } =20 --=20 2.40.0.1.gaa8946217a0b From nobody Mon Apr 13 06:39:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2333FC761A6 for ; Wed, 22 Mar 2023 14:40:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231712AbjCVOju (ORCPT ); Wed, 22 Mar 2023 10:39:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231531AbjCVOj0 (ORCPT ); Wed, 22 Mar 2023 10:39:26 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 530D6521ED for ; Wed, 22 Mar 2023 07:39:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679495965; x=1711031965; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XodOHskzLqB9GOrDUS/F5Kh8Lt/zUFltWrdOozMmc8c=; b=Tx2pAAeGQgygEUDmpnqScbs3EkjrnpC35XNYuL7aMZBU+771JiNo6G0U 2iupDvqhjbsFQ/JWqx8wngkuBQU7LhqkJCDUX9zIOByU3IPN4fyFotEi1 nEpPpSfC2v+SgA3BENqc6EjyJ3SeJAI8tfAthvHCN5/RgTIEH9s6w8KpR 8uKaicf8XtBM1o3uDo6YgBPQL7XcRTTKl1pUykedYy1yFeL5FrraIRkOQ /xeQoLZsKeyGZu1EFTOJAk2kkMRMolOh+LF560pfOLIazAIxQK0qQItCZ xFwtxsFyPKbQCjGnc4Y1Z3IjpZVLOYEZ0YbRI7IP0qXru+kKbzANoXOQQ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="327609307" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="327609307" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 07:39:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="792579436" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="792579436" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 22 Mar 2023 07:39:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 03630944; Wed, 22 Mar 2023 16:40:07 +0200 (EET) From: Andy Shevchenko To: Bumwoo Lee , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: MyungJoo Ham , Chanwoo Choi Subject: [PATCH v1 12/14] extcon: Use sizeof(*pointer) instead of sizeof(type) Date: Wed, 22 Mar 2023 16:40:03 +0200 Message-Id: <20230322144005.40368-13-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> References: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It is preferred to use sizeof(*pointer) instead of sizeof(type). The type of the variable can change and one needs not change the former (unlike the latter). No functional change intended. Signed-off-by: Andy Shevchenko Acked-by: Bumwoo Lee --- drivers/extcon/extcon.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 0e04ea185c26..b3f038639cd6 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -1099,9 +1099,7 @@ static int extcon_alloc_cables(struct extcon_dev *ede= v) if (!edev->max_supported) return 0; =20 - edev->cables =3D kcalloc(edev->max_supported, - sizeof(struct extcon_cable), - GFP_KERNEL); + edev->cables =3D kcalloc(edev->max_supported, sizeof(*edev->cables), GFP_= KERNEL); if (!edev->cables) return -ENOMEM; =20 @@ -1160,14 +1158,12 @@ static int extcon_alloc_muex(struct extcon_dev *ede= v) for (index =3D 0; edev->mutually_exclusive[index]; index++) ; =20 - edev->attrs_muex =3D kcalloc(index + 1, - sizeof(struct attribute *), + edev->attrs_muex =3D kcalloc(index + 1, sizeof(*edev->attrs_muex), GFP_KERNEL); if (!edev->attrs_muex) return -ENOMEM; =20 - edev->d_attrs_muex =3D kcalloc(index, - sizeof(struct device_attribute), + edev->d_attrs_muex =3D kcalloc(index, sizeof(*edev->d_attrs_muex), GFP_KERNEL); if (!edev->d_attrs_muex) { kfree(edev->attrs_muex); @@ -1213,8 +1209,8 @@ static int extcon_alloc_groups(struct extcon_dev *ede= v) return 0; =20 edev->extcon_dev_type.groups =3D kcalloc(edev->max_supported + 2, - sizeof(struct attribute_group *), - GFP_KERNEL); + sizeof(*edev->extcon_dev_type.groups), + GFP_KERNEL); if (!edev->extcon_dev_type.groups) return -ENOMEM; =20 @@ -1298,8 +1294,7 @@ int extcon_dev_register(struct extcon_dev *edev) =20 spin_lock_init(&edev->lock); if (edev->max_supported) { - edev->nh =3D kcalloc(edev->max_supported, sizeof(*edev->nh), - GFP_KERNEL); + edev->nh =3D kcalloc(edev->max_supported, sizeof(*edev->nh), GFP_KERNEL); if (!edev->nh) { ret =3D -ENOMEM; goto err_alloc_nh; --=20 2.40.0.1.gaa8946217a0b From nobody Mon Apr 13 06:39:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A648C77B60 for ; Wed, 22 Mar 2023 14:40:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231840AbjCVOj6 (ORCPT ); Wed, 22 Mar 2023 10:39:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231539AbjCVOj0 (ORCPT ); Wed, 22 Mar 2023 10:39:26 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE7B454C8D for ; Wed, 22 Mar 2023 07:39:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679495965; x=1711031965; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hoaAx9Ps+XUntb1eapTod1FMgNK7hAJfzIEXEA74T44=; b=YowXbGbEuwMX3f3a+dXoyeNhKZCY7RyzQ84gWM0B3rFMryNud0dY9XJD enltDkzUTVghWNzucsQ1nZZV9DXJTunY86/LCQAzZrPFssxp34j8BtYSP hprXPEsKev+DVovGO/SlklR0zO/7IcymTWTRbeTsSZvWDAYHM6256Ojf+ /mstvdtC3W7Siwh12wClIz8mL1zcldGBrabwD8h6LURdVEkudilGoFmVE ouhNNpuLp5edowb929o/ljdq9PH+4qxgMuod07GjqFQ+Let8X63LznfAe Zr08nYBufeFUct0RFY+usN+7ulDQVaC+YSGYyjGBWpYaPCc9N6yebTsdm g==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="319622128" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="319622128" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 07:39:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="856116428" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="856116428" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 22 Mar 2023 07:39:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 11EC0A53; Wed, 22 Mar 2023 16:40:07 +0200 (EET) From: Andy Shevchenko To: Bumwoo Lee , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: MyungJoo Ham , Chanwoo Choi Subject: [PATCH v1 13/14] extcon: Drop unneeded assignments Date: Wed, 22 Mar 2023 16:40:04 +0200 Message-Id: <20230322144005.40368-14-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> References: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In one case the assignment is duplicative, in the other, it's better to move it into the loop =E2=80=94 the user of it. Signed-off-by: Andy Shevchenko Acked-by: Bumwoo Lee Acked-by: Chanwoo Choi --- drivers/extcon/extcon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index b3f038639cd6..edfa0450e605 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -246,7 +246,7 @@ static DEFINE_MUTEX(extcon_dev_list_lock); =20 static int check_mutually_exclusive(struct extcon_dev *edev, u32 new_state) { - int i =3D 0; + int i; =20 if (!edev->mutually_exclusive) return 0; @@ -1244,7 +1244,7 @@ static int extcon_alloc_groups(struct extcon_dev *ede= v) */ int extcon_dev_register(struct extcon_dev *edev) { - int ret, index =3D 0; + int ret, index; =20 ret =3D create_extcon_class(); if (ret < 0) @@ -1253,7 +1253,7 @@ int extcon_dev_register(struct extcon_dev *edev) if (!edev || !edev->supported_cable) return -EINVAL; =20 - for (; edev->supported_cable[index] !=3D EXTCON_NONE; index++); + for (index =3D 0; edev->supported_cable[index] !=3D EXTCON_NONE; index++); =20 edev->max_supported =3D index; if (index > SUPPORTED_CABLE_MAX) { --=20 2.40.0.1.gaa8946217a0b From nobody Mon Apr 13 06:39:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EED0BC77B62 for ; Wed, 22 Mar 2023 14:40:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231863AbjCVOkA (ORCPT ); Wed, 22 Mar 2023 10:40:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231560AbjCVOj2 (ORCPT ); Wed, 22 Mar 2023 10:39:28 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E5905FEAB for ; Wed, 22 Mar 2023 07:39:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679495966; x=1711031966; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mmz2iv76okOwpVenPFn6EHP4R2cbAkp+w1ZBuPRcRrI=; b=dH1tx7ZBnq2ocjMA4zKKKcauKCfFH8/HAkCNBGktQ+hvVgIci7CZM8wj ro4I18u2BjVqcxFHLt33fjoJkLN9jbHkRHVD2UjN1aCzWhda4XcreuvjD DzhkAkAUSwbAJ00HuDXN30W4+ApgEnf5QEUT/pMdXCRAuB43Hhandf6gk 29ODE6UUbc3+IeuWDYsYGIo2V363zrf8laG7GbHw0Yb0YDdIU6trTAd2X V1pxrVmQooiusdk7l+4fnfJSCHezGePg27b61QJvBE3nWpQcwwE9OsOsE 0/4DMf9dYUlQTO5MafqNUC3naVHbQYosqIstiMp3N8lkZpV5g+AgzTTpC Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="319622131" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="319622131" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 07:39:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="856116430" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="856116430" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 22 Mar 2023 07:39:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 171C7A43; Wed, 22 Mar 2023 16:40:07 +0200 (EET) From: Andy Shevchenko To: Bumwoo Lee , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: MyungJoo Ham , Chanwoo Choi Subject: [PATCH v1 14/14] extcon: Use positive conditional in ternary operator Date: Wed, 22 Mar 2023 16:40:05 +0200 Message-Id: <20230322144005.40368-15-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> References: <20230322144005.40368-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It's easier to parse by a human being the positive conditional. Signed-off-by: Andy Shevchenko Acked-by: Bumwoo Lee --- 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 edfa0450e605..3e8522d522b4 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -1466,7 +1466,7 @@ EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle); */ const char *extcon_get_edev_name(struct extcon_dev *edev) { - return !edev ? NULL : edev->name; + return edev ? edev->name : NULL; } EXPORT_SYMBOL_GPL(extcon_get_edev_name); =20 --=20 2.40.0.1.gaa8946217a0b