hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/video/fbdev/geode/lxfb_core.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Geode LX framebuffer driver.
34 *
45 * Copyright (C) 2007 Advanced Micro Devices, Inc.
56 * Built from gxfb (which is Copyright (C) 2006 Arcom Control Systems Ltd.)
6
- *
7
- * This program is free software; you can redistribute it and/or modify it
8
- * under the terms of the GNU General Public License as published by the
9
- * Free Software Foundation; either version 2 of the License, or (at your
10
- * option) any later version.
117 */
128
139 #include <linux/module.h>
....@@ -22,6 +18,8 @@
2218 #include <linux/init.h>
2319 #include <linux/pci.h>
2420 #include <linux/uaccess.h>
21
+
22
+#include <asm/olpc.h>
2523
2624 #include "lxfb.h"
2725
....@@ -216,9 +214,6 @@
216214 0, FB_VMODE_NONINTERLACED, 0 },
217215 };
218216
219
-#ifdef CONFIG_OLPC
220
-#include <asm/olpc.h>
221
-
222217 static struct fb_videomode olpc_dcon_modedb[] = {
223218 /* The only mode the DCON has is 1200x900 */
224219 { NULL, 50, 1200, 900, 17460, 24, 8, 4, 5, 8, 3,
....@@ -237,16 +232,11 @@
237232 }
238233 }
239234
240
-#else
241
-static void get_modedb(struct fb_videomode **modedb, unsigned int *size)
242
-{
243
- *modedb = (struct fb_videomode *) geode_modedb;
244
- *size = ARRAY_SIZE(geode_modedb);
245
-}
246
-#endif
247
-
248235 static int lxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
249236 {
237
+ if (!var->pixclock)
238
+ return -EINVAL;
239
+
250240 if (var->xres > 1920 || var->yres > 1440)
251241 return -EINVAL;
252242
....@@ -399,7 +389,7 @@
399389 return 0;
400390 }
401391
402
-static struct fb_ops lxfb_ops = {
392
+static const struct fb_ops lxfb_ops = {
403393 .owner = THIS_MODULE,
404394 .fb_check_var = lxfb_check_var,
405395 .fb_set_par = lxfb_set_par,
....@@ -456,17 +446,14 @@
456446 return info;
457447 }
458448
459
-#ifdef CONFIG_PM
460
-static int lxfb_suspend(struct pci_dev *pdev, pm_message_t state)
449
+static int __maybe_unused lxfb_suspend(struct device *dev)
461450 {
462
- struct fb_info *info = pci_get_drvdata(pdev);
451
+ struct fb_info *info = dev_get_drvdata(dev);
463452
464
- if (state.event == PM_EVENT_SUSPEND) {
465
- console_lock();
466
- lx_powerdown(info);
467
- fb_set_suspend(info, 1);
468
- console_unlock();
469
- }
453
+ console_lock();
454
+ lx_powerdown(info);
455
+ fb_set_suspend(info, 1);
456
+ console_unlock();
470457
471458 /* there's no point in setting PCI states; we emulate PCI, so
472459 * we don't end up getting power savings anyways */
....@@ -474,9 +461,9 @@
474461 return 0;
475462 }
476463
477
-static int lxfb_resume(struct pci_dev *pdev)
464
+static int __maybe_unused lxfb_resume(struct device *dev)
478465 {
479
- struct fb_info *info = pci_get_drvdata(pdev);
466
+ struct fb_info *info = dev_get_drvdata(dev);
480467 int ret;
481468
482469 console_lock();
....@@ -490,10 +477,6 @@
490477 console_unlock();
491478 return 0;
492479 }
493
-#else
494
-#define lxfb_suspend NULL
495
-#define lxfb_resume NULL
496
-#endif
497480
498481 static int lxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
499482 {
....@@ -613,13 +596,23 @@
613596
614597 MODULE_DEVICE_TABLE(pci, lxfb_id_table);
615598
599
+static const struct dev_pm_ops lxfb_pm_ops = {
600
+#ifdef CONFIG_PM_SLEEP
601
+ .suspend = lxfb_suspend,
602
+ .resume = lxfb_resume,
603
+ .freeze = NULL,
604
+ .thaw = lxfb_resume,
605
+ .poweroff = NULL,
606
+ .restore = lxfb_resume,
607
+#endif
608
+};
609
+
616610 static struct pci_driver lxfb_driver = {
617611 .name = "lxfb",
618612 .id_table = lxfb_id_table,
619613 .probe = lxfb_probe,
620614 .remove = lxfb_remove,
621
- .suspend = lxfb_suspend,
622
- .resume = lxfb_resume,
615
+ .driver.pm = &lxfb_pm_ops,
623616 };
624617
625618 #ifndef MODULE