From patchwork Sat Oct 21 17:38:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 116611 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2933804qgn; Sat, 21 Oct 2017 10:40:30 -0700 (PDT) X-Received: by 10.159.214.152 with SMTP id n24mr6863522plp.48.1508607630792; Sat, 21 Oct 2017 10:40:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508607630; cv=none; d=google.com; s=arc-20160816; b=K2w/+K8vcI2vG4hiEmms1gqazhADTg9qcwJVUgfAEmDpBOg9BCn0CLovKm9inGkejM Q7hW80pdohO7fzQZUryFHxYnhn/WwoBLUBTjhwB12lLBiaCzzkE1nuDCVOZCd0QLvXgz DrlqXfc4QWGqSs3zXInS1nAH5K6/QeLyUpPycgKH+Py3cG12olPRusu3RrTDgENro8rO Qb3lXMCkFIEPmTte5ZBO72UiR3SBXt06Sk6szGk1OsMiAk38WBHr9kdip9ucoZAZjZY2 reyrRwc4ZarNenWwKKS4JVJcpHYUrDCVcYTQ7UELyB0akznUJhxNxkl5FWnrPNsArvr4 caHw== 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=jGv4TWGdEFjA6KdEUw5KM9l9ZibDP53QqcgRcsw2jCM=; b=rklMn3BVGT11JENo6/xtSAJZjm+workIEr3kCECK3yw9c9y6pJ1/mANAFfScl/Va3a 1efNjcowA4aBjPFo40TasHXMUcOfYnvgDBCAz73YKBxp7v1WBm3tXNNsacf1ORSQ+kqi TtlduuD9guBBM3jjP+BUiiwgkd86Na5kxbiPonWND5xxX+gBnh92gy7ubUKm1GymET7U B8KokkWdIdy1OtmoIhoFg13ZKX91vNwExt/GXJCayqJ2hN4x4tGttVO8xI1+9LGIZZo4 eadZh0GNzefIrABHF58S4TLd+qPVSGEABTP4CJJ4H6xQ+x/ST0Yf56wALgio4D6mg08B 3gjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pJXM+IEd; 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 w2si2429264pgt.267.2017.10.21.10.40.30; Sat, 21 Oct 2017 10:40:30 -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=pJXM+IEd; 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 S932239AbdJURk2 (ORCPT + 27 others); Sat, 21 Oct 2017 13:40:28 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:44439 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932132AbdJURk0 (ORCPT ); Sat, 21 Oct 2017 13:40:26 -0400 Received: by mail-wr0-f196.google.com with SMTP id z55so7676342wrz.1; Sat, 21 Oct 2017 10:40:25 -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=jGv4TWGdEFjA6KdEUw5KM9l9ZibDP53QqcgRcsw2jCM=; b=pJXM+IEdjsvQm4LwlzldfVd8NDukOCq2YHxSyFbBN7T38MqcA2377CSEwaaKoQWzxk SfB3cG+AWPiA6k2u415ka/y83fUbBTgxv4UcqpThpH1qpjZL0+SPld8QV6Nd5aAvvEyp MBsk/q6kxT3p9Q4n5ALx4F5jhVVsYHj1CjMk39p5RF6Qyqlw22y5YCqMbip39Pz79KUQ 7vv6vBTXxiaeya4qufBah14yyRnG2A+Lu+JYP9x7APacBAslHcLt0cpwHMjMbKywWGjX Xh5juIDQLlQBB/YfKqEdhlKCVQpDjjMAkON4Ob2RpZkQbRcvttaUkbJIOb3fdMGRXliN h4XQ== 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=jGv4TWGdEFjA6KdEUw5KM9l9ZibDP53QqcgRcsw2jCM=; b=LP6qpmkUDpO0o2VLdKy2OuX6gR+yJUJfT1zjdWJFWV48eao8N2To9qu2oCL43xT52u sNt7RKAyaPMInJSOK6J+q9mFCCtdnG6yvHHYNospTD17/4nRtrEvOX38QY3/XuIPdWiS ZsbGmbestQvKs+0mK2wvtldzhYo1NmI00L1ob5ftXVXIj8fFukUH6lIeFZu/vf0REI2+ GP0+rX1a2hH4T6Yw4KFVvK8KSdxrr2Q8hk3SPnErV5QF6i59w9UIMLMnaeWHbcTMPWdq otqgX6eGaPImk7Zd19TpA9jZfT8hKUT1e8BamATdFcM5MYvUIhaNv0e216R0JkfQjlWZ Dd6A== X-Gm-Message-State: AMCzsaX/kHSAJkq5OyCuLIR/Tua8UywDJ488T9+a5EeJuldwsg7HEd7t +wRyUNCPjzxyvl7y5LDF/Xg= X-Google-Smtp-Source: ABhQp+QYdsmuP7lc3+/xC7CWk3WzgIy01QsJekEAQRqPhZ8LRofYK+FydTaNq5A3o/CjTzD5cZM7cQ== X-Received: by 10.223.128.170 with SMTP id 39mr7081946wrl.236.1508607624942; Sat, 21 Oct 2017 10:40:24 -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 z35sm9383763wrc.9.2017.10.21.10.40.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 21 Oct 2017 10:40:24 -0700 (PDT) From: Corentin Labbe To: thierry.reding@gmail.com, maxime.ripard@free-electrons.com, wens@csie.org Cc: linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Corentin Labbe Subject: [PATCH] pwm: sunxi: use of_device_get_match_data Date: Sat, 21 Oct 2017 19:38:12 +0200 Message-Id: <20171021173812.30102-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/pwm/pwm-sun4i.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.13.6 diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c index 6d23f1d1c9b7..334199c58f1d 100644 --- a/drivers/pwm/pwm-sun4i.c +++ b/drivers/pwm/pwm-sun4i.c @@ -368,14 +368,15 @@ static int sun4i_pwm_probe(struct platform_device *pdev) struct sun4i_pwm_chip *pwm; struct resource *res; int ret; - const struct of_device_id *match; - - match = of_match_device(sun4i_pwm_dt_ids, &pdev->dev); pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL); if (!pwm) return -ENOMEM; + pwm->data = of_device_get_match_data(&pdev->dev); + if (!pwm->data) + return -ENODEV; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); pwm->base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(pwm->base)) @@ -385,7 +386,6 @@ static int sun4i_pwm_probe(struct platform_device *pdev) if (IS_ERR(pwm->clk)) return PTR_ERR(pwm->clk); - pwm->data = match->data; pwm->chip.dev = &pdev->dev; pwm->chip.ops = &sun4i_pwm_ops; pwm->chip.base = -1;