Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3465450pxv; Mon, 19 Jul 2021 00:17:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe5G4+rGt4fqc5g2EjeKXjzfEz3qs9pFqUamTwdcOOAl3k4vCML4c81oFZF6+almiN5Cgq X-Received: by 2002:a92:db4c:: with SMTP id w12mr16993064ilq.306.1626679066413; Mon, 19 Jul 2021 00:17:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626679066; cv=none; d=google.com; s=arc-20160816; b=grhFnd+A+EI3o4h9zAD/v010Kelf1nZudXOGwcFwa3aoTn8ubRvXRTvnpoZoW5xlTv T3MXrzcbNXLpSLYJAGEipSr2Q0Nsnz/QM8py3WrGeJfnIyALHMyMlTQ0Y9edIp1W8QhJ 2JOpswUJCCTadgG7JyHyfvreQgJ7rQ64E6yKLp3HZh2c1LmGbrfl7qzsWL59KgeDAJS/ wU4vpbtwpJubzc12JarmKnzE/tlEDBhv2ihtGI42P0l4XY4abqjy73D2r5ryegQQZmiI FJ3k53kOIuyX0je2j1o3c33/SmND9Alm4TsT/4PaiyRmNW1b4/09PSJY/Qbbe3BCqtti CnSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=Gsy8fAEshMJrhY66pOFvLUaR9V8p8BeIq0LKD0vQHRA=; b=ES7wBFTcYYJirwj4NOokPbSzGsGboVrFuR5OUNzAAWBbKTgvc7zX84WNLyWKDDSVHk 7cu35eX/SHQN2Vu8e/cW5xiBKkj5nSMzXVLTPlb65uG3dwuhZMo1WA8/6lFo2BrOI+ZR 7EBIbjRliPgK82wplJKtSbrQJKGJ7ZoZaMA2wdUD/eYHPx7Ccs4Nw/anMQmmnOdcM8so 0g8PVrSDUGWY0ZUSWKGnQuDBeKnoZ3eXTrCCLw6XhlRHzMh6YvyxM8bDpm/vuIxf3O5m yw0HvUsc8Sh9Ac2jrQWkuVFmvjiF3JG34+tZgsjI/Nn5PGxyc3AoQ73YPbb870ov37KY 41+Q== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x16si3947524jas.1.2021.07.19.00.17.34; Mon, 19 Jul 2021 00:17:46 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234617AbhGSHUA (ORCPT + 99 others); Mon, 19 Jul 2021 03:20:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234559AbhGSHT7 (ORCPT ); Mon, 19 Jul 2021 03:19:59 -0400 Received: from andre.telenet-ops.be (andre.telenet-ops.be [IPv6:2a02:1800:120:4::f00:15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB864C061762 for ; Mon, 19 Jul 2021 00:16:59 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed40:80b1:eb38:fde3:179e]) by andre.telenet-ops.be with bizsmtp id WvGt250040UDlMe01vGtJ9; Mon, 19 Jul 2021 09:16:55 +0200 Received: from geert (helo=localhost) by ramsan.of.borg with local-esmtp (Exim 4.93) (envelope-from ) id 1m5NWG-000kQw-VC; Mon, 19 Jul 2021 09:16:52 +0200 Date: Mon, 19 Jul 2021 09:16:52 +0200 (CEST) From: Geert Uytterhoeven X-X-Sender: geert@ramsan.of.borg To: Amy Parker cc: pavel@ucw.cz, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] swap led_brightness from enum to typedef In-Reply-To: <9b5902665dcc4c0fca7546987303e348d8657f59.1626383424.git.apark0006@student.cerritos.edu> Message-ID: References: <9b5902665dcc4c0fca7546987303e348d8657f59.1626383424.git.apark0006@student.cerritos.edu> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Amy, On Thu, 15 Jul 2021, Amy Parker wrote: > This commit changes how led_brightness, declared in header file > include/linux/leds.h, works throughout the kernel, and updates other > files in accordance. > > The TODO located at drivers/leds/TODO requests: > > * Get rid of led_brightness > > It is really an integer, as maximum is configurable. Get rid of it, or > make it into typedef or something. > > This patch changes the declaration of led_brightness from an enum to a > typedef. In order to hold the currently existing enum values, macro > definitions are provided. Files which use led_brightness are updated to > conform to the new types. > > Signed-off-by: Amy Parker Thanks for your patch! > 207 files changed, 437 insertions(+), 438 deletions(-) This touches a lot of files, so we better get it right. > --- a/include/linux/leds.h > +++ b/include/linux/leds.h > @@ -26,12 +26,11 @@ struct device_node; > */ > > /* This is obsolete/useless. We now support variable maximum brightness. */ > -enum led_brightness { > - LED_OFF = 0, > - LED_ON = 1, > - LED_HALF = 127, > - LED_FULL = 255, > -}; > +typedef u8 led_brightness; In general, typedefs are frowned upon in the kernel, but there can be a good reason to use one. What if the maximum brightness is larger than 255? Using "unsigned int" sounds better to me, but let's wait for Pavel... > +#define LED_OFF 0 > +#define LED_ON 1 > +#define LED_HALF 127 > +#define LED_FULL 255 Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds