Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753166Ab2FOLML (ORCPT ); Fri, 15 Jun 2012 07:12:11 -0400 Received: from mail-ob0-f174.google.com ([209.85.214.174]:45989 "EHLO mail-ob0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751361Ab2FOLMJ convert rfc822-to-8bit (ORCPT ); Fri, 15 Jun 2012 07:12:09 -0400 MIME-Version: 1.0 Reply-To: axel.lin@gmail.com In-Reply-To: References: From: Axel Lin Date: Fri, 15 Jun 2012 19:11:48 +0800 Message-ID: Subject: Re: [PATCH v2] regulator: add new regulator driver for lp872x To: "Kim, Milo" Cc: Mark Brown , "linux-kernel@vger.kernel.org" , "Girdwood, Liam" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2201 Lines: 73 > + > +static int lp872x_init_dvs(struct lp872x *lp) > +{ > + ? ? ? int ret, gpio; > + ? ? ? struct lp872x_dvs *dvs = lp->pdata->dvs; > + > + ? ? ? ret = lp872x_check_dvs_validity(lp); > + ? ? ? if (ret) { > + ? ? ? ? ? ? ? dev_warn(lp->dev, "invalid dvs data: %d\n", ret); > + ? ? ? ? ? ? ? return ret; > + ? ? ? } > + > + ? ? ? gpio = dvs->gpio; > + > + ? ? ? if (!gpio_is_valid(gpio)) { > + ? ? ? ? ? ? ? dev_err(lp->dev, "invalid gpio: %d\n", gpio); > + ? ? ? ? ? ? ? return -EINVAL; > + ? ? ? } > + > + ? ? ? ret = gpio_request(gpio, "LP872X DVS"); devm_gpio_request > + ? ? ? if (ret) { > + ? ? ? ? ? ? ? dev_err(lp->dev, "gpio request err: %d\n", ret); > + ? ? ? ? ? ? ? return ret; > + ? ? ? } > + > + ? ? ? gpio_direction_output(gpio, dvs->init_state); > + ? ? ? lp->dvs_pin = dvs->init_state; > + ? ? ? lp->dvs_gpio = gpio; > + > + ? ? ? return 0; > +} > + > +static void lp872x_deinit_dvs(struct lp872x *lp) > +{ > + ? ? ? if (lp->dvs_gpio) > + ? ? ? ? ? ? ? gpio_free(lp->dvs_gpio); > +} If you are using devm_gpio_request in lp872x_init_dvs() , you can just kill lp872x_deinit_dvs() function. > +static struct regulator_init_data > +*lp872x_find_regulator_init_data(int idx, struct lp872x *lp) > +{ > + ? ? ? int i; > + ? ? ? int base = lp->chipid == LP8725 ? LP8725_ID_BASE : 0; > + ? ? ? int id = idx + base; > + > + ? ? ? for (i = 0 ; i < LP872X_MAX_REGULATORS ; i++) > + ? ? ? ? ? ? ? if (lp->pdata->regulator_data[i].id == id) > + ? ? ? ? ? ? ? ? ? ? ? break; return lp->pdata->regulator_data[i].init_data; > + > + ? ? ? return (i == LP872X_MAX_REGULATORS) ? NULL : > + ? ? ? ? ? ? ? ? ? ? ? lp->pdata->regulator_data[i].init_data; return NULL; // seems better readability this way > +} > + > +module_i2c_driver(lp872x_driver); I think you need to use subsys_initcall() here. Regulators need to be available early in init in order to allow them to be available for consumers when requested. -- 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/