lkml.org 
[lkml]   [2016]   [Jan]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] FMC: use to_fmc_device and kobj_to_dev
Date
Use to_fmc_device() and kobj_to_dev() instead of open-coding.

Signed-off-by: Geliang Tang <geliangtang@163.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



\
 
 \ /
  Last update: 2016-01-05 15:41    [W:0.033 / U:0.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site