@@ -1399,7 +1399,9 @@ static irqreturn_t bd7181x_int_11_interrupt(int irq, void *pwrsys)
13991399static int bd7181x_charger_get_property (struct power_supply * psy ,
14001400 enum power_supply_property psp , union power_supply_propval * val )
14011401{
1402- struct bd7181x_power * pwr = dev_get_drvdata (psy -> dev .parent );
1402+ //struct bd7181x_power *pwr = dev_get_drvdata(psy->dev.parent);
1403+ //struct bd7181x_power *pwr = dev_get_drvdata(&psy->dev);
1404+ struct bd7181x_power * pwr = container_of (psy -> desc , struct bd7181x_power , ac );
14031405 u32 vot ;
14041406
14051407 switch (psp ) {
@@ -1428,7 +1430,9 @@ static int bd7181x_charger_get_property(struct power_supply *psy,
14281430static int bd7181x_battery_get_property (struct power_supply * psy ,
14291431 enum power_supply_property psp , union power_supply_propval * val )
14301432{
1431- struct bd7181x_power * pwr = dev_get_drvdata (psy -> dev .parent );
1433+ // struct bd7181x_power *pwr = dev_get_drvdata(psy->dev.parent);
1434+ //struct bd7181x_power *pwr = dev_get_drvdata(&psy->dev);
1435+ struct bd7181x_power * pwr = container_of (psy -> desc , struct bd7181x_power , bat );
14321436 // u32 cap, vot, r;
14331437 // u8 ret;
14341438
@@ -1964,11 +1968,25 @@ static char *bd7181x_ac_supplied_to[] = {
19641968 */
19651969static int bd7181x_power_probe (struct platform_device * pdev )
19661970{
1967- struct bd7181x * bd7181x = dev_get_drvdata ( pdev -> dev . parent ) ;
1971+ struct bd7181x * bd7181x ;
19681972 struct bd7181x_power * pwr ;
1969- struct power_supply_config ac_cfg ;
1973+ struct power_supply_config ac_cfg = { 0 } ;
19701974 int irq , ret , reg ;
19711975
1976+ if ( bd7181x_revision_init () )
1977+ pr_err ("Failed to init revision\n" );
1978+
1979+ if (!pdev -> dev .parent ) {
1980+ pr_err ("No parent\n" );
1981+ return - ENODEV ;
1982+ }
1983+ bd7181x = dev_get_drvdata (pdev -> dev .parent );
1984+
1985+ if (!bd7181x ) {
1986+ pr_err ("No parent drvdata\n" );
1987+ return - ENODEV ;
1988+ }
1989+
19721990 pwr = kzalloc (sizeof (* pwr ), GFP_KERNEL );
19731991 if (pwr == NULL )
19741992 return - ENOMEM ;
@@ -1983,6 +2001,7 @@ static int bd7181x_power_probe(struct platform_device *pdev)
19832001
19842002 pwr -> dev = & pdev -> dev ;
19852003 pwr -> mfd = bd7181x ;
2004+ if (!bd7181x )
19862005
19872006 platform_set_drvdata (pdev , pwr );
19882007
@@ -2157,28 +2176,30 @@ static struct platform_driver bd7181x_power_driver = {
21572176 .name = "bd7181x-power" ,
21582177 .owner = THIS_MODULE ,
21592178 },
2160- .remove = __exit_p (bd7181x_power_remove ),
2179+ .remove = bd7181x_power_remove ,
2180+ .probe = bd7181x_power_probe ,
21612181};
21622182
21632183/** @brief module initialize function */
2164- static int bd7181x_power_init (void )
2184+ /* static int bd7181x_power_init(void)
21652185{
21662186 int r;
21672187 r = bd7181x_revision_init();
21682188 if(r)
21692189 return r;
2170- return platform_driver_probe (& bd7181x_power_driver , bd7181x_power_probe );
2190+ return platform_driver_ (&bd7181x_power_driver, bd7181x_power_probe);
21712191}
2172-
2173- module_init (bd7181x_power_init );
2192+ */
2193+ //module_init(bd7181x_power_init);
2194+ module_platform_driver (bd7181x_power_driver );
21742195
21752196/** @brief module deinitialize function */
2176- static void bd7181x_power_exit (void )
2197+ /* static void bd7181x_power_exit(void)
21772198{
21782199 platform_driver_unregister(&bd7181x_power_driver);
21792200}
2180-
2181- module_exit (bd7181x_power_exit );
2201+ */
2202+ // module_exit(bd7181x_power_exit);
21822203
21832204module_param (battery_cycle , uint , S_IWUSR | S_IRUGO );
21842205MODULE_PARM_DESC (battery_parameters , "battery_cycle:battery charge/discharge cycles" );
0 commit comments