Skip to contentSkip to conversation

staging: gasket: gasket_open use container_of()

PATCH RESEND New Todd Poynor 1 participant 1 message Jul 15, 2018 Staging

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 staging: gasket: gasket_open use container_of()

From: Todd Poynor <[email protected]>

Use container_of(), drop unnecessary NULL check.

---
 drivers/staging/gasket/gasket_core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/staging/gasket/gasket_core.c +2 -5
index 20da6bdb7a73..4ac239c33ea3 100644
@@ -1088,12 +1088,9 @@ static int gasket_open(struct inode *inode, struct file *filp)
 	const struct gasket_driver_desc *driver_desc;
 	struct gasket_ownership *ownership;
 	char task_name[TASK_COMM_LEN];
-	struct gasket_cdev_info *dev_info = gasket_cdev_get_info(inode->i_cdev);
+	struct gasket_cdev_info *dev_info =
+	    container_of(inode->i_cdev, struct gasket_cdev_info, cdev);
 
-	if (!dev_info) {
-		gasket_nodev_error("Unable to retrieve device data");
-		return -EINVAL;
-	}
 	gasket_dev = dev_info->gasket_dev_ptr;
 	driver_desc = gasket_dev->internal_desc->driver_desc;
 	ownership = &dev_info->ownership;
Signature · 4 lines
2.18.0.203.gfac676dfb9-goog

Resending, extracted from the previous stack of patches that needs
other cleanups.