From patchwork Fri Oct 20 05:37:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 116447 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1292530qgn; Thu, 19 Oct 2017 22:39:44 -0700 (PDT) X-Received: by 10.98.194.193 with SMTP id w62mr3702686pfk.67.1508477984826; Thu, 19 Oct 2017 22:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508477984; cv=none; d=google.com; s=arc-20160816; b=DO/FTvLT5y/WUE+Mo3IepNuvdPfTSt99jRir0ea6p7uZxydCLLJq3Nya84XzqbzFNL I2hmGfhVf2JhG5a2HR1FEemWvMJNRnmPDt+Egbt8TbMa7rLj8twLmyb4A9YSQO+brpbM myhzwA7vutezgVNg/xRDTNnZ/rDGrDRW+x2gXYD9BdnfUR4qhOJXeZ0ecaIRbeBJLY/I /O59Ex7NreipJAvj+eTV8FqYQqIcmXCukmauSIZ6YUGUkIyRaUMkGxm7ULe0RlkIYQVe lglAjPBl8eA+bgemrEAaajjbKBMtCoeDIG94NwivHPF5ZjqfFN0u0rPNI0cbZCi8thtC 0luA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=3K0xZUY2+wnx7IrNlpXtI/BjeNpg+U61bTq5+E0vm9Q=; b=ZGj8/vfwTgCmc+E1Li4ftM96MNiWTnqqnHlWcUCOrc2expF7Z0/Rb2FPYd16uXsQnt HDUmgCcHrMOzC3pS/1VehRucYh2sYTC68egGlRXTefadhCJGF94+dDGWbfQ/WDqSY91O RonkL03woWq2r/Q+29JCjWf7r6qMqYlmZSUXPJ8ntx3ibETOedZKWoUcKnhSYKKNo0tU cAk7hSwNZIaYh6wqh0QWLlP/4XraqOkMtTkqXRmzzLDvDnPimQvrukPWUEnloQW41+M2 W5FxZo5ry38HCkIchoQnBQtVySQwzPjVZjtiD5zQGlPAGNSSfLEGZ1KjTJEJbVTn2jRW U/lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RCKMZvcq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 138si201037pgd.210.2017.10.19.22.39.44; Thu, 19 Oct 2017 22:39:44 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RCKMZvcq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751762AbdJTFjm (ORCPT + 27 others); Fri, 20 Oct 2017 01:39:42 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:54691 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750927AbdJTFjk (ORCPT ); Fri, 20 Oct 2017 01:39:40 -0400 Received: by mail-wr0-f194.google.com with SMTP id o44so10301064wrf.11; Thu, 19 Oct 2017 22:39:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=3K0xZUY2+wnx7IrNlpXtI/BjeNpg+U61bTq5+E0vm9Q=; b=RCKMZvcqHOVu7uCFULxROJvebn53o9qdxw2XXpRWmsq6AIJqkyyo+hNlZw4ak3XyQw kw9N/yYTffD5pUmlQHlPHoZoVEJaVxJQwDKvnBIqYwm1RN9X5YF4rowDvUdFIrcx0WQe re/LUupgxFNW3UlM4qVx0IiXBpWZoGA1D87c8TtcTkt8dLvflEih497+qP3ioAFom+vG EB1jtKi7qsNxJNlNdtWNZ1KPs1OlIKoZ/lDz5B6o7rJbfaLXdnZGT/nFN/YbHmt2W3Pw nfpZE65MWiSsEUBa8Qx+VmUE4tDuJYBkgXgmDd55nhwWx0DNr5YIl3vH+GOdl6x7FiDi r1aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3K0xZUY2+wnx7IrNlpXtI/BjeNpg+U61bTq5+E0vm9Q=; b=b0Jx4sRRQ/JcB+Mgnd8mSpgct33NsmZj9lCD+y57OokKD2LDPaSuIjsytBi/2+L5Yu 0ri6g9ex4/jgsMYfeDZIQuEWsqV+8CAwui3I/hSkuGSUGjidpoUq0XY/K3hX7DldcGjT 4X/VnGO0x6SE4Z7XvVmhpz/HSzSaXGzpXMum1wVB0IxEji9+MnPGjXJYCPXH3oETuN2J Z2O/QBCb8gB2JX3WI9gSbb8v3jjKGZVPW1ezxHXVMnXEKc0pVYn6pbrKZp3nkDY+66id JJNyrPhniSKmllOp6J73Re8/++2Q6UP88n7hDRXmTcPztlV5Kpw8z1rFcoXOYJxJHkPK 8N2A== X-Gm-Message-State: AMCzsaVN1vforZUnyaOxoh4fRtZd+OPjuuRQqYRKLtARcvoVRVOMBtuQ sgJFPKqWgTa0PppsH9bjmZs= X-Google-Smtp-Source: ABhQp+Rmn6WbNL20rdw4LbGodDYC9fWNRH3DYnBESM/8RaoTuI7UaeQEVLgCL2RcApdHObm7XW0Q/g== X-Received: by 10.223.199.205 with SMTP id y13mr3622227wrg.71.1508477979048; Thu, 19 Oct 2017 22:39:39 -0700 (PDT) Received: from Red.local (LFbn-MAR-1-580-96.w90-118.abo.wanadoo.fr. [90.118.159.96]) by smtp.googlemail.com with ESMTPSA id m26sm298660wrb.81.2017.10.19.22.39.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Oct 2017 22:39:38 -0700 (PDT) From: Corentin Labbe To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, maxime.ripard@free-electrons.com, wens@csie.org, pmeerw@pmeerw.net, quentin.schulz@free-electrons.com Cc: linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Corentin Labbe Subject: [PATCH] iio: adc: sun4i-gpadc: use of_device_get_match_data Date: Fri, 20 Oct 2017 07:37:29 +0200 Message-Id: <20171020053729.23248-1-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.6 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The usage of of_device_get_match_data reduce the code size a bit. Furthermore, it prevents an improbable dereference when of_match_device() return NULL. Signed-off-by: Corentin Labbe --- drivers/iio/adc/sun4i-gpadc-iio.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.13.6 diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index c4e70f1cad79..04d7147e0110 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -501,17 +501,15 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev, struct iio_dev *indio_dev) { struct sun4i_gpadc_iio *info = iio_priv(indio_dev); - const struct of_device_id *of_dev; struct resource *mem; void __iomem *base; int ret; - of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev); - if (!of_dev) + info->data = of_device_get_match_data(&pdev->dev); + if (!info->data) return -ENODEV; info->no_irq = true; - info->data = (struct gpadc_data *)of_dev->data; indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels); indio_dev->channels = sun8i_a33_gpadc_channels;