summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorentin LABBE <clabbe.montjoie@gmail.com>2017-09-20 14:42:48 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2017-10-07 00:10:35 -0400
commit7d556931520e1e0df4c3e545ab8ba74046410c37 (patch)
tree2ff27f55af9d3cfd0ab2d2e56c959dd493f5fcb3
parentde915688385ca9df749a3d46e824a8200f05d65e (diff)
crypto: omap - use of_device_get_match_data
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 <clabbe.montjoie@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--drivers/crypto/omap-aes.c7
-rw-r--r--drivers/crypto/omap-des.c7
-rw-r--r--drivers/crypto/omap-sham.c7
3 files changed, 6 insertions, 15 deletions
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,
975 struct device *dev, struct resource *res) 975 struct device *dev, struct resource *res)
976{ 976{
977 struct device_node *node = dev->of_node; 977 struct device_node *node = dev->of_node;
978 const struct of_device_id *match;
979 int err = 0; 978 int err = 0;
980 979
981 match = of_match_device(of_match_ptr(omap_aes_of_match), dev); 980 dd->pdata = of_device_get_match_data(dev);
982 if (!match) { 981 if (!dd->pdata) {
983 dev_err(dev, "no compatible OF match\n"); 982 dev_err(dev, "no compatible OF match\n");
984 err = -EINVAL; 983 err = -EINVAL;
985 goto err; 984 goto err;
@@ -992,8 +991,6 @@ static int omap_aes_get_res_of(struct omap_aes_dev *dd,
992 goto err; 991 goto err;
993 } 992 }
994 993
995 dd->pdata = match->data;
996
997err: 994err:
998 return err; 995 return err;
999} 996}
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);
928static int omap_des_get_of(struct omap_des_dev *dd, 928static int omap_des_get_of(struct omap_des_dev *dd,
929 struct platform_device *pdev) 929 struct platform_device *pdev)
930{ 930{
931 const struct of_device_id *match;
932 931
933 match = of_match_device(of_match_ptr(omap_des_of_match), &pdev->dev); 932 dd->pdata = of_device_get_match_data(&pdev->dev);
934 if (!match) { 933 if (!dd->pdata) {
935 dev_err(&pdev->dev, "no compatible OF match\n"); 934 dev_err(&pdev->dev, "no compatible OF match\n");
936 return -EINVAL; 935 return -EINVAL;
937 } 936 }
938 937
939 dd->pdata = match->data;
940
941 return 0; 938 return 0;
942} 939}
943#else 940#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,
1944 struct device *dev, struct resource *res) 1944 struct device *dev, struct resource *res)
1945{ 1945{
1946 struct device_node *node = dev->of_node; 1946 struct device_node *node = dev->of_node;
1947 const struct of_device_id *match;
1948 int err = 0; 1947 int err = 0;
1949 1948
1950 match = of_match_device(of_match_ptr(omap_sham_of_match), dev); 1949 dd->pdata = of_device_get_match_data(dev);
1951 if (!match) { 1950 if (!dd->pdata) {
1952 dev_err(dev, "no compatible OF match\n"); 1951 dev_err(dev, "no compatible OF match\n");
1953 err = -EINVAL; 1952 err = -EINVAL;
1954 goto err; 1953 goto err;
@@ -1968,8 +1967,6 @@ static int omap_sham_get_res_of(struct omap_sham_dev *dd,
1968 goto err; 1967 goto err;
1969 } 1968 }
1970 1969
1971 dd->pdata = match->data;
1972
1973err: 1970err:
1974 return err; 1971 return err;
1975} 1972}