aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaud Pouliquen <arnaud.pouliquen@st.com>2018-01-15 03:57:39 -0500
committerMark Brown <broonie@kernel.org>2018-01-15 13:50:21 -0500
commitabaca806fd13afd069e04e883de8ec75924b0598 (patch)
treea5de7c5afe851a6086af5b67b0022006ed208b99
parentd5ff18bcd4b5e66396eab7e8271172157ee1253e (diff)
IIO: ADC: stm32-dfsdm: code optimization
Use of_device_get_match_data to optimize the source code. No check is needed on dev_data as match table is defined in driver. Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/iio/adc/stm32-dfsdm-adc.c9
-rw-r--r--drivers/iio/adc/stm32-dfsdm-core.c8
2 files changed, 2 insertions, 15 deletions
diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c
index 5e871404f565..3fe9b34ac6af 100644
--- a/drivers/iio/adc/stm32-dfsdm-adc.c
+++ b/drivers/iio/adc/stm32-dfsdm-adc.c
@@ -1087,18 +1087,11 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev)
1087 struct device_node *np = dev->of_node; 1087 struct device_node *np = dev->of_node;
1088 const struct stm32_dfsdm_dev_data *dev_data; 1088 const struct stm32_dfsdm_dev_data *dev_data;
1089 struct iio_dev *iio; 1089 struct iio_dev *iio;
1090 const struct of_device_id *of_id;
1091 char *name; 1090 char *name;
1092 int ret, irq, val; 1091 int ret, irq, val;
1093 1092
1094 of_id = of_match_node(stm32_dfsdm_adc_match, np);
1095 if (!of_id->data) {
1096 dev_err(&pdev->dev, "Data associated to device is missing\n");
1097 return -EINVAL;
1098 }
1099
1100 dev_data = (const struct stm32_dfsdm_dev_data *)of_id->data;
1101 1093
1094 dev_data = of_device_get_match_data(dev);
1102 iio = devm_iio_device_alloc(dev, sizeof(*adc)); 1095 iio = devm_iio_device_alloc(dev, sizeof(*adc));
1103 if (!iio) { 1096 if (!iio) {
1104 dev_err(dev, "%s: Failed to allocate IIO\n", __func__); 1097 dev_err(dev, "%s: Failed to allocate IIO\n", __func__);
diff --git a/drivers/iio/adc/stm32-dfsdm-core.c b/drivers/iio/adc/stm32-dfsdm-core.c
index 6cd655f8239b..6290332cfd3f 100644
--- a/drivers/iio/adc/stm32-dfsdm-core.c
+++ b/drivers/iio/adc/stm32-dfsdm-core.c
@@ -242,7 +242,6 @@ MODULE_DEVICE_TABLE(of, stm32_dfsdm_of_match);
242static int stm32_dfsdm_probe(struct platform_device *pdev) 242static int stm32_dfsdm_probe(struct platform_device *pdev)
243{ 243{
244 struct dfsdm_priv *priv; 244 struct dfsdm_priv *priv;
245 const struct of_device_id *of_id;
246 const struct stm32_dfsdm_dev_data *dev_data; 245 const struct stm32_dfsdm_dev_data *dev_data;
247 struct stm32_dfsdm *dfsdm; 246 struct stm32_dfsdm *dfsdm;
248 int ret; 247 int ret;
@@ -253,13 +252,8 @@ static int stm32_dfsdm_probe(struct platform_device *pdev)
253 252
254 priv->pdev = pdev; 253 priv->pdev = pdev;
255 254
256 of_id = of_match_node(stm32_dfsdm_of_match, pdev->dev.of_node); 255 dev_data = of_device_get_match_data(&pdev->dev);
257 if (!of_id->data) {
258 dev_err(&pdev->dev, "Data associated to device is missing\n");
259 return -EINVAL;
260 }
261 256
262 dev_data = (const struct stm32_dfsdm_dev_data *)of_id->data;
263 dfsdm = &priv->dfsdm; 257 dfsdm = &priv->dfsdm;
264 dfsdm->fl_list = devm_kcalloc(&pdev->dev, dev_data->num_filters, 258 dfsdm->fl_list = devm_kcalloc(&pdev->dev, dev_data->num_filters,
265 sizeof(*dfsdm->fl_list), GFP_KERNEL); 259 sizeof(*dfsdm->fl_list), GFP_KERNEL);