• Kim, Milo's avatar
    iio: inkern: clean up error return code · 3183bac1
    Kim, Milo authored
     When the IIO consumer tries to get specific IIO channel,
     few error cases can be happened.
     (a) Memory allocation failure
     (b) No matched ADC channel error
     (c) Invalid input arguments
     This patch enables cleaning up error handling in case of (a) and (b).
    
     In error handling code,
     (a): the reference count of the IIO device should be decreased.
     (b): the allocated memory should be freed with restoring the reference count.
     Therefore iio_deivce_put() is called in both cases.
     This can be handled in the last error statement.
    
     Additionally, integer variable is used for stating each error case explicitly.
     Then, the error returns as ERR_PTR() with this value.
    Signed-off-by: default avatarMilo(Woogyom) Kim <milo.kim@ti.com>
    Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
    3183bac1
inkern.c 8.97 KB