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: 10021467 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0833A600CC for ; Sat, 21 Oct 2017 17:41:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E83622851D for ; Sat, 21 Oct 2017 17:40:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB73628A9F; Sat, 21 Oct 2017 17:40:59 +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=-3.7 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7958B2851D for ; Sat, 21 Oct 2017 17:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=m4OPWSCFJmjt7nApXAdpxdjw8J2u4YW4XPD875LhXeA=; b=nmW GY+Qw0w8BfgjaSQdg/0CGjzmy9xxURFONsR5esAsApnhrkw68xrTkouDGFQSIijGKspjCnfYKokST YduLJOiidmhkPQZ4h3Z4B8K2L8QnpXk6Zk7f5nN4A9GV90r3x7Mi0LaLwaqfB/jJQ+Eq6s03xDq6p U52jAuzKIciAaS825dU1ExXvqoS64rB7x8NV0A4RGqPAWTDUYKIB6vQxq6PZMwjV9H3yAXod8t3G9 cES1lsyYzrHliCjJlHFwJyDrn0wWOKeYbtrgBg6BtVukDRO36Bv+1Cbox3/1MENVAzwfL88PpCCuF l25BOETYL+oyY1vwGVpOV+Gern0yuFA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e5xlS-0004V5-Gi; Sat, 21 Oct 2017 17:40:50 +0000 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e5xlP-0004RU-FK for linux-arm-kernel@lists.infradead.org; Sat, 21 Oct 2017 17:40:49 +0000 Received: by mail-wr0-x243.google.com with SMTP id k62so13731197wrc.9 for ; Sat, 21 Oct 2017 10:40:26 -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=YJNpiM7ffgUImjgVIoMNld4PYZ3HJrjExeZm4YCfdg6fnLdS+kvTsVfGf84MJuhtwU GPTBm5vJP+jyWwd9NPRfs/TOFrDNqTYdthPfjH9ddbtOpxOQDSiyL7jEEdWf5HEdXOog LivTAfV3jQEnDHPp3Pa67zbTfIjq1eprBEWx6CwnZCf09YYA6Zl76uq2aYLfpVvwPK6g CvNLratD8bXTNfIVMLw7s0VNicLEboQCbNfChb2z1MgnfZEy/Oc3SoRYFEGouW96lGfV SsrR9lXId2VhEz3xZNAJlctePI90ZcWLR1pnYbsszzY4MX1qvkMGJyNl8Rca1Y913vdC VLiw== X-Gm-Message-State: AMCzsaV2ZCUoKiGOMge7OkoWEMqoyAgJGV05GzwopOrJbaphn1lGB96e l8zwGuo4ffRJL1nrNjHLBJ8= 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171021_104047_669625_86B3D293 X-CRM114-Status: GOOD ( 10.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, Corentin Labbe , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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;