* re: regulator: tps65217: Add device tree support
@ 2012-07-13 9:02 Dan Carpenter
[not found] ` <20120713090220.GA18561-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2012-07-13 9:02 UTC (permalink / raw)
To: anilkumar-l0cyMroinI0; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
Hello AnilKumar Ch,
This is a semi-automatic email about new static checker warnings.
The patch a7f1b63eb856: "regulator: tps65217: Add device tree
support" from Jul 10, 2012, leads to the following Smatch complaint:
drivers/mfd/tps65217.c:245 tps65217_probe()
error: we previously assumed 'pdata' could be null (see line 205)
drivers/mfd/tps65217.c
204
205 if (!pdata && client->dev.of_node)
^^^^^^
New check.
206 pdata = tps65217_parse_dt(client);
207
208 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
209 if (!tps)
210 return -ENOMEM;
211
212 tps->pdata = pdata;
213 tps->regmap = devm_regmap_init_i2c(client, &tps65217_regmap_config);
214 if (IS_ERR(tps->regmap)) {
215 ret = PTR_ERR(tps->regmap);
216 dev_err(tps->dev, "Failed to allocate register map: %d\n",
217 ret);
218 return ret;
219 }
220
221 i2c_set_clientdata(client, tps);
222 tps->dev = &client->dev;
223
224 ret = tps65217_reg_read(tps, TPS65217_REG_CHIPID, &version);
225 if (ret < 0) {
226 dev_err(tps->dev, "Failed to read revision register: %d\n",
227 ret);
228 return ret;
229 }
230
231 dev_info(tps->dev, "TPS65217 ID %#x version 1.%d\n",
232 (version & TPS65217_CHIPID_CHIP_MASK) >> 4,
233 version & TPS65217_CHIPID_REV_MASK);
234
235 for (i = 0; i < TPS65217_NUM_REGULATOR; i++) {
236 struct platform_device *pdev;
237
238 pdev = platform_device_alloc("tps65217-pmic", i);
239 if (!pdev) {
240 dev_err(tps->dev, "Cannot create regulator %d\n", i);
241 continue;
242 }
243
244 pdev->dev.parent = tps->dev;
245 pdev->dev.of_node = pdata->of_node[i];
^^^^^^^^^^^^^^
Old dereference.
246 reg_data = pdata->tps65217_init_data[i];
247 platform_device_add_data(pdev, reg_data, sizeof(*reg_data));
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: regulator: tps65217: Add device tree support
[not found] ` <20120713090220.GA18561-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
@ 2012-07-16 11:07 ` AnilKumar, Chimata
0 siblings, 0 replies; 2+ messages in thread
From: AnilKumar, Chimata @ 2012-07-16 11:07 UTC (permalink / raw)
To: Dan Carpenter; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Mark Brown
+cc Mark
Hi Dan,
Thanks for checking the static code warnings.
On Fri, Jul 13, 2012 at 14:32:20, Dan Carpenter wrote:
> Hello AnilKumar Ch,
>
> This is a semi-automatic email about new static checker warnings.
>
> The patch a7f1b63eb856: "regulator: tps65217: Add device tree
> support" from Jul 10, 2012, leads to the following Smatch complaint:
>
> drivers/mfd/tps65217.c:245 tps65217_probe()
> error: we previously assumed 'pdata' could be null (see line 205)
>
> drivers/mfd/tps65217.c
> 204
> 205 if (!pdata && client->dev.of_node)
> ^^^^^^
> New check.
!pdata in the above if condition is not required if we do a separate check for
"pdata == NULL". So removing pdata check from this and adding a separate
check for NULL pointer.
>
> 206 pdata = tps65217_parse_dt(client);
Above two lines will be replaced with these lines
if (client->dev.of_node)
pdata = tps65217_parse_dt(client);
if (!pdata) {
dev_err(&client->dev, "tps65217 requires platform data\n");
return -EINVAL;
}
I will submit a separate patch for this.
Thanks
AnilKumar
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-07-16 11:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-13 9:02 regulator: tps65217: Add device tree support Dan Carpenter
[not found] ` <20120713090220.GA18561-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
2012-07-16 11:07 ` AnilKumar, Chimata
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.