From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C62E4C12002 for ; Mon, 19 Jul 2021 07:17:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B3130611AE for ; Mon, 19 Jul 2021 07:17:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234734AbhGSHUA (ORCPT ); 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