Commit ecddad64 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'fbdev-fixes-4.0' of git://git.kernel.org/pub/scm/linux/kernel/git/tomba/linux

Pull fbdev fixes from Tomi Valkeinen:
 - Fix regression in with omapdss when using i2c displays
 - Fix possible null deref in fbmon
 - Check kalloc return value in AMBA CLCD

* tag 'fbdev-fixes-4.0' of git://git.kernel.org/pub/scm/linux/kernel/git/tomba/linux:
  OMAPDSS: fix regression with display sysfs files
  video: fbdev: fix possible null dereference
  video: ARM CLCD: Add missing error check for devm_kzalloc
parents c0e99a71 a38bb793
...@@ -599,6 +599,9 @@ static int clcdfb_of_get_mode(struct device *dev, struct device_node *endpoint, ...@@ -599,6 +599,9 @@ static int clcdfb_of_get_mode(struct device *dev, struct device_node *endpoint,
len = clcdfb_snprintf_mode(NULL, 0, mode); len = clcdfb_snprintf_mode(NULL, 0, mode);
name = devm_kzalloc(dev, len + 1, GFP_KERNEL); name = devm_kzalloc(dev, len + 1, GFP_KERNEL);
if (!name)
return -ENOMEM;
clcdfb_snprintf_mode(name, len + 1, mode); clcdfb_snprintf_mode(name, len + 1, mode);
mode->name = name; mode->name = name;
......
...@@ -624,9 +624,6 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize, ...@@ -624,9 +624,6 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize,
int num = 0, i, first = 1; int num = 0, i, first = 1;
int ver, rev; int ver, rev;
ver = edid[EDID_STRUCT_VERSION];
rev = edid[EDID_STRUCT_REVISION];
mode = kzalloc(50 * sizeof(struct fb_videomode), GFP_KERNEL); mode = kzalloc(50 * sizeof(struct fb_videomode), GFP_KERNEL);
if (mode == NULL) if (mode == NULL)
return NULL; return NULL;
...@@ -637,6 +634,9 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize, ...@@ -637,6 +634,9 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize,
return NULL; return NULL;
} }
ver = edid[EDID_STRUCT_VERSION];
rev = edid[EDID_STRUCT_REVISION];
*dbsize = 0; *dbsize = 0;
DPRINTK(" Detailed Timings\n"); DPRINTK(" Detailed Timings\n");
......
...@@ -28,44 +28,22 @@ ...@@ -28,44 +28,22 @@
#include <video/omapdss.h> #include <video/omapdss.h>
#include "dss.h" #include "dss.h"
static struct omap_dss_device *to_dss_device_sysfs(struct device *dev) static ssize_t display_name_show(struct omap_dss_device *dssdev, char *buf)
{ {
struct omap_dss_device *dssdev = NULL;
for_each_dss_dev(dssdev) {
if (dssdev->dev == dev) {
omap_dss_put_device(dssdev);
return dssdev;
}
}
return NULL;
}
static ssize_t display_name_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
return snprintf(buf, PAGE_SIZE, "%s\n", return snprintf(buf, PAGE_SIZE, "%s\n",
dssdev->name ? dssdev->name ?
dssdev->name : ""); dssdev->name : "");
} }
static ssize_t display_enabled_show(struct device *dev, static ssize_t display_enabled_show(struct omap_dss_device *dssdev, char *buf)
struct device_attribute *attr, char *buf)
{ {
struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
return snprintf(buf, PAGE_SIZE, "%d\n", return snprintf(buf, PAGE_SIZE, "%d\n",
omapdss_device_is_enabled(dssdev)); omapdss_device_is_enabled(dssdev));
} }
static ssize_t display_enabled_store(struct device *dev, static ssize_t display_enabled_store(struct omap_dss_device *dssdev,
struct device_attribute *attr,
const char *buf, size_t size) const char *buf, size_t size)
{ {
struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
int r; int r;
bool enable; bool enable;
...@@ -90,19 +68,16 @@ static ssize_t display_enabled_store(struct device *dev, ...@@ -90,19 +68,16 @@ static ssize_t display_enabled_store(struct device *dev,
return size; return size;
} }
static ssize_t display_tear_show(struct device *dev, static ssize_t display_tear_show(struct omap_dss_device *dssdev, char *buf)
struct device_attribute *attr, char *buf)
{ {
struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
return snprintf(buf, PAGE_SIZE, "%d\n", return snprintf(buf, PAGE_SIZE, "%d\n",
dssdev->driver->get_te ? dssdev->driver->get_te ?
dssdev->driver->get_te(dssdev) : 0); dssdev->driver->get_te(dssdev) : 0);
} }
static ssize_t display_tear_store(struct device *dev, static ssize_t display_tear_store(struct omap_dss_device *dssdev,
struct device_attribute *attr, const char *buf, size_t size) const char *buf, size_t size)
{ {
struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
int r; int r;
bool te; bool te;
...@@ -120,10 +95,8 @@ static ssize_t display_tear_store(struct device *dev, ...@@ -120,10 +95,8 @@ static ssize_t display_tear_store(struct device *dev,
return size; return size;
} }
static ssize_t display_timings_show(struct device *dev, static ssize_t display_timings_show(struct omap_dss_device *dssdev, char *buf)
struct device_attribute *attr, char *buf)
{ {
struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
struct omap_video_timings t; struct omap_video_timings t;
if (!dssdev->driver->get_timings) if (!dssdev->driver->get_timings)
...@@ -137,10 +110,9 @@ static ssize_t display_timings_show(struct device *dev, ...@@ -137,10 +110,9 @@ static ssize_t display_timings_show(struct device *dev,
t.y_res, t.vfp, t.vbp, t.vsw); t.y_res, t.vfp, t.vbp, t.vsw);
} }
static ssize_t display_timings_store(struct device *dev, static ssize_t display_timings_store(struct omap_dss_device *dssdev,
struct device_attribute *attr, const char *buf, size_t size) const char *buf, size_t size)
{ {
struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
struct omap_video_timings t = dssdev->panel.timings; struct omap_video_timings t = dssdev->panel.timings;
int r, found; int r, found;
...@@ -176,10 +148,8 @@ static ssize_t display_timings_store(struct device *dev, ...@@ -176,10 +148,8 @@ static ssize_t display_timings_store(struct device *dev,
return size; return size;
} }
static ssize_t display_rotate_show(struct device *dev, static ssize_t display_rotate_show(struct omap_dss_device *dssdev, char *buf)
struct device_attribute *attr, char *buf)
{ {
struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
int rotate; int rotate;
if (!dssdev->driver->get_rotate) if (!dssdev->driver->get_rotate)
return -ENOENT; return -ENOENT;
...@@ -187,10 +157,9 @@ static ssize_t display_rotate_show(struct device *dev, ...@@ -187,10 +157,9 @@ static ssize_t display_rotate_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%u\n", rotate); return snprintf(buf, PAGE_SIZE, "%u\n", rotate);
} }
static ssize_t display_rotate_store(struct device *dev, static ssize_t display_rotate_store(struct omap_dss_device *dssdev,
struct device_attribute *attr, const char *buf, size_t size) const char *buf, size_t size)
{ {
struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
int rot, r; int rot, r;
if (!dssdev->driver->set_rotate || !dssdev->driver->get_rotate) if (!dssdev->driver->set_rotate || !dssdev->driver->get_rotate)
...@@ -207,10 +176,8 @@ static ssize_t display_rotate_store(struct device *dev, ...@@ -207,10 +176,8 @@ static ssize_t display_rotate_store(struct device *dev,
return size; return size;
} }
static ssize_t display_mirror_show(struct device *dev, static ssize_t display_mirror_show(struct omap_dss_device *dssdev, char *buf)
struct device_attribute *attr, char *buf)
{ {
struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
int mirror; int mirror;
if (!dssdev->driver->get_mirror) if (!dssdev->driver->get_mirror)
return -ENOENT; return -ENOENT;
...@@ -218,10 +185,9 @@ static ssize_t display_mirror_show(struct device *dev, ...@@ -218,10 +185,9 @@ static ssize_t display_mirror_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%u\n", mirror); return snprintf(buf, PAGE_SIZE, "%u\n", mirror);
} }
static ssize_t display_mirror_store(struct device *dev, static ssize_t display_mirror_store(struct omap_dss_device *dssdev,
struct device_attribute *attr, const char *buf, size_t size) const char *buf, size_t size)
{ {
struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
int r; int r;
bool mirror; bool mirror;
...@@ -239,10 +205,8 @@ static ssize_t display_mirror_store(struct device *dev, ...@@ -239,10 +205,8 @@ static ssize_t display_mirror_store(struct device *dev,
return size; return size;
} }
static ssize_t display_wss_show(struct device *dev, static ssize_t display_wss_show(struct omap_dss_device *dssdev, char *buf)
struct device_attribute *attr, char *buf)
{ {
struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
unsigned int wss; unsigned int wss;
if (!dssdev->driver->get_wss) if (!dssdev->driver->get_wss)
...@@ -253,10 +217,9 @@ static ssize_t display_wss_show(struct device *dev, ...@@ -253,10 +217,9 @@ static ssize_t display_wss_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "0x%05x\n", wss); return snprintf(buf, PAGE_SIZE, "0x%05x\n", wss);
} }
static ssize_t display_wss_store(struct device *dev, static ssize_t display_wss_store(struct omap_dss_device *dssdev,
struct device_attribute *attr, const char *buf, size_t size) const char *buf, size_t size)
{ {
struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
u32 wss; u32 wss;
int r; int r;
...@@ -277,50 +240,94 @@ static ssize_t display_wss_store(struct device *dev, ...@@ -277,50 +240,94 @@ static ssize_t display_wss_store(struct device *dev,
return size; return size;
} }
static DEVICE_ATTR(display_name, S_IRUGO, display_name_show, NULL); struct display_attribute {
static DEVICE_ATTR(enabled, S_IRUGO|S_IWUSR, struct attribute attr;
ssize_t (*show)(struct omap_dss_device *, char *);
ssize_t (*store)(struct omap_dss_device *, const char *, size_t);
};
#define DISPLAY_ATTR(_name, _mode, _show, _store) \
struct display_attribute display_attr_##_name = \
__ATTR(_name, _mode, _show, _store)
static DISPLAY_ATTR(name, S_IRUGO, display_name_show, NULL);
static DISPLAY_ATTR(display_name, S_IRUGO, display_name_show, NULL);
static DISPLAY_ATTR(enabled, S_IRUGO|S_IWUSR,
display_enabled_show, display_enabled_store); display_enabled_show, display_enabled_store);
static DEVICE_ATTR(tear_elim, S_IRUGO|S_IWUSR, static DISPLAY_ATTR(tear_elim, S_IRUGO|S_IWUSR,
display_tear_show, display_tear_store); display_tear_show, display_tear_store);
static DEVICE_ATTR(timings, S_IRUGO|S_IWUSR, static DISPLAY_ATTR(timings, S_IRUGO|S_IWUSR,
display_timings_show, display_timings_store); display_timings_show, display_timings_store);
static DEVICE_ATTR(rotate, S_IRUGO|S_IWUSR, static DISPLAY_ATTR(rotate, S_IRUGO|S_IWUSR,
display_rotate_show, display_rotate_store); display_rotate_show, display_rotate_store);
static DEVICE_ATTR(mirror, S_IRUGO|S_IWUSR, static DISPLAY_ATTR(mirror, S_IRUGO|S_IWUSR,
display_mirror_show, display_mirror_store); display_mirror_show, display_mirror_store);
static DEVICE_ATTR(wss, S_IRUGO|S_IWUSR, static DISPLAY_ATTR(wss, S_IRUGO|S_IWUSR,
display_wss_show, display_wss_store); display_wss_show, display_wss_store);
static const struct attribute *display_sysfs_attrs[] = { static struct attribute *display_sysfs_attrs[] = {
&dev_attr_display_name.attr, &display_attr_name.attr,
&dev_attr_enabled.attr, &display_attr_display_name.attr,
&dev_attr_tear_elim.attr, &display_attr_enabled.attr,
&dev_attr_timings.attr, &display_attr_tear_elim.attr,
&dev_attr_rotate.attr, &display_attr_timings.attr,
&dev_attr_mirror.attr, &display_attr_rotate.attr,
&dev_attr_wss.attr, &display_attr_mirror.attr,
&display_attr_wss.attr,
NULL NULL
}; };
static ssize_t display_attr_show(struct kobject *kobj, struct attribute *attr,
char *buf)
{
struct omap_dss_device *dssdev;
struct display_attribute *display_attr;
dssdev = container_of(kobj, struct omap_dss_device, kobj);
display_attr = container_of(attr, struct display_attribute, attr);
if (!display_attr->show)
return -ENOENT;
return display_attr->show(dssdev, buf);
}
static ssize_t display_attr_store(struct kobject *kobj, struct attribute *attr,
const char *buf, size_t size)
{
struct omap_dss_device *dssdev;
struct display_attribute *display_attr;
dssdev = container_of(kobj, struct omap_dss_device, kobj);
display_attr = container_of(attr, struct display_attribute, attr);
if (!display_attr->store)
return -ENOENT;
return display_attr->store(dssdev, buf, size);
}
static const struct sysfs_ops display_sysfs_ops = {
.show = display_attr_show,
.store = display_attr_store,
};
static struct kobj_type display_ktype = {
.sysfs_ops = &display_sysfs_ops,
.default_attrs = display_sysfs_attrs,
};
int display_init_sysfs(struct platform_device *pdev) int display_init_sysfs(struct platform_device *pdev)
{ {
struct omap_dss_device *dssdev = NULL; struct omap_dss_device *dssdev = NULL;
int r; int r;
for_each_dss_dev(dssdev) { for_each_dss_dev(dssdev) {
struct kobject *kobj = &dssdev->dev->kobj; r = kobject_init_and_add(&dssdev->kobj, &display_ktype,
&pdev->dev.kobj, dssdev->alias);
r = sysfs_create_files(kobj, display_sysfs_attrs);
if (r) { if (r) {
DSSERR("failed to create sysfs files\n"); DSSERR("failed to create sysfs files\n");
goto err; omap_dss_put_device(dssdev);
}
r = sysfs_create_link(&pdev->dev.kobj, kobj, dssdev->alias);
if (r) {
sysfs_remove_files(kobj, display_sysfs_attrs);
DSSERR("failed to create sysfs display link\n");
goto err; goto err;
} }
} }
...@@ -338,8 +345,12 @@ void display_uninit_sysfs(struct platform_device *pdev) ...@@ -338,8 +345,12 @@ void display_uninit_sysfs(struct platform_device *pdev)
struct omap_dss_device *dssdev = NULL; struct omap_dss_device *dssdev = NULL;
for_each_dss_dev(dssdev) { for_each_dss_dev(dssdev) {
sysfs_remove_link(&pdev->dev.kobj, dssdev->alias); if (kobject_name(&dssdev->kobj) == NULL)
sysfs_remove_files(&dssdev->dev->kobj, continue;
display_sysfs_attrs);
kobject_del(&dssdev->kobj);
kobject_put(&dssdev->kobj);
memset(&dssdev->kobj, 0, sizeof(dssdev->kobj));
} }
} }
...@@ -689,6 +689,7 @@ struct omapdss_dsi_ops { ...@@ -689,6 +689,7 @@ struct omapdss_dsi_ops {
}; };
struct omap_dss_device { struct omap_dss_device {
struct kobject kobj;
struct device *dev; struct device *dev;
struct module *owner; struct module *owner;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment