diff options
author | Paul Fertser <fercerpav@gmail.com> | 2009-10-17 04:47:35 +0400 |
---|---|---|
committer | Paul Fertser <fercerpav@gmail.com> | 2009-10-17 04:52:57 +0400 |
commit | 350d5560bb262e73e1f1c05bf488fea6750a52d6 (patch) | |
tree | 46a2abf96452b8c7abcb206dba8176e60083e23e | |
parent | 3daf677d5e8e4d6a89845952e0a503c4bd57e456 (diff) |
Fix memleak in pcf50633_client_dev_registe
Ported from 207ec43e8c5a54dfc82a0e65af5b8f2765e3cbb8
-rw-r--r-- | drivers/input/misc/pcf50606-input.c | 8 | ||||
-rw-r--r-- | drivers/mfd/pcf50606-adc.c | 5 | ||||
-rw-r--r-- | drivers/mfd/pcf50606-core.c | 4 | ||||
-rw-r--r-- | drivers/power/pcf50606-charger.c | 3 | ||||
-rw-r--r-- | drivers/rtc/rtc-pcf50606.c | 5 | ||||
-rw-r--r-- | drivers/watchdog/pcf50606_wdt.c | 9 | ||||
-rw-r--r-- | include/linux/mfd/pcf50606/core.h | 10 |
7 files changed, 14 insertions, 30 deletions
diff --git a/drivers/input/misc/pcf50606-input.c b/drivers/input/misc/pcf50606-input.c index 044438ed662..da78fb92fbc 100644 --- a/drivers/input/misc/pcf50606-input.c +++ b/drivers/input/misc/pcf50606-input.c @@ -63,11 +63,9 @@ pcf50606_input_irq(int irq, void *data) static int __devinit pcf50606_input_probe(struct platform_device *pdev) { struct pcf50606_input *input; - struct pcf50606_subdev_pdata *pdata = pdev->dev.platform_data; struct input_dev *input_dev; int ret; - input = kzalloc(sizeof(*input), GFP_KERNEL); if (!input) return -ENOMEM; @@ -79,7 +77,7 @@ static int __devinit pcf50606_input_probe(struct platform_device *pdev) } platform_set_drvdata(pdev, input); - input->pcf = pdata->pcf; + input->pcf = dev_to_pcf50606(pdev->dev.parent); input->input_dev = input_dev; input_dev->name = "PCF50606 PMU events"; @@ -93,9 +91,9 @@ static int __devinit pcf50606_input_probe(struct platform_device *pdev) kfree(input); return ret; } - pcf50606_register_irq(pdata->pcf, PCF50606_IRQ_ONKEYR, + pcf50606_register_irq(input->pcf, PCF50606_IRQ_ONKEYR, pcf50606_input_irq, input); - pcf50606_register_irq(pdata->pcf, PCF50606_IRQ_ONKEYF, + pcf50606_register_irq(input->pcf, PCF50606_IRQ_ONKEYF, pcf50606_input_irq, input); return 0; diff --git a/drivers/mfd/pcf50606-adc.c b/drivers/mfd/pcf50606-adc.c index 38f5b5c0593..47210a9cce8 100644 --- a/drivers/mfd/pcf50606-adc.c +++ b/drivers/mfd/pcf50606-adc.c @@ -211,17 +211,16 @@ static void pcf50606_adc_irq(int irq, void *data) static int __devinit pcf50606_adc_probe(struct platform_device *pdev) { - struct pcf50606_subdev_pdata *pdata = pdev->dev.platform_data; struct pcf50606_adc *adc; adc = kzalloc(sizeof(*adc), GFP_KERNEL); if (!adc) return -ENOMEM; - adc->pcf = pdata->pcf; + adc->pcf = dev_to_pcf50606(pdev->dev.parent); platform_set_drvdata(pdev, adc); - pcf50606_register_irq(pdata->pcf, PCF50606_IRQ_ADCRDY, + pcf50606_register_irq(adc->pcf, PCF50606_IRQ_ADCRDY, pcf50606_adc_irq, adc); mutex_init(&adc->queue_mutex); diff --git a/drivers/mfd/pcf50606-core.c b/drivers/mfd/pcf50606-core.c index 355a7fc7476..a6ff522931d 100644 --- a/drivers/mfd/pcf50606-core.c +++ b/drivers/mfd/pcf50606-core.c @@ -436,7 +436,6 @@ static void pcf50606_client_dev_register(struct pcf50606 *pcf, const char *name, struct platform_device **pdev) { - struct pcf50606_subdev_pdata subdev_pdata; int ret; *pdev = platform_device_alloc(name, -1); @@ -445,9 +444,6 @@ pcf50606_client_dev_register(struct pcf50606 *pcf, const char *name, return; } - subdev_pdata.pcf = pcf; - platform_device_add_data(*pdev, &subdev_pdata, sizeof(subdev_pdata)); - (*pdev)->dev.parent = pcf->dev; ret = platform_device_add(*pdev); diff --git a/drivers/power/pcf50606-charger.c b/drivers/power/pcf50606-charger.c index a566fe3ed56..f90c5ed25b3 100644 --- a/drivers/power/pcf50606-charger.c +++ b/drivers/power/pcf50606-charger.c @@ -159,7 +159,6 @@ static const u8 mbc_irq_handlers[] = { static int __devinit pcf50606_mbc_probe(struct platform_device *pdev) { struct pcf50606_mbc *mbc; - struct pcf50606_subdev_pdata *pdata = pdev->dev.platform_data; int ret; int i; u8 oocs; @@ -169,7 +168,7 @@ static int __devinit pcf50606_mbc_probe(struct platform_device *pdev) return -ENOMEM; platform_set_drvdata(pdev, mbc); - mbc->pcf = pdata->pcf; + mbc->pcf = dev_to_pcf50606(pdev->dev.parent); /* Set up IRQ handlers */ for (i = 0; i < ARRAY_SIZE(mbc_irq_handlers); i++) diff --git a/drivers/rtc/rtc-pcf50606.c b/drivers/rtc/rtc-pcf50606.c index 6bd93b0b672..01ce1b9e48f 100644 --- a/drivers/rtc/rtc-pcf50606.c +++ b/drivers/rtc/rtc-pcf50606.c @@ -271,16 +271,13 @@ static void pcf50606_rtc_irq(int irq, void *data) static int __devinit pcf50606_rtc_probe(struct platform_device *pdev) { - struct pcf50606_subdev_pdata *pdata; struct pcf50606_rtc *rtc; - rtc = kzalloc(sizeof(*rtc), GFP_KERNEL); if (!rtc) return -ENOMEM; - pdata = pdev->dev.platform_data; - rtc->pcf = pdata->pcf; + rtc->pcf = dev_to_pcf50606(pdev->dev.parent); platform_set_drvdata(pdev, rtc); rtc->rtc_dev = rtc_device_register("pcf50606-rtc", &pdev->dev, &pcf50606_rtc_ops, THIS_MODULE); diff --git a/drivers/watchdog/pcf50606_wdt.c b/drivers/watchdog/pcf50606_wdt.c index f0858747bf9..6a53c664b21 100644 --- a/drivers/watchdog/pcf50606_wdt.c +++ b/drivers/watchdog/pcf50606_wdt.c @@ -158,7 +158,6 @@ static void pcf50606_wdt_irq(int irq, void *unused) int __init pcf50606_wdt_probe(struct platform_device *pdev) { - struct pcf50606_subdev_pdata *pdata; int err; if (pcf) { @@ -166,13 +165,7 @@ int __init pcf50606_wdt_probe(struct platform_device *pdev) return -ENODEV; } - pdata = pdev->dev.platform_data; - if (!pdata) { - dev_err(&pdev->dev, "No platform data available\n"); - return -EINVAL; - } - - pcf = pdata->pcf; + pcf = dev_to_pcf50606(pdev->dev.parent); err = misc_register(&pcf50606_wdt_miscdev); if (err) { diff --git a/include/linux/mfd/pcf50606/core.h b/include/linux/mfd/pcf50606/core.h index a51b1b548c2..e036e07064c 100644 --- a/include/linux/mfd/pcf50606/core.h +++ b/include/linux/mfd/pcf50606/core.h @@ -38,10 +38,6 @@ struct pcf50606_platform_data { u8 resumers[3]; }; -struct pcf50606_subdev_pdata { - struct pcf50606 *pcf; -}; - struct pcf50606_irq { void (*handler)(int, void *); void *data; @@ -166,5 +162,11 @@ enum pcf50606_reg_int3 { #define PCF50606_REG_OOCC1 0x08 #define PCF50606_OOCC1_GOSTDBY 0x01 + +static inline struct pcf50606 *dev_to_pcf50606(struct device *dev) +{ + return dev_get_drvdata(dev); +} + #endif |