lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Date:	Tue,  5 Jan 2016 22:27:01 +0800
From:	Geliang Tang <geliangtang@....com>
To:	Alessandro Rubini <rubini@...dd.com>
Cc:	Geliang Tang <geliangtang@....com>, linux-kernel@...r.kernel.org
Subject: [PATCH] FMC: use to_fmc_device and kobj_to_dev

Use to_fmc_device() and kobj_to_dev() instead of open-coding.

Signed-off-by: Geliang Tang <geliangtang@....com>
---
 drivers/fmc/fmc-core.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/fmc/fmc-core.c b/drivers/fmc/fmc-core.c
index 353fc54..0f5ea03 100644
--- a/drivers/fmc/fmc-core.c
+++ b/drivers/fmc/fmc-core.c
@@ -69,7 +69,7 @@ static struct bus_type fmc_bus_type = {
 
 static void fmc_release(struct device *dev)
 {
-	struct fmc_device *fmc = container_of(dev, struct fmc_device, dev);
+	struct fmc_device *fmc = to_fmc_device(dev);
 
 	kfree(fmc);
 }
@@ -82,13 +82,10 @@ static ssize_t fmc_read_eeprom(struct file *file, struct kobject *kobj,
 			   struct bin_attribute *bin_attr,
 			   char *buf, loff_t off, size_t count)
 {
-	struct device *dev;
-	struct fmc_device *fmc;
-	int eelen;
+	struct device *dev = kobj_to_dev(kobj);
+	struct fmc_device *fmc = to_fmc_device(dev);
+	int eelen = fmc->eeprom_len;
 
-	dev = container_of(kobj, struct device, kobj);
-	fmc = container_of(dev, struct fmc_device, dev);
-	eelen = fmc->eeprom_len;
 	if (off > eelen)
 		return -ESPIPE;
 	if (off == eelen)
@@ -103,11 +100,9 @@ static ssize_t fmc_write_eeprom(struct file *file, struct kobject *kobj,
 				struct bin_attribute *bin_attr,
 				char *buf, loff_t off, size_t count)
 {
-	struct device *dev;
-	struct fmc_device *fmc;
+	struct device *dev = kobj_to_dev(kobj);
+	struct fmc_device *fmc = to_fmc_device(dev);
 
-	dev = container_of(kobj, struct device, kobj);
-	fmc = container_of(dev, struct fmc_device, dev);
 	return fmc->op->write_ee(fmc, off, buf, count);
 }
 
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ