[2/2] i2c-puv3: Improve a size determination in puv3_i2c_probe()

Message ID ab401452-cf6c-e4b0-eb8c-f9daf20c981c@users.sourceforge.net
State New
Headers show
Series
  • i2c-puv3: Adjustments for puv3_i2c_probe()
Related show

Commit Message

SF Markus Elfring Feb. 2, 2018, 3:02 p.m.
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 2 Feb 2018 15:43:21 +0100

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/i2c/busses/i2c-puv3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/drivers/i2c/busses/i2c-puv3.c b/drivers/i2c/busses/i2c-puv3.c
index 5bd001d01bef..929fd12b92de 100644
--- a/drivers/i2c/busses/i2c-puv3.c
+++ b/drivers/i2c/busses/i2c-puv3.c
@@ -196,7 +196,7 @@  static int puv3_i2c_probe(struct platform_device *pdev)
 	if (!request_mem_region(mem->start, resource_size(mem), "puv3_i2c"))
 		return -EBUSY;
 
-	adapter = kzalloc(sizeof(struct i2c_adapter), GFP_KERNEL);
+	adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
 	if (adapter == NULL) {
 		rc = -ENOMEM;
 		goto fail_nomem;