linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: Correct struct allocation style
@ 2019-06-27 11:56 Fabian Schindlatz
  2019-06-27 12:06 ` Guenter Roeck
  0 siblings, 1 reply; 4+ messages in thread
From: Fabian Schindlatz @ 2019-06-27 11:56 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck, Fenghua Yu, Rudolf Marek,
	linux-hwmon, linux-kernel
  Cc: Fabian Schindlatz, Thomas Röthenbacher, linux-kernel

Use sizeof(*var) instead of sizeof(struct var_type) as argument to
kalloc() and friends to comply with the kernel coding style.

Co-developed-by: Thomas Röthenbacher <thomas.roethenbacher@fau.de>
Signed-off-by: Thomas Röthenbacher <thomas.roethenbacher@fau.de>
Signed-off-by: Fabian Schindlatz <fabian.schindlatz@fau.de>
Cc: linux-kernel@i4.cs.fau.de
---
 drivers/hwmon/acpi_power_meter.c | 2 +-
 drivers/hwmon/coretemp.c         | 4 ++--
 drivers/hwmon/fschmd.c           | 2 +-
 drivers/hwmon/sch56xx-common.c   | 2 +-
 drivers/hwmon/via-cputemp.c      | 4 ++--
 drivers/hwmon/w83793.c           | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index 6ba1a08253f0..f20223e3579c 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -862,7 +862,7 @@ static int acpi_power_meter_add(struct acpi_device *device)
 	if (!device)
 		return -EINVAL;
 
-	resource = kzalloc(sizeof(struct acpi_power_meter_resource),
+	resource = kzalloc(sizeof(*resource),
 			   GFP_KERNEL);
 	if (!resource)
 		return -ENOMEM;
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index fe6618e49dc4..0361115d25dd 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -433,7 +433,7 @@ static struct temp_data *init_temp_data(unsigned int cpu, int pkg_flag)
 {
 	struct temp_data *tdata;
 
-	tdata = kzalloc(sizeof(struct temp_data), GFP_KERNEL);
+	tdata = kzalloc(sizeof(*tdata), GFP_KERNEL);
 	if (!tdata)
 		return NULL;
 
@@ -532,7 +532,7 @@ static int coretemp_probe(struct platform_device *pdev)
 	struct platform_data *pdata;
 
 	/* Initialize the per-zone data structures */
-	pdata = devm_kzalloc(dev, sizeof(struct platform_data), GFP_KERNEL);
+	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
 	if (!pdata)
 		return -ENOMEM;
 
diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c
index fa0c2f1fb443..d464dcbe5ac8 100644
--- a/drivers/hwmon/fschmd.c
+++ b/drivers/hwmon/fschmd.c
@@ -1090,7 +1090,7 @@ static int fschmd_probe(struct i2c_client *client,
 	int i, err;
 	enum chips kind = id->driver_data;
 
-	data = kzalloc(sizeof(struct fschmd_data), GFP_KERNEL);
+	data = kzalloc(sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
diff --git a/drivers/hwmon/sch56xx-common.c b/drivers/hwmon/sch56xx-common.c
index 6c84780e358e..0d6d20814183 100644
--- a/drivers/hwmon/sch56xx-common.c
+++ b/drivers/hwmon/sch56xx-common.c
@@ -401,7 +401,7 @@ struct sch56xx_watchdog_data *sch56xx_watchdog_register(struct device *parent,
 		return NULL;
 	}
 
-	data = kzalloc(sizeof(struct sch56xx_watchdog_data), GFP_KERNEL);
+	data = kzalloc(sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return NULL;
 
diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
index 8264e849e588..338b600716a5 100644
--- a/drivers/hwmon/via-cputemp.c
+++ b/drivers/hwmon/via-cputemp.c
@@ -114,7 +114,7 @@ static int via_cputemp_probe(struct platform_device *pdev)
 	int err;
 	u32 eax, edx;
 
-	data = devm_kzalloc(&pdev->dev, sizeof(struct via_cputemp_data),
+	data = devm_kzalloc(&pdev->dev, sizeof(*data),
 			    GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
@@ -223,7 +223,7 @@ static int via_cputemp_online(unsigned int cpu)
 		goto exit;
 	}
 
-	pdev_entry = kzalloc(sizeof(struct pdev_entry), GFP_KERNEL);
+	pdev_entry = kzalloc(sizeof(*pdev_entry), GFP_KERNEL);
 	if (!pdev_entry) {
 		err = -ENOMEM;
 		goto exit_device_put;
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index 46f5dfec8d0a..b37106c6f26d 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -1669,7 +1669,7 @@ static int w83793_probe(struct i2c_client *client,
 	int files_pwm = ARRAY_SIZE(w83793_left_pwm) / 5;
 	int files_temp = ARRAY_SIZE(w83793_temp) / 6;
 
-	data = kzalloc(sizeof(struct w83793_data), GFP_KERNEL);
+	data = kzalloc(sizeof(*data), GFP_KERNEL);
 	if (!data) {
 		err = -ENOMEM;
 		goto exit;
-- 
2.20.1


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

* Re: [PATCH] hwmon: Correct struct allocation style
  2019-06-27 11:56 [PATCH] hwmon: Correct struct allocation style Fabian Schindlatz
@ 2019-06-27 12:06 ` Guenter Roeck
  2019-06-27 15:27   ` [PATCH v2] " Fabian Schindlatz
  0 siblings, 1 reply; 4+ messages in thread
From: Guenter Roeck @ 2019-06-27 12:06 UTC (permalink / raw)
  To: Fabian Schindlatz, Jean Delvare, Fenghua Yu, Rudolf Marek,
	linux-hwmon, linux-kernel
  Cc: Thomas Röthenbacher, linux-kernel

On 6/27/19 4:56 AM, Fabian Schindlatz wrote:
> Use sizeof(*var) instead of sizeof(struct var_type) as argument to
> kalloc() and friends to comply with the kernel coding style.
> 
> Co-developed-by: Thomas Röthenbacher <thomas.roethenbacher@fau.de>
> Signed-off-by: Thomas Röthenbacher <thomas.roethenbacher@fau.de>
> Signed-off-by: Fabian Schindlatz <fabian.schindlatz@fau.de>
> Cc: linux-kernel@i4.cs.fau.de
> ---
>   drivers/hwmon/acpi_power_meter.c | 2 +-
>   drivers/hwmon/coretemp.c         | 4 ++--
>   drivers/hwmon/fschmd.c           | 2 +-
>   drivers/hwmon/sch56xx-common.c   | 2 +-
>   drivers/hwmon/via-cputemp.c      | 4 ++--
>   drivers/hwmon/w83793.c           | 2 +-
>   6 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
> index 6ba1a08253f0..f20223e3579c 100644
> --- a/drivers/hwmon/acpi_power_meter.c
> +++ b/drivers/hwmon/acpi_power_meter.c
> @@ -862,7 +862,7 @@ static int acpi_power_meter_add(struct acpi_device *device)
>   	if (!device)
>   		return -EINVAL;
>   
> -	resource = kzalloc(sizeof(struct acpi_power_meter_resource),
> +	resource = kzalloc(sizeof(*resource),
>   			   GFP_KERNEL);

Continuation line is no longer necessary.

>   	if (!resource)
>   		return -ENOMEM;
> diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
> index fe6618e49dc4..0361115d25dd 100644
> --- a/drivers/hwmon/coretemp.c
> +++ b/drivers/hwmon/coretemp.c
> @@ -433,7 +433,7 @@ static struct temp_data *init_temp_data(unsigned int cpu, int pkg_flag)
>   {
>   	struct temp_data *tdata;
>   
> -	tdata = kzalloc(sizeof(struct temp_data), GFP_KERNEL);
> +	tdata = kzalloc(sizeof(*tdata), GFP_KERNEL);
>   	if (!tdata)
>   		return NULL;
>   
> @@ -532,7 +532,7 @@ static int coretemp_probe(struct platform_device *pdev)
>   	struct platform_data *pdata;
>   
>   	/* Initialize the per-zone data structures */
> -	pdata = devm_kzalloc(dev, sizeof(struct platform_data), GFP_KERNEL);
> +	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
>   	if (!pdata)
>   		return -ENOMEM;
>   
> diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c
> index fa0c2f1fb443..d464dcbe5ac8 100644
> --- a/drivers/hwmon/fschmd.c
> +++ b/drivers/hwmon/fschmd.c
> @@ -1090,7 +1090,7 @@ static int fschmd_probe(struct i2c_client *client,
>   	int i, err;
>   	enum chips kind = id->driver_data;
>   
> -	data = kzalloc(sizeof(struct fschmd_data), GFP_KERNEL);
> +	data = kzalloc(sizeof(*data), GFP_KERNEL);
>   	if (!data)
>   		return -ENOMEM;
>   
> diff --git a/drivers/hwmon/sch56xx-common.c b/drivers/hwmon/sch56xx-common.c
> index 6c84780e358e..0d6d20814183 100644
> --- a/drivers/hwmon/sch56xx-common.c
> +++ b/drivers/hwmon/sch56xx-common.c
> @@ -401,7 +401,7 @@ struct sch56xx_watchdog_data *sch56xx_watchdog_register(struct device *parent,
>   		return NULL;
>   	}
>   
> -	data = kzalloc(sizeof(struct sch56xx_watchdog_data), GFP_KERNEL);
> +	data = kzalloc(sizeof(*data), GFP_KERNEL);
>   	if (!data)
>   		return NULL;
>   
> diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
> index 8264e849e588..338b600716a5 100644
> --- a/drivers/hwmon/via-cputemp.c
> +++ b/drivers/hwmon/via-cputemp.c
> @@ -114,7 +114,7 @@ static int via_cputemp_probe(struct platform_device *pdev)
>   	int err;
>   	u32 eax, edx;
>   
> -	data = devm_kzalloc(&pdev->dev, sizeof(struct via_cputemp_data),
> +	data = devm_kzalloc(&pdev->dev, sizeof(*data),
>   			    GFP_KERNEL);

Continuation line is no longer necessary.

>   	if (!data)
>   		return -ENOMEM;
> @@ -223,7 +223,7 @@ static int via_cputemp_online(unsigned int cpu)
>   		goto exit;
>   	}
>   
> -	pdev_entry = kzalloc(sizeof(struct pdev_entry), GFP_KERNEL);
> +	pdev_entry = kzalloc(sizeof(*pdev_entry), GFP_KERNEL);
>   	if (!pdev_entry) {
>   		err = -ENOMEM;
>   		goto exit_device_put;
> diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
> index 46f5dfec8d0a..b37106c6f26d 100644
> --- a/drivers/hwmon/w83793.c
> +++ b/drivers/hwmon/w83793.c
> @@ -1669,7 +1669,7 @@ static int w83793_probe(struct i2c_client *client,
>   	int files_pwm = ARRAY_SIZE(w83793_left_pwm) / 5;
>   	int files_temp = ARRAY_SIZE(w83793_temp) / 6;
>   
> -	data = kzalloc(sizeof(struct w83793_data), GFP_KERNEL);
> +	data = kzalloc(sizeof(*data), GFP_KERNEL);
>   	if (!data) {
>   		err = -ENOMEM;
>   		goto exit;
> 


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

* [PATCH v2] hwmon: Correct struct allocation style
  2019-06-27 12:06 ` Guenter Roeck
@ 2019-06-27 15:27   ` Fabian Schindlatz
  2019-06-28 13:28     ` Guenter Roeck
  0 siblings, 1 reply; 4+ messages in thread
From: Fabian Schindlatz @ 2019-06-27 15:27 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck, Fenghua Yu, Rudolf Marek,
	linux-hwmon, linux-kernel
  Cc: Fabian Schindlatz, Thomas Röthenbacher, linux-kernel

Use sizeof(*var) instead of sizeof(struct var_type) as argument to
kalloc() and friends to comply with the kernel coding style.

Co-developed-by: Thomas Röthenbacher <thomas.roethenbacher@fau.de>
Signed-off-by: Thomas Röthenbacher <thomas.roethenbacher@fau.de>
Signed-off-by: Fabian Schindlatz <fabian.schindlatz@fau.de>
Cc: linux-kernel@i4.cs.fau.de
---
 drivers/hwmon/acpi_power_meter.c | 3 +--
 drivers/hwmon/coretemp.c         | 4 ++--
 drivers/hwmon/fschmd.c           | 2 +-
 drivers/hwmon/sch56xx-common.c   | 2 +-
 drivers/hwmon/via-cputemp.c      | 5 ++---
 drivers/hwmon/w83793.c           | 2 +-
 6 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index 6ba1a08253f0..48c4570c61d7 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -862,8 +862,7 @@ static int acpi_power_meter_add(struct acpi_device *device)
 	if (!device)
 		return -EINVAL;
 
-	resource = kzalloc(sizeof(struct acpi_power_meter_resource),
-			   GFP_KERNEL);
+	resource = kzalloc(sizeof(*resource), GFP_KERNEL);
 	if (!resource)
 		return -ENOMEM;
 
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index fe6618e49dc4..0361115d25dd 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -433,7 +433,7 @@ static struct temp_data *init_temp_data(unsigned int cpu, int pkg_flag)
 {
 	struct temp_data *tdata;
 
-	tdata = kzalloc(sizeof(struct temp_data), GFP_KERNEL);
+	tdata = kzalloc(sizeof(*tdata), GFP_KERNEL);
 	if (!tdata)
 		return NULL;
 
@@ -532,7 +532,7 @@ static int coretemp_probe(struct platform_device *pdev)
 	struct platform_data *pdata;
 
 	/* Initialize the per-zone data structures */
-	pdata = devm_kzalloc(dev, sizeof(struct platform_data), GFP_KERNEL);
+	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
 	if (!pdata)
 		return -ENOMEM;
 
diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c
index fa0c2f1fb443..d464dcbe5ac8 100644
--- a/drivers/hwmon/fschmd.c
+++ b/drivers/hwmon/fschmd.c
@@ -1090,7 +1090,7 @@ static int fschmd_probe(struct i2c_client *client,
 	int i, err;
 	enum chips kind = id->driver_data;
 
-	data = kzalloc(sizeof(struct fschmd_data), GFP_KERNEL);
+	data = kzalloc(sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
diff --git a/drivers/hwmon/sch56xx-common.c b/drivers/hwmon/sch56xx-common.c
index 6c84780e358e..0d6d20814183 100644
--- a/drivers/hwmon/sch56xx-common.c
+++ b/drivers/hwmon/sch56xx-common.c
@@ -401,7 +401,7 @@ struct sch56xx_watchdog_data *sch56xx_watchdog_register(struct device *parent,
 		return NULL;
 	}
 
-	data = kzalloc(sizeof(struct sch56xx_watchdog_data), GFP_KERNEL);
+	data = kzalloc(sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return NULL;
 
diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
index 8264e849e588..0feb1d0b5e13 100644
--- a/drivers/hwmon/via-cputemp.c
+++ b/drivers/hwmon/via-cputemp.c
@@ -114,8 +114,7 @@ static int via_cputemp_probe(struct platform_device *pdev)
 	int err;
 	u32 eax, edx;
 
-	data = devm_kzalloc(&pdev->dev, sizeof(struct via_cputemp_data),
-			    GFP_KERNEL);
+	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
@@ -223,7 +222,7 @@ static int via_cputemp_online(unsigned int cpu)
 		goto exit;
 	}
 
-	pdev_entry = kzalloc(sizeof(struct pdev_entry), GFP_KERNEL);
+	pdev_entry = kzalloc(sizeof(*pdev_entry), GFP_KERNEL);
 	if (!pdev_entry) {
 		err = -ENOMEM;
 		goto exit_device_put;
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index 46f5dfec8d0a..b37106c6f26d 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -1669,7 +1669,7 @@ static int w83793_probe(struct i2c_client *client,
 	int files_pwm = ARRAY_SIZE(w83793_left_pwm) / 5;
 	int files_temp = ARRAY_SIZE(w83793_temp) / 6;
 
-	data = kzalloc(sizeof(struct w83793_data), GFP_KERNEL);
+	data = kzalloc(sizeof(*data), GFP_KERNEL);
 	if (!data) {
 		err = -ENOMEM;
 		goto exit;
-- 
2.20.1


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

* Re: [PATCH v2] hwmon: Correct struct allocation style
  2019-06-27 15:27   ` [PATCH v2] " Fabian Schindlatz
@ 2019-06-28 13:28     ` Guenter Roeck
  0 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2019-06-28 13:28 UTC (permalink / raw)
  To: Fabian Schindlatz
  Cc: Jean Delvare, Fenghua Yu, Rudolf Marek, linux-hwmon,
	linux-kernel, Thomas Röthenbacher, linux-kernel

On Thu, Jun 27, 2019 at 05:27:38PM +0200, Fabian Schindlatz wrote:
> Use sizeof(*var) instead of sizeof(struct var_type) as argument to
> kalloc() and friends to comply with the kernel coding style.
> 
> Co-developed-by: Thomas Röthenbacher <thomas.roethenbacher@fau.de>
> Signed-off-by: Thomas Röthenbacher <thomas.roethenbacher@fau.de>
> Signed-off-by: Fabian Schindlatz <fabian.schindlatz@fau.de>
> Cc: linux-kernel@i4.cs.fau.de

Applied to hwmon-next. Note that it is in general much easier for me
if such patches are applied against mainline (or hwmon-next), not
against linux-next.

Guenter

> ---
>  drivers/hwmon/acpi_power_meter.c | 3 +--
>  drivers/hwmon/coretemp.c         | 4 ++--
>  drivers/hwmon/fschmd.c           | 2 +-
>  drivers/hwmon/sch56xx-common.c   | 2 +-
>  drivers/hwmon/via-cputemp.c      | 5 ++---
>  drivers/hwmon/w83793.c           | 2 +-
>  6 files changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
> index 6ba1a08253f0..48c4570c61d7 100644
> --- a/drivers/hwmon/acpi_power_meter.c
> +++ b/drivers/hwmon/acpi_power_meter.c
> @@ -862,8 +862,7 @@ static int acpi_power_meter_add(struct acpi_device *device)
>  	if (!device)
>  		return -EINVAL;
>  
> -	resource = kzalloc(sizeof(struct acpi_power_meter_resource),
> -			   GFP_KERNEL);
> +	resource = kzalloc(sizeof(*resource), GFP_KERNEL);
>  	if (!resource)
>  		return -ENOMEM;
>  
> diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
> index fe6618e49dc4..0361115d25dd 100644
> --- a/drivers/hwmon/coretemp.c
> +++ b/drivers/hwmon/coretemp.c
> @@ -433,7 +433,7 @@ static struct temp_data *init_temp_data(unsigned int cpu, int pkg_flag)
>  {
>  	struct temp_data *tdata;
>  
> -	tdata = kzalloc(sizeof(struct temp_data), GFP_KERNEL);
> +	tdata = kzalloc(sizeof(*tdata), GFP_KERNEL);
>  	if (!tdata)
>  		return NULL;
>  
> @@ -532,7 +532,7 @@ static int coretemp_probe(struct platform_device *pdev)
>  	struct platform_data *pdata;
>  
>  	/* Initialize the per-zone data structures */
> -	pdata = devm_kzalloc(dev, sizeof(struct platform_data), GFP_KERNEL);
> +	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
>  	if (!pdata)
>  		return -ENOMEM;
>  
> diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c
> index fa0c2f1fb443..d464dcbe5ac8 100644
> --- a/drivers/hwmon/fschmd.c
> +++ b/drivers/hwmon/fschmd.c
> @@ -1090,7 +1090,7 @@ static int fschmd_probe(struct i2c_client *client,
>  	int i, err;
>  	enum chips kind = id->driver_data;
>  
> -	data = kzalloc(sizeof(struct fschmd_data), GFP_KERNEL);
> +	data = kzalloc(sizeof(*data), GFP_KERNEL);
>  	if (!data)
>  		return -ENOMEM;
>  
> diff --git a/drivers/hwmon/sch56xx-common.c b/drivers/hwmon/sch56xx-common.c
> index 6c84780e358e..0d6d20814183 100644
> --- a/drivers/hwmon/sch56xx-common.c
> +++ b/drivers/hwmon/sch56xx-common.c
> @@ -401,7 +401,7 @@ struct sch56xx_watchdog_data *sch56xx_watchdog_register(struct device *parent,
>  		return NULL;
>  	}
>  
> -	data = kzalloc(sizeof(struct sch56xx_watchdog_data), GFP_KERNEL);
> +	data = kzalloc(sizeof(*data), GFP_KERNEL);
>  	if (!data)
>  		return NULL;
>  
> diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
> index 8264e849e588..0feb1d0b5e13 100644
> --- a/drivers/hwmon/via-cputemp.c
> +++ b/drivers/hwmon/via-cputemp.c
> @@ -114,8 +114,7 @@ static int via_cputemp_probe(struct platform_device *pdev)
>  	int err;
>  	u32 eax, edx;
>  
> -	data = devm_kzalloc(&pdev->dev, sizeof(struct via_cputemp_data),
> -			    GFP_KERNEL);
> +	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
>  	if (!data)
>  		return -ENOMEM;
>  
> @@ -223,7 +222,7 @@ static int via_cputemp_online(unsigned int cpu)
>  		goto exit;
>  	}
>  
> -	pdev_entry = kzalloc(sizeof(struct pdev_entry), GFP_KERNEL);
> +	pdev_entry = kzalloc(sizeof(*pdev_entry), GFP_KERNEL);
>  	if (!pdev_entry) {
>  		err = -ENOMEM;
>  		goto exit_device_put;
> diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
> index 46f5dfec8d0a..b37106c6f26d 100644
> --- a/drivers/hwmon/w83793.c
> +++ b/drivers/hwmon/w83793.c
> @@ -1669,7 +1669,7 @@ static int w83793_probe(struct i2c_client *client,
>  	int files_pwm = ARRAY_SIZE(w83793_left_pwm) / 5;
>  	int files_temp = ARRAY_SIZE(w83793_temp) / 6;
>  
> -	data = kzalloc(sizeof(struct w83793_data), GFP_KERNEL);
> +	data = kzalloc(sizeof(*data), GFP_KERNEL);
>  	if (!data) {
>  		err = -ENOMEM;
>  		goto exit;

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

end of thread, other threads:[~2019-06-28 13:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-27 11:56 [PATCH] hwmon: Correct struct allocation style Fabian Schindlatz
2019-06-27 12:06 ` Guenter Roeck
2019-06-27 15:27   ` [PATCH v2] " Fabian Schindlatz
2019-06-28 13:28     ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).