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); From patchwork Wed Nov 21 16:03:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 10692751 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 2FA5C5A4 for ; Wed, 21 Nov 2018 16:04:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E29A2C049 for ; Wed, 21 Nov 2018 16:04:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1295F2837E; Wed, 21 Nov 2018 16:04:30 +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 816952C022 for ; Wed, 21 Nov 2018 16:04:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731291AbeKVCja (ORCPT ); Wed, 21 Nov 2018 21:39:30 -0500 Received: from mail-eopbgr60116.outbound.protection.outlook.com ([40.107.6.116]:6167 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730072AbeKVCja (ORCPT ); Wed, 21 Nov 2018 21:39:30 -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=9mx65iwArHjHF4esXtppNzt4GYWb/7x4VD0ES3d2PrA=; b=pyMz+JIjI/P70elfgcdPmWuc1jCARhPQbcid+nuKiz3ra9Xcbs5piGUeoRUABWL4sjCyova2ViNsAd4UNI8u53HeWHR/WPiqUUbz+1xPJt5afp0lxO0+n/426G9lLA+V/+wd5r3xKJzoyEp6HNK8lhJkJBXKM9Dx3vHBGdQU05E= 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:46 +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:46 +0000 From: Peter Rosin To: "linux-kernel@vger.kernel.org" CC: Peter Rosin , Jean Delvare , Guenter Roeck , "linux-hwmon@vger.kernel.org" Subject: [PATCH 2/2] hwmon: (ntc_thermistor) use a table to lookup the thermistor type Thread-Topic: [PATCH 2/2] hwmon: (ntc_thermistor) use a table to lookup the thermistor type Thread-Index: AQHUgbPImXAkheNCakiay8+1i/ECrg== Date: Wed, 21 Nov 2018 16:03:46 +0000 Message-ID: <20181121160327.16772-3-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:FzDazX3YdXXw2tvScyf+pUG3dIDM6Ldxz9Te0OCvxsa+qVEdfI8FVeI4qXBC3oaMb0QscDoKaOD9Lr7v4rUmS3ZI4cwVPWBxQXeFyMVirbvz17QgRMRn1Teea6El8ViOmzK620cNFH8TgBqy/Me4FftKs0JBdpG1P6654gg1eytCoxKXRDXcfxphZNPmRfxingj4YD9fJsFLquA1a4GRQ8pVJ4OOIe8nbnvR0a/Knyj982sLy3HtMydgNR1AKKNJKkNHbgykHW4SC/aiOJS9UtH/DL5WjycUhG3gwxKV2vOvT4qWzwNSrZJiq6OgX1Sgd2QN6M3jKP2ttBu4IgXZFEOjB3PfP50Kv51PfNve1JSxCBzSvq/JoZOKYWF0LQLqkM6jZEsopKB1iTW7RgiSN5SfwBILtKzH6l7t0rD++n8VeVG/6VX5DcwF01yanoX58rcX0He/qCn/5ggVXFzXZQ==;5:8uO8ZcZj4HBv8KfkKvAOGDcm1CGVQfNjdhq9PO4Jv/rOqnrUQbQM6dCBTz5PEGGJAlkaEEqUT7iCFKgZL7rROzl5zFhZhyZhfzx7vW4xJ56zfb6IQVeoqnmsc45AfHGmQ7GaH2VswsFG9iMKud8OJ/biUwi/6eJJD8R+5yXGJhA=;7:eJAyi3apbfa6flhTs2OwbfFKZE86XQKrIdy1B9nltFEJ/prfj549NKnKBmeHpLMJnlmZ7WoIoz0qLi4lGXGSA6dXIhZrfzdMy/OViNudiYLeS2zb9N3AxQQpgVIdMf9C6cyl2B8W+ASpSrxX6k9lhw== x-ms-office365-filtering-correlation-id: 832967cd-ff34-4227-0451-08d64fcaeab3 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)(68736007)(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: EePWVtvrEmaw9KD0rRIZxLotK6RsRPSFHmcAqRB8Q6/hQSHQRKOVyBXW7h8Wfr89PKfIadlA/tQuGFubkcEcYhqAPGGhKsiRsqVCSpBcl4OvCSTTFPVxS5w1PrPYnu92sRAEIRacS6J6BxQH1ZX2oc0F4hm2Tqz4dBvdQpGM0fb3SsCsJxHpi2sS1L0tOhqk+92SZVoe8I23McJOTvIAqPgUpzd+umzAcXwyNTu4WOej2A4s+aHo/d+cV2venAUAWg6QjcrgWbWtL6R7vIi2qqfa9S/oqrzgzF44QTzNsxBI5tTx4c3zqaq+PVK84F1zvdS8q6/AEa/cqUasEkamJZr2iTradxi37IIdJoKN9YY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-Network-Message-Id: 832967cd-ff34-4227-0451-08d64fcaeab3 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 16:03:46.2675 (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 Sort the entries while at it. Signed-off-by: Peter Rosin --- drivers/hwmon/ntc_thermistor.c | 47 +++++++++++++--------------- include/linux/platform_data/ntc_thermistor.h | 6 ++-- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c index 7747c1ed1f02..56d83b2472c8 100644 --- a/drivers/hwmon/ntc_thermistor.c +++ b/drivers/hwmon/ntc_thermistor.c @@ -315,6 +315,23 @@ static const struct ntc_compensation b57891s0103[] = { { .temp_c = 155.0, .ohm = 168 }, }; +struct ntc_type { + const struct ntc_compensation *comp; + int n_comp; +}; + +#define NTC_TYPE(ntc, compensation) \ +[(ntc)] = { .comp = (compensation), .n_comp = ARRAY_SIZE(compensation) } + +static const struct ntc_type ntc_type[] = { + NTC_TYPE(TYPE_B57330V2103, b57330v2103), + NTC_TYPE(TYPE_B57891S0103, b57891s0103), + NTC_TYPE(TYPE_NCPXXWB473, ncpXXwb473), + NTC_TYPE(TYPE_NCPXXWF104, ncpXXwf104), + NTC_TYPE(TYPE_NCPXXWL333, ncpXXwl333), + NTC_TYPE(TYPE_NCPXXXH103, ncpXXxh103), +}; + struct ntc_data { struct ntc_thermistor_platform_data *pdata; const struct ntc_compensation *comp; @@ -671,37 +688,15 @@ static int ntc_thermistor_probe(struct platform_device *pdev) data->pdata = pdata; - switch (pdev_id->driver_data) { - case TYPE_NCPXXWB473: - data->comp = ncpXXwb473; - data->n_comp = ARRAY_SIZE(ncpXXwb473); - break; - case TYPE_NCPXXWL333: - data->comp = ncpXXwl333; - data->n_comp = ARRAY_SIZE(ncpXXwl333); - break; - case TYPE_B57330V2103: - data->comp = b57330v2103; - data->n_comp = ARRAY_SIZE(b57330v2103); - break; - case TYPE_NCPXXWF104: - data->comp = ncpXXwf104; - data->n_comp = ARRAY_SIZE(ncpXXwf104); - break; - case TYPE_NCPXXXH103: - data->comp = ncpXXxh103; - data->n_comp = ARRAY_SIZE(ncpXXxh103); - break; - case TYPE_B57891S0103: - data->comp = b57891s0103; - data->n_comp = ARRAY_SIZE(b57891s0103); - break; - default: + if (pdev_id->driver_data >= ARRAY_SIZE(ntc_type)) { dev_err(dev, "Unknown device type: %lu(%s)\n", pdev_id->driver_data, pdev_id->name); return -EINVAL; } + data->comp = ntc_type[pdev_id->driver_data].comp; + data->n_comp = ntc_type[pdev_id->driver_data].n_comp; + hwmon_dev = devm_hwmon_device_register_with_groups(dev, pdev_id->name, data, ntc_groups); if (IS_ERR(hwmon_dev)) { diff --git a/include/linux/platform_data/ntc_thermistor.h b/include/linux/platform_data/ntc_thermistor.h index 231a27c302ec..ee03d429742b 100644 --- a/include/linux/platform_data/ntc_thermistor.h +++ b/include/linux/platform_data/ntc_thermistor.h @@ -24,12 +24,12 @@ struct iio_channel; enum ntc_thermistor_type { - TYPE_NCPXXWB473, - TYPE_NCPXXWL333, TYPE_B57330V2103, + TYPE_B57891S0103, + TYPE_NCPXXWB473, TYPE_NCPXXWF104, + TYPE_NCPXXWL333, TYPE_NCPXXXH103, - TYPE_B57891S0103, }; struct ntc_thermistor_platform_data {