diff options
Diffstat (limited to 'drivers')
173 files changed, 5168 insertions, 5485 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 33e2ca847a26..82710ae39228 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -205,6 +205,18 @@ config ACPI_IBM | |||
205 | 205 | ||
206 | If you have an IBM ThinkPad laptop, say Y or M here. | 206 | If you have an IBM ThinkPad laptop, say Y or M here. |
207 | 207 | ||
208 | config ACPI_IBM_DOCK | ||
209 | bool "Legacy Docking Station Support" | ||
210 | depends on ACPI_IBM | ||
211 | default n | ||
212 | ---help--- | ||
213 | Allows the ibm_acpi driver to handle docking station events. | ||
214 | This support is obsoleted by CONFIG_HOTPLUG_PCI_ACPI. It will | ||
215 | allow locking and removing the laptop from the docking station, | ||
216 | but will not properly connect PCI devices. | ||
217 | |||
218 | If you are not sure, say N here. | ||
219 | |||
208 | config ACPI_TOSHIBA | 220 | config ACPI_TOSHIBA |
209 | tristate "Toshiba Laptop Extras" | 221 | tristate "Toshiba Laptop Extras" |
210 | depends on X86 | 222 | depends on X86 |
diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c index 5cc090326ddc..262b1f41335a 100644 --- a/drivers/acpi/ibm_acpi.c +++ b/drivers/acpi/ibm_acpi.c | |||
@@ -160,13 +160,13 @@ IBM_HANDLE(cmos, root, "\\UCMS", /* R50, R50e, R50p, R51, T4x, X31, X40 */ | |||
160 | "\\CMOS", /* A3x, G4x, R32, T23, T30, X22-24, X30 */ | 160 | "\\CMOS", /* A3x, G4x, R32, T23, T30, X22-24, X30 */ |
161 | "\\CMS", /* R40, R40e */ | 161 | "\\CMS", /* R40, R40e */ |
162 | ); /* all others */ | 162 | ); /* all others */ |
163 | 163 | #ifdef CONFIG_ACPI_IBM_DOCK | |
164 | IBM_HANDLE(dock, root, "\\_SB.GDCK", /* X30, X31, X40 */ | 164 | IBM_HANDLE(dock, root, "\\_SB.GDCK", /* X30, X31, X40 */ |
165 | "\\_SB.PCI0.DOCK", /* 600e/x,770e,770x,A2xm/p,T20-22,X20-21 */ | 165 | "\\_SB.PCI0.DOCK", /* 600e/x,770e,770x,A2xm/p,T20-22,X20-21 */ |
166 | "\\_SB.PCI0.PCI1.DOCK", /* all others */ | 166 | "\\_SB.PCI0.PCI1.DOCK", /* all others */ |
167 | "\\_SB.PCI.ISA.SLCE", /* 570 */ | 167 | "\\_SB.PCI.ISA.SLCE", /* 570 */ |
168 | ); /* A21e,G4x,R30,R31,R32,R40,R40e,R50e */ | 168 | ); /* A21e,G4x,R30,R31,R32,R40,R40e,R50e */ |
169 | 169 | #endif | |
170 | IBM_HANDLE(bay, root, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */ | 170 | IBM_HANDLE(bay, root, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */ |
171 | "\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */ | 171 | "\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */ |
172 | "\\_SB.PCI0.IDE0.SCND.MSTR", /* all others */ | 172 | "\\_SB.PCI0.IDE0.SCND.MSTR", /* all others */ |
@@ -844,7 +844,7 @@ static int _sta(acpi_handle handle) | |||
844 | 844 | ||
845 | return status; | 845 | return status; |
846 | } | 846 | } |
847 | 847 | #ifdef CONFIG_ACPI_IBM_DOCK | |
848 | #define dock_docked() (_sta(dock_handle) & 1) | 848 | #define dock_docked() (_sta(dock_handle) & 1) |
849 | 849 | ||
850 | static int dock_read(char *p) | 850 | static int dock_read(char *p) |
@@ -907,6 +907,7 @@ static void dock_notify(struct ibm_struct *ibm, u32 event) | |||
907 | acpi_bus_generate_event(ibm->device, event, 0); /* unknown */ | 907 | acpi_bus_generate_event(ibm->device, event, 0); /* unknown */ |
908 | } | 908 | } |
909 | } | 909 | } |
910 | #endif | ||
910 | 911 | ||
911 | static int bay_status_supported; | 912 | static int bay_status_supported; |
912 | static int bay_status2_supported; | 913 | static int bay_status2_supported; |
@@ -1574,6 +1575,7 @@ static struct ibm_struct ibms[] = { | |||
1574 | .read = light_read, | 1575 | .read = light_read, |
1575 | .write = light_write, | 1576 | .write = light_write, |
1576 | }, | 1577 | }, |
1578 | #ifdef CONFIG_ACPI_IBM_DOCK | ||
1577 | { | 1579 | { |
1578 | .name = "dock", | 1580 | .name = "dock", |
1579 | .read = dock_read, | 1581 | .read = dock_read, |
@@ -1589,6 +1591,7 @@ static struct ibm_struct ibms[] = { | |||
1589 | .handle = &pci_handle, | 1591 | .handle = &pci_handle, |
1590 | .type = ACPI_SYSTEM_NOTIFY, | 1592 | .type = ACPI_SYSTEM_NOTIFY, |
1591 | }, | 1593 | }, |
1594 | #endif | ||
1592 | { | 1595 | { |
1593 | .name = "bay", | 1596 | .name = "bay", |
1594 | .init = bay_init, | 1597 | .init = bay_init, |
@@ -1880,7 +1883,9 @@ IBM_PARAM(hotkey); | |||
1880 | IBM_PARAM(bluetooth); | 1883 | IBM_PARAM(bluetooth); |
1881 | IBM_PARAM(video); | 1884 | IBM_PARAM(video); |
1882 | IBM_PARAM(light); | 1885 | IBM_PARAM(light); |
1886 | #ifdef CONFIG_ACPI_IBM_DOCK | ||
1883 | IBM_PARAM(dock); | 1887 | IBM_PARAM(dock); |
1888 | #endif | ||
1884 | IBM_PARAM(bay); | 1889 | IBM_PARAM(bay); |
1885 | IBM_PARAM(cmos); | 1890 | IBM_PARAM(cmos); |
1886 | IBM_PARAM(led); | 1891 | IBM_PARAM(led); |
@@ -1927,7 +1932,9 @@ static int __init acpi_ibm_init(void) | |||
1927 | IBM_HANDLE_INIT(hkey); | 1932 | IBM_HANDLE_INIT(hkey); |
1928 | IBM_HANDLE_INIT(lght); | 1933 | IBM_HANDLE_INIT(lght); |
1929 | IBM_HANDLE_INIT(cmos); | 1934 | IBM_HANDLE_INIT(cmos); |
1935 | #ifdef CONFIG_ACPI_IBM_DOCK | ||
1930 | IBM_HANDLE_INIT(dock); | 1936 | IBM_HANDLE_INIT(dock); |
1937 | #endif | ||
1931 | IBM_HANDLE_INIT(pci); | 1938 | IBM_HANDLE_INIT(pci); |
1932 | IBM_HANDLE_INIT(bay); | 1939 | IBM_HANDLE_INIT(bay); |
1933 | if (bay_handle) | 1940 | if (bay_handle) |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 9271e5209ac1..a0ab828b2cc5 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -23,7 +23,6 @@ static LIST_HEAD(acpi_device_list); | |||
23 | DEFINE_SPINLOCK(acpi_device_lock); | 23 | DEFINE_SPINLOCK(acpi_device_lock); |
24 | LIST_HEAD(acpi_wakeup_device_list); | 24 | LIST_HEAD(acpi_wakeup_device_list); |
25 | 25 | ||
26 | static int acpi_bus_trim(struct acpi_device *start, int rmdevice); | ||
27 | 26 | ||
28 | static void acpi_device_release(struct kobject *kobj) | 27 | static void acpi_device_release(struct kobject *kobj) |
29 | { | 28 | { |
@@ -1284,7 +1283,7 @@ int acpi_bus_start(struct acpi_device *device) | |||
1284 | 1283 | ||
1285 | EXPORT_SYMBOL(acpi_bus_start); | 1284 | EXPORT_SYMBOL(acpi_bus_start); |
1286 | 1285 | ||
1287 | static int acpi_bus_trim(struct acpi_device *start, int rmdevice) | 1286 | int acpi_bus_trim(struct acpi_device *start, int rmdevice) |
1288 | { | 1287 | { |
1289 | acpi_status status; | 1288 | acpi_status status; |
1290 | struct acpi_device *parent, *child; | 1289 | struct acpi_device *parent, *child; |
@@ -1337,6 +1336,8 @@ static int acpi_bus_trim(struct acpi_device *start, int rmdevice) | |||
1337 | } | 1336 | } |
1338 | return err; | 1337 | return err; |
1339 | } | 1338 | } |
1339 | EXPORT_SYMBOL_GPL(acpi_bus_trim); | ||
1340 | |||
1340 | 1341 | ||
1341 | static int acpi_bus_scan_fixed(struct acpi_device *root) | 1342 | static int acpi_bus_scan_fixed(struct acpi_device *root) |
1342 | { | 1343 | { |
diff --git a/drivers/base/power/suspend.c b/drivers/base/power/suspend.c index 8660779fb288..bdb60663f2ef 100644 --- a/drivers/base/power/suspend.c +++ b/drivers/base/power/suspend.c | |||
@@ -8,6 +8,7 @@ | |||
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/vt_kern.h> | ||
11 | #include <linux/device.h> | 12 | #include <linux/device.h> |
12 | #include "../base.h" | 13 | #include "../base.h" |
13 | #include "power.h" | 14 | #include "power.h" |
@@ -62,7 +63,6 @@ int suspend_device(struct device * dev, pm_message_t state) | |||
62 | return error; | 63 | return error; |
63 | } | 64 | } |
64 | 65 | ||
65 | |||
66 | /** | 66 | /** |
67 | * device_suspend - Save state and stop all devices in system. | 67 | * device_suspend - Save state and stop all devices in system. |
68 | * @state: Power state to put each device in. | 68 | * @state: Power state to put each device in. |
@@ -82,6 +82,9 @@ int device_suspend(pm_message_t state) | |||
82 | { | 82 | { |
83 | int error = 0; | 83 | int error = 0; |
84 | 84 | ||
85 | if (!is_console_suspend_safe()) | ||
86 | return -EINVAL; | ||
87 | |||
85 | down(&dpm_sem); | 88 | down(&dpm_sem); |
86 | down(&dpm_list_sem); | 89 | down(&dpm_list_sem); |
87 | while (!list_empty(&dpm_active) && error == 0) { | 90 | while (!list_empty(&dpm_active) && error == 0) { |
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index cf39cf9aac25..e29b8926f80e 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -3268,8 +3268,8 @@ clean2: | |||
3268 | unregister_blkdev(hba[i]->major, hba[i]->devname); | 3268 | unregister_blkdev(hba[i]->major, hba[i]->devname); |
3269 | clean1: | 3269 | clean1: |
3270 | release_io_mem(hba[i]); | 3270 | release_io_mem(hba[i]); |
3271 | free_hba(i); | ||
3272 | hba[i]->busy_initializing = 0; | 3271 | hba[i]->busy_initializing = 0; |
3272 | free_hba(i); | ||
3273 | return(-1); | 3273 | return(-1); |
3274 | } | 3274 | } |
3275 | 3275 | ||
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index d23b54332d7e..fb2d0be7cdeb 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -179,6 +179,7 @@ static int print_unex = 1; | |||
179 | #include <linux/devfs_fs_kernel.h> | 179 | #include <linux/devfs_fs_kernel.h> |
180 | #include <linux/platform_device.h> | 180 | #include <linux/platform_device.h> |
181 | #include <linux/buffer_head.h> /* for invalidate_buffers() */ | 181 | #include <linux/buffer_head.h> /* for invalidate_buffers() */ |
182 | #include <linux/mutex.h> | ||
182 | 183 | ||
183 | /* | 184 | /* |
184 | * PS/2 floppies have much slower step rates than regular floppies. | 185 | * PS/2 floppies have much slower step rates than regular floppies. |
@@ -413,7 +414,7 @@ static struct floppy_write_errors write_errors[N_DRIVE]; | |||
413 | static struct timer_list motor_off_timer[N_DRIVE]; | 414 | static struct timer_list motor_off_timer[N_DRIVE]; |
414 | static struct gendisk *disks[N_DRIVE]; | 415 | static struct gendisk *disks[N_DRIVE]; |
415 | static struct block_device *opened_bdev[N_DRIVE]; | 416 | static struct block_device *opened_bdev[N_DRIVE]; |
416 | static DECLARE_MUTEX(open_lock); | 417 | static DEFINE_MUTEX(open_lock); |
417 | static struct floppy_raw_cmd *raw_cmd, default_raw_cmd; | 418 | static struct floppy_raw_cmd *raw_cmd, default_raw_cmd; |
418 | 419 | ||
419 | /* | 420 | /* |
@@ -3333,7 +3334,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g, | |||
3333 | if (type) { | 3334 | if (type) { |
3334 | if (!capable(CAP_SYS_ADMIN)) | 3335 | if (!capable(CAP_SYS_ADMIN)) |
3335 | return -EPERM; | 3336 | return -EPERM; |
3336 | down(&open_lock); | 3337 | mutex_lock(&open_lock); |
3337 | LOCK_FDC(drive, 1); | 3338 | LOCK_FDC(drive, 1); |
3338 | floppy_type[type] = *g; | 3339 | floppy_type[type] = *g; |
3339 | floppy_type[type].name = "user format"; | 3340 | floppy_type[type].name = "user format"; |
@@ -3347,7 +3348,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g, | |||
3347 | continue; | 3348 | continue; |
3348 | __invalidate_device(bdev); | 3349 | __invalidate_device(bdev); |
3349 | } | 3350 | } |
3350 | up(&open_lock); | 3351 | mutex_unlock(&open_lock); |
3351 | } else { | 3352 | } else { |
3352 | int oldStretch; | 3353 | int oldStretch; |
3353 | LOCK_FDC(drive, 1); | 3354 | LOCK_FDC(drive, 1); |
@@ -3674,7 +3675,7 @@ static int floppy_release(struct inode *inode, struct file *filp) | |||
3674 | { | 3675 | { |
3675 | int drive = (long)inode->i_bdev->bd_disk->private_data; | 3676 | int drive = (long)inode->i_bdev->bd_disk->private_data; |
3676 | 3677 | ||
3677 | down(&open_lock); | 3678 | mutex_lock(&open_lock); |
3678 | if (UDRS->fd_ref < 0) | 3679 | if (UDRS->fd_ref < 0) |
3679 | UDRS->fd_ref = 0; | 3680 | UDRS->fd_ref = 0; |
3680 | else if (!UDRS->fd_ref--) { | 3681 | else if (!UDRS->fd_ref--) { |
@@ -3684,7 +3685,7 @@ static int floppy_release(struct inode *inode, struct file *filp) | |||
3684 | if (!UDRS->fd_ref) | 3685 | if (!UDRS->fd_ref) |
3685 | opened_bdev[drive] = NULL; | 3686 | opened_bdev[drive] = NULL; |
3686 | floppy_release_irq_and_dma(); | 3687 | floppy_release_irq_and_dma(); |
3687 | up(&open_lock); | 3688 | mutex_unlock(&open_lock); |
3688 | return 0; | 3689 | return 0; |
3689 | } | 3690 | } |
3690 | 3691 | ||
@@ -3702,7 +3703,7 @@ static int floppy_open(struct inode *inode, struct file *filp) | |||
3702 | char *tmp; | 3703 | char *tmp; |
3703 | 3704 | ||
3704 | filp->private_data = (void *)0; | 3705 | filp->private_data = (void *)0; |
3705 | down(&open_lock); | 3706 | mutex_lock(&open_lock); |
3706 | old_dev = UDRS->fd_device; | 3707 | old_dev = UDRS->fd_device; |
3707 | if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev) | 3708 | if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev) |
3708 | goto out2; | 3709 | goto out2; |
@@ -3785,7 +3786,7 @@ static int floppy_open(struct inode *inode, struct file *filp) | |||
3785 | if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE))) | 3786 | if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE))) |
3786 | goto out; | 3787 | goto out; |
3787 | } | 3788 | } |
3788 | up(&open_lock); | 3789 | mutex_unlock(&open_lock); |
3789 | return 0; | 3790 | return 0; |
3790 | out: | 3791 | out: |
3791 | if (UDRS->fd_ref < 0) | 3792 | if (UDRS->fd_ref < 0) |
@@ -3796,7 +3797,7 @@ out: | |||
3796 | opened_bdev[drive] = NULL; | 3797 | opened_bdev[drive] = NULL; |
3797 | floppy_release_irq_and_dma(); | 3798 | floppy_release_irq_and_dma(); |
3798 | out2: | 3799 | out2: |
3799 | up(&open_lock); | 3800 | mutex_unlock(&open_lock); |
3800 | return res; | 3801 | return res; |
3801 | } | 3802 | } |
3802 | 3803 | ||
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 0010704739e3..74bf0255e98f 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
@@ -1144,7 +1144,7 @@ static int lo_ioctl(struct inode * inode, struct file * file, | |||
1144 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; | 1144 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; |
1145 | int err; | 1145 | int err; |
1146 | 1146 | ||
1147 | down(&lo->lo_ctl_mutex); | 1147 | mutex_lock(&lo->lo_ctl_mutex); |
1148 | switch (cmd) { | 1148 | switch (cmd) { |
1149 | case LOOP_SET_FD: | 1149 | case LOOP_SET_FD: |
1150 | err = loop_set_fd(lo, file, inode->i_bdev, arg); | 1150 | err = loop_set_fd(lo, file, inode->i_bdev, arg); |
@@ -1170,7 +1170,7 @@ static int lo_ioctl(struct inode * inode, struct file * file, | |||
1170 | default: | 1170 | default: |
1171 | err = lo->ioctl ? lo->ioctl(lo, cmd, arg) : -EINVAL; | 1171 | err = lo->ioctl ? lo->ioctl(lo, cmd, arg) : -EINVAL; |
1172 | } | 1172 | } |
1173 | up(&lo->lo_ctl_mutex); | 1173 | mutex_unlock(&lo->lo_ctl_mutex); |
1174 | return err; | 1174 | return err; |
1175 | } | 1175 | } |
1176 | 1176 | ||
@@ -1178,9 +1178,9 @@ static int lo_open(struct inode *inode, struct file *file) | |||
1178 | { | 1178 | { |
1179 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; | 1179 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; |
1180 | 1180 | ||
1181 | down(&lo->lo_ctl_mutex); | 1181 | mutex_lock(&lo->lo_ctl_mutex); |
1182 | lo->lo_refcnt++; | 1182 | lo->lo_refcnt++; |
1183 | up(&lo->lo_ctl_mutex); | 1183 | mutex_unlock(&lo->lo_ctl_mutex); |
1184 | 1184 | ||
1185 | return 0; | 1185 | return 0; |
1186 | } | 1186 | } |
@@ -1189,9 +1189,9 @@ static int lo_release(struct inode *inode, struct file *file) | |||
1189 | { | 1189 | { |
1190 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; | 1190 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; |
1191 | 1191 | ||
1192 | down(&lo->lo_ctl_mutex); | 1192 | mutex_lock(&lo->lo_ctl_mutex); |
1193 | --lo->lo_refcnt; | 1193 | --lo->lo_refcnt; |
1194 | up(&lo->lo_ctl_mutex); | 1194 | mutex_unlock(&lo->lo_ctl_mutex); |
1195 | 1195 | ||
1196 | return 0; | 1196 | return 0; |
1197 | } | 1197 | } |
@@ -1233,12 +1233,12 @@ int loop_unregister_transfer(int number) | |||
1233 | xfer_funcs[n] = NULL; | 1233 | xfer_funcs[n] = NULL; |
1234 | 1234 | ||
1235 | for (lo = &loop_dev[0]; lo < &loop_dev[max_loop]; lo++) { | 1235 | for (lo = &loop_dev[0]; lo < &loop_dev[max_loop]; lo++) { |
1236 | down(&lo->lo_ctl_mutex); | 1236 | mutex_lock(&lo->lo_ctl_mutex); |
1237 | 1237 | ||
1238 | if (lo->lo_encryption == xfer) | 1238 | if (lo->lo_encryption == xfer) |
1239 | loop_release_xfer(lo); | 1239 | loop_release_xfer(lo); |
1240 | 1240 | ||
1241 | up(&lo->lo_ctl_mutex); | 1241 | mutex_unlock(&lo->lo_ctl_mutex); |
1242 | } | 1242 | } |
1243 | 1243 | ||
1244 | return 0; | 1244 | return 0; |
@@ -1285,7 +1285,7 @@ static int __init loop_init(void) | |||
1285 | lo->lo_queue = blk_alloc_queue(GFP_KERNEL); | 1285 | lo->lo_queue = blk_alloc_queue(GFP_KERNEL); |
1286 | if (!lo->lo_queue) | 1286 | if (!lo->lo_queue) |
1287 | goto out_mem4; | 1287 | goto out_mem4; |
1288 | init_MUTEX(&lo->lo_ctl_mutex); | 1288 | mutex_init(&lo->lo_ctl_mutex); |
1289 | init_completion(&lo->lo_done); | 1289 | init_completion(&lo->lo_done); |
1290 | init_completion(&lo->lo_bh_done); | 1290 | init_completion(&lo->lo_bh_done); |
1291 | lo->lo_number = i; | 1291 | lo->lo_number = i; |
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 6997d8e6bfb5..a9bde30dadad 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -459,9 +459,9 @@ static void do_nbd_request(request_queue_t * q) | |||
459 | req->errors = 0; | 459 | req->errors = 0; |
460 | spin_unlock_irq(q->queue_lock); | 460 | spin_unlock_irq(q->queue_lock); |
461 | 461 | ||
462 | down(&lo->tx_lock); | 462 | mutex_lock(&lo->tx_lock); |
463 | if (unlikely(!lo->sock)) { | 463 | if (unlikely(!lo->sock)) { |
464 | up(&lo->tx_lock); | 464 | mutex_unlock(&lo->tx_lock); |
465 | printk(KERN_ERR "%s: Attempted send on closed socket\n", | 465 | printk(KERN_ERR "%s: Attempted send on closed socket\n", |
466 | lo->disk->disk_name); | 466 | lo->disk->disk_name); |
467 | req->errors++; | 467 | req->errors++; |
@@ -484,7 +484,7 @@ static void do_nbd_request(request_queue_t * q) | |||
484 | } | 484 | } |
485 | 485 | ||
486 | lo->active_req = NULL; | 486 | lo->active_req = NULL; |
487 | up(&lo->tx_lock); | 487 | mutex_unlock(&lo->tx_lock); |
488 | wake_up_all(&lo->active_wq); | 488 | wake_up_all(&lo->active_wq); |
489 | 489 | ||
490 | spin_lock_irq(q->queue_lock); | 490 | spin_lock_irq(q->queue_lock); |
@@ -534,9 +534,9 @@ static int nbd_ioctl(struct inode *inode, struct file *file, | |||
534 | 534 | ||
535 | case NBD_CLEAR_SOCK: | 535 | case NBD_CLEAR_SOCK: |
536 | error = 0; | 536 | error = 0; |
537 | down(&lo->tx_lock); | 537 | mutex_lock(&lo->tx_lock); |
538 | lo->sock = NULL; | 538 | lo->sock = NULL; |
539 | up(&lo->tx_lock); | 539 | mutex_unlock(&lo->tx_lock); |
540 | file = lo->file; | 540 | file = lo->file; |
541 | lo->file = NULL; | 541 | lo->file = NULL; |
542 | nbd_clear_que(lo); | 542 | nbd_clear_que(lo); |
@@ -590,7 +590,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file, | |||
590 | * FIXME: This code is duplicated from sys_shutdown, but | 590 | * FIXME: This code is duplicated from sys_shutdown, but |
591 | * there should be a more generic interface rather than | 591 | * there should be a more generic interface rather than |
592 | * calling socket ops directly here */ | 592 | * calling socket ops directly here */ |
593 | down(&lo->tx_lock); | 593 | mutex_lock(&lo->tx_lock); |
594 | if (lo->sock) { | 594 | if (lo->sock) { |
595 | printk(KERN_WARNING "%s: shutting down socket\n", | 595 | printk(KERN_WARNING "%s: shutting down socket\n", |
596 | lo->disk->disk_name); | 596 | lo->disk->disk_name); |
@@ -598,7 +598,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file, | |||
598 | SEND_SHUTDOWN|RCV_SHUTDOWN); | 598 | SEND_SHUTDOWN|RCV_SHUTDOWN); |
599 | lo->sock = NULL; | 599 | lo->sock = NULL; |
600 | } | 600 | } |
601 | up(&lo->tx_lock); | 601 | mutex_unlock(&lo->tx_lock); |
602 | file = lo->file; | 602 | file = lo->file; |
603 | lo->file = NULL; | 603 | lo->file = NULL; |
604 | nbd_clear_que(lo); | 604 | nbd_clear_que(lo); |
@@ -683,7 +683,7 @@ static int __init nbd_init(void) | |||
683 | nbd_dev[i].flags = 0; | 683 | nbd_dev[i].flags = 0; |
684 | spin_lock_init(&nbd_dev[i].queue_lock); | 684 | spin_lock_init(&nbd_dev[i].queue_lock); |
685 | INIT_LIST_HEAD(&nbd_dev[i].queue_head); | 685 | INIT_LIST_HEAD(&nbd_dev[i].queue_head); |
686 | init_MUTEX(&nbd_dev[i].tx_lock); | 686 | mutex_init(&nbd_dev[i].tx_lock); |
687 | init_waitqueue_head(&nbd_dev[i].active_wq); | 687 | init_waitqueue_head(&nbd_dev[i].active_wq); |
688 | nbd_dev[i].blksize = 1024; | 688 | nbd_dev[i].blksize = 1024; |
689 | nbd_dev[i].bytesize = 0x7ffffc00ULL << 10; /* 2TB */ | 689 | nbd_dev[i].bytesize = 0x7ffffc00ULL << 10; /* 2TB */ |
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 476a5b553f34..1d261f985f31 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -56,6 +56,7 @@ | |||
56 | #include <linux/seq_file.h> | 56 | #include <linux/seq_file.h> |
57 | #include <linux/miscdevice.h> | 57 | #include <linux/miscdevice.h> |
58 | #include <linux/suspend.h> | 58 | #include <linux/suspend.h> |
59 | #include <linux/mutex.h> | ||
59 | #include <scsi/scsi_cmnd.h> | 60 | #include <scsi/scsi_cmnd.h> |
60 | #include <scsi/scsi_ioctl.h> | 61 | #include <scsi/scsi_ioctl.h> |
61 | #include <scsi/scsi.h> | 62 | #include <scsi/scsi.h> |
@@ -81,7 +82,7 @@ | |||
81 | static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; | 82 | static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; |
82 | static struct proc_dir_entry *pkt_proc; | 83 | static struct proc_dir_entry *pkt_proc; |
83 | static int pkt_major; | 84 | static int pkt_major; |
84 | static struct semaphore ctl_mutex; /* Serialize open/close/setup/teardown */ | 85 | static struct mutex ctl_mutex; /* Serialize open/close/setup/teardown */ |
85 | static mempool_t *psd_pool; | 86 | static mempool_t *psd_pool; |
86 | 87 | ||
87 | 88 | ||
@@ -2018,7 +2019,7 @@ static int pkt_open(struct inode *inode, struct file *file) | |||
2018 | 2019 | ||
2019 | VPRINTK("pktcdvd: entering open\n"); | 2020 | VPRINTK("pktcdvd: entering open\n"); |
2020 | 2021 | ||
2021 | down(&ctl_mutex); | 2022 | mutex_lock(&ctl_mutex); |
2022 | pd = pkt_find_dev_from_minor(iminor(inode)); | 2023 | pd = pkt_find_dev_from_minor(iminor(inode)); |
2023 | if (!pd) { | 2024 | if (!pd) { |
2024 | ret = -ENODEV; | 2025 | ret = -ENODEV; |
@@ -2044,14 +2045,14 @@ static int pkt_open(struct inode *inode, struct file *file) | |||
2044 | set_blocksize(inode->i_bdev, CD_FRAMESIZE); | 2045 | set_blocksize(inode->i_bdev, CD_FRAMESIZE); |
2045 | } | 2046 | } |
2046 | 2047 | ||
2047 | up(&ctl_mutex); | 2048 | mutex_unlock(&ctl_mutex); |
2048 | return 0; | 2049 | return 0; |
2049 | 2050 | ||
2050 | out_dec: | 2051 | out_dec: |
2051 | pd->refcnt--; | 2052 | pd->refcnt--; |
2052 | out: | 2053 | out: |
2053 | VPRINTK("pktcdvd: failed open (%d)\n", ret); | 2054 | VPRINTK("pktcdvd: failed open (%d)\n", ret); |
2054 | up(&ctl_mutex); | 2055 | mutex_unlock(&ctl_mutex); |
2055 | return ret; | 2056 | return ret; |
2056 | } | 2057 | } |
2057 | 2058 | ||
@@ -2060,14 +2061,14 @@ static int pkt_close(struct inode *inode, struct file *file) | |||
2060 | struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; | 2061 | struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; |
2061 | int ret = 0; | 2062 | int ret = 0; |
2062 | 2063 | ||
2063 | down(&ctl_mutex); | 2064 | mutex_lock(&ctl_mutex); |
2064 | pd->refcnt--; | 2065 | pd->refcnt--; |
2065 | BUG_ON(pd->refcnt < 0); | 2066 | BUG_ON(pd->refcnt < 0); |
2066 | if (pd->refcnt == 0) { | 2067 | if (pd->refcnt == 0) { |
2067 | int flush = test_bit(PACKET_WRITABLE, &pd->flags); | 2068 | int flush = test_bit(PACKET_WRITABLE, &pd->flags); |
2068 | pkt_release_dev(pd, flush); | 2069 | pkt_release_dev(pd, flush); |
2069 | } | 2070 | } |
2070 | up(&ctl_mutex); | 2071 | mutex_unlock(&ctl_mutex); |
2071 | return ret; | 2072 | return ret; |
2072 | } | 2073 | } |
2073 | 2074 | ||
@@ -2596,21 +2597,21 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm | |||
2596 | case PKT_CTRL_CMD_SETUP: | 2597 | case PKT_CTRL_CMD_SETUP: |
2597 | if (!capable(CAP_SYS_ADMIN)) | 2598 | if (!capable(CAP_SYS_ADMIN)) |
2598 | return -EPERM; | 2599 | return -EPERM; |
2599 | down(&ctl_mutex); | 2600 | mutex_lock(&ctl_mutex); |
2600 | ret = pkt_setup_dev(&ctrl_cmd); | 2601 | ret = pkt_setup_dev(&ctrl_cmd); |
2601 | up(&ctl_mutex); | 2602 | mutex_unlock(&ctl_mutex); |
2602 | break; | 2603 | break; |
2603 | case PKT_CTRL_CMD_TEARDOWN: | 2604 | case PKT_CTRL_CMD_TEARDOWN: |
2604 | if (!capable(CAP_SYS_ADMIN)) | 2605 | if (!capable(CAP_SYS_ADMIN)) |
2605 | return -EPERM; | 2606 | return -EPERM; |
2606 | down(&ctl_mutex); | 2607 | mutex_lock(&ctl_mutex); |
2607 | ret = pkt_remove_dev(&ctrl_cmd); | 2608 | ret = pkt_remove_dev(&ctrl_cmd); |
2608 | up(&ctl_mutex); | 2609 | mutex_unlock(&ctl_mutex); |
2609 | break; | 2610 | break; |
2610 | case PKT_CTRL_CMD_STATUS: | 2611 | case PKT_CTRL_CMD_STATUS: |
2611 | down(&ctl_mutex); | 2612 | mutex_lock(&ctl_mutex); |
2612 | pkt_get_status(&ctrl_cmd); | 2613 | pkt_get_status(&ctrl_cmd); |
2613 | up(&ctl_mutex); | 2614 | mutex_unlock(&ctl_mutex); |
2614 | break; | 2615 | break; |
2615 | default: | 2616 | default: |
2616 | return -ENOTTY; | 2617 | return -ENOTTY; |
@@ -2656,7 +2657,7 @@ static int __init pkt_init(void) | |||
2656 | goto out; | 2657 | goto out; |
2657 | } | 2658 | } |
2658 | 2659 | ||
2659 | init_MUTEX(&ctl_mutex); | 2660 | mutex_init(&ctl_mutex); |
2660 | 2661 | ||
2661 | pkt_proc = proc_mkdir("pktcdvd", proc_root_driver); | 2662 | pkt_proc = proc_mkdir("pktcdvd", proc_root_driver); |
2662 | 2663 | ||
diff --git a/drivers/block/rd.c b/drivers/block/rd.c index ffd6abd6d5a0..1c54f46d3f70 100644 --- a/drivers/block/rd.c +++ b/drivers/block/rd.c | |||
@@ -310,12 +310,12 @@ static int rd_ioctl(struct inode *inode, struct file *file, | |||
310 | * cache | 310 | * cache |
311 | */ | 311 | */ |
312 | error = -EBUSY; | 312 | error = -EBUSY; |
313 | down(&bdev->bd_sem); | 313 | mutex_lock(&bdev->bd_mutex); |
314 | if (bdev->bd_openers <= 2) { | 314 | if (bdev->bd_openers <= 2) { |
315 | truncate_inode_pages(bdev->bd_inode->i_mapping, 0); | 315 | truncate_inode_pages(bdev->bd_inode->i_mapping, 0); |
316 | error = 0; | 316 | error = 0; |
317 | } | 317 | } |
318 | up(&bdev->bd_sem); | 318 | mutex_unlock(&bdev->bd_mutex); |
319 | return error; | 319 | return error; |
320 | } | 320 | } |
321 | 321 | ||
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 879bbc26ce96..a59876a0bfa1 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c | |||
@@ -407,7 +407,6 @@ int register_cdrom(struct cdrom_device_info *cdi) | |||
407 | ENSURE(get_mcn, CDC_MCN); | 407 | ENSURE(get_mcn, CDC_MCN); |
408 | ENSURE(reset, CDC_RESET); | 408 | ENSURE(reset, CDC_RESET); |
409 | ENSURE(audio_ioctl, CDC_PLAY_AUDIO); | 409 | ENSURE(audio_ioctl, CDC_PLAY_AUDIO); |
410 | ENSURE(dev_ioctl, CDC_IOCTLS); | ||
411 | ENSURE(generic_packet, CDC_GENERIC_PACKET); | 410 | ENSURE(generic_packet, CDC_GENERIC_PACKET); |
412 | cdi->mc_flags = 0; | 411 | cdi->mc_flags = 0; |
413 | cdo->n_minors = 0; | 412 | cdo->n_minors = 0; |
@@ -2196,395 +2195,586 @@ retry: | |||
2196 | return cdrom_read_cdda_old(cdi, ubuf, lba, nframes); | 2195 | return cdrom_read_cdda_old(cdi, ubuf, lba, nframes); |
2197 | } | 2196 | } |
2198 | 2197 | ||
2199 | /* Just about every imaginable ioctl is supported in the Uniform layer | 2198 | static int cdrom_ioctl_multisession(struct cdrom_device_info *cdi, |
2200 | * these days. ATAPI / SCSI specific code now mainly resides in | 2199 | void __user *argp) |
2201 | * mmc_ioct(). | ||
2202 | */ | ||
2203 | int cdrom_ioctl(struct file * file, struct cdrom_device_info *cdi, | ||
2204 | struct inode *ip, unsigned int cmd, unsigned long arg) | ||
2205 | { | 2200 | { |
2206 | struct cdrom_device_ops *cdo = cdi->ops; | 2201 | struct cdrom_multisession ms_info; |
2202 | u8 requested_format; | ||
2207 | int ret; | 2203 | int ret; |
2208 | 2204 | ||
2209 | /* Try the generic SCSI command ioctl's first.. */ | 2205 | cdinfo(CD_DO_IOCTL, "entering CDROMMULTISESSION\n"); |
2210 | ret = scsi_cmd_ioctl(file, ip->i_bdev->bd_disk, cmd, (void __user *)arg); | 2206 | |
2211 | if (ret != -ENOTTY) | 2207 | if (!(cdi->ops->capability & CDC_MULTI_SESSION)) |
2208 | return -ENOSYS; | ||
2209 | |||
2210 | if (copy_from_user(&ms_info, argp, sizeof(ms_info))) | ||
2211 | return -EFAULT; | ||
2212 | |||
2213 | requested_format = ms_info.addr_format; | ||
2214 | if (requested_format != CDROM_MSF && requested_format != CDROM_LBA) | ||
2215 | return -EINVAL; | ||
2216 | ms_info.addr_format = CDROM_LBA; | ||
2217 | |||
2218 | ret = cdi->ops->get_last_session(cdi, &ms_info); | ||
2219 | if (ret) | ||
2212 | return ret; | 2220 | return ret; |
2213 | 2221 | ||
2214 | /* the first few commands do not deal with audio drive_info, but | 2222 | sanitize_format(&ms_info.addr, &ms_info.addr_format, requested_format); |
2215 | only with routines in cdrom device operations. */ | 2223 | |
2216 | switch (cmd) { | 2224 | if (copy_to_user(argp, &ms_info, sizeof(ms_info))) |
2217 | case CDROMMULTISESSION: { | 2225 | return -EFAULT; |
2218 | struct cdrom_multisession ms_info; | 2226 | |
2219 | u_char requested_format; | 2227 | cdinfo(CD_DO_IOCTL, "CDROMMULTISESSION successful\n"); |
2220 | cdinfo(CD_DO_IOCTL, "entering CDROMMULTISESSION\n"); | 2228 | return 0; |
2221 | if (!(cdo->capability & CDC_MULTI_SESSION)) | 2229 | } |
2222 | return -ENOSYS; | 2230 | |
2223 | IOCTL_IN(arg, struct cdrom_multisession, ms_info); | 2231 | static int cdrom_ioctl_eject(struct cdrom_device_info *cdi) |
2224 | requested_format = ms_info.addr_format; | 2232 | { |
2225 | if (!((requested_format == CDROM_MSF) || | 2233 | cdinfo(CD_DO_IOCTL, "entering CDROMEJECT\n"); |
2226 | (requested_format == CDROM_LBA))) | 2234 | |
2227 | return -EINVAL; | 2235 | if (!CDROM_CAN(CDC_OPEN_TRAY)) |
2228 | ms_info.addr_format = CDROM_LBA; | 2236 | return -ENOSYS; |
2229 | if ((ret=cdo->get_last_session(cdi, &ms_info))) | 2237 | if (cdi->use_count != 1 || keeplocked) |
2238 | return -EBUSY; | ||
2239 | if (CDROM_CAN(CDC_LOCK)) { | ||
2240 | int ret = cdi->ops->lock_door(cdi, 0); | ||
2241 | if (ret) | ||
2230 | return ret; | 2242 | return ret; |
2231 | sanitize_format(&ms_info.addr, &ms_info.addr_format, | 2243 | } |
2232 | requested_format); | ||
2233 | IOCTL_OUT(arg, struct cdrom_multisession, ms_info); | ||
2234 | cdinfo(CD_DO_IOCTL, "CDROMMULTISESSION successful\n"); | ||
2235 | return 0; | ||
2236 | } | ||
2237 | 2244 | ||
2238 | case CDROMEJECT: { | 2245 | return cdi->ops->tray_move(cdi, 1); |
2239 | cdinfo(CD_DO_IOCTL, "entering CDROMEJECT\n"); | 2246 | } |
2240 | if (!CDROM_CAN(CDC_OPEN_TRAY)) | ||
2241 | return -ENOSYS; | ||
2242 | if (cdi->use_count != 1 || keeplocked) | ||
2243 | return -EBUSY; | ||
2244 | if (CDROM_CAN(CDC_LOCK)) | ||
2245 | if ((ret=cdo->lock_door(cdi, 0))) | ||
2246 | return ret; | ||
2247 | 2247 | ||
2248 | return cdo->tray_move(cdi, 1); | 2248 | static int cdrom_ioctl_closetray(struct cdrom_device_info *cdi) |
2249 | } | 2249 | { |
2250 | cdinfo(CD_DO_IOCTL, "entering CDROMCLOSETRAY\n"); | ||
2250 | 2251 | ||
2251 | case CDROMCLOSETRAY: { | 2252 | if (!CDROM_CAN(CDC_CLOSE_TRAY)) |
2252 | cdinfo(CD_DO_IOCTL, "entering CDROMCLOSETRAY\n"); | 2253 | return -ENOSYS; |
2253 | if (!CDROM_CAN(CDC_CLOSE_TRAY)) | 2254 | return cdi->ops->tray_move(cdi, 0); |
2254 | return -ENOSYS; | 2255 | } |
2255 | return cdo->tray_move(cdi, 0); | ||
2256 | } | ||
2257 | 2256 | ||
2258 | case CDROMEJECT_SW: { | 2257 | static int cdrom_ioctl_eject_sw(struct cdrom_device_info *cdi, |
2259 | cdinfo(CD_DO_IOCTL, "entering CDROMEJECT_SW\n"); | 2258 | unsigned long arg) |
2260 | if (!CDROM_CAN(CDC_OPEN_TRAY)) | 2259 | { |
2261 | return -ENOSYS; | 2260 | cdinfo(CD_DO_IOCTL, "entering CDROMEJECT_SW\n"); |
2262 | if (keeplocked) | ||
2263 | return -EBUSY; | ||
2264 | cdi->options &= ~(CDO_AUTO_CLOSE | CDO_AUTO_EJECT); | ||
2265 | if (arg) | ||
2266 | cdi->options |= CDO_AUTO_CLOSE | CDO_AUTO_EJECT; | ||
2267 | return 0; | ||
2268 | } | ||
2269 | 2261 | ||
2270 | case CDROM_MEDIA_CHANGED: { | 2262 | if (!CDROM_CAN(CDC_OPEN_TRAY)) |
2271 | struct cdrom_changer_info *info; | 2263 | return -ENOSYS; |
2272 | int changed; | 2264 | if (keeplocked) |
2265 | return -EBUSY; | ||
2273 | 2266 | ||
2274 | cdinfo(CD_DO_IOCTL, "entering CDROM_MEDIA_CHANGED\n"); | 2267 | cdi->options &= ~(CDO_AUTO_CLOSE | CDO_AUTO_EJECT); |
2275 | if (!CDROM_CAN(CDC_MEDIA_CHANGED)) | 2268 | if (arg) |
2276 | return -ENOSYS; | 2269 | cdi->options |= CDO_AUTO_CLOSE | CDO_AUTO_EJECT; |
2270 | return 0; | ||
2271 | } | ||
2277 | 2272 | ||
2278 | /* cannot select disc or select current disc */ | 2273 | static int cdrom_ioctl_media_changed(struct cdrom_device_info *cdi, |
2279 | if (!CDROM_CAN(CDC_SELECT_DISC) || arg == CDSL_CURRENT) | 2274 | unsigned long arg) |
2280 | return media_changed(cdi, 1); | 2275 | { |
2276 | struct cdrom_changer_info *info; | ||
2277 | int ret; | ||
2281 | 2278 | ||
2282 | if ((unsigned int)arg >= cdi->capacity) | 2279 | cdinfo(CD_DO_IOCTL, "entering CDROM_MEDIA_CHANGED\n"); |
2283 | return -EINVAL; | ||
2284 | 2280 | ||
2285 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 2281 | if (!CDROM_CAN(CDC_MEDIA_CHANGED)) |
2286 | if (!info) | 2282 | return -ENOSYS; |
2287 | return -ENOMEM; | ||
2288 | 2283 | ||
2289 | if ((ret = cdrom_read_mech_status(cdi, info))) { | 2284 | /* cannot select disc or select current disc */ |
2290 | kfree(info); | 2285 | if (!CDROM_CAN(CDC_SELECT_DISC) || arg == CDSL_CURRENT) |
2291 | return ret; | 2286 | return media_changed(cdi, 1); |
2292 | } | ||
2293 | 2287 | ||
2294 | changed = info->slots[arg].change; | 2288 | if ((unsigned int)arg >= cdi->capacity) |
2295 | kfree(info); | 2289 | return -EINVAL; |
2296 | return changed; | ||
2297 | } | ||
2298 | 2290 | ||
2299 | case CDROM_SET_OPTIONS: { | 2291 | info = kmalloc(sizeof(*info), GFP_KERNEL); |
2300 | cdinfo(CD_DO_IOCTL, "entering CDROM_SET_OPTIONS\n"); | 2292 | if (!info) |
2301 | /* options need to be in sync with capability. too late for | 2293 | return -ENOMEM; |
2302 | that, so we have to check each one separately... */ | ||
2303 | switch (arg) { | ||
2304 | case CDO_USE_FFLAGS: | ||
2305 | case CDO_CHECK_TYPE: | ||
2306 | break; | ||
2307 | case CDO_LOCK: | ||
2308 | if (!CDROM_CAN(CDC_LOCK)) | ||
2309 | return -ENOSYS; | ||
2310 | break; | ||
2311 | case 0: | ||
2312 | return cdi->options; | ||
2313 | /* default is basically CDO_[AUTO_CLOSE|AUTO_EJECT] */ | ||
2314 | default: | ||
2315 | if (!CDROM_CAN(arg)) | ||
2316 | return -ENOSYS; | ||
2317 | } | ||
2318 | cdi->options |= (int) arg; | ||
2319 | return cdi->options; | ||
2320 | } | ||
2321 | 2294 | ||
2322 | case CDROM_CLEAR_OPTIONS: { | 2295 | ret = cdrom_read_mech_status(cdi, info); |
2323 | cdinfo(CD_DO_IOCTL, "entering CDROM_CLEAR_OPTIONS\n"); | 2296 | if (!ret) |
2324 | cdi->options &= ~(int) arg; | 2297 | ret = info->slots[arg].change; |
2325 | return cdi->options; | 2298 | kfree(info); |
2326 | } | 2299 | return ret; |
2300 | } | ||
2327 | 2301 | ||
2328 | case CDROM_SELECT_SPEED: { | 2302 | static int cdrom_ioctl_set_options(struct cdrom_device_info *cdi, |
2329 | cdinfo(CD_DO_IOCTL, "entering CDROM_SELECT_SPEED\n"); | 2303 | unsigned long arg) |
2330 | if (!CDROM_CAN(CDC_SELECT_SPEED)) | 2304 | { |
2331 | return -ENOSYS; | 2305 | cdinfo(CD_DO_IOCTL, "entering CDROM_SET_OPTIONS\n"); |
2332 | return cdo->select_speed(cdi, arg); | ||
2333 | } | ||
2334 | 2306 | ||
2335 | case CDROM_SELECT_DISC: { | 2307 | /* |
2336 | cdinfo(CD_DO_IOCTL, "entering CDROM_SELECT_DISC\n"); | 2308 | * Options need to be in sync with capability. |
2337 | if (!CDROM_CAN(CDC_SELECT_DISC)) | 2309 | * Too late for that, so we have to check each one separately. |
2310 | */ | ||
2311 | switch (arg) { | ||
2312 | case CDO_USE_FFLAGS: | ||
2313 | case CDO_CHECK_TYPE: | ||
2314 | break; | ||
2315 | case CDO_LOCK: | ||
2316 | if (!CDROM_CAN(CDC_LOCK)) | ||
2317 | return -ENOSYS; | ||
2318 | break; | ||
2319 | case 0: | ||
2320 | return cdi->options; | ||
2321 | /* default is basically CDO_[AUTO_CLOSE|AUTO_EJECT] */ | ||
2322 | default: | ||
2323 | if (!CDROM_CAN(arg)) | ||
2338 | return -ENOSYS; | 2324 | return -ENOSYS; |
2325 | } | ||
2326 | cdi->options |= (int) arg; | ||
2327 | return cdi->options; | ||
2328 | } | ||
2339 | 2329 | ||
2340 | if ((arg != CDSL_CURRENT) && (arg != CDSL_NONE)) | 2330 | static int cdrom_ioctl_clear_options(struct cdrom_device_info *cdi, |
2341 | if ((int)arg >= cdi->capacity) | 2331 | unsigned long arg) |
2342 | return -EINVAL; | 2332 | { |
2343 | 2333 | cdinfo(CD_DO_IOCTL, "entering CDROM_CLEAR_OPTIONS\n"); | |
2344 | /* cdo->select_disc is a hook to allow a driver-specific | ||
2345 | * way of seleting disc. However, since there is no | ||
2346 | * equiv hook for cdrom_slot_status this may not | ||
2347 | * actually be useful... | ||
2348 | */ | ||
2349 | if (cdo->select_disc != NULL) | ||
2350 | return cdo->select_disc(cdi, arg); | ||
2351 | |||
2352 | /* no driver specific select_disc(), call our own */ | ||
2353 | cdinfo(CD_CHANGER, "Using generic cdrom_select_disc()\n"); | ||
2354 | return cdrom_select_disc(cdi, arg); | ||
2355 | } | ||
2356 | 2334 | ||
2357 | case CDROMRESET: { | 2335 | cdi->options &= ~(int) arg; |
2358 | if (!capable(CAP_SYS_ADMIN)) | 2336 | return cdi->options; |
2359 | return -EACCES; | 2337 | } |
2360 | cdinfo(CD_DO_IOCTL, "entering CDROM_RESET\n"); | ||
2361 | if (!CDROM_CAN(CDC_RESET)) | ||
2362 | return -ENOSYS; | ||
2363 | invalidate_bdev(ip->i_bdev, 0); | ||
2364 | return cdo->reset(cdi); | ||
2365 | } | ||
2366 | 2338 | ||
2367 | case CDROM_LOCKDOOR: { | 2339 | static int cdrom_ioctl_select_speed(struct cdrom_device_info *cdi, |
2368 | cdinfo(CD_DO_IOCTL, "%socking door.\n", arg ? "L" : "Unl"); | 2340 | unsigned long arg) |
2369 | if (!CDROM_CAN(CDC_LOCK)) | 2341 | { |
2370 | return -EDRIVE_CANT_DO_THIS; | 2342 | cdinfo(CD_DO_IOCTL, "entering CDROM_SELECT_SPEED\n"); |
2371 | keeplocked = arg ? 1 : 0; | ||
2372 | /* don't unlock the door on multiple opens,but allow root | ||
2373 | * to do so */ | ||
2374 | if ((cdi->use_count != 1) && !arg && !capable(CAP_SYS_ADMIN)) | ||
2375 | return -EBUSY; | ||
2376 | return cdo->lock_door(cdi, arg); | ||
2377 | } | ||
2378 | 2343 | ||
2379 | case CDROM_DEBUG: { | 2344 | if (!CDROM_CAN(CDC_SELECT_SPEED)) |
2380 | if (!capable(CAP_SYS_ADMIN)) | 2345 | return -ENOSYS; |
2381 | return -EACCES; | 2346 | return cdi->ops->select_speed(cdi, arg); |
2382 | cdinfo(CD_DO_IOCTL, "%sabling debug.\n", arg ? "En" : "Dis"); | 2347 | } |
2383 | debug = arg ? 1 : 0; | ||
2384 | return debug; | ||
2385 | } | ||
2386 | 2348 | ||
2387 | case CDROM_GET_CAPABILITY: { | 2349 | static int cdrom_ioctl_select_disc(struct cdrom_device_info *cdi, |
2388 | cdinfo(CD_DO_IOCTL, "entering CDROM_GET_CAPABILITY\n"); | 2350 | unsigned long arg) |
2389 | return (cdo->capability & ~cdi->mask); | 2351 | { |
2390 | } | 2352 | cdinfo(CD_DO_IOCTL, "entering CDROM_SELECT_DISC\n"); |
2353 | |||
2354 | if (!CDROM_CAN(CDC_SELECT_DISC)) | ||
2355 | return -ENOSYS; | ||
2356 | |||
2357 | if (arg != CDSL_CURRENT && arg != CDSL_NONE) { | ||
2358 | if ((int)arg >= cdi->capacity) | ||
2359 | return -EINVAL; | ||
2360 | } | ||
2361 | |||
2362 | /* | ||
2363 | * ->select_disc is a hook to allow a driver-specific way of | ||
2364 | * seleting disc. However, since there is no equivalent hook for | ||
2365 | * cdrom_slot_status this may not actually be useful... | ||
2366 | */ | ||
2367 | if (cdi->ops->select_disc) | ||
2368 | return cdi->ops->select_disc(cdi, arg); | ||
2369 | |||
2370 | cdinfo(CD_CHANGER, "Using generic cdrom_select_disc()\n"); | ||
2371 | return cdrom_select_disc(cdi, arg); | ||
2372 | } | ||
2373 | |||
2374 | static int cdrom_ioctl_reset(struct cdrom_device_info *cdi, | ||
2375 | struct block_device *bdev) | ||
2376 | { | ||
2377 | cdinfo(CD_DO_IOCTL, "entering CDROM_RESET\n"); | ||
2378 | |||
2379 | if (!capable(CAP_SYS_ADMIN)) | ||
2380 | return -EACCES; | ||
2381 | if (!CDROM_CAN(CDC_RESET)) | ||
2382 | return -ENOSYS; | ||
2383 | invalidate_bdev(bdev, 0); | ||
2384 | return cdi->ops->reset(cdi); | ||
2385 | } | ||
2386 | |||
2387 | static int cdrom_ioctl_lock_door(struct cdrom_device_info *cdi, | ||
2388 | unsigned long arg) | ||
2389 | { | ||
2390 | cdinfo(CD_DO_IOCTL, "%socking door.\n", arg ? "L" : "Unl"); | ||
2391 | |||
2392 | if (!CDROM_CAN(CDC_LOCK)) | ||
2393 | return -EDRIVE_CANT_DO_THIS; | ||
2394 | |||
2395 | keeplocked = arg ? 1 : 0; | ||
2396 | |||
2397 | /* | ||
2398 | * Don't unlock the door on multiple opens by default, but allow | ||
2399 | * root to do so. | ||
2400 | */ | ||
2401 | if (cdi->use_count != 1 && !arg && !capable(CAP_SYS_ADMIN)) | ||
2402 | return -EBUSY; | ||
2403 | return cdi->ops->lock_door(cdi, arg); | ||
2404 | } | ||
2405 | |||
2406 | static int cdrom_ioctl_debug(struct cdrom_device_info *cdi, | ||
2407 | unsigned long arg) | ||
2408 | { | ||
2409 | cdinfo(CD_DO_IOCTL, "%sabling debug.\n", arg ? "En" : "Dis"); | ||
2410 | |||
2411 | if (!capable(CAP_SYS_ADMIN)) | ||
2412 | return -EACCES; | ||
2413 | debug = arg ? 1 : 0; | ||
2414 | return debug; | ||
2415 | } | ||
2391 | 2416 | ||
2392 | /* The following function is implemented, although very few audio | 2417 | static int cdrom_ioctl_get_capability(struct cdrom_device_info *cdi) |
2418 | { | ||
2419 | cdinfo(CD_DO_IOCTL, "entering CDROM_GET_CAPABILITY\n"); | ||
2420 | return (cdi->ops->capability & ~cdi->mask); | ||
2421 | } | ||
2422 | |||
2423 | /* | ||
2424 | * The following function is implemented, although very few audio | ||
2393 | * discs give Universal Product Code information, which should just be | 2425 | * discs give Universal Product Code information, which should just be |
2394 | * the Medium Catalog Number on the box. Note, that the way the code | 2426 | * the Medium Catalog Number on the box. Note, that the way the code |
2395 | * is written on the CD is /not/ uniform across all discs! | 2427 | * is written on the CD is /not/ uniform across all discs! |
2396 | */ | 2428 | */ |
2397 | case CDROM_GET_MCN: { | 2429 | static int cdrom_ioctl_get_mcn(struct cdrom_device_info *cdi, |
2398 | struct cdrom_mcn mcn; | 2430 | void __user *argp) |
2399 | cdinfo(CD_DO_IOCTL, "entering CDROM_GET_MCN\n"); | 2431 | { |
2400 | if (!(cdo->capability & CDC_MCN)) | 2432 | struct cdrom_mcn mcn; |
2401 | return -ENOSYS; | 2433 | int ret; |
2402 | if ((ret=cdo->get_mcn(cdi, &mcn))) | ||
2403 | return ret; | ||
2404 | IOCTL_OUT(arg, struct cdrom_mcn, mcn); | ||
2405 | cdinfo(CD_DO_IOCTL, "CDROM_GET_MCN successful\n"); | ||
2406 | return 0; | ||
2407 | } | ||
2408 | 2434 | ||
2409 | case CDROM_DRIVE_STATUS: { | 2435 | cdinfo(CD_DO_IOCTL, "entering CDROM_GET_MCN\n"); |
2410 | cdinfo(CD_DO_IOCTL, "entering CDROM_DRIVE_STATUS\n"); | ||
2411 | if (!(cdo->capability & CDC_DRIVE_STATUS)) | ||
2412 | return -ENOSYS; | ||
2413 | if (!CDROM_CAN(CDC_SELECT_DISC)) | ||
2414 | return cdo->drive_status(cdi, CDSL_CURRENT); | ||
2415 | if ((arg == CDSL_CURRENT) || (arg == CDSL_NONE)) | ||
2416 | return cdo->drive_status(cdi, CDSL_CURRENT); | ||
2417 | if (((int)arg >= cdi->capacity)) | ||
2418 | return -EINVAL; | ||
2419 | return cdrom_slot_status(cdi, arg); | ||
2420 | } | ||
2421 | 2436 | ||
2422 | /* Ok, this is where problems start. The current interface for the | 2437 | if (!(cdi->ops->capability & CDC_MCN)) |
2423 | CDROM_DISC_STATUS ioctl is flawed. It makes the false assumption | 2438 | return -ENOSYS; |
2424 | that CDs are all CDS_DATA_1 or all CDS_AUDIO, etc. Unfortunatly, | 2439 | ret = cdi->ops->get_mcn(cdi, &mcn); |
2425 | while this is often the case, it is also very common for CDs to | 2440 | if (ret) |
2426 | have some tracks with data, and some tracks with audio. Just | 2441 | return ret; |
2427 | because I feel like it, I declare the following to be the best | ||
2428 | way to cope. If the CD has ANY data tracks on it, it will be | ||
2429 | returned as a data CD. If it has any XA tracks, I will return | ||
2430 | it as that. Now I could simplify this interface by combining these | ||
2431 | returns with the above, but this more clearly demonstrates | ||
2432 | the problem with the current interface. Too bad this wasn't | ||
2433 | designed to use bitmasks... -Erik | ||
2434 | |||
2435 | Well, now we have the option CDS_MIXED: a mixed-type CD. | ||
2436 | User level programmers might feel the ioctl is not very useful. | ||
2437 | ---david | ||
2438 | */ | ||
2439 | case CDROM_DISC_STATUS: { | ||
2440 | tracktype tracks; | ||
2441 | cdinfo(CD_DO_IOCTL, "entering CDROM_DISC_STATUS\n"); | ||
2442 | cdrom_count_tracks(cdi, &tracks); | ||
2443 | if (tracks.error) | ||
2444 | return(tracks.error); | ||
2445 | |||
2446 | /* Policy mode on */ | ||
2447 | if (tracks.audio > 0) { | ||
2448 | if (tracks.data==0 && tracks.cdi==0 && tracks.xa==0) | ||
2449 | return CDS_AUDIO; | ||
2450 | else | ||
2451 | return CDS_MIXED; | ||
2452 | } | ||
2453 | if (tracks.cdi > 0) return CDS_XA_2_2; | ||
2454 | if (tracks.xa > 0) return CDS_XA_2_1; | ||
2455 | if (tracks.data > 0) return CDS_DATA_1; | ||
2456 | /* Policy mode off */ | ||
2457 | 2442 | ||
2458 | cdinfo(CD_WARNING,"This disc doesn't have any tracks I recognize!\n"); | 2443 | if (copy_to_user(argp, &mcn, sizeof(mcn))) |
2459 | return CDS_NO_INFO; | 2444 | return -EFAULT; |
2460 | } | 2445 | cdinfo(CD_DO_IOCTL, "CDROM_GET_MCN successful\n"); |
2446 | return 0; | ||
2447 | } | ||
2461 | 2448 | ||
2462 | case CDROM_CHANGER_NSLOTS: { | 2449 | static int cdrom_ioctl_drive_status(struct cdrom_device_info *cdi, |
2463 | cdinfo(CD_DO_IOCTL, "entering CDROM_CHANGER_NSLOTS\n"); | 2450 | unsigned long arg) |
2464 | return cdi->capacity; | 2451 | { |
2465 | } | 2452 | cdinfo(CD_DO_IOCTL, "entering CDROM_DRIVE_STATUS\n"); |
2453 | |||
2454 | if (!(cdi->ops->capability & CDC_DRIVE_STATUS)) | ||
2455 | return -ENOSYS; | ||
2456 | if (!CDROM_CAN(CDC_SELECT_DISC) || | ||
2457 | (arg == CDSL_CURRENT || arg == CDSL_NONE)) | ||
2458 | return cdi->ops->drive_status(cdi, CDSL_CURRENT); | ||
2459 | if (((int)arg >= cdi->capacity)) | ||
2460 | return -EINVAL; | ||
2461 | return cdrom_slot_status(cdi, arg); | ||
2462 | } | ||
2463 | |||
2464 | /* | ||
2465 | * Ok, this is where problems start. The current interface for the | ||
2466 | * CDROM_DISC_STATUS ioctl is flawed. It makes the false assumption that | ||
2467 | * CDs are all CDS_DATA_1 or all CDS_AUDIO, etc. Unfortunatly, while this | ||
2468 | * is often the case, it is also very common for CDs to have some tracks | ||
2469 | * with data, and some tracks with audio. Just because I feel like it, | ||
2470 | * I declare the following to be the best way to cope. If the CD has ANY | ||
2471 | * data tracks on it, it will be returned as a data CD. If it has any XA | ||
2472 | * tracks, I will return it as that. Now I could simplify this interface | ||
2473 | * by combining these returns with the above, but this more clearly | ||
2474 | * demonstrates the problem with the current interface. Too bad this | ||
2475 | * wasn't designed to use bitmasks... -Erik | ||
2476 | * | ||
2477 | * Well, now we have the option CDS_MIXED: a mixed-type CD. | ||
2478 | * User level programmers might feel the ioctl is not very useful. | ||
2479 | * ---david | ||
2480 | */ | ||
2481 | static int cdrom_ioctl_disc_status(struct cdrom_device_info *cdi) | ||
2482 | { | ||
2483 | tracktype tracks; | ||
2484 | |||
2485 | cdinfo(CD_DO_IOCTL, "entering CDROM_DISC_STATUS\n"); | ||
2486 | |||
2487 | cdrom_count_tracks(cdi, &tracks); | ||
2488 | if (tracks.error) | ||
2489 | return tracks.error; | ||
2490 | |||
2491 | /* Policy mode on */ | ||
2492 | if (tracks.audio > 0) { | ||
2493 | if (!tracks.data && !tracks.cdi && !tracks.xa) | ||
2494 | return CDS_AUDIO; | ||
2495 | else | ||
2496 | return CDS_MIXED; | ||
2466 | } | 2497 | } |
2467 | 2498 | ||
2468 | /* use the ioctls that are implemented through the generic_packet() | 2499 | if (tracks.cdi > 0) |
2469 | interface. this may look at bit funny, but if -ENOTTY is | 2500 | return CDS_XA_2_2; |
2470 | returned that particular ioctl is not implemented and we | 2501 | if (tracks.xa > 0) |
2471 | let it go through the device specific ones. */ | 2502 | return CDS_XA_2_1; |
2503 | if (tracks.data > 0) | ||
2504 | return CDS_DATA_1; | ||
2505 | /* Policy mode off */ | ||
2506 | |||
2507 | cdinfo(CD_WARNING,"This disc doesn't have any tracks I recognize!\n"); | ||
2508 | return CDS_NO_INFO; | ||
2509 | } | ||
2510 | |||
2511 | static int cdrom_ioctl_changer_nslots(struct cdrom_device_info *cdi) | ||
2512 | { | ||
2513 | cdinfo(CD_DO_IOCTL, "entering CDROM_CHANGER_NSLOTS\n"); | ||
2514 | return cdi->capacity; | ||
2515 | } | ||
2516 | |||
2517 | static int cdrom_ioctl_get_subchnl(struct cdrom_device_info *cdi, | ||
2518 | void __user *argp) | ||
2519 | { | ||
2520 | struct cdrom_subchnl q; | ||
2521 | u8 requested, back; | ||
2522 | int ret; | ||
2523 | |||
2524 | /* cdinfo(CD_DO_IOCTL,"entering CDROMSUBCHNL\n");*/ | ||
2525 | |||
2526 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2527 | return -ENOSYS; | ||
2528 | if (copy_from_user(&q, argp, sizeof(q))) | ||
2529 | return -EFAULT; | ||
2530 | |||
2531 | requested = q.cdsc_format; | ||
2532 | if (requested != CDROM_MSF && requested != CDROM_LBA) | ||
2533 | return -EINVAL; | ||
2534 | q.cdsc_format = CDROM_MSF; | ||
2535 | |||
2536 | ret = cdi->ops->audio_ioctl(cdi, CDROMSUBCHNL, &q); | ||
2537 | if (ret) | ||
2538 | return ret; | ||
2539 | |||
2540 | back = q.cdsc_format; /* local copy */ | ||
2541 | sanitize_format(&q.cdsc_absaddr, &back, requested); | ||
2542 | sanitize_format(&q.cdsc_reladdr, &q.cdsc_format, requested); | ||
2543 | |||
2544 | if (copy_to_user(argp, &q, sizeof(q))) | ||
2545 | return -EFAULT; | ||
2546 | /* cdinfo(CD_DO_IOCTL, "CDROMSUBCHNL successful\n"); */ | ||
2547 | return 0; | ||
2548 | } | ||
2549 | |||
2550 | static int cdrom_ioctl_read_tochdr(struct cdrom_device_info *cdi, | ||
2551 | void __user *argp) | ||
2552 | { | ||
2553 | struct cdrom_tochdr header; | ||
2554 | int ret; | ||
2555 | |||
2556 | /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCHDR\n"); */ | ||
2557 | |||
2558 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2559 | return -ENOSYS; | ||
2560 | if (copy_from_user(&header, argp, sizeof(header))) | ||
2561 | return -EFAULT; | ||
2562 | |||
2563 | ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCHDR, &header); | ||
2564 | if (ret) | ||
2565 | return ret; | ||
2566 | |||
2567 | if (copy_to_user(argp, &header, sizeof(header))) | ||
2568 | return -EFAULT; | ||
2569 | /* cdinfo(CD_DO_IOCTL, "CDROMREADTOCHDR successful\n"); */ | ||
2570 | return 0; | ||
2571 | } | ||
2572 | |||
2573 | static int cdrom_ioctl_read_tocentry(struct cdrom_device_info *cdi, | ||
2574 | void __user *argp) | ||
2575 | { | ||
2576 | struct cdrom_tocentry entry; | ||
2577 | u8 requested_format; | ||
2578 | int ret; | ||
2579 | |||
2580 | /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCENTRY\n"); */ | ||
2581 | |||
2582 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2583 | return -ENOSYS; | ||
2584 | if (copy_from_user(&entry, argp, sizeof(entry))) | ||
2585 | return -EFAULT; | ||
2586 | |||
2587 | requested_format = entry.cdte_format; | ||
2588 | if (requested_format != CDROM_MSF && requested_format != CDROM_LBA) | ||
2589 | return -EINVAL; | ||
2590 | /* make interface to low-level uniform */ | ||
2591 | entry.cdte_format = CDROM_MSF; | ||
2592 | ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCENTRY, &entry); | ||
2593 | if (ret) | ||
2594 | return ret; | ||
2595 | sanitize_format(&entry.cdte_addr, &entry.cdte_format, requested_format); | ||
2596 | |||
2597 | if (copy_to_user(argp, &entry, sizeof(entry))) | ||
2598 | return -EFAULT; | ||
2599 | /* cdinfo(CD_DO_IOCTL, "CDROMREADTOCENTRY successful\n"); */ | ||
2600 | return 0; | ||
2601 | } | ||
2602 | |||
2603 | static int cdrom_ioctl_play_msf(struct cdrom_device_info *cdi, | ||
2604 | void __user *argp) | ||
2605 | { | ||
2606 | struct cdrom_msf msf; | ||
2607 | |||
2608 | cdinfo(CD_DO_IOCTL, "entering CDROMPLAYMSF\n"); | ||
2609 | |||
2610 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2611 | return -ENOSYS; | ||
2612 | if (copy_from_user(&msf, argp, sizeof(msf))) | ||
2613 | return -EFAULT; | ||
2614 | return cdi->ops->audio_ioctl(cdi, CDROMPLAYMSF, &msf); | ||
2615 | } | ||
2616 | |||
2617 | static int cdrom_ioctl_play_trkind(struct cdrom_device_info *cdi, | ||
2618 | void __user *argp) | ||
2619 | { | ||
2620 | struct cdrom_ti ti; | ||
2621 | int ret; | ||
2622 | |||
2623 | cdinfo(CD_DO_IOCTL, "entering CDROMPLAYTRKIND\n"); | ||
2624 | |||
2625 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2626 | return -ENOSYS; | ||
2627 | if (copy_from_user(&ti, argp, sizeof(ti))) | ||
2628 | return -EFAULT; | ||
2629 | |||
2630 | ret = check_for_audio_disc(cdi, cdi->ops); | ||
2631 | if (ret) | ||
2632 | return ret; | ||
2633 | return cdi->ops->audio_ioctl(cdi, CDROMPLAYTRKIND, &ti); | ||
2634 | } | ||
2635 | static int cdrom_ioctl_volctrl(struct cdrom_device_info *cdi, | ||
2636 | void __user *argp) | ||
2637 | { | ||
2638 | struct cdrom_volctrl volume; | ||
2639 | |||
2640 | cdinfo(CD_DO_IOCTL, "entering CDROMVOLCTRL\n"); | ||
2641 | |||
2642 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2643 | return -ENOSYS; | ||
2644 | if (copy_from_user(&volume, argp, sizeof(volume))) | ||
2645 | return -EFAULT; | ||
2646 | return cdi->ops->audio_ioctl(cdi, CDROMVOLCTRL, &volume); | ||
2647 | } | ||
2648 | |||
2649 | static int cdrom_ioctl_volread(struct cdrom_device_info *cdi, | ||
2650 | void __user *argp) | ||
2651 | { | ||
2652 | struct cdrom_volctrl volume; | ||
2653 | int ret; | ||
2654 | |||
2655 | cdinfo(CD_DO_IOCTL, "entering CDROMVOLREAD\n"); | ||
2656 | |||
2657 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2658 | return -ENOSYS; | ||
2659 | |||
2660 | ret = cdi->ops->audio_ioctl(cdi, CDROMVOLREAD, &volume); | ||
2661 | if (ret) | ||
2662 | return ret; | ||
2663 | |||
2664 | if (copy_to_user(argp, &volume, sizeof(volume))) | ||
2665 | return -EFAULT; | ||
2666 | return 0; | ||
2667 | } | ||
2668 | |||
2669 | static int cdrom_ioctl_audioctl(struct cdrom_device_info *cdi, | ||
2670 | unsigned int cmd) | ||
2671 | { | ||
2672 | int ret; | ||
2673 | |||
2674 | cdinfo(CD_DO_IOCTL, "doing audio ioctl (start/stop/pause/resume)\n"); | ||
2675 | |||
2676 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2677 | return -ENOSYS; | ||
2678 | ret = check_for_audio_disc(cdi, cdi->ops); | ||
2679 | if (ret) | ||
2680 | return ret; | ||
2681 | return cdi->ops->audio_ioctl(cdi, cmd, NULL); | ||
2682 | } | ||
2683 | |||
2684 | /* | ||
2685 | * Just about every imaginable ioctl is supported in the Uniform layer | ||
2686 | * these days. | ||
2687 | * ATAPI / SCSI specific code now mainly resides in mmc_ioctl(). | ||
2688 | */ | ||
2689 | int cdrom_ioctl(struct file * file, struct cdrom_device_info *cdi, | ||
2690 | struct inode *ip, unsigned int cmd, unsigned long arg) | ||
2691 | { | ||
2692 | void __user *argp = (void __user *)arg; | ||
2693 | int ret; | ||
2694 | |||
2695 | /* | ||
2696 | * Try the generic SCSI command ioctl's first. | ||
2697 | */ | ||
2698 | ret = scsi_cmd_ioctl(file, ip->i_bdev->bd_disk, cmd, argp); | ||
2699 | if (ret != -ENOTTY) | ||
2700 | return ret; | ||
2701 | |||
2702 | switch (cmd) { | ||
2703 | case CDROMMULTISESSION: | ||
2704 | return cdrom_ioctl_multisession(cdi, argp); | ||
2705 | case CDROMEJECT: | ||
2706 | return cdrom_ioctl_eject(cdi); | ||
2707 | case CDROMCLOSETRAY: | ||
2708 | return cdrom_ioctl_closetray(cdi); | ||
2709 | case CDROMEJECT_SW: | ||
2710 | return cdrom_ioctl_eject_sw(cdi, arg); | ||
2711 | case CDROM_MEDIA_CHANGED: | ||
2712 | return cdrom_ioctl_media_changed(cdi, arg); | ||
2713 | case CDROM_SET_OPTIONS: | ||
2714 | return cdrom_ioctl_set_options(cdi, arg); | ||
2715 | case CDROM_CLEAR_OPTIONS: | ||
2716 | return cdrom_ioctl_clear_options(cdi, arg); | ||
2717 | case CDROM_SELECT_SPEED: | ||
2718 | return cdrom_ioctl_select_speed(cdi, arg); | ||
2719 | case CDROM_SELECT_DISC: | ||
2720 | return cdrom_ioctl_select_disc(cdi, arg); | ||
2721 | case CDROMRESET: | ||
2722 | return cdrom_ioctl_reset(cdi, ip->i_bdev); | ||
2723 | case CDROM_LOCKDOOR: | ||
2724 | return cdrom_ioctl_lock_door(cdi, arg); | ||
2725 | case CDROM_DEBUG: | ||
2726 | return cdrom_ioctl_debug(cdi, arg); | ||
2727 | case CDROM_GET_CAPABILITY: | ||
2728 | return cdrom_ioctl_get_capability(cdi); | ||
2729 | case CDROM_GET_MCN: | ||
2730 | return cdrom_ioctl_get_mcn(cdi, argp); | ||
2731 | case CDROM_DRIVE_STATUS: | ||
2732 | return cdrom_ioctl_drive_status(cdi, arg); | ||
2733 | case CDROM_DISC_STATUS: | ||
2734 | return cdrom_ioctl_disc_status(cdi); | ||
2735 | case CDROM_CHANGER_NSLOTS: | ||
2736 | return cdrom_ioctl_changer_nslots(cdi); | ||
2737 | } | ||
2738 | |||
2739 | /* | ||
2740 | * Use the ioctls that are implemented through the generic_packet() | ||
2741 | * interface. this may look at bit funny, but if -ENOTTY is | ||
2742 | * returned that particular ioctl is not implemented and we | ||
2743 | * let it go through the device specific ones. | ||
2744 | */ | ||
2472 | if (CDROM_CAN(CDC_GENERIC_PACKET)) { | 2745 | if (CDROM_CAN(CDC_GENERIC_PACKET)) { |
2473 | ret = mmc_ioctl(cdi, cmd, arg); | 2746 | ret = mmc_ioctl(cdi, cmd, arg); |
2474 | if (ret != -ENOTTY) { | 2747 | if (ret != -ENOTTY) |
2475 | return ret; | 2748 | return ret; |
2476 | } | ||
2477 | } | 2749 | } |
2478 | 2750 | ||
2479 | /* note: most of the cdinfo() calls are commented out here, | 2751 | /* |
2480 | because they fill up the sys log when CD players poll | 2752 | * Note: most of the cdinfo() calls are commented out here, |
2481 | the drive. */ | 2753 | * because they fill up the sys log when CD players poll |
2754 | * the drive. | ||
2755 | */ | ||
2482 | switch (cmd) { | 2756 | switch (cmd) { |
2483 | case CDROMSUBCHNL: { | 2757 | case CDROMSUBCHNL: |
2484 | struct cdrom_subchnl q; | 2758 | return cdrom_ioctl_get_subchnl(cdi, argp); |
2485 | u_char requested, back; | 2759 | case CDROMREADTOCHDR: |
2486 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | 2760 | return cdrom_ioctl_read_tochdr(cdi, argp); |
2487 | return -ENOSYS; | 2761 | case CDROMREADTOCENTRY: |
2488 | /* cdinfo(CD_DO_IOCTL,"entering CDROMSUBCHNL\n");*/ | 2762 | return cdrom_ioctl_read_tocentry(cdi, argp); |
2489 | IOCTL_IN(arg, struct cdrom_subchnl, q); | 2763 | case CDROMPLAYMSF: |
2490 | requested = q.cdsc_format; | 2764 | return cdrom_ioctl_play_msf(cdi, argp); |
2491 | if (!((requested == CDROM_MSF) || | 2765 | case CDROMPLAYTRKIND: |
2492 | (requested == CDROM_LBA))) | 2766 | return cdrom_ioctl_play_trkind(cdi, argp); |
2493 | return -EINVAL; | 2767 | case CDROMVOLCTRL: |
2494 | q.cdsc_format = CDROM_MSF; | 2768 | return cdrom_ioctl_volctrl(cdi, argp); |
2495 | if ((ret=cdo->audio_ioctl(cdi, cmd, &q))) | 2769 | case CDROMVOLREAD: |
2496 | return ret; | 2770 | return cdrom_ioctl_volread(cdi, argp); |
2497 | back = q.cdsc_format; /* local copy */ | ||
2498 | sanitize_format(&q.cdsc_absaddr, &back, requested); | ||
2499 | sanitize_format(&q.cdsc_reladdr, &q.cdsc_format, requested); | ||
2500 | IOCTL_OUT(arg, struct cdrom_subchnl, q); | ||
2501 | /* cdinfo(CD_DO_IOCTL, "CDROMSUBCHNL successful\n"); */ | ||
2502 | return 0; | ||
2503 | } | ||
2504 | case CDROMREADTOCHDR: { | ||
2505 | struct cdrom_tochdr header; | ||
2506 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2507 | return -ENOSYS; | ||
2508 | /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCHDR\n"); */ | ||
2509 | IOCTL_IN(arg, struct cdrom_tochdr, header); | ||
2510 | if ((ret=cdo->audio_ioctl(cdi, cmd, &header))) | ||
2511 | return ret; | ||
2512 | IOCTL_OUT(arg, struct cdrom_tochdr, header); | ||
2513 | /* cdinfo(CD_DO_IOCTL, "CDROMREADTOCHDR successful\n"); */ | ||
2514 | return 0; | ||
2515 | } | ||
2516 | case CDROMREADTOCENTRY: { | ||
2517 | struct cdrom_tocentry entry; | ||
2518 | u_char requested_format; | ||
2519 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2520 | return -ENOSYS; | ||
2521 | /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCENTRY\n"); */ | ||
2522 | IOCTL_IN(arg, struct cdrom_tocentry, entry); | ||
2523 | requested_format = entry.cdte_format; | ||
2524 | if (!((requested_format == CDROM_MSF) || | ||
2525 | (requested_format == CDROM_LBA))) | ||
2526 | return -EINVAL; | ||
2527 | /* make interface to low-level uniform */ | ||
2528 | entry.cdte_format = CDROM_MSF; | ||
2529 | if ((ret=cdo->audio_ioctl(cdi, cmd, &entry))) | ||
2530 | return ret; | ||
2531 | sanitize_format(&entry.cdte_addr, | ||
2532 | &entry.cdte_format, requested_format); | ||
2533 | IOCTL_OUT(arg, struct cdrom_tocentry, entry); | ||
2534 | /* cdinfo(CD_DO_IOCTL, "CDROMREADTOCENTRY successful\n"); */ | ||
2535 | return 0; | ||
2536 | } | ||
2537 | case CDROMPLAYMSF: { | ||
2538 | struct cdrom_msf msf; | ||
2539 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2540 | return -ENOSYS; | ||
2541 | cdinfo(CD_DO_IOCTL, "entering CDROMPLAYMSF\n"); | ||
2542 | IOCTL_IN(arg, struct cdrom_msf, msf); | ||
2543 | return cdo->audio_ioctl(cdi, cmd, &msf); | ||
2544 | } | ||
2545 | case CDROMPLAYTRKIND: { | ||
2546 | struct cdrom_ti ti; | ||
2547 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2548 | return -ENOSYS; | ||
2549 | cdinfo(CD_DO_IOCTL, "entering CDROMPLAYTRKIND\n"); | ||
2550 | IOCTL_IN(arg, struct cdrom_ti, ti); | ||
2551 | CHECKAUDIO; | ||
2552 | return cdo->audio_ioctl(cdi, cmd, &ti); | ||
2553 | } | ||
2554 | case CDROMVOLCTRL: { | ||
2555 | struct cdrom_volctrl volume; | ||
2556 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2557 | return -ENOSYS; | ||
2558 | cdinfo(CD_DO_IOCTL, "entering CDROMVOLCTRL\n"); | ||
2559 | IOCTL_IN(arg, struct cdrom_volctrl, volume); | ||
2560 | return cdo->audio_ioctl(cdi, cmd, &volume); | ||
2561 | } | ||
2562 | case CDROMVOLREAD: { | ||
2563 | struct cdrom_volctrl volume; | ||
2564 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2565 | return -ENOSYS; | ||
2566 | cdinfo(CD_DO_IOCTL, "entering CDROMVOLREAD\n"); | ||
2567 | if ((ret=cdo->audio_ioctl(cdi, cmd, &volume))) | ||
2568 | return ret; | ||
2569 | IOCTL_OUT(arg, struct cdrom_volctrl, volume); | ||
2570 | return 0; | ||
2571 | } | ||
2572 | case CDROMSTART: | 2771 | case CDROMSTART: |
2573 | case CDROMSTOP: | 2772 | case CDROMSTOP: |
2574 | case CDROMPAUSE: | 2773 | case CDROMPAUSE: |
2575 | case CDROMRESUME: { | 2774 | case CDROMRESUME: |
2576 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | 2775 | return cdrom_ioctl_audioctl(cdi, cmd); |
2577 | return -ENOSYS; | 2776 | } |
2578 | cdinfo(CD_DO_IOCTL, "doing audio ioctl (start/stop/pause/resume)\n"); | ||
2579 | CHECKAUDIO; | ||
2580 | return cdo->audio_ioctl(cdi, cmd, NULL); | ||
2581 | } | ||
2582 | } /* switch */ | ||
2583 | 2777 | ||
2584 | /* do the device specific ioctls */ | ||
2585 | if (CDROM_CAN(CDC_IOCTLS)) | ||
2586 | return cdo->dev_ioctl(cdi, cmd, arg); | ||
2587 | |||
2588 | return -ENOSYS; | 2778 | return -ENOSYS; |
2589 | } | 2779 | } |
2590 | 2780 | ||
diff --git a/drivers/cdrom/cdu31a.c b/drivers/cdrom/cdu31a.c index 378e88d20757..72ffd64e8b1e 100644 --- a/drivers/cdrom/cdu31a.c +++ b/drivers/cdrom/cdu31a.c | |||
@@ -2668,7 +2668,7 @@ static int scd_audio_ioctl(struct cdrom_device_info *cdi, | |||
2668 | return retval; | 2668 | return retval; |
2669 | } | 2669 | } |
2670 | 2670 | ||
2671 | static int scd_dev_ioctl(struct cdrom_device_info *cdi, | 2671 | static int scd_read_audio(struct cdrom_device_info *cdi, |
2672 | unsigned int cmd, unsigned long arg) | 2672 | unsigned int cmd, unsigned long arg) |
2673 | { | 2673 | { |
2674 | void __user *argp = (void __user *)arg; | 2674 | void __user *argp = (void __user *)arg; |
@@ -2894,11 +2894,10 @@ static struct cdrom_device_ops scd_dops = { | |||
2894 | .get_mcn = scd_get_mcn, | 2894 | .get_mcn = scd_get_mcn, |
2895 | .reset = scd_reset, | 2895 | .reset = scd_reset, |
2896 | .audio_ioctl = scd_audio_ioctl, | 2896 | .audio_ioctl = scd_audio_ioctl, |
2897 | .dev_ioctl = scd_dev_ioctl, | ||
2898 | .capability = CDC_OPEN_TRAY | CDC_CLOSE_TRAY | CDC_LOCK | | 2897 | .capability = CDC_OPEN_TRAY | CDC_CLOSE_TRAY | CDC_LOCK | |
2899 | CDC_SELECT_SPEED | CDC_MULTI_SESSION | | 2898 | CDC_SELECT_SPEED | CDC_MULTI_SESSION | |
2900 | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | | 2899 | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | |
2901 | CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS, | 2900 | CDC_RESET | CDC_DRIVE_STATUS, |
2902 | .n_minors = 1, | 2901 | .n_minors = 1, |
2903 | }; | 2902 | }; |
2904 | 2903 | ||
@@ -2936,6 +2935,9 @@ static int scd_block_ioctl(struct inode *inode, struct file *file, | |||
2936 | case CDROMCLOSETRAY: | 2935 | case CDROMCLOSETRAY: |
2937 | retval = scd_tray_move(&scd_info, 0); | 2936 | retval = scd_tray_move(&scd_info, 0); |
2938 | break; | 2937 | break; |
2938 | case CDROMREADAUDIO: | ||
2939 | retval = scd_read_audio(&scd_info, CDROMREADAUDIO, arg); | ||
2940 | break; | ||
2939 | default: | 2941 | default: |
2940 | retval = cdrom_ioctl(file, &scd_info, inode, cmd, arg); | 2942 | retval = cdrom_ioctl(file, &scd_info, inode, cmd, arg); |
2941 | } | 2943 | } |
diff --git a/drivers/cdrom/cm206.c b/drivers/cdrom/cm206.c index ce127f7ec0f6..fad27a87ce35 100644 --- a/drivers/cdrom/cm206.c +++ b/drivers/cdrom/cm206.c | |||
@@ -1157,32 +1157,6 @@ static int cm206_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, | |||
1157 | } | 1157 | } |
1158 | } | 1158 | } |
1159 | 1159 | ||
1160 | /* Ioctl. These ioctls are specific to the cm206 driver. I have made | ||
1161 | some driver statistics accessible through ioctl calls. | ||
1162 | */ | ||
1163 | |||
1164 | static int cm206_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, | ||
1165 | unsigned long arg) | ||
1166 | { | ||
1167 | switch (cmd) { | ||
1168 | #ifdef STATISTICS | ||
1169 | case CM206CTL_GET_STAT: | ||
1170 | if (arg >= NR_STATS) | ||
1171 | return -EINVAL; | ||
1172 | else | ||
1173 | return cd->stats[arg]; | ||
1174 | case CM206CTL_GET_LAST_STAT: | ||
1175 | if (arg >= NR_STATS) | ||
1176 | return -EINVAL; | ||
1177 | else | ||
1178 | return cd->last_stat[arg]; | ||
1179 | #endif | ||
1180 | default: | ||
1181 | debug(("Unknown ioctl call 0x%x\n", cmd)); | ||
1182 | return -EINVAL; | ||
1183 | } | ||
1184 | } | ||
1185 | |||
1186 | static int cm206_media_changed(struct cdrom_device_info *cdi, int disc_nr) | 1160 | static int cm206_media_changed(struct cdrom_device_info *cdi, int disc_nr) |
1187 | { | 1161 | { |
1188 | if (cd != NULL) { | 1162 | if (cd != NULL) { |
@@ -1321,11 +1295,10 @@ static struct cdrom_device_ops cm206_dops = { | |||
1321 | .get_mcn = cm206_get_upc, | 1295 | .get_mcn = cm206_get_upc, |
1322 | .reset = cm206_reset, | 1296 | .reset = cm206_reset, |
1323 | .audio_ioctl = cm206_audio_ioctl, | 1297 | .audio_ioctl = cm206_audio_ioctl, |
1324 | .dev_ioctl = cm206_ioctl, | ||
1325 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | | 1298 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | |
1326 | CDC_MULTI_SESSION | CDC_MEDIA_CHANGED | | 1299 | CDC_MULTI_SESSION | CDC_MEDIA_CHANGED | |
1327 | CDC_MCN | CDC_PLAY_AUDIO | CDC_SELECT_SPEED | | 1300 | CDC_MCN | CDC_PLAY_AUDIO | CDC_SELECT_SPEED | |
1328 | CDC_IOCTLS | CDC_DRIVE_STATUS, | 1301 | CDC_DRIVE_STATUS, |
1329 | .n_minors = 1, | 1302 | .n_minors = 1, |
1330 | }; | 1303 | }; |
1331 | 1304 | ||
@@ -1350,6 +1323,21 @@ static int cm206_block_release(struct inode *inode, struct file *file) | |||
1350 | static int cm206_block_ioctl(struct inode *inode, struct file *file, | 1323 | static int cm206_block_ioctl(struct inode *inode, struct file *file, |
1351 | unsigned cmd, unsigned long arg) | 1324 | unsigned cmd, unsigned long arg) |
1352 | { | 1325 | { |
1326 | switch (cmd) { | ||
1327 | #ifdef STATISTICS | ||
1328 | case CM206CTL_GET_STAT: | ||
1329 | if (arg >= NR_STATS) | ||
1330 | return -EINVAL; | ||
1331 | return cd->stats[arg]; | ||
1332 | case CM206CTL_GET_LAST_STAT: | ||
1333 | if (arg >= NR_STATS) | ||
1334 | return -EINVAL; | ||
1335 | return cd->last_stat[arg]; | ||
1336 | #endif | ||
1337 | default: | ||
1338 | break; | ||
1339 | } | ||
1340 | |||
1353 | return cdrom_ioctl(file, &cm206_info, inode, cmd, arg); | 1341 | return cdrom_ioctl(file, &cm206_info, inode, cmd, arg); |
1354 | } | 1342 | } |
1355 | 1343 | ||
diff --git a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c index 466e9c2974bd..4760f515f591 100644 --- a/drivers/cdrom/sbpcd.c +++ b/drivers/cdrom/sbpcd.c | |||
@@ -4160,332 +4160,6 @@ static int sbpcd_get_last_session(struct cdrom_device_info *cdi, struct cdrom_mu | |||
4160 | return 0; | 4160 | return 0; |
4161 | } | 4161 | } |
4162 | 4162 | ||
4163 | /*==========================================================================*/ | ||
4164 | /*==========================================================================*/ | ||
4165 | /* | ||
4166 | * ioctl support | ||
4167 | */ | ||
4168 | static int sbpcd_dev_ioctl(struct cdrom_device_info *cdi, u_int cmd, | ||
4169 | u_long arg) | ||
4170 | { | ||
4171 | struct sbpcd_drive *p = cdi->handle; | ||
4172 | int i; | ||
4173 | |||
4174 | msg(DBG_IO2,"ioctl(%s, 0x%08lX, 0x%08lX)\n", cdi->name, cmd, arg); | ||
4175 | if (p->drv_id==-1) { | ||
4176 | msg(DBG_INF, "ioctl: bad device: %s\n", cdi->name); | ||
4177 | return (-ENXIO); /* no such drive */ | ||
4178 | } | ||
4179 | down(&ioctl_read_sem); | ||
4180 | if (p != current_drive) | ||
4181 | switch_drive(p); | ||
4182 | |||
4183 | msg(DBG_IO2,"ioctl: device %s, request %04X\n",cdi->name,cmd); | ||
4184 | switch (cmd) /* Sun-compatible */ | ||
4185 | { | ||
4186 | case DDIOCSDBG: /* DDI Debug */ | ||
4187 | if (!capable(CAP_SYS_ADMIN)) RETURN_UP(-EPERM); | ||
4188 | i=sbpcd_dbg_ioctl(arg,1); | ||
4189 | RETURN_UP(i); | ||
4190 | case CDROMRESET: /* hard reset the drive */ | ||
4191 | msg(DBG_IOC,"ioctl: CDROMRESET entered.\n"); | ||
4192 | i=DriveReset(); | ||
4193 | current_drive->audio_state=0; | ||
4194 | RETURN_UP(i); | ||
4195 | |||
4196 | case CDROMREADMODE1: | ||
4197 | msg(DBG_IOC,"ioctl: CDROMREADMODE1 requested.\n"); | ||
4198 | #ifdef SAFE_MIXED | ||
4199 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); | ||
4200 | #endif /* SAFE_MIXED */ | ||
4201 | cc_ModeSelect(CD_FRAMESIZE); | ||
4202 | cc_ModeSense(); | ||
4203 | current_drive->mode=READ_M1; | ||
4204 | RETURN_UP(0); | ||
4205 | |||
4206 | case CDROMREADMODE2: /* not usable at the moment */ | ||
4207 | msg(DBG_IOC,"ioctl: CDROMREADMODE2 requested.\n"); | ||
4208 | #ifdef SAFE_MIXED | ||
4209 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); | ||
4210 | #endif /* SAFE_MIXED */ | ||
4211 | cc_ModeSelect(CD_FRAMESIZE_RAW1); | ||
4212 | cc_ModeSense(); | ||
4213 | current_drive->mode=READ_M2; | ||
4214 | RETURN_UP(0); | ||
4215 | |||
4216 | case CDROMAUDIOBUFSIZ: /* configure the audio buffer size */ | ||
4217 | msg(DBG_IOC,"ioctl: CDROMAUDIOBUFSIZ entered.\n"); | ||
4218 | if (current_drive->sbp_audsiz>0) | ||
4219 | vfree(current_drive->aud_buf); | ||
4220 | current_drive->aud_buf=NULL; | ||
4221 | current_drive->sbp_audsiz=arg; | ||
4222 | |||
4223 | if (current_drive->sbp_audsiz>16) | ||
4224 | { | ||
4225 | current_drive->sbp_audsiz = 0; | ||
4226 | RETURN_UP(current_drive->sbp_audsiz); | ||
4227 | } | ||
4228 | |||
4229 | if (current_drive->sbp_audsiz>0) | ||
4230 | { | ||
4231 | current_drive->aud_buf=(u_char *) vmalloc(current_drive->sbp_audsiz*CD_FRAMESIZE_RAW); | ||
4232 | if (current_drive->aud_buf==NULL) | ||
4233 | { | ||
4234 | msg(DBG_INF,"audio buffer (%d frames) not available.\n",current_drive->sbp_audsiz); | ||
4235 | current_drive->sbp_audsiz=0; | ||
4236 | } | ||
4237 | else msg(DBG_INF,"audio buffer size: %d frames.\n",current_drive->sbp_audsiz); | ||
4238 | } | ||
4239 | RETURN_UP(current_drive->sbp_audsiz); | ||
4240 | |||
4241 | case CDROMREADAUDIO: | ||
4242 | { /* start of CDROMREADAUDIO */ | ||
4243 | int i=0, j=0, frame, block=0; | ||
4244 | u_int try=0; | ||
4245 | u_long timeout; | ||
4246 | u_char *p; | ||
4247 | u_int data_tries = 0; | ||
4248 | u_int data_waits = 0; | ||
4249 | u_int data_retrying = 0; | ||
4250 | int status_tries; | ||
4251 | int error_flag; | ||
4252 | |||
4253 | msg(DBG_IOC,"ioctl: CDROMREADAUDIO entered.\n"); | ||
4254 | if (fam0_drive) RETURN_UP(-EINVAL); | ||
4255 | if (famL_drive) RETURN_UP(-EINVAL); | ||
4256 | if (famV_drive) RETURN_UP(-EINVAL); | ||
4257 | if (famT_drive) RETURN_UP(-EINVAL); | ||
4258 | #ifdef SAFE_MIXED | ||
4259 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); | ||
4260 | #endif /* SAFE_MIXED */ | ||
4261 | if (current_drive->aud_buf==NULL) RETURN_UP(-EINVAL); | ||
4262 | if (copy_from_user(&read_audio, (void __user *)arg, | ||
4263 | sizeof(struct cdrom_read_audio))) | ||
4264 | RETURN_UP(-EFAULT); | ||
4265 | if (read_audio.nframes < 0 || read_audio.nframes>current_drive->sbp_audsiz) RETURN_UP(-EINVAL); | ||
4266 | if (!access_ok(VERIFY_WRITE, read_audio.buf, | ||
4267 | read_audio.nframes*CD_FRAMESIZE_RAW)) | ||
4268 | RETURN_UP(-EFAULT); | ||
4269 | |||
4270 | if (read_audio.addr_format==CDROM_MSF) /* MSF-bin specification of where to start */ | ||
4271 | block=msf2lba(&read_audio.addr.msf.minute); | ||
4272 | else if (read_audio.addr_format==CDROM_LBA) /* lba specification of where to start */ | ||
4273 | block=read_audio.addr.lba; | ||
4274 | else RETURN_UP(-EINVAL); | ||
4275 | #if 000 | ||
4276 | i=cc_SetSpeed(speed_150,0,0); | ||
4277 | if (i) msg(DBG_AUD,"read_audio: SetSpeed error %d\n", i); | ||
4278 | #endif | ||
4279 | msg(DBG_AUD,"read_audio: lba: %d, msf: %06X\n", | ||
4280 | block, blk2msf(block)); | ||
4281 | msg(DBG_AUD,"read_audio: before cc_ReadStatus.\n"); | ||
4282 | #if OLD_BUSY | ||
4283 | while (busy_data) sbp_sleep(HZ/10); /* wait a bit */ | ||
4284 | busy_audio=1; | ||
4285 | #endif /* OLD_BUSY */ | ||
4286 | error_flag=0; | ||
4287 | for (data_tries=5; data_tries>0; data_tries--) | ||
4288 | { | ||
4289 | msg(DBG_AUD,"data_tries=%d ...\n", data_tries); | ||
4290 | current_drive->mode=READ_AU; | ||
4291 | cc_ModeSelect(CD_FRAMESIZE_RAW); | ||
4292 | cc_ModeSense(); | ||
4293 | for (status_tries=3; status_tries > 0; status_tries--) | ||
4294 | { | ||
4295 | flags_cmd_out |= f_respo3; | ||
4296 | cc_ReadStatus(); | ||
4297 | if (sbp_status() != 0) break; | ||
4298 | if (st_check) cc_ReadError(); | ||
4299 | sbp_sleep(1); /* wait a bit, try again */ | ||
4300 | } | ||
4301 | if (status_tries == 0) | ||
4302 | { | ||
4303 | msg(DBG_AUD,"read_audio: sbp_status: failed after 3 tries in line %d.\n", __LINE__); | ||
4304 | continue; | ||
4305 | } | ||
4306 | msg(DBG_AUD,"read_audio: sbp_status: ok.\n"); | ||
4307 | |||
4308 | flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus | f_obey_p_check; | ||
4309 | if (fam0L_drive) | ||
4310 | { | ||
4311 | flags_cmd_out |= f_lopsta | f_getsta | f_bit1; | ||
4312 | cmd_type=READ_M2; | ||
4313 | drvcmd[0]=CMD0_READ_XA; /* "read XA frames", old drives */ | ||
4314 | drvcmd[1]=(block>>16)&0x000000ff; | ||
4315 | drvcmd[2]=(block>>8)&0x000000ff; | ||
4316 | drvcmd[3]=block&0x000000ff; | ||
4317 | drvcmd[4]=0; | ||
4318 | drvcmd[5]=read_audio.nframes; /* # of frames */ | ||
4319 | drvcmd[6]=0; | ||
4320 | } | ||
4321 | else if (fam1_drive) | ||
4322 | { | ||
4323 | drvcmd[0]=CMD1_READ; /* "read frames", new drives */ | ||
4324 | lba2msf(block,&drvcmd[1]); /* msf-bin format required */ | ||
4325 | drvcmd[4]=0; | ||
4326 | drvcmd[5]=0; | ||
4327 | drvcmd[6]=read_audio.nframes; /* # of frames */ | ||
4328 | } | ||
4329 | else if (fam2_drive) | ||
4330 | { | ||
4331 | drvcmd[0]=CMD2_READ_XA2; | ||
4332 | lba2msf(block,&drvcmd[1]); /* msf-bin format required */ | ||
4333 | drvcmd[4]=0; | ||
4334 | drvcmd[5]=read_audio.nframes; /* # of frames */ | ||
4335 | drvcmd[6]=0x11; /* raw mode */ | ||
4336 | } | ||
4337 | else if (famT_drive) /* CD-55A: not tested yet */ | ||
4338 | { | ||
4339 | } | ||
4340 | msg(DBG_AUD,"read_audio: before giving \"read\" command.\n"); | ||
4341 | flags_cmd_out=f_putcmd; | ||
4342 | response_count=0; | ||
4343 | i=cmd_out(); | ||
4344 | if (i<0) msg(DBG_INF,"error giving READ AUDIO command: %0d\n", i); | ||
4345 | sbp_sleep(0); | ||
4346 | msg(DBG_AUD,"read_audio: after giving \"read\" command.\n"); | ||
4347 | for (frame=1;frame<2 && !error_flag; frame++) | ||
4348 | { | ||
4349 | try=maxtim_data; | ||
4350 | for (timeout=jiffies+9*HZ; ; ) | ||
4351 | { | ||
4352 | for ( ; try!=0;try--) | ||
4353 | { | ||
4354 | j=inb(CDi_status); | ||
4355 | if (!(j&s_not_data_ready)) break; | ||
4356 | if (!(j&s_not_result_ready)) break; | ||
4357 | if (fam0L_drive) if (j&s_attention) break; | ||
4358 | } | ||
4359 | if (try != 0 || time_after_eq(jiffies, timeout)) break; | ||
4360 | if (data_retrying == 0) data_waits++; | ||
4361 | data_retrying = 1; | ||
4362 | sbp_sleep(1); | ||
4363 | try = 1; | ||
4364 | } | ||
4365 | if (try==0) | ||
4366 | { | ||
4367 | msg(DBG_INF,"read_audio: sbp_data: CDi_status timeout.\n"); | ||
4368 | error_flag++; | ||
4369 | break; | ||
4370 | } | ||
4371 | msg(DBG_AUD,"read_audio: sbp_data: CDi_status ok.\n"); | ||
4372 | if (j&s_not_data_ready) | ||
4373 | { | ||
4374 | msg(DBG_INF, "read_audio: sbp_data: DATA_READY timeout.\n"); | ||
4375 | error_flag++; | ||
4376 | break; | ||
4377 | } | ||
4378 | msg(DBG_AUD,"read_audio: before reading data.\n"); | ||
4379 | error_flag=0; | ||
4380 | p = current_drive->aud_buf; | ||
4381 | if (sbpro_type==1) OUT(CDo_sel_i_d,1); | ||
4382 | if (do_16bit) | ||
4383 | { | ||
4384 | u_short *p2 = (u_short *) p; | ||
4385 | |||
4386 | for (; (u_char *) p2 < current_drive->aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;) | ||
4387 | { | ||
4388 | if ((inb_p(CDi_status)&s_not_data_ready)) continue; | ||
4389 | |||
4390 | /* get one sample */ | ||
4391 | *p2++ = inw_p(CDi_data); | ||
4392 | *p2++ = inw_p(CDi_data); | ||
4393 | } | ||
4394 | } else { | ||
4395 | for (; p < current_drive->aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;) | ||
4396 | { | ||
4397 | if ((inb_p(CDi_status)&s_not_data_ready)) continue; | ||
4398 | |||
4399 | /* get one sample */ | ||
4400 | *p++ = inb_p(CDi_data); | ||
4401 | *p++ = inb_p(CDi_data); | ||
4402 | *p++ = inb_p(CDi_data); | ||
4403 | *p++ = inb_p(CDi_data); | ||
4404 | } | ||
4405 | } | ||
4406 | if (sbpro_type==1) OUT(CDo_sel_i_d,0); | ||
4407 | data_retrying = 0; | ||
4408 | } | ||
4409 | msg(DBG_AUD,"read_audio: after reading data.\n"); | ||
4410 | if (error_flag) /* must have been spurious D_RDY or (ATTN&&!D_RDY) */ | ||
4411 | { | ||
4412 | msg(DBG_AUD,"read_audio: read aborted by drive\n"); | ||
4413 | #if 0000 | ||
4414 | i=cc_DriveReset(); /* ugly fix to prevent a hang */ | ||
4415 | #else | ||
4416 | i=cc_ReadError(); | ||
4417 | #endif | ||
4418 | continue; | ||
4419 | } | ||
4420 | if (fam0L_drive) | ||
4421 | { | ||
4422 | i=maxtim_data; | ||
4423 | for (timeout=jiffies+9*HZ; time_before(jiffies, timeout); timeout--) | ||
4424 | { | ||
4425 | for ( ;i!=0;i--) | ||
4426 | { | ||
4427 | j=inb(CDi_status); | ||
4428 | if (!(j&s_not_data_ready)) break; | ||
4429 | if (!(j&s_not_result_ready)) break; | ||
4430 | if (j&s_attention) break; | ||
4431 | } | ||
4432 | if (i != 0 || time_after_eq(jiffies, timeout)) break; | ||
4433 | sbp_sleep(0); | ||
4434 | i = 1; | ||
4435 | } | ||
4436 | if (i==0) msg(DBG_AUD,"read_audio: STATUS TIMEOUT AFTER READ"); | ||
4437 | if (!(j&s_attention)) | ||
4438 | { | ||
4439 | msg(DBG_AUD,"read_audio: sbp_data: timeout waiting DRV_ATTN - retrying\n"); | ||
4440 | i=cc_DriveReset(); /* ugly fix to prevent a hang */ | ||
4441 | continue; | ||
4442 | } | ||
4443 | } | ||
4444 | do | ||
4445 | { | ||
4446 | if (fam0L_drive) cc_ReadStatus(); | ||
4447 | i=ResponseStatus(); /* builds status_bits, returns orig. status (old) or faked p_success (new) */ | ||
4448 | if (i<0) { msg(DBG_AUD, | ||
4449 | "read_audio: cc_ReadStatus error after read: %02X\n", | ||
4450 | current_drive->status_bits); | ||
4451 | continue; /* FIXME */ | ||
4452 | } | ||
4453 | } | ||
4454 | while ((fam0L_drive)&&(!st_check)&&(!(i&p_success))); | ||
4455 | if (st_check) | ||
4456 | { | ||
4457 | i=cc_ReadError(); | ||
4458 | msg(DBG_AUD,"read_audio: cc_ReadError was necessary after read: %02X\n",i); | ||
4459 | continue; | ||
4460 | } | ||
4461 | if (copy_to_user(read_audio.buf, | ||
4462 | current_drive->aud_buf, | ||
4463 | read_audio.nframes * CD_FRAMESIZE_RAW)) | ||
4464 | RETURN_UP(-EFAULT); | ||
4465 | msg(DBG_AUD,"read_audio: copy_to_user done.\n"); | ||
4466 | break; | ||
4467 | } | ||
4468 | cc_ModeSelect(CD_FRAMESIZE); | ||
4469 | cc_ModeSense(); | ||
4470 | current_drive->mode=READ_M1; | ||
4471 | #if OLD_BUSY | ||
4472 | busy_audio=0; | ||
4473 | #endif /* OLD_BUSY */ | ||
4474 | if (data_tries == 0) | ||
4475 | { | ||
4476 | msg(DBG_AUD,"read_audio: failed after 5 tries in line %d.\n", __LINE__); | ||
4477 | RETURN_UP(-EIO); | ||
4478 | } | ||
4479 | msg(DBG_AUD,"read_audio: successful return.\n"); | ||
4480 | RETURN_UP(0); | ||
4481 | } /* end of CDROMREADAUDIO */ | ||
4482 | |||
4483 | default: | ||
4484 | msg(DBG_IOC,"ioctl: unknown function request %04X\n", cmd); | ||
4485 | RETURN_UP(-EINVAL); | ||
4486 | } /* end switch(cmd) */ | ||
4487 | } | ||
4488 | |||
4489 | static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | 4163 | static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, |
4490 | void * arg) | 4164 | void * arg) |
4491 | { | 4165 | { |
@@ -4530,7 +4204,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4530 | default: | 4204 | default: |
4531 | RETURN_UP(-EINVAL); | 4205 | RETURN_UP(-EINVAL); |
4532 | } | 4206 | } |
4533 | 4207 | ||
4534 | case CDROMRESUME: /* resume paused audio play */ | 4208 | case CDROMRESUME: /* resume paused audio play */ |
4535 | msg(DBG_IOC,"ioctl: CDROMRESUME entered.\n"); | 4209 | msg(DBG_IOC,"ioctl: CDROMRESUME entered.\n"); |
4536 | /* resume playing audio tracks when a previous PLAY AUDIO call has */ | 4210 | /* resume playing audio tracks when a previous PLAY AUDIO call has */ |
@@ -4544,12 +4218,12 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4544 | if (i<0) RETURN_UP(-EIO); | 4218 | if (i<0) RETURN_UP(-EIO); |
4545 | current_drive->audio_state=audio_playing; | 4219 | current_drive->audio_state=audio_playing; |
4546 | RETURN_UP(0); | 4220 | RETURN_UP(0); |
4547 | 4221 | ||
4548 | case CDROMPLAYMSF: | 4222 | case CDROMPLAYMSF: |
4549 | msg(DBG_IOC,"ioctl: CDROMPLAYMSF entered.\n"); | 4223 | msg(DBG_IOC,"ioctl: CDROMPLAYMSF entered.\n"); |
4550 | #ifdef SAFE_MIXED | 4224 | #ifdef SAFE_MIXED |
4551 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); | 4225 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); |
4552 | #endif /* SAFE_MIXED */ | 4226 | #endif /* SAFE_MIXED */ |
4553 | if (current_drive->audio_state==audio_playing) | 4227 | if (current_drive->audio_state==audio_playing) |
4554 | { | 4228 | { |
4555 | i=cc_Pause_Resume(1); | 4229 | i=cc_Pause_Resume(1); |
@@ -4584,7 +4258,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4584 | msg(DBG_IOC,"ioctl: CDROMPLAYTRKIND entered.\n"); | 4258 | msg(DBG_IOC,"ioctl: CDROMPLAYTRKIND entered.\n"); |
4585 | #ifdef SAFE_MIXED | 4259 | #ifdef SAFE_MIXED |
4586 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); | 4260 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); |
4587 | #endif /* SAFE_MIXED */ | 4261 | #endif /* SAFE_MIXED */ |
4588 | if (current_drive->audio_state==audio_playing) | 4262 | if (current_drive->audio_state==audio_playing) |
4589 | { | 4263 | { |
4590 | msg(DBG_IOX,"CDROMPLAYTRKIND: already audio_playing.\n"); | 4264 | msg(DBG_IOX,"CDROMPLAYTRKIND: already audio_playing.\n"); |
@@ -4654,13 +4328,13 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4654 | cc_DriveReset(); | 4328 | cc_DriveReset(); |
4655 | #endif | 4329 | #endif |
4656 | RETURN_UP(i); | 4330 | RETURN_UP(i); |
4657 | 4331 | ||
4658 | case CDROMSTART: /* Spin up the drive */ | 4332 | case CDROMSTART: /* Spin up the drive */ |
4659 | msg(DBG_IOC,"ioctl: CDROMSTART entered.\n"); | 4333 | msg(DBG_IOC,"ioctl: CDROMSTART entered.\n"); |
4660 | cc_SpinUp(); | 4334 | cc_SpinUp(); |
4661 | current_drive->audio_state=0; | 4335 | current_drive->audio_state=0; |
4662 | RETURN_UP(0); | 4336 | RETURN_UP(0); |
4663 | 4337 | ||
4664 | case CDROMVOLCTRL: /* Volume control */ | 4338 | case CDROMVOLCTRL: /* Volume control */ |
4665 | msg(DBG_IOC,"ioctl: CDROMVOLCTRL entered.\n"); | 4339 | msg(DBG_IOC,"ioctl: CDROMVOLCTRL entered.\n"); |
4666 | memcpy(&volctrl,(char *) arg,sizeof(volctrl)); | 4340 | memcpy(&volctrl,(char *) arg,sizeof(volctrl)); |
@@ -4670,7 +4344,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4670 | current_drive->vol_ctrl1=volctrl.channel1; | 4344 | current_drive->vol_ctrl1=volctrl.channel1; |
4671 | i=cc_SetVolume(); | 4345 | i=cc_SetVolume(); |
4672 | RETURN_UP(0); | 4346 | RETURN_UP(0); |
4673 | 4347 | ||
4674 | case CDROMVOLREAD: /* read Volume settings from drive */ | 4348 | case CDROMVOLREAD: /* read Volume settings from drive */ |
4675 | msg(DBG_IOC,"ioctl: CDROMVOLREAD entered.\n"); | 4349 | msg(DBG_IOC,"ioctl: CDROMVOLREAD entered.\n"); |
4676 | st=cc_GetVolume(); | 4350 | st=cc_GetVolume(); |
@@ -4694,7 +4368,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4694 | if (i<0) { | 4368 | if (i<0) { |
4695 | j=cc_ReadError(); /* clear out error status from drive */ | 4369 | j=cc_ReadError(); /* clear out error status from drive */ |
4696 | current_drive->audio_state=CDROM_AUDIO_NO_STATUS; | 4370 | current_drive->audio_state=CDROM_AUDIO_NO_STATUS; |
4697 | /* get and set the disk state here, | 4371 | /* get and set the disk state here, |
4698 | probably not the right place, but who cares! | 4372 | probably not the right place, but who cares! |
4699 | It makes it work properly! --AJK */ | 4373 | It makes it work properly! --AJK */ |
4700 | if (current_drive->CD_changed==0xFF) { | 4374 | if (current_drive->CD_changed==0xFF) { |
@@ -4715,8 +4389,8 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4715 | } | 4389 | } |
4716 | } | 4390 | } |
4717 | memcpy(&SC, (void *) arg, sizeof(struct cdrom_subchnl)); | 4391 | memcpy(&SC, (void *) arg, sizeof(struct cdrom_subchnl)); |
4718 | /* | 4392 | /* |
4719 | This virtual crap is very bogus! | 4393 | This virtual crap is very bogus! |
4720 | It doesn't detect when the cd is done playing audio! | 4394 | It doesn't detect when the cd is done playing audio! |
4721 | Lets do this right with proper hardware register reading! | 4395 | Lets do this right with proper hardware register reading! |
4722 | */ | 4396 | */ |
@@ -4775,7 +4449,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4775 | SC.cdsc_trk,SC.cdsc_ind, | 4449 | SC.cdsc_trk,SC.cdsc_ind, |
4776 | SC.cdsc_absaddr,SC.cdsc_reladdr); | 4450 | SC.cdsc_absaddr,SC.cdsc_reladdr); |
4777 | RETURN_UP(0); | 4451 | RETURN_UP(0); |
4778 | 4452 | ||
4779 | default: | 4453 | default: |
4780 | msg(DBG_IOC,"ioctl: unknown function request %04X\n", cmd); | 4454 | msg(DBG_IOC,"ioctl: unknown function request %04X\n", cmd); |
4781 | RETURN_UP(-EINVAL); | 4455 | RETURN_UP(-EINVAL); |
@@ -4788,7 +4462,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4788 | static void sbp_transfer(struct request *req) | 4462 | static void sbp_transfer(struct request *req) |
4789 | { | 4463 | { |
4790 | long offs; | 4464 | long offs; |
4791 | 4465 | ||
4792 | while ( (req->nr_sectors > 0) && | 4466 | while ( (req->nr_sectors > 0) && |
4793 | (req->sector/4 >= current_drive->sbp_first_frame) && | 4467 | (req->sector/4 >= current_drive->sbp_first_frame) && |
4794 | (req->sector/4 <= current_drive->sbp_last_frame) ) | 4468 | (req->sector/4 <= current_drive->sbp_last_frame) ) |
@@ -4807,11 +4481,11 @@ static void sbp_transfer(struct request *req) | |||
4807 | * | 4481 | * |
4808 | * This is a kludge so we don't need to modify end_request. | 4482 | * This is a kludge so we don't need to modify end_request. |
4809 | * We put the req we take out after INIT_REQUEST in the requests list, | 4483 | * We put the req we take out after INIT_REQUEST in the requests list, |
4810 | * so that end_request will discard it. | 4484 | * so that end_request will discard it. |
4811 | * | 4485 | * |
4812 | * The bug could be present in other block devices, perhaps we | 4486 | * The bug could be present in other block devices, perhaps we |
4813 | * should modify INIT_REQUEST and end_request instead, and | 4487 | * should modify INIT_REQUEST and end_request instead, and |
4814 | * change every block device.. | 4488 | * change every block device.. |
4815 | * | 4489 | * |
4816 | * Could be a race here?? Could e.g. a timer interrupt schedule() us? | 4490 | * Could be a race here?? Could e.g. a timer interrupt schedule() us? |
4817 | * If so, we should copy end_request here, and do it right.. (or | 4491 | * If so, we should copy end_request here, and do it right.. (or |
@@ -4883,19 +4557,19 @@ static void do_sbpcd_request(request_queue_t * q) | |||
4883 | while (busy_audio) sbp_sleep(HZ); /* wait a bit */ | 4557 | while (busy_audio) sbp_sleep(HZ); /* wait a bit */ |
4884 | busy_data=1; | 4558 | busy_data=1; |
4885 | #endif /* OLD_BUSY */ | 4559 | #endif /* OLD_BUSY */ |
4886 | 4560 | ||
4887 | if (p->audio_state==audio_playing) goto err_done; | 4561 | if (p->audio_state==audio_playing) goto err_done; |
4888 | if (p != current_drive) | 4562 | if (p != current_drive) |
4889 | switch_drive(p); | 4563 | switch_drive(p); |
4890 | 4564 | ||
4891 | block = req->sector; /* always numbered as 512-byte-pieces */ | 4565 | block = req->sector; /* always numbered as 512-byte-pieces */ |
4892 | nsect = req->nr_sectors; /* always counted as 512-byte-pieces */ | 4566 | nsect = req->nr_sectors; /* always counted as 512-byte-pieces */ |
4893 | 4567 | ||
4894 | msg(DBG_BSZ,"read sector %d (%d sectors)\n", block, nsect); | 4568 | msg(DBG_BSZ,"read sector %d (%d sectors)\n", block, nsect); |
4895 | #if 0 | 4569 | #if 0 |
4896 | msg(DBG_MUL,"read LBA %d\n", block/4); | 4570 | msg(DBG_MUL,"read LBA %d\n", block/4); |
4897 | #endif | 4571 | #endif |
4898 | 4572 | ||
4899 | sbp_transfer(req); | 4573 | sbp_transfer(req); |
4900 | /* if we satisfied the request from the buffer, we're done. */ | 4574 | /* if we satisfied the request from the buffer, we're done. */ |
4901 | if (req->nr_sectors == 0) | 4575 | if (req->nr_sectors == 0) |
@@ -4914,10 +4588,10 @@ static void do_sbpcd_request(request_queue_t * q) | |||
4914 | i=prepare(0,0); /* at moment not really a hassle check, but ... */ | 4588 | i=prepare(0,0); /* at moment not really a hassle check, but ... */ |
4915 | if (i!=0) | 4589 | if (i!=0) |
4916 | msg(DBG_INF,"\"prepare\" tells error %d -- ignored\n", i); | 4590 | msg(DBG_INF,"\"prepare\" tells error %d -- ignored\n", i); |
4917 | #endif /* FUTURE */ | 4591 | #endif /* FUTURE */ |
4918 | 4592 | ||
4919 | if (!st_spinning) cc_SpinUp(); | 4593 | if (!st_spinning) cc_SpinUp(); |
4920 | 4594 | ||
4921 | for (data_tries=n_retries; data_tries > 0; data_tries--) | 4595 | for (data_tries=n_retries; data_tries > 0; data_tries--) |
4922 | { | 4596 | { |
4923 | for (status_tries=3; status_tries > 0; status_tries--) | 4597 | for (status_tries=3; status_tries > 0; status_tries--) |
@@ -4940,7 +4614,7 @@ static void do_sbpcd_request(request_queue_t * q) | |||
4940 | { | 4614 | { |
4941 | #ifdef SAFE_MIXED | 4615 | #ifdef SAFE_MIXED |
4942 | current_drive->has_data=2; /* is really a data disk */ | 4616 | current_drive->has_data=2; /* is really a data disk */ |
4943 | #endif /* SAFE_MIXED */ | 4617 | #endif /* SAFE_MIXED */ |
4944 | #ifdef DEBUG_GTL | 4618 | #ifdef DEBUG_GTL |
4945 | printk(" do_sbpcd_request[%do](%p:%ld+%ld) end 3, Time:%li\n", | 4619 | printk(" do_sbpcd_request[%do](%p:%ld+%ld) end 3, Time:%li\n", |
4946 | xnr, req, req->sector, req->nr_sectors, jiffies); | 4620 | xnr, req, req->sector, req->nr_sectors, jiffies); |
@@ -4951,7 +4625,7 @@ static void do_sbpcd_request(request_queue_t * q) | |||
4951 | goto request_loop; | 4625 | goto request_loop; |
4952 | } | 4626 | } |
4953 | } | 4627 | } |
4954 | 4628 | ||
4955 | err_done: | 4629 | err_done: |
4956 | #if OLD_BUSY | 4630 | #if OLD_BUSY |
4957 | busy_data=0; | 4631 | busy_data=0; |
@@ -4976,7 +4650,7 @@ static void sbp_read_cmd(struct request *req) | |||
4976 | 4650 | ||
4977 | int i; | 4651 | int i; |
4978 | int block; | 4652 | int block; |
4979 | 4653 | ||
4980 | current_drive->sbp_first_frame=current_drive->sbp_last_frame=-1; /* purge buffer */ | 4654 | current_drive->sbp_first_frame=current_drive->sbp_last_frame=-1; /* purge buffer */ |
4981 | current_drive->sbp_current = 0; | 4655 | current_drive->sbp_current = 0; |
4982 | block=req->sector/4; | 4656 | block=req->sector/4; |
@@ -4993,7 +4667,7 @@ static void sbp_read_cmd(struct request *req) | |||
4993 | current_drive->sbp_read_frames=1; | 4667 | current_drive->sbp_read_frames=1; |
4994 | } | 4668 | } |
4995 | } | 4669 | } |
4996 | 4670 | ||
4997 | flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus | f_obey_p_check; | 4671 | flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus | f_obey_p_check; |
4998 | clr_cmdbuf(); | 4672 | clr_cmdbuf(); |
4999 | if (famV_drive) | 4673 | if (famV_drive) |
@@ -5092,7 +4766,7 @@ static int sbp_data(struct request *req) | |||
5092 | int success; | 4766 | int success; |
5093 | int wait; | 4767 | int wait; |
5094 | int duration; | 4768 | int duration; |
5095 | 4769 | ||
5096 | error_flag=0; | 4770 | error_flag=0; |
5097 | success=0; | 4771 | success=0; |
5098 | #if LONG_TIMING | 4772 | #if LONG_TIMING |
@@ -5105,12 +4779,12 @@ static int sbp_data(struct request *req) | |||
5105 | for (frame=0;frame<current_drive->sbp_read_frames&&!error_flag; frame++) | 4779 | for (frame=0;frame<current_drive->sbp_read_frames&&!error_flag; frame++) |
5106 | { | 4780 | { |
5107 | SBPCD_CLI; | 4781 | SBPCD_CLI; |
5108 | 4782 | ||
5109 | del_timer(&data_timer); | 4783 | del_timer(&data_timer); |
5110 | data_timer.expires=jiffies+max_latency; | 4784 | data_timer.expires=jiffies+max_latency; |
5111 | timed_out_data=0; | 4785 | timed_out_data=0; |
5112 | add_timer(&data_timer); | 4786 | add_timer(&data_timer); |
5113 | while (!timed_out_data) | 4787 | while (!timed_out_data) |
5114 | { | 4788 | { |
5115 | if (current_drive->f_multisession) try=maxtim_data*4; | 4789 | if (current_drive->f_multisession) try=maxtim_data*4; |
5116 | else try=maxtim_data; | 4790 | else try=maxtim_data; |
@@ -5207,9 +4881,9 @@ static int sbp_data(struct request *req) | |||
5207 | else | 4881 | else |
5208 | { | 4882 | { |
5209 | sbp_sleep(1); | 4883 | sbp_sleep(1); |
5210 | OUT(CDo_sel_i_d,0); | 4884 | OUT(CDo_sel_i_d,0); |
5211 | i=inb(CDi_status); | 4885 | i=inb(CDi_status); |
5212 | } | 4886 | } |
5213 | if (!(i&s_not_data_ready)) | 4887 | if (!(i&s_not_data_ready)) |
5214 | { | 4888 | { |
5215 | OUT(CDo_sel_i_d,1); | 4889 | OUT(CDo_sel_i_d,1); |
@@ -5311,7 +4985,7 @@ static int sbp_data(struct request *req) | |||
5311 | } | 4985 | } |
5312 | SBPCD_STI; | 4986 | SBPCD_STI; |
5313 | } | 4987 | } |
5314 | 4988 | ||
5315 | #if 0 | 4989 | #if 0 |
5316 | if (!success) | 4990 | if (!success) |
5317 | #endif | 4991 | #endif |
@@ -5370,7 +5044,326 @@ static int sbpcd_block_ioctl(struct inode *inode, struct file *file, | |||
5370 | unsigned cmd, unsigned long arg) | 5044 | unsigned cmd, unsigned long arg) |
5371 | { | 5045 | { |
5372 | struct sbpcd_drive *p = inode->i_bdev->bd_disk->private_data; | 5046 | struct sbpcd_drive *p = inode->i_bdev->bd_disk->private_data; |
5373 | return cdrom_ioctl(file, p->sbpcd_infop, inode, cmd, arg); | 5047 | struct cdrom_device_info *cdi = p->sbpcd_infop; |
5048 | int ret, i; | ||
5049 | |||
5050 | ret = cdrom_ioctl(file, p->sbpcd_infop, inode, cmd, arg); | ||
5051 | if (ret != -ENOSYS) | ||
5052 | return ret; | ||
5053 | |||
5054 | msg(DBG_IO2,"ioctl(%s, 0x%08lX, 0x%08lX)\n", cdi->name, cmd, arg); | ||
5055 | if (p->drv_id==-1) { | ||
5056 | msg(DBG_INF, "ioctl: bad device: %s\n", cdi->name); | ||
5057 | return (-ENXIO); /* no such drive */ | ||
5058 | } | ||
5059 | down(&ioctl_read_sem); | ||
5060 | if (p != current_drive) | ||
5061 | switch_drive(p); | ||
5062 | |||
5063 | msg(DBG_IO2,"ioctl: device %s, request %04X\n",cdi->name,cmd); | ||
5064 | switch (cmd) /* Sun-compatible */ | ||
5065 | { | ||
5066 | case DDIOCSDBG: /* DDI Debug */ | ||
5067 | if (!capable(CAP_SYS_ADMIN)) RETURN_UP(-EPERM); | ||
5068 | i=sbpcd_dbg_ioctl(arg,1); | ||
5069 | RETURN_UP(i); | ||
5070 | case CDROMRESET: /* hard reset the drive */ | ||
5071 | msg(DBG_IOC,"ioctl: CDROMRESET entered.\n"); | ||
5072 | i=DriveReset(); | ||
5073 | current_drive->audio_state=0; | ||
5074 | RETURN_UP(i); | ||
5075 | |||
5076 | case CDROMREADMODE1: | ||
5077 | msg(DBG_IOC,"ioctl: CDROMREADMODE1 requested.\n"); | ||
5078 | #ifdef SAFE_MIXED | ||
5079 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); | ||
5080 | #endif /* SAFE_MIXED */ | ||
5081 | cc_ModeSelect(CD_FRAMESIZE); | ||
5082 | cc_ModeSense(); | ||
5083 | current_drive->mode=READ_M1; | ||
5084 | RETURN_UP(0); | ||
5085 | |||
5086 | case CDROMREADMODE2: /* not usable at the moment */ | ||
5087 | msg(DBG_IOC,"ioctl: CDROMREADMODE2 requested.\n"); | ||
5088 | #ifdef SAFE_MIXED | ||
5089 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); | ||
5090 | #endif /* SAFE_MIXED */ | ||
5091 | cc_ModeSelect(CD_FRAMESIZE_RAW1); | ||
5092 | cc_ModeSense(); | ||
5093 | current_drive->mode=READ_M2; | ||
5094 | RETURN_UP(0); | ||
5095 | |||
5096 | case CDROMAUDIOBUFSIZ: /* configure the audio buffer size */ | ||
5097 | msg(DBG_IOC,"ioctl: CDROMAUDIOBUFSIZ entered.\n"); | ||
5098 | if (current_drive->sbp_audsiz>0) | ||
5099 | vfree(current_drive->aud_buf); | ||
5100 | current_drive->aud_buf=NULL; | ||
5101 | current_drive->sbp_audsiz=arg; | ||
5102 | |||
5103 | if (current_drive->sbp_audsiz>16) | ||
5104 | { | ||
5105 | current_drive->sbp_audsiz = 0; | ||
5106 | RETURN_UP(current_drive->sbp_audsiz); | ||
5107 | } | ||
5108 | |||
5109 | if (current_drive->sbp_audsiz>0) | ||
5110 | { | ||
5111 | current_drive->aud_buf=(u_char *) vmalloc(current_drive->sbp_audsiz*CD_FRAMESIZE_RAW); | ||
5112 | if (current_drive->aud_buf==NULL) | ||
5113 | { | ||
5114 | msg(DBG_INF,"audio buffer (%d frames) not available.\n",current_drive->sbp_audsiz); | ||
5115 | current_drive->sbp_audsiz=0; | ||
5116 | } | ||
5117 | else msg(DBG_INF,"audio buffer size: %d frames.\n",current_drive->sbp_audsiz); | ||
5118 | } | ||
5119 | RETURN_UP(current_drive->sbp_audsiz); | ||
5120 | |||
5121 | case CDROMREADAUDIO: | ||
5122 | { /* start of CDROMREADAUDIO */ | ||
5123 | int i=0, j=0, frame, block=0; | ||
5124 | u_int try=0; | ||
5125 | u_long timeout; | ||
5126 | u_char *p; | ||
5127 | u_int data_tries = 0; | ||
5128 | u_int data_waits = 0; | ||
5129 | u_int data_retrying = 0; | ||
5130 | int status_tries; | ||
5131 | int error_flag; | ||
5132 | |||
5133 | msg(DBG_IOC,"ioctl: CDROMREADAUDIO entered.\n"); | ||
5134 | if (fam0_drive) RETURN_UP(-EINVAL); | ||
5135 | if (famL_drive) RETURN_UP(-EINVAL); | ||
5136 | if (famV_drive) RETURN_UP(-EINVAL); | ||
5137 | if (famT_drive) RETURN_UP(-EINVAL); | ||
5138 | #ifdef SAFE_MIXED | ||
5139 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); | ||
5140 | #endif /* SAFE_MIXED */ | ||
5141 | if (current_drive->aud_buf==NULL) RETURN_UP(-EINVAL); | ||
5142 | if (copy_from_user(&read_audio, (void __user *)arg, | ||
5143 | sizeof(struct cdrom_read_audio))) | ||
5144 | RETURN_UP(-EFAULT); | ||
5145 | if (read_audio.nframes < 0 || read_audio.nframes>current_drive->sbp_audsiz) RETURN_UP(-EINVAL); | ||
5146 | if (!access_ok(VERIFY_WRITE, read_audio.buf, | ||
5147 | read_audio.nframes*CD_FRAMESIZE_RAW)) | ||
5148 | RETURN_UP(-EFAULT); | ||
5149 | |||
5150 | if (read_audio.addr_format==CDROM_MSF) /* MSF-bin specification of where to start */ | ||
5151 | block=msf2lba(&read_audio.addr.msf.minute); | ||
5152 | else if (read_audio.addr_format==CDROM_LBA) /* lba specification of where to start */ | ||
5153 | block=read_audio.addr.lba; | ||
5154 | else RETURN_UP(-EINVAL); | ||
5155 | #if 000 | ||
5156 | i=cc_SetSpeed(speed_150,0,0); | ||
5157 | if (i) msg(DBG_AUD,"read_audio: SetSpeed error %d\n", i); | ||
5158 | #endif | ||
5159 | msg(DBG_AUD,"read_audio: lba: %d, msf: %06X\n", | ||
5160 | block, blk2msf(block)); | ||
5161 | msg(DBG_AUD,"read_audio: before cc_ReadStatus.\n"); | ||
5162 | #if OLD_BUSY | ||
5163 | while (busy_data) sbp_sleep(HZ/10); /* wait a bit */ | ||
5164 | busy_audio=1; | ||
5165 | #endif /* OLD_BUSY */ | ||
5166 | error_flag=0; | ||
5167 | for (data_tries=5; data_tries>0; data_tries--) | ||
5168 | { | ||
5169 | msg(DBG_AUD,"data_tries=%d ...\n", data_tries); | ||
5170 | current_drive->mode=READ_AU; | ||
5171 | cc_ModeSelect(CD_FRAMESIZE_RAW); | ||
5172 | cc_ModeSense(); | ||
5173 | for (status_tries=3; status_tries > 0; status_tries--) | ||
5174 | { | ||
5175 | flags_cmd_out |= f_respo3; | ||
5176 | cc_ReadStatus(); | ||
5177 | if (sbp_status() != 0) break; | ||
5178 | if (st_check) cc_ReadError(); | ||
5179 | sbp_sleep(1); /* wait a bit, try again */ | ||
5180 | } | ||
5181 | if (status_tries == 0) | ||
5182 | { | ||
5183 | msg(DBG_AUD,"read_audio: sbp_status: failed after 3 tries in line %d.\n", __LINE__); | ||
5184 | continue; | ||
5185 | } | ||
5186 | msg(DBG_AUD,"read_audio: sbp_status: ok.\n"); | ||
5187 | |||
5188 | flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus | f_obey_p_check; | ||
5189 | if (fam0L_drive) | ||
5190 | { | ||
5191 | flags_cmd_out |= f_lopsta | f_getsta | f_bit1; | ||
5192 | cmd_type=READ_M2; | ||
5193 | drvcmd[0]=CMD0_READ_XA; /* "read XA frames", old drives */ | ||
5194 | drvcmd[1]=(block>>16)&0x000000ff; | ||
5195 | drvcmd[2]=(block>>8)&0x000000ff; | ||
5196 | drvcmd[3]=block&0x000000ff; | ||
5197 | drvcmd[4]=0; | ||
5198 | drvcmd[5]=read_audio.nframes; /* # of frames */ | ||
5199 | drvcmd[6]=0; | ||
5200 | } | ||
5201 | else if (fam1_drive) | ||
5202 | { | ||
5203 | drvcmd[0]=CMD1_READ; /* "read frames", new drives */ | ||
5204 | lba2msf(block,&drvcmd[1]); /* msf-bin format required */ | ||
5205 | drvcmd[4]=0; | ||
5206 | drvcmd[5]=0; | ||
5207 | drvcmd[6]=read_audio.nframes; /* # of frames */ | ||
5208 | } | ||
5209 | else if (fam2_drive) | ||
5210 | { | ||
5211 | drvcmd[0]=CMD2_READ_XA2; | ||
5212 | lba2msf(block,&drvcmd[1]); /* msf-bin format required */ | ||
5213 | drvcmd[4]=0; | ||
5214 | drvcmd[5]=read_audio.nframes; /* # of frames */ | ||
5215 | drvcmd[6]=0x11; /* raw mode */ | ||
5216 | } | ||
5217 | else if (famT_drive) /* CD-55A: not tested yet */ | ||
5218 | { | ||
5219 | } | ||
5220 | msg(DBG_AUD,"read_audio: before giving \"read\" command.\n"); | ||
5221 | flags_cmd_out=f_putcmd; | ||
5222 | response_count=0; | ||
5223 | i=cmd_out(); | ||
5224 | if (i<0) msg(DBG_INF,"error giving READ AUDIO command: %0d\n", i); | ||
5225 | sbp_sleep(0); | ||
5226 | msg(DBG_AUD,"read_audio: after giving \"read\" command.\n"); | ||
5227 | for (frame=1;frame<2 && !error_flag; frame++) | ||
5228 | { | ||
5229 | try=maxtim_data; | ||
5230 | for (timeout=jiffies+9*HZ; ; ) | ||
5231 | { | ||
5232 | for ( ; try!=0;try--) | ||
5233 | { | ||
5234 | j=inb(CDi_status); | ||
5235 | if (!(j&s_not_data_ready)) break; | ||
5236 | if (!(j&s_not_result_ready)) break; | ||
5237 | if (fam0L_drive) if (j&s_attention) break; | ||
5238 | } | ||
5239 | if (try != 0 || time_after_eq(jiffies, timeout)) break; | ||
5240 | if (data_retrying == 0) data_waits++; | ||
5241 | data_retrying = 1; | ||
5242 | sbp_sleep(1); | ||
5243 | try = 1; | ||
5244 | } | ||
5245 | if (try==0) | ||
5246 | { | ||
5247 | msg(DBG_INF,"read_audio: sbp_data: CDi_status timeout.\n"); | ||
5248 | error_flag++; | ||
5249 | break; | ||
5250 | } | ||
5251 | msg(DBG_AUD,"read_audio: sbp_data: CDi_status ok.\n"); | ||
5252 | if (j&s_not_data_ready) | ||
5253 | { | ||
5254 | msg(DBG_INF, "read_audio: sbp_data: DATA_READY timeout.\n"); | ||
5255 | error_flag++; | ||
5256 | break; | ||
5257 | } | ||
5258 | msg(DBG_AUD,"read_audio: before reading data.\n"); | ||
5259 | error_flag=0; | ||
5260 | p = current_drive->aud_buf; | ||
5261 | if (sbpro_type==1) OUT(CDo_sel_i_d,1); | ||
5262 | if (do_16bit) | ||
5263 | { | ||
5264 | u_short *p2 = (u_short *) p; | ||
5265 | |||
5266 | for (; (u_char *) p2 < current_drive->aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;) | ||
5267 | { | ||
5268 | if ((inb_p(CDi_status)&s_not_data_ready)) continue; | ||
5269 | |||
5270 | /* get one sample */ | ||
5271 | *p2++ = inw_p(CDi_data); | ||
5272 | *p2++ = inw_p(CDi_data); | ||
5273 | } | ||
5274 | } else { | ||
5275 | for (; p < current_drive->aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;) | ||
5276 | { | ||
5277 | if ((inb_p(CDi_status)&s_not_data_ready)) continue; | ||
5278 | |||
5279 | /* get one sample */ | ||
5280 | *p++ = inb_p(CDi_data); | ||
5281 | *p++ = inb_p(CDi_data); | ||
5282 | *p++ = inb_p(CDi_data); | ||
5283 | *p++ = inb_p(CDi_data); | ||
5284 | } | ||
5285 | } | ||
5286 | if (sbpro_type==1) OUT(CDo_sel_i_d,0); | ||
5287 | data_retrying = 0; | ||
5288 | } | ||
5289 | msg(DBG_AUD,"read_audio: after reading data.\n"); | ||
5290 | if (error_flag) /* must have been spurious D_RDY or (ATTN&&!D_RDY) */ | ||
5291 | { | ||
5292 | msg(DBG_AUD,"read_audio: read aborted by drive\n"); | ||
5293 | #if 0000 | ||
5294 | i=cc_DriveReset(); /* ugly fix to prevent a hang */ | ||
5295 | #else | ||
5296 | i=cc_ReadError(); | ||
5297 | #endif | ||
5298 | continue; | ||
5299 | } | ||
5300 | if (fam0L_drive) | ||
5301 | { | ||
5302 | i=maxtim_data; | ||
5303 | for (timeout=jiffies+9*HZ; time_before(jiffies, timeout); timeout--) | ||
5304 | { | ||
5305 | for ( ;i!=0;i--) | ||
5306 | { | ||
5307 | j=inb(CDi_status); | ||
5308 | if (!(j&s_not_data_ready)) break; | ||
5309 | if (!(j&s_not_result_ready)) break; | ||
5310 | if (j&s_attention) break; | ||
5311 | } | ||
5312 | if (i != 0 || time_after_eq(jiffies, timeout)) break; | ||
5313 | sbp_sleep(0); | ||
5314 | i = 1; | ||
5315 | } | ||
5316 | if (i==0) msg(DBG_AUD,"read_audio: STATUS TIMEOUT AFTER READ"); | ||
5317 | if (!(j&s_attention)) | ||
5318 | { | ||
5319 | msg(DBG_AUD,"read_audio: sbp_data: timeout waiting DRV_ATTN - retrying\n"); | ||
5320 | i=cc_DriveReset(); /* ugly fix to prevent a hang */ | ||
5321 | continue; | ||
5322 | } | ||
5323 | } | ||
5324 | do | ||
5325 | { | ||
5326 | if (fam0L_drive) cc_ReadStatus(); | ||
5327 | i=ResponseStatus(); /* builds status_bits, returns orig. status (old) or faked p_success (new) */ | ||
5328 | if (i<0) { msg(DBG_AUD, | ||
5329 | "read_audio: cc_ReadStatus error after read: %02X\n", | ||
5330 | current_drive->status_bits); | ||
5331 | continue; /* FIXME */ | ||
5332 | } | ||
5333 | } | ||
5334 | while ((fam0L_drive)&&(!st_check)&&(!(i&p_success))); | ||
5335 | if (st_check) | ||
5336 | { | ||
5337 | i=cc_ReadError(); | ||
5338 | msg(DBG_AUD,"read_audio: cc_ReadError was necessary after read: %02X\n",i); | ||
5339 | continue; | ||
5340 | } | ||
5341 | if (copy_to_user(read_audio.buf, | ||
5342 | current_drive->aud_buf, | ||
5343 | read_audio.nframes * CD_FRAMESIZE_RAW)) | ||
5344 | RETURN_UP(-EFAULT); | ||
5345 | msg(DBG_AUD,"read_audio: copy_to_user done.\n"); | ||
5346 | break; | ||
5347 | } | ||
5348 | cc_ModeSelect(CD_FRAMESIZE); | ||
5349 | cc_ModeSense(); | ||
5350 | current_drive->mode=READ_M1; | ||
5351 | #if OLD_BUSY | ||
5352 | busy_audio=0; | ||
5353 | #endif /* OLD_BUSY */ | ||
5354 | if (data_tries == 0) | ||
5355 | { | ||
5356 | msg(DBG_AUD,"read_audio: failed after 5 tries in line %d.\n", __LINE__); | ||
5357 | RETURN_UP(-EIO); | ||
5358 | } | ||
5359 | msg(DBG_AUD,"read_audio: successful return.\n"); | ||
5360 | RETURN_UP(0); | ||
5361 | } /* end of CDROMREADAUDIO */ | ||
5362 | |||
5363 | default: | ||
5364 | msg(DBG_IOC,"ioctl: unknown function request %04X\n", cmd); | ||
5365 | RETURN_UP(-EINVAL); | ||
5366 | } /* end switch(cmd) */ | ||
5374 | } | 5367 | } |
5375 | 5368 | ||
5376 | static int sbpcd_block_media_changed(struct gendisk *disk) | 5369 | static int sbpcd_block_media_changed(struct gendisk *disk) |
@@ -5478,10 +5471,9 @@ static struct cdrom_device_ops sbpcd_dops = { | |||
5478 | .get_mcn = sbpcd_get_mcn, | 5471 | .get_mcn = sbpcd_get_mcn, |
5479 | .reset = sbpcd_reset, | 5472 | .reset = sbpcd_reset, |
5480 | .audio_ioctl = sbpcd_audio_ioctl, | 5473 | .audio_ioctl = sbpcd_audio_ioctl, |
5481 | .dev_ioctl = sbpcd_dev_ioctl, | ||
5482 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | | 5474 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | |
5483 | CDC_MULTI_SESSION | CDC_MEDIA_CHANGED | | 5475 | CDC_MULTI_SESSION | CDC_MEDIA_CHANGED | |
5484 | CDC_MCN | CDC_PLAY_AUDIO | CDC_IOCTLS, | 5476 | CDC_MCN | CDC_PLAY_AUDIO, |
5485 | .n_minors = 1, | 5477 | .n_minors = 1, |
5486 | }; | 5478 | }; |
5487 | 5479 | ||
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c index e27617259552..c0f817ba7adb 100644 --- a/drivers/cdrom/viocd.c +++ b/drivers/cdrom/viocd.c | |||
@@ -627,7 +627,7 @@ static struct cdrom_device_ops viocd_dops = { | |||
627 | .media_changed = viocd_media_changed, | 627 | .media_changed = viocd_media_changed, |
628 | .lock_door = viocd_lock_door, | 628 | .lock_door = viocd_lock_door, |
629 | .generic_packet = viocd_packet, | 629 | .generic_packet = viocd_packet, |
630 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | CDC_SELECT_DISC | CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS | CDC_GENERIC_PACKET | CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | CDC_DVD_RAM | CDC_RAM | 630 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | CDC_SELECT_DISC | CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | CDC_DRIVE_STATUS | CDC_GENERIC_PACKET | CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | CDC_DVD_RAM | CDC_RAM |
631 | }; | 631 | }; |
632 | 632 | ||
633 | static int __init find_capability(const char *type) | 633 | static int __init find_capability(const char *type) |
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c index 7ac365b5d9ec..6602b3156df5 100644 --- a/drivers/char/amiserial.c +++ b/drivers/char/amiserial.c | |||
@@ -46,8 +46,6 @@ | |||
46 | 46 | ||
47 | /* Sanity checks */ | 47 | /* Sanity checks */ |
48 | 48 | ||
49 | #define SERIAL_INLINE | ||
50 | |||
51 | #if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT) | 49 | #if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT) |
52 | #define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \ | 50 | #define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \ |
53 | tty->name, (info->flags), serial_driver->refcount,info->count,tty->count,s) | 51 | tty->name, (info->flags), serial_driver->refcount,info->count,tty->count,s) |
@@ -95,10 +93,6 @@ static char *serial_version = "4.30"; | |||
95 | #include <asm/amigahw.h> | 93 | #include <asm/amigahw.h> |
96 | #include <asm/amigaints.h> | 94 | #include <asm/amigaints.h> |
97 | 95 | ||
98 | #ifdef SERIAL_INLINE | ||
99 | #define _INLINE_ inline | ||
100 | #endif | ||
101 | |||
102 | #define custom amiga_custom | 96 | #define custom amiga_custom |
103 | static char *serial_name = "Amiga-builtin serial driver"; | 97 | static char *serial_name = "Amiga-builtin serial driver"; |
104 | 98 | ||
@@ -253,14 +247,14 @@ static void rs_start(struct tty_struct *tty) | |||
253 | * This routine is used by the interrupt handler to schedule | 247 | * This routine is used by the interrupt handler to schedule |
254 | * processing in the software interrupt portion of the driver. | 248 | * processing in the software interrupt portion of the driver. |
255 | */ | 249 | */ |
256 | static _INLINE_ void rs_sched_event(struct async_struct *info, | 250 | static void rs_sched_event(struct async_struct *info, |
257 | int event) | 251 | int event) |
258 | { | 252 | { |
259 | info->event |= 1 << event; | 253 | info->event |= 1 << event; |
260 | tasklet_schedule(&info->tlet); | 254 | tasklet_schedule(&info->tlet); |
261 | } | 255 | } |
262 | 256 | ||
263 | static _INLINE_ void receive_chars(struct async_struct *info) | 257 | static void receive_chars(struct async_struct *info) |
264 | { | 258 | { |
265 | int status; | 259 | int status; |
266 | int serdatr; | 260 | int serdatr; |
@@ -349,7 +343,7 @@ out: | |||
349 | return; | 343 | return; |
350 | } | 344 | } |
351 | 345 | ||
352 | static _INLINE_ void transmit_chars(struct async_struct *info) | 346 | static void transmit_chars(struct async_struct *info) |
353 | { | 347 | { |
354 | custom.intreq = IF_TBE; | 348 | custom.intreq = IF_TBE; |
355 | mb(); | 349 | mb(); |
@@ -389,7 +383,7 @@ static _INLINE_ void transmit_chars(struct async_struct *info) | |||
389 | } | 383 | } |
390 | } | 384 | } |
391 | 385 | ||
392 | static _INLINE_ void check_modem_status(struct async_struct *info) | 386 | static void check_modem_status(struct async_struct *info) |
393 | { | 387 | { |
394 | unsigned char status = ciab.pra & (SER_DCD | SER_CTS | SER_DSR); | 388 | unsigned char status = ciab.pra & (SER_DCD | SER_CTS | SER_DSR); |
395 | unsigned char dstatus; | 389 | unsigned char dstatus; |
@@ -1959,7 +1953,7 @@ done: | |||
1959 | * number, and identifies which options were configured into this | 1953 | * number, and identifies which options were configured into this |
1960 | * driver. | 1954 | * driver. |
1961 | */ | 1955 | */ |
1962 | static _INLINE_ void show_serial_version(void) | 1956 | static void show_serial_version(void) |
1963 | { | 1957 | { |
1964 | printk(KERN_INFO "%s version %s\n", serial_name, serial_version); | 1958 | printk(KERN_INFO "%s version %s\n", serial_name, serial_version); |
1965 | } | 1959 | } |
diff --git a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c index e38a5f0e07bb..5e59c0b42731 100644 --- a/drivers/char/generic_serial.c +++ b/drivers/char/generic_serial.c | |||
@@ -48,8 +48,8 @@ static int gs_debug; | |||
48 | #define NEW_WRITE_LOCKING 1 | 48 | #define NEW_WRITE_LOCKING 1 |
49 | #if NEW_WRITE_LOCKING | 49 | #if NEW_WRITE_LOCKING |
50 | #define DECL /* Nothing */ | 50 | #define DECL /* Nothing */ |
51 | #define LOCKIT down (& port->port_write_sem); | 51 | #define LOCKIT mutex_lock(& port->port_write_mutex); |
52 | #define RELEASEIT up (&port->port_write_sem); | 52 | #define RELEASEIT mutex_unlock(&port->port_write_mutex); |
53 | #else | 53 | #else |
54 | #define DECL unsigned long flags; | 54 | #define DECL unsigned long flags; |
55 | #define LOCKIT save_flags (flags);cli () | 55 | #define LOCKIT save_flags (flags);cli () |
@@ -124,14 +124,14 @@ int gs_write(struct tty_struct * tty, | |||
124 | /* get exclusive "write" access to this port (problem 3) */ | 124 | /* get exclusive "write" access to this port (problem 3) */ |
125 | /* This is not a spinlock because we can have a disk access (page | 125 | /* This is not a spinlock because we can have a disk access (page |
126 | fault) in copy_from_user */ | 126 | fault) in copy_from_user */ |
127 | down (& port->port_write_sem); | 127 | mutex_lock(& port->port_write_mutex); |
128 | 128 | ||
129 | while (1) { | 129 | while (1) { |
130 | 130 | ||
131 | c = count; | 131 | c = count; |
132 | 132 | ||
133 | /* This is safe because we "OWN" the "head". Noone else can | 133 | /* This is safe because we "OWN" the "head". Noone else can |
134 | change the "head": we own the port_write_sem. */ | 134 | change the "head": we own the port_write_mutex. */ |
135 | /* Don't overrun the end of the buffer */ | 135 | /* Don't overrun the end of the buffer */ |
136 | t = SERIAL_XMIT_SIZE - port->xmit_head; | 136 | t = SERIAL_XMIT_SIZE - port->xmit_head; |
137 | if (t < c) c = t; | 137 | if (t < c) c = t; |
@@ -153,7 +153,7 @@ int gs_write(struct tty_struct * tty, | |||
153 | count -= c; | 153 | count -= c; |
154 | total += c; | 154 | total += c; |
155 | } | 155 | } |
156 | up (& port->port_write_sem); | 156 | mutex_unlock(& port->port_write_mutex); |
157 | 157 | ||
158 | gs_dprintk (GS_DEBUG_WRITE, "write: interrupts are %s\n", | 158 | gs_dprintk (GS_DEBUG_WRITE, "write: interrupts are %s\n", |
159 | (port->flags & GS_TX_INTEN)?"enabled": "disabled"); | 159 | (port->flags & GS_TX_INTEN)?"enabled": "disabled"); |
@@ -214,7 +214,7 @@ int gs_write(struct tty_struct * tty, | |||
214 | c = count; | 214 | c = count; |
215 | 215 | ||
216 | /* This is safe because we "OWN" the "head". Noone else can | 216 | /* This is safe because we "OWN" the "head". Noone else can |
217 | change the "head": we own the port_write_sem. */ | 217 | change the "head": we own the port_write_mutex. */ |
218 | /* Don't overrun the end of the buffer */ | 218 | /* Don't overrun the end of the buffer */ |
219 | t = SERIAL_XMIT_SIZE - port->xmit_head; | 219 | t = SERIAL_XMIT_SIZE - port->xmit_head; |
220 | if (t < c) c = t; | 220 | if (t < c) c = t; |
@@ -888,7 +888,7 @@ int gs_init_port(struct gs_port *port) | |||
888 | spin_lock_irqsave (&port->driver_lock, flags); | 888 | spin_lock_irqsave (&port->driver_lock, flags); |
889 | if (port->tty) | 889 | if (port->tty) |
890 | clear_bit(TTY_IO_ERROR, &port->tty->flags); | 890 | clear_bit(TTY_IO_ERROR, &port->tty->flags); |
891 | init_MUTEX(&port->port_write_sem); | 891 | mutex_init(&port->port_write_mutex); |
892 | port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; | 892 | port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; |
893 | spin_unlock_irqrestore(&port->driver_lock, flags); | 893 | spin_unlock_irqrestore(&port->driver_lock, flags); |
894 | gs_set_termios(port->tty, NULL); | 894 | gs_set_termios(port->tty, NULL); |
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c index 28c5a3193b81..ede128356af2 100644 --- a/drivers/char/istallion.c +++ b/drivers/char/istallion.c | |||
@@ -181,7 +181,6 @@ static struct tty_driver *stli_serial; | |||
181 | * is already swapping a shared buffer won't make things any worse. | 181 | * is already swapping a shared buffer won't make things any worse. |
182 | */ | 182 | */ |
183 | static char *stli_tmpwritebuf; | 183 | static char *stli_tmpwritebuf; |
184 | static DECLARE_MUTEX(stli_tmpwritesem); | ||
185 | 184 | ||
186 | #define STLI_TXBUFSIZE 4096 | 185 | #define STLI_TXBUFSIZE 4096 |
187 | 186 | ||
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index ccad7ae94541..ede365d05387 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c | |||
@@ -132,7 +132,7 @@ static void put_tty_queue(unsigned char c, struct tty_struct *tty) | |||
132 | * We test the TTY_THROTTLED bit first so that it always | 132 | * We test the TTY_THROTTLED bit first so that it always |
133 | * indicates the current state. The decision about whether | 133 | * indicates the current state. The decision about whether |
134 | * it is worth allowing more input has been taken by the caller. | 134 | * it is worth allowing more input has been taken by the caller. |
135 | * Can sleep, may be called under the atomic_read semaphore but | 135 | * Can sleep, may be called under the atomic_read_lock mutex but |
136 | * this is not guaranteed. | 136 | * this is not guaranteed. |
137 | */ | 137 | */ |
138 | 138 | ||
@@ -1132,7 +1132,7 @@ static inline int input_available_p(struct tty_struct *tty, int amt) | |||
1132 | * buffer, and once to drain the space from the (physical) beginning of | 1132 | * buffer, and once to drain the space from the (physical) beginning of |
1133 | * the buffer to head pointer. | 1133 | * the buffer to head pointer. |
1134 | * | 1134 | * |
1135 | * Called under the tty->atomic_read sem and with TTY_DONT_FLIP set | 1135 | * Called under the tty->atomic_read_lock sem and with TTY_DONT_FLIP set |
1136 | * | 1136 | * |
1137 | */ | 1137 | */ |
1138 | 1138 | ||
@@ -1262,11 +1262,11 @@ do_it_again: | |||
1262 | * Internal serialization of reads. | 1262 | * Internal serialization of reads. |
1263 | */ | 1263 | */ |
1264 | if (file->f_flags & O_NONBLOCK) { | 1264 | if (file->f_flags & O_NONBLOCK) { |
1265 | if (down_trylock(&tty->atomic_read)) | 1265 | if (!mutex_trylock(&tty->atomic_read_lock)) |
1266 | return -EAGAIN; | 1266 | return -EAGAIN; |
1267 | } | 1267 | } |
1268 | else { | 1268 | else { |
1269 | if (down_interruptible(&tty->atomic_read)) | 1269 | if (mutex_lock_interruptible(&tty->atomic_read_lock)) |
1270 | return -ERESTARTSYS; | 1270 | return -ERESTARTSYS; |
1271 | } | 1271 | } |
1272 | 1272 | ||
@@ -1393,7 +1393,7 @@ do_it_again: | |||
1393 | timeout = time; | 1393 | timeout = time; |
1394 | } | 1394 | } |
1395 | clear_bit(TTY_DONT_FLIP, &tty->flags); | 1395 | clear_bit(TTY_DONT_FLIP, &tty->flags); |
1396 | up(&tty->atomic_read); | 1396 | mutex_unlock(&tty->atomic_read_lock); |
1397 | remove_wait_queue(&tty->read_wait, &wait); | 1397 | remove_wait_queue(&tty->read_wait, &wait); |
1398 | 1398 | ||
1399 | if (!waitqueue_active(&tty->read_wait)) | 1399 | if (!waitqueue_active(&tty->read_wait)) |
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c index ca41d62b1d9d..8865387d3448 100644 --- a/drivers/char/nwflash.c +++ b/drivers/char/nwflash.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/rwsem.h> | 27 | #include <linux/rwsem.h> |
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/smp_lock.h> | 29 | #include <linux/smp_lock.h> |
30 | #include <linux/mutex.h> | ||
30 | 31 | ||
31 | #include <asm/hardware/dec21285.h> | 32 | #include <asm/hardware/dec21285.h> |
32 | #include <asm/io.h> | 33 | #include <asm/io.h> |
@@ -56,7 +57,7 @@ static int gbWriteEnable; | |||
56 | static int gbWriteBase64Enable; | 57 | static int gbWriteBase64Enable; |
57 | static volatile unsigned char *FLASH_BASE; | 58 | static volatile unsigned char *FLASH_BASE; |
58 | static int gbFlashSize = KFLASH_SIZE; | 59 | static int gbFlashSize = KFLASH_SIZE; |
59 | static DECLARE_MUTEX(nwflash_sem); | 60 | static DEFINE_MUTEX(nwflash_mutex); |
60 | 61 | ||
61 | extern spinlock_t gpio_lock; | 62 | extern spinlock_t gpio_lock; |
62 | 63 | ||
@@ -140,7 +141,7 @@ static ssize_t flash_read(struct file *file, char __user *buf, size_t size, | |||
140 | /* | 141 | /* |
141 | * We now lock against reads and writes. --rmk | 142 | * We now lock against reads and writes. --rmk |
142 | */ | 143 | */ |
143 | if (down_interruptible(&nwflash_sem)) | 144 | if (mutex_lock_interruptible(&nwflash_mutex)) |
144 | return -ERESTARTSYS; | 145 | return -ERESTARTSYS; |
145 | 146 | ||
146 | ret = copy_to_user(buf, (void *)(FLASH_BASE + p), count); | 147 | ret = copy_to_user(buf, (void *)(FLASH_BASE + p), count); |
@@ -149,7 +150,7 @@ static ssize_t flash_read(struct file *file, char __user *buf, size_t size, | |||
149 | *ppos += count; | 150 | *ppos += count; |
150 | } else | 151 | } else |
151 | ret = -EFAULT; | 152 | ret = -EFAULT; |
152 | up(&nwflash_sem); | 153 | mutex_unlock(&nwflash_mutex); |
153 | } | 154 | } |
154 | return ret; | 155 | return ret; |
155 | } | 156 | } |
@@ -188,7 +189,7 @@ static ssize_t flash_write(struct file *file, const char __user *buf, | |||
188 | /* | 189 | /* |
189 | * We now lock against reads and writes. --rmk | 190 | * We now lock against reads and writes. --rmk |
190 | */ | 191 | */ |
191 | if (down_interruptible(&nwflash_sem)) | 192 | if (mutex_lock_interruptible(&nwflash_mutex)) |
192 | return -ERESTARTSYS; | 193 | return -ERESTARTSYS; |
193 | 194 | ||
194 | written = 0; | 195 | written = 0; |
@@ -277,7 +278,7 @@ static ssize_t flash_write(struct file *file, const char __user *buf, | |||
277 | */ | 278 | */ |
278 | leds_event(led_release); | 279 | leds_event(led_release); |
279 | 280 | ||
280 | up(&nwflash_sem); | 281 | mutex_unlock(&nwflash_mutex); |
281 | 282 | ||
282 | return written; | 283 | return written; |
283 | } | 284 | } |
diff --git a/drivers/char/raw.c b/drivers/char/raw.c index 30e4cbe16bb0..15a7b4086524 100644 --- a/drivers/char/raw.c +++ b/drivers/char/raw.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/uio.h> | 19 | #include <linux/uio.h> |
20 | #include <linux/cdev.h> | 20 | #include <linux/cdev.h> |
21 | #include <linux/device.h> | 21 | #include <linux/device.h> |
22 | #include <linux/mutex.h> | ||
22 | 23 | ||
23 | #include <asm/uaccess.h> | 24 | #include <asm/uaccess.h> |
24 | 25 | ||
@@ -29,7 +30,7 @@ struct raw_device_data { | |||
29 | 30 | ||
30 | static struct class *raw_class; | 31 | static struct class *raw_class; |
31 | static struct raw_device_data raw_devices[MAX_RAW_MINORS]; | 32 | static struct raw_device_data raw_devices[MAX_RAW_MINORS]; |
32 | static DECLARE_MUTEX(raw_mutex); | 33 | static DEFINE_MUTEX(raw_mutex); |
33 | static struct file_operations raw_ctl_fops; /* forward declaration */ | 34 | static struct file_operations raw_ctl_fops; /* forward declaration */ |
34 | 35 | ||
35 | /* | 36 | /* |
@@ -53,7 +54,7 @@ static int raw_open(struct inode *inode, struct file *filp) | |||
53 | return 0; | 54 | return 0; |
54 | } | 55 | } |
55 | 56 | ||
56 | down(&raw_mutex); | 57 | mutex_lock(&raw_mutex); |
57 | 58 | ||
58 | /* | 59 | /* |
59 | * All we need to do on open is check that the device is bound. | 60 | * All we need to do on open is check that the device is bound. |
@@ -78,7 +79,7 @@ static int raw_open(struct inode *inode, struct file *filp) | |||
78 | filp->f_dentry->d_inode->i_mapping = | 79 | filp->f_dentry->d_inode->i_mapping = |
79 | bdev->bd_inode->i_mapping; | 80 | bdev->bd_inode->i_mapping; |
80 | filp->private_data = bdev; | 81 | filp->private_data = bdev; |
81 | up(&raw_mutex); | 82 | mutex_unlock(&raw_mutex); |
82 | return 0; | 83 | return 0; |
83 | 84 | ||
84 | out2: | 85 | out2: |
@@ -86,7 +87,7 @@ out2: | |||
86 | out1: | 87 | out1: |
87 | blkdev_put(bdev); | 88 | blkdev_put(bdev); |
88 | out: | 89 | out: |
89 | up(&raw_mutex); | 90 | mutex_unlock(&raw_mutex); |
90 | return err; | 91 | return err; |
91 | } | 92 | } |
92 | 93 | ||
@@ -99,14 +100,14 @@ static int raw_release(struct inode *inode, struct file *filp) | |||
99 | const int minor= iminor(inode); | 100 | const int minor= iminor(inode); |
100 | struct block_device *bdev; | 101 | struct block_device *bdev; |
101 | 102 | ||
102 | down(&raw_mutex); | 103 | mutex_lock(&raw_mutex); |
103 | bdev = raw_devices[minor].binding; | 104 | bdev = raw_devices[minor].binding; |
104 | if (--raw_devices[minor].inuse == 0) { | 105 | if (--raw_devices[minor].inuse == 0) { |
105 | /* Here inode->i_mapping == bdev->bd_inode->i_mapping */ | 106 | /* Here inode->i_mapping == bdev->bd_inode->i_mapping */ |
106 | inode->i_mapping = &inode->i_data; | 107 | inode->i_mapping = &inode->i_data; |
107 | inode->i_mapping->backing_dev_info = &default_backing_dev_info; | 108 | inode->i_mapping->backing_dev_info = &default_backing_dev_info; |
108 | } | 109 | } |
109 | up(&raw_mutex); | 110 | mutex_unlock(&raw_mutex); |
110 | 111 | ||
111 | bd_release(bdev); | 112 | bd_release(bdev); |
112 | blkdev_put(bdev); | 113 | blkdev_put(bdev); |
@@ -187,9 +188,9 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp, | |||
187 | goto out; | 188 | goto out; |
188 | } | 189 | } |
189 | 190 | ||
190 | down(&raw_mutex); | 191 | mutex_lock(&raw_mutex); |
191 | if (rawdev->inuse) { | 192 | if (rawdev->inuse) { |
192 | up(&raw_mutex); | 193 | mutex_unlock(&raw_mutex); |
193 | err = -EBUSY; | 194 | err = -EBUSY; |
194 | goto out; | 195 | goto out; |
195 | } | 196 | } |
@@ -211,11 +212,11 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp, | |||
211 | bind_device(&rq); | 212 | bind_device(&rq); |
212 | } | 213 | } |
213 | } | 214 | } |
214 | up(&raw_mutex); | 215 | mutex_unlock(&raw_mutex); |
215 | } else { | 216 | } else { |
216 | struct block_device *bdev; | 217 | struct block_device *bdev; |
217 | 218 | ||
218 | down(&raw_mutex); | 219 | mutex_lock(&raw_mutex); |
219 | bdev = rawdev->binding; | 220 | bdev = rawdev->binding; |
220 | if (bdev) { | 221 | if (bdev) { |
221 | rq.block_major = MAJOR(bdev->bd_dev); | 222 | rq.block_major = MAJOR(bdev->bd_dev); |
@@ -223,7 +224,7 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp, | |||
223 | } else { | 224 | } else { |
224 | rq.block_major = rq.block_minor = 0; | 225 | rq.block_major = rq.block_minor = 0; |
225 | } | 226 | } |
226 | up(&raw_mutex); | 227 | mutex_unlock(&raw_mutex); |
227 | if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) { | 228 | if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) { |
228 | err = -EFAULT; | 229 | err = -EFAULT; |
229 | goto out; | 230 | goto out; |
diff --git a/drivers/char/ser_a2232.c b/drivers/char/ser_a2232.c index fee68cc895f8..510bd3e0e88b 100644 --- a/drivers/char/ser_a2232.c +++ b/drivers/char/ser_a2232.c | |||
@@ -97,7 +97,7 @@ | |||
97 | #include <asm/amigahw.h> | 97 | #include <asm/amigahw.h> |
98 | #include <linux/zorro.h> | 98 | #include <linux/zorro.h> |
99 | #include <asm/irq.h> | 99 | #include <asm/irq.h> |
100 | #include <asm/semaphore.h> | 100 | #include <linux/mutex.h> |
101 | 101 | ||
102 | #include <linux/delay.h> | 102 | #include <linux/delay.h> |
103 | 103 | ||
@@ -654,7 +654,7 @@ static void a2232_init_portstructs(void) | |||
654 | port->gs.closing_wait = 30 * HZ; | 654 | port->gs.closing_wait = 30 * HZ; |
655 | port->gs.rd = &a2232_real_driver; | 655 | port->gs.rd = &a2232_real_driver; |
656 | #ifdef NEW_WRITE_LOCKING | 656 | #ifdef NEW_WRITE_LOCKING |
657 | init_MUTEX(&(port->gs.port_write_sem)); | 657 | init_MUTEX(&(port->gs.port_write_mutex)); |
658 | #endif | 658 | #endif |
659 | init_waitqueue_head(&port->gs.open_wait); | 659 | init_waitqueue_head(&port->gs.open_wait); |
660 | init_waitqueue_head(&port->gs.close_wait); | 660 | init_waitqueue_head(&port->gs.close_wait); |
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c index 0e7d216e7eb0..b543821d8cb4 100644 --- a/drivers/char/snsc.c +++ b/drivers/char/snsc.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * License. See the file "COPYING" in the main directory of this archive | 5 | * License. See the file "COPYING" in the main directory of this archive |
6 | * for more details. | 6 | * for more details. |
7 | * | 7 | * |
8 | * Copyright (C) 2004 Silicon Graphics, Inc. All rights reserved. | 8 | * Copyright (C) 2004, 2006 Silicon Graphics, Inc. All rights reserved. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | /* | 11 | /* |
@@ -77,7 +77,7 @@ scdrv_open(struct inode *inode, struct file *file) | |||
77 | scd = container_of(inode->i_cdev, struct sysctl_data_s, scd_cdev); | 77 | scd = container_of(inode->i_cdev, struct sysctl_data_s, scd_cdev); |
78 | 78 | ||
79 | /* allocate memory for subchannel data */ | 79 | /* allocate memory for subchannel data */ |
80 | sd = kmalloc(sizeof (struct subch_data_s), GFP_KERNEL); | 80 | sd = kzalloc(sizeof (struct subch_data_s), GFP_KERNEL); |
81 | if (sd == NULL) { | 81 | if (sd == NULL) { |
82 | printk("%s: couldn't allocate subchannel data\n", | 82 | printk("%s: couldn't allocate subchannel data\n", |
83 | __FUNCTION__); | 83 | __FUNCTION__); |
@@ -85,7 +85,6 @@ scdrv_open(struct inode *inode, struct file *file) | |||
85 | } | 85 | } |
86 | 86 | ||
87 | /* initialize subch_data_s fields */ | 87 | /* initialize subch_data_s fields */ |
88 | memset(sd, 0, sizeof (struct subch_data_s)); | ||
89 | sd->sd_nasid = scd->scd_nasid; | 88 | sd->sd_nasid = scd->scd_nasid; |
90 | sd->sd_subch = ia64_sn_irtr_open(scd->scd_nasid); | 89 | sd->sd_subch = ia64_sn_irtr_open(scd->scd_nasid); |
91 | 90 | ||
@@ -394,7 +393,7 @@ scdrv_init(void) | |||
394 | sprintf(devnamep, "#%d", geo_slab(geoid)); | 393 | sprintf(devnamep, "#%d", geo_slab(geoid)); |
395 | 394 | ||
396 | /* allocate sysctl device data */ | 395 | /* allocate sysctl device data */ |
397 | scd = kmalloc(sizeof (struct sysctl_data_s), | 396 | scd = kzalloc(sizeof (struct sysctl_data_s), |
398 | GFP_KERNEL); | 397 | GFP_KERNEL); |
399 | if (!scd) { | 398 | if (!scd) { |
400 | printk("%s: failed to allocate device info" | 399 | printk("%s: failed to allocate device info" |
@@ -402,7 +401,6 @@ scdrv_init(void) | |||
402 | SYSCTL_BASENAME, devname); | 401 | SYSCTL_BASENAME, devname); |
403 | continue; | 402 | continue; |
404 | } | 403 | } |
405 | memset(scd, 0, sizeof (struct sysctl_data_s)); | ||
406 | 404 | ||
407 | /* initialize sysctl device data fields */ | 405 | /* initialize sysctl device data fields */ |
408 | scd->scd_nasid = cnodeid_to_nasid(cnode); | 406 | scd->scd_nasid = cnodeid_to_nasid(cnode); |
diff --git a/drivers/char/snsc_event.c b/drivers/char/snsc_event.c index a4fa507eed9e..e234d50e142a 100644 --- a/drivers/char/snsc_event.c +++ b/drivers/char/snsc_event.c | |||
@@ -287,7 +287,7 @@ scdrv_event_init(struct sysctl_data_s *scd) | |||
287 | { | 287 | { |
288 | int rv; | 288 | int rv; |
289 | 289 | ||
290 | event_sd = kmalloc(sizeof (struct subch_data_s), GFP_KERNEL); | 290 | event_sd = kzalloc(sizeof (struct subch_data_s), GFP_KERNEL); |
291 | if (event_sd == NULL) { | 291 | if (event_sd == NULL) { |
292 | printk(KERN_WARNING "%s: couldn't allocate subchannel info" | 292 | printk(KERN_WARNING "%s: couldn't allocate subchannel info" |
293 | " for event monitoring\n", __FUNCTION__); | 293 | " for event monitoring\n", __FUNCTION__); |
@@ -295,7 +295,6 @@ scdrv_event_init(struct sysctl_data_s *scd) | |||
295 | } | 295 | } |
296 | 296 | ||
297 | /* initialize subch_data_s fields */ | 297 | /* initialize subch_data_s fields */ |
298 | memset(event_sd, 0, sizeof (struct subch_data_s)); | ||
299 | event_sd->sd_nasid = scd->scd_nasid; | 298 | event_sd->sd_nasid = scd->scd_nasid; |
300 | spin_lock_init(&event_sd->sd_rlock); | 299 | spin_lock_init(&event_sd->sd_rlock); |
301 | 300 | ||
@@ -321,5 +320,3 @@ scdrv_event_init(struct sysctl_data_s *scd) | |||
321 | return; | 320 | return; |
322 | } | 321 | } |
323 | } | 322 | } |
324 | |||
325 | |||
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c index bdaab6992109..3f5d6077f39c 100644 --- a/drivers/char/stallion.c +++ b/drivers/char/stallion.c | |||
@@ -148,7 +148,6 @@ static struct tty_driver *stl_serial; | |||
148 | * is already swapping a shared buffer won't make things any worse. | 148 | * is already swapping a shared buffer won't make things any worse. |
149 | */ | 149 | */ |
150 | static char *stl_tmpwritebuf; | 150 | static char *stl_tmpwritebuf; |
151 | static DECLARE_MUTEX(stl_tmpwritesem); | ||
152 | 151 | ||
153 | /* | 152 | /* |
154 | * Define a local default termios struct. All ports will be created | 153 | * Define a local default termios struct. All ports will be created |
diff --git a/drivers/char/sx.c b/drivers/char/sx.c index a6b4f02bdceb..3b4747230270 100644 --- a/drivers/char/sx.c +++ b/drivers/char/sx.c | |||
@@ -2318,7 +2318,7 @@ static int sx_init_portstructs (int nboards, int nports) | |||
2318 | port->board = board; | 2318 | port->board = board; |
2319 | port->gs.rd = &sx_real_driver; | 2319 | port->gs.rd = &sx_real_driver; |
2320 | #ifdef NEW_WRITE_LOCKING | 2320 | #ifdef NEW_WRITE_LOCKING |
2321 | port->gs.port_write_sem = MUTEX; | 2321 | port->gs.port_write_mutex = MUTEX; |
2322 | #endif | 2322 | #endif |
2323 | port->gs.driver_lock = SPIN_LOCK_UNLOCKED; | 2323 | port->gs.driver_lock = SPIN_LOCK_UNLOCKED; |
2324 | /* | 2324 | /* |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 53d3d066554e..76592ee1fb38 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -130,7 +130,7 @@ LIST_HEAD(tty_drivers); /* linked list of tty drivers */ | |||
130 | 130 | ||
131 | /* Semaphore to protect creating and releasing a tty. This is shared with | 131 | /* Semaphore to protect creating and releasing a tty. This is shared with |
132 | vt.c for deeply disgusting hack reasons */ | 132 | vt.c for deeply disgusting hack reasons */ |
133 | DECLARE_MUTEX(tty_sem); | 133 | DEFINE_MUTEX(tty_mutex); |
134 | 134 | ||
135 | #ifdef CONFIG_UNIX98_PTYS | 135 | #ifdef CONFIG_UNIX98_PTYS |
136 | extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */ | 136 | extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */ |
@@ -1188,11 +1188,11 @@ void disassociate_ctty(int on_exit) | |||
1188 | 1188 | ||
1189 | lock_kernel(); | 1189 | lock_kernel(); |
1190 | 1190 | ||
1191 | down(&tty_sem); | 1191 | mutex_lock(&tty_mutex); |
1192 | tty = current->signal->tty; | 1192 | tty = current->signal->tty; |
1193 | if (tty) { | 1193 | if (tty) { |
1194 | tty_pgrp = tty->pgrp; | 1194 | tty_pgrp = tty->pgrp; |
1195 | up(&tty_sem); | 1195 | mutex_unlock(&tty_mutex); |
1196 | if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) | 1196 | if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) |
1197 | tty_vhangup(tty); | 1197 | tty_vhangup(tty); |
1198 | } else { | 1198 | } else { |
@@ -1200,7 +1200,7 @@ void disassociate_ctty(int on_exit) | |||
1200 | kill_pg(current->signal->tty_old_pgrp, SIGHUP, on_exit); | 1200 | kill_pg(current->signal->tty_old_pgrp, SIGHUP, on_exit); |
1201 | kill_pg(current->signal->tty_old_pgrp, SIGCONT, on_exit); | 1201 | kill_pg(current->signal->tty_old_pgrp, SIGCONT, on_exit); |
1202 | } | 1202 | } |
1203 | up(&tty_sem); | 1203 | mutex_unlock(&tty_mutex); |
1204 | unlock_kernel(); | 1204 | unlock_kernel(); |
1205 | return; | 1205 | return; |
1206 | } | 1206 | } |
@@ -1211,7 +1211,7 @@ void disassociate_ctty(int on_exit) | |||
1211 | } | 1211 | } |
1212 | 1212 | ||
1213 | /* Must lock changes to tty_old_pgrp */ | 1213 | /* Must lock changes to tty_old_pgrp */ |
1214 | down(&tty_sem); | 1214 | mutex_lock(&tty_mutex); |
1215 | current->signal->tty_old_pgrp = 0; | 1215 | current->signal->tty_old_pgrp = 0; |
1216 | tty->session = 0; | 1216 | tty->session = 0; |
1217 | tty->pgrp = -1; | 1217 | tty->pgrp = -1; |
@@ -1222,7 +1222,7 @@ void disassociate_ctty(int on_exit) | |||
1222 | p->signal->tty = NULL; | 1222 | p->signal->tty = NULL; |
1223 | } while_each_task_pid(current->signal->session, PIDTYPE_SID, p); | 1223 | } while_each_task_pid(current->signal->session, PIDTYPE_SID, p); |
1224 | read_unlock(&tasklist_lock); | 1224 | read_unlock(&tasklist_lock); |
1225 | up(&tty_sem); | 1225 | mutex_unlock(&tty_mutex); |
1226 | unlock_kernel(); | 1226 | unlock_kernel(); |
1227 | } | 1227 | } |
1228 | 1228 | ||
@@ -1306,7 +1306,7 @@ static inline ssize_t do_tty_write( | |||
1306 | ssize_t ret = 0, written = 0; | 1306 | ssize_t ret = 0, written = 0; |
1307 | unsigned int chunk; | 1307 | unsigned int chunk; |
1308 | 1308 | ||
1309 | if (down_interruptible(&tty->atomic_write)) { | 1309 | if (mutex_lock_interruptible(&tty->atomic_write_lock)) { |
1310 | return -ERESTARTSYS; | 1310 | return -ERESTARTSYS; |
1311 | } | 1311 | } |
1312 | 1312 | ||
@@ -1329,7 +1329,7 @@ static inline ssize_t do_tty_write( | |||
1329 | if (count < chunk) | 1329 | if (count < chunk) |
1330 | chunk = count; | 1330 | chunk = count; |
1331 | 1331 | ||
1332 | /* write_buf/write_cnt is protected by the atomic_write semaphore */ | 1332 | /* write_buf/write_cnt is protected by the atomic_write_lock mutex */ |
1333 | if (tty->write_cnt < chunk) { | 1333 | if (tty->write_cnt < chunk) { |
1334 | unsigned char *buf; | 1334 | unsigned char *buf; |
1335 | 1335 | ||
@@ -1338,7 +1338,7 @@ static inline ssize_t do_tty_write( | |||
1338 | 1338 | ||
1339 | buf = kmalloc(chunk, GFP_KERNEL); | 1339 | buf = kmalloc(chunk, GFP_KERNEL); |
1340 | if (!buf) { | 1340 | if (!buf) { |
1341 | up(&tty->atomic_write); | 1341 | mutex_unlock(&tty->atomic_write_lock); |
1342 | return -ENOMEM; | 1342 | return -ENOMEM; |
1343 | } | 1343 | } |
1344 | kfree(tty->write_buf); | 1344 | kfree(tty->write_buf); |
@@ -1374,7 +1374,7 @@ static inline ssize_t do_tty_write( | |||
1374 | inode->i_mtime = current_fs_time(inode->i_sb); | 1374 | inode->i_mtime = current_fs_time(inode->i_sb); |
1375 | ret = written; | 1375 | ret = written; |
1376 | } | 1376 | } |
1377 | up(&tty->atomic_write); | 1377 | mutex_unlock(&tty->atomic_write_lock); |
1378 | return ret; | 1378 | return ret; |
1379 | } | 1379 | } |
1380 | 1380 | ||
@@ -1442,8 +1442,8 @@ static inline void tty_line_name(struct tty_driver *driver, int index, char *p) | |||
1442 | 1442 | ||
1443 | /* | 1443 | /* |
1444 | * WSH 06/09/97: Rewritten to remove races and properly clean up after a | 1444 | * WSH 06/09/97: Rewritten to remove races and properly clean up after a |
1445 | * failed open. The new code protects the open with a semaphore, so it's | 1445 | * failed open. The new code protects the open with a mutex, so it's |
1446 | * really quite straightforward. The semaphore locking can probably be | 1446 | * really quite straightforward. The mutex locking can probably be |
1447 | * relaxed for the (most common) case of reopening a tty. | 1447 | * relaxed for the (most common) case of reopening a tty. |
1448 | */ | 1448 | */ |
1449 | static int init_dev(struct tty_driver *driver, int idx, | 1449 | static int init_dev(struct tty_driver *driver, int idx, |
@@ -1640,7 +1640,7 @@ fast_track: | |||
1640 | success: | 1640 | success: |
1641 | *ret_tty = tty; | 1641 | *ret_tty = tty; |
1642 | 1642 | ||
1643 | /* All paths come through here to release the semaphore */ | 1643 | /* All paths come through here to release the mutex */ |
1644 | end_init: | 1644 | end_init: |
1645 | return retval; | 1645 | return retval; |
1646 | 1646 | ||
@@ -1837,7 +1837,7 @@ static void release_dev(struct file * filp) | |||
1837 | /* Guard against races with tty->count changes elsewhere and | 1837 | /* Guard against races with tty->count changes elsewhere and |
1838 | opens on /dev/tty */ | 1838 | opens on /dev/tty */ |
1839 | 1839 | ||
1840 | down(&tty_sem); | 1840 | mutex_lock(&tty_mutex); |
1841 | tty_closing = tty->count <= 1; | 1841 | tty_closing = tty->count <= 1; |
1842 | o_tty_closing = o_tty && | 1842 | o_tty_closing = o_tty && |
1843 | (o_tty->count <= (pty_master ? 1 : 0)); | 1843 | (o_tty->count <= (pty_master ? 1 : 0)); |
@@ -1868,7 +1868,7 @@ static void release_dev(struct file * filp) | |||
1868 | 1868 | ||
1869 | printk(KERN_WARNING "release_dev: %s: read/write wait queue " | 1869 | printk(KERN_WARNING "release_dev: %s: read/write wait queue " |
1870 | "active!\n", tty_name(tty, buf)); | 1870 | "active!\n", tty_name(tty, buf)); |
1871 | up(&tty_sem); | 1871 | mutex_unlock(&tty_mutex); |
1872 | schedule(); | 1872 | schedule(); |
1873 | } | 1873 | } |
1874 | 1874 | ||
@@ -1934,7 +1934,7 @@ static void release_dev(struct file * filp) | |||
1934 | read_unlock(&tasklist_lock); | 1934 | read_unlock(&tasklist_lock); |
1935 | } | 1935 | } |
1936 | 1936 | ||
1937 | up(&tty_sem); | 1937 | mutex_unlock(&tty_mutex); |
1938 | 1938 | ||
1939 | /* check whether both sides are closing ... */ | 1939 | /* check whether both sides are closing ... */ |
1940 | if (!tty_closing || (o_tty && !o_tty_closing)) | 1940 | if (!tty_closing || (o_tty && !o_tty_closing)) |
@@ -2040,11 +2040,11 @@ retry_open: | |||
2040 | index = -1; | 2040 | index = -1; |
2041 | retval = 0; | 2041 | retval = 0; |
2042 | 2042 | ||
2043 | down(&tty_sem); | 2043 | mutex_lock(&tty_mutex); |
2044 | 2044 | ||
2045 | if (device == MKDEV(TTYAUX_MAJOR,0)) { | 2045 | if (device == MKDEV(TTYAUX_MAJOR,0)) { |
2046 | if (!current->signal->tty) { | 2046 | if (!current->signal->tty) { |
2047 | up(&tty_sem); | 2047 | mutex_unlock(&tty_mutex); |
2048 | return -ENXIO; | 2048 | return -ENXIO; |
2049 | } | 2049 | } |
2050 | driver = current->signal->tty->driver; | 2050 | driver = current->signal->tty->driver; |
@@ -2070,18 +2070,18 @@ retry_open: | |||
2070 | noctty = 1; | 2070 | noctty = 1; |
2071 | goto got_driver; | 2071 | goto got_driver; |
2072 | } | 2072 | } |
2073 | up(&tty_sem); | 2073 | mutex_unlock(&tty_mutex); |
2074 | return -ENODEV; | 2074 | return -ENODEV; |
2075 | } | 2075 | } |
2076 | 2076 | ||
2077 | driver = get_tty_driver(device, &index); | 2077 | driver = get_tty_driver(device, &index); |
2078 | if (!driver) { | 2078 | if (!driver) { |
2079 | up(&tty_sem); | 2079 | mutex_unlock(&tty_mutex); |
2080 | return -ENODEV; | 2080 | return -ENODEV; |
2081 | } | 2081 | } |
2082 | got_driver: | 2082 | got_driver: |
2083 | retval = init_dev(driver, index, &tty); | 2083 | retval = init_dev(driver, index, &tty); |
2084 | up(&tty_sem); | 2084 | mutex_unlock(&tty_mutex); |
2085 | if (retval) | 2085 | if (retval) |
2086 | return retval; | 2086 | return retval; |
2087 | 2087 | ||
@@ -2167,9 +2167,9 @@ static int ptmx_open(struct inode * inode, struct file * filp) | |||
2167 | } | 2167 | } |
2168 | up(&allocated_ptys_lock); | 2168 | up(&allocated_ptys_lock); |
2169 | 2169 | ||
2170 | down(&tty_sem); | 2170 | mutex_lock(&tty_mutex); |
2171 | retval = init_dev(ptm_driver, index, &tty); | 2171 | retval = init_dev(ptm_driver, index, &tty); |
2172 | up(&tty_sem); | 2172 | mutex_unlock(&tty_mutex); |
2173 | 2173 | ||
2174 | if (retval) | 2174 | if (retval) |
2175 | goto out; | 2175 | goto out; |
@@ -2915,8 +2915,8 @@ static void initialize_tty_struct(struct tty_struct *tty) | |||
2915 | init_waitqueue_head(&tty->write_wait); | 2915 | init_waitqueue_head(&tty->write_wait); |
2916 | init_waitqueue_head(&tty->read_wait); | 2916 | init_waitqueue_head(&tty->read_wait); |
2917 | INIT_WORK(&tty->hangup_work, do_tty_hangup, tty); | 2917 | INIT_WORK(&tty->hangup_work, do_tty_hangup, tty); |
2918 | sema_init(&tty->atomic_read, 1); | 2918 | mutex_init(&tty->atomic_read_lock); |
2919 | sema_init(&tty->atomic_write, 1); | 2919 | mutex_init(&tty->atomic_write_lock); |
2920 | spin_lock_init(&tty->read_lock); | 2920 | spin_lock_init(&tty->read_lock); |
2921 | INIT_LIST_HEAD(&tty->tty_files); | 2921 | INIT_LIST_HEAD(&tty->tty_files); |
2922 | INIT_WORK(&tty->SAK_work, NULL, NULL); | 2922 | INIT_WORK(&tty->SAK_work, NULL, NULL); |
diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c index d9325281e482..fd00822ac145 100644 --- a/drivers/char/vme_scc.c +++ b/drivers/char/vme_scc.c | |||
@@ -184,7 +184,7 @@ static void scc_init_portstructs(void) | |||
184 | port->gs.closing_wait = 30 * HZ; | 184 | port->gs.closing_wait = 30 * HZ; |
185 | port->gs.rd = &scc_real_driver; | 185 | port->gs.rd = &scc_real_driver; |
186 | #ifdef NEW_WRITE_LOCKING | 186 | #ifdef NEW_WRITE_LOCKING |
187 | port->gs.port_write_sem = MUTEX; | 187 | port->gs.port_write_mutex = MUTEX; |
188 | #endif | 188 | #endif |
189 | init_waitqueue_head(&port->gs.open_wait); | 189 | init_waitqueue_head(&port->gs.open_wait); |
190 | init_waitqueue_head(&port->gs.close_wait); | 190 | init_waitqueue_head(&port->gs.close_wait); |
diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 0900d1dbee59..ca4844c527da 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c | |||
@@ -2489,7 +2489,7 @@ static int con_open(struct tty_struct *tty, struct file *filp) | |||
2489 | } | 2489 | } |
2490 | 2490 | ||
2491 | /* | 2491 | /* |
2492 | * We take tty_sem in here to prevent another thread from coming in via init_dev | 2492 | * We take tty_mutex in here to prevent another thread from coming in via init_dev |
2493 | * and taking a ref against the tty while we're in the process of forgetting | 2493 | * and taking a ref against the tty while we're in the process of forgetting |
2494 | * about it and cleaning things up. | 2494 | * about it and cleaning things up. |
2495 | * | 2495 | * |
@@ -2497,7 +2497,7 @@ static int con_open(struct tty_struct *tty, struct file *filp) | |||
2497 | */ | 2497 | */ |
2498 | static void con_close(struct tty_struct *tty, struct file *filp) | 2498 | static void con_close(struct tty_struct *tty, struct file *filp) |
2499 | { | 2499 | { |
2500 | down(&tty_sem); | 2500 | mutex_lock(&tty_mutex); |
2501 | acquire_console_sem(); | 2501 | acquire_console_sem(); |
2502 | if (tty && tty->count == 1) { | 2502 | if (tty && tty->count == 1) { |
2503 | struct vc_data *vc = tty->driver_data; | 2503 | struct vc_data *vc = tty->driver_data; |
@@ -2507,15 +2507,15 @@ static void con_close(struct tty_struct *tty, struct file *filp) | |||
2507 | tty->driver_data = NULL; | 2507 | tty->driver_data = NULL; |
2508 | release_console_sem(); | 2508 | release_console_sem(); |
2509 | vcs_remove_devfs(tty); | 2509 | vcs_remove_devfs(tty); |
2510 | up(&tty_sem); | 2510 | mutex_unlock(&tty_mutex); |
2511 | /* | 2511 | /* |
2512 | * tty_sem is released, but we still hold BKL, so there is | 2512 | * tty_mutex is released, but we still hold BKL, so there is |
2513 | * still exclusion against init_dev() | 2513 | * still exclusion against init_dev() |
2514 | */ | 2514 | */ |
2515 | return; | 2515 | return; |
2516 | } | 2516 | } |
2517 | release_console_sem(); | 2517 | release_console_sem(); |
2518 | up(&tty_sem); | 2518 | mutex_unlock(&tty_mutex); |
2519 | } | 2519 | } |
2520 | 2520 | ||
2521 | static void vc_init(struct vc_data *vc, unsigned int rows, | 2521 | static void vc_init(struct vc_data *vc, unsigned int rows, |
@@ -2869,9 +2869,9 @@ void unblank_screen(void) | |||
2869 | } | 2869 | } |
2870 | 2870 | ||
2871 | /* | 2871 | /* |
2872 | * We defer the timer blanking to work queue so it can take the console semaphore | 2872 | * We defer the timer blanking to work queue so it can take the console mutex |
2873 | * (console operations can still happen at irq time, but only from printk which | 2873 | * (console operations can still happen at irq time, but only from printk which |
2874 | * has the console semaphore. Not perfect yet, but better than no locking | 2874 | * has the console mutex. Not perfect yet, but better than no locking |
2875 | */ | 2875 | */ |
2876 | static void blank_screen_t(unsigned long dummy) | 2876 | static void blank_screen_t(unsigned long dummy) |
2877 | { | 2877 | { |
@@ -3234,6 +3234,14 @@ void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org) | |||
3234 | } | 3234 | } |
3235 | } | 3235 | } |
3236 | 3236 | ||
3237 | int is_console_suspend_safe(void) | ||
3238 | { | ||
3239 | /* It is unsafe to suspend devices while X has control of the | ||
3240 | * hardware. Make sure we are running on a kernel-controlled console. | ||
3241 | */ | ||
3242 | return vc_cons[fg_console].d->vc_mode == KD_TEXT; | ||
3243 | } | ||
3244 | |||
3237 | /* | 3245 | /* |
3238 | * Visible symbols for modules | 3246 | * Visible symbols for modules |
3239 | */ | 3247 | */ |
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c index 1533f56baa42..2700c5c45b8a 100644 --- a/drivers/char/watchdog/pcwd_usb.c +++ b/drivers/char/watchdog/pcwd_usb.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/completion.h> | 42 | #include <linux/completion.h> |
43 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
44 | #include <linux/usb.h> | 44 | #include <linux/usb.h> |
45 | #include <linux/mutex.h> | ||
45 | 46 | ||
46 | 47 | ||
47 | #ifdef CONFIG_USB_DEBUG | 48 | #ifdef CONFIG_USB_DEBUG |
@@ -143,7 +144,7 @@ struct usb_pcwd_private { | |||
143 | static struct usb_pcwd_private *usb_pcwd_device; | 144 | static struct usb_pcwd_private *usb_pcwd_device; |
144 | 145 | ||
145 | /* prevent races between open() and disconnect() */ | 146 | /* prevent races between open() and disconnect() */ |
146 | static DECLARE_MUTEX (disconnect_sem); | 147 | static DEFINE_MUTEX(disconnect_mutex); |
147 | 148 | ||
148 | /* local function prototypes */ | 149 | /* local function prototypes */ |
149 | static int usb_pcwd_probe (struct usb_interface *interface, const struct usb_device_id *id); | 150 | static int usb_pcwd_probe (struct usb_interface *interface, const struct usb_device_id *id); |
@@ -723,7 +724,7 @@ static void usb_pcwd_disconnect(struct usb_interface *interface) | |||
723 | struct usb_pcwd_private *usb_pcwd; | 724 | struct usb_pcwd_private *usb_pcwd; |
724 | 725 | ||
725 | /* prevent races with open() */ | 726 | /* prevent races with open() */ |
726 | down (&disconnect_sem); | 727 | mutex_lock(&disconnect_mutex); |
727 | 728 | ||
728 | usb_pcwd = usb_get_intfdata (interface); | 729 | usb_pcwd = usb_get_intfdata (interface); |
729 | usb_set_intfdata (interface, NULL); | 730 | usb_set_intfdata (interface, NULL); |
@@ -749,7 +750,7 @@ static void usb_pcwd_disconnect(struct usb_interface *interface) | |||
749 | 750 | ||
750 | cards_found--; | 751 | cards_found--; |
751 | 752 | ||
752 | up (&disconnect_sem); | 753 | mutex_unlock(&disconnect_mutex); |
753 | 754 | ||
754 | printk(KERN_INFO PFX "USB PC Watchdog disconnected\n"); | 755 | printk(KERN_INFO PFX "USB PC Watchdog disconnected\n"); |
755 | } | 756 | } |
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c index d7125f4d9113..35897079a78d 100644 --- a/drivers/connector/connector.c +++ b/drivers/connector/connector.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/netlink.h> | 26 | #include <linux/netlink.h> |
27 | #include <linux/moduleparam.h> | 27 | #include <linux/moduleparam.h> |
28 | #include <linux/connector.h> | 28 | #include <linux/connector.h> |
29 | #include <linux/mutex.h> | ||
29 | 30 | ||
30 | #include <net/sock.h> | 31 | #include <net/sock.h> |
31 | 32 | ||
@@ -41,7 +42,7 @@ module_param(cn_val, uint, 0); | |||
41 | MODULE_PARM_DESC(cn_idx, "Connector's main device idx."); | 42 | MODULE_PARM_DESC(cn_idx, "Connector's main device idx."); |
42 | MODULE_PARM_DESC(cn_val, "Connector's main device val."); | 43 | MODULE_PARM_DESC(cn_val, "Connector's main device val."); |
43 | 44 | ||
44 | static DECLARE_MUTEX(notify_lock); | 45 | static DEFINE_MUTEX(notify_lock); |
45 | static LIST_HEAD(notify_list); | 46 | static LIST_HEAD(notify_list); |
46 | 47 | ||
47 | static struct cn_dev cdev; | 48 | static struct cn_dev cdev; |
@@ -260,7 +261,7 @@ static void cn_notify(struct cb_id *id, u32 notify_event) | |||
260 | { | 261 | { |
261 | struct cn_ctl_entry *ent; | 262 | struct cn_ctl_entry *ent; |
262 | 263 | ||
263 | down(¬ify_lock); | 264 | mutex_lock(¬ify_lock); |
264 | list_for_each_entry(ent, ¬ify_list, notify_entry) { | 265 | list_for_each_entry(ent, ¬ify_list, notify_entry) { |
265 | int i; | 266 | int i; |
266 | struct cn_notify_req *req; | 267 | struct cn_notify_req *req; |
@@ -293,7 +294,7 @@ static void cn_notify(struct cb_id *id, u32 notify_event) | |||
293 | cn_netlink_send(&m, ctl->group, GFP_KERNEL); | 294 | cn_netlink_send(&m, ctl->group, GFP_KERNEL); |
294 | } | 295 | } |
295 | } | 296 | } |
296 | up(¬ify_lock); | 297 | mutex_unlock(¬ify_lock); |
297 | } | 298 | } |
298 | 299 | ||
299 | /* | 300 | /* |
@@ -407,14 +408,14 @@ static void cn_callback(void *data) | |||
407 | if (ctl->group == 0) { | 408 | if (ctl->group == 0) { |
408 | struct cn_ctl_entry *n; | 409 | struct cn_ctl_entry *n; |
409 | 410 | ||
410 | down(¬ify_lock); | 411 | mutex_lock(¬ify_lock); |
411 | list_for_each_entry_safe(ent, n, ¬ify_list, notify_entry) { | 412 | list_for_each_entry_safe(ent, n, ¬ify_list, notify_entry) { |
412 | if (cn_ctl_msg_equals(ent->msg, ctl)) { | 413 | if (cn_ctl_msg_equals(ent->msg, ctl)) { |
413 | list_del(&ent->notify_entry); | 414 | list_del(&ent->notify_entry); |
414 | kfree(ent); | 415 | kfree(ent); |
415 | } | 416 | } |
416 | } | 417 | } |
417 | up(¬ify_lock); | 418 | mutex_unlock(¬ify_lock); |
418 | 419 | ||
419 | return; | 420 | return; |
420 | } | 421 | } |
@@ -429,9 +430,9 @@ static void cn_callback(void *data) | |||
429 | 430 | ||
430 | memcpy(ent->msg, ctl, size - sizeof(*ent)); | 431 | memcpy(ent->msg, ctl, size - sizeof(*ent)); |
431 | 432 | ||
432 | down(¬ify_lock); | 433 | mutex_lock(¬ify_lock); |
433 | list_add(&ent->notify_entry, ¬ify_list); | 434 | list_add(&ent->notify_entry, ¬ify_list); |
434 | up(¬ify_lock); | 435 | mutex_unlock(¬ify_lock); |
435 | } | 436 | } |
436 | 437 | ||
437 | static int __init cn_init(void) | 438 | static int __init cn_init(void) |
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c index 3a4e5c5b4e1f..d6543fc4a923 100644 --- a/drivers/firmware/dcdbas.c +++ b/drivers/firmware/dcdbas.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/spinlock.h> | 33 | #include <linux/spinlock.h> |
34 | #include <linux/string.h> | 34 | #include <linux/string.h> |
35 | #include <linux/types.h> | 35 | #include <linux/types.h> |
36 | #include <linux/mutex.h> | ||
36 | #include <asm/io.h> | 37 | #include <asm/io.h> |
37 | #include <asm/semaphore.h> | 38 | #include <asm/semaphore.h> |
38 | 39 | ||
@@ -48,7 +49,7 @@ static u8 *smi_data_buf; | |||
48 | static dma_addr_t smi_data_buf_handle; | 49 | static dma_addr_t smi_data_buf_handle; |
49 | static unsigned long smi_data_buf_size; | 50 | static unsigned long smi_data_buf_size; |
50 | static u32 smi_data_buf_phys_addr; | 51 | static u32 smi_data_buf_phys_addr; |
51 | static DECLARE_MUTEX(smi_data_lock); | 52 | static DEFINE_MUTEX(smi_data_lock); |
52 | 53 | ||
53 | static unsigned int host_control_action; | 54 | static unsigned int host_control_action; |
54 | static unsigned int host_control_smi_type; | 55 | static unsigned int host_control_smi_type; |
@@ -139,9 +140,9 @@ static ssize_t smi_data_buf_size_store(struct device *dev, | |||
139 | buf_size = simple_strtoul(buf, NULL, 10); | 140 | buf_size = simple_strtoul(buf, NULL, 10); |
140 | 141 | ||
141 | /* make sure SMI data buffer is at least buf_size */ | 142 | /* make sure SMI data buffer is at least buf_size */ |
142 | down(&smi_data_lock); | 143 | mutex_lock(&smi_data_lock); |
143 | ret = smi_data_buf_realloc(buf_size); | 144 | ret = smi_data_buf_realloc(buf_size); |
144 | up(&smi_data_lock); | 145 | mutex_unlock(&smi_data_lock); |
145 | if (ret) | 146 | if (ret) |
146 | return ret; | 147 | return ret; |
147 | 148 | ||
@@ -154,7 +155,7 @@ static ssize_t smi_data_read(struct kobject *kobj, char *buf, loff_t pos, | |||
154 | size_t max_read; | 155 | size_t max_read; |
155 | ssize_t ret; | 156 | ssize_t ret; |
156 | 157 | ||
157 | down(&smi_data_lock); | 158 | mutex_lock(&smi_data_lock); |
158 | 159 | ||
159 | if (pos >= smi_data_buf_size) { | 160 | if (pos >= smi_data_buf_size) { |
160 | ret = 0; | 161 | ret = 0; |
@@ -165,7 +166,7 @@ static ssize_t smi_data_read(struct kobject *kobj, char *buf, loff_t pos, | |||
165 | ret = min(max_read, count); | 166 | ret = min(max_read, count); |
166 | memcpy(buf, smi_data_buf + pos, ret); | 167 | memcpy(buf, smi_data_buf + pos, ret); |
167 | out: | 168 | out: |
168 | up(&smi_data_lock); | 169 | mutex_unlock(&smi_data_lock); |
169 | return ret; | 170 | return ret; |
170 | } | 171 | } |
171 | 172 | ||
@@ -174,7 +175,7 @@ static ssize_t smi_data_write(struct kobject *kobj, char *buf, loff_t pos, | |||
174 | { | 175 | { |
175 | ssize_t ret; | 176 | ssize_t ret; |
176 | 177 | ||
177 | down(&smi_data_lock); | 178 | mutex_lock(&smi_data_lock); |
178 | 179 | ||
179 | ret = smi_data_buf_realloc(pos + count); | 180 | ret = smi_data_buf_realloc(pos + count); |
180 | if (ret) | 181 | if (ret) |
@@ -183,7 +184,7 @@ static ssize_t smi_data_write(struct kobject *kobj, char *buf, loff_t pos, | |||
183 | memcpy(smi_data_buf + pos, buf, count); | 184 | memcpy(smi_data_buf + pos, buf, count); |
184 | ret = count; | 185 | ret = count; |
185 | out: | 186 | out: |
186 | up(&smi_data_lock); | 187 | mutex_unlock(&smi_data_lock); |
187 | return ret; | 188 | return ret; |
188 | } | 189 | } |
189 | 190 | ||
@@ -201,9 +202,9 @@ static ssize_t host_control_action_store(struct device *dev, | |||
201 | ssize_t ret; | 202 | ssize_t ret; |
202 | 203 | ||
203 | /* make sure buffer is available for host control command */ | 204 | /* make sure buffer is available for host control command */ |
204 | down(&smi_data_lock); | 205 | mutex_lock(&smi_data_lock); |
205 | ret = smi_data_buf_realloc(sizeof(struct apm_cmd)); | 206 | ret = smi_data_buf_realloc(sizeof(struct apm_cmd)); |
206 | up(&smi_data_lock); | 207 | mutex_unlock(&smi_data_lock); |
207 | if (ret) | 208 | if (ret) |
208 | return ret; | 209 | return ret; |
209 | 210 | ||
@@ -302,7 +303,7 @@ static ssize_t smi_request_store(struct device *dev, | |||
302 | unsigned long val = simple_strtoul(buf, NULL, 10); | 303 | unsigned long val = simple_strtoul(buf, NULL, 10); |
303 | ssize_t ret; | 304 | ssize_t ret; |
304 | 305 | ||
305 | down(&smi_data_lock); | 306 | mutex_lock(&smi_data_lock); |
306 | 307 | ||
307 | if (smi_data_buf_size < sizeof(struct smi_cmd)) { | 308 | if (smi_data_buf_size < sizeof(struct smi_cmd)) { |
308 | ret = -ENODEV; | 309 | ret = -ENODEV; |
@@ -334,7 +335,7 @@ static ssize_t smi_request_store(struct device *dev, | |||
334 | } | 335 | } |
335 | 336 | ||
336 | out: | 337 | out: |
337 | up(&smi_data_lock); | 338 | mutex_unlock(&smi_data_lock); |
338 | return ret; | 339 | return ret; |
339 | } | 340 | } |
340 | 341 | ||
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 7230d4e08196..99cdc612d2c6 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -406,13 +406,14 @@ config SENSORS_W83L785TS | |||
406 | will be called w83l785ts. | 406 | will be called w83l785ts. |
407 | 407 | ||
408 | config SENSORS_W83627HF | 408 | config SENSORS_W83627HF |
409 | tristate "Winbond W83627HF, W83627THF, W83637HF, W83697HF" | 409 | tristate "Winbond W83627HF, W83627THF, W83637HF, W83687THF, W83697HF" |
410 | depends on HWMON && I2C && EXPERIMENTAL | 410 | depends on HWMON && I2C |
411 | select I2C_ISA | 411 | select I2C_ISA |
412 | select HWMON_VID | 412 | select HWMON_VID |
413 | help | 413 | help |
414 | If you say yes here you get support for the Winbond W836X7 series | 414 | If you say yes here you get support for the Winbond W836X7 series |
415 | of sensor chips: the W83627HF, W83627THF, W83637HF, and the W83697HF | 415 | of sensor chips: the W83627HF, W83627THF, W83637HF, W83687THF and |
416 | W83697HF. | ||
416 | 417 | ||
417 | This driver can also be built as a module. If so, the module | 418 | This driver can also be built as a module. If so, the module |
418 | will be called w83627hf. | 419 | will be called w83627hf. |
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index 665612729cb9..2b6e74dd4a82 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
27 | #include <linux/hwmon.h> | 27 | #include <linux/hwmon.h> |
28 | #include <linux/err.h> | 28 | #include <linux/err.h> |
29 | #include <linux/mutex.h> | ||
29 | 30 | ||
30 | 31 | ||
31 | /* Addresses to scan */ | 32 | /* Addresses to scan */ |
@@ -92,7 +93,7 @@ struct adm1021_data { | |||
92 | struct class_device *class_dev; | 93 | struct class_device *class_dev; |
93 | enum chips type; | 94 | enum chips type; |
94 | 95 | ||
95 | struct semaphore update_lock; | 96 | struct mutex update_lock; |
96 | char valid; /* !=0 if following fields are valid */ | 97 | char valid; /* !=0 if following fields are valid */ |
97 | unsigned long last_updated; /* In jiffies */ | 98 | unsigned long last_updated; /* In jiffies */ |
98 | 99 | ||
@@ -162,10 +163,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co | |||
162 | struct adm1021_data *data = i2c_get_clientdata(client); \ | 163 | struct adm1021_data *data = i2c_get_clientdata(client); \ |
163 | int temp = simple_strtoul(buf, NULL, 10); \ | 164 | int temp = simple_strtoul(buf, NULL, 10); \ |
164 | \ | 165 | \ |
165 | down(&data->update_lock); \ | 166 | mutex_lock(&data->update_lock); \ |
166 | data->value = TEMP_TO_REG(temp); \ | 167 | data->value = TEMP_TO_REG(temp); \ |
167 | adm1021_write_value(client, reg, data->value); \ | 168 | adm1021_write_value(client, reg, data->value); \ |
168 | up(&data->update_lock); \ | 169 | mutex_unlock(&data->update_lock); \ |
169 | return count; \ | 170 | return count; \ |
170 | } | 171 | } |
171 | set(temp_max, ADM1021_REG_TOS_W); | 172 | set(temp_max, ADM1021_REG_TOS_W); |
@@ -275,7 +276,7 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) | |||
275 | strlcpy(new_client->name, type_name, I2C_NAME_SIZE); | 276 | strlcpy(new_client->name, type_name, I2C_NAME_SIZE); |
276 | data->type = kind; | 277 | data->type = kind; |
277 | data->valid = 0; | 278 | data->valid = 0; |
278 | init_MUTEX(&data->update_lock); | 279 | mutex_init(&data->update_lock); |
279 | 280 | ||
280 | /* Tell the I2C layer a new client has arrived */ | 281 | /* Tell the I2C layer a new client has arrived */ |
281 | if ((err = i2c_attach_client(new_client))) | 282 | if ((err = i2c_attach_client(new_client))) |
@@ -351,7 +352,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev) | |||
351 | struct i2c_client *client = to_i2c_client(dev); | 352 | struct i2c_client *client = to_i2c_client(dev); |
352 | struct adm1021_data *data = i2c_get_clientdata(client); | 353 | struct adm1021_data *data = i2c_get_clientdata(client); |
353 | 354 | ||
354 | down(&data->update_lock); | 355 | mutex_lock(&data->update_lock); |
355 | 356 | ||
356 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 357 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
357 | || !data->valid) { | 358 | || !data->valid) { |
@@ -375,7 +376,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev) | |||
375 | data->valid = 1; | 376 | data->valid = 1; |
376 | } | 377 | } |
377 | 378 | ||
378 | up(&data->update_lock); | 379 | mutex_unlock(&data->update_lock); |
379 | 380 | ||
380 | return data; | 381 | return data; |
381 | } | 382 | } |
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index 9331c56d2ba6..a4c859c9fbf8 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c | |||
@@ -53,6 +53,7 @@ | |||
53 | #include <linux/hwmon.h> | 53 | #include <linux/hwmon.h> |
54 | #include <linux/hwmon-vid.h> | 54 | #include <linux/hwmon-vid.h> |
55 | #include <linux/err.h> | 55 | #include <linux/err.h> |
56 | #include <linux/mutex.h> | ||
56 | 57 | ||
57 | /* | 58 | /* |
58 | * Addresses to scan | 59 | * Addresses to scan |
@@ -133,7 +134,7 @@ static struct i2c_driver adm1025_driver = { | |||
133 | struct adm1025_data { | 134 | struct adm1025_data { |
134 | struct i2c_client client; | 135 | struct i2c_client client; |
135 | struct class_device *class_dev; | 136 | struct class_device *class_dev; |
136 | struct semaphore update_lock; | 137 | struct mutex update_lock; |
137 | char valid; /* zero until following fields are valid */ | 138 | char valid; /* zero until following fields are valid */ |
138 | unsigned long last_updated; /* in jiffies */ | 139 | unsigned long last_updated; /* in jiffies */ |
139 | 140 | ||
@@ -207,11 +208,11 @@ static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute | |||
207 | struct adm1025_data *data = i2c_get_clientdata(client); \ | 208 | struct adm1025_data *data = i2c_get_clientdata(client); \ |
208 | long val = simple_strtol(buf, NULL, 10); \ | 209 | long val = simple_strtol(buf, NULL, 10); \ |
209 | \ | 210 | \ |
210 | down(&data->update_lock); \ | 211 | mutex_lock(&data->update_lock); \ |
211 | data->in_min[offset] = IN_TO_REG(val, in_scale[offset]); \ | 212 | data->in_min[offset] = IN_TO_REG(val, in_scale[offset]); \ |
212 | i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(offset), \ | 213 | i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(offset), \ |
213 | data->in_min[offset]); \ | 214 | data->in_min[offset]); \ |
214 | up(&data->update_lock); \ | 215 | mutex_unlock(&data->update_lock); \ |
215 | return count; \ | 216 | return count; \ |
216 | } \ | 217 | } \ |
217 | static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ | 218 | static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ |
@@ -221,11 +222,11 @@ static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute | |||
221 | struct adm1025_data *data = i2c_get_clientdata(client); \ | 222 | struct adm1025_data *data = i2c_get_clientdata(client); \ |
222 | long val = simple_strtol(buf, NULL, 10); \ | 223 | long val = simple_strtol(buf, NULL, 10); \ |
223 | \ | 224 | \ |
224 | down(&data->update_lock); \ | 225 | mutex_lock(&data->update_lock); \ |
225 | data->in_max[offset] = IN_TO_REG(val, in_scale[offset]); \ | 226 | data->in_max[offset] = IN_TO_REG(val, in_scale[offset]); \ |
226 | i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(offset), \ | 227 | i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(offset), \ |
227 | data->in_max[offset]); \ | 228 | data->in_max[offset]); \ |
228 | up(&data->update_lock); \ | 229 | mutex_unlock(&data->update_lock); \ |
229 | return count; \ | 230 | return count; \ |
230 | } \ | 231 | } \ |
231 | static DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ | 232 | static DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ |
@@ -247,11 +248,11 @@ static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribut | |||
247 | struct adm1025_data *data = i2c_get_clientdata(client); \ | 248 | struct adm1025_data *data = i2c_get_clientdata(client); \ |
248 | long val = simple_strtol(buf, NULL, 10); \ | 249 | long val = simple_strtol(buf, NULL, 10); \ |
249 | \ | 250 | \ |
250 | down(&data->update_lock); \ | 251 | mutex_lock(&data->update_lock); \ |
251 | data->temp_min[offset-1] = TEMP_TO_REG(val); \ | 252 | data->temp_min[offset-1] = TEMP_TO_REG(val); \ |
252 | i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW(offset-1), \ | 253 | i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW(offset-1), \ |
253 | data->temp_min[offset-1]); \ | 254 | data->temp_min[offset-1]); \ |
254 | up(&data->update_lock); \ | 255 | mutex_unlock(&data->update_lock); \ |
255 | return count; \ | 256 | return count; \ |
256 | } \ | 257 | } \ |
257 | static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ | 258 | static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ |
@@ -261,11 +262,11 @@ static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribut | |||
261 | struct adm1025_data *data = i2c_get_clientdata(client); \ | 262 | struct adm1025_data *data = i2c_get_clientdata(client); \ |
262 | long val = simple_strtol(buf, NULL, 10); \ | 263 | long val = simple_strtol(buf, NULL, 10); \ |
263 | \ | 264 | \ |
264 | down(&data->update_lock); \ | 265 | mutex_lock(&data->update_lock); \ |
265 | data->temp_max[offset-1] = TEMP_TO_REG(val); \ | 266 | data->temp_max[offset-1] = TEMP_TO_REG(val); \ |
266 | i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(offset-1), \ | 267 | i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(offset-1), \ |
267 | data->temp_max[offset-1]); \ | 268 | data->temp_max[offset-1]); \ |
268 | up(&data->update_lock); \ | 269 | mutex_unlock(&data->update_lock); \ |
269 | return count; \ | 270 | return count; \ |
270 | } \ | 271 | } \ |
271 | static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ | 272 | static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ |
@@ -404,7 +405,7 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind) | |||
404 | /* We can fill in the remaining client fields */ | 405 | /* We can fill in the remaining client fields */ |
405 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 406 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
406 | data->valid = 0; | 407 | data->valid = 0; |
407 | init_MUTEX(&data->update_lock); | 408 | mutex_init(&data->update_lock); |
408 | 409 | ||
409 | /* Tell the I2C layer a new client has arrived */ | 410 | /* Tell the I2C layer a new client has arrived */ |
410 | if ((err = i2c_attach_client(new_client))) | 411 | if ((err = i2c_attach_client(new_client))) |
@@ -523,7 +524,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev) | |||
523 | struct i2c_client *client = to_i2c_client(dev); | 524 | struct i2c_client *client = to_i2c_client(dev); |
524 | struct adm1025_data *data = i2c_get_clientdata(client); | 525 | struct adm1025_data *data = i2c_get_clientdata(client); |
525 | 526 | ||
526 | down(&data->update_lock); | 527 | mutex_lock(&data->update_lock); |
527 | 528 | ||
528 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 529 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
529 | int i; | 530 | int i; |
@@ -558,7 +559,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev) | |||
558 | data->valid = 1; | 559 | data->valid = 1; |
559 | } | 560 | } |
560 | 561 | ||
561 | up(&data->update_lock); | 562 | mutex_unlock(&data->update_lock); |
562 | 563 | ||
563 | return data; | 564 | return data; |
564 | } | 565 | } |
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index fefe6e74fd02..6d4f8b8d358e 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/hwmon-sysfs.h> | 32 | #include <linux/hwmon-sysfs.h> |
33 | #include <linux/hwmon-vid.h> | 33 | #include <linux/hwmon-vid.h> |
34 | #include <linux/err.h> | 34 | #include <linux/err.h> |
35 | #include <linux/mutex.h> | ||
35 | 36 | ||
36 | /* Addresses to scan */ | 37 | /* Addresses to scan */ |
37 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 38 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
@@ -260,10 +261,10 @@ struct pwm_data { | |||
260 | struct adm1026_data { | 261 | struct adm1026_data { |
261 | struct i2c_client client; | 262 | struct i2c_client client; |
262 | struct class_device *class_dev; | 263 | struct class_device *class_dev; |
263 | struct semaphore lock; | 264 | struct mutex lock; |
264 | enum chips type; | 265 | enum chips type; |
265 | 266 | ||
266 | struct semaphore update_lock; | 267 | struct mutex update_lock; |
267 | int valid; /* !=0 if following fields are valid */ | 268 | int valid; /* !=0 if following fields are valid */ |
268 | unsigned long last_reading; /* In jiffies */ | 269 | unsigned long last_reading; /* In jiffies */ |
269 | unsigned long last_config; /* In jiffies */ | 270 | unsigned long last_config; /* In jiffies */ |
@@ -298,9 +299,8 @@ static int adm1026_attach_adapter(struct i2c_adapter *adapter); | |||
298 | static int adm1026_detect(struct i2c_adapter *adapter, int address, | 299 | static int adm1026_detect(struct i2c_adapter *adapter, int address, |
299 | int kind); | 300 | int kind); |
300 | static int adm1026_detach_client(struct i2c_client *client); | 301 | static int adm1026_detach_client(struct i2c_client *client); |
301 | static int adm1026_read_value(struct i2c_client *client, u8 register); | 302 | static int adm1026_read_value(struct i2c_client *client, u8 reg); |
302 | static int adm1026_write_value(struct i2c_client *client, u8 register, | 303 | static int adm1026_write_value(struct i2c_client *client, u8 reg, int value); |
303 | int value); | ||
304 | static void adm1026_print_gpio(struct i2c_client *client); | 304 | static void adm1026_print_gpio(struct i2c_client *client); |
305 | static void adm1026_fixup_gpio(struct i2c_client *client); | 305 | static void adm1026_fixup_gpio(struct i2c_client *client); |
306 | static struct adm1026_data *adm1026_update_device(struct device *dev); | 306 | static struct adm1026_data *adm1026_update_device(struct device *dev); |
@@ -575,7 +575,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
575 | int i; | 575 | int i; |
576 | long value, alarms, gpio; | 576 | long value, alarms, gpio; |
577 | 577 | ||
578 | down(&data->update_lock); | 578 | mutex_lock(&data->update_lock); |
579 | if (!data->valid | 579 | if (!data->valid |
580 | || time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) { | 580 | || time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) { |
581 | /* Things that change quickly */ | 581 | /* Things that change quickly */ |
@@ -710,7 +710,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
710 | dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n"); | 710 | dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n"); |
711 | data->vid = (data->gpio >> 11) & 0x1f; | 711 | data->vid = (data->gpio >> 11) & 0x1f; |
712 | data->valid = 1; | 712 | data->valid = 1; |
713 | up(&data->update_lock); | 713 | mutex_unlock(&data->update_lock); |
714 | return data; | 714 | return data; |
715 | } | 715 | } |
716 | 716 | ||
@@ -739,10 +739,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | |||
739 | struct adm1026_data *data = i2c_get_clientdata(client); | 739 | struct adm1026_data *data = i2c_get_clientdata(client); |
740 | int val = simple_strtol(buf, NULL, 10); | 740 | int val = simple_strtol(buf, NULL, 10); |
741 | 741 | ||
742 | down(&data->update_lock); | 742 | mutex_lock(&data->update_lock); |
743 | data->in_min[nr] = INS_TO_REG(nr, val); | 743 | data->in_min[nr] = INS_TO_REG(nr, val); |
744 | adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]); | 744 | adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]); |
745 | up(&data->update_lock); | 745 | mutex_unlock(&data->update_lock); |
746 | return count; | 746 | return count; |
747 | } | 747 | } |
748 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, | 748 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, |
@@ -762,10 +762,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | |||
762 | struct adm1026_data *data = i2c_get_clientdata(client); | 762 | struct adm1026_data *data = i2c_get_clientdata(client); |
763 | int val = simple_strtol(buf, NULL, 10); | 763 | int val = simple_strtol(buf, NULL, 10); |
764 | 764 | ||
765 | down(&data->update_lock); | 765 | mutex_lock(&data->update_lock); |
766 | data->in_max[nr] = INS_TO_REG(nr, val); | 766 | data->in_max[nr] = INS_TO_REG(nr, val); |
767 | adm1026_write_value(client, ADM1026_REG_IN_MAX[nr], data->in_max[nr]); | 767 | adm1026_write_value(client, ADM1026_REG_IN_MAX[nr], data->in_max[nr]); |
768 | up(&data->update_lock); | 768 | mutex_unlock(&data->update_lock); |
769 | return count; | 769 | return count; |
770 | } | 770 | } |
771 | 771 | ||
@@ -813,10 +813,10 @@ static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr, c | |||
813 | struct adm1026_data *data = i2c_get_clientdata(client); | 813 | struct adm1026_data *data = i2c_get_clientdata(client); |
814 | int val = simple_strtol(buf, NULL, 10); | 814 | int val = simple_strtol(buf, NULL, 10); |
815 | 815 | ||
816 | down(&data->update_lock); | 816 | mutex_lock(&data->update_lock); |
817 | data->in_min[16] = INS_TO_REG(16, val + NEG12_OFFSET); | 817 | data->in_min[16] = INS_TO_REG(16, val + NEG12_OFFSET); |
818 | adm1026_write_value(client, ADM1026_REG_IN_MIN[16], data->in_min[16]); | 818 | adm1026_write_value(client, ADM1026_REG_IN_MIN[16], data->in_min[16]); |
819 | up(&data->update_lock); | 819 | mutex_unlock(&data->update_lock); |
820 | return count; | 820 | return count; |
821 | } | 821 | } |
822 | static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf) | 822 | static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf) |
@@ -831,10 +831,10 @@ static ssize_t set_in16_max(struct device *dev, struct device_attribute *attr, c | |||
831 | struct adm1026_data *data = i2c_get_clientdata(client); | 831 | struct adm1026_data *data = i2c_get_clientdata(client); |
832 | int val = simple_strtol(buf, NULL, 10); | 832 | int val = simple_strtol(buf, NULL, 10); |
833 | 833 | ||
834 | down(&data->update_lock); | 834 | mutex_lock(&data->update_lock); |
835 | data->in_max[16] = INS_TO_REG(16, val+NEG12_OFFSET); | 835 | data->in_max[16] = INS_TO_REG(16, val+NEG12_OFFSET); |
836 | adm1026_write_value(client, ADM1026_REG_IN_MAX[16], data->in_max[16]); | 836 | adm1026_write_value(client, ADM1026_REG_IN_MAX[16], data->in_max[16]); |
837 | up(&data->update_lock); | 837 | mutex_unlock(&data->update_lock); |
838 | return count; | 838 | return count; |
839 | } | 839 | } |
840 | 840 | ||
@@ -874,11 +874,11 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
874 | struct adm1026_data *data = i2c_get_clientdata(client); | 874 | struct adm1026_data *data = i2c_get_clientdata(client); |
875 | int val = simple_strtol(buf, NULL, 10); | 875 | int val = simple_strtol(buf, NULL, 10); |
876 | 876 | ||
877 | down(&data->update_lock); | 877 | mutex_lock(&data->update_lock); |
878 | data->fan_min[nr] = FAN_TO_REG(val, data->fan_div[nr]); | 878 | data->fan_min[nr] = FAN_TO_REG(val, data->fan_div[nr]); |
879 | adm1026_write_value(client, ADM1026_REG_FAN_MIN(nr), | 879 | adm1026_write_value(client, ADM1026_REG_FAN_MIN(nr), |
880 | data->fan_min[nr]); | 880 | data->fan_min[nr]); |
881 | up(&data->update_lock); | 881 | mutex_unlock(&data->update_lock); |
882 | return count; | 882 | return count; |
883 | } | 883 | } |
884 | 884 | ||
@@ -939,7 +939,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
939 | if (new_div == 0) { | 939 | if (new_div == 0) { |
940 | return -EINVAL; | 940 | return -EINVAL; |
941 | } | 941 | } |
942 | down(&data->update_lock); | 942 | mutex_lock(&data->update_lock); |
943 | orig_div = data->fan_div[nr]; | 943 | orig_div = data->fan_div[nr]; |
944 | data->fan_div[nr] = DIV_FROM_REG(new_div); | 944 | data->fan_div[nr] = DIV_FROM_REG(new_div); |
945 | 945 | ||
@@ -958,7 +958,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
958 | if (data->fan_div[nr] != orig_div) { | 958 | if (data->fan_div[nr] != orig_div) { |
959 | fixup_fan_min(dev,nr,orig_div); | 959 | fixup_fan_min(dev,nr,orig_div); |
960 | } | 960 | } |
961 | up(&data->update_lock); | 961 | mutex_unlock(&data->update_lock); |
962 | return count; | 962 | return count; |
963 | } | 963 | } |
964 | 964 | ||
@@ -1001,11 +1001,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | |||
1001 | struct adm1026_data *data = i2c_get_clientdata(client); | 1001 | struct adm1026_data *data = i2c_get_clientdata(client); |
1002 | int val = simple_strtol(buf, NULL, 10); | 1002 | int val = simple_strtol(buf, NULL, 10); |
1003 | 1003 | ||
1004 | down(&data->update_lock); | 1004 | mutex_lock(&data->update_lock); |
1005 | data->temp_min[nr] = TEMP_TO_REG(val); | 1005 | data->temp_min[nr] = TEMP_TO_REG(val); |
1006 | adm1026_write_value(client, ADM1026_REG_TEMP_MIN[nr], | 1006 | adm1026_write_value(client, ADM1026_REG_TEMP_MIN[nr], |
1007 | data->temp_min[nr]); | 1007 | data->temp_min[nr]); |
1008 | up(&data->update_lock); | 1008 | mutex_unlock(&data->update_lock); |
1009 | return count; | 1009 | return count; |
1010 | } | 1010 | } |
1011 | static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, | 1011 | static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, |
@@ -1025,11 +1025,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
1025 | struct adm1026_data *data = i2c_get_clientdata(client); | 1025 | struct adm1026_data *data = i2c_get_clientdata(client); |
1026 | int val = simple_strtol(buf, NULL, 10); | 1026 | int val = simple_strtol(buf, NULL, 10); |
1027 | 1027 | ||
1028 | down(&data->update_lock); | 1028 | mutex_lock(&data->update_lock); |
1029 | data->temp_max[nr] = TEMP_TO_REG(val); | 1029 | data->temp_max[nr] = TEMP_TO_REG(val); |
1030 | adm1026_write_value(client, ADM1026_REG_TEMP_MAX[nr], | 1030 | adm1026_write_value(client, ADM1026_REG_TEMP_MAX[nr], |
1031 | data->temp_max[nr]); | 1031 | data->temp_max[nr]); |
1032 | up(&data->update_lock); | 1032 | mutex_unlock(&data->update_lock); |
1033 | return count; | 1033 | return count; |
1034 | } | 1034 | } |
1035 | 1035 | ||
@@ -1064,11 +1064,11 @@ static ssize_t set_temp_offset(struct device *dev, | |||
1064 | struct adm1026_data *data = i2c_get_clientdata(client); | 1064 | struct adm1026_data *data = i2c_get_clientdata(client); |
1065 | int val = simple_strtol(buf, NULL, 10); | 1065 | int val = simple_strtol(buf, NULL, 10); |
1066 | 1066 | ||
1067 | down(&data->update_lock); | 1067 | mutex_lock(&data->update_lock); |
1068 | data->temp_offset[nr] = TEMP_TO_REG(val); | 1068 | data->temp_offset[nr] = TEMP_TO_REG(val); |
1069 | adm1026_write_value(client, ADM1026_REG_TEMP_OFFSET[nr], | 1069 | adm1026_write_value(client, ADM1026_REG_TEMP_OFFSET[nr], |
1070 | data->temp_offset[nr]); | 1070 | data->temp_offset[nr]); |
1071 | up(&data->update_lock); | 1071 | mutex_unlock(&data->update_lock); |
1072 | return count; | 1072 | return count; |
1073 | } | 1073 | } |
1074 | 1074 | ||
@@ -1115,11 +1115,11 @@ static ssize_t set_temp_auto_point1_temp(struct device *dev, | |||
1115 | struct adm1026_data *data = i2c_get_clientdata(client); | 1115 | struct adm1026_data *data = i2c_get_clientdata(client); |
1116 | int val = simple_strtol(buf, NULL, 10); | 1116 | int val = simple_strtol(buf, NULL, 10); |
1117 | 1117 | ||
1118 | down(&data->update_lock); | 1118 | mutex_lock(&data->update_lock); |
1119 | data->temp_tmin[nr] = TEMP_TO_REG(val); | 1119 | data->temp_tmin[nr] = TEMP_TO_REG(val); |
1120 | adm1026_write_value(client, ADM1026_REG_TEMP_TMIN[nr], | 1120 | adm1026_write_value(client, ADM1026_REG_TEMP_TMIN[nr], |
1121 | data->temp_tmin[nr]); | 1121 | data->temp_tmin[nr]); |
1122 | up(&data->update_lock); | 1122 | mutex_unlock(&data->update_lock); |
1123 | return count; | 1123 | return count; |
1124 | } | 1124 | } |
1125 | 1125 | ||
@@ -1150,11 +1150,11 @@ static ssize_t set_temp_crit_enable(struct device *dev, | |||
1150 | int val = simple_strtol(buf, NULL, 10); | 1150 | int val = simple_strtol(buf, NULL, 10); |
1151 | 1151 | ||
1152 | if ((val == 1) || (val==0)) { | 1152 | if ((val == 1) || (val==0)) { |
1153 | down(&data->update_lock); | 1153 | mutex_lock(&data->update_lock); |
1154 | data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4); | 1154 | data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4); |
1155 | adm1026_write_value(client, ADM1026_REG_CONFIG1, | 1155 | adm1026_write_value(client, ADM1026_REG_CONFIG1, |
1156 | data->config1); | 1156 | data->config1); |
1157 | up(&data->update_lock); | 1157 | mutex_unlock(&data->update_lock); |
1158 | } | 1158 | } |
1159 | return count; | 1159 | return count; |
1160 | } | 1160 | } |
@@ -1184,11 +1184,11 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, | |||
1184 | struct adm1026_data *data = i2c_get_clientdata(client); | 1184 | struct adm1026_data *data = i2c_get_clientdata(client); |
1185 | int val = simple_strtol(buf, NULL, 10); | 1185 | int val = simple_strtol(buf, NULL, 10); |
1186 | 1186 | ||
1187 | down(&data->update_lock); | 1187 | mutex_lock(&data->update_lock); |
1188 | data->temp_crit[nr] = TEMP_TO_REG(val); | 1188 | data->temp_crit[nr] = TEMP_TO_REG(val); |
1189 | adm1026_write_value(client, ADM1026_REG_TEMP_THERM[nr], | 1189 | adm1026_write_value(client, ADM1026_REG_TEMP_THERM[nr], |
1190 | data->temp_crit[nr]); | 1190 | data->temp_crit[nr]); |
1191 | up(&data->update_lock); | 1191 | mutex_unlock(&data->update_lock); |
1192 | return count; | 1192 | return count; |
1193 | } | 1193 | } |
1194 | 1194 | ||
@@ -1212,10 +1212,10 @@ static ssize_t set_analog_out_reg(struct device *dev, struct device_attribute *a | |||
1212 | struct adm1026_data *data = i2c_get_clientdata(client); | 1212 | struct adm1026_data *data = i2c_get_clientdata(client); |
1213 | int val = simple_strtol(buf, NULL, 10); | 1213 | int val = simple_strtol(buf, NULL, 10); |
1214 | 1214 | ||
1215 | down(&data->update_lock); | 1215 | mutex_lock(&data->update_lock); |
1216 | data->analog_out = DAC_TO_REG(val); | 1216 | data->analog_out = DAC_TO_REG(val); |
1217 | adm1026_write_value(client, ADM1026_REG_DAC, data->analog_out); | 1217 | adm1026_write_value(client, ADM1026_REG_DAC, data->analog_out); |
1218 | up(&data->update_lock); | 1218 | mutex_unlock(&data->update_lock); |
1219 | return count; | 1219 | return count; |
1220 | } | 1220 | } |
1221 | 1221 | ||
@@ -1267,7 +1267,7 @@ static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr, | |||
1267 | int val = simple_strtol(buf, NULL, 10); | 1267 | int val = simple_strtol(buf, NULL, 10); |
1268 | unsigned long mask; | 1268 | unsigned long mask; |
1269 | 1269 | ||
1270 | down(&data->update_lock); | 1270 | mutex_lock(&data->update_lock); |
1271 | data->alarm_mask = val & 0x7fffffff; | 1271 | data->alarm_mask = val & 0x7fffffff; |
1272 | mask = data->alarm_mask | 1272 | mask = data->alarm_mask |
1273 | | (data->gpio_mask & 0x10000 ? 0x80000000 : 0); | 1273 | | (data->gpio_mask & 0x10000 ? 0x80000000 : 0); |
@@ -1282,7 +1282,7 @@ static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr, | |||
1282 | mask >>= 8; | 1282 | mask >>= 8; |
1283 | adm1026_write_value(client, ADM1026_REG_MASK4, | 1283 | adm1026_write_value(client, ADM1026_REG_MASK4, |
1284 | mask & 0xff); | 1284 | mask & 0xff); |
1285 | up(&data->update_lock); | 1285 | mutex_unlock(&data->update_lock); |
1286 | return count; | 1286 | return count; |
1287 | } | 1287 | } |
1288 | 1288 | ||
@@ -1303,7 +1303,7 @@ static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const | |||
1303 | int val = simple_strtol(buf, NULL, 10); | 1303 | int val = simple_strtol(buf, NULL, 10); |
1304 | long gpio; | 1304 | long gpio; |
1305 | 1305 | ||
1306 | down(&data->update_lock); | 1306 | mutex_lock(&data->update_lock); |
1307 | data->gpio = val & 0x1ffff; | 1307 | data->gpio = val & 0x1ffff; |
1308 | gpio = data->gpio; | 1308 | gpio = data->gpio; |
1309 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7,gpio & 0xff); | 1309 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7,gpio & 0xff); |
@@ -1311,7 +1311,7 @@ static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const | |||
1311 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_8_15,gpio & 0xff); | 1311 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_8_15,gpio & 0xff); |
1312 | gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f); | 1312 | gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f); |
1313 | adm1026_write_value(client, ADM1026_REG_STATUS4,gpio & 0xff); | 1313 | adm1026_write_value(client, ADM1026_REG_STATUS4,gpio & 0xff); |
1314 | up(&data->update_lock); | 1314 | mutex_unlock(&data->update_lock); |
1315 | return count; | 1315 | return count; |
1316 | } | 1316 | } |
1317 | 1317 | ||
@@ -1331,7 +1331,7 @@ static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr, | |||
1331 | int val = simple_strtol(buf, NULL, 10); | 1331 | int val = simple_strtol(buf, NULL, 10); |
1332 | long mask; | 1332 | long mask; |
1333 | 1333 | ||
1334 | down(&data->update_lock); | 1334 | mutex_lock(&data->update_lock); |
1335 | data->gpio_mask = val & 0x1ffff; | 1335 | data->gpio_mask = val & 0x1ffff; |
1336 | mask = data->gpio_mask; | 1336 | mask = data->gpio_mask; |
1337 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7,mask & 0xff); | 1337 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7,mask & 0xff); |
@@ -1339,7 +1339,7 @@ static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr, | |||
1339 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_8_15,mask & 0xff); | 1339 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_8_15,mask & 0xff); |
1340 | mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f); | 1340 | mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f); |
1341 | adm1026_write_value(client, ADM1026_REG_MASK1,mask & 0xff); | 1341 | adm1026_write_value(client, ADM1026_REG_MASK1,mask & 0xff); |
1342 | up(&data->update_lock); | 1342 | mutex_unlock(&data->update_lock); |
1343 | return count; | 1343 | return count; |
1344 | } | 1344 | } |
1345 | 1345 | ||
@@ -1359,10 +1359,10 @@ static ssize_t set_pwm_reg(struct device *dev, struct device_attribute *attr, co | |||
1359 | if (data->pwm1.enable == 1) { | 1359 | if (data->pwm1.enable == 1) { |
1360 | int val = simple_strtol(buf, NULL, 10); | 1360 | int val = simple_strtol(buf, NULL, 10); |
1361 | 1361 | ||
1362 | down(&data->update_lock); | 1362 | mutex_lock(&data->update_lock); |
1363 | data->pwm1.pwm = PWM_TO_REG(val); | 1363 | data->pwm1.pwm = PWM_TO_REG(val); |
1364 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); | 1364 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); |
1365 | up(&data->update_lock); | 1365 | mutex_unlock(&data->update_lock); |
1366 | } | 1366 | } |
1367 | return count; | 1367 | return count; |
1368 | } | 1368 | } |
@@ -1378,14 +1378,14 @@ static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *att | |||
1378 | struct adm1026_data *data = i2c_get_clientdata(client); | 1378 | struct adm1026_data *data = i2c_get_clientdata(client); |
1379 | int val = simple_strtol(buf, NULL, 10); | 1379 | int val = simple_strtol(buf, NULL, 10); |
1380 | 1380 | ||
1381 | down(&data->update_lock); | 1381 | mutex_lock(&data->update_lock); |
1382 | data->pwm1.auto_pwm_min = SENSORS_LIMIT(val,0,255); | 1382 | data->pwm1.auto_pwm_min = SENSORS_LIMIT(val,0,255); |
1383 | if (data->pwm1.enable == 2) { /* apply immediately */ | 1383 | if (data->pwm1.enable == 2) { /* apply immediately */ |
1384 | data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | | 1384 | data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | |
1385 | PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); | 1385 | PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); |
1386 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); | 1386 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); |
1387 | } | 1387 | } |
1388 | up(&data->update_lock); | 1388 | mutex_unlock(&data->update_lock); |
1389 | return count; | 1389 | return count; |
1390 | } | 1390 | } |
1391 | static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf) | 1391 | static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf) |
@@ -1406,7 +1406,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
1406 | int old_enable; | 1406 | int old_enable; |
1407 | 1407 | ||
1408 | if ((val >= 0) && (val < 3)) { | 1408 | if ((val >= 0) && (val < 3)) { |
1409 | down(&data->update_lock); | 1409 | mutex_lock(&data->update_lock); |
1410 | old_enable = data->pwm1.enable; | 1410 | old_enable = data->pwm1.enable; |
1411 | data->pwm1.enable = val; | 1411 | data->pwm1.enable = val; |
1412 | data->config1 = (data->config1 & ~CFG1_PWM_AFC) | 1412 | data->config1 = (data->config1 & ~CFG1_PWM_AFC) |
@@ -1424,7 +1424,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
1424 | adm1026_write_value(client, ADM1026_REG_PWM, | 1424 | adm1026_write_value(client, ADM1026_REG_PWM, |
1425 | data->pwm1.pwm); | 1425 | data->pwm1.pwm); |
1426 | } | 1426 | } |
1427 | up(&data->update_lock); | 1427 | mutex_unlock(&data->update_lock); |
1428 | } | 1428 | } |
1429 | return count; | 1429 | return count; |
1430 | } | 1430 | } |
@@ -1541,7 +1541,7 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, | |||
1541 | /* Fill in the remaining client fields */ | 1541 | /* Fill in the remaining client fields */ |
1542 | data->type = kind; | 1542 | data->type = kind; |
1543 | data->valid = 0; | 1543 | data->valid = 0; |
1544 | init_MUTEX(&data->update_lock); | 1544 | mutex_init(&data->update_lock); |
1545 | 1545 | ||
1546 | /* Tell the I2C layer a new client has arrived */ | 1546 | /* Tell the I2C layer a new client has arrived */ |
1547 | if ((err = i2c_attach_client(new_client))) | 1547 | if ((err = i2c_attach_client(new_client))) |
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index d06397966081..3bf2da621aed 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/hwmon.h> | 29 | #include <linux/hwmon.h> |
30 | #include <linux/err.h> | 30 | #include <linux/err.h> |
31 | #include <linux/mutex.h> | ||
31 | 32 | ||
32 | /* Following macros takes channel parameter starting from 0 to 2 */ | 33 | /* Following macros takes channel parameter starting from 0 to 2 */ |
33 | #define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr)) | 34 | #define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr)) |
@@ -70,7 +71,7 @@ typedef u8 auto_chan_table_t[8][2]; | |||
70 | struct adm1031_data { | 71 | struct adm1031_data { |
71 | struct i2c_client client; | 72 | struct i2c_client client; |
72 | struct class_device *class_dev; | 73 | struct class_device *class_dev; |
73 | struct semaphore update_lock; | 74 | struct mutex update_lock; |
74 | int chip_type; | 75 | int chip_type; |
75 | char valid; /* !=0 if following fields are valid */ | 76 | char valid; /* !=0 if following fields are valid */ |
76 | unsigned long last_updated; /* In jiffies */ | 77 | unsigned long last_updated; /* In jiffies */ |
@@ -262,10 +263,10 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr) | |||
262 | 263 | ||
263 | old_fan_mode = data->conf1; | 264 | old_fan_mode = data->conf1; |
264 | 265 | ||
265 | down(&data->update_lock); | 266 | mutex_lock(&data->update_lock); |
266 | 267 | ||
267 | if ((ret = get_fan_auto_nearest(data, nr, val, data->conf1, ®))) { | 268 | if ((ret = get_fan_auto_nearest(data, nr, val, data->conf1, ®))) { |
268 | up(&data->update_lock); | 269 | mutex_unlock(&data->update_lock); |
269 | return ret; | 270 | return ret; |
270 | } | 271 | } |
271 | if (((data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1)) & ADM1031_CONF1_AUTO_MODE) ^ | 272 | if (((data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1)) & ADM1031_CONF1_AUTO_MODE) ^ |
@@ -288,7 +289,7 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr) | |||
288 | } | 289 | } |
289 | data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1); | 290 | data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1); |
290 | adm1031_write_value(client, ADM1031_REG_CONF1, data->conf1); | 291 | adm1031_write_value(client, ADM1031_REG_CONF1, data->conf1); |
291 | up(&data->update_lock); | 292 | mutex_unlock(&data->update_lock); |
292 | return count; | 293 | return count; |
293 | } | 294 | } |
294 | 295 | ||
@@ -329,11 +330,11 @@ set_auto_temp_min(struct device *dev, const char *buf, size_t count, int nr) | |||
329 | struct adm1031_data *data = i2c_get_clientdata(client); | 330 | struct adm1031_data *data = i2c_get_clientdata(client); |
330 | int val = simple_strtol(buf, NULL, 10); | 331 | int val = simple_strtol(buf, NULL, 10); |
331 | 332 | ||
332 | down(&data->update_lock); | 333 | mutex_lock(&data->update_lock); |
333 | data->auto_temp[nr] = AUTO_TEMP_MIN_TO_REG(val, data->auto_temp[nr]); | 334 | data->auto_temp[nr] = AUTO_TEMP_MIN_TO_REG(val, data->auto_temp[nr]); |
334 | adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), | 335 | adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), |
335 | data->auto_temp[nr]); | 336 | data->auto_temp[nr]); |
336 | up(&data->update_lock); | 337 | mutex_unlock(&data->update_lock); |
337 | return count; | 338 | return count; |
338 | } | 339 | } |
339 | static ssize_t show_auto_temp_max(struct device *dev, char *buf, int nr) | 340 | static ssize_t show_auto_temp_max(struct device *dev, char *buf, int nr) |
@@ -349,11 +350,11 @@ set_auto_temp_max(struct device *dev, const char *buf, size_t count, int nr) | |||
349 | struct adm1031_data *data = i2c_get_clientdata(client); | 350 | struct adm1031_data *data = i2c_get_clientdata(client); |
350 | int val = simple_strtol(buf, NULL, 10); | 351 | int val = simple_strtol(buf, NULL, 10); |
351 | 352 | ||
352 | down(&data->update_lock); | 353 | mutex_lock(&data->update_lock); |
353 | data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr], data->pwm[nr]); | 354 | data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr], data->pwm[nr]); |
354 | adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), | 355 | adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), |
355 | data->temp_max[nr]); | 356 | data->temp_max[nr]); |
356 | up(&data->update_lock); | 357 | mutex_unlock(&data->update_lock); |
357 | return count; | 358 | return count; |
358 | } | 359 | } |
359 | 360 | ||
@@ -405,11 +406,11 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr) | |||
405 | int val = simple_strtol(buf, NULL, 10); | 406 | int val = simple_strtol(buf, NULL, 10); |
406 | int reg; | 407 | int reg; |
407 | 408 | ||
408 | down(&data->update_lock); | 409 | mutex_lock(&data->update_lock); |
409 | if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) && | 410 | if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) && |
410 | (((val>>4) & 0xf) != 5)) { | 411 | (((val>>4) & 0xf) != 5)) { |
411 | /* In automatic mode, the only PWM accepted is 33% */ | 412 | /* In automatic mode, the only PWM accepted is 33% */ |
412 | up(&data->update_lock); | 413 | mutex_unlock(&data->update_lock); |
413 | return -EINVAL; | 414 | return -EINVAL; |
414 | } | 415 | } |
415 | data->pwm[nr] = PWM_TO_REG(val); | 416 | data->pwm[nr] = PWM_TO_REG(val); |
@@ -417,7 +418,7 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr) | |||
417 | adm1031_write_value(client, ADM1031_REG_PWM, | 418 | adm1031_write_value(client, ADM1031_REG_PWM, |
418 | nr ? ((data->pwm[nr] << 4) & 0xf0) | (reg & 0xf) | 419 | nr ? ((data->pwm[nr] << 4) & 0xf0) | (reg & 0xf) |
419 | : (data->pwm[nr] & 0xf) | (reg & 0xf0)); | 420 | : (data->pwm[nr] & 0xf) | (reg & 0xf0)); |
420 | up(&data->update_lock); | 421 | mutex_unlock(&data->update_lock); |
421 | return count; | 422 | return count; |
422 | } | 423 | } |
423 | 424 | ||
@@ -511,7 +512,7 @@ set_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
511 | struct adm1031_data *data = i2c_get_clientdata(client); | 512 | struct adm1031_data *data = i2c_get_clientdata(client); |
512 | int val = simple_strtol(buf, NULL, 10); | 513 | int val = simple_strtol(buf, NULL, 10); |
513 | 514 | ||
514 | down(&data->update_lock); | 515 | mutex_lock(&data->update_lock); |
515 | if (val) { | 516 | if (val) { |
516 | data->fan_min[nr] = | 517 | data->fan_min[nr] = |
517 | FAN_TO_REG(val, FAN_DIV_FROM_REG(data->fan_div[nr])); | 518 | FAN_TO_REG(val, FAN_DIV_FROM_REG(data->fan_div[nr])); |
@@ -519,7 +520,7 @@ set_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
519 | data->fan_min[nr] = 0xff; | 520 | data->fan_min[nr] = 0xff; |
520 | } | 521 | } |
521 | adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), data->fan_min[nr]); | 522 | adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), data->fan_min[nr]); |
522 | up(&data->update_lock); | 523 | mutex_unlock(&data->update_lock); |
523 | return count; | 524 | return count; |
524 | } | 525 | } |
525 | static ssize_t | 526 | static ssize_t |
@@ -540,7 +541,7 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr) | |||
540 | if (tmp == 0xff) | 541 | if (tmp == 0xff) |
541 | return -EINVAL; | 542 | return -EINVAL; |
542 | 543 | ||
543 | down(&data->update_lock); | 544 | mutex_lock(&data->update_lock); |
544 | old_div = FAN_DIV_FROM_REG(data->fan_div[nr]); | 545 | old_div = FAN_DIV_FROM_REG(data->fan_div[nr]); |
545 | data->fan_div[nr] = (tmp & 0xC0) | (0x3f & data->fan_div[nr]); | 546 | data->fan_div[nr] = (tmp & 0xC0) | (0x3f & data->fan_div[nr]); |
546 | new_min = data->fan_min[nr] * old_div / | 547 | new_min = data->fan_min[nr] * old_div / |
@@ -553,7 +554,7 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr) | |||
553 | data->fan_div[nr]); | 554 | data->fan_div[nr]); |
554 | adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), | 555 | adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), |
555 | data->fan_min[nr]); | 556 | data->fan_min[nr]); |
556 | up(&data->update_lock); | 557 | mutex_unlock(&data->update_lock); |
557 | return count; | 558 | return count; |
558 | } | 559 | } |
559 | 560 | ||
@@ -627,11 +628,11 @@ set_temp_min(struct device *dev, const char *buf, size_t count, int nr) | |||
627 | 628 | ||
628 | val = simple_strtol(buf, NULL, 10); | 629 | val = simple_strtol(buf, NULL, 10); |
629 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); | 630 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); |
630 | down(&data->update_lock); | 631 | mutex_lock(&data->update_lock); |
631 | data->temp_min[nr] = TEMP_TO_REG(val); | 632 | data->temp_min[nr] = TEMP_TO_REG(val); |
632 | adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr), | 633 | adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr), |
633 | data->temp_min[nr]); | 634 | data->temp_min[nr]); |
634 | up(&data->update_lock); | 635 | mutex_unlock(&data->update_lock); |
635 | return count; | 636 | return count; |
636 | } | 637 | } |
637 | static ssize_t | 638 | static ssize_t |
@@ -643,11 +644,11 @@ set_temp_max(struct device *dev, const char *buf, size_t count, int nr) | |||
643 | 644 | ||
644 | val = simple_strtol(buf, NULL, 10); | 645 | val = simple_strtol(buf, NULL, 10); |
645 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); | 646 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); |
646 | down(&data->update_lock); | 647 | mutex_lock(&data->update_lock); |
647 | data->temp_max[nr] = TEMP_TO_REG(val); | 648 | data->temp_max[nr] = TEMP_TO_REG(val); |
648 | adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr), | 649 | adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr), |
649 | data->temp_max[nr]); | 650 | data->temp_max[nr]); |
650 | up(&data->update_lock); | 651 | mutex_unlock(&data->update_lock); |
651 | return count; | 652 | return count; |
652 | } | 653 | } |
653 | static ssize_t | 654 | static ssize_t |
@@ -659,11 +660,11 @@ set_temp_crit(struct device *dev, const char *buf, size_t count, int nr) | |||
659 | 660 | ||
660 | val = simple_strtol(buf, NULL, 10); | 661 | val = simple_strtol(buf, NULL, 10); |
661 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); | 662 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); |
662 | down(&data->update_lock); | 663 | mutex_lock(&data->update_lock); |
663 | data->temp_crit[nr] = TEMP_TO_REG(val); | 664 | data->temp_crit[nr] = TEMP_TO_REG(val); |
664 | adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr), | 665 | adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr), |
665 | data->temp_crit[nr]); | 666 | data->temp_crit[nr]); |
666 | up(&data->update_lock); | 667 | mutex_unlock(&data->update_lock); |
667 | return count; | 668 | return count; |
668 | } | 669 | } |
669 | 670 | ||
@@ -778,7 +779,7 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) | |||
778 | 779 | ||
779 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 780 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
780 | data->valid = 0; | 781 | data->valid = 0; |
781 | init_MUTEX(&data->update_lock); | 782 | mutex_init(&data->update_lock); |
782 | 783 | ||
783 | /* Tell the I2C layer a new client has arrived */ | 784 | /* Tell the I2C layer a new client has arrived */ |
784 | if ((err = i2c_attach_client(new_client))) | 785 | if ((err = i2c_attach_client(new_client))) |
@@ -891,7 +892,7 @@ static struct adm1031_data *adm1031_update_device(struct device *dev) | |||
891 | struct adm1031_data *data = i2c_get_clientdata(client); | 892 | struct adm1031_data *data = i2c_get_clientdata(client); |
892 | int chan; | 893 | int chan; |
893 | 894 | ||
894 | down(&data->update_lock); | 895 | mutex_lock(&data->update_lock); |
895 | 896 | ||
896 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 897 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
897 | || !data->valid) { | 898 | || !data->valid) { |
@@ -965,7 +966,7 @@ static struct adm1031_data *adm1031_update_device(struct device *dev) | |||
965 | data->valid = 1; | 966 | data->valid = 1; |
966 | } | 967 | } |
967 | 968 | ||
968 | up(&data->update_lock); | 969 | mutex_unlock(&data->update_lock); |
969 | 970 | ||
970 | return data; | 971 | return data; |
971 | } | 972 | } |
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index 5ddc22fea4a3..43f6991b588c 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include <linux/hwmon.h> | 49 | #include <linux/hwmon.h> |
50 | #include <linux/hwmon-vid.h> | 50 | #include <linux/hwmon-vid.h> |
51 | #include <linux/err.h> | 51 | #include <linux/err.h> |
52 | #include <linux/mutex.h> | ||
52 | 53 | ||
53 | /* Addresses to scan */ | 54 | /* Addresses to scan */ |
54 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, | 55 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, |
@@ -150,7 +151,7 @@ struct adm9240_data { | |||
150 | enum chips type; | 151 | enum chips type; |
151 | struct i2c_client client; | 152 | struct i2c_client client; |
152 | struct class_device *class_dev; | 153 | struct class_device *class_dev; |
153 | struct semaphore update_lock; | 154 | struct mutex update_lock; |
154 | char valid; | 155 | char valid; |
155 | unsigned long last_updated_measure; | 156 | unsigned long last_updated_measure; |
156 | unsigned long last_updated_config; | 157 | unsigned long last_updated_config; |
@@ -195,11 +196,11 @@ static ssize_t set_max(struct device *dev, struct device_attribute *devattr, | |||
195 | struct adm9240_data *data = i2c_get_clientdata(client); | 196 | struct adm9240_data *data = i2c_get_clientdata(client); |
196 | long val = simple_strtol(buf, NULL, 10); | 197 | long val = simple_strtol(buf, NULL, 10); |
197 | 198 | ||
198 | down(&data->update_lock); | 199 | mutex_lock(&data->update_lock); |
199 | data->temp_max[attr->index] = TEMP_TO_REG(val); | 200 | data->temp_max[attr->index] = TEMP_TO_REG(val); |
200 | i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index), | 201 | i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index), |
201 | data->temp_max[attr->index]); | 202 | data->temp_max[attr->index]); |
202 | up(&data->update_lock); | 203 | mutex_unlock(&data->update_lock); |
203 | return count; | 204 | return count; |
204 | } | 205 | } |
205 | 206 | ||
@@ -246,11 +247,11 @@ static ssize_t set_in_min(struct device *dev, | |||
246 | struct adm9240_data *data = i2c_get_clientdata(client); | 247 | struct adm9240_data *data = i2c_get_clientdata(client); |
247 | unsigned long val = simple_strtoul(buf, NULL, 10); | 248 | unsigned long val = simple_strtoul(buf, NULL, 10); |
248 | 249 | ||
249 | down(&data->update_lock); | 250 | mutex_lock(&data->update_lock); |
250 | data->in_min[attr->index] = IN_TO_REG(val, attr->index); | 251 | data->in_min[attr->index] = IN_TO_REG(val, attr->index); |
251 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index), | 252 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index), |
252 | data->in_min[attr->index]); | 253 | data->in_min[attr->index]); |
253 | up(&data->update_lock); | 254 | mutex_unlock(&data->update_lock); |
254 | return count; | 255 | return count; |
255 | } | 256 | } |
256 | 257 | ||
@@ -263,11 +264,11 @@ static ssize_t set_in_max(struct device *dev, | |||
263 | struct adm9240_data *data = i2c_get_clientdata(client); | 264 | struct adm9240_data *data = i2c_get_clientdata(client); |
264 | unsigned long val = simple_strtoul(buf, NULL, 10); | 265 | unsigned long val = simple_strtoul(buf, NULL, 10); |
265 | 266 | ||
266 | down(&data->update_lock); | 267 | mutex_lock(&data->update_lock); |
267 | data->in_max[attr->index] = IN_TO_REG(val, attr->index); | 268 | data->in_max[attr->index] = IN_TO_REG(val, attr->index); |
268 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index), | 269 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index), |
269 | data->in_max[attr->index]); | 270 | data->in_max[attr->index]); |
270 | up(&data->update_lock); | 271 | mutex_unlock(&data->update_lock); |
271 | return count; | 272 | return count; |
272 | } | 273 | } |
273 | 274 | ||
@@ -350,7 +351,7 @@ static ssize_t set_fan_min(struct device *dev, | |||
350 | int nr = attr->index; | 351 | int nr = attr->index; |
351 | u8 new_div; | 352 | u8 new_div; |
352 | 353 | ||
353 | down(&data->update_lock); | 354 | mutex_lock(&data->update_lock); |
354 | 355 | ||
355 | if (!val) { | 356 | if (!val) { |
356 | data->fan_min[nr] = 255; | 357 | data->fan_min[nr] = 255; |
@@ -390,7 +391,7 @@ static ssize_t set_fan_min(struct device *dev, | |||
390 | i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr), | 391 | i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr), |
391 | data->fan_min[nr]); | 392 | data->fan_min[nr]); |
392 | 393 | ||
393 | up(&data->update_lock); | 394 | mutex_unlock(&data->update_lock); |
394 | return count; | 395 | return count; |
395 | } | 396 | } |
396 | 397 | ||
@@ -439,10 +440,10 @@ static ssize_t set_aout(struct device *dev, | |||
439 | struct adm9240_data *data = i2c_get_clientdata(client); | 440 | struct adm9240_data *data = i2c_get_clientdata(client); |
440 | unsigned long val = simple_strtol(buf, NULL, 10); | 441 | unsigned long val = simple_strtol(buf, NULL, 10); |
441 | 442 | ||
442 | down(&data->update_lock); | 443 | mutex_lock(&data->update_lock); |
443 | data->aout = AOUT_TO_REG(val); | 444 | data->aout = AOUT_TO_REG(val); |
444 | i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout); | 445 | i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout); |
445 | up(&data->update_lock); | 446 | mutex_unlock(&data->update_lock); |
446 | return count; | 447 | return count; |
447 | } | 448 | } |
448 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); | 449 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); |
@@ -539,7 +540,7 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
539 | /* fill in the remaining client fields and attach */ | 540 | /* fill in the remaining client fields and attach */ |
540 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 541 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
541 | data->type = kind; | 542 | data->type = kind; |
542 | init_MUTEX(&data->update_lock); | 543 | mutex_init(&data->update_lock); |
543 | 544 | ||
544 | if ((err = i2c_attach_client(new_client))) | 545 | if ((err = i2c_attach_client(new_client))) |
545 | goto exit_free; | 546 | goto exit_free; |
@@ -691,7 +692,7 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) | |||
691 | struct adm9240_data *data = i2c_get_clientdata(client); | 692 | struct adm9240_data *data = i2c_get_clientdata(client); |
692 | int i; | 693 | int i; |
693 | 694 | ||
694 | down(&data->update_lock); | 695 | mutex_lock(&data->update_lock); |
695 | 696 | ||
696 | /* minimum measurement cycle: 1.75 seconds */ | 697 | /* minimum measurement cycle: 1.75 seconds */ |
697 | if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4)) | 698 | if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4)) |
@@ -771,7 +772,7 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) | |||
771 | data->last_updated_config = jiffies; | 772 | data->last_updated_config = jiffies; |
772 | data->valid = 1; | 773 | data->valid = 1; |
773 | } | 774 | } |
774 | up(&data->update_lock); | 775 | mutex_unlock(&data->update_lock); |
775 | return data; | 776 | return data; |
776 | } | 777 | } |
777 | 778 | ||
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index ae9de63cf2e0..65b2709f750c 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/err.h> | 44 | #include <linux/err.h> |
45 | #include <linux/init.h> | 45 | #include <linux/init.h> |
46 | #include <linux/jiffies.h> | 46 | #include <linux/jiffies.h> |
47 | #include <linux/mutex.h> | ||
47 | #include "lm75.h" | 48 | #include "lm75.h" |
48 | 49 | ||
49 | /* | 50 | /* |
@@ -182,10 +183,10 @@ static u8 DIV_TO_REG(long val) | |||
182 | struct asb100_data { | 183 | struct asb100_data { |
183 | struct i2c_client client; | 184 | struct i2c_client client; |
184 | struct class_device *class_dev; | 185 | struct class_device *class_dev; |
185 | struct semaphore lock; | 186 | struct mutex lock; |
186 | enum chips type; | 187 | enum chips type; |
187 | 188 | ||
188 | struct semaphore update_lock; | 189 | struct mutex update_lock; |
189 | unsigned long last_updated; /* In jiffies */ | 190 | unsigned long last_updated; /* In jiffies */ |
190 | 191 | ||
191 | /* array of 2 pointers to subclients */ | 192 | /* array of 2 pointers to subclients */ |
@@ -245,11 +246,11 @@ static ssize_t set_in_##reg(struct device *dev, const char *buf, \ | |||
245 | struct asb100_data *data = i2c_get_clientdata(client); \ | 246 | struct asb100_data *data = i2c_get_clientdata(client); \ |
246 | unsigned long val = simple_strtoul(buf, NULL, 10); \ | 247 | unsigned long val = simple_strtoul(buf, NULL, 10); \ |
247 | \ | 248 | \ |
248 | down(&data->update_lock); \ | 249 | mutex_lock(&data->update_lock); \ |
249 | data->in_##reg[nr] = IN_TO_REG(val); \ | 250 | data->in_##reg[nr] = IN_TO_REG(val); \ |
250 | asb100_write_value(client, ASB100_REG_IN_##REG(nr), \ | 251 | asb100_write_value(client, ASB100_REG_IN_##REG(nr), \ |
251 | data->in_##reg[nr]); \ | 252 | data->in_##reg[nr]); \ |
252 | up(&data->update_lock); \ | 253 | mutex_unlock(&data->update_lock); \ |
253 | return count; \ | 254 | return count; \ |
254 | } | 255 | } |
255 | 256 | ||
@@ -331,10 +332,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
331 | struct asb100_data *data = i2c_get_clientdata(client); | 332 | struct asb100_data *data = i2c_get_clientdata(client); |
332 | u32 val = simple_strtoul(buf, NULL, 10); | 333 | u32 val = simple_strtoul(buf, NULL, 10); |
333 | 334 | ||
334 | down(&data->update_lock); | 335 | mutex_lock(&data->update_lock); |
335 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 336 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
336 | asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); | 337 | asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); |
337 | up(&data->update_lock); | 338 | mutex_unlock(&data->update_lock); |
338 | return count; | 339 | return count; |
339 | } | 340 | } |
340 | 341 | ||
@@ -351,7 +352,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
351 | unsigned long val = simple_strtoul(buf, NULL, 10); | 352 | unsigned long val = simple_strtoul(buf, NULL, 10); |
352 | int reg; | 353 | int reg; |
353 | 354 | ||
354 | down(&data->update_lock); | 355 | mutex_lock(&data->update_lock); |
355 | 356 | ||
356 | min = FAN_FROM_REG(data->fan_min[nr], | 357 | min = FAN_FROM_REG(data->fan_min[nr], |
357 | DIV_FROM_REG(data->fan_div[nr])); | 358 | DIV_FROM_REG(data->fan_div[nr])); |
@@ -381,7 +382,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
381 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 382 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
382 | asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); | 383 | asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); |
383 | 384 | ||
384 | up(&data->update_lock); | 385 | mutex_unlock(&data->update_lock); |
385 | 386 | ||
386 | return count; | 387 | return count; |
387 | } | 388 | } |
@@ -461,7 +462,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \ | |||
461 | struct asb100_data *data = i2c_get_clientdata(client); \ | 462 | struct asb100_data *data = i2c_get_clientdata(client); \ |
462 | unsigned long val = simple_strtoul(buf, NULL, 10); \ | 463 | unsigned long val = simple_strtoul(buf, NULL, 10); \ |
463 | \ | 464 | \ |
464 | down(&data->update_lock); \ | 465 | mutex_lock(&data->update_lock); \ |
465 | switch (nr) { \ | 466 | switch (nr) { \ |
466 | case 1: case 2: \ | 467 | case 1: case 2: \ |
467 | data->reg[nr] = LM75_TEMP_TO_REG(val); \ | 468 | data->reg[nr] = LM75_TEMP_TO_REG(val); \ |
@@ -472,7 +473,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \ | |||
472 | } \ | 473 | } \ |
473 | asb100_write_value(client, ASB100_REG_TEMP_##REG(nr+1), \ | 474 | asb100_write_value(client, ASB100_REG_TEMP_##REG(nr+1), \ |
474 | data->reg[nr]); \ | 475 | data->reg[nr]); \ |
475 | up(&data->update_lock); \ | 476 | mutex_unlock(&data->update_lock); \ |
476 | return count; \ | 477 | return count; \ |
477 | } | 478 | } |
478 | 479 | ||
@@ -574,11 +575,11 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const | |||
574 | struct asb100_data *data = i2c_get_clientdata(client); | 575 | struct asb100_data *data = i2c_get_clientdata(client); |
575 | unsigned long val = simple_strtoul(buf, NULL, 10); | 576 | unsigned long val = simple_strtoul(buf, NULL, 10); |
576 | 577 | ||
577 | down(&data->update_lock); | 578 | mutex_lock(&data->update_lock); |
578 | data->pwm &= 0x80; /* keep the enable bit */ | 579 | data->pwm &= 0x80; /* keep the enable bit */ |
579 | data->pwm |= (0x0f & ASB100_PWM_TO_REG(val)); | 580 | data->pwm |= (0x0f & ASB100_PWM_TO_REG(val)); |
580 | asb100_write_value(client, ASB100_REG_PWM1, data->pwm); | 581 | asb100_write_value(client, ASB100_REG_PWM1, data->pwm); |
581 | up(&data->update_lock); | 582 | mutex_unlock(&data->update_lock); |
582 | return count; | 583 | return count; |
583 | } | 584 | } |
584 | 585 | ||
@@ -595,11 +596,11 @@ static ssize_t set_pwm_enable1(struct device *dev, struct device_attribute *attr | |||
595 | struct asb100_data *data = i2c_get_clientdata(client); | 596 | struct asb100_data *data = i2c_get_clientdata(client); |
596 | unsigned long val = simple_strtoul(buf, NULL, 10); | 597 | unsigned long val = simple_strtoul(buf, NULL, 10); |
597 | 598 | ||
598 | down(&data->update_lock); | 599 | mutex_lock(&data->update_lock); |
599 | data->pwm &= 0x0f; /* keep the duty cycle bits */ | 600 | data->pwm &= 0x0f; /* keep the duty cycle bits */ |
600 | data->pwm |= (val ? 0x80 : 0x00); | 601 | data->pwm |= (val ? 0x80 : 0x00); |
601 | asb100_write_value(client, ASB100_REG_PWM1, data->pwm); | 602 | asb100_write_value(client, ASB100_REG_PWM1, data->pwm); |
602 | up(&data->update_lock); | 603 | mutex_unlock(&data->update_lock); |
603 | return count; | 604 | return count; |
604 | } | 605 | } |
605 | 606 | ||
@@ -729,7 +730,7 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | |||
729 | } | 730 | } |
730 | 731 | ||
731 | new_client = &data->client; | 732 | new_client = &data->client; |
732 | init_MUTEX(&data->lock); | 733 | mutex_init(&data->lock); |
733 | i2c_set_clientdata(new_client, data); | 734 | i2c_set_clientdata(new_client, data); |
734 | new_client->addr = address; | 735 | new_client->addr = address; |
735 | new_client->adapter = adapter; | 736 | new_client->adapter = adapter; |
@@ -789,7 +790,7 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | |||
789 | data->type = kind; | 790 | data->type = kind; |
790 | 791 | ||
791 | data->valid = 0; | 792 | data->valid = 0; |
792 | init_MUTEX(&data->update_lock); | 793 | mutex_init(&data->update_lock); |
793 | 794 | ||
794 | /* Tell the I2C layer a new client has arrived */ | 795 | /* Tell the I2C layer a new client has arrived */ |
795 | if ((err = i2c_attach_client(new_client))) | 796 | if ((err = i2c_attach_client(new_client))) |
@@ -885,7 +886,7 @@ static int asb100_read_value(struct i2c_client *client, u16 reg) | |||
885 | struct i2c_client *cl; | 886 | struct i2c_client *cl; |
886 | int res, bank; | 887 | int res, bank; |
887 | 888 | ||
888 | down(&data->lock); | 889 | mutex_lock(&data->lock); |
889 | 890 | ||
890 | bank = (reg >> 8) & 0x0f; | 891 | bank = (reg >> 8) & 0x0f; |
891 | if (bank > 2) | 892 | if (bank > 2) |
@@ -919,7 +920,7 @@ static int asb100_read_value(struct i2c_client *client, u16 reg) | |||
919 | if (bank > 2) | 920 | if (bank > 2) |
920 | i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); | 921 | i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); |
921 | 922 | ||
922 | up(&data->lock); | 923 | mutex_unlock(&data->lock); |
923 | 924 | ||
924 | return res; | 925 | return res; |
925 | } | 926 | } |
@@ -930,7 +931,7 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
930 | struct i2c_client *cl; | 931 | struct i2c_client *cl; |
931 | int bank; | 932 | int bank; |
932 | 933 | ||
933 | down(&data->lock); | 934 | mutex_lock(&data->lock); |
934 | 935 | ||
935 | bank = (reg >> 8) & 0x0f; | 936 | bank = (reg >> 8) & 0x0f; |
936 | if (bank > 2) | 937 | if (bank > 2) |
@@ -960,7 +961,7 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
960 | if (bank > 2) | 961 | if (bank > 2) |
961 | i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); | 962 | i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); |
962 | 963 | ||
963 | up(&data->lock); | 964 | mutex_unlock(&data->lock); |
964 | } | 965 | } |
965 | 966 | ||
966 | static void asb100_init_client(struct i2c_client *client) | 967 | static void asb100_init_client(struct i2c_client *client) |
@@ -984,7 +985,7 @@ static struct asb100_data *asb100_update_device(struct device *dev) | |||
984 | struct asb100_data *data = i2c_get_clientdata(client); | 985 | struct asb100_data *data = i2c_get_clientdata(client); |
985 | int i; | 986 | int i; |
986 | 987 | ||
987 | down(&data->update_lock); | 988 | mutex_lock(&data->update_lock); |
988 | 989 | ||
989 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 990 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
990 | || !data->valid) { | 991 | || !data->valid) { |
@@ -1042,7 +1043,7 @@ static struct asb100_data *asb100_update_device(struct device *dev) | |||
1042 | dev_dbg(&client->dev, "... device update complete\n"); | 1043 | dev_dbg(&client->dev, "... device update complete\n"); |
1043 | } | 1044 | } |
1044 | 1045 | ||
1045 | up(&data->update_lock); | 1046 | mutex_unlock(&data->update_lock); |
1046 | 1047 | ||
1047 | return data; | 1048 | return data; |
1048 | } | 1049 | } |
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index b0c490073c8e..728a1e8b9190 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/hwmon.h> | 26 | #include <linux/hwmon.h> |
27 | #include <linux/hwmon-vid.h> | 27 | #include <linux/hwmon-vid.h> |
28 | #include <linux/err.h> | 28 | #include <linux/err.h> |
29 | #include <linux/mutex.h> | ||
29 | 30 | ||
30 | MODULE_LICENSE("GPL"); | 31 | MODULE_LICENSE("GPL"); |
31 | MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); | 32 | MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); |
@@ -60,7 +61,7 @@ static struct i2c_driver atxp1_driver = { | |||
60 | struct atxp1_data { | 61 | struct atxp1_data { |
61 | struct i2c_client client; | 62 | struct i2c_client client; |
62 | struct class_device *class_dev; | 63 | struct class_device *class_dev; |
63 | struct semaphore update_lock; | 64 | struct mutex update_lock; |
64 | unsigned long last_updated; | 65 | unsigned long last_updated; |
65 | u8 valid; | 66 | u8 valid; |
66 | struct { | 67 | struct { |
@@ -80,7 +81,7 @@ static struct atxp1_data * atxp1_update_device(struct device *dev) | |||
80 | client = to_i2c_client(dev); | 81 | client = to_i2c_client(dev); |
81 | data = i2c_get_clientdata(client); | 82 | data = i2c_get_clientdata(client); |
82 | 83 | ||
83 | down(&data->update_lock); | 84 | mutex_lock(&data->update_lock); |
84 | 85 | ||
85 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | 86 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { |
86 | 87 | ||
@@ -93,7 +94,7 @@ static struct atxp1_data * atxp1_update_device(struct device *dev) | |||
93 | data->valid = 1; | 94 | data->valid = 1; |
94 | } | 95 | } |
95 | 96 | ||
96 | up(&data->update_lock); | 97 | mutex_unlock(&data->update_lock); |
97 | 98 | ||
98 | return(data); | 99 | return(data); |
99 | } | 100 | } |
@@ -309,7 +310,7 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) | |||
309 | 310 | ||
310 | data->valid = 0; | 311 | data->valid = 0; |
311 | 312 | ||
312 | init_MUTEX(&data->update_lock); | 313 | mutex_init(&data->update_lock); |
313 | 314 | ||
314 | err = i2c_attach_client(new_client); | 315 | err = i2c_attach_client(new_client); |
315 | 316 | ||
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index 203f9c7abb20..478eb4bb8570 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/hwmon.h> | 29 | #include <linux/hwmon.h> |
30 | #include <linux/err.h> | 30 | #include <linux/err.h> |
31 | #include <linux/mutex.h> | ||
31 | #include "lm75.h" | 32 | #include "lm75.h" |
32 | 33 | ||
33 | /* Addresses to scan */ | 34 | /* Addresses to scan */ |
@@ -72,7 +73,7 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low") | |||
72 | struct ds1621_data { | 73 | struct ds1621_data { |
73 | struct i2c_client client; | 74 | struct i2c_client client; |
74 | struct class_device *class_dev; | 75 | struct class_device *class_dev; |
75 | struct semaphore update_lock; | 76 | struct mutex update_lock; |
76 | char valid; /* !=0 if following fields are valid */ | 77 | char valid; /* !=0 if following fields are valid */ |
77 | unsigned long last_updated; /* In jiffies */ | 78 | unsigned long last_updated; /* In jiffies */ |
78 | 79 | ||
@@ -156,10 +157,10 @@ static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *at | |||
156 | struct ds1621_data *data = ds1621_update_client(dev); \ | 157 | struct ds1621_data *data = ds1621_update_client(dev); \ |
157 | u16 val = LM75_TEMP_TO_REG(simple_strtoul(buf, NULL, 10)); \ | 158 | u16 val = LM75_TEMP_TO_REG(simple_strtoul(buf, NULL, 10)); \ |
158 | \ | 159 | \ |
159 | down(&data->update_lock); \ | 160 | mutex_lock(&data->update_lock); \ |
160 | data->value = val; \ | 161 | data->value = val; \ |
161 | ds1621_write_value(client, reg, data->value); \ | 162 | ds1621_write_value(client, reg, data->value); \ |
162 | up(&data->update_lock); \ | 163 | mutex_unlock(&data->update_lock); \ |
163 | return count; \ | 164 | return count; \ |
164 | } | 165 | } |
165 | 166 | ||
@@ -242,7 +243,7 @@ static int ds1621_detect(struct i2c_adapter *adapter, int address, | |||
242 | /* Fill in remaining client fields and put it into the global list */ | 243 | /* Fill in remaining client fields and put it into the global list */ |
243 | strlcpy(new_client->name, "ds1621", I2C_NAME_SIZE); | 244 | strlcpy(new_client->name, "ds1621", I2C_NAME_SIZE); |
244 | data->valid = 0; | 245 | data->valid = 0; |
245 | init_MUTEX(&data->update_lock); | 246 | mutex_init(&data->update_lock); |
246 | 247 | ||
247 | /* Tell the I2C layer a new client has arrived */ | 248 | /* Tell the I2C layer a new client has arrived */ |
248 | if ((err = i2c_attach_client(new_client))) | 249 | if ((err = i2c_attach_client(new_client))) |
@@ -297,7 +298,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev) | |||
297 | struct ds1621_data *data = i2c_get_clientdata(client); | 298 | struct ds1621_data *data = i2c_get_clientdata(client); |
298 | u8 new_conf; | 299 | u8 new_conf; |
299 | 300 | ||
300 | down(&data->update_lock); | 301 | mutex_lock(&data->update_lock); |
301 | 302 | ||
302 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 303 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
303 | || !data->valid) { | 304 | || !data->valid) { |
@@ -327,7 +328,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev) | |||
327 | data->valid = 1; | 328 | data->valid = 1; |
328 | } | 329 | } |
329 | 330 | ||
330 | up(&data->update_lock); | 331 | mutex_unlock(&data->update_lock); |
331 | 332 | ||
332 | return data; | 333 | return data; |
333 | } | 334 | } |
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c index e029e0a94ecc..885465df6e6a 100644 --- a/drivers/hwmon/f71805f.c +++ b/drivers/hwmon/f71805f.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/hwmon.h> | 30 | #include <linux/hwmon.h> |
31 | #include <linux/hwmon-sysfs.h> | 31 | #include <linux/hwmon-sysfs.h> |
32 | #include <linux/err.h> | 32 | #include <linux/err.h> |
33 | #include <linux/mutex.h> | ||
33 | #include <asm/io.h> | 34 | #include <asm/io.h> |
34 | 35 | ||
35 | static struct platform_device *pdev; | 36 | static struct platform_device *pdev; |
@@ -131,10 +132,10 @@ static struct resource f71805f_resource __initdata = { | |||
131 | struct f71805f_data { | 132 | struct f71805f_data { |
132 | unsigned short addr; | 133 | unsigned short addr; |
133 | const char *name; | 134 | const char *name; |
134 | struct semaphore lock; | 135 | struct mutex lock; |
135 | struct class_device *class_dev; | 136 | struct class_device *class_dev; |
136 | 137 | ||
137 | struct semaphore update_lock; | 138 | struct mutex update_lock; |
138 | char valid; /* !=0 if following fields are valid */ | 139 | char valid; /* !=0 if following fields are valid */ |
139 | unsigned long last_updated; /* In jiffies */ | 140 | unsigned long last_updated; /* In jiffies */ |
140 | unsigned long last_limits; /* In jiffies */ | 141 | unsigned long last_limits; /* In jiffies */ |
@@ -224,20 +225,20 @@ static u8 f71805f_read8(struct f71805f_data *data, u8 reg) | |||
224 | { | 225 | { |
225 | u8 val; | 226 | u8 val; |
226 | 227 | ||
227 | down(&data->lock); | 228 | mutex_lock(&data->lock); |
228 | outb(reg, data->addr + ADDR_REG_OFFSET); | 229 | outb(reg, data->addr + ADDR_REG_OFFSET); |
229 | val = inb(data->addr + DATA_REG_OFFSET); | 230 | val = inb(data->addr + DATA_REG_OFFSET); |
230 | up(&data->lock); | 231 | mutex_unlock(&data->lock); |
231 | 232 | ||
232 | return val; | 233 | return val; |
233 | } | 234 | } |
234 | 235 | ||
235 | static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val) | 236 | static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val) |
236 | { | 237 | { |
237 | down(&data->lock); | 238 | mutex_lock(&data->lock); |
238 | outb(reg, data->addr + ADDR_REG_OFFSET); | 239 | outb(reg, data->addr + ADDR_REG_OFFSET); |
239 | outb(val, data->addr + DATA_REG_OFFSET); | 240 | outb(val, data->addr + DATA_REG_OFFSET); |
240 | up(&data->lock); | 241 | mutex_unlock(&data->lock); |
241 | } | 242 | } |
242 | 243 | ||
243 | /* It is important to read the MSB first, because doing so latches the | 244 | /* It is important to read the MSB first, because doing so latches the |
@@ -246,24 +247,24 @@ static u16 f71805f_read16(struct f71805f_data *data, u8 reg) | |||
246 | { | 247 | { |
247 | u16 val; | 248 | u16 val; |
248 | 249 | ||
249 | down(&data->lock); | 250 | mutex_lock(&data->lock); |
250 | outb(reg, data->addr + ADDR_REG_OFFSET); | 251 | outb(reg, data->addr + ADDR_REG_OFFSET); |
251 | val = inb(data->addr + DATA_REG_OFFSET) << 8; | 252 | val = inb(data->addr + DATA_REG_OFFSET) << 8; |
252 | outb(++reg, data->addr + ADDR_REG_OFFSET); | 253 | outb(++reg, data->addr + ADDR_REG_OFFSET); |
253 | val |= inb(data->addr + DATA_REG_OFFSET); | 254 | val |= inb(data->addr + DATA_REG_OFFSET); |
254 | up(&data->lock); | 255 | mutex_unlock(&data->lock); |
255 | 256 | ||
256 | return val; | 257 | return val; |
257 | } | 258 | } |
258 | 259 | ||
259 | static void f71805f_write16(struct f71805f_data *data, u8 reg, u16 val) | 260 | static void f71805f_write16(struct f71805f_data *data, u8 reg, u16 val) |
260 | { | 261 | { |
261 | down(&data->lock); | 262 | mutex_lock(&data->lock); |
262 | outb(reg, data->addr + ADDR_REG_OFFSET); | 263 | outb(reg, data->addr + ADDR_REG_OFFSET); |
263 | outb(val >> 8, data->addr + DATA_REG_OFFSET); | 264 | outb(val >> 8, data->addr + DATA_REG_OFFSET); |
264 | outb(++reg, data->addr + ADDR_REG_OFFSET); | 265 | outb(++reg, data->addr + ADDR_REG_OFFSET); |
265 | outb(val & 0xff, data->addr + DATA_REG_OFFSET); | 266 | outb(val & 0xff, data->addr + DATA_REG_OFFSET); |
266 | up(&data->lock); | 267 | mutex_unlock(&data->lock); |
267 | } | 268 | } |
268 | 269 | ||
269 | static struct f71805f_data *f71805f_update_device(struct device *dev) | 270 | static struct f71805f_data *f71805f_update_device(struct device *dev) |
@@ -271,7 +272,7 @@ static struct f71805f_data *f71805f_update_device(struct device *dev) | |||
271 | struct f71805f_data *data = dev_get_drvdata(dev); | 272 | struct f71805f_data *data = dev_get_drvdata(dev); |
272 | int nr; | 273 | int nr; |
273 | 274 | ||
274 | down(&data->update_lock); | 275 | mutex_lock(&data->update_lock); |
275 | 276 | ||
276 | /* Limit registers cache is refreshed after 60 seconds */ | 277 | /* Limit registers cache is refreshed after 60 seconds */ |
277 | if (time_after(jiffies, data->last_updated + 60 * HZ) | 278 | if (time_after(jiffies, data->last_updated + 60 * HZ) |
@@ -323,7 +324,7 @@ static struct f71805f_data *f71805f_update_device(struct device *dev) | |||
323 | data->valid = 1; | 324 | data->valid = 1; |
324 | } | 325 | } |
325 | 326 | ||
326 | up(&data->update_lock); | 327 | mutex_unlock(&data->update_lock); |
327 | 328 | ||
328 | return data; | 329 | return data; |
329 | } | 330 | } |
@@ -362,10 +363,10 @@ static ssize_t set_in0_max(struct device *dev, struct device_attribute | |||
362 | struct f71805f_data *data = dev_get_drvdata(dev); | 363 | struct f71805f_data *data = dev_get_drvdata(dev); |
363 | long val = simple_strtol(buf, NULL, 10); | 364 | long val = simple_strtol(buf, NULL, 10); |
364 | 365 | ||
365 | down(&data->update_lock); | 366 | mutex_lock(&data->update_lock); |
366 | data->in_high[0] = in0_to_reg(val); | 367 | data->in_high[0] = in0_to_reg(val); |
367 | f71805f_write8(data, F71805F_REG_IN_HIGH(0), data->in_high[0]); | 368 | f71805f_write8(data, F71805F_REG_IN_HIGH(0), data->in_high[0]); |
368 | up(&data->update_lock); | 369 | mutex_unlock(&data->update_lock); |
369 | 370 | ||
370 | return count; | 371 | return count; |
371 | } | 372 | } |
@@ -376,18 +377,14 @@ static ssize_t set_in0_min(struct device *dev, struct device_attribute | |||
376 | struct f71805f_data *data = dev_get_drvdata(dev); | 377 | struct f71805f_data *data = dev_get_drvdata(dev); |
377 | long val = simple_strtol(buf, NULL, 10); | 378 | long val = simple_strtol(buf, NULL, 10); |
378 | 379 | ||
379 | down(&data->update_lock); | 380 | mutex_lock(&data->update_lock); |
380 | data->in_low[0] = in0_to_reg(val); | 381 | data->in_low[0] = in0_to_reg(val); |
381 | f71805f_write8(data, F71805F_REG_IN_LOW(0), data->in_low[0]); | 382 | f71805f_write8(data, F71805F_REG_IN_LOW(0), data->in_low[0]); |
382 | up(&data->update_lock); | 383 | mutex_unlock(&data->update_lock); |
383 | 384 | ||
384 | return count; | 385 | return count; |
385 | } | 386 | } |
386 | 387 | ||
387 | static DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL); | ||
388 | static DEVICE_ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max); | ||
389 | static DEVICE_ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min); | ||
390 | |||
391 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, | 388 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, |
392 | char *buf) | 389 | char *buf) |
393 | { | 390 | { |
@@ -426,10 +423,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute | |||
426 | int nr = attr->index; | 423 | int nr = attr->index; |
427 | long val = simple_strtol(buf, NULL, 10); | 424 | long val = simple_strtol(buf, NULL, 10); |
428 | 425 | ||
429 | down(&data->update_lock); | 426 | mutex_lock(&data->update_lock); |
430 | data->in_high[nr] = in_to_reg(val); | 427 | data->in_high[nr] = in_to_reg(val); |
431 | f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]); | 428 | f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]); |
432 | up(&data->update_lock); | 429 | mutex_unlock(&data->update_lock); |
433 | 430 | ||
434 | return count; | 431 | return count; |
435 | } | 432 | } |
@@ -442,31 +439,14 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute | |||
442 | int nr = attr->index; | 439 | int nr = attr->index; |
443 | long val = simple_strtol(buf, NULL, 10); | 440 | long val = simple_strtol(buf, NULL, 10); |
444 | 441 | ||
445 | down(&data->update_lock); | 442 | mutex_lock(&data->update_lock); |
446 | data->in_low[nr] = in_to_reg(val); | 443 | data->in_low[nr] = in_to_reg(val); |
447 | f71805f_write8(data, F71805F_REG_IN_LOW(nr), data->in_low[nr]); | 444 | f71805f_write8(data, F71805F_REG_IN_LOW(nr), data->in_low[nr]); |
448 | up(&data->update_lock); | 445 | mutex_unlock(&data->update_lock); |
449 | 446 | ||
450 | return count; | 447 | return count; |
451 | } | 448 | } |
452 | 449 | ||
453 | #define sysfs_in(offset) \ | ||
454 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ | ||
455 | show_in, NULL, offset); \ | ||
456 | static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | ||
457 | show_in_max, set_in_max, offset); \ | ||
458 | static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | ||
459 | show_in_min, set_in_min, offset) | ||
460 | |||
461 | sysfs_in(1); | ||
462 | sysfs_in(2); | ||
463 | sysfs_in(3); | ||
464 | sysfs_in(4); | ||
465 | sysfs_in(5); | ||
466 | sysfs_in(6); | ||
467 | sysfs_in(7); | ||
468 | sysfs_in(8); | ||
469 | |||
470 | static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, | 450 | static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, |
471 | char *buf) | 451 | char *buf) |
472 | { | 452 | { |
@@ -495,24 +475,14 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute | |||
495 | int nr = attr->index; | 475 | int nr = attr->index; |
496 | long val = simple_strtol(buf, NULL, 10); | 476 | long val = simple_strtol(buf, NULL, 10); |
497 | 477 | ||
498 | down(&data->update_lock); | 478 | mutex_lock(&data->update_lock); |
499 | data->fan_low[nr] = fan_to_reg(val); | 479 | data->fan_low[nr] = fan_to_reg(val); |
500 | f71805f_write16(data, F71805F_REG_FAN_LOW(nr), data->fan_low[nr]); | 480 | f71805f_write16(data, F71805F_REG_FAN_LOW(nr), data->fan_low[nr]); |
501 | up(&data->update_lock); | 481 | mutex_unlock(&data->update_lock); |
502 | 482 | ||
503 | return count; | 483 | return count; |
504 | } | 484 | } |
505 | 485 | ||
506 | #define sysfs_fan(offset) \ | ||
507 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
508 | show_fan, NULL, offset - 1); \ | ||
509 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
510 | show_fan_min, set_fan_min, offset - 1) | ||
511 | |||
512 | sysfs_fan(1); | ||
513 | sysfs_fan(2); | ||
514 | sysfs_fan(3); | ||
515 | |||
516 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, | 486 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, |
517 | char *buf) | 487 | char *buf) |
518 | { | 488 | { |
@@ -562,10 +532,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute | |||
562 | int nr = attr->index; | 532 | int nr = attr->index; |
563 | long val = simple_strtol(buf, NULL, 10); | 533 | long val = simple_strtol(buf, NULL, 10); |
564 | 534 | ||
565 | down(&data->update_lock); | 535 | mutex_lock(&data->update_lock); |
566 | data->temp_high[nr] = temp_to_reg(val); | 536 | data->temp_high[nr] = temp_to_reg(val); |
567 | f71805f_write8(data, F71805F_REG_TEMP_HIGH(nr), data->temp_high[nr]); | 537 | f71805f_write8(data, F71805F_REG_TEMP_HIGH(nr), data->temp_high[nr]); |
568 | up(&data->update_lock); | 538 | mutex_unlock(&data->update_lock); |
569 | 539 | ||
570 | return count; | 540 | return count; |
571 | } | 541 | } |
@@ -578,28 +548,14 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute | |||
578 | int nr = attr->index; | 548 | int nr = attr->index; |
579 | long val = simple_strtol(buf, NULL, 10); | 549 | long val = simple_strtol(buf, NULL, 10); |
580 | 550 | ||
581 | down(&data->update_lock); | 551 | mutex_lock(&data->update_lock); |
582 | data->temp_hyst[nr] = temp_to_reg(val); | 552 | data->temp_hyst[nr] = temp_to_reg(val); |
583 | f71805f_write8(data, F71805F_REG_TEMP_HYST(nr), data->temp_hyst[nr]); | 553 | f71805f_write8(data, F71805F_REG_TEMP_HYST(nr), data->temp_hyst[nr]); |
584 | up(&data->update_lock); | 554 | mutex_unlock(&data->update_lock); |
585 | 555 | ||
586 | return count; | 556 | return count; |
587 | } | 557 | } |
588 | 558 | ||
589 | #define sysfs_temp(offset) \ | ||
590 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ | ||
591 | show_temp, NULL, offset - 1); \ | ||
592 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ | ||
593 | show_temp_max, set_temp_max, offset - 1); \ | ||
594 | static SENSOR_DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \ | ||
595 | show_temp_hyst, set_temp_hyst, offset - 1); \ | ||
596 | static SENSOR_DEVICE_ATTR(temp##offset##_type, S_IRUGO, \ | ||
597 | show_temp_type, NULL, offset - 1) | ||
598 | |||
599 | sysfs_temp(1); | ||
600 | sysfs_temp(2); | ||
601 | sysfs_temp(3); | ||
602 | |||
603 | static ssize_t show_alarms_in(struct device *dev, struct device_attribute | 559 | static ssize_t show_alarms_in(struct device *dev, struct device_attribute |
604 | *devattr, char *buf) | 560 | *devattr, char *buf) |
605 | { | 561 | { |
@@ -625,10 +581,6 @@ static ssize_t show_alarms_temp(struct device *dev, struct device_attribute | |||
625 | return sprintf(buf, "%d\n", (data->alarms[1] >> 3) & 0x07); | 581 | return sprintf(buf, "%d\n", (data->alarms[1] >> 3) & 0x07); |
626 | } | 582 | } |
627 | 583 | ||
628 | static DEVICE_ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL); | ||
629 | static DEVICE_ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL); | ||
630 | static DEVICE_ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL); | ||
631 | |||
632 | static ssize_t show_name(struct device *dev, struct device_attribute | 584 | static ssize_t show_name(struct device *dev, struct device_attribute |
633 | *devattr, char *buf) | 585 | *devattr, char *buf) |
634 | { | 586 | { |
@@ -637,7 +589,89 @@ static ssize_t show_name(struct device *dev, struct device_attribute | |||
637 | return sprintf(buf, "%s\n", data->name); | 589 | return sprintf(buf, "%s\n", data->name); |
638 | } | 590 | } |
639 | 591 | ||
640 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | 592 | static struct device_attribute f71805f_dev_attr[] = { |
593 | __ATTR(in0_input, S_IRUGO, show_in0, NULL), | ||
594 | __ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max), | ||
595 | __ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min), | ||
596 | __ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL), | ||
597 | __ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL), | ||
598 | __ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL), | ||
599 | __ATTR(name, S_IRUGO, show_name, NULL), | ||
600 | }; | ||
601 | |||
602 | static struct sensor_device_attribute f71805f_sensor_attr[] = { | ||
603 | SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1), | ||
604 | SENSOR_ATTR(in1_max, S_IRUGO | S_IWUSR, | ||
605 | show_in_max, set_in_max, 1), | ||
606 | SENSOR_ATTR(in1_min, S_IRUGO | S_IWUSR, | ||
607 | show_in_min, set_in_min, 1), | ||
608 | SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2), | ||
609 | SENSOR_ATTR(in2_max, S_IRUGO | S_IWUSR, | ||
610 | show_in_max, set_in_max, 2), | ||
611 | SENSOR_ATTR(in2_min, S_IRUGO | S_IWUSR, | ||
612 | show_in_min, set_in_min, 2), | ||
613 | SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3), | ||
614 | SENSOR_ATTR(in3_max, S_IRUGO | S_IWUSR, | ||
615 | show_in_max, set_in_max, 3), | ||
616 | SENSOR_ATTR(in3_min, S_IRUGO | S_IWUSR, | ||
617 | show_in_min, set_in_min, 3), | ||
618 | SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4), | ||
619 | SENSOR_ATTR(in4_max, S_IRUGO | S_IWUSR, | ||
620 | show_in_max, set_in_max, 4), | ||
621 | SENSOR_ATTR(in4_min, S_IRUGO | S_IWUSR, | ||
622 | show_in_min, set_in_min, 4), | ||
623 | SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5), | ||
624 | SENSOR_ATTR(in5_max, S_IRUGO | S_IWUSR, | ||
625 | show_in_max, set_in_max, 5), | ||
626 | SENSOR_ATTR(in5_min, S_IRUGO | S_IWUSR, | ||
627 | show_in_min, set_in_min, 5), | ||
628 | SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6), | ||
629 | SENSOR_ATTR(in6_max, S_IRUGO | S_IWUSR, | ||
630 | show_in_max, set_in_max, 6), | ||
631 | SENSOR_ATTR(in6_min, S_IRUGO | S_IWUSR, | ||
632 | show_in_min, set_in_min, 6), | ||
633 | SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7), | ||
634 | SENSOR_ATTR(in7_max, S_IRUGO | S_IWUSR, | ||
635 | show_in_max, set_in_max, 7), | ||
636 | SENSOR_ATTR(in7_min, S_IRUGO | S_IWUSR, | ||
637 | show_in_min, set_in_min, 7), | ||
638 | SENSOR_ATTR(in8_input, S_IRUGO, show_in, NULL, 8), | ||
639 | SENSOR_ATTR(in8_max, S_IRUGO | S_IWUSR, | ||
640 | show_in_max, set_in_max, 8), | ||
641 | SENSOR_ATTR(in8_min, S_IRUGO | S_IWUSR, | ||
642 | show_in_min, set_in_min, 8), | ||
643 | |||
644 | SENSOR_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0), | ||
645 | SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, | ||
646 | show_temp_max, set_temp_max, 0), | ||
647 | SENSOR_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, | ||
648 | show_temp_hyst, set_temp_hyst, 0), | ||
649 | SENSOR_ATTR(temp1_type, S_IRUGO, show_temp_type, NULL, 0), | ||
650 | SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1), | ||
651 | SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, | ||
652 | show_temp_max, set_temp_max, 1), | ||
653 | SENSOR_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR, | ||
654 | show_temp_hyst, set_temp_hyst, 1), | ||
655 | SENSOR_ATTR(temp2_type, S_IRUGO, show_temp_type, NULL, 1), | ||
656 | SENSOR_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2), | ||
657 | SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, | ||
658 | show_temp_max, set_temp_max, 2), | ||
659 | SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, | ||
660 | show_temp_hyst, set_temp_hyst, 2), | ||
661 | SENSOR_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2), | ||
662 | }; | ||
663 | |||
664 | static struct sensor_device_attribute f71805f_fan_attr[] = { | ||
665 | SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0), | ||
666 | SENSOR_ATTR(fan1_min, S_IRUGO | S_IWUSR, | ||
667 | show_fan_min, set_fan_min, 0), | ||
668 | SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1), | ||
669 | SENSOR_ATTR(fan2_min, S_IRUGO | S_IWUSR, | ||
670 | show_fan_min, set_fan_min, 1), | ||
671 | SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2), | ||
672 | SENSOR_ATTR(fan3_min, S_IRUGO | S_IWUSR, | ||
673 | show_fan_min, set_fan_min, 2), | ||
674 | }; | ||
641 | 675 | ||
642 | /* | 676 | /* |
643 | * Device registration and initialization | 677 | * Device registration and initialization |
@@ -668,7 +702,7 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
668 | { | 702 | { |
669 | struct f71805f_data *data; | 703 | struct f71805f_data *data; |
670 | struct resource *res; | 704 | struct resource *res; |
671 | int err; | 705 | int i, err; |
672 | 706 | ||
673 | if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) { | 707 | if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) { |
674 | err = -ENOMEM; | 708 | err = -ENOMEM; |
@@ -678,9 +712,9 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
678 | 712 | ||
679 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 713 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
680 | data->addr = res->start; | 714 | data->addr = res->start; |
681 | init_MUTEX(&data->lock); | 715 | mutex_init(&data->lock); |
682 | data->name = "f71805f"; | 716 | data->name = "f71805f"; |
683 | init_MUTEX(&data->update_lock); | 717 | mutex_init(&data->update_lock); |
684 | 718 | ||
685 | platform_set_drvdata(pdev, data); | 719 | platform_set_drvdata(pdev, data); |
686 | 720 | ||
@@ -695,76 +729,31 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
695 | f71805f_init_device(data); | 729 | f71805f_init_device(data); |
696 | 730 | ||
697 | /* Register sysfs interface files */ | 731 | /* Register sysfs interface files */ |
698 | device_create_file(&pdev->dev, &dev_attr_in0_input); | 732 | for (i = 0; i < ARRAY_SIZE(f71805f_dev_attr); i++) { |
699 | device_create_file(&pdev->dev, &dev_attr_in0_max); | 733 | err = device_create_file(&pdev->dev, &f71805f_dev_attr[i]); |
700 | device_create_file(&pdev->dev, &dev_attr_in0_min); | 734 | if (err) |
701 | device_create_file(&pdev->dev, &sensor_dev_attr_in1_input.dev_attr); | 735 | goto exit_class; |
702 | device_create_file(&pdev->dev, &sensor_dev_attr_in2_input.dev_attr); | ||
703 | device_create_file(&pdev->dev, &sensor_dev_attr_in3_input.dev_attr); | ||
704 | device_create_file(&pdev->dev, &sensor_dev_attr_in4_input.dev_attr); | ||
705 | device_create_file(&pdev->dev, &sensor_dev_attr_in5_input.dev_attr); | ||
706 | device_create_file(&pdev->dev, &sensor_dev_attr_in6_input.dev_attr); | ||
707 | device_create_file(&pdev->dev, &sensor_dev_attr_in7_input.dev_attr); | ||
708 | device_create_file(&pdev->dev, &sensor_dev_attr_in8_input.dev_attr); | ||
709 | device_create_file(&pdev->dev, &sensor_dev_attr_in1_max.dev_attr); | ||
710 | device_create_file(&pdev->dev, &sensor_dev_attr_in2_max.dev_attr); | ||
711 | device_create_file(&pdev->dev, &sensor_dev_attr_in3_max.dev_attr); | ||
712 | device_create_file(&pdev->dev, &sensor_dev_attr_in4_max.dev_attr); | ||
713 | device_create_file(&pdev->dev, &sensor_dev_attr_in5_max.dev_attr); | ||
714 | device_create_file(&pdev->dev, &sensor_dev_attr_in6_max.dev_attr); | ||
715 | device_create_file(&pdev->dev, &sensor_dev_attr_in7_max.dev_attr); | ||
716 | device_create_file(&pdev->dev, &sensor_dev_attr_in8_max.dev_attr); | ||
717 | device_create_file(&pdev->dev, &sensor_dev_attr_in1_min.dev_attr); | ||
718 | device_create_file(&pdev->dev, &sensor_dev_attr_in2_min.dev_attr); | ||
719 | device_create_file(&pdev->dev, &sensor_dev_attr_in3_min.dev_attr); | ||
720 | device_create_file(&pdev->dev, &sensor_dev_attr_in4_min.dev_attr); | ||
721 | device_create_file(&pdev->dev, &sensor_dev_attr_in5_min.dev_attr); | ||
722 | device_create_file(&pdev->dev, &sensor_dev_attr_in6_min.dev_attr); | ||
723 | device_create_file(&pdev->dev, &sensor_dev_attr_in7_min.dev_attr); | ||
724 | device_create_file(&pdev->dev, &sensor_dev_attr_in8_min.dev_attr); | ||
725 | if (data->fan_enabled & (1 << 0)) { | ||
726 | device_create_file(&pdev->dev, | ||
727 | &sensor_dev_attr_fan1_input.dev_attr); | ||
728 | device_create_file(&pdev->dev, | ||
729 | &sensor_dev_attr_fan1_min.dev_attr); | ||
730 | } | 736 | } |
731 | if (data->fan_enabled & (1 << 1)) { | 737 | for (i = 0; i < ARRAY_SIZE(f71805f_sensor_attr); i++) { |
732 | device_create_file(&pdev->dev, | 738 | err = device_create_file(&pdev->dev, |
733 | &sensor_dev_attr_fan2_input.dev_attr); | 739 | &f71805f_sensor_attr[i].dev_attr); |
734 | device_create_file(&pdev->dev, | 740 | if (err) |
735 | &sensor_dev_attr_fan2_min.dev_attr); | 741 | goto exit_class; |
736 | } | 742 | } |
737 | if (data->fan_enabled & (1 << 2)) { | 743 | for (i = 0; i < ARRAY_SIZE(f71805f_fan_attr); i++) { |
738 | device_create_file(&pdev->dev, | 744 | if (!(data->fan_enabled & (1 << (i / 2)))) |
739 | &sensor_dev_attr_fan3_input.dev_attr); | 745 | continue; |
740 | device_create_file(&pdev->dev, | 746 | err = device_create_file(&pdev->dev, |
741 | &sensor_dev_attr_fan3_min.dev_attr); | 747 | &f71805f_fan_attr[i].dev_attr); |
748 | if (err) | ||
749 | goto exit_class; | ||
742 | } | 750 | } |
743 | device_create_file(&pdev->dev, | ||
744 | &sensor_dev_attr_temp1_input.dev_attr); | ||
745 | device_create_file(&pdev->dev, | ||
746 | &sensor_dev_attr_temp2_input.dev_attr); | ||
747 | device_create_file(&pdev->dev, | ||
748 | &sensor_dev_attr_temp3_input.dev_attr); | ||
749 | device_create_file(&pdev->dev, &sensor_dev_attr_temp1_max.dev_attr); | ||
750 | device_create_file(&pdev->dev, &sensor_dev_attr_temp2_max.dev_attr); | ||
751 | device_create_file(&pdev->dev, &sensor_dev_attr_temp3_max.dev_attr); | ||
752 | device_create_file(&pdev->dev, | ||
753 | &sensor_dev_attr_temp1_max_hyst.dev_attr); | ||
754 | device_create_file(&pdev->dev, | ||
755 | &sensor_dev_attr_temp2_max_hyst.dev_attr); | ||
756 | device_create_file(&pdev->dev, | ||
757 | &sensor_dev_attr_temp3_max_hyst.dev_attr); | ||
758 | device_create_file(&pdev->dev, &sensor_dev_attr_temp1_type.dev_attr); | ||
759 | device_create_file(&pdev->dev, &sensor_dev_attr_temp2_type.dev_attr); | ||
760 | device_create_file(&pdev->dev, &sensor_dev_attr_temp3_type.dev_attr); | ||
761 | device_create_file(&pdev->dev, &dev_attr_alarms_in); | ||
762 | device_create_file(&pdev->dev, &dev_attr_alarms_fan); | ||
763 | device_create_file(&pdev->dev, &dev_attr_alarms_temp); | ||
764 | device_create_file(&pdev->dev, &dev_attr_name); | ||
765 | 751 | ||
766 | return 0; | 752 | return 0; |
767 | 753 | ||
754 | exit_class: | ||
755 | dev_err(&pdev->dev, "Sysfs interface creation failed\n"); | ||
756 | hwmon_device_unregister(data->class_dev); | ||
768 | exit_free: | 757 | exit_free: |
769 | kfree(data); | 758 | kfree(data); |
770 | exit: | 759 | exit: |
diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index 25409181d1eb..6bc76b407636 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
34 | #include <linux/hwmon.h> | 34 | #include <linux/hwmon.h> |
35 | #include <linux/err.h> | 35 | #include <linux/err.h> |
36 | #include <linux/mutex.h> | ||
36 | 37 | ||
37 | /* | 38 | /* |
38 | * Addresses to scan | 39 | * Addresses to scan |
@@ -133,7 +134,7 @@ static struct i2c_driver fscher_driver = { | |||
133 | struct fscher_data { | 134 | struct fscher_data { |
134 | struct i2c_client client; | 135 | struct i2c_client client; |
135 | struct class_device *class_dev; | 136 | struct class_device *class_dev; |
136 | struct semaphore update_lock; | 137 | struct mutex update_lock; |
137 | char valid; /* zero until following fields are valid */ | 138 | char valid; /* zero until following fields are valid */ |
138 | unsigned long last_updated; /* in jiffies */ | 139 | unsigned long last_updated; /* in jiffies */ |
139 | 140 | ||
@@ -332,7 +333,7 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind) | |||
332 | * global list */ | 333 | * global list */ |
333 | strlcpy(new_client->name, "fscher", I2C_NAME_SIZE); | 334 | strlcpy(new_client->name, "fscher", I2C_NAME_SIZE); |
334 | data->valid = 0; | 335 | data->valid = 0; |
335 | init_MUTEX(&data->update_lock); | 336 | mutex_init(&data->update_lock); |
336 | 337 | ||
337 | /* Tell the I2C layer a new client has arrived */ | 338 | /* Tell the I2C layer a new client has arrived */ |
338 | if ((err = i2c_attach_client(new_client))) | 339 | if ((err = i2c_attach_client(new_client))) |
@@ -417,7 +418,7 @@ static struct fscher_data *fscher_update_device(struct device *dev) | |||
417 | struct i2c_client *client = to_i2c_client(dev); | 418 | struct i2c_client *client = to_i2c_client(dev); |
418 | struct fscher_data *data = i2c_get_clientdata(client); | 419 | struct fscher_data *data = i2c_get_clientdata(client); |
419 | 420 | ||
420 | down(&data->update_lock); | 421 | mutex_lock(&data->update_lock); |
421 | 422 | ||
422 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { | 423 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { |
423 | 424 | ||
@@ -457,7 +458,7 @@ static struct fscher_data *fscher_update_device(struct device *dev) | |||
457 | data->valid = 1; | 458 | data->valid = 1; |
458 | } | 459 | } |
459 | 460 | ||
460 | up(&data->update_lock); | 461 | mutex_unlock(&data->update_lock); |
461 | 462 | ||
462 | return data; | 463 | return data; |
463 | } | 464 | } |
@@ -472,10 +473,10 @@ static ssize_t set_fan_status(struct i2c_client *client, struct fscher_data *dat | |||
472 | /* bits 0..1, 3..7 reserved => mask with 0x04 */ | 473 | /* bits 0..1, 3..7 reserved => mask with 0x04 */ |
473 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x04; | 474 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x04; |
474 | 475 | ||
475 | down(&data->update_lock); | 476 | mutex_lock(&data->update_lock); |
476 | data->fan_status[FAN_INDEX_FROM_NUM(nr)] &= ~v; | 477 | data->fan_status[FAN_INDEX_FROM_NUM(nr)] &= ~v; |
477 | fscher_write_value(client, reg, v); | 478 | fscher_write_value(client, reg, v); |
478 | up(&data->update_lock); | 479 | mutex_unlock(&data->update_lock); |
479 | return count; | 480 | return count; |
480 | } | 481 | } |
481 | 482 | ||
@@ -490,10 +491,10 @@ static ssize_t set_pwm(struct i2c_client *client, struct fscher_data *data, | |||
490 | { | 491 | { |
491 | unsigned long v = simple_strtoul(buf, NULL, 10); | 492 | unsigned long v = simple_strtoul(buf, NULL, 10); |
492 | 493 | ||
493 | down(&data->update_lock); | 494 | mutex_lock(&data->update_lock); |
494 | data->fan_min[FAN_INDEX_FROM_NUM(nr)] = v > 0xff ? 0xff : v; | 495 | data->fan_min[FAN_INDEX_FROM_NUM(nr)] = v > 0xff ? 0xff : v; |
495 | fscher_write_value(client, reg, data->fan_min[FAN_INDEX_FROM_NUM(nr)]); | 496 | fscher_write_value(client, reg, data->fan_min[FAN_INDEX_FROM_NUM(nr)]); |
496 | up(&data->update_lock); | 497 | mutex_unlock(&data->update_lock); |
497 | return count; | 498 | return count; |
498 | } | 499 | } |
499 | 500 | ||
@@ -518,14 +519,14 @@ static ssize_t set_fan_div(struct i2c_client *client, struct fscher_data *data, | |||
518 | return -EINVAL; | 519 | return -EINVAL; |
519 | } | 520 | } |
520 | 521 | ||
521 | down(&data->update_lock); | 522 | mutex_lock(&data->update_lock); |
522 | 523 | ||
523 | /* bits 2..7 reserved => mask with 0x03 */ | 524 | /* bits 2..7 reserved => mask with 0x03 */ |
524 | data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] &= ~0x03; | 525 | data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] &= ~0x03; |
525 | data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] |= v; | 526 | data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] |= v; |
526 | 527 | ||
527 | fscher_write_value(client, reg, data->fan_ripple[FAN_INDEX_FROM_NUM(nr)]); | 528 | fscher_write_value(client, reg, data->fan_ripple[FAN_INDEX_FROM_NUM(nr)]); |
528 | up(&data->update_lock); | 529 | mutex_unlock(&data->update_lock); |
529 | return count; | 530 | return count; |
530 | } | 531 | } |
531 | 532 | ||
@@ -552,10 +553,10 @@ static ssize_t set_temp_status(struct i2c_client *client, struct fscher_data *da | |||
552 | /* bits 2..7 reserved, 0 read only => mask with 0x02 */ | 553 | /* bits 2..7 reserved, 0 read only => mask with 0x02 */ |
553 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02; | 554 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02; |
554 | 555 | ||
555 | down(&data->update_lock); | 556 | mutex_lock(&data->update_lock); |
556 | data->temp_status[TEMP_INDEX_FROM_NUM(nr)] &= ~v; | 557 | data->temp_status[TEMP_INDEX_FROM_NUM(nr)] &= ~v; |
557 | fscher_write_value(client, reg, v); | 558 | fscher_write_value(client, reg, v); |
558 | up(&data->update_lock); | 559 | mutex_unlock(&data->update_lock); |
559 | return count; | 560 | return count; |
560 | } | 561 | } |
561 | 562 | ||
@@ -609,10 +610,10 @@ static ssize_t set_control(struct i2c_client *client, struct fscher_data *data, | |||
609 | /* bits 1..7 reserved => mask with 0x01 */ | 610 | /* bits 1..7 reserved => mask with 0x01 */ |
610 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x01; | 611 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x01; |
611 | 612 | ||
612 | down(&data->update_lock); | 613 | mutex_lock(&data->update_lock); |
613 | data->global_control &= ~v; | 614 | data->global_control &= ~v; |
614 | fscher_write_value(client, reg, v); | 615 | fscher_write_value(client, reg, v); |
615 | up(&data->update_lock); | 616 | mutex_unlock(&data->update_lock); |
616 | return count; | 617 | return count; |
617 | } | 618 | } |
618 | 619 | ||
@@ -631,11 +632,11 @@ static ssize_t set_watchdog_control(struct i2c_client *client, struct | |||
631 | /* bits 0..3 reserved => mask with 0xf0 */ | 632 | /* bits 0..3 reserved => mask with 0xf0 */ |
632 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0; | 633 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0; |
633 | 634 | ||
634 | down(&data->update_lock); | 635 | mutex_lock(&data->update_lock); |
635 | data->watchdog[2] &= ~0xf0; | 636 | data->watchdog[2] &= ~0xf0; |
636 | data->watchdog[2] |= v; | 637 | data->watchdog[2] |= v; |
637 | fscher_write_value(client, reg, data->watchdog[2]); | 638 | fscher_write_value(client, reg, data->watchdog[2]); |
638 | up(&data->update_lock); | 639 | mutex_unlock(&data->update_lock); |
639 | return count; | 640 | return count; |
640 | } | 641 | } |
641 | 642 | ||
@@ -651,10 +652,10 @@ static ssize_t set_watchdog_status(struct i2c_client *client, struct fscher_data | |||
651 | /* bits 0, 2..7 reserved => mask with 0x02 */ | 652 | /* bits 0, 2..7 reserved => mask with 0x02 */ |
652 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02; | 653 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02; |
653 | 654 | ||
654 | down(&data->update_lock); | 655 | mutex_lock(&data->update_lock); |
655 | data->watchdog[1] &= ~v; | 656 | data->watchdog[1] &= ~v; |
656 | fscher_write_value(client, reg, v); | 657 | fscher_write_value(client, reg, v); |
657 | up(&data->update_lock); | 658 | mutex_unlock(&data->update_lock); |
658 | return count; | 659 | return count; |
659 | } | 660 | } |
660 | 661 | ||
@@ -669,10 +670,10 @@ static ssize_t set_watchdog_preset(struct i2c_client *client, struct fscher_data | |||
669 | { | 670 | { |
670 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff; | 671 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff; |
671 | 672 | ||
672 | down(&data->update_lock); | 673 | mutex_lock(&data->update_lock); |
673 | data->watchdog[0] = v; | 674 | data->watchdog[0] = v; |
674 | fscher_write_value(client, reg, data->watchdog[0]); | 675 | fscher_write_value(client, reg, data->watchdog[0]); |
675 | up(&data->update_lock); | 676 | mutex_unlock(&data->update_lock); |
676 | return count; | 677 | return count; |
677 | } | 678 | } |
678 | 679 | ||
diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index 6d0146b57020..6dc4846b9eeb 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/hwmon.h> | 38 | #include <linux/hwmon.h> |
39 | #include <linux/err.h> | 39 | #include <linux/err.h> |
40 | #include <linux/mutex.h> | ||
40 | 41 | ||
41 | /* | 42 | /* |
42 | * Addresses to scan | 43 | * Addresses to scan |
@@ -89,8 +90,8 @@ static int fscpos_attach_adapter(struct i2c_adapter *adapter); | |||
89 | static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind); | 90 | static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind); |
90 | static int fscpos_detach_client(struct i2c_client *client); | 91 | static int fscpos_detach_client(struct i2c_client *client); |
91 | 92 | ||
92 | static int fscpos_read_value(struct i2c_client *client, u8 register); | 93 | static int fscpos_read_value(struct i2c_client *client, u8 reg); |
93 | static int fscpos_write_value(struct i2c_client *client, u8 register, u8 value); | 94 | static int fscpos_write_value(struct i2c_client *client, u8 reg, u8 value); |
94 | static struct fscpos_data *fscpos_update_device(struct device *dev); | 95 | static struct fscpos_data *fscpos_update_device(struct device *dev); |
95 | static void fscpos_init_client(struct i2c_client *client); | 96 | static void fscpos_init_client(struct i2c_client *client); |
96 | 97 | ||
@@ -114,7 +115,7 @@ static struct i2c_driver fscpos_driver = { | |||
114 | struct fscpos_data { | 115 | struct fscpos_data { |
115 | struct i2c_client client; | 116 | struct i2c_client client; |
116 | struct class_device *class_dev; | 117 | struct class_device *class_dev; |
117 | struct semaphore update_lock; | 118 | struct mutex update_lock; |
118 | char valid; /* 0 until following fields are valid */ | 119 | char valid; /* 0 until following fields are valid */ |
119 | unsigned long last_updated; /* In jiffies */ | 120 | unsigned long last_updated; /* In jiffies */ |
120 | 121 | ||
@@ -208,13 +209,13 @@ static ssize_t set_fan_ripple(struct i2c_client *client, struct fscpos_data | |||
208 | return -EINVAL; | 209 | return -EINVAL; |
209 | } | 210 | } |
210 | 211 | ||
211 | down(&data->update_lock); | 212 | mutex_lock(&data->update_lock); |
212 | /* bits 2..7 reserved => mask with 0x03 */ | 213 | /* bits 2..7 reserved => mask with 0x03 */ |
213 | data->fan_ripple[nr - 1] &= ~0x03; | 214 | data->fan_ripple[nr - 1] &= ~0x03; |
214 | data->fan_ripple[nr - 1] |= v; | 215 | data->fan_ripple[nr - 1] |= v; |
215 | 216 | ||
216 | fscpos_write_value(client, reg, data->fan_ripple[nr - 1]); | 217 | fscpos_write_value(client, reg, data->fan_ripple[nr - 1]); |
217 | up(&data->update_lock); | 218 | mutex_unlock(&data->update_lock); |
218 | return count; | 219 | return count; |
219 | } | 220 | } |
220 | 221 | ||
@@ -232,10 +233,10 @@ static ssize_t set_pwm(struct i2c_client *client, struct fscpos_data *data, | |||
232 | if (v < 0) v = 0; | 233 | if (v < 0) v = 0; |
233 | if (v > 255) v = 255; | 234 | if (v > 255) v = 255; |
234 | 235 | ||
235 | down(&data->update_lock); | 236 | mutex_lock(&data->update_lock); |
236 | data->pwm[nr - 1] = v; | 237 | data->pwm[nr - 1] = v; |
237 | fscpos_write_value(client, reg, data->pwm[nr - 1]); | 238 | fscpos_write_value(client, reg, data->pwm[nr - 1]); |
238 | up(&data->update_lock); | 239 | mutex_unlock(&data->update_lock); |
239 | return count; | 240 | return count; |
240 | } | 241 | } |
241 | 242 | ||
@@ -278,11 +279,11 @@ static ssize_t set_wdog_control(struct i2c_client *client, struct fscpos_data | |||
278 | /* bits 0..3 reserved => mask with 0xf0 */ | 279 | /* bits 0..3 reserved => mask with 0xf0 */ |
279 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0; | 280 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0; |
280 | 281 | ||
281 | down(&data->update_lock); | 282 | mutex_lock(&data->update_lock); |
282 | data->wdog_control &= ~0xf0; | 283 | data->wdog_control &= ~0xf0; |
283 | data->wdog_control |= v; | 284 | data->wdog_control |= v; |
284 | fscpos_write_value(client, reg, data->wdog_control); | 285 | fscpos_write_value(client, reg, data->wdog_control); |
285 | up(&data->update_lock); | 286 | mutex_unlock(&data->update_lock); |
286 | return count; | 287 | return count; |
287 | } | 288 | } |
288 | 289 | ||
@@ -304,10 +305,10 @@ static ssize_t set_wdog_state(struct i2c_client *client, struct fscpos_data | |||
304 | return -EINVAL; | 305 | return -EINVAL; |
305 | } | 306 | } |
306 | 307 | ||
307 | down(&data->update_lock); | 308 | mutex_lock(&data->update_lock); |
308 | data->wdog_state &= ~v; | 309 | data->wdog_state &= ~v; |
309 | fscpos_write_value(client, reg, v); | 310 | fscpos_write_value(client, reg, v); |
310 | up(&data->update_lock); | 311 | mutex_unlock(&data->update_lock); |
311 | return count; | 312 | return count; |
312 | } | 313 | } |
313 | 314 | ||
@@ -321,10 +322,10 @@ static ssize_t set_wdog_preset(struct i2c_client *client, struct fscpos_data | |||
321 | { | 322 | { |
322 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff; | 323 | unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff; |
323 | 324 | ||
324 | down(&data->update_lock); | 325 | mutex_lock(&data->update_lock); |
325 | data->wdog_preset = v; | 326 | data->wdog_preset = v; |
326 | fscpos_write_value(client, reg, data->wdog_preset); | 327 | fscpos_write_value(client, reg, data->wdog_preset); |
327 | up(&data->update_lock); | 328 | mutex_unlock(&data->update_lock); |
328 | return count; | 329 | return count; |
329 | } | 330 | } |
330 | 331 | ||
@@ -483,7 +484,7 @@ static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) | |||
483 | strlcpy(new_client->name, "fscpos", I2C_NAME_SIZE); | 484 | strlcpy(new_client->name, "fscpos", I2C_NAME_SIZE); |
484 | 485 | ||
485 | data->valid = 0; | 486 | data->valid = 0; |
486 | init_MUTEX(&data->update_lock); | 487 | mutex_init(&data->update_lock); |
487 | 488 | ||
488 | /* Tell the I2C layer a new client has arrived */ | 489 | /* Tell the I2C layer a new client has arrived */ |
489 | if ((err = i2c_attach_client(new_client))) | 490 | if ((err = i2c_attach_client(new_client))) |
@@ -579,7 +580,7 @@ static struct fscpos_data *fscpos_update_device(struct device *dev) | |||
579 | struct i2c_client *client = to_i2c_client(dev); | 580 | struct i2c_client *client = to_i2c_client(dev); |
580 | struct fscpos_data *data = i2c_get_clientdata(client); | 581 | struct fscpos_data *data = i2c_get_clientdata(client); |
581 | 582 | ||
582 | down(&data->update_lock); | 583 | mutex_lock(&data->update_lock); |
583 | 584 | ||
584 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { | 585 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { |
585 | int i; | 586 | int i; |
@@ -625,7 +626,7 @@ static struct fscpos_data *fscpos_update_device(struct device *dev) | |||
625 | data->last_updated = jiffies; | 626 | data->last_updated = jiffies; |
626 | data->valid = 1; | 627 | data->valid = 1; |
627 | } | 628 | } |
628 | up(&data->update_lock); | 629 | mutex_unlock(&data->update_lock); |
629 | return data; | 630 | return data; |
630 | } | 631 | } |
631 | 632 | ||
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 9e685e3a3bc9..6606aabdb49d 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #include <linux/i2c.h> | 43 | #include <linux/i2c.h> |
44 | #include <linux/hwmon.h> | 44 | #include <linux/hwmon.h> |
45 | #include <linux/err.h> | 45 | #include <linux/err.h> |
46 | #include <linux/mutex.h> | ||
46 | 47 | ||
47 | /* Addresses to scan */ | 48 | /* Addresses to scan */ |
48 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; | 49 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; |
@@ -120,7 +121,7 @@ struct gl518_data { | |||
120 | struct class_device *class_dev; | 121 | struct class_device *class_dev; |
121 | enum chips type; | 122 | enum chips type; |
122 | 123 | ||
123 | struct semaphore update_lock; | 124 | struct mutex update_lock; |
124 | char valid; /* !=0 if following fields are valid */ | 125 | char valid; /* !=0 if following fields are valid */ |
125 | unsigned long last_updated; /* In jiffies */ | 126 | unsigned long last_updated; /* In jiffies */ |
126 | 127 | ||
@@ -212,10 +213,10 @@ static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, c | |||
212 | struct gl518_data *data = i2c_get_clientdata(client); \ | 213 | struct gl518_data *data = i2c_get_clientdata(client); \ |
213 | long val = simple_strtol(buf, NULL, 10); \ | 214 | long val = simple_strtol(buf, NULL, 10); \ |
214 | \ | 215 | \ |
215 | down(&data->update_lock); \ | 216 | mutex_lock(&data->update_lock); \ |
216 | data->value = type##_TO_REG(val); \ | 217 | data->value = type##_TO_REG(val); \ |
217 | gl518_write_value(client, reg, data->value); \ | 218 | gl518_write_value(client, reg, data->value); \ |
218 | up(&data->update_lock); \ | 219 | mutex_unlock(&data->update_lock); \ |
219 | return count; \ | 220 | return count; \ |
220 | } | 221 | } |
221 | 222 | ||
@@ -228,12 +229,12 @@ static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, c | |||
228 | int regvalue; \ | 229 | int regvalue; \ |
229 | unsigned long val = simple_strtoul(buf, NULL, 10); \ | 230 | unsigned long val = simple_strtoul(buf, NULL, 10); \ |
230 | \ | 231 | \ |
231 | down(&data->update_lock); \ | 232 | mutex_lock(&data->update_lock); \ |
232 | regvalue = gl518_read_value(client, reg); \ | 233 | regvalue = gl518_read_value(client, reg); \ |
233 | data->value = type##_TO_REG(val); \ | 234 | data->value = type##_TO_REG(val); \ |
234 | regvalue = (regvalue & ~mask) | (data->value << shift); \ | 235 | regvalue = (regvalue & ~mask) | (data->value << shift); \ |
235 | gl518_write_value(client, reg, regvalue); \ | 236 | gl518_write_value(client, reg, regvalue); \ |
236 | up(&data->update_lock); \ | 237 | mutex_unlock(&data->update_lock); \ |
237 | return count; \ | 238 | return count; \ |
238 | } | 239 | } |
239 | 240 | ||
@@ -265,7 +266,7 @@ static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, c | |||
265 | int regvalue; | 266 | int regvalue; |
266 | unsigned long val = simple_strtoul(buf, NULL, 10); | 267 | unsigned long val = simple_strtoul(buf, NULL, 10); |
267 | 268 | ||
268 | down(&data->update_lock); | 269 | mutex_lock(&data->update_lock); |
269 | regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); | 270 | regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); |
270 | data->fan_min[0] = FAN_TO_REG(val, | 271 | data->fan_min[0] = FAN_TO_REG(val, |
271 | DIV_FROM_REG(data->fan_div[0])); | 272 | DIV_FROM_REG(data->fan_div[0])); |
@@ -280,7 +281,7 @@ static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, c | |||
280 | data->beep_mask &= data->alarm_mask; | 281 | data->beep_mask &= data->alarm_mask; |
281 | gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); | 282 | gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); |
282 | 283 | ||
283 | up(&data->update_lock); | 284 | mutex_unlock(&data->update_lock); |
284 | return count; | 285 | return count; |
285 | } | 286 | } |
286 | 287 | ||
@@ -291,7 +292,7 @@ static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, c | |||
291 | int regvalue; | 292 | int regvalue; |
292 | unsigned long val = simple_strtoul(buf, NULL, 10); | 293 | unsigned long val = simple_strtoul(buf, NULL, 10); |
293 | 294 | ||
294 | down(&data->update_lock); | 295 | mutex_lock(&data->update_lock); |
295 | regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); | 296 | regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); |
296 | data->fan_min[1] = FAN_TO_REG(val, | 297 | data->fan_min[1] = FAN_TO_REG(val, |
297 | DIV_FROM_REG(data->fan_div[1])); | 298 | DIV_FROM_REG(data->fan_div[1])); |
@@ -306,7 +307,7 @@ static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, c | |||
306 | data->beep_mask &= data->alarm_mask; | 307 | data->beep_mask &= data->alarm_mask; |
307 | gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); | 308 | gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); |
308 | 309 | ||
309 | up(&data->update_lock); | 310 | mutex_unlock(&data->update_lock); |
310 | return count; | 311 | return count; |
311 | } | 312 | } |
312 | 313 | ||
@@ -407,7 +408,7 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) | |||
407 | strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE); | 408 | strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE); |
408 | data->type = kind; | 409 | data->type = kind; |
409 | data->valid = 0; | 410 | data->valid = 0; |
410 | init_MUTEX(&data->update_lock); | 411 | mutex_init(&data->update_lock); |
411 | 412 | ||
412 | /* Tell the I2C layer a new client has arrived */ | 413 | /* Tell the I2C layer a new client has arrived */ |
413 | if ((err = i2c_attach_client(new_client))) | 414 | if ((err = i2c_attach_client(new_client))) |
@@ -525,7 +526,7 @@ static struct gl518_data *gl518_update_device(struct device *dev) | |||
525 | struct gl518_data *data = i2c_get_clientdata(client); | 526 | struct gl518_data *data = i2c_get_clientdata(client); |
526 | int val; | 527 | int val; |
527 | 528 | ||
528 | down(&data->update_lock); | 529 | mutex_lock(&data->update_lock); |
529 | 530 | ||
530 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 531 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
531 | || !data->valid) { | 532 | || !data->valid) { |
@@ -586,7 +587,7 @@ static struct gl518_data *gl518_update_device(struct device *dev) | |||
586 | data->valid = 1; | 587 | data->valid = 1; |
587 | } | 588 | } |
588 | 589 | ||
589 | up(&data->update_lock); | 590 | mutex_unlock(&data->update_lock); |
590 | 591 | ||
591 | return data; | 592 | return data; |
592 | } | 593 | } |
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index baee60e44b52..47b4d49f75c6 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/hwmon.h> | 29 | #include <linux/hwmon.h> |
30 | #include <linux/hwmon-vid.h> | 30 | #include <linux/hwmon-vid.h> |
31 | #include <linux/err.h> | 31 | #include <linux/err.h> |
32 | #include <linux/mutex.h> | ||
32 | 33 | ||
33 | /* Type of the extra sensor */ | 34 | /* Type of the extra sensor */ |
34 | static unsigned short extra_sensor_type; | 35 | static unsigned short extra_sensor_type; |
@@ -121,7 +122,7 @@ static struct i2c_driver gl520_driver = { | |||
121 | struct gl520_data { | 122 | struct gl520_data { |
122 | struct i2c_client client; | 123 | struct i2c_client client; |
123 | struct class_device *class_dev; | 124 | struct class_device *class_dev; |
124 | struct semaphore update_lock; | 125 | struct mutex update_lock; |
125 | char valid; /* zero until the following fields are valid */ | 126 | char valid; /* zero until the following fields are valid */ |
126 | unsigned long last_updated; /* in jiffies */ | 127 | unsigned long last_updated; /* in jiffies */ |
127 | 128 | ||
@@ -303,7 +304,7 @@ static ssize_t set_in_min(struct i2c_client *client, struct gl520_data *data, co | |||
303 | long v = simple_strtol(buf, NULL, 10); | 304 | long v = simple_strtol(buf, NULL, 10); |
304 | u8 r; | 305 | u8 r; |
305 | 306 | ||
306 | down(&data->update_lock); | 307 | mutex_lock(&data->update_lock); |
307 | 308 | ||
308 | if (n == 0) | 309 | if (n == 0) |
309 | r = VDD_TO_REG(v); | 310 | r = VDD_TO_REG(v); |
@@ -317,7 +318,7 @@ static ssize_t set_in_min(struct i2c_client *client, struct gl520_data *data, co | |||
317 | else | 318 | else |
318 | gl520_write_value(client, reg, r); | 319 | gl520_write_value(client, reg, r); |
319 | 320 | ||
320 | up(&data->update_lock); | 321 | mutex_unlock(&data->update_lock); |
321 | return count; | 322 | return count; |
322 | } | 323 | } |
323 | 324 | ||
@@ -331,7 +332,7 @@ static ssize_t set_in_max(struct i2c_client *client, struct gl520_data *data, co | |||
331 | else | 332 | else |
332 | r = IN_TO_REG(v); | 333 | r = IN_TO_REG(v); |
333 | 334 | ||
334 | down(&data->update_lock); | 335 | mutex_lock(&data->update_lock); |
335 | 336 | ||
336 | data->in_max[n] = r; | 337 | data->in_max[n] = r; |
337 | 338 | ||
@@ -340,7 +341,7 @@ static ssize_t set_in_max(struct i2c_client *client, struct gl520_data *data, co | |||
340 | else | 341 | else |
341 | gl520_write_value(client, reg, r); | 342 | gl520_write_value(client, reg, r); |
342 | 343 | ||
343 | up(&data->update_lock); | 344 | mutex_unlock(&data->update_lock); |
344 | return count; | 345 | return count; |
345 | } | 346 | } |
346 | 347 | ||
@@ -373,7 +374,7 @@ static ssize_t set_fan_min(struct i2c_client *client, struct gl520_data *data, c | |||
373 | unsigned long v = simple_strtoul(buf, NULL, 10); | 374 | unsigned long v = simple_strtoul(buf, NULL, 10); |
374 | u8 r; | 375 | u8 r; |
375 | 376 | ||
376 | down(&data->update_lock); | 377 | mutex_lock(&data->update_lock); |
377 | r = FAN_TO_REG(v, data->fan_div[n - 1]); | 378 | r = FAN_TO_REG(v, data->fan_div[n - 1]); |
378 | data->fan_min[n - 1] = r; | 379 | data->fan_min[n - 1] = r; |
379 | 380 | ||
@@ -390,7 +391,7 @@ static ssize_t set_fan_min(struct i2c_client *client, struct gl520_data *data, c | |||
390 | data->beep_mask &= data->alarm_mask; | 391 | data->beep_mask &= data->alarm_mask; |
391 | gl520_write_value(client, GL520_REG_BEEP_MASK, data->beep_mask); | 392 | gl520_write_value(client, GL520_REG_BEEP_MASK, data->beep_mask); |
392 | 393 | ||
393 | up(&data->update_lock); | 394 | mutex_unlock(&data->update_lock); |
394 | return count; | 395 | return count; |
395 | } | 396 | } |
396 | 397 | ||
@@ -409,7 +410,7 @@ static ssize_t set_fan_div(struct i2c_client *client, struct gl520_data *data, c | |||
409 | return -EINVAL; | 410 | return -EINVAL; |
410 | } | 411 | } |
411 | 412 | ||
412 | down(&data->update_lock); | 413 | mutex_lock(&data->update_lock); |
413 | data->fan_div[n - 1] = r; | 414 | data->fan_div[n - 1] = r; |
414 | 415 | ||
415 | if (n == 1) | 416 | if (n == 1) |
@@ -417,7 +418,7 @@ static ssize_t set_fan_div(struct i2c_client *client, struct gl520_data *data, c | |||
417 | else | 418 | else |
418 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x30) | (r << 4)); | 419 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x30) | (r << 4)); |
419 | 420 | ||
420 | up(&data->update_lock); | 421 | mutex_unlock(&data->update_lock); |
421 | return count; | 422 | return count; |
422 | } | 423 | } |
423 | 424 | ||
@@ -425,10 +426,10 @@ static ssize_t set_fan_off(struct i2c_client *client, struct gl520_data *data, c | |||
425 | { | 426 | { |
426 | u8 r = simple_strtoul(buf, NULL, 10)?1:0; | 427 | u8 r = simple_strtoul(buf, NULL, 10)?1:0; |
427 | 428 | ||
428 | down(&data->update_lock); | 429 | mutex_lock(&data->update_lock); |
429 | data->fan_off = r; | 430 | data->fan_off = r; |
430 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x0c) | (r << 2)); | 431 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x0c) | (r << 2)); |
431 | up(&data->update_lock); | 432 | mutex_unlock(&data->update_lock); |
432 | return count; | 433 | return count; |
433 | } | 434 | } |
434 | 435 | ||
@@ -454,10 +455,10 @@ static ssize_t set_temp_max(struct i2c_client *client, struct gl520_data *data, | |||
454 | { | 455 | { |
455 | long v = simple_strtol(buf, NULL, 10); | 456 | long v = simple_strtol(buf, NULL, 10); |
456 | 457 | ||
457 | down(&data->update_lock); | 458 | mutex_lock(&data->update_lock); |
458 | data->temp_max[n - 1] = TEMP_TO_REG(v);; | 459 | data->temp_max[n - 1] = TEMP_TO_REG(v);; |
459 | gl520_write_value(client, reg, data->temp_max[n - 1]); | 460 | gl520_write_value(client, reg, data->temp_max[n - 1]); |
460 | up(&data->update_lock); | 461 | mutex_unlock(&data->update_lock); |
461 | return count; | 462 | return count; |
462 | } | 463 | } |
463 | 464 | ||
@@ -465,10 +466,10 @@ static ssize_t set_temp_max_hyst(struct i2c_client *client, struct gl520_data *d | |||
465 | { | 466 | { |
466 | long v = simple_strtol(buf, NULL, 10); | 467 | long v = simple_strtol(buf, NULL, 10); |
467 | 468 | ||
468 | down(&data->update_lock); | 469 | mutex_lock(&data->update_lock); |
469 | data->temp_max_hyst[n - 1] = TEMP_TO_REG(v); | 470 | data->temp_max_hyst[n - 1] = TEMP_TO_REG(v); |
470 | gl520_write_value(client, reg, data->temp_max_hyst[n - 1]); | 471 | gl520_write_value(client, reg, data->temp_max_hyst[n - 1]); |
471 | up(&data->update_lock); | 472 | mutex_unlock(&data->update_lock); |
472 | return count; | 473 | return count; |
473 | } | 474 | } |
474 | 475 | ||
@@ -491,10 +492,10 @@ static ssize_t set_beep_enable(struct i2c_client *client, struct gl520_data *dat | |||
491 | { | 492 | { |
492 | u8 r = simple_strtoul(buf, NULL, 10)?0:1; | 493 | u8 r = simple_strtoul(buf, NULL, 10)?0:1; |
493 | 494 | ||
494 | down(&data->update_lock); | 495 | mutex_lock(&data->update_lock); |
495 | data->beep_enable = !r; | 496 | data->beep_enable = !r; |
496 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x04) | (r << 2)); | 497 | gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x04) | (r << 2)); |
497 | up(&data->update_lock); | 498 | mutex_unlock(&data->update_lock); |
498 | return count; | 499 | return count; |
499 | } | 500 | } |
500 | 501 | ||
@@ -502,11 +503,11 @@ static ssize_t set_beep_mask(struct i2c_client *client, struct gl520_data *data, | |||
502 | { | 503 | { |
503 | u8 r = simple_strtoul(buf, NULL, 10); | 504 | u8 r = simple_strtoul(buf, NULL, 10); |
504 | 505 | ||
505 | down(&data->update_lock); | 506 | mutex_lock(&data->update_lock); |
506 | r &= data->alarm_mask; | 507 | r &= data->alarm_mask; |
507 | data->beep_mask = r; | 508 | data->beep_mask = r; |
508 | gl520_write_value(client, reg, r); | 509 | gl520_write_value(client, reg, r); |
509 | up(&data->update_lock); | 510 | mutex_unlock(&data->update_lock); |
510 | return count; | 511 | return count; |
511 | } | 512 | } |
512 | 513 | ||
@@ -561,7 +562,7 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) | |||
561 | /* Fill in the remaining client fields */ | 562 | /* Fill in the remaining client fields */ |
562 | strlcpy(new_client->name, "gl520sm", I2C_NAME_SIZE); | 563 | strlcpy(new_client->name, "gl520sm", I2C_NAME_SIZE); |
563 | data->valid = 0; | 564 | data->valid = 0; |
564 | init_MUTEX(&data->update_lock); | 565 | mutex_init(&data->update_lock); |
565 | 566 | ||
566 | /* Tell the I2C layer a new client has arrived */ | 567 | /* Tell the I2C layer a new client has arrived */ |
567 | if ((err = i2c_attach_client(new_client))) | 568 | if ((err = i2c_attach_client(new_client))) |
@@ -685,7 +686,7 @@ static struct gl520_data *gl520_update_device(struct device *dev) | |||
685 | struct gl520_data *data = i2c_get_clientdata(client); | 686 | struct gl520_data *data = i2c_get_clientdata(client); |
686 | int val; | 687 | int val; |
687 | 688 | ||
688 | down(&data->update_lock); | 689 | mutex_lock(&data->update_lock); |
689 | 690 | ||
690 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { | 691 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { |
691 | 692 | ||
@@ -750,7 +751,7 @@ static struct gl520_data *gl520_update_device(struct device *dev) | |||
750 | data->valid = 1; | 751 | data->valid = 1; |
751 | } | 752 | } |
752 | 753 | ||
753 | up(&data->update_lock); | 754 | mutex_unlock(&data->update_lock); |
754 | 755 | ||
755 | return data; | 756 | return data; |
756 | } | 757 | } |
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c index 23a9e1ea8e32..7636c1a58f9c 100644 --- a/drivers/hwmon/hdaps.c +++ b/drivers/hwmon/hdaps.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/module.h> | 33 | #include <linux/module.h> |
34 | #include <linux/timer.h> | 34 | #include <linux/timer.h> |
35 | #include <linux/dmi.h> | 35 | #include <linux/dmi.h> |
36 | #include <linux/mutex.h> | ||
36 | #include <asm/io.h> | 37 | #include <asm/io.h> |
37 | 38 | ||
38 | #define HDAPS_LOW_PORT 0x1600 /* first port used by hdaps */ | 39 | #define HDAPS_LOW_PORT 0x1600 /* first port used by hdaps */ |
@@ -70,10 +71,10 @@ static u8 km_activity; | |||
70 | static int rest_x; | 71 | static int rest_x; |
71 | static int rest_y; | 72 | static int rest_y; |
72 | 73 | ||
73 | static DECLARE_MUTEX(hdaps_sem); | 74 | static DEFINE_MUTEX(hdaps_mutex); |
74 | 75 | ||
75 | /* | 76 | /* |
76 | * __get_latch - Get the value from a given port. Callers must hold hdaps_sem. | 77 | * __get_latch - Get the value from a given port. Callers must hold hdaps_mutex. |
77 | */ | 78 | */ |
78 | static inline u8 __get_latch(u16 port) | 79 | static inline u8 __get_latch(u16 port) |
79 | { | 80 | { |
@@ -82,7 +83,7 @@ static inline u8 __get_latch(u16 port) | |||
82 | 83 | ||
83 | /* | 84 | /* |
84 | * __check_latch - Check a port latch for a given value. Returns zero if the | 85 | * __check_latch - Check a port latch for a given value. Returns zero if the |
85 | * port contains the given value. Callers must hold hdaps_sem. | 86 | * port contains the given value. Callers must hold hdaps_mutex. |
86 | */ | 87 | */ |
87 | static inline int __check_latch(u16 port, u8 val) | 88 | static inline int __check_latch(u16 port, u8 val) |
88 | { | 89 | { |
@@ -93,7 +94,7 @@ static inline int __check_latch(u16 port, u8 val) | |||
93 | 94 | ||
94 | /* | 95 | /* |
95 | * __wait_latch - Wait up to 100us for a port latch to get a certain value, | 96 | * __wait_latch - Wait up to 100us for a port latch to get a certain value, |
96 | * returning zero if the value is obtained. Callers must hold hdaps_sem. | 97 | * returning zero if the value is obtained. Callers must hold hdaps_mutex. |
97 | */ | 98 | */ |
98 | static int __wait_latch(u16 port, u8 val) | 99 | static int __wait_latch(u16 port, u8 val) |
99 | { | 100 | { |
@@ -110,7 +111,7 @@ static int __wait_latch(u16 port, u8 val) | |||
110 | 111 | ||
111 | /* | 112 | /* |
112 | * __device_refresh - request a refresh from the accelerometer. Does not wait | 113 | * __device_refresh - request a refresh from the accelerometer. Does not wait |
113 | * for refresh to complete. Callers must hold hdaps_sem. | 114 | * for refresh to complete. Callers must hold hdaps_mutex. |
114 | */ | 115 | */ |
115 | static void __device_refresh(void) | 116 | static void __device_refresh(void) |
116 | { | 117 | { |
@@ -124,7 +125,7 @@ static void __device_refresh(void) | |||
124 | /* | 125 | /* |
125 | * __device_refresh_sync - request a synchronous refresh from the | 126 | * __device_refresh_sync - request a synchronous refresh from the |
126 | * accelerometer. We wait for the refresh to complete. Returns zero if | 127 | * accelerometer. We wait for the refresh to complete. Returns zero if |
127 | * successful and nonzero on error. Callers must hold hdaps_sem. | 128 | * successful and nonzero on error. Callers must hold hdaps_mutex. |
128 | */ | 129 | */ |
129 | static int __device_refresh_sync(void) | 130 | static int __device_refresh_sync(void) |
130 | { | 131 | { |
@@ -134,7 +135,7 @@ static int __device_refresh_sync(void) | |||
134 | 135 | ||
135 | /* | 136 | /* |
136 | * __device_complete - indicate to the accelerometer that we are done reading | 137 | * __device_complete - indicate to the accelerometer that we are done reading |
137 | * data, and then initiate an async refresh. Callers must hold hdaps_sem. | 138 | * data, and then initiate an async refresh. Callers must hold hdaps_mutex. |
138 | */ | 139 | */ |
139 | static inline void __device_complete(void) | 140 | static inline void __device_complete(void) |
140 | { | 141 | { |
@@ -152,7 +153,7 @@ static int hdaps_readb_one(unsigned int port, u8 *val) | |||
152 | { | 153 | { |
153 | int ret; | 154 | int ret; |
154 | 155 | ||
155 | down(&hdaps_sem); | 156 | mutex_lock(&hdaps_mutex); |
156 | 157 | ||
157 | /* do a sync refresh -- we need to be sure that we read fresh data */ | 158 | /* do a sync refresh -- we need to be sure that we read fresh data */ |
158 | ret = __device_refresh_sync(); | 159 | ret = __device_refresh_sync(); |
@@ -163,7 +164,7 @@ static int hdaps_readb_one(unsigned int port, u8 *val) | |||
163 | __device_complete(); | 164 | __device_complete(); |
164 | 165 | ||
165 | out: | 166 | out: |
166 | up(&hdaps_sem); | 167 | mutex_unlock(&hdaps_mutex); |
167 | return ret; | 168 | return ret; |
168 | } | 169 | } |
169 | 170 | ||
@@ -198,9 +199,9 @@ static int hdaps_read_pair(unsigned int port1, unsigned int port2, | |||
198 | { | 199 | { |
199 | int ret; | 200 | int ret; |
200 | 201 | ||
201 | down(&hdaps_sem); | 202 | mutex_lock(&hdaps_mutex); |
202 | ret = __hdaps_read_pair(port1, port2, val1, val2); | 203 | ret = __hdaps_read_pair(port1, port2, val1, val2); |
203 | up(&hdaps_sem); | 204 | mutex_unlock(&hdaps_mutex); |
204 | 205 | ||
205 | return ret; | 206 | return ret; |
206 | } | 207 | } |
@@ -213,7 +214,7 @@ static int hdaps_device_init(void) | |||
213 | { | 214 | { |
214 | int total, ret = -ENXIO; | 215 | int total, ret = -ENXIO; |
215 | 216 | ||
216 | down(&hdaps_sem); | 217 | mutex_lock(&hdaps_mutex); |
217 | 218 | ||
218 | outb(0x13, 0x1610); | 219 | outb(0x13, 0x1610); |
219 | outb(0x01, 0x161f); | 220 | outb(0x01, 0x161f); |
@@ -279,7 +280,7 @@ static int hdaps_device_init(void) | |||
279 | } | 280 | } |
280 | 281 | ||
281 | out: | 282 | out: |
282 | up(&hdaps_sem); | 283 | mutex_unlock(&hdaps_mutex); |
283 | return ret; | 284 | return ret; |
284 | } | 285 | } |
285 | 286 | ||
@@ -313,7 +314,7 @@ static struct platform_driver hdaps_driver = { | |||
313 | }; | 314 | }; |
314 | 315 | ||
315 | /* | 316 | /* |
316 | * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_sem. | 317 | * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_mutex. |
317 | */ | 318 | */ |
318 | static void hdaps_calibrate(void) | 319 | static void hdaps_calibrate(void) |
319 | { | 320 | { |
@@ -325,7 +326,7 @@ static void hdaps_mousedev_poll(unsigned long unused) | |||
325 | int x, y; | 326 | int x, y; |
326 | 327 | ||
327 | /* Cannot sleep. Try nonblockingly. If we fail, try again later. */ | 328 | /* Cannot sleep. Try nonblockingly. If we fail, try again later. */ |
328 | if (down_trylock(&hdaps_sem)) { | 329 | if (!mutex_trylock(&hdaps_mutex)) { |
329 | mod_timer(&hdaps_timer,jiffies + HDAPS_POLL_PERIOD); | 330 | mod_timer(&hdaps_timer,jiffies + HDAPS_POLL_PERIOD); |
330 | return; | 331 | return; |
331 | } | 332 | } |
@@ -340,7 +341,7 @@ static void hdaps_mousedev_poll(unsigned long unused) | |||
340 | mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD); | 341 | mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD); |
341 | 342 | ||
342 | out: | 343 | out: |
343 | up(&hdaps_sem); | 344 | mutex_unlock(&hdaps_mutex); |
344 | } | 345 | } |
345 | 346 | ||
346 | 347 | ||
@@ -420,9 +421,9 @@ static ssize_t hdaps_calibrate_store(struct device *dev, | |||
420 | struct device_attribute *attr, | 421 | struct device_attribute *attr, |
421 | const char *buf, size_t count) | 422 | const char *buf, size_t count) |
422 | { | 423 | { |
423 | down(&hdaps_sem); | 424 | mutex_lock(&hdaps_mutex); |
424 | hdaps_calibrate(); | 425 | hdaps_calibrate(); |
425 | up(&hdaps_sem); | 426 | mutex_unlock(&hdaps_mutex); |
426 | 427 | ||
427 | return count; | 428 | return count; |
428 | } | 429 | } |
diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c index e497274916ce..a74a44f16f51 100644 --- a/drivers/hwmon/hwmon-vid.c +++ b/drivers/hwmon/hwmon-vid.c | |||
@@ -54,6 +54,10 @@ | |||
54 | (IMVP-II). You can find more information in the datasheet of Max1718 | 54 | (IMVP-II). You can find more information in the datasheet of Max1718 |
55 | http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2452 | 55 | http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2452 |
56 | 56 | ||
57 | The 13 specification corresponds to the Intel Pentium M series. There | ||
58 | doesn't seem to be any named specification for these. The conversion | ||
59 | tables are detailed directly in the various Pentium M datasheets: | ||
60 | http://www.intel.com/design/intarch/pentiumm/docs_pentiumm.htm | ||
57 | */ | 61 | */ |
58 | 62 | ||
59 | /* vrm is the VRM/VRD document version multiplied by 10. | 63 | /* vrm is the VRM/VRD document version multiplied by 10. |
@@ -100,6 +104,8 @@ int vid_from_reg(int val, u8 vrm) | |||
100 | case 17: /* Intel IMVP-II */ | 104 | case 17: /* Intel IMVP-II */ |
101 | return(val & 0x10 ? 975 - (val & 0xF) * 25 : | 105 | return(val & 0x10 ? 975 - (val & 0xF) * 25 : |
102 | 1750 - val * 50); | 106 | 1750 - val * 50); |
107 | case 13: | ||
108 | return(1708 - (val & 0x3f) * 16); | ||
103 | default: /* report 0 for unknown */ | 109 | default: /* report 0 for unknown */ |
104 | printk(KERN_INFO "hwmon-vid: requested unknown VRM version\n"); | 110 | printk(KERN_INFO "hwmon-vid: requested unknown VRM version\n"); |
105 | return 0; | 111 | return 0; |
@@ -129,8 +135,9 @@ struct vrm_model { | |||
129 | static struct vrm_model vrm_models[] = { | 135 | static struct vrm_model vrm_models[] = { |
130 | {X86_VENDOR_AMD, 0x6, ANY, ANY, 90}, /* Athlon Duron etc */ | 136 | {X86_VENDOR_AMD, 0x6, ANY, ANY, 90}, /* Athlon Duron etc */ |
131 | {X86_VENDOR_AMD, 0xF, ANY, ANY, 24}, /* Athlon 64, Opteron and above VRM 24 */ | 137 | {X86_VENDOR_AMD, 0xF, ANY, ANY, 24}, /* Athlon 64, Opteron and above VRM 24 */ |
132 | {X86_VENDOR_INTEL, 0x6, 0x9, ANY, 85}, /* 0.13um too */ | 138 | {X86_VENDOR_INTEL, 0x6, 0x9, ANY, 13}, /* Pentium M (130 nm) */ |
133 | {X86_VENDOR_INTEL, 0x6, 0xB, ANY, 85}, /* Tualatin */ | 139 | {X86_VENDOR_INTEL, 0x6, 0xB, ANY, 85}, /* Tualatin */ |
140 | {X86_VENDOR_INTEL, 0x6, 0xD, ANY, 13}, /* Pentium M (90 nm) */ | ||
134 | {X86_VENDOR_INTEL, 0x6, ANY, ANY, 82}, /* any P6 */ | 141 | {X86_VENDOR_INTEL, 0x6, ANY, ANY, 82}, /* any P6 */ |
135 | {X86_VENDOR_INTEL, 0x7, ANY, ANY, 0}, /* Itanium */ | 142 | {X86_VENDOR_INTEL, 0x7, ANY, ANY, 0}, /* Itanium */ |
136 | {X86_VENDOR_INTEL, 0xF, 0x0, ANY, 90}, /* P4 */ | 143 | {X86_VENDOR_INTEL, 0xF, 0x0, ANY, 90}, /* P4 */ |
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index dddd3eb9b387..106fa01cdb60 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/idr.h> | 17 | #include <linux/idr.h> |
18 | #include <linux/hwmon.h> | 18 | #include <linux/hwmon.h> |
19 | #include <linux/gfp.h> | 19 | #include <linux/gfp.h> |
20 | #include <linux/spinlock.h> | ||
20 | 21 | ||
21 | #define HWMON_ID_PREFIX "hwmon" | 22 | #define HWMON_ID_PREFIX "hwmon" |
22 | #define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d" | 23 | #define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d" |
@@ -24,6 +25,7 @@ | |||
24 | static struct class *hwmon_class; | 25 | static struct class *hwmon_class; |
25 | 26 | ||
26 | static DEFINE_IDR(hwmon_idr); | 27 | static DEFINE_IDR(hwmon_idr); |
28 | static DEFINE_SPINLOCK(idr_lock); | ||
27 | 29 | ||
28 | /** | 30 | /** |
29 | * hwmon_device_register - register w/ hwmon sysfs class | 31 | * hwmon_device_register - register w/ hwmon sysfs class |
@@ -37,20 +39,30 @@ static DEFINE_IDR(hwmon_idr); | |||
37 | struct class_device *hwmon_device_register(struct device *dev) | 39 | struct class_device *hwmon_device_register(struct device *dev) |
38 | { | 40 | { |
39 | struct class_device *cdev; | 41 | struct class_device *cdev; |
40 | int id; | 42 | int id, err; |
41 | 43 | ||
42 | if (idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0) | 44 | again: |
45 | if (unlikely(idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0)) | ||
43 | return ERR_PTR(-ENOMEM); | 46 | return ERR_PTR(-ENOMEM); |
44 | 47 | ||
45 | if (idr_get_new(&hwmon_idr, NULL, &id) < 0) | 48 | spin_lock(&idr_lock); |
46 | return ERR_PTR(-ENOMEM); | 49 | err = idr_get_new(&hwmon_idr, NULL, &id); |
50 | spin_unlock(&idr_lock); | ||
51 | |||
52 | if (unlikely(err == -EAGAIN)) | ||
53 | goto again; | ||
54 | else if (unlikely(err)) | ||
55 | return ERR_PTR(err); | ||
47 | 56 | ||
48 | id = id & MAX_ID_MASK; | 57 | id = id & MAX_ID_MASK; |
49 | cdev = class_device_create(hwmon_class, NULL, MKDEV(0,0), dev, | 58 | cdev = class_device_create(hwmon_class, NULL, MKDEV(0,0), dev, |
50 | HWMON_ID_FORMAT, id); | 59 | HWMON_ID_FORMAT, id); |
51 | 60 | ||
52 | if (IS_ERR(cdev)) | 61 | if (IS_ERR(cdev)) { |
62 | spin_lock(&idr_lock); | ||
53 | idr_remove(&hwmon_idr, id); | 63 | idr_remove(&hwmon_idr, id); |
64 | spin_unlock(&idr_lock); | ||
65 | } | ||
54 | 66 | ||
55 | return cdev; | 67 | return cdev; |
56 | } | 68 | } |
@@ -64,9 +76,11 @@ void hwmon_device_unregister(struct class_device *cdev) | |||
64 | { | 76 | { |
65 | int id; | 77 | int id; |
66 | 78 | ||
67 | if (sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1) { | 79 | if (likely(sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1)) { |
68 | class_device_unregister(cdev); | 80 | class_device_unregister(cdev); |
81 | spin_lock(&idr_lock); | ||
69 | idr_remove(&hwmon_idr, id); | 82 | idr_remove(&hwmon_idr, id); |
83 | spin_unlock(&idr_lock); | ||
70 | } else | 84 | } else |
71 | dev_dbg(cdev->dev, | 85 | dev_dbg(cdev->dev, |
72 | "hwmon_device_unregister() failed: bad class ID!\n"); | 86 | "hwmon_device_unregister() failed: bad class ID!\n"); |
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index d7a9401600bb..06df92b3ee49 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/hwmon-sysfs.h> | 41 | #include <linux/hwmon-sysfs.h> |
42 | #include <linux/hwmon-vid.h> | 42 | #include <linux/hwmon-vid.h> |
43 | #include <linux/err.h> | 43 | #include <linux/err.h> |
44 | #include <linux/mutex.h> | ||
44 | #include <asm/io.h> | 45 | #include <asm/io.h> |
45 | 46 | ||
46 | 47 | ||
@@ -194,10 +195,10 @@ static int DIV_TO_REG(int val) | |||
194 | struct it87_data { | 195 | struct it87_data { |
195 | struct i2c_client client; | 196 | struct i2c_client client; |
196 | struct class_device *class_dev; | 197 | struct class_device *class_dev; |
197 | struct semaphore lock; | 198 | struct mutex lock; |
198 | enum chips type; | 199 | enum chips type; |
199 | 200 | ||
200 | struct semaphore update_lock; | 201 | struct mutex update_lock; |
201 | char valid; /* !=0 if following fields are valid */ | 202 | char valid; /* !=0 if following fields are valid */ |
202 | unsigned long last_updated; /* In jiffies */ | 203 | unsigned long last_updated; /* In jiffies */ |
203 | 204 | ||
@@ -224,9 +225,8 @@ static int it87_isa_attach_adapter(struct i2c_adapter *adapter); | |||
224 | static int it87_detect(struct i2c_adapter *adapter, int address, int kind); | 225 | static int it87_detect(struct i2c_adapter *adapter, int address, int kind); |
225 | static int it87_detach_client(struct i2c_client *client); | 226 | static int it87_detach_client(struct i2c_client *client); |
226 | 227 | ||
227 | static int it87_read_value(struct i2c_client *client, u8 register); | 228 | static int it87_read_value(struct i2c_client *client, u8 reg); |
228 | static int it87_write_value(struct i2c_client *client, u8 register, | 229 | static int it87_write_value(struct i2c_client *client, u8 reg, u8 value); |
229 | u8 value); | ||
230 | static struct it87_data *it87_update_device(struct device *dev); | 230 | static struct it87_data *it87_update_device(struct device *dev); |
231 | static int it87_check_pwm(struct i2c_client *client); | 231 | static int it87_check_pwm(struct i2c_client *client); |
232 | static void it87_init_client(struct i2c_client *client, struct it87_data *data); | 232 | static void it87_init_client(struct i2c_client *client, struct it87_data *data); |
@@ -290,11 +290,11 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | |||
290 | struct it87_data *data = i2c_get_clientdata(client); | 290 | struct it87_data *data = i2c_get_clientdata(client); |
291 | unsigned long val = simple_strtoul(buf, NULL, 10); | 291 | unsigned long val = simple_strtoul(buf, NULL, 10); |
292 | 292 | ||
293 | down(&data->update_lock); | 293 | mutex_lock(&data->update_lock); |
294 | data->in_min[nr] = IN_TO_REG(val); | 294 | data->in_min[nr] = IN_TO_REG(val); |
295 | it87_write_value(client, IT87_REG_VIN_MIN(nr), | 295 | it87_write_value(client, IT87_REG_VIN_MIN(nr), |
296 | data->in_min[nr]); | 296 | data->in_min[nr]); |
297 | up(&data->update_lock); | 297 | mutex_unlock(&data->update_lock); |
298 | return count; | 298 | return count; |
299 | } | 299 | } |
300 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | 300 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, |
@@ -307,11 +307,11 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | |||
307 | struct it87_data *data = i2c_get_clientdata(client); | 307 | struct it87_data *data = i2c_get_clientdata(client); |
308 | unsigned long val = simple_strtoul(buf, NULL, 10); | 308 | unsigned long val = simple_strtoul(buf, NULL, 10); |
309 | 309 | ||
310 | down(&data->update_lock); | 310 | mutex_lock(&data->update_lock); |
311 | data->in_max[nr] = IN_TO_REG(val); | 311 | data->in_max[nr] = IN_TO_REG(val); |
312 | it87_write_value(client, IT87_REG_VIN_MAX(nr), | 312 | it87_write_value(client, IT87_REG_VIN_MAX(nr), |
313 | data->in_max[nr]); | 313 | data->in_max[nr]); |
314 | up(&data->update_lock); | 314 | mutex_unlock(&data->update_lock); |
315 | return count; | 315 | return count; |
316 | } | 316 | } |
317 | 317 | ||
@@ -381,10 +381,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
381 | struct it87_data *data = i2c_get_clientdata(client); | 381 | struct it87_data *data = i2c_get_clientdata(client); |
382 | int val = simple_strtol(buf, NULL, 10); | 382 | int val = simple_strtol(buf, NULL, 10); |
383 | 383 | ||
384 | down(&data->update_lock); | 384 | mutex_lock(&data->update_lock); |
385 | data->temp_high[nr] = TEMP_TO_REG(val); | 385 | data->temp_high[nr] = TEMP_TO_REG(val); |
386 | it87_write_value(client, IT87_REG_TEMP_HIGH(nr), data->temp_high[nr]); | 386 | it87_write_value(client, IT87_REG_TEMP_HIGH(nr), data->temp_high[nr]); |
387 | up(&data->update_lock); | 387 | mutex_unlock(&data->update_lock); |
388 | return count; | 388 | return count; |
389 | } | 389 | } |
390 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | 390 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
@@ -397,10 +397,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | |||
397 | struct it87_data *data = i2c_get_clientdata(client); | 397 | struct it87_data *data = i2c_get_clientdata(client); |
398 | int val = simple_strtol(buf, NULL, 10); | 398 | int val = simple_strtol(buf, NULL, 10); |
399 | 399 | ||
400 | down(&data->update_lock); | 400 | mutex_lock(&data->update_lock); |
401 | data->temp_low[nr] = TEMP_TO_REG(val); | 401 | data->temp_low[nr] = TEMP_TO_REG(val); |
402 | it87_write_value(client, IT87_REG_TEMP_LOW(nr), data->temp_low[nr]); | 402 | it87_write_value(client, IT87_REG_TEMP_LOW(nr), data->temp_low[nr]); |
403 | up(&data->update_lock); | 403 | mutex_unlock(&data->update_lock); |
404 | return count; | 404 | return count; |
405 | } | 405 | } |
406 | #define show_temp_offset(offset) \ | 406 | #define show_temp_offset(offset) \ |
@@ -440,7 +440,7 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr, | |||
440 | struct it87_data *data = i2c_get_clientdata(client); | 440 | struct it87_data *data = i2c_get_clientdata(client); |
441 | int val = simple_strtol(buf, NULL, 10); | 441 | int val = simple_strtol(buf, NULL, 10); |
442 | 442 | ||
443 | down(&data->update_lock); | 443 | mutex_lock(&data->update_lock); |
444 | 444 | ||
445 | data->sensor &= ~(1 << nr); | 445 | data->sensor &= ~(1 << nr); |
446 | data->sensor &= ~(8 << nr); | 446 | data->sensor &= ~(8 << nr); |
@@ -450,11 +450,11 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr, | |||
450 | else if (val == 2) | 450 | else if (val == 2) |
451 | data->sensor |= 8 << nr; | 451 | data->sensor |= 8 << nr; |
452 | else if (val != 0) { | 452 | else if (val != 0) { |
453 | up(&data->update_lock); | 453 | mutex_unlock(&data->update_lock); |
454 | return -EINVAL; | 454 | return -EINVAL; |
455 | } | 455 | } |
456 | it87_write_value(client, IT87_REG_TEMP_ENABLE, data->sensor); | 456 | it87_write_value(client, IT87_REG_TEMP_ENABLE, data->sensor); |
457 | up(&data->update_lock); | 457 | mutex_unlock(&data->update_lock); |
458 | return count; | 458 | return count; |
459 | } | 459 | } |
460 | #define show_sensor_offset(offset) \ | 460 | #define show_sensor_offset(offset) \ |
@@ -524,7 +524,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
524 | int val = simple_strtol(buf, NULL, 10); | 524 | int val = simple_strtol(buf, NULL, 10); |
525 | u8 reg = it87_read_value(client, IT87_REG_FAN_DIV); | 525 | u8 reg = it87_read_value(client, IT87_REG_FAN_DIV); |
526 | 526 | ||
527 | down(&data->update_lock); | 527 | mutex_lock(&data->update_lock); |
528 | switch (nr) { | 528 | switch (nr) { |
529 | case 0: data->fan_div[nr] = reg & 0x07; break; | 529 | case 0: data->fan_div[nr] = reg & 0x07; break; |
530 | case 1: data->fan_div[nr] = (reg >> 3) & 0x07; break; | 530 | case 1: data->fan_div[nr] = (reg >> 3) & 0x07; break; |
@@ -533,7 +533,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
533 | 533 | ||
534 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 534 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
535 | it87_write_value(client, IT87_REG_FAN_MIN(nr), data->fan_min[nr]); | 535 | it87_write_value(client, IT87_REG_FAN_MIN(nr), data->fan_min[nr]); |
536 | up(&data->update_lock); | 536 | mutex_unlock(&data->update_lock); |
537 | return count; | 537 | return count; |
538 | } | 538 | } |
539 | static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | 539 | static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, |
@@ -548,7 +548,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
548 | int i, min[3]; | 548 | int i, min[3]; |
549 | u8 old; | 549 | u8 old; |
550 | 550 | ||
551 | down(&data->update_lock); | 551 | mutex_lock(&data->update_lock); |
552 | old = it87_read_value(client, IT87_REG_FAN_DIV); | 552 | old = it87_read_value(client, IT87_REG_FAN_DIV); |
553 | 553 | ||
554 | for (i = 0; i < 3; i++) | 554 | for (i = 0; i < 3; i++) |
@@ -576,7 +576,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
576 | data->fan_min[i]=FAN_TO_REG(min[i], DIV_FROM_REG(data->fan_div[i])); | 576 | data->fan_min[i]=FAN_TO_REG(min[i], DIV_FROM_REG(data->fan_div[i])); |
577 | it87_write_value(client, IT87_REG_FAN_MIN(i), data->fan_min[i]); | 577 | it87_write_value(client, IT87_REG_FAN_MIN(i), data->fan_min[i]); |
578 | } | 578 | } |
579 | up(&data->update_lock); | 579 | mutex_unlock(&data->update_lock); |
580 | return count; | 580 | return count; |
581 | } | 581 | } |
582 | static ssize_t set_pwm_enable(struct device *dev, | 582 | static ssize_t set_pwm_enable(struct device *dev, |
@@ -589,7 +589,7 @@ static ssize_t set_pwm_enable(struct device *dev, | |||
589 | struct it87_data *data = i2c_get_clientdata(client); | 589 | struct it87_data *data = i2c_get_clientdata(client); |
590 | int val = simple_strtol(buf, NULL, 10); | 590 | int val = simple_strtol(buf, NULL, 10); |
591 | 591 | ||
592 | down(&data->update_lock); | 592 | mutex_lock(&data->update_lock); |
593 | 593 | ||
594 | if (val == 0) { | 594 | if (val == 0) { |
595 | int tmp; | 595 | int tmp; |
@@ -606,11 +606,11 @@ static ssize_t set_pwm_enable(struct device *dev, | |||
606 | /* set saved pwm value, clear FAN_CTLX PWM mode bit */ | 606 | /* set saved pwm value, clear FAN_CTLX PWM mode bit */ |
607 | it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr])); | 607 | it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr])); |
608 | } else { | 608 | } else { |
609 | up(&data->update_lock); | 609 | mutex_unlock(&data->update_lock); |
610 | return -EINVAL; | 610 | return -EINVAL; |
611 | } | 611 | } |
612 | 612 | ||
613 | up(&data->update_lock); | 613 | mutex_unlock(&data->update_lock); |
614 | return count; | 614 | return count; |
615 | } | 615 | } |
616 | static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, | 616 | static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, |
@@ -626,11 +626,11 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, | |||
626 | if (val < 0 || val > 255) | 626 | if (val < 0 || val > 255) |
627 | return -EINVAL; | 627 | return -EINVAL; |
628 | 628 | ||
629 | down(&data->update_lock); | 629 | mutex_lock(&data->update_lock); |
630 | data->manual_pwm_ctl[nr] = val; | 630 | data->manual_pwm_ctl[nr] = val; |
631 | if (data->fan_main_ctrl & (1 << nr)) | 631 | if (data->fan_main_ctrl & (1 << nr)) |
632 | it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr])); | 632 | it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr])); |
633 | up(&data->update_lock); | 633 | mutex_unlock(&data->update_lock); |
634 | return count; | 634 | return count; |
635 | } | 635 | } |
636 | 636 | ||
@@ -776,7 +776,7 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
776 | 776 | ||
777 | new_client = &data->client; | 777 | new_client = &data->client; |
778 | if (is_isa) | 778 | if (is_isa) |
779 | init_MUTEX(&data->lock); | 779 | mutex_init(&data->lock); |
780 | i2c_set_clientdata(new_client, data); | 780 | i2c_set_clientdata(new_client, data); |
781 | new_client->addr = address; | 781 | new_client->addr = address; |
782 | new_client->adapter = adapter; | 782 | new_client->adapter = adapter; |
@@ -823,7 +823,7 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
823 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 823 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
824 | data->type = kind; | 824 | data->type = kind; |
825 | data->valid = 0; | 825 | data->valid = 0; |
826 | init_MUTEX(&data->update_lock); | 826 | mutex_init(&data->update_lock); |
827 | 827 | ||
828 | /* Tell the I2C layer a new client has arrived */ | 828 | /* Tell the I2C layer a new client has arrived */ |
829 | if ((err = i2c_attach_client(new_client))) | 829 | if ((err = i2c_attach_client(new_client))) |
@@ -950,10 +950,10 @@ static int it87_read_value(struct i2c_client *client, u8 reg) | |||
950 | 950 | ||
951 | int res; | 951 | int res; |
952 | if (i2c_is_isa_client(client)) { | 952 | if (i2c_is_isa_client(client)) { |
953 | down(&data->lock); | 953 | mutex_lock(&data->lock); |
954 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); | 954 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); |
955 | res = inb_p(client->addr + IT87_DATA_REG_OFFSET); | 955 | res = inb_p(client->addr + IT87_DATA_REG_OFFSET); |
956 | up(&data->lock); | 956 | mutex_unlock(&data->lock); |
957 | return res; | 957 | return res; |
958 | } else | 958 | } else |
959 | return i2c_smbus_read_byte_data(client, reg); | 959 | return i2c_smbus_read_byte_data(client, reg); |
@@ -969,10 +969,10 @@ static int it87_write_value(struct i2c_client *client, u8 reg, u8 value) | |||
969 | struct it87_data *data = i2c_get_clientdata(client); | 969 | struct it87_data *data = i2c_get_clientdata(client); |
970 | 970 | ||
971 | if (i2c_is_isa_client(client)) { | 971 | if (i2c_is_isa_client(client)) { |
972 | down(&data->lock); | 972 | mutex_lock(&data->lock); |
973 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); | 973 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); |
974 | outb_p(value, client->addr + IT87_DATA_REG_OFFSET); | 974 | outb_p(value, client->addr + IT87_DATA_REG_OFFSET); |
975 | up(&data->lock); | 975 | mutex_unlock(&data->lock); |
976 | return 0; | 976 | return 0; |
977 | } else | 977 | } else |
978 | return i2c_smbus_write_byte_data(client, reg, value); | 978 | return i2c_smbus_write_byte_data(client, reg, value); |
@@ -1098,7 +1098,7 @@ static struct it87_data *it87_update_device(struct device *dev) | |||
1098 | struct it87_data *data = i2c_get_clientdata(client); | 1098 | struct it87_data *data = i2c_get_clientdata(client); |
1099 | int i; | 1099 | int i; |
1100 | 1100 | ||
1101 | down(&data->update_lock); | 1101 | mutex_lock(&data->update_lock); |
1102 | 1102 | ||
1103 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 1103 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
1104 | || !data->valid) { | 1104 | || !data->valid) { |
@@ -1160,7 +1160,7 @@ static struct it87_data *it87_update_device(struct device *dev) | |||
1160 | data->valid = 1; | 1160 | data->valid = 1; |
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | up(&data->update_lock); | 1163 | mutex_unlock(&data->update_lock); |
1164 | 1164 | ||
1165 | return data; | 1165 | return data; |
1166 | } | 1166 | } |
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 6b1aa7ef552e..071f0fc6adec 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/hwmon-sysfs.h> | 45 | #include <linux/hwmon-sysfs.h> |
46 | #include <linux/hwmon.h> | 46 | #include <linux/hwmon.h> |
47 | #include <linux/err.h> | 47 | #include <linux/err.h> |
48 | #include <linux/mutex.h> | ||
48 | 49 | ||
49 | /* | 50 | /* |
50 | * Addresses to scan | 51 | * Addresses to scan |
@@ -153,7 +154,7 @@ static struct i2c_driver lm63_driver = { | |||
153 | struct lm63_data { | 154 | struct lm63_data { |
154 | struct i2c_client client; | 155 | struct i2c_client client; |
155 | struct class_device *class_dev; | 156 | struct class_device *class_dev; |
156 | struct semaphore update_lock; | 157 | struct mutex update_lock; |
157 | char valid; /* zero until following fields are valid */ | 158 | char valid; /* zero until following fields are valid */ |
158 | unsigned long last_updated; /* in jiffies */ | 159 | unsigned long last_updated; /* in jiffies */ |
159 | 160 | ||
@@ -192,13 +193,13 @@ static ssize_t set_fan(struct device *dev, struct device_attribute *dummy, | |||
192 | struct lm63_data *data = i2c_get_clientdata(client); | 193 | struct lm63_data *data = i2c_get_clientdata(client); |
193 | unsigned long val = simple_strtoul(buf, NULL, 10); | 194 | unsigned long val = simple_strtoul(buf, NULL, 10); |
194 | 195 | ||
195 | down(&data->update_lock); | 196 | mutex_lock(&data->update_lock); |
196 | data->fan[1] = FAN_TO_REG(val); | 197 | data->fan[1] = FAN_TO_REG(val); |
197 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB, | 198 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB, |
198 | data->fan[1] & 0xFF); | 199 | data->fan[1] & 0xFF); |
199 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB, | 200 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB, |
200 | data->fan[1] >> 8); | 201 | data->fan[1] >> 8); |
201 | up(&data->update_lock); | 202 | mutex_unlock(&data->update_lock); |
202 | return count; | 203 | return count; |
203 | } | 204 | } |
204 | 205 | ||
@@ -222,12 +223,12 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy, | |||
222 | return -EPERM; | 223 | return -EPERM; |
223 | 224 | ||
224 | val = simple_strtoul(buf, NULL, 10); | 225 | val = simple_strtoul(buf, NULL, 10); |
225 | down(&data->update_lock); | 226 | mutex_lock(&data->update_lock); |
226 | data->pwm1_value = val <= 0 ? 0 : | 227 | data->pwm1_value = val <= 0 ? 0 : |
227 | val >= 255 ? 2 * data->pwm1_freq : | 228 | val >= 255 ? 2 * data->pwm1_freq : |
228 | (val * data->pwm1_freq * 2 + 127) / 255; | 229 | (val * data->pwm1_freq * 2 + 127) / 255; |
229 | i2c_smbus_write_byte_data(client, LM63_REG_PWM_VALUE, data->pwm1_value); | 230 | i2c_smbus_write_byte_data(client, LM63_REG_PWM_VALUE, data->pwm1_value); |
230 | up(&data->update_lock); | 231 | mutex_unlock(&data->update_lock); |
231 | return count; | 232 | return count; |
232 | } | 233 | } |
233 | 234 | ||
@@ -253,10 +254,10 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *dummy, | |||
253 | struct lm63_data *data = i2c_get_clientdata(client); | 254 | struct lm63_data *data = i2c_get_clientdata(client); |
254 | long val = simple_strtol(buf, NULL, 10); | 255 | long val = simple_strtol(buf, NULL, 10); |
255 | 256 | ||
256 | down(&data->update_lock); | 257 | mutex_lock(&data->update_lock); |
257 | data->temp8[1] = TEMP8_TO_REG(val); | 258 | data->temp8[1] = TEMP8_TO_REG(val); |
258 | i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]); | 259 | i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]); |
259 | up(&data->update_lock); | 260 | mutex_unlock(&data->update_lock); |
260 | return count; | 261 | return count; |
261 | } | 262 | } |
262 | 263 | ||
@@ -284,13 +285,13 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, | |||
284 | long val = simple_strtol(buf, NULL, 10); | 285 | long val = simple_strtol(buf, NULL, 10); |
285 | int nr = attr->index; | 286 | int nr = attr->index; |
286 | 287 | ||
287 | down(&data->update_lock); | 288 | mutex_lock(&data->update_lock); |
288 | data->temp11[nr] = TEMP11_TO_REG(val); | 289 | data->temp11[nr] = TEMP11_TO_REG(val); |
289 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], | 290 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], |
290 | data->temp11[nr] >> 8); | 291 | data->temp11[nr] >> 8); |
291 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], | 292 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], |
292 | data->temp11[nr] & 0xff); | 293 | data->temp11[nr] & 0xff); |
293 | up(&data->update_lock); | 294 | mutex_unlock(&data->update_lock); |
294 | return count; | 295 | return count; |
295 | } | 296 | } |
296 | 297 | ||
@@ -314,11 +315,11 @@ static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute * | |||
314 | long val = simple_strtol(buf, NULL, 10); | 315 | long val = simple_strtol(buf, NULL, 10); |
315 | long hyst; | 316 | long hyst; |
316 | 317 | ||
317 | down(&data->update_lock); | 318 | mutex_lock(&data->update_lock); |
318 | hyst = TEMP8_FROM_REG(data->temp8[2]) - val; | 319 | hyst = TEMP8_FROM_REG(data->temp8[2]) - val; |
319 | i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, | 320 | i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, |
320 | HYST_TO_REG(hyst)); | 321 | HYST_TO_REG(hyst)); |
321 | up(&data->update_lock); | 322 | mutex_unlock(&data->update_lock); |
322 | return count; | 323 | return count; |
323 | } | 324 | } |
324 | 325 | ||
@@ -427,7 +428,7 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) | |||
427 | 428 | ||
428 | strlcpy(new_client->name, "lm63", I2C_NAME_SIZE); | 429 | strlcpy(new_client->name, "lm63", I2C_NAME_SIZE); |
429 | data->valid = 0; | 430 | data->valid = 0; |
430 | init_MUTEX(&data->update_lock); | 431 | mutex_init(&data->update_lock); |
431 | 432 | ||
432 | /* Tell the I2C layer a new client has arrived */ | 433 | /* Tell the I2C layer a new client has arrived */ |
433 | if ((err = i2c_attach_client(new_client))) | 434 | if ((err = i2c_attach_client(new_client))) |
@@ -530,7 +531,7 @@ static struct lm63_data *lm63_update_device(struct device *dev) | |||
530 | struct i2c_client *client = to_i2c_client(dev); | 531 | struct i2c_client *client = to_i2c_client(dev); |
531 | struct lm63_data *data = i2c_get_clientdata(client); | 532 | struct lm63_data *data = i2c_get_clientdata(client); |
532 | 533 | ||
533 | down(&data->update_lock); | 534 | mutex_lock(&data->update_lock); |
534 | 535 | ||
535 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | 536 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { |
536 | if (data->config & 0x04) { /* tachometer enabled */ | 537 | if (data->config & 0x04) { /* tachometer enabled */ |
@@ -582,7 +583,7 @@ static struct lm63_data *lm63_update_device(struct device *dev) | |||
582 | data->valid = 1; | 583 | data->valid = 1; |
583 | } | 584 | } |
584 | 585 | ||
585 | up(&data->update_lock); | 586 | mutex_unlock(&data->update_lock); |
586 | 587 | ||
587 | return data; | 588 | return data; |
588 | } | 589 | } |
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 74ca2c8c61c3..fc25b90ec24a 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
26 | #include <linux/hwmon.h> | 26 | #include <linux/hwmon.h> |
27 | #include <linux/err.h> | 27 | #include <linux/err.h> |
28 | #include <linux/mutex.h> | ||
28 | #include "lm75.h" | 29 | #include "lm75.h" |
29 | 30 | ||
30 | 31 | ||
@@ -47,7 +48,7 @@ I2C_CLIENT_INSMOD_1(lm75); | |||
47 | struct lm75_data { | 48 | struct lm75_data { |
48 | struct i2c_client client; | 49 | struct i2c_client client; |
49 | struct class_device *class_dev; | 50 | struct class_device *class_dev; |
50 | struct semaphore update_lock; | 51 | struct mutex update_lock; |
51 | char valid; /* !=0 if following fields are valid */ | 52 | char valid; /* !=0 if following fields are valid */ |
52 | unsigned long last_updated; /* In jiffies */ | 53 | unsigned long last_updated; /* In jiffies */ |
53 | u16 temp_input; /* Register values */ | 54 | u16 temp_input; /* Register values */ |
@@ -91,10 +92,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co | |||
91 | struct lm75_data *data = i2c_get_clientdata(client); \ | 92 | struct lm75_data *data = i2c_get_clientdata(client); \ |
92 | int temp = simple_strtoul(buf, NULL, 10); \ | 93 | int temp = simple_strtoul(buf, NULL, 10); \ |
93 | \ | 94 | \ |
94 | down(&data->update_lock); \ | 95 | mutex_lock(&data->update_lock); \ |
95 | data->value = LM75_TEMP_TO_REG(temp); \ | 96 | data->value = LM75_TEMP_TO_REG(temp); \ |
96 | lm75_write_value(client, reg, data->value); \ | 97 | lm75_write_value(client, reg, data->value); \ |
97 | up(&data->update_lock); \ | 98 | mutex_unlock(&data->update_lock); \ |
98 | return count; \ | 99 | return count; \ |
99 | } | 100 | } |
100 | set(temp_max, LM75_REG_TEMP_OS); | 101 | set(temp_max, LM75_REG_TEMP_OS); |
@@ -188,7 +189,7 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) | |||
188 | /* Fill in the remaining client fields and put it into the global list */ | 189 | /* Fill in the remaining client fields and put it into the global list */ |
189 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 190 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
190 | data->valid = 0; | 191 | data->valid = 0; |
191 | init_MUTEX(&data->update_lock); | 192 | mutex_init(&data->update_lock); |
192 | 193 | ||
193 | /* Tell the I2C layer a new client has arrived */ | 194 | /* Tell the I2C layer a new client has arrived */ |
194 | if ((err = i2c_attach_client(new_client))) | 195 | if ((err = i2c_attach_client(new_client))) |
@@ -264,7 +265,7 @@ static struct lm75_data *lm75_update_device(struct device *dev) | |||
264 | struct i2c_client *client = to_i2c_client(dev); | 265 | struct i2c_client *client = to_i2c_client(dev); |
265 | struct lm75_data *data = i2c_get_clientdata(client); | 266 | struct lm75_data *data = i2c_get_clientdata(client); |
266 | 267 | ||
267 | down(&data->update_lock); | 268 | mutex_lock(&data->update_lock); |
268 | 269 | ||
269 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 270 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
270 | || !data->valid) { | 271 | || !data->valid) { |
@@ -277,7 +278,7 @@ static struct lm75_data *lm75_update_device(struct device *dev) | |||
277 | data->valid = 1; | 278 | data->valid = 1; |
278 | } | 279 | } |
279 | 280 | ||
280 | up(&data->update_lock); | 281 | mutex_unlock(&data->update_lock); |
281 | 282 | ||
282 | return data; | 283 | return data; |
283 | } | 284 | } |
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index df9e02aaa70a..459cc977380a 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/i2c.h> | 32 | #include <linux/i2c.h> |
33 | #include <linux/hwmon.h> | 33 | #include <linux/hwmon.h> |
34 | #include <linux/err.h> | 34 | #include <linux/err.h> |
35 | #include <linux/mutex.h> | ||
35 | 36 | ||
36 | /* Addresses to scan */ | 37 | /* Addresses to scan */ |
37 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; | 38 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; |
@@ -51,7 +52,7 @@ I2C_CLIENT_INSMOD_1(lm77); | |||
51 | struct lm77_data { | 52 | struct lm77_data { |
52 | struct i2c_client client; | 53 | struct i2c_client client; |
53 | struct class_device *class_dev; | 54 | struct class_device *class_dev; |
54 | struct semaphore update_lock; | 55 | struct mutex update_lock; |
55 | char valid; | 56 | char valid; |
56 | unsigned long last_updated; /* In jiffies */ | 57 | unsigned long last_updated; /* In jiffies */ |
57 | int temp_input; /* Temperatures */ | 58 | int temp_input; /* Temperatures */ |
@@ -139,10 +140,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co | |||
139 | struct lm77_data *data = i2c_get_clientdata(client); \ | 140 | struct lm77_data *data = i2c_get_clientdata(client); \ |
140 | long val = simple_strtoul(buf, NULL, 10); \ | 141 | long val = simple_strtoul(buf, NULL, 10); \ |
141 | \ | 142 | \ |
142 | down(&data->update_lock); \ | 143 | mutex_lock(&data->update_lock); \ |
143 | data->value = val; \ | 144 | data->value = val; \ |
144 | lm77_write_value(client, reg, LM77_TEMP_TO_REG(data->value)); \ | 145 | lm77_write_value(client, reg, LM77_TEMP_TO_REG(data->value)); \ |
145 | up(&data->update_lock); \ | 146 | mutex_unlock(&data->update_lock); \ |
146 | return count; \ | 147 | return count; \ |
147 | } | 148 | } |
148 | 149 | ||
@@ -157,11 +158,11 @@ static ssize_t set_temp_crit_hyst(struct device *dev, struct device_attribute *a | |||
157 | struct lm77_data *data = i2c_get_clientdata(client); | 158 | struct lm77_data *data = i2c_get_clientdata(client); |
158 | unsigned long val = simple_strtoul(buf, NULL, 10); | 159 | unsigned long val = simple_strtoul(buf, NULL, 10); |
159 | 160 | ||
160 | down(&data->update_lock); | 161 | mutex_lock(&data->update_lock); |
161 | data->temp_hyst = data->temp_crit - val; | 162 | data->temp_hyst = data->temp_crit - val; |
162 | lm77_write_value(client, LM77_REG_TEMP_HYST, | 163 | lm77_write_value(client, LM77_REG_TEMP_HYST, |
163 | LM77_TEMP_TO_REG(data->temp_hyst)); | 164 | LM77_TEMP_TO_REG(data->temp_hyst)); |
164 | up(&data->update_lock); | 165 | mutex_unlock(&data->update_lock); |
165 | return count; | 166 | return count; |
166 | } | 167 | } |
167 | 168 | ||
@@ -173,7 +174,7 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, | |||
173 | long val = simple_strtoul(buf, NULL, 10); | 174 | long val = simple_strtoul(buf, NULL, 10); |
174 | int oldcrithyst; | 175 | int oldcrithyst; |
175 | 176 | ||
176 | down(&data->update_lock); | 177 | mutex_lock(&data->update_lock); |
177 | oldcrithyst = data->temp_crit - data->temp_hyst; | 178 | oldcrithyst = data->temp_crit - data->temp_hyst; |
178 | data->temp_crit = val; | 179 | data->temp_crit = val; |
179 | data->temp_hyst = data->temp_crit - oldcrithyst; | 180 | data->temp_hyst = data->temp_crit - oldcrithyst; |
@@ -181,7 +182,7 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, | |||
181 | LM77_TEMP_TO_REG(data->temp_crit)); | 182 | LM77_TEMP_TO_REG(data->temp_crit)); |
182 | lm77_write_value(client, LM77_REG_TEMP_HYST, | 183 | lm77_write_value(client, LM77_REG_TEMP_HYST, |
183 | LM77_TEMP_TO_REG(data->temp_hyst)); | 184 | LM77_TEMP_TO_REG(data->temp_hyst)); |
184 | up(&data->update_lock); | 185 | mutex_unlock(&data->update_lock); |
185 | return count; | 186 | return count; |
186 | } | 187 | } |
187 | 188 | ||
@@ -306,7 +307,7 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) | |||
306 | /* Fill in the remaining client fields and put it into the global list */ | 307 | /* Fill in the remaining client fields and put it into the global list */ |
307 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 308 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
308 | data->valid = 0; | 309 | data->valid = 0; |
309 | init_MUTEX(&data->update_lock); | 310 | mutex_init(&data->update_lock); |
310 | 311 | ||
311 | /* Tell the I2C layer a new client has arrived */ | 312 | /* Tell the I2C layer a new client has arrived */ |
312 | if ((err = i2c_attach_client(new_client))) | 313 | if ((err = i2c_attach_client(new_client))) |
@@ -380,7 +381,7 @@ static struct lm77_data *lm77_update_device(struct device *dev) | |||
380 | struct i2c_client *client = to_i2c_client(dev); | 381 | struct i2c_client *client = to_i2c_client(dev); |
381 | struct lm77_data *data = i2c_get_clientdata(client); | 382 | struct lm77_data *data = i2c_get_clientdata(client); |
382 | 383 | ||
383 | down(&data->update_lock); | 384 | mutex_lock(&data->update_lock); |
384 | 385 | ||
385 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 386 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
386 | || !data->valid) { | 387 | || !data->valid) { |
@@ -406,7 +407,7 @@ static struct lm77_data *lm77_update_device(struct device *dev) | |||
406 | data->valid = 1; | 407 | data->valid = 1; |
407 | } | 408 | } |
408 | 409 | ||
409 | up(&data->update_lock); | 410 | mutex_unlock(&data->update_lock); |
410 | 411 | ||
411 | return data; | 412 | return data; |
412 | } | 413 | } |
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index e404001e20da..94be3d797e61 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/hwmon.h> | 27 | #include <linux/hwmon.h> |
28 | #include <linux/hwmon-vid.h> | 28 | #include <linux/hwmon-vid.h> |
29 | #include <linux/err.h> | 29 | #include <linux/err.h> |
30 | #include <linux/mutex.h> | ||
30 | #include <asm/io.h> | 31 | #include <asm/io.h> |
31 | 32 | ||
32 | /* Addresses to scan */ | 33 | /* Addresses to scan */ |
@@ -131,10 +132,10 @@ static inline int TEMP_FROM_REG(s8 val) | |||
131 | struct lm78_data { | 132 | struct lm78_data { |
132 | struct i2c_client client; | 133 | struct i2c_client client; |
133 | struct class_device *class_dev; | 134 | struct class_device *class_dev; |
134 | struct semaphore lock; | 135 | struct mutex lock; |
135 | enum chips type; | 136 | enum chips type; |
136 | 137 | ||
137 | struct semaphore update_lock; | 138 | struct mutex update_lock; |
138 | char valid; /* !=0 if following fields are valid */ | 139 | char valid; /* !=0 if following fields are valid */ |
139 | unsigned long last_updated; /* In jiffies */ | 140 | unsigned long last_updated; /* In jiffies */ |
140 | 141 | ||
@@ -157,8 +158,8 @@ static int lm78_isa_attach_adapter(struct i2c_adapter *adapter); | |||
157 | static int lm78_detect(struct i2c_adapter *adapter, int address, int kind); | 158 | static int lm78_detect(struct i2c_adapter *adapter, int address, int kind); |
158 | static int lm78_detach_client(struct i2c_client *client); | 159 | static int lm78_detach_client(struct i2c_client *client); |
159 | 160 | ||
160 | static int lm78_read_value(struct i2c_client *client, u8 register); | 161 | static int lm78_read_value(struct i2c_client *client, u8 reg); |
161 | static int lm78_write_value(struct i2c_client *client, u8 register, u8 value); | 162 | static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value); |
162 | static struct lm78_data *lm78_update_device(struct device *dev); | 163 | static struct lm78_data *lm78_update_device(struct device *dev); |
163 | static void lm78_init_client(struct i2c_client *client); | 164 | static void lm78_init_client(struct i2c_client *client); |
164 | 165 | ||
@@ -207,10 +208,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf, | |||
207 | struct lm78_data *data = i2c_get_clientdata(client); | 208 | struct lm78_data *data = i2c_get_clientdata(client); |
208 | unsigned long val = simple_strtoul(buf, NULL, 10); | 209 | unsigned long val = simple_strtoul(buf, NULL, 10); |
209 | 210 | ||
210 | down(&data->update_lock); | 211 | mutex_lock(&data->update_lock); |
211 | data->in_min[nr] = IN_TO_REG(val); | 212 | data->in_min[nr] = IN_TO_REG(val); |
212 | lm78_write_value(client, LM78_REG_IN_MIN(nr), data->in_min[nr]); | 213 | lm78_write_value(client, LM78_REG_IN_MIN(nr), data->in_min[nr]); |
213 | up(&data->update_lock); | 214 | mutex_unlock(&data->update_lock); |
214 | return count; | 215 | return count; |
215 | } | 216 | } |
216 | 217 | ||
@@ -221,10 +222,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
221 | struct lm78_data *data = i2c_get_clientdata(client); | 222 | struct lm78_data *data = i2c_get_clientdata(client); |
222 | unsigned long val = simple_strtoul(buf, NULL, 10); | 223 | unsigned long val = simple_strtoul(buf, NULL, 10); |
223 | 224 | ||
224 | down(&data->update_lock); | 225 | mutex_lock(&data->update_lock); |
225 | data->in_max[nr] = IN_TO_REG(val); | 226 | data->in_max[nr] = IN_TO_REG(val); |
226 | lm78_write_value(client, LM78_REG_IN_MAX(nr), data->in_max[nr]); | 227 | lm78_write_value(client, LM78_REG_IN_MAX(nr), data->in_max[nr]); |
227 | up(&data->update_lock); | 228 | mutex_unlock(&data->update_lock); |
228 | return count; | 229 | return count; |
229 | } | 230 | } |
230 | 231 | ||
@@ -288,10 +289,10 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr, | |||
288 | struct lm78_data *data = i2c_get_clientdata(client); | 289 | struct lm78_data *data = i2c_get_clientdata(client); |
289 | long val = simple_strtol(buf, NULL, 10); | 290 | long val = simple_strtol(buf, NULL, 10); |
290 | 291 | ||
291 | down(&data->update_lock); | 292 | mutex_lock(&data->update_lock); |
292 | data->temp_over = TEMP_TO_REG(val); | 293 | data->temp_over = TEMP_TO_REG(val); |
293 | lm78_write_value(client, LM78_REG_TEMP_OVER, data->temp_over); | 294 | lm78_write_value(client, LM78_REG_TEMP_OVER, data->temp_over); |
294 | up(&data->update_lock); | 295 | mutex_unlock(&data->update_lock); |
295 | return count; | 296 | return count; |
296 | } | 297 | } |
297 | 298 | ||
@@ -307,10 +308,10 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr, | |||
307 | struct lm78_data *data = i2c_get_clientdata(client); | 308 | struct lm78_data *data = i2c_get_clientdata(client); |
308 | long val = simple_strtol(buf, NULL, 10); | 309 | long val = simple_strtol(buf, NULL, 10); |
309 | 310 | ||
310 | down(&data->update_lock); | 311 | mutex_lock(&data->update_lock); |
311 | data->temp_hyst = TEMP_TO_REG(val); | 312 | data->temp_hyst = TEMP_TO_REG(val); |
312 | lm78_write_value(client, LM78_REG_TEMP_HYST, data->temp_hyst); | 313 | lm78_write_value(client, LM78_REG_TEMP_HYST, data->temp_hyst); |
313 | up(&data->update_lock); | 314 | mutex_unlock(&data->update_lock); |
314 | return count; | 315 | return count; |
315 | } | 316 | } |
316 | 317 | ||
@@ -342,10 +343,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
342 | struct lm78_data *data = i2c_get_clientdata(client); | 343 | struct lm78_data *data = i2c_get_clientdata(client); |
343 | unsigned long val = simple_strtoul(buf, NULL, 10); | 344 | unsigned long val = simple_strtoul(buf, NULL, 10); |
344 | 345 | ||
345 | down(&data->update_lock); | 346 | mutex_lock(&data->update_lock); |
346 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 347 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
347 | lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); | 348 | lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); |
348 | up(&data->update_lock); | 349 | mutex_unlock(&data->update_lock); |
349 | return count; | 350 | return count; |
350 | } | 351 | } |
351 | 352 | ||
@@ -368,7 +369,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
368 | unsigned long min; | 369 | unsigned long min; |
369 | u8 reg; | 370 | u8 reg; |
370 | 371 | ||
371 | down(&data->update_lock); | 372 | mutex_lock(&data->update_lock); |
372 | min = FAN_FROM_REG(data->fan_min[nr], | 373 | min = FAN_FROM_REG(data->fan_min[nr], |
373 | DIV_FROM_REG(data->fan_div[nr])); | 374 | DIV_FROM_REG(data->fan_div[nr])); |
374 | 375 | ||
@@ -380,7 +381,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
380 | default: | 381 | default: |
381 | dev_err(&client->dev, "fan_div value %ld not " | 382 | dev_err(&client->dev, "fan_div value %ld not " |
382 | "supported. Choose one of 1, 2, 4 or 8!\n", val); | 383 | "supported. Choose one of 1, 2, 4 or 8!\n", val); |
383 | up(&data->update_lock); | 384 | mutex_unlock(&data->update_lock); |
384 | return -EINVAL; | 385 | return -EINVAL; |
385 | } | 386 | } |
386 | 387 | ||
@@ -398,7 +399,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
398 | data->fan_min[nr] = | 399 | data->fan_min[nr] = |
399 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 400 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
400 | lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); | 401 | lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); |
401 | up(&data->update_lock); | 402 | mutex_unlock(&data->update_lock); |
402 | 403 | ||
403 | return count; | 404 | return count; |
404 | } | 405 | } |
@@ -548,7 +549,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind) | |||
548 | 549 | ||
549 | new_client = &data->client; | 550 | new_client = &data->client; |
550 | if (is_isa) | 551 | if (is_isa) |
551 | init_MUTEX(&data->lock); | 552 | mutex_init(&data->lock); |
552 | i2c_set_clientdata(new_client, data); | 553 | i2c_set_clientdata(new_client, data); |
553 | new_client->addr = address; | 554 | new_client->addr = address; |
554 | new_client->adapter = adapter; | 555 | new_client->adapter = adapter; |
@@ -598,7 +599,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind) | |||
598 | data->type = kind; | 599 | data->type = kind; |
599 | 600 | ||
600 | data->valid = 0; | 601 | data->valid = 0; |
601 | init_MUTEX(&data->update_lock); | 602 | mutex_init(&data->update_lock); |
602 | 603 | ||
603 | /* Tell the I2C layer a new client has arrived */ | 604 | /* Tell the I2C layer a new client has arrived */ |
604 | if ((err = i2c_attach_client(new_client))) | 605 | if ((err = i2c_attach_client(new_client))) |
@@ -697,10 +698,10 @@ static int lm78_read_value(struct i2c_client *client, u8 reg) | |||
697 | int res; | 698 | int res; |
698 | if (i2c_is_isa_client(client)) { | 699 | if (i2c_is_isa_client(client)) { |
699 | struct lm78_data *data = i2c_get_clientdata(client); | 700 | struct lm78_data *data = i2c_get_clientdata(client); |
700 | down(&data->lock); | 701 | mutex_lock(&data->lock); |
701 | outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); | 702 | outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); |
702 | res = inb_p(client->addr + LM78_DATA_REG_OFFSET); | 703 | res = inb_p(client->addr + LM78_DATA_REG_OFFSET); |
703 | up(&data->lock); | 704 | mutex_unlock(&data->lock); |
704 | return res; | 705 | return res; |
705 | } else | 706 | } else |
706 | return i2c_smbus_read_byte_data(client, reg); | 707 | return i2c_smbus_read_byte_data(client, reg); |
@@ -717,10 +718,10 @@ static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value) | |||
717 | { | 718 | { |
718 | if (i2c_is_isa_client(client)) { | 719 | if (i2c_is_isa_client(client)) { |
719 | struct lm78_data *data = i2c_get_clientdata(client); | 720 | struct lm78_data *data = i2c_get_clientdata(client); |
720 | down(&data->lock); | 721 | mutex_lock(&data->lock); |
721 | outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); | 722 | outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); |
722 | outb_p(value, client->addr + LM78_DATA_REG_OFFSET); | 723 | outb_p(value, client->addr + LM78_DATA_REG_OFFSET); |
723 | up(&data->lock); | 724 | mutex_unlock(&data->lock); |
724 | return 0; | 725 | return 0; |
725 | } else | 726 | } else |
726 | return i2c_smbus_write_byte_data(client, reg, value); | 727 | return i2c_smbus_write_byte_data(client, reg, value); |
@@ -742,7 +743,7 @@ static struct lm78_data *lm78_update_device(struct device *dev) | |||
742 | struct lm78_data *data = i2c_get_clientdata(client); | 743 | struct lm78_data *data = i2c_get_clientdata(client); |
743 | int i; | 744 | int i; |
744 | 745 | ||
745 | down(&data->update_lock); | 746 | mutex_lock(&data->update_lock); |
746 | 747 | ||
747 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 748 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
748 | || !data->valid) { | 749 | || !data->valid) { |
@@ -786,7 +787,7 @@ static struct lm78_data *lm78_update_device(struct device *dev) | |||
786 | data->fan_div[2] = 1; | 787 | data->fan_div[2] = 1; |
787 | } | 788 | } |
788 | 789 | ||
789 | up(&data->update_lock); | 790 | mutex_unlock(&data->update_lock); |
790 | 791 | ||
791 | return data; | 792 | return data; |
792 | } | 793 | } |
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index c9a7cdea7bd7..f72120d08c4c 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/hwmon.h> | 29 | #include <linux/hwmon.h> |
30 | #include <linux/err.h> | 30 | #include <linux/err.h> |
31 | #include <linux/mutex.h> | ||
31 | 32 | ||
32 | /* Addresses to scan */ | 33 | /* Addresses to scan */ |
33 | static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, | 34 | static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, |
@@ -108,7 +109,7 @@ static inline long TEMP_FROM_REG(u16 temp) | |||
108 | struct lm80_data { | 109 | struct lm80_data { |
109 | struct i2c_client client; | 110 | struct i2c_client client; |
110 | struct class_device *class_dev; | 111 | struct class_device *class_dev; |
111 | struct semaphore update_lock; | 112 | struct mutex update_lock; |
112 | char valid; /* !=0 if following fields are valid */ | 113 | char valid; /* !=0 if following fields are valid */ |
113 | unsigned long last_updated; /* In jiffies */ | 114 | unsigned long last_updated; /* In jiffies */ |
114 | 115 | ||
@@ -191,10 +192,10 @@ static ssize_t set_in_##suffix(struct device *dev, struct device_attribute *attr | |||
191 | struct lm80_data *data = i2c_get_clientdata(client); \ | 192 | struct lm80_data *data = i2c_get_clientdata(client); \ |
192 | long val = simple_strtol(buf, NULL, 10); \ | 193 | long val = simple_strtol(buf, NULL, 10); \ |
193 | \ | 194 | \ |
194 | down(&data->update_lock);\ | 195 | mutex_lock(&data->update_lock);\ |
195 | data->value = IN_TO_REG(val); \ | 196 | data->value = IN_TO_REG(val); \ |
196 | lm80_write_value(client, reg, data->value); \ | 197 | lm80_write_value(client, reg, data->value); \ |
197 | up(&data->update_lock);\ | 198 | mutex_unlock(&data->update_lock);\ |
198 | return count; \ | 199 | return count; \ |
199 | } | 200 | } |
200 | set_in(min0, in_min[0], LM80_REG_IN_MIN(0)); | 201 | set_in(min0, in_min[0], LM80_REG_IN_MIN(0)); |
@@ -241,10 +242,10 @@ static ssize_t set_fan_##suffix(struct device *dev, struct device_attribute *att | |||
241 | struct lm80_data *data = i2c_get_clientdata(client); \ | 242 | struct lm80_data *data = i2c_get_clientdata(client); \ |
242 | long val = simple_strtoul(buf, NULL, 10); \ | 243 | long val = simple_strtoul(buf, NULL, 10); \ |
243 | \ | 244 | \ |
244 | down(&data->update_lock);\ | 245 | mutex_lock(&data->update_lock);\ |
245 | data->value = FAN_TO_REG(val, DIV_FROM_REG(data->div)); \ | 246 | data->value = FAN_TO_REG(val, DIV_FROM_REG(data->div)); \ |
246 | lm80_write_value(client, reg, data->value); \ | 247 | lm80_write_value(client, reg, data->value); \ |
247 | up(&data->update_lock);\ | 248 | mutex_unlock(&data->update_lock);\ |
248 | return count; \ | 249 | return count; \ |
249 | } | 250 | } |
250 | set_fan(min1, fan_min[0], LM80_REG_FAN_MIN(1), fan_div[0]); | 251 | set_fan(min1, fan_min[0], LM80_REG_FAN_MIN(1), fan_div[0]); |
@@ -263,7 +264,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
263 | u8 reg; | 264 | u8 reg; |
264 | 265 | ||
265 | /* Save fan_min */ | 266 | /* Save fan_min */ |
266 | down(&data->update_lock); | 267 | mutex_lock(&data->update_lock); |
267 | min = FAN_FROM_REG(data->fan_min[nr], | 268 | min = FAN_FROM_REG(data->fan_min[nr], |
268 | DIV_FROM_REG(data->fan_div[nr])); | 269 | DIV_FROM_REG(data->fan_div[nr])); |
269 | 270 | ||
@@ -275,7 +276,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
275 | default: | 276 | default: |
276 | dev_err(&client->dev, "fan_div value %ld not " | 277 | dev_err(&client->dev, "fan_div value %ld not " |
277 | "supported. Choose one of 1, 2, 4 or 8!\n", val); | 278 | "supported. Choose one of 1, 2, 4 or 8!\n", val); |
278 | up(&data->update_lock); | 279 | mutex_unlock(&data->update_lock); |
279 | return -EINVAL; | 280 | return -EINVAL; |
280 | } | 281 | } |
281 | 282 | ||
@@ -286,7 +287,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
286 | /* Restore fan_min */ | 287 | /* Restore fan_min */ |
287 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 288 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
288 | lm80_write_value(client, LM80_REG_FAN_MIN(nr + 1), data->fan_min[nr]); | 289 | lm80_write_value(client, LM80_REG_FAN_MIN(nr + 1), data->fan_min[nr]); |
289 | up(&data->update_lock); | 290 | mutex_unlock(&data->update_lock); |
290 | 291 | ||
291 | return count; | 292 | return count; |
292 | } | 293 | } |
@@ -325,10 +326,10 @@ static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *at | |||
325 | struct lm80_data *data = i2c_get_clientdata(client); \ | 326 | struct lm80_data *data = i2c_get_clientdata(client); \ |
326 | long val = simple_strtoul(buf, NULL, 10); \ | 327 | long val = simple_strtoul(buf, NULL, 10); \ |
327 | \ | 328 | \ |
328 | down(&data->update_lock); \ | 329 | mutex_lock(&data->update_lock); \ |
329 | data->value = TEMP_LIMIT_TO_REG(val); \ | 330 | data->value = TEMP_LIMIT_TO_REG(val); \ |
330 | lm80_write_value(client, reg, data->value); \ | 331 | lm80_write_value(client, reg, data->value); \ |
331 | up(&data->update_lock); \ | 332 | mutex_unlock(&data->update_lock); \ |
332 | return count; \ | 333 | return count; \ |
333 | } | 334 | } |
334 | set_temp(hot_max, temp_hot_max, LM80_REG_TEMP_HOT_MAX); | 335 | set_temp(hot_max, temp_hot_max, LM80_REG_TEMP_HOT_MAX); |
@@ -437,7 +438,7 @@ static int lm80_detect(struct i2c_adapter *adapter, int address, int kind) | |||
437 | /* Fill in the remaining client fields and put it into the global list */ | 438 | /* Fill in the remaining client fields and put it into the global list */ |
438 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 439 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
439 | data->valid = 0; | 440 | data->valid = 0; |
440 | init_MUTEX(&data->update_lock); | 441 | mutex_init(&data->update_lock); |
441 | 442 | ||
442 | /* Tell the I2C layer a new client has arrived */ | 443 | /* Tell the I2C layer a new client has arrived */ |
443 | if ((err = i2c_attach_client(new_client))) | 444 | if ((err = i2c_attach_client(new_client))) |
@@ -545,7 +546,7 @@ static struct lm80_data *lm80_update_device(struct device *dev) | |||
545 | struct lm80_data *data = i2c_get_clientdata(client); | 546 | struct lm80_data *data = i2c_get_clientdata(client); |
546 | int i; | 547 | int i; |
547 | 548 | ||
548 | down(&data->update_lock); | 549 | mutex_lock(&data->update_lock); |
549 | 550 | ||
550 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { | 551 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { |
551 | dev_dbg(&client->dev, "Starting lm80 update\n"); | 552 | dev_dbg(&client->dev, "Starting lm80 update\n"); |
@@ -585,7 +586,7 @@ static struct lm80_data *lm80_update_device(struct device *dev) | |||
585 | data->valid = 1; | 586 | data->valid = 1; |
586 | } | 587 | } |
587 | 588 | ||
588 | up(&data->update_lock); | 589 | mutex_unlock(&data->update_lock); |
589 | 590 | ||
590 | return data; | 591 | return data; |
591 | } | 592 | } |
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index 26dfa9e216c2..aac4ec2bf694 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/hwmon-sysfs.h> | 35 | #include <linux/hwmon-sysfs.h> |
36 | #include <linux/hwmon.h> | 36 | #include <linux/hwmon.h> |
37 | #include <linux/err.h> | 37 | #include <linux/err.h> |
38 | #include <linux/mutex.h> | ||
38 | 39 | ||
39 | /* | 40 | /* |
40 | * Addresses to scan | 41 | * Addresses to scan |
@@ -139,7 +140,7 @@ static struct i2c_driver lm83_driver = { | |||
139 | struct lm83_data { | 140 | struct lm83_data { |
140 | struct i2c_client client; | 141 | struct i2c_client client; |
141 | struct class_device *class_dev; | 142 | struct class_device *class_dev; |
142 | struct semaphore update_lock; | 143 | struct mutex update_lock; |
143 | char valid; /* zero until following fields are valid */ | 144 | char valid; /* zero until following fields are valid */ |
144 | unsigned long last_updated; /* in jiffies */ | 145 | unsigned long last_updated; /* in jiffies */ |
145 | 146 | ||
@@ -171,11 +172,11 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, | |||
171 | long val = simple_strtol(buf, NULL, 10); | 172 | long val = simple_strtol(buf, NULL, 10); |
172 | int nr = attr->index; | 173 | int nr = attr->index; |
173 | 174 | ||
174 | down(&data->update_lock); | 175 | mutex_lock(&data->update_lock); |
175 | data->temp[nr] = TEMP_TO_REG(val); | 176 | data->temp[nr] = TEMP_TO_REG(val); |
176 | i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4], | 177 | i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4], |
177 | data->temp[nr]); | 178 | data->temp[nr]); |
178 | up(&data->update_lock); | 179 | mutex_unlock(&data->update_lock); |
179 | return count; | 180 | return count; |
180 | } | 181 | } |
181 | 182 | ||
@@ -300,7 +301,7 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind) | |||
300 | /* We can fill in the remaining client fields */ | 301 | /* We can fill in the remaining client fields */ |
301 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 302 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
302 | data->valid = 0; | 303 | data->valid = 0; |
303 | init_MUTEX(&data->update_lock); | 304 | mutex_init(&data->update_lock); |
304 | 305 | ||
305 | /* Tell the I2C layer a new client has arrived */ | 306 | /* Tell the I2C layer a new client has arrived */ |
306 | if ((err = i2c_attach_client(new_client))) | 307 | if ((err = i2c_attach_client(new_client))) |
@@ -373,7 +374,7 @@ static struct lm83_data *lm83_update_device(struct device *dev) | |||
373 | struct i2c_client *client = to_i2c_client(dev); | 374 | struct i2c_client *client = to_i2c_client(dev); |
374 | struct lm83_data *data = i2c_get_clientdata(client); | 375 | struct lm83_data *data = i2c_get_clientdata(client); |
375 | 376 | ||
376 | down(&data->update_lock); | 377 | mutex_lock(&data->update_lock); |
377 | 378 | ||
378 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 379 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
379 | int nr; | 380 | int nr; |
@@ -393,7 +394,7 @@ static struct lm83_data *lm83_update_device(struct device *dev) | |||
393 | data->valid = 1; | 394 | data->valid = 1; |
394 | } | 395 | } |
395 | 396 | ||
396 | up(&data->update_lock); | 397 | mutex_unlock(&data->update_lock); |
397 | 398 | ||
398 | return data; | 399 | return data; |
399 | } | 400 | } |
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 7389a0127547..342e9663119d 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/hwmon.h> | 31 | #include <linux/hwmon.h> |
32 | #include <linux/hwmon-vid.h> | 32 | #include <linux/hwmon-vid.h> |
33 | #include <linux/err.h> | 33 | #include <linux/err.h> |
34 | #include <linux/mutex.h> | ||
34 | 35 | ||
35 | /* Addresses to scan */ | 36 | /* Addresses to scan */ |
36 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 37 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
@@ -331,10 +332,10 @@ struct lm85_autofan { | |||
331 | struct lm85_data { | 332 | struct lm85_data { |
332 | struct i2c_client client; | 333 | struct i2c_client client; |
333 | struct class_device *class_dev; | 334 | struct class_device *class_dev; |
334 | struct semaphore lock; | 335 | struct mutex lock; |
335 | enum chips type; | 336 | enum chips type; |
336 | 337 | ||
337 | struct semaphore update_lock; | 338 | struct mutex update_lock; |
338 | int valid; /* !=0 if following fields are valid */ | 339 | int valid; /* !=0 if following fields are valid */ |
339 | unsigned long last_reading; /* In jiffies */ | 340 | unsigned long last_reading; /* In jiffies */ |
340 | unsigned long last_config; /* In jiffies */ | 341 | unsigned long last_config; /* In jiffies */ |
@@ -373,8 +374,8 @@ static int lm85_detect(struct i2c_adapter *adapter, int address, | |||
373 | int kind); | 374 | int kind); |
374 | static int lm85_detach_client(struct i2c_client *client); | 375 | static int lm85_detach_client(struct i2c_client *client); |
375 | 376 | ||
376 | static int lm85_read_value(struct i2c_client *client, u8 register); | 377 | static int lm85_read_value(struct i2c_client *client, u8 reg); |
377 | static int lm85_write_value(struct i2c_client *client, u8 register, int value); | 378 | static int lm85_write_value(struct i2c_client *client, u8 reg, int value); |
378 | static struct lm85_data *lm85_update_device(struct device *dev); | 379 | static struct lm85_data *lm85_update_device(struct device *dev); |
379 | static void lm85_init_client(struct i2c_client *client); | 380 | static void lm85_init_client(struct i2c_client *client); |
380 | 381 | ||
@@ -407,10 +408,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
407 | struct lm85_data *data = i2c_get_clientdata(client); | 408 | struct lm85_data *data = i2c_get_clientdata(client); |
408 | long val = simple_strtol(buf, NULL, 10); | 409 | long val = simple_strtol(buf, NULL, 10); |
409 | 410 | ||
410 | down(&data->update_lock); | 411 | mutex_lock(&data->update_lock); |
411 | data->fan_min[nr] = FAN_TO_REG(val); | 412 | data->fan_min[nr] = FAN_TO_REG(val); |
412 | lm85_write_value(client, LM85_REG_FAN_MIN(nr), data->fan_min[nr]); | 413 | lm85_write_value(client, LM85_REG_FAN_MIN(nr), data->fan_min[nr]); |
413 | up(&data->update_lock); | 414 | mutex_unlock(&data->update_lock); |
414 | return count; | 415 | return count; |
415 | } | 416 | } |
416 | 417 | ||
@@ -499,10 +500,10 @@ static ssize_t set_pwm(struct device *dev, const char *buf, | |||
499 | struct lm85_data *data = i2c_get_clientdata(client); | 500 | struct lm85_data *data = i2c_get_clientdata(client); |
500 | long val = simple_strtol(buf, NULL, 10); | 501 | long val = simple_strtol(buf, NULL, 10); |
501 | 502 | ||
502 | down(&data->update_lock); | 503 | mutex_lock(&data->update_lock); |
503 | data->pwm[nr] = PWM_TO_REG(val); | 504 | data->pwm[nr] = PWM_TO_REG(val); |
504 | lm85_write_value(client, LM85_REG_PWM(nr), data->pwm[nr]); | 505 | lm85_write_value(client, LM85_REG_PWM(nr), data->pwm[nr]); |
505 | up(&data->update_lock); | 506 | mutex_unlock(&data->update_lock); |
506 | return count; | 507 | return count; |
507 | } | 508 | } |
508 | static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr) | 509 | static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr) |
@@ -559,10 +560,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf, | |||
559 | struct lm85_data *data = i2c_get_clientdata(client); | 560 | struct lm85_data *data = i2c_get_clientdata(client); |
560 | long val = simple_strtol(buf, NULL, 10); | 561 | long val = simple_strtol(buf, NULL, 10); |
561 | 562 | ||
562 | down(&data->update_lock); | 563 | mutex_lock(&data->update_lock); |
563 | data->in_min[nr] = INS_TO_REG(nr, val); | 564 | data->in_min[nr] = INS_TO_REG(nr, val); |
564 | lm85_write_value(client, LM85_REG_IN_MIN(nr), data->in_min[nr]); | 565 | lm85_write_value(client, LM85_REG_IN_MIN(nr), data->in_min[nr]); |
565 | up(&data->update_lock); | 566 | mutex_unlock(&data->update_lock); |
566 | return count; | 567 | return count; |
567 | } | 568 | } |
568 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) | 569 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) |
@@ -577,10 +578,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
577 | struct lm85_data *data = i2c_get_clientdata(client); | 578 | struct lm85_data *data = i2c_get_clientdata(client); |
578 | long val = simple_strtol(buf, NULL, 10); | 579 | long val = simple_strtol(buf, NULL, 10); |
579 | 580 | ||
580 | down(&data->update_lock); | 581 | mutex_lock(&data->update_lock); |
581 | data->in_max[nr] = INS_TO_REG(nr, val); | 582 | data->in_max[nr] = INS_TO_REG(nr, val); |
582 | lm85_write_value(client, LM85_REG_IN_MAX(nr), data->in_max[nr]); | 583 | lm85_write_value(client, LM85_REG_IN_MAX(nr), data->in_max[nr]); |
583 | up(&data->update_lock); | 584 | mutex_unlock(&data->update_lock); |
584 | return count; | 585 | return count; |
585 | } | 586 | } |
586 | #define show_in_reg(offset) \ | 587 | #define show_in_reg(offset) \ |
@@ -640,10 +641,10 @@ static ssize_t set_temp_min(struct device *dev, const char *buf, | |||
640 | struct lm85_data *data = i2c_get_clientdata(client); | 641 | struct lm85_data *data = i2c_get_clientdata(client); |
641 | long val = simple_strtol(buf, NULL, 10); | 642 | long val = simple_strtol(buf, NULL, 10); |
642 | 643 | ||
643 | down(&data->update_lock); | 644 | mutex_lock(&data->update_lock); |
644 | data->temp_min[nr] = TEMP_TO_REG(val); | 645 | data->temp_min[nr] = TEMP_TO_REG(val); |
645 | lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]); | 646 | lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]); |
646 | up(&data->update_lock); | 647 | mutex_unlock(&data->update_lock); |
647 | return count; | 648 | return count; |
648 | } | 649 | } |
649 | static ssize_t show_temp_max(struct device *dev, char *buf, int nr) | 650 | static ssize_t show_temp_max(struct device *dev, char *buf, int nr) |
@@ -658,10 +659,10 @@ static ssize_t set_temp_max(struct device *dev, const char *buf, | |||
658 | struct lm85_data *data = i2c_get_clientdata(client); | 659 | struct lm85_data *data = i2c_get_clientdata(client); |
659 | long val = simple_strtol(buf, NULL, 10); | 660 | long val = simple_strtol(buf, NULL, 10); |
660 | 661 | ||
661 | down(&data->update_lock); | 662 | mutex_lock(&data->update_lock); |
662 | data->temp_max[nr] = TEMP_TO_REG(val); | 663 | data->temp_max[nr] = TEMP_TO_REG(val); |
663 | lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]); | 664 | lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]); |
664 | up(&data->update_lock); | 665 | mutex_unlock(&data->update_lock); |
665 | return count; | 666 | return count; |
666 | } | 667 | } |
667 | #define show_temp_reg(offset) \ | 668 | #define show_temp_reg(offset) \ |
@@ -713,12 +714,12 @@ static ssize_t set_pwm_auto_channels(struct device *dev, const char *buf, | |||
713 | struct lm85_data *data = i2c_get_clientdata(client); | 714 | struct lm85_data *data = i2c_get_clientdata(client); |
714 | long val = simple_strtol(buf, NULL, 10); | 715 | long val = simple_strtol(buf, NULL, 10); |
715 | 716 | ||
716 | down(&data->update_lock); | 717 | mutex_lock(&data->update_lock); |
717 | data->autofan[nr].config = (data->autofan[nr].config & (~0xe0)) | 718 | data->autofan[nr].config = (data->autofan[nr].config & (~0xe0)) |
718 | | ZONE_TO_REG(val) ; | 719 | | ZONE_TO_REG(val) ; |
719 | lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), | 720 | lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), |
720 | data->autofan[nr].config); | 721 | data->autofan[nr].config); |
721 | up(&data->update_lock); | 722 | mutex_unlock(&data->update_lock); |
722 | return count; | 723 | return count; |
723 | } | 724 | } |
724 | static ssize_t show_pwm_auto_pwm_min(struct device *dev, char *buf, int nr) | 725 | static ssize_t show_pwm_auto_pwm_min(struct device *dev, char *buf, int nr) |
@@ -733,11 +734,11 @@ static ssize_t set_pwm_auto_pwm_min(struct device *dev, const char *buf, | |||
733 | struct lm85_data *data = i2c_get_clientdata(client); | 734 | struct lm85_data *data = i2c_get_clientdata(client); |
734 | long val = simple_strtol(buf, NULL, 10); | 735 | long val = simple_strtol(buf, NULL, 10); |
735 | 736 | ||
736 | down(&data->update_lock); | 737 | mutex_lock(&data->update_lock); |
737 | data->autofan[nr].min_pwm = PWM_TO_REG(val); | 738 | data->autofan[nr].min_pwm = PWM_TO_REG(val); |
738 | lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr), | 739 | lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr), |
739 | data->autofan[nr].min_pwm); | 740 | data->autofan[nr].min_pwm); |
740 | up(&data->update_lock); | 741 | mutex_unlock(&data->update_lock); |
741 | return count; | 742 | return count; |
742 | } | 743 | } |
743 | static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, char *buf, int nr) | 744 | static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, char *buf, int nr) |
@@ -752,7 +753,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf, | |||
752 | struct lm85_data *data = i2c_get_clientdata(client); | 753 | struct lm85_data *data = i2c_get_clientdata(client); |
753 | long val = simple_strtol(buf, NULL, 10); | 754 | long val = simple_strtol(buf, NULL, 10); |
754 | 755 | ||
755 | down(&data->update_lock); | 756 | mutex_lock(&data->update_lock); |
756 | data->autofan[nr].min_off = val; | 757 | data->autofan[nr].min_off = val; |
757 | lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0] | 758 | lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0] |
758 | | data->syncpwm3 | 759 | | data->syncpwm3 |
@@ -760,7 +761,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf, | |||
760 | | (data->autofan[1].min_off ? 0x40 : 0) | 761 | | (data->autofan[1].min_off ? 0x40 : 0) |
761 | | (data->autofan[2].min_off ? 0x80 : 0) | 762 | | (data->autofan[2].min_off ? 0x80 : 0) |
762 | ); | 763 | ); |
763 | up(&data->update_lock); | 764 | mutex_unlock(&data->update_lock); |
764 | return count; | 765 | return count; |
765 | } | 766 | } |
766 | static ssize_t show_pwm_auto_pwm_freq(struct device *dev, char *buf, int nr) | 767 | static ssize_t show_pwm_auto_pwm_freq(struct device *dev, char *buf, int nr) |
@@ -775,13 +776,13 @@ static ssize_t set_pwm_auto_pwm_freq(struct device *dev, const char *buf, | |||
775 | struct lm85_data *data = i2c_get_clientdata(client); | 776 | struct lm85_data *data = i2c_get_clientdata(client); |
776 | long val = simple_strtol(buf, NULL, 10); | 777 | long val = simple_strtol(buf, NULL, 10); |
777 | 778 | ||
778 | down(&data->update_lock); | 779 | mutex_lock(&data->update_lock); |
779 | data->autofan[nr].freq = FREQ_TO_REG(val); | 780 | data->autofan[nr].freq = FREQ_TO_REG(val); |
780 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), | 781 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), |
781 | (data->zone[nr].range << 4) | 782 | (data->zone[nr].range << 4) |
782 | | data->autofan[nr].freq | 783 | | data->autofan[nr].freq |
783 | ); | 784 | ); |
784 | up(&data->update_lock); | 785 | mutex_unlock(&data->update_lock); |
785 | return count; | 786 | return count; |
786 | } | 787 | } |
787 | #define pwm_auto(offset) \ | 788 | #define pwm_auto(offset) \ |
@@ -857,7 +858,7 @@ static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf, | |||
857 | int min; | 858 | int min; |
858 | long val = simple_strtol(buf, NULL, 10); | 859 | long val = simple_strtol(buf, NULL, 10); |
859 | 860 | ||
860 | down(&data->update_lock); | 861 | mutex_lock(&data->update_lock); |
861 | min = TEMP_FROM_REG(data->zone[nr].limit); | 862 | min = TEMP_FROM_REG(data->zone[nr].limit); |
862 | data->zone[nr].off_desired = TEMP_TO_REG(val); | 863 | data->zone[nr].off_desired = TEMP_TO_REG(val); |
863 | data->zone[nr].hyst = HYST_TO_REG(min - val); | 864 | data->zone[nr].hyst = HYST_TO_REG(min - val); |
@@ -871,7 +872,7 @@ static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf, | |||
871 | (data->zone[2].hyst << 4) | 872 | (data->zone[2].hyst << 4) |
872 | ); | 873 | ); |
873 | } | 874 | } |
874 | up(&data->update_lock); | 875 | mutex_unlock(&data->update_lock); |
875 | return count; | 876 | return count; |
876 | } | 877 | } |
877 | static ssize_t show_temp_auto_temp_min(struct device *dev, char *buf, int nr) | 878 | static ssize_t show_temp_auto_temp_min(struct device *dev, char *buf, int nr) |
@@ -886,7 +887,7 @@ static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf, | |||
886 | struct lm85_data *data = i2c_get_clientdata(client); | 887 | struct lm85_data *data = i2c_get_clientdata(client); |
887 | long val = simple_strtol(buf, NULL, 10); | 888 | long val = simple_strtol(buf, NULL, 10); |
888 | 889 | ||
889 | down(&data->update_lock); | 890 | mutex_lock(&data->update_lock); |
890 | data->zone[nr].limit = TEMP_TO_REG(val); | 891 | data->zone[nr].limit = TEMP_TO_REG(val); |
891 | lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr), | 892 | lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr), |
892 | data->zone[nr].limit); | 893 | data->zone[nr].limit); |
@@ -913,7 +914,7 @@ static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf, | |||
913 | (data->zone[2].hyst << 4) | 914 | (data->zone[2].hyst << 4) |
914 | ); | 915 | ); |
915 | } | 916 | } |
916 | up(&data->update_lock); | 917 | mutex_unlock(&data->update_lock); |
917 | return count; | 918 | return count; |
918 | } | 919 | } |
919 | static ssize_t show_temp_auto_temp_max(struct device *dev, char *buf, int nr) | 920 | static ssize_t show_temp_auto_temp_max(struct device *dev, char *buf, int nr) |
@@ -930,7 +931,7 @@ static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf, | |||
930 | int min; | 931 | int min; |
931 | long val = simple_strtol(buf, NULL, 10); | 932 | long val = simple_strtol(buf, NULL, 10); |
932 | 933 | ||
933 | down(&data->update_lock); | 934 | mutex_lock(&data->update_lock); |
934 | min = TEMP_FROM_REG(data->zone[nr].limit); | 935 | min = TEMP_FROM_REG(data->zone[nr].limit); |
935 | data->zone[nr].max_desired = TEMP_TO_REG(val); | 936 | data->zone[nr].max_desired = TEMP_TO_REG(val); |
936 | data->zone[nr].range = RANGE_TO_REG( | 937 | data->zone[nr].range = RANGE_TO_REG( |
@@ -938,7 +939,7 @@ static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf, | |||
938 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), | 939 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), |
939 | ((data->zone[nr].range & 0x0f) << 4) | 940 | ((data->zone[nr].range & 0x0f) << 4) |
940 | | (data->autofan[nr].freq & 0x07)); | 941 | | (data->autofan[nr].freq & 0x07)); |
941 | up(&data->update_lock); | 942 | mutex_unlock(&data->update_lock); |
942 | return count; | 943 | return count; |
943 | } | 944 | } |
944 | static ssize_t show_temp_auto_temp_crit(struct device *dev, char *buf, int nr) | 945 | static ssize_t show_temp_auto_temp_crit(struct device *dev, char *buf, int nr) |
@@ -953,11 +954,11 @@ static ssize_t set_temp_auto_temp_crit(struct device *dev, const char *buf, | |||
953 | struct lm85_data *data = i2c_get_clientdata(client); | 954 | struct lm85_data *data = i2c_get_clientdata(client); |
954 | long val = simple_strtol(buf, NULL, 10); | 955 | long val = simple_strtol(buf, NULL, 10); |
955 | 956 | ||
956 | down(&data->update_lock); | 957 | mutex_lock(&data->update_lock); |
957 | data->zone[nr].critical = TEMP_TO_REG(val); | 958 | data->zone[nr].critical = TEMP_TO_REG(val); |
958 | lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr), | 959 | lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr), |
959 | data->zone[nr].critical); | 960 | data->zone[nr].critical); |
960 | up(&data->update_lock); | 961 | mutex_unlock(&data->update_lock); |
961 | return count; | 962 | return count; |
962 | } | 963 | } |
963 | #define temp_auto(offset) \ | 964 | #define temp_auto(offset) \ |
@@ -1149,7 +1150,7 @@ static int lm85_detect(struct i2c_adapter *adapter, int address, | |||
1149 | /* Fill in the remaining client fields */ | 1150 | /* Fill in the remaining client fields */ |
1150 | data->type = kind; | 1151 | data->type = kind; |
1151 | data->valid = 0; | 1152 | data->valid = 0; |
1152 | init_MUTEX(&data->update_lock); | 1153 | mutex_init(&data->update_lock); |
1153 | 1154 | ||
1154 | /* Tell the I2C layer a new client has arrived */ | 1155 | /* Tell the I2C layer a new client has arrived */ |
1155 | if ((err = i2c_attach_client(new_client))) | 1156 | if ((err = i2c_attach_client(new_client))) |
@@ -1368,7 +1369,7 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1368 | struct lm85_data *data = i2c_get_clientdata(client); | 1369 | struct lm85_data *data = i2c_get_clientdata(client); |
1369 | int i; | 1370 | int i; |
1370 | 1371 | ||
1371 | down(&data->update_lock); | 1372 | mutex_lock(&data->update_lock); |
1372 | 1373 | ||
1373 | if ( !data->valid || | 1374 | if ( !data->valid || |
1374 | time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) { | 1375 | time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) { |
@@ -1571,7 +1572,7 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1571 | 1572 | ||
1572 | data->valid = 1; | 1573 | data->valid = 1; |
1573 | 1574 | ||
1574 | up(&data->update_lock); | 1575 | mutex_unlock(&data->update_lock); |
1575 | 1576 | ||
1576 | return data; | 1577 | return data; |
1577 | } | 1578 | } |
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 6ba34c302d8d..e229daf666de 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c | |||
@@ -60,6 +60,7 @@ | |||
60 | #include <linux/hwmon.h> | 60 | #include <linux/hwmon.h> |
61 | #include <linux/hwmon-vid.h> | 61 | #include <linux/hwmon-vid.h> |
62 | #include <linux/err.h> | 62 | #include <linux/err.h> |
63 | #include <linux/mutex.h> | ||
63 | 64 | ||
64 | /* | 65 | /* |
65 | * Addresses to scan | 66 | * Addresses to scan |
@@ -176,7 +177,7 @@ static struct i2c_driver lm87_driver = { | |||
176 | struct lm87_data { | 177 | struct lm87_data { |
177 | struct i2c_client client; | 178 | struct i2c_client client; |
178 | struct class_device *class_dev; | 179 | struct class_device *class_dev; |
179 | struct semaphore update_lock; | 180 | struct mutex update_lock; |
180 | char valid; /* zero until following fields are valid */ | 181 | char valid; /* zero until following fields are valid */ |
181 | unsigned long last_updated; /* In jiffies */ | 182 | unsigned long last_updated; /* In jiffies */ |
182 | 183 | ||
@@ -253,11 +254,11 @@ static void set_in_min(struct device *dev, const char *buf, int nr) | |||
253 | struct lm87_data *data = i2c_get_clientdata(client); | 254 | struct lm87_data *data = i2c_get_clientdata(client); |
254 | long val = simple_strtol(buf, NULL, 10); | 255 | long val = simple_strtol(buf, NULL, 10); |
255 | 256 | ||
256 | down(&data->update_lock); | 257 | mutex_lock(&data->update_lock); |
257 | data->in_min[nr] = IN_TO_REG(val, data->in_scale[nr]); | 258 | data->in_min[nr] = IN_TO_REG(val, data->in_scale[nr]); |
258 | lm87_write_value(client, nr<6 ? LM87_REG_IN_MIN(nr) : | 259 | lm87_write_value(client, nr<6 ? LM87_REG_IN_MIN(nr) : |
259 | LM87_REG_AIN_MIN(nr-6), data->in_min[nr]); | 260 | LM87_REG_AIN_MIN(nr-6), data->in_min[nr]); |
260 | up(&data->update_lock); | 261 | mutex_unlock(&data->update_lock); |
261 | } | 262 | } |
262 | 263 | ||
263 | static void set_in_max(struct device *dev, const char *buf, int nr) | 264 | static void set_in_max(struct device *dev, const char *buf, int nr) |
@@ -266,11 +267,11 @@ static void set_in_max(struct device *dev, const char *buf, int nr) | |||
266 | struct lm87_data *data = i2c_get_clientdata(client); | 267 | struct lm87_data *data = i2c_get_clientdata(client); |
267 | long val = simple_strtol(buf, NULL, 10); | 268 | long val = simple_strtol(buf, NULL, 10); |
268 | 269 | ||
269 | down(&data->update_lock); | 270 | mutex_lock(&data->update_lock); |
270 | data->in_max[nr] = IN_TO_REG(val, data->in_scale[nr]); | 271 | data->in_max[nr] = IN_TO_REG(val, data->in_scale[nr]); |
271 | lm87_write_value(client, nr<6 ? LM87_REG_IN_MAX(nr) : | 272 | lm87_write_value(client, nr<6 ? LM87_REG_IN_MAX(nr) : |
272 | LM87_REG_AIN_MAX(nr-6), data->in_max[nr]); | 273 | LM87_REG_AIN_MAX(nr-6), data->in_max[nr]); |
273 | up(&data->update_lock); | 274 | mutex_unlock(&data->update_lock); |
274 | } | 275 | } |
275 | 276 | ||
276 | #define set_in(offset) \ | 277 | #define set_in(offset) \ |
@@ -327,10 +328,10 @@ static void set_temp_low(struct device *dev, const char *buf, int nr) | |||
327 | struct lm87_data *data = i2c_get_clientdata(client); | 328 | struct lm87_data *data = i2c_get_clientdata(client); |
328 | long val = simple_strtol(buf, NULL, 10); | 329 | long val = simple_strtol(buf, NULL, 10); |
329 | 330 | ||
330 | down(&data->update_lock); | 331 | mutex_lock(&data->update_lock); |
331 | data->temp_low[nr] = TEMP_TO_REG(val); | 332 | data->temp_low[nr] = TEMP_TO_REG(val); |
332 | lm87_write_value(client, LM87_REG_TEMP_LOW[nr], data->temp_low[nr]); | 333 | lm87_write_value(client, LM87_REG_TEMP_LOW[nr], data->temp_low[nr]); |
333 | up(&data->update_lock); | 334 | mutex_unlock(&data->update_lock); |
334 | } | 335 | } |
335 | 336 | ||
336 | static void set_temp_high(struct device *dev, const char *buf, int nr) | 337 | static void set_temp_high(struct device *dev, const char *buf, int nr) |
@@ -339,10 +340,10 @@ static void set_temp_high(struct device *dev, const char *buf, int nr) | |||
339 | struct lm87_data *data = i2c_get_clientdata(client); | 340 | struct lm87_data *data = i2c_get_clientdata(client); |
340 | long val = simple_strtol(buf, NULL, 10); | 341 | long val = simple_strtol(buf, NULL, 10); |
341 | 342 | ||
342 | down(&data->update_lock); | 343 | mutex_lock(&data->update_lock); |
343 | data->temp_high[nr] = TEMP_TO_REG(val); | 344 | data->temp_high[nr] = TEMP_TO_REG(val); |
344 | lm87_write_value(client, LM87_REG_TEMP_HIGH[nr], data->temp_high[nr]); | 345 | lm87_write_value(client, LM87_REG_TEMP_HIGH[nr], data->temp_high[nr]); |
345 | up(&data->update_lock); | 346 | mutex_unlock(&data->update_lock); |
346 | } | 347 | } |
347 | 348 | ||
348 | #define set_temp(offset) \ | 349 | #define set_temp(offset) \ |
@@ -411,11 +412,11 @@ static void set_fan_min(struct device *dev, const char *buf, int nr) | |||
411 | struct lm87_data *data = i2c_get_clientdata(client); | 412 | struct lm87_data *data = i2c_get_clientdata(client); |
412 | long val = simple_strtol(buf, NULL, 10); | 413 | long val = simple_strtol(buf, NULL, 10); |
413 | 414 | ||
414 | down(&data->update_lock); | 415 | mutex_lock(&data->update_lock); |
415 | data->fan_min[nr] = FAN_TO_REG(val, | 416 | data->fan_min[nr] = FAN_TO_REG(val, |
416 | FAN_DIV_FROM_REG(data->fan_div[nr])); | 417 | FAN_DIV_FROM_REG(data->fan_div[nr])); |
417 | lm87_write_value(client, LM87_REG_FAN_MIN(nr), data->fan_min[nr]); | 418 | lm87_write_value(client, LM87_REG_FAN_MIN(nr), data->fan_min[nr]); |
418 | up(&data->update_lock); | 419 | mutex_unlock(&data->update_lock); |
419 | } | 420 | } |
420 | 421 | ||
421 | /* Note: we save and restore the fan minimum here, because its value is | 422 | /* Note: we save and restore the fan minimum here, because its value is |
@@ -431,7 +432,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
431 | unsigned long min; | 432 | unsigned long min; |
432 | u8 reg; | 433 | u8 reg; |
433 | 434 | ||
434 | down(&data->update_lock); | 435 | mutex_lock(&data->update_lock); |
435 | min = FAN_FROM_REG(data->fan_min[nr], | 436 | min = FAN_FROM_REG(data->fan_min[nr], |
436 | FAN_DIV_FROM_REG(data->fan_div[nr])); | 437 | FAN_DIV_FROM_REG(data->fan_div[nr])); |
437 | 438 | ||
@@ -441,7 +442,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
441 | case 4: data->fan_div[nr] = 2; break; | 442 | case 4: data->fan_div[nr] = 2; break; |
442 | case 8: data->fan_div[nr] = 3; break; | 443 | case 8: data->fan_div[nr] = 3; break; |
443 | default: | 444 | default: |
444 | up(&data->update_lock); | 445 | mutex_unlock(&data->update_lock); |
445 | return -EINVAL; | 446 | return -EINVAL; |
446 | } | 447 | } |
447 | 448 | ||
@@ -459,7 +460,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
459 | data->fan_min[nr] = FAN_TO_REG(min, val); | 460 | data->fan_min[nr] = FAN_TO_REG(min, val); |
460 | lm87_write_value(client, LM87_REG_FAN_MIN(nr), | 461 | lm87_write_value(client, LM87_REG_FAN_MIN(nr), |
461 | data->fan_min[nr]); | 462 | data->fan_min[nr]); |
462 | up(&data->update_lock); | 463 | mutex_unlock(&data->update_lock); |
463 | 464 | ||
464 | return count; | 465 | return count; |
465 | } | 466 | } |
@@ -522,10 +523,10 @@ static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const | |||
522 | struct lm87_data *data = i2c_get_clientdata(client); | 523 | struct lm87_data *data = i2c_get_clientdata(client); |
523 | long val = simple_strtol(buf, NULL, 10); | 524 | long val = simple_strtol(buf, NULL, 10); |
524 | 525 | ||
525 | down(&data->update_lock); | 526 | mutex_lock(&data->update_lock); |
526 | data->aout = AOUT_TO_REG(val); | 527 | data->aout = AOUT_TO_REG(val); |
527 | lm87_write_value(client, LM87_REG_AOUT, data->aout); | 528 | lm87_write_value(client, LM87_REG_AOUT, data->aout); |
528 | up(&data->update_lock); | 529 | mutex_unlock(&data->update_lock); |
529 | return count; | 530 | return count; |
530 | } | 531 | } |
531 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); | 532 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); |
@@ -589,7 +590,7 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
589 | /* We can fill in the remaining client fields */ | 590 | /* We can fill in the remaining client fields */ |
590 | strlcpy(new_client->name, "lm87", I2C_NAME_SIZE); | 591 | strlcpy(new_client->name, "lm87", I2C_NAME_SIZE); |
591 | data->valid = 0; | 592 | data->valid = 0; |
592 | init_MUTEX(&data->update_lock); | 593 | mutex_init(&data->update_lock); |
593 | 594 | ||
594 | /* Tell the I2C layer a new client has arrived */ | 595 | /* Tell the I2C layer a new client has arrived */ |
595 | if ((err = i2c_attach_client(new_client))) | 596 | if ((err = i2c_attach_client(new_client))) |
@@ -744,7 +745,7 @@ static struct lm87_data *lm87_update_device(struct device *dev) | |||
744 | struct i2c_client *client = to_i2c_client(dev); | 745 | struct i2c_client *client = to_i2c_client(dev); |
745 | struct lm87_data *data = i2c_get_clientdata(client); | 746 | struct lm87_data *data = i2c_get_clientdata(client); |
746 | 747 | ||
747 | down(&data->update_lock); | 748 | mutex_lock(&data->update_lock); |
748 | 749 | ||
749 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | 750 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { |
750 | int i, j; | 751 | int i, j; |
@@ -813,7 +814,7 @@ static struct lm87_data *lm87_update_device(struct device *dev) | |||
813 | data->valid = 1; | 814 | data->valid = 1; |
814 | } | 815 | } |
815 | 816 | ||
816 | up(&data->update_lock); | 817 | mutex_unlock(&data->update_lock); |
817 | 818 | ||
818 | return data; | 819 | return data; |
819 | } | 820 | } |
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 5679464447cc..d9eeaf7585bd 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c | |||
@@ -78,6 +78,7 @@ | |||
78 | #include <linux/hwmon-sysfs.h> | 78 | #include <linux/hwmon-sysfs.h> |
79 | #include <linux/hwmon.h> | 79 | #include <linux/hwmon.h> |
80 | #include <linux/err.h> | 80 | #include <linux/err.h> |
81 | #include <linux/mutex.h> | ||
81 | 82 | ||
82 | /* | 83 | /* |
83 | * Addresses to scan | 84 | * Addresses to scan |
@@ -201,7 +202,7 @@ static struct i2c_driver lm90_driver = { | |||
201 | struct lm90_data { | 202 | struct lm90_data { |
202 | struct i2c_client client; | 203 | struct i2c_client client; |
203 | struct class_device *class_dev; | 204 | struct class_device *class_dev; |
204 | struct semaphore update_lock; | 205 | struct mutex update_lock; |
205 | char valid; /* zero until following fields are valid */ | 206 | char valid; /* zero until following fields are valid */ |
206 | unsigned long last_updated; /* in jiffies */ | 207 | unsigned long last_updated; /* in jiffies */ |
207 | int kind; | 208 | int kind; |
@@ -247,13 +248,13 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, | |||
247 | long val = simple_strtol(buf, NULL, 10); | 248 | long val = simple_strtol(buf, NULL, 10); |
248 | int nr = attr->index; | 249 | int nr = attr->index; |
249 | 250 | ||
250 | down(&data->update_lock); | 251 | mutex_lock(&data->update_lock); |
251 | if (data->kind == adt7461) | 252 | if (data->kind == adt7461) |
252 | data->temp8[nr] = TEMP1_TO_REG_ADT7461(val); | 253 | data->temp8[nr] = TEMP1_TO_REG_ADT7461(val); |
253 | else | 254 | else |
254 | data->temp8[nr] = TEMP1_TO_REG(val); | 255 | data->temp8[nr] = TEMP1_TO_REG(val); |
255 | i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]); | 256 | i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]); |
256 | up(&data->update_lock); | 257 | mutex_unlock(&data->update_lock); |
257 | return count; | 258 | return count; |
258 | } | 259 | } |
259 | 260 | ||
@@ -281,7 +282,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, | |||
281 | long val = simple_strtol(buf, NULL, 10); | 282 | long val = simple_strtol(buf, NULL, 10); |
282 | int nr = attr->index; | 283 | int nr = attr->index; |
283 | 284 | ||
284 | down(&data->update_lock); | 285 | mutex_lock(&data->update_lock); |
285 | if (data->kind == adt7461) | 286 | if (data->kind == adt7461) |
286 | data->temp11[nr] = TEMP2_TO_REG_ADT7461(val); | 287 | data->temp11[nr] = TEMP2_TO_REG_ADT7461(val); |
287 | else | 288 | else |
@@ -290,7 +291,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, | |||
290 | data->temp11[nr] >> 8); | 291 | data->temp11[nr] >> 8); |
291 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], | 292 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], |
292 | data->temp11[nr] & 0xff); | 293 | data->temp11[nr] & 0xff); |
293 | up(&data->update_lock); | 294 | mutex_unlock(&data->update_lock); |
294 | return count; | 295 | return count; |
295 | } | 296 | } |
296 | 297 | ||
@@ -311,11 +312,11 @@ static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy, | |||
311 | long val = simple_strtol(buf, NULL, 10); | 312 | long val = simple_strtol(buf, NULL, 10); |
312 | long hyst; | 313 | long hyst; |
313 | 314 | ||
314 | down(&data->update_lock); | 315 | mutex_lock(&data->update_lock); |
315 | hyst = TEMP1_FROM_REG(data->temp8[3]) - val; | 316 | hyst = TEMP1_FROM_REG(data->temp8[3]) - val; |
316 | i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, | 317 | i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, |
317 | HYST_TO_REG(hyst)); | 318 | HYST_TO_REG(hyst)); |
318 | up(&data->update_lock); | 319 | mutex_unlock(&data->update_lock); |
319 | return count; | 320 | return count; |
320 | } | 321 | } |
321 | 322 | ||
@@ -558,7 +559,7 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
558 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 559 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
559 | data->valid = 0; | 560 | data->valid = 0; |
560 | data->kind = kind; | 561 | data->kind = kind; |
561 | init_MUTEX(&data->update_lock); | 562 | mutex_init(&data->update_lock); |
562 | 563 | ||
563 | /* Tell the I2C layer a new client has arrived */ | 564 | /* Tell the I2C layer a new client has arrived */ |
564 | if ((err = i2c_attach_client(new_client))) | 565 | if ((err = i2c_attach_client(new_client))) |
@@ -646,7 +647,7 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
646 | struct i2c_client *client = to_i2c_client(dev); | 647 | struct i2c_client *client = to_i2c_client(dev); |
647 | struct lm90_data *data = i2c_get_clientdata(client); | 648 | struct lm90_data *data = i2c_get_clientdata(client); |
648 | 649 | ||
649 | down(&data->update_lock); | 650 | mutex_lock(&data->update_lock); |
650 | 651 | ||
651 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 652 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
652 | u8 oldh, newh, l; | 653 | u8 oldh, newh, l; |
@@ -692,7 +693,7 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
692 | data->valid = 1; | 693 | data->valid = 1; |
693 | } | 694 | } |
694 | 695 | ||
695 | up(&data->update_lock); | 696 | mutex_unlock(&data->update_lock); |
696 | 697 | ||
697 | return data; | 698 | return data; |
698 | } | 699 | } |
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index b0c4cb730a7e..197f77226dc4 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/i2c.h> | 46 | #include <linux/i2c.h> |
47 | #include <linux/hwmon.h> | 47 | #include <linux/hwmon.h> |
48 | #include <linux/err.h> | 48 | #include <linux/err.h> |
49 | #include <linux/mutex.h> | ||
49 | 50 | ||
50 | /* The LM92 and MAX6635 have 2 two-state pins for address selection, | 51 | /* The LM92 and MAX6635 have 2 two-state pins for address selection, |
51 | resulting in 4 possible addresses. */ | 52 | resulting in 4 possible addresses. */ |
@@ -96,7 +97,7 @@ static struct i2c_driver lm92_driver; | |||
96 | struct lm92_data { | 97 | struct lm92_data { |
97 | struct i2c_client client; | 98 | struct i2c_client client; |
98 | struct class_device *class_dev; | 99 | struct class_device *class_dev; |
99 | struct semaphore update_lock; | 100 | struct mutex update_lock; |
100 | char valid; /* zero until following fields are valid */ | 101 | char valid; /* zero until following fields are valid */ |
101 | unsigned long last_updated; /* in jiffies */ | 102 | unsigned long last_updated; /* in jiffies */ |
102 | 103 | ||
@@ -114,7 +115,7 @@ static struct lm92_data *lm92_update_device(struct device *dev) | |||
114 | struct i2c_client *client = to_i2c_client(dev); | 115 | struct i2c_client *client = to_i2c_client(dev); |
115 | struct lm92_data *data = i2c_get_clientdata(client); | 116 | struct lm92_data *data = i2c_get_clientdata(client); |
116 | 117 | ||
117 | down(&data->update_lock); | 118 | mutex_lock(&data->update_lock); |
118 | 119 | ||
119 | if (time_after(jiffies, data->last_updated + HZ) | 120 | if (time_after(jiffies, data->last_updated + HZ) |
120 | || !data->valid) { | 121 | || !data->valid) { |
@@ -134,7 +135,7 @@ static struct lm92_data *lm92_update_device(struct device *dev) | |||
134 | data->valid = 1; | 135 | data->valid = 1; |
135 | } | 136 | } |
136 | 137 | ||
137 | up(&data->update_lock); | 138 | mutex_unlock(&data->update_lock); |
138 | 139 | ||
139 | return data; | 140 | return data; |
140 | } | 141 | } |
@@ -158,10 +159,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co | |||
158 | struct lm92_data *data = i2c_get_clientdata(client); \ | 159 | struct lm92_data *data = i2c_get_clientdata(client); \ |
159 | long val = simple_strtol(buf, NULL, 10); \ | 160 | long val = simple_strtol(buf, NULL, 10); \ |
160 | \ | 161 | \ |
161 | down(&data->update_lock); \ | 162 | mutex_lock(&data->update_lock); \ |
162 | data->value = TEMP_TO_REG(val); \ | 163 | data->value = TEMP_TO_REG(val); \ |
163 | i2c_smbus_write_word_data(client, reg, swab16(data->value)); \ | 164 | i2c_smbus_write_word_data(client, reg, swab16(data->value)); \ |
164 | up(&data->update_lock); \ | 165 | mutex_unlock(&data->update_lock); \ |
165 | return count; \ | 166 | return count; \ |
166 | } | 167 | } |
167 | set_temp(temp1_crit, LM92_REG_TEMP_CRIT); | 168 | set_temp(temp1_crit, LM92_REG_TEMP_CRIT); |
@@ -194,11 +195,11 @@ static ssize_t set_temp1_crit_hyst(struct device *dev, struct device_attribute * | |||
194 | struct lm92_data *data = i2c_get_clientdata(client); | 195 | struct lm92_data *data = i2c_get_clientdata(client); |
195 | long val = simple_strtol(buf, NULL, 10); | 196 | long val = simple_strtol(buf, NULL, 10); |
196 | 197 | ||
197 | down(&data->update_lock); | 198 | mutex_lock(&data->update_lock); |
198 | data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val; | 199 | data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val; |
199 | i2c_smbus_write_word_data(client, LM92_REG_TEMP_HYST, | 200 | i2c_smbus_write_word_data(client, LM92_REG_TEMP_HYST, |
200 | swab16(TEMP_TO_REG(data->temp1_hyst))); | 201 | swab16(TEMP_TO_REG(data->temp1_hyst))); |
201 | up(&data->update_lock); | 202 | mutex_unlock(&data->update_lock); |
202 | return count; | 203 | return count; |
203 | } | 204 | } |
204 | 205 | ||
@@ -348,7 +349,7 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind) | |||
348 | /* Fill in the remaining client fields */ | 349 | /* Fill in the remaining client fields */ |
349 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 350 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
350 | data->valid = 0; | 351 | data->valid = 0; |
351 | init_MUTEX(&data->update_lock); | 352 | mutex_init(&data->update_lock); |
352 | 353 | ||
353 | /* Tell the i2c subsystem a new client has arrived */ | 354 | /* Tell the i2c subsystem a new client has arrived */ |
354 | if ((err = i2c_attach_client(new_client))) | 355 | if ((err = i2c_attach_client(new_client))) |
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 3abe330b22ce..b4135b5971f4 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
34 | #include <linux/hwmon.h> | 34 | #include <linux/hwmon.h> |
35 | #include <linux/err.h> | 35 | #include <linux/err.h> |
36 | #include <linux/mutex.h> | ||
36 | 37 | ||
37 | static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, | 38 | static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, |
38 | 0x29, 0x2a, 0x2b, | 39 | 0x29, 0x2a, 0x2b, |
@@ -104,7 +105,7 @@ static struct i2c_driver max1619_driver = { | |||
104 | struct max1619_data { | 105 | struct max1619_data { |
105 | struct i2c_client client; | 106 | struct i2c_client client; |
106 | struct class_device *class_dev; | 107 | struct class_device *class_dev; |
107 | struct semaphore update_lock; | 108 | struct mutex update_lock; |
108 | char valid; /* zero until following fields are valid */ | 109 | char valid; /* zero until following fields are valid */ |
109 | unsigned long last_updated; /* in jiffies */ | 110 | unsigned long last_updated; /* in jiffies */ |
110 | 111 | ||
@@ -141,10 +142,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co | |||
141 | struct max1619_data *data = i2c_get_clientdata(client); \ | 142 | struct max1619_data *data = i2c_get_clientdata(client); \ |
142 | long val = simple_strtol(buf, NULL, 10); \ | 143 | long val = simple_strtol(buf, NULL, 10); \ |
143 | \ | 144 | \ |
144 | down(&data->update_lock); \ | 145 | mutex_lock(&data->update_lock); \ |
145 | data->value = TEMP_TO_REG(val); \ | 146 | data->value = TEMP_TO_REG(val); \ |
146 | i2c_smbus_write_byte_data(client, reg, data->value); \ | 147 | i2c_smbus_write_byte_data(client, reg, data->value); \ |
147 | up(&data->update_lock); \ | 148 | mutex_unlock(&data->update_lock); \ |
148 | return count; \ | 149 | return count; \ |
149 | } | 150 | } |
150 | 151 | ||
@@ -262,7 +263,7 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind) | |||
262 | /* We can fill in the remaining client fields */ | 263 | /* We can fill in the remaining client fields */ |
263 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | 264 | strlcpy(new_client->name, name, I2C_NAME_SIZE); |
264 | data->valid = 0; | 265 | data->valid = 0; |
265 | init_MUTEX(&data->update_lock); | 266 | mutex_init(&data->update_lock); |
266 | 267 | ||
267 | /* Tell the I2C layer a new client has arrived */ | 268 | /* Tell the I2C layer a new client has arrived */ |
268 | if ((err = i2c_attach_client(new_client))) | 269 | if ((err = i2c_attach_client(new_client))) |
@@ -330,7 +331,7 @@ static struct max1619_data *max1619_update_device(struct device *dev) | |||
330 | struct i2c_client *client = to_i2c_client(dev); | 331 | struct i2c_client *client = to_i2c_client(dev); |
331 | struct max1619_data *data = i2c_get_clientdata(client); | 332 | struct max1619_data *data = i2c_get_clientdata(client); |
332 | 333 | ||
333 | down(&data->update_lock); | 334 | mutex_lock(&data->update_lock); |
334 | 335 | ||
335 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 336 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
336 | dev_dbg(&client->dev, "Updating max1619 data.\n"); | 337 | dev_dbg(&client->dev, "Updating max1619 data.\n"); |
@@ -353,7 +354,7 @@ static struct max1619_data *max1619_update_device(struct device *dev) | |||
353 | data->valid = 1; | 354 | data->valid = 1; |
354 | } | 355 | } |
355 | 356 | ||
356 | up(&data->update_lock); | 357 | mutex_unlock(&data->update_lock); |
357 | 358 | ||
358 | return data; | 359 | return data; |
359 | } | 360 | } |
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index f161e88e3bb6..ae05e483a778 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #include <linux/hwmon-sysfs.h> | 43 | #include <linux/hwmon-sysfs.h> |
44 | #include <linux/hwmon-vid.h> | 44 | #include <linux/hwmon-vid.h> |
45 | #include <linux/err.h> | 45 | #include <linux/err.h> |
46 | #include <linux/mutex.h> | ||
46 | #include <asm/io.h> | 47 | #include <asm/io.h> |
47 | 48 | ||
48 | static u8 devid; | 49 | static u8 devid; |
@@ -183,8 +184,8 @@ static inline u8 PWM_TO_REG(int val, int inv) | |||
183 | struct pc87360_data { | 184 | struct pc87360_data { |
184 | struct i2c_client client; | 185 | struct i2c_client client; |
185 | struct class_device *class_dev; | 186 | struct class_device *class_dev; |
186 | struct semaphore lock; | 187 | struct mutex lock; |
187 | struct semaphore update_lock; | 188 | struct mutex update_lock; |
188 | char valid; /* !=0 if following fields are valid */ | 189 | char valid; /* !=0 if following fields are valid */ |
189 | unsigned long last_updated; /* In jiffies */ | 190 | unsigned long last_updated; /* In jiffies */ |
190 | 191 | ||
@@ -283,7 +284,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr, | |||
283 | struct pc87360_data *data = i2c_get_clientdata(client); | 284 | struct pc87360_data *data = i2c_get_clientdata(client); |
284 | long fan_min = simple_strtol(buf, NULL, 10); | 285 | long fan_min = simple_strtol(buf, NULL, 10); |
285 | 286 | ||
286 | down(&data->update_lock); | 287 | mutex_lock(&data->update_lock); |
287 | fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index])); | 288 | fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index])); |
288 | 289 | ||
289 | /* If it wouldn't fit, change clock divisor */ | 290 | /* If it wouldn't fit, change clock divisor */ |
@@ -300,23 +301,31 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr, | |||
300 | /* Write new divider, preserve alarm bits */ | 301 | /* Write new divider, preserve alarm bits */ |
301 | pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(attr->index), | 302 | pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(attr->index), |
302 | data->fan_status[attr->index] & 0xF9); | 303 | data->fan_status[attr->index] & 0xF9); |
303 | up(&data->update_lock); | 304 | mutex_unlock(&data->update_lock); |
304 | 305 | ||
305 | return count; | 306 | return count; |
306 | } | 307 | } |
307 | 308 | ||
308 | #define show_and_set_fan(offset) \ | 309 | static struct sensor_device_attribute fan_input[] = { |
309 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | 310 | SENSOR_ATTR(fan1_input, S_IRUGO, show_fan_input, NULL, 0), |
310 | show_fan_input, NULL, offset-1); \ | 311 | SENSOR_ATTR(fan2_input, S_IRUGO, show_fan_input, NULL, 1), |
311 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IWUSR | S_IRUGO, \ | 312 | SENSOR_ATTR(fan3_input, S_IRUGO, show_fan_input, NULL, 2), |
312 | show_fan_min, set_fan_min, offset-1); \ | 313 | }; |
313 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ | 314 | static struct sensor_device_attribute fan_status[] = { |
314 | show_fan_div, NULL, offset-1); \ | 315 | SENSOR_ATTR(fan1_status, S_IRUGO, show_fan_status, NULL, 0), |
315 | static SENSOR_DEVICE_ATTR(fan##offset##_status, S_IRUGO, \ | 316 | SENSOR_ATTR(fan2_status, S_IRUGO, show_fan_status, NULL, 1), |
316 | show_fan_status, NULL, offset-1); | 317 | SENSOR_ATTR(fan3_status, S_IRUGO, show_fan_status, NULL, 2), |
317 | show_and_set_fan(1) | 318 | }; |
318 | show_and_set_fan(2) | 319 | static struct sensor_device_attribute fan_div[] = { |
319 | show_and_set_fan(3) | 320 | SENSOR_ATTR(fan1_div, S_IRUGO, show_fan_div, NULL, 0), |
321 | SENSOR_ATTR(fan2_div, S_IRUGO, show_fan_div, NULL, 1), | ||
322 | SENSOR_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2), | ||
323 | }; | ||
324 | static struct sensor_device_attribute fan_min[] = { | ||
325 | SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 0), | ||
326 | SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 1), | ||
327 | SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 2), | ||
328 | }; | ||
320 | 329 | ||
321 | static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf) | 330 | static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf) |
322 | { | 331 | { |
@@ -335,21 +344,20 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, con | |||
335 | struct pc87360_data *data = i2c_get_clientdata(client); | 344 | struct pc87360_data *data = i2c_get_clientdata(client); |
336 | long val = simple_strtol(buf, NULL, 10); | 345 | long val = simple_strtol(buf, NULL, 10); |
337 | 346 | ||
338 | down(&data->update_lock); | 347 | mutex_lock(&data->update_lock); |
339 | data->pwm[attr->index] = PWM_TO_REG(val, | 348 | data->pwm[attr->index] = PWM_TO_REG(val, |
340 | FAN_CONFIG_INVERT(data->fan_conf, attr->index)); | 349 | FAN_CONFIG_INVERT(data->fan_conf, attr->index)); |
341 | pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(attr->index), | 350 | pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(attr->index), |
342 | data->pwm[attr->index]); | 351 | data->pwm[attr->index]); |
343 | up(&data->update_lock); | 352 | mutex_unlock(&data->update_lock); |
344 | return count; | 353 | return count; |
345 | } | 354 | } |
346 | 355 | ||
347 | #define show_and_set_pwm(offset) \ | 356 | static struct sensor_device_attribute pwm[] = { |
348 | static SENSOR_DEVICE_ATTR(pwm##offset, S_IWUSR | S_IRUGO, \ | 357 | SENSOR_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0), |
349 | show_pwm, set_pwm, offset-1); | 358 | SENSOR_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1), |
350 | show_and_set_pwm(1) | 359 | SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2), |
351 | show_and_set_pwm(2) | 360 | }; |
352 | show_and_set_pwm(3) | ||
353 | 361 | ||
354 | static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf) | 362 | static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf) |
355 | { | 363 | { |
@@ -386,11 +394,11 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *devattr, | |||
386 | struct pc87360_data *data = i2c_get_clientdata(client); | 394 | struct pc87360_data *data = i2c_get_clientdata(client); |
387 | long val = simple_strtol(buf, NULL, 10); | 395 | long val = simple_strtol(buf, NULL, 10); |
388 | 396 | ||
389 | down(&data->update_lock); | 397 | mutex_lock(&data->update_lock); |
390 | data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); | 398 | data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); |
391 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MIN, | 399 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MIN, |
392 | data->in_min[attr->index]); | 400 | data->in_min[attr->index]); |
393 | up(&data->update_lock); | 401 | mutex_unlock(&data->update_lock); |
394 | return count; | 402 | return count; |
395 | } | 403 | } |
396 | static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf, | 404 | static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf, |
@@ -401,35 +409,67 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, | |||
401 | struct pc87360_data *data = i2c_get_clientdata(client); | 409 | struct pc87360_data *data = i2c_get_clientdata(client); |
402 | long val = simple_strtol(buf, NULL, 10); | 410 | long val = simple_strtol(buf, NULL, 10); |
403 | 411 | ||
404 | down(&data->update_lock); | 412 | mutex_lock(&data->update_lock); |
405 | data->in_max[attr->index] = IN_TO_REG(val, | 413 | data->in_max[attr->index] = IN_TO_REG(val, |
406 | data->in_vref); | 414 | data->in_vref); |
407 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MAX, | 415 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MAX, |
408 | data->in_max[attr->index]); | 416 | data->in_max[attr->index]); |
409 | up(&data->update_lock); | 417 | mutex_unlock(&data->update_lock); |
410 | return count; | 418 | return count; |
411 | } | 419 | } |
412 | 420 | ||
413 | #define show_and_set_in(offset) \ | 421 | static struct sensor_device_attribute in_input[] = { |
414 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ | 422 | SENSOR_ATTR(in0_input, S_IRUGO, show_in_input, NULL, 0), |
415 | show_in_input, NULL, offset); \ | 423 | SENSOR_ATTR(in1_input, S_IRUGO, show_in_input, NULL, 1), |
416 | static SENSOR_DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ | 424 | SENSOR_ATTR(in2_input, S_IRUGO, show_in_input, NULL, 2), |
417 | show_in_min, set_in_min, offset); \ | 425 | SENSOR_ATTR(in3_input, S_IRUGO, show_in_input, NULL, 3), |
418 | static SENSOR_DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \ | 426 | SENSOR_ATTR(in4_input, S_IRUGO, show_in_input, NULL, 4), |
419 | show_in_max, set_in_max, offset); \ | 427 | SENSOR_ATTR(in5_input, S_IRUGO, show_in_input, NULL, 5), |
420 | static SENSOR_DEVICE_ATTR(in##offset##_status, S_IRUGO, \ | 428 | SENSOR_ATTR(in6_input, S_IRUGO, show_in_input, NULL, 6), |
421 | show_in_status, NULL, offset); | 429 | SENSOR_ATTR(in7_input, S_IRUGO, show_in_input, NULL, 7), |
422 | show_and_set_in(0) | 430 | SENSOR_ATTR(in8_input, S_IRUGO, show_in_input, NULL, 8), |
423 | show_and_set_in(1) | 431 | SENSOR_ATTR(in9_input, S_IRUGO, show_in_input, NULL, 9), |
424 | show_and_set_in(2) | 432 | SENSOR_ATTR(in10_input, S_IRUGO, show_in_input, NULL, 10), |
425 | show_and_set_in(3) | 433 | }; |
426 | show_and_set_in(4) | 434 | static struct sensor_device_attribute in_status[] = { |
427 | show_and_set_in(5) | 435 | SENSOR_ATTR(in0_status, S_IRUGO, show_in_status, NULL, 0), |
428 | show_and_set_in(6) | 436 | SENSOR_ATTR(in1_status, S_IRUGO, show_in_status, NULL, 1), |
429 | show_and_set_in(7) | 437 | SENSOR_ATTR(in2_status, S_IRUGO, show_in_status, NULL, 2), |
430 | show_and_set_in(8) | 438 | SENSOR_ATTR(in3_status, S_IRUGO, show_in_status, NULL, 3), |
431 | show_and_set_in(9) | 439 | SENSOR_ATTR(in4_status, S_IRUGO, show_in_status, NULL, 4), |
432 | show_and_set_in(10) | 440 | SENSOR_ATTR(in5_status, S_IRUGO, show_in_status, NULL, 5), |
441 | SENSOR_ATTR(in6_status, S_IRUGO, show_in_status, NULL, 6), | ||
442 | SENSOR_ATTR(in7_status, S_IRUGO, show_in_status, NULL, 7), | ||
443 | SENSOR_ATTR(in8_status, S_IRUGO, show_in_status, NULL, 8), | ||
444 | SENSOR_ATTR(in9_status, S_IRUGO, show_in_status, NULL, 9), | ||
445 | SENSOR_ATTR(in10_status, S_IRUGO, show_in_status, NULL, 10), | ||
446 | }; | ||
447 | static struct sensor_device_attribute in_min[] = { | ||
448 | SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 0), | ||
449 | SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 1), | ||
450 | SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 2), | ||
451 | SENSOR_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 3), | ||
452 | SENSOR_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 4), | ||
453 | SENSOR_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 5), | ||
454 | SENSOR_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 6), | ||
455 | SENSOR_ATTR(in7_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 7), | ||
456 | SENSOR_ATTR(in8_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 8), | ||
457 | SENSOR_ATTR(in9_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 9), | ||
458 | SENSOR_ATTR(in10_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 10), | ||
459 | }; | ||
460 | static struct sensor_device_attribute in_max[] = { | ||
461 | SENSOR_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 0), | ||
462 | SENSOR_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 1), | ||
463 | SENSOR_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 2), | ||
464 | SENSOR_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 3), | ||
465 | SENSOR_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 4), | ||
466 | SENSOR_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 5), | ||
467 | SENSOR_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 6), | ||
468 | SENSOR_ATTR(in7_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 7), | ||
469 | SENSOR_ATTR(in8_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 8), | ||
470 | SENSOR_ATTR(in9_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 9), | ||
471 | SENSOR_ATTR(in10_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 10), | ||
472 | }; | ||
433 | 473 | ||
434 | static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf) | 474 | static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf) |
435 | { | 475 | { |
@@ -473,11 +513,11 @@ static ssize_t set_therm_min(struct device *dev, struct device_attribute *devatt | |||
473 | struct pc87360_data *data = i2c_get_clientdata(client); | 513 | struct pc87360_data *data = i2c_get_clientdata(client); |
474 | long val = simple_strtol(buf, NULL, 10); | 514 | long val = simple_strtol(buf, NULL, 10); |
475 | 515 | ||
476 | down(&data->update_lock); | 516 | mutex_lock(&data->update_lock); |
477 | data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); | 517 | data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); |
478 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MIN, | 518 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MIN, |
479 | data->in_min[attr->index]); | 519 | data->in_min[attr->index]); |
480 | up(&data->update_lock); | 520 | mutex_unlock(&data->update_lock); |
481 | return count; | 521 | return count; |
482 | } | 522 | } |
483 | static ssize_t set_therm_max(struct device *dev, struct device_attribute *devattr, const char *buf, | 523 | static ssize_t set_therm_max(struct device *dev, struct device_attribute *devattr, const char *buf, |
@@ -488,11 +528,11 @@ static ssize_t set_therm_max(struct device *dev, struct device_attribute *devatt | |||
488 | struct pc87360_data *data = i2c_get_clientdata(client); | 528 | struct pc87360_data *data = i2c_get_clientdata(client); |
489 | long val = simple_strtol(buf, NULL, 10); | 529 | long val = simple_strtol(buf, NULL, 10); |
490 | 530 | ||
491 | down(&data->update_lock); | 531 | mutex_lock(&data->update_lock); |
492 | data->in_max[attr->index] = IN_TO_REG(val, data->in_vref); | 532 | data->in_max[attr->index] = IN_TO_REG(val, data->in_vref); |
493 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MAX, | 533 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MAX, |
494 | data->in_max[attr->index]); | 534 | data->in_max[attr->index]); |
495 | up(&data->update_lock); | 535 | mutex_unlock(&data->update_lock); |
496 | return count; | 536 | return count; |
497 | } | 537 | } |
498 | static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devattr, const char *buf, | 538 | static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devattr, const char *buf, |
@@ -503,28 +543,51 @@ static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devat | |||
503 | struct pc87360_data *data = i2c_get_clientdata(client); | 543 | struct pc87360_data *data = i2c_get_clientdata(client); |
504 | long val = simple_strtol(buf, NULL, 10); | 544 | long val = simple_strtol(buf, NULL, 10); |
505 | 545 | ||
506 | down(&data->update_lock); | 546 | mutex_lock(&data->update_lock); |
507 | data->in_crit[attr->index-11] = IN_TO_REG(val, data->in_vref); | 547 | data->in_crit[attr->index-11] = IN_TO_REG(val, data->in_vref); |
508 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_CRIT, | 548 | pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_CRIT, |
509 | data->in_crit[attr->index-11]); | 549 | data->in_crit[attr->index-11]); |
510 | up(&data->update_lock); | 550 | mutex_unlock(&data->update_lock); |
511 | return count; | 551 | return count; |
512 | } | 552 | } |
513 | 553 | ||
514 | #define show_and_set_therm(offset) \ | 554 | /* the +11 term below reflects the fact that VLM units 11,12,13 are |
515 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ | 555 | used in the chip to measure voltage across the thermistors |
516 | show_therm_input, NULL, 11+offset-4); \ | 556 | */ |
517 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ | 557 | static struct sensor_device_attribute therm_input[] = { |
518 | show_therm_min, set_therm_min, 11+offset-4); \ | 558 | SENSOR_ATTR(temp4_input, S_IRUGO, show_therm_input, NULL, 0+11), |
519 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ | 559 | SENSOR_ATTR(temp5_input, S_IRUGO, show_therm_input, NULL, 1+11), |
520 | show_therm_max, set_therm_max, 11+offset-4); \ | 560 | SENSOR_ATTR(temp6_input, S_IRUGO, show_therm_input, NULL, 2+11), |
521 | static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \ | 561 | }; |
522 | show_therm_crit, set_therm_crit, 11+offset-4); \ | 562 | static struct sensor_device_attribute therm_status[] = { |
523 | static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \ | 563 | SENSOR_ATTR(temp4_status, S_IRUGO, show_therm_status, NULL, 0+11), |
524 | show_therm_status, NULL, 11+offset-4); | 564 | SENSOR_ATTR(temp5_status, S_IRUGO, show_therm_status, NULL, 1+11), |
525 | show_and_set_therm(4) | 565 | SENSOR_ATTR(temp6_status, S_IRUGO, show_therm_status, NULL, 2+11), |
526 | show_and_set_therm(5) | 566 | }; |
527 | show_and_set_therm(6) | 567 | static struct sensor_device_attribute therm_min[] = { |
568 | SENSOR_ATTR(temp4_min, S_IRUGO | S_IWUSR, | ||
569 | show_therm_min, set_therm_min, 0+11), | ||
570 | SENSOR_ATTR(temp5_min, S_IRUGO | S_IWUSR, | ||
571 | show_therm_min, set_therm_min, 1+11), | ||
572 | SENSOR_ATTR(temp6_min, S_IRUGO | S_IWUSR, | ||
573 | show_therm_min, set_therm_min, 2+11), | ||
574 | }; | ||
575 | static struct sensor_device_attribute therm_max[] = { | ||
576 | SENSOR_ATTR(temp4_max, S_IRUGO | S_IWUSR, | ||
577 | show_therm_max, set_therm_max, 0+11), | ||
578 | SENSOR_ATTR(temp5_max, S_IRUGO | S_IWUSR, | ||
579 | show_therm_max, set_therm_max, 1+11), | ||
580 | SENSOR_ATTR(temp6_max, S_IRUGO | S_IWUSR, | ||
581 | show_therm_max, set_therm_max, 2+11), | ||
582 | }; | ||
583 | static struct sensor_device_attribute therm_crit[] = { | ||
584 | SENSOR_ATTR(temp4_crit, S_IRUGO | S_IWUSR, | ||
585 | show_therm_crit, set_therm_crit, 0+11), | ||
586 | SENSOR_ATTR(temp5_crit, S_IRUGO | S_IWUSR, | ||
587 | show_therm_crit, set_therm_crit, 1+11), | ||
588 | SENSOR_ATTR(temp6_crit, S_IRUGO | S_IWUSR, | ||
589 | show_therm_crit, set_therm_crit, 2+11), | ||
590 | }; | ||
528 | 591 | ||
529 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) | 592 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) |
530 | { | 593 | { |
@@ -592,11 +655,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *devattr | |||
592 | struct pc87360_data *data = i2c_get_clientdata(client); | 655 | struct pc87360_data *data = i2c_get_clientdata(client); |
593 | long val = simple_strtol(buf, NULL, 10); | 656 | long val = simple_strtol(buf, NULL, 10); |
594 | 657 | ||
595 | down(&data->update_lock); | 658 | mutex_lock(&data->update_lock); |
596 | data->temp_min[attr->index] = TEMP_TO_REG(val); | 659 | data->temp_min[attr->index] = TEMP_TO_REG(val); |
597 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MIN, | 660 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MIN, |
598 | data->temp_min[attr->index]); | 661 | data->temp_min[attr->index]); |
599 | up(&data->update_lock); | 662 | mutex_unlock(&data->update_lock); |
600 | return count; | 663 | return count; |
601 | } | 664 | } |
602 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf, | 665 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf, |
@@ -607,11 +670,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr | |||
607 | struct pc87360_data *data = i2c_get_clientdata(client); | 670 | struct pc87360_data *data = i2c_get_clientdata(client); |
608 | long val = simple_strtol(buf, NULL, 10); | 671 | long val = simple_strtol(buf, NULL, 10); |
609 | 672 | ||
610 | down(&data->update_lock); | 673 | mutex_lock(&data->update_lock); |
611 | data->temp_max[attr->index] = TEMP_TO_REG(val); | 674 | data->temp_max[attr->index] = TEMP_TO_REG(val); |
612 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MAX, | 675 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MAX, |
613 | data->temp_max[attr->index]); | 676 | data->temp_max[attr->index]); |
614 | up(&data->update_lock); | 677 | mutex_unlock(&data->update_lock); |
615 | return count; | 678 | return count; |
616 | } | 679 | } |
617 | static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf, | 680 | static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf, |
@@ -622,28 +685,48 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devatt | |||
622 | struct pc87360_data *data = i2c_get_clientdata(client); | 685 | struct pc87360_data *data = i2c_get_clientdata(client); |
623 | long val = simple_strtol(buf, NULL, 10); | 686 | long val = simple_strtol(buf, NULL, 10); |
624 | 687 | ||
625 | down(&data->update_lock); | 688 | mutex_lock(&data->update_lock); |
626 | data->temp_crit[attr->index] = TEMP_TO_REG(val); | 689 | data->temp_crit[attr->index] = TEMP_TO_REG(val); |
627 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_CRIT, | 690 | pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_CRIT, |
628 | data->temp_crit[attr->index]); | 691 | data->temp_crit[attr->index]); |
629 | up(&data->update_lock); | 692 | mutex_unlock(&data->update_lock); |
630 | return count; | 693 | return count; |
631 | } | 694 | } |
632 | 695 | ||
633 | #define show_and_set_temp(offset) \ | 696 | static struct sensor_device_attribute temp_input[] = { |
634 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ | 697 | SENSOR_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0), |
635 | show_temp_input, NULL, offset-1); \ | 698 | SENSOR_ATTR(temp2_input, S_IRUGO, show_temp_input, NULL, 1), |
636 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ | 699 | SENSOR_ATTR(temp3_input, S_IRUGO, show_temp_input, NULL, 2), |
637 | show_temp_min, set_temp_min, offset-1); \ | 700 | }; |
638 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ | 701 | static struct sensor_device_attribute temp_status[] = { |
639 | show_temp_max, set_temp_max, offset-1); \ | 702 | SENSOR_ATTR(temp1_status, S_IRUGO, show_temp_status, NULL, 0), |
640 | static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \ | 703 | SENSOR_ATTR(temp2_status, S_IRUGO, show_temp_status, NULL, 1), |
641 | show_temp_crit, set_temp_crit, offset-1); \ | 704 | SENSOR_ATTR(temp3_status, S_IRUGO, show_temp_status, NULL, 2), |
642 | static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \ | 705 | }; |
643 | show_temp_status, NULL, offset-1); | 706 | static struct sensor_device_attribute temp_min[] = { |
644 | show_and_set_temp(1) | 707 | SENSOR_ATTR(temp1_min, S_IRUGO | S_IWUSR, |
645 | show_and_set_temp(2) | 708 | show_temp_min, set_temp_min, 0), |
646 | show_and_set_temp(3) | 709 | SENSOR_ATTR(temp2_min, S_IRUGO | S_IWUSR, |
710 | show_temp_min, set_temp_min, 1), | ||
711 | SENSOR_ATTR(temp3_min, S_IRUGO | S_IWUSR, | ||
712 | show_temp_min, set_temp_min, 2), | ||
713 | }; | ||
714 | static struct sensor_device_attribute temp_max[] = { | ||
715 | SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, | ||
716 | show_temp_max, set_temp_max, 0), | ||
717 | SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, | ||
718 | show_temp_max, set_temp_max, 1), | ||
719 | SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, | ||
720 | show_temp_max, set_temp_max, 2), | ||
721 | }; | ||
722 | static struct sensor_device_attribute temp_crit[] = { | ||
723 | SENSOR_ATTR(temp1_crit, S_IRUGO | S_IWUSR, | ||
724 | show_temp_crit, set_temp_crit, 0), | ||
725 | SENSOR_ATTR(temp2_crit, S_IRUGO | S_IWUSR, | ||
726 | show_temp_crit, set_temp_crit, 1), | ||
727 | SENSOR_ATTR(temp3_crit, S_IRUGO | S_IWUSR, | ||
728 | show_temp_crit, set_temp_crit, 2), | ||
729 | }; | ||
647 | 730 | ||
648 | static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 731 | static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
649 | { | 732 | { |
@@ -749,22 +832,24 @@ static int __init pc87360_find(int sioaddr, u8 *devid, unsigned short *addresses | |||
749 | static int pc87360_detect(struct i2c_adapter *adapter) | 832 | static int pc87360_detect(struct i2c_adapter *adapter) |
750 | { | 833 | { |
751 | int i; | 834 | int i; |
752 | struct i2c_client *new_client; | 835 | struct i2c_client *client; |
753 | struct pc87360_data *data; | 836 | struct pc87360_data *data; |
754 | int err = 0; | 837 | int err = 0; |
755 | const char *name = "pc87360"; | 838 | const char *name = "pc87360"; |
756 | int use_thermistors = 0; | 839 | int use_thermistors = 0; |
840 | struct device *dev; | ||
757 | 841 | ||
758 | if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL))) | 842 | if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL))) |
759 | return -ENOMEM; | 843 | return -ENOMEM; |
760 | 844 | ||
761 | new_client = &data->client; | 845 | client = &data->client; |
762 | i2c_set_clientdata(new_client, data); | 846 | dev = &client->dev; |
763 | new_client->addr = address; | 847 | i2c_set_clientdata(client, data); |
764 | init_MUTEX(&data->lock); | 848 | client->addr = address; |
765 | new_client->adapter = adapter; | 849 | mutex_init(&data->lock); |
766 | new_client->driver = &pc87360_driver; | 850 | client->adapter = adapter; |
767 | new_client->flags = 0; | 851 | client->driver = &pc87360_driver; |
852 | client->flags = 0; | ||
768 | 853 | ||
769 | data->fannr = 2; | 854 | data->fannr = 2; |
770 | data->innr = 0; | 855 | data->innr = 0; |
@@ -792,15 +877,15 @@ static int pc87360_detect(struct i2c_adapter *adapter) | |||
792 | break; | 877 | break; |
793 | } | 878 | } |
794 | 879 | ||
795 | strcpy(new_client->name, name); | 880 | strlcpy(client->name, name, sizeof(client->name)); |
796 | data->valid = 0; | 881 | data->valid = 0; |
797 | init_MUTEX(&data->update_lock); | 882 | mutex_init(&data->update_lock); |
798 | 883 | ||
799 | for (i = 0; i < 3; i++) { | 884 | for (i = 0; i < 3; i++) { |
800 | if (((data->address[i] = extra_isa[i])) | 885 | if (((data->address[i] = extra_isa[i])) |
801 | && !request_region(extra_isa[i], PC87360_EXTENT, | 886 | && !request_region(extra_isa[i], PC87360_EXTENT, |
802 | pc87360_driver.driver.name)) { | 887 | pc87360_driver.driver.name)) { |
803 | dev_err(&new_client->dev, "Region 0x%x-0x%x already " | 888 | dev_err(&client->dev, "Region 0x%x-0x%x already " |
804 | "in use!\n", extra_isa[i], | 889 | "in use!\n", extra_isa[i], |
805 | extra_isa[i]+PC87360_EXTENT-1); | 890 | extra_isa[i]+PC87360_EXTENT-1); |
806 | for (i--; i >= 0; i--) | 891 | for (i--; i >= 0; i--) |
@@ -814,7 +899,7 @@ static int pc87360_detect(struct i2c_adapter *adapter) | |||
814 | if (data->fannr) | 899 | if (data->fannr) |
815 | data->fan_conf = confreg[0] | (confreg[1] << 8); | 900 | data->fan_conf = confreg[0] | (confreg[1] << 8); |
816 | 901 | ||
817 | if ((err = i2c_attach_client(new_client))) | 902 | if ((err = i2c_attach_client(client))) |
818 | goto ERROR2; | 903 | goto ERROR2; |
819 | 904 | ||
820 | /* Use the correct reference voltage | 905 | /* Use the correct reference voltage |
@@ -828,7 +913,7 @@ static int pc87360_detect(struct i2c_adapter *adapter) | |||
828 | PC87365_REG_TEMP_CONFIG); | 913 | PC87365_REG_TEMP_CONFIG); |
829 | } | 914 | } |
830 | data->in_vref = (i&0x02) ? 3025 : 2966; | 915 | data->in_vref = (i&0x02) ? 3025 : 2966; |
831 | dev_dbg(&new_client->dev, "Using %s reference voltage\n", | 916 | dev_dbg(&client->dev, "Using %s reference voltage\n", |
832 | (i&0x02) ? "external" : "internal"); | 917 | (i&0x02) ? "external" : "internal"); |
833 | 918 | ||
834 | data->vid_conf = confreg[3]; | 919 | data->vid_conf = confreg[3]; |
@@ -847,154 +932,64 @@ static int pc87360_detect(struct i2c_adapter *adapter) | |||
847 | if (devid == 0xe9 && data->address[1]) /* PC87366 */ | 932 | if (devid == 0xe9 && data->address[1]) /* PC87366 */ |
848 | use_thermistors = confreg[2] & 0x40; | 933 | use_thermistors = confreg[2] & 0x40; |
849 | 934 | ||
850 | pc87360_init_client(new_client, use_thermistors); | 935 | pc87360_init_client(client, use_thermistors); |
851 | } | 936 | } |
852 | 937 | ||
853 | /* Register sysfs hooks */ | 938 | /* Register sysfs hooks */ |
854 | data->class_dev = hwmon_device_register(&new_client->dev); | 939 | data->class_dev = hwmon_device_register(&client->dev); |
855 | if (IS_ERR(data->class_dev)) { | 940 | if (IS_ERR(data->class_dev)) { |
856 | err = PTR_ERR(data->class_dev); | 941 | err = PTR_ERR(data->class_dev); |
857 | goto ERROR3; | 942 | goto ERROR3; |
858 | } | 943 | } |
859 | 944 | ||
860 | if (data->innr) { | 945 | if (data->innr) { |
861 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); | 946 | for (i = 0; i < 11; i++) { |
862 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr); | 947 | device_create_file(dev, &in_input[i].dev_attr); |
863 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr); | 948 | device_create_file(dev, &in_min[i].dev_attr); |
864 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr); | 949 | device_create_file(dev, &in_max[i].dev_attr); |
865 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr); | 950 | device_create_file(dev, &in_status[i].dev_attr); |
866 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr); | 951 | } |
867 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr); | 952 | device_create_file(dev, &dev_attr_cpu0_vid); |
868 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr); | 953 | device_create_file(dev, &dev_attr_vrm); |
869 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr); | 954 | device_create_file(dev, &dev_attr_alarms_in); |
870 | device_create_file(&new_client->dev, &sensor_dev_attr_in9_input.dev_attr); | ||
871 | device_create_file(&new_client->dev, &sensor_dev_attr_in10_input.dev_attr); | ||
872 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr); | ||
873 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr); | ||
874 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr); | ||
875 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr); | ||
876 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr); | ||
877 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr); | ||
878 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr); | ||
879 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr); | ||
880 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_min.dev_attr); | ||
881 | device_create_file(&new_client->dev, &sensor_dev_attr_in9_min.dev_attr); | ||
882 | device_create_file(&new_client->dev, &sensor_dev_attr_in10_min.dev_attr); | ||
883 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr); | ||
884 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr); | ||
885 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr); | ||
886 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr); | ||
887 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr); | ||
888 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr); | ||
889 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr); | ||
890 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr); | ||
891 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_max.dev_attr); | ||
892 | device_create_file(&new_client->dev, &sensor_dev_attr_in9_max.dev_attr); | ||
893 | device_create_file(&new_client->dev, &sensor_dev_attr_in10_max.dev_attr); | ||
894 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_status.dev_attr); | ||
895 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_status.dev_attr); | ||
896 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_status.dev_attr); | ||
897 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_status.dev_attr); | ||
898 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_status.dev_attr); | ||
899 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_status.dev_attr); | ||
900 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_status.dev_attr); | ||
901 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_status.dev_attr); | ||
902 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_status.dev_attr); | ||
903 | device_create_file(&new_client->dev, &sensor_dev_attr_in9_status.dev_attr); | ||
904 | device_create_file(&new_client->dev, &sensor_dev_attr_in10_status.dev_attr); | ||
905 | |||
906 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | ||
907 | device_create_file(&new_client->dev, &dev_attr_vrm); | ||
908 | device_create_file(&new_client->dev, &dev_attr_alarms_in); | ||
909 | } | 955 | } |
910 | 956 | ||
911 | if (data->tempnr) { | 957 | if (data->tempnr) { |
912 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr); | 958 | for (i = 0; i < data->tempnr; i++) { |
913 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr); | 959 | device_create_file(dev, &temp_input[i].dev_attr); |
914 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr); | 960 | device_create_file(dev, &temp_min[i].dev_attr); |
915 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr); | 961 | device_create_file(dev, &temp_max[i].dev_attr); |
916 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr); | 962 | device_create_file(dev, &temp_crit[i].dev_attr); |
917 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr); | 963 | device_create_file(dev, &temp_status[i].dev_attr); |
918 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_crit.dev_attr); | ||
919 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_crit.dev_attr); | ||
920 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_status.dev_attr); | ||
921 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_status.dev_attr); | ||
922 | |||
923 | device_create_file(&new_client->dev, &dev_attr_alarms_temp); | ||
924 | } | ||
925 | if (data->tempnr == 3) { | ||
926 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr); | ||
927 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr); | ||
928 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr); | ||
929 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_crit.dev_attr); | ||
930 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_status.dev_attr); | ||
931 | } | ||
932 | if (data->innr == 14) { | ||
933 | device_create_file(&new_client->dev, &sensor_dev_attr_temp4_input.dev_attr); | ||
934 | device_create_file(&new_client->dev, &sensor_dev_attr_temp5_input.dev_attr); | ||
935 | device_create_file(&new_client->dev, &sensor_dev_attr_temp6_input.dev_attr); | ||
936 | device_create_file(&new_client->dev, &sensor_dev_attr_temp4_min.dev_attr); | ||
937 | device_create_file(&new_client->dev, &sensor_dev_attr_temp5_min.dev_attr); | ||
938 | device_create_file(&new_client->dev, &sensor_dev_attr_temp6_min.dev_attr); | ||
939 | device_create_file(&new_client->dev, &sensor_dev_attr_temp4_max.dev_attr); | ||
940 | device_create_file(&new_client->dev, &sensor_dev_attr_temp5_max.dev_attr); | ||
941 | device_create_file(&new_client->dev, &sensor_dev_attr_temp6_max.dev_attr); | ||
942 | device_create_file(&new_client->dev, &sensor_dev_attr_temp4_crit.dev_attr); | ||
943 | device_create_file(&new_client->dev, &sensor_dev_attr_temp5_crit.dev_attr); | ||
944 | device_create_file(&new_client->dev, &sensor_dev_attr_temp6_crit.dev_attr); | ||
945 | device_create_file(&new_client->dev, &sensor_dev_attr_temp4_status.dev_attr); | ||
946 | device_create_file(&new_client->dev, &sensor_dev_attr_temp5_status.dev_attr); | ||
947 | device_create_file(&new_client->dev, &sensor_dev_attr_temp6_status.dev_attr); | ||
948 | } | ||
949 | |||
950 | if (data->fannr) { | ||
951 | if (FAN_CONFIG_MONITOR(data->fan_conf, 0)) { | ||
952 | device_create_file(&new_client->dev, | ||
953 | &sensor_dev_attr_fan1_input.dev_attr); | ||
954 | device_create_file(&new_client->dev, | ||
955 | &sensor_dev_attr_fan1_min.dev_attr); | ||
956 | device_create_file(&new_client->dev, | ||
957 | &sensor_dev_attr_fan1_div.dev_attr); | ||
958 | device_create_file(&new_client->dev, | ||
959 | &sensor_dev_attr_fan1_status.dev_attr); | ||
960 | } | 964 | } |
965 | device_create_file(dev, &dev_attr_alarms_temp); | ||
966 | } | ||
961 | 967 | ||
962 | if (FAN_CONFIG_MONITOR(data->fan_conf, 1)) { | 968 | if (data->innr == 14) { |
963 | device_create_file(&new_client->dev, | 969 | for (i = 0; i < 3; i++) { |
964 | &sensor_dev_attr_fan2_input.dev_attr); | 970 | device_create_file(dev, &therm_input[i].dev_attr); |
965 | device_create_file(&new_client->dev, | 971 | device_create_file(dev, &therm_min[i].dev_attr); |
966 | &sensor_dev_attr_fan2_min.dev_attr); | 972 | device_create_file(dev, &therm_max[i].dev_attr); |
967 | device_create_file(&new_client->dev, | 973 | device_create_file(dev, &therm_crit[i].dev_attr); |
968 | &sensor_dev_attr_fan2_div.dev_attr); | 974 | device_create_file(dev, &therm_status[i].dev_attr); |
969 | device_create_file(&new_client->dev, | ||
970 | &sensor_dev_attr_fan2_status.dev_attr); | ||
971 | } | 975 | } |
972 | |||
973 | if (FAN_CONFIG_CONTROL(data->fan_conf, 0)) | ||
974 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm1.dev_attr); | ||
975 | if (FAN_CONFIG_CONTROL(data->fan_conf, 1)) | ||
976 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm2.dev_attr); | ||
977 | } | 976 | } |
978 | if (data->fannr == 3) { | ||
979 | if (FAN_CONFIG_MONITOR(data->fan_conf, 2)) { | ||
980 | device_create_file(&new_client->dev, | ||
981 | &sensor_dev_attr_fan3_input.dev_attr); | ||
982 | device_create_file(&new_client->dev, | ||
983 | &sensor_dev_attr_fan3_min.dev_attr); | ||
984 | device_create_file(&new_client->dev, | ||
985 | &sensor_dev_attr_fan3_div.dev_attr); | ||
986 | device_create_file(&new_client->dev, | ||
987 | &sensor_dev_attr_fan3_status.dev_attr); | ||
988 | } | ||
989 | 977 | ||
990 | if (FAN_CONFIG_CONTROL(data->fan_conf, 2)) | 978 | for (i = 0; i < data->fannr; i++) { |
991 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr); | 979 | if (FAN_CONFIG_MONITOR(data->fan_conf, i)) { |
980 | device_create_file(dev, &fan_input[i].dev_attr); | ||
981 | device_create_file(dev, &fan_min[i].dev_attr); | ||
982 | device_create_file(dev, &fan_div[i].dev_attr); | ||
983 | device_create_file(dev, &fan_status[i].dev_attr); | ||
984 | } | ||
985 | if (FAN_CONFIG_CONTROL(data->fan_conf, i)) | ||
986 | device_create_file(dev, &pwm[i].dev_attr); | ||
992 | } | 987 | } |
993 | 988 | ||
994 | return 0; | 989 | return 0; |
995 | 990 | ||
996 | ERROR3: | 991 | ERROR3: |
997 | i2c_detach_client(new_client); | 992 | i2c_detach_client(client); |
998 | ERROR2: | 993 | ERROR2: |
999 | for (i = 0; i < 3; i++) { | 994 | for (i = 0; i < 3; i++) { |
1000 | if (data->address[i]) { | 995 | if (data->address[i]) { |
@@ -1033,11 +1028,11 @@ static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank, | |||
1033 | { | 1028 | { |
1034 | int res; | 1029 | int res; |
1035 | 1030 | ||
1036 | down(&(data->lock)); | 1031 | mutex_lock(&(data->lock)); |
1037 | if (bank != NO_BANK) | 1032 | if (bank != NO_BANK) |
1038 | outb_p(bank, data->address[ldi] + PC87365_REG_BANK); | 1033 | outb_p(bank, data->address[ldi] + PC87365_REG_BANK); |
1039 | res = inb_p(data->address[ldi] + reg); | 1034 | res = inb_p(data->address[ldi] + reg); |
1040 | up(&(data->lock)); | 1035 | mutex_unlock(&(data->lock)); |
1041 | 1036 | ||
1042 | return res; | 1037 | return res; |
1043 | } | 1038 | } |
@@ -1045,11 +1040,11 @@ static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank, | |||
1045 | static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank, | 1040 | static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank, |
1046 | u8 reg, u8 value) | 1041 | u8 reg, u8 value) |
1047 | { | 1042 | { |
1048 | down(&(data->lock)); | 1043 | mutex_lock(&(data->lock)); |
1049 | if (bank != NO_BANK) | 1044 | if (bank != NO_BANK) |
1050 | outb_p(bank, data->address[ldi] + PC87365_REG_BANK); | 1045 | outb_p(bank, data->address[ldi] + PC87365_REG_BANK); |
1051 | outb_p(value, data->address[ldi] + reg); | 1046 | outb_p(value, data->address[ldi] + reg); |
1052 | up(&(data->lock)); | 1047 | mutex_unlock(&(data->lock)); |
1053 | } | 1048 | } |
1054 | 1049 | ||
1055 | static void pc87360_init_client(struct i2c_client *client, int use_thermistors) | 1050 | static void pc87360_init_client(struct i2c_client *client, int use_thermistors) |
@@ -1071,7 +1066,7 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors) | |||
1071 | } | 1066 | } |
1072 | 1067 | ||
1073 | nr = data->innr < 11 ? data->innr : 11; | 1068 | nr = data->innr < 11 ? data->innr : 11; |
1074 | for (i=0; i<nr; i++) { | 1069 | for (i = 0; i < nr; i++) { |
1075 | if (init >= init_in[i]) { | 1070 | if (init >= init_in[i]) { |
1076 | /* Forcibly enable voltage channel */ | 1071 | /* Forcibly enable voltage channel */ |
1077 | reg = pc87360_read_value(data, LD_IN, i, | 1072 | reg = pc87360_read_value(data, LD_IN, i, |
@@ -1088,14 +1083,14 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors) | |||
1088 | 1083 | ||
1089 | /* We can't blindly trust the Super-I/O space configuration bit, | 1084 | /* We can't blindly trust the Super-I/O space configuration bit, |
1090 | most BIOS won't set it properly */ | 1085 | most BIOS won't set it properly */ |
1091 | for (i=11; i<data->innr; i++) { | 1086 | for (i = 11; i < data->innr; i++) { |
1092 | reg = pc87360_read_value(data, LD_IN, i, | 1087 | reg = pc87360_read_value(data, LD_IN, i, |
1093 | PC87365_REG_TEMP_STATUS); | 1088 | PC87365_REG_TEMP_STATUS); |
1094 | use_thermistors = use_thermistors || (reg & 0x01); | 1089 | use_thermistors = use_thermistors || (reg & 0x01); |
1095 | } | 1090 | } |
1096 | 1091 | ||
1097 | i = use_thermistors ? 2 : 0; | 1092 | i = use_thermistors ? 2 : 0; |
1098 | for (; i<data->tempnr; i++) { | 1093 | for (; i < data->tempnr; i++) { |
1099 | if (init >= init_temp[i]) { | 1094 | if (init >= init_temp[i]) { |
1100 | /* Forcibly enable temperature channel */ | 1095 | /* Forcibly enable temperature channel */ |
1101 | reg = pc87360_read_value(data, LD_TEMP, i, | 1096 | reg = pc87360_read_value(data, LD_TEMP, i, |
@@ -1111,7 +1106,7 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors) | |||
1111 | } | 1106 | } |
1112 | 1107 | ||
1113 | if (use_thermistors) { | 1108 | if (use_thermistors) { |
1114 | for (i=11; i<data->innr; i++) { | 1109 | for (i = 11; i < data->innr; i++) { |
1115 | if (init >= init_in[i]) { | 1110 | if (init >= init_in[i]) { |
1116 | /* The pin may already be used by thermal | 1111 | /* The pin may already be used by thermal |
1117 | diodes */ | 1112 | diodes */ |
@@ -1221,7 +1216,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev) | |||
1221 | struct pc87360_data *data = i2c_get_clientdata(client); | 1216 | struct pc87360_data *data = i2c_get_clientdata(client); |
1222 | u8 i; | 1217 | u8 i; |
1223 | 1218 | ||
1224 | down(&data->update_lock); | 1219 | mutex_lock(&data->update_lock); |
1225 | 1220 | ||
1226 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 1221 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
1227 | dev_dbg(&client->dev, "Data update\n"); | 1222 | dev_dbg(&client->dev, "Data update\n"); |
@@ -1321,7 +1316,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev) | |||
1321 | data->valid = 1; | 1316 | data->valid = 1; |
1322 | } | 1317 | } |
1323 | 1318 | ||
1324 | up(&data->update_lock); | 1319 | mutex_unlock(&data->update_lock); |
1325 | 1320 | ||
1326 | return data; | 1321 | return data; |
1327 | } | 1322 | } |
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index 8be5189d9bd9..6f3fda73f70c 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c | |||
@@ -60,6 +60,7 @@ | |||
60 | #include <linux/err.h> | 60 | #include <linux/err.h> |
61 | #include <linux/init.h> | 61 | #include <linux/init.h> |
62 | #include <linux/jiffies.h> | 62 | #include <linux/jiffies.h> |
63 | #include <linux/mutex.h> | ||
63 | #include <asm/io.h> | 64 | #include <asm/io.h> |
64 | 65 | ||
65 | 66 | ||
@@ -167,9 +168,9 @@ static inline u8 DIV_TO_REG(int val) | |||
167 | struct sis5595_data { | 168 | struct sis5595_data { |
168 | struct i2c_client client; | 169 | struct i2c_client client; |
169 | struct class_device *class_dev; | 170 | struct class_device *class_dev; |
170 | struct semaphore lock; | 171 | struct mutex lock; |
171 | 172 | ||
172 | struct semaphore update_lock; | 173 | struct mutex update_lock; |
173 | char valid; /* !=0 if following fields are valid */ | 174 | char valid; /* !=0 if following fields are valid */ |
174 | unsigned long last_updated; /* In jiffies */ | 175 | unsigned long last_updated; /* In jiffies */ |
175 | char maxins; /* == 3 if temp enabled, otherwise == 4 */ | 176 | char maxins; /* == 3 if temp enabled, otherwise == 4 */ |
@@ -192,8 +193,8 @@ static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */ | |||
192 | static int sis5595_detect(struct i2c_adapter *adapter); | 193 | static int sis5595_detect(struct i2c_adapter *adapter); |
193 | static int sis5595_detach_client(struct i2c_client *client); | 194 | static int sis5595_detach_client(struct i2c_client *client); |
194 | 195 | ||
195 | static int sis5595_read_value(struct i2c_client *client, u8 register); | 196 | static int sis5595_read_value(struct i2c_client *client, u8 reg); |
196 | static int sis5595_write_value(struct i2c_client *client, u8 register, u8 value); | 197 | static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value); |
197 | static struct sis5595_data *sis5595_update_device(struct device *dev); | 198 | static struct sis5595_data *sis5595_update_device(struct device *dev); |
198 | static void sis5595_init_client(struct i2c_client *client); | 199 | static void sis5595_init_client(struct i2c_client *client); |
199 | 200 | ||
@@ -231,10 +232,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf, | |||
231 | struct sis5595_data *data = i2c_get_clientdata(client); | 232 | struct sis5595_data *data = i2c_get_clientdata(client); |
232 | unsigned long val = simple_strtoul(buf, NULL, 10); | 233 | unsigned long val = simple_strtoul(buf, NULL, 10); |
233 | 234 | ||
234 | down(&data->update_lock); | 235 | mutex_lock(&data->update_lock); |
235 | data->in_min[nr] = IN_TO_REG(val); | 236 | data->in_min[nr] = IN_TO_REG(val); |
236 | sis5595_write_value(client, SIS5595_REG_IN_MIN(nr), data->in_min[nr]); | 237 | sis5595_write_value(client, SIS5595_REG_IN_MIN(nr), data->in_min[nr]); |
237 | up(&data->update_lock); | 238 | mutex_unlock(&data->update_lock); |
238 | return count; | 239 | return count; |
239 | } | 240 | } |
240 | 241 | ||
@@ -245,10 +246,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
245 | struct sis5595_data *data = i2c_get_clientdata(client); | 246 | struct sis5595_data *data = i2c_get_clientdata(client); |
246 | unsigned long val = simple_strtoul(buf, NULL, 10); | 247 | unsigned long val = simple_strtoul(buf, NULL, 10); |
247 | 248 | ||
248 | down(&data->update_lock); | 249 | mutex_lock(&data->update_lock); |
249 | data->in_max[nr] = IN_TO_REG(val); | 250 | data->in_max[nr] = IN_TO_REG(val); |
250 | sis5595_write_value(client, SIS5595_REG_IN_MAX(nr), data->in_max[nr]); | 251 | sis5595_write_value(client, SIS5595_REG_IN_MAX(nr), data->in_max[nr]); |
251 | up(&data->update_lock); | 252 | mutex_unlock(&data->update_lock); |
252 | return count; | 253 | return count; |
253 | } | 254 | } |
254 | 255 | ||
@@ -310,10 +311,10 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr, | |||
310 | struct sis5595_data *data = i2c_get_clientdata(client); | 311 | struct sis5595_data *data = i2c_get_clientdata(client); |
311 | long val = simple_strtol(buf, NULL, 10); | 312 | long val = simple_strtol(buf, NULL, 10); |
312 | 313 | ||
313 | down(&data->update_lock); | 314 | mutex_lock(&data->update_lock); |
314 | data->temp_over = TEMP_TO_REG(val); | 315 | data->temp_over = TEMP_TO_REG(val); |
315 | sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over); | 316 | sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over); |
316 | up(&data->update_lock); | 317 | mutex_unlock(&data->update_lock); |
317 | return count; | 318 | return count; |
318 | } | 319 | } |
319 | 320 | ||
@@ -329,10 +330,10 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr, | |||
329 | struct sis5595_data *data = i2c_get_clientdata(client); | 330 | struct sis5595_data *data = i2c_get_clientdata(client); |
330 | long val = simple_strtol(buf, NULL, 10); | 331 | long val = simple_strtol(buf, NULL, 10); |
331 | 332 | ||
332 | down(&data->update_lock); | 333 | mutex_lock(&data->update_lock); |
333 | data->temp_hyst = TEMP_TO_REG(val); | 334 | data->temp_hyst = TEMP_TO_REG(val); |
334 | sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst); | 335 | sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst); |
335 | up(&data->update_lock); | 336 | mutex_unlock(&data->update_lock); |
336 | return count; | 337 | return count; |
337 | } | 338 | } |
338 | 339 | ||
@@ -364,10 +365,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
364 | struct sis5595_data *data = i2c_get_clientdata(client); | 365 | struct sis5595_data *data = i2c_get_clientdata(client); |
365 | unsigned long val = simple_strtoul(buf, NULL, 10); | 366 | unsigned long val = simple_strtoul(buf, NULL, 10); |
366 | 367 | ||
367 | down(&data->update_lock); | 368 | mutex_lock(&data->update_lock); |
368 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 369 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
369 | sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]); | 370 | sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]); |
370 | up(&data->update_lock); | 371 | mutex_unlock(&data->update_lock); |
371 | return count; | 372 | return count; |
372 | } | 373 | } |
373 | 374 | ||
@@ -390,7 +391,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
390 | unsigned long val = simple_strtoul(buf, NULL, 10); | 391 | unsigned long val = simple_strtoul(buf, NULL, 10); |
391 | int reg; | 392 | int reg; |
392 | 393 | ||
393 | down(&data->update_lock); | 394 | mutex_lock(&data->update_lock); |
394 | min = FAN_FROM_REG(data->fan_min[nr], | 395 | min = FAN_FROM_REG(data->fan_min[nr], |
395 | DIV_FROM_REG(data->fan_div[nr])); | 396 | DIV_FROM_REG(data->fan_div[nr])); |
396 | reg = sis5595_read_value(client, SIS5595_REG_FANDIV); | 397 | reg = sis5595_read_value(client, SIS5595_REG_FANDIV); |
@@ -403,7 +404,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
403 | default: | 404 | default: |
404 | dev_err(&client->dev, "fan_div value %ld not " | 405 | dev_err(&client->dev, "fan_div value %ld not " |
405 | "supported. Choose one of 1, 2, 4 or 8!\n", val); | 406 | "supported. Choose one of 1, 2, 4 or 8!\n", val); |
406 | up(&data->update_lock); | 407 | mutex_unlock(&data->update_lock); |
407 | return -EINVAL; | 408 | return -EINVAL; |
408 | } | 409 | } |
409 | 410 | ||
@@ -419,7 +420,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
419 | data->fan_min[nr] = | 420 | data->fan_min[nr] = |
420 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 421 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
421 | sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]); | 422 | sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]); |
422 | up(&data->update_lock); | 423 | mutex_unlock(&data->update_lock); |
423 | return count; | 424 | return count; |
424 | } | 425 | } |
425 | 426 | ||
@@ -527,7 +528,7 @@ static int sis5595_detect(struct i2c_adapter *adapter) | |||
527 | 528 | ||
528 | new_client = &data->client; | 529 | new_client = &data->client; |
529 | new_client->addr = address; | 530 | new_client->addr = address; |
530 | init_MUTEX(&data->lock); | 531 | mutex_init(&data->lock); |
531 | i2c_set_clientdata(new_client, data); | 532 | i2c_set_clientdata(new_client, data); |
532 | new_client->adapter = adapter; | 533 | new_client->adapter = adapter; |
533 | new_client->driver = &sis5595_driver; | 534 | new_client->driver = &sis5595_driver; |
@@ -548,7 +549,7 @@ static int sis5595_detect(struct i2c_adapter *adapter) | |||
548 | strlcpy(new_client->name, "sis5595", I2C_NAME_SIZE); | 549 | strlcpy(new_client->name, "sis5595", I2C_NAME_SIZE); |
549 | 550 | ||
550 | data->valid = 0; | 551 | data->valid = 0; |
551 | init_MUTEX(&data->update_lock); | 552 | mutex_init(&data->update_lock); |
552 | 553 | ||
553 | /* Tell the I2C layer a new client has arrived */ | 554 | /* Tell the I2C layer a new client has arrived */ |
554 | if ((err = i2c_attach_client(new_client))) | 555 | if ((err = i2c_attach_client(new_client))) |
@@ -635,20 +636,20 @@ static int sis5595_read_value(struct i2c_client *client, u8 reg) | |||
635 | int res; | 636 | int res; |
636 | 637 | ||
637 | struct sis5595_data *data = i2c_get_clientdata(client); | 638 | struct sis5595_data *data = i2c_get_clientdata(client); |
638 | down(&data->lock); | 639 | mutex_lock(&data->lock); |
639 | outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET); | 640 | outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET); |
640 | res = inb_p(client->addr + SIS5595_DATA_REG_OFFSET); | 641 | res = inb_p(client->addr + SIS5595_DATA_REG_OFFSET); |
641 | up(&data->lock); | 642 | mutex_unlock(&data->lock); |
642 | return res; | 643 | return res; |
643 | } | 644 | } |
644 | 645 | ||
645 | static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value) | 646 | static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value) |
646 | { | 647 | { |
647 | struct sis5595_data *data = i2c_get_clientdata(client); | 648 | struct sis5595_data *data = i2c_get_clientdata(client); |
648 | down(&data->lock); | 649 | mutex_lock(&data->lock); |
649 | outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET); | 650 | outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET); |
650 | outb_p(value, client->addr + SIS5595_DATA_REG_OFFSET); | 651 | outb_p(value, client->addr + SIS5595_DATA_REG_OFFSET); |
651 | up(&data->lock); | 652 | mutex_unlock(&data->lock); |
652 | return 0; | 653 | return 0; |
653 | } | 654 | } |
654 | 655 | ||
@@ -667,7 +668,7 @@ static struct sis5595_data *sis5595_update_device(struct device *dev) | |||
667 | struct sis5595_data *data = i2c_get_clientdata(client); | 668 | struct sis5595_data *data = i2c_get_clientdata(client); |
668 | int i; | 669 | int i; |
669 | 670 | ||
670 | down(&data->update_lock); | 671 | mutex_lock(&data->update_lock); |
671 | 672 | ||
672 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 673 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
673 | || !data->valid) { | 674 | || !data->valid) { |
@@ -707,7 +708,7 @@ static struct sis5595_data *sis5595_update_device(struct device *dev) | |||
707 | data->valid = 1; | 708 | data->valid = 1; |
708 | } | 709 | } |
709 | 710 | ||
710 | up(&data->update_lock); | 711 | mutex_unlock(&data->update_lock); |
711 | 712 | ||
712 | return data; | 713 | return data; |
713 | } | 714 | } |
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index 8663bbbe97f5..b6086186d225 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/hwmon.h> | 35 | #include <linux/hwmon.h> |
36 | #include <linux/err.h> | 36 | #include <linux/err.h> |
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/mutex.h> | ||
38 | #include <asm/io.h> | 39 | #include <asm/io.h> |
39 | 40 | ||
40 | /* Address is autodetected, there is no default value */ | 41 | /* Address is autodetected, there is no default value */ |
@@ -92,9 +93,9 @@ static u8 smsc47b397_reg_temp[] = {0x25, 0x26, 0x27, 0x80}; | |||
92 | struct smsc47b397_data { | 93 | struct smsc47b397_data { |
93 | struct i2c_client client; | 94 | struct i2c_client client; |
94 | struct class_device *class_dev; | 95 | struct class_device *class_dev; |
95 | struct semaphore lock; | 96 | struct mutex lock; |
96 | 97 | ||
97 | struct semaphore update_lock; | 98 | struct mutex update_lock; |
98 | unsigned long last_updated; /* in jiffies */ | 99 | unsigned long last_updated; /* in jiffies */ |
99 | int valid; | 100 | int valid; |
100 | 101 | ||
@@ -108,10 +109,10 @@ static int smsc47b397_read_value(struct i2c_client *client, u8 reg) | |||
108 | struct smsc47b397_data *data = i2c_get_clientdata(client); | 109 | struct smsc47b397_data *data = i2c_get_clientdata(client); |
109 | int res; | 110 | int res; |
110 | 111 | ||
111 | down(&data->lock); | 112 | mutex_lock(&data->lock); |
112 | outb(reg, client->addr); | 113 | outb(reg, client->addr); |
113 | res = inb_p(client->addr + 1); | 114 | res = inb_p(client->addr + 1); |
114 | up(&data->lock); | 115 | mutex_unlock(&data->lock); |
115 | return res; | 116 | return res; |
116 | } | 117 | } |
117 | 118 | ||
@@ -121,7 +122,7 @@ static struct smsc47b397_data *smsc47b397_update_device(struct device *dev) | |||
121 | struct smsc47b397_data *data = i2c_get_clientdata(client); | 122 | struct smsc47b397_data *data = i2c_get_clientdata(client); |
122 | int i; | 123 | int i; |
123 | 124 | ||
124 | down(&data->update_lock); | 125 | mutex_lock(&data->update_lock); |
125 | 126 | ||
126 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | 127 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { |
127 | dev_dbg(&client->dev, "starting device update...\n"); | 128 | dev_dbg(&client->dev, "starting device update...\n"); |
@@ -144,7 +145,7 @@ static struct smsc47b397_data *smsc47b397_update_device(struct device *dev) | |||
144 | dev_dbg(&client->dev, "... device update complete\n"); | 145 | dev_dbg(&client->dev, "... device update complete\n"); |
145 | } | 146 | } |
146 | 147 | ||
147 | up(&data->update_lock); | 148 | mutex_unlock(&data->update_lock); |
148 | 149 | ||
149 | return data; | 150 | return data; |
150 | } | 151 | } |
@@ -254,14 +255,14 @@ static int smsc47b397_detect(struct i2c_adapter *adapter) | |||
254 | new_client = &data->client; | 255 | new_client = &data->client; |
255 | i2c_set_clientdata(new_client, data); | 256 | i2c_set_clientdata(new_client, data); |
256 | new_client->addr = address; | 257 | new_client->addr = address; |
257 | init_MUTEX(&data->lock); | 258 | mutex_init(&data->lock); |
258 | new_client->adapter = adapter; | 259 | new_client->adapter = adapter; |
259 | new_client->driver = &smsc47b397_driver; | 260 | new_client->driver = &smsc47b397_driver; |
260 | new_client->flags = 0; | 261 | new_client->flags = 0; |
261 | 262 | ||
262 | strlcpy(new_client->name, "smsc47b397", I2C_NAME_SIZE); | 263 | strlcpy(new_client->name, "smsc47b397", I2C_NAME_SIZE); |
263 | 264 | ||
264 | init_MUTEX(&data->update_lock); | 265 | mutex_init(&data->update_lock); |
265 | 266 | ||
266 | if ((err = i2c_attach_client(new_client))) | 267 | if ((err = i2c_attach_client(new_client))) |
267 | goto error_free; | 268 | goto error_free; |
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index d1e3ec0fe4df..7732aec54594 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/hwmon.h> | 34 | #include <linux/hwmon.h> |
35 | #include <linux/err.h> | 35 | #include <linux/err.h> |
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/mutex.h> | ||
37 | #include <asm/io.h> | 38 | #include <asm/io.h> |
38 | 39 | ||
39 | /* Address is autodetected, there is no default value */ | 40 | /* Address is autodetected, there is no default value */ |
@@ -102,9 +103,9 @@ superio_exit(void) | |||
102 | struct smsc47m1_data { | 103 | struct smsc47m1_data { |
103 | struct i2c_client client; | 104 | struct i2c_client client; |
104 | struct class_device *class_dev; | 105 | struct class_device *class_dev; |
105 | struct semaphore lock; | 106 | struct mutex lock; |
106 | 107 | ||
107 | struct semaphore update_lock; | 108 | struct mutex update_lock; |
108 | unsigned long last_updated; /* In jiffies */ | 109 | unsigned long last_updated; /* In jiffies */ |
109 | 110 | ||
110 | u8 fan[2]; /* Register value */ | 111 | u8 fan[2]; /* Register value */ |
@@ -188,18 +189,18 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
188 | struct smsc47m1_data *data = i2c_get_clientdata(client); | 189 | struct smsc47m1_data *data = i2c_get_clientdata(client); |
189 | long rpmdiv, val = simple_strtol(buf, NULL, 10); | 190 | long rpmdiv, val = simple_strtol(buf, NULL, 10); |
190 | 191 | ||
191 | down(&data->update_lock); | 192 | mutex_lock(&data->update_lock); |
192 | rpmdiv = val * DIV_FROM_REG(data->fan_div[nr]); | 193 | rpmdiv = val * DIV_FROM_REG(data->fan_div[nr]); |
193 | 194 | ||
194 | if (983040 > 192 * rpmdiv || 2 * rpmdiv > 983040) { | 195 | if (983040 > 192 * rpmdiv || 2 * rpmdiv > 983040) { |
195 | up(&data->update_lock); | 196 | mutex_unlock(&data->update_lock); |
196 | return -EINVAL; | 197 | return -EINVAL; |
197 | } | 198 | } |
198 | 199 | ||
199 | data->fan_preload[nr] = 192 - ((983040 + rpmdiv / 2) / rpmdiv); | 200 | data->fan_preload[nr] = 192 - ((983040 + rpmdiv / 2) / rpmdiv); |
200 | smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr), | 201 | smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr), |
201 | data->fan_preload[nr]); | 202 | data->fan_preload[nr]); |
202 | up(&data->update_lock); | 203 | mutex_unlock(&data->update_lock); |
203 | 204 | ||
204 | return count; | 205 | return count; |
205 | } | 206 | } |
@@ -220,14 +221,14 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
220 | if (new_div == old_div) /* No change */ | 221 | if (new_div == old_div) /* No change */ |
221 | return count; | 222 | return count; |
222 | 223 | ||
223 | down(&data->update_lock); | 224 | mutex_lock(&data->update_lock); |
224 | switch (new_div) { | 225 | switch (new_div) { |
225 | case 1: data->fan_div[nr] = 0; break; | 226 | case 1: data->fan_div[nr] = 0; break; |
226 | case 2: data->fan_div[nr] = 1; break; | 227 | case 2: data->fan_div[nr] = 1; break; |
227 | case 4: data->fan_div[nr] = 2; break; | 228 | case 4: data->fan_div[nr] = 2; break; |
228 | case 8: data->fan_div[nr] = 3; break; | 229 | case 8: data->fan_div[nr] = 3; break; |
229 | default: | 230 | default: |
230 | up(&data->update_lock); | 231 | mutex_unlock(&data->update_lock); |
231 | return -EINVAL; | 232 | return -EINVAL; |
232 | } | 233 | } |
233 | 234 | ||
@@ -241,7 +242,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
241 | data->fan_preload[nr] = SENSORS_LIMIT(tmp, 0, 191); | 242 | data->fan_preload[nr] = SENSORS_LIMIT(tmp, 0, 191); |
242 | smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr), | 243 | smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr), |
243 | data->fan_preload[nr]); | 244 | data->fan_preload[nr]); |
244 | up(&data->update_lock); | 245 | mutex_unlock(&data->update_lock); |
245 | 246 | ||
246 | return count; | 247 | return count; |
247 | } | 248 | } |
@@ -257,12 +258,12 @@ static ssize_t set_pwm(struct device *dev, const char *buf, | |||
257 | if (val < 0 || val > 255) | 258 | if (val < 0 || val > 255) |
258 | return -EINVAL; | 259 | return -EINVAL; |
259 | 260 | ||
260 | down(&data->update_lock); | 261 | mutex_lock(&data->update_lock); |
261 | data->pwm[nr] &= 0x81; /* Preserve additional bits */ | 262 | data->pwm[nr] &= 0x81; /* Preserve additional bits */ |
262 | data->pwm[nr] |= PWM_TO_REG(val); | 263 | data->pwm[nr] |= PWM_TO_REG(val); |
263 | smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr), | 264 | smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr), |
264 | data->pwm[nr]); | 265 | data->pwm[nr]); |
265 | up(&data->update_lock); | 266 | mutex_unlock(&data->update_lock); |
266 | 267 | ||
267 | return count; | 268 | return count; |
268 | } | 269 | } |
@@ -278,12 +279,12 @@ static ssize_t set_pwm_en(struct device *dev, const char *buf, | |||
278 | if (val != 0 && val != 1) | 279 | if (val != 0 && val != 1) |
279 | return -EINVAL; | 280 | return -EINVAL; |
280 | 281 | ||
281 | down(&data->update_lock); | 282 | mutex_lock(&data->update_lock); |
282 | data->pwm[nr] &= 0xFE; /* preserve the other bits */ | 283 | data->pwm[nr] &= 0xFE; /* preserve the other bits */ |
283 | data->pwm[nr] |= !val; | 284 | data->pwm[nr] |= !val; |
284 | smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr), | 285 | smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr), |
285 | data->pwm[nr]); | 286 | data->pwm[nr]); |
286 | up(&data->update_lock); | 287 | mutex_unlock(&data->update_lock); |
287 | 288 | ||
288 | return count; | 289 | return count; |
289 | } | 290 | } |
@@ -408,13 +409,13 @@ static int smsc47m1_detect(struct i2c_adapter *adapter) | |||
408 | new_client = &data->client; | 409 | new_client = &data->client; |
409 | i2c_set_clientdata(new_client, data); | 410 | i2c_set_clientdata(new_client, data); |
410 | new_client->addr = address; | 411 | new_client->addr = address; |
411 | init_MUTEX(&data->lock); | 412 | mutex_init(&data->lock); |
412 | new_client->adapter = adapter; | 413 | new_client->adapter = adapter; |
413 | new_client->driver = &smsc47m1_driver; | 414 | new_client->driver = &smsc47m1_driver; |
414 | new_client->flags = 0; | 415 | new_client->flags = 0; |
415 | 416 | ||
416 | strlcpy(new_client->name, "smsc47m1", I2C_NAME_SIZE); | 417 | strlcpy(new_client->name, "smsc47m1", I2C_NAME_SIZE); |
417 | init_MUTEX(&data->update_lock); | 418 | mutex_init(&data->update_lock); |
418 | 419 | ||
419 | /* If no function is properly configured, there's no point in | 420 | /* If no function is properly configured, there's no point in |
420 | actually registering the chip. */ | 421 | actually registering the chip. */ |
@@ -512,17 +513,17 @@ static int smsc47m1_read_value(struct i2c_client *client, u8 reg) | |||
512 | { | 513 | { |
513 | int res; | 514 | int res; |
514 | 515 | ||
515 | down(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); | 516 | mutex_lock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); |
516 | res = inb_p(client->addr + reg); | 517 | res = inb_p(client->addr + reg); |
517 | up(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); | 518 | mutex_unlock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); |
518 | return res; | 519 | return res; |
519 | } | 520 | } |
520 | 521 | ||
521 | static void smsc47m1_write_value(struct i2c_client *client, u8 reg, u8 value) | 522 | static void smsc47m1_write_value(struct i2c_client *client, u8 reg, u8 value) |
522 | { | 523 | { |
523 | down(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); | 524 | mutex_lock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); |
524 | outb_p(value, client->addr + reg); | 525 | outb_p(value, client->addr + reg); |
525 | up(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); | 526 | mutex_unlock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock); |
526 | } | 527 | } |
527 | 528 | ||
528 | static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, | 529 | static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, |
@@ -531,7 +532,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, | |||
531 | struct i2c_client *client = to_i2c_client(dev); | 532 | struct i2c_client *client = to_i2c_client(dev); |
532 | struct smsc47m1_data *data = i2c_get_clientdata(client); | 533 | struct smsc47m1_data *data = i2c_get_clientdata(client); |
533 | 534 | ||
534 | down(&data->update_lock); | 535 | mutex_lock(&data->update_lock); |
535 | 536 | ||
536 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || init) { | 537 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || init) { |
537 | int i; | 538 | int i; |
@@ -558,7 +559,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, | |||
558 | data->last_updated = jiffies; | 559 | data->last_updated = jiffies; |
559 | } | 560 | } |
560 | 561 | ||
561 | up(&data->update_lock); | 562 | mutex_unlock(&data->update_lock); |
562 | return data; | 563 | return data; |
563 | } | 564 | } |
564 | 565 | ||
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index cb01848729b5..166298f1f190 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/hwmon.h> | 39 | #include <linux/hwmon.h> |
40 | #include <linux/err.h> | 40 | #include <linux/err.h> |
41 | #include <linux/init.h> | 41 | #include <linux/init.h> |
42 | #include <linux/mutex.h> | ||
42 | #include <asm/io.h> | 43 | #include <asm/io.h> |
43 | 44 | ||
44 | 45 | ||
@@ -296,7 +297,7 @@ static inline long TEMP_FROM_REG10(u16 val) | |||
296 | struct via686a_data { | 297 | struct via686a_data { |
297 | struct i2c_client client; | 298 | struct i2c_client client; |
298 | struct class_device *class_dev; | 299 | struct class_device *class_dev; |
299 | struct semaphore update_lock; | 300 | struct mutex update_lock; |
300 | char valid; /* !=0 if following fields are valid */ | 301 | char valid; /* !=0 if following fields are valid */ |
301 | unsigned long last_updated; /* In jiffies */ | 302 | unsigned long last_updated; /* In jiffies */ |
302 | 303 | ||
@@ -355,11 +356,11 @@ static ssize_t set_in_min(struct device *dev, const char *buf, | |||
355 | struct via686a_data *data = i2c_get_clientdata(client); | 356 | struct via686a_data *data = i2c_get_clientdata(client); |
356 | unsigned long val = simple_strtoul(buf, NULL, 10); | 357 | unsigned long val = simple_strtoul(buf, NULL, 10); |
357 | 358 | ||
358 | down(&data->update_lock); | 359 | mutex_lock(&data->update_lock); |
359 | data->in_min[nr] = IN_TO_REG(val, nr); | 360 | data->in_min[nr] = IN_TO_REG(val, nr); |
360 | via686a_write_value(client, VIA686A_REG_IN_MIN(nr), | 361 | via686a_write_value(client, VIA686A_REG_IN_MIN(nr), |
361 | data->in_min[nr]); | 362 | data->in_min[nr]); |
362 | up(&data->update_lock); | 363 | mutex_unlock(&data->update_lock); |
363 | return count; | 364 | return count; |
364 | } | 365 | } |
365 | static ssize_t set_in_max(struct device *dev, const char *buf, | 366 | static ssize_t set_in_max(struct device *dev, const char *buf, |
@@ -368,11 +369,11 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
368 | struct via686a_data *data = i2c_get_clientdata(client); | 369 | struct via686a_data *data = i2c_get_clientdata(client); |
369 | unsigned long val = simple_strtoul(buf, NULL, 10); | 370 | unsigned long val = simple_strtoul(buf, NULL, 10); |
370 | 371 | ||
371 | down(&data->update_lock); | 372 | mutex_lock(&data->update_lock); |
372 | data->in_max[nr] = IN_TO_REG(val, nr); | 373 | data->in_max[nr] = IN_TO_REG(val, nr); |
373 | via686a_write_value(client, VIA686A_REG_IN_MAX(nr), | 374 | via686a_write_value(client, VIA686A_REG_IN_MAX(nr), |
374 | data->in_max[nr]); | 375 | data->in_max[nr]); |
375 | up(&data->update_lock); | 376 | mutex_unlock(&data->update_lock); |
376 | return count; | 377 | return count; |
377 | } | 378 | } |
378 | #define show_in_offset(offset) \ | 379 | #define show_in_offset(offset) \ |
@@ -432,11 +433,11 @@ static ssize_t set_temp_over(struct device *dev, const char *buf, | |||
432 | struct via686a_data *data = i2c_get_clientdata(client); | 433 | struct via686a_data *data = i2c_get_clientdata(client); |
433 | int val = simple_strtol(buf, NULL, 10); | 434 | int val = simple_strtol(buf, NULL, 10); |
434 | 435 | ||
435 | down(&data->update_lock); | 436 | mutex_lock(&data->update_lock); |
436 | data->temp_over[nr] = TEMP_TO_REG(val); | 437 | data->temp_over[nr] = TEMP_TO_REG(val); |
437 | via686a_write_value(client, VIA686A_REG_TEMP_OVER[nr], | 438 | via686a_write_value(client, VIA686A_REG_TEMP_OVER[nr], |
438 | data->temp_over[nr]); | 439 | data->temp_over[nr]); |
439 | up(&data->update_lock); | 440 | mutex_unlock(&data->update_lock); |
440 | return count; | 441 | return count; |
441 | } | 442 | } |
442 | static ssize_t set_temp_hyst(struct device *dev, const char *buf, | 443 | static ssize_t set_temp_hyst(struct device *dev, const char *buf, |
@@ -445,11 +446,11 @@ static ssize_t set_temp_hyst(struct device *dev, const char *buf, | |||
445 | struct via686a_data *data = i2c_get_clientdata(client); | 446 | struct via686a_data *data = i2c_get_clientdata(client); |
446 | int val = simple_strtol(buf, NULL, 10); | 447 | int val = simple_strtol(buf, NULL, 10); |
447 | 448 | ||
448 | down(&data->update_lock); | 449 | mutex_lock(&data->update_lock); |
449 | data->temp_hyst[nr] = TEMP_TO_REG(val); | 450 | data->temp_hyst[nr] = TEMP_TO_REG(val); |
450 | via686a_write_value(client, VIA686A_REG_TEMP_HYST[nr], | 451 | via686a_write_value(client, VIA686A_REG_TEMP_HYST[nr], |
451 | data->temp_hyst[nr]); | 452 | data->temp_hyst[nr]); |
452 | up(&data->update_lock); | 453 | mutex_unlock(&data->update_lock); |
453 | return count; | 454 | return count; |
454 | } | 455 | } |
455 | #define show_temp_offset(offset) \ | 456 | #define show_temp_offset(offset) \ |
@@ -508,10 +509,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
508 | struct via686a_data *data = i2c_get_clientdata(client); | 509 | struct via686a_data *data = i2c_get_clientdata(client); |
509 | int val = simple_strtol(buf, NULL, 10); | 510 | int val = simple_strtol(buf, NULL, 10); |
510 | 511 | ||
511 | down(&data->update_lock); | 512 | mutex_lock(&data->update_lock); |
512 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 513 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
513 | via686a_write_value(client, VIA686A_REG_FAN_MIN(nr+1), data->fan_min[nr]); | 514 | via686a_write_value(client, VIA686A_REG_FAN_MIN(nr+1), data->fan_min[nr]); |
514 | up(&data->update_lock); | 515 | mutex_unlock(&data->update_lock); |
515 | return count; | 516 | return count; |
516 | } | 517 | } |
517 | static ssize_t set_fan_div(struct device *dev, const char *buf, | 518 | static ssize_t set_fan_div(struct device *dev, const char *buf, |
@@ -521,12 +522,12 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
521 | int val = simple_strtol(buf, NULL, 10); | 522 | int val = simple_strtol(buf, NULL, 10); |
522 | int old; | 523 | int old; |
523 | 524 | ||
524 | down(&data->update_lock); | 525 | mutex_lock(&data->update_lock); |
525 | old = via686a_read_value(client, VIA686A_REG_FANDIV); | 526 | old = via686a_read_value(client, VIA686A_REG_FANDIV); |
526 | data->fan_div[nr] = DIV_TO_REG(val); | 527 | data->fan_div[nr] = DIV_TO_REG(val); |
527 | old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); | 528 | old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); |
528 | via686a_write_value(client, VIA686A_REG_FANDIV, old); | 529 | via686a_write_value(client, VIA686A_REG_FANDIV, old); |
529 | up(&data->update_lock); | 530 | mutex_unlock(&data->update_lock); |
530 | return count; | 531 | return count; |
531 | } | 532 | } |
532 | 533 | ||
@@ -639,7 +640,7 @@ static int via686a_detect(struct i2c_adapter *adapter) | |||
639 | strlcpy(new_client->name, client_name, I2C_NAME_SIZE); | 640 | strlcpy(new_client->name, client_name, I2C_NAME_SIZE); |
640 | 641 | ||
641 | data->valid = 0; | 642 | data->valid = 0; |
642 | init_MUTEX(&data->update_lock); | 643 | mutex_init(&data->update_lock); |
643 | /* Tell the I2C layer a new client has arrived */ | 644 | /* Tell the I2C layer a new client has arrived */ |
644 | if ((err = i2c_attach_client(new_client))) | 645 | if ((err = i2c_attach_client(new_client))) |
645 | goto exit_free; | 646 | goto exit_free; |
@@ -733,7 +734,7 @@ static struct via686a_data *via686a_update_device(struct device *dev) | |||
733 | struct via686a_data *data = i2c_get_clientdata(client); | 734 | struct via686a_data *data = i2c_get_clientdata(client); |
734 | int i; | 735 | int i; |
735 | 736 | ||
736 | down(&data->update_lock); | 737 | mutex_lock(&data->update_lock); |
737 | 738 | ||
738 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 739 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
739 | || !data->valid) { | 740 | || !data->valid) { |
@@ -788,7 +789,7 @@ static struct via686a_data *via686a_update_device(struct device *dev) | |||
788 | data->valid = 1; | 789 | data->valid = 1; |
789 | } | 790 | } |
790 | 791 | ||
791 | up(&data->update_lock); | 792 | mutex_unlock(&data->update_lock); |
792 | 793 | ||
793 | return data; | 794 | return data; |
794 | } | 795 | } |
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c index 271e9cb9532c..686f3deb3093 100644 --- a/drivers/hwmon/vt8231.c +++ b/drivers/hwmon/vt8231.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/hwmon-sysfs.h> | 35 | #include <linux/hwmon-sysfs.h> |
36 | #include <linux/hwmon-vid.h> | 36 | #include <linux/hwmon-vid.h> |
37 | #include <linux/err.h> | 37 | #include <linux/err.h> |
38 | #include <linux/mutex.h> | ||
38 | #include <asm/io.h> | 39 | #include <asm/io.h> |
39 | 40 | ||
40 | static int force_addr; | 41 | static int force_addr; |
@@ -148,7 +149,7 @@ static inline u8 FAN_TO_REG(long rpm, int div) | |||
148 | 149 | ||
149 | struct vt8231_data { | 150 | struct vt8231_data { |
150 | struct i2c_client client; | 151 | struct i2c_client client; |
151 | struct semaphore update_lock; | 152 | struct mutex update_lock; |
152 | struct class_device *class_dev; | 153 | struct class_device *class_dev; |
153 | char valid; /* !=0 if following fields are valid */ | 154 | char valid; /* !=0 if following fields are valid */ |
154 | unsigned long last_updated; /* In jiffies */ | 155 | unsigned long last_updated; /* In jiffies */ |
@@ -223,10 +224,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | |||
223 | struct vt8231_data *data = i2c_get_clientdata(client); | 224 | struct vt8231_data *data = i2c_get_clientdata(client); |
224 | unsigned long val = simple_strtoul(buf, NULL, 10); | 225 | unsigned long val = simple_strtoul(buf, NULL, 10); |
225 | 226 | ||
226 | down(&data->update_lock); | 227 | mutex_lock(&data->update_lock); |
227 | data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); | 228 | data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); |
228 | vt8231_write_value(client, regvoltmin[nr], data->in_min[nr]); | 229 | vt8231_write_value(client, regvoltmin[nr], data->in_min[nr]); |
229 | up(&data->update_lock); | 230 | mutex_unlock(&data->update_lock); |
230 | return count; | 231 | return count; |
231 | } | 232 | } |
232 | 233 | ||
@@ -239,10 +240,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | |||
239 | struct vt8231_data *data = i2c_get_clientdata(client); | 240 | struct vt8231_data *data = i2c_get_clientdata(client); |
240 | unsigned long val = simple_strtoul(buf, NULL, 10); | 241 | unsigned long val = simple_strtoul(buf, NULL, 10); |
241 | 242 | ||
242 | down(&data->update_lock); | 243 | mutex_lock(&data->update_lock); |
243 | data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); | 244 | data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); |
244 | vt8231_write_value(client, regvoltmax[nr], data->in_max[nr]); | 245 | vt8231_write_value(client, regvoltmax[nr], data->in_max[nr]); |
245 | up(&data->update_lock); | 246 | mutex_unlock(&data->update_lock); |
246 | return count; | 247 | return count; |
247 | } | 248 | } |
248 | 249 | ||
@@ -281,11 +282,11 @@ static ssize_t set_in5_min(struct device *dev, struct device_attribute *attr, | |||
281 | struct vt8231_data *data = i2c_get_clientdata(client); | 282 | struct vt8231_data *data = i2c_get_clientdata(client); |
282 | unsigned long val = simple_strtoul(buf, NULL, 10); | 283 | unsigned long val = simple_strtoul(buf, NULL, 10); |
283 | 284 | ||
284 | down(&data->update_lock); | 285 | mutex_lock(&data->update_lock); |
285 | data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, | 286 | data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, |
286 | 0, 255); | 287 | 0, 255); |
287 | vt8231_write_value(client, regvoltmin[5], data->in_min[5]); | 288 | vt8231_write_value(client, regvoltmin[5], data->in_min[5]); |
288 | up(&data->update_lock); | 289 | mutex_unlock(&data->update_lock); |
289 | return count; | 290 | return count; |
290 | } | 291 | } |
291 | 292 | ||
@@ -296,11 +297,11 @@ static ssize_t set_in5_max(struct device *dev, struct device_attribute *attr, | |||
296 | struct vt8231_data *data = i2c_get_clientdata(client); | 297 | struct vt8231_data *data = i2c_get_clientdata(client); |
297 | unsigned long val = simple_strtoul(buf, NULL, 10); | 298 | unsigned long val = simple_strtoul(buf, NULL, 10); |
298 | 299 | ||
299 | down(&data->update_lock); | 300 | mutex_lock(&data->update_lock); |
300 | data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, | 301 | data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, |
301 | 0, 255); | 302 | 0, 255); |
302 | vt8231_write_value(client, regvoltmax[5], data->in_max[5]); | 303 | vt8231_write_value(client, regvoltmax[5], data->in_max[5]); |
303 | up(&data->update_lock); | 304 | mutex_unlock(&data->update_lock); |
304 | return count; | 305 | return count; |
305 | } | 306 | } |
306 | 307 | ||
@@ -351,10 +352,10 @@ static ssize_t set_temp0_max(struct device *dev, struct device_attribute *attr, | |||
351 | struct vt8231_data *data = i2c_get_clientdata(client); | 352 | struct vt8231_data *data = i2c_get_clientdata(client); |
352 | int val = simple_strtol(buf, NULL, 10); | 353 | int val = simple_strtol(buf, NULL, 10); |
353 | 354 | ||
354 | down(&data->update_lock); | 355 | mutex_lock(&data->update_lock); |
355 | data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); | 356 | data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); |
356 | vt8231_write_value(client, regtempmax[0], data->temp_max[0]); | 357 | vt8231_write_value(client, regtempmax[0], data->temp_max[0]); |
357 | up(&data->update_lock); | 358 | mutex_unlock(&data->update_lock); |
358 | return count; | 359 | return count; |
359 | } | 360 | } |
360 | static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr, | 361 | static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr, |
@@ -364,10 +365,10 @@ static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr, | |||
364 | struct vt8231_data *data = i2c_get_clientdata(client); | 365 | struct vt8231_data *data = i2c_get_clientdata(client); |
365 | int val = simple_strtol(buf, NULL, 10); | 366 | int val = simple_strtol(buf, NULL, 10); |
366 | 367 | ||
367 | down(&data->update_lock); | 368 | mutex_lock(&data->update_lock); |
368 | data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); | 369 | data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); |
369 | vt8231_write_value(client, regtempmin[0], data->temp_min[0]); | 370 | vt8231_write_value(client, regtempmin[0], data->temp_min[0]); |
370 | up(&data->update_lock); | 371 | mutex_unlock(&data->update_lock); |
371 | return count; | 372 | return count; |
372 | } | 373 | } |
373 | 374 | ||
@@ -407,10 +408,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
407 | struct vt8231_data *data = i2c_get_clientdata(client); | 408 | struct vt8231_data *data = i2c_get_clientdata(client); |
408 | int val = simple_strtol(buf, NULL, 10); | 409 | int val = simple_strtol(buf, NULL, 10); |
409 | 410 | ||
410 | down(&data->update_lock); | 411 | mutex_lock(&data->update_lock); |
411 | data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); | 412 | data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); |
412 | vt8231_write_value(client, regtempmax[nr], data->temp_max[nr]); | 413 | vt8231_write_value(client, regtempmax[nr], data->temp_max[nr]); |
413 | up(&data->update_lock); | 414 | mutex_unlock(&data->update_lock); |
414 | return count; | 415 | return count; |
415 | } | 416 | } |
416 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | 417 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
@@ -422,10 +423,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | |||
422 | struct vt8231_data *data = i2c_get_clientdata(client); | 423 | struct vt8231_data *data = i2c_get_clientdata(client); |
423 | int val = simple_strtol(buf, NULL, 10); | 424 | int val = simple_strtol(buf, NULL, 10); |
424 | 425 | ||
425 | down(&data->update_lock); | 426 | mutex_lock(&data->update_lock); |
426 | data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); | 427 | data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); |
427 | vt8231_write_value(client, regtempmin[nr], data->temp_min[nr]); | 428 | vt8231_write_value(client, regtempmin[nr], data->temp_min[nr]); |
428 | up(&data->update_lock); | 429 | mutex_unlock(&data->update_lock); |
429 | return count; | 430 | return count; |
430 | } | 431 | } |
431 | 432 | ||
@@ -520,10 +521,10 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
520 | struct vt8231_data *data = i2c_get_clientdata(client); | 521 | struct vt8231_data *data = i2c_get_clientdata(client); |
521 | int val = simple_strtoul(buf, NULL, 10); | 522 | int val = simple_strtoul(buf, NULL, 10); |
522 | 523 | ||
523 | down(&data->update_lock); | 524 | mutex_lock(&data->update_lock); |
524 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 525 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
525 | vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]); | 526 | vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]); |
526 | up(&data->update_lock); | 527 | mutex_unlock(&data->update_lock); |
527 | return count; | 528 | return count; |
528 | } | 529 | } |
529 | 530 | ||
@@ -539,7 +540,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
539 | long min = FAN_FROM_REG(data->fan_min[nr], | 540 | long min = FAN_FROM_REG(data->fan_min[nr], |
540 | DIV_FROM_REG(data->fan_div[nr])); | 541 | DIV_FROM_REG(data->fan_div[nr])); |
541 | 542 | ||
542 | down(&data->update_lock); | 543 | mutex_lock(&data->update_lock); |
543 | switch (val) { | 544 | switch (val) { |
544 | case 1: data->fan_div[nr] = 0; break; | 545 | case 1: data->fan_div[nr] = 0; break; |
545 | case 2: data->fan_div[nr] = 1; break; | 546 | case 2: data->fan_div[nr] = 1; break; |
@@ -548,7 +549,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
548 | default: | 549 | default: |
549 | dev_err(&client->dev, "fan_div value %ld not supported." | 550 | dev_err(&client->dev, "fan_div value %ld not supported." |
550 | "Choose one of 1, 2, 4 or 8!\n", val); | 551 | "Choose one of 1, 2, 4 or 8!\n", val); |
551 | up(&data->update_lock); | 552 | mutex_unlock(&data->update_lock); |
552 | return -EINVAL; | 553 | return -EINVAL; |
553 | } | 554 | } |
554 | 555 | ||
@@ -558,7 +559,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
558 | 559 | ||
559 | old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); | 560 | old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); |
560 | vt8231_write_value(client, VT8231_REG_FANDIV, old); | 561 | vt8231_write_value(client, VT8231_REG_FANDIV, old); |
561 | up(&data->update_lock); | 562 | mutex_unlock(&data->update_lock); |
562 | return count; | 563 | return count; |
563 | } | 564 | } |
564 | 565 | ||
@@ -660,7 +661,7 @@ int vt8231_detect(struct i2c_adapter *adapter) | |||
660 | /* Fill in the remaining client fields and put into the global list */ | 661 | /* Fill in the remaining client fields and put into the global list */ |
661 | strlcpy(client->name, "vt8231", I2C_NAME_SIZE); | 662 | strlcpy(client->name, "vt8231", I2C_NAME_SIZE); |
662 | 663 | ||
663 | init_MUTEX(&data->update_lock); | 664 | mutex_init(&data->update_lock); |
664 | 665 | ||
665 | /* Tell the I2C layer a new client has arrived */ | 666 | /* Tell the I2C layer a new client has arrived */ |
666 | if ((err = i2c_attach_client(client))) | 667 | if ((err = i2c_attach_client(client))) |
@@ -745,7 +746,7 @@ static struct vt8231_data *vt8231_update_device(struct device *dev) | |||
745 | int i; | 746 | int i; |
746 | u16 low; | 747 | u16 low; |
747 | 748 | ||
748 | down(&data->update_lock); | 749 | mutex_lock(&data->update_lock); |
749 | 750 | ||
750 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 751 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
751 | || !data->valid) { | 752 | || !data->valid) { |
@@ -804,7 +805,7 @@ static struct vt8231_data *vt8231_update_device(struct device *dev) | |||
804 | data->valid = 1; | 805 | data->valid = 1; |
805 | } | 806 | } |
806 | 807 | ||
807 | up(&data->update_lock); | 808 | mutex_unlock(&data->update_lock); |
808 | 809 | ||
809 | return data; | 810 | return data; |
810 | } | 811 | } |
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index 12d79f5e4900..b6bd5685fd38 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c | |||
@@ -42,7 +42,9 @@ | |||
42 | #include <linux/i2c.h> | 42 | #include <linux/i2c.h> |
43 | #include <linux/i2c-isa.h> | 43 | #include <linux/i2c-isa.h> |
44 | #include <linux/hwmon.h> | 44 | #include <linux/hwmon.h> |
45 | #include <linux/hwmon-sysfs.h> | ||
45 | #include <linux/err.h> | 46 | #include <linux/err.h> |
47 | #include <linux/mutex.h> | ||
46 | #include <asm/io.h> | 48 | #include <asm/io.h> |
47 | #include "lm75.h" | 49 | #include "lm75.h" |
48 | 50 | ||
@@ -177,9 +179,9 @@ temp1_to_reg(int temp) | |||
177 | struct w83627ehf_data { | 179 | struct w83627ehf_data { |
178 | struct i2c_client client; | 180 | struct i2c_client client; |
179 | struct class_device *class_dev; | 181 | struct class_device *class_dev; |
180 | struct semaphore lock; | 182 | struct mutex lock; |
181 | 183 | ||
182 | struct semaphore update_lock; | 184 | struct mutex update_lock; |
183 | char valid; /* !=0 if following fields are valid */ | 185 | char valid; /* !=0 if following fields are valid */ |
184 | unsigned long last_updated; /* In jiffies */ | 186 | unsigned long last_updated; /* In jiffies */ |
185 | 187 | ||
@@ -230,7 +232,7 @@ static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg) | |||
230 | struct w83627ehf_data *data = i2c_get_clientdata(client); | 232 | struct w83627ehf_data *data = i2c_get_clientdata(client); |
231 | int res, word_sized = is_word_sized(reg); | 233 | int res, word_sized = is_word_sized(reg); |
232 | 234 | ||
233 | down(&data->lock); | 235 | mutex_lock(&data->lock); |
234 | 236 | ||
235 | w83627ehf_set_bank(client, reg); | 237 | w83627ehf_set_bank(client, reg); |
236 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); | 238 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); |
@@ -242,7 +244,7 @@ static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg) | |||
242 | } | 244 | } |
243 | w83627ehf_reset_bank(client, reg); | 245 | w83627ehf_reset_bank(client, reg); |
244 | 246 | ||
245 | up(&data->lock); | 247 | mutex_unlock(&data->lock); |
246 | 248 | ||
247 | return res; | 249 | return res; |
248 | } | 250 | } |
@@ -252,7 +254,7 @@ static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
252 | struct w83627ehf_data *data = i2c_get_clientdata(client); | 254 | struct w83627ehf_data *data = i2c_get_clientdata(client); |
253 | int word_sized = is_word_sized(reg); | 255 | int word_sized = is_word_sized(reg); |
254 | 256 | ||
255 | down(&data->lock); | 257 | mutex_lock(&data->lock); |
256 | 258 | ||
257 | w83627ehf_set_bank(client, reg); | 259 | w83627ehf_set_bank(client, reg); |
258 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); | 260 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); |
@@ -264,7 +266,7 @@ static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
264 | outb_p(value & 0xff, client->addr + DATA_REG_OFFSET); | 266 | outb_p(value & 0xff, client->addr + DATA_REG_OFFSET); |
265 | w83627ehf_reset_bank(client, reg); | 267 | w83627ehf_reset_bank(client, reg); |
266 | 268 | ||
267 | up(&data->lock); | 269 | mutex_unlock(&data->lock); |
268 | return 0; | 270 | return 0; |
269 | } | 271 | } |
270 | 272 | ||
@@ -322,7 +324,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev) | |||
322 | struct w83627ehf_data *data = i2c_get_clientdata(client); | 324 | struct w83627ehf_data *data = i2c_get_clientdata(client); |
323 | int i; | 325 | int i; |
324 | 326 | ||
325 | down(&data->update_lock); | 327 | mutex_lock(&data->update_lock); |
326 | 328 | ||
327 | if (time_after(jiffies, data->last_updated + HZ) | 329 | if (time_after(jiffies, data->last_updated + HZ) |
328 | || !data->valid) { | 330 | || !data->valid) { |
@@ -397,7 +399,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev) | |||
397 | data->valid = 1; | 399 | data->valid = 1; |
398 | } | 400 | } |
399 | 401 | ||
400 | up(&data->update_lock); | 402 | mutex_unlock(&data->update_lock); |
401 | return data; | 403 | return data; |
402 | } | 404 | } |
403 | 405 | ||
@@ -407,9 +409,12 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev) | |||
407 | 409 | ||
408 | #define show_fan_reg(reg) \ | 410 | #define show_fan_reg(reg) \ |
409 | static ssize_t \ | 411 | static ssize_t \ |
410 | show_##reg(struct device *dev, char *buf, int nr) \ | 412 | show_##reg(struct device *dev, struct device_attribute *attr, \ |
413 | char *buf) \ | ||
411 | { \ | 414 | { \ |
412 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ | 415 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ |
416 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ | ||
417 | int nr = sensor_attr->index; \ | ||
413 | return sprintf(buf, "%d\n", \ | 418 | return sprintf(buf, "%d\n", \ |
414 | fan_from_reg(data->reg[nr], \ | 419 | fan_from_reg(data->reg[nr], \ |
415 | div_from_reg(data->fan_div[nr]))); \ | 420 | div_from_reg(data->fan_div[nr]))); \ |
@@ -418,23 +423,28 @@ show_fan_reg(fan); | |||
418 | show_fan_reg(fan_min); | 423 | show_fan_reg(fan_min); |
419 | 424 | ||
420 | static ssize_t | 425 | static ssize_t |
421 | show_fan_div(struct device *dev, char *buf, int nr) | 426 | show_fan_div(struct device *dev, struct device_attribute *attr, |
427 | char *buf) | ||
422 | { | 428 | { |
423 | struct w83627ehf_data *data = w83627ehf_update_device(dev); | 429 | struct w83627ehf_data *data = w83627ehf_update_device(dev); |
424 | return sprintf(buf, "%u\n", | 430 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
425 | div_from_reg(data->fan_div[nr])); | 431 | int nr = sensor_attr->index; |
432 | return sprintf(buf, "%u\n", div_from_reg(data->fan_div[nr])); | ||
426 | } | 433 | } |
427 | 434 | ||
428 | static ssize_t | 435 | static ssize_t |
429 | store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | 436 | store_fan_min(struct device *dev, struct device_attribute *attr, |
437 | const char *buf, size_t count) | ||
430 | { | 438 | { |
431 | struct i2c_client *client = to_i2c_client(dev); | 439 | struct i2c_client *client = to_i2c_client(dev); |
432 | struct w83627ehf_data *data = i2c_get_clientdata(client); | 440 | struct w83627ehf_data *data = i2c_get_clientdata(client); |
441 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
442 | int nr = sensor_attr->index; | ||
433 | unsigned int val = simple_strtoul(buf, NULL, 10); | 443 | unsigned int val = simple_strtoul(buf, NULL, 10); |
434 | unsigned int reg; | 444 | unsigned int reg; |
435 | u8 new_div; | 445 | u8 new_div; |
436 | 446 | ||
437 | down(&data->update_lock); | 447 | mutex_lock(&data->update_lock); |
438 | if (!val) { | 448 | if (!val) { |
439 | /* No min limit, alarm disabled */ | 449 | /* No min limit, alarm disabled */ |
440 | data->fan_min[nr] = 255; | 450 | data->fan_min[nr] = 255; |
@@ -482,63 +492,46 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
482 | } | 492 | } |
483 | w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr], | 493 | w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr], |
484 | data->fan_min[nr]); | 494 | data->fan_min[nr]); |
485 | up(&data->update_lock); | 495 | mutex_unlock(&data->update_lock); |
486 | 496 | ||
487 | return count; | 497 | return count; |
488 | } | 498 | } |
489 | 499 | ||
490 | #define sysfs_fan_offset(offset) \ | 500 | static struct sensor_device_attribute sda_fan_input[] = { |
491 | static ssize_t \ | 501 | SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0), |
492 | show_reg_fan_##offset(struct device *dev, struct device_attribute *attr, \ | 502 | SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1), |
493 | char *buf) \ | 503 | SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2), |
494 | { \ | 504 | SENSOR_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3), |
495 | return show_fan(dev, buf, offset-1); \ | 505 | SENSOR_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 4), |
496 | } \ | 506 | }; |
497 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
498 | show_reg_fan_##offset, NULL); | ||
499 | 507 | ||
500 | #define sysfs_fan_min_offset(offset) \ | 508 | static struct sensor_device_attribute sda_fan_min[] = { |
501 | static ssize_t \ | 509 | SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, |
502 | show_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ | 510 | store_fan_min, 0), |
503 | char *buf) \ | 511 | SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, |
504 | { \ | 512 | store_fan_min, 1), |
505 | return show_fan_min(dev, buf, offset-1); \ | 513 | SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, |
506 | } \ | 514 | store_fan_min, 2), |
507 | static ssize_t \ | 515 | SENSOR_ATTR(fan4_min, S_IWUSR | S_IRUGO, show_fan_min, |
508 | store_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ | 516 | store_fan_min, 3), |
509 | const char *buf, size_t count) \ | 517 | SENSOR_ATTR(fan5_min, S_IWUSR | S_IRUGO, show_fan_min, |
510 | { \ | 518 | store_fan_min, 4), |
511 | return store_fan_min(dev, buf, count, offset-1); \ | 519 | }; |
512 | } \ | ||
513 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
514 | show_reg_fan##offset##_min, \ | ||
515 | store_reg_fan##offset##_min); | ||
516 | 520 | ||
517 | #define sysfs_fan_div_offset(offset) \ | 521 | static struct sensor_device_attribute sda_fan_div[] = { |
518 | static ssize_t \ | 522 | SENSOR_ATTR(fan1_div, S_IRUGO, show_fan_div, NULL, 0), |
519 | show_reg_fan##offset##_div(struct device *dev, struct device_attribute *attr, \ | 523 | SENSOR_ATTR(fan2_div, S_IRUGO, show_fan_div, NULL, 1), |
520 | char *buf) \ | 524 | SENSOR_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2), |
521 | { \ | 525 | SENSOR_ATTR(fan4_div, S_IRUGO, show_fan_div, NULL, 3), |
522 | return show_fan_div(dev, buf, offset - 1); \ | 526 | SENSOR_ATTR(fan5_div, S_IRUGO, show_fan_div, NULL, 4), |
523 | } \ | 527 | }; |
524 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ | 528 | |
525 | show_reg_fan##offset##_div, NULL); | 529 | static void device_create_file_fan(struct device *dev, int i) |
526 | 530 | { | |
527 | sysfs_fan_offset(1); | 531 | device_create_file(dev, &sda_fan_input[i].dev_attr); |
528 | sysfs_fan_min_offset(1); | 532 | device_create_file(dev, &sda_fan_div[i].dev_attr); |
529 | sysfs_fan_div_offset(1); | 533 | device_create_file(dev, &sda_fan_min[i].dev_attr); |
530 | sysfs_fan_offset(2); | 534 | } |
531 | sysfs_fan_min_offset(2); | ||
532 | sysfs_fan_div_offset(2); | ||
533 | sysfs_fan_offset(3); | ||
534 | sysfs_fan_min_offset(3); | ||
535 | sysfs_fan_div_offset(3); | ||
536 | sysfs_fan_offset(4); | ||
537 | sysfs_fan_min_offset(4); | ||
538 | sysfs_fan_div_offset(4); | ||
539 | sysfs_fan_offset(5); | ||
540 | sysfs_fan_min_offset(5); | ||
541 | sysfs_fan_div_offset(5); | ||
542 | 535 | ||
543 | #define show_temp1_reg(reg) \ | 536 | #define show_temp1_reg(reg) \ |
544 | static ssize_t \ | 537 | static ssize_t \ |
@@ -561,27 +554,24 @@ store_temp1_##reg(struct device *dev, struct device_attribute *attr, \ | |||
561 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ | 554 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ |
562 | u32 val = simple_strtoul(buf, NULL, 10); \ | 555 | u32 val = simple_strtoul(buf, NULL, 10); \ |
563 | \ | 556 | \ |
564 | down(&data->update_lock); \ | 557 | mutex_lock(&data->update_lock); \ |
565 | data->temp1_##reg = temp1_to_reg(val); \ | 558 | data->temp1_##reg = temp1_to_reg(val); \ |
566 | w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \ | 559 | w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \ |
567 | data->temp1_##reg); \ | 560 | data->temp1_##reg); \ |
568 | up(&data->update_lock); \ | 561 | mutex_unlock(&data->update_lock); \ |
569 | return count; \ | 562 | return count; \ |
570 | } | 563 | } |
571 | store_temp1_reg(OVER, max); | 564 | store_temp1_reg(OVER, max); |
572 | store_temp1_reg(HYST, max_hyst); | 565 | store_temp1_reg(HYST, max_hyst); |
573 | 566 | ||
574 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL); | ||
575 | static DEVICE_ATTR(temp1_max, S_IRUGO| S_IWUSR, | ||
576 | show_temp1_max, store_temp1_max); | ||
577 | static DEVICE_ATTR(temp1_max_hyst, S_IRUGO| S_IWUSR, | ||
578 | show_temp1_max_hyst, store_temp1_max_hyst); | ||
579 | |||
580 | #define show_temp_reg(reg) \ | 567 | #define show_temp_reg(reg) \ |
581 | static ssize_t \ | 568 | static ssize_t \ |
582 | show_##reg (struct device *dev, char *buf, int nr) \ | 569 | show_##reg(struct device *dev, struct device_attribute *attr, \ |
570 | char *buf) \ | ||
583 | { \ | 571 | { \ |
584 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ | 572 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ |
573 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ | ||
574 | int nr = sensor_attr->index; \ | ||
585 | return sprintf(buf, "%d\n", \ | 575 | return sprintf(buf, "%d\n", \ |
586 | LM75_TEMP_FROM_REG(data->reg[nr])); \ | 576 | LM75_TEMP_FROM_REG(data->reg[nr])); \ |
587 | } | 577 | } |
@@ -591,55 +581,42 @@ show_temp_reg(temp_max_hyst); | |||
591 | 581 | ||
592 | #define store_temp_reg(REG, reg) \ | 582 | #define store_temp_reg(REG, reg) \ |
593 | static ssize_t \ | 583 | static ssize_t \ |
594 | store_##reg (struct device *dev, const char *buf, size_t count, int nr) \ | 584 | store_##reg(struct device *dev, struct device_attribute *attr, \ |
585 | const char *buf, size_t count) \ | ||
595 | { \ | 586 | { \ |
596 | struct i2c_client *client = to_i2c_client(dev); \ | 587 | struct i2c_client *client = to_i2c_client(dev); \ |
597 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ | 588 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ |
589 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ | ||
590 | int nr = sensor_attr->index; \ | ||
598 | u32 val = simple_strtoul(buf, NULL, 10); \ | 591 | u32 val = simple_strtoul(buf, NULL, 10); \ |
599 | \ | 592 | \ |
600 | down(&data->update_lock); \ | 593 | mutex_lock(&data->update_lock); \ |
601 | data->reg[nr] = LM75_TEMP_TO_REG(val); \ | 594 | data->reg[nr] = LM75_TEMP_TO_REG(val); \ |
602 | w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \ | 595 | w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \ |
603 | data->reg[nr]); \ | 596 | data->reg[nr]); \ |
604 | up(&data->update_lock); \ | 597 | mutex_unlock(&data->update_lock); \ |
605 | return count; \ | 598 | return count; \ |
606 | } | 599 | } |
607 | store_temp_reg(OVER, temp_max); | 600 | store_temp_reg(OVER, temp_max); |
608 | store_temp_reg(HYST, temp_max_hyst); | 601 | store_temp_reg(HYST, temp_max_hyst); |
609 | 602 | ||
610 | #define sysfs_temp_offset(offset) \ | 603 | static struct sensor_device_attribute sda_temp[] = { |
611 | static ssize_t \ | 604 | SENSOR_ATTR(temp1_input, S_IRUGO, show_temp1, NULL, 0), |
612 | show_reg_temp##offset (struct device *dev, struct device_attribute *attr, \ | 605 | SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 0), |
613 | char *buf) \ | 606 | SENSOR_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 1), |
614 | { \ | 607 | SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp1_max, |
615 | return show_temp(dev, buf, offset - 2); \ | 608 | store_temp1_max, 0), |
616 | } \ | 609 | SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, show_temp_max, |
617 | static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ | 610 | store_temp_max, 0), |
618 | show_reg_temp##offset, NULL); | 611 | SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, show_temp_max, |
619 | 612 | store_temp_max, 1), | |
620 | #define sysfs_temp_reg_offset(reg, offset) \ | 613 | SENSOR_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1_max_hyst, |
621 | static ssize_t \ | 614 | store_temp1_max_hyst, 0), |
622 | show_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ | 615 | SENSOR_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst, |
623 | char *buf) \ | 616 | store_temp_max_hyst, 0), |
624 | { \ | 617 | SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst, |
625 | return show_temp_##reg(dev, buf, offset - 2); \ | 618 | store_temp_max_hyst, 1), |
626 | } \ | 619 | }; |
627 | static ssize_t \ | ||
628 | store_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ | ||
629 | const char *buf, size_t count) \ | ||
630 | { \ | ||
631 | return store_temp_##reg(dev, buf, count, offset - 2); \ | ||
632 | } \ | ||
633 | static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \ | ||
634 | show_reg_temp##offset##_##reg, \ | ||
635 | store_reg_temp##offset##_##reg); | ||
636 | |||
637 | sysfs_temp_offset(2); | ||
638 | sysfs_temp_reg_offset(max, 2); | ||
639 | sysfs_temp_reg_offset(max_hyst, 2); | ||
640 | sysfs_temp_offset(3); | ||
641 | sysfs_temp_reg_offset(max, 3); | ||
642 | sysfs_temp_reg_offset(max_hyst, 3); | ||
643 | 620 | ||
644 | /* | 621 | /* |
645 | * Driver and client management | 622 | * Driver and client management |
@@ -673,6 +650,7 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) | |||
673 | { | 650 | { |
674 | struct i2c_client *client; | 651 | struct i2c_client *client; |
675 | struct w83627ehf_data *data; | 652 | struct w83627ehf_data *data; |
653 | struct device *dev; | ||
676 | int i, err = 0; | 654 | int i, err = 0; |
677 | 655 | ||
678 | if (!request_region(address + REGION_OFFSET, REGION_LENGTH, | 656 | if (!request_region(address + REGION_OFFSET, REGION_LENGTH, |
@@ -689,14 +667,15 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) | |||
689 | client = &data->client; | 667 | client = &data->client; |
690 | i2c_set_clientdata(client, data); | 668 | i2c_set_clientdata(client, data); |
691 | client->addr = address; | 669 | client->addr = address; |
692 | init_MUTEX(&data->lock); | 670 | mutex_init(&data->lock); |
693 | client->adapter = adapter; | 671 | client->adapter = adapter; |
694 | client->driver = &w83627ehf_driver; | 672 | client->driver = &w83627ehf_driver; |
695 | client->flags = 0; | 673 | client->flags = 0; |
674 | dev = &client->dev; | ||
696 | 675 | ||
697 | strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE); | 676 | strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE); |
698 | data->valid = 0; | 677 | data->valid = 0; |
699 | init_MUTEX(&data->update_lock); | 678 | mutex_init(&data->update_lock); |
700 | 679 | ||
701 | /* Tell the i2c layer a new client has arrived */ | 680 | /* Tell the i2c layer a new client has arrived */ |
702 | if ((err = i2c_attach_client(client))) | 681 | if ((err = i2c_attach_client(client))) |
@@ -720,42 +699,18 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) | |||
720 | data->has_fan |= (1 << 4); | 699 | data->has_fan |= (1 << 4); |
721 | 700 | ||
722 | /* Register sysfs hooks */ | 701 | /* Register sysfs hooks */ |
723 | data->class_dev = hwmon_device_register(&client->dev); | 702 | data->class_dev = hwmon_device_register(dev); |
724 | if (IS_ERR(data->class_dev)) { | 703 | if (IS_ERR(data->class_dev)) { |
725 | err = PTR_ERR(data->class_dev); | 704 | err = PTR_ERR(data->class_dev); |
726 | goto exit_detach; | 705 | goto exit_detach; |
727 | } | 706 | } |
728 | 707 | ||
729 | device_create_file(&client->dev, &dev_attr_fan1_input); | 708 | for (i = 0; i < 5; i++) { |
730 | device_create_file(&client->dev, &dev_attr_fan1_min); | 709 | if (data->has_fan & (1 << i)) |
731 | device_create_file(&client->dev, &dev_attr_fan1_div); | 710 | device_create_file_fan(dev, i); |
732 | device_create_file(&client->dev, &dev_attr_fan2_input); | ||
733 | device_create_file(&client->dev, &dev_attr_fan2_min); | ||
734 | device_create_file(&client->dev, &dev_attr_fan2_div); | ||
735 | device_create_file(&client->dev, &dev_attr_fan3_input); | ||
736 | device_create_file(&client->dev, &dev_attr_fan3_min); | ||
737 | device_create_file(&client->dev, &dev_attr_fan3_div); | ||
738 | |||
739 | if (data->has_fan & (1 << 3)) { | ||
740 | device_create_file(&client->dev, &dev_attr_fan4_input); | ||
741 | device_create_file(&client->dev, &dev_attr_fan4_min); | ||
742 | device_create_file(&client->dev, &dev_attr_fan4_div); | ||
743 | } | ||
744 | if (data->has_fan & (1 << 4)) { | ||
745 | device_create_file(&client->dev, &dev_attr_fan5_input); | ||
746 | device_create_file(&client->dev, &dev_attr_fan5_min); | ||
747 | device_create_file(&client->dev, &dev_attr_fan5_div); | ||
748 | } | 711 | } |
749 | 712 | for (i = 0; i < ARRAY_SIZE(sda_temp); i++) | |
750 | device_create_file(&client->dev, &dev_attr_temp1_input); | 713 | device_create_file(dev, &sda_temp[i].dev_attr); |
751 | device_create_file(&client->dev, &dev_attr_temp1_max); | ||
752 | device_create_file(&client->dev, &dev_attr_temp1_max_hyst); | ||
753 | device_create_file(&client->dev, &dev_attr_temp2_input); | ||
754 | device_create_file(&client->dev, &dev_attr_temp2_max); | ||
755 | device_create_file(&client->dev, &dev_attr_temp2_max_hyst); | ||
756 | device_create_file(&client->dev, &dev_attr_temp3_input); | ||
757 | device_create_file(&client->dev, &dev_attr_temp3_max); | ||
758 | device_create_file(&client->dev, &dev_attr_temp3_max_hyst); | ||
759 | 714 | ||
760 | return 0; | 715 | return 0; |
761 | 716 | ||
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 7ea441d4da63..71fb7f1af8f5 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c | |||
@@ -28,6 +28,7 @@ | |||
28 | w83627hf 9 3 2 3 0x20 0x5ca3 no yes(LPC) | 28 | w83627hf 9 3 2 3 0x20 0x5ca3 no yes(LPC) |
29 | w83627thf 7 3 3 3 0x90 0x5ca3 no yes(LPC) | 29 | w83627thf 7 3 3 3 0x90 0x5ca3 no yes(LPC) |
30 | w83637hf 7 3 3 3 0x80 0x5ca3 no yes(LPC) | 30 | w83637hf 7 3 3 3 0x80 0x5ca3 no yes(LPC) |
31 | w83687thf 7 3 3 3 0x90 0x5ca3 no yes(LPC) | ||
31 | w83697hf 8 2 2 2 0x60 0x5ca3 no yes(LPC) | 32 | w83697hf 8 2 2 2 0x60 0x5ca3 no yes(LPC) |
32 | 33 | ||
33 | For other winbond chips, and for i2c support in the above chips, | 34 | For other winbond chips, and for i2c support in the above chips, |
@@ -46,6 +47,7 @@ | |||
46 | #include <linux/hwmon.h> | 47 | #include <linux/hwmon.h> |
47 | #include <linux/hwmon-vid.h> | 48 | #include <linux/hwmon-vid.h> |
48 | #include <linux/err.h> | 49 | #include <linux/err.h> |
50 | #include <linux/mutex.h> | ||
49 | #include <asm/io.h> | 51 | #include <asm/io.h> |
50 | #include "lm75.h" | 52 | #include "lm75.h" |
51 | 53 | ||
@@ -62,7 +64,7 @@ MODULE_PARM_DESC(force_i2c, | |||
62 | static unsigned short address; | 64 | static unsigned short address; |
63 | 65 | ||
64 | /* Insmod parameters */ | 66 | /* Insmod parameters */ |
65 | enum chips { any_chip, w83627hf, w83627thf, w83697hf, w83637hf }; | 67 | enum chips { any_chip, w83627hf, w83627thf, w83697hf, w83637hf, w83687thf }; |
66 | 68 | ||
67 | static int reset; | 69 | static int reset; |
68 | module_param(reset, bool, 0); | 70 | module_param(reset, bool, 0); |
@@ -100,6 +102,10 @@ static int VAL; /* The value to read/write */ | |||
100 | #define W83627THF_GPIO5_IOSR 0xf3 /* w83627thf only */ | 102 | #define W83627THF_GPIO5_IOSR 0xf3 /* w83627thf only */ |
101 | #define W83627THF_GPIO5_DR 0xf4 /* w83627thf only */ | 103 | #define W83627THF_GPIO5_DR 0xf4 /* w83627thf only */ |
102 | 104 | ||
105 | #define W83687THF_VID_EN 0x29 /* w83687thf only */ | ||
106 | #define W83687THF_VID_CFG 0xF0 /* w83687thf only */ | ||
107 | #define W83687THF_VID_DATA 0xF1 /* w83687thf only */ | ||
108 | |||
103 | static inline void | 109 | static inline void |
104 | superio_outb(int reg, int val) | 110 | superio_outb(int reg, int val) |
105 | { | 111 | { |
@@ -138,6 +144,7 @@ superio_exit(void) | |||
138 | #define W627THF_DEVID 0x82 | 144 | #define W627THF_DEVID 0x82 |
139 | #define W697_DEVID 0x60 | 145 | #define W697_DEVID 0x60 |
140 | #define W637_DEVID 0x70 | 146 | #define W637_DEVID 0x70 |
147 | #define W687THF_DEVID 0x85 | ||
141 | #define WINB_ACT_REG 0x30 | 148 | #define WINB_ACT_REG 0x30 |
142 | #define WINB_BASE_REG 0x60 | 149 | #define WINB_BASE_REG 0x60 |
143 | /* Constants specified below */ | 150 | /* Constants specified below */ |
@@ -201,11 +208,11 @@ superio_exit(void) | |||
201 | #define W83627HF_REG_PWM1 0x5A | 208 | #define W83627HF_REG_PWM1 0x5A |
202 | #define W83627HF_REG_PWM2 0x5B | 209 | #define W83627HF_REG_PWM2 0x5B |
203 | 210 | ||
204 | #define W83627THF_REG_PWM1 0x01 /* 697HF and 637HF too */ | 211 | #define W83627THF_REG_PWM1 0x01 /* 697HF/637HF/687THF too */ |
205 | #define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */ | 212 | #define W83627THF_REG_PWM2 0x03 /* 697HF/637HF/687THF too */ |
206 | #define W83627THF_REG_PWM3 0x11 /* 637HF too */ | 213 | #define W83627THF_REG_PWM3 0x11 /* 637HF/687THF too */ |
207 | 214 | ||
208 | #define W83627THF_REG_VRM_OVT_CFG 0x18 /* 637HF too */ | 215 | #define W83627THF_REG_VRM_OVT_CFG 0x18 /* 637HF/687THF too */ |
209 | 216 | ||
210 | static const u8 regpwm_627hf[] = { W83627HF_REG_PWM1, W83627HF_REG_PWM2 }; | 217 | static const u8 regpwm_627hf[] = { W83627HF_REG_PWM1, W83627HF_REG_PWM2 }; |
211 | static const u8 regpwm[] = { W83627THF_REG_PWM1, W83627THF_REG_PWM2, | 218 | static const u8 regpwm[] = { W83627THF_REG_PWM1, W83627THF_REG_PWM2, |
@@ -285,10 +292,10 @@ static inline u8 DIV_TO_REG(long val) | |||
285 | struct w83627hf_data { | 292 | struct w83627hf_data { |
286 | struct i2c_client client; | 293 | struct i2c_client client; |
287 | struct class_device *class_dev; | 294 | struct class_device *class_dev; |
288 | struct semaphore lock; | 295 | struct mutex lock; |
289 | enum chips type; | 296 | enum chips type; |
290 | 297 | ||
291 | struct semaphore update_lock; | 298 | struct mutex update_lock; |
292 | char valid; /* !=0 if following fields are valid */ | 299 | char valid; /* !=0 if following fields are valid */ |
293 | unsigned long last_updated; /* In jiffies */ | 300 | unsigned long last_updated; /* In jiffies */ |
294 | 301 | ||
@@ -318,16 +325,15 @@ struct w83627hf_data { | |||
318 | Default = 3435. | 325 | Default = 3435. |
319 | Other Betas unimplemented */ | 326 | Other Betas unimplemented */ |
320 | u8 vrm; | 327 | u8 vrm; |
321 | u8 vrm_ovt; /* Register value, 627thf & 637hf only */ | 328 | u8 vrm_ovt; /* Register value, 627THF/637HF/687THF only */ |
322 | }; | 329 | }; |
323 | 330 | ||
324 | 331 | ||
325 | static int w83627hf_detect(struct i2c_adapter *adapter); | 332 | static int w83627hf_detect(struct i2c_adapter *adapter); |
326 | static int w83627hf_detach_client(struct i2c_client *client); | 333 | static int w83627hf_detach_client(struct i2c_client *client); |
327 | 334 | ||
328 | static int w83627hf_read_value(struct i2c_client *client, u16 register); | 335 | static int w83627hf_read_value(struct i2c_client *client, u16 reg); |
329 | static int w83627hf_write_value(struct i2c_client *client, u16 register, | 336 | static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value); |
330 | u16 value); | ||
331 | static struct w83627hf_data *w83627hf_update_device(struct device *dev); | 337 | static struct w83627hf_data *w83627hf_update_device(struct device *dev); |
332 | static void w83627hf_init_client(struct i2c_client *client); | 338 | static void w83627hf_init_client(struct i2c_client *client); |
333 | 339 | ||
@@ -360,12 +366,12 @@ store_in_##reg (struct device *dev, const char *buf, size_t count, int nr) \ | |||
360 | \ | 366 | \ |
361 | val = simple_strtoul(buf, NULL, 10); \ | 367 | val = simple_strtoul(buf, NULL, 10); \ |
362 | \ | 368 | \ |
363 | down(&data->update_lock); \ | 369 | mutex_lock(&data->update_lock); \ |
364 | data->in_##reg[nr] = IN_TO_REG(val); \ | 370 | data->in_##reg[nr] = IN_TO_REG(val); \ |
365 | w83627hf_write_value(client, W83781D_REG_IN_##REG(nr), \ | 371 | w83627hf_write_value(client, W83781D_REG_IN_##REG(nr), \ |
366 | data->in_##reg[nr]); \ | 372 | data->in_##reg[nr]); \ |
367 | \ | 373 | \ |
368 | up(&data->update_lock); \ | 374 | mutex_unlock(&data->update_lock); \ |
369 | return count; \ | 375 | return count; \ |
370 | } | 376 | } |
371 | store_in_reg(MIN, min) | 377 | store_in_reg(MIN, min) |
@@ -413,7 +419,8 @@ static ssize_t show_in_0(struct w83627hf_data *data, char *buf, u8 reg) | |||
413 | long in0; | 419 | long in0; |
414 | 420 | ||
415 | if ((data->vrm_ovt & 0x01) && | 421 | if ((data->vrm_ovt & 0x01) && |
416 | (w83627thf == data->type || w83637hf == data->type)) | 422 | (w83627thf == data->type || w83637hf == data->type |
423 | || w83687thf == data->type)) | ||
417 | 424 | ||
418 | /* use VRM9 calculation */ | 425 | /* use VRM9 calculation */ |
419 | in0 = (long)((reg * 488 + 70000 + 50) / 100); | 426 | in0 = (long)((reg * 488 + 70000 + 50) / 100); |
@@ -451,10 +458,11 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a | |||
451 | 458 | ||
452 | val = simple_strtoul(buf, NULL, 10); | 459 | val = simple_strtoul(buf, NULL, 10); |
453 | 460 | ||
454 | down(&data->update_lock); | 461 | mutex_lock(&data->update_lock); |
455 | 462 | ||
456 | if ((data->vrm_ovt & 0x01) && | 463 | if ((data->vrm_ovt & 0x01) && |
457 | (w83627thf == data->type || w83637hf == data->type)) | 464 | (w83627thf == data->type || w83637hf == data->type |
465 | || w83687thf == data->type)) | ||
458 | 466 | ||
459 | /* use VRM9 calculation */ | 467 | /* use VRM9 calculation */ |
460 | data->in_min[0] = | 468 | data->in_min[0] = |
@@ -465,7 +473,7 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a | |||
465 | data->in_min[0] = IN_TO_REG(val); | 473 | data->in_min[0] = IN_TO_REG(val); |
466 | 474 | ||
467 | w83627hf_write_value(client, W83781D_REG_IN_MIN(0), data->in_min[0]); | 475 | w83627hf_write_value(client, W83781D_REG_IN_MIN(0), data->in_min[0]); |
468 | up(&data->update_lock); | 476 | mutex_unlock(&data->update_lock); |
469 | return count; | 477 | return count; |
470 | } | 478 | } |
471 | 479 | ||
@@ -478,10 +486,11 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a | |||
478 | 486 | ||
479 | val = simple_strtoul(buf, NULL, 10); | 487 | val = simple_strtoul(buf, NULL, 10); |
480 | 488 | ||
481 | down(&data->update_lock); | 489 | mutex_lock(&data->update_lock); |
482 | 490 | ||
483 | if ((data->vrm_ovt & 0x01) && | 491 | if ((data->vrm_ovt & 0x01) && |
484 | (w83627thf == data->type || w83637hf == data->type)) | 492 | (w83627thf == data->type || w83637hf == data->type |
493 | || w83687thf == data->type)) | ||
485 | 494 | ||
486 | /* use VRM9 calculation */ | 495 | /* use VRM9 calculation */ |
487 | data->in_max[0] = | 496 | data->in_max[0] = |
@@ -492,7 +501,7 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a | |||
492 | data->in_max[0] = IN_TO_REG(val); | 501 | data->in_max[0] = IN_TO_REG(val); |
493 | 502 | ||
494 | w83627hf_write_value(client, W83781D_REG_IN_MAX(0), data->in_max[0]); | 503 | w83627hf_write_value(client, W83781D_REG_IN_MAX(0), data->in_max[0]); |
495 | up(&data->update_lock); | 504 | mutex_unlock(&data->update_lock); |
496 | return count; | 505 | return count; |
497 | } | 506 | } |
498 | 507 | ||
@@ -529,13 +538,13 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
529 | 538 | ||
530 | val = simple_strtoul(buf, NULL, 10); | 539 | val = simple_strtoul(buf, NULL, 10); |
531 | 540 | ||
532 | down(&data->update_lock); | 541 | mutex_lock(&data->update_lock); |
533 | data->fan_min[nr - 1] = | 542 | data->fan_min[nr - 1] = |
534 | FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); | 543 | FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); |
535 | w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr), | 544 | w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr), |
536 | data->fan_min[nr - 1]); | 545 | data->fan_min[nr - 1]); |
537 | 546 | ||
538 | up(&data->update_lock); | 547 | mutex_unlock(&data->update_lock); |
539 | return count; | 548 | return count; |
540 | } | 549 | } |
541 | 550 | ||
@@ -597,7 +606,7 @@ store_temp_##reg (struct device *dev, const char *buf, size_t count, int nr) \ | |||
597 | \ | 606 | \ |
598 | val = simple_strtoul(buf, NULL, 10); \ | 607 | val = simple_strtoul(buf, NULL, 10); \ |
599 | \ | 608 | \ |
600 | down(&data->update_lock); \ | 609 | mutex_lock(&data->update_lock); \ |
601 | \ | 610 | \ |
602 | if (nr >= 2) { /* TEMP2 and TEMP3 */ \ | 611 | if (nr >= 2) { /* TEMP2 and TEMP3 */ \ |
603 | data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \ | 612 | data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \ |
@@ -609,7 +618,7 @@ store_temp_##reg (struct device *dev, const char *buf, size_t count, int nr) \ | |||
609 | data->temp_##reg); \ | 618 | data->temp_##reg); \ |
610 | } \ | 619 | } \ |
611 | \ | 620 | \ |
612 | up(&data->update_lock); \ | 621 | mutex_unlock(&data->update_lock); \ |
613 | return count; \ | 622 | return count; \ |
614 | } | 623 | } |
615 | store_temp_reg(OVER, max); | 624 | store_temp_reg(OVER, max); |
@@ -718,7 +727,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count, | |||
718 | 727 | ||
719 | val = simple_strtoul(buf, NULL, 10); | 728 | val = simple_strtoul(buf, NULL, 10); |
720 | 729 | ||
721 | down(&data->update_lock); | 730 | mutex_lock(&data->update_lock); |
722 | 731 | ||
723 | if (update_mask == BEEP_MASK) { /* We are storing beep_mask */ | 732 | if (update_mask == BEEP_MASK) { /* We are storing beep_mask */ |
724 | data->beep_mask = BEEP_MASK_TO_REG(val); | 733 | data->beep_mask = BEEP_MASK_TO_REG(val); |
@@ -736,7 +745,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count, | |||
736 | w83627hf_write_value(client, W83781D_REG_BEEP_INTS2, | 745 | w83627hf_write_value(client, W83781D_REG_BEEP_INTS2, |
737 | val2 | data->beep_enable << 7); | 746 | val2 | data->beep_enable << 7); |
738 | 747 | ||
739 | up(&data->update_lock); | 748 | mutex_unlock(&data->update_lock); |
740 | return count; | 749 | return count; |
741 | } | 750 | } |
742 | 751 | ||
@@ -783,7 +792,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
783 | u8 reg; | 792 | u8 reg; |
784 | unsigned long val = simple_strtoul(buf, NULL, 10); | 793 | unsigned long val = simple_strtoul(buf, NULL, 10); |
785 | 794 | ||
786 | down(&data->update_lock); | 795 | mutex_lock(&data->update_lock); |
787 | 796 | ||
788 | /* Save fan_min */ | 797 | /* Save fan_min */ |
789 | min = FAN_FROM_REG(data->fan_min[nr], | 798 | min = FAN_FROM_REG(data->fan_min[nr], |
@@ -805,7 +814,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
805 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 814 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
806 | w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); | 815 | w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); |
807 | 816 | ||
808 | up(&data->update_lock); | 817 | mutex_unlock(&data->update_lock); |
809 | return count; | 818 | return count; |
810 | } | 819 | } |
811 | 820 | ||
@@ -848,7 +857,7 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
848 | 857 | ||
849 | val = simple_strtoul(buf, NULL, 10); | 858 | val = simple_strtoul(buf, NULL, 10); |
850 | 859 | ||
851 | down(&data->update_lock); | 860 | mutex_lock(&data->update_lock); |
852 | 861 | ||
853 | if (data->type == w83627thf) { | 862 | if (data->type == w83627thf) { |
854 | /* bits 0-3 are reserved in 627THF */ | 863 | /* bits 0-3 are reserved in 627THF */ |
@@ -865,7 +874,7 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
865 | data->pwm[nr - 1]); | 874 | data->pwm[nr - 1]); |
866 | } | 875 | } |
867 | 876 | ||
868 | up(&data->update_lock); | 877 | mutex_unlock(&data->update_lock); |
869 | return count; | 878 | return count; |
870 | } | 879 | } |
871 | 880 | ||
@@ -907,7 +916,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
907 | 916 | ||
908 | val = simple_strtoul(buf, NULL, 10); | 917 | val = simple_strtoul(buf, NULL, 10); |
909 | 918 | ||
910 | down(&data->update_lock); | 919 | mutex_lock(&data->update_lock); |
911 | 920 | ||
912 | switch (val) { | 921 | switch (val) { |
913 | case 1: /* PII/Celeron diode */ | 922 | case 1: /* PII/Celeron diode */ |
@@ -941,7 +950,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
941 | break; | 950 | break; |
942 | } | 951 | } |
943 | 952 | ||
944 | up(&data->update_lock); | 953 | mutex_unlock(&data->update_lock); |
945 | return count; | 954 | return count; |
946 | } | 955 | } |
947 | 956 | ||
@@ -980,7 +989,8 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr) | |||
980 | if(val != W627_DEVID && | 989 | if(val != W627_DEVID && |
981 | val != W627THF_DEVID && | 990 | val != W627THF_DEVID && |
982 | val != W697_DEVID && | 991 | val != W697_DEVID && |
983 | val != W637_DEVID) { | 992 | val != W637_DEVID && |
993 | val != W687THF_DEVID) { | ||
984 | superio_exit(); | 994 | superio_exit(); |
985 | return -ENODEV; | 995 | return -ENODEV; |
986 | } | 996 | } |
@@ -1034,6 +1044,8 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1034 | kind = w83627thf; | 1044 | kind = w83627thf; |
1035 | else if(val == W637_DEVID) | 1045 | else if(val == W637_DEVID) |
1036 | kind = w83637hf; | 1046 | kind = w83637hf; |
1047 | else if (val == W687THF_DEVID) | ||
1048 | kind = w83687thf; | ||
1037 | else { | 1049 | else { |
1038 | dev_info(&adapter->dev, | 1050 | dev_info(&adapter->dev, |
1039 | "Unsupported chip (dev_id=0x%02X).\n", val); | 1051 | "Unsupported chip (dev_id=0x%02X).\n", val); |
@@ -1057,7 +1069,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1057 | new_client = &data->client; | 1069 | new_client = &data->client; |
1058 | i2c_set_clientdata(new_client, data); | 1070 | i2c_set_clientdata(new_client, data); |
1059 | new_client->addr = address; | 1071 | new_client->addr = address; |
1060 | init_MUTEX(&data->lock); | 1072 | mutex_init(&data->lock); |
1061 | new_client->adapter = adapter; | 1073 | new_client->adapter = adapter; |
1062 | new_client->driver = &w83627hf_driver; | 1074 | new_client->driver = &w83627hf_driver; |
1063 | new_client->flags = 0; | 1075 | new_client->flags = 0; |
@@ -1071,13 +1083,15 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1071 | client_name = "w83697hf"; | 1083 | client_name = "w83697hf"; |
1072 | } else if (kind == w83637hf) { | 1084 | } else if (kind == w83637hf) { |
1073 | client_name = "w83637hf"; | 1085 | client_name = "w83637hf"; |
1086 | } else if (kind == w83687thf) { | ||
1087 | client_name = "w83687thf"; | ||
1074 | } | 1088 | } |
1075 | 1089 | ||
1076 | /* Fill in the remaining client fields and put into the global list */ | 1090 | /* Fill in the remaining client fields and put into the global list */ |
1077 | strlcpy(new_client->name, client_name, I2C_NAME_SIZE); | 1091 | strlcpy(new_client->name, client_name, I2C_NAME_SIZE); |
1078 | data->type = kind; | 1092 | data->type = kind; |
1079 | data->valid = 0; | 1093 | data->valid = 0; |
1080 | init_MUTEX(&data->update_lock); | 1094 | mutex_init(&data->update_lock); |
1081 | 1095 | ||
1082 | /* Tell the I2C layer a new client has arrived */ | 1096 | /* Tell the I2C layer a new client has arrived */ |
1083 | if ((err = i2c_attach_client(new_client))) | 1097 | if ((err = i2c_attach_client(new_client))) |
@@ -1106,7 +1120,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1106 | device_create_file_in(new_client, 2); | 1120 | device_create_file_in(new_client, 2); |
1107 | device_create_file_in(new_client, 3); | 1121 | device_create_file_in(new_client, 3); |
1108 | device_create_file_in(new_client, 4); | 1122 | device_create_file_in(new_client, 4); |
1109 | if (kind != w83627thf && kind != w83637hf) { | 1123 | if (kind == w83627hf || kind == w83697hf) { |
1110 | device_create_file_in(new_client, 5); | 1124 | device_create_file_in(new_client, 5); |
1111 | device_create_file_in(new_client, 6); | 1125 | device_create_file_in(new_client, 6); |
1112 | } | 1126 | } |
@@ -1139,7 +1153,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1139 | 1153 | ||
1140 | device_create_file_pwm(new_client, 1); | 1154 | device_create_file_pwm(new_client, 1); |
1141 | device_create_file_pwm(new_client, 2); | 1155 | device_create_file_pwm(new_client, 2); |
1142 | if (kind == w83627thf || kind == w83637hf) | 1156 | if (kind == w83627thf || kind == w83637hf || kind == w83687thf) |
1143 | device_create_file_pwm(new_client, 3); | 1157 | device_create_file_pwm(new_client, 3); |
1144 | 1158 | ||
1145 | device_create_file_sensor(new_client, 1); | 1159 | device_create_file_sensor(new_client, 1); |
@@ -1187,7 +1201,7 @@ static int w83627hf_read_value(struct i2c_client *client, u16 reg) | |||
1187 | struct w83627hf_data *data = i2c_get_clientdata(client); | 1201 | struct w83627hf_data *data = i2c_get_clientdata(client); |
1188 | int res, word_sized; | 1202 | int res, word_sized; |
1189 | 1203 | ||
1190 | down(&data->lock); | 1204 | mutex_lock(&data->lock); |
1191 | word_sized = (((reg & 0xff00) == 0x100) | 1205 | word_sized = (((reg & 0xff00) == 0x100) |
1192 | || ((reg & 0xff00) == 0x200)) | 1206 | || ((reg & 0xff00) == 0x200)) |
1193 | && (((reg & 0x00ff) == 0x50) | 1207 | && (((reg & 0x00ff) == 0x50) |
@@ -1213,7 +1227,7 @@ static int w83627hf_read_value(struct i2c_client *client, u16 reg) | |||
1213 | client->addr + W83781D_ADDR_REG_OFFSET); | 1227 | client->addr + W83781D_ADDR_REG_OFFSET); |
1214 | outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); | 1228 | outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); |
1215 | } | 1229 | } |
1216 | up(&data->lock); | 1230 | mutex_unlock(&data->lock); |
1217 | return res; | 1231 | return res; |
1218 | } | 1232 | } |
1219 | 1233 | ||
@@ -1247,12 +1261,39 @@ exit: | |||
1247 | return res; | 1261 | return res; |
1248 | } | 1262 | } |
1249 | 1263 | ||
1264 | static int w83687thf_read_vid(struct i2c_client *client) | ||
1265 | { | ||
1266 | int res = 0xff; | ||
1267 | |||
1268 | superio_enter(); | ||
1269 | superio_select(W83627HF_LD_HWM); | ||
1270 | |||
1271 | /* Make sure these GPIO pins are enabled */ | ||
1272 | if (!(superio_inb(W83687THF_VID_EN) & (1 << 2))) { | ||
1273 | dev_dbg(&client->dev, "VID disabled, no VID function\n"); | ||
1274 | goto exit; | ||
1275 | } | ||
1276 | |||
1277 | /* Make sure the pins are configured for input */ | ||
1278 | if (!(superio_inb(W83687THF_VID_CFG) & (1 << 4))) { | ||
1279 | dev_dbg(&client->dev, "VID configured as output, " | ||
1280 | "no VID function\n"); | ||
1281 | goto exit; | ||
1282 | } | ||
1283 | |||
1284 | res = superio_inb(W83687THF_VID_DATA) & 0x3f; | ||
1285 | |||
1286 | exit: | ||
1287 | superio_exit(); | ||
1288 | return res; | ||
1289 | } | ||
1290 | |||
1250 | static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value) | 1291 | static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value) |
1251 | { | 1292 | { |
1252 | struct w83627hf_data *data = i2c_get_clientdata(client); | 1293 | struct w83627hf_data *data = i2c_get_clientdata(client); |
1253 | int word_sized; | 1294 | int word_sized; |
1254 | 1295 | ||
1255 | down(&data->lock); | 1296 | mutex_lock(&data->lock); |
1256 | word_sized = (((reg & 0xff00) == 0x100) | 1297 | word_sized = (((reg & 0xff00) == 0x100) |
1257 | || ((reg & 0xff00) == 0x200)) | 1298 | || ((reg & 0xff00) == 0x200)) |
1258 | && (((reg & 0x00ff) == 0x53) | 1299 | && (((reg & 0x00ff) == 0x53) |
@@ -1277,7 +1318,7 @@ static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
1277 | client->addr + W83781D_ADDR_REG_OFFSET); | 1318 | client->addr + W83781D_ADDR_REG_OFFSET); |
1278 | outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); | 1319 | outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); |
1279 | } | 1320 | } |
1280 | up(&data->lock); | 1321 | mutex_unlock(&data->lock); |
1281 | return 0; | 1322 | return 0; |
1282 | } | 1323 | } |
1283 | 1324 | ||
@@ -1324,10 +1365,13 @@ static void w83627hf_init_client(struct i2c_client *client) | |||
1324 | data->vid = (lo & 0x0f) | ((hi & 0x01) << 4); | 1365 | data->vid = (lo & 0x0f) | ((hi & 0x01) << 4); |
1325 | } else if (w83627thf == data->type) { | 1366 | } else if (w83627thf == data->type) { |
1326 | data->vid = w83627thf_read_gpio5(client); | 1367 | data->vid = w83627thf_read_gpio5(client); |
1368 | } else if (w83687thf == data->type) { | ||
1369 | data->vid = w83687thf_read_vid(client); | ||
1327 | } | 1370 | } |
1328 | 1371 | ||
1329 | /* Read VRM & OVT Config only once */ | 1372 | /* Read VRM & OVT Config only once */ |
1330 | if (w83627thf == data->type || w83637hf == data->type) { | 1373 | if (w83627thf == data->type || w83637hf == data->type |
1374 | || w83687thf == data->type) { | ||
1331 | data->vrm_ovt = | 1375 | data->vrm_ovt = |
1332 | w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG); | 1376 | w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG); |
1333 | } | 1377 | } |
@@ -1387,14 +1431,14 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev) | |||
1387 | struct w83627hf_data *data = i2c_get_clientdata(client); | 1431 | struct w83627hf_data *data = i2c_get_clientdata(client); |
1388 | int i; | 1432 | int i; |
1389 | 1433 | ||
1390 | down(&data->update_lock); | 1434 | mutex_lock(&data->update_lock); |
1391 | 1435 | ||
1392 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 1436 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
1393 | || !data->valid) { | 1437 | || !data->valid) { |
1394 | for (i = 0; i <= 8; i++) { | 1438 | for (i = 0; i <= 8; i++) { |
1395 | /* skip missing sensors */ | 1439 | /* skip missing sensors */ |
1396 | if (((data->type == w83697hf) && (i == 1)) || | 1440 | if (((data->type == w83697hf) && (i == 1)) || |
1397 | ((data->type == w83627thf || data->type == w83637hf) | 1441 | ((data->type != w83627hf && data->type != w83697hf) |
1398 | && (i == 5 || i == 6))) | 1442 | && (i == 5 || i == 6))) |
1399 | continue; | 1443 | continue; |
1400 | data->in[i] = | 1444 | data->in[i] = |
@@ -1470,7 +1514,7 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev) | |||
1470 | data->valid = 1; | 1514 | data->valid = 1; |
1471 | } | 1515 | } |
1472 | 1516 | ||
1473 | up(&data->update_lock); | 1517 | mutex_unlock(&data->update_lock); |
1474 | 1518 | ||
1475 | return data; | 1519 | return data; |
1476 | } | 1520 | } |
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index 64c1f8af5bb2..e4c700356c44 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/hwmon.h> | 42 | #include <linux/hwmon.h> |
43 | #include <linux/hwmon-vid.h> | 43 | #include <linux/hwmon-vid.h> |
44 | #include <linux/err.h> | 44 | #include <linux/err.h> |
45 | #include <linux/mutex.h> | ||
45 | #include <asm/io.h> | 46 | #include <asm/io.h> |
46 | #include "lm75.h" | 47 | #include "lm75.h" |
47 | 48 | ||
@@ -56,6 +57,10 @@ I2C_CLIENT_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f); | |||
56 | I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " | 57 | I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " |
57 | "{bus, clientaddr, subclientaddr1, subclientaddr2}"); | 58 | "{bus, clientaddr, subclientaddr1, subclientaddr2}"); |
58 | 59 | ||
60 | static int reset; | ||
61 | module_param(reset, bool, 0); | ||
62 | MODULE_PARM_DESC(reset, "Set to one to reset chip on load"); | ||
63 | |||
59 | static int init = 1; | 64 | static int init = 1; |
60 | module_param(init, bool, 0); | 65 | module_param(init, bool, 0); |
61 | MODULE_PARM_DESC(init, "Set to zero to bypass chip initialization"); | 66 | MODULE_PARM_DESC(init, "Set to zero to bypass chip initialization"); |
@@ -226,10 +231,10 @@ DIV_TO_REG(long val, enum chips type) | |||
226 | struct w83781d_data { | 231 | struct w83781d_data { |
227 | struct i2c_client client; | 232 | struct i2c_client client; |
228 | struct class_device *class_dev; | 233 | struct class_device *class_dev; |
229 | struct semaphore lock; | 234 | struct mutex lock; |
230 | enum chips type; | 235 | enum chips type; |
231 | 236 | ||
232 | struct semaphore update_lock; | 237 | struct mutex update_lock; |
233 | char valid; /* !=0 if following fields are valid */ | 238 | char valid; /* !=0 if following fields are valid */ |
234 | unsigned long last_updated; /* In jiffies */ | 239 | unsigned long last_updated; /* In jiffies */ |
235 | 240 | ||
@@ -267,9 +272,8 @@ static int w83781d_isa_attach_adapter(struct i2c_adapter *adapter); | |||
267 | static int w83781d_detect(struct i2c_adapter *adapter, int address, int kind); | 272 | static int w83781d_detect(struct i2c_adapter *adapter, int address, int kind); |
268 | static int w83781d_detach_client(struct i2c_client *client); | 273 | static int w83781d_detach_client(struct i2c_client *client); |
269 | 274 | ||
270 | static int w83781d_read_value(struct i2c_client *client, u16 register); | 275 | static int w83781d_read_value(struct i2c_client *client, u16 reg); |
271 | static int w83781d_write_value(struct i2c_client *client, u16 register, | 276 | static int w83781d_write_value(struct i2c_client *client, u16 reg, u16 value); |
272 | u16 value); | ||
273 | static struct w83781d_data *w83781d_update_device(struct device *dev); | 277 | static struct w83781d_data *w83781d_update_device(struct device *dev); |
274 | static void w83781d_init_client(struct i2c_client *client); | 278 | static void w83781d_init_client(struct i2c_client *client); |
275 | 279 | ||
@@ -311,11 +315,11 @@ static ssize_t store_in_##reg (struct device *dev, const char *buf, size_t count | |||
311 | \ | 315 | \ |
312 | val = simple_strtoul(buf, NULL, 10) / 10; \ | 316 | val = simple_strtoul(buf, NULL, 10) / 10; \ |
313 | \ | 317 | \ |
314 | down(&data->update_lock); \ | 318 | mutex_lock(&data->update_lock); \ |
315 | data->in_##reg[nr] = IN_TO_REG(val); \ | 319 | data->in_##reg[nr] = IN_TO_REG(val); \ |
316 | w83781d_write_value(client, W83781D_REG_IN_##REG(nr), data->in_##reg[nr]); \ | 320 | w83781d_write_value(client, W83781D_REG_IN_##REG(nr), data->in_##reg[nr]); \ |
317 | \ | 321 | \ |
318 | up(&data->update_lock); \ | 322 | mutex_unlock(&data->update_lock); \ |
319 | return count; \ | 323 | return count; \ |
320 | } | 324 | } |
321 | store_in_reg(MIN, min); | 325 | store_in_reg(MIN, min); |
@@ -381,13 +385,13 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
381 | 385 | ||
382 | val = simple_strtoul(buf, NULL, 10); | 386 | val = simple_strtoul(buf, NULL, 10); |
383 | 387 | ||
384 | down(&data->update_lock); | 388 | mutex_lock(&data->update_lock); |
385 | data->fan_min[nr - 1] = | 389 | data->fan_min[nr - 1] = |
386 | FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); | 390 | FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); |
387 | w83781d_write_value(client, W83781D_REG_FAN_MIN(nr), | 391 | w83781d_write_value(client, W83781D_REG_FAN_MIN(nr), |
388 | data->fan_min[nr - 1]); | 392 | data->fan_min[nr - 1]); |
389 | 393 | ||
390 | up(&data->update_lock); | 394 | mutex_unlock(&data->update_lock); |
391 | return count; | 395 | return count; |
392 | } | 396 | } |
393 | 397 | ||
@@ -446,7 +450,7 @@ static ssize_t store_temp_##reg (struct device *dev, const char *buf, size_t cou | |||
446 | \ | 450 | \ |
447 | val = simple_strtol(buf, NULL, 10); \ | 451 | val = simple_strtol(buf, NULL, 10); \ |
448 | \ | 452 | \ |
449 | down(&data->update_lock); \ | 453 | mutex_lock(&data->update_lock); \ |
450 | \ | 454 | \ |
451 | if (nr >= 2) { /* TEMP2 and TEMP3 */ \ | 455 | if (nr >= 2) { /* TEMP2 and TEMP3 */ \ |
452 | data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \ | 456 | data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \ |
@@ -458,7 +462,7 @@ static ssize_t store_temp_##reg (struct device *dev, const char *buf, size_t cou | |||
458 | data->temp_##reg); \ | 462 | data->temp_##reg); \ |
459 | } \ | 463 | } \ |
460 | \ | 464 | \ |
461 | up(&data->update_lock); \ | 465 | mutex_unlock(&data->update_lock); \ |
462 | return count; \ | 466 | return count; \ |
463 | } | 467 | } |
464 | store_temp_reg(OVER, max); | 468 | store_temp_reg(OVER, max); |
@@ -571,7 +575,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count, | |||
571 | 575 | ||
572 | val = simple_strtoul(buf, NULL, 10); | 576 | val = simple_strtoul(buf, NULL, 10); |
573 | 577 | ||
574 | down(&data->update_lock); | 578 | mutex_lock(&data->update_lock); |
575 | 579 | ||
576 | if (update_mask == BEEP_MASK) { /* We are storing beep_mask */ | 580 | if (update_mask == BEEP_MASK) { /* We are storing beep_mask */ |
577 | data->beep_mask = BEEP_MASK_TO_REG(val, data->type); | 581 | data->beep_mask = BEEP_MASK_TO_REG(val, data->type); |
@@ -592,7 +596,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count, | |||
592 | w83781d_write_value(client, W83781D_REG_BEEP_INTS2, | 596 | w83781d_write_value(client, W83781D_REG_BEEP_INTS2, |
593 | val2 | data->beep_enable << 7); | 597 | val2 | data->beep_enable << 7); |
594 | 598 | ||
595 | up(&data->update_lock); | 599 | mutex_unlock(&data->update_lock); |
596 | return count; | 600 | return count; |
597 | } | 601 | } |
598 | 602 | ||
@@ -637,7 +641,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
637 | u8 reg; | 641 | u8 reg; |
638 | unsigned long val = simple_strtoul(buf, NULL, 10); | 642 | unsigned long val = simple_strtoul(buf, NULL, 10); |
639 | 643 | ||
640 | down(&data->update_lock); | 644 | mutex_lock(&data->update_lock); |
641 | 645 | ||
642 | /* Save fan_min */ | 646 | /* Save fan_min */ |
643 | min = FAN_FROM_REG(data->fan_min[nr], | 647 | min = FAN_FROM_REG(data->fan_min[nr], |
@@ -662,7 +666,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
662 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 666 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
663 | w83781d_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); | 667 | w83781d_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); |
664 | 668 | ||
665 | up(&data->update_lock); | 669 | mutex_unlock(&data->update_lock); |
666 | return count; | 670 | return count; |
667 | } | 671 | } |
668 | 672 | ||
@@ -709,10 +713,10 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
709 | 713 | ||
710 | val = simple_strtoul(buf, NULL, 10); | 714 | val = simple_strtoul(buf, NULL, 10); |
711 | 715 | ||
712 | down(&data->update_lock); | 716 | mutex_lock(&data->update_lock); |
713 | data->pwm[nr - 1] = PWM_TO_REG(val); | 717 | data->pwm[nr - 1] = PWM_TO_REG(val); |
714 | w83781d_write_value(client, W83781D_REG_PWM(nr), data->pwm[nr - 1]); | 718 | w83781d_write_value(client, W83781D_REG_PWM(nr), data->pwm[nr - 1]); |
715 | up(&data->update_lock); | 719 | mutex_unlock(&data->update_lock); |
716 | return count; | 720 | return count; |
717 | } | 721 | } |
718 | 722 | ||
@@ -725,7 +729,7 @@ store_pwmenable_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
725 | 729 | ||
726 | val = simple_strtoul(buf, NULL, 10); | 730 | val = simple_strtoul(buf, NULL, 10); |
727 | 731 | ||
728 | down(&data->update_lock); | 732 | mutex_lock(&data->update_lock); |
729 | 733 | ||
730 | switch (val) { | 734 | switch (val) { |
731 | case 0: | 735 | case 0: |
@@ -742,11 +746,11 @@ store_pwmenable_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
742 | break; | 746 | break; |
743 | 747 | ||
744 | default: | 748 | default: |
745 | up(&data->update_lock); | 749 | mutex_unlock(&data->update_lock); |
746 | return -EINVAL; | 750 | return -EINVAL; |
747 | } | 751 | } |
748 | 752 | ||
749 | up(&data->update_lock); | 753 | mutex_unlock(&data->update_lock); |
750 | return count; | 754 | return count; |
751 | } | 755 | } |
752 | 756 | ||
@@ -808,7 +812,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
808 | 812 | ||
809 | val = simple_strtoul(buf, NULL, 10); | 813 | val = simple_strtoul(buf, NULL, 10); |
810 | 814 | ||
811 | down(&data->update_lock); | 815 | mutex_lock(&data->update_lock); |
812 | 816 | ||
813 | switch (val) { | 817 | switch (val) { |
814 | case 1: /* PII/Celeron diode */ | 818 | case 1: /* PII/Celeron diode */ |
@@ -841,7 +845,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
841 | break; | 845 | break; |
842 | } | 846 | } |
843 | 847 | ||
844 | up(&data->update_lock); | 848 | mutex_unlock(&data->update_lock); |
845 | return count; | 849 | return count; |
846 | } | 850 | } |
847 | 851 | ||
@@ -1073,7 +1077,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1073 | new_client = &data->client; | 1077 | new_client = &data->client; |
1074 | i2c_set_clientdata(new_client, data); | 1078 | i2c_set_clientdata(new_client, data); |
1075 | new_client->addr = address; | 1079 | new_client->addr = address; |
1076 | init_MUTEX(&data->lock); | 1080 | mutex_init(&data->lock); |
1077 | new_client->adapter = adapter; | 1081 | new_client->adapter = adapter; |
1078 | new_client->driver = is_isa ? &w83781d_isa_driver : &w83781d_driver; | 1082 | new_client->driver = is_isa ? &w83781d_isa_driver : &w83781d_driver; |
1079 | new_client->flags = 0; | 1083 | new_client->flags = 0; |
@@ -1178,7 +1182,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1178 | data->type = kind; | 1182 | data->type = kind; |
1179 | 1183 | ||
1180 | data->valid = 0; | 1184 | data->valid = 0; |
1181 | init_MUTEX(&data->update_lock); | 1185 | mutex_init(&data->update_lock); |
1182 | 1186 | ||
1183 | /* Tell the I2C layer a new client has arrived */ | 1187 | /* Tell the I2C layer a new client has arrived */ |
1184 | if ((err = i2c_attach_client(new_client))) | 1188 | if ((err = i2c_attach_client(new_client))) |
@@ -1325,7 +1329,7 @@ w83781d_read_value(struct i2c_client *client, u16 reg) | |||
1325 | int res, word_sized, bank; | 1329 | int res, word_sized, bank; |
1326 | struct i2c_client *cl; | 1330 | struct i2c_client *cl; |
1327 | 1331 | ||
1328 | down(&data->lock); | 1332 | mutex_lock(&data->lock); |
1329 | if (i2c_is_isa_client(client)) { | 1333 | if (i2c_is_isa_client(client)) { |
1330 | word_sized = (((reg & 0xff00) == 0x100) | 1334 | word_sized = (((reg & 0xff00) == 0x100) |
1331 | || ((reg & 0xff00) == 0x200)) | 1335 | || ((reg & 0xff00) == 0x200)) |
@@ -1383,7 +1387,7 @@ w83781d_read_value(struct i2c_client *client, u16 reg) | |||
1383 | if (bank > 2) | 1387 | if (bank > 2) |
1384 | i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0); | 1388 | i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0); |
1385 | } | 1389 | } |
1386 | up(&data->lock); | 1390 | mutex_unlock(&data->lock); |
1387 | return res; | 1391 | return res; |
1388 | } | 1392 | } |
1389 | 1393 | ||
@@ -1394,7 +1398,7 @@ w83781d_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
1394 | int word_sized, bank; | 1398 | int word_sized, bank; |
1395 | struct i2c_client *cl; | 1399 | struct i2c_client *cl; |
1396 | 1400 | ||
1397 | down(&data->lock); | 1401 | mutex_lock(&data->lock); |
1398 | if (i2c_is_isa_client(client)) { | 1402 | if (i2c_is_isa_client(client)) { |
1399 | word_sized = (((reg & 0xff00) == 0x100) | 1403 | word_sized = (((reg & 0xff00) == 0x100) |
1400 | || ((reg & 0xff00) == 0x200)) | 1404 | || ((reg & 0xff00) == 0x200)) |
@@ -1447,7 +1451,7 @@ w83781d_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
1447 | if (bank > 2) | 1451 | if (bank > 2) |
1448 | i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0); | 1452 | i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0); |
1449 | } | 1453 | } |
1450 | up(&data->lock); | 1454 | mutex_unlock(&data->lock); |
1451 | return 0; | 1455 | return 0; |
1452 | } | 1456 | } |
1453 | 1457 | ||
@@ -1459,8 +1463,17 @@ w83781d_init_client(struct i2c_client *client) | |||
1459 | int type = data->type; | 1463 | int type = data->type; |
1460 | u8 tmp; | 1464 | u8 tmp; |
1461 | 1465 | ||
1462 | if (init && type != as99127f) { /* this resets registers we don't have | 1466 | if (reset && type != as99127f) { /* this resets registers we don't have |
1463 | documentation for on the as99127f */ | 1467 | documentation for on the as99127f */ |
1468 | /* Resetting the chip has been the default for a long time, | ||
1469 | but it causes the BIOS initializations (fan clock dividers, | ||
1470 | thermal sensor types...) to be lost, so it is now optional. | ||
1471 | It might even go away if nobody reports it as being useful, | ||
1472 | as I see very little reason why this would be needed at | ||
1473 | all. */ | ||
1474 | dev_info(&client->dev, "If reset=1 solved a problem you were " | ||
1475 | "having, please report!\n"); | ||
1476 | |||
1464 | /* save these registers */ | 1477 | /* save these registers */ |
1465 | i = w83781d_read_value(client, W83781D_REG_BEEP_CONFIG); | 1478 | i = w83781d_read_value(client, W83781D_REG_BEEP_CONFIG); |
1466 | p = w83781d_read_value(client, W83781D_REG_PWMCLK12); | 1479 | p = w83781d_read_value(client, W83781D_REG_PWMCLK12); |
@@ -1477,6 +1490,13 @@ w83781d_init_client(struct i2c_client *client) | |||
1477 | w83781d_write_value(client, W83781D_REG_BEEP_INTS2, 0); | 1490 | w83781d_write_value(client, W83781D_REG_BEEP_INTS2, 0); |
1478 | } | 1491 | } |
1479 | 1492 | ||
1493 | /* Disable power-on abnormal beep, as advised by the datasheet. | ||
1494 | Already done if reset=1. */ | ||
1495 | if (init && !reset && type != as99127f) { | ||
1496 | i = w83781d_read_value(client, W83781D_REG_BEEP_CONFIG); | ||
1497 | w83781d_write_value(client, W83781D_REG_BEEP_CONFIG, i | 0x80); | ||
1498 | } | ||
1499 | |||
1480 | data->vrm = vid_which_vrm(); | 1500 | data->vrm = vid_which_vrm(); |
1481 | 1501 | ||
1482 | if ((type != w83781d) && (type != as99127f)) { | 1502 | if ((type != w83781d) && (type != as99127f)) { |
@@ -1533,7 +1553,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1533 | struct w83781d_data *data = i2c_get_clientdata(client); | 1553 | struct w83781d_data *data = i2c_get_clientdata(client); |
1534 | int i; | 1554 | int i; |
1535 | 1555 | ||
1536 | down(&data->update_lock); | 1556 | mutex_lock(&data->update_lock); |
1537 | 1557 | ||
1538 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 1558 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
1539 | || !data->valid) { | 1559 | || !data->valid) { |
@@ -1641,7 +1661,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1641 | data->valid = 1; | 1661 | data->valid = 1; |
1642 | } | 1662 | } |
1643 | 1663 | ||
1644 | up(&data->update_lock); | 1664 | mutex_unlock(&data->update_lock); |
1645 | 1665 | ||
1646 | return data; | 1666 | return data; |
1647 | } | 1667 | } |
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index a2f6bb676235..6865c64d8a51 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #include <linux/hwmon.h> | 43 | #include <linux/hwmon.h> |
44 | #include <linux/hwmon-sysfs.h> | 44 | #include <linux/hwmon-sysfs.h> |
45 | #include <linux/err.h> | 45 | #include <linux/err.h> |
46 | #include <linux/mutex.h> | ||
46 | 47 | ||
47 | /* Addresses to scan */ | 48 | /* Addresses to scan */ |
48 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; | 49 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; |
@@ -271,7 +272,7 @@ struct w83792d_data { | |||
271 | struct class_device *class_dev; | 272 | struct class_device *class_dev; |
272 | enum chips type; | 273 | enum chips type; |
273 | 274 | ||
274 | struct semaphore update_lock; | 275 | struct mutex update_lock; |
275 | char valid; /* !=0 if following fields are valid */ | 276 | char valid; /* !=0 if following fields are valid */ |
276 | unsigned long last_updated; /* In jiffies */ | 277 | unsigned long last_updated; /* In jiffies */ |
277 | 278 | ||
@@ -382,30 +383,40 @@ static ssize_t store_in_##reg (struct device *dev, \ | |||
382 | store_in_reg(MIN, min); | 383 | store_in_reg(MIN, min); |
383 | store_in_reg(MAX, max); | 384 | store_in_reg(MAX, max); |
384 | 385 | ||
385 | #define sysfs_in_reg(offset) \ | 386 | static struct sensor_device_attribute sda_in_input[] = { |
386 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in, \ | 387 | SENSOR_ATTR(in0_input, S_IRUGO, show_in, NULL, 0), |
387 | NULL, offset); \ | 388 | SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1), |
388 | static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | 389 | SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2), |
389 | show_in_min, store_in_min, offset); \ | 390 | SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3), |
390 | static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | 391 | SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4), |
391 | show_in_max, store_in_max, offset); | 392 | SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5), |
392 | 393 | SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6), | |
393 | sysfs_in_reg(0); | 394 | SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7), |
394 | sysfs_in_reg(1); | 395 | SENSOR_ATTR(in8_input, S_IRUGO, show_in, NULL, 8), |
395 | sysfs_in_reg(2); | 396 | }; |
396 | sysfs_in_reg(3); | 397 | static struct sensor_device_attribute sda_in_min[] = { |
397 | sysfs_in_reg(4); | 398 | SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 0), |
398 | sysfs_in_reg(5); | 399 | SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 1), |
399 | sysfs_in_reg(6); | 400 | SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 2), |
400 | sysfs_in_reg(7); | 401 | SENSOR_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 3), |
401 | sysfs_in_reg(8); | 402 | SENSOR_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 4), |
402 | 403 | SENSOR_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 5), | |
403 | #define device_create_file_in(client, offset) \ | 404 | SENSOR_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 6), |
404 | do { \ | 405 | SENSOR_ATTR(in7_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 7), |
405 | device_create_file(&client->dev, &sensor_dev_attr_in##offset##_input.dev_attr); \ | 406 | SENSOR_ATTR(in8_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 8), |
406 | device_create_file(&client->dev, &sensor_dev_attr_in##offset##_max.dev_attr); \ | 407 | }; |
407 | device_create_file(&client->dev, &sensor_dev_attr_in##offset##_min.dev_attr); \ | 408 | static struct sensor_device_attribute sda_in_max[] = { |
408 | } while (0) | 409 | SENSOR_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 0), |
410 | SENSOR_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 1), | ||
411 | SENSOR_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 2), | ||
412 | SENSOR_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 3), | ||
413 | SENSOR_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 4), | ||
414 | SENSOR_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 5), | ||
415 | SENSOR_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 6), | ||
416 | SENSOR_ATTR(in7_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 7), | ||
417 | SENSOR_ATTR(in8_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 8), | ||
418 | }; | ||
419 | |||
409 | 420 | ||
410 | #define show_fan_reg(reg) \ | 421 | #define show_fan_reg(reg) \ |
411 | static ssize_t show_##reg (struct device *dev, struct device_attribute *attr, \ | 422 | static ssize_t show_##reg (struct device *dev, struct device_attribute *attr, \ |
@@ -486,28 +497,33 @@ store_fan_div(struct device *dev, struct device_attribute *attr, | |||
486 | return count; | 497 | return count; |
487 | } | 498 | } |
488 | 499 | ||
489 | #define sysfs_fan(offset) \ | 500 | static struct sensor_device_attribute sda_fan_input[] = { |
490 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan, NULL, \ | 501 | SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 1), |
491 | offset); \ | 502 | SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 2), |
492 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ | 503 | SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 3), |
493 | show_fan_div, store_fan_div, offset); \ | 504 | SENSOR_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 4), |
494 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | 505 | SENSOR_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 5), |
495 | show_fan_min, store_fan_min, offset); | 506 | SENSOR_ATTR(fan6_input, S_IRUGO, show_fan, NULL, 6), |
496 | 507 | SENSOR_ATTR(fan7_input, S_IRUGO, show_fan, NULL, 7), | |
497 | sysfs_fan(1); | 508 | }; |
498 | sysfs_fan(2); | 509 | static struct sensor_device_attribute sda_fan_min[] = { |
499 | sysfs_fan(3); | 510 | SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 1), |
500 | sysfs_fan(4); | 511 | SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 2), |
501 | sysfs_fan(5); | 512 | SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 3), |
502 | sysfs_fan(6); | 513 | SENSOR_ATTR(fan4_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 4), |
503 | sysfs_fan(7); | 514 | SENSOR_ATTR(fan5_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 5), |
504 | 515 | SENSOR_ATTR(fan6_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 6), | |
505 | #define device_create_file_fan(client, offset) \ | 516 | SENSOR_ATTR(fan7_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 7), |
506 | do { \ | 517 | }; |
507 | device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_input.dev_attr); \ | 518 | static struct sensor_device_attribute sda_fan_div[] = { |
508 | device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_div.dev_attr); \ | 519 | SENSOR_ATTR(fan1_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 1), |
509 | device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_min.dev_attr); \ | 520 | SENSOR_ATTR(fan2_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 2), |
510 | } while (0) | 521 | SENSOR_ATTR(fan3_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 3), |
522 | SENSOR_ATTR(fan4_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 4), | ||
523 | SENSOR_ATTR(fan5_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 5), | ||
524 | SENSOR_ATTR(fan6_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 6), | ||
525 | SENSOR_ATTR(fan7_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 7), | ||
526 | }; | ||
511 | 527 | ||
512 | 528 | ||
513 | /* read/write the temperature1, includes measured value and limits */ | 529 | /* read/write the temperature1, includes measured value and limits */ |
@@ -539,21 +555,6 @@ static ssize_t store_temp1(struct device *dev, struct device_attribute *attr, | |||
539 | return count; | 555 | return count; |
540 | } | 556 | } |
541 | 557 | ||
542 | |||
543 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL, 0); | ||
544 | static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp1, | ||
545 | store_temp1, 1); | ||
546 | static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1, | ||
547 | store_temp1, 2); | ||
548 | |||
549 | #define device_create_file_temp1(client) \ | ||
550 | do { \ | ||
551 | device_create_file(&client->dev, &sensor_dev_attr_temp1_input.dev_attr); \ | ||
552 | device_create_file(&client->dev, &sensor_dev_attr_temp1_max.dev_attr); \ | ||
553 | device_create_file(&client->dev, &sensor_dev_attr_temp1_max_hyst.dev_attr); \ | ||
554 | } while (0) | ||
555 | |||
556 | |||
557 | /* read/write the temperature2-3, includes measured value and limits */ | 558 | /* read/write the temperature2-3, includes measured value and limits */ |
558 | 559 | ||
559 | static ssize_t show_temp23(struct device *dev, struct device_attribute *attr, | 560 | static ssize_t show_temp23(struct device *dev, struct device_attribute *attr, |
@@ -590,25 +591,23 @@ static ssize_t store_temp23(struct device *dev, struct device_attribute *attr, | |||
590 | return count; | 591 | return count; |
591 | } | 592 | } |
592 | 593 | ||
593 | #define sysfs_temp23(name,idx) \ | 594 | static struct sensor_device_attribute_2 sda_temp_input[] = { |
594 | static SENSOR_DEVICE_ATTR_2(name##_input, S_IRUGO, show_temp23, NULL, \ | 595 | SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp1, NULL, 0, 0), |
595 | idx, 0); \ | 596 | SENSOR_ATTR_2(temp2_input, S_IRUGO, show_temp23, NULL, 0, 0), |
596 | static SENSOR_DEVICE_ATTR_2(name##_max, S_IRUGO | S_IWUSR, \ | 597 | SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp23, NULL, 1, 0), |
597 | show_temp23, store_temp23, idx, 2); \ | 598 | }; |
598 | static SENSOR_DEVICE_ATTR_2(name##_max_hyst, S_IRUGO | S_IWUSR, \ | ||
599 | show_temp23, store_temp23, idx, 4); | ||
600 | |||
601 | sysfs_temp23(temp2,0) | ||
602 | sysfs_temp23(temp3,1) | ||
603 | 599 | ||
604 | #define device_create_file_temp_add(client, offset) \ | 600 | static struct sensor_device_attribute_2 sda_temp_max[] = { |
605 | do { \ | 601 | SENSOR_ATTR_2(temp1_max, S_IRUGO | S_IWUSR, show_temp1, store_temp1, 0, 1), |
606 | device_create_file(&client->dev, &sensor_dev_attr_temp##offset##_input.dev_attr); \ | 602 | SENSOR_ATTR_2(temp2_max, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 0, 2), |
607 | device_create_file(&client->dev, &sensor_dev_attr_temp##offset##_max.dev_attr); \ | 603 | SENSOR_ATTR_2(temp3_max, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 1, 2), |
608 | device_create_file(&client->dev, \ | 604 | }; |
609 | &sensor_dev_attr_temp##offset##_max_hyst.dev_attr); \ | ||
610 | } while (0) | ||
611 | 605 | ||
606 | static struct sensor_device_attribute_2 sda_temp_max_hyst[] = { | ||
607 | SENSOR_ATTR_2(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1, store_temp1, 0, 2), | ||
608 | SENSOR_ATTR_2(temp2_max_hyst, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 0, 4), | ||
609 | SENSOR_ATTR_2(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 1, 4), | ||
610 | }; | ||
612 | 611 | ||
613 | /* get reatime status of all sensors items: voltage, temp, fan */ | 612 | /* get reatime status of all sensors items: voltage, temp, fan */ |
614 | static ssize_t | 613 | static ssize_t |
@@ -620,10 +619,6 @@ show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) | |||
620 | 619 | ||
621 | static | 620 | static |
622 | DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); | 621 | DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); |
623 | #define device_create_file_alarms(client) \ | ||
624 | device_create_file(&client->dev, &dev_attr_alarms); | ||
625 | |||
626 | |||
627 | 622 | ||
628 | static ssize_t | 623 | static ssize_t |
629 | show_pwm(struct device *dev, struct device_attribute *attr, | 624 | show_pwm(struct device *dev, struct device_attribute *attr, |
@@ -711,26 +706,19 @@ store_pwmenable(struct device *dev, struct device_attribute *attr, | |||
711 | return count; | 706 | return count; |
712 | } | 707 | } |
713 | 708 | ||
714 | #define sysfs_pwm(offset) \ | 709 | static struct sensor_device_attribute sda_pwm[] = { |
715 | static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ | 710 | SENSOR_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 1), |
716 | show_pwm, store_pwm, offset); \ | 711 | SENSOR_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 2), |
717 | static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ | 712 | SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 3), |
718 | show_pwmenable, store_pwmenable, offset); \ | 713 | }; |
719 | 714 | static struct sensor_device_attribute sda_pwm_enable[] = { | |
720 | sysfs_pwm(1); | 715 | SENSOR_ATTR(pwm1_enable, S_IWUSR | S_IRUGO, |
721 | sysfs_pwm(2); | 716 | show_pwmenable, store_pwmenable, 1), |
722 | sysfs_pwm(3); | 717 | SENSOR_ATTR(pwm2_enable, S_IWUSR | S_IRUGO, |
723 | 718 | show_pwmenable, store_pwmenable, 2), | |
724 | 719 | SENSOR_ATTR(pwm3_enable, S_IWUSR | S_IRUGO, | |
725 | #define device_create_file_pwm(client, offset) \ | 720 | show_pwmenable, store_pwmenable, 3), |
726 | do { \ | 721 | }; |
727 | device_create_file(&client->dev, &sensor_dev_attr_pwm##offset.dev_attr); \ | ||
728 | } while (0) | ||
729 | |||
730 | #define device_create_file_pwmenable(client, offset) \ | ||
731 | do { \ | ||
732 | device_create_file(&client->dev, &sensor_dev_attr_pwm##offset##_enable.dev_attr); \ | ||
733 | } while (0) | ||
734 | 722 | ||
735 | 723 | ||
736 | static ssize_t | 724 | static ssize_t |
@@ -764,18 +752,14 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr, | |||
764 | return count; | 752 | return count; |
765 | } | 753 | } |
766 | 754 | ||
767 | #define sysfs_pwm_mode(offset) \ | 755 | static struct sensor_device_attribute sda_pwm_mode[] = { |
768 | static SENSOR_DEVICE_ATTR(pwm##offset##_mode, S_IRUGO | S_IWUSR, \ | 756 | SENSOR_ATTR(pwm1_mode, S_IWUSR | S_IRUGO, |
769 | show_pwm_mode, store_pwm_mode, offset); | 757 | show_pwm_mode, store_pwm_mode, 1), |
770 | 758 | SENSOR_ATTR(pwm2_mode, S_IWUSR | S_IRUGO, | |
771 | sysfs_pwm_mode(1); | 759 | show_pwm_mode, store_pwm_mode, 2), |
772 | sysfs_pwm_mode(2); | 760 | SENSOR_ATTR(pwm3_mode, S_IWUSR | S_IRUGO, |
773 | sysfs_pwm_mode(3); | 761 | show_pwm_mode, store_pwm_mode, 3), |
774 | 762 | }; | |
775 | #define device_create_file_pwm_mode(client, offset) \ | ||
776 | do { \ | ||
777 | device_create_file(&client->dev, &sensor_dev_attr_pwm##offset##_mode.dev_attr); \ | ||
778 | } while (0) | ||
779 | 763 | ||
780 | 764 | ||
781 | static ssize_t | 765 | static ssize_t |
@@ -788,12 +772,6 @@ show_regs_chassis(struct device *dev, struct device_attribute *attr, | |||
788 | 772 | ||
789 | static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL); | 773 | static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL); |
790 | 774 | ||
791 | #define device_create_file_chassis(client) \ | ||
792 | do { \ | ||
793 | device_create_file(&client->dev, &dev_attr_chassis); \ | ||
794 | } while (0) | ||
795 | |||
796 | |||
797 | static ssize_t | 775 | static ssize_t |
798 | show_chassis_clear(struct device *dev, struct device_attribute *attr, char *buf) | 776 | show_chassis_clear(struct device *dev, struct device_attribute *attr, char *buf) |
799 | { | 777 | { |
@@ -824,13 +802,6 @@ store_chassis_clear(struct device *dev, struct device_attribute *attr, | |||
824 | static DEVICE_ATTR(chassis_clear, S_IRUGO | S_IWUSR, | 802 | static DEVICE_ATTR(chassis_clear, S_IRUGO | S_IWUSR, |
825 | show_chassis_clear, store_chassis_clear); | 803 | show_chassis_clear, store_chassis_clear); |
826 | 804 | ||
827 | #define device_create_file_chassis_clear(client) \ | ||
828 | do { \ | ||
829 | device_create_file(&client->dev, &dev_attr_chassis_clear); \ | ||
830 | } while (0) | ||
831 | |||
832 | |||
833 | |||
834 | /* For Smart Fan I / Thermal Cruise */ | 805 | /* For Smart Fan I / Thermal Cruise */ |
835 | static ssize_t | 806 | static ssize_t |
836 | show_thermal_cruise(struct device *dev, struct device_attribute *attr, | 807 | show_thermal_cruise(struct device *dev, struct device_attribute *attr, |
@@ -864,20 +835,14 @@ store_thermal_cruise(struct device *dev, struct device_attribute *attr, | |||
864 | return count; | 835 | return count; |
865 | } | 836 | } |
866 | 837 | ||
867 | #define sysfs_thermal_cruise(offset) \ | 838 | static struct sensor_device_attribute sda_thermal_cruise[] = { |
868 | static SENSOR_DEVICE_ATTR(thermal_cruise##offset, S_IRUGO | S_IWUSR, \ | 839 | SENSOR_ATTR(thermal_cruise1, S_IWUSR | S_IRUGO, |
869 | show_thermal_cruise, store_thermal_cruise, offset); | 840 | show_thermal_cruise, store_thermal_cruise, 1), |
870 | 841 | SENSOR_ATTR(thermal_cruise2, S_IWUSR | S_IRUGO, | |
871 | sysfs_thermal_cruise(1); | 842 | show_thermal_cruise, store_thermal_cruise, 2), |
872 | sysfs_thermal_cruise(2); | 843 | SENSOR_ATTR(thermal_cruise3, S_IWUSR | S_IRUGO, |
873 | sysfs_thermal_cruise(3); | 844 | show_thermal_cruise, store_thermal_cruise, 3), |
874 | 845 | }; | |
875 | #define device_create_file_thermal_cruise(client, offset) \ | ||
876 | do { \ | ||
877 | device_create_file(&client->dev, \ | ||
878 | &sensor_dev_attr_thermal_cruise##offset.dev_attr); \ | ||
879 | } while (0) | ||
880 | |||
881 | 846 | ||
882 | /* For Smart Fan I/Thermal Cruise and Smart Fan II */ | 847 | /* For Smart Fan I/Thermal Cruise and Smart Fan II */ |
883 | static ssize_t | 848 | static ssize_t |
@@ -916,19 +881,14 @@ store_tolerance(struct device *dev, struct device_attribute *attr, | |||
916 | return count; | 881 | return count; |
917 | } | 882 | } |
918 | 883 | ||
919 | #define sysfs_tolerance(offset) \ | 884 | static struct sensor_device_attribute sda_tolerance[] = { |
920 | static SENSOR_DEVICE_ATTR(tolerance##offset, S_IRUGO | S_IWUSR, \ | 885 | SENSOR_ATTR(tolerance1, S_IWUSR | S_IRUGO, |
921 | show_tolerance, store_tolerance, offset); | 886 | show_tolerance, store_tolerance, 1), |
922 | 887 | SENSOR_ATTR(tolerance2, S_IWUSR | S_IRUGO, | |
923 | sysfs_tolerance(1); | 888 | show_tolerance, store_tolerance, 2), |
924 | sysfs_tolerance(2); | 889 | SENSOR_ATTR(tolerance3, S_IWUSR | S_IRUGO, |
925 | sysfs_tolerance(3); | 890 | show_tolerance, store_tolerance, 3), |
926 | 891 | }; | |
927 | #define device_create_file_tolerance(client, offset) \ | ||
928 | do { \ | ||
929 | device_create_file(&client->dev, &sensor_dev_attr_tolerance##offset.dev_attr); \ | ||
930 | } while (0) | ||
931 | |||
932 | 892 | ||
933 | /* For Smart Fan II */ | 893 | /* For Smart Fan II */ |
934 | static ssize_t | 894 | static ssize_t |
@@ -964,28 +924,34 @@ store_sf2_point(struct device *dev, struct device_attribute *attr, | |||
964 | return count; | 924 | return count; |
965 | } | 925 | } |
966 | 926 | ||
967 | #define sysfs_sf2_point(offset, index) \ | 927 | static struct sensor_device_attribute_2 sda_sf2_point[] = { |
968 | static SENSOR_DEVICE_ATTR_2(sf2_point##offset##_fan##index, S_IRUGO | S_IWUSR, \ | 928 | SENSOR_ATTR_2(sf2_point1_fan1, S_IRUGO | S_IWUSR, |
969 | show_sf2_point, store_sf2_point, offset, index); | 929 | show_sf2_point, store_sf2_point, 1, 1), |
970 | 930 | SENSOR_ATTR_2(sf2_point2_fan1, S_IRUGO | S_IWUSR, | |
971 | sysfs_sf2_point(1, 1); /* Fan1 */ | 931 | show_sf2_point, store_sf2_point, 2, 1), |
972 | sysfs_sf2_point(2, 1); /* Fan1 */ | 932 | SENSOR_ATTR_2(sf2_point3_fan1, S_IRUGO | S_IWUSR, |
973 | sysfs_sf2_point(3, 1); /* Fan1 */ | 933 | show_sf2_point, store_sf2_point, 3, 1), |
974 | sysfs_sf2_point(4, 1); /* Fan1 */ | 934 | SENSOR_ATTR_2(sf2_point4_fan1, S_IRUGO | S_IWUSR, |
975 | sysfs_sf2_point(1, 2); /* Fan2 */ | 935 | show_sf2_point, store_sf2_point, 4, 1), |
976 | sysfs_sf2_point(2, 2); /* Fan2 */ | 936 | |
977 | sysfs_sf2_point(3, 2); /* Fan2 */ | 937 | SENSOR_ATTR_2(sf2_point1_fan2, S_IRUGO | S_IWUSR, |
978 | sysfs_sf2_point(4, 2); /* Fan2 */ | 938 | show_sf2_point, store_sf2_point, 1, 2), |
979 | sysfs_sf2_point(1, 3); /* Fan3 */ | 939 | SENSOR_ATTR_2(sf2_point2_fan2, S_IRUGO | S_IWUSR, |
980 | sysfs_sf2_point(2, 3); /* Fan3 */ | 940 | show_sf2_point, store_sf2_point, 2, 2), |
981 | sysfs_sf2_point(3, 3); /* Fan3 */ | 941 | SENSOR_ATTR_2(sf2_point3_fan2, S_IRUGO | S_IWUSR, |
982 | sysfs_sf2_point(4, 3); /* Fan3 */ | 942 | show_sf2_point, store_sf2_point, 3, 2), |
983 | 943 | SENSOR_ATTR_2(sf2_point4_fan2, S_IRUGO | S_IWUSR, | |
984 | #define device_create_file_sf2_point(client, offset, index) \ | 944 | show_sf2_point, store_sf2_point, 4, 2), |
985 | do { \ | 945 | |
986 | device_create_file(&client->dev, \ | 946 | SENSOR_ATTR_2(sf2_point1_fan3, S_IRUGO | S_IWUSR, |
987 | &sensor_dev_attr_sf2_point##offset##_fan##index.dev_attr); \ | 947 | show_sf2_point, store_sf2_point, 1, 3), |
988 | } while (0) | 948 | SENSOR_ATTR_2(sf2_point2_fan3, S_IRUGO | S_IWUSR, |
949 | show_sf2_point, store_sf2_point, 2, 3), | ||
950 | SENSOR_ATTR_2(sf2_point3_fan3, S_IRUGO | S_IWUSR, | ||
951 | show_sf2_point, store_sf2_point, 3, 3), | ||
952 | SENSOR_ATTR_2(sf2_point4_fan3, S_IRUGO | S_IWUSR, | ||
953 | show_sf2_point, store_sf2_point, 4, 3), | ||
954 | }; | ||
989 | 955 | ||
990 | 956 | ||
991 | static ssize_t | 957 | static ssize_t |
@@ -1026,26 +992,28 @@ store_sf2_level(struct device *dev, struct device_attribute *attr, | |||
1026 | return count; | 992 | return count; |
1027 | } | 993 | } |
1028 | 994 | ||
1029 | #define sysfs_sf2_level(offset, index) \ | 995 | static struct sensor_device_attribute_2 sda_sf2_level[] = { |
1030 | static SENSOR_DEVICE_ATTR_2(sf2_level##offset##_fan##index, S_IRUGO | S_IWUSR, \ | 996 | SENSOR_ATTR_2(sf2_level1_fan1, S_IRUGO | S_IWUSR, |
1031 | show_sf2_level, store_sf2_level, offset, index); | 997 | show_sf2_level, store_sf2_level, 1, 1), |
1032 | 998 | SENSOR_ATTR_2(sf2_level2_fan1, S_IRUGO | S_IWUSR, | |
1033 | sysfs_sf2_level(1, 1); /* Fan1 */ | 999 | show_sf2_level, store_sf2_level, 2, 1), |
1034 | sysfs_sf2_level(2, 1); /* Fan1 */ | 1000 | SENSOR_ATTR_2(sf2_level3_fan1, S_IRUGO | S_IWUSR, |
1035 | sysfs_sf2_level(3, 1); /* Fan1 */ | 1001 | show_sf2_level, store_sf2_level, 3, 1), |
1036 | sysfs_sf2_level(1, 2); /* Fan2 */ | 1002 | |
1037 | sysfs_sf2_level(2, 2); /* Fan2 */ | 1003 | SENSOR_ATTR_2(sf2_level1_fan2, S_IRUGO | S_IWUSR, |
1038 | sysfs_sf2_level(3, 2); /* Fan2 */ | 1004 | show_sf2_level, store_sf2_level, 1, 2), |
1039 | sysfs_sf2_level(1, 3); /* Fan3 */ | 1005 | SENSOR_ATTR_2(sf2_level2_fan2, S_IRUGO | S_IWUSR, |
1040 | sysfs_sf2_level(2, 3); /* Fan3 */ | 1006 | show_sf2_level, store_sf2_level, 2, 2), |
1041 | sysfs_sf2_level(3, 3); /* Fan3 */ | 1007 | SENSOR_ATTR_2(sf2_level3_fan2, S_IRUGO | S_IWUSR, |
1042 | 1008 | show_sf2_level, store_sf2_level, 3, 2), | |
1043 | #define device_create_file_sf2_level(client, offset, index) \ | 1009 | |
1044 | do { \ | 1010 | SENSOR_ATTR_2(sf2_level1_fan3, S_IRUGO | S_IWUSR, |
1045 | device_create_file(&client->dev, \ | 1011 | show_sf2_level, store_sf2_level, 1, 3), |
1046 | &sensor_dev_attr_sf2_level##offset##_fan##index.dev_attr); \ | 1012 | SENSOR_ATTR_2(sf2_level2_fan3, S_IRUGO | S_IWUSR, |
1047 | } while (0) | 1013 | show_sf2_level, store_sf2_level, 2, 3), |
1048 | 1014 | SENSOR_ATTR_2(sf2_level3_fan3, S_IRUGO | S_IWUSR, | |
1015 | show_sf2_level, store_sf2_level, 3, 3), | ||
1016 | }; | ||
1049 | 1017 | ||
1050 | /* This function is called when: | 1018 | /* This function is called when: |
1051 | * w83792d_driver is inserted (when this module is loaded), for each | 1019 | * w83792d_driver is inserted (when this module is loaded), for each |
@@ -1147,12 +1115,19 @@ ERROR_SC_0: | |||
1147 | return err; | 1115 | return err; |
1148 | } | 1116 | } |
1149 | 1117 | ||
1118 | static void device_create_file_fan(struct device *dev, int i) | ||
1119 | { | ||
1120 | device_create_file(dev, &sda_fan_input[i].dev_attr); | ||
1121 | device_create_file(dev, &sda_fan_div[i].dev_attr); | ||
1122 | device_create_file(dev, &sda_fan_min[i].dev_attr); | ||
1123 | } | ||
1150 | 1124 | ||
1151 | static int | 1125 | static int |
1152 | w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | 1126 | w83792d_detect(struct i2c_adapter *adapter, int address, int kind) |
1153 | { | 1127 | { |
1154 | int i = 0, val1 = 0, val2; | 1128 | int i = 0, val1 = 0, val2; |
1155 | struct i2c_client *new_client; | 1129 | struct i2c_client *client; |
1130 | struct device *dev; | ||
1156 | struct w83792d_data *data; | 1131 | struct w83792d_data *data; |
1157 | int err = 0; | 1132 | int err = 0; |
1158 | const char *client_name = ""; | 1133 | const char *client_name = ""; |
@@ -1170,12 +1145,13 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1170 | goto ERROR0; | 1145 | goto ERROR0; |
1171 | } | 1146 | } |
1172 | 1147 | ||
1173 | new_client = &data->client; | 1148 | client = &data->client; |
1174 | i2c_set_clientdata(new_client, data); | 1149 | dev = &client->dev; |
1175 | new_client->addr = address; | 1150 | i2c_set_clientdata(client, data); |
1176 | new_client->adapter = adapter; | 1151 | client->addr = address; |
1177 | new_client->driver = &w83792d_driver; | 1152 | client->adapter = adapter; |
1178 | new_client->flags = 0; | 1153 | client->driver = &w83792d_driver; |
1154 | client->flags = 0; | ||
1179 | 1155 | ||
1180 | /* Now, we do the remaining detection. */ | 1156 | /* Now, we do the remaining detection. */ |
1181 | 1157 | ||
@@ -1184,13 +1160,12 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1184 | force_*=... parameter, and the Winbond will be reset to the right | 1160 | force_*=... parameter, and the Winbond will be reset to the right |
1185 | bank. */ | 1161 | bank. */ |
1186 | if (kind < 0) { | 1162 | if (kind < 0) { |
1187 | if (w83792d_read_value(new_client, W83792D_REG_CONFIG) & 0x80) { | 1163 | if (w83792d_read_value(client, W83792D_REG_CONFIG) & 0x80) { |
1188 | dev_warn(&new_client->dev, "Detection failed at step " | 1164 | dev_warn(dev, "Detection failed at step 3\n"); |
1189 | "3\n"); | ||
1190 | goto ERROR1; | 1165 | goto ERROR1; |
1191 | } | 1166 | } |
1192 | val1 = w83792d_read_value(new_client, W83792D_REG_BANK); | 1167 | val1 = w83792d_read_value(client, W83792D_REG_BANK); |
1193 | val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN); | 1168 | val2 = w83792d_read_value(client, W83792D_REG_CHIPMAN); |
1194 | /* Check for Winbond ID if in bank 0 */ | 1169 | /* Check for Winbond ID if in bank 0 */ |
1195 | if (!(val1 & 0x07)) { /* is Bank0 */ | 1170 | if (!(val1 & 0x07)) { /* is Bank0 */ |
1196 | if (((!(val1 & 0x80)) && (val2 != 0xa3)) || | 1171 | if (((!(val1 & 0x80)) && (val2 != 0xa3)) || |
@@ -1200,34 +1175,33 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1200 | } | 1175 | } |
1201 | /* If Winbond chip, address of chip and W83792D_REG_I2C_ADDR | 1176 | /* If Winbond chip, address of chip and W83792D_REG_I2C_ADDR |
1202 | should match */ | 1177 | should match */ |
1203 | if (w83792d_read_value(new_client, | 1178 | if (w83792d_read_value(client, |
1204 | W83792D_REG_I2C_ADDR) != address) { | 1179 | W83792D_REG_I2C_ADDR) != address) { |
1205 | dev_warn(&new_client->dev, "Detection failed " | 1180 | dev_warn(dev, "Detection failed at step 5\n"); |
1206 | "at step 5\n"); | ||
1207 | goto ERROR1; | 1181 | goto ERROR1; |
1208 | } | 1182 | } |
1209 | } | 1183 | } |
1210 | 1184 | ||
1211 | /* We have either had a force parameter, or we have already detected the | 1185 | /* We have either had a force parameter, or we have already detected the |
1212 | Winbond. Put it now into bank 0 and Vendor ID High Byte */ | 1186 | Winbond. Put it now into bank 0 and Vendor ID High Byte */ |
1213 | w83792d_write_value(new_client, | 1187 | w83792d_write_value(client, |
1214 | W83792D_REG_BANK, | 1188 | W83792D_REG_BANK, |
1215 | (w83792d_read_value(new_client, | 1189 | (w83792d_read_value(client, |
1216 | W83792D_REG_BANK) & 0x78) | 0x80); | 1190 | W83792D_REG_BANK) & 0x78) | 0x80); |
1217 | 1191 | ||
1218 | /* Determine the chip type. */ | 1192 | /* Determine the chip type. */ |
1219 | if (kind <= 0) { | 1193 | if (kind <= 0) { |
1220 | /* get vendor ID */ | 1194 | /* get vendor ID */ |
1221 | val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN); | 1195 | val2 = w83792d_read_value(client, W83792D_REG_CHIPMAN); |
1222 | if (val2 != 0x5c) { /* the vendor is NOT Winbond */ | 1196 | if (val2 != 0x5c) { /* the vendor is NOT Winbond */ |
1223 | goto ERROR1; | 1197 | goto ERROR1; |
1224 | } | 1198 | } |
1225 | val1 = w83792d_read_value(new_client, W83792D_REG_WCHIPID); | 1199 | val1 = w83792d_read_value(client, W83792D_REG_WCHIPID); |
1226 | if (val1 == 0x7a) { | 1200 | if (val1 == 0x7a) { |
1227 | kind = w83792d; | 1201 | kind = w83792d; |
1228 | } else { | 1202 | } else { |
1229 | if (kind == 0) | 1203 | if (kind == 0) |
1230 | dev_warn(&new_client->dev, | 1204 | dev_warn(dev, |
1231 | "w83792d: Ignoring 'force' parameter for" | 1205 | "w83792d: Ignoring 'force' parameter for" |
1232 | " unknown chip at adapter %d, address" | 1206 | " unknown chip at adapter %d, address" |
1233 | " 0x%02x\n", i2c_adapter_id(adapter), | 1207 | " 0x%02x\n", i2c_adapter_id(adapter), |
@@ -1239,120 +1213,86 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1239 | if (kind == w83792d) { | 1213 | if (kind == w83792d) { |
1240 | client_name = "w83792d"; | 1214 | client_name = "w83792d"; |
1241 | } else { | 1215 | } else { |
1242 | dev_err(&new_client->dev, "w83792d: Internal error: unknown" | 1216 | dev_err(dev, "w83792d: Internal error: unknown" |
1243 | " kind (%d)?!?", kind); | 1217 | " kind (%d)?!?", kind); |
1244 | goto ERROR1; | 1218 | goto ERROR1; |
1245 | } | 1219 | } |
1246 | 1220 | ||
1247 | /* Fill in the remaining client fields and put into the global list */ | 1221 | /* Fill in the remaining client fields and put into the global list */ |
1248 | strlcpy(new_client->name, client_name, I2C_NAME_SIZE); | 1222 | strlcpy(client->name, client_name, I2C_NAME_SIZE); |
1249 | data->type = kind; | 1223 | data->type = kind; |
1250 | 1224 | ||
1251 | data->valid = 0; | 1225 | data->valid = 0; |
1252 | init_MUTEX(&data->update_lock); | 1226 | mutex_init(&data->update_lock); |
1253 | 1227 | ||
1254 | /* Tell the I2C layer a new client has arrived */ | 1228 | /* Tell the I2C layer a new client has arrived */ |
1255 | if ((err = i2c_attach_client(new_client))) | 1229 | if ((err = i2c_attach_client(client))) |
1256 | goto ERROR1; | 1230 | goto ERROR1; |
1257 | 1231 | ||
1258 | if ((err = w83792d_detect_subclients(adapter, address, | 1232 | if ((err = w83792d_detect_subclients(adapter, address, |
1259 | kind, new_client))) | 1233 | kind, client))) |
1260 | goto ERROR2; | 1234 | goto ERROR2; |
1261 | 1235 | ||
1262 | /* Initialize the chip */ | 1236 | /* Initialize the chip */ |
1263 | w83792d_init_client(new_client); | 1237 | w83792d_init_client(client); |
1264 | 1238 | ||
1265 | /* A few vars need to be filled upon startup */ | 1239 | /* A few vars need to be filled upon startup */ |
1266 | for (i = 0; i < 7; i++) { | 1240 | for (i = 0; i < 7; i++) { |
1267 | data->fan_min[i] = w83792d_read_value(new_client, | 1241 | data->fan_min[i] = w83792d_read_value(client, |
1268 | W83792D_REG_FAN_MIN[i]); | 1242 | W83792D_REG_FAN_MIN[i]); |
1269 | } | 1243 | } |
1270 | 1244 | ||
1271 | /* Register sysfs hooks */ | 1245 | /* Register sysfs hooks */ |
1272 | data->class_dev = hwmon_device_register(&new_client->dev); | 1246 | data->class_dev = hwmon_device_register(dev); |
1273 | if (IS_ERR(data->class_dev)) { | 1247 | if (IS_ERR(data->class_dev)) { |
1274 | err = PTR_ERR(data->class_dev); | 1248 | err = PTR_ERR(data->class_dev); |
1275 | goto ERROR3; | 1249 | goto ERROR3; |
1276 | } | 1250 | } |
1277 | device_create_file_in(new_client, 0); | 1251 | for (i = 0; i < 9; i++) { |
1278 | device_create_file_in(new_client, 1); | 1252 | device_create_file(dev, &sda_in_input[i].dev_attr); |
1279 | device_create_file_in(new_client, 2); | 1253 | device_create_file(dev, &sda_in_max[i].dev_attr); |
1280 | device_create_file_in(new_client, 3); | 1254 | device_create_file(dev, &sda_in_min[i].dev_attr); |
1281 | device_create_file_in(new_client, 4); | 1255 | } |
1282 | device_create_file_in(new_client, 5); | 1256 | for (i = 0; i < 3; i++) |
1283 | device_create_file_in(new_client, 6); | 1257 | device_create_file_fan(dev, i); |
1284 | device_create_file_in(new_client, 7); | ||
1285 | device_create_file_in(new_client, 8); | ||
1286 | |||
1287 | device_create_file_fan(new_client, 1); | ||
1288 | device_create_file_fan(new_client, 2); | ||
1289 | device_create_file_fan(new_client, 3); | ||
1290 | 1258 | ||
1291 | /* Read GPIO enable register to check if pins for fan 4,5 are used as | 1259 | /* Read GPIO enable register to check if pins for fan 4,5 are used as |
1292 | GPIO */ | 1260 | GPIO */ |
1293 | val1 = w83792d_read_value(new_client, W83792D_REG_GPIO_EN); | 1261 | val1 = w83792d_read_value(client, W83792D_REG_GPIO_EN); |
1294 | if (!(val1 & 0x40)) | 1262 | if (!(val1 & 0x40)) |
1295 | device_create_file_fan(new_client, 4); | 1263 | device_create_file_fan(dev, 3); |
1296 | if (!(val1 & 0x20)) | 1264 | if (!(val1 & 0x20)) |
1297 | device_create_file_fan(new_client, 5); | 1265 | device_create_file_fan(dev, 4); |
1298 | 1266 | ||
1299 | val1 = w83792d_read_value(new_client, W83792D_REG_PIN); | 1267 | val1 = w83792d_read_value(client, W83792D_REG_PIN); |
1300 | if (val1 & 0x40) | 1268 | if (val1 & 0x40) |
1301 | device_create_file_fan(new_client, 6); | 1269 | device_create_file_fan(dev, 5); |
1302 | if (val1 & 0x04) | 1270 | if (val1 & 0x04) |
1303 | device_create_file_fan(new_client, 7); | 1271 | device_create_file_fan(dev, 6); |
1304 | 1272 | ||
1305 | device_create_file_temp1(new_client); /* Temp1 */ | 1273 | for (i = 0; i < 3; i++) { |
1306 | device_create_file_temp_add(new_client, 2); /* Temp2 */ | 1274 | device_create_file(dev, &sda_temp_input[i].dev_attr); |
1307 | device_create_file_temp_add(new_client, 3); /* Temp3 */ | 1275 | device_create_file(dev, &sda_temp_max[i].dev_attr); |
1308 | 1276 | device_create_file(dev, &sda_temp_max_hyst[i].dev_attr); | |
1309 | device_create_file_alarms(new_client); | 1277 | device_create_file(dev, &sda_thermal_cruise[i].dev_attr); |
1310 | 1278 | device_create_file(dev, &sda_tolerance[i].dev_attr); | |
1311 | device_create_file_pwm(new_client, 1); | 1279 | } |
1312 | device_create_file_pwm(new_client, 2); | 1280 | |
1313 | device_create_file_pwm(new_client, 3); | 1281 | for (i = 0; i < ARRAY_SIZE(sda_pwm); i++) { |
1314 | 1282 | device_create_file(dev, &sda_pwm[i].dev_attr); | |
1315 | device_create_file_pwmenable(new_client, 1); | 1283 | device_create_file(dev, &sda_pwm_enable[i].dev_attr); |
1316 | device_create_file_pwmenable(new_client, 2); | 1284 | device_create_file(dev, &sda_pwm_mode[i].dev_attr); |
1317 | device_create_file_pwmenable(new_client, 3); | 1285 | } |
1318 | 1286 | ||
1319 | device_create_file_pwm_mode(new_client, 1); | 1287 | device_create_file(dev, &dev_attr_alarms); |
1320 | device_create_file_pwm_mode(new_client, 2); | 1288 | device_create_file(dev, &dev_attr_chassis); |
1321 | device_create_file_pwm_mode(new_client, 3); | 1289 | device_create_file(dev, &dev_attr_chassis_clear); |
1322 | 1290 | ||
1323 | device_create_file_chassis(new_client); | 1291 | for (i = 0; i < ARRAY_SIZE(sda_sf2_point); i++) |
1324 | device_create_file_chassis_clear(new_client); | 1292 | device_create_file(dev, &sda_sf2_point[i].dev_attr); |
1325 | 1293 | ||
1326 | device_create_file_thermal_cruise(new_client, 1); | 1294 | for (i = 0; i < ARRAY_SIZE(sda_sf2_level); i++) |
1327 | device_create_file_thermal_cruise(new_client, 2); | 1295 | device_create_file(dev, &sda_sf2_level[i].dev_attr); |
1328 | device_create_file_thermal_cruise(new_client, 3); | ||
1329 | |||
1330 | device_create_file_tolerance(new_client, 1); | ||
1331 | device_create_file_tolerance(new_client, 2); | ||
1332 | device_create_file_tolerance(new_client, 3); | ||
1333 | |||
1334 | device_create_file_sf2_point(new_client, 1, 1); /* Fan1 */ | ||
1335 | device_create_file_sf2_point(new_client, 2, 1); /* Fan1 */ | ||
1336 | device_create_file_sf2_point(new_client, 3, 1); /* Fan1 */ | ||
1337 | device_create_file_sf2_point(new_client, 4, 1); /* Fan1 */ | ||
1338 | device_create_file_sf2_point(new_client, 1, 2); /* Fan2 */ | ||
1339 | device_create_file_sf2_point(new_client, 2, 2); /* Fan2 */ | ||
1340 | device_create_file_sf2_point(new_client, 3, 2); /* Fan2 */ | ||
1341 | device_create_file_sf2_point(new_client, 4, 2); /* Fan2 */ | ||
1342 | device_create_file_sf2_point(new_client, 1, 3); /* Fan3 */ | ||
1343 | device_create_file_sf2_point(new_client, 2, 3); /* Fan3 */ | ||
1344 | device_create_file_sf2_point(new_client, 3, 3); /* Fan3 */ | ||
1345 | device_create_file_sf2_point(new_client, 4, 3); /* Fan3 */ | ||
1346 | |||
1347 | device_create_file_sf2_level(new_client, 1, 1); /* Fan1 */ | ||
1348 | device_create_file_sf2_level(new_client, 2, 1); /* Fan1 */ | ||
1349 | device_create_file_sf2_level(new_client, 3, 1); /* Fan1 */ | ||
1350 | device_create_file_sf2_level(new_client, 1, 2); /* Fan2 */ | ||
1351 | device_create_file_sf2_level(new_client, 2, 2); /* Fan2 */ | ||
1352 | device_create_file_sf2_level(new_client, 3, 2); /* Fan2 */ | ||
1353 | device_create_file_sf2_level(new_client, 1, 3); /* Fan3 */ | ||
1354 | device_create_file_sf2_level(new_client, 2, 3); /* Fan3 */ | ||
1355 | device_create_file_sf2_level(new_client, 3, 3); /* Fan3 */ | ||
1356 | 1296 | ||
1357 | return 0; | 1297 | return 0; |
1358 | 1298 | ||
@@ -1366,7 +1306,7 @@ ERROR3: | |||
1366 | kfree(data->lm75[1]); | 1306 | kfree(data->lm75[1]); |
1367 | } | 1307 | } |
1368 | ERROR2: | 1308 | ERROR2: |
1369 | i2c_detach_client(new_client); | 1309 | i2c_detach_client(client); |
1370 | ERROR1: | 1310 | ERROR1: |
1371 | kfree(data); | 1311 | kfree(data); |
1372 | ERROR0: | 1312 | ERROR0: |
@@ -1434,7 +1374,7 @@ static struct w83792d_data *w83792d_update_device(struct device *dev) | |||
1434 | int i, j; | 1374 | int i, j; |
1435 | u8 reg_array_tmp[4], pwm_array_tmp[7], reg_tmp; | 1375 | u8 reg_array_tmp[4], pwm_array_tmp[7], reg_tmp; |
1436 | 1376 | ||
1437 | down(&data->update_lock); | 1377 | mutex_lock(&data->update_lock); |
1438 | 1378 | ||
1439 | if (time_after | 1379 | if (time_after |
1440 | (jiffies - data->last_updated, (unsigned long) (HZ * 3)) | 1380 | (jiffies - data->last_updated, (unsigned long) (HZ * 3)) |
@@ -1545,7 +1485,7 @@ static struct w83792d_data *w83792d_update_device(struct device *dev) | |||
1545 | data->valid = 1; | 1485 | data->valid = 1; |
1546 | } | 1486 | } |
1547 | 1487 | ||
1548 | up(&data->update_lock); | 1488 | mutex_unlock(&data->update_lock); |
1549 | 1489 | ||
1550 | #ifdef DEBUG | 1490 | #ifdef DEBUG |
1551 | w83792d_print_debug(data, dev); | 1491 | w83792d_print_debug(data, dev); |
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index f66c0cfdeda7..3f2bac125fb1 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/hwmon.h> | 39 | #include <linux/hwmon.h> |
40 | #include <linux/hwmon-sysfs.h> | 40 | #include <linux/hwmon-sysfs.h> |
41 | #include <linux/err.h> | 41 | #include <linux/err.h> |
42 | #include <linux/mutex.h> | ||
42 | 43 | ||
43 | /* How many retries on register read error */ | 44 | /* How many retries on register read error */ |
44 | #define MAX_RETRIES 5 | 45 | #define MAX_RETRIES 5 |
@@ -107,7 +108,7 @@ static struct i2c_driver w83l785ts_driver = { | |||
107 | struct w83l785ts_data { | 108 | struct w83l785ts_data { |
108 | struct i2c_client client; | 109 | struct i2c_client client; |
109 | struct class_device *class_dev; | 110 | struct class_device *class_dev; |
110 | struct semaphore update_lock; | 111 | struct mutex update_lock; |
111 | char valid; /* zero until following fields are valid */ | 112 | char valid; /* zero until following fields are valid */ |
112 | unsigned long last_updated; /* in jiffies */ | 113 | unsigned long last_updated; /* in jiffies */ |
113 | 114 | ||
@@ -221,7 +222,7 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) | |||
221 | /* We can fill in the remaining client fields. */ | 222 | /* We can fill in the remaining client fields. */ |
222 | strlcpy(new_client->name, "w83l785ts", I2C_NAME_SIZE); | 223 | strlcpy(new_client->name, "w83l785ts", I2C_NAME_SIZE); |
223 | data->valid = 0; | 224 | data->valid = 0; |
224 | init_MUTEX(&data->update_lock); | 225 | mutex_init(&data->update_lock); |
225 | 226 | ||
226 | /* Default values in case the first read fails (unlikely). */ | 227 | /* Default values in case the first read fails (unlikely). */ |
227 | data->temp[1] = data->temp[0] = 0; | 228 | data->temp[1] = data->temp[0] = 0; |
@@ -299,7 +300,7 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev) | |||
299 | struct i2c_client *client = to_i2c_client(dev); | 300 | struct i2c_client *client = to_i2c_client(dev); |
300 | struct w83l785ts_data *data = i2c_get_clientdata(client); | 301 | struct w83l785ts_data *data = i2c_get_clientdata(client); |
301 | 302 | ||
302 | down(&data->update_lock); | 303 | mutex_lock(&data->update_lock); |
303 | 304 | ||
304 | if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { | 305 | if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { |
305 | dev_dbg(&client->dev, "Updating w83l785ts data.\n"); | 306 | dev_dbg(&client->dev, "Updating w83l785ts data.\n"); |
@@ -312,7 +313,7 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev) | |||
312 | data->valid = 1; | 313 | data->valid = 1; |
313 | } | 314 | } |
314 | 315 | ||
315 | up(&data->update_lock); | 316 | mutex_unlock(&data->update_lock); |
316 | 317 | ||
317 | return data; | 318 | return data; |
318 | } | 319 | } |
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index ff92735c7c85..089c6f5b24de 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -168,12 +168,14 @@ config I2C_PIIX4 | |||
168 | help | 168 | help |
169 | If you say yes to this option, support will be included for the Intel | 169 | If you say yes to this option, support will be included for the Intel |
170 | PIIX4 family of mainboard I2C interfaces. Specifically, the following | 170 | PIIX4 family of mainboard I2C interfaces. Specifically, the following |
171 | versions of the chipset are supported: | 171 | versions of the chipset are supported (note that Serverworks is part |
172 | of Broadcom): | ||
172 | Intel PIIX4 | 173 | Intel PIIX4 |
173 | Intel 440MX | 174 | Intel 440MX |
174 | Serverworks OSB4 | 175 | Serverworks OSB4 |
175 | Serverworks CSB5 | 176 | Serverworks CSB5 |
176 | Serverworks CSB6 | 177 | Serverworks CSB6 |
178 | Serverworks HT-1000 | ||
177 | SMSC Victory66 | 179 | SMSC Victory66 |
178 | 180 | ||
179 | This driver can also be built as a module. If so, the module | 181 | This driver can also be built as a module. If so, the module |
@@ -389,10 +391,11 @@ config SCx200_I2C_SDA | |||
389 | also be specified with a module parameter. | 391 | also be specified with a module parameter. |
390 | 392 | ||
391 | config SCx200_ACB | 393 | config SCx200_ACB |
392 | tristate "NatSemi SCx200 ACCESS.bus" | 394 | tristate "Geode ACCESS.bus support" |
393 | depends on I2C && PCI | 395 | depends on X86_32 && I2C && PCI |
394 | help | 396 | help |
395 | Enable the use of the ACCESS.bus controllers of a SCx200 processor. | 397 | Enable the use of the ACCESS.bus controllers on the Geode SCx200 and |
398 | SC1100 processors and the CS5535 and CS5536 Geode companion devices. | ||
396 | 399 | ||
397 | If you don't know what to do here, say N. | 400 | If you don't know what to do here, say N. |
398 | 401 | ||
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index 3eb47890db40..d3ef46aeeb3c 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c | |||
@@ -63,7 +63,6 @@ | |||
63 | #include <linux/i2c.h> | 63 | #include <linux/i2c.h> |
64 | #include <linux/init.h> | 64 | #include <linux/init.h> |
65 | #include <asm/io.h> | 65 | #include <asm/io.h> |
66 | #include <asm/semaphore.h> | ||
67 | 66 | ||
68 | 67 | ||
69 | /* ALI1535 SMBus address offsets */ | 68 | /* ALI1535 SMBus address offsets */ |
@@ -136,7 +135,6 @@ | |||
136 | 135 | ||
137 | static struct pci_driver ali1535_driver; | 136 | static struct pci_driver ali1535_driver; |
138 | static unsigned short ali1535_smba; | 137 | static unsigned short ali1535_smba; |
139 | static DECLARE_MUTEX(i2c_ali1535_sem); | ||
140 | 138 | ||
141 | /* Detect whether a ALI1535 can be found, and initialize it, where necessary. | 139 | /* Detect whether a ALI1535 can be found, and initialize it, where necessary. |
142 | Note the differences between kernels with the old PCI BIOS interface and | 140 | Note the differences between kernels with the old PCI BIOS interface and |
@@ -345,7 +343,6 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, | |||
345 | int timeout; | 343 | int timeout; |
346 | s32 result = 0; | 344 | s32 result = 0; |
347 | 345 | ||
348 | down(&i2c_ali1535_sem); | ||
349 | /* make sure SMBus is idle */ | 346 | /* make sure SMBus is idle */ |
350 | temp = inb_p(SMBHSTSTS); | 347 | temp = inb_p(SMBHSTSTS); |
351 | for (timeout = 0; | 348 | for (timeout = 0; |
@@ -460,7 +457,6 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, | |||
460 | break; | 457 | break; |
461 | } | 458 | } |
462 | EXIT: | 459 | EXIT: |
463 | up(&i2c_ali1535_sem); | ||
464 | return result; | 460 | return result; |
465 | } | 461 | } |
466 | 462 | ||
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c index 56c7d987590f..08e915730caf 100644 --- a/drivers/i2c/busses/i2c-amd756-s4882.c +++ b/drivers/i2c/busses/i2c-amd756-s4882.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
39 | #include <linux/init.h> | 39 | #include <linux/init.h> |
40 | #include <linux/i2c.h> | 40 | #include <linux/i2c.h> |
41 | #include <linux/mutex.h> | ||
41 | 42 | ||
42 | extern struct i2c_adapter amd756_smbus; | 43 | extern struct i2c_adapter amd756_smbus; |
43 | 44 | ||
@@ -45,7 +46,7 @@ static struct i2c_adapter *s4882_adapter; | |||
45 | static struct i2c_algorithm *s4882_algo; | 46 | static struct i2c_algorithm *s4882_algo; |
46 | 47 | ||
47 | /* Wrapper access functions for multiplexed SMBus */ | 48 | /* Wrapper access functions for multiplexed SMBus */ |
48 | static struct semaphore amd756_lock; | 49 | static DEFINE_MUTEX(amd756_lock); |
49 | 50 | ||
50 | static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr, | 51 | static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr, |
51 | unsigned short flags, char read_write, | 52 | unsigned short flags, char read_write, |
@@ -59,12 +60,12 @@ static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr, | |||
59 | || addr == 0x18) | 60 | || addr == 0x18) |
60 | return -1; | 61 | return -1; |
61 | 62 | ||
62 | down(&amd756_lock); | 63 | mutex_lock(&amd756_lock); |
63 | 64 | ||
64 | error = amd756_smbus.algo->smbus_xfer(adap, addr, flags, read_write, | 65 | error = amd756_smbus.algo->smbus_xfer(adap, addr, flags, read_write, |
65 | command, size, data); | 66 | command, size, data); |
66 | 67 | ||
67 | up(&amd756_lock); | 68 | mutex_unlock(&amd756_lock); |
68 | 69 | ||
69 | return error; | 70 | return error; |
70 | } | 71 | } |
@@ -87,7 +88,7 @@ static inline s32 amd756_access_channel(struct i2c_adapter * adap, u16 addr, | |||
87 | if (addr != 0x4c && (addr & 0xfc) != 0x50 && (addr & 0xfc) != 0x30) | 88 | if (addr != 0x4c && (addr & 0xfc) != 0x50 && (addr & 0xfc) != 0x30) |
88 | return -1; | 89 | return -1; |
89 | 90 | ||
90 | down(&amd756_lock); | 91 | mutex_lock(&amd756_lock); |
91 | 92 | ||
92 | if (last_channels != channels) { | 93 | if (last_channels != channels) { |
93 | union i2c_smbus_data mplxdata; | 94 | union i2c_smbus_data mplxdata; |
@@ -105,7 +106,7 @@ static inline s32 amd756_access_channel(struct i2c_adapter * adap, u16 addr, | |||
105 | command, size, data); | 106 | command, size, data); |
106 | 107 | ||
107 | UNLOCK: | 108 | UNLOCK: |
108 | up(&amd756_lock); | 109 | mutex_unlock(&amd756_lock); |
109 | return error; | 110 | return error; |
110 | } | 111 | } |
111 | 112 | ||
@@ -166,8 +167,6 @@ static int __init amd756_s4882_init(void) | |||
166 | } | 167 | } |
167 | 168 | ||
168 | printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n"); | 169 | printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n"); |
169 | init_MUTEX(&amd756_lock); | ||
170 | |||
171 | /* Define the 5 virtual adapters and algorithms structures */ | 170 | /* Define the 5 virtual adapters and algorithms structures */ |
172 | if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter), | 171 | if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter), |
173 | GFP_KERNEL))) { | 172 | GFP_KERNEL))) { |
diff --git a/drivers/i2c/busses/i2c-frodo.c b/drivers/i2c/busses/i2c-frodo.c deleted file mode 100644 index b6f52f5a4138..000000000000 --- a/drivers/i2c/busses/i2c-frodo.c +++ /dev/null | |||
@@ -1,85 +0,0 @@ | |||
1 | |||
2 | /* | ||
3 | * linux/drivers/i2c/i2c-frodo.c | ||
4 | * | ||
5 | * Author: Abraham van der Merwe <abraham@2d3d.co.za> | ||
6 | * | ||
7 | * An I2C adapter driver for the 2d3D, Inc. StrongARM SA-1110 | ||
8 | * Development board (Frodo). | ||
9 | * | ||
10 | * This source code is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * version 2 as published by the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #include <linux/module.h> | ||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/delay.h> | ||
19 | #include <linux/i2c.h> | ||
20 | #include <linux/i2c-algo-bit.h> | ||
21 | #include <asm/hardware.h> | ||
22 | |||
23 | |||
24 | static void frodo_setsda (void *data,int state) | ||
25 | { | ||
26 | if (state) | ||
27 | FRODO_CPLD_I2C |= FRODO_I2C_SDA_OUT; | ||
28 | else | ||
29 | FRODO_CPLD_I2C &= ~FRODO_I2C_SDA_OUT; | ||
30 | } | ||
31 | |||
32 | static void frodo_setscl (void *data,int state) | ||
33 | { | ||
34 | if (state) | ||
35 | FRODO_CPLD_I2C |= FRODO_I2C_SCL_OUT; | ||
36 | else | ||
37 | FRODO_CPLD_I2C &= ~FRODO_I2C_SCL_OUT; | ||
38 | } | ||
39 | |||
40 | static int frodo_getsda (void *data) | ||
41 | { | ||
42 | return ((FRODO_CPLD_I2C & FRODO_I2C_SDA_IN) != 0); | ||
43 | } | ||
44 | |||
45 | static int frodo_getscl (void *data) | ||
46 | { | ||
47 | return ((FRODO_CPLD_I2C & FRODO_I2C_SCL_IN) != 0); | ||
48 | } | ||
49 | |||
50 | static struct i2c_algo_bit_data bit_frodo_data = { | ||
51 | .setsda = frodo_setsda, | ||
52 | .setscl = frodo_setscl, | ||
53 | .getsda = frodo_getsda, | ||
54 | .getscl = frodo_getscl, | ||
55 | .udelay = 80, | ||
56 | .mdelay = 80, | ||
57 | .timeout = HZ | ||
58 | }; | ||
59 | |||
60 | static struct i2c_adapter frodo_ops = { | ||
61 | .owner = THIS_MODULE, | ||
62 | .id = I2C_HW_B_FRODO, | ||
63 | .algo_data = &bit_frodo_data, | ||
64 | .dev = { | ||
65 | .name = "Frodo adapter driver", | ||
66 | }, | ||
67 | }; | ||
68 | |||
69 | static int __init i2c_frodo_init (void) | ||
70 | { | ||
71 | return i2c_bit_add_bus(&frodo_ops); | ||
72 | } | ||
73 | |||
74 | static void __exit i2c_frodo_exit (void) | ||
75 | { | ||
76 | i2c_bit_del_bus(&frodo_ops); | ||
77 | } | ||
78 | |||
79 | MODULE_AUTHOR ("Abraham van der Merwe <abraham@2d3d.co.za>"); | ||
80 | MODULE_DESCRIPTION ("I2C-Bus adapter routines for Frodo"); | ||
81 | MODULE_LICENSE ("GPL"); | ||
82 | |||
83 | module_init (i2c_frodo_init); | ||
84 | module_exit (i2c_frodo_exit); | ||
85 | |||
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index 4344ae6b1fcb..c3e1d3e888d7 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c | |||
@@ -125,7 +125,7 @@ int i2c_isa_del_driver(struct i2c_driver *driver) | |||
125 | 125 | ||
126 | static int __init i2c_isa_init(void) | 126 | static int __init i2c_isa_init(void) |
127 | { | 127 | { |
128 | init_MUTEX(&isa_adapter.clist_lock); | 128 | mutex_init(&isa_adapter.clist_lock); |
129 | INIT_LIST_HEAD(&isa_adapter.clients); | 129 | INIT_LIST_HEAD(&isa_adapter.clients); |
130 | 130 | ||
131 | isa_adapter.nr = ANY_I2C_ISA_BUS; | 131 | isa_adapter.nr = ANY_I2C_ISA_BUS; |
diff --git a/drivers/i2c/busses/i2c-ite.c b/drivers/i2c/busses/i2c-ite.c index 5f5d2944808b..d82e6dae8407 100644 --- a/drivers/i2c/busses/i2c-ite.c +++ b/drivers/i2c/busses/i2c-ite.c | |||
@@ -200,9 +200,7 @@ static struct i2c_adapter iic_ite_ops = { | |||
200 | .owner = THIS_MODULE, | 200 | .owner = THIS_MODULE, |
201 | .id = I2C_HW_I_IIC, | 201 | .id = I2C_HW_I_IIC, |
202 | .algo_data = &iic_ite_data, | 202 | .algo_data = &iic_ite_data, |
203 | .dev = { | 203 | .name = "ITE IIC adapter", |
204 | .name = "ITE IIC adapter", | ||
205 | }, | ||
206 | }; | 204 | }; |
207 | 205 | ||
208 | /* Called when the module is loaded. This function starts the | 206 | /* Called when the module is loaded. This function starts the |
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c index e422d8b2d4d6..2ed07112d683 100644 --- a/drivers/i2c/busses/i2c-ixp4xx.c +++ b/drivers/i2c/busses/i2c-ixp4xx.c | |||
@@ -126,6 +126,7 @@ static int ixp4xx_i2c_probe(struct platform_device *plat_dev) | |||
126 | drv_data->algo_data.timeout = 100; | 126 | drv_data->algo_data.timeout = 100; |
127 | 127 | ||
128 | drv_data->adapter.id = I2C_HW_B_IXP4XX; | 128 | drv_data->adapter.id = I2C_HW_B_IXP4XX; |
129 | drv_data->adapter.class = I2C_CLASS_HWMON; | ||
129 | strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name, | 130 | strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name, |
130 | I2C_NAME_SIZE); | 131 | I2C_NAME_SIZE); |
131 | drv_data->adapter.algo_data = &drv_data->algo_data; | 132 | drv_data->adapter.algo_data = &drv_data->algo_data; |
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 692f47345481..d9c7c00e71f9 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c | |||
@@ -22,7 +22,7 @@ | |||
22 | /* | 22 | /* |
23 | Supports: | 23 | Supports: |
24 | Intel PIIX4, 440MX | 24 | Intel PIIX4, 440MX |
25 | Serverworks OSB4, CSB5, CSB6 | 25 | Serverworks OSB4, CSB5, CSB6, HT-1000 |
26 | SMSC Victory66 | 26 | SMSC Victory66 |
27 | 27 | ||
28 | Note: we assume there can only be one device, with one SMBus interface. | 28 | Note: we assume there can only be one device, with one SMBus interface. |
@@ -419,6 +419,8 @@ static struct pci_device_id piix4_ids[] = { | |||
419 | .driver_data = 0 }, | 419 | .driver_data = 0 }, |
420 | { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6), | 420 | { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6), |
421 | .driver_data = 0 }, | 421 | .driver_data = 0 }, |
422 | { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000SB), | ||
423 | .driver_data = 0 }, | ||
422 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_3), | 424 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_3), |
423 | .driver_data = 3 }, | 425 | .driver_data = 3 }, |
424 | { PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_3), | 426 | { PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_3), |
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 7579f4b256a8..5155010b455e 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c | |||
@@ -647,7 +647,7 @@ static inline void i2c_pxa_start_message(struct pxa_i2c *i2c) | |||
647 | } | 647 | } |
648 | 648 | ||
649 | /* | 649 | /* |
650 | * We are protected by the adapter bus semaphore. | 650 | * We are protected by the adapter bus mutex. |
651 | */ | 651 | */ |
652 | static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num) | 652 | static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num) |
653 | { | 653 | { |
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index d3478e084522..8bd305e47f0d 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c | |||
@@ -1,27 +1,26 @@ | |||
1 | /* linux/drivers/i2c/scx200_acb.c | 1 | /* |
2 | |||
3 | Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com> | 2 | Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com> |
4 | 3 | ||
5 | National Semiconductor SCx200 ACCESS.bus support | 4 | National Semiconductor SCx200 ACCESS.bus support |
6 | 5 | Also supports the AMD CS5535 and AMD CS5536 | |
6 | |||
7 | Based on i2c-keywest.c which is: | 7 | Based on i2c-keywest.c which is: |
8 | Copyright (c) 2001 Benjamin Herrenschmidt <benh@kernel.crashing.org> | 8 | Copyright (c) 2001 Benjamin Herrenschmidt <benh@kernel.crashing.org> |
9 | Copyright (c) 2000 Philip Edelbrock <phil@stimpy.netroedge.com> | 9 | Copyright (c) 2000 Philip Edelbrock <phil@stimpy.netroedge.com> |
10 | 10 | ||
11 | This program is free software; you can redistribute it and/or | 11 | This program is free software; you can redistribute it and/or |
12 | modify it under the terms of the GNU General Public License as | 12 | modify it under the terms of the GNU General Public License as |
13 | published by the Free Software Foundation; either version 2 of the | 13 | published by the Free Software Foundation; either version 2 of the |
14 | License, or (at your option) any later version. | 14 | License, or (at your option) any later version. |
15 | 15 | ||
16 | This program is distributed in the hope that it will be useful, | 16 | This program is distributed in the hope that it will be useful, |
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 | General Public License for more details. | 19 | General Public License for more details. |
20 | 20 | ||
21 | You should have received a copy of the GNU General Public License | 21 | You should have received a copy of the GNU General Public License |
22 | along with this program; if not, write to the Free Software | 22 | along with this program; if not, write to the Free Software |
23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | |||
25 | */ | 24 | */ |
26 | 25 | ||
27 | #include <linux/module.h> | 26 | #include <linux/module.h> |
@@ -32,7 +31,9 @@ | |||
32 | #include <linux/smp_lock.h> | 31 | #include <linux/smp_lock.h> |
33 | #include <linux/pci.h> | 32 | #include <linux/pci.h> |
34 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
34 | #include <linux/mutex.h> | ||
35 | #include <asm/io.h> | 35 | #include <asm/io.h> |
36 | #include <asm/msr.h> | ||
36 | 37 | ||
37 | #include <linux/scx200.h> | 38 | #include <linux/scx200.h> |
38 | 39 | ||
@@ -47,16 +48,7 @@ static int base[MAX_DEVICES] = { 0x820, 0x840 }; | |||
47 | module_param_array(base, int, NULL, 0); | 48 | module_param_array(base, int, NULL, 0); |
48 | MODULE_PARM_DESC(base, "Base addresses for the ACCESS.bus controllers"); | 49 | MODULE_PARM_DESC(base, "Base addresses for the ACCESS.bus controllers"); |
49 | 50 | ||
50 | #ifdef DEBUG | 51 | #define POLL_TIMEOUT (HZ/5) |
51 | #define DBG(x...) printk(KERN_DEBUG NAME ": " x) | ||
52 | #else | ||
53 | #define DBG(x...) | ||
54 | #endif | ||
55 | |||
56 | /* The hardware supports interrupt driven mode too, but I haven't | ||
57 | implemented that. */ | ||
58 | #define POLLED_MODE 1 | ||
59 | #define POLL_TIMEOUT (HZ) | ||
60 | 52 | ||
61 | enum scx200_acb_state { | 53 | enum scx200_acb_state { |
62 | state_idle, | 54 | state_idle, |
@@ -79,12 +71,11 @@ static const char *scx200_acb_state_name[] = { | |||
79 | }; | 71 | }; |
80 | 72 | ||
81 | /* Physical interface */ | 73 | /* Physical interface */ |
82 | struct scx200_acb_iface | 74 | struct scx200_acb_iface { |
83 | { | ||
84 | struct scx200_acb_iface *next; | 75 | struct scx200_acb_iface *next; |
85 | struct i2c_adapter adapter; | 76 | struct i2c_adapter adapter; |
86 | unsigned base; | 77 | unsigned base; |
87 | struct semaphore sem; | 78 | struct mutex mutex; |
88 | 79 | ||
89 | /* State machine data */ | 80 | /* State machine data */ |
90 | enum scx200_acb_state state; | 81 | enum scx200_acb_state state; |
@@ -100,7 +91,7 @@ struct scx200_acb_iface | |||
100 | #define ACBSDA (iface->base + 0) | 91 | #define ACBSDA (iface->base + 0) |
101 | #define ACBST (iface->base + 1) | 92 | #define ACBST (iface->base + 1) |
102 | #define ACBST_SDAST 0x40 /* SDA Status */ | 93 | #define ACBST_SDAST 0x40 /* SDA Status */ |
103 | #define ACBST_BER 0x20 | 94 | #define ACBST_BER 0x20 |
104 | #define ACBST_NEGACK 0x10 /* Negative Acknowledge */ | 95 | #define ACBST_NEGACK 0x10 /* Negative Acknowledge */ |
105 | #define ACBST_STASTR 0x08 /* Stall After Start */ | 96 | #define ACBST_STASTR 0x08 /* Stall After Start */ |
106 | #define ACBST_MASTER 0x02 | 97 | #define ACBST_MASTER 0x02 |
@@ -109,9 +100,9 @@ struct scx200_acb_iface | |||
109 | #define ACBCTL1 (iface->base + 3) | 100 | #define ACBCTL1 (iface->base + 3) |
110 | #define ACBCTL1_STASTRE 0x80 | 101 | #define ACBCTL1_STASTRE 0x80 |
111 | #define ACBCTL1_NMINTE 0x40 | 102 | #define ACBCTL1_NMINTE 0x40 |
112 | #define ACBCTL1_ACK 0x10 | 103 | #define ACBCTL1_ACK 0x10 |
113 | #define ACBCTL1_STOP 0x02 | 104 | #define ACBCTL1_STOP 0x02 |
114 | #define ACBCTL1_START 0x01 | 105 | #define ACBCTL1_START 0x01 |
115 | #define ACBADDR (iface->base + 4) | 106 | #define ACBADDR (iface->base + 4) |
116 | #define ACBCTL2 (iface->base + 5) | 107 | #define ACBCTL2 (iface->base + 5) |
117 | #define ACBCTL2_ENABLE 0x01 | 108 | #define ACBCTL2_ENABLE 0x01 |
@@ -122,8 +113,8 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) | |||
122 | { | 113 | { |
123 | const char *errmsg; | 114 | const char *errmsg; |
124 | 115 | ||
125 | DBG("state %s, status = 0x%02x\n", | 116 | dev_dbg(&iface->adapter.dev, "state %s, status = 0x%02x\n", |
126 | scx200_acb_state_name[iface->state], status); | 117 | scx200_acb_state_name[iface->state], status); |
127 | 118 | ||
128 | if (status & ACBST_BER) { | 119 | if (status & ACBST_BER) { |
129 | errmsg = "bus error"; | 120 | errmsg = "bus error"; |
@@ -133,8 +124,17 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) | |||
133 | errmsg = "not master"; | 124 | errmsg = "not master"; |
134 | goto error; | 125 | goto error; |
135 | } | 126 | } |
136 | if (status & ACBST_NEGACK) | 127 | if (status & ACBST_NEGACK) { |
137 | goto negack; | 128 | dev_dbg(&iface->adapter.dev, "negative ack in state %s\n", |
129 | scx200_acb_state_name[iface->state]); | ||
130 | |||
131 | iface->state = state_idle; | ||
132 | iface->result = -ENXIO; | ||
133 | |||
134 | outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); | ||
135 | outb(ACBST_STASTR | ACBST_NEGACK, ACBST); | ||
136 | return; | ||
137 | } | ||
138 | 138 | ||
139 | switch (iface->state) { | 139 | switch (iface->state) { |
140 | case state_idle: | 140 | case state_idle: |
@@ -160,10 +160,10 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) | |||
160 | case state_repeat_start: | 160 | case state_repeat_start: |
161 | outb(inb(ACBCTL1) | ACBCTL1_START, ACBCTL1); | 161 | outb(inb(ACBCTL1) | ACBCTL1_START, ACBCTL1); |
162 | /* fallthrough */ | 162 | /* fallthrough */ |
163 | 163 | ||
164 | case state_quick: | 164 | case state_quick: |
165 | if (iface->address_byte & 1) { | 165 | if (iface->address_byte & 1) { |
166 | if (iface->len == 1) | 166 | if (iface->len == 1) |
167 | outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1); | 167 | outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1); |
168 | else | 168 | else |
169 | outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1); | 169 | outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1); |
@@ -202,26 +202,15 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) | |||
202 | outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); | 202 | outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); |
203 | break; | 203 | break; |
204 | } | 204 | } |
205 | 205 | ||
206 | outb(*iface->ptr++, ACBSDA); | 206 | outb(*iface->ptr++, ACBSDA); |
207 | --iface->len; | 207 | --iface->len; |
208 | 208 | ||
209 | break; | 209 | break; |
210 | } | 210 | } |
211 | 211 | ||
212 | return; | 212 | return; |
213 | 213 | ||
214 | negack: | ||
215 | DBG("negative acknowledge in state %s\n", | ||
216 | scx200_acb_state_name[iface->state]); | ||
217 | |||
218 | iface->state = state_idle; | ||
219 | iface->result = -ENXIO; | ||
220 | |||
221 | outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); | ||
222 | outb(ACBST_STASTR | ACBST_NEGACK, ACBST); | ||
223 | return; | ||
224 | |||
225 | error: | 214 | error: |
226 | dev_err(&iface->adapter.dev, "%s in state %s\n", errmsg, | 215 | dev_err(&iface->adapter.dev, "%s in state %s\n", errmsg, |
227 | scx200_acb_state_name[iface->state]); | 216 | scx200_acb_state_name[iface->state]); |
@@ -231,20 +220,9 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) | |||
231 | iface->needs_reset = 1; | 220 | iface->needs_reset = 1; |
232 | } | 221 | } |
233 | 222 | ||
234 | static void scx200_acb_timeout(struct scx200_acb_iface *iface) | ||
235 | { | ||
236 | dev_err(&iface->adapter.dev, "timeout in state %s\n", | ||
237 | scx200_acb_state_name[iface->state]); | ||
238 | |||
239 | iface->state = state_idle; | ||
240 | iface->result = -EIO; | ||
241 | iface->needs_reset = 1; | ||
242 | } | ||
243 | |||
244 | #ifdef POLLED_MODE | ||
245 | static void scx200_acb_poll(struct scx200_acb_iface *iface) | 223 | static void scx200_acb_poll(struct scx200_acb_iface *iface) |
246 | { | 224 | { |
247 | u8 status = 0; | 225 | u8 status; |
248 | unsigned long timeout; | 226 | unsigned long timeout; |
249 | 227 | ||
250 | timeout = jiffies + POLL_TIMEOUT; | 228 | timeout = jiffies + POLL_TIMEOUT; |
@@ -254,17 +232,21 @@ static void scx200_acb_poll(struct scx200_acb_iface *iface) | |||
254 | scx200_acb_machine(iface, status); | 232 | scx200_acb_machine(iface, status); |
255 | return; | 233 | return; |
256 | } | 234 | } |
257 | msleep(10); | 235 | yield(); |
258 | } | 236 | } |
259 | 237 | ||
260 | scx200_acb_timeout(iface); | 238 | dev_err(&iface->adapter.dev, "timeout in state %s\n", |
239 | scx200_acb_state_name[iface->state]); | ||
240 | |||
241 | iface->state = state_idle; | ||
242 | iface->result = -EIO; | ||
243 | iface->needs_reset = 1; | ||
261 | } | 244 | } |
262 | #endif /* POLLED_MODE */ | ||
263 | 245 | ||
264 | static void scx200_acb_reset(struct scx200_acb_iface *iface) | 246 | static void scx200_acb_reset(struct scx200_acb_iface *iface) |
265 | { | 247 | { |
266 | /* Disable the ACCESS.bus device and Configure the SCL | 248 | /* Disable the ACCESS.bus device and Configure the SCL |
267 | frequency: 16 clock cycles */ | 249 | frequency: 16 clock cycles */ |
268 | outb(0x70, ACBCTL2); | 250 | outb(0x70, ACBCTL2); |
269 | /* Polling mode */ | 251 | /* Polling mode */ |
270 | outb(0, ACBCTL1); | 252 | outb(0, ACBCTL1); |
@@ -283,9 +265,9 @@ static void scx200_acb_reset(struct scx200_acb_iface *iface) | |||
283 | } | 265 | } |
284 | 266 | ||
285 | static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter, | 267 | static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter, |
286 | u16 address, unsigned short flags, | 268 | u16 address, unsigned short flags, |
287 | char rw, u8 command, int size, | 269 | char rw, u8 command, int size, |
288 | union i2c_smbus_data *data) | 270 | union i2c_smbus_data *data) |
289 | { | 271 | { |
290 | struct scx200_acb_iface *iface = i2c_get_adapdata(adapter); | 272 | struct scx200_acb_iface *iface = i2c_get_adapdata(adapter); |
291 | int len; | 273 | int len; |
@@ -295,53 +277,47 @@ static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter, | |||
295 | 277 | ||
296 | switch (size) { | 278 | switch (size) { |
297 | case I2C_SMBUS_QUICK: | 279 | case I2C_SMBUS_QUICK: |
298 | len = 0; | 280 | len = 0; |
299 | buffer = NULL; | 281 | buffer = NULL; |
300 | break; | 282 | break; |
283 | |||
301 | case I2C_SMBUS_BYTE: | 284 | case I2C_SMBUS_BYTE: |
302 | if (rw == I2C_SMBUS_READ) { | 285 | len = 1; |
303 | len = 1; | 286 | buffer = rw ? &data->byte : &command; |
304 | buffer = &data->byte; | 287 | break; |
305 | } else { | 288 | |
306 | len = 1; | ||
307 | buffer = &command; | ||
308 | } | ||
309 | break; | ||
310 | case I2C_SMBUS_BYTE_DATA: | 289 | case I2C_SMBUS_BYTE_DATA: |
311 | len = 1; | 290 | len = 1; |
312 | buffer = &data->byte; | 291 | buffer = &data->byte; |
313 | break; | 292 | break; |
293 | |||
314 | case I2C_SMBUS_WORD_DATA: | 294 | case I2C_SMBUS_WORD_DATA: |
315 | len = 2; | 295 | len = 2; |
316 | cur_word = cpu_to_le16(data->word); | 296 | cur_word = cpu_to_le16(data->word); |
317 | buffer = (u8 *)&cur_word; | 297 | buffer = (u8 *)&cur_word; |
318 | break; | 298 | break; |
299 | |||
319 | case I2C_SMBUS_BLOCK_DATA: | 300 | case I2C_SMBUS_BLOCK_DATA: |
320 | len = data->block[0]; | 301 | len = data->block[0]; |
321 | buffer = &data->block[1]; | 302 | buffer = &data->block[1]; |
322 | break; | 303 | break; |
304 | |||
323 | default: | 305 | default: |
324 | return -EINVAL; | 306 | return -EINVAL; |
325 | } | 307 | } |
326 | 308 | ||
327 | DBG("size=%d, address=0x%x, command=0x%x, len=%d, read=%d\n", | 309 | dev_dbg(&adapter->dev, |
328 | size, address, command, len, rw == I2C_SMBUS_READ); | 310 | "size=%d, address=0x%x, command=0x%x, len=%d, read=%d\n", |
311 | size, address, command, len, rw); | ||
329 | 312 | ||
330 | if (!len && rw == I2C_SMBUS_READ) { | 313 | if (!len && rw == I2C_SMBUS_READ) { |
331 | dev_warn(&adapter->dev, "zero length read\n"); | 314 | dev_dbg(&adapter->dev, "zero length read\n"); |
332 | return -EINVAL; | 315 | return -EINVAL; |
333 | } | 316 | } |
334 | 317 | ||
335 | if (len && !buffer) { | 318 | mutex_lock(&iface->mutex); |
336 | dev_warn(&adapter->dev, "nonzero length but no buffer\n"); | ||
337 | return -EFAULT; | ||
338 | } | ||
339 | |||
340 | down(&iface->sem); | ||
341 | 319 | ||
342 | iface->address_byte = address<<1; | 320 | iface->address_byte = (address << 1) | rw; |
343 | if (rw == I2C_SMBUS_READ) | ||
344 | iface->address_byte |= 1; | ||
345 | iface->command = command; | 321 | iface->command = command; |
346 | iface->ptr = buffer; | 322 | iface->ptr = buffer; |
347 | iface->len = len; | 323 | iface->len = len; |
@@ -355,25 +331,21 @@ static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter, | |||
355 | else | 331 | else |
356 | iface->state = state_address; | 332 | iface->state = state_address; |
357 | 333 | ||
358 | #ifdef POLLED_MODE | ||
359 | while (iface->state != state_idle) | 334 | while (iface->state != state_idle) |
360 | scx200_acb_poll(iface); | 335 | scx200_acb_poll(iface); |
361 | #else /* POLLED_MODE */ | ||
362 | #error Interrupt driven mode not implemented | ||
363 | #endif /* POLLED_MODE */ | ||
364 | 336 | ||
365 | if (iface->needs_reset) | 337 | if (iface->needs_reset) |
366 | scx200_acb_reset(iface); | 338 | scx200_acb_reset(iface); |
367 | 339 | ||
368 | rc = iface->result; | 340 | rc = iface->result; |
369 | 341 | ||
370 | up(&iface->sem); | 342 | mutex_unlock(&iface->mutex); |
371 | 343 | ||
372 | if (rc == 0 && size == I2C_SMBUS_WORD_DATA && rw == I2C_SMBUS_READ) | 344 | if (rc == 0 && size == I2C_SMBUS_WORD_DATA && rw == I2C_SMBUS_READ) |
373 | data->word = le16_to_cpu(cur_word); | 345 | data->word = le16_to_cpu(cur_word); |
374 | 346 | ||
375 | #ifdef DEBUG | 347 | #ifdef DEBUG |
376 | DBG(": transfer done, result: %d", rc); | 348 | dev_dbg(&adapter->dev, "transfer done, result: %d", rc); |
377 | if (buffer) { | 349 | if (buffer) { |
378 | int i; | 350 | int i; |
379 | printk(" data:"); | 351 | printk(" data:"); |
@@ -400,17 +372,18 @@ static struct i2c_algorithm scx200_acb_algorithm = { | |||
400 | }; | 372 | }; |
401 | 373 | ||
402 | static struct scx200_acb_iface *scx200_acb_list; | 374 | static struct scx200_acb_iface *scx200_acb_list; |
375 | static DECLARE_MUTEX(scx200_acb_list_mutex); | ||
403 | 376 | ||
404 | static int scx200_acb_probe(struct scx200_acb_iface *iface) | 377 | static int scx200_acb_probe(struct scx200_acb_iface *iface) |
405 | { | 378 | { |
406 | u8 val; | 379 | u8 val; |
407 | 380 | ||
408 | /* Disable the ACCESS.bus device and Configure the SCL | 381 | /* Disable the ACCESS.bus device and Configure the SCL |
409 | frequency: 16 clock cycles */ | 382 | frequency: 16 clock cycles */ |
410 | outb(0x70, ACBCTL2); | 383 | outb(0x70, ACBCTL2); |
411 | 384 | ||
412 | if (inb(ACBCTL2) != 0x70) { | 385 | if (inb(ACBCTL2) != 0x70) { |
413 | DBG("ACBCTL2 readback failed\n"); | 386 | pr_debug(NAME ": ACBCTL2 readback failed\n"); |
414 | return -ENXIO; | 387 | return -ENXIO; |
415 | } | 388 | } |
416 | 389 | ||
@@ -418,7 +391,8 @@ static int scx200_acb_probe(struct scx200_acb_iface *iface) | |||
418 | 391 | ||
419 | val = inb(ACBCTL1); | 392 | val = inb(ACBCTL1); |
420 | if (val) { | 393 | if (val) { |
421 | DBG("disabled, but ACBCTL1=0x%02x\n", val); | 394 | pr_debug(NAME ": disabled, but ACBCTL1=0x%02x\n", |
395 | val); | ||
422 | return -ENXIO; | 396 | return -ENXIO; |
423 | } | 397 | } |
424 | 398 | ||
@@ -428,18 +402,19 @@ static int scx200_acb_probe(struct scx200_acb_iface *iface) | |||
428 | 402 | ||
429 | val = inb(ACBCTL1); | 403 | val = inb(ACBCTL1); |
430 | if ((val & ACBCTL1_NMINTE) != ACBCTL1_NMINTE) { | 404 | if ((val & ACBCTL1_NMINTE) != ACBCTL1_NMINTE) { |
431 | DBG("enabled, but NMINTE won't be set, ACBCTL1=0x%02x\n", val); | 405 | pr_debug(NAME ": enabled, but NMINTE won't be set, " |
406 | "ACBCTL1=0x%02x\n", val); | ||
432 | return -ENXIO; | 407 | return -ENXIO; |
433 | } | 408 | } |
434 | 409 | ||
435 | return 0; | 410 | return 0; |
436 | } | 411 | } |
437 | 412 | ||
438 | static int __init scx200_acb_create(int base, int index) | 413 | static int __init scx200_acb_create(const char *text, int base, int index) |
439 | { | 414 | { |
440 | struct scx200_acb_iface *iface; | 415 | struct scx200_acb_iface *iface; |
441 | struct i2c_adapter *adapter; | 416 | struct i2c_adapter *adapter; |
442 | int rc = 0; | 417 | int rc; |
443 | char description[64]; | 418 | char description[64]; |
444 | 419 | ||
445 | iface = kzalloc(sizeof(*iface), GFP_KERNEL); | 420 | iface = kzalloc(sizeof(*iface), GFP_KERNEL); |
@@ -451,50 +426,51 @@ static int __init scx200_acb_create(int base, int index) | |||
451 | 426 | ||
452 | adapter = &iface->adapter; | 427 | adapter = &iface->adapter; |
453 | i2c_set_adapdata(adapter, iface); | 428 | i2c_set_adapdata(adapter, iface); |
454 | snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index); | 429 | snprintf(adapter->name, I2C_NAME_SIZE, "%s ACB%d", text, index); |
455 | adapter->owner = THIS_MODULE; | 430 | adapter->owner = THIS_MODULE; |
456 | adapter->id = I2C_HW_SMBUS_SCX200; | 431 | adapter->id = I2C_HW_SMBUS_SCX200; |
457 | adapter->algo = &scx200_acb_algorithm; | 432 | adapter->algo = &scx200_acb_algorithm; |
458 | adapter->class = I2C_CLASS_HWMON; | 433 | adapter->class = I2C_CLASS_HWMON; |
459 | 434 | ||
460 | init_MUTEX(&iface->sem); | 435 | mutex_init(&iface->mutex); |
436 | |||
437 | snprintf(description, sizeof(description), "%s ACCESS.bus [%s]", | ||
438 | text, adapter->name); | ||
461 | 439 | ||
462 | snprintf(description, sizeof(description), "NatSemi SCx200 ACCESS.bus [%s]", adapter->name); | ||
463 | if (request_region(base, 8, description) == 0) { | 440 | if (request_region(base, 8, description) == 0) { |
464 | dev_err(&adapter->dev, "can't allocate io 0x%x-0x%x\n", | 441 | printk(KERN_ERR NAME ": can't allocate io 0x%x-0x%x\n", |
465 | base, base + 8-1); | 442 | base, base + 8-1); |
466 | rc = -EBUSY; | 443 | rc = -EBUSY; |
467 | goto errout; | 444 | goto errout_free; |
468 | } | 445 | } |
469 | iface->base = base; | 446 | iface->base = base; |
470 | 447 | ||
471 | rc = scx200_acb_probe(iface); | 448 | rc = scx200_acb_probe(iface); |
472 | if (rc) { | 449 | if (rc) { |
473 | dev_warn(&adapter->dev, "probe failed\n"); | 450 | printk(KERN_WARNING NAME ": probe failed\n"); |
474 | goto errout; | 451 | goto errout_release; |
475 | } | 452 | } |
476 | 453 | ||
477 | scx200_acb_reset(iface); | 454 | scx200_acb_reset(iface); |
478 | 455 | ||
479 | if (i2c_add_adapter(adapter) < 0) { | 456 | if (i2c_add_adapter(adapter) < 0) { |
480 | dev_err(&adapter->dev, "failed to register\n"); | 457 | printk(KERN_ERR NAME ": failed to register\n"); |
481 | rc = -ENODEV; | 458 | rc = -ENODEV; |
482 | goto errout; | 459 | goto errout_release; |
483 | } | 460 | } |
484 | 461 | ||
485 | lock_kernel(); | 462 | down(&scx200_acb_list_mutex); |
486 | iface->next = scx200_acb_list; | 463 | iface->next = scx200_acb_list; |
487 | scx200_acb_list = iface; | 464 | scx200_acb_list = iface; |
488 | unlock_kernel(); | 465 | up(&scx200_acb_list_mutex); |
489 | 466 | ||
490 | return 0; | 467 | return 0; |
491 | 468 | ||
469 | errout_release: | ||
470 | release_region(iface->base, 8); | ||
471 | errout_free: | ||
472 | kfree(iface); | ||
492 | errout: | 473 | errout: |
493 | if (iface) { | ||
494 | if (iface->base) | ||
495 | release_region(iface->base, 8); | ||
496 | kfree(iface); | ||
497 | } | ||
498 | return rc; | 474 | return rc; |
499 | } | 475 | } |
500 | 476 | ||
@@ -504,50 +480,69 @@ static struct pci_device_id scx200[] = { | |||
504 | { }, | 480 | { }, |
505 | }; | 481 | }; |
506 | 482 | ||
483 | static struct pci_device_id divil_pci[] = { | ||
484 | { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) }, | ||
485 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) }, | ||
486 | { } /* NULL entry */ | ||
487 | }; | ||
488 | |||
489 | #define MSR_LBAR_SMB 0x5140000B | ||
490 | |||
491 | static int scx200_add_cs553x(void) | ||
492 | { | ||
493 | u32 low, hi; | ||
494 | u32 smb_base; | ||
495 | |||
496 | /* Grab & reserve the SMB I/O range */ | ||
497 | rdmsr(MSR_LBAR_SMB, low, hi); | ||
498 | |||
499 | /* Check the IO mask and whether SMB is enabled */ | ||
500 | if (hi != 0x0000F001) { | ||
501 | printk(KERN_WARNING NAME ": SMBus not enabled\n"); | ||
502 | return -ENODEV; | ||
503 | } | ||
504 | |||
505 | /* SMBus IO size is 8 bytes */ | ||
506 | smb_base = low & 0x0000FFF8; | ||
507 | |||
508 | return scx200_acb_create("CS5535", smb_base, 0); | ||
509 | } | ||
510 | |||
507 | static int __init scx200_acb_init(void) | 511 | static int __init scx200_acb_init(void) |
508 | { | 512 | { |
509 | int i; | 513 | int i; |
510 | int rc; | 514 | int rc = -ENODEV; |
511 | 515 | ||
512 | pr_debug(NAME ": NatSemi SCx200 ACCESS.bus Driver\n"); | 516 | pr_debug(NAME ": NatSemi SCx200 ACCESS.bus Driver\n"); |
513 | 517 | ||
514 | /* Verify that this really is a SCx200 processor */ | 518 | /* Verify that this really is a SCx200 processor */ |
515 | if (pci_dev_present(scx200) == 0) | 519 | if (pci_dev_present(scx200)) { |
516 | return -ENODEV; | 520 | for (i = 0; i < MAX_DEVICES; ++i) { |
521 | if (base[i] > 0) | ||
522 | rc = scx200_acb_create("SCx200", base[i], i); | ||
523 | } | ||
524 | } else if (pci_dev_present(divil_pci)) | ||
525 | rc = scx200_add_cs553x(); | ||
517 | 526 | ||
518 | rc = -ENXIO; | ||
519 | for (i = 0; i < MAX_DEVICES; ++i) { | ||
520 | if (base[i] > 0) | ||
521 | rc = scx200_acb_create(base[i], i); | ||
522 | } | ||
523 | if (scx200_acb_list) | ||
524 | return 0; | ||
525 | return rc; | 527 | return rc; |
526 | } | 528 | } |
527 | 529 | ||
528 | static void __exit scx200_acb_cleanup(void) | 530 | static void __exit scx200_acb_cleanup(void) |
529 | { | 531 | { |
530 | struct scx200_acb_iface *iface; | 532 | struct scx200_acb_iface *iface; |
531 | lock_kernel(); | 533 | |
534 | down(&scx200_acb_list_mutex); | ||
532 | while ((iface = scx200_acb_list) != NULL) { | 535 | while ((iface = scx200_acb_list) != NULL) { |
533 | scx200_acb_list = iface->next; | 536 | scx200_acb_list = iface->next; |
534 | unlock_kernel(); | 537 | up(&scx200_acb_list_mutex); |
535 | 538 | ||
536 | i2c_del_adapter(&iface->adapter); | 539 | i2c_del_adapter(&iface->adapter); |
537 | release_region(iface->base, 8); | 540 | release_region(iface->base, 8); |
538 | kfree(iface); | 541 | kfree(iface); |
539 | lock_kernel(); | 542 | down(&scx200_acb_list_mutex); |
540 | } | 543 | } |
541 | unlock_kernel(); | 544 | up(&scx200_acb_list_mutex); |
542 | } | 545 | } |
543 | 546 | ||
544 | module_init(scx200_acb_init); | 547 | module_init(scx200_acb_init); |
545 | module_exit(scx200_acb_cleanup); | 548 | module_exit(scx200_acb_cleanup); |
546 | |||
547 | /* | ||
548 | Local variables: | ||
549 | compile-command: "make -k -C ../.. SUBDIRS=drivers/i2c modules" | ||
550 | c-basic-offset: 8 | ||
551 | End: | ||
552 | */ | ||
553 | |||
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index 0710b9da9d54..03d09ed5ec2c 100644 --- a/drivers/i2c/chips/ds1374.c +++ b/drivers/i2c/chips/ds1374.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
27 | #include <linux/rtc.h> | 27 | #include <linux/rtc.h> |
28 | #include <linux/bcd.h> | 28 | #include <linux/bcd.h> |
29 | #include <linux/mutex.h> | ||
29 | 30 | ||
30 | #define DS1374_REG_TOD0 0x00 | 31 | #define DS1374_REG_TOD0 0x00 |
31 | #define DS1374_REG_TOD1 0x01 | 32 | #define DS1374_REG_TOD1 0x01 |
@@ -41,7 +42,7 @@ | |||
41 | 42 | ||
42 | #define DS1374_DRV_NAME "ds1374" | 43 | #define DS1374_DRV_NAME "ds1374" |
43 | 44 | ||
44 | static DECLARE_MUTEX(ds1374_mutex); | 45 | static DEFINE_MUTEX(ds1374_mutex); |
45 | 46 | ||
46 | static struct i2c_driver ds1374_driver; | 47 | static struct i2c_driver ds1374_driver; |
47 | static struct i2c_client *save_client; | 48 | static struct i2c_client *save_client; |
@@ -114,7 +115,7 @@ ulong ds1374_get_rtc_time(void) | |||
114 | ulong t1, t2; | 115 | ulong t1, t2; |
115 | int limit = 10; /* arbitrary retry limit */ | 116 | int limit = 10; /* arbitrary retry limit */ |
116 | 117 | ||
117 | down(&ds1374_mutex); | 118 | mutex_lock(&ds1374_mutex); |
118 | 119 | ||
119 | /* | 120 | /* |
120 | * Since the reads are being performed one byte at a time using | 121 | * Since the reads are being performed one byte at a time using |
@@ -127,7 +128,7 @@ ulong ds1374_get_rtc_time(void) | |||
127 | t2 = ds1374_read_rtc(); | 128 | t2 = ds1374_read_rtc(); |
128 | } while (t1 != t2 && limit--); | 129 | } while (t1 != t2 && limit--); |
129 | 130 | ||
130 | up(&ds1374_mutex); | 131 | mutex_unlock(&ds1374_mutex); |
131 | 132 | ||
132 | if (t1 != t2) { | 133 | if (t1 != t2) { |
133 | dev_warn(&save_client->dev, | 134 | dev_warn(&save_client->dev, |
@@ -145,7 +146,7 @@ static void ds1374_set_tlet(ulong arg) | |||
145 | 146 | ||
146 | t1 = *(ulong *) arg; | 147 | t1 = *(ulong *) arg; |
147 | 148 | ||
148 | down(&ds1374_mutex); | 149 | mutex_lock(&ds1374_mutex); |
149 | 150 | ||
150 | /* | 151 | /* |
151 | * Since the writes are being performed one byte at a time using | 152 | * Since the writes are being performed one byte at a time using |
@@ -158,7 +159,7 @@ static void ds1374_set_tlet(ulong arg) | |||
158 | t2 = ds1374_read_rtc(); | 159 | t2 = ds1374_read_rtc(); |
159 | } while (t1 != t2 && limit--); | 160 | } while (t1 != t2 && limit--); |
160 | 161 | ||
161 | up(&ds1374_mutex); | 162 | mutex_unlock(&ds1374_mutex); |
162 | 163 | ||
163 | if (t1 != t2) | 164 | if (t1 != t2) |
164 | dev_warn(&save_client->dev, | 165 | dev_warn(&save_client->dev, |
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index 41116b7947f6..13c108269a6d 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/sched.h> | 33 | #include <linux/sched.h> |
34 | #include <linux/jiffies.h> | 34 | #include <linux/jiffies.h> |
35 | #include <linux/i2c.h> | 35 | #include <linux/i2c.h> |
36 | #include <linux/mutex.h> | ||
36 | 37 | ||
37 | /* Addresses to scan */ | 38 | /* Addresses to scan */ |
38 | static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54, | 39 | static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54, |
@@ -54,7 +55,7 @@ enum eeprom_nature { | |||
54 | /* Each client has this additional data */ | 55 | /* Each client has this additional data */ |
55 | struct eeprom_data { | 56 | struct eeprom_data { |
56 | struct i2c_client client; | 57 | struct i2c_client client; |
57 | struct semaphore update_lock; | 58 | struct mutex update_lock; |
58 | u8 valid; /* bitfield, bit!=0 if slice is valid */ | 59 | u8 valid; /* bitfield, bit!=0 if slice is valid */ |
59 | unsigned long last_updated[8]; /* In jiffies, 8 slices */ | 60 | unsigned long last_updated[8]; /* In jiffies, 8 slices */ |
60 | u8 data[EEPROM_SIZE]; /* Register values */ | 61 | u8 data[EEPROM_SIZE]; /* Register values */ |
@@ -81,7 +82,7 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice) | |||
81 | struct eeprom_data *data = i2c_get_clientdata(client); | 82 | struct eeprom_data *data = i2c_get_clientdata(client); |
82 | int i, j; | 83 | int i, j; |
83 | 84 | ||
84 | down(&data->update_lock); | 85 | mutex_lock(&data->update_lock); |
85 | 86 | ||
86 | if (!(data->valid & (1 << slice)) || | 87 | if (!(data->valid & (1 << slice)) || |
87 | time_after(jiffies, data->last_updated[slice] + 300 * HZ)) { | 88 | time_after(jiffies, data->last_updated[slice] + 300 * HZ)) { |
@@ -107,7 +108,7 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice) | |||
107 | data->valid |= (1 << slice); | 108 | data->valid |= (1 << slice); |
108 | } | 109 | } |
109 | exit: | 110 | exit: |
110 | up(&data->update_lock); | 111 | mutex_unlock(&data->update_lock); |
111 | } | 112 | } |
112 | 113 | ||
113 | static ssize_t eeprom_read(struct kobject *kobj, char *buf, loff_t off, size_t count) | 114 | static ssize_t eeprom_read(struct kobject *kobj, char *buf, loff_t off, size_t count) |
@@ -187,7 +188,7 @@ static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) | |||
187 | /* Fill in the remaining client fields */ | 188 | /* Fill in the remaining client fields */ |
188 | strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE); | 189 | strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE); |
189 | data->valid = 0; | 190 | data->valid = 0; |
190 | init_MUTEX(&data->update_lock); | 191 | mutex_init(&data->update_lock); |
191 | data->nature = UNKNOWN; | 192 | data->nature = UNKNOWN; |
192 | 193 | ||
193 | /* Tell the I2C layer a new client has arrived */ | 194 | /* Tell the I2C layer a new client has arrived */ |
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index 1251c7fc18d5..e6f1ab7b913c 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c | |||
@@ -1635,8 +1635,6 @@ static struct i2c_driver isp1301_driver = { | |||
1635 | .driver = { | 1635 | .driver = { |
1636 | .name = "isp1301_omap", | 1636 | .name = "isp1301_omap", |
1637 | }, | 1637 | }, |
1638 | .id = 1301, /* FIXME "official", i2c-ids.h */ | ||
1639 | .class = I2C_CLASS_HWMON, | ||
1640 | .attach_adapter = isp1301_scan_bus, | 1638 | .attach_adapter = isp1301_scan_bus, |
1641 | .detach_client = isp1301_detach_client, | 1639 | .detach_client = isp1301_detach_client, |
1642 | }; | 1640 | }; |
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index 2dc3d48375fc..b5aabe7cf792 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c | |||
@@ -24,13 +24,14 @@ | |||
24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
25 | #include <linux/rtc.h> | 25 | #include <linux/rtc.h> |
26 | #include <linux/bcd.h> | 26 | #include <linux/bcd.h> |
27 | #include <linux/mutex.h> | ||
27 | 28 | ||
28 | #include <asm/time.h> | 29 | #include <asm/time.h> |
29 | #include <asm/rtc.h> | 30 | #include <asm/rtc.h> |
30 | 31 | ||
31 | #define M41T00_DRV_NAME "m41t00" | 32 | #define M41T00_DRV_NAME "m41t00" |
32 | 33 | ||
33 | static DECLARE_MUTEX(m41t00_mutex); | 34 | static DEFINE_MUTEX(m41t00_mutex); |
34 | 35 | ||
35 | static struct i2c_driver m41t00_driver; | 36 | static struct i2c_driver m41t00_driver; |
36 | static struct i2c_client *save_client; | 37 | static struct i2c_client *save_client; |
@@ -54,7 +55,7 @@ m41t00_get_rtc_time(void) | |||
54 | sec = min = hour = day = mon = year = 0; | 55 | sec = min = hour = day = mon = year = 0; |
55 | sec1 = min1 = hour1 = day1 = mon1 = year1 = 0; | 56 | sec1 = min1 = hour1 = day1 = mon1 = year1 = 0; |
56 | 57 | ||
57 | down(&m41t00_mutex); | 58 | mutex_lock(&m41t00_mutex); |
58 | do { | 59 | do { |
59 | if (((sec = i2c_smbus_read_byte_data(save_client, 0)) >= 0) | 60 | if (((sec = i2c_smbus_read_byte_data(save_client, 0)) >= 0) |
60 | && ((min = i2c_smbus_read_byte_data(save_client, 1)) | 61 | && ((min = i2c_smbus_read_byte_data(save_client, 1)) |
@@ -80,7 +81,7 @@ m41t00_get_rtc_time(void) | |||
80 | mon1 = mon; | 81 | mon1 = mon; |
81 | year1 = year; | 82 | year1 = year; |
82 | } while (--limit > 0); | 83 | } while (--limit > 0); |
83 | up(&m41t00_mutex); | 84 | mutex_unlock(&m41t00_mutex); |
84 | 85 | ||
85 | if (limit == 0) { | 86 | if (limit == 0) { |
86 | dev_warn(&save_client->dev, | 87 | dev_warn(&save_client->dev, |
@@ -125,7 +126,7 @@ m41t00_set_tlet(ulong arg) | |||
125 | BIN_TO_BCD(tm.tm_mday); | 126 | BIN_TO_BCD(tm.tm_mday); |
126 | BIN_TO_BCD(tm.tm_year); | 127 | BIN_TO_BCD(tm.tm_year); |
127 | 128 | ||
128 | down(&m41t00_mutex); | 129 | mutex_lock(&m41t00_mutex); |
129 | if ((i2c_smbus_write_byte_data(save_client, 0, tm.tm_sec & 0x7f) < 0) | 130 | if ((i2c_smbus_write_byte_data(save_client, 0, tm.tm_sec & 0x7f) < 0) |
130 | || (i2c_smbus_write_byte_data(save_client, 1, tm.tm_min & 0x7f) | 131 | || (i2c_smbus_write_byte_data(save_client, 1, tm.tm_min & 0x7f) |
131 | < 0) | 132 | < 0) |
@@ -140,7 +141,7 @@ m41t00_set_tlet(ulong arg) | |||
140 | 141 | ||
141 | dev_warn(&save_client->dev,"m41t00: can't write to rtc chip\n"); | 142 | dev_warn(&save_client->dev,"m41t00: can't write to rtc chip\n"); |
142 | 143 | ||
143 | up(&m41t00_mutex); | 144 | mutex_unlock(&m41t00_mutex); |
144 | return; | 145 | return; |
145 | } | 146 | } |
146 | 147 | ||
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 6d3ff584155e..88d2ddee4490 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
34 | #include <asm/semaphore.h> | 34 | #include <linux/mutex.h> |
35 | 35 | ||
36 | /* Do not scan - the MAX6875 access method will write to some EEPROM chips */ | 36 | /* Do not scan - the MAX6875 access method will write to some EEPROM chips */ |
37 | static unsigned short normal_i2c[] = {I2C_CLIENT_END}; | 37 | static unsigned short normal_i2c[] = {I2C_CLIENT_END}; |
@@ -54,7 +54,7 @@ I2C_CLIENT_INSMOD_1(max6875); | |||
54 | /* Each client has this additional data */ | 54 | /* Each client has this additional data */ |
55 | struct max6875_data { | 55 | struct max6875_data { |
56 | struct i2c_client client; | 56 | struct i2c_client client; |
57 | struct semaphore update_lock; | 57 | struct mutex update_lock; |
58 | 58 | ||
59 | u32 valid; | 59 | u32 valid; |
60 | u8 data[USER_EEPROM_SIZE]; | 60 | u8 data[USER_EEPROM_SIZE]; |
@@ -83,7 +83,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice) | |||
83 | if (slice >= USER_EEPROM_SLICES) | 83 | if (slice >= USER_EEPROM_SLICES) |
84 | return; | 84 | return; |
85 | 85 | ||
86 | down(&data->update_lock); | 86 | mutex_lock(&data->update_lock); |
87 | 87 | ||
88 | buf = &data->data[slice << SLICE_BITS]; | 88 | buf = &data->data[slice << SLICE_BITS]; |
89 | 89 | ||
@@ -122,7 +122,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice) | |||
122 | data->valid |= (1 << slice); | 122 | data->valid |= (1 << slice); |
123 | } | 123 | } |
124 | exit_up: | 124 | exit_up: |
125 | up(&data->update_lock); | 125 | mutex_unlock(&data->update_lock); |
126 | } | 126 | } |
127 | 127 | ||
128 | static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, | 128 | static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, |
@@ -196,7 +196,7 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) | |||
196 | real_client->driver = &max6875_driver; | 196 | real_client->driver = &max6875_driver; |
197 | real_client->flags = 0; | 197 | real_client->flags = 0; |
198 | strlcpy(real_client->name, "max6875", I2C_NAME_SIZE); | 198 | strlcpy(real_client->name, "max6875", I2C_NAME_SIZE); |
199 | init_MUTEX(&data->update_lock); | 199 | mutex_init(&data->update_lock); |
200 | 200 | ||
201 | /* Init fake client data */ | 201 | /* Init fake client data */ |
202 | /* set the client data to the i2c_client so that it will get freed */ | 202 | /* set the client data to the i2c_client so that it will get freed */ |
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c index 36cff09c678d..925a6b371fd2 100644 --- a/drivers/i2c/chips/pcf8591.c +++ b/drivers/i2c/chips/pcf8591.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
27 | #include <linux/mutex.h> | ||
27 | 28 | ||
28 | /* Addresses to scan */ | 29 | /* Addresses to scan */ |
29 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, | 30 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, |
@@ -74,7 +75,7 @@ MODULE_PARM_DESC(input_mode, | |||
74 | 75 | ||
75 | struct pcf8591_data { | 76 | struct pcf8591_data { |
76 | struct i2c_client client; | 77 | struct i2c_client client; |
77 | struct semaphore update_lock; | 78 | struct mutex update_lock; |
78 | 79 | ||
79 | u8 control; | 80 | u8 control; |
80 | u8 aout; | 81 | u8 aout; |
@@ -144,13 +145,13 @@ static ssize_t set_out0_enable(struct device *dev, struct device_attribute *attr | |||
144 | struct pcf8591_data *data = i2c_get_clientdata(client); | 145 | struct pcf8591_data *data = i2c_get_clientdata(client); |
145 | unsigned long val = simple_strtoul(buf, NULL, 10); | 146 | unsigned long val = simple_strtoul(buf, NULL, 10); |
146 | 147 | ||
147 | down(&data->update_lock); | 148 | mutex_lock(&data->update_lock); |
148 | if (val) | 149 | if (val) |
149 | data->control |= PCF8591_CONTROL_AOEF; | 150 | data->control |= PCF8591_CONTROL_AOEF; |
150 | else | 151 | else |
151 | data->control &= ~PCF8591_CONTROL_AOEF; | 152 | data->control &= ~PCF8591_CONTROL_AOEF; |
152 | i2c_smbus_write_byte(client, data->control); | 153 | i2c_smbus_write_byte(client, data->control); |
153 | up(&data->update_lock); | 154 | mutex_unlock(&data->update_lock); |
154 | return count; | 155 | return count; |
155 | } | 156 | } |
156 | 157 | ||
@@ -200,7 +201,7 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) | |||
200 | /* Fill in the remaining client fields and put it into the global | 201 | /* Fill in the remaining client fields and put it into the global |
201 | list */ | 202 | list */ |
202 | strlcpy(new_client->name, "pcf8591", I2C_NAME_SIZE); | 203 | strlcpy(new_client->name, "pcf8591", I2C_NAME_SIZE); |
203 | init_MUTEX(&data->update_lock); | 204 | mutex_init(&data->update_lock); |
204 | 205 | ||
205 | /* Tell the I2C layer a new client has arrived */ | 206 | /* Tell the I2C layer a new client has arrived */ |
206 | if ((err = i2c_attach_client(new_client))) | 207 | if ((err = i2c_attach_client(new_client))) |
@@ -265,7 +266,7 @@ static int pcf8591_read_channel(struct device *dev, int channel) | |||
265 | struct i2c_client *client = to_i2c_client(dev); | 266 | struct i2c_client *client = to_i2c_client(dev); |
266 | struct pcf8591_data *data = i2c_get_clientdata(client); | 267 | struct pcf8591_data *data = i2c_get_clientdata(client); |
267 | 268 | ||
268 | down(&data->update_lock); | 269 | mutex_lock(&data->update_lock); |
269 | 270 | ||
270 | if ((data->control & PCF8591_CONTROL_AICH_MASK) != channel) { | 271 | if ((data->control & PCF8591_CONTROL_AICH_MASK) != channel) { |
271 | data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK) | 272 | data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK) |
@@ -278,7 +279,7 @@ static int pcf8591_read_channel(struct device *dev, int channel) | |||
278 | } | 279 | } |
279 | value = i2c_smbus_read_byte(client); | 280 | value = i2c_smbus_read_byte(client); |
280 | 281 | ||
281 | up(&data->update_lock); | 282 | mutex_unlock(&data->update_lock); |
282 | 283 | ||
283 | if ((channel == 2 && input_mode == 2) || | 284 | if ((channel == 2 && input_mode == 2) || |
284 | (channel != 3 && (input_mode == 1 || input_mode == 3))) | 285 | (channel != 3 && (input_mode == 1 || input_mode == 3))) |
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c index 1af3dfbb8086..179b1e022d80 100644 --- a/drivers/i2c/chips/tps65010.c +++ b/drivers/i2c/chips/tps65010.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/suspend.h> | 32 | #include <linux/suspend.h> |
33 | #include <linux/debugfs.h> | 33 | #include <linux/debugfs.h> |
34 | #include <linux/seq_file.h> | 34 | #include <linux/seq_file.h> |
35 | #include <linux/mutex.h> | ||
35 | 36 | ||
36 | #include <asm/irq.h> | 37 | #include <asm/irq.h> |
37 | #include <asm/mach-types.h> | 38 | #include <asm/mach-types.h> |
@@ -81,7 +82,7 @@ enum tps_model { | |||
81 | 82 | ||
82 | struct tps65010 { | 83 | struct tps65010 { |
83 | struct i2c_client client; | 84 | struct i2c_client client; |
84 | struct semaphore lock; | 85 | struct mutex lock; |
85 | int irq; | 86 | int irq; |
86 | struct work_struct work; | 87 | struct work_struct work; |
87 | struct dentry *file; | 88 | struct dentry *file; |
@@ -218,7 +219,7 @@ static int dbg_show(struct seq_file *s, void *_) | |||
218 | seq_printf(s, "driver %s\nversion %s\nchip %s\n\n", | 219 | seq_printf(s, "driver %s\nversion %s\nchip %s\n\n", |
219 | DRIVER_NAME, DRIVER_VERSION, chip); | 220 | DRIVER_NAME, DRIVER_VERSION, chip); |
220 | 221 | ||
221 | down(&tps->lock); | 222 | mutex_lock(&tps->lock); |
222 | 223 | ||
223 | /* FIXME how can we tell whether a battery is present? | 224 | /* FIXME how can we tell whether a battery is present? |
224 | * likely involves a charge gauging chip (like BQ26501). | 225 | * likely involves a charge gauging chip (like BQ26501). |
@@ -300,7 +301,7 @@ static int dbg_show(struct seq_file *s, void *_) | |||
300 | (v2 & (1 << (4 + i))) ? "rising" : "falling"); | 301 | (v2 & (1 << (4 + i))) ? "rising" : "falling"); |
301 | } | 302 | } |
302 | 303 | ||
303 | up(&tps->lock); | 304 | mutex_unlock(&tps->lock); |
304 | return 0; | 305 | return 0; |
305 | } | 306 | } |
306 | 307 | ||
@@ -416,7 +417,7 @@ static void tps65010_work(void *_tps) | |||
416 | { | 417 | { |
417 | struct tps65010 *tps = _tps; | 418 | struct tps65010 *tps = _tps; |
418 | 419 | ||
419 | down(&tps->lock); | 420 | mutex_lock(&tps->lock); |
420 | 421 | ||
421 | tps65010_interrupt(tps); | 422 | tps65010_interrupt(tps); |
422 | 423 | ||
@@ -444,7 +445,7 @@ static void tps65010_work(void *_tps) | |||
444 | if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags)) | 445 | if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags)) |
445 | enable_irq(tps->irq); | 446 | enable_irq(tps->irq); |
446 | 447 | ||
447 | up(&tps->lock); | 448 | mutex_unlock(&tps->lock); |
448 | } | 449 | } |
449 | 450 | ||
450 | static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs) | 451 | static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs) |
@@ -505,7 +506,7 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind) | |||
505 | if (!tps) | 506 | if (!tps) |
506 | return 0; | 507 | return 0; |
507 | 508 | ||
508 | init_MUTEX(&tps->lock); | 509 | mutex_init(&tps->lock); |
509 | INIT_WORK(&tps->work, tps65010_work, tps); | 510 | INIT_WORK(&tps->work, tps65010_work, tps); |
510 | tps->irq = -1; | 511 | tps->irq = -1; |
511 | tps->client.addr = address; | 512 | tps->client.addr = address; |
@@ -695,7 +696,7 @@ int tps65010_set_gpio_out_value(unsigned gpio, unsigned value) | |||
695 | if ((gpio < GPIO1) || (gpio > GPIO4)) | 696 | if ((gpio < GPIO1) || (gpio > GPIO4)) |
696 | return -EINVAL; | 697 | return -EINVAL; |
697 | 698 | ||
698 | down(&the_tps->lock); | 699 | mutex_lock(&the_tps->lock); |
699 | 700 | ||
700 | defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO); | 701 | defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO); |
701 | 702 | ||
@@ -720,7 +721,7 @@ int tps65010_set_gpio_out_value(unsigned gpio, unsigned value) | |||
720 | gpio, value ? "high" : "low", | 721 | gpio, value ? "high" : "low", |
721 | i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO)); | 722 | i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO)); |
722 | 723 | ||
723 | up(&the_tps->lock); | 724 | mutex_unlock(&the_tps->lock); |
724 | return status; | 725 | return status; |
725 | } | 726 | } |
726 | EXPORT_SYMBOL(tps65010_set_gpio_out_value); | 727 | EXPORT_SYMBOL(tps65010_set_gpio_out_value); |
@@ -745,7 +746,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
745 | led = LED2; | 746 | led = LED2; |
746 | } | 747 | } |
747 | 748 | ||
748 | down(&the_tps->lock); | 749 | mutex_lock(&the_tps->lock); |
749 | 750 | ||
750 | pr_debug("%s: led%i_on 0x%02x\n", DRIVER_NAME, led, | 751 | pr_debug("%s: led%i_on 0x%02x\n", DRIVER_NAME, led, |
751 | i2c_smbus_read_byte_data(&the_tps->client, | 752 | i2c_smbus_read_byte_data(&the_tps->client, |
@@ -771,7 +772,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
771 | default: | 772 | default: |
772 | printk(KERN_ERR "%s: Wrong mode parameter for set_led()\n", | 773 | printk(KERN_ERR "%s: Wrong mode parameter for set_led()\n", |
773 | DRIVER_NAME); | 774 | DRIVER_NAME); |
774 | up(&the_tps->lock); | 775 | mutex_unlock(&the_tps->lock); |
775 | return -EINVAL; | 776 | return -EINVAL; |
776 | } | 777 | } |
777 | 778 | ||
@@ -781,7 +782,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
781 | if (status != 0) { | 782 | if (status != 0) { |
782 | printk(KERN_ERR "%s: Failed to write led%i_on register\n", | 783 | printk(KERN_ERR "%s: Failed to write led%i_on register\n", |
783 | DRIVER_NAME, led); | 784 | DRIVER_NAME, led); |
784 | up(&the_tps->lock); | 785 | mutex_unlock(&the_tps->lock); |
785 | return status; | 786 | return status; |
786 | } | 787 | } |
787 | 788 | ||
@@ -794,7 +795,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
794 | if (status != 0) { | 795 | if (status != 0) { |
795 | printk(KERN_ERR "%s: Failed to write led%i_per register\n", | 796 | printk(KERN_ERR "%s: Failed to write led%i_per register\n", |
796 | DRIVER_NAME, led); | 797 | DRIVER_NAME, led); |
797 | up(&the_tps->lock); | 798 | mutex_unlock(&the_tps->lock); |
798 | return status; | 799 | return status; |
799 | } | 800 | } |
800 | 801 | ||
@@ -802,7 +803,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
802 | i2c_smbus_read_byte_data(&the_tps->client, | 803 | i2c_smbus_read_byte_data(&the_tps->client, |
803 | TPS_LED1_PER + offs)); | 804 | TPS_LED1_PER + offs)); |
804 | 805 | ||
805 | up(&the_tps->lock); | 806 | mutex_unlock(&the_tps->lock); |
806 | 807 | ||
807 | return status; | 808 | return status; |
808 | } | 809 | } |
@@ -820,7 +821,7 @@ int tps65010_set_vib(unsigned value) | |||
820 | if (!the_tps) | 821 | if (!the_tps) |
821 | return -ENODEV; | 822 | return -ENODEV; |
822 | 823 | ||
823 | down(&the_tps->lock); | 824 | mutex_lock(&the_tps->lock); |
824 | 825 | ||
825 | vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2); | 826 | vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2); |
826 | vdcdc2 &= ~(1 << 1); | 827 | vdcdc2 &= ~(1 << 1); |
@@ -831,7 +832,7 @@ int tps65010_set_vib(unsigned value) | |||
831 | 832 | ||
832 | pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off"); | 833 | pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off"); |
833 | 834 | ||
834 | up(&the_tps->lock); | 835 | mutex_unlock(&the_tps->lock); |
835 | return status; | 836 | return status; |
836 | } | 837 | } |
837 | EXPORT_SYMBOL(tps65010_set_vib); | 838 | EXPORT_SYMBOL(tps65010_set_vib); |
@@ -848,7 +849,7 @@ int tps65010_set_low_pwr(unsigned mode) | |||
848 | if (!the_tps) | 849 | if (!the_tps) |
849 | return -ENODEV; | 850 | return -ENODEV; |
850 | 851 | ||
851 | down(&the_tps->lock); | 852 | mutex_lock(&the_tps->lock); |
852 | 853 | ||
853 | pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME, | 854 | pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME, |
854 | mode ? "enable" : "disable", | 855 | mode ? "enable" : "disable", |
@@ -876,7 +877,7 @@ int tps65010_set_low_pwr(unsigned mode) | |||
876 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, | 877 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, |
877 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | 878 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); |
878 | 879 | ||
879 | up(&the_tps->lock); | 880 | mutex_unlock(&the_tps->lock); |
880 | 881 | ||
881 | return status; | 882 | return status; |
882 | } | 883 | } |
@@ -894,7 +895,7 @@ int tps65010_config_vregs1(unsigned value) | |||
894 | if (!the_tps) | 895 | if (!the_tps) |
895 | return -ENODEV; | 896 | return -ENODEV; |
896 | 897 | ||
897 | down(&the_tps->lock); | 898 | mutex_lock(&the_tps->lock); |
898 | 899 | ||
899 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, | 900 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, |
900 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); | 901 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); |
@@ -909,7 +910,7 @@ int tps65010_config_vregs1(unsigned value) | |||
909 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, | 910 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, |
910 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); | 911 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); |
911 | 912 | ||
912 | up(&the_tps->lock); | 913 | mutex_unlock(&the_tps->lock); |
913 | 914 | ||
914 | return status; | 915 | return status; |
915 | } | 916 | } |
@@ -931,7 +932,7 @@ int tps65013_set_low_pwr(unsigned mode) | |||
931 | if (!the_tps || the_tps->por) | 932 | if (!the_tps || the_tps->por) |
932 | return -ENODEV; | 933 | return -ENODEV; |
933 | 934 | ||
934 | down(&the_tps->lock); | 935 | mutex_lock(&the_tps->lock); |
935 | 936 | ||
936 | pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n", | 937 | pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n", |
937 | DRIVER_NAME, | 938 | DRIVER_NAME, |
@@ -959,7 +960,7 @@ int tps65013_set_low_pwr(unsigned mode) | |||
959 | if (status != 0) { | 960 | if (status != 0) { |
960 | printk(KERN_ERR "%s: Failed to write chconfig register\n", | 961 | printk(KERN_ERR "%s: Failed to write chconfig register\n", |
961 | DRIVER_NAME); | 962 | DRIVER_NAME); |
962 | up(&the_tps->lock); | 963 | mutex_unlock(&the_tps->lock); |
963 | return status; | 964 | return status; |
964 | } | 965 | } |
965 | 966 | ||
@@ -977,7 +978,7 @@ int tps65013_set_low_pwr(unsigned mode) | |||
977 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, | 978 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, |
978 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | 979 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); |
979 | 980 | ||
980 | up(&the_tps->lock); | 981 | mutex_unlock(&the_tps->lock); |
981 | 982 | ||
982 | return status; | 983 | return status; |
983 | } | 984 | } |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 1a2c9ab5d9e3..45e2cdf54736 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -31,12 +31,13 @@ | |||
31 | #include <linux/idr.h> | 31 | #include <linux/idr.h> |
32 | #include <linux/seq_file.h> | 32 | #include <linux/seq_file.h> |
33 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
34 | #include <linux/mutex.h> | ||
34 | #include <asm/uaccess.h> | 35 | #include <asm/uaccess.h> |
35 | 36 | ||
36 | 37 | ||
37 | static LIST_HEAD(adapters); | 38 | static LIST_HEAD(adapters); |
38 | static LIST_HEAD(drivers); | 39 | static LIST_HEAD(drivers); |
39 | static DECLARE_MUTEX(core_lists); | 40 | static DEFINE_MUTEX(core_lists); |
40 | static DEFINE_IDR(i2c_adapter_idr); | 41 | static DEFINE_IDR(i2c_adapter_idr); |
41 | 42 | ||
42 | /* match always succeeds, as we want the probe() to tell if we really accept this match */ | 43 | /* match always succeeds, as we want the probe() to tell if we really accept this match */ |
@@ -153,7 +154,7 @@ int i2c_add_adapter(struct i2c_adapter *adap) | |||
153 | struct list_head *item; | 154 | struct list_head *item; |
154 | struct i2c_driver *driver; | 155 | struct i2c_driver *driver; |
155 | 156 | ||
156 | down(&core_lists); | 157 | mutex_lock(&core_lists); |
157 | 158 | ||
158 | if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) { | 159 | if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) { |
159 | res = -ENOMEM; | 160 | res = -ENOMEM; |
@@ -168,8 +169,8 @@ int i2c_add_adapter(struct i2c_adapter *adap) | |||
168 | } | 169 | } |
169 | 170 | ||
170 | adap->nr = id & MAX_ID_MASK; | 171 | adap->nr = id & MAX_ID_MASK; |
171 | init_MUTEX(&adap->bus_lock); | 172 | mutex_init(&adap->bus_lock); |
172 | init_MUTEX(&adap->clist_lock); | 173 | mutex_init(&adap->clist_lock); |
173 | list_add_tail(&adap->list,&adapters); | 174 | list_add_tail(&adap->list,&adapters); |
174 | INIT_LIST_HEAD(&adap->clients); | 175 | INIT_LIST_HEAD(&adap->clients); |
175 | 176 | ||
@@ -203,7 +204,7 @@ int i2c_add_adapter(struct i2c_adapter *adap) | |||
203 | } | 204 | } |
204 | 205 | ||
205 | out_unlock: | 206 | out_unlock: |
206 | up(&core_lists); | 207 | mutex_unlock(&core_lists); |
207 | return res; | 208 | return res; |
208 | } | 209 | } |
209 | 210 | ||
@@ -216,7 +217,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
216 | struct i2c_client *client; | 217 | struct i2c_client *client; |
217 | int res = 0; | 218 | int res = 0; |
218 | 219 | ||
219 | down(&core_lists); | 220 | mutex_lock(&core_lists); |
220 | 221 | ||
221 | /* First make sure that this adapter was ever added */ | 222 | /* First make sure that this adapter was ever added */ |
222 | list_for_each_entry(adap_from_list, &adapters, list) { | 223 | list_for_each_entry(adap_from_list, &adapters, list) { |
@@ -272,7 +273,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
272 | dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); | 273 | dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); |
273 | 274 | ||
274 | out_unlock: | 275 | out_unlock: |
275 | up(&core_lists); | 276 | mutex_unlock(&core_lists); |
276 | return res; | 277 | return res; |
277 | } | 278 | } |
278 | 279 | ||
@@ -287,9 +288,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) | |||
287 | { | 288 | { |
288 | struct list_head *item; | 289 | struct list_head *item; |
289 | struct i2c_adapter *adapter; | 290 | struct i2c_adapter *adapter; |
290 | int res = 0; | 291 | int res; |
291 | |||
292 | down(&core_lists); | ||
293 | 292 | ||
294 | /* add the driver to the list of i2c drivers in the driver core */ | 293 | /* add the driver to the list of i2c drivers in the driver core */ |
295 | driver->driver.owner = owner; | 294 | driver->driver.owner = owner; |
@@ -297,8 +296,10 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) | |||
297 | 296 | ||
298 | res = driver_register(&driver->driver); | 297 | res = driver_register(&driver->driver); |
299 | if (res) | 298 | if (res) |
300 | goto out_unlock; | 299 | return res; |
301 | 300 | ||
301 | mutex_lock(&core_lists); | ||
302 | |||
302 | list_add_tail(&driver->list,&drivers); | 303 | list_add_tail(&driver->list,&drivers); |
303 | pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name); | 304 | pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name); |
304 | 305 | ||
@@ -310,9 +311,8 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) | |||
310 | } | 311 | } |
311 | } | 312 | } |
312 | 313 | ||
313 | out_unlock: | 314 | mutex_unlock(&core_lists); |
314 | up(&core_lists); | 315 | return 0; |
315 | return res; | ||
316 | } | 316 | } |
317 | EXPORT_SYMBOL(i2c_register_driver); | 317 | EXPORT_SYMBOL(i2c_register_driver); |
318 | 318 | ||
@@ -324,7 +324,7 @@ int i2c_del_driver(struct i2c_driver *driver) | |||
324 | 324 | ||
325 | int res = 0; | 325 | int res = 0; |
326 | 326 | ||
327 | down(&core_lists); | 327 | mutex_lock(&core_lists); |
328 | 328 | ||
329 | /* Have a look at each adapter, if clients of this driver are still | 329 | /* Have a look at each adapter, if clients of this driver are still |
330 | * attached. If so, detach them to be able to kill the driver | 330 | * attached. If so, detach them to be able to kill the driver |
@@ -363,7 +363,7 @@ int i2c_del_driver(struct i2c_driver *driver) | |||
363 | pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); | 363 | pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); |
364 | 364 | ||
365 | out_unlock: | 365 | out_unlock: |
366 | up(&core_lists); | 366 | mutex_unlock(&core_lists); |
367 | return 0; | 367 | return 0; |
368 | } | 368 | } |
369 | 369 | ||
@@ -384,9 +384,9 @@ int i2c_check_addr(struct i2c_adapter *adapter, int addr) | |||
384 | { | 384 | { |
385 | int rval; | 385 | int rval; |
386 | 386 | ||
387 | down(&adapter->clist_lock); | 387 | mutex_lock(&adapter->clist_lock); |
388 | rval = __i2c_check_addr(adapter, addr); | 388 | rval = __i2c_check_addr(adapter, addr); |
389 | up(&adapter->clist_lock); | 389 | mutex_unlock(&adapter->clist_lock); |
390 | 390 | ||
391 | return rval; | 391 | return rval; |
392 | } | 392 | } |
@@ -395,13 +395,13 @@ int i2c_attach_client(struct i2c_client *client) | |||
395 | { | 395 | { |
396 | struct i2c_adapter *adapter = client->adapter; | 396 | struct i2c_adapter *adapter = client->adapter; |
397 | 397 | ||
398 | down(&adapter->clist_lock); | 398 | mutex_lock(&adapter->clist_lock); |
399 | if (__i2c_check_addr(client->adapter, client->addr)) { | 399 | if (__i2c_check_addr(client->adapter, client->addr)) { |
400 | up(&adapter->clist_lock); | 400 | mutex_unlock(&adapter->clist_lock); |
401 | return -EBUSY; | 401 | return -EBUSY; |
402 | } | 402 | } |
403 | list_add_tail(&client->list,&adapter->clients); | 403 | list_add_tail(&client->list,&adapter->clients); |
404 | up(&adapter->clist_lock); | 404 | mutex_unlock(&adapter->clist_lock); |
405 | 405 | ||
406 | if (adapter->client_register) { | 406 | if (adapter->client_register) { |
407 | if (adapter->client_register(client)) { | 407 | if (adapter->client_register(client)) { |
@@ -450,12 +450,12 @@ int i2c_detach_client(struct i2c_client *client) | |||
450 | } | 450 | } |
451 | } | 451 | } |
452 | 452 | ||
453 | down(&adapter->clist_lock); | 453 | mutex_lock(&adapter->clist_lock); |
454 | list_del(&client->list); | 454 | list_del(&client->list); |
455 | init_completion(&client->released); | 455 | init_completion(&client->released); |
456 | device_remove_file(&client->dev, &dev_attr_client_name); | 456 | device_remove_file(&client->dev, &dev_attr_client_name); |
457 | device_unregister(&client->dev); | 457 | device_unregister(&client->dev); |
458 | up(&adapter->clist_lock); | 458 | mutex_unlock(&adapter->clist_lock); |
459 | wait_for_completion(&client->released); | 459 | wait_for_completion(&client->released); |
460 | 460 | ||
461 | out: | 461 | out: |
@@ -513,19 +513,19 @@ void i2c_clients_command(struct i2c_adapter *adap, unsigned int cmd, void *arg) | |||
513 | struct list_head *item; | 513 | struct list_head *item; |
514 | struct i2c_client *client; | 514 | struct i2c_client *client; |
515 | 515 | ||
516 | down(&adap->clist_lock); | 516 | mutex_lock(&adap->clist_lock); |
517 | list_for_each(item,&adap->clients) { | 517 | list_for_each(item,&adap->clients) { |
518 | client = list_entry(item, struct i2c_client, list); | 518 | client = list_entry(item, struct i2c_client, list); |
519 | if (!try_module_get(client->driver->driver.owner)) | 519 | if (!try_module_get(client->driver->driver.owner)) |
520 | continue; | 520 | continue; |
521 | if (NULL != client->driver->command) { | 521 | if (NULL != client->driver->command) { |
522 | up(&adap->clist_lock); | 522 | mutex_unlock(&adap->clist_lock); |
523 | client->driver->command(client,cmd,arg); | 523 | client->driver->command(client,cmd,arg); |
524 | down(&adap->clist_lock); | 524 | mutex_lock(&adap->clist_lock); |
525 | } | 525 | } |
526 | module_put(client->driver->driver.owner); | 526 | module_put(client->driver->driver.owner); |
527 | } | 527 | } |
528 | up(&adap->clist_lock); | 528 | mutex_unlock(&adap->clist_lock); |
529 | } | 529 | } |
530 | 530 | ||
531 | static int __init i2c_init(void) | 531 | static int __init i2c_init(void) |
@@ -569,9 +569,9 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num) | |||
569 | } | 569 | } |
570 | #endif | 570 | #endif |
571 | 571 | ||
572 | down(&adap->bus_lock); | 572 | mutex_lock(&adap->bus_lock); |
573 | ret = adap->algo->master_xfer(adap,msgs,num); | 573 | ret = adap->algo->master_xfer(adap,msgs,num); |
574 | up(&adap->bus_lock); | 574 | mutex_unlock(&adap->bus_lock); |
575 | 575 | ||
576 | return ret; | 576 | return ret; |
577 | } else { | 577 | } else { |
@@ -779,12 +779,12 @@ struct i2c_adapter* i2c_get_adapter(int id) | |||
779 | { | 779 | { |
780 | struct i2c_adapter *adapter; | 780 | struct i2c_adapter *adapter; |
781 | 781 | ||
782 | down(&core_lists); | 782 | mutex_lock(&core_lists); |
783 | adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); | 783 | adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); |
784 | if (adapter && !try_module_get(adapter->owner)) | 784 | if (adapter && !try_module_get(adapter->owner)) |
785 | adapter = NULL; | 785 | adapter = NULL; |
786 | 786 | ||
787 | up(&core_lists); | 787 | mutex_unlock(&core_lists); |
788 | return adapter; | 788 | return adapter; |
789 | } | 789 | } |
790 | 790 | ||
@@ -919,12 +919,11 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command, | |||
919 | u8 length, u8 *values) | 919 | u8 length, u8 *values) |
920 | { | 920 | { |
921 | union i2c_smbus_data data; | 921 | union i2c_smbus_data data; |
922 | int i; | 922 | |
923 | if (length > I2C_SMBUS_BLOCK_MAX) | 923 | if (length > I2C_SMBUS_BLOCK_MAX) |
924 | length = I2C_SMBUS_BLOCK_MAX; | 924 | length = I2C_SMBUS_BLOCK_MAX; |
925 | for (i = 1; i <= length; i++) | ||
926 | data.block[i] = values[i-1]; | ||
927 | data.block[0] = length; | 925 | data.block[0] = length; |
926 | memcpy(&data.block[1], values, length); | ||
928 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, | 927 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, |
929 | I2C_SMBUS_WRITE,command, | 928 | I2C_SMBUS_WRITE,command, |
930 | I2C_SMBUS_BLOCK_DATA,&data); | 929 | I2C_SMBUS_BLOCK_DATA,&data); |
@@ -934,16 +933,14 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command, | |||
934 | s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values) | 933 | s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values) |
935 | { | 934 | { |
936 | union i2c_smbus_data data; | 935 | union i2c_smbus_data data; |
937 | int i; | 936 | |
938 | if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, | 937 | if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, |
939 | I2C_SMBUS_READ,command, | 938 | I2C_SMBUS_READ,command, |
940 | I2C_SMBUS_I2C_BLOCK_DATA,&data)) | 939 | I2C_SMBUS_I2C_BLOCK_DATA,&data)) |
941 | return -1; | 940 | return -1; |
942 | else { | 941 | |
943 | for (i = 1; i <= data.block[0]; i++) | 942 | memcpy(values, &data.block[1], data.block[0]); |
944 | values[i-1] = data.block[i]; | 943 | return data.block[0]; |
945 | return data.block[0]; | ||
946 | } | ||
947 | } | 944 | } |
948 | 945 | ||
949 | s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command, | 946 | s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command, |
@@ -1118,10 +1115,10 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, | |||
1118 | flags &= I2C_M_TEN | I2C_CLIENT_PEC; | 1115 | flags &= I2C_M_TEN | I2C_CLIENT_PEC; |
1119 | 1116 | ||
1120 | if (adapter->algo->smbus_xfer) { | 1117 | if (adapter->algo->smbus_xfer) { |
1121 | down(&adapter->bus_lock); | 1118 | mutex_lock(&adapter->bus_lock); |
1122 | res = adapter->algo->smbus_xfer(adapter,addr,flags,read_write, | 1119 | res = adapter->algo->smbus_xfer(adapter,addr,flags,read_write, |
1123 | command,size,data); | 1120 | command,size,data); |
1124 | up(&adapter->bus_lock); | 1121 | mutex_unlock(&adapter->bus_lock); |
1125 | } else | 1122 | } else |
1126 | res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, | 1123 | res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, |
1127 | command,size,data); | 1124 | command,size,data); |
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 3325660f7248..c7671e188017 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -313,6 +313,7 @@ | |||
313 | #include <linux/cdrom.h> | 313 | #include <linux/cdrom.h> |
314 | #include <linux/ide.h> | 314 | #include <linux/ide.h> |
315 | #include <linux/completion.h> | 315 | #include <linux/completion.h> |
316 | #include <linux/mutex.h> | ||
316 | 317 | ||
317 | #include <scsi/scsi.h> /* For SCSI -> ATAPI command conversion */ | 318 | #include <scsi/scsi.h> /* For SCSI -> ATAPI command conversion */ |
318 | 319 | ||
@@ -324,7 +325,7 @@ | |||
324 | 325 | ||
325 | #include "ide-cd.h" | 326 | #include "ide-cd.h" |
326 | 327 | ||
327 | static DECLARE_MUTEX(idecd_ref_sem); | 328 | static DEFINE_MUTEX(idecd_ref_mutex); |
328 | 329 | ||
329 | #define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref) | 330 | #define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref) |
330 | 331 | ||
@@ -335,11 +336,11 @@ static struct cdrom_info *ide_cd_get(struct gendisk *disk) | |||
335 | { | 336 | { |
336 | struct cdrom_info *cd = NULL; | 337 | struct cdrom_info *cd = NULL; |
337 | 338 | ||
338 | down(&idecd_ref_sem); | 339 | mutex_lock(&idecd_ref_mutex); |
339 | cd = ide_cd_g(disk); | 340 | cd = ide_cd_g(disk); |
340 | if (cd) | 341 | if (cd) |
341 | kref_get(&cd->kref); | 342 | kref_get(&cd->kref); |
342 | up(&idecd_ref_sem); | 343 | mutex_unlock(&idecd_ref_mutex); |
343 | return cd; | 344 | return cd; |
344 | } | 345 | } |
345 | 346 | ||
@@ -347,9 +348,9 @@ static void ide_cd_release(struct kref *); | |||
347 | 348 | ||
348 | static void ide_cd_put(struct cdrom_info *cd) | 349 | static void ide_cd_put(struct cdrom_info *cd) |
349 | { | 350 | { |
350 | down(&idecd_ref_sem); | 351 | mutex_lock(&idecd_ref_mutex); |
351 | kref_put(&cd->kref, ide_cd_release); | 352 | kref_put(&cd->kref, ide_cd_release); |
352 | up(&idecd_ref_sem); | 353 | mutex_unlock(&idecd_ref_mutex); |
353 | } | 354 | } |
354 | 355 | ||
355 | /**************************************************************************** | 356 | /**************************************************************************** |
@@ -2471,52 +2472,6 @@ static int ide_cdrom_packet(struct cdrom_device_info *cdi, | |||
2471 | } | 2472 | } |
2472 | 2473 | ||
2473 | static | 2474 | static |
2474 | int ide_cdrom_dev_ioctl (struct cdrom_device_info *cdi, | ||
2475 | unsigned int cmd, unsigned long arg) | ||
2476 | { | ||
2477 | struct packet_command cgc; | ||
2478 | char buffer[16]; | ||
2479 | int stat; | ||
2480 | |||
2481 | init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN); | ||
2482 | |||
2483 | /* These will be moved into the Uniform layer shortly... */ | ||
2484 | switch (cmd) { | ||
2485 | case CDROMSETSPINDOWN: { | ||
2486 | char spindown; | ||
2487 | |||
2488 | if (copy_from_user(&spindown, (void __user *) arg, sizeof(char))) | ||
2489 | return -EFAULT; | ||
2490 | |||
2491 | if ((stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0))) | ||
2492 | return stat; | ||
2493 | |||
2494 | buffer[11] = (buffer[11] & 0xf0) | (spindown & 0x0f); | ||
2495 | |||
2496 | return cdrom_mode_select(cdi, &cgc); | ||
2497 | } | ||
2498 | |||
2499 | case CDROMGETSPINDOWN: { | ||
2500 | char spindown; | ||
2501 | |||
2502 | if ((stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0))) | ||
2503 | return stat; | ||
2504 | |||
2505 | spindown = buffer[11] & 0x0f; | ||
2506 | |||
2507 | if (copy_to_user((void __user *) arg, &spindown, sizeof (char))) | ||
2508 | return -EFAULT; | ||
2509 | |||
2510 | return 0; | ||
2511 | } | ||
2512 | |||
2513 | default: | ||
2514 | return -EINVAL; | ||
2515 | } | ||
2516 | |||
2517 | } | ||
2518 | |||
2519 | static | ||
2520 | int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi, | 2475 | int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi, |
2521 | unsigned int cmd, void *arg) | 2476 | unsigned int cmd, void *arg) |
2522 | 2477 | ||
@@ -2852,12 +2807,11 @@ static struct cdrom_device_ops ide_cdrom_dops = { | |||
2852 | .get_mcn = ide_cdrom_get_mcn, | 2807 | .get_mcn = ide_cdrom_get_mcn, |
2853 | .reset = ide_cdrom_reset, | 2808 | .reset = ide_cdrom_reset, |
2854 | .audio_ioctl = ide_cdrom_audio_ioctl, | 2809 | .audio_ioctl = ide_cdrom_audio_ioctl, |
2855 | .dev_ioctl = ide_cdrom_dev_ioctl, | ||
2856 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | | 2810 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | |
2857 | CDC_SELECT_SPEED | CDC_SELECT_DISC | | 2811 | CDC_SELECT_SPEED | CDC_SELECT_DISC | |
2858 | CDC_MULTI_SESSION | CDC_MCN | | 2812 | CDC_MULTI_SESSION | CDC_MCN | |
2859 | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | | 2813 | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | |
2860 | CDC_IOCTLS | CDC_DRIVE_STATUS | CDC_CD_R | | 2814 | CDC_DRIVE_STATUS | CDC_CD_R | |
2861 | CDC_CD_RW | CDC_DVD | CDC_DVD_R| CDC_DVD_RAM | | 2815 | CDC_CD_RW | CDC_DVD | CDC_DVD_R| CDC_DVD_RAM | |
2862 | CDC_GENERIC_PACKET | CDC_MO_DRIVE | CDC_MRW | | 2816 | CDC_GENERIC_PACKET | CDC_MO_DRIVE | CDC_MRW | |
2863 | CDC_MRW_W | CDC_RAM, | 2817 | CDC_MRW_W | CDC_RAM, |
@@ -3367,6 +3321,45 @@ static int idecd_release(struct inode * inode, struct file * file) | |||
3367 | return 0; | 3321 | return 0; |
3368 | } | 3322 | } |
3369 | 3323 | ||
3324 | static int idecd_set_spindown(struct cdrom_device_info *cdi, unsigned long arg) | ||
3325 | { | ||
3326 | struct packet_command cgc; | ||
3327 | char buffer[16]; | ||
3328 | int stat; | ||
3329 | char spindown; | ||
3330 | |||
3331 | if (copy_from_user(&spindown, (void __user *)arg, sizeof(char))) | ||
3332 | return -EFAULT; | ||
3333 | |||
3334 | init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN); | ||
3335 | |||
3336 | stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0); | ||
3337 | if (stat) | ||
3338 | return stat; | ||
3339 | |||
3340 | buffer[11] = (buffer[11] & 0xf0) | (spindown & 0x0f); | ||
3341 | return cdrom_mode_select(cdi, &cgc); | ||
3342 | } | ||
3343 | |||
3344 | static int idecd_get_spindown(struct cdrom_device_info *cdi, unsigned long arg) | ||
3345 | { | ||
3346 | struct packet_command cgc; | ||
3347 | char buffer[16]; | ||
3348 | int stat; | ||
3349 | char spindown; | ||
3350 | |||
3351 | init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN); | ||
3352 | |||
3353 | stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0); | ||
3354 | if (stat) | ||
3355 | return stat; | ||
3356 | |||
3357 | spindown = buffer[11] & 0x0f; | ||
3358 | if (copy_to_user((void __user *)arg, &spindown, sizeof (char))) | ||
3359 | return -EFAULT; | ||
3360 | return 0; | ||
3361 | } | ||
3362 | |||
3370 | static int idecd_ioctl (struct inode *inode, struct file *file, | 3363 | static int idecd_ioctl (struct inode *inode, struct file *file, |
3371 | unsigned int cmd, unsigned long arg) | 3364 | unsigned int cmd, unsigned long arg) |
3372 | { | 3365 | { |
@@ -3374,7 +3367,16 @@ static int idecd_ioctl (struct inode *inode, struct file *file, | |||
3374 | struct cdrom_info *info = ide_cd_g(bdev->bd_disk); | 3367 | struct cdrom_info *info = ide_cd_g(bdev->bd_disk); |
3375 | int err; | 3368 | int err; |
3376 | 3369 | ||
3377 | err = generic_ide_ioctl(info->drive, file, bdev, cmd, arg); | 3370 | switch (cmd) { |
3371 | case CDROMSETSPINDOWN: | ||
3372 | return idecd_set_spindown(&info->devinfo, arg); | ||
3373 | case CDROMGETSPINDOWN: | ||
3374 | return idecd_get_spindown(&info->devinfo, arg); | ||
3375 | default: | ||
3376 | break; | ||
3377 | } | ||
3378 | |||
3379 | err = generic_ide_ioctl(info->drive, file, bdev, cmd, arg); | ||
3378 | if (err == -EINVAL) | 3380 | if (err == -EINVAL) |
3379 | err = cdrom_ioctl(file, &info->devinfo, inode, cmd, arg); | 3381 | err = cdrom_ioctl(file, &info->devinfo, inode, cmd, arg); |
3380 | 3382 | ||
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 09086b8b6486..e238b7da824b 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -60,6 +60,7 @@ | |||
60 | #include <linux/genhd.h> | 60 | #include <linux/genhd.h> |
61 | #include <linux/slab.h> | 61 | #include <linux/slab.h> |
62 | #include <linux/delay.h> | 62 | #include <linux/delay.h> |
63 | #include <linux/mutex.h> | ||
63 | 64 | ||
64 | #define _IDE_DISK | 65 | #define _IDE_DISK |
65 | 66 | ||
@@ -78,7 +79,7 @@ struct ide_disk_obj { | |||
78 | struct kref kref; | 79 | struct kref kref; |
79 | }; | 80 | }; |
80 | 81 | ||
81 | static DECLARE_MUTEX(idedisk_ref_sem); | 82 | static DEFINE_MUTEX(idedisk_ref_mutex); |
82 | 83 | ||
83 | #define to_ide_disk(obj) container_of(obj, struct ide_disk_obj, kref) | 84 | #define to_ide_disk(obj) container_of(obj, struct ide_disk_obj, kref) |
84 | 85 | ||
@@ -89,11 +90,11 @@ static struct ide_disk_obj *ide_disk_get(struct gendisk *disk) | |||
89 | { | 90 | { |
90 | struct ide_disk_obj *idkp = NULL; | 91 | struct ide_disk_obj *idkp = NULL; |
91 | 92 | ||
92 | down(&idedisk_ref_sem); | 93 | mutex_lock(&idedisk_ref_mutex); |
93 | idkp = ide_disk_g(disk); | 94 | idkp = ide_disk_g(disk); |
94 | if (idkp) | 95 | if (idkp) |
95 | kref_get(&idkp->kref); | 96 | kref_get(&idkp->kref); |
96 | up(&idedisk_ref_sem); | 97 | mutex_unlock(&idedisk_ref_mutex); |
97 | return idkp; | 98 | return idkp; |
98 | } | 99 | } |
99 | 100 | ||
@@ -101,9 +102,9 @@ static void ide_disk_release(struct kref *); | |||
101 | 102 | ||
102 | static void ide_disk_put(struct ide_disk_obj *idkp) | 103 | static void ide_disk_put(struct ide_disk_obj *idkp) |
103 | { | 104 | { |
104 | down(&idedisk_ref_sem); | 105 | mutex_lock(&idedisk_ref_mutex); |
105 | kref_put(&idkp->kref, ide_disk_release); | 106 | kref_put(&idkp->kref, ide_disk_release); |
106 | up(&idedisk_ref_sem); | 107 | mutex_unlock(&idedisk_ref_mutex); |
107 | } | 108 | } |
108 | 109 | ||
109 | /* | 110 | /* |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 1f8db9ac05d1..a53e3ce4a142 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -98,6 +98,7 @@ | |||
98 | #include <linux/cdrom.h> | 98 | #include <linux/cdrom.h> |
99 | #include <linux/ide.h> | 99 | #include <linux/ide.h> |
100 | #include <linux/bitops.h> | 100 | #include <linux/bitops.h> |
101 | #include <linux/mutex.h> | ||
101 | 102 | ||
102 | #include <asm/byteorder.h> | 103 | #include <asm/byteorder.h> |
103 | #include <asm/irq.h> | 104 | #include <asm/irq.h> |
@@ -517,7 +518,7 @@ typedef struct { | |||
517 | u8 reserved[4]; | 518 | u8 reserved[4]; |
518 | } idefloppy_mode_parameter_header_t; | 519 | } idefloppy_mode_parameter_header_t; |
519 | 520 | ||
520 | static DECLARE_MUTEX(idefloppy_ref_sem); | 521 | static DEFINE_MUTEX(idefloppy_ref_mutex); |
521 | 522 | ||
522 | #define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref) | 523 | #define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref) |
523 | 524 | ||
@@ -528,11 +529,11 @@ static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk) | |||
528 | { | 529 | { |
529 | struct ide_floppy_obj *floppy = NULL; | 530 | struct ide_floppy_obj *floppy = NULL; |
530 | 531 | ||
531 | down(&idefloppy_ref_sem); | 532 | mutex_lock(&idefloppy_ref_mutex); |
532 | floppy = ide_floppy_g(disk); | 533 | floppy = ide_floppy_g(disk); |
533 | if (floppy) | 534 | if (floppy) |
534 | kref_get(&floppy->kref); | 535 | kref_get(&floppy->kref); |
535 | up(&idefloppy_ref_sem); | 536 | mutex_unlock(&idefloppy_ref_mutex); |
536 | return floppy; | 537 | return floppy; |
537 | } | 538 | } |
538 | 539 | ||
@@ -540,9 +541,9 @@ static void ide_floppy_release(struct kref *); | |||
540 | 541 | ||
541 | static void ide_floppy_put(struct ide_floppy_obj *floppy) | 542 | static void ide_floppy_put(struct ide_floppy_obj *floppy) |
542 | { | 543 | { |
543 | down(&idefloppy_ref_sem); | 544 | mutex_lock(&idefloppy_ref_mutex); |
544 | kref_put(&floppy->kref, ide_floppy_release); | 545 | kref_put(&floppy->kref, ide_floppy_release); |
545 | up(&idefloppy_ref_sem); | 546 | mutex_unlock(&idefloppy_ref_mutex); |
546 | } | 547 | } |
547 | 548 | ||
548 | /* | 549 | /* |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 0101d0def7c5..ebc59064b475 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -443,6 +443,7 @@ | |||
443 | #include <linux/smp_lock.h> | 443 | #include <linux/smp_lock.h> |
444 | #include <linux/completion.h> | 444 | #include <linux/completion.h> |
445 | #include <linux/bitops.h> | 445 | #include <linux/bitops.h> |
446 | #include <linux/mutex.h> | ||
446 | 447 | ||
447 | #include <asm/byteorder.h> | 448 | #include <asm/byteorder.h> |
448 | #include <asm/irq.h> | 449 | #include <asm/irq.h> |
@@ -1011,7 +1012,7 @@ typedef struct ide_tape_obj { | |||
1011 | int debug_level; | 1012 | int debug_level; |
1012 | } idetape_tape_t; | 1013 | } idetape_tape_t; |
1013 | 1014 | ||
1014 | static DECLARE_MUTEX(idetape_ref_sem); | 1015 | static DEFINE_MUTEX(idetape_ref_mutex); |
1015 | 1016 | ||
1016 | static struct class *idetape_sysfs_class; | 1017 | static struct class *idetape_sysfs_class; |
1017 | 1018 | ||
@@ -1024,11 +1025,11 @@ static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) | |||
1024 | { | 1025 | { |
1025 | struct ide_tape_obj *tape = NULL; | 1026 | struct ide_tape_obj *tape = NULL; |
1026 | 1027 | ||
1027 | down(&idetape_ref_sem); | 1028 | mutex_lock(&idetape_ref_mutex); |
1028 | tape = ide_tape_g(disk); | 1029 | tape = ide_tape_g(disk); |
1029 | if (tape) | 1030 | if (tape) |
1030 | kref_get(&tape->kref); | 1031 | kref_get(&tape->kref); |
1031 | up(&idetape_ref_sem); | 1032 | mutex_unlock(&idetape_ref_mutex); |
1032 | return tape; | 1033 | return tape; |
1033 | } | 1034 | } |
1034 | 1035 | ||
@@ -1036,9 +1037,9 @@ static void ide_tape_release(struct kref *); | |||
1036 | 1037 | ||
1037 | static void ide_tape_put(struct ide_tape_obj *tape) | 1038 | static void ide_tape_put(struct ide_tape_obj *tape) |
1038 | { | 1039 | { |
1039 | down(&idetape_ref_sem); | 1040 | mutex_lock(&idetape_ref_mutex); |
1040 | kref_put(&tape->kref, ide_tape_release); | 1041 | kref_put(&tape->kref, ide_tape_release); |
1041 | up(&idetape_ref_sem); | 1042 | mutex_unlock(&idetape_ref_mutex); |
1042 | } | 1043 | } |
1043 | 1044 | ||
1044 | /* | 1045 | /* |
@@ -1290,11 +1291,11 @@ static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i) | |||
1290 | { | 1291 | { |
1291 | struct ide_tape_obj *tape = NULL; | 1292 | struct ide_tape_obj *tape = NULL; |
1292 | 1293 | ||
1293 | down(&idetape_ref_sem); | 1294 | mutex_lock(&idetape_ref_mutex); |
1294 | tape = idetape_devs[i]; | 1295 | tape = idetape_devs[i]; |
1295 | if (tape) | 1296 | if (tape) |
1296 | kref_get(&tape->kref); | 1297 | kref_get(&tape->kref); |
1297 | up(&idetape_ref_sem); | 1298 | mutex_unlock(&idetape_ref_mutex); |
1298 | return tape; | 1299 | return tape; |
1299 | } | 1300 | } |
1300 | 1301 | ||
@@ -4870,11 +4871,11 @@ static int ide_tape_probe(ide_drive_t *drive) | |||
4870 | 4871 | ||
4871 | drive->driver_data = tape; | 4872 | drive->driver_data = tape; |
4872 | 4873 | ||
4873 | down(&idetape_ref_sem); | 4874 | mutex_lock(&idetape_ref_mutex); |
4874 | for (minor = 0; idetape_devs[minor]; minor++) | 4875 | for (minor = 0; idetape_devs[minor]; minor++) |
4875 | ; | 4876 | ; |
4876 | idetape_devs[minor] = tape; | 4877 | idetape_devs[minor] = tape; |
4877 | up(&idetape_ref_sem); | 4878 | mutex_unlock(&idetape_ref_mutex); |
4878 | 4879 | ||
4879 | idetape_setup(drive, tape, minor); | 4880 | idetape_setup(drive, tape, minor); |
4880 | 4881 | ||
diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c index feec40cf5900..8c4fcb9027b3 100644 --- a/drivers/isdn/capi/kcapi.c +++ b/drivers/isdn/capi/kcapi.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #ifdef CONFIG_AVMB1_COMPAT | 32 | #ifdef CONFIG_AVMB1_COMPAT |
33 | #include <linux/b1lli.h> | 33 | #include <linux/b1lli.h> |
34 | #endif | 34 | #endif |
35 | #include <linux/mutex.h> | ||
35 | 36 | ||
36 | static char *revision = "$Revision: 1.1.2.8 $"; | 37 | static char *revision = "$Revision: 1.1.2.8 $"; |
37 | 38 | ||
@@ -66,7 +67,7 @@ LIST_HEAD(capi_drivers); | |||
66 | DEFINE_RWLOCK(capi_drivers_list_lock); | 67 | DEFINE_RWLOCK(capi_drivers_list_lock); |
67 | 68 | ||
68 | static DEFINE_RWLOCK(application_lock); | 69 | static DEFINE_RWLOCK(application_lock); |
69 | static DECLARE_MUTEX(controller_sem); | 70 | static DEFINE_MUTEX(controller_mutex); |
70 | 71 | ||
71 | struct capi20_appl *capi_applications[CAPI_MAXAPPL]; | 72 | struct capi20_appl *capi_applications[CAPI_MAXAPPL]; |
72 | struct capi_ctr *capi_cards[CAPI_MAXCONTR]; | 73 | struct capi_ctr *capi_cards[CAPI_MAXCONTR]; |
@@ -395,20 +396,20 @@ attach_capi_ctr(struct capi_ctr *card) | |||
395 | { | 396 | { |
396 | int i; | 397 | int i; |
397 | 398 | ||
398 | down(&controller_sem); | 399 | mutex_lock(&controller_mutex); |
399 | 400 | ||
400 | for (i = 0; i < CAPI_MAXCONTR; i++) { | 401 | for (i = 0; i < CAPI_MAXCONTR; i++) { |
401 | if (capi_cards[i] == NULL) | 402 | if (capi_cards[i] == NULL) |
402 | break; | 403 | break; |
403 | } | 404 | } |
404 | if (i == CAPI_MAXCONTR) { | 405 | if (i == CAPI_MAXCONTR) { |
405 | up(&controller_sem); | 406 | mutex_unlock(&controller_mutex); |
406 | printk(KERN_ERR "kcapi: out of controller slots\n"); | 407 | printk(KERN_ERR "kcapi: out of controller slots\n"); |
407 | return -EBUSY; | 408 | return -EBUSY; |
408 | } | 409 | } |
409 | capi_cards[i] = card; | 410 | capi_cards[i] = card; |
410 | 411 | ||
411 | up(&controller_sem); | 412 | mutex_unlock(&controller_mutex); |
412 | 413 | ||
413 | card->nrecvctlpkt = 0; | 414 | card->nrecvctlpkt = 0; |
414 | card->nrecvdatapkt = 0; | 415 | card->nrecvdatapkt = 0; |
@@ -531,13 +532,13 @@ u16 capi20_register(struct capi20_appl *ap) | |||
531 | 532 | ||
532 | write_unlock_irqrestore(&application_lock, flags); | 533 | write_unlock_irqrestore(&application_lock, flags); |
533 | 534 | ||
534 | down(&controller_sem); | 535 | mutex_lock(&controller_mutex); |
535 | for (i = 0; i < CAPI_MAXCONTR; i++) { | 536 | for (i = 0; i < CAPI_MAXCONTR; i++) { |
536 | if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING) | 537 | if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING) |
537 | continue; | 538 | continue; |
538 | register_appl(capi_cards[i], applid, &ap->rparam); | 539 | register_appl(capi_cards[i], applid, &ap->rparam); |
539 | } | 540 | } |
540 | up(&controller_sem); | 541 | mutex_unlock(&controller_mutex); |
541 | 542 | ||
542 | if (showcapimsgs & 1) { | 543 | if (showcapimsgs & 1) { |
543 | printk(KERN_DEBUG "kcapi: appl %d up\n", applid); | 544 | printk(KERN_DEBUG "kcapi: appl %d up\n", applid); |
@@ -560,13 +561,13 @@ u16 capi20_release(struct capi20_appl *ap) | |||
560 | capi_applications[ap->applid - 1] = NULL; | 561 | capi_applications[ap->applid - 1] = NULL; |
561 | write_unlock_irqrestore(&application_lock, flags); | 562 | write_unlock_irqrestore(&application_lock, flags); |
562 | 563 | ||
563 | down(&controller_sem); | 564 | mutex_lock(&controller_mutex); |
564 | for (i = 0; i < CAPI_MAXCONTR; i++) { | 565 | for (i = 0; i < CAPI_MAXCONTR; i++) { |
565 | if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING) | 566 | if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING) |
566 | continue; | 567 | continue; |
567 | release_appl(capi_cards[i], ap->applid); | 568 | release_appl(capi_cards[i], ap->applid); |
568 | } | 569 | } |
569 | up(&controller_sem); | 570 | mutex_unlock(&controller_mutex); |
570 | 571 | ||
571 | flush_scheduled_work(); | 572 | flush_scheduled_work(); |
572 | skb_queue_purge(&ap->recv_queue); | 573 | skb_queue_purge(&ap->recv_queue); |
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c index df9d65201819..27332506f9f7 100644 --- a/drivers/isdn/hisax/config.c +++ b/drivers/isdn/hisax/config.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/workqueue.h> | 25 | #include <linux/workqueue.h> |
26 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
27 | #define HISAX_STATUS_BUFSIZE 4096 | 27 | #define HISAX_STATUS_BUFSIZE 4096 |
28 | #define INCLUDE_INLINE_FUNCS | ||
29 | 28 | ||
30 | /* | 29 | /* |
31 | * This structure array contains one entry per card. An entry looks | 30 | * This structure array contains one entry per card. An entry looks |
diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c index 110e9fd669c5..f8ca4b323331 100644 --- a/drivers/isdn/hisax/elsa.c +++ b/drivers/isdn/hisax/elsa.c | |||
@@ -108,7 +108,6 @@ static const char *ITACVer[] = | |||
108 | #define ELSA_ASSIGN 4 | 108 | #define ELSA_ASSIGN 4 |
109 | 109 | ||
110 | #define RS_ISR_PASS_LIMIT 256 | 110 | #define RS_ISR_PASS_LIMIT 256 |
111 | #define _INLINE_ inline | ||
112 | #define FLG_MODEM_ACTIVE 1 | 111 | #define FLG_MODEM_ACTIVE 1 |
113 | /* IPAC AUX */ | 112 | /* IPAC AUX */ |
114 | #define ELSA_IPAC_LINE_LED 0x40 /* Bit 6 Gelbe LED */ | 113 | #define ELSA_IPAC_LINE_LED 0x40 /* Bit 6 Gelbe LED */ |
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c index d18bf9097dc9..671e36db224d 100644 --- a/drivers/media/video/adv7170.c +++ b/drivers/media/video/adv7170.c | |||
@@ -53,7 +53,6 @@ MODULE_AUTHOR("Maxim Yevtyushkin"); | |||
53 | MODULE_LICENSE("GPL"); | 53 | MODULE_LICENSE("GPL"); |
54 | 54 | ||
55 | #include <linux/i2c.h> | 55 | #include <linux/i2c.h> |
56 | #include <linux/i2c-dev.h> | ||
57 | 56 | ||
58 | #define I2C_NAME(x) (x)->name | 57 | #define I2C_NAME(x) (x)->name |
59 | 58 | ||
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index 1a2b111897d5..085e8863cacb 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c | |||
@@ -49,7 +49,6 @@ MODULE_AUTHOR("Dave Perks"); | |||
49 | MODULE_LICENSE("GPL"); | 49 | MODULE_LICENSE("GPL"); |
50 | 50 | ||
51 | #include <linux/i2c.h> | 51 | #include <linux/i2c.h> |
52 | #include <linux/i2c-dev.h> | ||
53 | 52 | ||
54 | #define I2C_NAME(s) (s)->name | 53 | #define I2C_NAME(s) (s)->name |
55 | 54 | ||
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c index c2c450fbf683..d8a18a6a5bee 100644 --- a/drivers/media/video/bt819.c +++ b/drivers/media/video/bt819.c | |||
@@ -53,7 +53,6 @@ MODULE_AUTHOR("Mike Bernson & Dave Perks"); | |||
53 | MODULE_LICENSE("GPL"); | 53 | MODULE_LICENSE("GPL"); |
54 | 54 | ||
55 | #include <linux/i2c.h> | 55 | #include <linux/i2c.h> |
56 | #include <linux/i2c-dev.h> | ||
57 | 56 | ||
58 | #define I2C_NAME(s) (s)->name | 57 | #define I2C_NAME(s) (s)->name |
59 | 58 | ||
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c index 7c68937853b0..4d47a0a0e974 100644 --- a/drivers/media/video/bt856.c +++ b/drivers/media/video/bt856.c | |||
@@ -53,7 +53,6 @@ MODULE_AUTHOR("Mike Bernson & Dave Perks"); | |||
53 | MODULE_LICENSE("GPL"); | 53 | MODULE_LICENSE("GPL"); |
54 | 54 | ||
55 | #include <linux/i2c.h> | 55 | #include <linux/i2c.h> |
56 | #include <linux/i2c-dev.h> | ||
57 | 56 | ||
58 | #define I2C_NAME(s) (s)->name | 57 | #define I2C_NAME(s) (s)->name |
59 | 58 | ||
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c index 36123fa0b63f..e18ea268384b 100644 --- a/drivers/media/video/saa7110.c +++ b/drivers/media/video/saa7110.c | |||
@@ -39,7 +39,6 @@ MODULE_AUTHOR("Pauline Middelink"); | |||
39 | MODULE_LICENSE("GPL"); | 39 | MODULE_LICENSE("GPL"); |
40 | 40 | ||
41 | #include <linux/i2c.h> | 41 | #include <linux/i2c.h> |
42 | #include <linux/i2c-dev.h> | ||
43 | 42 | ||
44 | #define I2C_NAME(s) (s)->name | 43 | #define I2C_NAME(s) (s)->name |
45 | 44 | ||
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index cb27917c376a..f9ba0c943adf 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c | |||
@@ -52,7 +52,6 @@ MODULE_AUTHOR("Dave Perks"); | |||
52 | MODULE_LICENSE("GPL"); | 52 | MODULE_LICENSE("GPL"); |
53 | 53 | ||
54 | #include <linux/i2c.h> | 54 | #include <linux/i2c.h> |
55 | #include <linux/i2c-dev.h> | ||
56 | 55 | ||
57 | #define I2C_NAME(s) (s)->name | 56 | #define I2C_NAME(s) (s)->name |
58 | 57 | ||
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c index 849b54cd5c24..4a1f841d0c77 100644 --- a/drivers/media/video/saa7114.c +++ b/drivers/media/video/saa7114.c | |||
@@ -55,7 +55,6 @@ MODULE_AUTHOR("Maxim Yevtyushkin"); | |||
55 | MODULE_LICENSE("GPL"); | 55 | MODULE_LICENSE("GPL"); |
56 | 56 | ||
57 | #include <linux/i2c.h> | 57 | #include <linux/i2c.h> |
58 | #include <linux/i2c-dev.h> | ||
59 | 58 | ||
60 | #define I2C_NAME(x) (x)->name | 59 | #define I2C_NAME(x) (x)->name |
61 | 60 | ||
diff --git a/drivers/media/video/saa711x.c b/drivers/media/video/saa711x.c index 6c161f2f5e2c..708fae51e8ee 100644 --- a/drivers/media/video/saa711x.c +++ b/drivers/media/video/saa711x.c | |||
@@ -45,7 +45,6 @@ MODULE_AUTHOR("Dave Perks, Jose Ignacio Gijon, Joerg Heckenbach, Mark McClelland | |||
45 | MODULE_LICENSE("GPL"); | 45 | MODULE_LICENSE("GPL"); |
46 | 46 | ||
47 | #include <linux/i2c.h> | 47 | #include <linux/i2c.h> |
48 | #include <linux/i2c-dev.h> | ||
49 | 48 | ||
50 | #define I2C_NAME(s) (s)->name | 49 | #define I2C_NAME(s) (s)->name |
51 | 50 | ||
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c index 67dfa7186453..9f99ee1303e0 100644 --- a/drivers/media/video/saa7185.c +++ b/drivers/media/video/saa7185.c | |||
@@ -49,7 +49,6 @@ MODULE_AUTHOR("Dave Perks"); | |||
49 | MODULE_LICENSE("GPL"); | 49 | MODULE_LICENSE("GPL"); |
50 | 50 | ||
51 | #include <linux/i2c.h> | 51 | #include <linux/i2c.h> |
52 | #include <linux/i2c-dev.h> | ||
53 | 52 | ||
54 | #define I2C_NAME(s) (s)->name | 53 | #define I2C_NAME(s) (s)->name |
55 | 54 | ||
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c index d0a1e72ea8c4..4cd579967487 100644 --- a/drivers/media/video/vpx3220.c +++ b/drivers/media/video/vpx3220.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <asm/uaccess.h> | 30 | #include <asm/uaccess.h> |
31 | 31 | ||
32 | #include <linux/i2c.h> | 32 | #include <linux/i2c.h> |
33 | #include <linux/i2c-dev.h> | ||
34 | 33 | ||
35 | #define I2C_NAME(x) (x)->name | 34 | #define I2C_NAME(x) (x)->name |
36 | 35 | ||
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index 7d213707008a..2671da20a496 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
@@ -9,13 +9,54 @@ | |||
9 | * Written by: Michael Chan (mchan@broadcom.com) | 9 | * Written by: Michael Chan (mchan@broadcom.com) |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/config.h> | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/moduleparam.h> | ||
16 | |||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/timer.h> | ||
19 | #include <linux/errno.h> | ||
20 | #include <linux/ioport.h> | ||
21 | #include <linux/slab.h> | ||
22 | #include <linux/vmalloc.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | #include <linux/pci.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/netdevice.h> | ||
27 | #include <linux/etherdevice.h> | ||
28 | #include <linux/skbuff.h> | ||
29 | #include <linux/dma-mapping.h> | ||
30 | #include <asm/bitops.h> | ||
31 | #include <asm/io.h> | ||
32 | #include <asm/irq.h> | ||
33 | #include <linux/delay.h> | ||
34 | #include <asm/byteorder.h> | ||
35 | #include <linux/time.h> | ||
36 | #include <linux/ethtool.h> | ||
37 | #include <linux/mii.h> | ||
38 | #ifdef NETIF_F_HW_VLAN_TX | ||
39 | #include <linux/if_vlan.h> | ||
40 | #define BCM_VLAN 1 | ||
41 | #endif | ||
42 | #ifdef NETIF_F_TSO | ||
43 | #include <net/ip.h> | ||
44 | #include <net/tcp.h> | ||
45 | #include <net/checksum.h> | ||
46 | #define BCM_TSO 1 | ||
47 | #endif | ||
48 | #include <linux/workqueue.h> | ||
49 | #include <linux/crc32.h> | ||
50 | #include <linux/prefetch.h> | ||
51 | #include <linux/cache.h> | ||
52 | |||
12 | #include "bnx2.h" | 53 | #include "bnx2.h" |
13 | #include "bnx2_fw.h" | 54 | #include "bnx2_fw.h" |
14 | 55 | ||
15 | #define DRV_MODULE_NAME "bnx2" | 56 | #define DRV_MODULE_NAME "bnx2" |
16 | #define PFX DRV_MODULE_NAME ": " | 57 | #define PFX DRV_MODULE_NAME ": " |
17 | #define DRV_MODULE_VERSION "1.4.38" | 58 | #define DRV_MODULE_VERSION "1.4.39" |
18 | #define DRV_MODULE_RELDATE "February 10, 2006" | 59 | #define DRV_MODULE_RELDATE "March 22, 2006" |
19 | 60 | ||
20 | #define RUN_AT(x) (jiffies + (x)) | 61 | #define RUN_AT(x) (jiffies + (x)) |
21 | 62 | ||
@@ -313,8 +354,6 @@ bnx2_disable_int(struct bnx2 *bp) | |||
313 | static void | 354 | static void |
314 | bnx2_enable_int(struct bnx2 *bp) | 355 | bnx2_enable_int(struct bnx2 *bp) |
315 | { | 356 | { |
316 | u32 val; | ||
317 | |||
318 | REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD, | 357 | REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD, |
319 | BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | | 358 | BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | |
320 | BNX2_PCICFG_INT_ACK_CMD_MASK_INT | bp->last_status_idx); | 359 | BNX2_PCICFG_INT_ACK_CMD_MASK_INT | bp->last_status_idx); |
@@ -322,8 +361,7 @@ bnx2_enable_int(struct bnx2 *bp) | |||
322 | REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD, | 361 | REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD, |
323 | BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | bp->last_status_idx); | 362 | BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | bp->last_status_idx); |
324 | 363 | ||
325 | val = REG_RD(bp, BNX2_HC_COMMAND); | 364 | REG_WR(bp, BNX2_HC_COMMAND, bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW); |
326 | REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW); | ||
327 | } | 365 | } |
328 | 366 | ||
329 | static void | 367 | static void |
@@ -362,15 +400,11 @@ bnx2_free_mem(struct bnx2 *bp) | |||
362 | { | 400 | { |
363 | int i; | 401 | int i; |
364 | 402 | ||
365 | if (bp->stats_blk) { | ||
366 | pci_free_consistent(bp->pdev, sizeof(struct statistics_block), | ||
367 | bp->stats_blk, bp->stats_blk_mapping); | ||
368 | bp->stats_blk = NULL; | ||
369 | } | ||
370 | if (bp->status_blk) { | 403 | if (bp->status_blk) { |
371 | pci_free_consistent(bp->pdev, sizeof(struct status_block), | 404 | pci_free_consistent(bp->pdev, bp->status_stats_size, |
372 | bp->status_blk, bp->status_blk_mapping); | 405 | bp->status_blk, bp->status_blk_mapping); |
373 | bp->status_blk = NULL; | 406 | bp->status_blk = NULL; |
407 | bp->stats_blk = NULL; | ||
374 | } | 408 | } |
375 | if (bp->tx_desc_ring) { | 409 | if (bp->tx_desc_ring) { |
376 | pci_free_consistent(bp->pdev, | 410 | pci_free_consistent(bp->pdev, |
@@ -395,14 +429,13 @@ bnx2_free_mem(struct bnx2 *bp) | |||
395 | static int | 429 | static int |
396 | bnx2_alloc_mem(struct bnx2 *bp) | 430 | bnx2_alloc_mem(struct bnx2 *bp) |
397 | { | 431 | { |
398 | int i; | 432 | int i, status_blk_size; |
399 | 433 | ||
400 | bp->tx_buf_ring = kmalloc(sizeof(struct sw_bd) * TX_DESC_CNT, | 434 | bp->tx_buf_ring = kzalloc(sizeof(struct sw_bd) * TX_DESC_CNT, |
401 | GFP_KERNEL); | 435 | GFP_KERNEL); |
402 | if (bp->tx_buf_ring == NULL) | 436 | if (bp->tx_buf_ring == NULL) |
403 | return -ENOMEM; | 437 | return -ENOMEM; |
404 | 438 | ||
405 | memset(bp->tx_buf_ring, 0, sizeof(struct sw_bd) * TX_DESC_CNT); | ||
406 | bp->tx_desc_ring = pci_alloc_consistent(bp->pdev, | 439 | bp->tx_desc_ring = pci_alloc_consistent(bp->pdev, |
407 | sizeof(struct tx_bd) * | 440 | sizeof(struct tx_bd) * |
408 | TX_DESC_CNT, | 441 | TX_DESC_CNT, |
@@ -428,21 +461,22 @@ bnx2_alloc_mem(struct bnx2 *bp) | |||
428 | 461 | ||
429 | } | 462 | } |
430 | 463 | ||
431 | bp->status_blk = pci_alloc_consistent(bp->pdev, | 464 | /* Combine status and statistics blocks into one allocation. */ |
432 | sizeof(struct status_block), | 465 | status_blk_size = L1_CACHE_ALIGN(sizeof(struct status_block)); |
466 | bp->status_stats_size = status_blk_size + | ||
467 | sizeof(struct statistics_block); | ||
468 | |||
469 | bp->status_blk = pci_alloc_consistent(bp->pdev, bp->status_stats_size, | ||
433 | &bp->status_blk_mapping); | 470 | &bp->status_blk_mapping); |
434 | if (bp->status_blk == NULL) | 471 | if (bp->status_blk == NULL) |
435 | goto alloc_mem_err; | 472 | goto alloc_mem_err; |
436 | 473 | ||
437 | memset(bp->status_blk, 0, sizeof(struct status_block)); | 474 | memset(bp->status_blk, 0, bp->status_stats_size); |
438 | 475 | ||
439 | bp->stats_blk = pci_alloc_consistent(bp->pdev, | 476 | bp->stats_blk = (void *) ((unsigned long) bp->status_blk + |
440 | sizeof(struct statistics_block), | 477 | status_blk_size); |
441 | &bp->stats_blk_mapping); | ||
442 | if (bp->stats_blk == NULL) | ||
443 | goto alloc_mem_err; | ||
444 | 478 | ||
445 | memset(bp->stats_blk, 0, sizeof(struct statistics_block)); | 479 | bp->stats_blk_mapping = bp->status_blk_mapping + status_blk_size; |
446 | 480 | ||
447 | return 0; | 481 | return 0; |
448 | 482 | ||
@@ -1926,6 +1960,13 @@ bnx2_poll(struct net_device *dev, int *budget) | |||
1926 | spin_lock(&bp->phy_lock); | 1960 | spin_lock(&bp->phy_lock); |
1927 | bnx2_phy_int(bp); | 1961 | bnx2_phy_int(bp); |
1928 | spin_unlock(&bp->phy_lock); | 1962 | spin_unlock(&bp->phy_lock); |
1963 | |||
1964 | /* This is needed to take care of transient status | ||
1965 | * during link changes. | ||
1966 | */ | ||
1967 | REG_WR(bp, BNX2_HC_COMMAND, | ||
1968 | bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW_WO_INT); | ||
1969 | REG_RD(bp, BNX2_HC_COMMAND); | ||
1929 | } | 1970 | } |
1930 | 1971 | ||
1931 | if (bp->status_blk->status_tx_quick_consumer_index0 != bp->hw_tx_cons) | 1972 | if (bp->status_blk->status_tx_quick_consumer_index0 != bp->hw_tx_cons) |
@@ -3307,6 +3348,8 @@ bnx2_init_chip(struct bnx2 *bp) | |||
3307 | 3348 | ||
3308 | udelay(20); | 3349 | udelay(20); |
3309 | 3350 | ||
3351 | bp->hc_cmd = REG_RD(bp, BNX2_HC_COMMAND); | ||
3352 | |||
3310 | return rc; | 3353 | return rc; |
3311 | } | 3354 | } |
3312 | 3355 | ||
@@ -3746,7 +3789,6 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode) | |||
3746 | struct sk_buff *skb, *rx_skb; | 3789 | struct sk_buff *skb, *rx_skb; |
3747 | unsigned char *packet; | 3790 | unsigned char *packet; |
3748 | u16 rx_start_idx, rx_idx; | 3791 | u16 rx_start_idx, rx_idx; |
3749 | u32 val; | ||
3750 | dma_addr_t map; | 3792 | dma_addr_t map; |
3751 | struct tx_bd *txbd; | 3793 | struct tx_bd *txbd; |
3752 | struct sw_bd *rx_buf; | 3794 | struct sw_bd *rx_buf; |
@@ -3777,8 +3819,9 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode) | |||
3777 | map = pci_map_single(bp->pdev, skb->data, pkt_size, | 3819 | map = pci_map_single(bp->pdev, skb->data, pkt_size, |
3778 | PCI_DMA_TODEVICE); | 3820 | PCI_DMA_TODEVICE); |
3779 | 3821 | ||
3780 | val = REG_RD(bp, BNX2_HC_COMMAND); | 3822 | REG_WR(bp, BNX2_HC_COMMAND, |
3781 | REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW_WO_INT); | 3823 | bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW_WO_INT); |
3824 | |||
3782 | REG_RD(bp, BNX2_HC_COMMAND); | 3825 | REG_RD(bp, BNX2_HC_COMMAND); |
3783 | 3826 | ||
3784 | udelay(5); | 3827 | udelay(5); |
@@ -3802,8 +3845,9 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode) | |||
3802 | 3845 | ||
3803 | udelay(100); | 3846 | udelay(100); |
3804 | 3847 | ||
3805 | val = REG_RD(bp, BNX2_HC_COMMAND); | 3848 | REG_WR(bp, BNX2_HC_COMMAND, |
3806 | REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW_WO_INT); | 3849 | bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW_WO_INT); |
3850 | |||
3807 | REG_RD(bp, BNX2_HC_COMMAND); | 3851 | REG_RD(bp, BNX2_HC_COMMAND); |
3808 | 3852 | ||
3809 | udelay(5); | 3853 | udelay(5); |
@@ -3939,7 +3983,6 @@ static int | |||
3939 | bnx2_test_intr(struct bnx2 *bp) | 3983 | bnx2_test_intr(struct bnx2 *bp) |
3940 | { | 3984 | { |
3941 | int i; | 3985 | int i; |
3942 | u32 val; | ||
3943 | u16 status_idx; | 3986 | u16 status_idx; |
3944 | 3987 | ||
3945 | if (!netif_running(bp->dev)) | 3988 | if (!netif_running(bp->dev)) |
@@ -3948,8 +3991,7 @@ bnx2_test_intr(struct bnx2 *bp) | |||
3948 | status_idx = REG_RD(bp, BNX2_PCICFG_INT_ACK_CMD) & 0xffff; | 3991 | status_idx = REG_RD(bp, BNX2_PCICFG_INT_ACK_CMD) & 0xffff; |
3949 | 3992 | ||
3950 | /* This register is not touched during run-time. */ | 3993 | /* This register is not touched during run-time. */ |
3951 | val = REG_RD(bp, BNX2_HC_COMMAND); | 3994 | REG_WR(bp, BNX2_HC_COMMAND, bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW); |
3952 | REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW); | ||
3953 | REG_RD(bp, BNX2_HC_COMMAND); | 3995 | REG_RD(bp, BNX2_HC_COMMAND); |
3954 | 3996 | ||
3955 | for (i = 0; i < 10; i++) { | 3997 | for (i = 0; i < 10; i++) { |
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h index fd4b7f2eb477..b87925f6a228 100644 --- a/drivers/net/bnx2.h +++ b/drivers/net/bnx2.h | |||
@@ -13,46 +13,6 @@ | |||
13 | #ifndef BNX2_H | 13 | #ifndef BNX2_H |
14 | #define BNX2_H | 14 | #define BNX2_H |
15 | 15 | ||
16 | #include <linux/config.h> | ||
17 | |||
18 | #include <linux/module.h> | ||
19 | #include <linux/moduleparam.h> | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/timer.h> | ||
23 | #include <linux/errno.h> | ||
24 | #include <linux/ioport.h> | ||
25 | #include <linux/slab.h> | ||
26 | #include <linux/vmalloc.h> | ||
27 | #include <linux/interrupt.h> | ||
28 | #include <linux/pci.h> | ||
29 | #include <linux/init.h> | ||
30 | #include <linux/netdevice.h> | ||
31 | #include <linux/etherdevice.h> | ||
32 | #include <linux/skbuff.h> | ||
33 | #include <linux/dma-mapping.h> | ||
34 | #include <asm/bitops.h> | ||
35 | #include <asm/io.h> | ||
36 | #include <asm/irq.h> | ||
37 | #include <linux/delay.h> | ||
38 | #include <asm/byteorder.h> | ||
39 | #include <linux/time.h> | ||
40 | #include <linux/ethtool.h> | ||
41 | #include <linux/mii.h> | ||
42 | #ifdef NETIF_F_HW_VLAN_TX | ||
43 | #include <linux/if_vlan.h> | ||
44 | #define BCM_VLAN 1 | ||
45 | #endif | ||
46 | #ifdef NETIF_F_TSO | ||
47 | #include <net/ip.h> | ||
48 | #include <net/tcp.h> | ||
49 | #include <net/checksum.h> | ||
50 | #define BCM_TSO 1 | ||
51 | #endif | ||
52 | #include <linux/workqueue.h> | ||
53 | #include <linux/crc32.h> | ||
54 | #include <linux/prefetch.h> | ||
55 | |||
56 | /* Hardware data structures and register definitions automatically | 16 | /* Hardware data structures and register definitions automatically |
57 | * generated from RTL code. Do not modify. | 17 | * generated from RTL code. Do not modify. |
58 | */ | 18 | */ |
@@ -3917,15 +3877,17 @@ struct bnx2 { | |||
3917 | #define USING_MSI_FLAG 0x20 | 3877 | #define USING_MSI_FLAG 0x20 |
3918 | #define ASF_ENABLE_FLAG 0x40 | 3878 | #define ASF_ENABLE_FLAG 0x40 |
3919 | 3879 | ||
3920 | struct tx_bd *tx_desc_ring; | 3880 | /* Put tx producer and consumer fields in separate cache lines. */ |
3921 | struct sw_bd *tx_buf_ring; | ||
3922 | u32 tx_prod_bseq; | ||
3923 | u16 tx_prod; | ||
3924 | u16 tx_cons; | ||
3925 | int tx_ring_size; | ||
3926 | 3881 | ||
3927 | u16 hw_tx_cons; | 3882 | u32 tx_prod_bseq __attribute__((aligned(L1_CACHE_BYTES))); |
3928 | u16 hw_rx_cons; | 3883 | u16 tx_prod; |
3884 | |||
3885 | struct tx_bd *tx_desc_ring; | ||
3886 | struct sw_bd *tx_buf_ring; | ||
3887 | int tx_ring_size; | ||
3888 | |||
3889 | u16 tx_cons __attribute__((aligned(L1_CACHE_BYTES))); | ||
3890 | u16 hw_tx_cons; | ||
3929 | 3891 | ||
3930 | #ifdef BCM_VLAN | 3892 | #ifdef BCM_VLAN |
3931 | struct vlan_group *vlgrp; | 3893 | struct vlan_group *vlgrp; |
@@ -3939,6 +3901,7 @@ struct bnx2 { | |||
3939 | u32 rx_prod_bseq; | 3901 | u32 rx_prod_bseq; |
3940 | u16 rx_prod; | 3902 | u16 rx_prod; |
3941 | u16 rx_cons; | 3903 | u16 rx_cons; |
3904 | u16 hw_rx_cons; | ||
3942 | 3905 | ||
3943 | u32 rx_csum; | 3906 | u32 rx_csum; |
3944 | 3907 | ||
@@ -4038,6 +4001,7 @@ struct bnx2 { | |||
4038 | struct statistics_block *stats_blk; | 4001 | struct statistics_block *stats_blk; |
4039 | dma_addr_t stats_blk_mapping; | 4002 | dma_addr_t stats_blk_mapping; |
4040 | 4003 | ||
4004 | u32 hc_cmd; | ||
4041 | u32 rx_mode; | 4005 | u32 rx_mode; |
4042 | 4006 | ||
4043 | u16 req_line_speed; | 4007 | u16 req_line_speed; |
@@ -4082,6 +4046,8 @@ struct bnx2 { | |||
4082 | 4046 | ||
4083 | struct flash_spec *flash_info; | 4047 | struct flash_spec *flash_info; |
4084 | u32 flash_size; | 4048 | u32 flash_size; |
4049 | |||
4050 | int status_stats_size; | ||
4085 | }; | 4051 | }; |
4086 | 4052 | ||
4087 | static u32 bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset); | 4053 | static u32 bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset); |
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 690a1aae0b34..0c13795dca38 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c | |||
@@ -172,11 +172,9 @@ static struct net_device_stats *get_stats(struct net_device *dev) | |||
172 | 172 | ||
173 | memset(stats, 0, sizeof(struct net_device_stats)); | 173 | memset(stats, 0, sizeof(struct net_device_stats)); |
174 | 174 | ||
175 | for (i=0; i < NR_CPUS; i++) { | 175 | for_each_cpu(i) { |
176 | struct net_device_stats *lb_stats; | 176 | struct net_device_stats *lb_stats; |
177 | 177 | ||
178 | if (!cpu_possible(i)) | ||
179 | continue; | ||
180 | lb_stats = &per_cpu(loopback_stats, i); | 178 | lb_stats = &per_cpu(loopback_stats, i); |
181 | stats->rx_bytes += lb_stats->rx_bytes; | 179 | stats->rx_bytes += lb_stats->rx_bytes; |
182 | stats->tx_bytes += lb_stats->tx_bytes; | 180 | stats->tx_bytes += lb_stats->tx_bytes; |
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c index f608c12e3e8b..b2073fce8216 100644 --- a/drivers/net/ppp_generic.c +++ b/drivers/net/ppp_generic.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/rwsem.h> | 46 | #include <linux/rwsem.h> |
47 | #include <linux/stddef.h> | 47 | #include <linux/stddef.h> |
48 | #include <linux/device.h> | 48 | #include <linux/device.h> |
49 | #include <linux/mutex.h> | ||
49 | #include <net/slhc_vj.h> | 50 | #include <net/slhc_vj.h> |
50 | #include <asm/atomic.h> | 51 | #include <asm/atomic.h> |
51 | 52 | ||
@@ -198,11 +199,11 @@ static unsigned int cardmap_find_first_free(struct cardmap *map); | |||
198 | static void cardmap_destroy(struct cardmap **map); | 199 | static void cardmap_destroy(struct cardmap **map); |
199 | 200 | ||
200 | /* | 201 | /* |
201 | * all_ppp_sem protects the all_ppp_units mapping. | 202 | * all_ppp_mutex protects the all_ppp_units mapping. |
202 | * It also ensures that finding a ppp unit in the all_ppp_units map | 203 | * It also ensures that finding a ppp unit in the all_ppp_units map |
203 | * and updating its file.refcnt field is atomic. | 204 | * and updating its file.refcnt field is atomic. |
204 | */ | 205 | */ |
205 | static DECLARE_MUTEX(all_ppp_sem); | 206 | static DEFINE_MUTEX(all_ppp_mutex); |
206 | static struct cardmap *all_ppp_units; | 207 | static struct cardmap *all_ppp_units; |
207 | static atomic_t ppp_unit_count = ATOMIC_INIT(0); | 208 | static atomic_t ppp_unit_count = ATOMIC_INIT(0); |
208 | 209 | ||
@@ -804,7 +805,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file, | |||
804 | /* Attach to an existing ppp unit */ | 805 | /* Attach to an existing ppp unit */ |
805 | if (get_user(unit, p)) | 806 | if (get_user(unit, p)) |
806 | break; | 807 | break; |
807 | down(&all_ppp_sem); | 808 | mutex_lock(&all_ppp_mutex); |
808 | err = -ENXIO; | 809 | err = -ENXIO; |
809 | ppp = ppp_find_unit(unit); | 810 | ppp = ppp_find_unit(unit); |
810 | if (ppp != 0) { | 811 | if (ppp != 0) { |
@@ -812,7 +813,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file, | |||
812 | file->private_data = &ppp->file; | 813 | file->private_data = &ppp->file; |
813 | err = 0; | 814 | err = 0; |
814 | } | 815 | } |
815 | up(&all_ppp_sem); | 816 | mutex_unlock(&all_ppp_mutex); |
816 | break; | 817 | break; |
817 | 818 | ||
818 | case PPPIOCATTCHAN: | 819 | case PPPIOCATTCHAN: |
@@ -2446,7 +2447,7 @@ ppp_create_interface(int unit, int *retp) | |||
2446 | dev->do_ioctl = ppp_net_ioctl; | 2447 | dev->do_ioctl = ppp_net_ioctl; |
2447 | 2448 | ||
2448 | ret = -EEXIST; | 2449 | ret = -EEXIST; |
2449 | down(&all_ppp_sem); | 2450 | mutex_lock(&all_ppp_mutex); |
2450 | if (unit < 0) | 2451 | if (unit < 0) |
2451 | unit = cardmap_find_first_free(all_ppp_units); | 2452 | unit = cardmap_find_first_free(all_ppp_units); |
2452 | else if (cardmap_get(all_ppp_units, unit) != NULL) | 2453 | else if (cardmap_get(all_ppp_units, unit) != NULL) |
@@ -2465,12 +2466,12 @@ ppp_create_interface(int unit, int *retp) | |||
2465 | 2466 | ||
2466 | atomic_inc(&ppp_unit_count); | 2467 | atomic_inc(&ppp_unit_count); |
2467 | cardmap_set(&all_ppp_units, unit, ppp); | 2468 | cardmap_set(&all_ppp_units, unit, ppp); |
2468 | up(&all_ppp_sem); | 2469 | mutex_unlock(&all_ppp_mutex); |
2469 | *retp = 0; | 2470 | *retp = 0; |
2470 | return ppp; | 2471 | return ppp; |
2471 | 2472 | ||
2472 | out2: | 2473 | out2: |
2473 | up(&all_ppp_sem); | 2474 | mutex_unlock(&all_ppp_mutex); |
2474 | free_netdev(dev); | 2475 | free_netdev(dev); |
2475 | out1: | 2476 | out1: |
2476 | kfree(ppp); | 2477 | kfree(ppp); |
@@ -2500,7 +2501,7 @@ static void ppp_shutdown_interface(struct ppp *ppp) | |||
2500 | { | 2501 | { |
2501 | struct net_device *dev; | 2502 | struct net_device *dev; |
2502 | 2503 | ||
2503 | down(&all_ppp_sem); | 2504 | mutex_lock(&all_ppp_mutex); |
2504 | ppp_lock(ppp); | 2505 | ppp_lock(ppp); |
2505 | dev = ppp->dev; | 2506 | dev = ppp->dev; |
2506 | ppp->dev = NULL; | 2507 | ppp->dev = NULL; |
@@ -2514,7 +2515,7 @@ static void ppp_shutdown_interface(struct ppp *ppp) | |||
2514 | ppp->file.dead = 1; | 2515 | ppp->file.dead = 1; |
2515 | ppp->owner = NULL; | 2516 | ppp->owner = NULL; |
2516 | wake_up_interruptible(&ppp->file.rwait); | 2517 | wake_up_interruptible(&ppp->file.rwait); |
2517 | up(&all_ppp_sem); | 2518 | mutex_unlock(&all_ppp_mutex); |
2518 | } | 2519 | } |
2519 | 2520 | ||
2520 | /* | 2521 | /* |
@@ -2556,7 +2557,7 @@ static void ppp_destroy_interface(struct ppp *ppp) | |||
2556 | 2557 | ||
2557 | /* | 2558 | /* |
2558 | * Locate an existing ppp unit. | 2559 | * Locate an existing ppp unit. |
2559 | * The caller should have locked the all_ppp_sem. | 2560 | * The caller should have locked the all_ppp_mutex. |
2560 | */ | 2561 | */ |
2561 | static struct ppp * | 2562 | static struct ppp * |
2562 | ppp_find_unit(int unit) | 2563 | ppp_find_unit(int unit) |
@@ -2601,7 +2602,7 @@ ppp_connect_channel(struct channel *pch, int unit) | |||
2601 | int ret = -ENXIO; | 2602 | int ret = -ENXIO; |
2602 | int hdrlen; | 2603 | int hdrlen; |
2603 | 2604 | ||
2604 | down(&all_ppp_sem); | 2605 | mutex_lock(&all_ppp_mutex); |
2605 | ppp = ppp_find_unit(unit); | 2606 | ppp = ppp_find_unit(unit); |
2606 | if (ppp == 0) | 2607 | if (ppp == 0) |
2607 | goto out; | 2608 | goto out; |
@@ -2626,7 +2627,7 @@ ppp_connect_channel(struct channel *pch, int unit) | |||
2626 | outl: | 2627 | outl: |
2627 | write_unlock_bh(&pch->upl); | 2628 | write_unlock_bh(&pch->upl); |
2628 | out: | 2629 | out: |
2629 | up(&all_ppp_sem); | 2630 | mutex_unlock(&all_ppp_mutex); |
2630 | return ret; | 2631 | return ret; |
2631 | } | 2632 | } |
2632 | 2633 | ||
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 88829eb9568e..b5473325bff4 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -69,8 +69,8 @@ | |||
69 | 69 | ||
70 | #define DRV_MODULE_NAME "tg3" | 70 | #define DRV_MODULE_NAME "tg3" |
71 | #define PFX DRV_MODULE_NAME ": " | 71 | #define PFX DRV_MODULE_NAME ": " |
72 | #define DRV_MODULE_VERSION "3.53" | 72 | #define DRV_MODULE_VERSION "3.54" |
73 | #define DRV_MODULE_RELDATE "Mar 22, 2006" | 73 | #define DRV_MODULE_RELDATE "Mar 23, 2006" |
74 | 74 | ||
75 | #define TG3_DEF_MAC_MODE 0 | 75 | #define TG3_DEF_MAC_MODE 0 |
76 | #define TG3_DEF_RX_MODE 0 | 76 | #define TG3_DEF_RX_MODE 0 |
@@ -225,6 +225,10 @@ static struct pci_device_id tg3_pci_tbl[] = { | |||
225 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | 225 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
226 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5754M, | 226 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5754M, |
227 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | 227 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
228 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5755, | ||
229 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | ||
230 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5755M, | ||
231 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | ||
228 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787, | 232 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787, |
229 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, | 233 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
230 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787M, | 234 | { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787M, |
@@ -4557,6 +4561,7 @@ static int tg3_chip_reset(struct tg3 *tp) | |||
4557 | } | 4561 | } |
4558 | 4562 | ||
4559 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || | 4563 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || |
4564 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || | ||
4560 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | 4565 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) |
4561 | tw32(GRC_FASTBOOT_PC, 0); | 4566 | tw32(GRC_FASTBOOT_PC, 0); |
4562 | 4567 | ||
@@ -6152,6 +6157,9 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
6152 | gpio_mask |= GRC_LCLCTRL_GPIO_OE3 | | 6157 | gpio_mask |= GRC_LCLCTRL_GPIO_OE3 | |
6153 | GRC_LCLCTRL_GPIO_OUTPUT3; | 6158 | GRC_LCLCTRL_GPIO_OUTPUT3; |
6154 | 6159 | ||
6160 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) | ||
6161 | gpio_mask |= GRC_LCLCTRL_GPIO_UART_SEL; | ||
6162 | |||
6155 | tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask; | 6163 | tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask; |
6156 | 6164 | ||
6157 | /* GPIO1 must be driven high for eeprom write protect */ | 6165 | /* GPIO1 must be driven high for eeprom write protect */ |
@@ -6191,7 +6199,8 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
6191 | } | 6199 | } |
6192 | 6200 | ||
6193 | /* Enable host coalescing bug fix */ | 6201 | /* Enable host coalescing bug fix */ |
6194 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | 6202 | if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) || |
6203 | (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)) | ||
6195 | val |= (1 << 29); | 6204 | val |= (1 << 29); |
6196 | 6205 | ||
6197 | tw32_f(WDMAC_MODE, val); | 6206 | tw32_f(WDMAC_MODE, val); |
@@ -6249,6 +6258,9 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
6249 | udelay(100); | 6258 | udelay(100); |
6250 | 6259 | ||
6251 | tp->rx_mode = RX_MODE_ENABLE; | 6260 | tp->rx_mode = RX_MODE_ENABLE; |
6261 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) | ||
6262 | tp->rx_mode |= RX_MODE_IPV6_CSUM_ENABLE; | ||
6263 | |||
6252 | tw32_f(MAC_RX_MODE, tp->rx_mode); | 6264 | tw32_f(MAC_RX_MODE, tp->rx_mode); |
6253 | udelay(10); | 6265 | udelay(10); |
6254 | 6266 | ||
@@ -7907,7 +7919,8 @@ static int tg3_set_tx_csum(struct net_device *dev, u32 data) | |||
7907 | return 0; | 7919 | return 0; |
7908 | } | 7920 | } |
7909 | 7921 | ||
7910 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | 7922 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || |
7923 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | ||
7911 | ethtool_op_set_tx_hw_csum(dev, data); | 7924 | ethtool_op_set_tx_hw_csum(dev, data); |
7912 | else | 7925 | else |
7913 | ethtool_op_set_tx_csum(dev, data); | 7926 | ethtool_op_set_tx_csum(dev, data); |
@@ -8332,7 +8345,8 @@ static int tg3_test_memory(struct tg3 *tp) | |||
8332 | int i; | 8345 | int i; |
8333 | 8346 | ||
8334 | if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) { | 8347 | if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) { |
8335 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | 8348 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || |
8349 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | ||
8336 | mem_tbl = mem_tbl_5755; | 8350 | mem_tbl = mem_tbl_5755; |
8337 | else | 8351 | else |
8338 | mem_tbl = mem_tbl_5705; | 8352 | mem_tbl = mem_tbl_5705; |
@@ -8924,6 +8938,47 @@ static void __devinit tg3_get_5752_nvram_info(struct tg3 *tp) | |||
8924 | } | 8938 | } |
8925 | } | 8939 | } |
8926 | 8940 | ||
8941 | static void __devinit tg3_get_5755_nvram_info(struct tg3 *tp) | ||
8942 | { | ||
8943 | u32 nvcfg1; | ||
8944 | |||
8945 | nvcfg1 = tr32(NVRAM_CFG1); | ||
8946 | |||
8947 | /* NVRAM protection for TPM */ | ||
8948 | if (nvcfg1 & (1 << 27)) | ||
8949 | tp->tg3_flags2 |= TG3_FLG2_PROTECTED_NVRAM; | ||
8950 | |||
8951 | switch (nvcfg1 & NVRAM_CFG1_5752VENDOR_MASK) { | ||
8952 | case FLASH_5755VENDOR_ATMEL_EEPROM_64KHZ: | ||
8953 | case FLASH_5755VENDOR_ATMEL_EEPROM_376KHZ: | ||
8954 | tp->nvram_jedecnum = JEDEC_ATMEL; | ||
8955 | tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; | ||
8956 | tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE; | ||
8957 | |||
8958 | nvcfg1 &= ~NVRAM_CFG1_COMPAT_BYPASS; | ||
8959 | tw32(NVRAM_CFG1, nvcfg1); | ||
8960 | break; | ||
8961 | case FLASH_5752VENDOR_ATMEL_FLASH_BUFFERED: | ||
8962 | case FLASH_5755VENDOR_ATMEL_FLASH_1: | ||
8963 | case FLASH_5755VENDOR_ATMEL_FLASH_2: | ||
8964 | case FLASH_5755VENDOR_ATMEL_FLASH_3: | ||
8965 | case FLASH_5755VENDOR_ATMEL_FLASH_4: | ||
8966 | tp->nvram_jedecnum = JEDEC_ATMEL; | ||
8967 | tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; | ||
8968 | tp->tg3_flags2 |= TG3_FLG2_FLASH; | ||
8969 | tp->nvram_pagesize = 264; | ||
8970 | break; | ||
8971 | case FLASH_5752VENDOR_ST_M45PE10: | ||
8972 | case FLASH_5752VENDOR_ST_M45PE20: | ||
8973 | case FLASH_5752VENDOR_ST_M45PE40: | ||
8974 | tp->nvram_jedecnum = JEDEC_ST; | ||
8975 | tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED; | ||
8976 | tp->tg3_flags2 |= TG3_FLG2_FLASH; | ||
8977 | tp->nvram_pagesize = 256; | ||
8978 | break; | ||
8979 | } | ||
8980 | } | ||
8981 | |||
8927 | static void __devinit tg3_get_5787_nvram_info(struct tg3 *tp) | 8982 | static void __devinit tg3_get_5787_nvram_info(struct tg3 *tp) |
8928 | { | 8983 | { |
8929 | u32 nvcfg1; | 8984 | u32 nvcfg1; |
@@ -8997,6 +9052,8 @@ static void __devinit tg3_nvram_init(struct tg3 *tp) | |||
8997 | 9052 | ||
8998 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) | 9053 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) |
8999 | tg3_get_5752_nvram_info(tp); | 9054 | tg3_get_5752_nvram_info(tp); |
9055 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) | ||
9056 | tg3_get_5755_nvram_info(tp); | ||
9000 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | 9057 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) |
9001 | tg3_get_5787_nvram_info(tp); | 9058 | tg3_get_5787_nvram_info(tp); |
9002 | else | 9059 | else |
@@ -9310,6 +9367,7 @@ static int tg3_nvram_write_block_buffered(struct tg3 *tp, u32 offset, u32 len, | |||
9310 | nvram_cmd |= NVRAM_CMD_LAST; | 9367 | nvram_cmd |= NVRAM_CMD_LAST; |
9311 | 9368 | ||
9312 | if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752) && | 9369 | if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752) && |
9370 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5755) && | ||
9313 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787) && | 9371 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787) && |
9314 | (tp->nvram_jedecnum == JEDEC_ST) && | 9372 | (tp->nvram_jedecnum == JEDEC_ST) && |
9315 | (nvram_cmd & NVRAM_CMD_FIRST)) { | 9373 | (nvram_cmd & NVRAM_CMD_FIRST)) { |
@@ -10044,6 +10102,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
10044 | 10102 | ||
10045 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 || | 10103 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 || |
10046 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || | 10104 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || |
10105 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || | ||
10047 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787 || | 10106 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787 || |
10048 | (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) | 10107 | (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) |
10049 | tp->tg3_flags2 |= TG3_FLG2_5750_PLUS; | 10108 | tp->tg3_flags2 |= TG3_FLG2_5750_PLUS; |
@@ -10053,7 +10112,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
10053 | tp->tg3_flags2 |= TG3_FLG2_5705_PLUS; | 10112 | tp->tg3_flags2 |= TG3_FLG2_5705_PLUS; |
10054 | 10113 | ||
10055 | if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) { | 10114 | if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) { |
10056 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) { | 10115 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || |
10116 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) { | ||
10057 | tp->tg3_flags2 |= TG3_FLG2_HW_TSO_2; | 10117 | tp->tg3_flags2 |= TG3_FLG2_HW_TSO_2; |
10058 | tp->tg3_flags2 |= TG3_FLG2_1SHOT_MSI; | 10118 | tp->tg3_flags2 |= TG3_FLG2_1SHOT_MSI; |
10059 | } else | 10119 | } else |
@@ -10063,6 +10123,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
10063 | if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && | 10123 | if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && |
10064 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750 && | 10124 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750 && |
10065 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752 && | 10125 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752 && |
10126 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5755 && | ||
10066 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787) | 10127 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787) |
10067 | tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE; | 10128 | tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE; |
10068 | 10129 | ||
@@ -10219,6 +10280,9 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
10219 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) | 10280 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) |
10220 | tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3; | 10281 | tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3; |
10221 | 10282 | ||
10283 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) | ||
10284 | tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_UART_SEL; | ||
10285 | |||
10222 | /* Force the chip into D0. */ | 10286 | /* Force the chip into D0. */ |
10223 | err = tg3_set_power_state(tp, PCI_D0); | 10287 | err = tg3_set_power_state(tp, PCI_D0); |
10224 | if (err) { | 10288 | if (err) { |
@@ -10274,6 +10338,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
10274 | tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG; | 10338 | tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG; |
10275 | 10339 | ||
10276 | if ((tp->tg3_flags2 & TG3_FLG2_5705_PLUS) && | 10340 | if ((tp->tg3_flags2 & TG3_FLG2_5705_PLUS) && |
10341 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5755) && | ||
10277 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787)) | 10342 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787)) |
10278 | tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; | 10343 | tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; |
10279 | 10344 | ||
@@ -10413,7 +10478,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
10413 | /* All chips before 5787 can get confused if TX buffers | 10478 | /* All chips before 5787 can get confused if TX buffers |
10414 | * straddle the 4GB address boundary in some cases. | 10479 | * straddle the 4GB address boundary in some cases. |
10415 | */ | 10480 | */ |
10416 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | 10481 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || |
10482 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | ||
10417 | tp->dev->hard_start_xmit = tg3_start_xmit; | 10483 | tp->dev->hard_start_xmit = tg3_start_xmit; |
10418 | else | 10484 | else |
10419 | tp->dev->hard_start_xmit = tg3_start_xmit_dma_bug; | 10485 | tp->dev->hard_start_xmit = tg3_start_xmit_dma_bug; |
@@ -11002,6 +11068,7 @@ static char * __devinit tg3_phy_string(struct tg3 *tp) | |||
11002 | case PHY_ID_BCM5752: return "5752"; | 11068 | case PHY_ID_BCM5752: return "5752"; |
11003 | case PHY_ID_BCM5714: return "5714"; | 11069 | case PHY_ID_BCM5714: return "5714"; |
11004 | case PHY_ID_BCM5780: return "5780"; | 11070 | case PHY_ID_BCM5780: return "5780"; |
11071 | case PHY_ID_BCM5755: return "5755"; | ||
11005 | case PHY_ID_BCM5787: return "5787"; | 11072 | case PHY_ID_BCM5787: return "5787"; |
11006 | case PHY_ID_BCM8002: return "8002/serdes"; | 11073 | case PHY_ID_BCM8002: return "8002/serdes"; |
11007 | case 0: return "serdes"; | 11074 | case 0: return "serdes"; |
@@ -11350,7 +11417,8 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, | |||
11350 | * checksumming. | 11417 | * checksumming. |
11351 | */ | 11418 | */ |
11352 | if ((tp->tg3_flags & TG3_FLAG_BROKEN_CHECKSUMS) == 0) { | 11419 | if ((tp->tg3_flags & TG3_FLAG_BROKEN_CHECKSUMS) == 0) { |
11353 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | 11420 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || |
11421 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) | ||
11354 | dev->features |= NETIF_F_HW_CSUM; | 11422 | dev->features |= NETIF_F_HW_CSUM; |
11355 | else | 11423 | else |
11356 | dev->features |= NETIF_F_IP_CSUM; | 11424 | dev->features |= NETIF_F_IP_CSUM; |
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h index baa34c4721db..c43cc3264202 100644 --- a/drivers/net/tg3.h +++ b/drivers/net/tg3.h | |||
@@ -138,6 +138,7 @@ | |||
138 | #define ASIC_REV_5752 0x06 | 138 | #define ASIC_REV_5752 0x06 |
139 | #define ASIC_REV_5780 0x08 | 139 | #define ASIC_REV_5780 0x08 |
140 | #define ASIC_REV_5714 0x09 | 140 | #define ASIC_REV_5714 0x09 |
141 | #define ASIC_REV_5755 0x0a | ||
141 | #define ASIC_REV_5787 0x0b | 142 | #define ASIC_REV_5787 0x0b |
142 | #define GET_CHIP_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 8) | 143 | #define GET_CHIP_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 8) |
143 | #define CHIPREV_5700_AX 0x70 | 144 | #define CHIPREV_5700_AX 0x70 |
@@ -456,6 +457,7 @@ | |||
456 | #define RX_MODE_PROMISC 0x00000100 | 457 | #define RX_MODE_PROMISC 0x00000100 |
457 | #define RX_MODE_NO_CRC_CHECK 0x00000200 | 458 | #define RX_MODE_NO_CRC_CHECK 0x00000200 |
458 | #define RX_MODE_KEEP_VLAN_TAG 0x00000400 | 459 | #define RX_MODE_KEEP_VLAN_TAG 0x00000400 |
460 | #define RX_MODE_IPV6_CSUM_ENABLE 0x01000000 | ||
459 | #define MAC_RX_STATUS 0x0000046c | 461 | #define MAC_RX_STATUS 0x0000046c |
460 | #define RX_STATUS_REMOTE_TX_XOFFED 0x00000001 | 462 | #define RX_STATUS_REMOTE_TX_XOFFED 0x00000001 |
461 | #define RX_STATUS_XOFF_RCVD 0x00000002 | 463 | #define RX_STATUS_XOFF_RCVD 0x00000002 |
@@ -1340,6 +1342,7 @@ | |||
1340 | #define GRC_LCLCTRL_CLEARINT 0x00000002 | 1342 | #define GRC_LCLCTRL_CLEARINT 0x00000002 |
1341 | #define GRC_LCLCTRL_SETINT 0x00000004 | 1343 | #define GRC_LCLCTRL_SETINT 0x00000004 |
1342 | #define GRC_LCLCTRL_INT_ON_ATTN 0x00000008 | 1344 | #define GRC_LCLCTRL_INT_ON_ATTN 0x00000008 |
1345 | #define GRC_LCLCTRL_GPIO_UART_SEL 0x00000010 /* 5755 only */ | ||
1343 | #define GRC_LCLCTRL_USE_SIG_DETECT 0x00000010 /* 5714/5780 only */ | 1346 | #define GRC_LCLCTRL_USE_SIG_DETECT 0x00000010 /* 5714/5780 only */ |
1344 | #define GRC_LCLCTRL_USE_EXT_SIG_DETECT 0x00000020 /* 5714/5780 only */ | 1347 | #define GRC_LCLCTRL_USE_EXT_SIG_DETECT 0x00000020 /* 5714/5780 only */ |
1345 | #define GRC_LCLCTRL_GPIO_INPUT3 0x00000020 | 1348 | #define GRC_LCLCTRL_GPIO_INPUT3 0x00000020 |
@@ -1441,6 +1444,9 @@ | |||
1441 | #define FLASH_5755VENDOR_ATMEL_FLASH_1 0x03400001 | 1444 | #define FLASH_5755VENDOR_ATMEL_FLASH_1 0x03400001 |
1442 | #define FLASH_5755VENDOR_ATMEL_FLASH_2 0x03400002 | 1445 | #define FLASH_5755VENDOR_ATMEL_FLASH_2 0x03400002 |
1443 | #define FLASH_5755VENDOR_ATMEL_FLASH_3 0x03400000 | 1446 | #define FLASH_5755VENDOR_ATMEL_FLASH_3 0x03400000 |
1447 | #define FLASH_5755VENDOR_ATMEL_FLASH_4 0x00000003 | ||
1448 | #define FLASH_5755VENDOR_ATMEL_EEPROM_64KHZ 0x03c00003 | ||
1449 | #define FLASH_5755VENDOR_ATMEL_EEPROM_376KHZ 0x03c00002 | ||
1444 | #define FLASH_5787VENDOR_ATMEL_EEPROM_64KHZ 0x03000003 | 1450 | #define FLASH_5787VENDOR_ATMEL_EEPROM_64KHZ 0x03000003 |
1445 | #define FLASH_5787VENDOR_ATMEL_EEPROM_376KHZ 0x03000002 | 1451 | #define FLASH_5787VENDOR_ATMEL_EEPROM_376KHZ 0x03000002 |
1446 | #define FLASH_5787VENDOR_MICRO_EEPROM_64KHZ 0x03000000 | 1452 | #define FLASH_5787VENDOR_MICRO_EEPROM_64KHZ 0x03000000 |
@@ -2259,6 +2265,7 @@ struct tg3 { | |||
2259 | #define PHY_ID_BCM5752 0x60008100 | 2265 | #define PHY_ID_BCM5752 0x60008100 |
2260 | #define PHY_ID_BCM5714 0x60008340 | 2266 | #define PHY_ID_BCM5714 0x60008340 |
2261 | #define PHY_ID_BCM5780 0x60008350 | 2267 | #define PHY_ID_BCM5780 0x60008350 |
2268 | #define PHY_ID_BCM5755 0xbc050cc0 | ||
2262 | #define PHY_ID_BCM5787 0xbc050ce0 | 2269 | #define PHY_ID_BCM5787 0xbc050ce0 |
2263 | #define PHY_ID_BCM8002 0x60010140 | 2270 | #define PHY_ID_BCM8002 0x60010140 |
2264 | #define PHY_ID_INVALID 0xffffffff | 2271 | #define PHY_ID_INVALID 0xffffffff |
@@ -2286,7 +2293,7 @@ struct tg3 { | |||
2286 | (X) == PHY_ID_BCM5705 || (X) == PHY_ID_BCM5750 || \ | 2293 | (X) == PHY_ID_BCM5705 || (X) == PHY_ID_BCM5750 || \ |
2287 | (X) == PHY_ID_BCM5752 || (X) == PHY_ID_BCM5714 || \ | 2294 | (X) == PHY_ID_BCM5752 || (X) == PHY_ID_BCM5714 || \ |
2288 | (X) == PHY_ID_BCM5780 || (X) == PHY_ID_BCM5787 || \ | 2295 | (X) == PHY_ID_BCM5780 || (X) == PHY_ID_BCM5787 || \ |
2289 | (X) == PHY_ID_BCM8002) | 2296 | (X) == PHY_ID_BCM5755 || (X) == PHY_ID_BCM8002) |
2290 | 2297 | ||
2291 | struct tg3_hw_stats *hw_stats; | 2298 | struct tg3_hw_stats *hw_stats; |
2292 | dma_addr_t stats_mapping; | 2299 | dma_addr_t stats_mapping; |
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c index 78193e4bbdb5..330d3869b41e 100644 --- a/drivers/oprofile/cpu_buffer.c +++ b/drivers/oprofile/cpu_buffer.c | |||
@@ -38,9 +38,8 @@ void free_cpu_buffers(void) | |||
38 | { | 38 | { |
39 | int i; | 39 | int i; |
40 | 40 | ||
41 | for_each_online_cpu(i) { | 41 | for_each_online_cpu(i) |
42 | vfree(cpu_buffer[i].buffer); | 42 | vfree(cpu_buffer[i].buffer); |
43 | } | ||
44 | } | 43 | } |
45 | 44 | ||
46 | int alloc_cpu_buffers(void) | 45 | int alloc_cpu_buffers(void) |
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index f187fd8aeed6..4d762fc4878c 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig | |||
@@ -11,24 +11,11 @@ config PCI_MSI | |||
11 | generate an interrupt using an inbound Memory Write on its | 11 | generate an interrupt using an inbound Memory Write on its |
12 | PCI bus instead of asserting a device IRQ pin. | 12 | PCI bus instead of asserting a device IRQ pin. |
13 | 13 | ||
14 | If you don't know what to do here, say N. | 14 | Use of PCI MSI interrupts can be disabled at kernel boot time |
15 | 15 | by using the 'pci=nomsi' option. This disables MSI for the | |
16 | config PCI_LEGACY_PROC | 16 | entire system. |
17 | bool "Legacy /proc/pci interface" | ||
18 | depends on PCI | ||
19 | ---help--- | ||
20 | This feature enables a procfs file -- /proc/pci -- that provides a | ||
21 | summary of PCI devices in the system. | ||
22 | |||
23 | This feature has been deprecated as of v2.5.53, in favor of using the | ||
24 | tool lspci(8). This feature may be removed at a future date. | ||
25 | 17 | ||
26 | lspci can provide the same data, as well as much more. lspci is a part of | 18 | If you don't know what to do here, say N. |
27 | the pci-utils package, which should be installed by your distribution. | ||
28 | See <file:Documentation/Changes> for information on where to get the latest | ||
29 | version. | ||
30 | |||
31 | When in doubt, say N. | ||
32 | 19 | ||
33 | config PCI_DEBUG | 20 | config PCI_DEBUG |
34 | bool "PCI Debugging" | 21 | bool "PCI Debugging" |
diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile index 3c71e3077ff1..421cfffb1756 100644 --- a/drivers/pci/hotplug/Makefile +++ b/drivers/pci/hotplug/Makefile | |||
@@ -22,6 +22,9 @@ ifdef CONFIG_HOTPLUG_PCI_CPCI | |||
22 | pci_hotplug-objs += cpci_hotplug_core.o \ | 22 | pci_hotplug-objs += cpci_hotplug_core.o \ |
23 | cpci_hotplug_pci.o | 23 | cpci_hotplug_pci.o |
24 | endif | 24 | endif |
25 | ifdef CONFIG_ACPI | ||
26 | pci_hotplug-objs += acpi_pcihp.o | ||
27 | endif | ||
25 | 28 | ||
26 | cpqphp-objs := cpqphp_core.o \ | 29 | cpqphp-objs := cpqphp_core.o \ |
27 | cpqphp_ctrl.o \ | 30 | cpqphp_ctrl.o \ |
@@ -37,7 +40,8 @@ ibmphp-objs := ibmphp_core.o \ | |||
37 | ibmphp_hpc.o | 40 | ibmphp_hpc.o |
38 | 41 | ||
39 | acpiphp-objs := acpiphp_core.o \ | 42 | acpiphp-objs := acpiphp_core.o \ |
40 | acpiphp_glue.o | 43 | acpiphp_glue.o \ |
44 | acpiphp_dock.o | ||
41 | 45 | ||
42 | rpaphp-objs := rpaphp_core.o \ | 46 | rpaphp-objs := rpaphp_core.o \ |
43 | rpaphp_pci.o \ | 47 | rpaphp_pci.o \ |
@@ -50,23 +54,9 @@ pciehp-objs := pciehp_core.o \ | |||
50 | pciehp_ctrl.o \ | 54 | pciehp_ctrl.o \ |
51 | pciehp_pci.o \ | 55 | pciehp_pci.o \ |
52 | pciehp_hpc.o | 56 | pciehp_hpc.o |
53 | ifdef CONFIG_ACPI | ||
54 | pciehp-objs += pciehprm_acpi.o | ||
55 | else | ||
56 | pciehp-objs += pciehprm_nonacpi.o | ||
57 | endif | ||
58 | 57 | ||
59 | shpchp-objs := shpchp_core.o \ | 58 | shpchp-objs := shpchp_core.o \ |
60 | shpchp_ctrl.o \ | 59 | shpchp_ctrl.o \ |
61 | shpchp_pci.o \ | 60 | shpchp_pci.o \ |
62 | shpchp_sysfs.o \ | 61 | shpchp_sysfs.o \ |
63 | shpchp_hpc.o | 62 | shpchp_hpc.o |
64 | ifdef CONFIG_ACPI | ||
65 | shpchp-objs += shpchprm_acpi.o | ||
66 | else | ||
67 | ifdef CONFIG_HOTPLUG_PCI_SHPC_PHPRM_LEGACY | ||
68 | shpchp-objs += shpchprm_legacy.o | ||
69 | else | ||
70 | shpchp-objs += shpchprm_nonacpi.o | ||
71 | endif | ||
72 | endif | ||
diff --git a/drivers/pci/hotplug/shpchprm_acpi.c b/drivers/pci/hotplug/acpi_pcihp.c index 17145e52223a..39af9c325f35 100644 --- a/drivers/pci/hotplug/shpchprm_acpi.c +++ b/drivers/pci/hotplug/acpi_pcihp.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * SHPCHPRM ACPI: PHP Resource Manager for ACPI platform | 2 | * Common ACPI functions for hot plug platforms |
3 | * | 3 | * |
4 | * Copyright (C) 2003-2004 Intel Corporation | 4 | * Copyright (C) 2006 Intel Corporation |
5 | * | 5 | * |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
@@ -31,26 +31,12 @@ | |||
31 | #include <acpi/acpi.h> | 31 | #include <acpi/acpi.h> |
32 | #include <acpi/acpi_bus.h> | 32 | #include <acpi/acpi_bus.h> |
33 | #include <acpi/actypes.h> | 33 | #include <acpi/actypes.h> |
34 | #include "shpchp.h" | 34 | #include "pci_hotplug.h" |
35 | 35 | ||
36 | #define METHOD_NAME__SUN "_SUN" | 36 | #define METHOD_NAME__SUN "_SUN" |
37 | #define METHOD_NAME__HPP "_HPP" | 37 | #define METHOD_NAME__HPP "_HPP" |
38 | #define METHOD_NAME_OSHP "OSHP" | 38 | #define METHOD_NAME_OSHP "OSHP" |
39 | 39 | ||
40 | static u8 * acpi_path_name( acpi_handle handle) | ||
41 | { | ||
42 | acpi_status status; | ||
43 | static u8 path_name[ACPI_PATHNAME_MAX]; | ||
44 | struct acpi_buffer ret_buf = { ACPI_PATHNAME_MAX, path_name }; | ||
45 | |||
46 | memset(path_name, 0, sizeof (path_name)); | ||
47 | status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &ret_buf); | ||
48 | |||
49 | if (ACPI_FAILURE(status)) | ||
50 | return NULL; | ||
51 | else | ||
52 | return path_name; | ||
53 | } | ||
54 | 40 | ||
55 | static acpi_status | 41 | static acpi_status |
56 | acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp) | 42 | acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp) |
@@ -58,18 +44,21 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp) | |||
58 | acpi_status status; | 44 | acpi_status status; |
59 | u8 nui[4]; | 45 | u8 nui[4]; |
60 | struct acpi_buffer ret_buf = { 0, NULL}; | 46 | struct acpi_buffer ret_buf = { 0, NULL}; |
47 | struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
61 | union acpi_object *ext_obj, *package; | 48 | union acpi_object *ext_obj, *package; |
62 | u8 *path_name = acpi_path_name(handle); | ||
63 | int i, len = 0; | 49 | int i, len = 0; |
64 | 50 | ||
51 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &string); | ||
52 | |||
65 | /* get _hpp */ | 53 | /* get _hpp */ |
66 | status = acpi_evaluate_object(handle, METHOD_NAME__HPP, NULL, &ret_buf); | 54 | status = acpi_evaluate_object(handle, METHOD_NAME__HPP, NULL, &ret_buf); |
67 | switch (status) { | 55 | switch (status) { |
68 | case AE_BUFFER_OVERFLOW: | 56 | case AE_BUFFER_OVERFLOW: |
69 | ret_buf.pointer = kmalloc (ret_buf.length, GFP_KERNEL); | 57 | ret_buf.pointer = kmalloc (ret_buf.length, GFP_KERNEL); |
70 | if (!ret_buf.pointer) { | 58 | if (!ret_buf.pointer) { |
71 | err ("%s:%s alloc for _HPP fail\n", __FUNCTION__, | 59 | printk(KERN_ERR "%s:%s alloc for _HPP fail\n", |
72 | path_name); | 60 | __FUNCTION__, (char *)string.pointer); |
61 | acpi_os_free(string.pointer); | ||
73 | return AE_NO_MEMORY; | 62 | return AE_NO_MEMORY; |
74 | } | 63 | } |
75 | status = acpi_evaluate_object(handle, METHOD_NAME__HPP, | 64 | status = acpi_evaluate_object(handle, METHOD_NAME__HPP, |
@@ -78,16 +67,17 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp) | |||
78 | break; | 67 | break; |
79 | default: | 68 | default: |
80 | if (ACPI_FAILURE(status)) { | 69 | if (ACPI_FAILURE(status)) { |
81 | dbg("%s:%s _HPP fail=0x%x\n", __FUNCTION__, | 70 | pr_debug("%s:%s _HPP fail=0x%x\n", __FUNCTION__, |
82 | path_name, status); | 71 | (char *)string.pointer, status); |
72 | acpi_os_free(string.pointer); | ||
83 | return status; | 73 | return status; |
84 | } | 74 | } |
85 | } | 75 | } |
86 | 76 | ||
87 | ext_obj = (union acpi_object *) ret_buf.pointer; | 77 | ext_obj = (union acpi_object *) ret_buf.pointer; |
88 | if (ext_obj->type != ACPI_TYPE_PACKAGE) { | 78 | if (ext_obj->type != ACPI_TYPE_PACKAGE) { |
89 | err ("%s:%s _HPP obj not a package\n", __FUNCTION__, | 79 | printk(KERN_ERR "%s:%s _HPP obj not a package\n", __FUNCTION__, |
90 | path_name); | 80 | (char *)string.pointer); |
91 | status = AE_ERROR; | 81 | status = AE_ERROR; |
92 | goto free_and_return; | 82 | goto free_and_return; |
93 | } | 83 | } |
@@ -101,8 +91,8 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp) | |||
101 | nui[i] = (u8)ext_obj->integer.value; | 91 | nui[i] = (u8)ext_obj->integer.value; |
102 | break; | 92 | break; |
103 | default: | 93 | default: |
104 | err ("%s:%s _HPP obj type incorrect\n", __FUNCTION__, | 94 | printk(KERN_ERR "%s:%s _HPP obj type incorrect\n", |
105 | path_name); | 95 | __FUNCTION__, (char *)string.pointer); |
106 | status = AE_ERROR; | 96 | status = AE_ERROR; |
107 | goto free_and_return; | 97 | goto free_and_return; |
108 | } | 98 | } |
@@ -113,54 +103,52 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp) | |||
113 | hpp->enable_serr = nui[2]; | 103 | hpp->enable_serr = nui[2]; |
114 | hpp->enable_perr = nui[3]; | 104 | hpp->enable_perr = nui[3]; |
115 | 105 | ||
116 | dbg(" _HPP: cache_line_size=0x%x\n", hpp->cache_line_size); | 106 | pr_debug(" _HPP: cache_line_size=0x%x\n", hpp->cache_line_size); |
117 | dbg(" _HPP: latency timer =0x%x\n", hpp->latency_timer); | 107 | pr_debug(" _HPP: latency timer =0x%x\n", hpp->latency_timer); |
118 | dbg(" _HPP: enable SERR =0x%x\n", hpp->enable_serr); | 108 | pr_debug(" _HPP: enable SERR =0x%x\n", hpp->enable_serr); |
119 | dbg(" _HPP: enable PERR =0x%x\n", hpp->enable_perr); | 109 | pr_debug(" _HPP: enable PERR =0x%x\n", hpp->enable_perr); |
120 | 110 | ||
121 | free_and_return: | 111 | free_and_return: |
122 | kfree(ret_buf.pointer); | 112 | acpi_os_free(string.pointer); |
113 | acpi_os_free(ret_buf.pointer); | ||
123 | return status; | 114 | return status; |
124 | } | 115 | } |
125 | 116 | ||
126 | static void acpi_run_oshp(acpi_handle handle) | 117 | |
118 | |||
119 | /* acpi_run_oshp - get control of hotplug from the firmware | ||
120 | * | ||
121 | * @handle - the handle of the hotplug controller. | ||
122 | */ | ||
123 | acpi_status acpi_run_oshp(acpi_handle handle) | ||
127 | { | 124 | { |
128 | acpi_status status; | 125 | acpi_status status; |
129 | u8 *path_name = acpi_path_name(handle); | 126 | struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL }; |
127 | |||
128 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &string); | ||
130 | 129 | ||
131 | /* run OSHP */ | 130 | /* run OSHP */ |
132 | status = acpi_evaluate_object(handle, METHOD_NAME_OSHP, NULL, NULL); | 131 | status = acpi_evaluate_object(handle, METHOD_NAME_OSHP, NULL, NULL); |
133 | if (ACPI_FAILURE(status)) { | 132 | if (ACPI_FAILURE(status)) |
134 | err("%s:%s OSHP fails=0x%x\n", __FUNCTION__, path_name, | 133 | printk(KERN_ERR "%s:%s OSHP fails=0x%x\n", __FUNCTION__, |
135 | status); | 134 | (char *)string.pointer, status); |
136 | } else { | 135 | else |
137 | dbg("%s:%s OSHP passes\n", __FUNCTION__, path_name); | 136 | pr_debug("%s:%s OSHP passes\n", __FUNCTION__, |
138 | } | 137 | (char *)string.pointer); |
139 | } | ||
140 | |||
141 | int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum) | ||
142 | { | ||
143 | int offset = devnum - ctrl->slot_device_offset; | ||
144 | 138 | ||
145 | dbg("%s: ctrl->slot_num_inc %d, offset %d\n", __FUNCTION__, ctrl->slot_num_inc, offset); | 139 | acpi_os_free(string.pointer); |
146 | *sun = (u8) (ctrl->first_slot + ctrl->slot_num_inc *offset); | 140 | return status; |
147 | return 0; | ||
148 | } | 141 | } |
142 | EXPORT_SYMBOL_GPL(acpi_run_oshp); | ||
143 | |||
149 | 144 | ||
150 | void get_hp_hw_control_from_firmware(struct pci_dev *dev) | ||
151 | { | ||
152 | /* | ||
153 | * OSHP is an optional ACPI firmware control method. If present, | ||
154 | * we need to run it to inform BIOS that we will control SHPC | ||
155 | * hardware from now on. | ||
156 | */ | ||
157 | acpi_handle handle = DEVICE_ACPI_HANDLE(&(dev->dev)); | ||
158 | if (!handle) | ||
159 | return; | ||
160 | acpi_run_oshp(handle); | ||
161 | } | ||
162 | 145 | ||
163 | void get_hp_params_from_firmware(struct pci_dev *dev, | 146 | /* acpi_get_hp_params_from_firmware |
147 | * | ||
148 | * @dev - the pci_dev of the newly added device | ||
149 | * @hpp - allocated by the caller | ||
150 | */ | ||
151 | acpi_status acpi_get_hp_params_from_firmware(struct pci_dev *dev, | ||
164 | struct hotplug_params *hpp) | 152 | struct hotplug_params *hpp) |
165 | { | 153 | { |
166 | acpi_status status = AE_NOT_FOUND; | 154 | acpi_status status = AE_NOT_FOUND; |
@@ -182,5 +170,42 @@ void get_hp_params_from_firmware(struct pci_dev *dev, | |||
182 | /* Check if a parent object supports _HPP */ | 170 | /* Check if a parent object supports _HPP */ |
183 | pdev = pdev->bus->parent->self; | 171 | pdev = pdev->bus->parent->self; |
184 | } | 172 | } |
173 | return status; | ||
185 | } | 174 | } |
175 | EXPORT_SYMBOL_GPL(acpi_get_hp_params_from_firmware); | ||
186 | 176 | ||
177 | |||
178 | /* acpi_root_bridge - check to see if this acpi object is a root bridge | ||
179 | * | ||
180 | * @handle - the acpi object in question. | ||
181 | */ | ||
182 | int acpi_root_bridge(acpi_handle handle) | ||
183 | { | ||
184 | acpi_status status; | ||
185 | struct acpi_device_info *info; | ||
186 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
187 | int i; | ||
188 | |||
189 | status = acpi_get_object_info(handle, &buffer); | ||
190 | if (ACPI_SUCCESS(status)) { | ||
191 | info = buffer.pointer; | ||
192 | if ((info->valid & ACPI_VALID_HID) && | ||
193 | !strcmp(PCI_ROOT_HID_STRING, | ||
194 | info->hardware_id.value)) { | ||
195 | acpi_os_free(buffer.pointer); | ||
196 | return 1; | ||
197 | } | ||
198 | if (info->valid & ACPI_VALID_CID) { | ||
199 | for (i=0; i < info->compatibility_id.count; i++) { | ||
200 | if (!strcmp(PCI_ROOT_HID_STRING, | ||
201 | info->compatibility_id.id[i].value)) { | ||
202 | acpi_os_free(buffer.pointer); | ||
203 | return 1; | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | acpi_os_free(buffer.pointer); | ||
208 | } | ||
209 | return 0; | ||
210 | } | ||
211 | EXPORT_SYMBOL_GPL(acpi_root_bridge); | ||
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h index 293603e1b7c3..467ac70a46ff 100644 --- a/drivers/pci/hotplug/acpiphp.h +++ b/drivers/pci/hotplug/acpiphp.h | |||
@@ -37,6 +37,7 @@ | |||
37 | 37 | ||
38 | #include <linux/acpi.h> | 38 | #include <linux/acpi.h> |
39 | #include <linux/kobject.h> /* for KOBJ_NAME_LEN */ | 39 | #include <linux/kobject.h> /* for KOBJ_NAME_LEN */ |
40 | #include <linux/mutex.h> | ||
40 | #include "pci_hotplug.h" | 41 | #include "pci_hotplug.h" |
41 | 42 | ||
42 | #define dbg(format, arg...) \ | 43 | #define dbg(format, arg...) \ |
@@ -59,26 +60,10 @@ struct acpiphp_slot; | |||
59 | * struct slot - slot information for each *physical* slot | 60 | * struct slot - slot information for each *physical* slot |
60 | */ | 61 | */ |
61 | struct slot { | 62 | struct slot { |
62 | u8 number; | ||
63 | struct hotplug_slot *hotplug_slot; | 63 | struct hotplug_slot *hotplug_slot; |
64 | struct list_head slot_list; | ||
65 | |||
66 | struct acpiphp_slot *acpi_slot; | 64 | struct acpiphp_slot *acpi_slot; |
67 | }; | 65 | }; |
68 | 66 | ||
69 | /** | ||
70 | * struct hpp_param - ACPI 2.0 _HPP Hot Plug Parameters | ||
71 | * @cache_line_size in DWORD | ||
72 | * @latency_timer in PCI clock | ||
73 | * @enable_SERR 0 or 1 | ||
74 | * @enable_PERR 0 or 1 | ||
75 | */ | ||
76 | struct hpp_param { | ||
77 | u8 cache_line_size; | ||
78 | u8 latency_timer; | ||
79 | u8 enable_SERR; | ||
80 | u8 enable_PERR; | ||
81 | }; | ||
82 | 67 | ||
83 | 68 | ||
84 | /** | 69 | /** |
@@ -102,7 +87,7 @@ struct acpiphp_bridge { | |||
102 | struct pci_dev *pci_dev; | 87 | struct pci_dev *pci_dev; |
103 | 88 | ||
104 | /* ACPI 2.0 _HPP parameters */ | 89 | /* ACPI 2.0 _HPP parameters */ |
105 | struct hpp_param hpp; | 90 | struct hotplug_params hpp; |
106 | 91 | ||
107 | spinlock_t res_lock; | 92 | spinlock_t res_lock; |
108 | }; | 93 | }; |
@@ -118,9 +103,9 @@ struct acpiphp_slot { | |||
118 | struct acpiphp_bridge *bridge; /* parent */ | 103 | struct acpiphp_bridge *bridge; /* parent */ |
119 | struct list_head funcs; /* one slot may have different | 104 | struct list_head funcs; /* one slot may have different |
120 | objects (i.e. for each function) */ | 105 | objects (i.e. for each function) */ |
121 | struct semaphore crit_sect; | 106 | struct slot *slot; |
107 | struct mutex crit_sect; | ||
122 | 108 | ||
123 | u32 id; /* slot id (serial #) for hotplug core */ | ||
124 | u8 device; /* pci device# */ | 109 | u8 device; /* pci device# */ |
125 | 110 | ||
126 | u32 sun; /* ACPI _SUN (slot unique number) */ | 111 | u32 sun; /* ACPI _SUN (slot unique number) */ |
@@ -160,6 +145,25 @@ struct acpiphp_attention_info | |||
160 | struct module *owner; | 145 | struct module *owner; |
161 | }; | 146 | }; |
162 | 147 | ||
148 | |||
149 | struct dependent_device { | ||
150 | struct list_head device_list; | ||
151 | struct list_head pci_list; | ||
152 | acpi_handle handle; | ||
153 | struct acpiphp_func *func; | ||
154 | }; | ||
155 | |||
156 | |||
157 | struct acpiphp_dock_station { | ||
158 | acpi_handle handle; | ||
159 | u32 last_dock_time; | ||
160 | u32 flags; | ||
161 | struct acpiphp_func *dock_bridge; | ||
162 | struct list_head dependent_devices; | ||
163 | struct list_head pci_dependent_devices; | ||
164 | }; | ||
165 | |||
166 | |||
163 | /* PCI bus bridge HID */ | 167 | /* PCI bus bridge HID */ |
164 | #define ACPI_PCI_HOST_HID "PNP0A03" | 168 | #define ACPI_PCI_HOST_HID "PNP0A03" |
165 | 169 | ||
@@ -197,19 +201,27 @@ struct acpiphp_attention_info | |||
197 | #define FUNC_HAS_PS1 (0x00000020) | 201 | #define FUNC_HAS_PS1 (0x00000020) |
198 | #define FUNC_HAS_PS2 (0x00000040) | 202 | #define FUNC_HAS_PS2 (0x00000040) |
199 | #define FUNC_HAS_PS3 (0x00000080) | 203 | #define FUNC_HAS_PS3 (0x00000080) |
204 | #define FUNC_HAS_DCK (0x00000100) | ||
205 | #define FUNC_IS_DD (0x00000200) | ||
206 | |||
207 | /* dock station flags */ | ||
208 | #define DOCK_DOCKING (0x00000001) | ||
209 | #define DOCK_HAS_BRIDGE (0x00000002) | ||
200 | 210 | ||
201 | /* function prototypes */ | 211 | /* function prototypes */ |
202 | 212 | ||
203 | /* acpiphp_core.c */ | 213 | /* acpiphp_core.c */ |
204 | extern int acpiphp_register_attention(struct acpiphp_attention_info*info); | 214 | extern int acpiphp_register_attention(struct acpiphp_attention_info*info); |
205 | extern int acpiphp_unregister_attention(struct acpiphp_attention_info *info); | 215 | extern int acpiphp_unregister_attention(struct acpiphp_attention_info *info); |
216 | extern int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot); | ||
217 | extern void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot); | ||
206 | 218 | ||
207 | /* acpiphp_glue.c */ | 219 | /* acpiphp_glue.c */ |
208 | extern int acpiphp_glue_init (void); | 220 | extern int acpiphp_glue_init (void); |
209 | extern void acpiphp_glue_exit (void); | 221 | extern void acpiphp_glue_exit (void); |
210 | extern int acpiphp_get_num_slots (void); | 222 | extern int acpiphp_get_num_slots (void); |
211 | extern struct acpiphp_slot *get_slot_from_id (int id); | ||
212 | typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data); | 223 | typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data); |
224 | void handle_hotplug_event_func(acpi_handle, u32, void*); | ||
213 | 225 | ||
214 | extern int acpiphp_enable_slot (struct acpiphp_slot *slot); | 226 | extern int acpiphp_enable_slot (struct acpiphp_slot *slot); |
215 | extern int acpiphp_disable_slot (struct acpiphp_slot *slot); | 227 | extern int acpiphp_disable_slot (struct acpiphp_slot *slot); |
@@ -219,6 +231,16 @@ extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot); | |||
219 | extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot); | 231 | extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot); |
220 | extern u32 acpiphp_get_address (struct acpiphp_slot *slot); | 232 | extern u32 acpiphp_get_address (struct acpiphp_slot *slot); |
221 | 233 | ||
234 | /* acpiphp_dock.c */ | ||
235 | extern int find_dock_station(void); | ||
236 | extern void remove_dock_station(void); | ||
237 | extern void add_dependent_device(struct dependent_device *new_dd); | ||
238 | extern void add_pci_dependent_device(struct dependent_device *new_dd); | ||
239 | extern struct dependent_device *get_dependent_device(acpi_handle handle); | ||
240 | extern int is_dependent_device(acpi_handle handle); | ||
241 | extern int detect_dependent_devices(acpi_handle *bridge_handle); | ||
242 | extern struct dependent_device *alloc_dependent_device(acpi_handle handle); | ||
243 | |||
222 | /* variables */ | 244 | /* variables */ |
223 | extern int acpiphp_debug; | 245 | extern int acpiphp_debug; |
224 | 246 | ||
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c index 60c4c38047a3..4f1b0da8e47e 100644 --- a/drivers/pci/hotplug/acpiphp_core.c +++ b/drivers/pci/hotplug/acpiphp_core.c | |||
@@ -44,8 +44,6 @@ | |||
44 | #include "pci_hotplug.h" | 44 | #include "pci_hotplug.h" |
45 | #include "acpiphp.h" | 45 | #include "acpiphp.h" |
46 | 46 | ||
47 | static LIST_HEAD(slot_list); | ||
48 | |||
49 | #define MY_NAME "acpiphp" | 47 | #define MY_NAME "acpiphp" |
50 | 48 | ||
51 | static int debug; | 49 | static int debug; |
@@ -341,62 +339,53 @@ static void release_slot(struct hotplug_slot *hotplug_slot) | |||
341 | kfree(slot); | 339 | kfree(slot); |
342 | } | 340 | } |
343 | 341 | ||
344 | /** | 342 | /* callback routine to initialize 'struct slot' for each slot */ |
345 | * init_slots - initialize 'struct slot' structures for each slot | 343 | int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot) |
346 | * | ||
347 | */ | ||
348 | static int __init init_slots(void) | ||
349 | { | 344 | { |
350 | struct slot *slot; | 345 | struct slot *slot; |
346 | struct hotplug_slot *hotplug_slot; | ||
347 | struct hotplug_slot_info *hotplug_slot_info; | ||
351 | int retval = -ENOMEM; | 348 | int retval = -ENOMEM; |
352 | int i; | 349 | |
353 | 350 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); | |
354 | for (i = 0; i < num_slots; ++i) { | 351 | if (!slot) |
355 | slot = kmalloc(sizeof(struct slot), GFP_KERNEL); | 352 | goto error; |
356 | if (!slot) | 353 | |
357 | goto error; | 354 | slot->hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL); |
358 | memset(slot, 0, sizeof(struct slot)); | 355 | if (!slot->hotplug_slot) |
359 | 356 | goto error_slot; | |
360 | slot->hotplug_slot = kmalloc(sizeof(struct hotplug_slot), GFP_KERNEL); | 357 | |
361 | if (!slot->hotplug_slot) | 358 | slot->hotplug_slot->info = kzalloc(sizeof(*hotplug_slot_info), |
362 | goto error_slot; | 359 | GFP_KERNEL); |
363 | memset(slot->hotplug_slot, 0, sizeof(struct hotplug_slot)); | 360 | if (!slot->hotplug_slot->info) |
364 | 361 | goto error_hpslot; | |
365 | slot->hotplug_slot->info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); | 362 | |
366 | if (!slot->hotplug_slot->info) | 363 | slot->hotplug_slot->name = kzalloc(SLOT_NAME_SIZE, GFP_KERNEL); |
367 | goto error_hpslot; | 364 | if (!slot->hotplug_slot->name) |
368 | memset(slot->hotplug_slot->info, 0, sizeof(struct hotplug_slot_info)); | 365 | goto error_info; |
369 | 366 | ||
370 | slot->hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); | 367 | slot->hotplug_slot->private = slot; |
371 | if (!slot->hotplug_slot->name) | 368 | slot->hotplug_slot->release = &release_slot; |
372 | goto error_info; | 369 | slot->hotplug_slot->ops = &acpi_hotplug_slot_ops; |
373 | 370 | ||
374 | slot->number = i; | 371 | slot->acpi_slot = acpiphp_slot; |
375 | 372 | slot->hotplug_slot->info->power_status = acpiphp_get_power_status(slot->acpi_slot); | |
376 | slot->hotplug_slot->private = slot; | 373 | slot->hotplug_slot->info->attention_status = 0; |
377 | slot->hotplug_slot->release = &release_slot; | 374 | slot->hotplug_slot->info->latch_status = acpiphp_get_latch_status(slot->acpi_slot); |
378 | slot->hotplug_slot->ops = &acpi_hotplug_slot_ops; | 375 | slot->hotplug_slot->info->adapter_status = acpiphp_get_adapter_status(slot->acpi_slot); |
379 | 376 | slot->hotplug_slot->info->max_bus_speed = PCI_SPEED_UNKNOWN; | |
380 | slot->acpi_slot = get_slot_from_id(i); | 377 | slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN; |
381 | slot->hotplug_slot->info->power_status = acpiphp_get_power_status(slot->acpi_slot); | 378 | |
382 | slot->hotplug_slot->info->attention_status = 0; | 379 | acpiphp_slot->slot = slot; |
383 | slot->hotplug_slot->info->latch_status = acpiphp_get_latch_status(slot->acpi_slot); | 380 | make_slot_name(slot); |
384 | slot->hotplug_slot->info->adapter_status = acpiphp_get_adapter_status(slot->acpi_slot); | 381 | |
385 | slot->hotplug_slot->info->max_bus_speed = PCI_SPEED_UNKNOWN; | 382 | retval = pci_hp_register(slot->hotplug_slot); |
386 | slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN; | 383 | if (retval) { |
387 | 384 | err("pci_hp_register failed with error %d\n", retval); | |
388 | make_slot_name(slot); | 385 | goto error_name; |
389 | 386 | } | |
390 | retval = pci_hp_register(slot->hotplug_slot); | 387 | |
391 | if (retval) { | 388 | info("Slot [%s] registered\n", slot->hotplug_slot->name); |
392 | err("pci_hp_register failed with error %d\n", retval); | ||
393 | goto error_name; | ||
394 | } | ||
395 | |||
396 | /* add slot to our internal list */ | ||
397 | list_add(&slot->slot_list, &slot_list); | ||
398 | info("Slot [%s] registered\n", slot->hotplug_slot->name); | ||
399 | } | ||
400 | 389 | ||
401 | return 0; | 390 | return 0; |
402 | error_name: | 391 | error_name: |
@@ -412,42 +401,51 @@ error: | |||
412 | } | 401 | } |
413 | 402 | ||
414 | 403 | ||
415 | static void __exit cleanup_slots (void) | 404 | void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *acpiphp_slot) |
416 | { | 405 | { |
417 | struct list_head *tmp, *n; | 406 | struct slot *slot = acpiphp_slot->slot; |
418 | struct slot *slot; | 407 | int retval = 0; |
419 | 408 | ||
420 | list_for_each_safe (tmp, n, &slot_list) { | 409 | info ("Slot [%s] unregistered\n", slot->hotplug_slot->name); |
421 | /* memory will be freed in release_slot callback */ | 410 | |
422 | slot = list_entry(tmp, struct slot, slot_list); | 411 | retval = pci_hp_deregister(slot->hotplug_slot); |
423 | list_del(&slot->slot_list); | 412 | if (retval) |
424 | pci_hp_deregister(slot->hotplug_slot); | 413 | err("pci_hp_deregister failed with error %d\n", retval); |
425 | } | ||
426 | } | 414 | } |
427 | 415 | ||
428 | 416 | ||
429 | static int __init acpiphp_init(void) | 417 | static int __init acpiphp_init(void) |
430 | { | 418 | { |
431 | int retval; | 419 | int retval; |
420 | int docking_station; | ||
432 | 421 | ||
433 | info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); | 422 | info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); |
434 | 423 | ||
435 | acpiphp_debug = debug; | 424 | acpiphp_debug = debug; |
436 | 425 | ||
426 | docking_station = find_dock_station(); | ||
427 | |||
437 | /* read all the ACPI info from the system */ | 428 | /* read all the ACPI info from the system */ |
438 | retval = init_acpi(); | 429 | retval = init_acpi(); |
439 | if (retval) | ||
440 | return retval; | ||
441 | 430 | ||
442 | return init_slots(); | 431 | /* if we have found a docking station, we should |
432 | * go ahead and load even if init_acpi has found | ||
433 | * no slots. This handles the case when the _DCK | ||
434 | * method not defined under the actual dock bridge | ||
435 | */ | ||
436 | if (docking_station) | ||
437 | return 0; | ||
438 | else | ||
439 | return retval; | ||
443 | } | 440 | } |
444 | 441 | ||
445 | 442 | ||
446 | static void __exit acpiphp_exit(void) | 443 | static void __exit acpiphp_exit(void) |
447 | { | 444 | { |
448 | cleanup_slots(); | ||
449 | /* deallocate internal data structures etc. */ | 445 | /* deallocate internal data structures etc. */ |
450 | acpiphp_glue_exit(); | 446 | acpiphp_glue_exit(); |
447 | |||
448 | remove_dock_station(); | ||
451 | } | 449 | } |
452 | 450 | ||
453 | module_init(acpiphp_init); | 451 | module_init(acpiphp_init); |
diff --git a/drivers/pci/hotplug/acpiphp_dock.c b/drivers/pci/hotplug/acpiphp_dock.c new file mode 100644 index 000000000000..4f1aaf128312 --- /dev/null +++ b/drivers/pci/hotplug/acpiphp_dock.c | |||
@@ -0,0 +1,438 @@ | |||
1 | /* | ||
2 | * ACPI PCI HotPlug dock functions to ACPI CA subsystem | ||
3 | * | ||
4 | * Copyright (C) 2006 Kristen Carlson Accardi (kristen.c.accardi@intel.com) | ||
5 | * Copyright (C) 2006 Intel Corporation | ||
6 | * | ||
7 | * All rights reserved. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or (at | ||
12 | * your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
17 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
18 | * details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | * | ||
24 | * Send feedback to <kristen.c.accardi@intel.com> | ||
25 | * | ||
26 | */ | ||
27 | #include <linux/init.h> | ||
28 | #include <linux/module.h> | ||
29 | |||
30 | #include <linux/kernel.h> | ||
31 | #include <linux/pci.h> | ||
32 | #include <linux/smp_lock.h> | ||
33 | #include <linux/mutex.h> | ||
34 | |||
35 | #include "../pci.h" | ||
36 | #include "pci_hotplug.h" | ||
37 | #include "acpiphp.h" | ||
38 | |||
39 | static struct acpiphp_dock_station *ds; | ||
40 | #define MY_NAME "acpiphp_dock" | ||
41 | |||
42 | |||
43 | int is_dependent_device(acpi_handle handle) | ||
44 | { | ||
45 | return (get_dependent_device(handle) ? 1 : 0); | ||
46 | } | ||
47 | |||
48 | |||
49 | static acpi_status | ||
50 | find_dependent_device(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
51 | { | ||
52 | int *count = (int *)context; | ||
53 | |||
54 | if (is_dependent_device(handle)) { | ||
55 | (*count)++; | ||
56 | return AE_CTRL_TERMINATE; | ||
57 | } else { | ||
58 | return AE_OK; | ||
59 | } | ||
60 | } | ||
61 | |||
62 | |||
63 | |||
64 | |||
65 | void add_dependent_device(struct dependent_device *new_dd) | ||
66 | { | ||
67 | list_add_tail(&new_dd->device_list, &ds->dependent_devices); | ||
68 | } | ||
69 | |||
70 | |||
71 | void add_pci_dependent_device(struct dependent_device *new_dd) | ||
72 | { | ||
73 | list_add_tail(&new_dd->pci_list, &ds->pci_dependent_devices); | ||
74 | } | ||
75 | |||
76 | |||
77 | |||
78 | struct dependent_device * get_dependent_device(acpi_handle handle) | ||
79 | { | ||
80 | struct dependent_device *dd; | ||
81 | |||
82 | if (!ds) | ||
83 | return NULL; | ||
84 | |||
85 | list_for_each_entry(dd, &ds->dependent_devices, device_list) { | ||
86 | if (handle == dd->handle) | ||
87 | return dd; | ||
88 | } | ||
89 | return NULL; | ||
90 | } | ||
91 | |||
92 | |||
93 | |||
94 | struct dependent_device *alloc_dependent_device(acpi_handle handle) | ||
95 | { | ||
96 | struct dependent_device *dd; | ||
97 | |||
98 | dd = kzalloc(sizeof(*dd), GFP_KERNEL); | ||
99 | if (dd) { | ||
100 | INIT_LIST_HEAD(&dd->pci_list); | ||
101 | INIT_LIST_HEAD(&dd->device_list); | ||
102 | dd->handle = handle; | ||
103 | } | ||
104 | return dd; | ||
105 | } | ||
106 | |||
107 | |||
108 | |||
109 | static int is_dock(acpi_handle handle) | ||
110 | { | ||
111 | acpi_status status; | ||
112 | acpi_handle tmp; | ||
113 | |||
114 | status = acpi_get_handle(handle, "_DCK", &tmp); | ||
115 | if (ACPI_FAILURE(status)) { | ||
116 | return 0; | ||
117 | } | ||
118 | return 1; | ||
119 | } | ||
120 | |||
121 | |||
122 | |||
123 | static int dock_present(void) | ||
124 | { | ||
125 | unsigned long sta; | ||
126 | acpi_status status; | ||
127 | |||
128 | if (ds) { | ||
129 | status = acpi_evaluate_integer(ds->handle, "_STA", NULL, &sta); | ||
130 | if (ACPI_SUCCESS(status) && sta) | ||
131 | return 1; | ||
132 | } | ||
133 | return 0; | ||
134 | } | ||
135 | |||
136 | |||
137 | |||
138 | static void eject_dock(void) | ||
139 | { | ||
140 | struct acpi_object_list arg_list; | ||
141 | union acpi_object arg; | ||
142 | |||
143 | arg_list.count = 1; | ||
144 | arg_list.pointer = &arg; | ||
145 | arg.type = ACPI_TYPE_INTEGER; | ||
146 | arg.integer.value = 1; | ||
147 | |||
148 | if (ACPI_FAILURE(acpi_evaluate_object(ds->handle, "_EJ0", | ||
149 | &arg_list, NULL)) || dock_present()) | ||
150 | warn("%s: failed to eject dock!\n", __FUNCTION__); | ||
151 | |||
152 | return; | ||
153 | } | ||
154 | |||
155 | |||
156 | |||
157 | |||
158 | static acpi_status handle_dock(int dock) | ||
159 | { | ||
160 | acpi_status status; | ||
161 | struct acpi_object_list arg_list; | ||
162 | union acpi_object arg; | ||
163 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
164 | |||
165 | dbg("%s: %s\n", __FUNCTION__, dock ? "docking" : "undocking"); | ||
166 | |||
167 | /* _DCK method has one argument */ | ||
168 | arg_list.count = 1; | ||
169 | arg_list.pointer = &arg; | ||
170 | arg.type = ACPI_TYPE_INTEGER; | ||
171 | arg.integer.value = dock; | ||
172 | status = acpi_evaluate_object(ds->handle, "_DCK", | ||
173 | &arg_list, &buffer); | ||
174 | if (ACPI_FAILURE(status)) | ||
175 | err("%s: failed to execute _DCK\n", __FUNCTION__); | ||
176 | acpi_os_free(buffer.pointer); | ||
177 | |||
178 | return status; | ||
179 | } | ||
180 | |||
181 | |||
182 | |||
183 | static inline void dock(void) | ||
184 | { | ||
185 | handle_dock(1); | ||
186 | } | ||
187 | |||
188 | |||
189 | |||
190 | static inline void undock(void) | ||
191 | { | ||
192 | handle_dock(0); | ||
193 | } | ||
194 | |||
195 | |||
196 | |||
197 | /* | ||
198 | * the _DCK method can do funny things... and sometimes not | ||
199 | * hah-hah funny. | ||
200 | * | ||
201 | * TBD - figure out a way to only call fixups for | ||
202 | * systems that require them. | ||
203 | */ | ||
204 | static void post_dock_fixups(void) | ||
205 | { | ||
206 | struct pci_bus *bus; | ||
207 | u32 buses; | ||
208 | struct dependent_device *dd; | ||
209 | |||
210 | list_for_each_entry(dd, &ds->pci_dependent_devices, pci_list) { | ||
211 | bus = dd->func->slot->bridge->pci_bus; | ||
212 | |||
213 | /* fixup bad _DCK function that rewrites | ||
214 | * secondary bridge on slot | ||
215 | */ | ||
216 | pci_read_config_dword(bus->self, | ||
217 | PCI_PRIMARY_BUS, | ||
218 | &buses); | ||
219 | |||
220 | if (((buses >> 8) & 0xff) != bus->secondary) { | ||
221 | buses = (buses & 0xff000000) | ||
222 | | ((unsigned int)(bus->primary) << 0) | ||
223 | | ((unsigned int)(bus->secondary) << 8) | ||
224 | | ((unsigned int)(bus->subordinate) << 16); | ||
225 | pci_write_config_dword(bus->self, | ||
226 | PCI_PRIMARY_BUS, | ||
227 | buses); | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | |||
232 | |||
233 | |||
234 | static void hotplug_pci(u32 type) | ||
235 | { | ||
236 | struct dependent_device *dd; | ||
237 | |||
238 | list_for_each_entry(dd, &ds->pci_dependent_devices, pci_list) | ||
239 | handle_hotplug_event_func(dd->handle, type, dd->func); | ||
240 | } | ||
241 | |||
242 | |||
243 | |||
244 | static inline void begin_dock(void) | ||
245 | { | ||
246 | ds->flags |= DOCK_DOCKING; | ||
247 | } | ||
248 | |||
249 | |||
250 | static inline void complete_dock(void) | ||
251 | { | ||
252 | ds->flags &= ~(DOCK_DOCKING); | ||
253 | ds->last_dock_time = jiffies; | ||
254 | } | ||
255 | |||
256 | |||
257 | static int dock_in_progress(void) | ||
258 | { | ||
259 | if (ds->flags & DOCK_DOCKING || | ||
260 | ds->last_dock_time == jiffies) { | ||
261 | dbg("dock in progress\n"); | ||
262 | return 1; | ||
263 | } | ||
264 | return 0; | ||
265 | } | ||
266 | |||
267 | |||
268 | |||
269 | static void | ||
270 | handle_hotplug_event_dock(acpi_handle handle, u32 type, void *context) | ||
271 | { | ||
272 | dbg("%s: enter\n", __FUNCTION__); | ||
273 | |||
274 | switch (type) { | ||
275 | case ACPI_NOTIFY_BUS_CHECK: | ||
276 | dbg("BUS Check\n"); | ||
277 | if (!dock_in_progress() && dock_present()) { | ||
278 | begin_dock(); | ||
279 | dock(); | ||
280 | if (!dock_present()) { | ||
281 | err("Unable to dock!\n"); | ||
282 | break; | ||
283 | } | ||
284 | post_dock_fixups(); | ||
285 | hotplug_pci(type); | ||
286 | complete_dock(); | ||
287 | } | ||
288 | break; | ||
289 | case ACPI_NOTIFY_EJECT_REQUEST: | ||
290 | dbg("EJECT request\n"); | ||
291 | if (!dock_in_progress() && dock_present()) { | ||
292 | hotplug_pci(type); | ||
293 | undock(); | ||
294 | eject_dock(); | ||
295 | if (dock_present()) | ||
296 | err("Unable to undock!\n"); | ||
297 | } | ||
298 | break; | ||
299 | } | ||
300 | } | ||
301 | |||
302 | |||
303 | |||
304 | |||
305 | static acpi_status | ||
306 | find_dock_ejd(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
307 | { | ||
308 | acpi_status status; | ||
309 | acpi_handle tmp; | ||
310 | acpi_handle dck_handle = (acpi_handle) context; | ||
311 | char objname[64]; | ||
312 | struct acpi_buffer buffer = { .length = sizeof(objname), | ||
313 | .pointer = objname }; | ||
314 | struct acpi_buffer ejd_buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
315 | union acpi_object *ejd_obj; | ||
316 | |||
317 | status = acpi_get_handle(handle, "_EJD", &tmp); | ||
318 | if (ACPI_FAILURE(status)) | ||
319 | return AE_OK; | ||
320 | |||
321 | /* make sure we are dependent on the dock device, | ||
322 | * by executing the _EJD method, then getting a handle | ||
323 | * to the device referenced by that name. If that | ||
324 | * device handle is the same handle as the dock station | ||
325 | * handle, then we are a device dependent on the dock station | ||
326 | */ | ||
327 | acpi_get_name(dck_handle, ACPI_FULL_PATHNAME, &buffer); | ||
328 | status = acpi_evaluate_object(handle, "_EJD", NULL, &ejd_buffer); | ||
329 | if (ACPI_FAILURE(status)) { | ||
330 | err("Unable to execute _EJD!\n"); | ||
331 | goto find_ejd_out; | ||
332 | } | ||
333 | ejd_obj = ejd_buffer.pointer; | ||
334 | status = acpi_get_handle(NULL, ejd_obj->string.pointer, &tmp); | ||
335 | if (ACPI_FAILURE(status)) | ||
336 | goto find_ejd_out; | ||
337 | |||
338 | if (tmp == dck_handle) { | ||
339 | struct dependent_device *dd; | ||
340 | dbg("%s: found device dependent on dock\n", __FUNCTION__); | ||
341 | dd = alloc_dependent_device(handle); | ||
342 | if (!dd) { | ||
343 | err("Can't allocate memory for dependent device!\n"); | ||
344 | goto find_ejd_out; | ||
345 | } | ||
346 | add_dependent_device(dd); | ||
347 | } | ||
348 | |||
349 | find_ejd_out: | ||
350 | acpi_os_free(ejd_buffer.pointer); | ||
351 | return AE_OK; | ||
352 | } | ||
353 | |||
354 | |||
355 | |||
356 | int detect_dependent_devices(acpi_handle *bridge_handle) | ||
357 | { | ||
358 | acpi_status status; | ||
359 | int count; | ||
360 | |||
361 | count = 0; | ||
362 | |||
363 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle, | ||
364 | (u32)1, find_dependent_device, | ||
365 | (void *)&count, NULL); | ||
366 | |||
367 | return count; | ||
368 | } | ||
369 | |||
370 | |||
371 | |||
372 | |||
373 | |||
374 | static acpi_status | ||
375 | find_dock(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
376 | { | ||
377 | int *count = (int *)context; | ||
378 | |||
379 | if (is_dock(handle)) { | ||
380 | dbg("%s: found dock\n", __FUNCTION__); | ||
381 | ds = kzalloc(sizeof(*ds), GFP_KERNEL); | ||
382 | ds->handle = handle; | ||
383 | INIT_LIST_HEAD(&ds->dependent_devices); | ||
384 | INIT_LIST_HEAD(&ds->pci_dependent_devices); | ||
385 | |||
386 | /* look for devices dependent on dock station */ | ||
387 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
388 | ACPI_UINT32_MAX, find_dock_ejd, handle, NULL); | ||
389 | |||
390 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | ||
391 | handle_hotplug_event_dock, ds); | ||
392 | (*count)++; | ||
393 | } | ||
394 | |||
395 | return AE_OK; | ||
396 | } | ||
397 | |||
398 | |||
399 | |||
400 | |||
401 | int find_dock_station(void) | ||
402 | { | ||
403 | int num = 0; | ||
404 | |||
405 | ds = NULL; | ||
406 | |||
407 | /* start from the root object, because some laptops define | ||
408 | * _DCK methods outside the scope of PCI (IBM x-series laptop) | ||
409 | */ | ||
410 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
411 | ACPI_UINT32_MAX, find_dock, &num, NULL); | ||
412 | |||
413 | return num; | ||
414 | } | ||
415 | |||
416 | |||
417 | |||
418 | void remove_dock_station(void) | ||
419 | { | ||
420 | struct dependent_device *dd, *tmp; | ||
421 | if (ds) { | ||
422 | if (ACPI_FAILURE(acpi_remove_notify_handler(ds->handle, | ||
423 | ACPI_SYSTEM_NOTIFY, handle_hotplug_event_dock))) | ||
424 | err("failed to remove dock notify handler\n"); | ||
425 | |||
426 | /* free all dependent devices */ | ||
427 | list_for_each_entry_safe(dd, tmp, &ds->dependent_devices, | ||
428 | device_list) | ||
429 | kfree(dd); | ||
430 | |||
431 | /* no need to touch the pci_dependent_device list, | ||
432 | * cause all memory was freed above | ||
433 | */ | ||
434 | kfree(ds); | ||
435 | } | ||
436 | } | ||
437 | |||
438 | |||
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 509a5b3ae998..053ee843863c 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/kernel.h> | 46 | #include <linux/kernel.h> |
47 | #include <linux/pci.h> | 47 | #include <linux/pci.h> |
48 | #include <linux/smp_lock.h> | 48 | #include <linux/smp_lock.h> |
49 | #include <asm/semaphore.h> | 49 | #include <linux/mutex.h> |
50 | 50 | ||
51 | #include "../pci.h" | 51 | #include "../pci.h" |
52 | #include "pci_hotplug.h" | 52 | #include "pci_hotplug.h" |
@@ -57,7 +57,6 @@ static LIST_HEAD(bridge_list); | |||
57 | #define MY_NAME "acpiphp_glue" | 57 | #define MY_NAME "acpiphp_glue" |
58 | 58 | ||
59 | static void handle_hotplug_event_bridge (acpi_handle, u32, void *); | 59 | static void handle_hotplug_event_bridge (acpi_handle, u32, void *); |
60 | static void handle_hotplug_event_func (acpi_handle, u32, void *); | ||
61 | static void acpiphp_sanitize_bus(struct pci_bus *bus); | 60 | static void acpiphp_sanitize_bus(struct pci_bus *bus); |
62 | static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus); | 61 | static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus); |
63 | 62 | ||
@@ -125,11 +124,11 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
125 | struct acpiphp_bridge *bridge = (struct acpiphp_bridge *)context; | 124 | struct acpiphp_bridge *bridge = (struct acpiphp_bridge *)context; |
126 | struct acpiphp_slot *slot; | 125 | struct acpiphp_slot *slot; |
127 | struct acpiphp_func *newfunc; | 126 | struct acpiphp_func *newfunc; |
127 | struct dependent_device *dd; | ||
128 | acpi_handle tmp; | 128 | acpi_handle tmp; |
129 | acpi_status status = AE_OK; | 129 | acpi_status status = AE_OK; |
130 | unsigned long adr, sun; | 130 | unsigned long adr, sun; |
131 | int device, function; | 131 | int device, function, retval; |
132 | static int num_slots = 0; /* XXX if we support I/O node hotplug... */ | ||
133 | 132 | ||
134 | status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr); | 133 | status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr); |
135 | 134 | ||
@@ -138,21 +137,21 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
138 | 137 | ||
139 | status = acpi_get_handle(handle, "_EJ0", &tmp); | 138 | status = acpi_get_handle(handle, "_EJ0", &tmp); |
140 | 139 | ||
141 | if (ACPI_FAILURE(status)) | 140 | if (ACPI_FAILURE(status) && !(is_dependent_device(handle))) |
142 | return AE_OK; | 141 | return AE_OK; |
143 | 142 | ||
144 | device = (adr >> 16) & 0xffff; | 143 | device = (adr >> 16) & 0xffff; |
145 | function = adr & 0xffff; | 144 | function = adr & 0xffff; |
146 | 145 | ||
147 | newfunc = kmalloc(sizeof(struct acpiphp_func), GFP_KERNEL); | 146 | newfunc = kzalloc(sizeof(struct acpiphp_func), GFP_KERNEL); |
148 | if (!newfunc) | 147 | if (!newfunc) |
149 | return AE_NO_MEMORY; | 148 | return AE_NO_MEMORY; |
150 | memset(newfunc, 0, sizeof(struct acpiphp_func)); | ||
151 | 149 | ||
152 | INIT_LIST_HEAD(&newfunc->sibling); | 150 | INIT_LIST_HEAD(&newfunc->sibling); |
153 | newfunc->handle = handle; | 151 | newfunc->handle = handle; |
154 | newfunc->function = function; | 152 | newfunc->function = function; |
155 | newfunc->flags = FUNC_HAS_EJ0; | 153 | if (ACPI_SUCCESS(status)) |
154 | newfunc->flags = FUNC_HAS_EJ0; | ||
156 | 155 | ||
157 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_STA", &tmp))) | 156 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_STA", &tmp))) |
158 | newfunc->flags |= FUNC_HAS_STA; | 157 | newfunc->flags |= FUNC_HAS_STA; |
@@ -163,6 +162,19 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
163 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_PS3", &tmp))) | 162 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_PS3", &tmp))) |
164 | newfunc->flags |= FUNC_HAS_PS3; | 163 | newfunc->flags |= FUNC_HAS_PS3; |
165 | 164 | ||
165 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_DCK", &tmp))) { | ||
166 | newfunc->flags |= FUNC_HAS_DCK; | ||
167 | /* add to devices dependent on dock station, | ||
168 | * because this may actually be the dock bridge | ||
169 | */ | ||
170 | dd = alloc_dependent_device(handle); | ||
171 | if (!dd) | ||
172 | err("Can't allocate memory for " | ||
173 | "new dependent device!\n"); | ||
174 | else | ||
175 | add_dependent_device(dd); | ||
176 | } | ||
177 | |||
166 | status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun); | 178 | status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun); |
167 | if (ACPI_FAILURE(status)) | 179 | if (ACPI_FAILURE(status)) |
168 | sun = -1; | 180 | sun = -1; |
@@ -176,19 +188,17 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
176 | } | 188 | } |
177 | 189 | ||
178 | if (!slot) { | 190 | if (!slot) { |
179 | slot = kmalloc(sizeof(struct acpiphp_slot), GFP_KERNEL); | 191 | slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL); |
180 | if (!slot) { | 192 | if (!slot) { |
181 | kfree(newfunc); | 193 | kfree(newfunc); |
182 | return AE_NO_MEMORY; | 194 | return AE_NO_MEMORY; |
183 | } | 195 | } |
184 | 196 | ||
185 | memset(slot, 0, sizeof(struct acpiphp_slot)); | ||
186 | slot->bridge = bridge; | 197 | slot->bridge = bridge; |
187 | slot->id = num_slots++; | ||
188 | slot->device = device; | 198 | slot->device = device; |
189 | slot->sun = sun; | 199 | slot->sun = sun; |
190 | INIT_LIST_HEAD(&slot->funcs); | 200 | INIT_LIST_HEAD(&slot->funcs); |
191 | init_MUTEX(&slot->crit_sect); | 201 | mutex_init(&slot->crit_sect); |
192 | 202 | ||
193 | slot->next = bridge->slots; | 203 | slot->next = bridge->slots; |
194 | bridge->slots = slot; | 204 | bridge->slots = slot; |
@@ -198,6 +208,11 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
198 | dbg("found ACPI PCI Hotplug slot %d at PCI %04x:%02x:%02x\n", | 208 | dbg("found ACPI PCI Hotplug slot %d at PCI %04x:%02x:%02x\n", |
199 | slot->sun, pci_domain_nr(bridge->pci_bus), | 209 | slot->sun, pci_domain_nr(bridge->pci_bus), |
200 | bridge->pci_bus->number, slot->device); | 210 | bridge->pci_bus->number, slot->device); |
211 | retval = acpiphp_register_hotplug_slot(slot); | ||
212 | if (retval) { | ||
213 | warn("acpiphp_register_hotplug_slot failed(err code = 0x%x)\n", retval); | ||
214 | goto err_exit; | ||
215 | } | ||
201 | } | 216 | } |
202 | 217 | ||
203 | newfunc->slot = slot; | 218 | newfunc->slot = slot; |
@@ -210,16 +225,41 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
210 | slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON); | 225 | slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON); |
211 | } | 226 | } |
212 | 227 | ||
228 | /* if this is a device dependent on a dock station, | ||
229 | * associate the acpiphp_func to the dependent_device | ||
230 | * struct. | ||
231 | */ | ||
232 | if ((dd = get_dependent_device(handle))) { | ||
233 | newfunc->flags |= FUNC_IS_DD; | ||
234 | /* | ||
235 | * we don't want any devices which is dependent | ||
236 | * on the dock to have it's _EJ0 method executed. | ||
237 | * because we need to run _DCK first. | ||
238 | */ | ||
239 | newfunc->flags &= ~FUNC_HAS_EJ0; | ||
240 | dd->func = newfunc; | ||
241 | add_pci_dependent_device(dd); | ||
242 | } | ||
243 | |||
213 | /* install notify handler */ | 244 | /* install notify handler */ |
214 | status = acpi_install_notify_handler(handle, | 245 | if (!(newfunc->flags & FUNC_HAS_DCK)) { |
246 | status = acpi_install_notify_handler(handle, | ||
215 | ACPI_SYSTEM_NOTIFY, | 247 | ACPI_SYSTEM_NOTIFY, |
216 | handle_hotplug_event_func, | 248 | handle_hotplug_event_func, |
217 | newfunc); | 249 | newfunc); |
218 | 250 | ||
219 | if (ACPI_FAILURE(status)) { | 251 | if (ACPI_FAILURE(status)) |
220 | err("failed to register interrupt notify handler\n"); | 252 | err("failed to register interrupt notify handler\n"); |
221 | return status; | 253 | } else |
222 | } | 254 | status = AE_OK; |
255 | |||
256 | return status; | ||
257 | |||
258 | err_exit: | ||
259 | bridge->nr_slots--; | ||
260 | bridge->slots = slot->next; | ||
261 | kfree(slot); | ||
262 | kfree(newfunc); | ||
223 | 263 | ||
224 | return AE_OK; | 264 | return AE_OK; |
225 | } | 265 | } |
@@ -245,57 +285,19 @@ static int detect_ejectable_slots(acpi_handle *bridge_handle) | |||
245 | static void decode_hpp(struct acpiphp_bridge *bridge) | 285 | static void decode_hpp(struct acpiphp_bridge *bridge) |
246 | { | 286 | { |
247 | acpi_status status; | 287 | acpi_status status; |
248 | struct acpi_buffer buffer = { .length = ACPI_ALLOCATE_BUFFER, | ||
249 | .pointer = NULL}; | ||
250 | union acpi_object *package; | ||
251 | int i; | ||
252 | |||
253 | /* default numbers */ | ||
254 | bridge->hpp.cache_line_size = 0x10; | ||
255 | bridge->hpp.latency_timer = 0x40; | ||
256 | bridge->hpp.enable_SERR = 0; | ||
257 | bridge->hpp.enable_PERR = 0; | ||
258 | |||
259 | status = acpi_evaluate_object(bridge->handle, "_HPP", NULL, &buffer); | ||
260 | 288 | ||
289 | status = acpi_get_hp_params_from_firmware(bridge->pci_dev, &bridge->hpp); | ||
261 | if (ACPI_FAILURE(status)) { | 290 | if (ACPI_FAILURE(status)) { |
262 | dbg("_HPP evaluation failed\n"); | 291 | /* use default numbers */ |
263 | return; | 292 | bridge->hpp.cache_line_size = 0x10; |
293 | bridge->hpp.latency_timer = 0x40; | ||
294 | bridge->hpp.enable_serr = 0; | ||
295 | bridge->hpp.enable_perr = 0; | ||
264 | } | 296 | } |
265 | |||
266 | package = (union acpi_object *) buffer.pointer; | ||
267 | |||
268 | if (!package || package->type != ACPI_TYPE_PACKAGE || | ||
269 | package->package.count != 4 || !package->package.elements) { | ||
270 | err("invalid _HPP object; ignoring\n"); | ||
271 | goto err_exit; | ||
272 | } | ||
273 | |||
274 | for (i = 0; i < 4; i++) { | ||
275 | if (package->package.elements[i].type != ACPI_TYPE_INTEGER) { | ||
276 | err("invalid _HPP parameter type; ignoring\n"); | ||
277 | goto err_exit; | ||
278 | } | ||
279 | } | ||
280 | |||
281 | bridge->hpp.cache_line_size = package->package.elements[0].integer.value; | ||
282 | bridge->hpp.latency_timer = package->package.elements[1].integer.value; | ||
283 | bridge->hpp.enable_SERR = package->package.elements[2].integer.value; | ||
284 | bridge->hpp.enable_PERR = package->package.elements[3].integer.value; | ||
285 | |||
286 | dbg("_HPP parameter = (%02x, %02x, %02x, %02x)\n", | ||
287 | bridge->hpp.cache_line_size, | ||
288 | bridge->hpp.latency_timer, | ||
289 | bridge->hpp.enable_SERR, | ||
290 | bridge->hpp.enable_PERR); | ||
291 | |||
292 | bridge->flags |= BRIDGE_HAS_HPP; | ||
293 | |||
294 | err_exit: | ||
295 | kfree(buffer.pointer); | ||
296 | } | 297 | } |
297 | 298 | ||
298 | 299 | ||
300 | |||
299 | /* initialize miscellaneous stuff for both root and PCI-to-PCI bridge */ | 301 | /* initialize miscellaneous stuff for both root and PCI-to-PCI bridge */ |
300 | static void init_bridge_misc(struct acpiphp_bridge *bridge) | 302 | static void init_bridge_misc(struct acpiphp_bridge *bridge) |
301 | { | 303 | { |
@@ -304,9 +306,16 @@ static void init_bridge_misc(struct acpiphp_bridge *bridge) | |||
304 | /* decode ACPI 2.0 _HPP (hot plug parameters) */ | 306 | /* decode ACPI 2.0 _HPP (hot plug parameters) */ |
305 | decode_hpp(bridge); | 307 | decode_hpp(bridge); |
306 | 308 | ||
309 | /* must be added to the list prior to calling register_slot */ | ||
310 | list_add(&bridge->list, &bridge_list); | ||
311 | |||
307 | /* register all slot objects under this bridge */ | 312 | /* register all slot objects under this bridge */ |
308 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge->handle, (u32)1, | 313 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge->handle, (u32)1, |
309 | register_slot, bridge, NULL); | 314 | register_slot, bridge, NULL); |
315 | if (ACPI_FAILURE(status)) { | ||
316 | list_del(&bridge->list); | ||
317 | return; | ||
318 | } | ||
310 | 319 | ||
311 | /* install notify handler */ | 320 | /* install notify handler */ |
312 | if (bridge->type != BRIDGE_TYPE_HOST) { | 321 | if (bridge->type != BRIDGE_TYPE_HOST) { |
@@ -319,8 +328,6 @@ static void init_bridge_misc(struct acpiphp_bridge *bridge) | |||
319 | err("failed to register interrupt notify handler\n"); | 328 | err("failed to register interrupt notify handler\n"); |
320 | } | 329 | } |
321 | } | 330 | } |
322 | |||
323 | list_add(&bridge->list, &bridge_list); | ||
324 | } | 331 | } |
325 | 332 | ||
326 | 333 | ||
@@ -329,12 +336,10 @@ static void add_host_bridge(acpi_handle *handle, struct pci_bus *pci_bus) | |||
329 | { | 336 | { |
330 | struct acpiphp_bridge *bridge; | 337 | struct acpiphp_bridge *bridge; |
331 | 338 | ||
332 | bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); | 339 | bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); |
333 | if (bridge == NULL) | 340 | if (bridge == NULL) |
334 | return; | 341 | return; |
335 | 342 | ||
336 | memset(bridge, 0, sizeof(struct acpiphp_bridge)); | ||
337 | |||
338 | bridge->type = BRIDGE_TYPE_HOST; | 343 | bridge->type = BRIDGE_TYPE_HOST; |
339 | bridge->handle = handle; | 344 | bridge->handle = handle; |
340 | 345 | ||
@@ -351,14 +356,12 @@ static void add_p2p_bridge(acpi_handle *handle, struct pci_dev *pci_dev) | |||
351 | { | 356 | { |
352 | struct acpiphp_bridge *bridge; | 357 | struct acpiphp_bridge *bridge; |
353 | 358 | ||
354 | bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); | 359 | bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); |
355 | if (bridge == NULL) { | 360 | if (bridge == NULL) { |
356 | err("out of memory\n"); | 361 | err("out of memory\n"); |
357 | return; | 362 | return; |
358 | } | 363 | } |
359 | 364 | ||
360 | memset(bridge, 0, sizeof(struct acpiphp_bridge)); | ||
361 | |||
362 | bridge->type = BRIDGE_TYPE_P2P; | 365 | bridge->type = BRIDGE_TYPE_P2P; |
363 | bridge->handle = handle; | 366 | bridge->handle = handle; |
364 | 367 | ||
@@ -410,11 +413,18 @@ find_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
410 | goto out; | 413 | goto out; |
411 | 414 | ||
412 | /* check if this bridge has ejectable slots */ | 415 | /* check if this bridge has ejectable slots */ |
413 | if (detect_ejectable_slots(handle) > 0) { | 416 | if ((detect_ejectable_slots(handle) > 0) || |
417 | (detect_dependent_devices(handle) > 0)) { | ||
414 | dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev)); | 418 | dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev)); |
415 | add_p2p_bridge(handle, dev); | 419 | add_p2p_bridge(handle, dev); |
416 | } | 420 | } |
417 | 421 | ||
422 | /* search P2P bridges under this p2p bridge */ | ||
423 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, | ||
424 | find_p2p_bridge, dev->subordinate, NULL); | ||
425 | if (ACPI_FAILURE(status)) | ||
426 | warn("find_p2p_bridge faied (error code = 0x%x)\n", status); | ||
427 | |||
418 | out: | 428 | out: |
419 | pci_dev_put(dev); | 429 | pci_dev_put(dev); |
420 | return AE_OK; | 430 | return AE_OK; |
@@ -512,15 +522,19 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge) | |||
512 | list_for_each_safe (list, tmp, &slot->funcs) { | 522 | list_for_each_safe (list, tmp, &slot->funcs) { |
513 | struct acpiphp_func *func; | 523 | struct acpiphp_func *func; |
514 | func = list_entry(list, struct acpiphp_func, sibling); | 524 | func = list_entry(list, struct acpiphp_func, sibling); |
515 | status = acpi_remove_notify_handler(func->handle, | 525 | if (!(func->flags & FUNC_HAS_DCK)) { |
526 | status = acpi_remove_notify_handler(func->handle, | ||
516 | ACPI_SYSTEM_NOTIFY, | 527 | ACPI_SYSTEM_NOTIFY, |
517 | handle_hotplug_event_func); | 528 | handle_hotplug_event_func); |
518 | if (ACPI_FAILURE(status)) | 529 | if (ACPI_FAILURE(status)) |
519 | err("failed to remove notify handler\n"); | 530 | err("failed to remove notify handler\n"); |
531 | } | ||
520 | pci_dev_put(func->pci_dev); | 532 | pci_dev_put(func->pci_dev); |
521 | list_del(list); | 533 | list_del(list); |
522 | kfree(func); | 534 | kfree(func); |
523 | } | 535 | } |
536 | acpiphp_unregister_hotplug_slot(slot); | ||
537 | list_del(&slot->funcs); | ||
524 | kfree(slot); | 538 | kfree(slot); |
525 | slot = next; | 539 | slot = next; |
526 | } | 540 | } |
@@ -551,7 +565,8 @@ static void remove_bridge(acpi_handle handle) | |||
551 | } else { | 565 | } else { |
552 | /* clean-up p2p bridges under this host bridge */ | 566 | /* clean-up p2p bridges under this host bridge */ |
553 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, | 567 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, |
554 | (u32)1, cleanup_p2p_bridge, NULL, NULL); | 568 | ACPI_UINT32_MAX, cleanup_p2p_bridge, |
569 | NULL, NULL); | ||
555 | } | 570 | } |
556 | } | 571 | } |
557 | 572 | ||
@@ -751,6 +766,113 @@ static int power_off_slot(struct acpiphp_slot *slot) | |||
751 | } | 766 | } |
752 | 767 | ||
753 | 768 | ||
769 | |||
770 | /** | ||
771 | * acpiphp_max_busnr - return the highest reserved bus number under | ||
772 | * the given bus. | ||
773 | * @bus: bus to start search with | ||
774 | * | ||
775 | */ | ||
776 | static unsigned char acpiphp_max_busnr(struct pci_bus *bus) | ||
777 | { | ||
778 | struct list_head *tmp; | ||
779 | unsigned char max, n; | ||
780 | |||
781 | /* | ||
782 | * pci_bus_max_busnr will return the highest | ||
783 | * reserved busnr for all these children. | ||
784 | * that is equivalent to the bus->subordinate | ||
785 | * value. We don't want to use the parent's | ||
786 | * bus->subordinate value because it could have | ||
787 | * padding in it. | ||
788 | */ | ||
789 | max = bus->secondary; | ||
790 | |||
791 | list_for_each(tmp, &bus->children) { | ||
792 | n = pci_bus_max_busnr(pci_bus_b(tmp)); | ||
793 | if (n > max) | ||
794 | max = n; | ||
795 | } | ||
796 | return max; | ||
797 | } | ||
798 | |||
799 | |||
800 | |||
801 | /** | ||
802 | * get_func - get a pointer to acpiphp_func given a slot, device | ||
803 | * @slot: slot to search | ||
804 | * @dev: pci_dev struct to match. | ||
805 | * | ||
806 | * This function will increase the reference count of pci_dev, | ||
807 | * so callers should call pci_dev_put when complete. | ||
808 | * | ||
809 | */ | ||
810 | static struct acpiphp_func * | ||
811 | get_func(struct acpiphp_slot *slot, struct pci_dev *dev) | ||
812 | { | ||
813 | struct acpiphp_func *func = NULL; | ||
814 | struct pci_bus *bus = slot->bridge->pci_bus; | ||
815 | struct pci_dev *pdev; | ||
816 | |||
817 | list_for_each_entry(func, &slot->funcs, sibling) { | ||
818 | pdev = pci_get_slot(bus, PCI_DEVFN(slot->device, | ||
819 | func->function)); | ||
820 | if (pdev) { | ||
821 | if (pdev == dev) | ||
822 | break; | ||
823 | pci_dev_put(pdev); | ||
824 | } | ||
825 | } | ||
826 | return func; | ||
827 | } | ||
828 | |||
829 | |||
830 | /** | ||
831 | * acpiphp_bus_add - add a new bus to acpi subsystem | ||
832 | * @func: acpiphp_func of the bridge | ||
833 | * | ||
834 | */ | ||
835 | static int acpiphp_bus_add(struct acpiphp_func *func) | ||
836 | { | ||
837 | acpi_handle phandle; | ||
838 | struct acpi_device *device, *pdevice; | ||
839 | int ret_val; | ||
840 | |||
841 | acpi_get_parent(func->handle, &phandle); | ||
842 | if (acpi_bus_get_device(phandle, &pdevice)) { | ||
843 | dbg("no parent device, assuming NULL\n"); | ||
844 | pdevice = NULL; | ||
845 | } | ||
846 | if (!acpi_bus_get_device(func->handle, &device)) { | ||
847 | dbg("bus exists... trim\n"); | ||
848 | /* this shouldn't be in here, so remove | ||
849 | * the bus then re-add it... | ||
850 | */ | ||
851 | ret_val = acpi_bus_trim(device, 1); | ||
852 | dbg("acpi_bus_trim return %x\n", ret_val); | ||
853 | } | ||
854 | |||
855 | ret_val = acpi_bus_add(&device, pdevice, func->handle, | ||
856 | ACPI_BUS_TYPE_DEVICE); | ||
857 | if (ret_val) { | ||
858 | dbg("error adding bus, %x\n", | ||
859 | -ret_val); | ||
860 | goto acpiphp_bus_add_out; | ||
861 | } | ||
862 | /* | ||
863 | * try to start anyway. We could have failed to add | ||
864 | * simply because this bus had previously been added | ||
865 | * on another add. Don't bother with the return value | ||
866 | * we just keep going. | ||
867 | */ | ||
868 | ret_val = acpi_bus_start(device); | ||
869 | |||
870 | acpiphp_bus_add_out: | ||
871 | return ret_val; | ||
872 | } | ||
873 | |||
874 | |||
875 | |||
754 | /** | 876 | /** |
755 | * enable_device - enable, configure a slot | 877 | * enable_device - enable, configure a slot |
756 | * @slot: slot to be enabled | 878 | * @slot: slot to be enabled |
@@ -788,7 +910,7 @@ static int enable_device(struct acpiphp_slot *slot) | |||
788 | goto err_exit; | 910 | goto err_exit; |
789 | } | 911 | } |
790 | 912 | ||
791 | max = bus->secondary; | 913 | max = acpiphp_max_busnr(bus); |
792 | for (pass = 0; pass < 2; pass++) { | 914 | for (pass = 0; pass < 2; pass++) { |
793 | list_for_each_entry(dev, &bus->devices, bus_list) { | 915 | list_for_each_entry(dev, &bus->devices, bus_list) { |
794 | if (PCI_SLOT(dev->devfn) != slot->device) | 916 | if (PCI_SLOT(dev->devfn) != slot->device) |
@@ -796,8 +918,15 @@ static int enable_device(struct acpiphp_slot *slot) | |||
796 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || | 918 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || |
797 | dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { | 919 | dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { |
798 | max = pci_scan_bridge(bus, dev, max, pass); | 920 | max = pci_scan_bridge(bus, dev, max, pass); |
799 | if (pass && dev->subordinate) | 921 | if (pass && dev->subordinate) { |
800 | pci_bus_size_bridges(dev->subordinate); | 922 | pci_bus_size_bridges(dev->subordinate); |
923 | func = get_func(slot, dev); | ||
924 | if (func) { | ||
925 | acpiphp_bus_add(func); | ||
926 | /* side effect of get_func */ | ||
927 | pci_dev_put(dev); | ||
928 | } | ||
929 | } | ||
801 | } | 930 | } |
802 | } | 931 | } |
803 | } | 932 | } |
@@ -806,8 +935,8 @@ static int enable_device(struct acpiphp_slot *slot) | |||
806 | acpiphp_sanitize_bus(bus); | 935 | acpiphp_sanitize_bus(bus); |
807 | pci_enable_bridges(bus); | 936 | pci_enable_bridges(bus); |
808 | pci_bus_add_devices(bus); | 937 | pci_bus_add_devices(bus); |
809 | acpiphp_set_hpp_values(DEVICE_ACPI_HANDLE(&bus->self->dev), bus); | 938 | acpiphp_set_hpp_values(slot->bridge->handle, bus); |
810 | acpiphp_configure_ioapics(DEVICE_ACPI_HANDLE(&bus->self->dev)); | 939 | acpiphp_configure_ioapics(slot->bridge->handle); |
811 | 940 | ||
812 | /* associate pci_dev to our representation */ | 941 | /* associate pci_dev to our representation */ |
813 | list_for_each (l, &slot->funcs) { | 942 | list_for_each (l, &slot->funcs) { |
@@ -987,11 +1116,11 @@ static void program_hpp(struct pci_dev *dev, struct acpiphp_bridge *bridge) | |||
987 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, | 1116 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, |
988 | bridge->hpp.latency_timer); | 1117 | bridge->hpp.latency_timer); |
989 | pci_read_config_word(dev, PCI_COMMAND, &pci_cmd); | 1118 | pci_read_config_word(dev, PCI_COMMAND, &pci_cmd); |
990 | if (bridge->hpp.enable_SERR) | 1119 | if (bridge->hpp.enable_serr) |
991 | pci_cmd |= PCI_COMMAND_SERR; | 1120 | pci_cmd |= PCI_COMMAND_SERR; |
992 | else | 1121 | else |
993 | pci_cmd &= ~PCI_COMMAND_SERR; | 1122 | pci_cmd &= ~PCI_COMMAND_SERR; |
994 | if (bridge->hpp.enable_PERR) | 1123 | if (bridge->hpp.enable_perr) |
995 | pci_cmd |= PCI_COMMAND_PARITY; | 1124 | pci_cmd |= PCI_COMMAND_PARITY; |
996 | else | 1125 | else |
997 | pci_cmd &= ~PCI_COMMAND_PARITY; | 1126 | pci_cmd &= ~PCI_COMMAND_PARITY; |
@@ -1002,11 +1131,11 @@ static void program_hpp(struct pci_dev *dev, struct acpiphp_bridge *bridge) | |||
1002 | pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, | 1131 | pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, |
1003 | bridge->hpp.latency_timer); | 1132 | bridge->hpp.latency_timer); |
1004 | pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl); | 1133 | pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl); |
1005 | if (bridge->hpp.enable_SERR) | 1134 | if (bridge->hpp.enable_serr) |
1006 | pci_bctl |= PCI_BRIDGE_CTL_SERR; | 1135 | pci_bctl |= PCI_BRIDGE_CTL_SERR; |
1007 | else | 1136 | else |
1008 | pci_bctl &= ~PCI_BRIDGE_CTL_SERR; | 1137 | pci_bctl &= ~PCI_BRIDGE_CTL_SERR; |
1009 | if (bridge->hpp.enable_PERR) | 1138 | if (bridge->hpp.enable_perr) |
1010 | pci_bctl |= PCI_BRIDGE_CTL_PARITY; | 1139 | pci_bctl |= PCI_BRIDGE_CTL_PARITY; |
1011 | else | 1140 | else |
1012 | pci_bctl &= ~PCI_BRIDGE_CTL_PARITY; | 1141 | pci_bctl &= ~PCI_BRIDGE_CTL_PARITY; |
@@ -1026,6 +1155,7 @@ static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus) | |||
1026 | 1155 | ||
1027 | memset(&bridge, 0, sizeof(bridge)); | 1156 | memset(&bridge, 0, sizeof(bridge)); |
1028 | bridge.handle = handle; | 1157 | bridge.handle = handle; |
1158 | bridge.pci_dev = bus->self; | ||
1029 | decode_hpp(&bridge); | 1159 | decode_hpp(&bridge); |
1030 | list_for_each_entry(dev, &bus->devices, bus_list) | 1160 | list_for_each_entry(dev, &bus->devices, bus_list) |
1031 | program_hpp(dev, &bridge); | 1161 | program_hpp(dev, &bridge); |
@@ -1200,7 +1330,7 @@ static void handle_hotplug_event_bridge(acpi_handle handle, u32 type, void *cont | |||
1200 | * handles ACPI event notification on slots | 1330 | * handles ACPI event notification on slots |
1201 | * | 1331 | * |
1202 | */ | 1332 | */ |
1203 | static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context) | 1333 | void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context) |
1204 | { | 1334 | { |
1205 | struct acpiphp_func *func; | 1335 | struct acpiphp_func *func; |
1206 | char objname[64]; | 1336 | char objname[64]; |
@@ -1242,41 +1372,13 @@ static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *contex | |||
1242 | } | 1372 | } |
1243 | } | 1373 | } |
1244 | 1374 | ||
1245 | static int is_root_bridge(acpi_handle handle) | ||
1246 | { | ||
1247 | acpi_status status; | ||
1248 | struct acpi_device_info *info; | ||
1249 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
1250 | int i; | ||
1251 | |||
1252 | status = acpi_get_object_info(handle, &buffer); | ||
1253 | if (ACPI_SUCCESS(status)) { | ||
1254 | info = buffer.pointer; | ||
1255 | if ((info->valid & ACPI_VALID_HID) && | ||
1256 | !strcmp(PCI_ROOT_HID_STRING, | ||
1257 | info->hardware_id.value)) { | ||
1258 | acpi_os_free(buffer.pointer); | ||
1259 | return 1; | ||
1260 | } | ||
1261 | if (info->valid & ACPI_VALID_CID) { | ||
1262 | for (i=0; i < info->compatibility_id.count; i++) { | ||
1263 | if (!strcmp(PCI_ROOT_HID_STRING, | ||
1264 | info->compatibility_id.id[i].value)) { | ||
1265 | acpi_os_free(buffer.pointer); | ||
1266 | return 1; | ||
1267 | } | ||
1268 | } | ||
1269 | } | ||
1270 | } | ||
1271 | return 0; | ||
1272 | } | ||
1273 | 1375 | ||
1274 | static acpi_status | 1376 | static acpi_status |
1275 | find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) | 1377 | find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) |
1276 | { | 1378 | { |
1277 | int *count = (int *)context; | 1379 | int *count = (int *)context; |
1278 | 1380 | ||
1279 | if (is_root_bridge(handle)) { | 1381 | if (acpi_root_bridge(handle)) { |
1280 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | 1382 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, |
1281 | handle_hotplug_event_bridge, NULL); | 1383 | handle_hotplug_event_bridge, NULL); |
1282 | (*count)++; | 1384 | (*count)++; |
@@ -1373,26 +1475,6 @@ static int acpiphp_for_each_slot(acpiphp_callback fn, void *data) | |||
1373 | } | 1475 | } |
1374 | #endif | 1476 | #endif |
1375 | 1477 | ||
1376 | /* search matching slot from id */ | ||
1377 | struct acpiphp_slot *get_slot_from_id(int id) | ||
1378 | { | ||
1379 | struct list_head *node; | ||
1380 | struct acpiphp_bridge *bridge; | ||
1381 | struct acpiphp_slot *slot; | ||
1382 | |||
1383 | list_for_each (node, &bridge_list) { | ||
1384 | bridge = (struct acpiphp_bridge *)node; | ||
1385 | for (slot = bridge->slots; slot; slot = slot->next) | ||
1386 | if (slot->id == id) | ||
1387 | return slot; | ||
1388 | } | ||
1389 | |||
1390 | /* should never happen! */ | ||
1391 | err("%s: no object for id %d\n", __FUNCTION__, id); | ||
1392 | WARN_ON(1); | ||
1393 | return NULL; | ||
1394 | } | ||
1395 | |||
1396 | 1478 | ||
1397 | /** | 1479 | /** |
1398 | * acpiphp_enable_slot - power on slot | 1480 | * acpiphp_enable_slot - power on slot |
@@ -1401,7 +1483,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot) | |||
1401 | { | 1483 | { |
1402 | int retval; | 1484 | int retval; |
1403 | 1485 | ||
1404 | down(&slot->crit_sect); | 1486 | mutex_lock(&slot->crit_sect); |
1405 | 1487 | ||
1406 | /* wake up all functions */ | 1488 | /* wake up all functions */ |
1407 | retval = power_on_slot(slot); | 1489 | retval = power_on_slot(slot); |
@@ -1413,7 +1495,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot) | |||
1413 | retval = enable_device(slot); | 1495 | retval = enable_device(slot); |
1414 | 1496 | ||
1415 | err_exit: | 1497 | err_exit: |
1416 | up(&slot->crit_sect); | 1498 | mutex_unlock(&slot->crit_sect); |
1417 | return retval; | 1499 | return retval; |
1418 | } | 1500 | } |
1419 | 1501 | ||
@@ -1424,7 +1506,7 @@ int acpiphp_disable_slot(struct acpiphp_slot *slot) | |||
1424 | { | 1506 | { |
1425 | int retval = 0; | 1507 | int retval = 0; |
1426 | 1508 | ||
1427 | down(&slot->crit_sect); | 1509 | mutex_lock(&slot->crit_sect); |
1428 | 1510 | ||
1429 | /* unconfigure all functions */ | 1511 | /* unconfigure all functions */ |
1430 | retval = disable_device(slot); | 1512 | retval = disable_device(slot); |
@@ -1437,7 +1519,7 @@ int acpiphp_disable_slot(struct acpiphp_slot *slot) | |||
1437 | goto err_exit; | 1519 | goto err_exit; |
1438 | 1520 | ||
1439 | err_exit: | 1521 | err_exit: |
1440 | up(&slot->crit_sect); | 1522 | mutex_unlock(&slot->crit_sect); |
1441 | return retval; | 1523 | return retval; |
1442 | } | 1524 | } |
1443 | 1525 | ||
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c index 30af105271a2..037ce4c91687 100644 --- a/drivers/pci/hotplug/cpci_hotplug_core.c +++ b/drivers/pci/hotplug/cpci_hotplug_core.c | |||
@@ -248,22 +248,19 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last) | |||
248 | * with the pci_hotplug subsystem. | 248 | * with the pci_hotplug subsystem. |
249 | */ | 249 | */ |
250 | for (i = first; i <= last; ++i) { | 250 | for (i = first; i <= last; ++i) { |
251 | slot = kmalloc(sizeof (struct slot), GFP_KERNEL); | 251 | slot = kzalloc(sizeof (struct slot), GFP_KERNEL); |
252 | if (!slot) | 252 | if (!slot) |
253 | goto error; | 253 | goto error; |
254 | memset(slot, 0, sizeof (struct slot)); | ||
255 | 254 | ||
256 | hotplug_slot = | 255 | hotplug_slot = |
257 | kmalloc(sizeof (struct hotplug_slot), GFP_KERNEL); | 256 | kzalloc(sizeof (struct hotplug_slot), GFP_KERNEL); |
258 | if (!hotplug_slot) | 257 | if (!hotplug_slot) |
259 | goto error_slot; | 258 | goto error_slot; |
260 | memset(hotplug_slot, 0, sizeof (struct hotplug_slot)); | ||
261 | slot->hotplug_slot = hotplug_slot; | 259 | slot->hotplug_slot = hotplug_slot; |
262 | 260 | ||
263 | info = kmalloc(sizeof (struct hotplug_slot_info), GFP_KERNEL); | 261 | info = kzalloc(sizeof (struct hotplug_slot_info), GFP_KERNEL); |
264 | if (!info) | 262 | if (!info) |
265 | goto error_hpslot; | 263 | goto error_hpslot; |
266 | memset(info, 0, sizeof (struct hotplug_slot_info)); | ||
267 | hotplug_slot->info = info; | 264 | hotplug_slot->info = info; |
268 | 265 | ||
269 | name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); | 266 | name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); |
diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h index cb88404c89fe..c74e9e37e76b 100644 --- a/drivers/pci/hotplug/cpqphp.h +++ b/drivers/pci/hotplug/cpqphp.h | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
33 | #include <asm/io.h> /* for read? and write? functions */ | 33 | #include <asm/io.h> /* for read? and write? functions */ |
34 | #include <linux/delay.h> /* for delays */ | 34 | #include <linux/delay.h> /* for delays */ |
35 | #include <linux/mutex.h> | ||
35 | 36 | ||
36 | #define MY_NAME "cpqphp" | 37 | #define MY_NAME "cpqphp" |
37 | 38 | ||
@@ -286,7 +287,7 @@ struct event_info { | |||
286 | struct controller { | 287 | struct controller { |
287 | struct controller *next; | 288 | struct controller *next; |
288 | u32 ctrl_int_comp; | 289 | u32 ctrl_int_comp; |
289 | struct semaphore crit_sect; /* critical section semaphore */ | 290 | struct mutex crit_sect; /* critical section mutex */ |
290 | void __iomem *hpc_reg; /* cookie for our pci controller location */ | 291 | void __iomem *hpc_reg; /* cookie for our pci controller location */ |
291 | struct pci_resource *mem_head; | 292 | struct pci_resource *mem_head; |
292 | struct pci_resource *p_mem_head; | 293 | struct pci_resource *p_mem_head; |
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c index b3659ffccac9..9bc1deb8df52 100644 --- a/drivers/pci/hotplug/cpqphp_core.c +++ b/drivers/pci/hotplug/cpqphp_core.c | |||
@@ -347,26 +347,22 @@ static int ctrl_slot_setup(struct controller *ctrl, | |||
347 | slot_number = ctrl->first_slot; | 347 | slot_number = ctrl->first_slot; |
348 | 348 | ||
349 | while (number_of_slots) { | 349 | while (number_of_slots) { |
350 | slot = kmalloc(sizeof(*slot), GFP_KERNEL); | 350 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); |
351 | if (!slot) | 351 | if (!slot) |
352 | goto error; | 352 | goto error; |
353 | 353 | ||
354 | memset(slot, 0, sizeof(struct slot)); | 354 | slot->hotplug_slot = kzalloc(sizeof(*(slot->hotplug_slot)), |
355 | slot->hotplug_slot = kmalloc(sizeof(*(slot->hotplug_slot)), | ||
356 | GFP_KERNEL); | 355 | GFP_KERNEL); |
357 | if (!slot->hotplug_slot) | 356 | if (!slot->hotplug_slot) |
358 | goto error_slot; | 357 | goto error_slot; |
359 | hotplug_slot = slot->hotplug_slot; | 358 | hotplug_slot = slot->hotplug_slot; |
360 | memset(hotplug_slot, 0, sizeof(struct hotplug_slot)); | ||
361 | 359 | ||
362 | hotplug_slot->info = | 360 | hotplug_slot->info = |
363 | kmalloc(sizeof(*(hotplug_slot->info)), | 361 | kzalloc(sizeof(*(hotplug_slot->info)), |
364 | GFP_KERNEL); | 362 | GFP_KERNEL); |
365 | if (!hotplug_slot->info) | 363 | if (!hotplug_slot->info) |
366 | goto error_hpslot; | 364 | goto error_hpslot; |
367 | hotplug_slot_info = hotplug_slot->info; | 365 | hotplug_slot_info = hotplug_slot->info; |
368 | memset(hotplug_slot_info, 0, | ||
369 | sizeof(struct hotplug_slot_info)); | ||
370 | hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); | 366 | hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); |
371 | 367 | ||
372 | if (!hotplug_slot->name) | 368 | if (!hotplug_slot->name) |
@@ -599,7 +595,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func, | |||
599 | hp_slot = func->device - ctrl->slot_device_offset; | 595 | hp_slot = func->device - ctrl->slot_device_offset; |
600 | 596 | ||
601 | // Wait for exclusive access to hardware | 597 | // Wait for exclusive access to hardware |
602 | down(&ctrl->crit_sect); | 598 | mutex_lock(&ctrl->crit_sect); |
603 | 599 | ||
604 | if (status == 1) { | 600 | if (status == 1) { |
605 | amber_LED_on (ctrl, hp_slot); | 601 | amber_LED_on (ctrl, hp_slot); |
@@ -607,7 +603,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func, | |||
607 | amber_LED_off (ctrl, hp_slot); | 603 | amber_LED_off (ctrl, hp_slot); |
608 | } else { | 604 | } else { |
609 | // Done with exclusive hardware access | 605 | // Done with exclusive hardware access |
610 | up(&ctrl->crit_sect); | 606 | mutex_unlock(&ctrl->crit_sect); |
611 | return(1); | 607 | return(1); |
612 | } | 608 | } |
613 | 609 | ||
@@ -617,7 +613,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func, | |||
617 | wait_for_ctrl_irq (ctrl); | 613 | wait_for_ctrl_irq (ctrl); |
618 | 614 | ||
619 | // Done with exclusive hardware access | 615 | // Done with exclusive hardware access |
620 | up(&ctrl->crit_sect); | 616 | mutex_unlock(&ctrl->crit_sect); |
621 | 617 | ||
622 | return(0); | 618 | return(0); |
623 | } | 619 | } |
@@ -854,13 +850,12 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
854 | goto err_disable_device; | 850 | goto err_disable_device; |
855 | } | 851 | } |
856 | 852 | ||
857 | ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL); | 853 | ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL); |
858 | if (!ctrl) { | 854 | if (!ctrl) { |
859 | err("%s : out of memory\n", __FUNCTION__); | 855 | err("%s : out of memory\n", __FUNCTION__); |
860 | rc = -ENOMEM; | 856 | rc = -ENOMEM; |
861 | goto err_disable_device; | 857 | goto err_disable_device; |
862 | } | 858 | } |
863 | memset(ctrl, 0, sizeof(struct controller)); | ||
864 | 859 | ||
865 | rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsystem_deviceid); | 860 | rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsystem_deviceid); |
866 | if (rc) { | 861 | if (rc) { |
@@ -1084,7 +1079,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1084 | dbg("bus device function rev: %d %d %d %d\n", ctrl->bus, | 1079 | dbg("bus device function rev: %d %d %d %d\n", ctrl->bus, |
1085 | PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), ctrl->rev); | 1080 | PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), ctrl->rev); |
1086 | 1081 | ||
1087 | init_MUTEX(&ctrl->crit_sect); | 1082 | mutex_init(&ctrl->crit_sect); |
1088 | init_waitqueue_head(&ctrl->queue); | 1083 | init_waitqueue_head(&ctrl->queue); |
1089 | 1084 | ||
1090 | /* initialize our threads if they haven't already been started up */ | 1085 | /* initialize our threads if they haven't already been started up */ |
@@ -1223,7 +1218,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1223 | 1218 | ||
1224 | // turn off empty slots here unless command line option "ON" set | 1219 | // turn off empty slots here unless command line option "ON" set |
1225 | // Wait for exclusive access to hardware | 1220 | // Wait for exclusive access to hardware |
1226 | down(&ctrl->crit_sect); | 1221 | mutex_lock(&ctrl->crit_sect); |
1227 | 1222 | ||
1228 | num_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F; | 1223 | num_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F; |
1229 | 1224 | ||
@@ -1270,12 +1265,12 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1270 | rc = init_SERR(ctrl); | 1265 | rc = init_SERR(ctrl); |
1271 | if (rc) { | 1266 | if (rc) { |
1272 | err("init_SERR failed\n"); | 1267 | err("init_SERR failed\n"); |
1273 | up(&ctrl->crit_sect); | 1268 | mutex_unlock(&ctrl->crit_sect); |
1274 | goto err_free_irq; | 1269 | goto err_free_irq; |
1275 | } | 1270 | } |
1276 | 1271 | ||
1277 | // Done with exclusive hardware access | 1272 | // Done with exclusive hardware access |
1278 | up(&ctrl->crit_sect); | 1273 | mutex_unlock(&ctrl->crit_sect); |
1279 | 1274 | ||
1280 | cpqhp_create_debugfs_files(ctrl); | 1275 | cpqhp_create_debugfs_files(ctrl); |
1281 | 1276 | ||
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c index 771ed34b1819..55d2dc7e39ca 100644 --- a/drivers/pci/hotplug/cpqphp_ctrl.c +++ b/drivers/pci/hotplug/cpqphp_ctrl.c | |||
@@ -1282,9 +1282,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1282 | u8 hp_slot; | 1282 | u8 hp_slot; |
1283 | u8 temp_byte; | 1283 | u8 temp_byte; |
1284 | u8 adapter_speed; | 1284 | u8 adapter_speed; |
1285 | u32 index; | ||
1286 | u32 rc = 0; | 1285 | u32 rc = 0; |
1287 | u32 src = 8; | ||
1288 | 1286 | ||
1289 | hp_slot = func->device - ctrl->slot_device_offset; | 1287 | hp_slot = func->device - ctrl->slot_device_offset; |
1290 | 1288 | ||
@@ -1299,7 +1297,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1299 | **********************************/ | 1297 | **********************************/ |
1300 | rc = CARD_FUNCTIONING; | 1298 | rc = CARD_FUNCTIONING; |
1301 | } else { | 1299 | } else { |
1302 | down(&ctrl->crit_sect); | 1300 | mutex_lock(&ctrl->crit_sect); |
1303 | 1301 | ||
1304 | /* turn on board without attaching to the bus */ | 1302 | /* turn on board without attaching to the bus */ |
1305 | enable_slot_power (ctrl, hp_slot); | 1303 | enable_slot_power (ctrl, hp_slot); |
@@ -1333,12 +1331,12 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1333 | /* Wait for SOBS to be unset */ | 1331 | /* Wait for SOBS to be unset */ |
1334 | wait_for_ctrl_irq (ctrl); | 1332 | wait_for_ctrl_irq (ctrl); |
1335 | 1333 | ||
1336 | up(&ctrl->crit_sect); | 1334 | mutex_unlock(&ctrl->crit_sect); |
1337 | 1335 | ||
1338 | if (rc) | 1336 | if (rc) |
1339 | return rc; | 1337 | return rc; |
1340 | 1338 | ||
1341 | down(&ctrl->crit_sect); | 1339 | mutex_lock(&ctrl->crit_sect); |
1342 | 1340 | ||
1343 | slot_enable (ctrl, hp_slot); | 1341 | slot_enable (ctrl, hp_slot); |
1344 | green_LED_blink (ctrl, hp_slot); | 1342 | green_LED_blink (ctrl, hp_slot); |
@@ -1350,7 +1348,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1350 | /* Wait for SOBS to be unset */ | 1348 | /* Wait for SOBS to be unset */ |
1351 | wait_for_ctrl_irq (ctrl); | 1349 | wait_for_ctrl_irq (ctrl); |
1352 | 1350 | ||
1353 | up(&ctrl->crit_sect); | 1351 | mutex_unlock(&ctrl->crit_sect); |
1354 | 1352 | ||
1355 | /* Wait for ~1 second because of hot plug spec */ | 1353 | /* Wait for ~1 second because of hot plug spec */ |
1356 | long_delay(1*HZ); | 1354 | long_delay(1*HZ); |
@@ -1368,76 +1366,30 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1368 | 1366 | ||
1369 | rc = cpqhp_configure_board(ctrl, func); | 1367 | rc = cpqhp_configure_board(ctrl, func); |
1370 | 1368 | ||
1371 | if (rc || src) { | 1369 | /* If configuration fails, turn it off |
1372 | /* If configuration fails, turn it off | 1370 | * Get slot won't work for devices behind |
1373 | * Get slot won't work for devices behind | 1371 | * bridges, but in this case it will always be |
1374 | * bridges, but in this case it will always be | 1372 | * called for the "base" bus/dev/func of an |
1375 | * called for the "base" bus/dev/func of an | 1373 | * adapter. */ |
1376 | * adapter. */ | ||
1377 | 1374 | ||
1378 | down(&ctrl->crit_sect); | 1375 | mutex_lock(&ctrl->crit_sect); |
1379 | 1376 | ||
1380 | amber_LED_on (ctrl, hp_slot); | 1377 | amber_LED_on (ctrl, hp_slot); |
1381 | green_LED_off (ctrl, hp_slot); | 1378 | green_LED_off (ctrl, hp_slot); |
1382 | slot_disable (ctrl, hp_slot); | 1379 | slot_disable (ctrl, hp_slot); |
1383 | |||
1384 | set_SOGO(ctrl); | ||
1385 | |||
1386 | /* Wait for SOBS to be unset */ | ||
1387 | wait_for_ctrl_irq (ctrl); | ||
1388 | |||
1389 | up(&ctrl->crit_sect); | ||
1390 | |||
1391 | if (rc) | ||
1392 | return rc; | ||
1393 | else | ||
1394 | return 1; | ||
1395 | } | ||
1396 | |||
1397 | func->status = 0; | ||
1398 | func->switch_save = 0x10; | ||
1399 | |||
1400 | index = 1; | ||
1401 | while (((func = cpqhp_slot_find(func->bus, func->device, index)) != NULL) && !rc) { | ||
1402 | rc |= cpqhp_configure_board(ctrl, func); | ||
1403 | index++; | ||
1404 | } | ||
1405 | |||
1406 | if (rc) { | ||
1407 | /* If configuration fails, turn it off | ||
1408 | * Get slot won't work for devices behind | ||
1409 | * bridges, but in this case it will always be | ||
1410 | * called for the "base" bus/dev/func of an | ||
1411 | * adapter. */ | ||
1412 | |||
1413 | down(&ctrl->crit_sect); | ||
1414 | |||
1415 | amber_LED_on (ctrl, hp_slot); | ||
1416 | green_LED_off (ctrl, hp_slot); | ||
1417 | slot_disable (ctrl, hp_slot); | ||
1418 | |||
1419 | set_SOGO(ctrl); | ||
1420 | |||
1421 | /* Wait for SOBS to be unset */ | ||
1422 | wait_for_ctrl_irq (ctrl); | ||
1423 | |||
1424 | up(&ctrl->crit_sect); | ||
1425 | |||
1426 | return rc; | ||
1427 | } | ||
1428 | /* Done configuring so turn LED on full time */ | ||
1429 | |||
1430 | down(&ctrl->crit_sect); | ||
1431 | |||
1432 | green_LED_on (ctrl, hp_slot); | ||
1433 | 1380 | ||
1434 | set_SOGO(ctrl); | 1381 | set_SOGO(ctrl); |
1435 | 1382 | ||
1436 | /* Wait for SOBS to be unset */ | 1383 | /* Wait for SOBS to be unset */ |
1437 | wait_for_ctrl_irq (ctrl); | 1384 | wait_for_ctrl_irq (ctrl); |
1438 | 1385 | ||
1439 | up(&ctrl->crit_sect); | 1386 | mutex_unlock(&ctrl->crit_sect); |
1440 | rc = 0; | 1387 | |
1388 | if (rc) | ||
1389 | return rc; | ||
1390 | else | ||
1391 | return 1; | ||
1392 | |||
1441 | } else { | 1393 | } else { |
1442 | /* Something is wrong | 1394 | /* Something is wrong |
1443 | 1395 | ||
@@ -1445,7 +1397,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1445 | * in this case it will always be called for the "base" | 1397 | * in this case it will always be called for the "base" |
1446 | * bus/dev/func of an adapter. */ | 1398 | * bus/dev/func of an adapter. */ |
1447 | 1399 | ||
1448 | down(&ctrl->crit_sect); | 1400 | mutex_lock(&ctrl->crit_sect); |
1449 | 1401 | ||
1450 | amber_LED_on (ctrl, hp_slot); | 1402 | amber_LED_on (ctrl, hp_slot); |
1451 | green_LED_off (ctrl, hp_slot); | 1403 | green_LED_off (ctrl, hp_slot); |
@@ -1456,7 +1408,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1456 | /* Wait for SOBS to be unset */ | 1408 | /* Wait for SOBS to be unset */ |
1457 | wait_for_ctrl_irq (ctrl); | 1409 | wait_for_ctrl_irq (ctrl); |
1458 | 1410 | ||
1459 | up(&ctrl->crit_sect); | 1411 | mutex_unlock(&ctrl->crit_sect); |
1460 | } | 1412 | } |
1461 | 1413 | ||
1462 | } | 1414 | } |
@@ -1488,7 +1440,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1488 | dbg("%s: func->device, slot_offset, hp_slot = %d, %d ,%d\n", | 1440 | dbg("%s: func->device, slot_offset, hp_slot = %d, %d ,%d\n", |
1489 | __FUNCTION__, func->device, ctrl->slot_device_offset, hp_slot); | 1441 | __FUNCTION__, func->device, ctrl->slot_device_offset, hp_slot); |
1490 | 1442 | ||
1491 | down(&ctrl->crit_sect); | 1443 | mutex_lock(&ctrl->crit_sect); |
1492 | 1444 | ||
1493 | /* turn on board without attaching to the bus */ | 1445 | /* turn on board without attaching to the bus */ |
1494 | enable_slot_power(ctrl, hp_slot); | 1446 | enable_slot_power(ctrl, hp_slot); |
@@ -1522,7 +1474,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1522 | /* Wait for SOBS to be unset */ | 1474 | /* Wait for SOBS to be unset */ |
1523 | wait_for_ctrl_irq(ctrl); | 1475 | wait_for_ctrl_irq(ctrl); |
1524 | 1476 | ||
1525 | up(&ctrl->crit_sect); | 1477 | mutex_unlock(&ctrl->crit_sect); |
1526 | 1478 | ||
1527 | if (rc) | 1479 | if (rc) |
1528 | return rc; | 1480 | return rc; |
@@ -1532,7 +1484,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1532 | /* turn on board and blink green LED */ | 1484 | /* turn on board and blink green LED */ |
1533 | 1485 | ||
1534 | dbg("%s: before down\n", __FUNCTION__); | 1486 | dbg("%s: before down\n", __FUNCTION__); |
1535 | down(&ctrl->crit_sect); | 1487 | mutex_lock(&ctrl->crit_sect); |
1536 | dbg("%s: after down\n", __FUNCTION__); | 1488 | dbg("%s: after down\n", __FUNCTION__); |
1537 | 1489 | ||
1538 | dbg("%s: before slot_enable\n", __FUNCTION__); | 1490 | dbg("%s: before slot_enable\n", __FUNCTION__); |
@@ -1553,7 +1505,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1553 | dbg("%s: after wait_for_ctrl_irq\n", __FUNCTION__); | 1505 | dbg("%s: after wait_for_ctrl_irq\n", __FUNCTION__); |
1554 | 1506 | ||
1555 | dbg("%s: before up\n", __FUNCTION__); | 1507 | dbg("%s: before up\n", __FUNCTION__); |
1556 | up(&ctrl->crit_sect); | 1508 | mutex_unlock(&ctrl->crit_sect); |
1557 | dbg("%s: after up\n", __FUNCTION__); | 1509 | dbg("%s: after up\n", __FUNCTION__); |
1558 | 1510 | ||
1559 | /* Wait for ~1 second because of hot plug spec */ | 1511 | /* Wait for ~1 second because of hot plug spec */ |
@@ -1607,7 +1559,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1607 | cpqhp_resource_sort_and_combine(&(ctrl->bus_head)); | 1559 | cpqhp_resource_sort_and_combine(&(ctrl->bus_head)); |
1608 | 1560 | ||
1609 | if (rc) { | 1561 | if (rc) { |
1610 | down(&ctrl->crit_sect); | 1562 | mutex_lock(&ctrl->crit_sect); |
1611 | 1563 | ||
1612 | amber_LED_on (ctrl, hp_slot); | 1564 | amber_LED_on (ctrl, hp_slot); |
1613 | green_LED_off (ctrl, hp_slot); | 1565 | green_LED_off (ctrl, hp_slot); |
@@ -1618,7 +1570,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1618 | /* Wait for SOBS to be unset */ | 1570 | /* Wait for SOBS to be unset */ |
1619 | wait_for_ctrl_irq (ctrl); | 1571 | wait_for_ctrl_irq (ctrl); |
1620 | 1572 | ||
1621 | up(&ctrl->crit_sect); | 1573 | mutex_unlock(&ctrl->crit_sect); |
1622 | return rc; | 1574 | return rc; |
1623 | } else { | 1575 | } else { |
1624 | cpqhp_save_slot_config(ctrl, func); | 1576 | cpqhp_save_slot_config(ctrl, func); |
@@ -1640,7 +1592,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1640 | } | 1592 | } |
1641 | } while (new_slot); | 1593 | } while (new_slot); |
1642 | 1594 | ||
1643 | down(&ctrl->crit_sect); | 1595 | mutex_lock(&ctrl->crit_sect); |
1644 | 1596 | ||
1645 | green_LED_on (ctrl, hp_slot); | 1597 | green_LED_on (ctrl, hp_slot); |
1646 | 1598 | ||
@@ -1649,9 +1601,9 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1649 | /* Wait for SOBS to be unset */ | 1601 | /* Wait for SOBS to be unset */ |
1650 | wait_for_ctrl_irq (ctrl); | 1602 | wait_for_ctrl_irq (ctrl); |
1651 | 1603 | ||
1652 | up(&ctrl->crit_sect); | 1604 | mutex_unlock(&ctrl->crit_sect); |
1653 | } else { | 1605 | } else { |
1654 | down(&ctrl->crit_sect); | 1606 | mutex_lock(&ctrl->crit_sect); |
1655 | 1607 | ||
1656 | amber_LED_on (ctrl, hp_slot); | 1608 | amber_LED_on (ctrl, hp_slot); |
1657 | green_LED_off (ctrl, hp_slot); | 1609 | green_LED_off (ctrl, hp_slot); |
@@ -1662,7 +1614,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1662 | /* Wait for SOBS to be unset */ | 1614 | /* Wait for SOBS to be unset */ |
1663 | wait_for_ctrl_irq (ctrl); | 1615 | wait_for_ctrl_irq (ctrl); |
1664 | 1616 | ||
1665 | up(&ctrl->crit_sect); | 1617 | mutex_unlock(&ctrl->crit_sect); |
1666 | 1618 | ||
1667 | return rc; | 1619 | return rc; |
1668 | } | 1620 | } |
@@ -1721,7 +1673,7 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control | |||
1721 | func->status = 0x01; | 1673 | func->status = 0x01; |
1722 | func->configured = 0; | 1674 | func->configured = 0; |
1723 | 1675 | ||
1724 | down(&ctrl->crit_sect); | 1676 | mutex_lock(&ctrl->crit_sect); |
1725 | 1677 | ||
1726 | green_LED_off (ctrl, hp_slot); | 1678 | green_LED_off (ctrl, hp_slot); |
1727 | slot_disable (ctrl, hp_slot); | 1679 | slot_disable (ctrl, hp_slot); |
@@ -1736,7 +1688,7 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control | |||
1736 | /* Wait for SOBS to be unset */ | 1688 | /* Wait for SOBS to be unset */ |
1737 | wait_for_ctrl_irq (ctrl); | 1689 | wait_for_ctrl_irq (ctrl); |
1738 | 1690 | ||
1739 | up(&ctrl->crit_sect); | 1691 | mutex_unlock(&ctrl->crit_sect); |
1740 | 1692 | ||
1741 | if (!replace_flag && ctrl->add_support) { | 1693 | if (!replace_flag && ctrl->add_support) { |
1742 | while (func) { | 1694 | while (func) { |
@@ -1899,7 +1851,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
1899 | dbg("button cancel\n"); | 1851 | dbg("button cancel\n"); |
1900 | del_timer(&p_slot->task_event); | 1852 | del_timer(&p_slot->task_event); |
1901 | 1853 | ||
1902 | down(&ctrl->crit_sect); | 1854 | mutex_lock(&ctrl->crit_sect); |
1903 | 1855 | ||
1904 | if (p_slot->state == BLINKINGOFF_STATE) { | 1856 | if (p_slot->state == BLINKINGOFF_STATE) { |
1905 | /* slot is on */ | 1857 | /* slot is on */ |
@@ -1922,7 +1874,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
1922 | /* Wait for SOBS to be unset */ | 1874 | /* Wait for SOBS to be unset */ |
1923 | wait_for_ctrl_irq (ctrl); | 1875 | wait_for_ctrl_irq (ctrl); |
1924 | 1876 | ||
1925 | up(&ctrl->crit_sect); | 1877 | mutex_unlock(&ctrl->crit_sect); |
1926 | } | 1878 | } |
1927 | /*** button Released (No action on press...) */ | 1879 | /*** button Released (No action on press...) */ |
1928 | else if (ctrl->event_queue[loop].event_type == INT_BUTTON_RELEASE) { | 1880 | else if (ctrl->event_queue[loop].event_type == INT_BUTTON_RELEASE) { |
@@ -1937,7 +1889,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
1937 | p_slot->state = BLINKINGON_STATE; | 1889 | p_slot->state = BLINKINGON_STATE; |
1938 | info(msg_button_on, p_slot->number); | 1890 | info(msg_button_on, p_slot->number); |
1939 | } | 1891 | } |
1940 | down(&ctrl->crit_sect); | 1892 | mutex_lock(&ctrl->crit_sect); |
1941 | 1893 | ||
1942 | dbg("blink green LED and turn off amber\n"); | 1894 | dbg("blink green LED and turn off amber\n"); |
1943 | 1895 | ||
@@ -1949,7 +1901,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
1949 | /* Wait for SOBS to be unset */ | 1901 | /* Wait for SOBS to be unset */ |
1950 | wait_for_ctrl_irq (ctrl); | 1902 | wait_for_ctrl_irq (ctrl); |
1951 | 1903 | ||
1952 | up(&ctrl->crit_sect); | 1904 | mutex_unlock(&ctrl->crit_sect); |
1953 | init_timer(&p_slot->task_event); | 1905 | init_timer(&p_slot->task_event); |
1954 | p_slot->hp_slot = hp_slot; | 1906 | p_slot->hp_slot = hp_slot; |
1955 | p_slot->ctrl = ctrl; | 1907 | p_slot->ctrl = ctrl; |
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c index 060d74775d7b..71b80c23e8ce 100644 --- a/drivers/pci/hotplug/fakephp.c +++ b/drivers/pci/hotplug/fakephp.c | |||
@@ -95,15 +95,13 @@ static int add_slot(struct pci_dev *dev) | |||
95 | struct hotplug_slot *slot; | 95 | struct hotplug_slot *slot; |
96 | int retval = -ENOMEM; | 96 | int retval = -ENOMEM; |
97 | 97 | ||
98 | slot = kmalloc(sizeof(struct hotplug_slot), GFP_KERNEL); | 98 | slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL); |
99 | if (!slot) | 99 | if (!slot) |
100 | goto error; | 100 | goto error; |
101 | memset(slot, 0, sizeof(*slot)); | ||
102 | 101 | ||
103 | slot->info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); | 102 | slot->info = kzalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); |
104 | if (!slot->info) | 103 | if (!slot->info) |
105 | goto error_slot; | 104 | goto error_slot; |
106 | memset(slot->info, 0, sizeof(struct hotplug_slot_info)); | ||
107 | 105 | ||
108 | slot->info->power_status = 1; | 106 | slot->info->power_status = 1; |
109 | slot->info->max_bus_speed = PCI_SPEED_UNKNOWN; | 107 | slot->info->max_bus_speed = PCI_SPEED_UNKNOWN; |
@@ -227,11 +225,10 @@ static void pci_rescan_bus(const struct pci_bus *bus) | |||
227 | { | 225 | { |
228 | unsigned int devfn; | 226 | unsigned int devfn; |
229 | struct pci_dev *dev; | 227 | struct pci_dev *dev; |
230 | dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL); | 228 | dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL); |
231 | if (!dev) | 229 | if (!dev) |
232 | return; | 230 | return; |
233 | 231 | ||
234 | memset(dev, 0, sizeof(dev)); | ||
235 | dev->bus = (struct pci_bus*)bus; | 232 | dev->bus = (struct pci_bus*)bus; |
236 | dev->sysdata = bus->sysdata; | 233 | dev->sysdata = bus->sysdata; |
237 | for (devfn = 0; devfn < 0x100; devfn += 8) { | 234 | for (devfn = 0; devfn < 0x100; devfn += 8) { |
diff --git a/drivers/pci/hotplug/ibmphp.h b/drivers/pci/hotplug/ibmphp.h index c22e0284d7b1..dba6d8ca9bda 100644 --- a/drivers/pci/hotplug/ibmphp.h +++ b/drivers/pci/hotplug/ibmphp.h | |||
@@ -406,8 +406,6 @@ extern void ibmphp_hpc_stop_poll_thread (void); | |||
406 | //---------------------------------------------------------------------------- | 406 | //---------------------------------------------------------------------------- |
407 | // HPC return codes | 407 | // HPC return codes |
408 | //---------------------------------------------------------------------------- | 408 | //---------------------------------------------------------------------------- |
409 | #define FALSE 0x00 | ||
410 | #define TRUE 0x01 | ||
411 | #define HPC_ERROR 0xFF | 409 | #define HPC_ERROR 0xFF |
412 | 410 | ||
413 | //----------------------------------------------------------------------------- | 411 | //----------------------------------------------------------------------------- |
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c index dc59da675c08..e13d5b87241a 100644 --- a/drivers/pci/hotplug/ibmphp_core.c +++ b/drivers/pci/hotplug/ibmphp_core.c | |||
@@ -1141,7 +1141,7 @@ static int enable_slot(struct hotplug_slot *hs) | |||
1141 | goto error_power; | 1141 | goto error_power; |
1142 | } | 1142 | } |
1143 | 1143 | ||
1144 | slot_cur->func = kmalloc(sizeof(struct pci_func), GFP_KERNEL); | 1144 | slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL); |
1145 | if (!slot_cur->func) { | 1145 | if (!slot_cur->func) { |
1146 | /* We cannot do update_slot_info here, since no memory for | 1146 | /* We cannot do update_slot_info here, since no memory for |
1147 | * kmalloc n.e.ways, and update_slot_info allocates some */ | 1147 | * kmalloc n.e.ways, and update_slot_info allocates some */ |
@@ -1149,7 +1149,6 @@ static int enable_slot(struct hotplug_slot *hs) | |||
1149 | rc = -ENOMEM; | 1149 | rc = -ENOMEM; |
1150 | goto error_power; | 1150 | goto error_power; |
1151 | } | 1151 | } |
1152 | memset(slot_cur->func, 0, sizeof(struct pci_func)); | ||
1153 | slot_cur->func->busno = slot_cur->bus; | 1152 | slot_cur->func->busno = slot_cur->bus; |
1154 | slot_cur->func->device = slot_cur->device; | 1153 | slot_cur->func->device = slot_cur->device; |
1155 | for (i = 0; i < 4; i++) | 1154 | for (i = 0; i < 4; i++) |
@@ -1240,9 +1239,9 @@ int ibmphp_do_disable_slot(struct slot *slot_cur) | |||
1240 | } | 1239 | } |
1241 | 1240 | ||
1242 | flag = slot_cur->flag; | 1241 | flag = slot_cur->flag; |
1243 | slot_cur->flag = TRUE; | 1242 | slot_cur->flag = 1; |
1244 | 1243 | ||
1245 | if (flag == TRUE) { | 1244 | if (flag == 1) { |
1246 | rc = validate(slot_cur, DISABLE); | 1245 | rc = validate(slot_cur, DISABLE); |
1247 | /* checking if powered off already & valid slot # */ | 1246 | /* checking if powered off already & valid slot # */ |
1248 | if (rc) | 1247 | if (rc) |
@@ -1252,13 +1251,12 @@ int ibmphp_do_disable_slot(struct slot *slot_cur) | |||
1252 | 1251 | ||
1253 | if (slot_cur->func == NULL) { | 1252 | if (slot_cur->func == NULL) { |
1254 | /* We need this for fncs's that were there on bootup */ | 1253 | /* We need this for fncs's that were there on bootup */ |
1255 | slot_cur->func = kmalloc(sizeof(struct pci_func), GFP_KERNEL); | 1254 | slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL); |
1256 | if (!slot_cur->func) { | 1255 | if (!slot_cur->func) { |
1257 | err("out of system memory\n"); | 1256 | err("out of system memory\n"); |
1258 | rc = -ENOMEM; | 1257 | rc = -ENOMEM; |
1259 | goto error; | 1258 | goto error; |
1260 | } | 1259 | } |
1261 | memset(slot_cur->func, 0, sizeof(struct pci_func)); | ||
1262 | slot_cur->func->busno = slot_cur->bus; | 1260 | slot_cur->func->busno = slot_cur->bus; |
1263 | slot_cur->func->device = slot_cur->device; | 1261 | slot_cur->func->device = slot_cur->device; |
1264 | } | 1262 | } |
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c index aea1187c73ad..05e4f5a1927a 100644 --- a/drivers/pci/hotplug/ibmphp_ebda.c +++ b/drivers/pci/hotplug/ibmphp_ebda.c | |||
@@ -72,13 +72,7 @@ static int ebda_rio_table (void); | |||
72 | 72 | ||
73 | static struct ebda_hpc_list * __init alloc_ebda_hpc_list (void) | 73 | static struct ebda_hpc_list * __init alloc_ebda_hpc_list (void) |
74 | { | 74 | { |
75 | struct ebda_hpc_list *list; | 75 | return kzalloc(sizeof(struct ebda_hpc_list), GFP_KERNEL); |
76 | |||
77 | list = kmalloc (sizeof (struct ebda_hpc_list), GFP_KERNEL); | ||
78 | if (!list) | ||
79 | return NULL; | ||
80 | memset (list, 0, sizeof (*list)); | ||
81 | return list; | ||
82 | } | 76 | } |
83 | 77 | ||
84 | static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count) | 78 | static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count) |
@@ -87,21 +81,18 @@ static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count) | |||
87 | struct ebda_hpc_slot *slots; | 81 | struct ebda_hpc_slot *slots; |
88 | struct ebda_hpc_bus *buses; | 82 | struct ebda_hpc_bus *buses; |
89 | 83 | ||
90 | controller = kmalloc (sizeof (struct controller), GFP_KERNEL); | 84 | controller = kzalloc(sizeof(struct controller), GFP_KERNEL); |
91 | if (!controller) | 85 | if (!controller) |
92 | goto error; | 86 | goto error; |
93 | memset (controller, 0, sizeof (*controller)); | ||
94 | 87 | ||
95 | slots = kmalloc (sizeof (struct ebda_hpc_slot) * slot_count, GFP_KERNEL); | 88 | slots = kcalloc(slot_count, sizeof(struct ebda_hpc_slot), GFP_KERNEL); |
96 | if (!slots) | 89 | if (!slots) |
97 | goto error_contr; | 90 | goto error_contr; |
98 | memset (slots, 0, sizeof (*slots) * slot_count); | ||
99 | controller->slots = slots; | 91 | controller->slots = slots; |
100 | 92 | ||
101 | buses = kmalloc (sizeof (struct ebda_hpc_bus) * bus_count, GFP_KERNEL); | 93 | buses = kcalloc(bus_count, sizeof(struct ebda_hpc_bus), GFP_KERNEL); |
102 | if (!buses) | 94 | if (!buses) |
103 | goto error_slots; | 95 | goto error_slots; |
104 | memset (buses, 0, sizeof (*buses) * bus_count); | ||
105 | controller->buses = buses; | 96 | controller->buses = buses; |
106 | 97 | ||
107 | return controller; | 98 | return controller; |
@@ -122,24 +113,12 @@ static void free_ebda_hpc (struct controller *controller) | |||
122 | 113 | ||
123 | static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list (void) | 114 | static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list (void) |
124 | { | 115 | { |
125 | struct ebda_rsrc_list *list; | 116 | return kzalloc(sizeof(struct ebda_rsrc_list), GFP_KERNEL); |
126 | |||
127 | list = kmalloc (sizeof (struct ebda_rsrc_list), GFP_KERNEL); | ||
128 | if (!list) | ||
129 | return NULL; | ||
130 | memset (list, 0, sizeof (*list)); | ||
131 | return list; | ||
132 | } | 117 | } |
133 | 118 | ||
134 | static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc (void) | 119 | static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc (void) |
135 | { | 120 | { |
136 | struct ebda_pci_rsrc *resource; | 121 | return kzalloc(sizeof(struct ebda_pci_rsrc), GFP_KERNEL); |
137 | |||
138 | resource = kmalloc (sizeof (struct ebda_pci_rsrc), GFP_KERNEL); | ||
139 | if (!resource) | ||
140 | return NULL; | ||
141 | memset (resource, 0, sizeof (*resource)); | ||
142 | return resource; | ||
143 | } | 122 | } |
144 | 123 | ||
145 | static void __init print_bus_info (void) | 124 | static void __init print_bus_info (void) |
@@ -390,10 +369,9 @@ int __init ibmphp_access_ebda (void) | |||
390 | debug ("now enter io table ---\n"); | 369 | debug ("now enter io table ---\n"); |
391 | debug ("rio blk id: %x\n", blk_id); | 370 | debug ("rio blk id: %x\n", blk_id); |
392 | 371 | ||
393 | rio_table_ptr = kmalloc (sizeof (struct rio_table_hdr), GFP_KERNEL); | 372 | rio_table_ptr = kzalloc(sizeof(struct rio_table_hdr), GFP_KERNEL); |
394 | if (!rio_table_ptr) | 373 | if (!rio_table_ptr) |
395 | return -ENOMEM; | 374 | return -ENOMEM; |
396 | memset (rio_table_ptr, 0, sizeof (struct rio_table_hdr) ); | ||
397 | rio_table_ptr->ver_num = readb (io_mem + offset); | 375 | rio_table_ptr->ver_num = readb (io_mem + offset); |
398 | rio_table_ptr->scal_count = readb (io_mem + offset + 1); | 376 | rio_table_ptr->scal_count = readb (io_mem + offset + 1); |
399 | rio_table_ptr->riodev_count = readb (io_mem + offset + 2); | 377 | rio_table_ptr->riodev_count = readb (io_mem + offset + 2); |
@@ -445,10 +423,9 @@ static int __init ebda_rio_table (void) | |||
445 | 423 | ||
446 | // we do concern about rio details | 424 | // we do concern about rio details |
447 | for (i = 0; i < rio_table_ptr->riodev_count; i++) { | 425 | for (i = 0; i < rio_table_ptr->riodev_count; i++) { |
448 | rio_detail_ptr = kmalloc (sizeof (struct rio_detail), GFP_KERNEL); | 426 | rio_detail_ptr = kzalloc(sizeof(struct rio_detail), GFP_KERNEL); |
449 | if (!rio_detail_ptr) | 427 | if (!rio_detail_ptr) |
450 | return -ENOMEM; | 428 | return -ENOMEM; |
451 | memset (rio_detail_ptr, 0, sizeof (struct rio_detail)); | ||
452 | rio_detail_ptr->rio_node_id = readb (io_mem + offset); | 429 | rio_detail_ptr->rio_node_id = readb (io_mem + offset); |
453 | rio_detail_ptr->bbar = readl (io_mem + offset + 1); | 430 | rio_detail_ptr->bbar = readl (io_mem + offset + 1); |
454 | rio_detail_ptr->rio_type = readb (io_mem + offset + 5); | 431 | rio_detail_ptr->rio_type = readb (io_mem + offset + 5); |
@@ -503,10 +480,9 @@ static int __init combine_wpg_for_chassis (void) | |||
503 | rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list); | 480 | rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list); |
504 | opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num); | 481 | opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num); |
505 | if (!opt_rio_ptr) { | 482 | if (!opt_rio_ptr) { |
506 | opt_rio_ptr = (struct opt_rio *) kmalloc (sizeof (struct opt_rio), GFP_KERNEL); | 483 | opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL); |
507 | if (!opt_rio_ptr) | 484 | if (!opt_rio_ptr) |
508 | return -ENOMEM; | 485 | return -ENOMEM; |
509 | memset (opt_rio_ptr, 0, sizeof (struct opt_rio)); | ||
510 | opt_rio_ptr->rio_type = rio_detail_ptr->rio_type; | 486 | opt_rio_ptr->rio_type = rio_detail_ptr->rio_type; |
511 | opt_rio_ptr->chassis_num = rio_detail_ptr->chassis_num; | 487 | opt_rio_ptr->chassis_num = rio_detail_ptr->chassis_num; |
512 | opt_rio_ptr->first_slot_num = rio_detail_ptr->first_slot_num; | 488 | opt_rio_ptr->first_slot_num = rio_detail_ptr->first_slot_num; |
@@ -546,10 +522,9 @@ static int combine_wpg_for_expansion (void) | |||
546 | rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list); | 522 | rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list); |
547 | opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num); | 523 | opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num); |
548 | if (!opt_rio_lo_ptr) { | 524 | if (!opt_rio_lo_ptr) { |
549 | opt_rio_lo_ptr = (struct opt_rio_lo *) kmalloc (sizeof (struct opt_rio_lo), GFP_KERNEL); | 525 | opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL); |
550 | if (!opt_rio_lo_ptr) | 526 | if (!opt_rio_lo_ptr) |
551 | return -ENOMEM; | 527 | return -ENOMEM; |
552 | memset (opt_rio_lo_ptr, 0, sizeof (struct opt_rio_lo)); | ||
553 | opt_rio_lo_ptr->rio_type = rio_detail_ptr->rio_type; | 528 | opt_rio_lo_ptr->rio_type = rio_detail_ptr->rio_type; |
554 | opt_rio_lo_ptr->chassis_num = rio_detail_ptr->chassis_num; | 529 | opt_rio_lo_ptr->chassis_num = rio_detail_ptr->chassis_num; |
555 | opt_rio_lo_ptr->first_slot_num = rio_detail_ptr->first_slot_num; | 530 | opt_rio_lo_ptr->first_slot_num = rio_detail_ptr->first_slot_num; |
@@ -842,12 +817,11 @@ static int __init ebda_rsrc_controller (void) | |||
842 | 817 | ||
843 | bus_info_ptr2 = ibmphp_find_same_bus_num (slot_ptr->slot_bus_num); | 818 | bus_info_ptr2 = ibmphp_find_same_bus_num (slot_ptr->slot_bus_num); |
844 | if (!bus_info_ptr2) { | 819 | if (!bus_info_ptr2) { |
845 | bus_info_ptr1 = (struct bus_info *) kmalloc (sizeof (struct bus_info), GFP_KERNEL); | 820 | bus_info_ptr1 = kzalloc(sizeof(struct bus_info), GFP_KERNEL); |
846 | if (!bus_info_ptr1) { | 821 | if (!bus_info_ptr1) { |
847 | rc = -ENOMEM; | 822 | rc = -ENOMEM; |
848 | goto error_no_hp_slot; | 823 | goto error_no_hp_slot; |
849 | } | 824 | } |
850 | memset (bus_info_ptr1, 0, sizeof (struct bus_info)); | ||
851 | bus_info_ptr1->slot_min = slot_ptr->slot_num; | 825 | bus_info_ptr1->slot_min = slot_ptr->slot_num; |
852 | bus_info_ptr1->slot_max = slot_ptr->slot_num; | 826 | bus_info_ptr1->slot_max = slot_ptr->slot_num; |
853 | bus_info_ptr1->slot_count += 1; | 827 | bus_info_ptr1->slot_count += 1; |
@@ -946,19 +920,17 @@ static int __init ebda_rsrc_controller (void) | |||
946 | // register slots with hpc core as well as create linked list of ibm slot | 920 | // register slots with hpc core as well as create linked list of ibm slot |
947 | for (index = 0; index < hpc_ptr->slot_count; index++) { | 921 | for (index = 0; index < hpc_ptr->slot_count; index++) { |
948 | 922 | ||
949 | hp_slot_ptr = kmalloc(sizeof(*hp_slot_ptr), GFP_KERNEL); | 923 | hp_slot_ptr = kzalloc(sizeof(*hp_slot_ptr), GFP_KERNEL); |
950 | if (!hp_slot_ptr) { | 924 | if (!hp_slot_ptr) { |
951 | rc = -ENOMEM; | 925 | rc = -ENOMEM; |
952 | goto error_no_hp_slot; | 926 | goto error_no_hp_slot; |
953 | } | 927 | } |
954 | memset(hp_slot_ptr, 0, sizeof(*hp_slot_ptr)); | ||
955 | 928 | ||
956 | hp_slot_ptr->info = kmalloc (sizeof(struct hotplug_slot_info), GFP_KERNEL); | 929 | hp_slot_ptr->info = kzalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); |
957 | if (!hp_slot_ptr->info) { | 930 | if (!hp_slot_ptr->info) { |
958 | rc = -ENOMEM; | 931 | rc = -ENOMEM; |
959 | goto error_no_hp_info; | 932 | goto error_no_hp_info; |
960 | } | 933 | } |
961 | memset(hp_slot_ptr->info, 0, sizeof(struct hotplug_slot_info)); | ||
962 | 934 | ||
963 | hp_slot_ptr->name = kmalloc(30, GFP_KERNEL); | 935 | hp_slot_ptr->name = kmalloc(30, GFP_KERNEL); |
964 | if (!hp_slot_ptr->name) { | 936 | if (!hp_slot_ptr->name) { |
@@ -966,14 +938,13 @@ static int __init ebda_rsrc_controller (void) | |||
966 | goto error_no_hp_name; | 938 | goto error_no_hp_name; |
967 | } | 939 | } |
968 | 940 | ||
969 | tmp_slot = kmalloc(sizeof(*tmp_slot), GFP_KERNEL); | 941 | tmp_slot = kzalloc(sizeof(*tmp_slot), GFP_KERNEL); |
970 | if (!tmp_slot) { | 942 | if (!tmp_slot) { |
971 | rc = -ENOMEM; | 943 | rc = -ENOMEM; |
972 | goto error_no_slot; | 944 | goto error_no_slot; |
973 | } | 945 | } |
974 | memset(tmp_slot, 0, sizeof(*tmp_slot)); | ||
975 | 946 | ||
976 | tmp_slot->flag = TRUE; | 947 | tmp_slot->flag = 1; |
977 | 948 | ||
978 | tmp_slot->capabilities = hpc_ptr->slots[index].slot_cap; | 949 | tmp_slot->capabilities = hpc_ptr->slots[index].slot_cap; |
979 | if ((hpc_ptr->slots[index].slot_cap & EBDA_SLOT_133_MAX) == EBDA_SLOT_133_MAX) | 950 | if ((hpc_ptr->slots[index].slot_cap & EBDA_SLOT_133_MAX) == EBDA_SLOT_133_MAX) |
diff --git a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c index 1a3eb8d3d4cb..c3ac98a0a6a6 100644 --- a/drivers/pci/hotplug/ibmphp_hpc.c +++ b/drivers/pci/hotplug/ibmphp_hpc.c | |||
@@ -34,9 +34,11 @@ | |||
34 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
35 | #include <linux/smp_lock.h> | 35 | #include <linux/smp_lock.h> |
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/mutex.h> | ||
38 | |||
37 | #include "ibmphp.h" | 39 | #include "ibmphp.h" |
38 | 40 | ||
39 | static int to_debug = FALSE; | 41 | static int to_debug = 0; |
40 | #define debug_polling(fmt, arg...) do { if (to_debug) debug (fmt, arg); } while (0) | 42 | #define debug_polling(fmt, arg...) do { if (to_debug) debug (fmt, arg); } while (0) |
41 | 43 | ||
42 | //---------------------------------------------------------------------------- | 44 | //---------------------------------------------------------------------------- |
@@ -93,15 +95,15 @@ static int to_debug = FALSE; | |||
93 | //---------------------------------------------------------------------------- | 95 | //---------------------------------------------------------------------------- |
94 | // macro utilities | 96 | // macro utilities |
95 | //---------------------------------------------------------------------------- | 97 | //---------------------------------------------------------------------------- |
96 | // if bits 20,22,25,26,27,29,30 are OFF return TRUE | 98 | // if bits 20,22,25,26,27,29,30 are OFF return 1 |
97 | #define HPC_I2CSTATUS_CHECK(s) ((u8)((s & 0x00000A76) ? FALSE : TRUE)) | 99 | #define HPC_I2CSTATUS_CHECK(s) ((u8)((s & 0x00000A76) ? 0 : 1)) |
98 | 100 | ||
99 | //---------------------------------------------------------------------------- | 101 | //---------------------------------------------------------------------------- |
100 | // global variables | 102 | // global variables |
101 | //---------------------------------------------------------------------------- | 103 | //---------------------------------------------------------------------------- |
102 | static int ibmphp_shutdown; | 104 | static int ibmphp_shutdown; |
103 | static int tid_poll; | 105 | static int tid_poll; |
104 | static struct semaphore sem_hpcaccess; // lock access to HPC | 106 | static struct mutex sem_hpcaccess; // lock access to HPC |
105 | static struct semaphore semOperations; // lock all operations and | 107 | static struct semaphore semOperations; // lock all operations and |
106 | // access to data structures | 108 | // access to data structures |
107 | static struct semaphore sem_exit; // make sure polling thread goes away | 109 | static struct semaphore sem_exit; // make sure polling thread goes away |
@@ -131,11 +133,11 @@ void __init ibmphp_hpc_initvars (void) | |||
131 | { | 133 | { |
132 | debug ("%s - Entry\n", __FUNCTION__); | 134 | debug ("%s - Entry\n", __FUNCTION__); |
133 | 135 | ||
134 | init_MUTEX (&sem_hpcaccess); | 136 | mutex_init(&sem_hpcaccess); |
135 | init_MUTEX (&semOperations); | 137 | init_MUTEX (&semOperations); |
136 | init_MUTEX_LOCKED (&sem_exit); | 138 | init_MUTEX_LOCKED (&sem_exit); |
137 | to_debug = FALSE; | 139 | to_debug = 0; |
138 | ibmphp_shutdown = FALSE; | 140 | ibmphp_shutdown = 0; |
139 | tid_poll = 0; | 141 | tid_poll = 0; |
140 | 142 | ||
141 | debug ("%s - Exit\n", __FUNCTION__); | 143 | debug ("%s - Exit\n", __FUNCTION__); |
@@ -737,21 +739,21 @@ int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd) | |||
737 | // check controller is still not working on the command | 739 | // check controller is still not working on the command |
738 | //-------------------------------------------------------------------- | 740 | //-------------------------------------------------------------------- |
739 | timeout = CMD_COMPLETE_TOUT_SEC; | 741 | timeout = CMD_COMPLETE_TOUT_SEC; |
740 | done = FALSE; | 742 | done = 0; |
741 | while (!done) { | 743 | while (!done) { |
742 | rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, | 744 | rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, |
743 | &status); | 745 | &status); |
744 | if (!rc) { | 746 | if (!rc) { |
745 | if (NEEDTOCHECK_CMDSTATUS (cmd)) { | 747 | if (NEEDTOCHECK_CMDSTATUS (cmd)) { |
746 | if (CTLR_FINISHED (status) == HPC_CTLR_FINISHED_YES) | 748 | if (CTLR_FINISHED (status) == HPC_CTLR_FINISHED_YES) |
747 | done = TRUE; | 749 | done = 1; |
748 | } else | 750 | } else |
749 | done = TRUE; | 751 | done = 1; |
750 | } | 752 | } |
751 | if (!done) { | 753 | if (!done) { |
752 | msleep(1000); | 754 | msleep(1000); |
753 | if (timeout < 1) { | 755 | if (timeout < 1) { |
754 | done = TRUE; | 756 | done = 1; |
755 | err ("%s - Error command complete timeout\n", __FUNCTION__); | 757 | err ("%s - Error command complete timeout\n", __FUNCTION__); |
756 | rc = -EFAULT; | 758 | rc = -EFAULT; |
757 | } else | 759 | } else |
@@ -778,7 +780,7 @@ int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd) | |||
778 | *---------------------------------------------------------------------*/ | 780 | *---------------------------------------------------------------------*/ |
779 | static void get_hpc_access (void) | 781 | static void get_hpc_access (void) |
780 | { | 782 | { |
781 | down (&sem_hpcaccess); | 783 | mutex_lock(&sem_hpcaccess); |
782 | } | 784 | } |
783 | 785 | ||
784 | /*---------------------------------------------------------------------- | 786 | /*---------------------------------------------------------------------- |
@@ -786,7 +788,7 @@ static void get_hpc_access (void) | |||
786 | *---------------------------------------------------------------------*/ | 788 | *---------------------------------------------------------------------*/ |
787 | void free_hpc_access (void) | 789 | void free_hpc_access (void) |
788 | { | 790 | { |
789 | up (&sem_hpcaccess); | 791 | mutex_unlock(&sem_hpcaccess); |
790 | } | 792 | } |
791 | 793 | ||
792 | /*---------------------------------------------------------------------- | 794 | /*---------------------------------------------------------------------- |
@@ -797,7 +799,7 @@ void free_hpc_access (void) | |||
797 | void ibmphp_lock_operations (void) | 799 | void ibmphp_lock_operations (void) |
798 | { | 800 | { |
799 | down (&semOperations); | 801 | down (&semOperations); |
800 | to_debug = TRUE; | 802 | to_debug = 1; |
801 | } | 803 | } |
802 | 804 | ||
803 | /*---------------------------------------------------------------------- | 805 | /*---------------------------------------------------------------------- |
@@ -807,7 +809,7 @@ void ibmphp_unlock_operations (void) | |||
807 | { | 809 | { |
808 | debug ("%s - Entry\n", __FUNCTION__); | 810 | debug ("%s - Entry\n", __FUNCTION__); |
809 | up (&semOperations); | 811 | up (&semOperations); |
810 | to_debug = FALSE; | 812 | to_debug = 0; |
811 | debug ("%s - Exit\n", __FUNCTION__); | 813 | debug ("%s - Exit\n", __FUNCTION__); |
812 | } | 814 | } |
813 | 815 | ||
@@ -935,40 +937,40 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot) | |||
935 | { | 937 | { |
936 | u8 status; | 938 | u8 status; |
937 | int rc = 0; | 939 | int rc = 0; |
938 | u8 disable = FALSE; | 940 | u8 disable = 0; |
939 | u8 update = FALSE; | 941 | u8 update = 0; |
940 | 942 | ||
941 | debug ("process_changeinstatus - Entry pslot[%p], poldslot[%p]\n", pslot, poldslot); | 943 | debug ("process_changeinstatus - Entry pslot[%p], poldslot[%p]\n", pslot, poldslot); |
942 | 944 | ||
943 | // bit 0 - HPC_SLOT_POWER | 945 | // bit 0 - HPC_SLOT_POWER |
944 | if ((pslot->status & 0x01) != (poldslot->status & 0x01)) | 946 | if ((pslot->status & 0x01) != (poldslot->status & 0x01)) |
945 | update = TRUE; | 947 | update = 1; |
946 | 948 | ||
947 | // bit 1 - HPC_SLOT_CONNECT | 949 | // bit 1 - HPC_SLOT_CONNECT |
948 | // ignore | 950 | // ignore |
949 | 951 | ||
950 | // bit 2 - HPC_SLOT_ATTN | 952 | // bit 2 - HPC_SLOT_ATTN |
951 | if ((pslot->status & 0x04) != (poldslot->status & 0x04)) | 953 | if ((pslot->status & 0x04) != (poldslot->status & 0x04)) |
952 | update = TRUE; | 954 | update = 1; |
953 | 955 | ||
954 | // bit 3 - HPC_SLOT_PRSNT2 | 956 | // bit 3 - HPC_SLOT_PRSNT2 |
955 | // bit 4 - HPC_SLOT_PRSNT1 | 957 | // bit 4 - HPC_SLOT_PRSNT1 |
956 | if (((pslot->status & 0x08) != (poldslot->status & 0x08)) | 958 | if (((pslot->status & 0x08) != (poldslot->status & 0x08)) |
957 | || ((pslot->status & 0x10) != (poldslot->status & 0x10))) | 959 | || ((pslot->status & 0x10) != (poldslot->status & 0x10))) |
958 | update = TRUE; | 960 | update = 1; |
959 | 961 | ||
960 | // bit 5 - HPC_SLOT_PWRGD | 962 | // bit 5 - HPC_SLOT_PWRGD |
961 | if ((pslot->status & 0x20) != (poldslot->status & 0x20)) | 963 | if ((pslot->status & 0x20) != (poldslot->status & 0x20)) |
962 | // OFF -> ON: ignore, ON -> OFF: disable slot | 964 | // OFF -> ON: ignore, ON -> OFF: disable slot |
963 | if ((poldslot->status & 0x20) && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) | 965 | if ((poldslot->status & 0x20) && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) |
964 | disable = TRUE; | 966 | disable = 1; |
965 | 967 | ||
966 | // bit 6 - HPC_SLOT_BUS_SPEED | 968 | // bit 6 - HPC_SLOT_BUS_SPEED |
967 | // ignore | 969 | // ignore |
968 | 970 | ||
969 | // bit 7 - HPC_SLOT_LATCH | 971 | // bit 7 - HPC_SLOT_LATCH |
970 | if ((pslot->status & 0x80) != (poldslot->status & 0x80)) { | 972 | if ((pslot->status & 0x80) != (poldslot->status & 0x80)) { |
971 | update = TRUE; | 973 | update = 1; |
972 | // OPEN -> CLOSE | 974 | // OPEN -> CLOSE |
973 | if (pslot->status & 0x80) { | 975 | if (pslot->status & 0x80) { |
974 | if (SLOT_PWRGD (pslot->status)) { | 976 | if (SLOT_PWRGD (pslot->status)) { |
@@ -977,7 +979,7 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot) | |||
977 | msleep(1000); | 979 | msleep(1000); |
978 | rc = ibmphp_hpc_readslot (pslot, READ_SLOTSTATUS, &status); | 980 | rc = ibmphp_hpc_readslot (pslot, READ_SLOTSTATUS, &status); |
979 | if (SLOT_PWRGD (status)) | 981 | if (SLOT_PWRGD (status)) |
980 | update = TRUE; | 982 | update = 1; |
981 | else // overwrite power in pslot to OFF | 983 | else // overwrite power in pslot to OFF |
982 | pslot->status &= ~HPC_SLOT_POWER; | 984 | pslot->status &= ~HPC_SLOT_POWER; |
983 | } | 985 | } |
@@ -985,17 +987,17 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot) | |||
985 | // CLOSE -> OPEN | 987 | // CLOSE -> OPEN |
986 | else if ((SLOT_PWRGD (poldslot->status) == HPC_SLOT_PWRGD_GOOD) | 988 | else if ((SLOT_PWRGD (poldslot->status) == HPC_SLOT_PWRGD_GOOD) |
987 | && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) { | 989 | && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) { |
988 | disable = TRUE; | 990 | disable = 1; |
989 | } | 991 | } |
990 | // else - ignore | 992 | // else - ignore |
991 | } | 993 | } |
992 | // bit 4 - HPC_SLOT_BLINK_ATTN | 994 | // bit 4 - HPC_SLOT_BLINK_ATTN |
993 | if ((pslot->ext_status & 0x08) != (poldslot->ext_status & 0x08)) | 995 | if ((pslot->ext_status & 0x08) != (poldslot->ext_status & 0x08)) |
994 | update = TRUE; | 996 | update = 1; |
995 | 997 | ||
996 | if (disable) { | 998 | if (disable) { |
997 | debug ("process_changeinstatus - disable slot\n"); | 999 | debug ("process_changeinstatus - disable slot\n"); |
998 | pslot->flag = FALSE; | 1000 | pslot->flag = 0; |
999 | rc = ibmphp_do_disable_slot (pslot); | 1001 | rc = ibmphp_do_disable_slot (pslot); |
1000 | } | 1002 | } |
1001 | 1003 | ||
@@ -1100,7 +1102,7 @@ void __exit ibmphp_hpc_stop_poll_thread (void) | |||
1100 | { | 1102 | { |
1101 | debug ("%s - Entry\n", __FUNCTION__); | 1103 | debug ("%s - Entry\n", __FUNCTION__); |
1102 | 1104 | ||
1103 | ibmphp_shutdown = TRUE; | 1105 | ibmphp_shutdown = 1; |
1104 | debug ("before locking operations \n"); | 1106 | debug ("before locking operations \n"); |
1105 | ibmphp_lock_operations (); | 1107 | ibmphp_lock_operations (); |
1106 | debug ("after locking operations \n"); | 1108 | debug ("after locking operations \n"); |
@@ -1134,7 +1136,7 @@ static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, v | |||
1134 | u8 * pstatus) | 1136 | u8 * pstatus) |
1135 | { | 1137 | { |
1136 | int rc = 0; | 1138 | int rc = 0; |
1137 | u8 done = FALSE; | 1139 | u8 done = 0; |
1138 | 1140 | ||
1139 | debug_polling ("hpc_wait_ctlr_notworking - Entry timeout[%d]\n", timeout); | 1141 | debug_polling ("hpc_wait_ctlr_notworking - Entry timeout[%d]\n", timeout); |
1140 | 1142 | ||
@@ -1142,14 +1144,14 @@ static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, v | |||
1142 | *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, WPG_CTLR_INDEX); | 1144 | *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, WPG_CTLR_INDEX); |
1143 | if (*pstatus == HPC_ERROR) { | 1145 | if (*pstatus == HPC_ERROR) { |
1144 | rc = HPC_ERROR; | 1146 | rc = HPC_ERROR; |
1145 | done = TRUE; | 1147 | done = 1; |
1146 | } | 1148 | } |
1147 | if (CTLR_WORKING (*pstatus) == HPC_CTLR_WORKING_NO) | 1149 | if (CTLR_WORKING (*pstatus) == HPC_CTLR_WORKING_NO) |
1148 | done = TRUE; | 1150 | done = 1; |
1149 | if (!done) { | 1151 | if (!done) { |
1150 | msleep(1000); | 1152 | msleep(1000); |
1151 | if (timeout < 1) { | 1153 | if (timeout < 1) { |
1152 | done = TRUE; | 1154 | done = 1; |
1153 | err ("HPCreadslot - Error ctlr timeout\n"); | 1155 | err ("HPCreadslot - Error ctlr timeout\n"); |
1154 | rc = HPC_ERROR; | 1156 | rc = HPC_ERROR; |
1155 | } else | 1157 | } else |
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c index 155133fe5c12..d87a9e3eaeeb 100644 --- a/drivers/pci/hotplug/ibmphp_pci.c +++ b/drivers/pci/hotplug/ibmphp_pci.c | |||
@@ -164,12 +164,11 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
164 | cleanup_count = 6; | 164 | cleanup_count = 6; |
165 | goto error; | 165 | goto error; |
166 | } | 166 | } |
167 | newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL); | 167 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
168 | if (!newfunc) { | 168 | if (!newfunc) { |
169 | err ("out of system memory\n"); | 169 | err ("out of system memory\n"); |
170 | return -ENOMEM; | 170 | return -ENOMEM; |
171 | } | 171 | } |
172 | memset (newfunc, 0, sizeof (struct pci_func)); | ||
173 | newfunc->busno = cur_func->busno; | 172 | newfunc->busno = cur_func->busno; |
174 | newfunc->device = device; | 173 | newfunc->device = device; |
175 | cur_func->next = newfunc; | 174 | cur_func->next = newfunc; |
@@ -200,15 +199,14 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
200 | } | 199 | } |
201 | 200 | ||
202 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); | 201 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); |
203 | flag = FALSE; | 202 | flag = 0; |
204 | for (i = 0; i < 32; i++) { | 203 | for (i = 0; i < 32; i++) { |
205 | if (func->devices[i]) { | 204 | if (func->devices[i]) { |
206 | newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL); | 205 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
207 | if (!newfunc) { | 206 | if (!newfunc) { |
208 | err ("out of system memory\n"); | 207 | err ("out of system memory\n"); |
209 | return -ENOMEM; | 208 | return -ENOMEM; |
210 | } | 209 | } |
211 | memset (newfunc, 0, sizeof (struct pci_func)); | ||
212 | newfunc->busno = sec_number; | 210 | newfunc->busno = sec_number; |
213 | newfunc->device = (u8) i; | 211 | newfunc->device = (u8) i; |
214 | for (j = 0; j < 4; j++) | 212 | for (j = 0; j < 4; j++) |
@@ -228,16 +226,15 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
228 | cleanup_count = 2; | 226 | cleanup_count = 2; |
229 | goto error; | 227 | goto error; |
230 | } | 228 | } |
231 | flag = TRUE; | 229 | flag = 1; |
232 | } | 230 | } |
233 | } | 231 | } |
234 | 232 | ||
235 | newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL); | 233 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
236 | if (!newfunc) { | 234 | if (!newfunc) { |
237 | err ("out of system memory\n"); | 235 | err ("out of system memory\n"); |
238 | return -ENOMEM; | 236 | return -ENOMEM; |
239 | } | 237 | } |
240 | memset (newfunc, 0, sizeof (struct pci_func)); | ||
241 | newfunc->busno = cur_func->busno; | 238 | newfunc->busno = cur_func->busno; |
242 | newfunc->device = device; | 239 | newfunc->device = device; |
243 | for (j = 0; j < 4; j++) | 240 | for (j = 0; j < 4; j++) |
@@ -275,16 +272,15 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
275 | cur_func->busno, device, function); | 272 | cur_func->busno, device, function); |
276 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); | 273 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); |
277 | debug ("after configuring bridge..., sec_number = %x\n", sec_number); | 274 | debug ("after configuring bridge..., sec_number = %x\n", sec_number); |
278 | flag = FALSE; | 275 | flag = 0; |
279 | for (i = 0; i < 32; i++) { | 276 | for (i = 0; i < 32; i++) { |
280 | if (func->devices[i]) { | 277 | if (func->devices[i]) { |
281 | debug ("inside for loop, device is %x\n", i); | 278 | debug ("inside for loop, device is %x\n", i); |
282 | newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL); | 279 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
283 | if (!newfunc) { | 280 | if (!newfunc) { |
284 | err (" out of system memory\n"); | 281 | err (" out of system memory\n"); |
285 | return -ENOMEM; | 282 | return -ENOMEM; |
286 | } | 283 | } |
287 | memset (newfunc, 0, sizeof (struct pci_func)); | ||
288 | newfunc->busno = sec_number; | 284 | newfunc->busno = sec_number; |
289 | newfunc->device = (u8) i; | 285 | newfunc->device = (u8) i; |
290 | for (j = 0; j < 4; j++) | 286 | for (j = 0; j < 4; j++) |
@@ -305,7 +301,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
305 | cleanup_count = 2; | 301 | cleanup_count = 2; |
306 | goto error; | 302 | goto error; |
307 | } | 303 | } |
308 | flag = TRUE; | 304 | flag = 1; |
309 | } | 305 | } |
310 | } | 306 | } |
311 | 307 | ||
@@ -405,13 +401,12 @@ static int configure_device (struct pci_func *func) | |||
405 | 401 | ||
406 | debug ("len[count] in IO %x, count %d\n", len[count], count); | 402 | debug ("len[count] in IO %x, count %d\n", len[count], count); |
407 | 403 | ||
408 | io[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 404 | io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
409 | 405 | ||
410 | if (!io[count]) { | 406 | if (!io[count]) { |
411 | err ("out of system memory\n"); | 407 | err ("out of system memory\n"); |
412 | return -ENOMEM; | 408 | return -ENOMEM; |
413 | } | 409 | } |
414 | memset (io[count], 0, sizeof (struct resource_node)); | ||
415 | io[count]->type = IO; | 410 | io[count]->type = IO; |
416 | io[count]->busno = func->busno; | 411 | io[count]->busno = func->busno; |
417 | io[count]->devfunc = PCI_DEVFN(func->device, func->function); | 412 | io[count]->devfunc = PCI_DEVFN(func->device, func->function); |
@@ -444,29 +439,27 @@ static int configure_device (struct pci_func *func) | |||
444 | 439 | ||
445 | debug ("len[count] in PFMEM %x, count %d\n", len[count], count); | 440 | debug ("len[count] in PFMEM %x, count %d\n", len[count], count); |
446 | 441 | ||
447 | pfmem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 442 | pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
448 | if (!pfmem[count]) { | 443 | if (!pfmem[count]) { |
449 | err ("out of system memory\n"); | 444 | err ("out of system memory\n"); |
450 | return -ENOMEM; | 445 | return -ENOMEM; |
451 | } | 446 | } |
452 | memset (pfmem[count], 0, sizeof (struct resource_node)); | ||
453 | pfmem[count]->type = PFMEM; | 447 | pfmem[count]->type = PFMEM; |
454 | pfmem[count]->busno = func->busno; | 448 | pfmem[count]->busno = func->busno; |
455 | pfmem[count]->devfunc = PCI_DEVFN(func->device, | 449 | pfmem[count]->devfunc = PCI_DEVFN(func->device, |
456 | func->function); | 450 | func->function); |
457 | pfmem[count]->len = len[count]; | 451 | pfmem[count]->len = len[count]; |
458 | pfmem[count]->fromMem = FALSE; | 452 | pfmem[count]->fromMem = 0; |
459 | if (ibmphp_check_resource (pfmem[count], 0) == 0) { | 453 | if (ibmphp_check_resource (pfmem[count], 0) == 0) { |
460 | ibmphp_add_resource (pfmem[count]); | 454 | ibmphp_add_resource (pfmem[count]); |
461 | func->pfmem[count] = pfmem[count]; | 455 | func->pfmem[count] = pfmem[count]; |
462 | } else { | 456 | } else { |
463 | mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL); | 457 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); |
464 | if (!mem_tmp) { | 458 | if (!mem_tmp) { |
465 | err ("out of system memory\n"); | 459 | err ("out of system memory\n"); |
466 | kfree (pfmem[count]); | 460 | kfree (pfmem[count]); |
467 | return -ENOMEM; | 461 | return -ENOMEM; |
468 | } | 462 | } |
469 | memset (mem_tmp, 0, sizeof (struct resource_node)); | ||
470 | mem_tmp->type = MEM; | 463 | mem_tmp->type = MEM; |
471 | mem_tmp->busno = pfmem[count]->busno; | 464 | mem_tmp->busno = pfmem[count]->busno; |
472 | mem_tmp->devfunc = pfmem[count]->devfunc; | 465 | mem_tmp->devfunc = pfmem[count]->devfunc; |
@@ -474,7 +467,7 @@ static int configure_device (struct pci_func *func) | |||
474 | debug ("there's no pfmem... going into mem.\n"); | 467 | debug ("there's no pfmem... going into mem.\n"); |
475 | if (ibmphp_check_resource (mem_tmp, 0) == 0) { | 468 | if (ibmphp_check_resource (mem_tmp, 0) == 0) { |
476 | ibmphp_add_resource (mem_tmp); | 469 | ibmphp_add_resource (mem_tmp); |
477 | pfmem[count]->fromMem = TRUE; | 470 | pfmem[count]->fromMem = 1; |
478 | pfmem[count]->rangeno = mem_tmp->rangeno; | 471 | pfmem[count]->rangeno = mem_tmp->rangeno; |
479 | pfmem[count]->start = mem_tmp->start; | 472 | pfmem[count]->start = mem_tmp->start; |
480 | pfmem[count]->end = mem_tmp->end; | 473 | pfmem[count]->end = mem_tmp->end; |
@@ -512,12 +505,11 @@ static int configure_device (struct pci_func *func) | |||
512 | 505 | ||
513 | debug ("len[count] in Mem %x, count %d\n", len[count], count); | 506 | debug ("len[count] in Mem %x, count %d\n", len[count], count); |
514 | 507 | ||
515 | mem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 508 | mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
516 | if (!mem[count]) { | 509 | if (!mem[count]) { |
517 | err ("out of system memory\n"); | 510 | err ("out of system memory\n"); |
518 | return -ENOMEM; | 511 | return -ENOMEM; |
519 | } | 512 | } |
520 | memset (mem[count], 0, sizeof (struct resource_node)); | ||
521 | mem[count]->type = MEM; | 513 | mem[count]->type = MEM; |
522 | mem[count]->busno = func->busno; | 514 | mem[count]->busno = func->busno; |
523 | mem[count]->devfunc = PCI_DEVFN(func->device, | 515 | mem[count]->devfunc = PCI_DEVFN(func->device, |
@@ -579,11 +571,11 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
579 | u16 pfmem_base; | 571 | u16 pfmem_base; |
580 | u32 bar[2]; | 572 | u32 bar[2]; |
581 | u32 len[2]; | 573 | u32 len[2]; |
582 | u8 flag_io = FALSE; | 574 | u8 flag_io = 0; |
583 | u8 flag_mem = FALSE; | 575 | u8 flag_mem = 0; |
584 | u8 flag_pfmem = FALSE; | 576 | u8 flag_pfmem = 0; |
585 | u8 need_io_upper = FALSE; | 577 | u8 need_io_upper = 0; |
586 | u8 need_pfmem_upper = FALSE; | 578 | u8 need_pfmem_upper = 0; |
587 | struct res_needed *amount_needed = NULL; | 579 | struct res_needed *amount_needed = NULL; |
588 | struct resource_node *io = NULL; | 580 | struct resource_node *io = NULL; |
589 | struct resource_node *bus_io[2] = {NULL, NULL}; | 581 | struct resource_node *bus_io[2] = {NULL, NULL}; |
@@ -677,14 +669,13 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
677 | 669 | ||
678 | debug ("len[count] in IO = %x\n", len[count]); | 670 | debug ("len[count] in IO = %x\n", len[count]); |
679 | 671 | ||
680 | bus_io[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 672 | bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
681 | 673 | ||
682 | if (!bus_io[count]) { | 674 | if (!bus_io[count]) { |
683 | err ("out of system memory\n"); | 675 | err ("out of system memory\n"); |
684 | retval = -ENOMEM; | 676 | retval = -ENOMEM; |
685 | goto error; | 677 | goto error; |
686 | } | 678 | } |
687 | memset (bus_io[count], 0, sizeof (struct resource_node)); | ||
688 | bus_io[count]->type = IO; | 679 | bus_io[count]->type = IO; |
689 | bus_io[count]->busno = func->busno; | 680 | bus_io[count]->busno = func->busno; |
690 | bus_io[count]->devfunc = PCI_DEVFN(func->device, | 681 | bus_io[count]->devfunc = PCI_DEVFN(func->device, |
@@ -711,37 +702,35 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
711 | 702 | ||
712 | debug ("len[count] in PFMEM = %x\n", len[count]); | 703 | debug ("len[count] in PFMEM = %x\n", len[count]); |
713 | 704 | ||
714 | bus_pfmem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 705 | bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
715 | if (!bus_pfmem[count]) { | 706 | if (!bus_pfmem[count]) { |
716 | err ("out of system memory\n"); | 707 | err ("out of system memory\n"); |
717 | retval = -ENOMEM; | 708 | retval = -ENOMEM; |
718 | goto error; | 709 | goto error; |
719 | } | 710 | } |
720 | memset (bus_pfmem[count], 0, sizeof (struct resource_node)); | ||
721 | bus_pfmem[count]->type = PFMEM; | 711 | bus_pfmem[count]->type = PFMEM; |
722 | bus_pfmem[count]->busno = func->busno; | 712 | bus_pfmem[count]->busno = func->busno; |
723 | bus_pfmem[count]->devfunc = PCI_DEVFN(func->device, | 713 | bus_pfmem[count]->devfunc = PCI_DEVFN(func->device, |
724 | func->function); | 714 | func->function); |
725 | bus_pfmem[count]->len = len[count]; | 715 | bus_pfmem[count]->len = len[count]; |
726 | bus_pfmem[count]->fromMem = FALSE; | 716 | bus_pfmem[count]->fromMem = 0; |
727 | if (ibmphp_check_resource (bus_pfmem[count], 0) == 0) { | 717 | if (ibmphp_check_resource (bus_pfmem[count], 0) == 0) { |
728 | ibmphp_add_resource (bus_pfmem[count]); | 718 | ibmphp_add_resource (bus_pfmem[count]); |
729 | func->pfmem[count] = bus_pfmem[count]; | 719 | func->pfmem[count] = bus_pfmem[count]; |
730 | } else { | 720 | } else { |
731 | mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL); | 721 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); |
732 | if (!mem_tmp) { | 722 | if (!mem_tmp) { |
733 | err ("out of system memory\n"); | 723 | err ("out of system memory\n"); |
734 | retval = -ENOMEM; | 724 | retval = -ENOMEM; |
735 | goto error; | 725 | goto error; |
736 | } | 726 | } |
737 | memset (mem_tmp, 0, sizeof (struct resource_node)); | ||
738 | mem_tmp->type = MEM; | 727 | mem_tmp->type = MEM; |
739 | mem_tmp->busno = bus_pfmem[count]->busno; | 728 | mem_tmp->busno = bus_pfmem[count]->busno; |
740 | mem_tmp->devfunc = bus_pfmem[count]->devfunc; | 729 | mem_tmp->devfunc = bus_pfmem[count]->devfunc; |
741 | mem_tmp->len = bus_pfmem[count]->len; | 730 | mem_tmp->len = bus_pfmem[count]->len; |
742 | if (ibmphp_check_resource (mem_tmp, 0) == 0) { | 731 | if (ibmphp_check_resource (mem_tmp, 0) == 0) { |
743 | ibmphp_add_resource (mem_tmp); | 732 | ibmphp_add_resource (mem_tmp); |
744 | bus_pfmem[count]->fromMem = TRUE; | 733 | bus_pfmem[count]->fromMem = 1; |
745 | bus_pfmem[count]->rangeno = mem_tmp->rangeno; | 734 | bus_pfmem[count]->rangeno = mem_tmp->rangeno; |
746 | ibmphp_add_pfmem_from_mem (bus_pfmem[count]); | 735 | ibmphp_add_pfmem_from_mem (bus_pfmem[count]); |
747 | func->pfmem[count] = bus_pfmem[count]; | 736 | func->pfmem[count] = bus_pfmem[count]; |
@@ -770,13 +759,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
770 | 759 | ||
771 | debug ("len[count] in Memory is %x\n", len[count]); | 760 | debug ("len[count] in Memory is %x\n", len[count]); |
772 | 761 | ||
773 | bus_mem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 762 | bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
774 | if (!bus_mem[count]) { | 763 | if (!bus_mem[count]) { |
775 | err ("out of system memory\n"); | 764 | err ("out of system memory\n"); |
776 | retval = -ENOMEM; | 765 | retval = -ENOMEM; |
777 | goto error; | 766 | goto error; |
778 | } | 767 | } |
779 | memset (bus_mem[count], 0, sizeof (struct resource_node)); | ||
780 | bus_mem[count]->type = MEM; | 768 | bus_mem[count]->type = MEM; |
781 | bus_mem[count]->busno = func->busno; | 769 | bus_mem[count]->busno = func->busno; |
782 | bus_mem[count]->devfunc = PCI_DEVFN(func->device, | 770 | bus_mem[count]->devfunc = PCI_DEVFN(func->device, |
@@ -838,17 +826,16 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
838 | 826 | ||
839 | if (!amount_needed->io) { | 827 | if (!amount_needed->io) { |
840 | debug ("it doesn't want IO?\n"); | 828 | debug ("it doesn't want IO?\n"); |
841 | flag_io = TRUE; | 829 | flag_io = 1; |
842 | } else { | 830 | } else { |
843 | debug ("it wants %x IO behind the bridge\n", amount_needed->io); | 831 | debug ("it wants %x IO behind the bridge\n", amount_needed->io); |
844 | io = kmalloc(sizeof(*io), GFP_KERNEL); | 832 | io = kzalloc(sizeof(*io), GFP_KERNEL); |
845 | 833 | ||
846 | if (!io) { | 834 | if (!io) { |
847 | err ("out of system memory\n"); | 835 | err ("out of system memory\n"); |
848 | retval = -ENOMEM; | 836 | retval = -ENOMEM; |
849 | goto error; | 837 | goto error; |
850 | } | 838 | } |
851 | memset (io, 0, sizeof (struct resource_node)); | ||
852 | io->type = IO; | 839 | io->type = IO; |
853 | io->busno = func->busno; | 840 | io->busno = func->busno; |
854 | io->devfunc = PCI_DEVFN(func->device, func->function); | 841 | io->devfunc = PCI_DEVFN(func->device, func->function); |
@@ -856,71 +843,68 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
856 | if (ibmphp_check_resource (io, 1) == 0) { | 843 | if (ibmphp_check_resource (io, 1) == 0) { |
857 | debug ("were we able to add io\n"); | 844 | debug ("were we able to add io\n"); |
858 | ibmphp_add_resource (io); | 845 | ibmphp_add_resource (io); |
859 | flag_io = TRUE; | 846 | flag_io = 1; |
860 | } | 847 | } |
861 | } | 848 | } |
862 | 849 | ||
863 | if (!amount_needed->mem) { | 850 | if (!amount_needed->mem) { |
864 | debug ("it doesn't want n.e.memory?\n"); | 851 | debug ("it doesn't want n.e.memory?\n"); |
865 | flag_mem = TRUE; | 852 | flag_mem = 1; |
866 | } else { | 853 | } else { |
867 | debug ("it wants %x memory behind the bridge\n", amount_needed->mem); | 854 | debug ("it wants %x memory behind the bridge\n", amount_needed->mem); |
868 | mem = kmalloc(sizeof(*mem), GFP_KERNEL); | 855 | mem = kzalloc(sizeof(*mem), GFP_KERNEL); |
869 | if (!mem) { | 856 | if (!mem) { |
870 | err ("out of system memory\n"); | 857 | err ("out of system memory\n"); |
871 | retval = -ENOMEM; | 858 | retval = -ENOMEM; |
872 | goto error; | 859 | goto error; |
873 | } | 860 | } |
874 | memset (mem, 0, sizeof (struct resource_node)); | ||
875 | mem->type = MEM; | 861 | mem->type = MEM; |
876 | mem->busno = func->busno; | 862 | mem->busno = func->busno; |
877 | mem->devfunc = PCI_DEVFN(func->device, func->function); | 863 | mem->devfunc = PCI_DEVFN(func->device, func->function); |
878 | mem->len = amount_needed->mem; | 864 | mem->len = amount_needed->mem; |
879 | if (ibmphp_check_resource (mem, 1) == 0) { | 865 | if (ibmphp_check_resource (mem, 1) == 0) { |
880 | ibmphp_add_resource (mem); | 866 | ibmphp_add_resource (mem); |
881 | flag_mem = TRUE; | 867 | flag_mem = 1; |
882 | debug ("were we able to add mem\n"); | 868 | debug ("were we able to add mem\n"); |
883 | } | 869 | } |
884 | } | 870 | } |
885 | 871 | ||
886 | if (!amount_needed->pfmem) { | 872 | if (!amount_needed->pfmem) { |
887 | debug ("it doesn't want n.e.pfmem mem?\n"); | 873 | debug ("it doesn't want n.e.pfmem mem?\n"); |
888 | flag_pfmem = TRUE; | 874 | flag_pfmem = 1; |
889 | } else { | 875 | } else { |
890 | debug ("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem); | 876 | debug ("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem); |
891 | pfmem = kmalloc(sizeof(*pfmem), GFP_KERNEL); | 877 | pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL); |
892 | if (!pfmem) { | 878 | if (!pfmem) { |
893 | err ("out of system memory\n"); | 879 | err ("out of system memory\n"); |
894 | retval = -ENOMEM; | 880 | retval = -ENOMEM; |
895 | goto error; | 881 | goto error; |
896 | } | 882 | } |
897 | memset (pfmem, 0, sizeof (struct resource_node)); | ||
898 | pfmem->type = PFMEM; | 883 | pfmem->type = PFMEM; |
899 | pfmem->busno = func->busno; | 884 | pfmem->busno = func->busno; |
900 | pfmem->devfunc = PCI_DEVFN(func->device, func->function); | 885 | pfmem->devfunc = PCI_DEVFN(func->device, func->function); |
901 | pfmem->len = amount_needed->pfmem; | 886 | pfmem->len = amount_needed->pfmem; |
902 | pfmem->fromMem = FALSE; | 887 | pfmem->fromMem = 0; |
903 | if (ibmphp_check_resource (pfmem, 1) == 0) { | 888 | if (ibmphp_check_resource (pfmem, 1) == 0) { |
904 | ibmphp_add_resource (pfmem); | 889 | ibmphp_add_resource (pfmem); |
905 | flag_pfmem = TRUE; | 890 | flag_pfmem = 1; |
906 | } else { | 891 | } else { |
907 | mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL); | 892 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); |
908 | if (!mem_tmp) { | 893 | if (!mem_tmp) { |
909 | err ("out of system memory\n"); | 894 | err ("out of system memory\n"); |
910 | retval = -ENOMEM; | 895 | retval = -ENOMEM; |
911 | goto error; | 896 | goto error; |
912 | } | 897 | } |
913 | memset (mem_tmp, 0, sizeof (struct resource_node)); | ||
914 | mem_tmp->type = MEM; | 898 | mem_tmp->type = MEM; |
915 | mem_tmp->busno = pfmem->busno; | 899 | mem_tmp->busno = pfmem->busno; |
916 | mem_tmp->devfunc = pfmem->devfunc; | 900 | mem_tmp->devfunc = pfmem->devfunc; |
917 | mem_tmp->len = pfmem->len; | 901 | mem_tmp->len = pfmem->len; |
918 | if (ibmphp_check_resource (mem_tmp, 1) == 0) { | 902 | if (ibmphp_check_resource (mem_tmp, 1) == 0) { |
919 | ibmphp_add_resource (mem_tmp); | 903 | ibmphp_add_resource (mem_tmp); |
920 | pfmem->fromMem = TRUE; | 904 | pfmem->fromMem = 1; |
921 | pfmem->rangeno = mem_tmp->rangeno; | 905 | pfmem->rangeno = mem_tmp->rangeno; |
922 | ibmphp_add_pfmem_from_mem (pfmem); | 906 | ibmphp_add_pfmem_from_mem (pfmem); |
923 | flag_pfmem = TRUE; | 907 | flag_pfmem = 1; |
924 | } | 908 | } |
925 | } | 909 | } |
926 | } | 910 | } |
@@ -936,13 +920,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
936 | */ | 920 | */ |
937 | bus = ibmphp_find_res_bus (sec_number); | 921 | bus = ibmphp_find_res_bus (sec_number); |
938 | if (!bus) { | 922 | if (!bus) { |
939 | bus = kmalloc(sizeof(*bus), GFP_KERNEL); | 923 | bus = kzalloc(sizeof(*bus), GFP_KERNEL); |
940 | if (!bus) { | 924 | if (!bus) { |
941 | err ("out of system memory\n"); | 925 | err ("out of system memory\n"); |
942 | retval = -ENOMEM; | 926 | retval = -ENOMEM; |
943 | goto error; | 927 | goto error; |
944 | } | 928 | } |
945 | memset (bus, 0, sizeof (struct bus_node)); | ||
946 | bus->busno = sec_number; | 929 | bus->busno = sec_number; |
947 | debug ("b4 adding new bus\n"); | 930 | debug ("b4 adding new bus\n"); |
948 | rc = add_new_bus (bus, io, mem, pfmem, func->busno); | 931 | rc = add_new_bus (bus, io, mem, pfmem, func->busno); |
@@ -967,11 +950,11 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
967 | 950 | ||
968 | if ((io_base & PCI_IO_RANGE_TYPE_MASK) == PCI_IO_RANGE_TYPE_32) { | 951 | if ((io_base & PCI_IO_RANGE_TYPE_MASK) == PCI_IO_RANGE_TYPE_32) { |
969 | debug ("io 32\n"); | 952 | debug ("io 32\n"); |
970 | need_io_upper = TRUE; | 953 | need_io_upper = 1; |
971 | } | 954 | } |
972 | if ((pfmem_base & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) { | 955 | if ((pfmem_base & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) { |
973 | debug ("pfmem 64\n"); | 956 | debug ("pfmem 64\n"); |
974 | need_pfmem_upper = TRUE; | 957 | need_pfmem_upper = 1; |
975 | } | 958 | } |
976 | 959 | ||
977 | if (bus->noIORanges) { | 960 | if (bus->noIORanges) { |
@@ -1111,10 +1094,9 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno) | |||
1111 | }; | 1094 | }; |
1112 | struct res_needed *amount; | 1095 | struct res_needed *amount; |
1113 | 1096 | ||
1114 | amount = kmalloc(sizeof(*amount), GFP_KERNEL); | 1097 | amount = kzalloc(sizeof(*amount), GFP_KERNEL); |
1115 | if (amount == NULL) | 1098 | if (amount == NULL) |
1116 | return NULL; | 1099 | return NULL; |
1117 | memset (amount, 0, sizeof (struct res_needed)); | ||
1118 | 1100 | ||
1119 | ibmphp_pci_bus->number = busno; | 1101 | ibmphp_pci_bus->number = busno; |
1120 | 1102 | ||
@@ -1137,7 +1119,7 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno) | |||
1137 | debug ("hdr_type behind the bridge is %x\n", hdr_type); | 1119 | debug ("hdr_type behind the bridge is %x\n", hdr_type); |
1138 | if (hdr_type & PCI_HEADER_TYPE_BRIDGE) { | 1120 | if (hdr_type & PCI_HEADER_TYPE_BRIDGE) { |
1139 | err ("embedded bridges not supported for hot-plugging.\n"); | 1121 | err ("embedded bridges not supported for hot-plugging.\n"); |
1140 | amount->not_correct = TRUE; | 1122 | amount->not_correct = 1; |
1141 | return amount; | 1123 | return amount; |
1142 | } | 1124 | } |
1143 | 1125 | ||
@@ -1145,12 +1127,12 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno) | |||
1145 | if (class == PCI_CLASS_NOT_DEFINED_VGA) { | 1127 | if (class == PCI_CLASS_NOT_DEFINED_VGA) { |
1146 | err ("The device %x is VGA compatible and as is not supported for hot plugging. " | 1128 | err ("The device %x is VGA compatible and as is not supported for hot plugging. " |
1147 | "Please choose another device.\n", device); | 1129 | "Please choose another device.\n", device); |
1148 | amount->not_correct = TRUE; | 1130 | amount->not_correct = 1; |
1149 | return amount; | 1131 | return amount; |
1150 | } else if (class == PCI_CLASS_DISPLAY_VGA) { | 1132 | } else if (class == PCI_CLASS_DISPLAY_VGA) { |
1151 | err ("The device %x is not supported for hot plugging. " | 1133 | err ("The device %x is not supported for hot plugging. " |
1152 | "Please choose another device.\n", device); | 1134 | "Please choose another device.\n", device); |
1153 | amount->not_correct = TRUE; | 1135 | amount->not_correct = 1; |
1154 | return amount; | 1136 | return amount; |
1155 | } | 1137 | } |
1156 | 1138 | ||
@@ -1210,9 +1192,9 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno) | |||
1210 | } /* end for */ | 1192 | } /* end for */ |
1211 | 1193 | ||
1212 | if (!howmany) | 1194 | if (!howmany) |
1213 | amount->not_correct = TRUE; | 1195 | amount->not_correct = 1; |
1214 | else | 1196 | else |
1215 | amount->not_correct = FALSE; | 1197 | amount->not_correct = 0; |
1216 | if ((amount->io) && (amount->io < IOBRIDGE)) | 1198 | if ((amount->io) && (amount->io < IOBRIDGE)) |
1217 | amount->io = IOBRIDGE; | 1199 | amount->io = IOBRIDGE; |
1218 | if ((amount->mem) && (amount->mem < MEMBRIDGE)) | 1200 | if ((amount->mem) && (amount->mem < MEMBRIDGE)) |
@@ -1672,12 +1654,11 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r | |||
1672 | list_add (&bus->bus_list, &cur_bus->bus_list); | 1654 | list_add (&bus->bus_list, &cur_bus->bus_list); |
1673 | } | 1655 | } |
1674 | if (io) { | 1656 | if (io) { |
1675 | io_range = kmalloc(sizeof(*io_range), GFP_KERNEL); | 1657 | io_range = kzalloc(sizeof(*io_range), GFP_KERNEL); |
1676 | if (!io_range) { | 1658 | if (!io_range) { |
1677 | err ("out of system memory\n"); | 1659 | err ("out of system memory\n"); |
1678 | return -ENOMEM; | 1660 | return -ENOMEM; |
1679 | } | 1661 | } |
1680 | memset (io_range, 0, sizeof (struct range_node)); | ||
1681 | io_range->start = io->start; | 1662 | io_range->start = io->start; |
1682 | io_range->end = io->end; | 1663 | io_range->end = io->end; |
1683 | io_range->rangeno = 1; | 1664 | io_range->rangeno = 1; |
@@ -1685,12 +1666,11 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r | |||
1685 | bus->rangeIO = io_range; | 1666 | bus->rangeIO = io_range; |
1686 | } | 1667 | } |
1687 | if (mem) { | 1668 | if (mem) { |
1688 | mem_range = kmalloc(sizeof(*mem_range), GFP_KERNEL); | 1669 | mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL); |
1689 | if (!mem_range) { | 1670 | if (!mem_range) { |
1690 | err ("out of system memory\n"); | 1671 | err ("out of system memory\n"); |
1691 | return -ENOMEM; | 1672 | return -ENOMEM; |
1692 | } | 1673 | } |
1693 | memset (mem_range, 0, sizeof (struct range_node)); | ||
1694 | mem_range->start = mem->start; | 1674 | mem_range->start = mem->start; |
1695 | mem_range->end = mem->end; | 1675 | mem_range->end = mem->end; |
1696 | mem_range->rangeno = 1; | 1676 | mem_range->rangeno = 1; |
@@ -1698,12 +1678,11 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r | |||
1698 | bus->rangeMem = mem_range; | 1678 | bus->rangeMem = mem_range; |
1699 | } | 1679 | } |
1700 | if (pfmem) { | 1680 | if (pfmem) { |
1701 | pfmem_range = kmalloc(sizeof(*pfmem_range), GFP_KERNEL); | 1681 | pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL); |
1702 | if (!pfmem_range) { | 1682 | if (!pfmem_range) { |
1703 | err ("out of system memory\n"); | 1683 | err ("out of system memory\n"); |
1704 | return -ENOMEM; | 1684 | return -ENOMEM; |
1705 | } | 1685 | } |
1706 | memset (pfmem_range, 0, sizeof (struct range_node)); | ||
1707 | pfmem_range->start = pfmem->start; | 1686 | pfmem_range->start = pfmem->start; |
1708 | pfmem_range->end = pfmem->end; | 1687 | pfmem_range->end = pfmem->end; |
1709 | pfmem_range->rangeno = 1; | 1688 | pfmem_range->rangeno = 1; |
diff --git a/drivers/pci/hotplug/ibmphp_res.c b/drivers/pci/hotplug/ibmphp_res.c index 9c224c94d698..5636b1ac2a2e 100644 --- a/drivers/pci/hotplug/ibmphp_res.c +++ b/drivers/pci/hotplug/ibmphp_res.c | |||
@@ -55,13 +55,12 @@ static struct bus_node * __init alloc_error_bus (struct ebda_pci_rsrc * curr, u8 | |||
55 | return NULL; | 55 | return NULL; |
56 | } | 56 | } |
57 | 57 | ||
58 | newbus = kmalloc (sizeof (struct bus_node), GFP_KERNEL); | 58 | newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); |
59 | if (!newbus) { | 59 | if (!newbus) { |
60 | err ("out of system memory\n"); | 60 | err ("out of system memory\n"); |
61 | return NULL; | 61 | return NULL; |
62 | } | 62 | } |
63 | 63 | ||
64 | memset (newbus, 0, sizeof (struct bus_node)); | ||
65 | if (flag) | 64 | if (flag) |
66 | newbus->busno = busno; | 65 | newbus->busno = busno; |
67 | else | 66 | else |
@@ -79,12 +78,11 @@ static struct resource_node * __init alloc_resources (struct ebda_pci_rsrc * cur | |||
79 | return NULL; | 78 | return NULL; |
80 | } | 79 | } |
81 | 80 | ||
82 | rs = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 81 | rs = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
83 | if (!rs) { | 82 | if (!rs) { |
84 | err ("out of system memory\n"); | 83 | err ("out of system memory\n"); |
85 | return NULL; | 84 | return NULL; |
86 | } | 85 | } |
87 | memset (rs, 0, sizeof (struct resource_node)); | ||
88 | rs->busno = curr->bus_num; | 86 | rs->busno = curr->bus_num; |
89 | rs->devfunc = curr->dev_fun; | 87 | rs->devfunc = curr->dev_fun; |
90 | rs->start = curr->start_addr; | 88 | rs->start = curr->start_addr; |
@@ -100,12 +98,11 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node | |||
100 | u8 num_ranges = 0; | 98 | u8 num_ranges = 0; |
101 | 99 | ||
102 | if (first_bus) { | 100 | if (first_bus) { |
103 | newbus = kmalloc (sizeof (struct bus_node), GFP_KERNEL); | 101 | newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); |
104 | if (!newbus) { | 102 | if (!newbus) { |
105 | err ("out of system memory.\n"); | 103 | err ("out of system memory.\n"); |
106 | return -ENOMEM; | 104 | return -ENOMEM; |
107 | } | 105 | } |
108 | memset (newbus, 0, sizeof (struct bus_node)); | ||
109 | newbus->busno = curr->bus_num; | 106 | newbus->busno = curr->bus_num; |
110 | } else { | 107 | } else { |
111 | newbus = *new_bus; | 108 | newbus = *new_bus; |
@@ -122,14 +119,13 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node | |||
122 | } | 119 | } |
123 | } | 120 | } |
124 | 121 | ||
125 | newrange = kmalloc (sizeof (struct range_node), GFP_KERNEL); | 122 | newrange = kzalloc(sizeof(struct range_node), GFP_KERNEL); |
126 | if (!newrange) { | 123 | if (!newrange) { |
127 | if (first_bus) | 124 | if (first_bus) |
128 | kfree (newbus); | 125 | kfree (newbus); |
129 | err ("out of system memory\n"); | 126 | err ("out of system memory\n"); |
130 | return -ENOMEM; | 127 | return -ENOMEM; |
131 | } | 128 | } |
132 | memset (newrange, 0, sizeof (struct range_node)); | ||
133 | newrange->start = curr->start_addr; | 129 | newrange->start = curr->start_addr; |
134 | newrange->end = curr->end_addr; | 130 | newrange->end = curr->end_addr; |
135 | 131 | ||
@@ -329,7 +325,7 @@ int __init ibmphp_rsrc_init (void) | |||
329 | if (!new_pfmem) | 325 | if (!new_pfmem) |
330 | return -ENOMEM; | 326 | return -ENOMEM; |
331 | new_pfmem->type = PFMEM; | 327 | new_pfmem->type = PFMEM; |
332 | new_pfmem->fromMem = FALSE; | 328 | new_pfmem->fromMem = 0; |
333 | if (ibmphp_add_resource (new_pfmem) < 0) { | 329 | if (ibmphp_add_resource (new_pfmem) < 0) { |
334 | newbus = alloc_error_bus (curr, 0, 0); | 330 | newbus = alloc_error_bus (curr, 0, 0); |
335 | if (!newbus) | 331 | if (!newbus) |
@@ -466,7 +462,7 @@ static int add_range (int type, struct range_node *range, struct bus_node *bus_c | |||
466 | static void update_resources (struct bus_node *bus_cur, int type, int rangeno) | 462 | static void update_resources (struct bus_node *bus_cur, int type, int rangeno) |
467 | { | 463 | { |
468 | struct resource_node *res = NULL; | 464 | struct resource_node *res = NULL; |
469 | u8 eol = FALSE; /* end of list indicator */ | 465 | u8 eol = 0; /* end of list indicator */ |
470 | 466 | ||
471 | switch (type) { | 467 | switch (type) { |
472 | case MEM: | 468 | case MEM: |
@@ -492,7 +488,7 @@ static void update_resources (struct bus_node *bus_cur, int type, int rangeno) | |||
492 | else if (res->nextRange) | 488 | else if (res->nextRange) |
493 | res = res->nextRange; | 489 | res = res->nextRange; |
494 | else { | 490 | else { |
495 | eol = TRUE; | 491 | eol = 1; |
496 | break; | 492 | break; |
497 | } | 493 | } |
498 | } | 494 | } |
@@ -983,7 +979,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
983 | int noranges = 0; | 979 | int noranges = 0; |
984 | u32 tmp_start; /* this is to make sure start address is divisible by the length needed */ | 980 | u32 tmp_start; /* this is to make sure start address is divisible by the length needed */ |
985 | u32 tmp_divide; | 981 | u32 tmp_divide; |
986 | u8 flag = FALSE; | 982 | u8 flag = 0; |
987 | 983 | ||
988 | if (!res) | 984 | if (!res) |
989 | return -EINVAL; | 985 | return -EINVAL; |
@@ -1050,17 +1046,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1050 | 1046 | ||
1051 | if ((range->start % tmp_divide) == 0) { | 1047 | if ((range->start % tmp_divide) == 0) { |
1052 | /* just perfect, starting address is divisible by length */ | 1048 | /* just perfect, starting address is divisible by length */ |
1053 | flag = TRUE; | 1049 | flag = 1; |
1054 | len_cur = len_tmp; | 1050 | len_cur = len_tmp; |
1055 | start_cur = range->start; | 1051 | start_cur = range->start; |
1056 | } else { | 1052 | } else { |
1057 | /* Needs adjusting */ | 1053 | /* Needs adjusting */ |
1058 | tmp_start = range->start; | 1054 | tmp_start = range->start; |
1059 | flag = FALSE; | 1055 | flag = 0; |
1060 | 1056 | ||
1061 | while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) { | 1057 | while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) { |
1062 | if ((tmp_start % tmp_divide) == 0) { | 1058 | if ((tmp_start % tmp_divide) == 0) { |
1063 | flag = TRUE; | 1059 | flag = 1; |
1064 | len_cur = len_tmp; | 1060 | len_cur = len_tmp; |
1065 | start_cur = tmp_start; | 1061 | start_cur = tmp_start; |
1066 | break; | 1062 | break; |
@@ -1089,17 +1085,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1089 | 1085 | ||
1090 | if (((res_cur->end + 1) % tmp_divide) == 0) { | 1086 | if (((res_cur->end + 1) % tmp_divide) == 0) { |
1091 | /* just perfect, starting address is divisible by length */ | 1087 | /* just perfect, starting address is divisible by length */ |
1092 | flag = TRUE; | 1088 | flag = 1; |
1093 | len_cur = len_tmp; | 1089 | len_cur = len_tmp; |
1094 | start_cur = res_cur->end + 1; | 1090 | start_cur = res_cur->end + 1; |
1095 | } else { | 1091 | } else { |
1096 | /* Needs adjusting */ | 1092 | /* Needs adjusting */ |
1097 | tmp_start = res_cur->end + 1; | 1093 | tmp_start = res_cur->end + 1; |
1098 | flag = FALSE; | 1094 | flag = 0; |
1099 | 1095 | ||
1100 | while ((len_tmp = range->end - tmp_start) >= res->len) { | 1096 | while ((len_tmp = range->end - tmp_start) >= res->len) { |
1101 | if ((tmp_start % tmp_divide) == 0) { | 1097 | if ((tmp_start % tmp_divide) == 0) { |
1102 | flag = TRUE; | 1098 | flag = 1; |
1103 | len_cur = len_tmp; | 1099 | len_cur = len_tmp; |
1104 | start_cur = tmp_start; | 1100 | start_cur = tmp_start; |
1105 | break; | 1101 | break; |
@@ -1127,17 +1123,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1127 | if ((len_tmp < len_cur) || (len_cur == 0)) { | 1123 | if ((len_tmp < len_cur) || (len_cur == 0)) { |
1128 | if ((range->start % tmp_divide) == 0) { | 1124 | if ((range->start % tmp_divide) == 0) { |
1129 | /* just perfect, starting address is divisible by length */ | 1125 | /* just perfect, starting address is divisible by length */ |
1130 | flag = TRUE; | 1126 | flag = 1; |
1131 | len_cur = len_tmp; | 1127 | len_cur = len_tmp; |
1132 | start_cur = range->start; | 1128 | start_cur = range->start; |
1133 | } else { | 1129 | } else { |
1134 | /* Needs adjusting */ | 1130 | /* Needs adjusting */ |
1135 | tmp_start = range->start; | 1131 | tmp_start = range->start; |
1136 | flag = FALSE; | 1132 | flag = 0; |
1137 | 1133 | ||
1138 | while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) { | 1134 | while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) { |
1139 | if ((tmp_start % tmp_divide) == 0) { | 1135 | if ((tmp_start % tmp_divide) == 0) { |
1140 | flag = TRUE; | 1136 | flag = 1; |
1141 | len_cur = len_tmp; | 1137 | len_cur = len_tmp; |
1142 | start_cur = tmp_start; | 1138 | start_cur = tmp_start; |
1143 | break; | 1139 | break; |
@@ -1162,17 +1158,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1162 | if ((len_tmp < len_cur) || (len_cur == 0)) { | 1158 | if ((len_tmp < len_cur) || (len_cur == 0)) { |
1163 | if (((res_prev->end + 1) % tmp_divide) == 0) { | 1159 | if (((res_prev->end + 1) % tmp_divide) == 0) { |
1164 | /* just perfect, starting address's divisible by length */ | 1160 | /* just perfect, starting address's divisible by length */ |
1165 | flag = TRUE; | 1161 | flag = 1; |
1166 | len_cur = len_tmp; | 1162 | len_cur = len_tmp; |
1167 | start_cur = res_prev->end + 1; | 1163 | start_cur = res_prev->end + 1; |
1168 | } else { | 1164 | } else { |
1169 | /* Needs adjusting */ | 1165 | /* Needs adjusting */ |
1170 | tmp_start = res_prev->end + 1; | 1166 | tmp_start = res_prev->end + 1; |
1171 | flag = FALSE; | 1167 | flag = 0; |
1172 | 1168 | ||
1173 | while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) { | 1169 | while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) { |
1174 | if ((tmp_start % tmp_divide) == 0) { | 1170 | if ((tmp_start % tmp_divide) == 0) { |
1175 | flag = TRUE; | 1171 | flag = 1; |
1176 | len_cur = len_tmp; | 1172 | len_cur = len_tmp; |
1177 | start_cur = tmp_start; | 1173 | start_cur = tmp_start; |
1178 | break; | 1174 | break; |
@@ -1221,17 +1217,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1221 | if ((len_tmp < len_cur) || (len_cur == 0)) { | 1217 | if ((len_tmp < len_cur) || (len_cur == 0)) { |
1222 | if ((range->start % tmp_divide) == 0) { | 1218 | if ((range->start % tmp_divide) == 0) { |
1223 | /* just perfect, starting address's divisible by length */ | 1219 | /* just perfect, starting address's divisible by length */ |
1224 | flag = TRUE; | 1220 | flag = 1; |
1225 | len_cur = len_tmp; | 1221 | len_cur = len_tmp; |
1226 | start_cur = range->start; | 1222 | start_cur = range->start; |
1227 | } else { | 1223 | } else { |
1228 | /* Needs adjusting */ | 1224 | /* Needs adjusting */ |
1229 | tmp_start = range->start; | 1225 | tmp_start = range->start; |
1230 | flag = FALSE; | 1226 | flag = 0; |
1231 | 1227 | ||
1232 | while ((len_tmp = range->end - tmp_start) >= res->len) { | 1228 | while ((len_tmp = range->end - tmp_start) >= res->len) { |
1233 | if ((tmp_start % tmp_divide) == 0) { | 1229 | if ((tmp_start % tmp_divide) == 0) { |
1234 | flag = TRUE; | 1230 | flag = 1; |
1235 | len_cur = len_tmp; | 1231 | len_cur = len_tmp; |
1236 | start_cur = tmp_start; | 1232 | start_cur = tmp_start; |
1237 | break; | 1233 | break; |
@@ -1285,17 +1281,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1285 | if ((len_tmp < len_cur) || (len_cur == 0)) { | 1281 | if ((len_tmp < len_cur) || (len_cur == 0)) { |
1286 | if ((range->start % tmp_divide) == 0) { | 1282 | if ((range->start % tmp_divide) == 0) { |
1287 | /* just perfect, starting address's divisible by length */ | 1283 | /* just perfect, starting address's divisible by length */ |
1288 | flag = TRUE; | 1284 | flag = 1; |
1289 | len_cur = len_tmp; | 1285 | len_cur = len_tmp; |
1290 | start_cur = range->start; | 1286 | start_cur = range->start; |
1291 | } else { | 1287 | } else { |
1292 | /* Needs adjusting */ | 1288 | /* Needs adjusting */ |
1293 | tmp_start = range->start; | 1289 | tmp_start = range->start; |
1294 | flag = FALSE; | 1290 | flag = 0; |
1295 | 1291 | ||
1296 | while ((len_tmp = range->end - tmp_start) >= res->len) { | 1292 | while ((len_tmp = range->end - tmp_start) >= res->len) { |
1297 | if ((tmp_start % tmp_divide) == 0) { | 1293 | if ((tmp_start % tmp_divide) == 0) { |
1298 | flag = TRUE; | 1294 | flag = 1; |
1299 | len_cur = len_tmp; | 1295 | len_cur = len_tmp; |
1300 | start_cur = tmp_start; | 1296 | start_cur = tmp_start; |
1301 | break; | 1297 | break; |
@@ -1688,7 +1684,7 @@ static int __init once_over (void) | |||
1688 | bus_cur = list_entry (tmp, struct bus_node, bus_list); | 1684 | bus_cur = list_entry (tmp, struct bus_node, bus_list); |
1689 | if ((!bus_cur->rangePFMem) && (bus_cur->firstPFMem)) { | 1685 | if ((!bus_cur->rangePFMem) && (bus_cur->firstPFMem)) { |
1690 | for (pfmem_cur = bus_cur->firstPFMem, pfmem_prev = NULL; pfmem_cur; pfmem_prev = pfmem_cur, pfmem_cur = pfmem_cur->next) { | 1686 | for (pfmem_cur = bus_cur->firstPFMem, pfmem_prev = NULL; pfmem_cur; pfmem_prev = pfmem_cur, pfmem_cur = pfmem_cur->next) { |
1691 | pfmem_cur->fromMem = TRUE; | 1687 | pfmem_cur->fromMem = 1; |
1692 | if (pfmem_prev) | 1688 | if (pfmem_prev) |
1693 | pfmem_prev->next = pfmem_cur->next; | 1689 | pfmem_prev->next = pfmem_cur->next; |
1694 | else | 1690 | else |
@@ -1705,12 +1701,11 @@ static int __init once_over (void) | |||
1705 | 1701 | ||
1706 | bus_cur->firstPFMemFromMem = pfmem_cur; | 1702 | bus_cur->firstPFMemFromMem = pfmem_cur; |
1707 | 1703 | ||
1708 | mem = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 1704 | mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
1709 | if (!mem) { | 1705 | if (!mem) { |
1710 | err ("out of system memory\n"); | 1706 | err ("out of system memory\n"); |
1711 | return -ENOMEM; | 1707 | return -ENOMEM; |
1712 | } | 1708 | } |
1713 | memset (mem, 0, sizeof (struct resource_node)); | ||
1714 | mem->type = MEM; | 1709 | mem->type = MEM; |
1715 | mem->busno = pfmem_cur->busno; | 1710 | mem->busno = pfmem_cur->busno; |
1716 | mem->devfunc = pfmem_cur->devfunc; | 1711 | mem->devfunc = pfmem_cur->devfunc; |
@@ -1994,12 +1989,11 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
1994 | end_address |= (upper_io_end << 16); | 1989 | end_address |= (upper_io_end << 16); |
1995 | 1990 | ||
1996 | if ((start_address) && (start_address <= end_address)) { | 1991 | if ((start_address) && (start_address <= end_address)) { |
1997 | range = kmalloc (sizeof (struct range_node), GFP_KERNEL); | 1992 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); |
1998 | if (!range) { | 1993 | if (!range) { |
1999 | err ("out of system memory\n"); | 1994 | err ("out of system memory\n"); |
2000 | return -ENOMEM; | 1995 | return -ENOMEM; |
2001 | } | 1996 | } |
2002 | memset (range, 0, sizeof (struct range_node)); | ||
2003 | range->start = start_address; | 1997 | range->start = start_address; |
2004 | range->end = end_address + 0xfff; | 1998 | range->end = end_address + 0xfff; |
2005 | 1999 | ||
@@ -2020,13 +2014,12 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2020 | fix_resources (bus_sec); | 2014 | fix_resources (bus_sec); |
2021 | 2015 | ||
2022 | if (ibmphp_find_resource (bus_cur, start_address, &io, IO)) { | 2016 | if (ibmphp_find_resource (bus_cur, start_address, &io, IO)) { |
2023 | io = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 2017 | io = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
2024 | if (!io) { | 2018 | if (!io) { |
2025 | kfree (range); | 2019 | kfree (range); |
2026 | err ("out of system memory\n"); | 2020 | err ("out of system memory\n"); |
2027 | return -ENOMEM; | 2021 | return -ENOMEM; |
2028 | } | 2022 | } |
2029 | memset (io, 0, sizeof (struct resource_node)); | ||
2030 | io->type = IO; | 2023 | io->type = IO; |
2031 | io->busno = bus_cur->busno; | 2024 | io->busno = bus_cur->busno; |
2032 | io->devfunc = ((device << 3) | (function & 0x7)); | 2025 | io->devfunc = ((device << 3) | (function & 0x7)); |
@@ -2045,12 +2038,11 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2045 | 2038 | ||
2046 | if ((start_address) && (start_address <= end_address)) { | 2039 | if ((start_address) && (start_address <= end_address)) { |
2047 | 2040 | ||
2048 | range = kmalloc (sizeof (struct range_node), GFP_KERNEL); | 2041 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); |
2049 | if (!range) { | 2042 | if (!range) { |
2050 | err ("out of system memory\n"); | 2043 | err ("out of system memory\n"); |
2051 | return -ENOMEM; | 2044 | return -ENOMEM; |
2052 | } | 2045 | } |
2053 | memset (range, 0, sizeof (struct range_node)); | ||
2054 | range->start = start_address; | 2046 | range->start = start_address; |
2055 | range->end = end_address + 0xfffff; | 2047 | range->end = end_address + 0xfffff; |
2056 | 2048 | ||
@@ -2072,13 +2064,12 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2072 | fix_resources (bus_sec); | 2064 | fix_resources (bus_sec); |
2073 | 2065 | ||
2074 | if (ibmphp_find_resource (bus_cur, start_address, &mem, MEM)) { | 2066 | if (ibmphp_find_resource (bus_cur, start_address, &mem, MEM)) { |
2075 | mem = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 2067 | mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
2076 | if (!mem) { | 2068 | if (!mem) { |
2077 | kfree (range); | 2069 | kfree (range); |
2078 | err ("out of system memory\n"); | 2070 | err ("out of system memory\n"); |
2079 | return -ENOMEM; | 2071 | return -ENOMEM; |
2080 | } | 2072 | } |
2081 | memset (mem, 0, sizeof (struct resource_node)); | ||
2082 | mem->type = MEM; | 2073 | mem->type = MEM; |
2083 | mem->busno = bus_cur->busno; | 2074 | mem->busno = bus_cur->busno; |
2084 | mem->devfunc = ((device << 3) | (function & 0x7)); | 2075 | mem->devfunc = ((device << 3) | (function & 0x7)); |
@@ -2101,12 +2092,11 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2101 | 2092 | ||
2102 | if ((start_address) && (start_address <= end_address)) { | 2093 | if ((start_address) && (start_address <= end_address)) { |
2103 | 2094 | ||
2104 | range = kmalloc (sizeof (struct range_node), GFP_KERNEL); | 2095 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); |
2105 | if (!range) { | 2096 | if (!range) { |
2106 | err ("out of system memory\n"); | 2097 | err ("out of system memory\n"); |
2107 | return -ENOMEM; | 2098 | return -ENOMEM; |
2108 | } | 2099 | } |
2109 | memset (range, 0, sizeof (struct range_node)); | ||
2110 | range->start = start_address; | 2100 | range->start = start_address; |
2111 | range->end = end_address + 0xfffff; | 2101 | range->end = end_address + 0xfffff; |
2112 | 2102 | ||
@@ -2127,20 +2117,19 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2127 | 2117 | ||
2128 | fix_resources (bus_sec); | 2118 | fix_resources (bus_sec); |
2129 | if (ibmphp_find_resource (bus_cur, start_address, &pfmem, PFMEM)) { | 2119 | if (ibmphp_find_resource (bus_cur, start_address, &pfmem, PFMEM)) { |
2130 | pfmem = kmalloc (sizeof (struct resource_node), GFP_KERNEL); | 2120 | pfmem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
2131 | if (!pfmem) { | 2121 | if (!pfmem) { |
2132 | kfree (range); | 2122 | kfree (range); |
2133 | err ("out of system memory\n"); | 2123 | err ("out of system memory\n"); |
2134 | return -ENOMEM; | 2124 | return -ENOMEM; |
2135 | } | 2125 | } |
2136 | memset (pfmem, 0, sizeof (struct resource_node)); | ||
2137 | pfmem->type = PFMEM; | 2126 | pfmem->type = PFMEM; |
2138 | pfmem->busno = bus_cur->busno; | 2127 | pfmem->busno = bus_cur->busno; |
2139 | pfmem->devfunc = ((device << 3) | (function & 0x7)); | 2128 | pfmem->devfunc = ((device << 3) | (function & 0x7)); |
2140 | pfmem->start = start_address; | 2129 | pfmem->start = start_address; |
2141 | pfmem->end = end_address + 0xfffff; | 2130 | pfmem->end = end_address + 0xfffff; |
2142 | pfmem->len = pfmem->end - pfmem->start + 1; | 2131 | pfmem->len = pfmem->end - pfmem->start + 1; |
2143 | pfmem->fromMem = FALSE; | 2132 | pfmem->fromMem = 0; |
2144 | 2133 | ||
2145 | ibmphp_add_resource (pfmem); | 2134 | ibmphp_add_resource (pfmem); |
2146 | } | 2135 | } |
diff --git a/drivers/pci/hotplug/pci_hotplug.h b/drivers/pci/hotplug/pci_hotplug.h index 88d44f7fef29..eb0d01d47236 100644 --- a/drivers/pci/hotplug/pci_hotplug.h +++ b/drivers/pci/hotplug/pci_hotplug.h | |||
@@ -176,5 +176,21 @@ extern int pci_hp_change_slot_info (struct hotplug_slot *slot, | |||
176 | struct hotplug_slot_info *info); | 176 | struct hotplug_slot_info *info); |
177 | extern struct subsystem pci_hotplug_slots_subsys; | 177 | extern struct subsystem pci_hotplug_slots_subsys; |
178 | 178 | ||
179 | struct hotplug_params { | ||
180 | u8 cache_line_size; | ||
181 | u8 latency_timer; | ||
182 | u8 enable_serr; | ||
183 | u8 enable_perr; | ||
184 | }; | ||
185 | |||
186 | #ifdef CONFIG_ACPI | ||
187 | #include <acpi/acpi.h> | ||
188 | #include <acpi/acpi_bus.h> | ||
189 | #include <acpi/actypes.h> | ||
190 | extern acpi_status acpi_run_oshp(acpi_handle handle); | ||
191 | extern acpi_status acpi_get_hp_params_from_firmware(struct pci_dev *dev, | ||
192 | struct hotplug_params *hpp); | ||
193 | int acpi_root_bridge(acpi_handle handle); | ||
194 | #endif | ||
179 | #endif | 195 | #endif |
180 | 196 | ||
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 0aac6a61337d..92c1f0f1e1ad 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
35 | #include <linux/sched.h> /* signal_pending() */ | 35 | #include <linux/sched.h> /* signal_pending() */ |
36 | #include <linux/pcieport_if.h> | 36 | #include <linux/pcieport_if.h> |
37 | #include <linux/mutex.h> | ||
37 | #include "pci_hotplug.h" | 38 | #include "pci_hotplug.h" |
38 | 39 | ||
39 | #define MY_NAME "pciehp" | 40 | #define MY_NAME "pciehp" |
@@ -49,12 +50,6 @@ extern int pciehp_force; | |||
49 | #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) | 50 | #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) |
50 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) | 51 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) |
51 | 52 | ||
52 | struct hotplug_params { | ||
53 | u8 cache_line_size; | ||
54 | u8 latency_timer; | ||
55 | u8 enable_serr; | ||
56 | u8 enable_perr; | ||
57 | }; | ||
58 | 53 | ||
59 | struct slot { | 54 | struct slot { |
60 | struct slot *next; | 55 | struct slot *next; |
@@ -96,7 +91,7 @@ struct php_ctlr_state_s { | |||
96 | #define MAX_EVENTS 10 | 91 | #define MAX_EVENTS 10 |
97 | struct controller { | 92 | struct controller { |
98 | struct controller *next; | 93 | struct controller *next; |
99 | struct semaphore crit_sect; /* critical section semaphore */ | 94 | struct mutex crit_sect; /* critical section mutex */ |
100 | struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */ | 95 | struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */ |
101 | int num_slots; /* Number of slots on ctlr */ | 96 | int num_slots; /* Number of slots on ctlr */ |
102 | int slot_num_inc; /* 1 or -1 */ | 97 | int slot_num_inc; /* 1 or -1 */ |
@@ -191,9 +186,6 @@ extern u8 pciehp_handle_power_fault (u8 hp_slot, void *inst_id); | |||
191 | /* pci functions */ | 186 | /* pci functions */ |
192 | extern int pciehp_configure_device (struct slot *p_slot); | 187 | extern int pciehp_configure_device (struct slot *p_slot); |
193 | extern int pciehp_unconfigure_device (struct slot *p_slot); | 188 | extern int pciehp_unconfigure_device (struct slot *p_slot); |
194 | extern int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev); | ||
195 | extern void pciehp_get_hp_params_from_firmware(struct pci_dev *dev, | ||
196 | struct hotplug_params *hpp); | ||
197 | 189 | ||
198 | 190 | ||
199 | 191 | ||
@@ -285,4 +277,19 @@ struct hpc_ops { | |||
285 | int (*check_lnk_status) (struct controller *ctrl); | 277 | int (*check_lnk_status) (struct controller *ctrl); |
286 | }; | 278 | }; |
287 | 279 | ||
280 | |||
281 | #ifdef CONFIG_ACPI | ||
282 | #define pciehp_get_hp_hw_control_from_firmware(dev) \ | ||
283 | pciehp_acpi_get_hp_hw_control_from_firmware(dev) | ||
284 | static inline int pciehp_get_hp_params_from_firmware(struct pci_dev *dev, | ||
285 | struct hotplug_params *hpp) | ||
286 | { | ||
287 | if (ACPI_FAILURE(acpi_get_hp_params_from_firmware(dev, hpp))) | ||
288 | return -ENODEV; | ||
289 | return 0; | ||
290 | } | ||
291 | #else | ||
292 | #define pciehp_get_hp_hw_control_from_firmware(dev) 0 | ||
293 | #define pciehp_get_hp_params_from_firmware(dev, hpp) (-ENODEV) | ||
294 | #endif /* CONFIG_ACPI */ | ||
288 | #endif /* _PCIEHP_H */ | 295 | #endif /* _PCIEHP_H */ |
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index 4fb569018a24..601cf9045b20 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c | |||
@@ -117,27 +117,23 @@ static int init_slots(struct controller *ctrl) | |||
117 | slot_number = ctrl->first_slot; | 117 | slot_number = ctrl->first_slot; |
118 | 118 | ||
119 | while (number_of_slots) { | 119 | while (number_of_slots) { |
120 | slot = kmalloc(sizeof(*slot), GFP_KERNEL); | 120 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); |
121 | if (!slot) | 121 | if (!slot) |
122 | goto error; | 122 | goto error; |
123 | 123 | ||
124 | memset(slot, 0, sizeof(struct slot)); | ||
125 | slot->hotplug_slot = | 124 | slot->hotplug_slot = |
126 | kmalloc(sizeof(*(slot->hotplug_slot)), | 125 | kzalloc(sizeof(*(slot->hotplug_slot)), |
127 | GFP_KERNEL); | 126 | GFP_KERNEL); |
128 | if (!slot->hotplug_slot) | 127 | if (!slot->hotplug_slot) |
129 | goto error_slot; | 128 | goto error_slot; |
130 | hotplug_slot = slot->hotplug_slot; | 129 | hotplug_slot = slot->hotplug_slot; |
131 | memset(hotplug_slot, 0, sizeof(struct hotplug_slot)); | ||
132 | 130 | ||
133 | hotplug_slot->info = | 131 | hotplug_slot->info = |
134 | kmalloc(sizeof(*(hotplug_slot->info)), | 132 | kzalloc(sizeof(*(hotplug_slot->info)), |
135 | GFP_KERNEL); | 133 | GFP_KERNEL); |
136 | if (!hotplug_slot->info) | 134 | if (!hotplug_slot->info) |
137 | goto error_hpslot; | 135 | goto error_hpslot; |
138 | hotplug_slot_info = hotplug_slot->info; | 136 | hotplug_slot_info = hotplug_slot->info; |
139 | memset(hotplug_slot_info, 0, | ||
140 | sizeof(struct hotplug_slot_info)); | ||
141 | hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); | 137 | hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); |
142 | if (!hotplug_slot->name) | 138 | if (!hotplug_slot->name) |
143 | goto error_info; | 139 | goto error_info; |
@@ -373,12 +369,11 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ | |||
373 | u8 value; | 369 | u8 value; |
374 | struct pci_dev *pdev; | 370 | struct pci_dev *pdev; |
375 | 371 | ||
376 | ctrl = kmalloc(sizeof(*ctrl), GFP_KERNEL); | 372 | ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); |
377 | if (!ctrl) { | 373 | if (!ctrl) { |
378 | err("%s : out of memory\n", __FUNCTION__); | 374 | err("%s : out of memory\n", __FUNCTION__); |
379 | goto err_out_none; | 375 | goto err_out_none; |
380 | } | 376 | } |
381 | memset(ctrl, 0, sizeof(struct controller)); | ||
382 | 377 | ||
383 | pdev = dev->port; | 378 | pdev = dev->port; |
384 | ctrl->pci_dev = pdev; | 379 | ctrl->pci_dev = pdev; |
@@ -439,7 +434,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ | |||
439 | } | 434 | } |
440 | 435 | ||
441 | /* Wait for exclusive access to hardware */ | 436 | /* Wait for exclusive access to hardware */ |
442 | down(&ctrl->crit_sect); | 437 | mutex_lock(&ctrl->crit_sect); |
443 | 438 | ||
444 | t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */ | 439 | t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */ |
445 | 440 | ||
@@ -447,7 +442,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ | |||
447 | rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/ | 442 | rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/ |
448 | if (rc) { | 443 | if (rc) { |
449 | /* Done with exclusive hardware access */ | 444 | /* Done with exclusive hardware access */ |
450 | up(&ctrl->crit_sect); | 445 | mutex_unlock(&ctrl->crit_sect); |
451 | goto err_out_free_ctrl_slot; | 446 | goto err_out_free_ctrl_slot; |
452 | } else | 447 | } else |
453 | /* Wait for the command to complete */ | 448 | /* Wait for the command to complete */ |
@@ -455,7 +450,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ | |||
455 | } | 450 | } |
456 | 451 | ||
457 | /* Done with exclusive hardware access */ | 452 | /* Done with exclusive hardware access */ |
458 | up(&ctrl->crit_sect); | 453 | mutex_unlock(&ctrl->crit_sect); |
459 | 454 | ||
460 | return 0; | 455 | return 0; |
461 | 456 | ||
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 83c4b865718a..33d198768356 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c | |||
@@ -229,13 +229,13 @@ u8 pciehp_handle_power_fault(u8 hp_slot, void *inst_id) | |||
229 | static void set_slot_off(struct controller *ctrl, struct slot * pslot) | 229 | static void set_slot_off(struct controller *ctrl, struct slot * pslot) |
230 | { | 230 | { |
231 | /* Wait for exclusive access to hardware */ | 231 | /* Wait for exclusive access to hardware */ |
232 | down(&ctrl->crit_sect); | 232 | mutex_lock(&ctrl->crit_sect); |
233 | 233 | ||
234 | /* turn off slot, turn on Amber LED, turn off Green LED if supported*/ | 234 | /* turn off slot, turn on Amber LED, turn off Green LED if supported*/ |
235 | if (POWER_CTRL(ctrl->ctrlcap)) { | 235 | if (POWER_CTRL(ctrl->ctrlcap)) { |
236 | if (pslot->hpc_ops->power_off_slot(pslot)) { | 236 | if (pslot->hpc_ops->power_off_slot(pslot)) { |
237 | err("%s: Issue of Slot Power Off command failed\n", __FUNCTION__); | 237 | err("%s: Issue of Slot Power Off command failed\n", __FUNCTION__); |
238 | up(&ctrl->crit_sect); | 238 | mutex_unlock(&ctrl->crit_sect); |
239 | return; | 239 | return; |
240 | } | 240 | } |
241 | wait_for_ctrl_irq (ctrl); | 241 | wait_for_ctrl_irq (ctrl); |
@@ -249,14 +249,14 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot) | |||
249 | if (ATTN_LED(ctrl->ctrlcap)) { | 249 | if (ATTN_LED(ctrl->ctrlcap)) { |
250 | if (pslot->hpc_ops->set_attention_status(pslot, 1)) { | 250 | if (pslot->hpc_ops->set_attention_status(pslot, 1)) { |
251 | err("%s: Issue of Set Attention Led command failed\n", __FUNCTION__); | 251 | err("%s: Issue of Set Attention Led command failed\n", __FUNCTION__); |
252 | up(&ctrl->crit_sect); | 252 | mutex_unlock(&ctrl->crit_sect); |
253 | return; | 253 | return; |
254 | } | 254 | } |
255 | wait_for_ctrl_irq (ctrl); | 255 | wait_for_ctrl_irq (ctrl); |
256 | } | 256 | } |
257 | 257 | ||
258 | /* Done with exclusive hardware access */ | 258 | /* Done with exclusive hardware access */ |
259 | up(&ctrl->crit_sect); | 259 | mutex_unlock(&ctrl->crit_sect); |
260 | } | 260 | } |
261 | 261 | ||
262 | /** | 262 | /** |
@@ -279,13 +279,13 @@ static int board_added(struct slot *p_slot) | |||
279 | ctrl->slot_device_offset, hp_slot); | 279 | ctrl->slot_device_offset, hp_slot); |
280 | 280 | ||
281 | /* Wait for exclusive access to hardware */ | 281 | /* Wait for exclusive access to hardware */ |
282 | down(&ctrl->crit_sect); | 282 | mutex_lock(&ctrl->crit_sect); |
283 | 283 | ||
284 | if (POWER_CTRL(ctrl->ctrlcap)) { | 284 | if (POWER_CTRL(ctrl->ctrlcap)) { |
285 | /* Power on slot */ | 285 | /* Power on slot */ |
286 | rc = p_slot->hpc_ops->power_on_slot(p_slot); | 286 | rc = p_slot->hpc_ops->power_on_slot(p_slot); |
287 | if (rc) { | 287 | if (rc) { |
288 | up(&ctrl->crit_sect); | 288 | mutex_unlock(&ctrl->crit_sect); |
289 | return -1; | 289 | return -1; |
290 | } | 290 | } |
291 | 291 | ||
@@ -301,7 +301,7 @@ static int board_added(struct slot *p_slot) | |||
301 | } | 301 | } |
302 | 302 | ||
303 | /* Done with exclusive hardware access */ | 303 | /* Done with exclusive hardware access */ |
304 | up(&ctrl->crit_sect); | 304 | mutex_unlock(&ctrl->crit_sect); |
305 | 305 | ||
306 | /* Wait for ~1 second */ | 306 | /* Wait for ~1 second */ |
307 | wait_for_ctrl_irq (ctrl); | 307 | wait_for_ctrl_irq (ctrl); |
@@ -335,7 +335,7 @@ static int board_added(struct slot *p_slot) | |||
335 | pci_fixup_device(pci_fixup_final, ctrl->pci_dev); | 335 | pci_fixup_device(pci_fixup_final, ctrl->pci_dev); |
336 | if (PWR_LED(ctrl->ctrlcap)) { | 336 | if (PWR_LED(ctrl->ctrlcap)) { |
337 | /* Wait for exclusive access to hardware */ | 337 | /* Wait for exclusive access to hardware */ |
338 | down(&ctrl->crit_sect); | 338 | mutex_lock(&ctrl->crit_sect); |
339 | 339 | ||
340 | p_slot->hpc_ops->green_led_on(p_slot); | 340 | p_slot->hpc_ops->green_led_on(p_slot); |
341 | 341 | ||
@@ -343,7 +343,7 @@ static int board_added(struct slot *p_slot) | |||
343 | wait_for_ctrl_irq (ctrl); | 343 | wait_for_ctrl_irq (ctrl); |
344 | 344 | ||
345 | /* Done with exclusive hardware access */ | 345 | /* Done with exclusive hardware access */ |
346 | up(&ctrl->crit_sect); | 346 | mutex_unlock(&ctrl->crit_sect); |
347 | } | 347 | } |
348 | return 0; | 348 | return 0; |
349 | 349 | ||
@@ -375,14 +375,14 @@ static int remove_board(struct slot *p_slot) | |||
375 | dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot); | 375 | dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot); |
376 | 376 | ||
377 | /* Wait for exclusive access to hardware */ | 377 | /* Wait for exclusive access to hardware */ |
378 | down(&ctrl->crit_sect); | 378 | mutex_lock(&ctrl->crit_sect); |
379 | 379 | ||
380 | if (POWER_CTRL(ctrl->ctrlcap)) { | 380 | if (POWER_CTRL(ctrl->ctrlcap)) { |
381 | /* power off slot */ | 381 | /* power off slot */ |
382 | rc = p_slot->hpc_ops->power_off_slot(p_slot); | 382 | rc = p_slot->hpc_ops->power_off_slot(p_slot); |
383 | if (rc) { | 383 | if (rc) { |
384 | err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); | 384 | err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); |
385 | up(&ctrl->crit_sect); | 385 | mutex_unlock(&ctrl->crit_sect); |
386 | return rc; | 386 | return rc; |
387 | } | 387 | } |
388 | /* Wait for the command to complete */ | 388 | /* Wait for the command to complete */ |
@@ -398,7 +398,7 @@ static int remove_board(struct slot *p_slot) | |||
398 | } | 398 | } |
399 | 399 | ||
400 | /* Done with exclusive hardware access */ | 400 | /* Done with exclusive hardware access */ |
401 | up(&ctrl->crit_sect); | 401 | mutex_unlock(&ctrl->crit_sect); |
402 | 402 | ||
403 | return 0; | 403 | return 0; |
404 | } | 404 | } |
@@ -445,7 +445,7 @@ static void pciehp_pushbutton_thread(unsigned long slot) | |||
445 | 445 | ||
446 | if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { | 446 | if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { |
447 | /* Wait for exclusive access to hardware */ | 447 | /* Wait for exclusive access to hardware */ |
448 | down(&p_slot->ctrl->crit_sect); | 448 | mutex_lock(&p_slot->ctrl->crit_sect); |
449 | 449 | ||
450 | p_slot->hpc_ops->green_led_off(p_slot); | 450 | p_slot->hpc_ops->green_led_off(p_slot); |
451 | 451 | ||
@@ -453,7 +453,7 @@ static void pciehp_pushbutton_thread(unsigned long slot) | |||
453 | wait_for_ctrl_irq (p_slot->ctrl); | 453 | wait_for_ctrl_irq (p_slot->ctrl); |
454 | 454 | ||
455 | /* Done with exclusive hardware access */ | 455 | /* Done with exclusive hardware access */ |
456 | up(&p_slot->ctrl->crit_sect); | 456 | mutex_unlock(&p_slot->ctrl->crit_sect); |
457 | } | 457 | } |
458 | p_slot->state = STATIC_STATE; | 458 | p_slot->state = STATIC_STATE; |
459 | } | 459 | } |
@@ -495,7 +495,7 @@ static void pciehp_surprise_rm_thread(unsigned long slot) | |||
495 | 495 | ||
496 | if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { | 496 | if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { |
497 | /* Wait for exclusive access to hardware */ | 497 | /* Wait for exclusive access to hardware */ |
498 | down(&p_slot->ctrl->crit_sect); | 498 | mutex_lock(&p_slot->ctrl->crit_sect); |
499 | 499 | ||
500 | p_slot->hpc_ops->green_led_off(p_slot); | 500 | p_slot->hpc_ops->green_led_off(p_slot); |
501 | 501 | ||
@@ -503,7 +503,7 @@ static void pciehp_surprise_rm_thread(unsigned long slot) | |||
503 | wait_for_ctrl_irq (p_slot->ctrl); | 503 | wait_for_ctrl_irq (p_slot->ctrl); |
504 | 504 | ||
505 | /* Done with exclusive hardware access */ | 505 | /* Done with exclusive hardware access */ |
506 | up(&p_slot->ctrl->crit_sect); | 506 | mutex_unlock(&p_slot->ctrl->crit_sect); |
507 | } | 507 | } |
508 | p_slot->state = STATIC_STATE; | 508 | p_slot->state = STATIC_STATE; |
509 | } | 509 | } |
@@ -616,7 +616,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
616 | switch (p_slot->state) { | 616 | switch (p_slot->state) { |
617 | case BLINKINGOFF_STATE: | 617 | case BLINKINGOFF_STATE: |
618 | /* Wait for exclusive access to hardware */ | 618 | /* Wait for exclusive access to hardware */ |
619 | down(&ctrl->crit_sect); | 619 | mutex_lock(&ctrl->crit_sect); |
620 | 620 | ||
621 | if (PWR_LED(ctrl->ctrlcap)) { | 621 | if (PWR_LED(ctrl->ctrlcap)) { |
622 | p_slot->hpc_ops->green_led_on(p_slot); | 622 | p_slot->hpc_ops->green_led_on(p_slot); |
@@ -630,11 +630,11 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
630 | wait_for_ctrl_irq (ctrl); | 630 | wait_for_ctrl_irq (ctrl); |
631 | } | 631 | } |
632 | /* Done with exclusive hardware access */ | 632 | /* Done with exclusive hardware access */ |
633 | up(&ctrl->crit_sect); | 633 | mutex_unlock(&ctrl->crit_sect); |
634 | break; | 634 | break; |
635 | case BLINKINGON_STATE: | 635 | case BLINKINGON_STATE: |
636 | /* Wait for exclusive access to hardware */ | 636 | /* Wait for exclusive access to hardware */ |
637 | down(&ctrl->crit_sect); | 637 | mutex_lock(&ctrl->crit_sect); |
638 | 638 | ||
639 | if (PWR_LED(ctrl->ctrlcap)) { | 639 | if (PWR_LED(ctrl->ctrlcap)) { |
640 | p_slot->hpc_ops->green_led_off(p_slot); | 640 | p_slot->hpc_ops->green_led_off(p_slot); |
@@ -647,7 +647,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
647 | wait_for_ctrl_irq (ctrl); | 647 | wait_for_ctrl_irq (ctrl); |
648 | } | 648 | } |
649 | /* Done with exclusive hardware access */ | 649 | /* Done with exclusive hardware access */ |
650 | up(&ctrl->crit_sect); | 650 | mutex_unlock(&ctrl->crit_sect); |
651 | 651 | ||
652 | break; | 652 | break; |
653 | default: | 653 | default: |
@@ -676,7 +676,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
676 | } | 676 | } |
677 | 677 | ||
678 | /* Wait for exclusive access to hardware */ | 678 | /* Wait for exclusive access to hardware */ |
679 | down(&ctrl->crit_sect); | 679 | mutex_lock(&ctrl->crit_sect); |
680 | 680 | ||
681 | /* blink green LED and turn off amber */ | 681 | /* blink green LED and turn off amber */ |
682 | if (PWR_LED(ctrl->ctrlcap)) { | 682 | if (PWR_LED(ctrl->ctrlcap)) { |
@@ -693,7 +693,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
693 | } | 693 | } |
694 | 694 | ||
695 | /* Done with exclusive hardware access */ | 695 | /* Done with exclusive hardware access */ |
696 | up(&ctrl->crit_sect); | 696 | mutex_unlock(&ctrl->crit_sect); |
697 | 697 | ||
698 | init_timer(&p_slot->task_event); | 698 | init_timer(&p_slot->task_event); |
699 | p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */ | 699 | p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */ |
@@ -708,7 +708,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
708 | if (POWER_CTRL(ctrl->ctrlcap)) { | 708 | if (POWER_CTRL(ctrl->ctrlcap)) { |
709 | dbg("power fault\n"); | 709 | dbg("power fault\n"); |
710 | /* Wait for exclusive access to hardware */ | 710 | /* Wait for exclusive access to hardware */ |
711 | down(&ctrl->crit_sect); | 711 | mutex_lock(&ctrl->crit_sect); |
712 | 712 | ||
713 | if (ATTN_LED(ctrl->ctrlcap)) { | 713 | if (ATTN_LED(ctrl->ctrlcap)) { |
714 | p_slot->hpc_ops->set_attention_status(p_slot, 1); | 714 | p_slot->hpc_ops->set_attention_status(p_slot, 1); |
@@ -721,7 +721,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
721 | } | 721 | } |
722 | 722 | ||
723 | /* Done with exclusive hardware access */ | 723 | /* Done with exclusive hardware access */ |
724 | up(&ctrl->crit_sect); | 724 | mutex_unlock(&ctrl->crit_sect); |
725 | } | 725 | } |
726 | } | 726 | } |
727 | /***********SURPRISE REMOVAL********************/ | 727 | /***********SURPRISE REMOVAL********************/ |
@@ -756,19 +756,19 @@ int pciehp_enable_slot(struct slot *p_slot) | |||
756 | int rc; | 756 | int rc; |
757 | 757 | ||
758 | /* Check to see if (latch closed, card present, power off) */ | 758 | /* Check to see if (latch closed, card present, power off) */ |
759 | down(&p_slot->ctrl->crit_sect); | 759 | mutex_lock(&p_slot->ctrl->crit_sect); |
760 | 760 | ||
761 | rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); | 761 | rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); |
762 | if (rc || !getstatus) { | 762 | if (rc || !getstatus) { |
763 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); | 763 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); |
764 | up(&p_slot->ctrl->crit_sect); | 764 | mutex_unlock(&p_slot->ctrl->crit_sect); |
765 | return 1; | 765 | return 1; |
766 | } | 766 | } |
767 | if (MRL_SENS(p_slot->ctrl->ctrlcap)) { | 767 | if (MRL_SENS(p_slot->ctrl->ctrlcap)) { |
768 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 768 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
769 | if (rc || getstatus) { | 769 | if (rc || getstatus) { |
770 | info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); | 770 | info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); |
771 | up(&p_slot->ctrl->crit_sect); | 771 | mutex_unlock(&p_slot->ctrl->crit_sect); |
772 | return 1; | 772 | return 1; |
773 | } | 773 | } |
774 | } | 774 | } |
@@ -777,11 +777,11 @@ int pciehp_enable_slot(struct slot *p_slot) | |||
777 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | 777 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
778 | if (rc || getstatus) { | 778 | if (rc || getstatus) { |
779 | info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); | 779 | info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); |
780 | up(&p_slot->ctrl->crit_sect); | 780 | mutex_unlock(&p_slot->ctrl->crit_sect); |
781 | return 1; | 781 | return 1; |
782 | } | 782 | } |
783 | } | 783 | } |
784 | up(&p_slot->ctrl->crit_sect); | 784 | mutex_unlock(&p_slot->ctrl->crit_sect); |
785 | 785 | ||
786 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 786 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
787 | 787 | ||
@@ -806,13 +806,13 @@ int pciehp_disable_slot(struct slot *p_slot) | |||
806 | return 1; | 806 | return 1; |
807 | 807 | ||
808 | /* Check to see if (latch closed, card present, power on) */ | 808 | /* Check to see if (latch closed, card present, power on) */ |
809 | down(&p_slot->ctrl->crit_sect); | 809 | mutex_lock(&p_slot->ctrl->crit_sect); |
810 | 810 | ||
811 | if (!HP_SUPR_RM(p_slot->ctrl->ctrlcap)) { | 811 | if (!HP_SUPR_RM(p_slot->ctrl->ctrlcap)) { |
812 | ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); | 812 | ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); |
813 | if (ret || !getstatus) { | 813 | if (ret || !getstatus) { |
814 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); | 814 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); |
815 | up(&p_slot->ctrl->crit_sect); | 815 | mutex_unlock(&p_slot->ctrl->crit_sect); |
816 | return 1; | 816 | return 1; |
817 | } | 817 | } |
818 | } | 818 | } |
@@ -821,7 +821,7 @@ int pciehp_disable_slot(struct slot *p_slot) | |||
821 | ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 821 | ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
822 | if (ret || getstatus) { | 822 | if (ret || getstatus) { |
823 | info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); | 823 | info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); |
824 | up(&p_slot->ctrl->crit_sect); | 824 | mutex_unlock(&p_slot->ctrl->crit_sect); |
825 | return 1; | 825 | return 1; |
826 | } | 826 | } |
827 | } | 827 | } |
@@ -830,12 +830,12 @@ int pciehp_disable_slot(struct slot *p_slot) | |||
830 | ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | 830 | ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
831 | if (ret || !getstatus) { | 831 | if (ret || !getstatus) { |
832 | info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); | 832 | info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); |
833 | up(&p_slot->ctrl->crit_sect); | 833 | mutex_unlock(&p_slot->ctrl->crit_sect); |
834 | return 1; | 834 | return 1; |
835 | } | 835 | } |
836 | } | 836 | } |
837 | 837 | ||
838 | up(&p_slot->ctrl->crit_sect); | 838 | mutex_unlock(&p_slot->ctrl->crit_sect); |
839 | 839 | ||
840 | ret = remove_board(p_slot); | 840 | ret = remove_board(p_slot); |
841 | update_slot_info(p_slot); | 841 | update_slot_info(p_slot); |
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 77e530321de2..6c14d9e46b2e 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c | |||
@@ -38,7 +38,10 @@ | |||
38 | 38 | ||
39 | #include "../pci.h" | 39 | #include "../pci.h" |
40 | #include "pciehp.h" | 40 | #include "pciehp.h" |
41 | 41 | #include <acpi/acpi.h> | |
42 | #include <acpi/acpi_bus.h> | ||
43 | #include <acpi/actypes.h> | ||
44 | #include <linux/pci-acpi.h> | ||
42 | #ifdef DEBUG | 45 | #ifdef DEBUG |
43 | #define DBG_K_TRACE_ENTRY ((unsigned int)0x00000001) /* On function entry */ | 46 | #define DBG_K_TRACE_ENTRY ((unsigned int)0x00000001) /* On function entry */ |
44 | #define DBG_K_TRACE_EXIT ((unsigned int)0x00000002) /* On function exit */ | 47 | #define DBG_K_TRACE_EXIT ((unsigned int)0x00000002) /* On function exit */ |
@@ -1236,6 +1239,76 @@ static struct hpc_ops pciehp_hpc_ops = { | |||
1236 | .check_lnk_status = hpc_check_lnk_status, | 1239 | .check_lnk_status = hpc_check_lnk_status, |
1237 | }; | 1240 | }; |
1238 | 1241 | ||
1242 | #ifdef CONFIG_ACPI | ||
1243 | int pciehp_acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev) | ||
1244 | { | ||
1245 | acpi_status status; | ||
1246 | acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev)); | ||
1247 | struct pci_dev *pdev = dev; | ||
1248 | struct pci_bus *parent; | ||
1249 | struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
1250 | |||
1251 | /* | ||
1252 | * Per PCI firmware specification, we should run the ACPI _OSC | ||
1253 | * method to get control of hotplug hardware before using it. | ||
1254 | * If an _OSC is missing, we look for an OSHP to do the same thing. | ||
1255 | * To handle different BIOS behavior, we look for _OSC and OSHP | ||
1256 | * within the scope of the hotplug controller and its parents, upto | ||
1257 | * the host bridge under which this controller exists. | ||
1258 | */ | ||
1259 | while (!handle) { | ||
1260 | /* | ||
1261 | * This hotplug controller was not listed in the ACPI name | ||
1262 | * space at all. Try to get acpi handle of parent pci bus. | ||
1263 | */ | ||
1264 | if (!pdev || !pdev->bus->parent) | ||
1265 | break; | ||
1266 | parent = pdev->bus->parent; | ||
1267 | dbg("Could not find %s in acpi namespace, trying parent\n", | ||
1268 | pci_name(pdev)); | ||
1269 | if (!parent->self) | ||
1270 | /* Parent must be a host bridge */ | ||
1271 | handle = acpi_get_pci_rootbridge_handle( | ||
1272 | pci_domain_nr(parent), | ||
1273 | parent->number); | ||
1274 | else | ||
1275 | handle = DEVICE_ACPI_HANDLE( | ||
1276 | &(parent->self->dev)); | ||
1277 | pdev = parent->self; | ||
1278 | } | ||
1279 | |||
1280 | while (handle) { | ||
1281 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &string); | ||
1282 | dbg("Trying to get hotplug control for %s \n", | ||
1283 | (char *)string.pointer); | ||
1284 | status = pci_osc_control_set(handle, | ||
1285 | OSC_PCI_EXPRESS_NATIVE_HP_CONTROL); | ||
1286 | if (status == AE_NOT_FOUND) | ||
1287 | status = acpi_run_oshp(handle); | ||
1288 | if (ACPI_SUCCESS(status)) { | ||
1289 | dbg("Gained control for hotplug HW for pci %s (%s)\n", | ||
1290 | pci_name(dev), (char *)string.pointer); | ||
1291 | acpi_os_free(string.pointer); | ||
1292 | return 0; | ||
1293 | } | ||
1294 | if (acpi_root_bridge(handle)) | ||
1295 | break; | ||
1296 | chandle = handle; | ||
1297 | status = acpi_get_parent(chandle, &handle); | ||
1298 | if (ACPI_FAILURE(status)) | ||
1299 | break; | ||
1300 | } | ||
1301 | |||
1302 | err("Cannot get control of hotplug hardware for pci %s\n", | ||
1303 | pci_name(dev)); | ||
1304 | |||
1305 | acpi_os_free(string.pointer); | ||
1306 | return -1; | ||
1307 | } | ||
1308 | #endif | ||
1309 | |||
1310 | |||
1311 | |||
1239 | int pcie_init(struct controller * ctrl, struct pcie_device *dev) | 1312 | int pcie_init(struct controller * ctrl, struct pcie_device *dev) |
1240 | { | 1313 | { |
1241 | struct php_ctlr_state_s *php_ctlr, *p; | 1314 | struct php_ctlr_state_s *php_ctlr, *p; |
@@ -1334,7 +1407,7 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev) | |||
1334 | if (pci_enable_device(pdev)) | 1407 | if (pci_enable_device(pdev)) |
1335 | goto abort_free_ctlr; | 1408 | goto abort_free_ctlr; |
1336 | 1409 | ||
1337 | init_MUTEX(&ctrl->crit_sect); | 1410 | mutex_init(&ctrl->crit_sect); |
1338 | /* setup wait queue */ | 1411 | /* setup wait queue */ |
1339 | init_waitqueue_head(&ctrl->queue); | 1412 | init_waitqueue_head(&ctrl->queue); |
1340 | 1413 | ||
diff --git a/drivers/pci/hotplug/pciehprm_acpi.c b/drivers/pci/hotplug/pciehprm_acpi.c deleted file mode 100644 index 2bdb30f68bf8..000000000000 --- a/drivers/pci/hotplug/pciehprm_acpi.c +++ /dev/null | |||
@@ -1,257 +0,0 @@ | |||
1 | /* | ||
2 | * PCIEHPRM ACPI: PHP Resource Manager for ACPI platform | ||
3 | * | ||
4 | * Copyright (C) 2003-2004 Intel Corporation | ||
5 | * | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or (at | ||
11 | * your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
16 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
17 | * details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
22 | * | ||
23 | * Send feedback to <kristen.c.accardi@intel.com> | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | #include <linux/module.h> | ||
28 | #include <linux/kernel.h> | ||
29 | #include <linux/types.h> | ||
30 | #include <linux/pci.h> | ||
31 | #include <linux/acpi.h> | ||
32 | #include <linux/pci-acpi.h> | ||
33 | #include <acpi/acpi_bus.h> | ||
34 | #include <acpi/actypes.h> | ||
35 | #include "pciehp.h" | ||
36 | |||
37 | #define METHOD_NAME__SUN "_SUN" | ||
38 | #define METHOD_NAME__HPP "_HPP" | ||
39 | #define METHOD_NAME_OSHP "OSHP" | ||
40 | |||
41 | static u8 * acpi_path_name( acpi_handle handle) | ||
42 | { | ||
43 | acpi_status status; | ||
44 | static u8 path_name[ACPI_PATHNAME_MAX]; | ||
45 | struct acpi_buffer ret_buf = { ACPI_PATHNAME_MAX, path_name }; | ||
46 | |||
47 | memset(path_name, 0, sizeof (path_name)); | ||
48 | status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &ret_buf); | ||
49 | |||
50 | if (ACPI_FAILURE(status)) | ||
51 | return NULL; | ||
52 | else | ||
53 | return path_name; | ||
54 | } | ||
55 | |||
56 | static acpi_status | ||
57 | acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp) | ||
58 | { | ||
59 | acpi_status status; | ||
60 | u8 nui[4]; | ||
61 | struct acpi_buffer ret_buf = { 0, NULL}; | ||
62 | union acpi_object *ext_obj, *package; | ||
63 | u8 *path_name = acpi_path_name(handle); | ||
64 | int i, len = 0; | ||
65 | |||
66 | /* get _hpp */ | ||
67 | status = acpi_evaluate_object(handle, METHOD_NAME__HPP, NULL, &ret_buf); | ||
68 | switch (status) { | ||
69 | case AE_BUFFER_OVERFLOW: | ||
70 | ret_buf.pointer = kmalloc (ret_buf.length, GFP_KERNEL); | ||
71 | if (!ret_buf.pointer) { | ||
72 | err ("%s:%s alloc for _HPP fail\n", __FUNCTION__, | ||
73 | path_name); | ||
74 | return AE_NO_MEMORY; | ||
75 | } | ||
76 | status = acpi_evaluate_object(handle, METHOD_NAME__HPP, | ||
77 | NULL, &ret_buf); | ||
78 | if (ACPI_SUCCESS(status)) | ||
79 | break; | ||
80 | default: | ||
81 | if (ACPI_FAILURE(status)) { | ||
82 | dbg("%s:%s _HPP fail=0x%x\n", __FUNCTION__, | ||
83 | path_name, status); | ||
84 | return status; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | ext_obj = (union acpi_object *) ret_buf.pointer; | ||
89 | if (ext_obj->type != ACPI_TYPE_PACKAGE) { | ||
90 | err ("%s:%s _HPP obj not a package\n", __FUNCTION__, | ||
91 | path_name); | ||
92 | status = AE_ERROR; | ||
93 | goto free_and_return; | ||
94 | } | ||
95 | |||
96 | len = ext_obj->package.count; | ||
97 | package = (union acpi_object *) ret_buf.pointer; | ||
98 | for ( i = 0; (i < len) || (i < 4); i++) { | ||
99 | ext_obj = (union acpi_object *) &package->package.elements[i]; | ||
100 | switch (ext_obj->type) { | ||
101 | case ACPI_TYPE_INTEGER: | ||
102 | nui[i] = (u8)ext_obj->integer.value; | ||
103 | break; | ||
104 | default: | ||
105 | err ("%s:%s _HPP obj type incorrect\n", __FUNCTION__, | ||
106 | path_name); | ||
107 | status = AE_ERROR; | ||
108 | goto free_and_return; | ||
109 | } | ||
110 | } | ||
111 | |||
112 | hpp->cache_line_size = nui[0]; | ||
113 | hpp->latency_timer = nui[1]; | ||
114 | hpp->enable_serr = nui[2]; | ||
115 | hpp->enable_perr = nui[3]; | ||
116 | |||
117 | dbg(" _HPP: cache_line_size=0x%x\n", hpp->cache_line_size); | ||
118 | dbg(" _HPP: latency timer =0x%x\n", hpp->latency_timer); | ||
119 | dbg(" _HPP: enable SERR =0x%x\n", hpp->enable_serr); | ||
120 | dbg(" _HPP: enable PERR =0x%x\n", hpp->enable_perr); | ||
121 | |||
122 | free_and_return: | ||
123 | kfree(ret_buf.pointer); | ||
124 | return status; | ||
125 | } | ||
126 | |||
127 | static acpi_status acpi_run_oshp(acpi_handle handle) | ||
128 | { | ||
129 | acpi_status status; | ||
130 | u8 *path_name = acpi_path_name(handle); | ||
131 | |||
132 | /* run OSHP */ | ||
133 | status = acpi_evaluate_object(handle, METHOD_NAME_OSHP, NULL, NULL); | ||
134 | if (ACPI_FAILURE(status)) { | ||
135 | dbg("%s:%s OSHP fails=0x%x\n", __FUNCTION__, path_name, | ||
136 | status); | ||
137 | } else { | ||
138 | dbg("%s:%s OSHP passes\n", __FUNCTION__, path_name); | ||
139 | } | ||
140 | return status; | ||
141 | } | ||
142 | |||
143 | static int is_root_bridge(acpi_handle handle) | ||
144 | { | ||
145 | acpi_status status; | ||
146 | struct acpi_device_info *info; | ||
147 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
148 | int i; | ||
149 | |||
150 | status = acpi_get_object_info(handle, &buffer); | ||
151 | if (ACPI_SUCCESS(status)) { | ||
152 | info = buffer.pointer; | ||
153 | if ((info->valid & ACPI_VALID_HID) && | ||
154 | !strcmp(PCI_ROOT_HID_STRING, | ||
155 | info->hardware_id.value)) { | ||
156 | acpi_os_free(buffer.pointer); | ||
157 | return 1; | ||
158 | } | ||
159 | if (info->valid & ACPI_VALID_CID) { | ||
160 | for (i=0; i < info->compatibility_id.count; i++) { | ||
161 | if (!strcmp(PCI_ROOT_HID_STRING, | ||
162 | info->compatibility_id.id[i].value)) { | ||
163 | acpi_os_free(buffer.pointer); | ||
164 | return 1; | ||
165 | } | ||
166 | } | ||
167 | } | ||
168 | } | ||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev) | ||
173 | { | ||
174 | acpi_status status; | ||
175 | acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev)); | ||
176 | struct pci_dev *pdev = dev; | ||
177 | struct pci_bus *parent; | ||
178 | u8 *path_name; | ||
179 | |||
180 | /* | ||
181 | * Per PCI firmware specification, we should run the ACPI _OSC | ||
182 | * method to get control of hotplug hardware before using it. | ||
183 | * If an _OSC is missing, we look for an OSHP to do the same thing. | ||
184 | * To handle different BIOS behavior, we look for _OSC and OSHP | ||
185 | * within the scope of the hotplug controller and its parents, upto | ||
186 | * the host bridge under which this controller exists. | ||
187 | */ | ||
188 | while (!handle) { | ||
189 | /* | ||
190 | * This hotplug controller was not listed in the ACPI name | ||
191 | * space at all. Try to get acpi handle of parent pci bus. | ||
192 | */ | ||
193 | if (!pdev || !pdev->bus->parent) | ||
194 | break; | ||
195 | parent = pdev->bus->parent; | ||
196 | dbg("Could not find %s in acpi namespace, trying parent\n", | ||
197 | pci_name(pdev)); | ||
198 | if (!parent->self) | ||
199 | /* Parent must be a host bridge */ | ||
200 | handle = acpi_get_pci_rootbridge_handle( | ||
201 | pci_domain_nr(parent), | ||
202 | parent->number); | ||
203 | else | ||
204 | handle = DEVICE_ACPI_HANDLE( | ||
205 | &(parent->self->dev)); | ||
206 | pdev = parent->self; | ||
207 | } | ||
208 | |||
209 | while (handle) { | ||
210 | path_name = acpi_path_name(handle); | ||
211 | dbg("Trying to get hotplug control for %s \n", path_name); | ||
212 | status = pci_osc_control_set(handle, | ||
213 | OSC_PCI_EXPRESS_NATIVE_HP_CONTROL); | ||
214 | if (status == AE_NOT_FOUND) | ||
215 | status = acpi_run_oshp(handle); | ||
216 | if (ACPI_SUCCESS(status)) { | ||
217 | dbg("Gained control for hotplug HW for pci %s (%s)\n", | ||
218 | pci_name(dev), path_name); | ||
219 | return 0; | ||
220 | } | ||
221 | if (is_root_bridge(handle)) | ||
222 | break; | ||
223 | chandle = handle; | ||
224 | status = acpi_get_parent(chandle, &handle); | ||
225 | if (ACPI_FAILURE(status)) | ||
226 | break; | ||
227 | } | ||
228 | |||
229 | err("Cannot get control of hotplug hardware for pci %s\n", | ||
230 | pci_name(dev)); | ||
231 | return -1; | ||
232 | } | ||
233 | |||
234 | void pciehp_get_hp_params_from_firmware(struct pci_dev *dev, | ||
235 | struct hotplug_params *hpp) | ||
236 | { | ||
237 | acpi_status status = AE_NOT_FOUND; | ||
238 | struct pci_dev *pdev = dev; | ||
239 | |||
240 | /* | ||
241 | * _HPP settings apply to all child buses, until another _HPP is | ||
242 | * encountered. If we don't find an _HPP for the input pci dev, | ||
243 | * look for it in the parent device scope since that would apply to | ||
244 | * this pci dev. If we don't find any _HPP, use hardcoded defaults | ||
245 | */ | ||
246 | while (pdev && (ACPI_FAILURE(status))) { | ||
247 | acpi_handle handle = DEVICE_ACPI_HANDLE(&(pdev->dev)); | ||
248 | if (!handle) | ||
249 | break; | ||
250 | status = acpi_run_hpp(handle, hpp); | ||
251 | if (!(pdev->bus->parent)) | ||
252 | break; | ||
253 | /* Check if a parent object supports _HPP */ | ||
254 | pdev = pdev->bus->parent->self; | ||
255 | } | ||
256 | } | ||
257 | |||
diff --git a/drivers/pci/hotplug/pciehprm_nonacpi.c b/drivers/pci/hotplug/pciehprm_nonacpi.c deleted file mode 100644 index 29180dfe8493..000000000000 --- a/drivers/pci/hotplug/pciehprm_nonacpi.c +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /* | ||
2 | * PCIEHPRM NONACPI: PHP Resource Manager for Non-ACPI/Legacy platform | ||
3 | * | ||
4 | * Copyright (C) 1995,2001 Compaq Computer Corporation | ||
5 | * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com) | ||
6 | * Copyright (C) 2001 IBM Corp. | ||
7 | * Copyright (C) 2003-2004 Intel Corporation | ||
8 | * | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> | ||
27 | * | ||
28 | */ | ||
29 | |||
30 | #include <linux/module.h> | ||
31 | #include <linux/kernel.h> | ||
32 | #include <linux/types.h> | ||
33 | #include <linux/sched.h> | ||
34 | #include <linux/pci.h> | ||
35 | #include <linux/slab.h> | ||
36 | #include "pciehp.h" | ||
37 | |||
38 | void pciehp_get_hp_params_from_firmware(struct pci_dev *dev, | ||
39 | struct hotplug_params *hpp) | ||
40 | { | ||
41 | return; | ||
42 | } | ||
43 | |||
44 | int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev) | ||
45 | { | ||
46 | return 0; | ||
47 | } | ||
diff --git a/drivers/pci/hotplug/pcihp_skeleton.c b/drivers/pci/hotplug/pcihp_skeleton.c index 3194d51c6ec9..0a46f549676a 100644 --- a/drivers/pci/hotplug/pcihp_skeleton.c +++ b/drivers/pci/hotplug/pcihp_skeleton.c | |||
@@ -37,10 +37,12 @@ | |||
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include "pci_hotplug.h" | 38 | #include "pci_hotplug.h" |
39 | 39 | ||
40 | #define SLOT_NAME_SIZE 10 | ||
40 | struct slot { | 41 | struct slot { |
41 | u8 number; | 42 | u8 number; |
42 | struct hotplug_slot *hotplug_slot; | 43 | struct hotplug_slot *hotplug_slot; |
43 | struct list_head slot_list; | 44 | struct list_head slot_list; |
45 | char name[SLOT_NAME_SIZE]; | ||
44 | }; | 46 | }; |
45 | 47 | ||
46 | static LIST_HEAD(slot_list); | 48 | static LIST_HEAD(slot_list); |
@@ -233,12 +235,10 @@ static void release_slot(struct hotplug_slot *hotplug_slot) | |||
233 | 235 | ||
234 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 236 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
235 | kfree(slot->hotplug_slot->info); | 237 | kfree(slot->hotplug_slot->info); |
236 | kfree(slot->hotplug_slot->name); | ||
237 | kfree(slot->hotplug_slot); | 238 | kfree(slot->hotplug_slot); |
238 | kfree(slot); | 239 | kfree(slot); |
239 | } | 240 | } |
240 | 241 | ||
241 | #define SLOT_NAME_SIZE 10 | ||
242 | static void make_slot_name(struct slot *slot) | 242 | static void make_slot_name(struct slot *slot) |
243 | { | 243 | { |
244 | /* | 244 | /* |
@@ -257,7 +257,6 @@ static int __init init_slots(void) | |||
257 | struct slot *slot; | 257 | struct slot *slot; |
258 | struct hotplug_slot *hotplug_slot; | 258 | struct hotplug_slot *hotplug_slot; |
259 | struct hotplug_slot_info *info; | 259 | struct hotplug_slot_info *info; |
260 | char *name; | ||
261 | int retval = -ENOMEM; | 260 | int retval = -ENOMEM; |
262 | int i; | 261 | int i; |
263 | 262 | ||
@@ -266,31 +265,23 @@ static int __init init_slots(void) | |||
266 | * with the pci_hotplug subsystem. | 265 | * with the pci_hotplug subsystem. |
267 | */ | 266 | */ |
268 | for (i = 0; i < num_slots; ++i) { | 267 | for (i = 0; i < num_slots; ++i) { |
269 | slot = kmalloc(sizeof(struct slot), GFP_KERNEL); | 268 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); |
270 | if (!slot) | 269 | if (!slot) |
271 | goto error; | 270 | goto error; |
272 | memset(slot, 0, sizeof(struct slot)); | ||
273 | 271 | ||
274 | hotplug_slot = kmalloc(sizeof(struct hotplug_slot), | 272 | hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL); |
275 | GFP_KERNEL); | ||
276 | if (!hotplug_slot) | 273 | if (!hotplug_slot) |
277 | goto error_slot; | 274 | goto error_slot; |
278 | memset(hotplug_slot, 0, sizeof (struct hotplug_slot)); | ||
279 | slot->hotplug_slot = hotplug_slot; | 275 | slot->hotplug_slot = hotplug_slot; |
280 | 276 | ||
281 | info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); | 277 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
282 | if (!info) | 278 | if (!info) |
283 | goto error_hpslot; | 279 | goto error_hpslot; |
284 | memset(info, 0, sizeof (struct hotplug_slot_info)); | ||
285 | hotplug_slot->info = info; | 280 | hotplug_slot->info = info; |
286 | 281 | ||
287 | name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); | ||
288 | if (!name) | ||
289 | goto error_info; | ||
290 | hotplug_slot->name = name; | ||
291 | |||
292 | slot->number = i; | 282 | slot->number = i; |
293 | 283 | ||
284 | hotplug_slot->name = slot->name; | ||
294 | hotplug_slot->private = slot; | 285 | hotplug_slot->private = slot; |
295 | hotplug_slot->release = &release_slot; | 286 | hotplug_slot->release = &release_slot; |
296 | make_slot_name(slot); | 287 | make_slot_name(slot); |
@@ -300,16 +291,16 @@ static int __init init_slots(void) | |||
300 | * Initialize the slot info structure with some known | 291 | * Initialize the slot info structure with some known |
301 | * good values. | 292 | * good values. |
302 | */ | 293 | */ |
303 | info->power_status = get_power_status(slot); | 294 | get_power_status(hotplug_slot, &info->power_status); |
304 | info->attention_status = get_attention_status(slot); | 295 | get_attention_status(hotplug_slot, &info->attention_status); |
305 | info->latch_status = get_latch_status(slot); | 296 | get_latch_status(hotplug_slot, &info->latch_status); |
306 | info->adapter_status = get_adapter_status(slot); | 297 | get_adapter_status(hotplug_slot, &info->adapter_status); |
307 | 298 | ||
308 | dbg("registering slot %d\n", i); | 299 | dbg("registering slot %d\n", i); |
309 | retval = pci_hp_register(slot->hotplug_slot); | 300 | retval = pci_hp_register(slot->hotplug_slot); |
310 | if (retval) { | 301 | if (retval) { |
311 | err("pci_hp_register failed with error %d\n", retval); | 302 | err("pci_hp_register failed with error %d\n", retval); |
312 | goto error_name; | 303 | goto error_info; |
313 | } | 304 | } |
314 | 305 | ||
315 | /* add slot to our internal list */ | 306 | /* add slot to our internal list */ |
@@ -317,8 +308,6 @@ static int __init init_slots(void) | |||
317 | } | 308 | } |
318 | 309 | ||
319 | return 0; | 310 | return 0; |
320 | error_name: | ||
321 | kfree(name); | ||
322 | error_info: | 311 | error_info: |
323 | kfree(info); | 312 | kfree(info); |
324 | error_hpslot: | 313 | error_hpslot: |
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c index 78943e064b59..b771196a654e 100644 --- a/drivers/pci/hotplug/rpaphp_slot.c +++ b/drivers/pci/hotplug/rpaphp_slot.c | |||
@@ -84,19 +84,16 @@ struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_ | |||
84 | { | 84 | { |
85 | struct slot *slot; | 85 | struct slot *slot; |
86 | 86 | ||
87 | slot = kmalloc(sizeof (struct slot), GFP_KERNEL); | 87 | slot = kzalloc(sizeof(struct slot), GFP_KERNEL); |
88 | if (!slot) | 88 | if (!slot) |
89 | goto error_nomem; | 89 | goto error_nomem; |
90 | memset(slot, 0, sizeof (struct slot)); | 90 | slot->hotplug_slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL); |
91 | slot->hotplug_slot = kmalloc(sizeof (struct hotplug_slot), GFP_KERNEL); | ||
92 | if (!slot->hotplug_slot) | 91 | if (!slot->hotplug_slot) |
93 | goto error_slot; | 92 | goto error_slot; |
94 | memset(slot->hotplug_slot, 0, sizeof (struct hotplug_slot)); | 93 | slot->hotplug_slot->info = kzalloc(sizeof(struct hotplug_slot_info), |
95 | slot->hotplug_slot->info = kmalloc(sizeof (struct hotplug_slot_info), | ||
96 | GFP_KERNEL); | 94 | GFP_KERNEL); |
97 | if (!slot->hotplug_slot->info) | 95 | if (!slot->hotplug_slot->info) |
98 | goto error_hpslot; | 96 | goto error_hpslot; |
99 | memset(slot->hotplug_slot->info, 0, sizeof (struct hotplug_slot_info)); | ||
100 | slot->hotplug_slot->name = kmalloc(BUS_ID_SIZE + 1, GFP_KERNEL); | 97 | slot->hotplug_slot->name = kmalloc(BUS_ID_SIZE + 1, GFP_KERNEL); |
101 | if (!slot->hotplug_slot->name) | 98 | if (!slot->hotplug_slot->name) |
102 | goto error_info; | 99 | goto error_info; |
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c index a32ae82e5922..c402da8e78ae 100644 --- a/drivers/pci/hotplug/sgi_hotplug.c +++ b/drivers/pci/hotplug/sgi_hotplug.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * License. See the file "COPYING" in the main directory of this archive | 3 | * License. See the file "COPYING" in the main directory of this archive |
4 | * for more details. | 4 | * for more details. |
5 | * | 5 | * |
6 | * Copyright (C) 2005 Silicon Graphics, Inc. All rights reserved. | 6 | * Copyright (C) 2005-2006 Silicon Graphics, Inc. All rights reserved. |
7 | * | 7 | * |
8 | * This work was based on the 2.4/2.6 kernel development by Dick Reigner. | 8 | * This work was based on the 2.4/2.6 kernel development by Dick Reigner. |
9 | * Work to add BIOS PROM support was completed by Mike Habeck. | 9 | * Work to add BIOS PROM support was completed by Mike Habeck. |
@@ -230,6 +230,13 @@ static void sn_bus_free_data(struct pci_dev *dev) | |||
230 | list_for_each_entry(child, &subordinate_bus->devices, bus_list) | 230 | list_for_each_entry(child, &subordinate_bus->devices, bus_list) |
231 | sn_bus_free_data(child); | 231 | sn_bus_free_data(child); |
232 | } | 232 | } |
233 | /* | ||
234 | * Some drivers may use dma accesses during the | ||
235 | * driver remove function. We release the sysdata | ||
236 | * areas after the driver remove functions have | ||
237 | * been called. | ||
238 | */ | ||
239 | sn_bus_store_sysdata(dev); | ||
233 | sn_pci_unfixup_slot(dev); | 240 | sn_pci_unfixup_slot(dev); |
234 | } | 241 | } |
235 | 242 | ||
@@ -429,13 +436,6 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
429 | PCI_DEVFN(slot->device_num + 1, | 436 | PCI_DEVFN(slot->device_num + 1, |
430 | PCI_FUNC(func))); | 437 | PCI_FUNC(func))); |
431 | if (dev) { | 438 | if (dev) { |
432 | /* | ||
433 | * Some drivers may use dma accesses during the | ||
434 | * driver remove function. We release the sysdata | ||
435 | * areas after the driver remove functions have | ||
436 | * been called. | ||
437 | */ | ||
438 | sn_bus_store_sysdata(dev); | ||
439 | sn_bus_free_data(dev); | 439 | sn_bus_free_data(dev); |
440 | pci_remove_bus_device(dev); | 440 | pci_remove_bus_device(dev); |
441 | pci_dev_put(dev); | 441 | pci_dev_put(dev); |
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h index 7d6f521d02ea..5c70f43908c4 100644 --- a/drivers/pci/hotplug/shpchp.h +++ b/drivers/pci/hotplug/shpchp.h | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/pci.h> | 33 | #include <linux/pci.h> |
34 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
35 | #include <linux/sched.h> /* signal_pending(), struct timer_list */ | 35 | #include <linux/sched.h> /* signal_pending(), struct timer_list */ |
36 | #include <linux/mutex.h> | ||
36 | 37 | ||
37 | #include "pci_hotplug.h" | 38 | #include "pci_hotplug.h" |
38 | 39 | ||
@@ -45,6 +46,7 @@ | |||
45 | extern int shpchp_poll_mode; | 46 | extern int shpchp_poll_mode; |
46 | extern int shpchp_poll_time; | 47 | extern int shpchp_poll_time; |
47 | extern int shpchp_debug; | 48 | extern int shpchp_debug; |
49 | extern struct workqueue_struct *shpchp_wq; | ||
48 | 50 | ||
49 | /*#define dbg(format, arg...) do { if (shpchp_debug) printk(KERN_DEBUG "%s: " format, MY_NAME , ## arg); } while (0)*/ | 51 | /*#define dbg(format, arg...) do { if (shpchp_debug) printk(KERN_DEBUG "%s: " format, MY_NAME , ## arg); } while (0)*/ |
50 | #define dbg(format, arg...) do { if (shpchp_debug) printk("%s: " format, MY_NAME , ## arg); } while (0) | 52 | #define dbg(format, arg...) do { if (shpchp_debug) printk("%s: " format, MY_NAME , ## arg); } while (0) |
@@ -52,10 +54,8 @@ extern int shpchp_debug; | |||
52 | #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) | 54 | #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) |
53 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) | 55 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) |
54 | 56 | ||
55 | #define SLOT_MAGIC 0x67267321 | 57 | #define SLOT_NAME_SIZE 10 |
56 | struct slot { | 58 | struct slot { |
57 | u32 magic; | ||
58 | struct slot *next; | ||
59 | u8 bus; | 59 | u8 bus; |
60 | u8 device; | 60 | u8 device; |
61 | u16 status; | 61 | u16 status; |
@@ -70,26 +70,27 @@ struct slot { | |||
70 | struct hpc_ops *hpc_ops; | 70 | struct hpc_ops *hpc_ops; |
71 | struct hotplug_slot *hotplug_slot; | 71 | struct hotplug_slot *hotplug_slot; |
72 | struct list_head slot_list; | 72 | struct list_head slot_list; |
73 | char name[SLOT_NAME_SIZE]; | ||
74 | struct work_struct work; /* work for button event */ | ||
75 | struct mutex lock; | ||
73 | }; | 76 | }; |
74 | 77 | ||
75 | struct event_info { | 78 | struct event_info { |
76 | u32 event_type; | 79 | u32 event_type; |
77 | u8 hp_slot; | 80 | struct slot *p_slot; |
81 | struct work_struct work; | ||
78 | }; | 82 | }; |
79 | 83 | ||
80 | struct controller { | 84 | struct controller { |
81 | struct controller *next; | 85 | struct mutex crit_sect; /* critical section mutex */ |
82 | struct semaphore crit_sect; /* critical section semaphore */ | 86 | struct mutex cmd_lock; /* command lock */ |
83 | struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */ | 87 | struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */ |
84 | int num_slots; /* Number of slots on ctlr */ | 88 | int num_slots; /* Number of slots on ctlr */ |
85 | int slot_num_inc; /* 1 or -1 */ | 89 | int slot_num_inc; /* 1 or -1 */ |
86 | struct pci_dev *pci_dev; | 90 | struct pci_dev *pci_dev; |
87 | struct pci_bus *pci_bus; | 91 | struct list_head slot_list; |
88 | struct event_info event_queue[10]; | ||
89 | struct slot *slot; | ||
90 | struct hpc_ops *hpc_ops; | 92 | struct hpc_ops *hpc_ops; |
91 | wait_queue_head_t queue; /* sleep & wake process */ | 93 | wait_queue_head_t queue; /* sleep & wake process */ |
92 | u8 next_event; | ||
93 | u8 bus; | 94 | u8 bus; |
94 | u8 device; | 95 | u8 device; |
95 | u8 function; | 96 | u8 function; |
@@ -105,12 +106,6 @@ struct controller { | |||
105 | volatile int cmd_busy; | 106 | volatile int cmd_busy; |
106 | }; | 107 | }; |
107 | 108 | ||
108 | struct hotplug_params { | ||
109 | u8 cache_line_size; | ||
110 | u8 latency_timer; | ||
111 | u8 enable_serr; | ||
112 | u8 enable_perr; | ||
113 | }; | ||
114 | 109 | ||
115 | /* Define AMD SHPC ID */ | 110 | /* Define AMD SHPC ID */ |
116 | #define PCI_DEVICE_ID_AMD_GOLAM_7450 0x7450 | 111 | #define PCI_DEVICE_ID_AMD_GOLAM_7450 0x7450 |
@@ -180,11 +175,8 @@ struct hotplug_params { | |||
180 | /* sysfs functions for the hotplug controller info */ | 175 | /* sysfs functions for the hotplug controller info */ |
181 | extern void shpchp_create_ctrl_files (struct controller *ctrl); | 176 | extern void shpchp_create_ctrl_files (struct controller *ctrl); |
182 | 177 | ||
183 | /* controller functions */ | 178 | extern int shpchp_sysfs_enable_slot(struct slot *slot); |
184 | extern int shpchp_event_start_thread(void); | 179 | extern int shpchp_sysfs_disable_slot(struct slot *slot); |
185 | extern void shpchp_event_stop_thread(void); | ||
186 | extern int shpchp_enable_slot(struct slot *slot); | ||
187 | extern int shpchp_disable_slot(struct slot *slot); | ||
188 | 180 | ||
189 | extern u8 shpchp_handle_attention_button(u8 hp_slot, void *inst_id); | 181 | extern u8 shpchp_handle_attention_button(u8 hp_slot, void *inst_id); |
190 | extern u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id); | 182 | extern u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id); |
@@ -195,16 +187,28 @@ extern u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id); | |||
195 | extern int shpchp_save_config(struct controller *ctrl, int busnumber, int num_ctlr_slots, int first_device_num); | 187 | extern int shpchp_save_config(struct controller *ctrl, int busnumber, int num_ctlr_slots, int first_device_num); |
196 | extern int shpchp_configure_device(struct slot *p_slot); | 188 | extern int shpchp_configure_device(struct slot *p_slot); |
197 | extern int shpchp_unconfigure_device(struct slot *p_slot); | 189 | extern int shpchp_unconfigure_device(struct slot *p_slot); |
198 | extern void get_hp_hw_control_from_firmware(struct pci_dev *dev); | ||
199 | extern void get_hp_params_from_firmware(struct pci_dev *dev, | ||
200 | struct hotplug_params *hpp); | ||
201 | extern int shpchprm_get_physical_slot_number(struct controller *ctrl, | ||
202 | u32 *sun, u8 busnum, u8 devnum); | ||
203 | extern void shpchp_remove_ctrl_files(struct controller *ctrl); | 190 | extern void shpchp_remove_ctrl_files(struct controller *ctrl); |
191 | extern void cleanup_slots(struct controller *ctrl); | ||
192 | extern void queue_pushbutton_work(void *data); | ||
204 | 193 | ||
205 | 194 | ||
206 | /* Global variables */ | 195 | #ifdef CONFIG_ACPI |
207 | extern struct controller *shpchp_ctrl_list; | 196 | static inline int get_hp_params_from_firmware(struct pci_dev *dev, |
197 | struct hotplug_params *hpp) | ||
198 | { | ||
199 | if (ACPI_FAILURE(acpi_get_hp_params_from_firmware(dev, hpp))) | ||
200 | return -ENODEV; | ||
201 | return 0; | ||
202 | } | ||
203 | #define get_hp_hw_control_from_firmware(pdev) \ | ||
204 | do { \ | ||
205 | if (DEVICE_ACPI_HANDLE(&(pdev->dev))) \ | ||
206 | acpi_run_oshp(DEVICE_ACPI_HANDLE(&(pdev->dev))); \ | ||
207 | } while (0) | ||
208 | #else | ||
209 | #define get_hp_params_from_firmware(dev, hpp) (-ENODEV) | ||
210 | #define get_hp_hw_control_from_firmware(dev) do { } while (0) | ||
211 | #endif | ||
208 | 212 | ||
209 | struct ctrl_reg { | 213 | struct ctrl_reg { |
210 | volatile u32 base_offset; | 214 | volatile u32 base_offset; |
@@ -286,10 +290,6 @@ static inline int slot_paranoia_check (struct slot *slot, const char *function) | |||
286 | dbg("%s - slot == NULL", function); | 290 | dbg("%s - slot == NULL", function); |
287 | return -1; | 291 | return -1; |
288 | } | 292 | } |
289 | if (slot->magic != SLOT_MAGIC) { | ||
290 | dbg("%s - bad magic number for slot", function); | ||
291 | return -1; | ||
292 | } | ||
293 | if (!slot->hotplug_slot) { | 293 | if (!slot->hotplug_slot) { |
294 | dbg("%s - slot->hotplug_slot == NULL!", function); | 294 | dbg("%s - slot->hotplug_slot == NULL!", function); |
295 | return -1; | 295 | return -1; |
@@ -314,44 +314,19 @@ static inline struct slot *get_slot (struct hotplug_slot *hotplug_slot, const ch | |||
314 | 314 | ||
315 | static inline struct slot *shpchp_find_slot (struct controller *ctrl, u8 device) | 315 | static inline struct slot *shpchp_find_slot (struct controller *ctrl, u8 device) |
316 | { | 316 | { |
317 | struct slot *p_slot, *tmp_slot = NULL; | 317 | struct slot *slot; |
318 | 318 | ||
319 | if (!ctrl) | 319 | if (!ctrl) |
320 | return NULL; | 320 | return NULL; |
321 | 321 | ||
322 | p_slot = ctrl->slot; | 322 | list_for_each_entry(slot, &ctrl->slot_list, slot_list) { |
323 | 323 | if (slot->device == device) | |
324 | while (p_slot && (p_slot->device != device)) { | 324 | return slot; |
325 | tmp_slot = p_slot; | ||
326 | p_slot = p_slot->next; | ||
327 | } | 325 | } |
328 | if (p_slot == NULL) { | ||
329 | err("ERROR: shpchp_find_slot device=0x%x\n", device); | ||
330 | p_slot = tmp_slot; | ||
331 | } | ||
332 | |||
333 | return (p_slot); | ||
334 | } | ||
335 | |||
336 | static inline int wait_for_ctrl_irq (struct controller *ctrl) | ||
337 | { | ||
338 | DECLARE_WAITQUEUE(wait, current); | ||
339 | int retval = 0; | ||
340 | |||
341 | add_wait_queue(&ctrl->queue, &wait); | ||
342 | 326 | ||
343 | if (!shpchp_poll_mode) { | 327 | err("%s: slot (device=0x%x) not found\n", __FUNCTION__, device); |
344 | /* Sleep for up to 1 second */ | ||
345 | msleep_interruptible(1000); | ||
346 | } else { | ||
347 | /* Sleep for up to 2 seconds */ | ||
348 | msleep_interruptible(2000); | ||
349 | } | ||
350 | remove_wait_queue(&ctrl->queue, &wait); | ||
351 | if (signal_pending(current)) | ||
352 | retval = -EINTR; | ||
353 | 328 | ||
354 | return retval; | 329 | return NULL; |
355 | } | 330 | } |
356 | 331 | ||
357 | static inline void amd_pogo_errata_save_misc_reg(struct slot *p_slot) | 332 | static inline void amd_pogo_errata_save_misc_reg(struct slot *p_slot) |
@@ -427,13 +402,6 @@ static inline void amd_pogo_errata_restore_misc_reg(struct slot *p_slot) | |||
427 | pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, pcix_misc2_temp); | 402 | pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, pcix_misc2_temp); |
428 | } | 403 | } |
429 | 404 | ||
430 | #define SLOT_NAME_SIZE 10 | ||
431 | |||
432 | static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot) | ||
433 | { | ||
434 | snprintf(buffer, buffer_size, "%04d_%04d", slot->bus, slot->number); | ||
435 | } | ||
436 | |||
437 | enum php_ctlr_type { | 405 | enum php_ctlr_type { |
438 | PCI, | 406 | PCI, |
439 | ISA, | 407 | ISA, |
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c index a2b3f0010cec..3be4d492ccc2 100644 --- a/drivers/pci/hotplug/shpchp_core.c +++ b/drivers/pci/hotplug/shpchp_core.c | |||
@@ -32,13 +32,14 @@ | |||
32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
33 | #include <linux/types.h> | 33 | #include <linux/types.h> |
34 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
35 | #include <linux/workqueue.h> | ||
35 | #include "shpchp.h" | 36 | #include "shpchp.h" |
36 | 37 | ||
37 | /* Global variables */ | 38 | /* Global variables */ |
38 | int shpchp_debug; | 39 | int shpchp_debug; |
39 | int shpchp_poll_mode; | 40 | int shpchp_poll_mode; |
40 | int shpchp_poll_time; | 41 | int shpchp_poll_time; |
41 | struct controller *shpchp_ctrl_list; /* = NULL */ | 42 | struct workqueue_struct *shpchp_wq; |
42 | 43 | ||
43 | #define DRIVER_VERSION "0.4" | 44 | #define DRIVER_VERSION "0.4" |
44 | #define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>" | 45 | #define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>" |
@@ -57,7 +58,6 @@ MODULE_PARM_DESC(shpchp_poll_time, "Polling mechanism frequency, in seconds"); | |||
57 | 58 | ||
58 | #define SHPC_MODULE_NAME "shpchp" | 59 | #define SHPC_MODULE_NAME "shpchp" |
59 | 60 | ||
60 | static int shpc_start_thread (void); | ||
61 | static int set_attention_status (struct hotplug_slot *slot, u8 value); | 61 | static int set_attention_status (struct hotplug_slot *slot, u8 value); |
62 | static int enable_slot (struct hotplug_slot *slot); | 62 | static int enable_slot (struct hotplug_slot *slot); |
63 | static int disable_slot (struct hotplug_slot *slot); | 63 | static int disable_slot (struct hotplug_slot *slot); |
@@ -94,107 +94,120 @@ static void release_slot(struct hotplug_slot *hotplug_slot) | |||
94 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 94 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
95 | 95 | ||
96 | kfree(slot->hotplug_slot->info); | 96 | kfree(slot->hotplug_slot->info); |
97 | kfree(slot->hotplug_slot->name); | ||
98 | kfree(slot->hotplug_slot); | 97 | kfree(slot->hotplug_slot); |
99 | kfree(slot); | 98 | kfree(slot); |
100 | } | 99 | } |
101 | 100 | ||
101 | static void make_slot_name(struct slot *slot) | ||
102 | { | ||
103 | snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%04d_%04d", | ||
104 | slot->bus, slot->number); | ||
105 | } | ||
106 | |||
107 | |||
108 | |||
109 | |||
110 | static int | ||
111 | shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, | ||
112 | u8 busnum, u8 devnum) | ||
113 | { | ||
114 | int offset = devnum - ctrl->slot_device_offset; | ||
115 | |||
116 | dbg("%s: ctrl->slot_num_inc %d, offset %d\n", __FUNCTION__, | ||
117 | ctrl->slot_num_inc, offset); | ||
118 | *sun = (u8) (ctrl->first_slot + ctrl->slot_num_inc *offset); | ||
119 | return 0; | ||
120 | } | ||
121 | |||
122 | |||
123 | |||
102 | static int init_slots(struct controller *ctrl) | 124 | static int init_slots(struct controller *ctrl) |
103 | { | 125 | { |
104 | struct slot *new_slot; | 126 | struct slot *slot; |
105 | u8 number_of_slots; | 127 | struct hotplug_slot *hotplug_slot; |
106 | u8 slot_device; | 128 | struct hotplug_slot_info *info; |
107 | u32 slot_number, sun; | 129 | int retval = -ENOMEM; |
108 | int result = -ENOMEM; | 130 | int i; |
109 | 131 | u32 sun; | |
110 | number_of_slots = ctrl->num_slots; | 132 | |
111 | slot_device = ctrl->slot_device_offset; | 133 | for (i = 0; i < ctrl->num_slots; i++) { |
112 | slot_number = ctrl->first_slot; | 134 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); |
113 | 135 | if (!slot) | |
114 | while (number_of_slots) { | ||
115 | new_slot = (struct slot *) kmalloc(sizeof(struct slot), GFP_KERNEL); | ||
116 | if (!new_slot) | ||
117 | goto error; | 136 | goto error; |
118 | 137 | ||
119 | memset(new_slot, 0, sizeof(struct slot)); | 138 | hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL); |
120 | new_slot->hotplug_slot = kmalloc (sizeof (struct hotplug_slot), GFP_KERNEL); | 139 | if (!hotplug_slot) |
121 | if (!new_slot->hotplug_slot) | ||
122 | goto error_slot; | 140 | goto error_slot; |
123 | memset(new_slot->hotplug_slot, 0, sizeof (struct hotplug_slot)); | 141 | slot->hotplug_slot = hotplug_slot; |
124 | 142 | ||
125 | new_slot->hotplug_slot->info = kmalloc (sizeof (struct hotplug_slot_info), GFP_KERNEL); | 143 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
126 | if (!new_slot->hotplug_slot->info) | 144 | if (!info) |
127 | goto error_hpslot; | 145 | goto error_hpslot; |
128 | memset(new_slot->hotplug_slot->info, 0, sizeof (struct hotplug_slot_info)); | 146 | hotplug_slot->info = info; |
129 | new_slot->hotplug_slot->name = kmalloc (SLOT_NAME_SIZE, GFP_KERNEL); | 147 | |
130 | if (!new_slot->hotplug_slot->name) | 148 | hotplug_slot->name = slot->name; |
131 | goto error_info; | ||
132 | 149 | ||
133 | new_slot->magic = SLOT_MAGIC; | 150 | slot->hp_slot = i; |
134 | new_slot->ctrl = ctrl; | 151 | slot->ctrl = ctrl; |
135 | new_slot->bus = ctrl->slot_bus; | 152 | slot->bus = ctrl->slot_bus; |
136 | new_slot->device = slot_device; | 153 | slot->device = ctrl->slot_device_offset + i; |
137 | new_slot->hpc_ops = ctrl->hpc_ops; | 154 | slot->hpc_ops = ctrl->hpc_ops; |
155 | mutex_init(&slot->lock); | ||
138 | 156 | ||
139 | if (shpchprm_get_physical_slot_number(ctrl, &sun, | 157 | if (shpchprm_get_physical_slot_number(ctrl, &sun, |
140 | new_slot->bus, new_slot->device)) | 158 | slot->bus, slot->device)) |
141 | goto error_name; | 159 | goto error_info; |
142 | 160 | ||
143 | new_slot->number = sun; | 161 | slot->number = sun; |
144 | new_slot->hp_slot = slot_device - ctrl->slot_device_offset; | 162 | INIT_WORK(&slot->work, queue_pushbutton_work, slot); |
145 | 163 | ||
146 | /* register this slot with the hotplug pci core */ | 164 | /* register this slot with the hotplug pci core */ |
147 | new_slot->hotplug_slot->private = new_slot; | 165 | hotplug_slot->private = slot; |
148 | new_slot->hotplug_slot->release = &release_slot; | 166 | hotplug_slot->release = &release_slot; |
149 | make_slot_name(new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot); | 167 | make_slot_name(slot); |
150 | new_slot->hotplug_slot->ops = &shpchp_hotplug_slot_ops; | 168 | hotplug_slot->ops = &shpchp_hotplug_slot_ops; |
151 | 169 | ||
152 | new_slot->hpc_ops->get_power_status(new_slot, &(new_slot->hotplug_slot->info->power_status)); | 170 | get_power_status(hotplug_slot, &info->power_status); |
153 | new_slot->hpc_ops->get_attention_status(new_slot, &(new_slot->hotplug_slot->info->attention_status)); | 171 | get_attention_status(hotplug_slot, &info->attention_status); |
154 | new_slot->hpc_ops->get_latch_status(new_slot, &(new_slot->hotplug_slot->info->latch_status)); | 172 | get_latch_status(hotplug_slot, &info->latch_status); |
155 | new_slot->hpc_ops->get_adapter_status(new_slot, &(new_slot->hotplug_slot->info->adapter_status)); | 173 | get_adapter_status(hotplug_slot, &info->adapter_status); |
156 | 174 | ||
157 | dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x slot_device_offset=%x\n", new_slot->bus, | 175 | dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x " |
158 | new_slot->device, new_slot->hp_slot, new_slot->number, ctrl->slot_device_offset); | 176 | "slot_device_offset=%x\n", slot->bus, slot->device, |
159 | result = pci_hp_register (new_slot->hotplug_slot); | 177 | slot->hp_slot, slot->number, ctrl->slot_device_offset); |
160 | if (result) { | 178 | retval = pci_hp_register(slot->hotplug_slot); |
161 | err ("pci_hp_register failed with error %d\n", result); | 179 | if (retval) { |
162 | goto error_name; | 180 | err("pci_hp_register failed with error %d\n", retval); |
181 | goto error_info; | ||
163 | } | 182 | } |
164 | 183 | ||
165 | new_slot->next = ctrl->slot; | 184 | list_add(&slot->slot_list, &ctrl->slot_list); |
166 | ctrl->slot = new_slot; | ||
167 | |||
168 | number_of_slots--; | ||
169 | slot_device++; | ||
170 | slot_number += ctrl->slot_num_inc; | ||
171 | } | 185 | } |
172 | 186 | ||
173 | return 0; | 187 | return 0; |
174 | |||
175 | error_name: | ||
176 | kfree(new_slot->hotplug_slot->name); | ||
177 | error_info: | 188 | error_info: |
178 | kfree(new_slot->hotplug_slot->info); | 189 | kfree(info); |
179 | error_hpslot: | 190 | error_hpslot: |
180 | kfree(new_slot->hotplug_slot); | 191 | kfree(hotplug_slot); |
181 | error_slot: | 192 | error_slot: |
182 | kfree(new_slot); | 193 | kfree(slot); |
183 | error: | 194 | error: |
184 | return result; | 195 | return retval; |
185 | } | 196 | } |
186 | 197 | ||
187 | static void cleanup_slots(struct controller *ctrl) | 198 | void cleanup_slots(struct controller *ctrl) |
188 | { | 199 | { |
189 | struct slot *old_slot, *next_slot; | 200 | struct list_head *tmp; |
190 | 201 | struct list_head *next; | |
191 | old_slot = ctrl->slot; | 202 | struct slot *slot; |
192 | ctrl->slot = NULL; | 203 | |
193 | 204 | list_for_each_safe(tmp, next, &ctrl->slot_list) { | |
194 | while (old_slot) { | 205 | slot = list_entry(tmp, struct slot, slot_list); |
195 | next_slot = old_slot->next; | 206 | list_del(&slot->slot_list); |
196 | pci_hp_deregister(old_slot->hotplug_slot); | 207 | cancel_delayed_work(&slot->work); |
197 | old_slot = next_slot; | 208 | flush_scheduled_work(); |
209 | flush_workqueue(shpchp_wq); | ||
210 | pci_hp_deregister(slot->hotplug_slot); | ||
198 | } | 211 | } |
199 | } | 212 | } |
200 | 213 | ||
@@ -207,9 +220,12 @@ static int get_ctlr_slot_config(struct controller *ctrl) | |||
207 | int rc; | 220 | int rc; |
208 | int flags; | 221 | int flags; |
209 | 222 | ||
210 | rc = shpc_get_ctlr_slot_config(ctrl, &num_ctlr_slots, &first_device_num, &physical_slot_num, &updown, &flags); | 223 | rc = shpc_get_ctlr_slot_config(ctrl, &num_ctlr_slots, |
224 | &first_device_num, &physical_slot_num, | ||
225 | &updown, &flags); | ||
211 | if (rc) { | 226 | if (rc) { |
212 | err("%s: get_ctlr_slot_config fail for b:d (%x:%x)\n", __FUNCTION__, ctrl->bus, ctrl->device); | 227 | err("%s: get_ctlr_slot_config fail for b:d (%x:%x)\n", |
228 | __FUNCTION__, ctrl->bus, ctrl->device); | ||
213 | return -1; | 229 | return -1; |
214 | } | 230 | } |
215 | 231 | ||
@@ -218,19 +234,19 @@ static int get_ctlr_slot_config(struct controller *ctrl) | |||
218 | ctrl->first_slot = physical_slot_num; | 234 | ctrl->first_slot = physical_slot_num; |
219 | ctrl->slot_num_inc = updown; /* either -1 or 1 */ | 235 | ctrl->slot_num_inc = updown; /* either -1 or 1 */ |
220 | 236 | ||
221 | dbg("%s: num_slot(0x%x) 1st_dev(0x%x) psn(0x%x) updown(%d) for b:d (%x:%x)\n", | 237 | dbg("%s: num_slot(0x%x) 1st_dev(0x%x) psn(0x%x) updown(%d) for b:d " |
222 | __FUNCTION__, num_ctlr_slots, first_device_num, physical_slot_num, updown, ctrl->bus, ctrl->device); | 238 | "(%x:%x)\n", __FUNCTION__, num_ctlr_slots, first_device_num, |
239 | physical_slot_num, updown, ctrl->bus, ctrl->device); | ||
223 | 240 | ||
224 | return 0; | 241 | return 0; |
225 | } | 242 | } |
226 | 243 | ||
227 | |||
228 | /* | 244 | /* |
229 | * set_attention_status - Turns the Amber LED for a slot on, off or blink | 245 | * set_attention_status - Turns the Amber LED for a slot on, off or blink |
230 | */ | 246 | */ |
231 | static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) | 247 | static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) |
232 | { | 248 | { |
233 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 249 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
234 | 250 | ||
235 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 251 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
236 | 252 | ||
@@ -240,29 +256,27 @@ static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) | |||
240 | return 0; | 256 | return 0; |
241 | } | 257 | } |
242 | 258 | ||
243 | |||
244 | static int enable_slot (struct hotplug_slot *hotplug_slot) | 259 | static int enable_slot (struct hotplug_slot *hotplug_slot) |
245 | { | 260 | { |
246 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 261 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
247 | 262 | ||
248 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 263 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
249 | 264 | ||
250 | return shpchp_enable_slot(slot); | 265 | return shpchp_sysfs_enable_slot(slot); |
251 | } | 266 | } |
252 | 267 | ||
253 | |||
254 | static int disable_slot (struct hotplug_slot *hotplug_slot) | 268 | static int disable_slot (struct hotplug_slot *hotplug_slot) |
255 | { | 269 | { |
256 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 270 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
257 | 271 | ||
258 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 272 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
259 | 273 | ||
260 | return shpchp_disable_slot(slot); | 274 | return shpchp_sysfs_disable_slot(slot); |
261 | } | 275 | } |
262 | 276 | ||
263 | static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value) | 277 | static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value) |
264 | { | 278 | { |
265 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 279 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
266 | int retval; | 280 | int retval; |
267 | 281 | ||
268 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 282 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
@@ -276,7 +290,7 @@ static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
276 | 290 | ||
277 | static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value) | 291 | static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value) |
278 | { | 292 | { |
279 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 293 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
280 | int retval; | 294 | int retval; |
281 | 295 | ||
282 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 296 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
@@ -290,7 +304,7 @@ static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
290 | 304 | ||
291 | static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value) | 305 | static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value) |
292 | { | 306 | { |
293 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 307 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
294 | int retval; | 308 | int retval; |
295 | 309 | ||
296 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 310 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
@@ -304,7 +318,7 @@ static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
304 | 318 | ||
305 | static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value) | 319 | static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value) |
306 | { | 320 | { |
307 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 321 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
308 | int retval; | 322 | int retval; |
309 | 323 | ||
310 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 324 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
@@ -318,7 +332,7 @@ static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
318 | 332 | ||
319 | static int get_address (struct hotplug_slot *hotplug_slot, u32 *value) | 333 | static int get_address (struct hotplug_slot *hotplug_slot, u32 *value) |
320 | { | 334 | { |
321 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 335 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
322 | struct pci_bus *bus = slot->ctrl->pci_dev->subordinate; | 336 | struct pci_bus *bus = slot->ctrl->pci_dev->subordinate; |
323 | 337 | ||
324 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 338 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
@@ -330,11 +344,11 @@ static int get_address (struct hotplug_slot *hotplug_slot, u32 *value) | |||
330 | 344 | ||
331 | static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) | 345 | static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) |
332 | { | 346 | { |
333 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 347 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
334 | int retval; | 348 | int retval; |
335 | 349 | ||
336 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 350 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
337 | 351 | ||
338 | retval = slot->hpc_ops->get_max_bus_speed(slot, value); | 352 | retval = slot->hpc_ops->get_max_bus_speed(slot, value); |
339 | if (retval < 0) | 353 | if (retval < 0) |
340 | *value = PCI_SPEED_UNKNOWN; | 354 | *value = PCI_SPEED_UNKNOWN; |
@@ -344,11 +358,11 @@ static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp | |||
344 | 358 | ||
345 | static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) | 359 | static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) |
346 | { | 360 | { |
347 | struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); | 361 | struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); |
348 | int retval; | 362 | int retval; |
349 | 363 | ||
350 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 364 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
351 | 365 | ||
352 | retval = slot->hpc_ops->get_cur_bus_speed(slot, value); | 366 | retval = slot->hpc_ops->get_cur_bus_speed(slot, value); |
353 | if (retval < 0) | 367 | if (retval < 0) |
354 | *value = PCI_SPEED_UNKNOWN; | 368 | *value = PCI_SPEED_UNKNOWN; |
@@ -372,61 +386,54 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
372 | int rc; | 386 | int rc; |
373 | struct controller *ctrl; | 387 | struct controller *ctrl; |
374 | struct slot *t_slot; | 388 | struct slot *t_slot; |
375 | int first_device_num; /* first PCI device number supported by this SHPC */ | 389 | int first_device_num; /* first PCI device number */ |
376 | int num_ctlr_slots; /* number of slots supported by this SHPC */ | 390 | int num_ctlr_slots; /* number of slots implemented */ |
377 | 391 | ||
378 | if (!is_shpc_capable(pdev)) | 392 | if (!is_shpc_capable(pdev)) |
379 | return -ENODEV; | 393 | return -ENODEV; |
380 | 394 | ||
381 | ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL); | 395 | ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); |
382 | if (!ctrl) { | 396 | if (!ctrl) { |
383 | err("%s : out of memory\n", __FUNCTION__); | 397 | err("%s : out of memory\n", __FUNCTION__); |
384 | goto err_out_none; | 398 | goto err_out_none; |
385 | } | 399 | } |
386 | memset(ctrl, 0, sizeof(struct controller)); | 400 | INIT_LIST_HEAD(&ctrl->slot_list); |
387 | 401 | ||
388 | rc = shpc_init(ctrl, pdev); | 402 | rc = shpc_init(ctrl, pdev); |
389 | if (rc) { | 403 | if (rc) { |
390 | dbg("%s: controller initialization failed\n", SHPC_MODULE_NAME); | 404 | dbg("%s: controller initialization failed\n", |
405 | SHPC_MODULE_NAME); | ||
391 | goto err_out_free_ctrl; | 406 | goto err_out_free_ctrl; |
392 | } | 407 | } |
393 | 408 | ||
394 | pci_set_drvdata(pdev, ctrl); | 409 | pci_set_drvdata(pdev, ctrl); |
395 | 410 | ||
396 | ctrl->pci_bus = kmalloc (sizeof (*ctrl->pci_bus), GFP_KERNEL); | ||
397 | if (!ctrl->pci_bus) { | ||
398 | err("out of memory\n"); | ||
399 | rc = -ENOMEM; | ||
400 | goto err_out_unmap_mmio_region; | ||
401 | } | ||
402 | |||
403 | memcpy (ctrl->pci_bus, pdev->bus, sizeof (*ctrl->pci_bus)); | ||
404 | ctrl->bus = pdev->bus->number; | 411 | ctrl->bus = pdev->bus->number; |
405 | ctrl->slot_bus = pdev->subordinate->number; | 412 | ctrl->slot_bus = pdev->subordinate->number; |
406 | |||
407 | ctrl->device = PCI_SLOT(pdev->devfn); | 413 | ctrl->device = PCI_SLOT(pdev->devfn); |
408 | ctrl->function = PCI_FUNC(pdev->devfn); | 414 | ctrl->function = PCI_FUNC(pdev->devfn); |
409 | dbg("ctrl bus=0x%x, device=%x, function=%x, irq=%x\n", ctrl->bus, ctrl->device, ctrl->function, pdev->irq); | 415 | |
416 | dbg("ctrl bus=0x%x, device=%x, function=%x, irq=%x\n", | ||
417 | ctrl->bus, ctrl->device, ctrl->function, pdev->irq); | ||
410 | 418 | ||
411 | /* | 419 | /* |
412 | * Save configuration headers for this and subordinate PCI buses | 420 | * Save configuration headers for this and subordinate PCI buses |
413 | */ | 421 | */ |
414 | |||
415 | rc = get_ctlr_slot_config(ctrl); | 422 | rc = get_ctlr_slot_config(ctrl); |
416 | if (rc) { | 423 | if (rc) { |
417 | err(msg_initialization_err, rc); | 424 | err(msg_initialization_err, rc); |
418 | goto err_out_free_ctrl_bus; | 425 | goto err_out_release_ctlr; |
419 | } | 426 | } |
420 | first_device_num = ctrl->slot_device_offset; | 427 | first_device_num = ctrl->slot_device_offset; |
421 | num_ctlr_slots = ctrl->num_slots; | 428 | num_ctlr_slots = ctrl->num_slots; |
422 | 429 | ||
423 | ctrl->add_support = 1; | 430 | ctrl->add_support = 1; |
424 | 431 | ||
425 | /* Setup the slot information structures */ | 432 | /* Setup the slot information structures */ |
426 | rc = init_slots(ctrl); | 433 | rc = init_slots(ctrl); |
427 | if (rc) { | 434 | if (rc) { |
428 | err(msg_initialization_err, 6); | 435 | err(msg_initialization_err, 6); |
429 | goto err_out_free_ctrl_slot; | 436 | goto err_out_release_ctlr; |
430 | } | 437 | } |
431 | 438 | ||
432 | /* Now hpc_functions (slot->hpc_ops->functions) are ready */ | 439 | /* Now hpc_functions (slot->hpc_ops->functions) are ready */ |
@@ -437,30 +444,16 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
437 | dbg("%s: t_slot->hp_slot %x\n", __FUNCTION__,t_slot->hp_slot); | 444 | dbg("%s: t_slot->hp_slot %x\n", __FUNCTION__,t_slot->hp_slot); |
438 | 445 | ||
439 | if (rc || ctrl->speed == PCI_SPEED_UNKNOWN) { | 446 | if (rc || ctrl->speed == PCI_SPEED_UNKNOWN) { |
440 | err(SHPC_MODULE_NAME ": Can't get current bus speed. Set to 33MHz PCI.\n"); | 447 | err(SHPC_MODULE_NAME ": Can't get current bus speed. " |
448 | "Set to 33MHz PCI.\n"); | ||
441 | ctrl->speed = PCI_SPEED_33MHz; | 449 | ctrl->speed = PCI_SPEED_33MHz; |
442 | } | 450 | } |
443 | 451 | ||
444 | /* Finish setting up the hot plug ctrl device */ | ||
445 | ctrl->next_event = 0; | ||
446 | |||
447 | if (!shpchp_ctrl_list) { | ||
448 | shpchp_ctrl_list = ctrl; | ||
449 | ctrl->next = NULL; | ||
450 | } else { | ||
451 | ctrl->next = shpchp_ctrl_list; | ||
452 | shpchp_ctrl_list = ctrl; | ||
453 | } | ||
454 | |||
455 | shpchp_create_ctrl_files(ctrl); | 452 | shpchp_create_ctrl_files(ctrl); |
456 | 453 | ||
457 | return 0; | 454 | return 0; |
458 | 455 | ||
459 | err_out_free_ctrl_slot: | 456 | err_out_release_ctlr: |
460 | cleanup_slots(ctrl); | ||
461 | err_out_free_ctrl_bus: | ||
462 | kfree(ctrl->pci_bus); | ||
463 | err_out_unmap_mmio_region: | ||
464 | ctrl->hpc_ops->release_ctlr(ctrl); | 457 | ctrl->hpc_ops->release_ctlr(ctrl); |
465 | err_out_free_ctrl: | 458 | err_out_free_ctrl: |
466 | kfree(ctrl); | 459 | kfree(ctrl); |
@@ -468,74 +461,28 @@ err_out_none: | |||
468 | return -ENODEV; | 461 | return -ENODEV; |
469 | } | 462 | } |
470 | 463 | ||
471 | 464 | static void shpc_remove(struct pci_dev *dev) | |
472 | static int shpc_start_thread(void) | ||
473 | { | ||
474 | int retval = 0; | ||
475 | |||
476 | dbg("Initialize + Start the notification/polling mechanism \n"); | ||
477 | |||
478 | retval = shpchp_event_start_thread(); | ||
479 | if (retval) { | ||
480 | dbg("shpchp_event_start_thread() failed\n"); | ||
481 | return retval; | ||
482 | } | ||
483 | |||
484 | return retval; | ||
485 | } | ||
486 | |||
487 | static void __exit unload_shpchpd(void) | ||
488 | { | 465 | { |
489 | struct controller *ctrl; | 466 | struct controller *ctrl = pci_get_drvdata(dev); |
490 | struct controller *tctrl; | ||
491 | |||
492 | ctrl = shpchp_ctrl_list; | ||
493 | |||
494 | while (ctrl) { | ||
495 | shpchp_remove_ctrl_files(ctrl); | ||
496 | cleanup_slots(ctrl); | ||
497 | |||
498 | kfree (ctrl->pci_bus); | ||
499 | ctrl->hpc_ops->release_ctlr(ctrl); | ||
500 | |||
501 | tctrl = ctrl; | ||
502 | ctrl = ctrl->next; | ||
503 | |||
504 | kfree(tctrl); | ||
505 | } | ||
506 | |||
507 | /* Stop the notification mechanism */ | ||
508 | shpchp_event_stop_thread(); | ||
509 | 467 | ||
468 | shpchp_remove_ctrl_files(ctrl); | ||
469 | ctrl->hpc_ops->release_ctlr(ctrl); | ||
470 | kfree(ctrl); | ||
510 | } | 471 | } |
511 | 472 | ||
512 | |||
513 | static struct pci_device_id shpcd_pci_tbl[] = { | 473 | static struct pci_device_id shpcd_pci_tbl[] = { |
514 | { | 474 | {PCI_DEVICE_CLASS(((PCI_CLASS_BRIDGE_PCI << 8) | 0x00), ~0)}, |
515 | .class = ((PCI_CLASS_BRIDGE_PCI << 8) | 0x00), | ||
516 | .class_mask = ~0, | ||
517 | .vendor = PCI_ANY_ID, | ||
518 | .device = PCI_ANY_ID, | ||
519 | .subvendor = PCI_ANY_ID, | ||
520 | .subdevice = PCI_ANY_ID, | ||
521 | }, | ||
522 | |||
523 | { /* end: all zeroes */ } | 475 | { /* end: all zeroes */ } |
524 | }; | 476 | }; |
525 | |||
526 | MODULE_DEVICE_TABLE(pci, shpcd_pci_tbl); | 477 | MODULE_DEVICE_TABLE(pci, shpcd_pci_tbl); |
527 | 478 | ||
528 | |||
529 | |||
530 | static struct pci_driver shpc_driver = { | 479 | static struct pci_driver shpc_driver = { |
531 | .name = SHPC_MODULE_NAME, | 480 | .name = SHPC_MODULE_NAME, |
532 | .id_table = shpcd_pci_tbl, | 481 | .id_table = shpcd_pci_tbl, |
533 | .probe = shpc_probe, | 482 | .probe = shpc_probe, |
534 | /* remove: shpc_remove_one, */ | 483 | .remove = shpc_remove, |
535 | }; | 484 | }; |
536 | 485 | ||
537 | |||
538 | |||
539 | static int __init shpcd_init(void) | 486 | static int __init shpcd_init(void) |
540 | { | 487 | { |
541 | int retval = 0; | 488 | int retval = 0; |
@@ -544,17 +491,15 @@ static int __init shpcd_init(void) | |||
544 | shpchp_poll_mode = 1; | 491 | shpchp_poll_mode = 1; |
545 | #endif | 492 | #endif |
546 | 493 | ||
547 | retval = shpc_start_thread(); | 494 | shpchp_wq = create_singlethread_workqueue("shpchpd"); |
548 | if (retval) | 495 | if (!shpchp_wq) |
549 | goto error_hpc_init; | 496 | return -ENOMEM; |
550 | 497 | ||
551 | retval = pci_register_driver(&shpc_driver); | 498 | retval = pci_register_driver(&shpc_driver); |
552 | dbg("%s: pci_register_driver = %d\n", __FUNCTION__, retval); | 499 | dbg("%s: pci_register_driver = %d\n", __FUNCTION__, retval); |
553 | info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); | 500 | info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); |
554 | |||
555 | error_hpc_init: | ||
556 | if (retval) { | 501 | if (retval) { |
557 | shpchp_event_stop_thread(); | 502 | destroy_workqueue(shpchp_wq); |
558 | } | 503 | } |
559 | return retval; | 504 | return retval; |
560 | } | 505 | } |
@@ -562,10 +507,8 @@ error_hpc_init: | |||
562 | static void __exit shpcd_cleanup(void) | 507 | static void __exit shpcd_cleanup(void) |
563 | { | 508 | { |
564 | dbg("unload_shpchpd()\n"); | 509 | dbg("unload_shpchpd()\n"); |
565 | unload_shpchpd(); | ||
566 | |||
567 | pci_unregister_driver(&shpc_driver); | 510 | pci_unregister_driver(&shpc_driver); |
568 | 511 | destroy_workqueue(shpchp_wq); | |
569 | info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n"); | 512 | info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n"); |
570 | } | 513 | } |
571 | 514 | ||
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c index 643252d9bf3b..4e6381481c55 100644 --- a/drivers/pci/hotplug/shpchp_ctrl.c +++ b/drivers/pci/hotplug/shpchp_ctrl.c | |||
@@ -32,65 +32,50 @@ | |||
32 | #include <linux/types.h> | 32 | #include <linux/types.h> |
33 | #include <linux/smp_lock.h> | 33 | #include <linux/smp_lock.h> |
34 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
35 | #include <linux/workqueue.h> | ||
35 | #include "../pci.h" | 36 | #include "../pci.h" |
36 | #include "shpchp.h" | 37 | #include "shpchp.h" |
37 | 38 | ||
38 | static void interrupt_event_handler(struct controller *ctrl); | 39 | static void interrupt_event_handler(void *data); |
40 | static int shpchp_enable_slot(struct slot *p_slot); | ||
41 | static int shpchp_disable_slot(struct slot *p_slot); | ||
39 | 42 | ||
40 | static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */ | 43 | static int queue_interrupt_event(struct slot *p_slot, u32 event_type) |
41 | static struct semaphore event_exit; /* guard ensure thread has exited before calling it quits */ | 44 | { |
42 | static int event_finished; | 45 | struct event_info *info; |
43 | static unsigned long pushbutton_pending; /* = 0 */ | 46 | |
47 | info = kmalloc(sizeof(*info), GFP_ATOMIC); | ||
48 | if (!info) | ||
49 | return -ENOMEM; | ||
50 | |||
51 | info->event_type = event_type; | ||
52 | info->p_slot = p_slot; | ||
53 | INIT_WORK(&info->work, interrupt_event_handler, info); | ||
54 | |||
55 | schedule_work(&info->work); | ||
56 | |||
57 | return 0; | ||
58 | } | ||
44 | 59 | ||
45 | u8 shpchp_handle_attention_button(u8 hp_slot, void *inst_id) | 60 | u8 shpchp_handle_attention_button(u8 hp_slot, void *inst_id) |
46 | { | 61 | { |
47 | struct controller *ctrl = (struct controller *) inst_id; | 62 | struct controller *ctrl = (struct controller *) inst_id; |
48 | struct slot *p_slot; | 63 | struct slot *p_slot; |
49 | u8 rc = 0; | 64 | u32 event_type; |
50 | u8 getstatus; | ||
51 | struct event_info *taskInfo; | ||
52 | 65 | ||
53 | /* Attention Button Change */ | 66 | /* Attention Button Change */ |
54 | dbg("shpchp: Attention button interrupt received.\n"); | 67 | dbg("shpchp: Attention button interrupt received.\n"); |
55 | 68 | ||
56 | /* This is the structure that tells the worker thread what to do */ | ||
57 | taskInfo = &(ctrl->event_queue[ctrl->next_event]); | ||
58 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); | 69 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
59 | |||
60 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); | 70 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); |
61 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | ||
62 | |||
63 | ctrl->next_event = (ctrl->next_event + 1) % 10; | ||
64 | taskInfo->hp_slot = hp_slot; | ||
65 | |||
66 | rc++; | ||
67 | 71 | ||
68 | /* | 72 | /* |
69 | * Button pressed - See if need to TAKE ACTION!!! | 73 | * Button pressed - See if need to TAKE ACTION!!! |
70 | */ | 74 | */ |
71 | info("Button pressed on Slot(%d)\n", ctrl->first_slot + hp_slot); | 75 | info("Button pressed on Slot(%d)\n", ctrl->first_slot + hp_slot); |
72 | taskInfo->event_type = INT_BUTTON_PRESS; | 76 | event_type = INT_BUTTON_PRESS; |
73 | |||
74 | if ((p_slot->state == BLINKINGON_STATE) | ||
75 | || (p_slot->state == BLINKINGOFF_STATE)) { | ||
76 | /* Cancel if we are still blinking; this means that we press the | ||
77 | * attention again before the 5 sec. limit expires to cancel hot-add | ||
78 | * or hot-remove | ||
79 | */ | ||
80 | taskInfo->event_type = INT_BUTTON_CANCEL; | ||
81 | info("Button cancel on Slot(%d)\n", ctrl->first_slot + hp_slot); | ||
82 | } else if ((p_slot->state == POWERON_STATE) | ||
83 | || (p_slot->state == POWEROFF_STATE)) { | ||
84 | /* Ignore if the slot is on power-on or power-off state; this | ||
85 | * means that the previous attention button action to hot-add or | ||
86 | * hot-remove is undergoing | ||
87 | */ | ||
88 | taskInfo->event_type = INT_BUTTON_IGNORE; | ||
89 | info("Button ignore on Slot(%d)\n", ctrl->first_slot + hp_slot); | ||
90 | } | ||
91 | 77 | ||
92 | if (rc) | 78 | queue_interrupt_event(p_slot, event_type); |
93 | up(&event_semaphore); /* signal event thread that new event is posted */ | ||
94 | 79 | ||
95 | return 0; | 80 | return 0; |
96 | 81 | ||
@@ -100,21 +85,12 @@ u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id) | |||
100 | { | 85 | { |
101 | struct controller *ctrl = (struct controller *) inst_id; | 86 | struct controller *ctrl = (struct controller *) inst_id; |
102 | struct slot *p_slot; | 87 | struct slot *p_slot; |
103 | u8 rc = 0; | ||
104 | u8 getstatus; | 88 | u8 getstatus; |
105 | struct event_info *taskInfo; | 89 | u32 event_type; |
106 | 90 | ||
107 | /* Switch Change */ | 91 | /* Switch Change */ |
108 | dbg("shpchp: Switch interrupt received.\n"); | 92 | dbg("shpchp: Switch interrupt received.\n"); |
109 | 93 | ||
110 | /* This is the structure that tells the worker thread | ||
111 | * what to do | ||
112 | */ | ||
113 | taskInfo = &(ctrl->event_queue[ctrl->next_event]); | ||
114 | ctrl->next_event = (ctrl->next_event + 1) % 10; | ||
115 | taskInfo->hp_slot = hp_slot; | ||
116 | |||
117 | rc++; | ||
118 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); | 94 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
119 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); | 95 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); |
120 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 96 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
@@ -126,9 +102,9 @@ u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id) | |||
126 | * Switch opened | 102 | * Switch opened |
127 | */ | 103 | */ |
128 | info("Latch open on Slot(%d)\n", ctrl->first_slot + hp_slot); | 104 | info("Latch open on Slot(%d)\n", ctrl->first_slot + hp_slot); |
129 | taskInfo->event_type = INT_SWITCH_OPEN; | 105 | event_type = INT_SWITCH_OPEN; |
130 | if (p_slot->pwr_save && p_slot->presence_save) { | 106 | if (p_slot->pwr_save && p_slot->presence_save) { |
131 | taskInfo->event_type = INT_POWER_FAULT; | 107 | event_type = INT_POWER_FAULT; |
132 | err("Surprise Removal of card\n"); | 108 | err("Surprise Removal of card\n"); |
133 | } | 109 | } |
134 | } else { | 110 | } else { |
@@ -136,34 +112,23 @@ u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id) | |||
136 | * Switch closed | 112 | * Switch closed |
137 | */ | 113 | */ |
138 | info("Latch close on Slot(%d)\n", ctrl->first_slot + hp_slot); | 114 | info("Latch close on Slot(%d)\n", ctrl->first_slot + hp_slot); |
139 | taskInfo->event_type = INT_SWITCH_CLOSE; | 115 | event_type = INT_SWITCH_CLOSE; |
140 | } | 116 | } |
141 | 117 | ||
142 | if (rc) | 118 | queue_interrupt_event(p_slot, event_type); |
143 | up(&event_semaphore); /* signal event thread that new event is posted */ | ||
144 | 119 | ||
145 | return rc; | 120 | return 1; |
146 | } | 121 | } |
147 | 122 | ||
148 | u8 shpchp_handle_presence_change(u8 hp_slot, void *inst_id) | 123 | u8 shpchp_handle_presence_change(u8 hp_slot, void *inst_id) |
149 | { | 124 | { |
150 | struct controller *ctrl = (struct controller *) inst_id; | 125 | struct controller *ctrl = (struct controller *) inst_id; |
151 | struct slot *p_slot; | 126 | struct slot *p_slot; |
152 | u8 rc = 0; | 127 | u32 event_type; |
153 | /*u8 temp_byte;*/ | ||
154 | struct event_info *taskInfo; | ||
155 | 128 | ||
156 | /* Presence Change */ | 129 | /* Presence Change */ |
157 | dbg("shpchp: Presence/Notify input change.\n"); | 130 | dbg("shpchp: Presence/Notify input change.\n"); |
158 | 131 | ||
159 | /* This is the structure that tells the worker thread | ||
160 | * what to do | ||
161 | */ | ||
162 | taskInfo = &(ctrl->event_queue[ctrl->next_event]); | ||
163 | ctrl->next_event = (ctrl->next_event + 1) % 10; | ||
164 | taskInfo->hp_slot = hp_slot; | ||
165 | |||
166 | rc++; | ||
167 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); | 132 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
168 | 133 | ||
169 | /* | 134 | /* |
@@ -175,39 +140,29 @@ u8 shpchp_handle_presence_change(u8 hp_slot, void *inst_id) | |||
175 | * Card Present | 140 | * Card Present |
176 | */ | 141 | */ |
177 | info("Card present on Slot(%d)\n", ctrl->first_slot + hp_slot); | 142 | info("Card present on Slot(%d)\n", ctrl->first_slot + hp_slot); |
178 | taskInfo->event_type = INT_PRESENCE_ON; | 143 | event_type = INT_PRESENCE_ON; |
179 | } else { | 144 | } else { |
180 | /* | 145 | /* |
181 | * Not Present | 146 | * Not Present |
182 | */ | 147 | */ |
183 | info("Card not present on Slot(%d)\n", ctrl->first_slot + hp_slot); | 148 | info("Card not present on Slot(%d)\n", ctrl->first_slot + hp_slot); |
184 | taskInfo->event_type = INT_PRESENCE_OFF; | 149 | event_type = INT_PRESENCE_OFF; |
185 | } | 150 | } |
186 | 151 | ||
187 | if (rc) | 152 | queue_interrupt_event(p_slot, event_type); |
188 | up(&event_semaphore); /* signal event thread that new event is posted */ | ||
189 | 153 | ||
190 | return rc; | 154 | return 1; |
191 | } | 155 | } |
192 | 156 | ||
193 | u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id) | 157 | u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id) |
194 | { | 158 | { |
195 | struct controller *ctrl = (struct controller *) inst_id; | 159 | struct controller *ctrl = (struct controller *) inst_id; |
196 | struct slot *p_slot; | 160 | struct slot *p_slot; |
197 | u8 rc = 0; | 161 | u32 event_type; |
198 | struct event_info *taskInfo; | ||
199 | 162 | ||
200 | /* Power fault */ | 163 | /* Power fault */ |
201 | dbg("shpchp: Power fault interrupt received.\n"); | 164 | dbg("shpchp: Power fault interrupt received.\n"); |
202 | 165 | ||
203 | /* This is the structure that tells the worker thread | ||
204 | * what to do | ||
205 | */ | ||
206 | taskInfo = &(ctrl->event_queue[ctrl->next_event]); | ||
207 | ctrl->next_event = (ctrl->next_event + 1) % 10; | ||
208 | taskInfo->hp_slot = hp_slot; | ||
209 | |||
210 | rc++; | ||
211 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); | 166 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
212 | 167 | ||
213 | if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) { | 168 | if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) { |
@@ -216,21 +171,21 @@ u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id) | |||
216 | */ | 171 | */ |
217 | info("Power fault cleared on Slot(%d)\n", ctrl->first_slot + hp_slot); | 172 | info("Power fault cleared on Slot(%d)\n", ctrl->first_slot + hp_slot); |
218 | p_slot->status = 0x00; | 173 | p_slot->status = 0x00; |
219 | taskInfo->event_type = INT_POWER_FAULT_CLEAR; | 174 | event_type = INT_POWER_FAULT_CLEAR; |
220 | } else { | 175 | } else { |
221 | /* | 176 | /* |
222 | * Power fault | 177 | * Power fault |
223 | */ | 178 | */ |
224 | info("Power fault on Slot(%d)\n", ctrl->first_slot + hp_slot); | 179 | info("Power fault on Slot(%d)\n", ctrl->first_slot + hp_slot); |
225 | taskInfo->event_type = INT_POWER_FAULT; | 180 | event_type = INT_POWER_FAULT; |
226 | /* set power fault status for this board */ | 181 | /* set power fault status for this board */ |
227 | p_slot->status = 0xFF; | 182 | p_slot->status = 0xFF; |
228 | info("power fault bit %x set\n", hp_slot); | 183 | info("power fault bit %x set\n", hp_slot); |
229 | } | 184 | } |
230 | if (rc) | ||
231 | up(&event_semaphore); /* signal event thread that new event is posted */ | ||
232 | 185 | ||
233 | return rc; | 186 | queue_interrupt_event(p_slot, event_type); |
187 | |||
188 | return 1; | ||
234 | } | 189 | } |
235 | 190 | ||
236 | /* The following routines constitute the bulk of the | 191 | /* The following routines constitute the bulk of the |
@@ -242,21 +197,11 @@ static int change_bus_speed(struct controller *ctrl, struct slot *p_slot, | |||
242 | int rc = 0; | 197 | int rc = 0; |
243 | 198 | ||
244 | dbg("%s: change to speed %d\n", __FUNCTION__, speed); | 199 | dbg("%s: change to speed %d\n", __FUNCTION__, speed); |
245 | down(&ctrl->crit_sect); | ||
246 | if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) { | 200 | if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) { |
247 | err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__); | 201 | err("%s: Issue of set bus speed mode command failed\n", |
248 | up(&ctrl->crit_sect); | 202 | __FUNCTION__); |
249 | return WRONG_BUS_FREQUENCY; | 203 | return WRONG_BUS_FREQUENCY; |
250 | } | 204 | } |
251 | |||
252 | if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { | ||
253 | err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n", | ||
254 | __FUNCTION__); | ||
255 | err("%s: Error code (%d)\n", __FUNCTION__, rc); | ||
256 | up(&ctrl->crit_sect); | ||
257 | return WRONG_BUS_FREQUENCY; | ||
258 | } | ||
259 | up(&ctrl->crit_sect); | ||
260 | return rc; | 205 | return rc; |
261 | } | 206 | } |
262 | 207 | ||
@@ -265,33 +210,26 @@ static int fix_bus_speed(struct controller *ctrl, struct slot *pslot, | |||
265 | enum pci_bus_speed msp) | 210 | enum pci_bus_speed msp) |
266 | { | 211 | { |
267 | int rc = 0; | 212 | int rc = 0; |
268 | 213 | ||
269 | if (flag != 0) { /* Other slots on the same bus are occupied */ | 214 | /* |
270 | if ( asp < bsp ) { | 215 | * If other slots on the same bus are occupied, we cannot |
271 | err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bsp, asp); | 216 | * change the bus speed. |
272 | return WRONG_BUS_FREQUENCY; | 217 | */ |
218 | if (flag) { | ||
219 | if (asp < bsp) { | ||
220 | err("%s: speed of bus %x and adapter %x mismatch\n", | ||
221 | __FUNCTION__, bsp, asp); | ||
222 | rc = WRONG_BUS_FREQUENCY; | ||
273 | } | 223 | } |
224 | return rc; | ||
225 | } | ||
226 | |||
227 | if (asp < msp) { | ||
228 | if (bsp != asp) | ||
229 | rc = change_bus_speed(ctrl, pslot, asp); | ||
274 | } else { | 230 | } else { |
275 | /* Other slots on the same bus are empty */ | 231 | if (bsp != msp) |
276 | if (msp == bsp) { | 232 | rc = change_bus_speed(ctrl, pslot, msp); |
277 | /* if adapter_speed >= bus_speed, do nothing */ | ||
278 | if (asp < bsp) { | ||
279 | /* | ||
280 | * Try to lower bus speed to accommodate the adapter if other slots | ||
281 | * on the same controller are empty | ||
282 | */ | ||
283 | if ((rc = change_bus_speed(ctrl, pslot, asp))) | ||
284 | return rc; | ||
285 | } | ||
286 | } else { | ||
287 | if (asp < msp) { | ||
288 | if ((rc = change_bus_speed(ctrl, pslot, asp))) | ||
289 | return rc; | ||
290 | } else { | ||
291 | if ((rc = change_bus_speed(ctrl, pslot, msp))) | ||
292 | return rc; | ||
293 | } | ||
294 | } | ||
295 | } | 233 | } |
296 | return rc; | 234 | return rc; |
297 | } | 235 | } |
@@ -308,8 +246,7 @@ static int board_added(struct slot *p_slot) | |||
308 | u8 hp_slot; | 246 | u8 hp_slot; |
309 | u8 slots_not_empty = 0; | 247 | u8 slots_not_empty = 0; |
310 | int rc = 0; | 248 | int rc = 0; |
311 | enum pci_bus_speed adapter_speed, bus_speed, max_bus_speed; | 249 | enum pci_bus_speed asp, bsp, msp; |
312 | u8 pi, mode; | ||
313 | struct controller *ctrl = p_slot->ctrl; | 250 | struct controller *ctrl = p_slot->ctrl; |
314 | 251 | ||
315 | hp_slot = p_slot->device - ctrl->slot_device_offset; | 252 | hp_slot = p_slot->device - ctrl->slot_device_offset; |
@@ -318,187 +255,68 @@ static int board_added(struct slot *p_slot) | |||
318 | __FUNCTION__, p_slot->device, | 255 | __FUNCTION__, p_slot->device, |
319 | ctrl->slot_device_offset, hp_slot); | 256 | ctrl->slot_device_offset, hp_slot); |
320 | 257 | ||
321 | /* Wait for exclusive access to hardware */ | ||
322 | down(&ctrl->crit_sect); | ||
323 | |||
324 | /* Power on slot without connecting to bus */ | 258 | /* Power on slot without connecting to bus */ |
325 | rc = p_slot->hpc_ops->power_on_slot(p_slot); | 259 | rc = p_slot->hpc_ops->power_on_slot(p_slot); |
326 | if (rc) { | 260 | if (rc) { |
327 | err("%s: Failed to power on slot\n", __FUNCTION__); | 261 | err("%s: Failed to power on slot\n", __FUNCTION__); |
328 | /* Done with exclusive hardware access */ | ||
329 | up(&ctrl->crit_sect); | ||
330 | return -1; | 262 | return -1; |
331 | } | 263 | } |
332 | 264 | ||
333 | rc = p_slot->hpc_ops->check_cmd_status(ctrl); | ||
334 | if (rc) { | ||
335 | err("%s: Failed to power on slot, error code(%d)\n", __FUNCTION__, rc); | ||
336 | /* Done with exclusive hardware access */ | ||
337 | up(&ctrl->crit_sect); | ||
338 | return -1; | ||
339 | } | ||
340 | |||
341 | |||
342 | if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) { | 265 | if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) { |
343 | if (slots_not_empty) | 266 | if (slots_not_empty) |
344 | return WRONG_BUS_FREQUENCY; | 267 | return WRONG_BUS_FREQUENCY; |
345 | 268 | ||
346 | if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) { | 269 | if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) { |
347 | err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__); | 270 | err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__); |
348 | up(&ctrl->crit_sect); | ||
349 | return WRONG_BUS_FREQUENCY; | 271 | return WRONG_BUS_FREQUENCY; |
350 | } | 272 | } |
351 | 273 | ||
352 | if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { | ||
353 | err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n", | ||
354 | __FUNCTION__); | ||
355 | err("%s: Error code (%d)\n", __FUNCTION__, rc); | ||
356 | up(&ctrl->crit_sect); | ||
357 | return WRONG_BUS_FREQUENCY; | ||
358 | } | ||
359 | /* turn on board, blink green LED, turn off Amber LED */ | 274 | /* turn on board, blink green LED, turn off Amber LED */ |
360 | if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { | 275 | if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { |
361 | err("%s: Issue of Slot Enable command failed\n", __FUNCTION__); | 276 | err("%s: Issue of Slot Enable command failed\n", __FUNCTION__); |
362 | up(&ctrl->crit_sect); | ||
363 | return rc; | 277 | return rc; |
364 | } | 278 | } |
365 | |||
366 | if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { | ||
367 | err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc); | ||
368 | up(&ctrl->crit_sect); | ||
369 | return rc; | ||
370 | } | ||
371 | } | 279 | } |
372 | 280 | ||
373 | rc = p_slot->hpc_ops->get_adapter_speed(p_slot, &adapter_speed); | 281 | rc = p_slot->hpc_ops->get_adapter_speed(p_slot, &asp); |
374 | /* 0 = PCI 33Mhz, 1 = PCI 66 Mhz, 2 = PCI-X 66 PA, 4 = PCI-X 66 ECC, */ | 282 | if (rc) { |
375 | /* 5 = PCI-X 133 PA, 7 = PCI-X 133 ECC, 0xa = PCI-X 133 Mhz 266, */ | 283 | err("%s: Can't get adapter speed or bus mode mismatch\n", |
376 | /* 0xd = PCI-X 133 Mhz 533 */ | 284 | __FUNCTION__); |
377 | /* This encoding is different from the one used in cur_bus_speed & */ | ||
378 | /* max_bus_speed */ | ||
379 | |||
380 | if (rc || adapter_speed == PCI_SPEED_UNKNOWN) { | ||
381 | err("%s: Can't get adapter speed or bus mode mismatch\n", __FUNCTION__); | ||
382 | /* Done with exclusive hardware access */ | ||
383 | up(&ctrl->crit_sect); | ||
384 | return WRONG_BUS_FREQUENCY; | 285 | return WRONG_BUS_FREQUENCY; |
385 | } | 286 | } |
386 | 287 | ||
387 | rc = p_slot->hpc_ops->get_cur_bus_speed(p_slot, &bus_speed); | 288 | rc = p_slot->hpc_ops->get_cur_bus_speed(p_slot, &bsp); |
388 | if (rc || bus_speed == PCI_SPEED_UNKNOWN) { | 289 | if (rc) { |
389 | err("%s: Can't get bus operation speed\n", __FUNCTION__); | 290 | err("%s: Can't get bus operation speed\n", __FUNCTION__); |
390 | /* Done with exclusive hardware access */ | ||
391 | up(&ctrl->crit_sect); | ||
392 | return WRONG_BUS_FREQUENCY; | 291 | return WRONG_BUS_FREQUENCY; |
393 | } | 292 | } |
394 | 293 | ||
395 | rc = p_slot->hpc_ops->get_max_bus_speed(p_slot, &max_bus_speed); | 294 | rc = p_slot->hpc_ops->get_max_bus_speed(p_slot, &msp); |
396 | if (rc || max_bus_speed == PCI_SPEED_UNKNOWN) { | 295 | if (rc) { |
397 | err("%s: Can't get max bus operation speed\n", __FUNCTION__); | 296 | err("%s: Can't get max bus operation speed\n", __FUNCTION__); |
398 | max_bus_speed = bus_speed; | 297 | msp = bsp; |
399 | } | ||
400 | |||
401 | /* Done with exclusive hardware access */ | ||
402 | up(&ctrl->crit_sect); | ||
403 | |||
404 | if ((rc = p_slot->hpc_ops->get_prog_int(p_slot, &pi))) { | ||
405 | err("%s: Can't get controller programming interface, set it to 1\n", __FUNCTION__); | ||
406 | pi = 1; | ||
407 | } | 298 | } |
408 | 299 | ||
409 | /* Check if there are other slots or devices on the same bus */ | 300 | /* Check if there are other slots or devices on the same bus */ |
410 | if (!list_empty(&ctrl->pci_dev->subordinate->devices)) | 301 | if (!list_empty(&ctrl->pci_dev->subordinate->devices)) |
411 | slots_not_empty = 1; | 302 | slots_not_empty = 1; |
412 | 303 | ||
413 | dbg("%s: slots_not_empty %d, pi %d\n", __FUNCTION__, | 304 | dbg("%s: slots_not_empty %d, adapter_speed %d, bus_speed %d, " |
414 | slots_not_empty, pi); | 305 | "max_bus_speed %d\n", __FUNCTION__, slots_not_empty, asp, |
415 | dbg("adapter_speed %d, bus_speed %d, max_bus_speed %d\n", | 306 | bsp, msp); |
416 | adapter_speed, bus_speed, max_bus_speed); | ||
417 | |||
418 | if (pi == 2) { | ||
419 | dbg("%s: In PI = %d\n", __FUNCTION__, pi); | ||
420 | if ((rc = p_slot->hpc_ops->get_mode1_ECC_cap(p_slot, &mode))) { | ||
421 | err("%s: Can't get Mode1_ECC, set mode to 0\n", __FUNCTION__); | ||
422 | mode = 0; | ||
423 | } | ||
424 | 307 | ||
425 | switch (adapter_speed) { | 308 | rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, asp, bsp, msp); |
426 | case PCI_SPEED_133MHz_PCIX_533: | 309 | if (rc) |
427 | case PCI_SPEED_133MHz_PCIX_266: | 310 | return rc; |
428 | if ((bus_speed != adapter_speed) && | ||
429 | ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) | ||
430 | return rc; | ||
431 | break; | ||
432 | case PCI_SPEED_133MHz_PCIX_ECC: | ||
433 | case PCI_SPEED_133MHz_PCIX: | ||
434 | if (mode) { /* Bus - Mode 1 ECC */ | ||
435 | if ((bus_speed != 0x7) && | ||
436 | ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) | ||
437 | return rc; | ||
438 | } else { | ||
439 | if ((bus_speed != 0x4) && | ||
440 | ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) | ||
441 | return rc; | ||
442 | } | ||
443 | break; | ||
444 | case PCI_SPEED_66MHz_PCIX_ECC: | ||
445 | case PCI_SPEED_66MHz_PCIX: | ||
446 | if (mode) { /* Bus - Mode 1 ECC */ | ||
447 | if ((bus_speed != 0x5) && | ||
448 | ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) | ||
449 | return rc; | ||
450 | } else { | ||
451 | if ((bus_speed != 0x2) && | ||
452 | ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) | ||
453 | return rc; | ||
454 | } | ||
455 | break; | ||
456 | case PCI_SPEED_66MHz: | ||
457 | if ((bus_speed != 0x1) && | ||
458 | ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) | ||
459 | return rc; | ||
460 | break; | ||
461 | case PCI_SPEED_33MHz: | ||
462 | if (bus_speed > 0x0) { | ||
463 | if (slots_not_empty == 0) { | ||
464 | if ((rc = change_bus_speed(ctrl, p_slot, adapter_speed))) | ||
465 | return rc; | ||
466 | } else { | ||
467 | err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bus_speed, adapter_speed); | ||
468 | return WRONG_BUS_FREQUENCY; | ||
469 | } | ||
470 | } | ||
471 | break; | ||
472 | default: | ||
473 | err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bus_speed, adapter_speed); | ||
474 | return WRONG_BUS_FREQUENCY; | ||
475 | } | ||
476 | } else { | ||
477 | /* If adpater_speed == bus_speed, nothing to do here */ | ||
478 | dbg("%s: In PI = %d\n", __FUNCTION__, pi); | ||
479 | if ((adapter_speed != bus_speed) && | ||
480 | ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed)))) | ||
481 | return rc; | ||
482 | } | ||
483 | 311 | ||
484 | down(&ctrl->crit_sect); | ||
485 | /* turn on board, blink green LED, turn off Amber LED */ | 312 | /* turn on board, blink green LED, turn off Amber LED */ |
486 | if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { | 313 | if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { |
487 | err("%s: Issue of Slot Enable command failed\n", __FUNCTION__); | 314 | err("%s: Issue of Slot Enable command failed\n", __FUNCTION__); |
488 | up(&ctrl->crit_sect); | ||
489 | return rc; | 315 | return rc; |
490 | } | 316 | } |
491 | 317 | ||
492 | if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { | ||
493 | err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc); | ||
494 | up(&ctrl->crit_sect); | ||
495 | return rc; | ||
496 | } | ||
497 | |||
498 | up(&ctrl->crit_sect); | ||
499 | |||
500 | /* Wait for ~1 second */ | 318 | /* Wait for ~1 second */ |
501 | wait_for_ctrl_irq (ctrl); | 319 | msleep(1000); |
502 | 320 | ||
503 | dbg("%s: slot status = %x\n", __FUNCTION__, p_slot->status); | 321 | dbg("%s: slot status = %x\n", __FUNCTION__, p_slot->status); |
504 | /* Check for a power fault */ | 322 | /* Check for a power fault */ |
@@ -520,40 +338,18 @@ static int board_added(struct slot *p_slot) | |||
520 | p_slot->is_a_board = 0x01; | 338 | p_slot->is_a_board = 0x01; |
521 | p_slot->pwr_save = 1; | 339 | p_slot->pwr_save = 1; |
522 | 340 | ||
523 | /* Wait for exclusive access to hardware */ | ||
524 | down(&ctrl->crit_sect); | ||
525 | |||
526 | p_slot->hpc_ops->green_led_on(p_slot); | 341 | p_slot->hpc_ops->green_led_on(p_slot); |
527 | 342 | ||
528 | /* Done with exclusive hardware access */ | ||
529 | up(&ctrl->crit_sect); | ||
530 | |||
531 | return 0; | 343 | return 0; |
532 | 344 | ||
533 | err_exit: | 345 | err_exit: |
534 | /* Wait for exclusive access to hardware */ | ||
535 | down(&ctrl->crit_sect); | ||
536 | |||
537 | /* turn off slot, turn on Amber LED, turn off Green LED */ | 346 | /* turn off slot, turn on Amber LED, turn off Green LED */ |
538 | rc = p_slot->hpc_ops->slot_disable(p_slot); | 347 | rc = p_slot->hpc_ops->slot_disable(p_slot); |
539 | if (rc) { | 348 | if (rc) { |
540 | err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); | 349 | err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); |
541 | /* Done with exclusive hardware access */ | ||
542 | up(&ctrl->crit_sect); | ||
543 | return rc; | ||
544 | } | ||
545 | |||
546 | rc = p_slot->hpc_ops->check_cmd_status(ctrl); | ||
547 | if (rc) { | ||
548 | err("%s: Failed to disable slot, error code(%d)\n", __FUNCTION__, rc); | ||
549 | /* Done with exclusive hardware access */ | ||
550 | up(&ctrl->crit_sect); | ||
551 | return rc; | 350 | return rc; |
552 | } | 351 | } |
553 | 352 | ||
554 | /* Done with exclusive hardware access */ | ||
555 | up(&ctrl->crit_sect); | ||
556 | |||
557 | return(rc); | 353 | return(rc); |
558 | } | 354 | } |
559 | 355 | ||
@@ -580,37 +376,19 @@ static int remove_board(struct slot *p_slot) | |||
580 | if (p_slot->is_a_board) | 376 | if (p_slot->is_a_board) |
581 | p_slot->status = 0x01; | 377 | p_slot->status = 0x01; |
582 | 378 | ||
583 | /* Wait for exclusive access to hardware */ | ||
584 | down(&ctrl->crit_sect); | ||
585 | |||
586 | /* turn off slot, turn on Amber LED, turn off Green LED */ | 379 | /* turn off slot, turn on Amber LED, turn off Green LED */ |
587 | rc = p_slot->hpc_ops->slot_disable(p_slot); | 380 | rc = p_slot->hpc_ops->slot_disable(p_slot); |
588 | if (rc) { | 381 | if (rc) { |
589 | err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); | 382 | err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); |
590 | /* Done with exclusive hardware access */ | ||
591 | up(&ctrl->crit_sect); | ||
592 | return rc; | 383 | return rc; |
593 | } | 384 | } |
594 | |||
595 | rc = p_slot->hpc_ops->check_cmd_status(ctrl); | ||
596 | if (rc) { | ||
597 | err("%s: Failed to disable slot, error code(%d)\n", __FUNCTION__, rc); | ||
598 | /* Done with exclusive hardware access */ | ||
599 | up(&ctrl->crit_sect); | ||
600 | return rc; | ||
601 | } | ||
602 | 385 | ||
603 | rc = p_slot->hpc_ops->set_attention_status(p_slot, 0); | 386 | rc = p_slot->hpc_ops->set_attention_status(p_slot, 0); |
604 | if (rc) { | 387 | if (rc) { |
605 | err("%s: Issue of Set Attention command failed\n", __FUNCTION__); | 388 | err("%s: Issue of Set Attention command failed\n", __FUNCTION__); |
606 | /* Done with exclusive hardware access */ | ||
607 | up(&ctrl->crit_sect); | ||
608 | return rc; | 389 | return rc; |
609 | } | 390 | } |
610 | 391 | ||
611 | /* Done with exclusive hardware access */ | ||
612 | up(&ctrl->crit_sect); | ||
613 | |||
614 | p_slot->pwr_save = 0; | 392 | p_slot->pwr_save = 0; |
615 | p_slot->is_a_board = 0; | 393 | p_slot->is_a_board = 0; |
616 | 394 | ||
@@ -618,13 +396,10 @@ static int remove_board(struct slot *p_slot) | |||
618 | } | 396 | } |
619 | 397 | ||
620 | 398 | ||
621 | static void pushbutton_helper_thread (unsigned long data) | 399 | struct pushbutton_work_info { |
622 | { | 400 | struct slot *p_slot; |
623 | pushbutton_pending = data; | 401 | struct work_struct work; |
624 | 402 | }; | |
625 | up(&event_semaphore); | ||
626 | } | ||
627 | |||
628 | 403 | ||
629 | /** | 404 | /** |
630 | * shpchp_pushbutton_thread | 405 | * shpchp_pushbutton_thread |
@@ -633,96 +408,63 @@ static void pushbutton_helper_thread (unsigned long data) | |||
633 | * Handles all pending events and exits. | 408 | * Handles all pending events and exits. |
634 | * | 409 | * |
635 | */ | 410 | */ |
636 | static void shpchp_pushbutton_thread (unsigned long slot) | 411 | static void shpchp_pushbutton_thread(void *data) |
637 | { | 412 | { |
638 | struct slot *p_slot = (struct slot *) slot; | 413 | struct pushbutton_work_info *info = data; |
639 | u8 getstatus; | 414 | struct slot *p_slot = info->p_slot; |
640 | |||
641 | pushbutton_pending = 0; | ||
642 | |||
643 | if (!p_slot) { | ||
644 | dbg("%s: Error! slot NULL\n", __FUNCTION__); | ||
645 | return; | ||
646 | } | ||
647 | |||
648 | p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | ||
649 | if (getstatus) { | ||
650 | p_slot->state = POWEROFF_STATE; | ||
651 | 415 | ||
416 | mutex_lock(&p_slot->lock); | ||
417 | switch (p_slot->state) { | ||
418 | case POWEROFF_STATE: | ||
419 | mutex_unlock(&p_slot->lock); | ||
652 | shpchp_disable_slot(p_slot); | 420 | shpchp_disable_slot(p_slot); |
421 | mutex_lock(&p_slot->lock); | ||
653 | p_slot->state = STATIC_STATE; | 422 | p_slot->state = STATIC_STATE; |
654 | } else { | 423 | break; |
655 | p_slot->state = POWERON_STATE; | 424 | case POWERON_STATE: |
656 | 425 | mutex_unlock(&p_slot->lock); | |
657 | if (shpchp_enable_slot(p_slot)) { | 426 | if (shpchp_enable_slot(p_slot)) |
658 | /* Wait for exclusive access to hardware */ | ||
659 | down(&p_slot->ctrl->crit_sect); | ||
660 | |||
661 | p_slot->hpc_ops->green_led_off(p_slot); | 427 | p_slot->hpc_ops->green_led_off(p_slot); |
662 | 428 | mutex_lock(&p_slot->lock); | |
663 | /* Done with exclusive hardware access */ | ||
664 | up(&p_slot->ctrl->crit_sect); | ||
665 | } | ||
666 | p_slot->state = STATIC_STATE; | 429 | p_slot->state = STATIC_STATE; |
430 | break; | ||
431 | default: | ||
432 | break; | ||
667 | } | 433 | } |
434 | mutex_unlock(&p_slot->lock); | ||
668 | 435 | ||
669 | return; | 436 | kfree(info); |
670 | } | ||
671 | |||
672 | |||
673 | /* this is the main worker thread */ | ||
674 | static int event_thread(void* data) | ||
675 | { | ||
676 | struct controller *ctrl; | ||
677 | lock_kernel(); | ||
678 | daemonize("shpchpd_event"); | ||
679 | unlock_kernel(); | ||
680 | |||
681 | while (1) { | ||
682 | dbg("!!!!event_thread sleeping\n"); | ||
683 | down_interruptible (&event_semaphore); | ||
684 | dbg("event_thread woken finished = %d\n", event_finished); | ||
685 | if (event_finished || signal_pending(current)) | ||
686 | break; | ||
687 | /* Do stuff here */ | ||
688 | if (pushbutton_pending) | ||
689 | shpchp_pushbutton_thread(pushbutton_pending); | ||
690 | else | ||
691 | for (ctrl = shpchp_ctrl_list; ctrl; ctrl=ctrl->next) | ||
692 | interrupt_event_handler(ctrl); | ||
693 | } | ||
694 | dbg("event_thread signals exit\n"); | ||
695 | up(&event_exit); | ||
696 | return 0; | ||
697 | } | 437 | } |
698 | 438 | ||
699 | int shpchp_event_start_thread (void) | 439 | void queue_pushbutton_work(void *data) |
700 | { | 440 | { |
701 | int pid; | 441 | struct slot *p_slot = data; |
442 | struct pushbutton_work_info *info; | ||
702 | 443 | ||
703 | /* initialize our semaphores */ | 444 | info = kmalloc(sizeof(*info), GFP_KERNEL); |
704 | init_MUTEX_LOCKED(&event_exit); | 445 | if (!info) { |
705 | event_finished=0; | 446 | err("%s: Cannot allocate memory\n", __FUNCTION__); |
706 | 447 | return; | |
707 | init_MUTEX_LOCKED(&event_semaphore); | ||
708 | pid = kernel_thread(event_thread, NULL, 0); | ||
709 | |||
710 | if (pid < 0) { | ||
711 | err ("Can't start up our event thread\n"); | ||
712 | return -1; | ||
713 | } | 448 | } |
714 | return 0; | 449 | info->p_slot = p_slot; |
715 | } | 450 | INIT_WORK(&info->work, shpchp_pushbutton_thread, info); |
716 | |||
717 | 451 | ||
718 | void shpchp_event_stop_thread (void) | 452 | mutex_lock(&p_slot->lock); |
719 | { | 453 | switch (p_slot->state) { |
720 | event_finished = 1; | 454 | case BLINKINGOFF_STATE: |
721 | up(&event_semaphore); | 455 | p_slot->state = POWEROFF_STATE; |
722 | down(&event_exit); | 456 | break; |
457 | case BLINKINGON_STATE: | ||
458 | p_slot->state = POWERON_STATE; | ||
459 | break; | ||
460 | default: | ||
461 | goto out; | ||
462 | } | ||
463 | queue_work(shpchp_wq, &info->work); | ||
464 | out: | ||
465 | mutex_unlock(&p_slot->lock); | ||
723 | } | 466 | } |
724 | 467 | ||
725 | |||
726 | static int update_slot_info (struct slot *slot) | 468 | static int update_slot_info (struct slot *slot) |
727 | { | 469 | { |
728 | struct hotplug_slot_info *info; | 470 | struct hotplug_slot_info *info; |
@@ -742,149 +484,110 @@ static int update_slot_info (struct slot *slot) | |||
742 | return result; | 484 | return result; |
743 | } | 485 | } |
744 | 486 | ||
745 | static void interrupt_event_handler(struct controller *ctrl) | 487 | /* |
488 | * Note: This function must be called with slot->lock held | ||
489 | */ | ||
490 | static void handle_button_press_event(struct slot *p_slot) | ||
746 | { | 491 | { |
747 | int loop = 0; | ||
748 | int change = 1; | ||
749 | u8 hp_slot; | ||
750 | u8 getstatus; | 492 | u8 getstatus; |
751 | struct slot *p_slot; | ||
752 | 493 | ||
753 | while (change) { | 494 | switch (p_slot->state) { |
754 | change = 0; | 495 | case STATIC_STATE: |
755 | 496 | p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | |
756 | for (loop = 0; loop < 10; loop++) { | 497 | if (getstatus) { |
757 | if (ctrl->event_queue[loop].event_type != 0) { | 498 | p_slot->state = BLINKINGOFF_STATE; |
758 | dbg("%s:loop %x event_type %x\n", __FUNCTION__, loop, | 499 | info(msg_button_off, p_slot->number); |
759 | ctrl->event_queue[loop].event_type); | 500 | } else { |
760 | hp_slot = ctrl->event_queue[loop].hp_slot; | 501 | p_slot->state = BLINKINGON_STATE; |
761 | 502 | info(msg_button_on, p_slot->number); | |
762 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); | 503 | } |
763 | 504 | /* blink green LED and turn off amber */ | |
764 | if (ctrl->event_queue[loop].event_type == INT_BUTTON_CANCEL) { | 505 | p_slot->hpc_ops->green_led_blink(p_slot); |
765 | dbg("%s: button cancel\n", __FUNCTION__); | 506 | p_slot->hpc_ops->set_attention_status(p_slot, 0); |
766 | del_timer(&p_slot->task_event); | 507 | |
767 | 508 | schedule_delayed_work(&p_slot->work, 5*HZ); | |
768 | switch (p_slot->state) { | 509 | break; |
769 | case BLINKINGOFF_STATE: | 510 | case BLINKINGOFF_STATE: |
770 | /* Wait for exclusive access to hardware */ | 511 | case BLINKINGON_STATE: |
771 | down(&ctrl->crit_sect); | 512 | /* |
772 | 513 | * Cancel if we are still blinking; this means that we | |
773 | p_slot->hpc_ops->green_led_on(p_slot); | 514 | * press the attention again before the 5 sec. limit |
774 | 515 | * expires to cancel hot-add or hot-remove | |
775 | p_slot->hpc_ops->set_attention_status(p_slot, 0); | 516 | */ |
776 | 517 | info("Button cancel on Slot(%s)\n", p_slot->name); | |
777 | /* Done with exclusive hardware access */ | 518 | dbg("%s: button cancel\n", __FUNCTION__); |
778 | up(&ctrl->crit_sect); | 519 | cancel_delayed_work(&p_slot->work); |
779 | break; | 520 | if (p_slot->state == BLINKINGOFF_STATE) |
780 | case BLINKINGON_STATE: | 521 | p_slot->hpc_ops->green_led_on(p_slot); |
781 | /* Wait for exclusive access to hardware */ | 522 | else |
782 | down(&ctrl->crit_sect); | 523 | p_slot->hpc_ops->green_led_off(p_slot); |
783 | 524 | p_slot->hpc_ops->set_attention_status(p_slot, 0); | |
784 | p_slot->hpc_ops->green_led_off(p_slot); | 525 | info(msg_button_cancel, p_slot->number); |
785 | 526 | p_slot->state = STATIC_STATE; | |
786 | p_slot->hpc_ops->set_attention_status(p_slot, 0); | 527 | break; |
787 | 528 | case POWEROFF_STATE: | |
788 | /* Done with exclusive hardware access */ | 529 | case POWERON_STATE: |
789 | up(&ctrl->crit_sect); | 530 | /* |
790 | 531 | * Ignore if the slot is on power-on or power-off state; | |
791 | break; | 532 | * this means that the previous attention button action |
792 | default: | 533 | * to hot-add or hot-remove is undergoing |
793 | warn("Not a valid state\n"); | 534 | */ |
794 | return; | 535 | info("Button ignore on Slot(%s)\n", p_slot->name); |
795 | } | 536 | update_slot_info(p_slot); |
796 | info(msg_button_cancel, p_slot->number); | 537 | break; |
797 | p_slot->state = STATIC_STATE; | 538 | default: |
798 | } else if (ctrl->event_queue[loop].event_type == INT_BUTTON_PRESS) { | 539 | warn("Not a valid state\n"); |
799 | /* Button Pressed (No action on 1st press...) */ | 540 | break; |
800 | dbg("%s: Button pressed\n", __FUNCTION__); | ||
801 | |||
802 | p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | ||
803 | if (getstatus) { | ||
804 | /* slot is on */ | ||
805 | dbg("%s: slot is on\n", __FUNCTION__); | ||
806 | p_slot->state = BLINKINGOFF_STATE; | ||
807 | info(msg_button_off, p_slot->number); | ||
808 | } else { | ||
809 | /* slot is off */ | ||
810 | dbg("%s: slot is off\n", __FUNCTION__); | ||
811 | p_slot->state = BLINKINGON_STATE; | ||
812 | info(msg_button_on, p_slot->number); | ||
813 | } | ||
814 | |||
815 | /* Wait for exclusive access to hardware */ | ||
816 | down(&ctrl->crit_sect); | ||
817 | |||
818 | /* blink green LED and turn off amber */ | ||
819 | p_slot->hpc_ops->green_led_blink(p_slot); | ||
820 | |||
821 | p_slot->hpc_ops->set_attention_status(p_slot, 0); | ||
822 | |||
823 | /* Done with exclusive hardware access */ | ||
824 | up(&ctrl->crit_sect); | ||
825 | |||
826 | init_timer(&p_slot->task_event); | ||
827 | p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */ | ||
828 | p_slot->task_event.function = (void (*)(unsigned long)) pushbutton_helper_thread; | ||
829 | p_slot->task_event.data = (unsigned long) p_slot; | ||
830 | |||
831 | dbg("%s: add_timer p_slot = %p\n", __FUNCTION__,(void *) p_slot); | ||
832 | add_timer(&p_slot->task_event); | ||
833 | } else if (ctrl->event_queue[loop].event_type == INT_POWER_FAULT) { | ||
834 | /***********POWER FAULT********************/ | ||
835 | dbg("%s: power fault\n", __FUNCTION__); | ||
836 | /* Wait for exclusive access to hardware */ | ||
837 | down(&ctrl->crit_sect); | ||
838 | |||
839 | p_slot->hpc_ops->set_attention_status(p_slot, 1); | ||
840 | |||
841 | p_slot->hpc_ops->green_led_off(p_slot); | ||
842 | |||
843 | /* Done with exclusive hardware access */ | ||
844 | up(&ctrl->crit_sect); | ||
845 | } else { | ||
846 | /* refresh notification */ | ||
847 | if (p_slot) | ||
848 | update_slot_info(p_slot); | ||
849 | } | ||
850 | |||
851 | ctrl->event_queue[loop].event_type = 0; | ||
852 | |||
853 | change = 1; | ||
854 | } | ||
855 | } /* End of FOR loop */ | ||
856 | } | 541 | } |
542 | } | ||
543 | |||
544 | static void interrupt_event_handler(void *data) | ||
545 | { | ||
546 | struct event_info *info = data; | ||
547 | struct slot *p_slot = info->p_slot; | ||
548 | |||
549 | mutex_lock(&p_slot->lock); | ||
550 | switch (info->event_type) { | ||
551 | case INT_BUTTON_PRESS: | ||
552 | handle_button_press_event(p_slot); | ||
553 | break; | ||
554 | case INT_POWER_FAULT: | ||
555 | dbg("%s: power fault\n", __FUNCTION__); | ||
556 | p_slot->hpc_ops->set_attention_status(p_slot, 1); | ||
557 | p_slot->hpc_ops->green_led_off(p_slot); | ||
558 | break; | ||
559 | default: | ||
560 | update_slot_info(p_slot); | ||
561 | break; | ||
562 | } | ||
563 | mutex_unlock(&p_slot->lock); | ||
857 | 564 | ||
858 | return; | 565 | kfree(info); |
859 | } | 566 | } |
860 | 567 | ||
861 | 568 | ||
862 | int shpchp_enable_slot (struct slot *p_slot) | 569 | static int shpchp_enable_slot (struct slot *p_slot) |
863 | { | 570 | { |
864 | u8 getstatus = 0; | 571 | u8 getstatus = 0; |
865 | int rc; | 572 | int rc, retval = -ENODEV; |
866 | 573 | ||
867 | /* Check to see if (latch closed, card present, power off) */ | 574 | /* Check to see if (latch closed, card present, power off) */ |
868 | down(&p_slot->ctrl->crit_sect); | 575 | mutex_lock(&p_slot->ctrl->crit_sect); |
869 | rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); | 576 | rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); |
870 | if (rc || !getstatus) { | 577 | if (rc || !getstatus) { |
871 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); | 578 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); |
872 | up(&p_slot->ctrl->crit_sect); | 579 | goto out; |
873 | return -ENODEV; | ||
874 | } | 580 | } |
875 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 581 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
876 | if (rc || getstatus) { | 582 | if (rc || getstatus) { |
877 | info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); | 583 | info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); |
878 | up(&p_slot->ctrl->crit_sect); | 584 | goto out; |
879 | return -ENODEV; | ||
880 | } | 585 | } |
881 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | 586 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
882 | if (rc || getstatus) { | 587 | if (rc || getstatus) { |
883 | info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); | 588 | info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); |
884 | up(&p_slot->ctrl->crit_sect); | 589 | goto out; |
885 | return -ENODEV; | ||
886 | } | 590 | } |
887 | up(&p_slot->ctrl->crit_sect); | ||
888 | 591 | ||
889 | p_slot->is_a_board = 1; | 592 | p_slot->is_a_board = 1; |
890 | 593 | ||
@@ -899,56 +602,119 @@ int shpchp_enable_slot (struct slot *p_slot) | |||
899 | && p_slot->ctrl->num_slots == 1) { | 602 | && p_slot->ctrl->num_slots == 1) { |
900 | /* handle amd pogo errata; this must be done before enable */ | 603 | /* handle amd pogo errata; this must be done before enable */ |
901 | amd_pogo_errata_save_misc_reg(p_slot); | 604 | amd_pogo_errata_save_misc_reg(p_slot); |
902 | rc = board_added(p_slot); | 605 | retval = board_added(p_slot); |
903 | /* handle amd pogo errata; this must be done after enable */ | 606 | /* handle amd pogo errata; this must be done after enable */ |
904 | amd_pogo_errata_restore_misc_reg(p_slot); | 607 | amd_pogo_errata_restore_misc_reg(p_slot); |
905 | } else | 608 | } else |
906 | rc = board_added(p_slot); | 609 | retval = board_added(p_slot); |
907 | 610 | ||
908 | if (rc) { | 611 | if (retval) { |
909 | p_slot->hpc_ops->get_adapter_status(p_slot, | 612 | p_slot->hpc_ops->get_adapter_status(p_slot, |
910 | &(p_slot->presence_save)); | 613 | &(p_slot->presence_save)); |
911 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 614 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
912 | } | 615 | } |
913 | 616 | ||
914 | update_slot_info(p_slot); | 617 | update_slot_info(p_slot); |
915 | return rc; | 618 | out: |
619 | mutex_unlock(&p_slot->ctrl->crit_sect); | ||
620 | return retval; | ||
916 | } | 621 | } |
917 | 622 | ||
918 | 623 | ||
919 | int shpchp_disable_slot (struct slot *p_slot) | 624 | static int shpchp_disable_slot (struct slot *p_slot) |
920 | { | 625 | { |
921 | u8 getstatus = 0; | 626 | u8 getstatus = 0; |
922 | int ret = 0; | 627 | int rc, retval = -ENODEV; |
923 | 628 | ||
924 | if (!p_slot->ctrl) | 629 | if (!p_slot->ctrl) |
925 | return -ENODEV; | 630 | return -ENODEV; |
926 | 631 | ||
927 | /* Check to see if (latch closed, card present, power on) */ | 632 | /* Check to see if (latch closed, card present, power on) */ |
928 | down(&p_slot->ctrl->crit_sect); | 633 | mutex_lock(&p_slot->ctrl->crit_sect); |
929 | 634 | ||
930 | ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); | 635 | rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); |
931 | if (ret || !getstatus) { | 636 | if (rc || !getstatus) { |
932 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); | 637 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); |
933 | up(&p_slot->ctrl->crit_sect); | 638 | goto out; |
934 | return -ENODEV; | ||
935 | } | 639 | } |
936 | ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 640 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
937 | if (ret || getstatus) { | 641 | if (rc || getstatus) { |
938 | info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); | 642 | info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); |
939 | up(&p_slot->ctrl->crit_sect); | 643 | goto out; |
940 | return -ENODEV; | ||
941 | } | 644 | } |
942 | ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | 645 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
943 | if (ret || !getstatus) { | 646 | if (rc || !getstatus) { |
944 | info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); | 647 | info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); |
945 | up(&p_slot->ctrl->crit_sect); | 648 | goto out; |
946 | return -ENODEV; | ||
947 | } | 649 | } |
948 | up(&p_slot->ctrl->crit_sect); | ||
949 | 650 | ||
950 | ret = remove_board(p_slot); | 651 | retval = remove_board(p_slot); |
951 | update_slot_info(p_slot); | 652 | update_slot_info(p_slot); |
952 | return ret; | 653 | out: |
654 | mutex_unlock(&p_slot->ctrl->crit_sect); | ||
655 | return retval; | ||
953 | } | 656 | } |
954 | 657 | ||
658 | int shpchp_sysfs_enable_slot(struct slot *p_slot) | ||
659 | { | ||
660 | int retval = -ENODEV; | ||
661 | |||
662 | mutex_lock(&p_slot->lock); | ||
663 | switch (p_slot->state) { | ||
664 | case BLINKINGON_STATE: | ||
665 | cancel_delayed_work(&p_slot->work); | ||
666 | case STATIC_STATE: | ||
667 | p_slot->state = POWERON_STATE; | ||
668 | mutex_unlock(&p_slot->lock); | ||
669 | retval = shpchp_enable_slot(p_slot); | ||
670 | mutex_lock(&p_slot->lock); | ||
671 | p_slot->state = STATIC_STATE; | ||
672 | break; | ||
673 | case POWERON_STATE: | ||
674 | info("Slot %s is already in powering on state\n", | ||
675 | p_slot->name); | ||
676 | break; | ||
677 | case BLINKINGOFF_STATE: | ||
678 | case POWEROFF_STATE: | ||
679 | info("Already enabled on slot %s\n", p_slot->name); | ||
680 | break; | ||
681 | default: | ||
682 | err("Not a valid state on slot %s\n", p_slot->name); | ||
683 | break; | ||
684 | } | ||
685 | mutex_unlock(&p_slot->lock); | ||
686 | |||
687 | return retval; | ||
688 | } | ||
689 | |||
690 | int shpchp_sysfs_disable_slot(struct slot *p_slot) | ||
691 | { | ||
692 | int retval = -ENODEV; | ||
693 | |||
694 | mutex_lock(&p_slot->lock); | ||
695 | switch (p_slot->state) { | ||
696 | case BLINKINGOFF_STATE: | ||
697 | cancel_delayed_work(&p_slot->work); | ||
698 | case STATIC_STATE: | ||
699 | p_slot->state = POWEROFF_STATE; | ||
700 | mutex_unlock(&p_slot->lock); | ||
701 | retval = shpchp_disable_slot(p_slot); | ||
702 | mutex_lock(&p_slot->lock); | ||
703 | p_slot->state = STATIC_STATE; | ||
704 | break; | ||
705 | case POWEROFF_STATE: | ||
706 | info("Slot %s is already in powering off state\n", | ||
707 | p_slot->name); | ||
708 | break; | ||
709 | case BLINKINGON_STATE: | ||
710 | case POWERON_STATE: | ||
711 | info("Already disabled on slot %s\n", p_slot->name); | ||
712 | break; | ||
713 | default: | ||
714 | err("Not a valid state on slot %s\n", p_slot->name); | ||
715 | break; | ||
716 | } | ||
717 | mutex_unlock(&p_slot->lock); | ||
718 | |||
719 | return retval; | ||
720 | } | ||
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c index b4226ff3a854..66123cf4deaa 100644 --- a/drivers/pci/hotplug/shpchp_hpc.c +++ b/drivers/pci/hotplug/shpchp_hpc.c | |||
@@ -82,31 +82,6 @@ | |||
82 | #define SLOT_100MHZ_PCIX_533 0x0f000000 | 82 | #define SLOT_100MHZ_PCIX_533 0x0f000000 |
83 | #define SLOT_133MHZ_PCIX_533 0xf0000000 | 83 | #define SLOT_133MHZ_PCIX_533 0xf0000000 |
84 | 84 | ||
85 | |||
86 | /* Secondary Bus Configuration Register */ | ||
87 | /* For PI = 1, Bits 0 to 2 have been encoded as follows to show current bus speed/mode */ | ||
88 | #define PCI_33MHZ 0x0 | ||
89 | #define PCI_66MHZ 0x1 | ||
90 | #define PCIX_66MHZ 0x2 | ||
91 | #define PCIX_100MHZ 0x3 | ||
92 | #define PCIX_133MHZ 0x4 | ||
93 | |||
94 | /* For PI = 2, Bits 0 to 3 have been encoded as follows to show current bus speed/mode */ | ||
95 | #define PCI_33MHZ 0x0 | ||
96 | #define PCI_66MHZ 0x1 | ||
97 | #define PCIX_66MHZ 0x2 | ||
98 | #define PCIX_100MHZ 0x3 | ||
99 | #define PCIX_133MHZ 0x4 | ||
100 | #define PCIX_66MHZ_ECC 0x5 | ||
101 | #define PCIX_100MHZ_ECC 0x6 | ||
102 | #define PCIX_133MHZ_ECC 0x7 | ||
103 | #define PCIX_66MHZ_266 0x9 | ||
104 | #define PCIX_100MHZ_266 0xa | ||
105 | #define PCIX_133MHZ_266 0xb | ||
106 | #define PCIX_66MHZ_533 0x11 | ||
107 | #define PCIX_100MHZ_533 0x12 | ||
108 | #define PCIX_133MHZ_533 0x13 | ||
109 | |||
110 | /* Slot Configuration */ | 85 | /* Slot Configuration */ |
111 | #define SLOT_NUM 0x0000001F | 86 | #define SLOT_NUM 0x0000001F |
112 | #define FIRST_DEV_NUM 0x00001F00 | 87 | #define FIRST_DEV_NUM 0x00001F00 |
@@ -231,6 +206,7 @@ static spinlock_t list_lock; | |||
231 | static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs); | 206 | static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs); |
232 | 207 | ||
233 | static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int seconds); | 208 | static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int seconds); |
209 | static int hpc_check_cmd_status(struct controller *ctrl); | ||
234 | 210 | ||
235 | /* This is the interrupt polling timeout function. */ | 211 | /* This is the interrupt polling timeout function. */ |
236 | static void int_poll_timeout(unsigned long lphp_ctlr) | 212 | static void int_poll_timeout(unsigned long lphp_ctlr) |
@@ -303,10 +279,13 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd) | |||
303 | int i; | 279 | int i; |
304 | 280 | ||
305 | DBG_ENTER_ROUTINE | 281 | DBG_ENTER_ROUTINE |
306 | 282 | ||
283 | mutex_lock(&slot->ctrl->cmd_lock); | ||
284 | |||
307 | if (!php_ctlr) { | 285 | if (!php_ctlr) { |
308 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); | 286 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
309 | return -1; | 287 | retval = -EINVAL; |
288 | goto out; | ||
310 | } | 289 | } |
311 | 290 | ||
312 | for (i = 0; i < 10; i++) { | 291 | for (i = 0; i < 10; i++) { |
@@ -323,7 +302,8 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd) | |||
323 | if (cmd_status & 0x1) { | 302 | if (cmd_status & 0x1) { |
324 | /* After 1 sec and and the controller is still busy */ | 303 | /* After 1 sec and and the controller is still busy */ |
325 | err("%s : Controller is still busy after 1 sec.\n", __FUNCTION__); | 304 | err("%s : Controller is still busy after 1 sec.\n", __FUNCTION__); |
326 | return -1; | 305 | retval = -EBUSY; |
306 | goto out; | ||
327 | } | 307 | } |
328 | 308 | ||
329 | ++t_slot; | 309 | ++t_slot; |
@@ -340,6 +320,17 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd) | |||
340 | * Wait for command completion. | 320 | * Wait for command completion. |
341 | */ | 321 | */ |
342 | retval = shpc_wait_cmd(slot->ctrl); | 322 | retval = shpc_wait_cmd(slot->ctrl); |
323 | if (retval) | ||
324 | goto out; | ||
325 | |||
326 | cmd_status = hpc_check_cmd_status(slot->ctrl); | ||
327 | if (cmd_status) { | ||
328 | err("%s: Failed to issued command 0x%x (error code = %d)\n", | ||
329 | __FUNCTION__, cmd, cmd_status); | ||
330 | retval = -EIO; | ||
331 | } | ||
332 | out: | ||
333 | mutex_unlock(&slot->ctrl->cmd_lock); | ||
343 | 334 | ||
344 | DBG_LEAVE_ROUTINE | 335 | DBG_LEAVE_ROUTINE |
345 | return retval; | 336 | return retval; |
@@ -532,81 +523,41 @@ static int hpc_get_prog_int(struct slot *slot, u8 *prog_int) | |||
532 | 523 | ||
533 | static int hpc_get_adapter_speed(struct slot *slot, enum pci_bus_speed *value) | 524 | static int hpc_get_adapter_speed(struct slot *slot, enum pci_bus_speed *value) |
534 | { | 525 | { |
535 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; | ||
536 | u32 slot_reg; | ||
537 | u16 slot_status, sec_bus_status; | ||
538 | u8 m66_cap, pcix_cap, pi; | ||
539 | int retval = 0; | 526 | int retval = 0; |
527 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; | ||
528 | u32 slot_reg = readl(php_ctlr->creg + SLOT1 + 4 * slot->hp_slot); | ||
529 | u8 pcix_cap = (slot_reg >> 12) & 7; | ||
530 | u8 m66_cap = (slot_reg >> 9) & 1; | ||
540 | 531 | ||
541 | DBG_ENTER_ROUTINE | 532 | DBG_ENTER_ROUTINE |
542 | 533 | ||
543 | if (!slot->ctrl->hpc_ctlr_handle) { | 534 | dbg("%s: slot_reg = %x, pcix_cap = %x, m66_cap = %x\n", |
544 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); | 535 | __FUNCTION__, slot_reg, pcix_cap, m66_cap); |
545 | return -1; | ||
546 | } | ||
547 | |||
548 | if (slot->hp_slot >= php_ctlr->num_slots) { | ||
549 | err("%s: Invalid HPC slot number!\n", __FUNCTION__); | ||
550 | return -1; | ||
551 | } | ||
552 | |||
553 | pi = readb(php_ctlr->creg + PROG_INTERFACE); | ||
554 | slot_reg = readl(php_ctlr->creg + SLOT1 + 4*(slot->hp_slot)); | ||
555 | dbg("%s: pi = %d, slot_reg = %x\n", __FUNCTION__, pi, slot_reg); | ||
556 | slot_status = (u16) slot_reg; | ||
557 | dbg("%s: slot_status = %x\n", __FUNCTION__, slot_status); | ||
558 | sec_bus_status = readw(php_ctlr->creg + SEC_BUS_CONFIG); | ||
559 | |||
560 | pcix_cap = (u8) ((slot_status & 0x3000) >> 12); | ||
561 | dbg("%s: pcix_cap = %x\n", __FUNCTION__, pcix_cap); | ||
562 | m66_cap = (u8) ((slot_status & 0x0200) >> 9); | ||
563 | dbg("%s: m66_cap = %x\n", __FUNCTION__, m66_cap); | ||
564 | |||
565 | 536 | ||
566 | if (pi == 2) { | 537 | switch (pcix_cap) { |
567 | switch (pcix_cap) { | 538 | case 0x0: |
568 | case 0: | 539 | *value = m66_cap ? PCI_SPEED_66MHz : PCI_SPEED_33MHz; |
569 | *value = m66_cap ? PCI_SPEED_66MHz : PCI_SPEED_33MHz; | 540 | break; |
570 | break; | 541 | case 0x1: |
571 | case 1: | 542 | *value = PCI_SPEED_66MHz_PCIX; |
572 | *value = PCI_SPEED_66MHz_PCIX; | 543 | break; |
573 | break; | 544 | case 0x3: |
574 | case 3: | 545 | *value = PCI_SPEED_133MHz_PCIX; |
575 | *value = PCI_SPEED_133MHz_PCIX; | 546 | break; |
576 | break; | 547 | case 0x4: |
577 | case 4: | 548 | *value = PCI_SPEED_133MHz_PCIX_266; |
578 | *value = PCI_SPEED_133MHz_PCIX_266; | 549 | break; |
579 | break; | 550 | case 0x5: |
580 | case 5: | 551 | *value = PCI_SPEED_133MHz_PCIX_533; |
581 | *value = PCI_SPEED_133MHz_PCIX_533; | 552 | break; |
582 | break; | 553 | case 0x2: |
583 | case 2: /* Reserved */ | 554 | default: |
584 | default: | 555 | *value = PCI_SPEED_UNKNOWN; |
585 | *value = PCI_SPEED_UNKNOWN; | 556 | retval = -ENODEV; |
586 | retval = -ENODEV; | 557 | break; |
587 | break; | ||
588 | } | ||
589 | } else { | ||
590 | switch (pcix_cap) { | ||
591 | case 0: | ||
592 | *value = m66_cap ? PCI_SPEED_66MHz : PCI_SPEED_33MHz; | ||
593 | break; | ||
594 | case 1: | ||
595 | *value = PCI_SPEED_66MHz_PCIX; | ||
596 | break; | ||
597 | case 3: | ||
598 | *value = PCI_SPEED_133MHz_PCIX; | ||
599 | break; | ||
600 | case 2: /* Reserved */ | ||
601 | default: | ||
602 | *value = PCI_SPEED_UNKNOWN; | ||
603 | retval = -ENODEV; | ||
604 | break; | ||
605 | } | ||
606 | } | 558 | } |
607 | 559 | ||
608 | dbg("Adapter speed = %d\n", *value); | 560 | dbg("Adapter speed = %d\n", *value); |
609 | |||
610 | DBG_LEAVE_ROUTINE | 561 | DBG_LEAVE_ROUTINE |
611 | return retval; | 562 | return retval; |
612 | } | 563 | } |
@@ -797,6 +748,7 @@ static void hpc_release_ctlr(struct controller *ctrl) | |||
797 | { | 748 | { |
798 | struct php_ctlr_state_s *php_ctlr = ctrl->hpc_ctlr_handle; | 749 | struct php_ctlr_state_s *php_ctlr = ctrl->hpc_ctlr_handle; |
799 | struct php_ctlr_state_s *p, *p_prev; | 750 | struct php_ctlr_state_s *p, *p_prev; |
751 | int i; | ||
800 | 752 | ||
801 | DBG_ENTER_ROUTINE | 753 | DBG_ENTER_ROUTINE |
802 | 754 | ||
@@ -805,6 +757,14 @@ static void hpc_release_ctlr(struct controller *ctrl) | |||
805 | return ; | 757 | return ; |
806 | } | 758 | } |
807 | 759 | ||
760 | /* | ||
761 | * Mask all slot event interrupts | ||
762 | */ | ||
763 | for (i = 0; i < ctrl->num_slots; i++) | ||
764 | writel(0xffff3fff, php_ctlr->creg + SLOT1 + (4 * i)); | ||
765 | |||
766 | cleanup_slots(ctrl); | ||
767 | |||
808 | if (shpchp_poll_mode) { | 768 | if (shpchp_poll_mode) { |
809 | del_timer(&php_ctlr->int_poll_timer); | 769 | del_timer(&php_ctlr->int_poll_timer); |
810 | } else { | 770 | } else { |
@@ -814,6 +774,7 @@ static void hpc_release_ctlr(struct controller *ctrl) | |||
814 | pci_disable_msi(php_ctlr->pci_dev); | 774 | pci_disable_msi(php_ctlr->pci_dev); |
815 | } | 775 | } |
816 | } | 776 | } |
777 | |||
817 | if (php_ctlr->pci_dev) { | 778 | if (php_ctlr->pci_dev) { |
818 | iounmap(php_ctlr->creg); | 779 | iounmap(php_ctlr->creg); |
819 | release_mem_region(ctrl->mmio_base, ctrl->mmio_size); | 780 | release_mem_region(ctrl->mmio_base, ctrl->mmio_size); |
@@ -939,98 +900,66 @@ static int hpc_slot_disable(struct slot * slot) | |||
939 | 900 | ||
940 | static int hpc_set_bus_speed_mode(struct slot * slot, enum pci_bus_speed value) | 901 | static int hpc_set_bus_speed_mode(struct slot * slot, enum pci_bus_speed value) |
941 | { | 902 | { |
942 | u8 slot_cmd; | 903 | int retval; |
943 | u8 pi; | ||
944 | int retval = 0; | ||
945 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; | 904 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; |
905 | u8 pi, cmd; | ||
946 | 906 | ||
947 | DBG_ENTER_ROUTINE | 907 | DBG_ENTER_ROUTINE |
948 | |||
949 | if (!slot->ctrl->hpc_ctlr_handle) { | ||
950 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); | ||
951 | return -1; | ||
952 | } | ||
953 | 908 | ||
954 | pi = readb(php_ctlr->creg + PROG_INTERFACE); | 909 | pi = readb(php_ctlr->creg + PROG_INTERFACE); |
955 | 910 | if ((pi == 1) && (value > PCI_SPEED_133MHz_PCIX)) | |
956 | if (pi == 1) { | 911 | return -EINVAL; |
957 | switch (value) { | ||
958 | case 0: | ||
959 | slot_cmd = SETA_PCI_33MHZ; | ||
960 | break; | ||
961 | case 1: | ||
962 | slot_cmd = SETA_PCI_66MHZ; | ||
963 | break; | ||
964 | case 2: | ||
965 | slot_cmd = SETA_PCIX_66MHZ; | ||
966 | break; | ||
967 | case 3: | ||
968 | slot_cmd = SETA_PCIX_100MHZ; | ||
969 | break; | ||
970 | case 4: | ||
971 | slot_cmd = SETA_PCIX_133MHZ; | ||
972 | break; | ||
973 | default: | ||
974 | slot_cmd = PCI_SPEED_UNKNOWN; | ||
975 | retval = -ENODEV; | ||
976 | return retval; | ||
977 | } | ||
978 | } else { | ||
979 | switch (value) { | ||
980 | case 0: | ||
981 | slot_cmd = SETB_PCI_33MHZ; | ||
982 | break; | ||
983 | case 1: | ||
984 | slot_cmd = SETB_PCI_66MHZ; | ||
985 | break; | ||
986 | case 2: | ||
987 | slot_cmd = SETB_PCIX_66MHZ_PM; | ||
988 | break; | ||
989 | case 3: | ||
990 | slot_cmd = SETB_PCIX_100MHZ_PM; | ||
991 | break; | ||
992 | case 4: | ||
993 | slot_cmd = SETB_PCIX_133MHZ_PM; | ||
994 | break; | ||
995 | case 5: | ||
996 | slot_cmd = SETB_PCIX_66MHZ_EM; | ||
997 | break; | ||
998 | case 6: | ||
999 | slot_cmd = SETB_PCIX_100MHZ_EM; | ||
1000 | break; | ||
1001 | case 7: | ||
1002 | slot_cmd = SETB_PCIX_133MHZ_EM; | ||
1003 | break; | ||
1004 | case 8: | ||
1005 | slot_cmd = SETB_PCIX_66MHZ_266; | ||
1006 | break; | ||
1007 | case 0x9: | ||
1008 | slot_cmd = SETB_PCIX_100MHZ_266; | ||
1009 | break; | ||
1010 | case 0xa: | ||
1011 | slot_cmd = SETB_PCIX_133MHZ_266; | ||
1012 | break; | ||
1013 | case 0xb: | ||
1014 | slot_cmd = SETB_PCIX_66MHZ_533; | ||
1015 | break; | ||
1016 | case 0xc: | ||
1017 | slot_cmd = SETB_PCIX_100MHZ_533; | ||
1018 | break; | ||
1019 | case 0xd: | ||
1020 | slot_cmd = SETB_PCIX_133MHZ_533; | ||
1021 | break; | ||
1022 | default: | ||
1023 | slot_cmd = PCI_SPEED_UNKNOWN; | ||
1024 | retval = -ENODEV; | ||
1025 | return retval; | ||
1026 | } | ||
1027 | 912 | ||
913 | switch (value) { | ||
914 | case PCI_SPEED_33MHz: | ||
915 | cmd = SETA_PCI_33MHZ; | ||
916 | break; | ||
917 | case PCI_SPEED_66MHz: | ||
918 | cmd = SETA_PCI_66MHZ; | ||
919 | break; | ||
920 | case PCI_SPEED_66MHz_PCIX: | ||
921 | cmd = SETA_PCIX_66MHZ; | ||
922 | break; | ||
923 | case PCI_SPEED_100MHz_PCIX: | ||
924 | cmd = SETA_PCIX_100MHZ; | ||
925 | break; | ||
926 | case PCI_SPEED_133MHz_PCIX: | ||
927 | cmd = SETA_PCIX_133MHZ; | ||
928 | break; | ||
929 | case PCI_SPEED_66MHz_PCIX_ECC: | ||
930 | cmd = SETB_PCIX_66MHZ_EM; | ||
931 | break; | ||
932 | case PCI_SPEED_100MHz_PCIX_ECC: | ||
933 | cmd = SETB_PCIX_100MHZ_EM; | ||
934 | break; | ||
935 | case PCI_SPEED_133MHz_PCIX_ECC: | ||
936 | cmd = SETB_PCIX_133MHZ_EM; | ||
937 | break; | ||
938 | case PCI_SPEED_66MHz_PCIX_266: | ||
939 | cmd = SETB_PCIX_66MHZ_266; | ||
940 | break; | ||
941 | case PCI_SPEED_100MHz_PCIX_266: | ||
942 | cmd = SETB_PCIX_100MHZ_266; | ||
943 | break; | ||
944 | case PCI_SPEED_133MHz_PCIX_266: | ||
945 | cmd = SETB_PCIX_133MHZ_266; | ||
946 | break; | ||
947 | case PCI_SPEED_66MHz_PCIX_533: | ||
948 | cmd = SETB_PCIX_66MHZ_533; | ||
949 | break; | ||
950 | case PCI_SPEED_100MHz_PCIX_533: | ||
951 | cmd = SETB_PCIX_100MHZ_533; | ||
952 | break; | ||
953 | case PCI_SPEED_133MHz_PCIX_533: | ||
954 | cmd = SETB_PCIX_133MHZ_533; | ||
955 | break; | ||
956 | default: | ||
957 | return -EINVAL; | ||
1028 | } | 958 | } |
1029 | retval = shpc_write_cmd(slot, 0, slot_cmd); | 959 | |
1030 | if (retval) { | 960 | retval = shpc_write_cmd(slot, 0, cmd); |
961 | if (retval) | ||
1031 | err("%s: Write command failed!\n", __FUNCTION__); | 962 | err("%s: Write command failed!\n", __FUNCTION__); |
1032 | return -1; | ||
1033 | } | ||
1034 | 963 | ||
1035 | DBG_LEAVE_ROUTINE | 964 | DBG_LEAVE_ROUTINE |
1036 | return retval; | 965 | return retval; |
@@ -1093,14 +1022,8 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs) | |||
1093 | wake_up_interruptible(&ctrl->queue); | 1022 | wake_up_interruptible(&ctrl->queue); |
1094 | } | 1023 | } |
1095 | 1024 | ||
1096 | if ((intr_loc = (intr_loc >> 1)) == 0) { | 1025 | if ((intr_loc = (intr_loc >> 1)) == 0) |
1097 | /* Unmask Global Interrupt Mask */ | 1026 | goto out; |
1098 | temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE); | ||
1099 | temp_dword &= 0xfffffffe; | ||
1100 | writel(temp_dword, php_ctlr->creg + SERR_INTR_ENABLE); | ||
1101 | |||
1102 | return IRQ_NONE; | ||
1103 | } | ||
1104 | 1027 | ||
1105 | for (hp_slot = 0; hp_slot < ctrl->num_slots; hp_slot++) { | 1028 | for (hp_slot = 0; hp_slot < ctrl->num_slots; hp_slot++) { |
1106 | /* To find out which slot has interrupt pending */ | 1029 | /* To find out which slot has interrupt pending */ |
@@ -1130,6 +1053,7 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs) | |||
1130 | dbg("%s: intr_loc2 = %x\n",__FUNCTION__, intr_loc2); | 1053 | dbg("%s: intr_loc2 = %x\n",__FUNCTION__, intr_loc2); |
1131 | } | 1054 | } |
1132 | } | 1055 | } |
1056 | out: | ||
1133 | if (!shpchp_poll_mode) { | 1057 | if (!shpchp_poll_mode) { |
1134 | /* Unmask Global Interrupt Mask */ | 1058 | /* Unmask Global Interrupt Mask */ |
1135 | temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE); | 1059 | temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE); |
@@ -1142,64 +1066,43 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs) | |||
1142 | 1066 | ||
1143 | static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value) | 1067 | static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value) |
1144 | { | 1068 | { |
1069 | int retval = 0; | ||
1145 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; | 1070 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; |
1146 | enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN; | 1071 | enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN; |
1147 | int retval = 0; | 1072 | u8 pi = readb(php_ctlr->creg + PROG_INTERFACE); |
1148 | u8 pi; | 1073 | u32 slot_avail1 = readl(php_ctlr->creg + SLOT_AVAIL1); |
1149 | u32 slot_avail1, slot_avail2; | 1074 | u32 slot_avail2 = readl(php_ctlr->creg + SLOT_AVAIL2); |
1150 | 1075 | ||
1151 | DBG_ENTER_ROUTINE | 1076 | DBG_ENTER_ROUTINE |
1152 | 1077 | ||
1153 | if (!slot->ctrl->hpc_ctlr_handle) { | ||
1154 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); | ||
1155 | return -1; | ||
1156 | } | ||
1157 | |||
1158 | if (slot->hp_slot >= php_ctlr->num_slots) { | ||
1159 | err("%s: Invalid HPC slot number!\n", __FUNCTION__); | ||
1160 | return -1; | ||
1161 | } | ||
1162 | |||
1163 | pi = readb(php_ctlr->creg + PROG_INTERFACE); | ||
1164 | slot_avail1 = readl(php_ctlr->creg + SLOT_AVAIL1); | ||
1165 | slot_avail2 = readl(php_ctlr->creg + SLOT_AVAIL2); | ||
1166 | |||
1167 | if (pi == 2) { | 1078 | if (pi == 2) { |
1168 | if (slot_avail2 & SLOT_133MHZ_PCIX_533) | 1079 | if (slot_avail2 & SLOT_133MHZ_PCIX_533) |
1169 | bus_speed = PCIX_133MHZ_533; | 1080 | bus_speed = PCI_SPEED_133MHz_PCIX_533; |
1170 | else if (slot_avail2 & SLOT_100MHZ_PCIX_533) | 1081 | else if (slot_avail2 & SLOT_100MHZ_PCIX_533) |
1171 | bus_speed = PCIX_100MHZ_533; | 1082 | bus_speed = PCI_SPEED_100MHz_PCIX_533; |
1172 | else if (slot_avail2 & SLOT_66MHZ_PCIX_533) | 1083 | else if (slot_avail2 & SLOT_66MHZ_PCIX_533) |
1173 | bus_speed = PCIX_66MHZ_533; | 1084 | bus_speed = PCI_SPEED_66MHz_PCIX_533; |
1174 | else if (slot_avail2 & SLOT_133MHZ_PCIX_266) | 1085 | else if (slot_avail2 & SLOT_133MHZ_PCIX_266) |
1175 | bus_speed = PCIX_133MHZ_266; | 1086 | bus_speed = PCI_SPEED_133MHz_PCIX_266; |
1176 | else if (slot_avail2 & SLOT_100MHZ_PCIX_266) | 1087 | else if (slot_avail2 & SLOT_100MHZ_PCIX_266) |
1177 | bus_speed = PCIX_100MHZ_266; | 1088 | bus_speed = PCI_SPEED_100MHz_PCIX_266; |
1178 | else if (slot_avail2 & SLOT_66MHZ_PCIX_266) | 1089 | else if (slot_avail2 & SLOT_66MHZ_PCIX_266) |
1179 | bus_speed = PCIX_66MHZ_266; | 1090 | bus_speed = PCI_SPEED_66MHz_PCIX_266; |
1180 | else if (slot_avail1 & SLOT_133MHZ_PCIX) | 1091 | } |
1181 | bus_speed = PCIX_133MHZ; | 1092 | |
1182 | else if (slot_avail1 & SLOT_100MHZ_PCIX) | 1093 | if (bus_speed == PCI_SPEED_UNKNOWN) { |
1183 | bus_speed = PCIX_100MHZ; | ||
1184 | else if (slot_avail1 & SLOT_66MHZ_PCIX) | ||
1185 | bus_speed = PCIX_66MHZ; | ||
1186 | else if (slot_avail2 & SLOT_66MHZ) | ||
1187 | bus_speed = PCI_66MHZ; | ||
1188 | else if (slot_avail1 & SLOT_33MHZ) | ||
1189 | bus_speed = PCI_33MHZ; | ||
1190 | else bus_speed = PCI_SPEED_UNKNOWN; | ||
1191 | } else { | ||
1192 | if (slot_avail1 & SLOT_133MHZ_PCIX) | 1094 | if (slot_avail1 & SLOT_133MHZ_PCIX) |
1193 | bus_speed = PCIX_133MHZ; | 1095 | bus_speed = PCI_SPEED_133MHz_PCIX; |
1194 | else if (slot_avail1 & SLOT_100MHZ_PCIX) | 1096 | else if (slot_avail1 & SLOT_100MHZ_PCIX) |
1195 | bus_speed = PCIX_100MHZ; | 1097 | bus_speed = PCI_SPEED_100MHz_PCIX; |
1196 | else if (slot_avail1 & SLOT_66MHZ_PCIX) | 1098 | else if (slot_avail1 & SLOT_66MHZ_PCIX) |
1197 | bus_speed = PCIX_66MHZ; | 1099 | bus_speed = PCI_SPEED_66MHz_PCIX; |
1198 | else if (slot_avail2 & SLOT_66MHZ) | 1100 | else if (slot_avail2 & SLOT_66MHZ) |
1199 | bus_speed = PCI_66MHZ; | 1101 | bus_speed = PCI_SPEED_66MHz; |
1200 | else if (slot_avail1 & SLOT_33MHZ) | 1102 | else if (slot_avail1 & SLOT_33MHZ) |
1201 | bus_speed = PCI_33MHZ; | 1103 | bus_speed = PCI_SPEED_33MHz; |
1202 | else bus_speed = PCI_SPEED_UNKNOWN; | 1104 | else |
1105 | retval = -ENODEV; | ||
1203 | } | 1106 | } |
1204 | 1107 | ||
1205 | *value = bus_speed; | 1108 | *value = bus_speed; |
@@ -1210,111 +1113,69 @@ static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value) | |||
1210 | 1113 | ||
1211 | static int hpc_get_cur_bus_speed (struct slot *slot, enum pci_bus_speed *value) | 1114 | static int hpc_get_cur_bus_speed (struct slot *slot, enum pci_bus_speed *value) |
1212 | { | 1115 | { |
1116 | int retval = 0; | ||
1213 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; | 1117 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; |
1214 | enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN; | 1118 | enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN; |
1215 | u16 sec_bus_status; | 1119 | u16 sec_bus_reg = readw(php_ctlr->creg + SEC_BUS_CONFIG); |
1216 | int retval = 0; | 1120 | u8 pi = readb(php_ctlr->creg + PROG_INTERFACE); |
1217 | u8 pi; | 1121 | u8 speed_mode = (pi == 2) ? (sec_bus_reg & 0xF) : (sec_bus_reg & 0x7); |
1218 | 1122 | ||
1219 | DBG_ENTER_ROUTINE | 1123 | DBG_ENTER_ROUTINE |
1220 | 1124 | ||
1221 | if (!slot->ctrl->hpc_ctlr_handle) { | 1125 | if ((pi == 1) && (speed_mode > 4)) { |
1222 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); | 1126 | *value = PCI_SPEED_UNKNOWN; |
1223 | return -1; | 1127 | return -ENODEV; |
1224 | } | ||
1225 | |||
1226 | if (slot->hp_slot >= php_ctlr->num_slots) { | ||
1227 | err("%s: Invalid HPC slot number!\n", __FUNCTION__); | ||
1228 | return -1; | ||
1229 | } | 1128 | } |
1230 | 1129 | ||
1231 | pi = readb(php_ctlr->creg + PROG_INTERFACE); | 1130 | switch (speed_mode) { |
1232 | sec_bus_status = readw(php_ctlr->creg + SEC_BUS_CONFIG); | 1131 | case 0x0: |
1233 | 1132 | *value = PCI_SPEED_33MHz; | |
1234 | if (pi == 2) { | 1133 | break; |
1235 | switch (sec_bus_status & 0x000f) { | 1134 | case 0x1: |
1236 | case 0: | 1135 | *value = PCI_SPEED_66MHz; |
1237 | bus_speed = PCI_SPEED_33MHz; | 1136 | break; |
1238 | break; | 1137 | case 0x2: |
1239 | case 1: | 1138 | *value = PCI_SPEED_66MHz_PCIX; |
1240 | bus_speed = PCI_SPEED_66MHz; | 1139 | break; |
1241 | break; | 1140 | case 0x3: |
1242 | case 2: | 1141 | *value = PCI_SPEED_100MHz_PCIX; |
1243 | bus_speed = PCI_SPEED_66MHz_PCIX; | 1142 | break; |
1244 | break; | 1143 | case 0x4: |
1245 | case 3: | 1144 | *value = PCI_SPEED_133MHz_PCIX; |
1246 | bus_speed = PCI_SPEED_100MHz_PCIX; | 1145 | break; |
1247 | break; | 1146 | case 0x5: |
1248 | case 4: | 1147 | *value = PCI_SPEED_66MHz_PCIX_ECC; |
1249 | bus_speed = PCI_SPEED_133MHz_PCIX; | 1148 | break; |
1250 | break; | 1149 | case 0x6: |
1251 | case 5: | 1150 | *value = PCI_SPEED_100MHz_PCIX_ECC; |
1252 | bus_speed = PCI_SPEED_66MHz_PCIX_ECC; | 1151 | break; |
1253 | break; | 1152 | case 0x7: |
1254 | case 6: | 1153 | *value = PCI_SPEED_133MHz_PCIX_ECC; |
1255 | bus_speed = PCI_SPEED_100MHz_PCIX_ECC; | 1154 | break; |
1256 | break; | 1155 | case 0x8: |
1257 | case 7: | 1156 | *value = PCI_SPEED_66MHz_PCIX_266; |
1258 | bus_speed = PCI_SPEED_133MHz_PCIX_ECC; | 1157 | break; |
1259 | break; | 1158 | case 0x9: |
1260 | case 8: | 1159 | *value = PCI_SPEED_100MHz_PCIX_266; |
1261 | bus_speed = PCI_SPEED_66MHz_PCIX_266; | 1160 | break; |
1262 | break; | 1161 | case 0xa: |
1263 | case 9: | 1162 | *value = PCI_SPEED_133MHz_PCIX_266; |
1264 | bus_speed = PCI_SPEED_100MHz_PCIX_266; | 1163 | break; |
1265 | break; | 1164 | case 0xb: |
1266 | case 0xa: | 1165 | *value = PCI_SPEED_66MHz_PCIX_533; |
1267 | bus_speed = PCI_SPEED_133MHz_PCIX_266; | 1166 | break; |
1268 | break; | 1167 | case 0xc: |
1269 | case 0xb: | 1168 | *value = PCI_SPEED_100MHz_PCIX_533; |
1270 | bus_speed = PCI_SPEED_66MHz_PCIX_533; | 1169 | break; |
1271 | break; | 1170 | case 0xd: |
1272 | case 0xc: | 1171 | *value = PCI_SPEED_133MHz_PCIX_533; |
1273 | bus_speed = PCI_SPEED_100MHz_PCIX_533; | 1172 | break; |
1274 | break; | 1173 | default: |
1275 | case 0xd: | 1174 | *value = PCI_SPEED_UNKNOWN; |
1276 | bus_speed = PCI_SPEED_133MHz_PCIX_533; | 1175 | retval = -ENODEV; |
1277 | break; | 1176 | break; |
1278 | case 0xe: | ||
1279 | case 0xf: | ||
1280 | default: | ||
1281 | bus_speed = PCI_SPEED_UNKNOWN; | ||
1282 | break; | ||
1283 | } | ||
1284 | } else { | ||
1285 | /* In the case where pi is undefined, default it to 1 */ | ||
1286 | switch (sec_bus_status & 0x0007) { | ||
1287 | case 0: | ||
1288 | bus_speed = PCI_SPEED_33MHz; | ||
1289 | break; | ||
1290 | case 1: | ||
1291 | bus_speed = PCI_SPEED_66MHz; | ||
1292 | break; | ||
1293 | case 2: | ||
1294 | bus_speed = PCI_SPEED_66MHz_PCIX; | ||
1295 | break; | ||
1296 | case 3: | ||
1297 | bus_speed = PCI_SPEED_100MHz_PCIX; | ||
1298 | break; | ||
1299 | case 4: | ||
1300 | bus_speed = PCI_SPEED_133MHz_PCIX; | ||
1301 | break; | ||
1302 | case 5: | ||
1303 | bus_speed = PCI_SPEED_UNKNOWN; /* Reserved */ | ||
1304 | break; | ||
1305 | case 6: | ||
1306 | bus_speed = PCI_SPEED_UNKNOWN; /* Reserved */ | ||
1307 | break; | ||
1308 | case 7: | ||
1309 | bus_speed = PCI_SPEED_UNKNOWN; /* Reserved */ | ||
1310 | break; | ||
1311 | default: | ||
1312 | bus_speed = PCI_SPEED_UNKNOWN; | ||
1313 | break; | ||
1314 | } | ||
1315 | } | 1177 | } |
1316 | 1178 | ||
1317 | *value = bus_speed; | ||
1318 | dbg("Current bus speed = %d\n", bus_speed); | 1179 | dbg("Current bus speed = %d\n", bus_speed); |
1319 | DBG_LEAVE_ROUTINE | 1180 | DBG_LEAVE_ROUTINE |
1320 | return retval; | 1181 | return retval; |
@@ -1343,7 +1204,6 @@ static struct hpc_ops shpchp_hpc_ops = { | |||
1343 | .green_led_blink = hpc_set_green_led_blink, | 1204 | .green_led_blink = hpc_set_green_led_blink, |
1344 | 1205 | ||
1345 | .release_ctlr = hpc_release_ctlr, | 1206 | .release_ctlr = hpc_release_ctlr, |
1346 | .check_cmd_status = hpc_check_cmd_status, | ||
1347 | }; | 1207 | }; |
1348 | 1208 | ||
1349 | inline static int shpc_indirect_creg_read(struct controller *ctrl, int index, | 1209 | inline static int shpc_indirect_creg_read(struct controller *ctrl, int index, |
@@ -1375,15 +1235,13 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev) | |||
1375 | ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */ | 1235 | ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */ |
1376 | 1236 | ||
1377 | spin_lock_init(&list_lock); | 1237 | spin_lock_init(&list_lock); |
1378 | php_ctlr = (struct php_ctlr_state_s *) kmalloc(sizeof(struct php_ctlr_state_s), GFP_KERNEL); | 1238 | php_ctlr = kzalloc(sizeof(*php_ctlr), GFP_KERNEL); |
1379 | 1239 | ||
1380 | if (!php_ctlr) { /* allocate controller state data */ | 1240 | if (!php_ctlr) { /* allocate controller state data */ |
1381 | err("%s: HPC controller memory allocation error!\n", __FUNCTION__); | 1241 | err("%s: HPC controller memory allocation error!\n", __FUNCTION__); |
1382 | goto abort; | 1242 | goto abort; |
1383 | } | 1243 | } |
1384 | 1244 | ||
1385 | memset(php_ctlr, 0, sizeof(struct php_ctlr_state_s)); | ||
1386 | |||
1387 | php_ctlr->pci_dev = pdev; /* save pci_dev in context */ | 1245 | php_ctlr->pci_dev = pdev; /* save pci_dev in context */ |
1388 | 1246 | ||
1389 | if ((pdev->vendor == PCI_VENDOR_ID_AMD) || (pdev->device == | 1247 | if ((pdev->vendor == PCI_VENDOR_ID_AMD) || (pdev->device == |
@@ -1454,7 +1312,9 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev) | |||
1454 | } | 1312 | } |
1455 | dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg); | 1313 | dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg); |
1456 | 1314 | ||
1457 | init_MUTEX(&ctrl->crit_sect); | 1315 | mutex_init(&ctrl->crit_sect); |
1316 | mutex_init(&ctrl->cmd_lock); | ||
1317 | |||
1458 | /* Setup wait queue */ | 1318 | /* Setup wait queue */ |
1459 | init_waitqueue_head(&ctrl->queue); | 1319 | init_waitqueue_head(&ctrl->queue); |
1460 | 1320 | ||
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c index 19e1a5e1e30b..257adc233996 100644 --- a/drivers/pci/hotplug/shpchp_pci.c +++ b/drivers/pci/hotplug/shpchp_pci.c | |||
@@ -38,7 +38,7 @@ static void program_fw_provided_values(struct pci_dev *dev) | |||
38 | { | 38 | { |
39 | u16 pci_cmd, pci_bctl; | 39 | u16 pci_cmd, pci_bctl; |
40 | struct pci_dev *cdev; | 40 | struct pci_dev *cdev; |
41 | struct hotplug_params hpp = {0x8, 0x40, 0, 0}; /* defaults */ | 41 | struct hotplug_params hpp; |
42 | 42 | ||
43 | /* Program hpp values for this device */ | 43 | /* Program hpp values for this device */ |
44 | if (!(dev->hdr_type == PCI_HEADER_TYPE_NORMAL || | 44 | if (!(dev->hdr_type == PCI_HEADER_TYPE_NORMAL || |
@@ -46,7 +46,13 @@ static void program_fw_provided_values(struct pci_dev *dev) | |||
46 | (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI))) | 46 | (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI))) |
47 | return; | 47 | return; |
48 | 48 | ||
49 | get_hp_params_from_firmware(dev, &hpp); | 49 | /* use default values if we can't get them from firmware */ |
50 | if (get_hp_params_from_firmware(dev, &hpp)) { | ||
51 | hpp.cache_line_size = 8; | ||
52 | hpp.latency_timer = 0x40; | ||
53 | hpp.enable_serr = 0; | ||
54 | hpp.enable_perr = 0; | ||
55 | } | ||
50 | 56 | ||
51 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, hpp.cache_line_size); | 57 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, hpp.cache_line_size); |
52 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, hpp.latency_timer); | 58 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, hpp.latency_timer); |
diff --git a/drivers/pci/hotplug/shpchprm_legacy.c b/drivers/pci/hotplug/shpchprm_legacy.c deleted file mode 100644 index ed6c1254bf6f..000000000000 --- a/drivers/pci/hotplug/shpchprm_legacy.c +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
1 | /* | ||
2 | * SHPCHPRM Legacy: PHP Resource Manager for Non-ACPI/Legacy platform | ||
3 | * | ||
4 | * Copyright (C) 1995,2001 Compaq Computer Corporation | ||
5 | * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com) | ||
6 | * Copyright (C) 2001 IBM Corp. | ||
7 | * Copyright (C) 2003-2004 Intel Corporation | ||
8 | * | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com> | ||
27 | * | ||
28 | */ | ||
29 | |||
30 | #include <linux/module.h> | ||
31 | #include <linux/kernel.h> | ||
32 | #include <linux/types.h> | ||
33 | #include <linux/pci.h> | ||
34 | #include "shpchp.h" | ||
35 | |||
36 | int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum) | ||
37 | { | ||
38 | int offset = devnum - ctrl->slot_device_offset; | ||
39 | |||
40 | *sun = (u8) (ctrl->first_slot + ctrl->slot_num_inc * offset); | ||
41 | return 0; | ||
42 | } | ||
43 | |||
44 | void get_hp_params_from_firmware(struct pci_dev *dev, | ||
45 | struct hotplug_params *hpp) | ||
46 | { | ||
47 | return; | ||
48 | } | ||
49 | |||
50 | void get_hp_hw_control_from_firmware(struct pci_dev *dev) | ||
51 | { | ||
52 | return; | ||
53 | } | ||
54 | |||
diff --git a/drivers/pci/hotplug/shpchprm_nonacpi.c b/drivers/pci/hotplug/shpchprm_nonacpi.c deleted file mode 100644 index c6b40998eeb3..000000000000 --- a/drivers/pci/hotplug/shpchprm_nonacpi.c +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | /* | ||
2 | * SHPCHPRM NONACPI: PHP Resource Manager for Non-ACPI/Legacy platform | ||
3 | * | ||
4 | * Copyright (C) 1995,2001 Compaq Computer Corporation | ||
5 | * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com) | ||
6 | * Copyright (C) 2001 IBM Corp. | ||
7 | * Copyright (C) 2003-2004 Intel Corporation | ||
8 | * | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> | ||
27 | * | ||
28 | */ | ||
29 | |||
30 | #include <linux/config.h> | ||
31 | #include <linux/module.h> | ||
32 | #include <linux/kernel.h> | ||
33 | #include <linux/types.h> | ||
34 | #include <linux/pci.h> | ||
35 | #include <linux/slab.h> | ||
36 | |||
37 | #include "shpchp.h" | ||
38 | |||
39 | int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum) | ||
40 | { | ||
41 | int offset = devnum - ctrl->slot_device_offset; | ||
42 | |||
43 | dbg("%s: ctrl->slot_num_inc %d, offset %d\n", __FUNCTION__, ctrl->slot_num_inc, offset); | ||
44 | *sun = (u8) (ctrl->first_slot + ctrl->slot_num_inc * offset); | ||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | void get_hp_params_from_firmware(struct pci_dev *dev, | ||
49 | struct hotplug_params *hpp) | ||
50 | { | ||
51 | return; | ||
52 | } | ||
53 | |||
54 | void get_hp_hw_control_from_firmware(struct pci_dev *dev) | ||
55 | { | ||
56 | return; | ||
57 | } | ||
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 48723d6fa60f..a77e79c8c82e 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -103,9 +103,9 @@ static void set_msi_affinity(unsigned int vector, cpumask_t cpu_mask) | |||
103 | switch (entry->msi_attrib.type) { | 103 | switch (entry->msi_attrib.type) { |
104 | case PCI_CAP_ID_MSI: | 104 | case PCI_CAP_ID_MSI: |
105 | { | 105 | { |
106 | int pos; | 106 | int pos = pci_find_capability(entry->dev, PCI_CAP_ID_MSI); |
107 | 107 | ||
108 | if (!(pos = pci_find_capability(entry->dev, PCI_CAP_ID_MSI))) | 108 | if (!pos) |
109 | return; | 109 | return; |
110 | 110 | ||
111 | pci_read_config_dword(entry->dev, msi_lower_address_reg(pos), | 111 | pci_read_config_dword(entry->dev, msi_lower_address_reg(pos), |
@@ -347,9 +347,9 @@ static int assign_msi_vector(void) | |||
347 | 347 | ||
348 | static int get_new_vector(void) | 348 | static int get_new_vector(void) |
349 | { | 349 | { |
350 | int vector; | 350 | int vector = assign_msi_vector(); |
351 | 351 | ||
352 | if ((vector = assign_msi_vector()) > 0) | 352 | if (vector > 0) |
353 | set_intr_gate(vector, interrupt[vector]); | 353 | set_intr_gate(vector, interrupt[vector]); |
354 | 354 | ||
355 | return vector; | 355 | return vector; |
@@ -369,7 +369,8 @@ static int msi_init(void) | |||
369 | return status; | 369 | return status; |
370 | } | 370 | } |
371 | 371 | ||
372 | if ((status = msi_cache_init()) < 0) { | 372 | status = msi_cache_init(); |
373 | if (status < 0) { | ||
373 | pci_msi_enable = 0; | 374 | pci_msi_enable = 0; |
374 | printk(KERN_WARNING "PCI: MSI cache init failed\n"); | 375 | printk(KERN_WARNING "PCI: MSI cache init failed\n"); |
375 | return status; | 376 | return status; |
@@ -523,10 +524,12 @@ static int msi_capability_init(struct pci_dev *dev) | |||
523 | pos = pci_find_capability(dev, PCI_CAP_ID_MSI); | 524 | pos = pci_find_capability(dev, PCI_CAP_ID_MSI); |
524 | pci_read_config_word(dev, msi_control_reg(pos), &control); | 525 | pci_read_config_word(dev, msi_control_reg(pos), &control); |
525 | /* MSI Entry Initialization */ | 526 | /* MSI Entry Initialization */ |
526 | if (!(entry = alloc_msi_entry())) | 527 | entry = alloc_msi_entry(); |
528 | if (!entry) | ||
527 | return -ENOMEM; | 529 | return -ENOMEM; |
528 | 530 | ||
529 | if ((vector = get_msi_vector(dev)) < 0) { | 531 | vector = get_msi_vector(dev); |
532 | if (vector < 0) { | ||
530 | kmem_cache_free(msi_cachep, entry); | 533 | kmem_cache_free(msi_cachep, entry); |
531 | return -EBUSY; | 534 | return -EBUSY; |
532 | } | 535 | } |
@@ -597,7 +600,8 @@ static int msix_capability_init(struct pci_dev *dev, | |||
597 | struct msg_address address; | 600 | struct msg_address address; |
598 | struct msg_data data; | 601 | struct msg_data data; |
599 | int vector, pos, i, j, nr_entries, temp = 0; | 602 | int vector, pos, i, j, nr_entries, temp = 0; |
600 | u32 phys_addr, table_offset; | 603 | unsigned long phys_addr; |
604 | u32 table_offset; | ||
601 | u16 control; | 605 | u16 control; |
602 | u8 bir; | 606 | u8 bir; |
603 | void __iomem *base; | 607 | void __iomem *base; |
@@ -606,11 +610,11 @@ static int msix_capability_init(struct pci_dev *dev, | |||
606 | /* Request & Map MSI-X table region */ | 610 | /* Request & Map MSI-X table region */ |
607 | pci_read_config_word(dev, msi_control_reg(pos), &control); | 611 | pci_read_config_word(dev, msi_control_reg(pos), &control); |
608 | nr_entries = multi_msix_capable(control); | 612 | nr_entries = multi_msix_capable(control); |
609 | pci_read_config_dword(dev, msix_table_offset_reg(pos), | 613 | |
610 | &table_offset); | 614 | pci_read_config_dword(dev, msix_table_offset_reg(pos), &table_offset); |
611 | bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK); | 615 | bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK); |
612 | phys_addr = pci_resource_start (dev, bir); | 616 | table_offset &= ~PCI_MSIX_FLAGS_BIRMASK; |
613 | phys_addr += (u32)(table_offset & ~PCI_MSIX_FLAGS_BIRMASK); | 617 | phys_addr = pci_resource_start (dev, bir) + table_offset; |
614 | base = ioremap_nocache(phys_addr, nr_entries * PCI_MSIX_ENTRY_SIZE); | 618 | base = ioremap_nocache(phys_addr, nr_entries * PCI_MSIX_ENTRY_SIZE); |
615 | if (base == NULL) | 619 | if (base == NULL) |
616 | return -ENOMEM; | 620 | return -ENOMEM; |
@@ -620,7 +624,8 @@ static int msix_capability_init(struct pci_dev *dev, | |||
620 | entry = alloc_msi_entry(); | 624 | entry = alloc_msi_entry(); |
621 | if (!entry) | 625 | if (!entry) |
622 | break; | 626 | break; |
623 | if ((vector = get_msi_vector(dev)) < 0) | 627 | vector = get_msi_vector(dev); |
628 | if (vector < 0) | ||
624 | break; | 629 | break; |
625 | 630 | ||
626 | j = entries[i].entry; | 631 | j = entries[i].entry; |
@@ -699,12 +704,17 @@ int pci_enable_msi(struct pci_dev* dev) | |||
699 | if (dev->no_msi) | 704 | if (dev->no_msi) |
700 | return status; | 705 | return status; |
701 | 706 | ||
707 | if (dev->bus->bus_flags & PCI_BUS_FLAGS_NO_MSI) | ||
708 | return -EINVAL; | ||
709 | |||
702 | temp = dev->irq; | 710 | temp = dev->irq; |
703 | 711 | ||
704 | if ((status = msi_init()) < 0) | 712 | status = msi_init(); |
713 | if (status < 0) | ||
705 | return status; | 714 | return status; |
706 | 715 | ||
707 | if (!(pos = pci_find_capability(dev, PCI_CAP_ID_MSI))) | 716 | pos = pci_find_capability(dev, PCI_CAP_ID_MSI); |
717 | if (!pos) | ||
708 | return -EINVAL; | 718 | return -EINVAL; |
709 | 719 | ||
710 | pci_read_config_word(dev, msi_control_reg(pos), &control); | 720 | pci_read_config_word(dev, msi_control_reg(pos), &control); |
@@ -728,8 +738,8 @@ int pci_enable_msi(struct pci_dev* dev) | |||
728 | dev->irq = temp; | 738 | dev->irq = temp; |
729 | } | 739 | } |
730 | /* Check whether driver already requested for MSI-X vectors */ | 740 | /* Check whether driver already requested for MSI-X vectors */ |
731 | if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSIX)) > 0 && | 741 | pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); |
732 | !msi_lookup_vector(dev, PCI_CAP_ID_MSIX)) { | 742 | if (pos > 0 && !msi_lookup_vector(dev, PCI_CAP_ID_MSIX)) { |
733 | printk(KERN_INFO "PCI: %s: Can't enable MSI. " | 743 | printk(KERN_INFO "PCI: %s: Can't enable MSI. " |
734 | "Device already has MSI-X vectors assigned\n", | 744 | "Device already has MSI-X vectors assigned\n", |
735 | pci_name(dev)); | 745 | pci_name(dev)); |
@@ -755,7 +765,13 @@ void pci_disable_msi(struct pci_dev* dev) | |||
755 | u16 control; | 765 | u16 control; |
756 | unsigned long flags; | 766 | unsigned long flags; |
757 | 767 | ||
758 | if (!dev || !(pos = pci_find_capability(dev, PCI_CAP_ID_MSI))) | 768 | if (!pci_msi_enable) |
769 | return; | ||
770 | if (!dev) | ||
771 | return; | ||
772 | |||
773 | pos = pci_find_capability(dev, PCI_CAP_ID_MSI); | ||
774 | if (!pos) | ||
759 | return; | 775 | return; |
760 | 776 | ||
761 | pci_read_config_word(dev, msi_control_reg(pos), &control); | 777 | pci_read_config_word(dev, msi_control_reg(pos), &control); |
@@ -826,8 +842,10 @@ static int msi_free_vector(struct pci_dev* dev, int vector, int reassign) | |||
826 | * Detect last MSI-X vector to be released. | 842 | * Detect last MSI-X vector to be released. |
827 | * Release the MSI-X memory-mapped table. | 843 | * Release the MSI-X memory-mapped table. |
828 | */ | 844 | */ |
845 | #if 0 | ||
829 | int pos, nr_entries; | 846 | int pos, nr_entries; |
830 | u32 phys_addr, table_offset; | 847 | unsigned long phys_addr; |
848 | u32 table_offset; | ||
831 | u16 control; | 849 | u16 control; |
832 | u8 bir; | 850 | u8 bir; |
833 | 851 | ||
@@ -838,9 +856,12 @@ static int msi_free_vector(struct pci_dev* dev, int vector, int reassign) | |||
838 | pci_read_config_dword(dev, msix_table_offset_reg(pos), | 856 | pci_read_config_dword(dev, msix_table_offset_reg(pos), |
839 | &table_offset); | 857 | &table_offset); |
840 | bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK); | 858 | bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK); |
841 | phys_addr = pci_resource_start (dev, bir); | 859 | table_offset &= ~PCI_MSIX_FLAGS_BIRMASK; |
842 | phys_addr += (u32)(table_offset & | 860 | phys_addr = pci_resource_start(dev, bir) + table_offset; |
843 | ~PCI_MSIX_FLAGS_BIRMASK); | 861 | /* |
862 | * FIXME! and what did you want to do with phys_addr? | ||
863 | */ | ||
864 | #endif | ||
844 | iounmap(base); | 865 | iounmap(base); |
845 | } | 866 | } |
846 | } | 867 | } |
@@ -924,10 +945,12 @@ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec) | |||
924 | if (!pci_msi_enable || !dev || !entries) | 945 | if (!pci_msi_enable || !dev || !entries) |
925 | return -EINVAL; | 946 | return -EINVAL; |
926 | 947 | ||
927 | if ((status = msi_init()) < 0) | 948 | status = msi_init(); |
949 | if (status < 0) | ||
928 | return status; | 950 | return status; |
929 | 951 | ||
930 | if (!(pos = pci_find_capability(dev, PCI_CAP_ID_MSIX))) | 952 | pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); |
953 | if (!pos) | ||
931 | return -EINVAL; | 954 | return -EINVAL; |
932 | 955 | ||
933 | pci_read_config_word(dev, msi_control_reg(pos), &control); | 956 | pci_read_config_word(dev, msi_control_reg(pos), &control); |
@@ -1006,7 +1029,13 @@ void pci_disable_msix(struct pci_dev* dev) | |||
1006 | int pos, temp; | 1029 | int pos, temp; |
1007 | u16 control; | 1030 | u16 control; |
1008 | 1031 | ||
1009 | if (!dev || !(pos = pci_find_capability(dev, PCI_CAP_ID_MSIX))) | 1032 | if (!pci_msi_enable) |
1033 | return; | ||
1034 | if (!dev) | ||
1035 | return; | ||
1036 | |||
1037 | pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); | ||
1038 | if (!pos) | ||
1010 | return; | 1039 | return; |
1011 | 1040 | ||
1012 | pci_read_config_word(dev, msi_control_reg(pos), &control); | 1041 | pci_read_config_word(dev, msi_control_reg(pos), &control); |
@@ -1066,8 +1095,8 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev) | |||
1066 | return; | 1095 | return; |
1067 | 1096 | ||
1068 | temp = dev->irq; /* Save IOAPIC IRQ */ | 1097 | temp = dev->irq; /* Save IOAPIC IRQ */ |
1069 | if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSI)) > 0 && | 1098 | pos = pci_find_capability(dev, PCI_CAP_ID_MSI); |
1070 | !msi_lookup_vector(dev, PCI_CAP_ID_MSI)) { | 1099 | if (pos > 0 && !msi_lookup_vector(dev, PCI_CAP_ID_MSI)) { |
1071 | spin_lock_irqsave(&msi_lock, flags); | 1100 | spin_lock_irqsave(&msi_lock, flags); |
1072 | state = msi_desc[dev->irq]->msi_attrib.state; | 1101 | state = msi_desc[dev->irq]->msi_attrib.state; |
1073 | spin_unlock_irqrestore(&msi_lock, flags); | 1102 | spin_unlock_irqrestore(&msi_lock, flags); |
@@ -1080,8 +1109,8 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev) | |||
1080 | msi_free_vector(dev, dev->irq, 0); | 1109 | msi_free_vector(dev, dev->irq, 0); |
1081 | dev->irq = temp; /* Restore IOAPIC IRQ */ | 1110 | dev->irq = temp; /* Restore IOAPIC IRQ */ |
1082 | } | 1111 | } |
1083 | if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSIX)) > 0 && | 1112 | pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); |
1084 | !msi_lookup_vector(dev, PCI_CAP_ID_MSIX)) { | 1113 | if (pos > 0 && !msi_lookup_vector(dev, PCI_CAP_ID_MSIX)) { |
1085 | int vector, head, tail = 0, warning = 0; | 1114 | int vector, head, tail = 0, warning = 0; |
1086 | void __iomem *base = NULL; | 1115 | void __iomem *base = NULL; |
1087 | 1116 | ||
@@ -1101,7 +1130,9 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev) | |||
1101 | msi_free_vector(dev, vector, 0); | 1130 | msi_free_vector(dev, vector, 0); |
1102 | if (warning) { | 1131 | if (warning) { |
1103 | /* Force to release the MSI-X memory-mapped table */ | 1132 | /* Force to release the MSI-X memory-mapped table */ |
1104 | u32 phys_addr, table_offset; | 1133 | #if 0 |
1134 | unsigned long phys_addr; | ||
1135 | u32 table_offset; | ||
1105 | u16 control; | 1136 | u16 control; |
1106 | u8 bir; | 1137 | u8 bir; |
1107 | 1138 | ||
@@ -1110,9 +1141,12 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev) | |||
1110 | pci_read_config_dword(dev, msix_table_offset_reg(pos), | 1141 | pci_read_config_dword(dev, msix_table_offset_reg(pos), |
1111 | &table_offset); | 1142 | &table_offset); |
1112 | bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK); | 1143 | bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK); |
1113 | phys_addr = pci_resource_start (dev, bir); | 1144 | table_offset &= ~PCI_MSIX_FLAGS_BIRMASK; |
1114 | phys_addr += (u32)(table_offset & | 1145 | phys_addr = pci_resource_start(dev, bir) + table_offset; |
1115 | ~PCI_MSIX_FLAGS_BIRMASK); | 1146 | /* |
1147 | * FIXME! and what did you want to do with phys_addr? | ||
1148 | */ | ||
1149 | #endif | ||
1116 | iounmap(base); | 1150 | iounmap(base); |
1117 | printk(KERN_WARNING "PCI: %s: msi_remove_pci_irq_vectors() " | 1151 | printk(KERN_WARNING "PCI: %s: msi_remove_pci_irq_vectors() " |
1118 | "called without free_irq() on all MSI-X vectors\n", | 1152 | "called without free_irq() on all MSI-X vectors\n", |
@@ -1123,6 +1157,11 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev) | |||
1123 | } | 1157 | } |
1124 | } | 1158 | } |
1125 | 1159 | ||
1160 | void pci_no_msi(void) | ||
1161 | { | ||
1162 | pci_msi_enable = 0; | ||
1163 | } | ||
1164 | |||
1126 | EXPORT_SYMBOL(pci_enable_msi); | 1165 | EXPORT_SYMBOL(pci_enable_msi); |
1127 | EXPORT_SYMBOL(pci_disable_msi); | 1166 | EXPORT_SYMBOL(pci_disable_msi); |
1128 | EXPORT_SYMBOL(pci_enable_msix); | 1167 | EXPORT_SYMBOL(pci_enable_msix); |
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 0aa14c92b570..f22f69ac6445 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -53,11 +53,10 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count) | |||
53 | if (fields < 0) | 53 | if (fields < 0) |
54 | return -EINVAL; | 54 | return -EINVAL; |
55 | 55 | ||
56 | dynid = kmalloc(sizeof(*dynid), GFP_KERNEL); | 56 | dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); |
57 | if (!dynid) | 57 | if (!dynid) |
58 | return -ENOMEM; | 58 | return -ENOMEM; |
59 | 59 | ||
60 | memset(dynid, 0, sizeof(*dynid)); | ||
61 | INIT_LIST_HEAD(&dynid->node); | 60 | INIT_LIST_HEAD(&dynid->node); |
62 | dynid->id.vendor = vendor; | 61 | dynid->id.vendor = vendor; |
63 | dynid->id.device = device; | 62 | dynid->id.device = device; |
@@ -380,14 +379,6 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner) | |||
380 | /* initialize common driver fields */ | 379 | /* initialize common driver fields */ |
381 | drv->driver.name = drv->name; | 380 | drv->driver.name = drv->name; |
382 | drv->driver.bus = &pci_bus_type; | 381 | drv->driver.bus = &pci_bus_type; |
383 | /* FIXME, once all of the existing PCI drivers have been fixed to set | ||
384 | * the pci shutdown function, this test can go away. */ | ||
385 | if (!drv->driver.shutdown) | ||
386 | drv->driver.shutdown = pci_device_shutdown; | ||
387 | else | ||
388 | printk(KERN_WARNING "Warning: PCI driver %s has a struct " | ||
389 | "device_driver shutdown method, please update!\n", | ||
390 | drv->name); | ||
391 | drv->driver.owner = owner; | 382 | drv->driver.owner = owner; |
392 | drv->driver.kobj.ktype = &pci_driver_kobj_type; | 383 | drv->driver.kobj.ktype = &pci_driver_kobj_type; |
393 | 384 | ||
@@ -514,6 +505,7 @@ struct bus_type pci_bus_type = { | |||
514 | .probe = pci_device_probe, | 505 | .probe = pci_device_probe, |
515 | .remove = pci_device_remove, | 506 | .remove = pci_device_remove, |
516 | .suspend = pci_device_suspend, | 507 | .suspend = pci_device_suspend, |
508 | .shutdown = pci_device_shutdown, | ||
517 | .resume = pci_device_resume, | 509 | .resume = pci_device_resume, |
518 | .dev_attrs = pci_dev_attrs, | 510 | .dev_attrs = pci_dev_attrs, |
519 | }; | 511 | }; |
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 965a5934623a..56ac2bc003c7 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -501,9 +501,8 @@ int pci_create_sysfs_dev_files (struct pci_dev *pdev) | |||
501 | if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) { | 501 | if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) { |
502 | struct bin_attribute *rom_attr; | 502 | struct bin_attribute *rom_attr; |
503 | 503 | ||
504 | rom_attr = kmalloc(sizeof(*rom_attr), GFP_ATOMIC); | 504 | rom_attr = kzalloc(sizeof(*rom_attr), GFP_ATOMIC); |
505 | if (rom_attr) { | 505 | if (rom_attr) { |
506 | memset(rom_attr, 0x00, sizeof(*rom_attr)); | ||
507 | pdev->rom_attr = rom_attr; | 506 | pdev->rom_attr = rom_attr; |
508 | rom_attr->size = pci_resource_len(pdev, PCI_ROM_RESOURCE); | 507 | rom_attr->size = pci_resource_len(pdev, PCI_ROM_RESOURCE); |
509 | rom_attr->attr.name = "rom"; | 508 | rom_attr->attr.name = "rom"; |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index d2d187916643..bea1ad1ad5ba 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <asm/dma.h> /* isa_dma_bridge_buggy */ | 19 | #include <asm/dma.h> /* isa_dma_bridge_buggy */ |
20 | #include "pci.h" | 20 | #include "pci.h" |
21 | 21 | ||
22 | #if 0 | ||
23 | 22 | ||
24 | /** | 23 | /** |
25 | * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children | 24 | * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children |
@@ -34,7 +33,7 @@ pci_bus_max_busnr(struct pci_bus* bus) | |||
34 | struct list_head *tmp; | 33 | struct list_head *tmp; |
35 | unsigned char max, n; | 34 | unsigned char max, n; |
36 | 35 | ||
37 | max = bus->number; | 36 | max = bus->subordinate; |
38 | list_for_each(tmp, &bus->children) { | 37 | list_for_each(tmp, &bus->children) { |
39 | n = pci_bus_max_busnr(pci_bus_b(tmp)); | 38 | n = pci_bus_max_busnr(pci_bus_b(tmp)); |
40 | if(n > max) | 39 | if(n > max) |
@@ -42,7 +41,9 @@ pci_bus_max_busnr(struct pci_bus* bus) | |||
42 | } | 41 | } |
43 | return max; | 42 | return max; |
44 | } | 43 | } |
44 | EXPORT_SYMBOL_GPL(pci_bus_max_busnr); | ||
45 | 45 | ||
46 | #if 0 | ||
46 | /** | 47 | /** |
47 | * pci_max_busnr - returns maximum PCI bus number | 48 | * pci_max_busnr - returns maximum PCI bus number |
48 | * | 49 | * |
@@ -495,9 +496,8 @@ pci_enable_device_bars(struct pci_dev *dev, int bars) | |||
495 | int | 496 | int |
496 | pci_enable_device(struct pci_dev *dev) | 497 | pci_enable_device(struct pci_dev *dev) |
497 | { | 498 | { |
498 | int err; | 499 | int err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1); |
499 | 500 | if (err) | |
500 | if ((err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1))) | ||
501 | return err; | 501 | return err; |
502 | pci_fixup_device(pci_fixup_enable, dev); | 502 | pci_fixup_device(pci_fixup_enable, dev); |
503 | dev->is_enabled = 1; | 503 | dev->is_enabled = 1; |
@@ -639,7 +639,7 @@ void pci_release_region(struct pci_dev *pdev, int bar) | |||
639 | * Returns 0 on success, or %EBUSY on error. A warning | 639 | * Returns 0 on success, or %EBUSY on error. A warning |
640 | * message is also printed on failure. | 640 | * message is also printed on failure. |
641 | */ | 641 | */ |
642 | int pci_request_region(struct pci_dev *pdev, int bar, char *res_name) | 642 | int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) |
643 | { | 643 | { |
644 | if (pci_resource_len(pdev, bar) == 0) | 644 | if (pci_resource_len(pdev, bar) == 0) |
645 | return 0; | 645 | return 0; |
@@ -697,7 +697,7 @@ void pci_release_regions(struct pci_dev *pdev) | |||
697 | * Returns 0 on success, or %EBUSY on error. A warning | 697 | * Returns 0 on success, or %EBUSY on error. A warning |
698 | * message is also printed on failure. | 698 | * message is also printed on failure. |
699 | */ | 699 | */ |
700 | int pci_request_regions(struct pci_dev *pdev, char *res_name) | 700 | int pci_request_regions(struct pci_dev *pdev, const char *res_name) |
701 | { | 701 | { |
702 | int i; | 702 | int i; |
703 | 703 | ||
@@ -900,8 +900,12 @@ static int __devinit pci_setup(char *str) | |||
900 | if (k) | 900 | if (k) |
901 | *k++ = 0; | 901 | *k++ = 0; |
902 | if (*str && (str = pcibios_setup(str)) && *str) { | 902 | if (*str && (str = pcibios_setup(str)) && *str) { |
903 | /* PCI layer options should be handled here */ | 903 | if (!strcmp(str, "nomsi")) { |
904 | printk(KERN_ERR "PCI: Unknown option `%s'\n", str); | 904 | pci_no_msi(); |
905 | } else { | ||
906 | printk(KERN_ERR "PCI: Unknown option `%s'\n", | ||
907 | str); | ||
908 | } | ||
905 | } | 909 | } |
906 | str = k; | 910 | str = k; |
907 | } | 911 | } |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index a6dfee2f6d2b..8f3fb47ea671 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -50,8 +50,10 @@ extern int pci_msi_quirk; | |||
50 | 50 | ||
51 | #ifdef CONFIG_PCI_MSI | 51 | #ifdef CONFIG_PCI_MSI |
52 | void disable_msi_mode(struct pci_dev *dev, int pos, int type); | 52 | void disable_msi_mode(struct pci_dev *dev, int pos, int type); |
53 | void pci_no_msi(void); | ||
53 | #else | 54 | #else |
54 | static inline void disable_msi_mode(struct pci_dev *dev, int pos, int type) { } | 55 | static inline void disable_msi_mode(struct pci_dev *dev, int pos, int type) { } |
56 | static inline void pci_no_msi(void) { } | ||
55 | #endif | 57 | #endif |
56 | 58 | ||
57 | extern int pcie_mch_quirk; | 59 | extern int pcie_mch_quirk; |
diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h index a63bd8f72601..1d317d22ee89 100644 --- a/drivers/pci/pcie/portdrv.h +++ b/drivers/pci/pcie/portdrv.h | |||
@@ -29,7 +29,6 @@ | |||
29 | 29 | ||
30 | struct pcie_port_device_ext { | 30 | struct pcie_port_device_ext { |
31 | int interrupt_mode; /* [0:INTx | 1:MSI | 2:MSI-X] */ | 31 | int interrupt_mode; /* [0:INTx | 1:MSI | 2:MSI-X] */ |
32 | unsigned int saved_msi_config_space[5]; | ||
33 | }; | 32 | }; |
34 | 33 | ||
35 | extern struct bus_type pcie_port_bus_type; | 34 | extern struct bus_type pcie_port_bus_type; |
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index e4e5f1e8d816..55c662267868 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c | |||
@@ -248,11 +248,10 @@ static struct pcie_device* alloc_pcie_device(struct pci_dev *parent, | |||
248 | { | 248 | { |
249 | struct pcie_device *device; | 249 | struct pcie_device *device; |
250 | 250 | ||
251 | device = kmalloc(sizeof(struct pcie_device), GFP_KERNEL); | 251 | device = kzalloc(sizeof(struct pcie_device), GFP_KERNEL); |
252 | if (!device) | 252 | if (!device) |
253 | return NULL; | 253 | return NULL; |
254 | 254 | ||
255 | memset(device, 0, sizeof(struct pcie_device)); | ||
256 | pcie_device_init(parent, device, port_type, service_type, irq,irq_mode); | 255 | pcie_device_init(parent, device, port_type, service_type, irq,irq_mode); |
257 | printk(KERN_DEBUG "Allocate Port Service[%s]\n", device->device.bus_id); | 256 | printk(KERN_DEBUG "Allocate Port Service[%s]\n", device->device.bus_id); |
258 | return device; | 257 | return device; |
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index 02260141dc81..50bfc1b2f3bf 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c | |||
@@ -30,75 +30,16 @@ MODULE_LICENSE("GPL"); | |||
30 | /* global data */ | 30 | /* global data */ |
31 | static const char device_name[] = "pcieport-driver"; | 31 | static const char device_name[] = "pcieport-driver"; |
32 | 32 | ||
33 | static void pci_save_msi_state(struct pci_dev *dev) | 33 | static int pcie_portdrv_save_config(struct pci_dev *dev) |
34 | { | 34 | { |
35 | struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev); | 35 | return pci_save_state(dev); |
36 | int i = 0, pos; | ||
37 | u16 control; | ||
38 | |||
39 | if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSI)) <= 0) | ||
40 | return; | ||
41 | |||
42 | pci_read_config_dword(dev, pos, &p_ext->saved_msi_config_space[i++]); | ||
43 | control = p_ext->saved_msi_config_space[0] >> 16; | ||
44 | pci_read_config_dword(dev, pos + PCI_MSI_ADDRESS_LO, | ||
45 | &p_ext->saved_msi_config_space[i++]); | ||
46 | if (control & PCI_MSI_FLAGS_64BIT) { | ||
47 | pci_read_config_dword(dev, pos + PCI_MSI_ADDRESS_HI, | ||
48 | &p_ext->saved_msi_config_space[i++]); | ||
49 | pci_read_config_dword(dev, pos + PCI_MSI_DATA_64, | ||
50 | &p_ext->saved_msi_config_space[i++]); | ||
51 | } else | ||
52 | pci_read_config_dword(dev, pos + PCI_MSI_DATA_32, | ||
53 | &p_ext->saved_msi_config_space[i++]); | ||
54 | if (control & PCI_MSI_FLAGS_MASKBIT) | ||
55 | pci_read_config_dword(dev, pos + PCI_MSI_MASK_BIT, | ||
56 | &p_ext->saved_msi_config_space[i++]); | ||
57 | } | ||
58 | |||
59 | static void pci_restore_msi_state(struct pci_dev *dev) | ||
60 | { | ||
61 | struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev); | ||
62 | int i = 0, pos; | ||
63 | u16 control; | ||
64 | |||
65 | if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSI)) <= 0) | ||
66 | return; | ||
67 | |||
68 | control = p_ext->saved_msi_config_space[i++] >> 16; | ||
69 | pci_write_config_word(dev, pos + PCI_MSI_FLAGS, control); | ||
70 | pci_write_config_dword(dev, pos + PCI_MSI_ADDRESS_LO, | ||
71 | p_ext->saved_msi_config_space[i++]); | ||
72 | if (control & PCI_MSI_FLAGS_64BIT) { | ||
73 | pci_write_config_dword(dev, pos + PCI_MSI_ADDRESS_HI, | ||
74 | p_ext->saved_msi_config_space[i++]); | ||
75 | pci_write_config_dword(dev, pos + PCI_MSI_DATA_64, | ||
76 | p_ext->saved_msi_config_space[i++]); | ||
77 | } else | ||
78 | pci_write_config_dword(dev, pos + PCI_MSI_DATA_32, | ||
79 | p_ext->saved_msi_config_space[i++]); | ||
80 | if (control & PCI_MSI_FLAGS_MASKBIT) | ||
81 | pci_write_config_dword(dev, pos + PCI_MSI_MASK_BIT, | ||
82 | p_ext->saved_msi_config_space[i++]); | ||
83 | } | ||
84 | |||
85 | static void pcie_portdrv_save_config(struct pci_dev *dev) | ||
86 | { | ||
87 | struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev); | ||
88 | |||
89 | pci_save_state(dev); | ||
90 | if (p_ext->interrupt_mode == PCIE_PORT_MSI_MODE) | ||
91 | pci_save_msi_state(dev); | ||
92 | } | 36 | } |
93 | 37 | ||
94 | static int pcie_portdrv_restore_config(struct pci_dev *dev) | 38 | static int pcie_portdrv_restore_config(struct pci_dev *dev) |
95 | { | 39 | { |
96 | struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev); | ||
97 | int retval; | 40 | int retval; |
98 | 41 | ||
99 | pci_restore_state(dev); | 42 | pci_restore_state(dev); |
100 | if (p_ext->interrupt_mode == PCIE_PORT_MSI_MODE) | ||
101 | pci_restore_msi_state(dev); | ||
102 | retval = pci_enable_device(dev); | 43 | retval = pci_enable_device(dev); |
103 | if (retval) | 44 | if (retval) |
104 | return retval; | 45 | return retval; |
@@ -149,7 +90,8 @@ static int pcie_portdrv_suspend (struct pci_dev *dev, pm_message_t state) | |||
149 | { | 90 | { |
150 | int ret = pcie_port_device_suspend(dev, state); | 91 | int ret = pcie_port_device_suspend(dev, state); |
151 | 92 | ||
152 | pcie_portdrv_save_config(dev); | 93 | if (!ret) |
94 | ret = pcie_portdrv_save_config(dev); | ||
153 | return ret; | 95 | return ret; |
154 | } | 96 | } |
155 | 97 | ||
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index adfad4fd6a13..a10ed9dab2c2 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -33,10 +33,9 @@ LIST_HEAD(pci_devices); | |||
33 | */ | 33 | */ |
34 | static void pci_create_legacy_files(struct pci_bus *b) | 34 | static void pci_create_legacy_files(struct pci_bus *b) |
35 | { | 35 | { |
36 | b->legacy_io = kmalloc(sizeof(struct bin_attribute) * 2, | 36 | b->legacy_io = kzalloc(sizeof(struct bin_attribute) * 2, |
37 | GFP_ATOMIC); | 37 | GFP_ATOMIC); |
38 | if (b->legacy_io) { | 38 | if (b->legacy_io) { |
39 | memset(b->legacy_io, 0, sizeof(struct bin_attribute) * 2); | ||
40 | b->legacy_io->attr.name = "legacy_io"; | 39 | b->legacy_io->attr.name = "legacy_io"; |
41 | b->legacy_io->size = 0xffff; | 40 | b->legacy_io->size = 0xffff; |
42 | b->legacy_io->attr.mode = S_IRUSR | S_IWUSR; | 41 | b->legacy_io->attr.mode = S_IRUSR | S_IWUSR; |
@@ -320,9 +319,8 @@ static struct pci_bus * __devinit pci_alloc_bus(void) | |||
320 | { | 319 | { |
321 | struct pci_bus *b; | 320 | struct pci_bus *b; |
322 | 321 | ||
323 | b = kmalloc(sizeof(*b), GFP_KERNEL); | 322 | b = kzalloc(sizeof(*b), GFP_KERNEL); |
324 | if (b) { | 323 | if (b) { |
325 | memset(b, 0, sizeof(*b)); | ||
326 | INIT_LIST_HEAD(&b->node); | 324 | INIT_LIST_HEAD(&b->node); |
327 | INIT_LIST_HEAD(&b->children); | 325 | INIT_LIST_HEAD(&b->children); |
328 | INIT_LIST_HEAD(&b->devices); | 326 | INIT_LIST_HEAD(&b->devices); |
@@ -347,6 +345,7 @@ pci_alloc_child_bus(struct pci_bus *parent, struct pci_dev *bridge, int busnr) | |||
347 | child->parent = parent; | 345 | child->parent = parent; |
348 | child->ops = parent->ops; | 346 | child->ops = parent->ops; |
349 | child->sysdata = parent->sysdata; | 347 | child->sysdata = parent->sysdata; |
348 | child->bus_flags = parent->bus_flags; | ||
350 | child->bridge = get_device(&bridge->dev); | 349 | child->bridge = get_device(&bridge->dev); |
351 | 350 | ||
352 | child->class_dev.class = &pcibus_class; | 351 | child->class_dev.class = &pcibus_class; |
@@ -456,7 +455,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
456 | * pass and just note the configuration. | 455 | * pass and just note the configuration. |
457 | */ | 456 | */ |
458 | if (pass) | 457 | if (pass) |
459 | return max; | 458 | goto out; |
460 | busnr = (buses >> 8) & 0xFF; | 459 | busnr = (buses >> 8) & 0xFF; |
461 | 460 | ||
462 | /* | 461 | /* |
@@ -466,12 +465,12 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
466 | if (pci_find_bus(pci_domain_nr(bus), busnr)) { | 465 | if (pci_find_bus(pci_domain_nr(bus), busnr)) { |
467 | printk(KERN_INFO "PCI: Bus %04x:%02x already known\n", | 466 | printk(KERN_INFO "PCI: Bus %04x:%02x already known\n", |
468 | pci_domain_nr(bus), busnr); | 467 | pci_domain_nr(bus), busnr); |
469 | return max; | 468 | goto out; |
470 | } | 469 | } |
471 | 470 | ||
472 | child = pci_add_new_bus(bus, dev, busnr); | 471 | child = pci_add_new_bus(bus, dev, busnr); |
473 | if (!child) | 472 | if (!child) |
474 | return max; | 473 | goto out; |
475 | child->primary = buses & 0xFF; | 474 | child->primary = buses & 0xFF; |
476 | child->subordinate = (buses >> 16) & 0xFF; | 475 | child->subordinate = (buses >> 16) & 0xFF; |
477 | child->bridge_ctl = bctl; | 476 | child->bridge_ctl = bctl; |
@@ -496,7 +495,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
496 | bus ranges. */ | 495 | bus ranges. */ |
497 | pci_write_config_dword(dev, PCI_PRIMARY_BUS, | 496 | pci_write_config_dword(dev, PCI_PRIMARY_BUS, |
498 | buses & ~0xffffff); | 497 | buses & ~0xffffff); |
499 | return max; | 498 | goto out; |
500 | } | 499 | } |
501 | 500 | ||
502 | /* Clear errors */ | 501 | /* Clear errors */ |
@@ -505,7 +504,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
505 | /* Prevent assigning a bus number that already exists. | 504 | /* Prevent assigning a bus number that already exists. |
506 | * This can happen when a bridge is hot-plugged */ | 505 | * This can happen when a bridge is hot-plugged */ |
507 | if (pci_find_bus(pci_domain_nr(bus), max+1)) | 506 | if (pci_find_bus(pci_domain_nr(bus), max+1)) |
508 | return max; | 507 | goto out; |
509 | child = pci_add_new_bus(bus, dev, ++max); | 508 | child = pci_add_new_bus(bus, dev, ++max); |
510 | buses = (buses & 0xff000000) | 509 | buses = (buses & 0xff000000) |
511 | | ((unsigned int)(child->primary) << 0) | 510 | | ((unsigned int)(child->primary) << 0) |
@@ -537,6 +536,11 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
537 | pci_fixup_parent_subordinate_busnr(child, max); | 536 | pci_fixup_parent_subordinate_busnr(child, max); |
538 | /* Now we can scan all subordinate buses... */ | 537 | /* Now we can scan all subordinate buses... */ |
539 | max = pci_scan_child_bus(child); | 538 | max = pci_scan_child_bus(child); |
539 | /* | ||
540 | * now fix it up again since we have found | ||
541 | * the real value of max. | ||
542 | */ | ||
543 | pci_fixup_parent_subordinate_busnr(child, max); | ||
540 | } else { | 544 | } else { |
541 | /* | 545 | /* |
542 | * For CardBus bridges, we leave 4 bus numbers | 546 | * For CardBus bridges, we leave 4 bus numbers |
@@ -576,8 +580,6 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
576 | pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); | 580 | pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); |
577 | } | 581 | } |
578 | 582 | ||
579 | pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bctl); | ||
580 | |||
581 | sprintf(child->name, (is_cardbus ? "PCI CardBus #%02x" : "PCI Bus #%02x"), child->number); | 583 | sprintf(child->name, (is_cardbus ? "PCI CardBus #%02x" : "PCI Bus #%02x"), child->number); |
582 | 584 | ||
583 | while (bus->parent) { | 585 | while (bus->parent) { |
@@ -585,17 +587,22 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
585 | (child->number > bus->subordinate) || | 587 | (child->number > bus->subordinate) || |
586 | (child->number < bus->number) || | 588 | (child->number < bus->number) || |
587 | (child->subordinate < bus->number)) { | 589 | (child->subordinate < bus->number)) { |
588 | printk(KERN_WARNING "PCI: Bus #%02x (-#%02x) may be " | 590 | printk(KERN_WARNING "PCI: Bus #%02x (-#%02x) is " |
589 | "hidden behind%s bridge #%02x (-#%02x)%s\n", | 591 | "hidden behind%s bridge #%02x (-#%02x)%s\n", |
590 | child->number, child->subordinate, | 592 | child->number, child->subordinate, |
591 | bus->self->transparent ? " transparent" : " ", | 593 | bus->self->transparent ? " transparent" : " ", |
592 | bus->number, bus->subordinate, | 594 | bus->number, bus->subordinate, |
593 | pcibios_assign_all_busses() ? " " : | 595 | pcibios_assign_all_busses() ? " " : |
594 | " (try 'pci=assign-busses')"); | 596 | " (try 'pci=assign-busses')"); |
597 | printk(KERN_WARNING "Please report the result to " | ||
598 | "linux-kernel to fix this permanently\n"); | ||
595 | } | 599 | } |
596 | bus = bus->parent; | 600 | bus = bus->parent; |
597 | } | 601 | } |
598 | 602 | ||
603 | out: | ||
604 | pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bctl); | ||
605 | |||
599 | return max; | 606 | return max; |
600 | } | 607 | } |
601 | 608 | ||
@@ -788,11 +795,10 @@ pci_scan_device(struct pci_bus *bus, int devfn) | |||
788 | if (pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type)) | 795 | if (pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type)) |
789 | return NULL; | 796 | return NULL; |
790 | 797 | ||
791 | dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL); | 798 | dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL); |
792 | if (!dev) | 799 | if (!dev) |
793 | return NULL; | 800 | return NULL; |
794 | 801 | ||
795 | memset(dev, 0, sizeof(struct pci_dev)); | ||
796 | dev->bus = bus; | 802 | dev->bus = bus; |
797 | dev->sysdata = bus->sysdata; | 803 | dev->sysdata = bus->sysdata; |
798 | dev->dev.parent = bus->bridge; | 804 | dev->dev.parent = bus->bridge; |
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index 92a885760832..54b2ebc9c91a 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c | |||
@@ -458,131 +458,6 @@ int pci_proc_detach_bus(struct pci_bus* bus) | |||
458 | return 0; | 458 | return 0; |
459 | } | 459 | } |
460 | 460 | ||
461 | #ifdef CONFIG_PCI_LEGACY_PROC | ||
462 | |||
463 | /* | ||
464 | * Backward compatible /proc/pci interface. | ||
465 | */ | ||
466 | |||
467 | /* | ||
468 | * Convert some of the configuration space registers of the device at | ||
469 | * address (bus,devfn) into a string (possibly several lines each). | ||
470 | * The configuration string is stored starting at buf[len]. If the | ||
471 | * string would exceed the size of the buffer (SIZE), 0 is returned. | ||
472 | */ | ||
473 | static int show_dev_config(struct seq_file *m, void *v) | ||
474 | { | ||
475 | struct pci_dev *dev = v; | ||
476 | struct pci_dev *first_dev; | ||
477 | struct pci_driver *drv; | ||
478 | u32 class_rev; | ||
479 | unsigned char latency, min_gnt, max_lat; | ||
480 | int reg; | ||
481 | |||
482 | first_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); | ||
483 | if (dev == first_dev) | ||
484 | seq_puts(m, "PCI devices found:\n"); | ||
485 | pci_dev_put(first_dev); | ||
486 | |||
487 | drv = pci_dev_driver(dev); | ||
488 | |||
489 | pci_user_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); | ||
490 | pci_user_read_config_byte (dev, PCI_LATENCY_TIMER, &latency); | ||
491 | pci_user_read_config_byte (dev, PCI_MIN_GNT, &min_gnt); | ||
492 | pci_user_read_config_byte (dev, PCI_MAX_LAT, &max_lat); | ||
493 | seq_printf(m, " Bus %2d, device %3d, function %2d:\n", | ||
494 | dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); | ||
495 | seq_printf(m, " Class %04x", class_rev >> 16); | ||
496 | seq_printf(m, ": PCI device %04x:%04x", dev->vendor, dev->device); | ||
497 | seq_printf(m, " (rev %d).\n", class_rev & 0xff); | ||
498 | |||
499 | if (dev->irq) | ||
500 | seq_printf(m, " IRQ %d.\n", dev->irq); | ||
501 | |||
502 | if (latency || min_gnt || max_lat) { | ||
503 | seq_printf(m, " Master Capable. "); | ||
504 | if (latency) | ||
505 | seq_printf(m, "Latency=%d. ", latency); | ||
506 | else | ||
507 | seq_puts(m, "No bursts. "); | ||
508 | if (min_gnt) | ||
509 | seq_printf(m, "Min Gnt=%d.", min_gnt); | ||
510 | if (max_lat) | ||
511 | seq_printf(m, "Max Lat=%d.", max_lat); | ||
512 | seq_putc(m, '\n'); | ||
513 | } | ||
514 | |||
515 | for (reg = 0; reg < 6; reg++) { | ||
516 | struct resource *res = dev->resource + reg; | ||
517 | unsigned long base, end, flags; | ||
518 | |||
519 | base = res->start; | ||
520 | end = res->end; | ||
521 | flags = res->flags; | ||
522 | if (!end) | ||
523 | continue; | ||
524 | |||
525 | if (flags & PCI_BASE_ADDRESS_SPACE_IO) { | ||
526 | seq_printf(m, " I/O at 0x%lx [0x%lx].\n", | ||
527 | base, end); | ||
528 | } else { | ||
529 | const char *pref, *type = "unknown"; | ||
530 | |||
531 | if (flags & PCI_BASE_ADDRESS_MEM_PREFETCH) | ||
532 | pref = "P"; | ||
533 | else | ||
534 | pref = "Non-p"; | ||
535 | switch (flags & PCI_BASE_ADDRESS_MEM_TYPE_MASK) { | ||
536 | case PCI_BASE_ADDRESS_MEM_TYPE_32: | ||
537 | type = "32 bit"; break; | ||
538 | case PCI_BASE_ADDRESS_MEM_TYPE_1M: | ||
539 | type = "20 bit"; break; | ||
540 | case PCI_BASE_ADDRESS_MEM_TYPE_64: | ||
541 | type = "64 bit"; break; | ||
542 | } | ||
543 | seq_printf(m, " %srefetchable %s memory at " | ||
544 | "0x%lx [0x%lx].\n", pref, type, | ||
545 | base, | ||
546 | end); | ||
547 | } | ||
548 | } | ||
549 | return 0; | ||
550 | } | ||
551 | |||
552 | static struct seq_operations proc_pci_op = { | ||
553 | .start = pci_seq_start, | ||
554 | .next = pci_seq_next, | ||
555 | .stop = pci_seq_stop, | ||
556 | .show = show_dev_config | ||
557 | }; | ||
558 | |||
559 | static int proc_pci_open(struct inode *inode, struct file *file) | ||
560 | { | ||
561 | return seq_open(file, &proc_pci_op); | ||
562 | } | ||
563 | static struct file_operations proc_pci_operations = { | ||
564 | .open = proc_pci_open, | ||
565 | .read = seq_read, | ||
566 | .llseek = seq_lseek, | ||
567 | .release = seq_release, | ||
568 | }; | ||
569 | |||
570 | static void legacy_proc_init(void) | ||
571 | { | ||
572 | struct proc_dir_entry * entry = create_proc_entry("pci", 0, NULL); | ||
573 | if (entry) | ||
574 | entry->proc_fops = &proc_pci_operations; | ||
575 | } | ||
576 | |||
577 | #else | ||
578 | |||
579 | static void legacy_proc_init(void) | ||
580 | { | ||
581 | |||
582 | } | ||
583 | |||
584 | #endif /* CONFIG_PCI_LEGACY_PROC */ | ||
585 | |||
586 | static int proc_bus_pci_dev_open(struct inode *inode, struct file *file) | 461 | static int proc_bus_pci_dev_open(struct inode *inode, struct file *file) |
587 | { | 462 | { |
588 | return seq_open(file, &proc_bus_pci_devices_op); | 463 | return seq_open(file, &proc_bus_pci_devices_op); |
@@ -606,7 +481,6 @@ static int __init pci_proc_init(void) | |||
606 | while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { | 481 | while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { |
607 | pci_proc_attach_device(dev); | 482 | pci_proc_attach_device(dev); |
608 | } | 483 | } |
609 | legacy_proc_init(); | ||
610 | return 0; | 484 | return 0; |
611 | } | 485 | } |
612 | 486 | ||
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index dda6099903c1..4970f47be72c 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -575,8 +575,11 @@ static void __init quirk_amd_8131_ioapic(struct pci_dev *dev) | |||
575 | { | 575 | { |
576 | unsigned char revid, tmp; | 576 | unsigned char revid, tmp; |
577 | 577 | ||
578 | pci_msi_quirk = 1; | 578 | if (dev->subordinate) { |
579 | printk(KERN_WARNING "PCI: MSI quirk detected. pci_msi_quirk set.\n"); | 579 | printk(KERN_WARNING "PCI: MSI quirk detected. " |
580 | "PCI_BUS_FLAGS_NO_MSI set for subordinate bus.\n"); | ||
581 | dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; | ||
582 | } | ||
580 | 583 | ||
581 | if (nr_ioapics == 0) | 584 | if (nr_ioapics == 0) |
582 | return; | 585 | return; |
@@ -934,6 +937,12 @@ static void __init asus_hides_smbus_hostbridge(struct pci_dev *dev) | |||
934 | case 0x12bd: /* HP D530 */ | 937 | case 0x12bd: /* HP D530 */ |
935 | asus_hides_smbus = 1; | 938 | asus_hides_smbus = 1; |
936 | } | 939 | } |
940 | if (dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB) { | ||
941 | switch (dev->subsystem_device) { | ||
942 | case 0x099c: /* HP Compaq nx6110 */ | ||
943 | asus_hides_smbus = 1; | ||
944 | } | ||
945 | } | ||
937 | } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_TOSHIBA)) { | 946 | } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_TOSHIBA)) { |
938 | if (dev->device == PCI_DEVICE_ID_INTEL_82855GM_HB) | 947 | if (dev->device == PCI_DEVICE_ID_INTEL_82855GM_HB) |
939 | switch(dev->subsystem_device) { | 948 | switch(dev->subsystem_device) { |
@@ -1068,6 +1077,37 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_651, quirk_sis_96x_ | |||
1068 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_735, quirk_sis_96x_compatible ); | 1077 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_735, quirk_sis_96x_compatible ); |
1069 | 1078 | ||
1070 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, quirk_sis_503 ); | 1079 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, quirk_sis_503 ); |
1080 | /* | ||
1081 | * On ASUS A8V and A8V Deluxe boards, the onboard AC97 audio controller | ||
1082 | * and MC97 modem controller are disabled when a second PCI soundcard is | ||
1083 | * present. This patch, tweaking the VT8237 ISA bridge, enables them. | ||
1084 | * -- bjd | ||
1085 | */ | ||
1086 | static void __init asus_hides_ac97_lpc(struct pci_dev *dev) | ||
1087 | { | ||
1088 | u8 val; | ||
1089 | int asus_hides_ac97 = 0; | ||
1090 | |||
1091 | if (likely(dev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK)) { | ||
1092 | if (dev->device == PCI_DEVICE_ID_VIA_8237) | ||
1093 | asus_hides_ac97 = 1; | ||
1094 | } | ||
1095 | |||
1096 | if (!asus_hides_ac97) | ||
1097 | return; | ||
1098 | |||
1099 | pci_read_config_byte(dev, 0x50, &val); | ||
1100 | if (val & 0xc0) { | ||
1101 | pci_write_config_byte(dev, 0x50, val & (~0xc0)); | ||
1102 | pci_read_config_byte(dev, 0x50, &val); | ||
1103 | if (val & 0xc0) | ||
1104 | printk(KERN_INFO "PCI: onboard AC97/MC97 devices continue to play 'hide and seek'! 0x%x\n", val); | ||
1105 | else | ||
1106 | printk(KERN_INFO "PCI: enabled onboard AC97/MC97 devices\n"); | ||
1107 | } | ||
1108 | } | ||
1109 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, asus_hides_ac97_lpc ); | ||
1110 | |||
1071 | 1111 | ||
1072 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_961, quirk_sis_96x_smbus ); | 1112 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_961, quirk_sis_96x_smbus ); |
1073 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_962, quirk_sis_96x_smbus ); | 1113 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_962, quirk_sis_96x_smbus ); |
@@ -1242,6 +1282,33 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXH_1, quirk_pc | |||
1242 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXHV, quirk_pcie_pxh); | 1282 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXHV, quirk_pcie_pxh); |
1243 | 1283 | ||
1244 | 1284 | ||
1285 | /* | ||
1286 | * Fixup the cardbus bridges on the IBM Dock II docking station | ||
1287 | */ | ||
1288 | static void __devinit quirk_ibm_dock2_cardbus(struct pci_dev *dev) | ||
1289 | { | ||
1290 | u32 val; | ||
1291 | |||
1292 | /* | ||
1293 | * tie the 2 interrupt pins to INTA, and configure the | ||
1294 | * multifunction routing register to handle this. | ||
1295 | */ | ||
1296 | if ((dev->subsystem_vendor == PCI_VENDOR_ID_IBM) && | ||
1297 | (dev->subsystem_device == 0x0148)) { | ||
1298 | printk(KERN_INFO "PCI: Found IBM Dock II Cardbus Bridge " | ||
1299 | "applying quirk\n"); | ||
1300 | pci_read_config_dword(dev, 0x8c, &val); | ||
1301 | val = ((val & 0xffffff00) | 0x1002); | ||
1302 | pci_write_config_dword(dev, 0x8c, val); | ||
1303 | pci_read_config_dword(dev, 0x80, &val); | ||
1304 | val = ((val & 0x00ffff00) | 0x2864c077); | ||
1305 | pci_write_config_dword(dev, 0x80, val); | ||
1306 | } | ||
1307 | } | ||
1308 | |||
1309 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1420, | ||
1310 | quirk_ibm_dock2_cardbus); | ||
1311 | |||
1245 | static void __devinit quirk_netmos(struct pci_dev *dev) | 1312 | static void __devinit quirk_netmos(struct pci_dev *dev) |
1246 | { | 1313 | { |
1247 | unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4; | 1314 | unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4; |
diff --git a/drivers/pci/search.c b/drivers/pci/search.c index 05fa91a31c62..ce7dd6e7be60 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c | |||
@@ -246,9 +246,9 @@ pci_get_subsys(unsigned int vendor, unsigned int device, | |||
246 | } | 246 | } |
247 | dev = NULL; | 247 | dev = NULL; |
248 | exit: | 248 | exit: |
249 | pci_dev_put(from); | ||
250 | dev = pci_dev_get(dev); | 249 | dev = pci_dev_get(dev); |
251 | spin_unlock(&pci_bus_lock); | 250 | spin_unlock(&pci_bus_lock); |
251 | pci_dev_put(from); | ||
252 | return dev; | 252 | return dev; |
253 | } | 253 | } |
254 | 254 | ||
@@ -339,9 +339,9 @@ struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from) | |||
339 | } | 339 | } |
340 | dev = NULL; | 340 | dev = NULL; |
341 | exit: | 341 | exit: |
342 | pci_dev_put(from); | ||
343 | dev = pci_dev_get(dev); | 342 | dev = pci_dev_get(dev); |
344 | spin_unlock(&pci_bus_lock); | 343 | spin_unlock(&pci_bus_lock); |
344 | pci_dev_put(from); | ||
345 | return dev; | 345 | return dev; |
346 | } | 346 | } |
347 | 347 | ||
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index 5e38cd7335f7..c89c98a2cca8 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c | |||
@@ -448,11 +448,7 @@ pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struc | |||
448 | break; | 448 | break; |
449 | 449 | ||
450 | case SMALL_TAG_END: | 450 | case SMALL_TAG_END: |
451 | if (option_independent != option) | 451 | return p + 2; |
452 | printk(KERN_WARNING "PnPBIOS: Missing SMALL_TAG_ENDDEP tag\n"); | ||
453 | p = p + 2; | ||
454 | return (unsigned char *)p; | ||
455 | break; | ||
456 | 452 | ||
457 | default: /* an unkown tag */ | 453 | default: /* an unkown tag */ |
458 | len_err: | 454 | len_err: |
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c index fafeeae52675..f9930552ab54 100644 --- a/drivers/s390/block/dasd_ioctl.c +++ b/drivers/s390/block/dasd_ioctl.c | |||
@@ -151,9 +151,9 @@ dasd_ioctl_enable(struct block_device *bdev, int no, long args) | |||
151 | return -ENODEV; | 151 | return -ENODEV; |
152 | dasd_enable_device(device); | 152 | dasd_enable_device(device); |
153 | /* Formatting the dasd device can change the capacity. */ | 153 | /* Formatting the dasd device can change the capacity. */ |
154 | down(&bdev->bd_sem); | 154 | mutex_lock(&bdev->bd_mutex); |
155 | i_size_write(bdev->bd_inode, (loff_t)get_capacity(device->gdp) << 9); | 155 | i_size_write(bdev->bd_inode, (loff_t)get_capacity(device->gdp) << 9); |
156 | up(&bdev->bd_sem); | 156 | mutex_unlock(&bdev->bd_mutex); |
157 | return 0; | 157 | return 0; |
158 | } | 158 | } |
159 | 159 | ||
@@ -184,9 +184,9 @@ dasd_ioctl_disable(struct block_device *bdev, int no, long args) | |||
184 | * Set i_size to zero, since read, write, etc. check against this | 184 | * Set i_size to zero, since read, write, etc. check against this |
185 | * value. | 185 | * value. |
186 | */ | 186 | */ |
187 | down(&bdev->bd_sem); | 187 | mutex_lock(&bdev->bd_mutex); |
188 | i_size_write(bdev->bd_inode, 0); | 188 | i_size_write(bdev->bd_inode, 0); |
189 | up(&bdev->bd_sem); | 189 | mutex_unlock(&bdev->bd_mutex); |
190 | return 0; | 190 | return 0; |
191 | } | 191 | } |
192 | 192 | ||
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 0cf0e4c7ac0c..39b760a24241 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <linux/ide.h> | 47 | #include <linux/ide.h> |
48 | #include <linux/scatterlist.h> | 48 | #include <linux/scatterlist.h> |
49 | #include <linux/delay.h> | 49 | #include <linux/delay.h> |
50 | #include <linux/mutex.h> | ||
50 | 51 | ||
51 | #include <asm/io.h> | 52 | #include <asm/io.h> |
52 | #include <asm/bitops.h> | 53 | #include <asm/bitops.h> |
@@ -109,7 +110,7 @@ typedef struct ide_scsi_obj { | |||
109 | unsigned long log; /* log flags */ | 110 | unsigned long log; /* log flags */ |
110 | } idescsi_scsi_t; | 111 | } idescsi_scsi_t; |
111 | 112 | ||
112 | static DECLARE_MUTEX(idescsi_ref_sem); | 113 | static DEFINE_MUTEX(idescsi_ref_mutex); |
113 | 114 | ||
114 | #define ide_scsi_g(disk) \ | 115 | #define ide_scsi_g(disk) \ |
115 | container_of((disk)->private_data, struct ide_scsi_obj, driver) | 116 | container_of((disk)->private_data, struct ide_scsi_obj, driver) |
@@ -118,19 +119,19 @@ static struct ide_scsi_obj *ide_scsi_get(struct gendisk *disk) | |||
118 | { | 119 | { |
119 | struct ide_scsi_obj *scsi = NULL; | 120 | struct ide_scsi_obj *scsi = NULL; |
120 | 121 | ||
121 | down(&idescsi_ref_sem); | 122 | mutex_lock(&idescsi_ref_mutex); |
122 | scsi = ide_scsi_g(disk); | 123 | scsi = ide_scsi_g(disk); |
123 | if (scsi) | 124 | if (scsi) |
124 | scsi_host_get(scsi->host); | 125 | scsi_host_get(scsi->host); |
125 | up(&idescsi_ref_sem); | 126 | mutex_unlock(&idescsi_ref_mutex); |
126 | return scsi; | 127 | return scsi; |
127 | } | 128 | } |
128 | 129 | ||
129 | static void ide_scsi_put(struct ide_scsi_obj *scsi) | 130 | static void ide_scsi_put(struct ide_scsi_obj *scsi) |
130 | { | 131 | { |
131 | down(&idescsi_ref_sem); | 132 | mutex_lock(&idescsi_ref_mutex); |
132 | scsi_host_put(scsi->host); | 133 | scsi_host_put(scsi->host); |
133 | up(&idescsi_ref_sem); | 134 | mutex_unlock(&idescsi_ref_mutex); |
134 | } | 135 | } |
135 | 136 | ||
136 | static inline idescsi_scsi_t *scsihost_to_idescsi(struct Scsi_Host *host) | 137 | static inline idescsi_scsi_t *scsihost_to_idescsi(struct Scsi_Host *host) |
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index f9c1192dc15e..7c80711e18ed 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -71,7 +71,7 @@ MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_CDROM_MAJOR); | |||
71 | #define SR_CAPABILITIES \ | 71 | #define SR_CAPABILITIES \ |
72 | (CDC_CLOSE_TRAY|CDC_OPEN_TRAY|CDC_LOCK|CDC_SELECT_SPEED| \ | 72 | (CDC_CLOSE_TRAY|CDC_OPEN_TRAY|CDC_LOCK|CDC_SELECT_SPEED| \ |
73 | CDC_SELECT_DISC|CDC_MULTI_SESSION|CDC_MCN|CDC_MEDIA_CHANGED| \ | 73 | CDC_SELECT_DISC|CDC_MULTI_SESSION|CDC_MCN|CDC_MEDIA_CHANGED| \ |
74 | CDC_PLAY_AUDIO|CDC_RESET|CDC_IOCTLS|CDC_DRIVE_STATUS| \ | 74 | CDC_PLAY_AUDIO|CDC_RESET|CDC_DRIVE_STATUS| \ |
75 | CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \ | 75 | CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \ |
76 | CDC_MRW|CDC_MRW_W|CDC_RAM) | 76 | CDC_MRW|CDC_MRW_W|CDC_RAM) |
77 | 77 | ||
@@ -118,7 +118,6 @@ static struct cdrom_device_ops sr_dops = { | |||
118 | .get_mcn = sr_get_mcn, | 118 | .get_mcn = sr_get_mcn, |
119 | .reset = sr_reset, | 119 | .reset = sr_reset, |
120 | .audio_ioctl = sr_audio_ioctl, | 120 | .audio_ioctl = sr_audio_ioctl, |
121 | .dev_ioctl = sr_dev_ioctl, | ||
122 | .capability = SR_CAPABILITIES, | 121 | .capability = SR_CAPABILITIES, |
123 | .generic_packet = sr_packet, | 122 | .generic_packet = sr_packet, |
124 | }; | 123 | }; |
@@ -456,17 +455,33 @@ static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd, | |||
456 | { | 455 | { |
457 | struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk); | 456 | struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk); |
458 | struct scsi_device *sdev = cd->device; | 457 | struct scsi_device *sdev = cd->device; |
458 | void __user *argp = (void __user *)arg; | ||
459 | int ret; | ||
459 | 460 | ||
460 | /* | 461 | /* |
461 | * Send SCSI addressing ioctls directly to mid level, send other | 462 | * Send SCSI addressing ioctls directly to mid level, send other |
462 | * ioctls to cdrom/block level. | 463 | * ioctls to cdrom/block level. |
463 | */ | 464 | */ |
464 | switch (cmd) { | 465 | switch (cmd) { |
465 | case SCSI_IOCTL_GET_IDLUN: | 466 | case SCSI_IOCTL_GET_IDLUN: |
466 | case SCSI_IOCTL_GET_BUS_NUMBER: | 467 | case SCSI_IOCTL_GET_BUS_NUMBER: |
467 | return scsi_ioctl(sdev, cmd, (void __user *)arg); | 468 | return scsi_ioctl(sdev, cmd, argp); |
468 | } | 469 | } |
469 | return cdrom_ioctl(file, &cd->cdi, inode, cmd, arg); | 470 | |
471 | ret = cdrom_ioctl(file, &cd->cdi, inode, cmd, arg); | ||
472 | if (ret != ENOSYS) | ||
473 | return ret; | ||
474 | |||
475 | /* | ||
476 | * ENODEV means that we didn't recognise the ioctl, or that we | ||
477 | * cannot execute it in the current device state. In either | ||
478 | * case fall through to scsi_ioctl, which will return ENDOEV again | ||
479 | * if it doesn't recognise the ioctl | ||
480 | */ | ||
481 | ret = scsi_nonblockable_ioctl(sdev, cmd, argp, NULL); | ||
482 | if (ret != -ENODEV) | ||
483 | return ret; | ||
484 | return scsi_ioctl(sdev, cmd, argp); | ||
470 | } | 485 | } |
471 | 486 | ||
472 | static int sr_block_media_changed(struct gendisk *disk) | 487 | static int sr_block_media_changed(struct gendisk *disk) |
diff --git a/drivers/scsi/sr.h b/drivers/scsi/sr.h index d2bcd99c272f..d65de9621b27 100644 --- a/drivers/scsi/sr.h +++ b/drivers/scsi/sr.h | |||
@@ -55,7 +55,6 @@ int sr_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *); | |||
55 | int sr_reset(struct cdrom_device_info *); | 55 | int sr_reset(struct cdrom_device_info *); |
56 | int sr_select_speed(struct cdrom_device_info *cdi, int speed); | 56 | int sr_select_speed(struct cdrom_device_info *cdi, int speed); |
57 | int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *); | 57 | int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *); |
58 | int sr_dev_ioctl(struct cdrom_device_info *, unsigned int, unsigned long); | ||
59 | 58 | ||
60 | int sr_is_xa(Scsi_CD *); | 59 | int sr_is_xa(Scsi_CD *); |
61 | 60 | ||
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index b65462f76484..d1268cb46837 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c | |||
@@ -562,22 +562,3 @@ int sr_is_xa(Scsi_CD *cd) | |||
562 | #endif | 562 | #endif |
563 | return is_xa; | 563 | return is_xa; |
564 | } | 564 | } |
565 | |||
566 | int sr_dev_ioctl(struct cdrom_device_info *cdi, | ||
567 | unsigned int cmd, unsigned long arg) | ||
568 | { | ||
569 | Scsi_CD *cd = cdi->handle; | ||
570 | int ret; | ||
571 | |||
572 | ret = scsi_nonblockable_ioctl(cd->device, cmd, | ||
573 | (void __user *)arg, NULL); | ||
574 | /* | ||
575 | * ENODEV means that we didn't recognise the ioctl, or that we | ||
576 | * cannot execute it in the current device state. In either | ||
577 | * case fall through to scsi_ioctl, which will return ENDOEV again | ||
578 | * if it doesn't recognise the ioctl | ||
579 | */ | ||
580 | if (ret != -ENODEV) | ||
581 | return ret; | ||
582 | return scsi_ioctl(cd->device, cmd, (void __user *)arg); | ||
583 | } | ||
diff --git a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c index 7f0f35a05dca..b88a7c1158af 100644 --- a/drivers/serial/68328serial.c +++ b/drivers/serial/68328serial.c | |||
@@ -101,8 +101,6 @@ struct tty_driver *serial_driver; | |||
101 | 101 | ||
102 | #define RS_ISR_PASS_LIMIT 256 | 102 | #define RS_ISR_PASS_LIMIT 256 |
103 | 103 | ||
104 | #define _INLINE_ inline | ||
105 | |||
106 | static void change_speed(struct m68k_serial *info); | 104 | static void change_speed(struct m68k_serial *info); |
107 | 105 | ||
108 | /* | 106 | /* |
@@ -262,7 +260,7 @@ static void batten_down_hatches(void) | |||
262 | /* Drop into the debugger */ | 260 | /* Drop into the debugger */ |
263 | } | 261 | } |
264 | 262 | ||
265 | static _INLINE_ void status_handle(struct m68k_serial *info, unsigned short status) | 263 | static void status_handle(struct m68k_serial *info, unsigned short status) |
266 | { | 264 | { |
267 | #if 0 | 265 | #if 0 |
268 | if(status & DCD) { | 266 | if(status & DCD) { |
@@ -289,7 +287,8 @@ static _INLINE_ void status_handle(struct m68k_serial *info, unsigned short stat | |||
289 | return; | 287 | return; |
290 | } | 288 | } |
291 | 289 | ||
292 | static _INLINE_ void receive_chars(struct m68k_serial *info, struct pt_regs *regs, unsigned short rx) | 290 | static void receive_chars(struct m68k_serial *info, struct pt_regs *regs, |
291 | unsigned short rx) | ||
293 | { | 292 | { |
294 | struct tty_struct *tty = info->tty; | 293 | struct tty_struct *tty = info->tty; |
295 | m68328_uart *uart = &uart_addr[info->line]; | 294 | m68328_uart *uart = &uart_addr[info->line]; |
@@ -359,7 +358,7 @@ clear_and_exit: | |||
359 | return; | 358 | return; |
360 | } | 359 | } |
361 | 360 | ||
362 | static _INLINE_ void transmit_chars(struct m68k_serial *info) | 361 | static void transmit_chars(struct m68k_serial *info) |
363 | { | 362 | { |
364 | m68328_uart *uart = &uart_addr[info->line]; | 363 | m68328_uart *uart = &uart_addr[info->line]; |
365 | 364 | ||
diff --git a/drivers/serial/au1x00_uart.c b/drivers/serial/au1x00_uart.c index 29f94bbb79be..948880ac5878 100644 --- a/drivers/serial/au1x00_uart.c +++ b/drivers/serial/au1x00_uart.c | |||
@@ -133,13 +133,12 @@ static const struct serial_uart_config uart_config[PORT_MAX_8250+1] = { | |||
133 | { "AU1X00_UART",16, UART_CLEAR_FIFO | UART_USE_FIFO }, | 133 | { "AU1X00_UART",16, UART_CLEAR_FIFO | UART_USE_FIFO }, |
134 | }; | 134 | }; |
135 | 135 | ||
136 | static _INLINE_ unsigned int serial_in(struct uart_8250_port *up, int offset) | 136 | static unsigned int serial_in(struct uart_8250_port *up, int offset) |
137 | { | 137 | { |
138 | return au_readl((unsigned long)up->port.membase + offset); | 138 | return au_readl((unsigned long)up->port.membase + offset); |
139 | } | 139 | } |
140 | 140 | ||
141 | static _INLINE_ void | 141 | static void serial_out(struct uart_8250_port *up, int offset, int value) |
142 | serial_out(struct uart_8250_port *up, int offset, int value) | ||
143 | { | 142 | { |
144 | au_writel(value, (unsigned long)up->port.membase + offset); | 143 | au_writel(value, (unsigned long)up->port.membase + offset); |
145 | } | 144 | } |
@@ -237,7 +236,7 @@ static void serial8250_enable_ms(struct uart_port *port) | |||
237 | serial_out(up, UART_IER, up->ier); | 236 | serial_out(up, UART_IER, up->ier); |
238 | } | 237 | } |
239 | 238 | ||
240 | static _INLINE_ void | 239 | static void |
241 | receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) | 240 | receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) |
242 | { | 241 | { |
243 | struct tty_struct *tty = up->port.info->tty; | 242 | struct tty_struct *tty = up->port.info->tty; |
@@ -312,7 +311,7 @@ receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) | |||
312 | spin_lock(&up->port.lock); | 311 | spin_lock(&up->port.lock); |
313 | } | 312 | } |
314 | 313 | ||
315 | static _INLINE_ void transmit_chars(struct uart_8250_port *up) | 314 | static void transmit_chars(struct uart_8250_port *up) |
316 | { | 315 | { |
317 | struct circ_buf *xmit = &up->port.info->xmit; | 316 | struct circ_buf *xmit = &up->port.info->xmit; |
318 | int count; | 317 | int count; |
@@ -346,7 +345,7 @@ static _INLINE_ void transmit_chars(struct uart_8250_port *up) | |||
346 | serial8250_stop_tx(&up->port); | 345 | serial8250_stop_tx(&up->port); |
347 | } | 346 | } |
348 | 347 | ||
349 | static _INLINE_ void check_modem_status(struct uart_8250_port *up) | 348 | static void check_modem_status(struct uart_8250_port *up) |
350 | { | 349 | { |
351 | int status; | 350 | int status; |
352 | 351 | ||
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c index be12623d8544..89700141f87e 100644 --- a/drivers/serial/crisv10.c +++ b/drivers/serial/crisv10.c | |||
@@ -481,8 +481,6 @@ static char *serial_version = "$Revision: 1.25 $"; | |||
481 | #include "serial_compat.h" | 481 | #include "serial_compat.h" |
482 | #endif | 482 | #endif |
483 | 483 | ||
484 | #define _INLINE_ inline | ||
485 | |||
486 | struct tty_driver *serial_driver; | 484 | struct tty_driver *serial_driver; |
487 | 485 | ||
488 | /* serial subtype definitions */ | 486 | /* serial subtype definitions */ |
@@ -591,8 +589,6 @@ static void rs_throttle(struct tty_struct * tty); | |||
591 | static void rs_wait_until_sent(struct tty_struct *tty, int timeout); | 589 | static void rs_wait_until_sent(struct tty_struct *tty, int timeout); |
592 | static int rs_write(struct tty_struct * tty, int from_user, | 590 | static int rs_write(struct tty_struct * tty, int from_user, |
593 | const unsigned char *buf, int count); | 591 | const unsigned char *buf, int count); |
594 | extern _INLINE_ int rs_raw_write(struct tty_struct * tty, int from_user, | ||
595 | const unsigned char *buf, int count); | ||
596 | #ifdef CONFIG_ETRAX_RS485 | 592 | #ifdef CONFIG_ETRAX_RS485 |
597 | static int e100_write_rs485(struct tty_struct * tty, int from_user, | 593 | static int e100_write_rs485(struct tty_struct * tty, int from_user, |
598 | const unsigned char *buf, int count); | 594 | const unsigned char *buf, int count); |
@@ -1538,8 +1534,7 @@ e100_enable_rxdma_irq(struct e100_serial *info) | |||
1538 | 1534 | ||
1539 | /* the tx DMA uses only dma_descr interrupt */ | 1535 | /* the tx DMA uses only dma_descr interrupt */ |
1540 | 1536 | ||
1541 | static _INLINE_ void | 1537 | static void e100_disable_txdma_irq(struct e100_serial *info) |
1542 | e100_disable_txdma_irq(struct e100_serial *info) | ||
1543 | { | 1538 | { |
1544 | #ifdef SERIAL_DEBUG_INTR | 1539 | #ifdef SERIAL_DEBUG_INTR |
1545 | printk("txdma_irq(%d): 0\n",info->line); | 1540 | printk("txdma_irq(%d): 0\n",info->line); |
@@ -1548,8 +1543,7 @@ e100_disable_txdma_irq(struct e100_serial *info) | |||
1548 | *R_IRQ_MASK2_CLR = info->irq; | 1543 | *R_IRQ_MASK2_CLR = info->irq; |
1549 | } | 1544 | } |
1550 | 1545 | ||
1551 | static _INLINE_ void | 1546 | static void e100_enable_txdma_irq(struct e100_serial *info) |
1552 | e100_enable_txdma_irq(struct e100_serial *info) | ||
1553 | { | 1547 | { |
1554 | #ifdef SERIAL_DEBUG_INTR | 1548 | #ifdef SERIAL_DEBUG_INTR |
1555 | printk("txdma_irq(%d): 1\n",info->line); | 1549 | printk("txdma_irq(%d): 1\n",info->line); |
@@ -1558,8 +1552,7 @@ e100_enable_txdma_irq(struct e100_serial *info) | |||
1558 | *R_IRQ_MASK2_SET = info->irq; | 1552 | *R_IRQ_MASK2_SET = info->irq; |
1559 | } | 1553 | } |
1560 | 1554 | ||
1561 | static _INLINE_ void | 1555 | static void e100_disable_txdma_channel(struct e100_serial *info) |
1562 | e100_disable_txdma_channel(struct e100_serial *info) | ||
1563 | { | 1556 | { |
1564 | unsigned long flags; | 1557 | unsigned long flags; |
1565 | 1558 | ||
@@ -1599,8 +1592,7 @@ e100_disable_txdma_channel(struct e100_serial *info) | |||
1599 | } | 1592 | } |
1600 | 1593 | ||
1601 | 1594 | ||
1602 | static _INLINE_ void | 1595 | static void e100_enable_txdma_channel(struct e100_serial *info) |
1603 | e100_enable_txdma_channel(struct e100_serial *info) | ||
1604 | { | 1596 | { |
1605 | unsigned long flags; | 1597 | unsigned long flags; |
1606 | 1598 | ||
@@ -1625,8 +1617,7 @@ e100_enable_txdma_channel(struct e100_serial *info) | |||
1625 | restore_flags(flags); | 1617 | restore_flags(flags); |
1626 | } | 1618 | } |
1627 | 1619 | ||
1628 | static _INLINE_ void | 1620 | static void e100_disable_rxdma_channel(struct e100_serial *info) |
1629 | e100_disable_rxdma_channel(struct e100_serial *info) | ||
1630 | { | 1621 | { |
1631 | unsigned long flags; | 1622 | unsigned long flags; |
1632 | 1623 | ||
@@ -1665,8 +1656,7 @@ e100_disable_rxdma_channel(struct e100_serial *info) | |||
1665 | } | 1656 | } |
1666 | 1657 | ||
1667 | 1658 | ||
1668 | static _INLINE_ void | 1659 | static void e100_enable_rxdma_channel(struct e100_serial *info) |
1669 | e100_enable_rxdma_channel(struct e100_serial *info) | ||
1670 | { | 1660 | { |
1671 | unsigned long flags; | 1661 | unsigned long flags; |
1672 | 1662 | ||
@@ -1913,9 +1903,7 @@ rs_start(struct tty_struct *tty) | |||
1913 | * This routine is used by the interrupt handler to schedule | 1903 | * This routine is used by the interrupt handler to schedule |
1914 | * processing in the software interrupt portion of the driver. | 1904 | * processing in the software interrupt portion of the driver. |
1915 | */ | 1905 | */ |
1916 | static _INLINE_ void | 1906 | static void rs_sched_event(struct e100_serial *info, int event) |
1917 | rs_sched_event(struct e100_serial *info, | ||
1918 | int event) | ||
1919 | { | 1907 | { |
1920 | if (info->event & (1 << event)) | 1908 | if (info->event & (1 << event)) |
1921 | return; | 1909 | return; |
@@ -2155,8 +2143,9 @@ add_char_and_flag(struct e100_serial *info, unsigned char data, unsigned char fl | |||
2155 | return 1; | 2143 | return 1; |
2156 | } | 2144 | } |
2157 | 2145 | ||
2158 | extern _INLINE_ unsigned int | 2146 | static unsigned int handle_descr_data(struct e100_serial *info, |
2159 | handle_descr_data(struct e100_serial *info, struct etrax_dma_descr *descr, unsigned int recvl) | 2147 | struct etrax_dma_descr *descr, |
2148 | unsigned int recvl) | ||
2160 | { | 2149 | { |
2161 | struct etrax_recv_buffer *buffer = phys_to_virt(descr->buf) - sizeof *buffer; | 2150 | struct etrax_recv_buffer *buffer = phys_to_virt(descr->buf) - sizeof *buffer; |
2162 | 2151 | ||
@@ -2182,8 +2171,7 @@ handle_descr_data(struct e100_serial *info, struct etrax_dma_descr *descr, unsig | |||
2182 | return recvl; | 2171 | return recvl; |
2183 | } | 2172 | } |
2184 | 2173 | ||
2185 | static _INLINE_ unsigned int | 2174 | static unsigned int handle_all_descr_data(struct e100_serial *info) |
2186 | handle_all_descr_data(struct e100_serial *info) | ||
2187 | { | 2175 | { |
2188 | struct etrax_dma_descr *descr; | 2176 | struct etrax_dma_descr *descr; |
2189 | unsigned int recvl; | 2177 | unsigned int recvl; |
@@ -2230,8 +2218,7 @@ handle_all_descr_data(struct e100_serial *info) | |||
2230 | return ret; | 2218 | return ret; |
2231 | } | 2219 | } |
2232 | 2220 | ||
2233 | static _INLINE_ void | 2221 | static void receive_chars_dma(struct e100_serial *info) |
2234 | receive_chars_dma(struct e100_serial *info) | ||
2235 | { | 2222 | { |
2236 | struct tty_struct *tty; | 2223 | struct tty_struct *tty; |
2237 | unsigned char rstat; | 2224 | unsigned char rstat; |
@@ -2292,8 +2279,7 @@ receive_chars_dma(struct e100_serial *info) | |||
2292 | *info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, restart); | 2279 | *info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, restart); |
2293 | } | 2280 | } |
2294 | 2281 | ||
2295 | static _INLINE_ int | 2282 | static int start_recv_dma(struct e100_serial *info) |
2296 | start_recv_dma(struct e100_serial *info) | ||
2297 | { | 2283 | { |
2298 | struct etrax_dma_descr *descr = info->rec_descr; | 2284 | struct etrax_dma_descr *descr = info->rec_descr; |
2299 | struct etrax_recv_buffer *buffer; | 2285 | struct etrax_recv_buffer *buffer; |
@@ -2348,11 +2334,6 @@ start_receive(struct e100_serial *info) | |||
2348 | } | 2334 | } |
2349 | 2335 | ||
2350 | 2336 | ||
2351 | static _INLINE_ void | ||
2352 | status_handle(struct e100_serial *info, unsigned short status) | ||
2353 | { | ||
2354 | } | ||
2355 | |||
2356 | /* the bits in the MASK2 register are laid out like this: | 2337 | /* the bits in the MASK2 register are laid out like this: |
2357 | DMAI_EOP DMAI_DESCR DMAO_EOP DMAO_DESCR | 2338 | DMAI_EOP DMAI_DESCR DMAO_EOP DMAO_DESCR |
2358 | where I is the input channel and O is the output channel for the port. | 2339 | where I is the input channel and O is the output channel for the port. |
@@ -2454,8 +2435,7 @@ rec_interrupt(int irq, void *dev_id, struct pt_regs * regs) | |||
2454 | return IRQ_RETVAL(handled); | 2435 | return IRQ_RETVAL(handled); |
2455 | } /* rec_interrupt */ | 2436 | } /* rec_interrupt */ |
2456 | 2437 | ||
2457 | static _INLINE_ int | 2438 | static int force_eop_if_needed(struct e100_serial *info) |
2458 | force_eop_if_needed(struct e100_serial *info) | ||
2459 | { | 2439 | { |
2460 | /* We check data_avail bit to determine if data has | 2440 | /* We check data_avail bit to determine if data has |
2461 | * arrived since last time | 2441 | * arrived since last time |
@@ -2499,8 +2479,7 @@ force_eop_if_needed(struct e100_serial *info) | |||
2499 | return 1; | 2479 | return 1; |
2500 | } | 2480 | } |
2501 | 2481 | ||
2502 | extern _INLINE_ void | 2482 | static void flush_to_flip_buffer(struct e100_serial *info) |
2503 | flush_to_flip_buffer(struct e100_serial *info) | ||
2504 | { | 2483 | { |
2505 | struct tty_struct *tty; | 2484 | struct tty_struct *tty; |
2506 | struct etrax_recv_buffer *buffer; | 2485 | struct etrax_recv_buffer *buffer; |
@@ -2611,8 +2590,7 @@ flush_to_flip_buffer(struct e100_serial *info) | |||
2611 | tty_flip_buffer_push(tty); | 2590 | tty_flip_buffer_push(tty); |
2612 | } | 2591 | } |
2613 | 2592 | ||
2614 | static _INLINE_ void | 2593 | static void check_flush_timeout(struct e100_serial *info) |
2615 | check_flush_timeout(struct e100_serial *info) | ||
2616 | { | 2594 | { |
2617 | /* Flip what we've got (if we can) */ | 2595 | /* Flip what we've got (if we can) */ |
2618 | flush_to_flip_buffer(info); | 2596 | flush_to_flip_buffer(info); |
@@ -2741,7 +2719,7 @@ TODO: The break will be delayed until an F or V character is received. | |||
2741 | 2719 | ||
2742 | */ | 2720 | */ |
2743 | 2721 | ||
2744 | extern _INLINE_ | 2722 | static |
2745 | struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info) | 2723 | struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info) |
2746 | { | 2724 | { |
2747 | unsigned long data_read; | 2725 | unsigned long data_read; |
@@ -2875,8 +2853,7 @@ more_data: | |||
2875 | return info; | 2853 | return info; |
2876 | } | 2854 | } |
2877 | 2855 | ||
2878 | extern _INLINE_ | 2856 | static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info) |
2879 | struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info) | ||
2880 | { | 2857 | { |
2881 | unsigned char rstat; | 2858 | unsigned char rstat; |
2882 | 2859 | ||
@@ -2995,7 +2972,7 @@ struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info) | |||
2995 | return info; | 2972 | return info; |
2996 | } /* handle_ser_rx_interrupt */ | 2973 | } /* handle_ser_rx_interrupt */ |
2997 | 2974 | ||
2998 | extern _INLINE_ void handle_ser_tx_interrupt(struct e100_serial *info) | 2975 | static void handle_ser_tx_interrupt(struct e100_serial *info) |
2999 | { | 2976 | { |
3000 | unsigned long flags; | 2977 | unsigned long flags; |
3001 | 2978 | ||
@@ -3621,9 +3598,8 @@ rs_flush_chars(struct tty_struct *tty) | |||
3621 | restore_flags(flags); | 3598 | restore_flags(flags); |
3622 | } | 3599 | } |
3623 | 3600 | ||
3624 | extern _INLINE_ int | 3601 | static int rs_raw_write(struct tty_struct * tty, int from_user, |
3625 | rs_raw_write(struct tty_struct * tty, int from_user, | 3602 | const unsigned char *buf, int count) |
3626 | const unsigned char *buf, int count) | ||
3627 | { | 3603 | { |
3628 | int c, ret = 0; | 3604 | int c, ret = 0; |
3629 | struct e100_serial *info = (struct e100_serial *)tty->driver_data; | 3605 | struct e100_serial *info = (struct e100_serial *)tty->driver_data; |
@@ -4710,7 +4686,7 @@ rs_open(struct tty_struct *tty, struct file * filp) | |||
4710 | * /proc fs routines.... | 4686 | * /proc fs routines.... |
4711 | */ | 4687 | */ |
4712 | 4688 | ||
4713 | extern _INLINE_ int line_info(char *buf, struct e100_serial *info) | 4689 | static int line_info(char *buf, struct e100_serial *info) |
4714 | { | 4690 | { |
4715 | char stat_buf[30]; | 4691 | char stat_buf[30]; |
4716 | int ret; | 4692 | int ret; |
diff --git a/drivers/serial/m32r_sio.c b/drivers/serial/m32r_sio.c index 876bc5e027bb..e9c10c0a30fc 100644 --- a/drivers/serial/m32r_sio.c +++ b/drivers/serial/m32r_sio.c | |||
@@ -248,17 +248,17 @@ static void sio_error(int *status) | |||
248 | 248 | ||
249 | #endif /* CONFIG_SERIAL_M32R_PLDSIO */ | 249 | #endif /* CONFIG_SERIAL_M32R_PLDSIO */ |
250 | 250 | ||
251 | static _INLINE_ unsigned int sio_in(struct uart_sio_port *up, int offset) | 251 | static unsigned int sio_in(struct uart_sio_port *up, int offset) |
252 | { | 252 | { |
253 | return __sio_in(up->port.iobase + offset); | 253 | return __sio_in(up->port.iobase + offset); |
254 | } | 254 | } |
255 | 255 | ||
256 | static _INLINE_ void sio_out(struct uart_sio_port *up, int offset, int value) | 256 | static void sio_out(struct uart_sio_port *up, int offset, int value) |
257 | { | 257 | { |
258 | __sio_out(value, up->port.iobase + offset); | 258 | __sio_out(value, up->port.iobase + offset); |
259 | } | 259 | } |
260 | 260 | ||
261 | static _INLINE_ unsigned int serial_in(struct uart_sio_port *up, int offset) | 261 | static unsigned int serial_in(struct uart_sio_port *up, int offset) |
262 | { | 262 | { |
263 | if (!offset) | 263 | if (!offset) |
264 | return 0; | 264 | return 0; |
@@ -266,8 +266,7 @@ static _INLINE_ unsigned int serial_in(struct uart_sio_port *up, int offset) | |||
266 | return __sio_in(offset); | 266 | return __sio_in(offset); |
267 | } | 267 | } |
268 | 268 | ||
269 | static _INLINE_ void | 269 | static void serial_out(struct uart_sio_port *up, int offset, int value) |
270 | serial_out(struct uart_sio_port *up, int offset, int value) | ||
271 | { | 270 | { |
272 | if (!offset) | 271 | if (!offset) |
273 | return; | 272 | return; |
@@ -326,8 +325,8 @@ static void m32r_sio_enable_ms(struct uart_port *port) | |||
326 | serial_out(up, UART_IER, up->ier); | 325 | serial_out(up, UART_IER, up->ier); |
327 | } | 326 | } |
328 | 327 | ||
329 | static _INLINE_ void receive_chars(struct uart_sio_port *up, int *status, | 328 | static void receive_chars(struct uart_sio_port *up, int *status, |
330 | struct pt_regs *regs) | 329 | struct pt_regs *regs) |
331 | { | 330 | { |
332 | struct tty_struct *tty = up->port.info->tty; | 331 | struct tty_struct *tty = up->port.info->tty; |
333 | unsigned char ch; | 332 | unsigned char ch; |
@@ -400,7 +399,7 @@ static _INLINE_ void receive_chars(struct uart_sio_port *up, int *status, | |||
400 | tty_flip_buffer_push(tty); | 399 | tty_flip_buffer_push(tty); |
401 | } | 400 | } |
402 | 401 | ||
403 | static _INLINE_ void transmit_chars(struct uart_sio_port *up) | 402 | static void transmit_chars(struct uart_sio_port *up) |
404 | { | 403 | { |
405 | struct circ_buf *xmit = &up->port.info->xmit; | 404 | struct circ_buf *xmit = &up->port.info->xmit; |
406 | int count; | 405 | int count; |
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c index 7fc3d3b41d18..9fe2283d91e5 100644 --- a/drivers/serial/sunsu.c +++ b/drivers/serial/sunsu.c | |||
@@ -102,9 +102,7 @@ struct uart_sunsu_port { | |||
102 | #endif | 102 | #endif |
103 | }; | 103 | }; |
104 | 104 | ||
105 | #define _INLINE_ | 105 | static unsigned int serial_in(struct uart_sunsu_port *up, int offset) |
106 | |||
107 | static _INLINE_ unsigned int serial_in(struct uart_sunsu_port *up, int offset) | ||
108 | { | 106 | { |
109 | offset <<= up->port.regshift; | 107 | offset <<= up->port.regshift; |
110 | 108 | ||
@@ -121,8 +119,7 @@ static _INLINE_ unsigned int serial_in(struct uart_sunsu_port *up, int offset) | |||
121 | } | 119 | } |
122 | } | 120 | } |
123 | 121 | ||
124 | static _INLINE_ void | 122 | static void serial_out(struct uart_sunsu_port *up, int offset, int value) |
125 | serial_out(struct uart_sunsu_port *up, int offset, int value) | ||
126 | { | 123 | { |
127 | #ifndef CONFIG_SPARC64 | 124 | #ifndef CONFIG_SPARC64 |
128 | /* | 125 | /* |
@@ -316,7 +313,7 @@ static void sunsu_enable_ms(struct uart_port *port) | |||
316 | spin_unlock_irqrestore(&up->port.lock, flags); | 313 | spin_unlock_irqrestore(&up->port.lock, flags); |
317 | } | 314 | } |
318 | 315 | ||
319 | static _INLINE_ struct tty_struct * | 316 | static struct tty_struct * |
320 | receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs *regs) | 317 | receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs *regs) |
321 | { | 318 | { |
322 | struct tty_struct *tty = up->port.info->tty; | 319 | struct tty_struct *tty = up->port.info->tty; |
@@ -395,7 +392,7 @@ receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs | |||
395 | return tty; | 392 | return tty; |
396 | } | 393 | } |
397 | 394 | ||
398 | static _INLINE_ void transmit_chars(struct uart_sunsu_port *up) | 395 | static void transmit_chars(struct uart_sunsu_port *up) |
399 | { | 396 | { |
400 | struct circ_buf *xmit = &up->port.info->xmit; | 397 | struct circ_buf *xmit = &up->port.info->xmit; |
401 | int count; | 398 | int count; |
@@ -431,7 +428,7 @@ static _INLINE_ void transmit_chars(struct uart_sunsu_port *up) | |||
431 | __stop_tx(up); | 428 | __stop_tx(up); |
432 | } | 429 | } |
433 | 430 | ||
434 | static _INLINE_ void check_modem_status(struct uart_sunsu_port *up) | 431 | static void check_modem_status(struct uart_sunsu_port *up) |
435 | { | 432 | { |
436 | int status; | 433 | int status; |
437 | 434 | ||
diff --git a/drivers/tc/zs.c b/drivers/tc/zs.c index 6756d0fab6fe..2dffa8e303b2 100644 --- a/drivers/tc/zs.c +++ b/drivers/tc/zs.c | |||
@@ -186,8 +186,6 @@ static struct tty_driver *serial_driver; | |||
186 | #define RS_STROBE_TIME 10 | 186 | #define RS_STROBE_TIME 10 |
187 | #define RS_ISR_PASS_LIMIT 256 | 187 | #define RS_ISR_PASS_LIMIT 256 |
188 | 188 | ||
189 | #define _INLINE_ inline | ||
190 | |||
191 | static void probe_sccs(void); | 189 | static void probe_sccs(void); |
192 | static void change_speed(struct dec_serial *info); | 190 | static void change_speed(struct dec_serial *info); |
193 | static void rs_wait_until_sent(struct tty_struct *tty, int timeout); | 191 | static void rs_wait_until_sent(struct tty_struct *tty, int timeout); |
@@ -344,14 +342,13 @@ static inline void rs_recv_clear(struct dec_zschannel *zsc) | |||
344 | * This routine is used by the interrupt handler to schedule | 342 | * This routine is used by the interrupt handler to schedule |
345 | * processing in the software interrupt portion of the driver. | 343 | * processing in the software interrupt portion of the driver. |
346 | */ | 344 | */ |
347 | static _INLINE_ void rs_sched_event(struct dec_serial *info, int event) | 345 | static void rs_sched_event(struct dec_serial *info, int event) |
348 | { | 346 | { |
349 | info->event |= 1 << event; | 347 | info->event |= 1 << event; |
350 | tasklet_schedule(&info->tlet); | 348 | tasklet_schedule(&info->tlet); |
351 | } | 349 | } |
352 | 350 | ||
353 | static _INLINE_ void receive_chars(struct dec_serial *info, | 351 | static void receive_chars(struct dec_serial *info, struct pt_regs *regs) |
354 | struct pt_regs *regs) | ||
355 | { | 352 | { |
356 | struct tty_struct *tty = info->tty; | 353 | struct tty_struct *tty = info->tty; |
357 | unsigned char ch, stat, flag; | 354 | unsigned char ch, stat, flag; |
@@ -441,7 +438,7 @@ static void transmit_chars(struct dec_serial *info) | |||
441 | rs_sched_event(info, RS_EVENT_WRITE_WAKEUP); | 438 | rs_sched_event(info, RS_EVENT_WRITE_WAKEUP); |
442 | } | 439 | } |
443 | 440 | ||
444 | static _INLINE_ void status_handle(struct dec_serial *info) | 441 | static void status_handle(struct dec_serial *info) |
445 | { | 442 | { |
446 | unsigned char stat; | 443 | unsigned char stat; |
447 | 444 | ||