From patchwork Mon Mar 6 19:55:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 659570 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 A0108C6FD1D for ; Mon, 6 Mar 2023 19:55:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230177AbjCFTzk (ORCPT ); Mon, 6 Mar 2023 14:55:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbjCFTzh (ORCPT ); Mon, 6 Mar 2023 14:55:37 -0500 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A77A64A93; Mon, 6 Mar 2023 11:55:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678132536; x=1709668536; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x77bSH20Ou4EihSoiJQDgs4+5OFy75brI2gUDSEqixA=; b=cMryF/q2DkCkGdjn36ecf/XF5C/Kdn/qJO3rQFe5iTgajiG6nR5bLnlJ pgA5t5nWmhjnQLHfBGmau/ZeYXdMrQKxh491XwFjlKqzfyb/BU+o/PCDv oUQ2B8N22aJh0yF4wWDoSWG4hSRZkjtHARIMv4blbIjTCRbTmhEm8rdix adiWN0u4mfDQzWas5FerAK/fBnGfBMSVkSUKRbF82hp+Z57y8Cm4HUSFz teN6rr9gStnG8Pjv4NDmditY057hyrt0+VwRgz7iyLpZPZgK+9ijInGvS ckR7VRvvq54Kko+G78+LQuK8iKq+CRgYuuayM3VBBSbqcqAg2WzIlQzqI Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="400483892" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="400483892" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 11:55:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="1005549562" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="1005549562" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 06 Mar 2023 11:55:28 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 6B292398; Mon, 6 Mar 2023 21:56:12 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Schspa Shi , Marc Zyngier , Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pwm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, patches@opensource.cirrus.com Cc: Linus Walleij , Doug Berger , Florian Fainelli , Broadcom internal kernel review list , Andy Shevchenko , Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Maxime Coquelin , Alexandre Torgue , Kuppuswamy Sathyanarayanan , Nandor Han , Semi Malinen Subject: [PATCH v1 04/16] lib/string_choices: Add str_input_output() helper Date: Mon, 6 Mar 2023 21:55:44 +0200 Message-Id: <20230306195556.55475-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230306195556.55475-1-andriy.shevchenko@linux.intel.com> References: <20230306195556.55475-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Add str_input_output() helper to return 'input' or 'output' string literal. Also add an inversed variant, i.e. str_output_input(). All the same for str_in_out(). Signed-off-by: Andy Shevchenko --- include/linux/string_choices.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h index 48120222b9b2..ad345df325ec 100644 --- a/include/linux/string_choices.h +++ b/include/linux/string_choices.h @@ -26,6 +26,18 @@ static inline const char *str_high_low(bool v) } #define str_low_high(v) str_high_low(!(v)) +static inline const char *str_in_out(bool v) +{ + return v ? "in" : "out"; +} +#define str_out_in(v) str_in_out(!(v)) + +static inline const char *str_input_output(bool v) +{ + return v ? "input" : "output"; +} +#define str_output_input(v) str_input_output(!(v)) + static inline const char *str_read_write(bool v) { return v ? "read" : "write";