From patchwork Sat Sep 15 10:50:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yue Haibing X-Patchwork-Id: 10601437 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 B14E414DB for ; Sat, 15 Sep 2018 10:51:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 962C72AFF5 for ; Sat, 15 Sep 2018 10:51:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 942952B693; Sat, 15 Sep 2018 10:51:01 +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=-7.9 required=2.0 tests=BAYES_00,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 3B3132B6C3 for ; Sat, 15 Sep 2018 10:51:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726954AbeIOQJ3 (ORCPT ); Sat, 15 Sep 2018 12:09:29 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:57425 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726446AbeIOQJ3 (ORCPT ); Sat, 15 Sep 2018 12:09:29 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 3AD2D9E7F8081; Sat, 15 Sep 2018 18:50:52 +0800 (CST) Received: from localhost (10.177.31.96) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.399.0; Sat, 15 Sep 2018 18:50:44 +0800 From: YueHaibing To: , , , CC: , , YueHaibing Subject: [PATCH -next] iio: potentiometer: max5481: merge calls to of_match_device and of_device_get_match_data Date: Sat, 15 Sep 2018 18:50:33 +0800 Message-ID: <20180915105033.5928-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.177.31.96] X-CFilter-Loop: Reflected Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Drop call to of_match_device, which is subsumed by the subsequent call to of_device_get_match_data. The code becomes simpler, and a temporary variable can be dropped. Found by coccinelle. Signed-off-by: YueHaibing --- drivers/iio/potentiometer/max5481.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/iio/potentiometer/max5481.c b/drivers/iio/potentiometer/max5481.c index ffe2761..6d2f13f 100644 --- a/drivers/iio/potentiometer/max5481.c +++ b/drivers/iio/potentiometer/max5481.c @@ -137,7 +137,6 @@ static int max5481_probe(struct spi_device *spi) struct iio_dev *indio_dev; struct max5481_data *data; const struct spi_device_id *id = spi_get_device_id(spi); - const struct of_device_id *match; int ret; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*data)); @@ -149,10 +148,8 @@ static int max5481_probe(struct spi_device *spi) data->spi = spi; - match = of_match_device(of_match_ptr(max5481_match), &spi->dev); - if (match) - data->cfg = of_device_get_match_data(&spi->dev); - else + data->cfg = of_device_get_match_data(&spi->dev); + if (!data->cfg) data->cfg = &max5481_cfg[id->driver_data]; indio_dev->name = id->name;