Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934518AbcKWJIs (ORCPT ); Wed, 23 Nov 2016 04:08:48 -0500 Received: from mail-ve1eur01on0104.outbound.protection.outlook.com ([104.47.1.104]:37280 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933640AbcKWJIo (ORCPT ); Wed, 23 Nov 2016 04:08:44 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; Subject: Re: [PATCH V2] i2c: mux: pca954x: Add ACPI support for pca954x To: , Wolfram Sang , , References: <1479891177-23048-1-git-send-email-tnhuynh@apm.com> CC: Loc Ho , Thang Nguyen , Phong Vo , From: Peter Rosin Organization: Axentia Technologies AB Message-ID: <401a3b3b-2680-8688-b21a-38cdb14471d5@axentia.se> Date: Wed, 23 Nov 2016 10:08:34 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1479891177-23048-1-git-send-email-tnhuynh@apm.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [217.210.101.82] X-ClientProxiedBy: HE1PR08CA0025.eurprd08.prod.outlook.com (10.161.112.35) To DB6PR0201MB2311.eurprd02.prod.outlook.com (10.169.222.150) X-MS-Office365-Filtering-Correlation-Id: ff23ece7-dc03-4d25-1dbb-08d413805073 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DB6PR0201MB2311; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0201MB2311;3:7QCjK+TWUXoTPLyEi92ilTvSl0bjy5lC4fPD4UIeUvT4TpGRS1dXXkA/ncBbJGlscjJDzRoGV5gDe7EEutHybIHzT5EkEJffc09M6JeuFoqVbuxsmc5iBfj8sYU4rhXGl+SeNbervKU+W+Ev8iVFHS26Itl1iXoUzbrLzPVIfS1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sV6fhdHFu/3gLzX64w1TviWhECDX9xSzfogszkkJ7zdH0zcU8GmREzKF69OSuBd4LAnoAgpeoNoHrQPjfvL8LL1RYnAeNbCVmaURbze/AJuO8pGPQYRwkKMVxs6xudkmtnrAwYd6HUKVfyj62MzM47MFi1ecAbkWBgePNibbJcgO9Bip0lRZfLV3C0p93shyRFqElfDpJW8P1wAm0CTgEoSi0VVLZsVQq94eBRfWPpOwTWlmGomukSF02Kpr6e/Djum05NvNdsSRAxF7d0PP2LA8c6ZiuH/kVwp1nU4OldwCNTSdhSPK9hyKNhYzul6gMcseUS2ZyYZecQGQfiNdXlZOzNXKWkfA4UuAQP+0XmqK2e091Aq2+DGaD/Hz0= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6060326)(6040307)(6045199)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6061324)(6041248)(2016111802025)(6072148)(6043046);SRVR:DB6PR0201MB2311;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0201MB2311; X-Forefront-PRVS: 013568035E X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6049001)(7916002)(377424004)(24454002)(199003)(54534003)(189002)(2950100002)(7736002)(6666003)(101416001)(36756003)(66066001)(230700001)(23746002)(50466002)(305945005)(5001770100001)(77096005)(31686004)(7846002)(5660300001)(2906002)(65826007)(83506001)(189998001)(6116002)(4326007)(3846002)(42186005)(50986999)(76176999)(31696002)(65956001)(47776003)(86362001)(64126003)(65806001)(2201001)(68736007)(105586002)(81166006)(97736004)(106356001)(74482002)(8676002)(38730400001)(81156014)(4001150100001)(4001350100001)(54356999)(92566002)(117156001)(229853002)(33646002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:DB6PR0201MB2311;H:[192.168.0.125];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;DB6PR0201MB2311;23:kS05YmvZZmPr40Y3QxsBLHWTC4KWgLoWgMU?= =?Windows-1252?Q?B4hlvJLyyVQ3eg8Odbfx9OT4OPAVz9ItAuYXrAojC9APVFVbZNWkeW6E?= =?Windows-1252?Q?8AZpueHYzt0z2dU3ldBzynVHRFtmcRsKG87t4muCSBDSF5l9RjL7uigI?= =?Windows-1252?Q?NzfferI/5+4x10d18x+5bbzTGFXTdAn5iMmpM4a8KpWApaaXRV68AsQ+?= =?Windows-1252?Q?CzJKVbvR9rrh18zzLQcyDdWCklAhKmPeLBqS0UH8IT/h0k/WZWnrWiiO?= =?Windows-1252?Q?mO7ZHOaVXkjKiJnGsHkkg+HujbZM1aKigyZoQOc8KYh+pefySykTbD4H?= =?Windows-1252?Q?EtN7j3dyDNxZiAll8fOdFt2pmtpU3hsT8S8ptAr+J1WAUZxB24CFa+dc?= =?Windows-1252?Q?uBHgNDPsKo44Jngzy5mDidu6mwmJqlhPm3YYkTjIwDnrP4ig/zOGT/Oz?= =?Windows-1252?Q?KS6okL19ZyvswM14iA8/n8Qmba4/agP7vb8AN+cWyPertwa6r7H//cMZ?= =?Windows-1252?Q?Kp7V8n/NgxWfHcY7EdUdM8+9Gv7q5BKhURI8pFJsIJAVEVdytDoPHStf?= =?Windows-1252?Q?26+5wdLNnpio+J0KvFnnr5XxQY71cpHCjV92nCPOv8eDZfWvE2M7j+st?= =?Windows-1252?Q?yaQSmWkVyVCKEV5tIuCurfwWAv5AvCtdv5aTxvQyJmEvBLOoTB+IzhA7?= =?Windows-1252?Q?gZRJVoqCjv36lLtRqb+apqkSZuy0CFywrP5ndRIQT8MBJevfohbRkXBy?= =?Windows-1252?Q?KjhDVpKp+sF9savmupqG5XsnddO1/C+IllVnBg4C2ageFY7LevREzW8c?= =?Windows-1252?Q?iZ0tOqEU5tkzxJ4ta5VUUwYLSFt6SMI7t+QDhhP2A7z1lp6uJhc24j/V?= =?Windows-1252?Q?XeO1xisfSBcdmroJ/HENwb15T/aIVDsUPsEkGXbA9kZwvqFm/RGBMynp?= =?Windows-1252?Q?Mh0Nqsbgq6FsFdXFxfm1i6f0BUEtOsFN1h3eH/3EheXzp13udEb0tnLP?= =?Windows-1252?Q?iUxUtWUyOClYFpwBNLxO44AB0esWgeTlmUklF71LPySpsALzoxeDQmsN?= =?Windows-1252?Q?NVUJ9kJPzKlaPuVIzSl/caL/nxVNwgOMAIsZkZmcswAH55D3uMwhARvK?= =?Windows-1252?Q?E7PQt+KNM1TaOoX+jQViLixtElVnYc6W8BGGW3Qo4M+i1zDSKH5xlpA/?= =?Windows-1252?Q?V8l3+xoojKkJmtunBo5yq8ViF7iJYbuiF9dfAW7vuEQ4oeO07NrYAjrD?= =?Windows-1252?Q?X/sFZbJQMVJHi2w+DkRDleRR9R2jCU7e9YoZZjwWUQ+S/UtofYjHsuv2?= =?Windows-1252?Q?wMPuGMK0hA56onFA56meDoO7vtTYuWsWYEDJ9+IuNvdIDzfnezoAmWX5?= =?Windows-1252?Q?TzyrWUYs5PpPyNVvRxqetLY/TAwgTz3FcH94npfrOzT8FjRW/NqTaFza?= =?Windows-1252?Q?duoAQVJu3zgh3cM3mDkvb7x3LBN6MeOLgysD7gdNf73iJp//iNXE6NRD?= =?Windows-1252?Q?FztT6iou/2xHxDS4KfhDu91Z7a+yF?= X-Microsoft-Exchange-Diagnostics: 1;DB6PR0201MB2311;6:SEyUXQhJkU4OoZb4WaQKKUUsu0Xd/liGCurqlal2Ooi6xs4edX6997ch/eBgqgHAkQ7+oaUT3hjzmFHG0CpLtbpwDjK5wU2U+iL52RcBC5Fj9992Xve6wlbKF8MQFnDOCjj++iwxVQARKOGg744h/z0dIE7pP4oTJPjVSZExhotRcwNxErv+oLDdAQHxikXFlLOERQv7xhfSHNHvslDm1w5w15m33ACBKA4lojVRFjOiImyq9kAIu2GCypWacpOR15rlNMNMwHynjSzHyTRmaX1B15PrKn9PKIzC1vhuV69vRB4E/6Txc0en9uWkaPBDeZeui/LY0aM9PHymf3UX5vXQzzOboUWeCyQfs4/wT79NEMmjGQO/3Ypp40O716tqpuJ/39G1RszqoENkpRKgoinJ8Pw0VrSx0jr2IQFM/zeBeVVeHSUeMG42BL3OfhYGGjBb72g/hiMawZiWIdoriQW/XiC9PiZLA2lG01Ic29s=;5:tTpbb8hqpUBRzYBtGeF1yiitclj7cJlpsrDHBDD2LmnUqZ7k/eg2OoEYYuS4jKM8ShobijZUjQ3DFXq9PZMvAbErhq8wJiZixPL26KEQt5YoQMbsA+/+5DXd0Ha5cAn1nAZ7H5ARn1BSm+lpqf5GJw==;24:XxiJmDGnzNB26wme9DlOBbJdGpJdGk1oIk2y+qAMdDcpia125BhrpqhvlVu8F5rtmTWQL+c9EvDYmPDr7uVmKGg19x4dhHMWUdXOnsdcr5w= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DB6PR0201MB2311;7:BMyOfunfhrEgTsr6DsScJAsNnvPBWXE/dEWEozW2VUt6ViZD0s5cKn3kzgLifnMRkP4Fd8GZsIu3Pw4VvfLsoYSuD7nN4Ovrk1ueqzILg+uOXkSnP6jZTgImK9CvhWK2soe4zUqVV1h47i5SnB6y/1A6VdzIA7aF+ZJi1XnbIyVoD/IiBEs3w5OMZHcw1wXYg7VhntdQJMLN3qHPIYtRYt21OHcPhxWBAq7vABQZAGwIz4YRK3zVdL8bT2e/dAGrY+nRipLXRjkXsd+/C2scXXD3jLV+zLzKQGjQMfqLxQkYNKMRLnkI7oV8njM0deEXMmSAtm5Fm/Wk2mXtP35OqxWAxMic7JaT/UGZzwn9Zj8SJXSoWRFNDcuh6IDmAa2Hwi1bz89xZxy2ffMTNNFpMMkcyWtqLeFX8ImJWTBHG3WJrF8ANBPczVFTrMy2JbwQEca79EvEaBSxXOIU0UQ7pQ== X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2016 09:08:38.1516 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0201MB2311 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3218 Lines: 96 On 2016-11-23 09:52, tnhuynh@apm.com wrote: > From: Tin Huynh > > This patch enables ACPI support for mux-pca954x driver. > > Signed-off-by: Tin Huynh > > Change from v1 : > -Don't shadow id variable. > -Include sorted header. > -Redefine acpi_device_id. > -Add CONFIG_ACPI. Please put these extra comment that do not belong in the changelog below the following three dashes. Then git will ignore these comments automatically, which simplifies applying the patch. > --- > drivers/i2c/muxes/i2c-mux-pca954x.c | 29 ++++++++++++++++++++++++++++- > 1 files changed, 28 insertions(+), 1 deletions(-) The customary position for extra comments is here, below the diffstat. > diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c > index 1091346..1ad67cb 100644 > --- a/drivers/i2c/muxes/i2c-mux-pca954x.c > +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c > @@ -35,6 +35,7 @@ > * warranty of any kind, whether express or implied. > */ > > +#include > #include > #include > #include > @@ -120,6 +121,21 @@ struct pca954x { > }; > MODULE_DEVICE_TABLE(i2c, pca954x_id); > > +#ifdef CONFIG_ACPI > +static const struct acpi_device_id pca954x_acpi_ids[] = { > + { .id = "PCA9540", .driver_data = pca_9540 }, > + { .id = "PCA9542", .driver_data = pca_9540 }, > + { .id = "PCA9543", .driver_data = pca_9543 }, > + { .id = "PCA9544", .driver_data = pca_9544 }, > + { .id = "PCA9545", .driver_data = pca_9545 }, > + { .id = "PCA9546", .driver_data = pca_9545 }, > + { .id = "PCA9547", .driver_data = pca_9547 }, > + { .id = "PCA9548", .driver_data = pca_9548 }, > + { } > +}; > +MODULE_DEVICE_TABLE(acpi, pca954x_acpi_ids); > +#endif > + > #ifdef CONFIG_OF > static const struct of_device_id pca954x_of_match[] = { > { .compatible = "nxp,pca9540", .data = &chips[pca_9540] }, > @@ -245,8 +261,18 @@ static int pca954x_probe(struct i2c_client *client, > match = of_match_device(of_match_ptr(pca954x_of_match), &client->dev); > if (match) > data->chip = of_device_get_match_data(&client->dev); > - else > + else if (id) > data->chip = &chips[id->driver_data]; > +#ifdef CONFIG_ACPI No, this #ifdef is not desired. If ACPI is not configured, acpi_match_device will return NULL unconditionally and the compiler should compile the whole else branch to be an unconditional "return -ENODEV;" and skip the dead code at the end of the block. This is better than leaving data->chip as NULL and oops later. It is also less cluttery to not have this extra #ifdef. Cheers, Peter > + else { > + const struct acpi_device_id *acpi_id; > + > + acpi_id = acpi_match_device(pca954x_acpi_ids, &client->dev); > + if (!acpi_id) > + return -ENODEV; > + data->chip = &chips[acpi_id->driver_data]; > + } > +#endif > > data->last_chan = 0; /* force the first selection */ > > @@ -321,6 +347,7 @@ static int pca954x_resume(struct device *dev) > .name = "pca954x", > .pm = &pca954x_pm, > .of_match_table = of_match_ptr(pca954x_of_match), > + .acpi_match_table = ACPI_PTR(pca954x_acpi_ids), > }, > .probe = pca954x_probe, > .remove = pca954x_remove, >