From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751483AbcGMXd3 (ORCPT ); Wed, 13 Jul 2016 19:33:29 -0400 Received: from mail2.openmailbox.org ([62.4.1.33]:44978 "EHLO mail2.openmailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751092AbcGMXdU (ORCPT ); Wed, 13 Jul 2016 19:33:20 -0400 From: =?UTF-8?q?Pawe=C5=82=20Grudzi=C5=84ski?= To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Hartmut Knaack , Peter Meerwald , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pawel Grudzinski Subject: [PATCH] iio: ad5380: Fix probe failure when no external reference is supplied Date: Thu, 14 Jul 2016 01:32:01 +0200 Message-Id: <20160713233202.812-1-pgrudzinski@openmailbox.org> X-Mailer: git-send-email 2.8.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pawel Grudzinski Driver fails to load when there is no external Vref regulator defined, leaving no way to use internal reference. ad5380_probe function tries to obtain regulator with demv_regulator_get and checks for error, in which case it would use internal reference. Even without "Vref" regulator defined devm_regulator_get returns dummy regulator which makes function omit use of internal reference and causes failure on regulator_get_voltage. Replace demv_regulator_get with demv_regulator_get_optional, which returns error instead of dummy regulator if it does not find one which is specified by the caller to make ad5380_probe configure internal reference when no "Vref" regulator is supplied. Signed-off-by: Paweł Grudziński --- There are couple more places where I suspect similar issue with devices having integrated reference, but I am sending this one because I tested it with hardware. If this gets accepted, I will look through other drivers obtaining Vref in same manner. drivers/iio/dac/ad5380.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c index 97d2c51..257d455 100644 --- a/drivers/iio/dac/ad5380.c +++ b/drivers/iio/dac/ad5380.c @@ -401,7 +401,7 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap, if (st->chip_info->int_vref == 2500) ctrl |= AD5380_CTRL_INT_VREF_2V5; - st->vref_reg = devm_regulator_get(dev, "vref"); + st->vref_reg = devm_regulator_get_optional(dev, "vref"); if (!IS_ERR(st->vref_reg)) { ret = regulator_enable(st->vref_reg); if (ret) { -- Best regards, Paweł Grudziński