Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755196AbbDNMMK (ORCPT ); Tue, 14 Apr 2015 08:12:10 -0400 Received: from mail-la0-f48.google.com ([209.85.215.48]:34884 "EHLO mail-la0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753585AbbDNMMA (ORCPT ); Tue, 14 Apr 2015 08:12:00 -0400 MIME-Version: 1.0 In-Reply-To: <1423712131-23795-3-git-send-email-bjorn.andersson@sonymobile.com> References: <1423712131-23795-1-git-send-email-bjorn.andersson@sonymobile.com> <1423712131-23795-3-git-send-email-bjorn.andersson@sonymobile.com> Date: Tue, 14 Apr 2015 21:11:58 +0900 Message-ID: Subject: Re: [PATCH 2/5] ufs: Rename of regulator_set_optimum_mode From: Akinobu Mita To: Bjorn Andersson Cc: Vinayak Holikatti , "James E.J. Bottomley" , Mark Brown , "linux-scsi@vger.kernel.org" , LKML , linux-arm-msm@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2794 Lines: 71 2015-02-12 12:35 GMT+09:00 Bjorn Andersson : > The function regulator_set_optimum_mode() is changing name to > regulator_set_load(), so update the code accordingly. Also cleaned up > ufshcd_config_vreg_load() while touching the code. > > Signed-off-by: Bjorn Andersson > --- > drivers/scsi/ufs/ufshcd.c | 27 +++++++-------------------- > 1 file changed, 7 insertions(+), 20 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 2e4614b..4b73b94 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -4225,22 +4225,15 @@ static struct scsi_host_template ufshcd_driver_template = { > static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg, > int ua) > { > - int ret = 0; > - struct regulator *reg = vreg->reg; > - const char *name = vreg->name; > + int ret; > > - BUG_ON(!vreg); > + if (!vreg) > + return 0; > > - ret = regulator_set_optimum_mode(reg, ua); > - if (ret >= 0) { > - /* > - * regulator_set_optimum_mode() returns new regulator > - * mode upon success. > - */ > - ret = 0; > - } else { > - dev_err(dev, "%s: %s set optimum mode(ua=%d) failed, err=%d\n", > - __func__, name, ua, ret); > + ret = regulator_set_load(vreg->reg, ua); > + if (ret < 0) { > + dev_err(dev, "%s: %s set load (ua=%d) failed, err=%d\n", > + __func__, vreg->name, ua, ret); > } > > return ret; > @@ -4249,18 +4242,12 @@ static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg, > static inline int ufshcd_config_vreg_lpm(struct ufs_hba *hba, > struct ufs_vreg *vreg) > { > - if (!vreg) > - return 0; > - > return ufshcd_config_vreg_load(hba->dev, vreg, UFS_VREG_LPM_LOAD_UA); > } > > static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba, > struct ufs_vreg *vreg) > { > - if (!vreg) > - return 0; > - > return ufshcd_config_vreg_load(hba->dev, vreg, vreg->max_uA); > } I tried this patch and it caused kernel null pointer dereference with 'verg->max_uA' when vreg == NULL. So you can't simply move !vreg check here into ufshcd_config_vreg_load(). -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/