Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp343430ybe; Wed, 4 Sep 2019 00:06:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjO8iif+fXLQuz38ZdCZhy08F8iOz2oDmtUQZw7A7GSgTIHiGW11HZ5p80A5W09fsuZRh3 X-Received: by 2002:a62:2ec7:: with SMTP id u190mr17106650pfu.121.1567580801402; Wed, 04 Sep 2019 00:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567580801; cv=none; d=google.com; s=arc-20160816; b=gpsWrf49Fg/ejLMG+EJWkXwXVi0FPNXm7cfYmm1TlbNxK2mUqaEGMzannts8dWHaPz 1Gdnd6Bhq0Byujagvbo85RbLKohRbqu/IYOWs0U7GX1zP/eg0YdgVyFfAt/vnEM7GLpa W0Uh24YuCKSi/Yo11RioG//8ZXEar1UG9yUZt6ElMDqCRD1HWPG4k4s8ux30ZYj6INoK 9SCbwfJX4PlFnTzJR6sLIaaoXeTrXxi8d6Qk9eMEEnT60YP/++0ILWK5/j+NqsiBHlU8 5cZka/cvHjByukcbOLo2FnqXxx8G11QbM/LkQIxcYcIyxy1wAwCFwrDG37eHaCG/NrvV 6mMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1+ctW3R0vQxzRzWGT7b8Ot4mD2NZ4odK+jG4wfwXIGg=; b=C3C0YbQEEHGJf2boyl6Ue/LgjjeDCk62zku7uw+15Ay08FijFYkkyxyogJR/fybxEw 7ZGgWX9OZbosjsbGfPxKLezlhB7AxC+FGbYSolriAfN1Z+hVGeRobwn9QHVklrvSTwrs tG7Hl6juoeWtLCD6kBksUXEG0ys+hYX1CmzvybqHxgQxQ33tcq2T0shNxrDvUnJH4aZU ek5mJTJGX1CljnL3AJ/7I8LCt7W90wkJyFzeFUqMEXP0dJvAnNHAtxi9UAxB5omFJpNQ ENGd1JvOMV0uioo/HBAXiFu8towQ2tOHtH9fsXnA6hniWthSw62wcG7kN+tU5p35S9WF KbDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I1XbJYry; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n5si16473604pgq.154.2019.09.04.00.06.23; Wed, 04 Sep 2019 00:06:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I1XbJYry; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728883AbfIDHFf (ORCPT + 99 others); Wed, 4 Sep 2019 03:05:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:59170 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725840AbfIDHFf (ORCPT ); Wed, 4 Sep 2019 03:05:35 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 10BF322CED; Wed, 4 Sep 2019 07:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567580734; bh=aWGzlmrB2PaClSzN/gYS8Kh4U8lGww1SuEpNwf6L34c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=I1XbJYryFvML98L8MUbUNMCVghNaG0ZM/kQjPjHdov2dtaPX33t3c4blqrFhgHB3X CsaSNk+frGyPriJzkBiC1Mb7JjcHzaMMqtcAdmekkZqnalpeTSQlfZCNSkRHwbW44n Shg6hZE5liVhGBAjhIHYqI5SEvhN10z5DxlY0rv4= Date: Wed, 4 Sep 2019 09:05:32 +0200 From: Greg Kroah-Hartman To: Jani Nikula Cc: linux-kernel@vger.kernel.org, Joonas Lahtinen , Rodrigo Vivi , intel-gfx@lists.freedesktop.org, Vishal Kulkarni , netdev@vger.kernel.org, linux-usb@vger.kernel.org, Andrew Morton , Julia Lawall Subject: Re: [PATCH 1/2] linux/kernel.h: add yesno(), onoff(), enableddisabled(), plural() helpers Message-ID: <20190904070532.GB18791@kroah.com> References: <20190903133731.2094-1-jani.nikula@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190903133731.2094-1-jani.nikula@intel.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 03, 2019 at 04:37:30PM +0300, Jani Nikula wrote: > The kernel has plenty of ternary operators to choose between constant > strings, such as condition ? "yes" : "no", as well as value == 1 ? "" : > "s": > > $ git grep '? "yes" : "no"' | wc -l > 258 > $ git grep '? "on" : "off"' | wc -l > 204 > $ git grep '? "enabled" : "disabled"' | wc -l > 196 > $ git grep '? "" : "s"' | wc -l > 25 > > Additionally, there are some occurences of the same in reverse order, > split to multiple lines, or otherwise not caught by the simple grep. > > Add helpers to return the constant strings. Remove existing equivalent > and conflicting functions in i915, cxgb4, and USB core. Further > conversion can be done incrementally. > > While the main goal here is to abstract recurring patterns, and slightly > clean up the code base by not open coding the ternary operators, there > are also some space savings to be had via better string constant > pooling. > > Cc: Joonas Lahtinen > Cc: Rodrigo Vivi > Cc: intel-gfx@lists.freedesktop.org > Cc: Vishal Kulkarni > Cc: netdev@vger.kernel.org > Cc: Greg Kroah-Hartman > Cc: linux-usb@vger.kernel.org > Cc: Andrew Morton > Cc: linux-kernel@vger.kernel.org > Cc: Julia Lawall > Signed-off-by: Jani Nikula > --- > drivers/gpu/drm/i915/i915_utils.h | 15 ------------- > .../ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 11 ---------- > drivers/usb/core/config.c | 5 ----- > drivers/usb/core/generic.c | 5 ----- > include/linux/kernel.h | 21 +++++++++++++++++++ > 5 files changed, 21 insertions(+), 36 deletions(-) Reviewed-by: Greg Kroah-Hartman