Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4976873pxb; Mon, 15 Feb 2021 06:28:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxzzFlp8V1OOmAgZx5evW7BnY5hXItDHH1iVCw3faW3SYKSvWtIsGumNOsMc/s8AkTRQmXf X-Received: by 2002:a17:906:1352:: with SMTP id x18mr10259592ejb.418.1613399308261; Mon, 15 Feb 2021 06:28:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1613399308; cv=pass; d=google.com; s=arc-20160816; b=i+Ed6Jffe581McLaKBqtbGvY7Lxnkvgc1TiLKYcsCEgfzIeBPjn2zfUC823PFunUDa EW9JzO17SPUVbFdf9seamYC307twx3a3Uzop+ZE22b35eCr8e4tnPUw8gZ0kL7Tny/XH 2xUyyzopduGjYgnu7zjQkNaj3YrPtZ9zyWmuQJiKSWYXcLS/wDJW63MMSQbnig4bQCwV OO6lQYecOid2hAW4zLAPoKv9e/G4PE42A5dgA0Tv8OwgsPTpJzZ24IVwF6zyTo/dxljE xCjaHP4/7zX3GXK1AhZVC9pcC7+RQHbFgEo0YXMTvLxJDNynOQzJlcX7m4nhXdteBu/9 79Eg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-language :content-transfer-encoding:in-reply-to:user-agent:date:message-id :from:references:cc:to:subject:dkim-signature; bh=kEPCJpwUacu5aR2jhd5tpwqz0a7bZLdP6xbT0Qt4Rkw=; b=FCUe4zD3nmZeUYMOHcMUahV5byHgCSs4mq2z4JQljASXGYg6IruaelwSoxHkGpzR0M nnUkarqbuANY14ui8SiwuJsQrxVwaWPgdpEOW1A8l1wVCary0qC5dEn6JH5/+si7edlm G5C3oqOyHGXp+k2k7u0+qWrtXZS7fw1bG96FY0UxXtp/YqjNjcchVIaosxQIVf7hGNv8 jXPwXNAXYqgJ9NF8PogyrWZKnScm7WL6dr/fI+2dov8r9MpV+EELGCXBt67Vqiyfdn4c GhzSeri4ZiLFfflbMJ309Zsg02SToiI3uhmXHYiu4nH+iY7tsDXCTgjozrwq3ad1+gNd /R+w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=wEA6EyQ8; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x21si12440668edv.185.2021.02.15.06.28.04; Mon, 15 Feb 2021 06:28:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=wEA6EyQ8; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230044AbhBOO1N (ORCPT + 99 others); Mon, 15 Feb 2021 09:27:13 -0500 Received: from mail-mw2nam12on2085.outbound.protection.outlook.com ([40.107.244.85]:32864 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229670AbhBOO1L (ORCPT ); Mon, 15 Feb 2021 09:27:11 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VlxSotLv6OECl+JnlX9bfjPiku9Yqo/R8VxXonfucN9MV13QGg472JedaNU0R3dHUPq1xvZHcQoh04TPAuverRAnn19nSCXH67brD8DxUo5gKRM+OgeXyjlMy3LYJHphMOwNubkgXt5Fi5xkBiAuDtwrwguM/WiYp4X7U9BxQmY6/Z3cJSn1uTmIWDez/S3S6Sr56Lk2sTGLvq2evVR32gPZtMbkLgVH2dKN8HgFP+5ixtOhp6L/IFyPIY5TbKSwIYFVX1AkQcG74xtOmgQ9WCuAJtSeynzWnpYFGWvqyb/bptc+saEMo+NCSHdPEBLm0Fs0HhBqoW+ssXFssYdcfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kEPCJpwUacu5aR2jhd5tpwqz0a7bZLdP6xbT0Qt4Rkw=; b=Uc56oFrd9vIPa4wLLNbiKwQqBBJS9YS6n9ZJuqk9FhhJPefuEbEb9ebt5RJXAmws7uHVgyvG/zwF60WurQsnJY9pQSeL1UUnWctp+FCSlUINY6FAbRfZ+pfjVstx4xpOZWX9FG2lSz5dnnGB5Uh+ACi1HPyIvXAMNrwdDR2pTnmhRg5lkCxRXJZjg8IAGtWDfZ6L8KVSuVeY36BoNUxAHf/utv3hycKsG7dQfETsJ2jIIFtS1IdBWNcCCiqi368iwa/wzPhIx13NSCQESwQZ6sVePP5LMaV3lqjM1pZt5wqLYbfqEA72KSSefdc2GUbMRgXiApd4cdpJzwizFQhpwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kEPCJpwUacu5aR2jhd5tpwqz0a7bZLdP6xbT0Qt4Rkw=; b=wEA6EyQ8iPdIx8ujPGQK6tluBNgfZBSl+A0s9OO1CB3zGSmEK6UEOTpYmjWjFPdjCsMx/UJMzyW0lF9FWKLukwoltrNqQ6yGVZae6eN4UfF9gP6/SsH1v9Fttr15yePvxclc4iCXNFWB157E5ohWkroiBtGuM5elDE6pycS34UY= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=amd.com; Received: from MN2PR12MB3775.namprd12.prod.outlook.com (2603:10b6:208:159::19) by MN2PR12MB4223.namprd12.prod.outlook.com (2603:10b6:208:1d3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27; Mon, 15 Feb 2021 14:26:16 +0000 Received: from MN2PR12MB3775.namprd12.prod.outlook.com ([fe80::c1ff:dcf1:9536:a1f2]) by MN2PR12MB3775.namprd12.prod.outlook.com ([fe80::c1ff:dcf1:9536:a1f2%2]) with mapi id 15.20.3846.038; Mon, 15 Feb 2021 14:26:16 +0000 Subject: Re: [PATCH v1 1/3] string: Consolidate yesno() helpers under string.h hood To: Andy Shevchenko , Alex Deucher , Mikita Lipski , Eryk Brol , Chris Wilson , "David S. Miller" , Rahul Lakkireddy , Francis Laniel , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, netdev@vger.kernel.org Cc: Harry Wentland , Leo Li , David Airlie , Daniel Vetter , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Raju Rangoju , Jakub Kicinski References: <20210215142137.64476-1-andriy.shevchenko@linux.intel.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <43456ba7-c372-84cc-4949-dcb817188e21@amd.com> Date: Mon, 15 Feb 2021 15:26:09 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 In-Reply-To: <20210215142137.64476-1-andriy.shevchenko@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [2a02:908:1252:fb60:83c6:b72d:87bd:4259] X-ClientProxiedBy: AM0PR01CA0086.eurprd01.prod.exchangelabs.com (2603:10a6:208:10e::27) To MN2PR12MB3775.namprd12.prod.outlook.com (2603:10b6:208:159::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [IPv6:2a02:908:1252:fb60:83c6:b72d:87bd:4259] (2a02:908:1252:fb60:83c6:b72d:87bd:4259) by AM0PR01CA0086.eurprd01.prod.exchangelabs.com (2603:10a6:208:10e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Mon, 15 Feb 2021 14:26:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ac94fef5-e2bd-474b-8a5e-08d8d1bda799 X-MS-TrafficTypeDiagnostic: MN2PR12MB4223: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zNmks1hC0bG4XZViiAJ6og59UUCwHWsDwGLvopN0x0AoN8HHR8yRjmRdryhoDEqDOMOM+c2nKlOC2sKJ7YXcbFqM1fMiRacWvHVGJUR5g05QFCg48c1GjLVt8BPmb5mqWogaRZmf4uCk9Z1fvAB0EsIoix5VomRVErCj9tRmGMILwA7SClR/wfBWXqYSyJo3FNXLFt7Hm2MNn9NN+wSF4T/6nGLX7+cs1XxT3hSD0CPQwr5EYmuxgFWwmGInvU+kTxDuGOXUvxTNS5GE1//kr9aYG3nriJ/mqyXdQSLIXTz/vdfUWJko0A7Ztf3/n6aZQ+29jSo5JNZ+7QXMdDwANl456R6SsdxeLAWEY5o9h5bR2Xm4CoQd4ygRt7eGtEgvZnAcX/odW2PMb3GskBw6Xt7kRu3eSYch54m9ZFnMsy1z9Bs72P9QLAQ3R0/QNQPeKXAnmM7GrWAEAJIZ8+HxCRvv9HoZnfk5Vac08PKfNnOOZ6Whm+Gc2QonXuGxJyF9Zp2R8w3Q8+jbyvMgI6L3xavKiY/R5bfcALjB+TG4eTbRCTv870n5L5RR9DldDwW5Hh96TDXdgCcyxdkvXpB8ZUNZzcqLfNAAMyw3h6qNV78= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB3775.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(376002)(366004)(39860400002)(396003)(136003)(6486002)(7416002)(5660300002)(2616005)(66946007)(36756003)(52116002)(31696002)(54906003)(4326008)(478600001)(16526019)(8936002)(86362001)(186003)(2906002)(83380400001)(31686004)(921005)(6666004)(66476007)(66556008)(316002)(8676002)(110136005)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?dDBnMzZiMTAxM1c1RVpQa0l3amdBa1luekI3TXNJSWVscmhqeVcvNHM3OXhL?= =?utf-8?B?Y0lqTE9sQmt0d1ZzT1BxbXBDNGltMHJoUm9PdXFQS2pDSkpOVUIwZGFQSlJU?= =?utf-8?B?WWRHSGR3T1Erb1VlclBiaVFTSTZQK3g1VDlyWUR6Ukt3RDltaHZsMTllVUsr?= =?utf-8?B?MEtrNlloSFB6cEN3TlZoeFA0RmxIZUZpZXFnWDlnVXZ6VEY2OHJ0a0d1Z1Nq?= =?utf-8?B?OVVBSHdQNWd6WDlUdjlKV3FTZjFqRURYemJsRU92eEo1WHBsWlNmdGRBNVJ1?= =?utf-8?B?Qm1Kc0J1ZDhKTDRob1VaNElTL21WdUVNbTRqc0dxU2xTK3RlTmhPVENrZUMx?= =?utf-8?B?Y215VWc4dFV3Y2F0MTJQQ1F1S3R1ait3SlkxVUNYbHVXSFNhT1cwQW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nNGU1JBNkZUMi9ObXpUdVVE?= =?utf-8?B?U0x5M2dxUVZmdVhNdEMwWmYyY1dMSlFDMVQxQnVVTTRMY2s5cm5DcDQ3MnVi?= =?utf-8?B?RSt4bHdjL3F1bnVJTWZHUW1rSzFWZkwwbXMrTHliTDU0SHRER3UzN0NLT0pP?= =?utf-8?B?VFIwZHFJRThtSVBVT21oQzB2S2VXYk5YRmFMaXU3OWpRWFVRU0gyeXZLSXp0?= =?utf-8?B?K05tRHNPZDhPc2JqSXVKdDNwaHBOWGlQVFpicHQxbWJsWFUzQldGK29JazlR?= =?utf-8?B?dEw2TkF3b2Y1RVJTbDJnRlllVnpqdkxTYUd6TnUyNTJBQkJ4L0J4UloxWXAy?= =?utf-8?B?WHZOcnlPZ1pNSUFiTUZialNHMkVMWFkxMkFjSElsRXk0N0d2bUEvcjRQb3lR?= =?utf-8?B?WkZmWi9PY0Ywb2lVYjYrNlZ1M1FMU1FyaFdvYkE5N2h3UEp2M2dTNTBTWWM4?= =?utf-8?B?dklLcWRkdlgvYUs2VS94SmdOUjVVVStNNENlWkJIMk5SM0J5aDY2U1IwMUlV?= =?utf-8?B?aDVtTlZYaC9WVjlrOEh4dTVsMDhkWnBzVThMNEJ1eVhwa0xEd1dqVFJlb0ho?= =?utf-8?Q?tW6z0X2w8/vPO?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac94fef5-e2bd-474b-8a5e-08d8d1bda799 X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3775.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2021 14:26:16.6915 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LIKjwn4Dp9M7WBLkT9H72QotDkZ3XLQ820usZ6NPvMJ9HikIyOJykFAW15ltd7iY X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4223 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 15.02.21 um 15:21 schrieb Andy Shevchenko: > We have already few similar implementation and a lot of code that can benefit > of the yesno() helper. Consolidate yesno() helpers under string.h hood. > > Signed-off-by: Andy Shevchenko Looks like a good idea to me, feel free to add an Acked-by: Christian König to the series. But looking at the use cases for this, wouldn't it make more sense to teach kprintf some new format modifier for this? Christian. > --- > .../drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 6 +----- > drivers/gpu/drm/i915/i915_utils.h | 6 +----- > drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 12 +----------- > include/linux/string.h | 5 +++++ > 4 files changed, 8 insertions(+), 21 deletions(-) > > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c > index 360952129b6d..7fde4f90e513 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c > @@ -23,6 +23,7 @@ > * > */ > > +#include > #include > > #include > @@ -49,11 +50,6 @@ struct dmub_debugfs_trace_entry { > uint32_t param1; > }; > > -static inline const char *yesno(bool v) > -{ > - return v ? "yes" : "no"; > -} > - > /* parse_write_buffer_into_params - Helper function to parse debugfs write buffer into an array > * > * Function takes in attributes passed to debugfs write entry > diff --git a/drivers/gpu/drm/i915/i915_utils.h b/drivers/gpu/drm/i915/i915_utils.h > index abd4dcd9f79c..e6da5a951132 100644 > --- a/drivers/gpu/drm/i915/i915_utils.h > +++ b/drivers/gpu/drm/i915/i915_utils.h > @@ -27,6 +27,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -408,11 +409,6 @@ wait_remaining_ms_from_jiffies(unsigned long timestamp_jiffies, int to_wait_ms) > #define MBps(x) KBps(1000 * (x)) > #define GBps(x) ((u64)1000 * MBps((x))) > > -static inline const char *yesno(bool v) > -{ > - return v ? "yes" : "no"; > -} > - > static inline const char *onoff(bool v) > { > return v ? "on" : "off"; > diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c > index 7d49fd4edc9e..c857d73abbd7 100644 > --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c > +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c > @@ -34,6 +34,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -2015,17 +2016,6 @@ static const struct file_operations rss_debugfs_fops = { > /* RSS Configuration. > */ > > -/* Small utility function to return the strings "yes" or "no" if the supplied > - * argument is non-zero. > - */ > -static const char *yesno(int x) > -{ > - static const char *yes = "yes"; > - static const char *no = "no"; > - > - return x ? yes : no; > -} > - > static int rss_config_show(struct seq_file *seq, void *v) > { > struct adapter *adapter = seq->private; > diff --git a/include/linux/string.h b/include/linux/string.h > index 9521d8cab18e..fd946a5e18c8 100644 > --- a/include/linux/string.h > +++ b/include/linux/string.h > @@ -308,4 +308,9 @@ static __always_inline size_t str_has_prefix(const char *str, const char *prefix > return strncmp(str, prefix, len) == 0 ? len : 0; > } > > +static inline const char *yesno(bool yes) > +{ > + return yes ? "yes" : "no"; > +} > + > #endif /* _LINUX_STRING_H_ */