mfd: tps65912: Convert to managed resources for allocating memory
Subsystems (5)
PATCH 1/16 mfd: tps65912: Convert to managed resources for allocating memory
Saves on code and simplifies the driver, as these resources are now tracked and freed automatically when the driver is realised.
--- drivers/mfd/tps65912-core.c | 2 -- drivers/mfd/tps65912-i2c.c | 3 ++- drivers/mfd/tps65912-spi.c | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/mfd/tps65912-core.c +0 -2
@@ -161,7 +161,6 @@ int tps65912_device_init(struct tps65912 *tps65912) err:mfd_remove_devices (tps65912->dev); -kfree (tps65912);return ret; }
@@ -169,7 +168,6 @@ void tps65912_device_exit(struct tps65912 *tps65912) {mfd_remove_devices (tps65912->dev);tps65912_irq_exit (tps65912); -kfree (tps65912); }MODULE_AUTHOR ("Margarita Olaya <[email protected]>" );
drivers/mfd/tps65912-i2c.c +2 -1
@@ -77,7 +77,8 @@ static int tps65912_i2c_probe(struct i2c_client *i2c, {struct tps65912 *tps65912; - tps65912 =kzalloc (sizeof (struct tps65912 ),GFP_KERNEL ); + tps65912 =devm_kzalloc (&i2c->dev, +sizeof (struct tps65912 ),GFP_KERNEL );if (tps65912 ==NULL )return -ENOMEM ;
drivers/mfd/tps65912-spi.c +2 -1
@@ -85,7 +85,8 @@ static int tps65912_spi_probe(struct spi_device *spi) {struct tps65912 *tps65912; - tps65912 =kzalloc (sizeof (struct tps65912 ),GFP_KERNEL ); + tps65912 =devm_kzalloc (&spi->dev, +sizeof (struct tps65912 ),GFP_KERNEL );if (tps65912 ==NULL )return -ENOMEM ;
Signature · 1 line
1.7.10.4
PATCH 2/16 mfd: 88pm860x: Convert to managed resources for allocating memory
--- drivers/mfd/88pm860x-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/mfd/88pm860x-core.c +2 -3
@@ -1150,7 +1150,8 @@ static int pm860x_probe(struct i2c_client *client,return -EINVAL ; } - chip =kzalloc (sizeof (struct pm860x_chip ),GFP_KERNEL ); + chip =devm_kzalloc (&client->dev, +sizeof (struct pm860x_chip ),GFP_KERNEL );if (chip ==NULL )return -ENOMEM ;
@@ -1160,7 +1161,6 @@ static int pm860x_probe(struct i2c_client *client, ret =PTR_ERR (chip->regmap);dev_err (&client->dev,"Failed to allocate register map: %d\n" , ret); -kfree (chip);return ret; } chip->client = client;
@@ -1204,7 +1204,6 @@ static int pm860x_remove(struct i2c_client *client)i2c_unregister_device (chip->companion); }regmap_exit (chip->regmap); -kfree (chip);return 0 ; }
Signature · 1 line
1.7.10.4
PATCH 3/16 mfd: ab3100-otp: Convert to managed resources for allocating memory
In reply to Lee Jones--- drivers/mfd/ab3100-otp.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/mfd/ab3100-otp.c +5 -9
@@ -187,7 +187,7 @@ static int __init ab3100_otp_probe(struct platform_device *pdev)int err =0 ;int i; - otp =kzalloc (sizeof (struct ab3100_otp ),GFP_KERNEL ); + otp =devm_kzalloc (&pdev->dev,sizeof (struct ab3100_otp ),GFP_KERNEL );if (!otp) {dev_err (&pdev->dev,"could not allocate AB3100 OTP device\n" );return -ENOMEM ;
@@ -199,7 +199,7 @@ static int __init ab3100_otp_probe(struct platform_device *pdev) err =ab3100_otp_read (otp);if (err) - goto err_otp_read; +return err;dev_info (&pdev->dev,"AB3100 OTP readout registered\n" );
@@ -208,22 +208,19 @@ static int __init ab3100_otp_probe(struct platform_device *pdev) err =device_create_file (&pdev->dev, &ab3100_otp_attrs[i]);if (err) - goto err_create_file; + goto err; }/* debugfs entries */ err =ab3100_otp_init_debugfs (&pdev->dev, otp);if (err) - goto err_init_debugfs; + goto err;return 0 ; -err_init_debugfs: -err_create_file: +err:while (--i >=0 )device_remove_file (&pdev->dev, &ab3100_otp_attrs[i]); -err_otp_read: -kfree (otp);return err; }
@@ -236,7 +233,6 @@ static int __exit ab3100_otp_remove(struct platform_device *pdev)device_remove_file (&pdev->dev, &ab3100_otp_attrs[i]);ab3100_otp_exit_debugfs (otp); -kfree (otp);return 0 ; }
Signature · 1 line
1.7.10.4
PATCH 4/16 mfd: ab8500-debug: Convert to managed resources for allocating memory
In reply to Lee Jones--- drivers/mfd/ab8500-debugfs.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-)
drivers/mfd/ab8500-debugfs.c +12 -22
@@ -2937,7 +2937,6 @@ static struct dentry *ab8500_gpadc_dir;static int ab8500_debug_probe (struct platform_device *plf) {struct dentry *file; -int ret = -ENOMEM ;struct ab8500 *ab8500;struct resource *res; debug_bank =AB8500_MISC ;
@@ -2946,24 +2945,26 @@ static int ab8500_debug_probe(struct platform_device *plf) ab8500 =dev_get_drvdata (plf->dev.parent); num_irqs = ab8500->mask_size; - irq_count =kzalloc (sizeof (*irq_count)*num_irqs,GFP_KERNEL ); + irq_count =devm_kzalloc (&plf->dev, +sizeof (*irq_count)*num_irqs,GFP_KERNEL );if (!irq_count)return -ENOMEM ; - dev_attr =kzalloc (sizeof (*dev_attr)*num_irqs,GFP_KERNEL ); + dev_attr =devm_kzalloc (&plf->dev, +sizeof (*dev_attr)*num_irqs,GFP_KERNEL );if (!dev_attr) - goto out_freeirq_count; +return -ENOMEM ; - event_name =kzalloc (sizeof (*event_name)*num_irqs,GFP_KERNEL ); + event_name =devm_kzalloc (&plf->dev, +sizeof (*event_name)*num_irqs,GFP_KERNEL );if (!event_name) - goto out_freedev_attr; +return -ENOMEM ; res =platform_get_resource_byname (plf,0 ,"IRQ_AB8500" );if (!res) {dev_err (&plf->dev,"AB8500 irq not found, err %d\n" , irq_first); - ret = -ENXIO ; - goto out_freeevent_name; +return ENXIO ; } irq_ab8500 = res->start;
@@ -2971,16 +2972,14 @@ static int ab8500_debug_probe(struct platform_device *plf)if (irq_first <0 ) {dev_err (&plf->dev,"First irq not found, err %d\n" , irq_first); - ret = irq_first; - goto out_freeevent_name; +return irq_first; } irq_last =platform_get_irq_byname (plf,"IRQ_LAST" );if (irq_last <0 ) {dev_err (&plf->dev,"Last irq not found, err %d\n" , irq_last); - ret = irq_last; - goto out_freeevent_name; +return irq_last; } ab8500_dir =debugfs_create_dir (AB8500_NAME_STRING ,NULL );
@@ -3189,22 +3188,13 @@ err:if (ab8500_dir)debugfs_remove_recursive (ab8500_dir);dev_err (&plf->dev,"failed to create debugfs entries.\n" ); -out_freeevent_name: -kfree (event_name); -out_freedev_attr: -kfree (dev_attr); -out_freeirq_count: -kfree (irq_count); -return ret; +return -ENOMEM ; }static int ab8500_debug_remove (struct platform_device *plf) {debugfs_remove_recursive (ab8500_dir); -kfree (event_name); -kfree (dev_attr); -kfree (irq_count);return 0 ; }
Signature · 1 line
1.7.10.4
PATCH 5/16 mfd: ab8500-gpadc: Convert to managed resources for allocating memory
In reply to Lee Jones--- drivers/mfd/ab8500-gpadc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/mfd/ab8500-gpadc.c +1 -5
@@ -925,7 +925,7 @@ static int ab8500_gpadc_probe(struct platform_device *pdev)int ret =0 ;struct ab8500_gpadc *gpadc; - gpadc =kzalloc (sizeof (struct ab8500_gpadc ),GFP_KERNEL ); + gpadc =devm_kzalloc (&pdev->dev,sizeof (struct ab8500_gpadc ),GFP_KERNEL );if (!gpadc) {dev_err (&pdev->dev,"Error: No memory\n" );return -ENOMEM ;
@@ -1005,8 +1005,6 @@ fail_irq:free_irq (gpadc->irq_sw, gpadc);free_irq (gpadc->irq_hw, gpadc); fail: -kfree (gpadc); - gpadc =NULL ;return ret; }
@@ -1031,8 +1029,6 @@ static int ab8500_gpadc_remove(struct platform_device *pdev)pm_runtime_put_noidle (gpadc->dev); -kfree (gpadc); - gpadc =NULL ;return 0 ; }
Signature · 1 line
1.7.10.4
PATCH 6/16 mfd: abx500-core: Convert to managed resources for allocating memory
In reply to Lee Jones--- drivers/mfd/abx500-core.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/mfd/abx500-core.c +4 -6
@@ -36,7 +36,9 @@ int abx500_register_ops(struct device *dev, struct abx500_ops *ops) {struct abx500_device_entry *dev_entry; - dev_entry =kzalloc (sizeof (struct abx500_device_entry ),GFP_KERNEL ); + dev_entry =devm_kzalloc (dev, +sizeof (struct abx500_device_entry ), +GFP_KERNEL );if (!dev_entry) {dev_err (dev,"register_ops kzalloc failed" );return -ENOMEM ;
@@ -54,12 +56,8 @@ void abx500_remove_ops(struct device *dev)struct abx500_device_entry *dev_entry, *tmp;list_for_each_entry_safe (dev_entry, tmp, &abx500_list, list) - { -if (dev_entry->dev == dev) { +if (dev_entry->dev == dev)list_del (&dev_entry->list); -kfree (dev_entry); - } - } }EXPORT_SYMBOL (abx500_remove_ops);
Signature · 1 line
1.7.10.4
PATCH 7/16 mfd: adp5520: Convert to managed resources for allocating memory
In reply to Lee Jones--- drivers/mfd/adp5520.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/mfd/adp5520.c +2 -6
@@ -223,7 +223,7 @@ static int adp5520_probe(struct i2c_client *client,return -ENODEV ; } - chip =kzalloc (sizeof (*chip),GFP_KERNEL ); + chip =devm_kzalloc (&client->dev,sizeof (*chip),GFP_KERNEL );if (!chip)return -ENOMEM ;
@@ -244,7 +244,7 @@ static int adp5520_probe(struct i2c_client *client,if (ret) {dev_err (&client->dev,"failed to request irq %d\n" , chip->irq); - goto out_free_chip; +return ret; } }
@@ -302,9 +302,6 @@ out_free_irq:if (chip->irq)free_irq (chip->irq, chip); -out_free_chip: -kfree (chip); -return ret; }
@@ -317,7 +314,6 @@ static int adp5520_remove(struct i2c_client *client)adp5520_remove_subdevs (chip);adp5520_write (chip->dev,ADP5520_MODE_STATUS ,0 ); -kfree (chip);return 0 ; }
Signature · 1 line
1.7.10.4
PATCH 8/16 mfd: asic3: Convert to managed resources for allocating memory
In reply to Lee Jones--- drivers/mfd/asic3.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/mfd/asic3.c +4 -10
@@ -958,7 +958,8 @@ static int __init asic3_probe(struct platform_device *pdev)unsigned long clksel;int ret =0 ; - asic =kzalloc (sizeof (struct asic3 ),GFP_KERNEL ); + asic =devm_kzalloc (&pdev->dev, +sizeof (struct asic3 ),GFP_KERNEL );if (asic ==NULL ) {printk (KERN_ERR "kzalloc failed\n" );return -ENOMEM ;
@@ -970,16 +971,14 @@ static int __init asic3_probe(struct platform_device *pdev) mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!mem) { - ret = -ENOMEM ;dev_err (asic->dev,"no MEM resource\n" ); - goto out_free; +return -ENOMEM ; } asic->mapping =ioremap (mem->start,resource_size (mem));if (!asic->mapping) { - ret = -ENOMEM ;dev_err (asic->dev,"Couldn't ioremap\n" ); - goto out_free; +return -ENOMEM ; } asic->irq_base = pdata->irq_base;
@@ -1033,9 +1032,6 @@ static int __init asic3_probe(struct platform_device *pdev) out_unmap:iounmap (asic->mapping); - out_free: -kfree (asic); -return ret; }
@@ -1058,8 +1054,6 @@ static int asic3_remove(struct platform_device *pdev)iounmap (asic->mapping); -kfree (asic); -return 0 ; }
Signature · 1 line
1.7.10.4
PATCH 9/16 mfd: cros_ec: Convert to managed resources for allocating memory
In reply to Lee Jones--- drivers/mfd/cros_ec.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)
drivers/mfd/cros_ec.c +9 -19
@@ -104,23 +104,19 @@ int cros_ec_register(struct cros_ec_device *ec_dev) ec_dev->command_sendrecv = cros_ec_command_sendrecv;if (ec_dev->din_size) { - ec_dev->din =kmalloc (ec_dev->din_size,GFP_KERNEL ); -if (!ec_dev->din) { - err = -ENOMEM ; - goto fail_din; - } + ec_dev->din =devm_kzalloc (dev, ec_dev->din_size,GFP_KERNEL ); +if (!ec_dev->din) +return -ENOMEM ; }if (ec_dev->dout_size) { - ec_dev->dout =kmalloc (ec_dev->dout_size,GFP_KERNEL ); -if (!ec_dev->dout) { - err = -ENOMEM ; - goto fail_dout; - } + ec_dev->dout =devm_kzalloc (dev, ec_dev->dout_size,GFP_KERNEL ); +if (!ec_dev->dout) +return -ENOMEM ; }if (!ec_dev->irq) {dev_dbg (dev,"no valid IRQ: %d\n" , ec_dev->irq); - goto fail_irq; +return err; } err = request_threaded_irq(ec_dev->irq, NULL, ec_irq_thread,
@@ -128,7 +124,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev) "chromeos-ec", ec_dev);if (err) {dev_err (dev,"request irq %d: error %d\n" , ec_dev->irq, err); - goto fail_irq; +return err; } err = mfd_add_devices(dev, 0, cros_devs,
@@ -145,11 +141,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev) fail_mfd:free_irq (ec_dev->irq, ec_dev); -fail_irq: -kfree (ec_dev->dout); -fail_dout: -kfree (ec_dev->din); -fail_din: +return err; }EXPORT_SYMBOL (cros_ec_register);
@@ -158,8 +150,6 @@ int cros_ec_remove(struct cros_ec_device *ec_dev) {mfd_remove_devices (ec_dev->dev);free_irq (ec_dev->irq, ec_dev); -kfree (ec_dev->dout); -kfree (ec_dev->din);return 0 ; }
Signature · 1 line
1.7.10.4
PATCH 10/16 mfd: davinci_voicecodec: Convert to managed resources for allocating memory
In reply to Lee Jones--- drivers/mfd/davinci_voicecodec.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/mfd/davinci_voicecodec.c +3 -7
@@ -50,7 +50,8 @@ static int __init davinci_vc_probe(struct platform_device *pdev)struct mfd_cell *cell =NULL ;int ret; - davinci_vc =kzalloc (sizeof (struct davinci_vc ),GFP_KERNEL ); + davinci_vc =devm_kzalloc (&pdev->dev, +sizeof (struct davinci_vc ),GFP_KERNEL );if (!davinci_vc) {dev_dbg (&pdev->dev,"could not allocate memory for private data\n" );
@@ -61,8 +62,7 @@ static int __init davinci_vc_probe(struct platform_device *pdev)if (IS_ERR (davinci_vc->clk)) {dev_dbg (&pdev->dev,"could not get the clock for voice codec\n" ); - ret = -ENODEV ; - goto fail1; +return -ENODEV ; }clk_enable (davinci_vc->clk);
@@ -145,8 +145,6 @@ fail2:clk_disable (davinci_vc->clk);clk_put (davinci_vc->clk); davinci_vc->clk =NULL ; -fail1: -kfree (davinci_vc);return ret; }
@@ -164,8 +162,6 @@ static int davinci_vc_remove(struct platform_device *pdev)clk_put (davinci_vc->clk); davinci_vc->clk =NULL ; -kfree (davinci_vc); -return 0 ; }
Signature · 1 line
1.7.10.4
PATCH 11/16 mfd: htc-egpio: Convert to managed resources for allocating memory
In reply to Lee Jones--- drivers/mfd/htc-egpio.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/mfd/htc-egpio.c +4 -5
@@ -270,7 +270,7 @@ static int __init egpio_probe(struct platform_device *pdev)int ret;/* Initialize ei data structure. */ - ei =kzalloc (sizeof (*ei),GFP_KERNEL ); + ei =devm_kzalloc (&pdev->dev,sizeof (*ei),GFP_KERNEL );if (!ei)return -ENOMEM ;
@@ -306,7 +306,9 @@ static int __init egpio_probe(struct platform_device *pdev)platform_set_drvdata (pdev, ei); ei->nchips = pdata->num_chips; - ei->chip =kzalloc (sizeof (struct egpio_chip ) * ei->nchips,GFP_KERNEL ); + ei->chip =devm_kzalloc (&pdev->dev, +sizeof (struct egpio_chip ) * ei->nchips, +GFP_KERNEL );if (!ei->chip) { ret = -ENOMEM ; goto fail;
@@ -361,7 +363,6 @@ static int __init egpio_probe(struct platform_device *pdev) fail:printk (KERN_ERR "EGPIO failed to setup\n" ); -kfree (ei);return ret; }
@@ -380,8 +381,6 @@ static int __exit egpio_remove(struct platform_device *pdev)device_init_wakeup (&pdev->dev,0 ); }iounmap (ei->base_addr); -kfree (ei->chip); -kfree (ei);return 0 ; }
Signature · 1 line
1.7.10.4
PATCH 12/16 mfd: htc-i2cpld: Convert to managed resources for allocating memory
In reply to Lee Jones--- drivers/mfd/htc-i2cpld.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/mfd/htc-i2cpld.c +5 -10
@@ -514,8 +514,8 @@ static int htcpld_setup_chips(struct platform_device *pdev)/* Setup each chip's output GPIOs */ htcpld->nchips = pdata->num_chip; - htcpld->chip =kzalloc (sizeof (struct htcpld_chip ) * htcpld->nchips, -GFP_KERNEL ); + htcpld->chip =devm_kzalloc (dev,sizeof (struct htcpld_chip ) * htcpld->nchips, +GFP_KERNEL );if (!htcpld->chip) {dev_warn (dev,"Unable to allocate memory for chips\n" );return -ENOMEM ;
@@ -580,12 +580,11 @@ static int htcpld_core_probe(struct platform_device *pdev)return -ENXIO ; } - htcpld =kzalloc (sizeof (struct htcpld_data ),GFP_KERNEL ); + htcpld =devm_kzalloc (dev,sizeof (struct htcpld_data ),GFP_KERNEL );if (!htcpld)return -ENOMEM ;/* Find chained irq */ - ret = -EINVAL ; res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 );if (res) {int flags;
@@ -598,7 +597,7 @@ static int htcpld_core_probe(struct platform_device *pdev) flags, pdev->name, htcpld);if (ret) {dev_warn (dev,"Unable to setup chained irq handler: %d\n" , ret); - goto fail; +return ret; }else device_init_wakeup (dev,0 ); }
@@ -609,7 +608,7 @@ static int htcpld_core_probe(struct platform_device *pdev)/* Setup the htcpld chips */ ret =htcpld_setup_chips (pdev);if (ret) - goto fail; +return ret;/* Request the GPIO(s) for the int reset and set them up */ if (pdata->int_reset_gpio_hi) {
@@ -644,10 +643,6 @@ static int htcpld_core_probe(struct platform_device *pdev)dev_info (dev,"Initialized successfully\n" );return 0 ; - -fail: -kfree (htcpld); -return ret; }/* The I2C Driver -- used internally */
Signature · 1 line
1.7.10.4
PATCH 13/16 mfd: htc-pasic3: Convert to managed resources for allocating memory
In reply to Lee Jones--- drivers/mfd/htc-pasic3.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mfd/htc-pasic3.c +1 -3
@@ -147,7 +147,7 @@ static int __init pasic3_probe(struct platform_device *pdev)if (!request_mem_region (r->start,resource_size (r),"pasic3" ))return -EBUSY ; - asic =kzalloc (sizeof (struct pasic3_data ),GFP_KERNEL ); + asic =devm_kzalloc (dev,sizeof (struct pasic3_data ),GFP_KERNEL );if (!asic)return -ENOMEM ;
@@ -156,7 +156,6 @@ static int __init pasic3_probe(struct platform_device *pdev) asic->mapping =ioremap (r->start,resource_size (r));if (!asic->mapping) {dev_err (dev,"couldn't ioremap PASIC3\n" ); -kfree (asic);return -ENOMEM ; }
@@ -195,7 +194,6 @@ static int pasic3_remove(struct platform_device *pdev)iounmap (asic->mapping); r =platform_get_resource (pdev,IORESOURCE_MEM ,0 );release_mem_region (r->start,resource_size (r)); -kfree (asic);return 0 ; }
Signature · 1 line
1.7.10.4
PATCH 14/16 mfd: janz-cmodio: Convert to managed resources for allocating memory
In reply to Lee Jones--- drivers/mfd/janz-cmodio.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/mfd/janz-cmodio.c +4 -8
@@ -183,11 +183,10 @@ static int cmodio_pci_probe(struct pci_dev *dev,struct cmodio_device *priv;int ret; - priv =kzalloc (sizeof (*priv),GFP_KERNEL ); + priv =devm_kzalloc (&dev->dev,sizeof (*priv),GFP_KERNEL );if (!priv) {dev_err (&dev->dev,"unable to allocate private data\n" ); - ret = -ENOMEM ; - goto out_return; +return -ENOMEM ; }pci_set_drvdata (dev, priv);
@@ -197,7 +196,7 @@ static int cmodio_pci_probe(struct pci_dev *dev, ret =pci_enable_device (dev);if (ret) {dev_err (&dev->dev,"unable to enable device\n" ); - goto out_free_priv; +return ret; }pci_set_master (dev);
@@ -248,9 +247,7 @@ out_pci_release_regions:pci_release_regions (dev); out_pci_disable_device:pci_disable_device (dev); -out_free_priv: -kfree (priv); -out_return: +return ret; }
@@ -263,7 +260,6 @@ static void cmodio_pci_remove(struct pci_dev *dev)iounmap (priv->ctrl);pci_release_regions (dev);pci_disable_device (dev); -kfree (priv); }#define PCI_VENDOR_ID_JANZ 0x13c3
Signature · 1 line
1.7.10.4
PATCH 15/16 mfd: max77686: Convert to managed resources for allocating memory
In reply to Lee Jones--- drivers/mfd/max77686.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-)
drivers/mfd/max77686.c +8 -17
@@ -84,12 +84,12 @@ static int max77686_i2c_probe(struct i2c_client *i2c, pdata =max77686_i2c_parse_dt_pdata (&i2c->dev);if (!pdata) { - ret = -EIO ;dev_err (&i2c->dev,"No platform data found.\n" ); - goto err; +return -EIO ; } - max77686 =kzalloc (sizeof (struct max77686_dev ),GFP_KERNEL ); + max77686 =devm_kzalloc (&i2c->dev, +sizeof (struct max77686_dev ),GFP_KERNEL );if (max77686 ==NULL )return -ENOMEM ;
@@ -107,7 +107,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c, ret =PTR_ERR (max77686->regmap);dev_err (max77686->dev,"Failed to allocate register map: %d\n" , ret); -kfree (max77686);return ret; }
@@ -115,8 +114,7 @@ static int max77686_i2c_probe(struct i2c_client *i2c, MAX77686_REG_DEVICE_ID, &data) < 0) {dev_err (max77686->dev,"device not found on this channel (this is not an error)\n" ); - ret = -ENODEV ; - goto err; +return -ENODEV ; } else dev_info(max77686->dev, "device found\n");
@@ -127,17 +125,11 @@ static int max77686_i2c_probe(struct i2c_client *i2c, ret =mfd_add_devices (max77686->dev,-1 , max77686_devs,ARRAY_SIZE (max77686_devs),NULL ,0 ,NULL ); +if (ret <0 ) { +mfd_remove_devices (max77686->dev); +i2c_unregister_device (max77686->rtc); + } -if (ret <0 ) - goto err_mfd; - -return ret; - -err_mfd: -mfd_remove_devices (max77686->dev); -i2c_unregister_device (max77686->rtc); -err: -kfree (max77686);return ret; }
@@ -147,7 +139,6 @@ static int max77686_i2c_remove(struct i2c_client *i2c)mfd_remove_devices (max77686->dev);i2c_unregister_device (max77686->rtc); -kfree (max77686);return 0 ; }
Signature · 1 line
1.7.10.4
PATCH 16/16 mfd: max8925: Convert to managed resources for allocating memory
In reply to Lee Jones--- drivers/mfd/max8925-i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mfd/max8925-i2c.c +2 -2
@@ -170,7 +170,8 @@ static int max8925_probe(struct i2c_client *client,return -EINVAL ; } - chip =kzalloc (sizeof (struct max8925_chip ),GFP_KERNEL ); + chip =devm_kzalloc (&client->dev, +sizeof (struct max8925_chip ),GFP_KERNEL );if (chip ==NULL )return -ENOMEM ; chip->i2c = client;
@@ -199,7 +200,6 @@ static int max8925_remove(struct i2c_client *client)max8925_device_exit (chip);i2c_unregister_device (chip->adc);i2c_unregister_device (chip->rtc); -kfree (chip);return 0 ; }
Signature · 1 line
1.7.10.4
Hi Lee,
Quoted 9 lines · Lee Jones
Saves on code and simplifies the driver, as these resources are now tracked and freed automatically when the driver is realised.
Signed-off-by Lee Jones <[email protected]>--- drivers/mfd/tps65912-core.c | 2 -- drivers/mfd/tps65912-i2c.c | 3 ++- drivers/mfd/tps65912-spi.c | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-)
All 16 patches applied to mfd-next, thanks.
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/