All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH 92/95] hwmon: (smsc47m1) Convert to use devm_ functions
@ 2012-06-15 15:24 Guenter Roeck
  2012-06-17 20:57 ` Jean Delvare
  2012-06-18  2:07 ` Guenter Roeck
  0 siblings, 2 replies; 3+ messages in thread
From: Guenter Roeck @ 2012-06-15 15:24 UTC (permalink / raw)
  To: lm-sensors

Convert to use devm_ functions to reduce code size and simplify the code.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/smsc47m1.c |   40 ++++++++--------------------------------
 1 file changed, 8 insertions(+), 32 deletions(-)

diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index b5aa38d..b3a38af 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -584,13 +584,11 @@ static void smsc47m1_restore(const struct smsc47m1_sio_data *sio_data)
 
 #define CHECK		1
 #define REQUEST		2
-#define RELEASE		3
 
 /*
  * This function can be used to:
  *  - test for resource conflicts with ACPI
  *  - request the resources
- *  - release the resources
  * We only allocate the I/O ports we really need, to minimize the risk of
  * conflicts with ACPI or with other drivers.
  */
@@ -642,21 +640,13 @@ static int smsc47m1_handle_resources(unsigned short address, enum chips type,
 			break;
 		case REQUEST:
 			/* Request the resources */
-			if (!request_region(start, len, DRVNAME)) {
-				dev_err(dev, "Region 0x%hx-0x%hx already in "
-					"use!\n", start, start + len);
-
-				/* Undo all requests */
-				for (i -= 2; i >= 0; i -= 2)
-					release_region(address + ports[i],
-						       ports[i + 1]);
+			if (!devm_request_region(dev, start, len, DRVNAME)) {
+				dev_err(dev,
+					"Region 0x%hx-0x%hx already in use!\n",
+					start, start + len);
 				return -EBUSY;
 			}
 			break;
-		case RELEASE:
-			/* Release the resources */
-			release_region(start, len);
-			break;
 		}
 	}
 
@@ -694,11 +684,9 @@ static int __init smsc47m1_probe(struct platform_device *pdev)
 	if (err < 0)
 		return err;
 
-	data = kzalloc(sizeof(struct smsc47m1_data), GFP_KERNEL);
-	if (!data) {
-		err = -ENOMEM;
-		goto error_release;
-	}
+	data = devm_kzalloc(dev, sizeof(struct smsc47m1_data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
 
 	data->addr = res->start;
 	data->type = sio_data->type;
@@ -733,8 +721,7 @@ static int __init smsc47m1_probe(struct platform_device *pdev)
 	}
 	if (!(fan1 || fan2 || fan3 || pwm1 || pwm2 || pwm3)) {
 		dev_warn(dev, "Device not configured, will not use\n");
-		err = -ENODEV;
-		goto error_free;
+		return -ENODEV;
 	}
 
 	/*
@@ -810,27 +797,16 @@ static int __init smsc47m1_probe(struct platform_device *pdev)
 
 error_remove_files:
 	smsc47m1_remove_files(dev);
-error_free:
-	platform_set_drvdata(pdev, NULL);
-	kfree(data);
-error_release:
-	smsc47m1_handle_resources(res->start, sio_data->type, RELEASE, dev);
 	return err;
 }
 
 static int __exit smsc47m1_remove(struct platform_device *pdev)
 {
 	struct smsc47m1_data *data = platform_get_drvdata(pdev);
-	struct resource *res;
 
 	hwmon_device_unregister(data->hwmon_dev);
 	smsc47m1_remove_files(&pdev->dev);
 
-	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
-	smsc47m1_handle_resources(res->start, data->type, RELEASE, &pdev->dev);
-	platform_set_drvdata(pdev, NULL);
-	kfree(data);
-
 	return 0;
 }
 
-- 
1.7.9.7


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [lm-sensors] [PATCH 92/95] hwmon: (smsc47m1) Convert to use devm_ functions
  2012-06-15 15:24 [lm-sensors] [PATCH 92/95] hwmon: (smsc47m1) Convert to use devm_ functions Guenter Roeck
@ 2012-06-17 20:57 ` Jean Delvare
  2012-06-18  2:07 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Jean Delvare @ 2012-06-17 20:57 UTC (permalink / raw)
  To: lm-sensors

On Fri, 15 Jun 2012 08:24:13 -0700, Guenter Roeck wrote:
> Convert to use devm_ functions to reduce code size and simplify the code.
> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  drivers/hwmon/smsc47m1.c |   40 ++++++++--------------------------------
>  1 file changed, 8 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
> index b5aa38d..b3a38af 100644
> --- a/drivers/hwmon/smsc47m1.c
> +++ b/drivers/hwmon/smsc47m1.c
> @@ -584,13 +584,11 @@ static void smsc47m1_restore(const struct smsc47m1_sio_data *sio_data)
>  
>  #define CHECK		1
>  #define REQUEST		2
> -#define RELEASE		3
>  
>  /*
>   * This function can be used to:
>   *  - test for resource conflicts with ACPI
>   *  - request the resources
> - *  - release the resources
>   * We only allocate the I/O ports we really need, to minimize the risk of
>   * conflicts with ACPI or with other drivers.
>   */
> @@ -642,21 +640,13 @@ static int smsc47m1_handle_resources(unsigned short address, enum chips type,

This function can now be marked __init.

Other than this, I have no issue with the patch.

Acked-by: Jean Delvare <khali@linux-fr.org>

-- 
Jean Delvare

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [lm-sensors] [PATCH 92/95] hwmon: (smsc47m1) Convert to use devm_ functions
  2012-06-15 15:24 [lm-sensors] [PATCH 92/95] hwmon: (smsc47m1) Convert to use devm_ functions Guenter Roeck
  2012-06-17 20:57 ` Jean Delvare
@ 2012-06-18  2:07 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2012-06-18  2:07 UTC (permalink / raw)
  To: lm-sensors

On Sun, Jun 17, 2012 at 04:57:05PM -0400, Jean Delvare wrote:
> On Fri, 15 Jun 2012 08:24:13 -0700, Guenter Roeck wrote:
> > Convert to use devm_ functions to reduce code size and simplify the code.
> > 
> > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> > ---
> >  drivers/hwmon/smsc47m1.c |   40 ++++++++--------------------------------
> >  1 file changed, 8 insertions(+), 32 deletions(-)
> > 
> > diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
> > index b5aa38d..b3a38af 100644
> > --- a/drivers/hwmon/smsc47m1.c
> > +++ b/drivers/hwmon/smsc47m1.c
> > @@ -584,13 +584,11 @@ static void smsc47m1_restore(const struct smsc47m1_sio_data *sio_data)
> >  
> >  #define CHECK		1
> >  #define REQUEST		2
> > -#define RELEASE		3
> >  
> >  /*
> >   * This function can be used to:
> >   *  - test for resource conflicts with ACPI
> >   *  - request the resources
> > - *  - release the resources
> >   * We only allocate the I/O ports we really need, to minimize the risk of
> >   * conflicts with ACPI or with other drivers.
> >   */
> > @@ -642,21 +640,13 @@ static int smsc47m1_handle_resources(unsigned short address, enum chips type,
> 
> This function can now be marked __init.
> 
Done.

> Other than this, I have no issue with the patch.
> 
> Acked-by: Jean Delvare <khali@linux-fr.org>
> 
Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-18  2:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-15 15:24 [lm-sensors] [PATCH 92/95] hwmon: (smsc47m1) Convert to use devm_ functions Guenter Roeck
2012-06-17 20:57 ` Jean Delvare
2012-06-18  2:07 ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.