[PATCH v1 2/8] ASoC: loongson: Simplify probe() with local dev variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Simplify the probe() function by using local 'dev' instead of
&pdev->dev.

Signed-off-by: Binbin Zhou <zhoubinbin@xxxxxxxxxxx>
---
 sound/soc/loongson/loongson_card.c    | 17 ++++++++-------
 sound/soc/loongson/loongson_i2s_pci.c | 30 +++++++++++++--------------
 2 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/sound/soc/loongson/loongson_card.c b/sound/soc/loongson/loongson_card.c
index 4d511b7589d0..d3cd23ddd027 100644
--- a/sound/soc/loongson/loongson_card.c
+++ b/sound/soc/loongson/loongson_card.c
@@ -159,40 +159,41 @@ static int loongson_card_parse_of(struct loongson_card_data *data)
 static int loongson_asoc_card_probe(struct platform_device *pdev)
 {
 	struct loongson_card_data *ls_priv;
+	struct device *dev = &pdev->dev;
 	struct snd_soc_card *card;
 	int ret;
 
-	ls_priv = devm_kzalloc(&pdev->dev, sizeof(*ls_priv), GFP_KERNEL);
+	ls_priv = devm_kzalloc(dev, sizeof(*ls_priv), GFP_KERNEL);
 	if (!ls_priv)
 		return -ENOMEM;
 
 	card = &ls_priv->snd_card;
 
-	card->dev = &pdev->dev;
+	card->dev = dev;
 	card->owner = THIS_MODULE;
 	card->dai_link = loongson_dai_links;
 	card->num_links = ARRAY_SIZE(loongson_dai_links);
 	snd_soc_card_set_drvdata(card, ls_priv);
 
-	ret = device_property_read_string(&pdev->dev, "model", &card->name);
+	ret = device_property_read_string(dev, "model", &card->name);
 	if (ret) {
-		dev_err(&pdev->dev, "Error parsing card name: %d\n", ret);
+		dev_err(dev, "Error parsing card name: %d\n", ret);
 		return ret;
 	}
-	ret = device_property_read_u32(&pdev->dev, "mclk-fs", &ls_priv->mclk_fs);
+	ret = device_property_read_u32(dev, "mclk-fs", &ls_priv->mclk_fs);
 	if (ret) {
-		dev_err(&pdev->dev, "Error parsing mclk-fs: %d\n", ret);
+		dev_err(dev, "Error parsing mclk-fs: %d\n", ret);
 		return ret;
 	}
 
-	if (has_acpi_companion(&pdev->dev))
+	if (has_acpi_companion(dev))
 		ret = loongson_card_parse_acpi(ls_priv);
 	else
 		ret = loongson_card_parse_of(ls_priv);
 	if (ret < 0)
 		return ret;
 
-	return devm_snd_soc_register_card(&pdev->dev, card);
+	return devm_snd_soc_register_card(dev, card);
 }
 
 static const struct of_device_id loongson_asoc_dt_ids[] = {
diff --git a/sound/soc/loongson/loongson_i2s_pci.c b/sound/soc/loongson/loongson_i2s_pci.c
index ec18b122cd79..e8ea28bc5a5f 100644
--- a/sound/soc/loongson/loongson_i2s_pci.c
+++ b/sound/soc/loongson/loongson_i2s_pci.c
@@ -75,32 +75,33 @@ static int loongson_i2s_pci_probe(struct pci_dev *pdev,
 {
 	const struct fwnode_handle *fwnode = pdev->dev.fwnode;
 	struct loongson_dma_data *tx_data, *rx_data;
+	struct device *dev = &pdev->dev;
 	struct loongson_i2s *i2s;
 	int ret;
 
 	if (pcim_enable_device(pdev)) {
-		dev_err(&pdev->dev, "pci_enable_device failed\n");
+		dev_err(dev, "pci_enable_device failed\n");
 		return -ENODEV;
 	}
 
-	i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL);
+	i2s = devm_kzalloc(dev, sizeof(*i2s), GFP_KERNEL);
 	if (!i2s)
 		return -ENOMEM;
 
 	i2s->rev_id = pdev->revision;
-	i2s->dev = &pdev->dev;
+	i2s->dev = dev;
 	pci_set_drvdata(pdev, i2s);
 
-	ret = pcim_iomap_regions(pdev, 1 << 0, dev_name(&pdev->dev));
+	ret = pcim_iomap_regions(pdev, 1 << 0, dev_name(dev));
 	if (ret < 0) {
-		dev_err(&pdev->dev, "iomap_regions failed\n");
+		dev_err(dev, "iomap_regions failed\n");
 		return ret;
 	}
 	i2s->reg_base = pcim_iomap_table(pdev)[0];
-	i2s->regmap = devm_regmap_init_mmio(&pdev->dev, i2s->reg_base,
+	i2s->regmap = devm_regmap_init_mmio(dev, i2s->reg_base,
 					    &loongson_i2s_regmap_config);
 	if (IS_ERR(i2s->regmap)) {
-		dev_err(&pdev->dev, "regmap_init_mmio failed\n");
+		dev_err(dev, "regmap_init_mmio failed\n");
 		return PTR_ERR(i2s->regmap);
 	}
 
@@ -115,34 +116,33 @@ static int loongson_i2s_pci_probe(struct pci_dev *pdev,
 
 	tx_data->irq = fwnode_irq_get_byname(fwnode, "tx");
 	if (tx_data->irq < 0) {
-		dev_err(&pdev->dev, "dma tx irq invalid\n");
+		dev_err(dev, "dma tx irq invalid\n");
 		return tx_data->irq;
 	}
 
 	rx_data->irq = fwnode_irq_get_byname(fwnode, "rx");
 	if (rx_data->irq < 0) {
-		dev_err(&pdev->dev, "dma rx irq invalid\n");
+		dev_err(dev, "dma rx irq invalid\n");
 		return rx_data->irq;
 	}
 
-	device_property_read_u32(&pdev->dev, "clock-frequency", &i2s->clk_rate);
+	device_property_read_u32(dev, "clock-frequency", &i2s->clk_rate);
 	if (!i2s->clk_rate) {
-		dev_err(&pdev->dev, "clock-frequency property invalid\n");
+		dev_err(dev, "clock-frequency property invalid\n");
 		return -EINVAL;
 	}
 
-	dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
 
 	if (i2s->rev_id == 1) {
 		regmap_write(i2s->regmap, LS_I2S_CTRL, I2S_CTRL_RESET);
 		udelay(200);
 	}
 
-	ret = devm_snd_soc_register_component(&pdev->dev,
-					      &loongson_i2s_component,
+	ret = devm_snd_soc_register_component(dev, &loongson_i2s_component,
 					      &loongson_i2s_dai, 1);
 	if (ret) {
-		dev_err(&pdev->dev, "register DAI failed %d\n", ret);
+		dev_err(dev, "register DAI failed %d\n", ret);
 		return ret;
 	}
 
-- 
2.43.5





[Index of Archives]     [Pulseaudio]     [Linux Audio Users]     [ALSA Devel]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux