module.c (1da177e4c3f41524e886b7f1b8a0c1fc7321cac2) | module.c (278d72ae8803ffcd16070c95fe1d53f4466dc741) |
---|---|
1 2/* 3 * IBM ASM Service Processor Device Driver 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. --- 42 unchanged lines hidden (view full) --- 51 */ 52 53#include <linux/pci.h> 54#include <linux/init.h> 55#include "ibmasm.h" 56#include "lowlevel.h" 57#include "remote.h" 58 | 1 2/* 3 * IBM ASM Service Processor Device Driver 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. --- 42 unchanged lines hidden (view full) --- 51 */ 52 53#include <linux/pci.h> 54#include <linux/init.h> 55#include "ibmasm.h" 56#include "lowlevel.h" 57#include "remote.h" 58 |
59int ibmasm_debug = 0; 60module_param(ibmasm_debug, int , S_IRUGO | S_IWUSR); 61MODULE_PARM_DESC(ibmasm_debug, " Set debug mode on or off"); |
|
59 | 62 |
63 |
|
60static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 61{ | 64static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 65{ |
62 int err, result = -ENOMEM; | 66 int result; |
63 struct service_processor *sp; 64 | 67 struct service_processor *sp; 68 |
65 if ((err = pci_enable_device(pdev))) { 66 printk(KERN_ERR "%s: can't enable PCI device at %s\n", 67 DRIVER_NAME, pci_name(pdev)); 68 return err; | 69 if ((result = pci_enable_device(pdev))) { 70 dev_err(&pdev->dev, "Failed to enable PCI device\n"); 71 return result; |
69 } | 72 } |
73 if ((result = pci_request_regions(pdev, DRIVER_NAME))) { 74 dev_err(&pdev->dev, "Failed to allocate PCI resources\n"); 75 goto error_resources; 76 } 77 /* vnc client won't work without bus-mastering */ 78 pci_set_master(pdev); |
|
70 71 sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL); 72 if (sp == NULL) { 73 dev_err(&pdev->dev, "Failed to allocate memory\n"); 74 result = -ENOMEM; 75 goto error_kmalloc; 76 } 77 memset(sp, 0, sizeof(struct service_processor)); 78 | 79 80 sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL); 81 if (sp == NULL) { 82 dev_err(&pdev->dev, "Failed to allocate memory\n"); 83 result = -ENOMEM; 84 goto error_kmalloc; 85 } 86 memset(sp, 0, sizeof(struct service_processor)); 87 |
88 sp->lock = SPIN_LOCK_UNLOCKED; 89 INIT_LIST_HEAD(&sp->command_queue); 90 |
|
79 pci_set_drvdata(pdev, (void *)sp); 80 sp->dev = &pdev->dev; 81 sp->number = pdev->bus->number; 82 snprintf(sp->dirname, IBMASM_NAME_SIZE, "%d", sp->number); 83 snprintf(sp->devname, IBMASM_NAME_SIZE, "%s%d", DRIVER_NAME, sp->number); 84 85 if (ibmasm_event_buffer_init(sp)) { 86 dev_err(sp->dev, "Failed to allocate event buffer\n"); --- 9 unchanged lines hidden (view full) --- 96 sp->base_address = ioremap(pci_resource_start(pdev, 0), 97 pci_resource_len(pdev, 0)); 98 if (sp->base_address == 0) { 99 dev_err(sp->dev, "Failed to ioremap pci memory\n"); 100 result = -ENODEV; 101 goto error_ioremap; 102 } 103 | 91 pci_set_drvdata(pdev, (void *)sp); 92 sp->dev = &pdev->dev; 93 sp->number = pdev->bus->number; 94 snprintf(sp->dirname, IBMASM_NAME_SIZE, "%d", sp->number); 95 snprintf(sp->devname, IBMASM_NAME_SIZE, "%s%d", DRIVER_NAME, sp->number); 96 97 if (ibmasm_event_buffer_init(sp)) { 98 dev_err(sp->dev, "Failed to allocate event buffer\n"); --- 9 unchanged lines hidden (view full) --- 108 sp->base_address = ioremap(pci_resource_start(pdev, 0), 109 pci_resource_len(pdev, 0)); 110 if (sp->base_address == 0) { 111 dev_err(sp->dev, "Failed to ioremap pci memory\n"); 112 result = -ENODEV; 113 goto error_ioremap; 114 } 115 |
104 result = ibmasm_init_remote_queue(sp); 105 if (result) { 106 dev_err(sp->dev, "Failed to initialize remote queue\n"); 107 goto error_remote_queue; 108 } 109 110 spin_lock_init(&sp->lock); 111 INIT_LIST_HEAD(&sp->command_queue); 112 | |
113 result = request_irq(sp->irq, ibmasm_interrupt_handler, SA_SHIRQ, sp->devname, (void*)sp); 114 if (result) { 115 dev_err(sp->dev, "Failed to register interrupt handler\n"); 116 goto error_request_irq; 117 } 118 119 enable_sp_interrupts(sp->base_address); | 116 result = request_irq(sp->irq, ibmasm_interrupt_handler, SA_SHIRQ, sp->devname, (void*)sp); 117 if (result) { 118 dev_err(sp->dev, "Failed to register interrupt handler\n"); 119 goto error_request_irq; 120 } 121 122 enable_sp_interrupts(sp->base_address); |
120 disable_mouse_interrupts(sp); | |
121 | 123 |
124 result = ibmasm_init_remote_input_dev(sp); 125 if (result) { 126 dev_err(sp->dev, "Failed to initialize remote queue\n"); 127 goto error_send_message; 128 } 129 |
|
122 result = ibmasm_send_driver_vpd(sp); 123 if (result) { 124 dev_err(sp->dev, "Failed to send driver VPD to service processor\n"); 125 goto error_send_message; 126 } 127 result = ibmasm_send_os_state(sp, SYSTEM_STATE_OS_UP); 128 if (result) { 129 dev_err(sp->dev, "Failed to send OS state to service processor\n"); 130 goto error_send_message; 131 } 132 ibmasmfs_add_sp(sp); 133 134 ibmasm_register_uart(sp); 135 | 130 result = ibmasm_send_driver_vpd(sp); 131 if (result) { 132 dev_err(sp->dev, "Failed to send driver VPD to service processor\n"); 133 goto error_send_message; 134 } 135 result = ibmasm_send_os_state(sp, SYSTEM_STATE_OS_UP); 136 if (result) { 137 dev_err(sp->dev, "Failed to send OS state to service processor\n"); 138 goto error_send_message; 139 } 140 ibmasmfs_add_sp(sp); 141 142 ibmasm_register_uart(sp); 143 |
136 dev_printk(KERN_DEBUG, &pdev->dev, "WARNING: This software may not be supported or function\n"); 137 dev_printk(KERN_DEBUG, &pdev->dev, "correctly on your IBM server. Please consult the IBM\n"); 138 dev_printk(KERN_DEBUG, &pdev->dev, "ServerProven website\n"); 139 dev_printk(KERN_DEBUG, &pdev->dev, "http://www.pc.ibm.com/ww/eserver/xseries/serverproven\n"); 140 dev_printk(KERN_DEBUG, &pdev->dev, "for information on the specific driver level and support\n"); 141 dev_printk(KERN_DEBUG, &pdev->dev, "statement for your IBM server.\n"); 142 | |
143 return 0; 144 145error_send_message: 146 disable_sp_interrupts(sp->base_address); | 144 return 0; 145 146error_send_message: 147 disable_sp_interrupts(sp->base_address); |
148 ibmasm_free_remote_input_dev(sp); |
|
147 free_irq(sp->irq, (void *)sp); 148error_request_irq: | 149 free_irq(sp->irq, (void *)sp); 150error_request_irq: |
149 ibmasm_free_remote_queue(sp); 150error_remote_queue: | |
151 iounmap(sp->base_address); 152error_ioremap: 153 ibmasm_heartbeat_exit(sp); 154error_heartbeat: 155 ibmasm_event_buffer_exit(sp); 156error_eventbuffer: | 151 iounmap(sp->base_address); 152error_ioremap: 153 ibmasm_heartbeat_exit(sp); 154error_heartbeat: 155 ibmasm_event_buffer_exit(sp); 156error_eventbuffer: |
157 pci_set_drvdata(pdev, NULL); |
|
157 kfree(sp); 158error_kmalloc: | 158 kfree(sp); 159error_kmalloc: |
159 pci_disable_device(pdev); | 160 pci_release_regions(pdev); 161error_resources: 162 pci_disable_device(pdev); |
160 161 return result; 162} 163 164static void __devexit ibmasm_remove_one(struct pci_dev *pdev) 165{ 166 struct service_processor *sp = (struct service_processor *)pci_get_drvdata(pdev); 167 | 163 164 return result; 165} 166 167static void __devexit ibmasm_remove_one(struct pci_dev *pdev) 168{ 169 struct service_processor *sp = (struct service_processor *)pci_get_drvdata(pdev); 170 |
171 dbg("Unregistering UART\n"); |
|
168 ibmasm_unregister_uart(sp); | 172 ibmasm_unregister_uart(sp); |
169 ibmasm_send_os_state(sp, SYSTEM_STATE_OS_DOWN); | 173 dbg("Sending OS down message\n"); 174 if (ibmasm_send_os_state(sp, SYSTEM_STATE_OS_DOWN)) 175 err("failed to get repsonse to 'Send OS State' command\n"); 176 dbg("Disabling heartbeats\n"); 177 ibmasm_heartbeat_exit(sp); 178 dbg("Disabling interrupts\n"); |
170 disable_sp_interrupts(sp->base_address); | 179 disable_sp_interrupts(sp->base_address); |
171 disable_mouse_interrupts(sp); | 180 dbg("Freeing SP irq\n"); |
172 free_irq(sp->irq, (void *)sp); | 181 free_irq(sp->irq, (void *)sp); |
173 ibmasm_heartbeat_exit(sp); 174 ibmasm_free_remote_queue(sp); | 182 dbg("Cleaning up\n"); 183 ibmasm_free_remote_input_dev(sp); |
175 iounmap(sp->base_address); 176 ibmasm_event_buffer_exit(sp); | 184 iounmap(sp->base_address); 185 ibmasm_event_buffer_exit(sp); |
186 pci_set_drvdata(pdev, NULL); |
|
177 kfree(sp); | 187 kfree(sp); |
188 pci_release_regions(pdev); |
|
178 pci_disable_device(pdev); 179} 180 181static struct pci_device_id ibmasm_pci_table[] = 182{ 183 { PCI_DEVICE(VENDORID_IBM, DEVICEID_RSA) }, 184 {}, 185}; --- 43 unchanged lines hidden --- | 189 pci_disable_device(pdev); 190} 191 192static struct pci_device_id ibmasm_pci_table[] = 193{ 194 { PCI_DEVICE(VENDORID_IBM, DEVICEID_RSA) }, 195 {}, 196}; --- 43 unchanged lines hidden --- |