[<prev] [next>] [day] [month] [year] [list]
Message-Id: <610802ecb6de36e1227880c6c18c5dfd2028e342.1452003937.git.geliangtang@163.com>
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