Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2969928imm; Sun, 24 Jun 2018 08:27:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJKlK42VVyg4tcbzoglG0/ZeFVH5aKjDr35HAYUxeJj6MsWOkMMy6aEaWb7DQWADctXczRO X-Received: by 2002:a17:902:59c5:: with SMTP id d5-v6mr9122856plj.253.1529854077842; Sun, 24 Jun 2018 08:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529854077; cv=none; d=google.com; s=arc-20160816; b=PPQ/BRQWnlt3xDOFj79euXSgfd0fFaUY/pnumCjP0vvYWMUMhnYpCPoigc1fzRxb+d h3VuK2iY2G8rHuDR9JhPNLqrLK9Bz7F+XZzIISkruVT238PougMKjLWSNnaVq6h/zt7d jAw3ICNmhT7xMXr4beErUCxLXS+Dz7Ql233i+3TtEgotr95hkPJy5DXnteCWIyYDgss3 16bJsB7O0K/EKvrjJB70a5PBba4SFdpBWp7bgmDpIzohnKDVwYivGt5DS0YJ45wWUqTT EiuspvwPlSfjKI/KizmNQSomthSSK8+Piq5Cz2bb0sxe2jdffo1pteVTaxvZQqZB6Bz3 ZwEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=G0Jb8He+GxjwiCXODRRzkCqSPj9l1j0UTW2sLBGtW8c=; b=VzVeQQl/rBpkC8ZIdUv8SNTYYTPcPDjBkIX6lqGb3/CQjyoTqOQc1Mzf2KxC/YrPeD Wc8R8min0DzXm+jQFWS9SHbsTZF3pcce3SDSTzPCFlxeZRHECPg9Jv0lnqdIG6ToeC5g kkjSh8lEizap9Mzk5mF2WW4g0MEj30mf83VVuMznvDBYhb03RqMW9RrgHkT3jWcn393E jxptAve9UbdGF1vF0rnhcSujThJOmgISOXepWGzKajH8IkP4yomtcjlYlszNrVTmbCNl OgrnUNyQBXTItV5xLLNoJRtarqvNpWIil4HKWGDlcE9VQJqn8NvK5v7aLGIJf1rNJ5MJ ckvg== ARC-Authentication-Results: i=1; mx.google.com; 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 z10-v6si9883777pgu.238.2018.06.24.08.27.43; Sun, 24 Jun 2018 08:27:57 -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; 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 S1752668AbeFXP0j (ORCPT + 99 others); Sun, 24 Jun 2018 11:26:39 -0400 Received: from smtprelay0031.hostedemail.com ([216.40.44.31]:39681 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751895AbeFXP0g (ORCPT ); Sun, 24 Jun 2018 11:26:36 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay04.hostedemail.com (Postfix) with ESMTP id B5C68180A9C62; Sun, 24 Jun 2018 15:26:35 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:1801:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3867:3870:3873:4321:4605:5007:10004:10400:10848:11026:11232:11233:11473:11658:11914:12043:12296:12438:12740:12760:12895:13069:13311:13357:13439:14659:14721:21080:21451:21627:30054:30091,0,RBL:47.151.150.235:@perches.com:.lbl8.mailshell.net-62.8.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: crate45_909d8511f660c X-Filterd-Recvd-Size: 2360 Received: from XPS-9350.home (unknown [47.151.150.235]) (Authenticated sender: joe@perches.com) by omf02.hostedemail.com (Postfix) with ESMTPA; Sun, 24 Jun 2018 15:26:33 +0000 (UTC) Message-ID: <36befceb2334197cce5cd44a61f86f38b870d54c.camel@perches.com> Subject: Re: [PATCH] staging: pi433: replace simple switch statements From: Joe Perches To: Valentin Vidic , Greg Kroah-Hartman Cc: Simon =?ISO-8859-1?Q?Sandstr=F6m?= , Marcus Wolf , Luca =?ISO-8859-1?Q?S=F6the?= , Marcin Ciupak , Michael Panzlaff , Derek Robson , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Hugo Lefeuvre , Dan Carpenter Date: Sun, 24 Jun 2018 08:26:32 -0700 In-Reply-To: <20180624094245.23741-1-Valentin.Vidic@CARNet.hr> References: <20180624094245.23741-1-Valentin.Vidic@CARNet.hr> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2018-06-24 at 11:42 +0200, Valentin Vidic wrote: > Use const array to map switch cases to resulting values. I suggest you make the const arrays the same type as the argument in the function being called. > diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c [] > @@ -111,27 +111,22 @@ static inline int rf69_read_mod_write(struct spi_device *spi, u8 reg, > > int rf69_set_mode(struct spi_device *spi, enum mode mode) > { > - switch (mode) { > - case transmit: > - return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, > - OPMODE_MODE_TRANSMIT); [] > + static const int mode_map[] = { > + [transmit] = OPMODE_MODE_TRANSMIT, > + [receive] = OPMODE_MODE_RECEIVE, > + [synthesizer] = OPMODE_MODE_SYNTHESIZER, > + [standby] = OPMODE_MODE_STANDBY, > + [mode_sleep] = OPMODE_MODE_SLEEP, > + }; [] > + return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, > + mode_map[mode]); drivers/staging/pi433/rf69.c:static inline int rf69_read_mod_write(struct spi_device *spi, u8 reg, drivers/staging/pi433/rf69.c- u8 mask, u8 value) so u8 here. etc...