[PATCH] FMC: use to_fmc_device and kobj_to_dev

From: Geliang Tang
Date: Tue Jan 05 2016 - 09:27:45 EST


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

Signed-off-by: Geliang Tang <geliangtang@xxxxxxx>
---
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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/