forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/drivers/video/fbdev/udlfb.c
....@@ -1,13 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * udlfb.c -- Framebuffer driver for DisplayLink USB controller
34 *
45 * Copyright (C) 2009 Roberto De Ioris <roberto@unbit.it>
56 * Copyright (C) 2009 Jaya Kumar <jayakumar.lkml@gmail.com>
67 * Copyright (C) 2009 Bernie Thompson <bernie@plugable.com>
7
- *
8
- * This file is subject to the terms and conditions of the GNU General Public
9
- * License v2. See the file COPYING in the main directory of this archive for
10
- * more details.
118 *
129 * Layout is based on skeletonfb by James Simmons and Geert Uytterhoeven,
1310 * usb-skeleton by GregKH.
....@@ -67,9 +64,9 @@
6764 MODULE_DEVICE_TABLE(usb, id_table);
6865
6966 /* module options */
70
-static bool console = 1; /* Allow fbcon to open framebuffer */
71
-static bool fb_defio = 1; /* Detect mmap writes using page faults */
72
-static bool shadow = 1; /* Optionally disable shadow framebuffer */
67
+static bool console = true; /* Allow fbcon to open framebuffer */
68
+static bool fb_defio = true; /* Detect mmap writes using page faults */
69
+static bool shadow = true; /* Optionally disable shadow framebuffer */
7370 static int pixel_limit; /* Optionally force a pixel resolution limit */
7471
7572 struct dlfb_deferred_free {
....@@ -1041,7 +1038,6 @@
10411038 fb_deferred_io_cleanup(info);
10421039 kfree(info->fbdefio);
10431040 info->fbdefio = NULL;
1044
- info->fbops->fb_mmap = dlfb_ops_mmap;
10451041 }
10461042
10471043 dev_dbg(info->dev, "release, user=%d count=%d\n", user, dlfb->fb_count);
....@@ -1187,7 +1183,7 @@
11871183 return 0;
11881184 }
11891185
1190
-static struct fb_ops dlfb_ops = {
1186
+static const struct fb_ops dlfb_ops = {
11911187 .owner = THIS_MODULE,
11921188 .fb_read = fb_sys_read,
11931189 .fb_write = dlfb_ops_write,
....@@ -1430,7 +1426,7 @@
14301426 struct device_attribute *a, char *buf) {
14311427 struct fb_info *fb_info = dev_get_drvdata(fbdev);
14321428 struct dlfb_data *dlfb = fb_info->par;
1433
- return snprintf(buf, PAGE_SIZE, "%u\n",
1429
+ return sysfs_emit(buf, "%u\n",
14341430 atomic_read(&dlfb->bytes_rendered));
14351431 }
14361432
....@@ -1438,7 +1434,7 @@
14381434 struct device_attribute *a, char *buf) {
14391435 struct fb_info *fb_info = dev_get_drvdata(fbdev);
14401436 struct dlfb_data *dlfb = fb_info->par;
1441
- return snprintf(buf, PAGE_SIZE, "%u\n",
1437
+ return sysfs_emit(buf, "%u\n",
14421438 atomic_read(&dlfb->bytes_identical));
14431439 }
14441440
....@@ -1446,7 +1442,7 @@
14461442 struct device_attribute *a, char *buf) {
14471443 struct fb_info *fb_info = dev_get_drvdata(fbdev);
14481444 struct dlfb_data *dlfb = fb_info->par;
1449
- return snprintf(buf, PAGE_SIZE, "%u\n",
1445
+ return sysfs_emit(buf, "%u\n",
14501446 atomic_read(&dlfb->bytes_sent));
14511447 }
14521448
....@@ -1454,7 +1450,7 @@
14541450 struct device_attribute *a, char *buf) {
14551451 struct fb_info *fb_info = dev_get_drvdata(fbdev);
14561452 struct dlfb_data *dlfb = fb_info->par;
1457
- return snprintf(buf, PAGE_SIZE, "%u\n",
1453
+ return sysfs_emit(buf, "%u\n",
14581454 atomic_read(&dlfb->cpu_kcycles_used));
14591455 }
14601456
....@@ -1462,7 +1458,7 @@
14621458 struct file *filp,
14631459 struct kobject *kobj, struct bin_attribute *a,
14641460 char *buf, loff_t off, size_t count) {
1465
- struct device *fbdev = container_of(kobj, struct device, kobj);
1461
+ struct device *fbdev = kobj_to_dev(kobj);
14661462 struct fb_info *fb_info = dev_get_drvdata(fbdev);
14671463 struct dlfb_data *dlfb = fb_info->par;
14681464
....@@ -1484,7 +1480,7 @@
14841480 struct file *filp,
14851481 struct kobject *kobj, struct bin_attribute *a,
14861482 char *src, loff_t src_off, size_t src_size) {
1487
- struct device *fbdev = container_of(kobj, struct device, kobj);
1483
+ struct device *fbdev = kobj_to_dev(kobj);
14881484 struct fb_info *fb_info = dev_get_drvdata(fbdev);
14891485 struct dlfb_data *dlfb = fb_info->par;
14901486 int ret;
....@@ -1653,8 +1649,9 @@
16531649 const struct device_attribute *attr;
16541650 struct dlfb_data *dlfb;
16551651 struct fb_info *info;
1656
- int retval = -ENOMEM;
1652
+ int retval;
16571653 struct usb_device *usbdev = interface_to_usbdev(intf);
1654
+ struct usb_endpoint_descriptor *out;
16581655
16591656 /* usb initialization */
16601657 dlfb = kzalloc(sizeof(*dlfb), GFP_KERNEL);
....@@ -1668,6 +1665,12 @@
16681665 dlfb->udev = usb_get_dev(usbdev);
16691666 usb_set_intfdata(intf, dlfb);
16701667
1668
+ retval = usb_find_common_endpoints(intf->cur_altsetting, NULL, &out, NULL, NULL);
1669
+ if (retval) {
1670
+ dev_err(&intf->dev, "Device should have at lease 1 bulk endpoint!\n");
1671
+ goto error;
1672
+ }
1673
+
16711674 dev_dbg(&intf->dev, "console enable=%d\n", console);
16721675 dev_dbg(&intf->dev, "fb_defio enable=%d\n", fb_defio);
16731676 dev_dbg(&intf->dev, "shadow enable=%d\n", shadow);
....@@ -1677,6 +1680,7 @@
16771680 if (!dlfb_parse_vendor_descriptor(dlfb, intf)) {
16781681 dev_err(&intf->dev,
16791682 "firmware not recognized, incompatible device?\n");
1683
+ retval = -ENODEV;
16801684 goto error;
16811685 }
16821686
....@@ -1691,7 +1695,7 @@
16911695 /* allocates framebuffer driver structure, not framebuffer memory */
16921696 info = framebuffer_alloc(0, &dlfb->udev->dev);
16931697 if (!info) {
1694
- dev_err(&dlfb->udev->dev, "framebuffer_alloc failed\n");
1698
+ retval = -ENOMEM;
16951699 goto error;
16961700 }
16971701