提交 d5de20a9 编写于 作者: A Artem Bityutskiy 提交者: David Woodhouse

mtd: kill dev_to_mtd helper

... since it is not needed because the generic 'dev_get_drvdata()' can be
used instead.
Signed-off-by: NArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Acked-by: NMike Frysinger <vapier@gentoo.org>
Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
上级 30fa9848
...@@ -107,7 +107,8 @@ static LIST_HEAD(mtd_notifiers); ...@@ -107,7 +107,8 @@ static LIST_HEAD(mtd_notifiers);
*/ */
static void mtd_release(struct device *dev) static void mtd_release(struct device *dev)
{ {
dev_t index = MTD_DEVT(dev_to_mtd(dev)->index); struct mtd_info *mtd = dev_get_drvdata(dev);
dev_t index = MTD_DEVT(mtd->index);
/* remove /dev/mtdXro node if needed */ /* remove /dev/mtdXro node if needed */
if (index) if (index)
...@@ -116,7 +117,7 @@ static void mtd_release(struct device *dev) ...@@ -116,7 +117,7 @@ static void mtd_release(struct device *dev)
static int mtd_cls_suspend(struct device *dev, pm_message_t state) static int mtd_cls_suspend(struct device *dev, pm_message_t state)
{ {
struct mtd_info *mtd = dev_to_mtd(dev); struct mtd_info *mtd = dev_get_drvdata(dev);
if (mtd && mtd->suspend) if (mtd && mtd->suspend)
return mtd_suspend(mtd); return mtd_suspend(mtd);
...@@ -126,7 +127,7 @@ static int mtd_cls_suspend(struct device *dev, pm_message_t state) ...@@ -126,7 +127,7 @@ static int mtd_cls_suspend(struct device *dev, pm_message_t state)
static int mtd_cls_resume(struct device *dev) static int mtd_cls_resume(struct device *dev)
{ {
struct mtd_info *mtd = dev_to_mtd(dev); struct mtd_info *mtd = dev_get_drvdata(dev);
if (mtd && mtd->resume) if (mtd && mtd->resume)
mtd_resume(mtd); mtd_resume(mtd);
...@@ -136,7 +137,7 @@ static int mtd_cls_resume(struct device *dev) ...@@ -136,7 +137,7 @@ static int mtd_cls_resume(struct device *dev)
static ssize_t mtd_type_show(struct device *dev, static ssize_t mtd_type_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct mtd_info *mtd = dev_to_mtd(dev); struct mtd_info *mtd = dev_get_drvdata(dev);
char *type; char *type;
switch (mtd->type) { switch (mtd->type) {
...@@ -172,7 +173,7 @@ static DEVICE_ATTR(type, S_IRUGO, mtd_type_show, NULL); ...@@ -172,7 +173,7 @@ static DEVICE_ATTR(type, S_IRUGO, mtd_type_show, NULL);
static ssize_t mtd_flags_show(struct device *dev, static ssize_t mtd_flags_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct mtd_info *mtd = dev_to_mtd(dev); struct mtd_info *mtd = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "0x%lx\n", (unsigned long)mtd->flags); return snprintf(buf, PAGE_SIZE, "0x%lx\n", (unsigned long)mtd->flags);
...@@ -182,7 +183,7 @@ static DEVICE_ATTR(flags, S_IRUGO, mtd_flags_show, NULL); ...@@ -182,7 +183,7 @@ static DEVICE_ATTR(flags, S_IRUGO, mtd_flags_show, NULL);
static ssize_t mtd_size_show(struct device *dev, static ssize_t mtd_size_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct mtd_info *mtd = dev_to_mtd(dev); struct mtd_info *mtd = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%llu\n", return snprintf(buf, PAGE_SIZE, "%llu\n",
(unsigned long long)mtd->size); (unsigned long long)mtd->size);
...@@ -193,7 +194,7 @@ static DEVICE_ATTR(size, S_IRUGO, mtd_size_show, NULL); ...@@ -193,7 +194,7 @@ static DEVICE_ATTR(size, S_IRUGO, mtd_size_show, NULL);
static ssize_t mtd_erasesize_show(struct device *dev, static ssize_t mtd_erasesize_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct mtd_info *mtd = dev_to_mtd(dev); struct mtd_info *mtd = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%lu\n", (unsigned long)mtd->erasesize); return snprintf(buf, PAGE_SIZE, "%lu\n", (unsigned long)mtd->erasesize);
...@@ -203,7 +204,7 @@ static DEVICE_ATTR(erasesize, S_IRUGO, mtd_erasesize_show, NULL); ...@@ -203,7 +204,7 @@ static DEVICE_ATTR(erasesize, S_IRUGO, mtd_erasesize_show, NULL);
static ssize_t mtd_writesize_show(struct device *dev, static ssize_t mtd_writesize_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct mtd_info *mtd = dev_to_mtd(dev); struct mtd_info *mtd = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%lu\n", (unsigned long)mtd->writesize); return snprintf(buf, PAGE_SIZE, "%lu\n", (unsigned long)mtd->writesize);
...@@ -213,7 +214,7 @@ static DEVICE_ATTR(writesize, S_IRUGO, mtd_writesize_show, NULL); ...@@ -213,7 +214,7 @@ static DEVICE_ATTR(writesize, S_IRUGO, mtd_writesize_show, NULL);
static ssize_t mtd_subpagesize_show(struct device *dev, static ssize_t mtd_subpagesize_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct mtd_info *mtd = dev_to_mtd(dev); struct mtd_info *mtd = dev_get_drvdata(dev);
unsigned int subpagesize = mtd->writesize >> mtd->subpage_sft; unsigned int subpagesize = mtd->writesize >> mtd->subpage_sft;
return snprintf(buf, PAGE_SIZE, "%u\n", subpagesize); return snprintf(buf, PAGE_SIZE, "%u\n", subpagesize);
...@@ -224,7 +225,7 @@ static DEVICE_ATTR(subpagesize, S_IRUGO, mtd_subpagesize_show, NULL); ...@@ -224,7 +225,7 @@ static DEVICE_ATTR(subpagesize, S_IRUGO, mtd_subpagesize_show, NULL);
static ssize_t mtd_oobsize_show(struct device *dev, static ssize_t mtd_oobsize_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct mtd_info *mtd = dev_to_mtd(dev); struct mtd_info *mtd = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%lu\n", (unsigned long)mtd->oobsize); return snprintf(buf, PAGE_SIZE, "%lu\n", (unsigned long)mtd->oobsize);
...@@ -234,7 +235,7 @@ static DEVICE_ATTR(oobsize, S_IRUGO, mtd_oobsize_show, NULL); ...@@ -234,7 +235,7 @@ static DEVICE_ATTR(oobsize, S_IRUGO, mtd_oobsize_show, NULL);
static ssize_t mtd_numeraseregions_show(struct device *dev, static ssize_t mtd_numeraseregions_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct mtd_info *mtd = dev_to_mtd(dev); struct mtd_info *mtd = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%u\n", mtd->numeraseregions); return snprintf(buf, PAGE_SIZE, "%u\n", mtd->numeraseregions);
...@@ -245,7 +246,7 @@ static DEVICE_ATTR(numeraseregions, S_IRUGO, mtd_numeraseregions_show, ...@@ -245,7 +246,7 @@ static DEVICE_ATTR(numeraseregions, S_IRUGO, mtd_numeraseregions_show,
static ssize_t mtd_name_show(struct device *dev, static ssize_t mtd_name_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct mtd_info *mtd = dev_to_mtd(dev); struct mtd_info *mtd = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%s\n", mtd->name); return snprintf(buf, PAGE_SIZE, "%s\n", mtd->name);
......
...@@ -422,11 +422,6 @@ static inline int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs) ...@@ -422,11 +422,6 @@ static inline int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs)
return mtd->block_markbad(mtd, ofs); return mtd->block_markbad(mtd, ofs);
} }
static inline struct mtd_info *dev_to_mtd(struct device *dev)
{
return dev ? dev_get_drvdata(dev) : NULL;
}
static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd) static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd)
{ {
if (mtd->erasesize_shift) if (mtd->erasesize_shift)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册