From patchwork Wed Sep 20 18:42:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 113167 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1106435qgf; Wed, 20 Sep 2017 11:45:02 -0700 (PDT) X-Received: by 10.98.214.23 with SMTP id r23mr3107054pfg.195.1505933102709; Wed, 20 Sep 2017 11:45:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505933102; cv=none; d=google.com; s=arc-20160816; b=fZ0l6DJyXVZV5diaxVr/k8/G6qHUXv4kz5z3deFbtnO0mFRlegHE497sVQYiuu8eWV mzcQFq2HDFMstgHQFlEVAa0LZbFz0BwE0KehNGlLbqtsPFIzxDEQ/WlBm21C68F/rSB5 D9Q3qmEs8JR+R02D5t0DQ9eAU7WVl/5o7QL8+1d80sN01CJTQGb4JFlO8PSj0yxZQJ+c HF/u966YMeVbE2bY6Mbczh3fAkZLF07NuWjM70MX8mE3HX8qHFuoHLnQv+zsjkVWWQC9 Bxo4gMVAlIGQ3dENzHrMBx55TckI7v8WywxorWs7KUjqpNh5nD8hSFkfIGD3ZcGEzjgs rX1A== 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=3m9TdZJtQ1YEN6R5ZfAQrbbYdrLtsuwGkazSq7EsWSY=; b=Q3EP3H4kXfTpQe9E+XQu5DfSOCDbt+PIU+YSJz3Zl768y4o8yr/jL3FsKHNnEB598i x4V5IroEkm+Y+AAY+ctaoMe5v75pmYGezzGQ5xZlgsv3q2XlzYq3RwY5zjNQ6UPPu6wW zxBDL96r2Q3emagfVzJB9QywuZBXp2iv+T5bnLrsKW2E9hKgoQv3RLw1Z2aM7cFNsviI mKvV0xtYLYLuzb7B1iVIPI0YmISga/nHVgq3YNq2kjAPKUF2eTJ0XvNduJFMB1CHkGMH QgthGAI23Tz7qWo17S4ty61NU1vhFiS2EVXhCtnwsC1URv47ciQub1QrE/G5BfitNVjf E2OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hZ6attWe; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 t21si1745942plo.594.2017.09.20.11.45.02; Wed, 20 Sep 2017 11:45:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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=hZ6attWe; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 S1751378AbdITSpA (ORCPT + 1 other); Wed, 20 Sep 2017 14:45:00 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34587 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751361AbdITSpA (ORCPT ); Wed, 20 Sep 2017 14:45:00 -0400 Received: by mail-wm0-f66.google.com with SMTP id i131so3221956wma.1; Wed, 20 Sep 2017 11:44:59 -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=3m9TdZJtQ1YEN6R5ZfAQrbbYdrLtsuwGkazSq7EsWSY=; b=hZ6attWeytuc1KIJLztuUpcebSW649t0YiLMVxj9mj7SGCDAc2x9/17RrpVtrrS1qa NrTaMH9BgVq3KMF7+CTUe9Qk4b/4h55GsRYtGjLrTe+wcK1dXaIzhVYn/iUyMyxskvEc VizK74Rf8AMUIz1hk1bGr0tDvIWepuMHglzbf0MAAibARcqJ5oTbC+Mu8AFJw1OvTkal cBQHb9wOkaRXkfw3k/Pjd72kY51rndGcGvda73b99ifdrQOeBwFW+QRgIdBSfzUW+uR2 K938RZeuo3jb6/zRO0JB7A2LcCMHxoG3Dj/wsghI+JkHvYB6GoAQlbNlTJhxgNzgS4iO EPmw== 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=3m9TdZJtQ1YEN6R5ZfAQrbbYdrLtsuwGkazSq7EsWSY=; b=tKwdO1BTif9B3WOnPqEXrkxkNUNSHAPoTjbWgPzLSZX+saYVFX2KxAA+ez+yE+xY9e fRmOCbZy7Svib+S1NyGIS27x06aE5mq2px4DfkHo691UdtzujI7xrWTGw+P9P0+7MPuV XClktCzJEtkEIdpmJMTsaNoN4w6G3uJ9mxRgREt+mGyx9RPsoXEBfrswcW17gASRb2ZJ OHrir/iJDtuQPvUuLrmD3BFUjX76OuOcN6FPnEL9Jq95BgCiYvnR3Ip7d0LUREiuxXgH flcRz0nDo9IoQX9DzqeAjnP0+/XDnEGXTnnWDvFQFweMvfWLssP/1z1t+OIuMdKMna2l ERxw== X-Gm-Message-State: AHPjjUiUruUw9d329BLIWgFILNCpnPcF+YRWGxOOcp+WwKPXjyX2nV54 2XxGWRhYvq0bsumrKkzddv0= X-Google-Smtp-Source: AOwi7QAU3p6pTStz6xGipBbiAItVKybzGRg5VA7W97zlL3Tq7tQ9Gl+mG0V+ZuygS/tEd4MGtR0sUw== X-Received: by 10.28.163.67 with SMTP id m64mr4761411wme.69.1505933098745; Wed, 20 Sep 2017 11:44:58 -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 g37sm2475246wra.6.2017.09.20.11.44.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Sep 2017 11:44:58 -0700 (PDT) From: Corentin Labbe To: herbert@gondor.apana.org.au, davem@davemloft.net Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Corentin Labbe Subject: [PATCH] crypto: omap: use of_device_get_match_data Date: Wed, 20 Sep 2017 20:42:48 +0200 Message-Id: <20170920184248.21027-1-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.5 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@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/crypto/omap-aes.c | 7 ++----- drivers/crypto/omap-des.c | 7 ++----- drivers/crypto/omap-sham.c | 7 ++----- 3 files changed, 6 insertions(+), 15 deletions(-) -- 2.13.5 diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index 1f3686a1ebfa..fbec0a2e76dd 100644 --- a/drivers/crypto/omap-aes.c +++ b/drivers/crypto/omap-aes.c @@ -975,11 +975,10 @@ static int omap_aes_get_res_of(struct omap_aes_dev *dd, struct device *dev, struct resource *res) { struct device_node *node = dev->of_node; - const struct of_device_id *match; int err = 0; - match = of_match_device(of_match_ptr(omap_aes_of_match), dev); - if (!match) { + dd->pdata = of_device_get_match_data(dev); + if (!dd->pdata) { dev_err(dev, "no compatible OF match\n"); err = -EINVAL; goto err; @@ -992,8 +991,6 @@ static int omap_aes_get_res_of(struct omap_aes_dev *dd, goto err; } - dd->pdata = match->data; - err: return err; } diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c index d37c9506c36c..ebc5c0f11f03 100644 --- a/drivers/crypto/omap-des.c +++ b/drivers/crypto/omap-des.c @@ -928,16 +928,13 @@ MODULE_DEVICE_TABLE(of, omap_des_of_match); static int omap_des_get_of(struct omap_des_dev *dd, struct platform_device *pdev) { - const struct of_device_id *match; - match = of_match_device(of_match_ptr(omap_des_of_match), &pdev->dev); - if (!match) { + dd->pdata = of_device_get_match_data(&pdev->dev); + if (!dd->pdata) { dev_err(&pdev->dev, "no compatible OF match\n"); return -EINVAL; } - dd->pdata = match->data; - return 0; } #else diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c index c40ac30ec002..86b89ace836f 100644 --- a/drivers/crypto/omap-sham.c +++ b/drivers/crypto/omap-sham.c @@ -1944,11 +1944,10 @@ static int omap_sham_get_res_of(struct omap_sham_dev *dd, struct device *dev, struct resource *res) { struct device_node *node = dev->of_node; - const struct of_device_id *match; int err = 0; - match = of_match_device(of_match_ptr(omap_sham_of_match), dev); - if (!match) { + dd->pdata = of_device_get_match_data(dev); + if (!dd->pdata) { dev_err(dev, "no compatible OF match\n"); err = -EINVAL; goto err; @@ -1968,8 +1967,6 @@ static int omap_sham_get_res_of(struct omap_sham_dev *dd, goto err; } - dd->pdata = match->data; - err: return err; }