From patchwork Wed Nov 21 16:03:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 10692749 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D3BE15A7 for ; Wed, 21 Nov 2018 16:03:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D6542BD6F for ; Wed, 21 Nov 2018 16:03:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 662BF2C0AE; Wed, 21 Nov 2018 16:03:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7FB52C0D3 for ; Wed, 21 Nov 2018 16:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731643AbeKVCip (ORCPT ); Wed, 21 Nov 2018 21:38:45 -0500 Received: from mail-eopbgr60134.outbound.protection.outlook.com ([40.107.6.134]:13952 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730072AbeKVCio (ORCPT ); Wed, 21 Nov 2018 21:38:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentia.se; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NwOfWys+ZTCsMTIpQzTBJiMRneRJ4CIU9STymAVfts4=; b=sO2pPBzQcIXUKvFFXZ3h6AjErf9Xe/GU/b/J+m5ThuPhgsb2foptWA1yNi5pk9TNhZ3D3P4KhoFRwMnudtNDTdIYpPlk/Vo1fBYQtTj729xzDnNm70wo662lcpnpe44HwitvlhZaP/xmAawooTbRg19npQjhT1li9Gtd/5VtYhE= Received: from AM5PR0201MB2451.eurprd02.prod.outlook.com (10.169.244.8) by AM5PR0201MB2275.eurprd02.prod.outlook.com (10.169.242.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.14; Wed, 21 Nov 2018 16:03:40 +0000 Received: from AM5PR0201MB2451.eurprd02.prod.outlook.com ([fe80::7d9b:e9c1:14e6:b72a]) by AM5PR0201MB2451.eurprd02.prod.outlook.com ([fe80::7d9b:e9c1:14e6:b72a%3]) with mapi id 15.20.1294.048; Wed, 21 Nov 2018 16:03:39 +0000 From: Peter Rosin To: "linux-kernel@vger.kernel.org" CC: Peter Rosin , Jean Delvare , Guenter Roeck , "linux-hwmon@vger.kernel.org" Subject: [PATCH 1/2] hwmon: (ntc_thermistor) sort thermistor id lists alphabetically Thread-Topic: [PATCH 1/2] hwmon: (ntc_thermistor) sort thermistor id lists alphabetically Thread-Index: AQHUgbPEET+pOXUUgUmQZRKZGtFkzA== Date: Wed, 21 Nov 2018 16:03:39 +0000 Message-ID: <20181121160327.16772-2-peda@axentia.se> References: <20181121160327.16772-1-peda@axentia.se> In-Reply-To: <20181121160327.16772-1-peda@axentia.se> Accept-Language: en-US, sv-SE Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.11.0 x-originating-ip: [85.226.244.23] x-clientproxiedby: HE1PR0402CA0042.eurprd04.prod.outlook.com (2603:10a6:7:7c::31) To AM5PR0201MB2451.eurprd02.prod.outlook.com (2603:10a6:203:35::8) authentication-results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;AM5PR0201MB2275;6:fn/O3M4850ZzGJD8Wk9uimmeZ75gQg5AlXNzczcajyfSE0LHAaoVmh7HRjdRNeCJaqj7GLy2Xv94CSo9visWDUrmzyA09wUU23+K9Gf0sySJ3LlHI9asCz43+s2EVIC+sSogbF8FzstD6LB7WbbkomRFEb0JALeLjTjyZl7weZCvrcQq7fxF6Tf+HkBpkb47wbRmnGaARykXADAioRcvGmi9SAkiWFz/nWAnuyXF5rA83JmxrRZjou7engC2iUP+/EWf3hA0sxKgFBRHEfx7E9UdWFHRUqNnM8phmC8y9lDFlyWd3cRPhG8eDjv8sfTxV8r7R9MIraimme5tEYzD9fhEhp5RLwCM+daBDRAUYjATxuct7qI036wbfKqVIRLCRfuHQWooMaCdAzVUIdO1IacabZ7bI+EypPtbxEThbAtAD99npa9bS7utfZZVHbJYS6AuqvVssSsZWJlpxWxFlw==;5:cHzCPLApkPTjkBozbVdV/OgHMbxYz+PiQ9S/MZYoPPDJuT3sRRuUE+nE30rSqcFeoCHqK+K39TBE+n2ck10fNhAuKO9no8jBJ3cBazoT3D4djL1uX/OuGTdZ1POklZG70WL1HxfDEEGVHtkNyPPLeetgBwtQ0bPpf7z8RbKBAqQ=;7:Tgz5ddeHRtU9A5D2vKt0TnkV7TQUK76Lb/kBJ8wgZ5IlZ4qCTRSzXRSAIfQlDuAOWQ0H5EuZUd90fV+TnSzqH/zU5qvLCeVAumsIHH/JKZdUAVuHsrgSXX5dtT0O507NpMvAZ2ms+rBtN+l+TEoZpw== x-ms-office365-filtering-correlation-id: 5a056ada-09c0-48d6-afd2-08d64fcae703 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(7021145)(8989299)(4534185)(7022145)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:AM5PR0201MB2275; x-ms-traffictypediagnostic: AM5PR0201MB2275: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231442)(944501410)(52105112)(3002001)(93006095)(93001095)(148016)(149066)(150057)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(2016111802025)(6043046)(201708071742011)(7699051)(76991095);SRVR:AM5PR0201MB2275;BCL:0;PCL:0;RULEID:;SRVR:AM5PR0201MB2275; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39830400003)(396003)(366004)(376002)(136003)(189003)(199004)(99286004)(14454004)(52116002)(76176011)(8676002)(81156014)(2900100001)(5640700003)(2501003)(81166006)(14444005)(68736007)(575784001)(53936002)(2351001)(106356001)(86362001)(11346002)(2616005)(476003)(256004)(6512007)(4326008)(316002)(6916009)(6486002)(1076002)(508600001)(3846002)(6116002)(74482002)(71200400001)(54906003)(50226002)(66066001)(71190400001)(2906002)(305945005)(36756003)(102836004)(6506007)(7736002)(97736004)(446003)(486006)(8936002)(6436002)(105586002)(25786009)(386003)(26005)(186003)(5660300001)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:AM5PR0201MB2275;H:AM5PR0201MB2451.eurprd02.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: axentia.se does not designate permitted sender hosts) x-microsoft-antispam-message-info: HuPHNbN4SNAhOnXiLYnOfFit1cebYeYYLU0+5dNa6KeUHcq7ONLsmMW7J8qHW/Cq8shFUndXnYaL/lFodUTm8sXTJ0bsjLpPHvm1c4XvS64F/xdfufnRnxQ6HcWoDsEozpcT+UpDI2uiiRDIrC11uatRQ1TbYYvkRtmoxnCS3uLAywOjXfs9O7w7GZICc2Uo+9hzeNT5HLbVNPqyeA106Ac1Q0rNqH03DrFgf4IEku3YOrSE7xCiVE5qcx/QZoZgdHG8BfXrdcV5US6fYCMC7RJQ0YbA5xRcoJl5///3jhfNRa15FEF3ADrZelQgejBPViRd/IX8wTwiHEep9UIa6XdLu9Ibep/ji/m5slEVpl0= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-Network-Message-Id: 5a056ada-09c0-48d6-afd2-08d64fcae703 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 16:03:39.9031 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4ee68585-03e1-4785-942a-df9c1871a234 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0201MB2275 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use an enum to index the array, so that it is possible to add sorted entries without causing churn. Signed-off-by: Peter Rosin --- drivers/hwmon/ntc_thermistor.c | 82 +++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c index e0c6b2f244a6..7747c1ed1f02 100644 --- a/drivers/hwmon/ntc_thermistor.c +++ b/drivers/hwmon/ntc_thermistor.c @@ -45,18 +45,34 @@ struct ntc_compensation { unsigned int ohm; }; -/* Order matters, ntc_match references the entries by index */ +/* + * Used as index in a zero-terminated array, holes not allowed so + * that NTC_LAST is the first empty array entry. + */ +enum { + NTC_B57330V2103, + NTC_B57891S0103, + NTC_NCP03WB473, + NTC_NCP03WF104, + NTC_NCP15WB473, + NTC_NCP15WL333, + NTC_NCP15XH103, + NTC_NCP18WB473, + NTC_NCP21WB473, + NTC_LAST, +}; + static const struct platform_device_id ntc_thermistor_id[] = { - { "ncp15wb473", TYPE_NCPXXWB473 }, - { "ncp18wb473", TYPE_NCPXXWB473 }, - { "ncp21wb473", TYPE_NCPXXWB473 }, - { "ncp03wb473", TYPE_NCPXXWB473 }, - { "ncp15wl333", TYPE_NCPXXWL333 }, - { "b57330v2103", TYPE_B57330V2103}, - { "ncp03wf104", TYPE_NCPXXWF104 }, - { "ncp15xh103", TYPE_NCPXXXH103 }, - { "b57891s0103", TYPE_B57891S0103 }, - { }, + [NTC_B57330V2103] = { "b57330v2103", TYPE_B57330V2103 }, + [NTC_B57891S0103] = { "b57891s0103", TYPE_B57891S0103 }, + [NTC_NCP03WB473] = { "ncp03wb473", TYPE_NCPXXWB473 }, + [NTC_NCP03WF104] = { "ncp03wf104", TYPE_NCPXXWF104 }, + [NTC_NCP15WB473] = { "ncp15wb473", TYPE_NCPXXWB473 }, + [NTC_NCP15WL333] = { "ncp15wl333", TYPE_NCPXXWL333 }, + [NTC_NCP15XH103] = { "ncp15xh103", TYPE_NCPXXXH103 }, + [NTC_NCP18WB473] = { "ncp18wb473", TYPE_NCPXXWB473 }, + [NTC_NCP21WB473] = { "ncp21wb473", TYPE_NCPXXWB473 }, + [NTC_LAST] = { }, }; /* @@ -327,36 +343,36 @@ static int ntc_adc_iio_read(struct ntc_thermistor_platform_data *pdata) } static const struct of_device_id ntc_match[] = { - { .compatible = "murata,ncp15wb473", - .data = &ntc_thermistor_id[0] }, - { .compatible = "murata,ncp18wb473", - .data = &ntc_thermistor_id[1] }, - { .compatible = "murata,ncp21wb473", - .data = &ntc_thermistor_id[2] }, - { .compatible = "murata,ncp03wb473", - .data = &ntc_thermistor_id[3] }, - { .compatible = "murata,ncp15wl333", - .data = &ntc_thermistor_id[4] }, { .compatible = "epcos,b57330v2103", - .data = &ntc_thermistor_id[5]}, + .data = &ntc_thermistor_id[NTC_B57330V2103]}, + { .compatible = "epcos,b57891s0103", + .data = &ntc_thermistor_id[NTC_B57891S0103] }, + { .compatible = "murata,ncp03wb473", + .data = &ntc_thermistor_id[NTC_NCP03WB473] }, { .compatible = "murata,ncp03wf104", - .data = &ntc_thermistor_id[6] }, + .data = &ntc_thermistor_id[NTC_NCP03WF104] }, + { .compatible = "murata,ncp15wb473", + .data = &ntc_thermistor_id[NTC_NCP15WB473] }, + { .compatible = "murata,ncp15wl333", + .data = &ntc_thermistor_id[NTC_NCP15WL333] }, { .compatible = "murata,ncp15xh103", - .data = &ntc_thermistor_id[7] }, - { .compatible = "epcos,b57891s0103", - .data = &ntc_thermistor_id[8] }, + .data = &ntc_thermistor_id[NTC_NCP15XH103] }, + { .compatible = "murata,ncp18wb473", + .data = &ntc_thermistor_id[NTC_NCP18WB473] }, + { .compatible = "murata,ncp21wb473", + .data = &ntc_thermistor_id[NTC_NCP21WB473] }, /* Usage of vendor name "ntc" is deprecated */ + { .compatible = "ntc,ncp03wb473", + .data = &ntc_thermistor_id[NTC_NCP03WB473] }, { .compatible = "ntc,ncp15wb473", - .data = &ntc_thermistor_id[0] }, + .data = &ntc_thermistor_id[NTC_NCP15WB473] }, + { .compatible = "ntc,ncp15wl333", + .data = &ntc_thermistor_id[NTC_NCP15WL333] }, { .compatible = "ntc,ncp18wb473", - .data = &ntc_thermistor_id[1] }, + .data = &ntc_thermistor_id[NTC_NCP18WB473] }, { .compatible = "ntc,ncp21wb473", - .data = &ntc_thermistor_id[2] }, - { .compatible = "ntc,ncp03wb473", - .data = &ntc_thermistor_id[3] }, - { .compatible = "ntc,ncp15wl333", - .data = &ntc_thermistor_id[4] }, + .data = &ntc_thermistor_id[NTC_NCP21WB473] }, { }, }; MODULE_DEVICE_TABLE(of, ntc_match);