Commit 5d90ccf9 authored by Thierry Reding's avatar Thierry Reding Committed by Daniel Vetter

vgaarb: Fix a few checkpatch errors and warnings

Wrap overly long lines (offending lines were mostly comments, so trivial
to fix up) and a number of other coding style issues pointed out by the
checkpatch tool.
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 8b7e2e86
...@@ -136,7 +136,6 @@ struct pci_dev *vga_default_device(void) ...@@ -136,7 +136,6 @@ struct pci_dev *vga_default_device(void)
{ {
return vga_default; return vga_default;
} }
EXPORT_SYMBOL_GPL(vga_default_device); EXPORT_SYMBOL_GPL(vga_default_device);
void vga_set_default_device(struct pci_dev *pdev) void vga_set_default_device(struct pci_dev *pdev)
...@@ -300,9 +299,9 @@ static struct vga_device *__vga_tryget(struct vga_device *vgadev, ...@@ -300,9 +299,9 @@ static struct vga_device *__vga_tryget(struct vga_device *vgadev,
pci_set_vga_state(vgadev->pdev, true, pci_bits, flags); pci_set_vga_state(vgadev->pdev, true, pci_bits, flags);
if (!vgadev->bridge_has_one_vga) { if (!vgadev->bridge_has_one_vga)
vga_irq_set_state(vgadev, true); vga_irq_set_state(vgadev, true);
}
vgadev->owns |= wants; vgadev->owns |= wants;
lock_them: lock_them:
vgadev->locks |= (rsrc & VGA_RSRC_LEGACY_MASK); vgadev->locks |= (rsrc & VGA_RSRC_LEGACY_MASK);
...@@ -454,15 +453,15 @@ void vga_put(struct pci_dev *pdev, unsigned int rsrc) ...@@ -454,15 +453,15 @@ void vga_put(struct pci_dev *pdev, unsigned int rsrc)
} }
EXPORT_SYMBOL(vga_put); EXPORT_SYMBOL(vga_put);
/* Rules for using a bridge to control a VGA descendant decoding: /*
if a bridge has only one VGA descendant then it can be used * Rules for using a bridge to control a VGA descendant decoding: if a bridge
to control the VGA routing for that device. * has only one VGA descendant then it can be used to control the VGA routing
It should always use the bridge closest to the device to control it. * for that device. It should always use the bridge closest to the device to
If a bridge has a direct VGA descendant, but also have a sub-bridge * control it. If a bridge has a direct VGA descendant, but also have a sub-
VGA descendant then we cannot use that bridge to control the direct VGA descendant. * bridge VGA descendant then we cannot use that bridge to control the direct
So for every device we register, we need to iterate all its parent bridges * VGA descendant. So for every device we register, we need to iterate all
so we can invalidate any devices using them properly. * its parent bridges so we can invalidate any devices using them properly.
*/ */
static void vga_arbiter_check_bridge_sharing(struct vga_device *vgadev) static void vga_arbiter_check_bridge_sharing(struct vga_device *vgadev)
{ {
struct vga_device *same_bridge_vgadev; struct vga_device *same_bridge_vgadev;
...@@ -486,21 +485,26 @@ static void vga_arbiter_check_bridge_sharing(struct vga_device *vgadev) ...@@ -486,21 +485,26 @@ static void vga_arbiter_check_bridge_sharing(struct vga_device *vgadev)
/* see if the share a bridge with this device */ /* see if the share a bridge with this device */
if (new_bridge == bridge) { if (new_bridge == bridge) {
/* if their direct parent bridge is the same /*
as any bridge of this device then it can't be used * If their direct parent bridge is the same
for that device */ * as any bridge of this device then it can't
* be used for that device.
*/
same_bridge_vgadev->bridge_has_one_vga = false; same_bridge_vgadev->bridge_has_one_vga = false;
} }
/* now iterate the previous devices bridge hierarchy */ /*
/* if the new devices parent bridge is in the other devices * Now iterate the previous devices bridge hierarchy.
hierarchy then we can't use it to control this device */ * If the new devices parent bridge is in the other
* devices hierarchy then we can't use it to control
* this device
*/
while (bus) { while (bus) {
bridge = bus->self; bridge = bus->self;
if (bridge) {
if (bridge == vgadev->pdev->bus->self) if (bridge && bridge == vgadev->pdev->bus->self)
vgadev->bridge_has_one_vga = false; vgadev->bridge_has_one_vga = false;
}
bus = bus->parent; bus = bus->parent;
} }
} }
...@@ -530,9 +534,9 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev) ...@@ -530,9 +534,9 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev)
vgadev = kmalloc(sizeof(struct vga_device), GFP_KERNEL); vgadev = kmalloc(sizeof(struct vga_device), GFP_KERNEL);
if (vgadev == NULL) { if (vgadev == NULL) {
pr_err("failed to allocate pci device\n"); pr_err("failed to allocate pci device\n");
/* What to do on allocation failure ? For now, let's /*
* just do nothing, I'm not sure there is anything saner * What to do on allocation failure ? For now, let's just do
* to be done * nothing, I'm not sure there is anything saner to be done.
*/ */
return false; return false;
} }
...@@ -568,8 +572,8 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev) ...@@ -568,8 +572,8 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev)
bridge = bus->self; bridge = bus->self;
if (bridge) { if (bridge) {
u16 l; u16 l;
pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
&l); pci_read_config_word(bridge, PCI_BRIDGE_CONTROL, &l);
if (!(l & PCI_BRIDGE_CTL_VGA)) { if (!(l & PCI_BRIDGE_CTL_VGA)) {
vgadev->owns = 0; vgadev->owns = 0;
break; break;
...@@ -677,7 +681,9 @@ static inline void vga_update_device_decodes(struct vga_device *vgadev, ...@@ -677,7 +681,9 @@ static inline void vga_update_device_decodes(struct vga_device *vgadev,
pr_debug("decoding count now is: %d\n", vga_decode_count); pr_debug("decoding count now is: %d\n", vga_decode_count);
} }
static void __vga_set_legacy_decoding(struct pci_dev *pdev, unsigned int decodes, bool userspace) static void __vga_set_legacy_decoding(struct pci_dev *pdev,
unsigned int decodes,
bool userspace)
{ {
struct vga_device *vgadev; struct vga_device *vgadev;
unsigned long flags; unsigned long flags;
...@@ -713,7 +719,8 @@ EXPORT_SYMBOL(vga_set_legacy_decoding); ...@@ -713,7 +719,8 @@ EXPORT_SYMBOL(vga_set_legacy_decoding);
/* call with NULL to unregister */ /* call with NULL to unregister */
int vga_client_register(struct pci_dev *pdev, void *cookie, int vga_client_register(struct pci_dev *pdev, void *cookie,
void (*irq_set_state)(void *cookie, bool state), void (*irq_set_state)(void *cookie, bool state),
unsigned int (*set_vga_decode)(void *cookie, bool decode)) unsigned int (*set_vga_decode)(void *cookie,
bool decode))
{ {
int ret = -ENODEV; int ret = -ENODEV;
struct vga_device *vgadev; struct vga_device *vgadev;
...@@ -833,7 +840,7 @@ static int vga_pci_str_to_vars(char *buf, int count, unsigned int *domain, ...@@ -833,7 +840,7 @@ static int vga_pci_str_to_vars(char *buf, int count, unsigned int *domain,
return 1; return 1;
} }
static ssize_t vga_arb_read(struct file *file, char __user * buf, static ssize_t vga_arb_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct vga_arb_private *priv = file->private_data; struct vga_arb_private *priv = file->private_data;
...@@ -900,7 +907,7 @@ static ssize_t vga_arb_read(struct file *file, char __user * buf, ...@@ -900,7 +907,7 @@ static ssize_t vga_arb_read(struct file *file, char __user * buf,
* TODO: To avoid parsing inside kernel and to improve the speed we may * TODO: To avoid parsing inside kernel and to improve the speed we may
* consider use ioctl here * consider use ioctl here
*/ */
static ssize_t vga_arb_write(struct file *file, const char __user * buf, static ssize_t vga_arb_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct vga_arb_private *priv = file->private_data; struct vga_arb_private *priv = file->private_data;
...@@ -1154,7 +1161,7 @@ static ssize_t vga_arb_write(struct file *file, const char __user * buf, ...@@ -1154,7 +1161,7 @@ static ssize_t vga_arb_write(struct file *file, const char __user * buf,
return ret_val; return ret_val;
} }
static unsigned int vga_arb_fpoll(struct file *file, poll_table * wait) static unsigned int vga_arb_fpoll(struct file *file, poll_table *wait)
{ {
struct vga_arb_private *priv = file->private_data; struct vga_arb_private *priv = file->private_data;
...@@ -1250,7 +1257,8 @@ static void vga_arbiter_notify_clients(void) ...@@ -1250,7 +1257,8 @@ static void vga_arbiter_notify_clients(void)
else else
new_state = true; new_state = true;
if (vgadev->set_vga_decode) { if (vgadev->set_vga_decode) {
new_decodes = vgadev->set_vga_decode(vgadev->cookie, new_state); new_decodes = vgadev->set_vga_decode(vgadev->cookie,
new_state);
vga_update_device_decodes(vgadev, new_decodes); vga_update_device_decodes(vgadev, new_decodes);
} }
} }
...@@ -1320,17 +1328,25 @@ static int __init vga_arb_device_init(void) ...@@ -1320,17 +1328,25 @@ static int __init vga_arb_device_init(void)
list_for_each_entry(vgadev, &vga_list, list) { list_for_each_entry(vgadev, &vga_list, list) {
#if defined(CONFIG_X86) || defined(CONFIG_IA64) #if defined(CONFIG_X86) || defined(CONFIG_IA64)
/* Override I/O based detection done by vga_arbiter_add_pci_device() /*
* as it may take the wrong device (e.g. on Apple system under EFI). * Override vga_arbiter_add_pci_device()'s I/O based detection
* as it may take the wrong device (e.g. on Apple system under
* EFI).
* *
* Select the device owning the boot framebuffer if there is one. * Select the device owning the boot framebuffer if there is
* one.
*/ */
resource_size_t start, end; resource_size_t start, end, limit;
unsigned long flags;
int i; int i;
limit = screen_info.lfb_base + screen_info.lfb_size;
/* Does firmware framebuffer belong to us? */ /* Does firmware framebuffer belong to us? */
for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
if (!(pci_resource_flags(vgadev->pdev, i) & IORESOURCE_MEM)) flags = pci_resource_flags(vgadev->pdev, i);
if ((flags & IORESOURCE_MEM) == 0)
continue; continue;
start = pci_resource_start(vgadev->pdev, i); start = pci_resource_start(vgadev->pdev, i);
...@@ -1339,9 +1355,9 @@ static int __init vga_arb_device_init(void) ...@@ -1339,9 +1355,9 @@ static int __init vga_arb_device_init(void)
if (!start || !end) if (!start || !end)
continue; continue;
if (screen_info.lfb_base < start || if (screen_info.lfb_base < start || limit >= end)
(screen_info.lfb_base + screen_info.lfb_size) >= end)
continue; continue;
if (!vga_default_device()) if (!vga_default_device())
pr_info("setting as boot device: PCI:%s\n", pr_info("setting as boot device: PCI:%s\n",
pci_name(vgadev->pdev)); pci_name(vgadev->pdev));
...@@ -1352,9 +1368,11 @@ static int __init vga_arb_device_init(void) ...@@ -1352,9 +1368,11 @@ static int __init vga_arb_device_init(void)
} }
#endif #endif
if (vgadev->bridge_has_one_vga) if (vgadev->bridge_has_one_vga)
pr_info("bridge control possible %s\n", pci_name(vgadev->pdev)); pr_info("bridge control possible %s\n",
pci_name(vgadev->pdev));
else else
pr_info("no bridge control possible %s\n", pci_name(vgadev->pdev)); pr_info("no bridge control possible %s\n",
pci_name(vgadev->pdev));
} }
return rc; return rc;
} }
......
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