Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3521204pxv; Mon, 19 Jul 2021 02:11:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAEnGi+66BOX1KIvWZ12DHwZooCsQPPUr3QuV8VKyGr84dvsNbBQWWUgz/nlW6FQKUnk9b X-Received: by 2002:a17:906:f746:: with SMTP id jp6mr26619337ejb.39.1626685869825; Mon, 19 Jul 2021 02:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626685869; cv=none; d=google.com; s=arc-20160816; b=i95LogZuSqnI+xGqPLNsyGuk7mjda8R3VnNIx+A/g3sFCDIKead3K3Bzv2wsAJ8voh MFsA5Az977n8Ie4Y9fpVUimYU59Pl6/12SZr5AIHGxRJDEzpiH/BG3TN8F56Soa1VYnL 6lHPcS5fVIHXJzMAdTbgExRiaXAWvu8tscIcIyfhhwR3C3HdAsfnMbCQGHk7AOhqgnEN oB2rQlyVF+6btApIqjeOIOliS7eR8jwqjzxgdfDIRq1Nz38J9YbnJipStUETNEjvbift UQFR7+ub0mLAmjTDbT1nMmra4FRmCeR3XqJaEU2EshaLUFObhkcRyfAFoWp/CoTGooDh 6KMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=IvRFsTZWHUBtfjypkwrQKZFWUxIibSU0lyg1+VUtg3o=; b=Oin8+2EtKHd3x2viK0W9tVW9HOIkaVgXW0uqj5TTmb4jEDl5bMvsi72A0bNalQBUEt LqydUJvmcStA1qb+h4OCbyNijHzKsYsQYva9dVwVSwlK8mBfngwJbpnqOxnwQJhhBDT8 wU/yplABreL3Zuqi3MyP2i+D/sEZRdd5Q8WtgnaDUtCNFgPcFPSJxIuEyZF4Xf9XNZTF nEvICmLsgr7Mivj6fvCP+mqTx1R81S1phm2J6RLzT7wljiSDfNHdThyMeresUnAudDOv xVFvgVJqjzxyYb2XYCZykiCnpToVsLzqySeYVAzt2gNq6E3c0ZHrviEPVgIC8iLuYrC7 PbAw== 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 sa13si20754884ejb.425.2021.07.19.02.10.47; Mon, 19 Jul 2021 02:11:09 -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 S235385AbhGSI3D (ORCPT + 99 others); Mon, 19 Jul 2021 04:29:03 -0400 Received: from mail-qv1-f43.google.com ([209.85.219.43]:33340 "EHLO mail-qv1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234991AbhGSI3D (ORCPT ); Mon, 19 Jul 2021 04:29:03 -0400 Received: by mail-qv1-f43.google.com with SMTP id h9so8050137qvs.0; Mon, 19 Jul 2021 02:09:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IvRFsTZWHUBtfjypkwrQKZFWUxIibSU0lyg1+VUtg3o=; b=j0bGFns5Ac3BxtVOjHAryaoX9TzjRmVc+Bb8oyKZYmB+1rRqQ0Krb6wrQvnuE3Imnl 9HzSLDHurtZjAcRlzXENZJmpFZLQTW+36lqYLs0S0BYTFuCFKpeK/VJ2ZCeUBkygdqOQ 71ODkqrMjCihexkcceWyeaX+BxV221udNoPLFrPb5q29LbfVxqj+G5DZXzKG5J5cgEGE Hf7Yy+xitn4bF49ZESiXseH0wsowhDRVyOc3aUWG2BCyfJDCUSuJrgodcbusWCMLQcHh sZwSiyRB7LtvIaukE9sIsWaCVgFHu1BSuyMJYEmXeMB/vWWjhnINz9LVodL1uQfKpBe5 HDnQ== X-Gm-Message-State: AOAM5328SYVW6WmIyuh2evRGYJkn0yrLxhYgvXS3L+PzP7FRKm4Mnh2X ADetPEmEDWUD9dyzd3fZ2JYn3teLOPLFWHKqssoqwCx6 X-Received: by 2002:ac5:cd9b:: with SMTP id i27mr20830596vka.1.1626684043244; Mon, 19 Jul 2021 01:40:43 -0700 (PDT) MIME-Version: 1.0 References: <9b5902665dcc4c0fca7546987303e348d8657f59.1626383424.git.apark0006@student.cerritos.edu> In-Reply-To: From: Geert Uytterhoeven Date: Mon, 19 Jul 2021 10:40:32 +0200 Message-ID: Subject: Re: [PATCH 1/2] swap led_brightness from enum to typedef To: Amy Parker Cc: Pavel Machek , linux-leds , Linux Kernel Mailing List , Dan Carpenter Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 19, 2021 at 9:18 AM Geert Uytterhoeven wrote: > 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... And as Dan just pointed out, "signed int" would be even better, as it would allow a function to return an error code. > > +#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