Hello Yingkun Meng,
Commit d84881e06836 ("ASoC: Add support for Loongson I2S controller")
from Jun 15, 2023 (linux-next), leads to the following Smatch static
checker warning:
sound/soc/loongson/loongson_i2s_pci.c:131 loongson_i2s_pci_probe()
error: 'i2s->regmap' dereferencing possible ERR_PTR()
sound/soc/loongson/loongson_i2s_pci.c
73 static int loongson_i2s_pci_probe(struct pci_dev *pdev,
74 const struct pci_device_id *pid)
75 {
76 const struct fwnode_handle *fwnode = pdev->dev.fwnode;
77 struct loongson_dma_data *tx_data, *rx_data;
78 struct device *dev = &pdev->dev;
79 struct loongson_i2s *i2s;
80 int ret;
81
82 if (pcim_enable_device(pdev)) {
83 dev_err(dev, "pci_enable_device failed\n");
84 return -ENODEV;
85 }
86
87 i2s = devm_kzalloc(dev, sizeof(*i2s), GFP_KERNEL);
88 if (!i2s)
89 return -ENOMEM;
90
91 i2s->rev_id = pdev->revision;
92 i2s->dev = dev;
93 pci_set_drvdata(pdev, i2s);
94
95 ret = pcim_iomap_regions(pdev, 1 << 0, dev_name(dev));
96 if (ret < 0) {
97 dev_err(dev, "iomap_regions failed\n");
98 return ret;
99 }
100
101 i2s->reg_base = pcim_iomap_table(pdev)[0];
102 i2s->regmap = devm_regmap_init_mmio(dev, i2s->reg_base,
103 &loongson_i2s_regmap_config);
104 if (IS_ERR(i2s->regmap))
105 dev_err_probe(dev, PTR_ERR(i2s->regmap), "regmap_init_mmio failed\n");
return dev_err_probe()?
106
107 tx_data = &i2s->tx_dma_data;
108 rx_data = &i2s->rx_dma_data;
109
110 tx_data->dev_addr = pci_resource_start(pdev, 0) + LS_I2S_TX_DATA;
111 tx_data->order_addr = i2s->reg_base + LS_I2S_TX_ORDER;
112
113 rx_data->dev_addr = pci_resource_start(pdev, 0) + LS_I2S_RX_DATA;
114 rx_data->order_addr = i2s->reg_base + LS_I2S_RX_ORDER;
115
116 tx_data->irq = fwnode_irq_get_byname(fwnode, "tx");
117 if (tx_data->irq < 0)
118 dev_err_probe(dev, tx_data->irq, "dma tx irq invalid\n");
119
120 rx_data->irq = fwnode_irq_get_byname(fwnode, "rx");
121 if (rx_data->irq < 0)
122 dev_err_probe(dev, rx_data->irq, "dma rx irq invalid\n");
123
124 ret = device_property_read_u32(dev, "clock-frequency", &i2s->clk_rate);
125 if (ret)
126 dev_err_probe(dev, ret, "clock-frequency property invalid\n");
127
128 dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
129
130 if (i2s->rev_id == 1) {
--> 131 regmap_write(i2s->regmap, LS_I2S_CTRL, I2S_CTRL_RESET);
^^^^^^^^^^^^
132 udelay(200);
133 }
134
135 ret = devm_snd_soc_register_component(dev, &loongson_i2s_component,
136 &loongson_i2s_dai, 1);
137 if (ret)
138 dev_err_probe(dev, ret, "register DAI failed\n");
Same. Seems like a missing return statement.
139
140 return 0;
141 }
regards,
dan carpenter
[Index of Archives]
[Pulseaudio]
[Linux Audio Users]
[ALSA Devel]
[Fedora Desktop]
[Fedora SELinux]
[Big List of Linux Books]
[Yosemite News]
[KDE Users]