Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756105Ab3IZINs (ORCPT ); Thu, 26 Sep 2013 04:13:48 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:51066 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751720Ab3IZINo (ORCPT ); Thu, 26 Sep 2013 04:13:44 -0400 X-AuditID: cbfee68e-b7f756d000004512-bf-5243ecb66967 From: Jingoo Han To: "'Axel Lin'" Cc: "'Mark Brown'" , "'Liam Girdwood'" , linux-kernel@vger.kernel.org, "'Jingoo Han'" , "'Sachin Kamat'" References: <003101ceba8c$88d6a840$9a83f8c0$%han@samsung.com> <003c01ceba8d$79872c60$6c958520$%han@samsung.com> In-reply-to: Subject: Re: [PATCH V3 12/14] regulator: tps6524x: use devm_regulator_register() Date: Thu, 26 Sep 2013 17:13:42 +0900 Message-id: <004101ceba90$50592700$f10b7500$%han@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac66j0RXU/Aj0chjTUeD+OaErYQDygAAIfMA Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrAIsWRmVeSWpSXmKPExsVy+t8zfd1tb5yDDF5st7E4Mucrs8XUh0/Y LC4vvMRq8e1KB5PF5V1z2CxO/ulldGDz2DnrLrtH288yj02rOtk87lzbw+bRt2UVo8fnTXIB bFFcNimpOZllqUX6dglcGW+fnWAsWCVcsabhAVMDYxtvFyMnh4SAiUT37AWsELaYxIV769m6 GLk4hASWMUr0zzjHDFPU/PYKI0RiOqPE2S23wDqEBH4xSnTdBpvEJqAm8eXLYXYQW0RAReJN /ysmkAZmgT2MEntmLmSG6N7BKPF87lqWLkYODk6BYIkfsxlBGoQFAiQuLZ4A1swioCrxZn8b WAmvgK3EvD3pIGFeAUGJH5PvsYDYzAJaEut3HmeCsOUlNq95ywxSLiGgLvHory7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xSnAwK4nw/ngFFOJNSays Si3Kjy8qzUktPsSYDPTnRGYp0eR8YNLKK4k3NDYxM7I0MrMwMjE3J01YSZz3YKt1oJBAemJJ anZqakFqEcwWJg5OqQbGfp247z5cXHbrPnt6ana+MOBn/v7HdL8S1wde7xQpf8FdDrk9b869 mX3TWPWzJ1+086euew/urn3qLngv34nVWm255KmZEyQsn1/O5Xk94fWbHkXv9U/NbqxfX7zv wwRhgxe+yirZfE9FNihOerGuKuWO+FNO752GppLF0dFPHO7+Eq/6eH+/EktxRqKhFnNRcSIA wHYIalADAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2642 Lines: 82 On Thursday, September 26, 2013 5:06 PM, Axel Lin wrote: > 2013/9/26 Jingoo Han : > > Use devm_regulator_register() to make cleanup paths simpler. > > > > Signed-off-by: Jingoo Han > > --- > > drivers/regulator/tps6524x-regulator.c | 7 +++---- > > 1 file changed, 3 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/regulator/tps6524x-regulator.c b/drivers/regulator/tps6524x-regulator.c > > index 8b9ee39..8fe67fb 100644 > > --- a/drivers/regulator/tps6524x-regulator.c > > +++ b/drivers/regulator/tps6524x-regulator.c > > @@ -584,10 +584,8 @@ static int pmic_remove(struct spi_device *spi) > > > > if (!hw) > > return 0; > > - for (i = 0; i < N_REGULATORS; i++) { > > - regulator_unregister(hw->rdev[i]); > > + for (i = 0; i < N_REGULATORS; i++) > > hw->rdev[i] = NULL; > > - } > > return 0; > > } > > > > @@ -631,7 +629,8 @@ static int pmic_probe(struct spi_device *spi) > > config.init_data = init_data; > > config.driver_data = hw; > > > > - hw->rdev[i] = regulator_register(&hw->desc[i], &config); > > + hw->rdev[i] = devm_regulator_register(dev, &hw->desc[i], > > + &config); > > if (IS_ERR(hw->rdev[i])) { > > ret = PTR_ERR(hw->rdev[i]); > > hw->rdev[i] = NULL; > > I think you can simply return PTR_ERR(hw->rdev[i]) if devm_regulator_register() > fails. > You are using devm_regulator_register now, so don't need to call > pmic_remove() in probe() error path. > Then pmic_remove() and .remove = pmic_remove() can be removed as well. > CC'ed Sachin Kamat, Hi Axel, I really appreciate your comment. Then, you mean the following. If I am wrong, please let me know. :-) Thank you. static int pmic_probe(struct spi_device *spi) { ...... hw->rdev[i] = devm_regulator_register(dev, &hw->desc[i], &config); if (IS_ERR(hw->rdev[i])) return PTR_ERR(hw->rdev[i]); } return 0; } static struct spi_driver pmic_driver = { .probe = pmic_probe, .driver = { .name = "tps6524x", .owner = THIS_MODULE, }, }; Best regards, Jingoo Han -- 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/