From patchwork Wed Nov 30 11:50:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13059738 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 9F938C4708A for ; Wed, 30 Nov 2022 11:50:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233498AbiK3LuG (ORCPT ); Wed, 30 Nov 2022 06:50:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233147AbiK3LuF (ORCPT ); Wed, 30 Nov 2022 06:50:05 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2C283E0A0; Wed, 30 Nov 2022 03:50:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669809004; x=1701345004; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=6wimyYQbsxLPBuz4Yl1fOGCJ7Sk/b97+f3lsZ3q38XY=; b=MAoRtzYTjQRwJVwyXb/RntzeXhsdBna8BVu7DATW/ssE6Vs/ow9W9vef nj7mluIybWVtTd5pQZZAMySaGt5/fooE3mJuPrC9a6gxTQI/Tj5bgaqe9 tMyWcVb5sZPriGPkUjXkVVBM4ULvPjIgB9ihtu32Gvd+DEA0YE5hN/sec 2qOmGnnTW75FQxhAAMF2OYG9oM3OnzfUkzwZo96W3+Fi4IpX+a5IjrVxf FK/+O2D0RxZT8udZ5yQWKFZz673xU/2jg31ToOfj4lAqORnNBOqzk+bPQ f7C0eL4oXzhrd2gRVsapzVkfqW2my6f0zt78cig87eEK7rP8u5cJNTN4D w==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="295739717" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="295739717" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2022 03:50:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="712779990" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="712779990" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 30 Nov 2022 03:50:02 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id C600B10E; Wed, 30 Nov 2022 13:50:29 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Hans de Goede , platform-driver-x86@vger.kernel.org Subject: [PATCH v1 1/3] lib/string_helpers: Add missing header files to MAINTAINERS database Date: Wed, 30 Nov 2022 13:50:20 +0200 Message-Id: <20221130115022.68956-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The header files string.h and string_helpers.h are missing in the MAINTAINERS. Add them. Signed-off-by: Andy Shevchenko --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 331dc0e3e5f9..c1f0310dae18 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8721,6 +8721,8 @@ F: drivers/input/touchscreen/resistive-adc-touch.c GENERIC STRING LIBRARY R: Andy Shevchenko S: Maintained +F: include/linux/string.h +F: include/linux/string_helpers.h F: lib/string.c F: lib/string_helpers.c F: lib/test_string.c From patchwork Wed Nov 30 11:50:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13059740 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 BDC2CC433FE for ; Wed, 30 Nov 2022 11:50:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233674AbiK3LuR (ORCPT ); Wed, 30 Nov 2022 06:50:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233620AbiK3LuH (ORCPT ); Wed, 30 Nov 2022 06:50:07 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F411F3E0A0; Wed, 30 Nov 2022 03:50:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669809006; x=1701345006; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J8XKqgebmXUSiaMQSAtHQW4ztiKX0139fFBUxXffoEs=; b=HQT1TzgAXlQKiib7NtUFWAZwVUh868cQMTEnMualdRlWSIU1nK/OTojl 0zcvP7IBCUBxmDIJZj0mEG69c0w0YJWDgm6rx9tpHR4SOcJmV8/Zmz+BR BZam8CMzNsPDJjb+ORNUbLwZ28Most0aE2FSRHdFQBLqmQITyj8gcP+ZS BQQVejabkwdo7EnMZNhm5OMZ+VQZrTfkbP0M1AFnCDnfPpImbSIMIqsoI dONQOUen+g/webfTVp0YuAmzaraZWHmgehZPvqOujPdcrre2oFsXoRxIi vNj39H7VbbW5g6aJCWjNJ38vxGClBsFY8pynVd5gS84/+1H+mlSgpGHlO w==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="298748041" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="298748041" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2022 03:50:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="732959314" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="732959314" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 30 Nov 2022 03:50:03 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id D15EC6A; Wed, 30 Nov 2022 13:50:29 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Hans de Goede , platform-driver-x86@vger.kernel.org Subject: [PATCH v1 2/3] lib/string_helpers: Add str_high_low() helper Date: Wed, 30 Nov 2022 13:50:21 +0200 Message-Id: <20221130115022.68956-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221130115022.68956-1-andriy.shevchenko@linux.intel.com> References: <20221130115022.68956-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Add str_high_low() helper to return 'high' or 'low' string literal. Signed-off-by: Andy Shevchenko --- include/linux/string_helpers.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h index 8530c7328269..fd72393e7975 100644 --- a/include/linux/string_helpers.h +++ b/include/linux/string_helpers.h @@ -128,6 +128,11 @@ static inline const char *str_enabled_disabled(bool v) return v ? "enabled" : "disabled"; } +static inline const char *str_high_low(bool v) +{ + return v ? "high" : "low"; +} + static inline const char *str_read_write(bool v) { return v ? "read" : "write"; From patchwork Wed Nov 30 11:50:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13059739 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 04CBDC433FE for ; Wed, 30 Nov 2022 11:50:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233719AbiK3LuH (ORCPT ); Wed, 30 Nov 2022 06:50:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233443AbiK3LuF (ORCPT ); Wed, 30 Nov 2022 06:50:05 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40C3E3E0B9; Wed, 30 Nov 2022 03:50:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669809005; x=1701345005; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SU/NorHp8bte8kSzQBB60nH7d9fJQrjLciVnA/+O99s=; b=YcIG8rzeP0u04+Z/4OPAQP5wzeLtomFlYIJZ3NQ6sgdZ955/4seyi2Ij Ndt/BjFM9TofIve4d9Eqj4xT/+xEDbZjFsR5eUhtiaRDXOmH0cTZ+Fr4P pk0PiT0j0EyTAu3zwEnZ9VsApE/SKmT2bKlyRBg+VVncEVnTJ3AmCNNHR P8vNkFD8pBwplmdT7PEpgoHxCnfM7edw4ISonIQ4g/ArUn94sgyJ0l98k xZf3o73r4TXOosdNn10i9DmwSeLd2vuSLY80ER35EAes6atxqwujhAHrK houqioOTL7vb7tBNiM+mohqMPRIr1c5iriVIGDTsAFUtoFsugiz2PGFCn w==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="298748038" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="298748038" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2022 03:50:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="732959311" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="732959311" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 30 Nov 2022 03:50:02 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id DF038184; Wed, 30 Nov 2022 13:50:29 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Hans de Goede , platform-driver-x86@vger.kernel.org Subject: [PATCH v1 3/3] lib/string_helpers: Split out string_choices.h Date: Wed, 30 Nov 2022 13:50:22 +0200 Message-Id: <20221130115022.68956-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221130115022.68956-1-andriy.shevchenko@linux.intel.com> References: <20221130115022.68956-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Some users may only need the string choice APIs. Split the respective header, i.e. string_choices.h. Include it in the string_helpers.h. Signed-off-by: Andy Shevchenko --- MAINTAINERS | 1 + include/linux/string_choices.h | 37 ++++++++++++++++++++++++++++++++++ include/linux/string_helpers.h | 31 +--------------------------- 3 files changed, 39 insertions(+), 30 deletions(-) create mode 100644 include/linux/string_choices.h diff --git a/MAINTAINERS b/MAINTAINERS index c1f0310dae18..b16c2488f05a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8722,6 +8722,7 @@ GENERIC STRING LIBRARY R: Andy Shevchenko S: Maintained F: include/linux/string.h +F: include/linux/string_choices.h F: include/linux/string_helpers.h F: lib/string.c F: lib/string_helpers.c diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h new file mode 100644 index 000000000000..ff7e202808a9 --- /dev/null +++ b/include/linux/string_choices.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_STRING_CHOICES_H_ +#define _LINUX_STRING_CHOICES_H_ + +#include + +static inline const char *str_enable_disable(bool v) +{ + return v ? "enable" : "disable"; +} + +static inline const char *str_enabled_disabled(bool v) +{ + return v ? "enabled" : "disabled"; +} + +static inline const char *str_high_low(bool v) +{ + return v ? "high" : "low"; +} + +static inline const char *str_read_write(bool v) +{ + return v ? "read" : "write"; +} + +static inline const char *str_on_off(bool v) +{ + return v ? "on" : "off"; +} + +static inline const char *str_yes_no(bool v) +{ + return v ? "yes" : "no"; +} + +#endif diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h index fd72393e7975..88fb8e1d0421 100644 --- a/include/linux/string_helpers.h +++ b/include/linux/string_helpers.h @@ -5,6 +5,7 @@ #include #include #include +#include #include struct device; @@ -108,34 +109,4 @@ void kfree_strarray(char **array, size_t n); char **devm_kasprintf_strarray(struct device *dev, const char *prefix, size_t n); -static inline const char *str_yes_no(bool v) -{ - return v ? "yes" : "no"; -} - -static inline const char *str_on_off(bool v) -{ - return v ? "on" : "off"; -} - -static inline const char *str_enable_disable(bool v) -{ - return v ? "enable" : "disable"; -} - -static inline const char *str_enabled_disabled(bool v) -{ - return v ? "enabled" : "disabled"; -} - -static inline const char *str_high_low(bool v) -{ - return v ? "high" : "low"; -} - -static inline const char *str_read_write(bool v) -{ - return v ? "read" : "write"; -} - #endif