Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c: altera: use proper variable to hold errno

device_property_read_u32() returns errno or 0, so we should use the
integer variable 'ret' and not the u32 'val' to hold the retval.

Fixes: 0560ad576268 ("i2c: altera: Add Altera I2C Controller driver")
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Thor Thayer <thor.thayer@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

authored by

Wolfram Sang and committed by
Wolfram Sang
edb2c9dd d79294d0

+4 -5
+4 -5
drivers/i2c/busses/i2c-altera.c
··· 384 384 struct altr_i2c_dev *idev = NULL; 385 385 struct resource *res; 386 386 int irq, ret; 387 - u32 val; 388 387 389 388 idev = devm_kzalloc(&pdev->dev, sizeof(*idev), GFP_KERNEL); 390 389 if (!idev) ··· 410 411 init_completion(&idev->msg_complete); 411 412 spin_lock_init(&idev->lock); 412 413 413 - val = device_property_read_u32(idev->dev, "fifo-size", 414 + ret = device_property_read_u32(idev->dev, "fifo-size", 414 415 &idev->fifo_size); 415 - if (val) { 416 + if (ret) { 416 417 dev_err(&pdev->dev, "FIFO size set to default of %d\n", 417 418 ALTR_I2C_DFLT_FIFO_SZ); 418 419 idev->fifo_size = ALTR_I2C_DFLT_FIFO_SZ; 419 420 } 420 421 421 - val = device_property_read_u32(idev->dev, "clock-frequency", 422 + ret = device_property_read_u32(idev->dev, "clock-frequency", 422 423 &idev->bus_clk_rate); 423 - if (val) { 424 + if (ret) { 424 425 dev_err(&pdev->dev, "Default to 100kHz\n"); 425 426 idev->bus_clk_rate = I2C_MAX_STANDARD_MODE_FREQ; /* default clock rate */ 426 427 }