Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dvb: Push down BKL into ioctl functions

This requires changing all users of dvb_usercopy to
omit the inode argument.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>

authored by

Arnd Bergmann and committed by
Frederic Weisbecker
16ef8def ce8273a5

+85 -58
+22 -9
drivers/media/dvb/dvb-core/dmxdev.c
··· 25 25 #include <linux/slab.h> 26 26 #include <linux/vmalloc.h> 27 27 #include <linux/module.h> 28 + #include <linux/smp_lock.h> 28 29 #include <linux/poll.h> 29 30 #include <linux/ioctl.h> 30 31 #include <linux/wait.h> ··· 964 963 return ret; 965 964 } 966 965 967 - static int dvb_demux_do_ioctl(struct inode *inode, struct file *file, 966 + static int dvb_demux_do_ioctl(struct file *file, 968 967 unsigned int cmd, void *parg) 969 968 { 970 969 struct dmxdev_filter *dmxdevfilter = file->private_data; ··· 1085 1084 return ret; 1086 1085 } 1087 1086 1088 - static int dvb_demux_ioctl(struct inode *inode, struct file *file, 1089 - unsigned int cmd, unsigned long arg) 1087 + static long dvb_demux_ioctl(struct file *file, unsigned int cmd, 1088 + unsigned long arg) 1090 1089 { 1091 - return dvb_usercopy(inode, file, cmd, arg, dvb_demux_do_ioctl); 1090 + int ret; 1091 + 1092 + lock_kernel(); 1093 + ret = dvb_usercopy(file, cmd, arg, dvb_demux_do_ioctl); 1094 + unlock_kernel(); 1095 + 1096 + return ret; 1092 1097 } 1093 1098 1094 1099 static unsigned int dvb_demux_poll(struct file *file, poll_table *wait) ··· 1146 1139 static const struct file_operations dvb_demux_fops = { 1147 1140 .owner = THIS_MODULE, 1148 1141 .read = dvb_demux_read, 1149 - .ioctl = dvb_demux_ioctl, 1142 + .unlocked_ioctl = dvb_demux_ioctl, 1150 1143 .open = dvb_demux_open, 1151 1144 .release = dvb_demux_release, 1152 1145 .poll = dvb_demux_poll, ··· 1159 1152 .fops = &dvb_demux_fops 1160 1153 }; 1161 1154 1162 - static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file, 1155 + static int dvb_dvr_do_ioctl(struct file *file, 1163 1156 unsigned int cmd, void *parg) 1164 1157 { 1165 1158 struct dvb_device *dvbdev = file->private_data; ··· 1183 1176 return ret; 1184 1177 } 1185 1178 1186 - static int dvb_dvr_ioctl(struct inode *inode, struct file *file, 1179 + static long dvb_dvr_ioctl(struct file *file, 1187 1180 unsigned int cmd, unsigned long arg) 1188 1181 { 1189 - return dvb_usercopy(inode, file, cmd, arg, dvb_dvr_do_ioctl); 1182 + int ret; 1183 + 1184 + lock_kernel(); 1185 + ret = dvb_usercopy(file, cmd, arg, dvb_dvr_do_ioctl); 1186 + unlock_kernel(); 1187 + 1188 + return ret; 1190 1189 } 1191 1190 1192 1191 static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait) ··· 1221 1208 .owner = THIS_MODULE, 1222 1209 .read = dvb_dvr_read, 1223 1210 .write = dvb_dvr_write, 1224 - .ioctl = dvb_dvr_ioctl, 1211 + .unlocked_ioctl = dvb_dvr_ioctl, 1225 1212 .open = dvb_dvr_open, 1226 1213 .release = dvb_dvr_release, 1227 1214 .poll = dvb_dvr_poll,
+12 -5
drivers/media/dvb/dvb-core/dvb_ca_en50221.c
··· 36 36 #include <linux/delay.h> 37 37 #include <linux/spinlock.h> 38 38 #include <linux/sched.h> 39 + #include <linux/smp_lock.h> 39 40 #include <linux/kthread.h> 40 41 41 42 #include "dvb_ca_en50221.h" ··· 1182 1181 * 1183 1182 * @return 0 on success, <0 on error. 1184 1183 */ 1185 - static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file, 1184 + static int dvb_ca_en50221_io_do_ioctl(struct file *file, 1186 1185 unsigned int cmd, void *parg) 1187 1186 { 1188 1187 struct dvb_device *dvbdev = file->private_data; ··· 1256 1255 * 1257 1256 * @return 0 on success, <0 on error. 1258 1257 */ 1259 - static int dvb_ca_en50221_io_ioctl(struct inode *inode, struct file *file, 1260 - unsigned int cmd, unsigned long arg) 1258 + static long dvb_ca_en50221_io_ioctl(struct file *file, 1259 + unsigned int cmd, unsigned long arg) 1261 1260 { 1262 - return dvb_usercopy(inode, file, cmd, arg, dvb_ca_en50221_io_do_ioctl); 1261 + int ret; 1262 + 1263 + lock_kernel(); 1264 + ret = dvb_usercopy(file, cmd, arg, dvb_ca_en50221_io_do_ioctl); 1265 + unlock_kernel(); 1266 + 1267 + return ret; 1263 1268 } 1264 1269 1265 1270 ··· 1618 1611 .owner = THIS_MODULE, 1619 1612 .read = dvb_ca_en50221_io_read, 1620 1613 .write = dvb_ca_en50221_io_write, 1621 - .ioctl = dvb_ca_en50221_io_ioctl, 1614 + .unlocked_ioctl = dvb_ca_en50221_io_ioctl, 1622 1615 .open = dvb_ca_en50221_io_open, 1623 1616 .release = dvb_ca_en50221_io_release, 1624 1617 .poll = dvb_ca_en50221_io_poll,
+15 -15
drivers/media/dvb/dvb-core/dvb_frontend.c
··· 36 36 #include <linux/list.h> 37 37 #include <linux/freezer.h> 38 38 #include <linux/jiffies.h> 39 + #include <linux/smp_lock.h> 39 40 #include <linux/kthread.h> 40 41 #include <asm/processor.h> 41 42 ··· 1189 1188 } 1190 1189 } 1191 1190 1192 - static int dvb_frontend_ioctl_legacy(struct inode *inode, struct file *file, 1191 + static int dvb_frontend_ioctl_legacy(struct file *file, 1193 1192 unsigned int cmd, void *parg); 1194 - static int dvb_frontend_ioctl_properties(struct inode *inode, struct file *file, 1193 + static int dvb_frontend_ioctl_properties(struct file *file, 1195 1194 unsigned int cmd, void *parg); 1196 1195 1197 1196 static int dtv_property_process_get(struct dvb_frontend *fe, 1198 1197 struct dtv_property *tvp, 1199 - struct inode *inode, struct file *file) 1198 + struct file *file) 1200 1199 { 1201 1200 int r = 0; 1202 1201 ··· 1329 1328 1330 1329 static int dtv_property_process_set(struct dvb_frontend *fe, 1331 1330 struct dtv_property *tvp, 1332 - struct inode *inode, 1333 1331 struct file *file) 1334 1332 { 1335 1333 int r = 0; ··· 1359 1359 dprintk("%s() Finalised property cache\n", __func__); 1360 1360 dtv_property_cache_submit(fe); 1361 1361 1362 - r |= dvb_frontend_ioctl_legacy(inode, file, FE_SET_FRONTEND, 1362 + r |= dvb_frontend_ioctl_legacy(file, FE_SET_FRONTEND, 1363 1363 &fepriv->parameters); 1364 1364 break; 1365 1365 case DTV_FREQUENCY: ··· 1391 1391 break; 1392 1392 case DTV_VOLTAGE: 1393 1393 fe->dtv_property_cache.voltage = tvp->u.data; 1394 - r = dvb_frontend_ioctl_legacy(inode, file, FE_SET_VOLTAGE, 1394 + r = dvb_frontend_ioctl_legacy(file, FE_SET_VOLTAGE, 1395 1395 (void *)fe->dtv_property_cache.voltage); 1396 1396 break; 1397 1397 case DTV_TONE: 1398 1398 fe->dtv_property_cache.sectone = tvp->u.data; 1399 - r = dvb_frontend_ioctl_legacy(inode, file, FE_SET_TONE, 1399 + r = dvb_frontend_ioctl_legacy(file, FE_SET_TONE, 1400 1400 (void *)fe->dtv_property_cache.sectone); 1401 1401 break; 1402 1402 case DTV_CODE_RATE_HP: ··· 1480 1480 return r; 1481 1481 } 1482 1482 1483 - static int dvb_frontend_ioctl(struct inode *inode, struct file *file, 1483 + static int dvb_frontend_ioctl(struct file *file, 1484 1484 unsigned int cmd, void *parg) 1485 1485 { 1486 1486 struct dvb_device *dvbdev = file->private_data; ··· 1502 1502 return -ERESTARTSYS; 1503 1503 1504 1504 if ((cmd == FE_SET_PROPERTY) || (cmd == FE_GET_PROPERTY)) 1505 - err = dvb_frontend_ioctl_properties(inode, file, cmd, parg); 1505 + err = dvb_frontend_ioctl_properties(file, cmd, parg); 1506 1506 else { 1507 1507 fe->dtv_property_cache.state = DTV_UNDEFINED; 1508 - err = dvb_frontend_ioctl_legacy(inode, file, cmd, parg); 1508 + err = dvb_frontend_ioctl_legacy(file, cmd, parg); 1509 1509 } 1510 1510 1511 1511 up(&fepriv->sem); 1512 1512 return err; 1513 1513 } 1514 1514 1515 - static int dvb_frontend_ioctl_properties(struct inode *inode, struct file *file, 1515 + static int dvb_frontend_ioctl_properties(struct file *file, 1516 1516 unsigned int cmd, void *parg) 1517 1517 { 1518 1518 struct dvb_device *dvbdev = file->private_data; ··· 1548 1548 } 1549 1549 1550 1550 for (i = 0; i < tvps->num; i++) { 1551 - (tvp + i)->result = dtv_property_process_set(fe, tvp + i, inode, file); 1551 + (tvp + i)->result = dtv_property_process_set(fe, tvp + i, file); 1552 1552 err |= (tvp + i)->result; 1553 1553 } 1554 1554 ··· 1580 1580 } 1581 1581 1582 1582 for (i = 0; i < tvps->num; i++) { 1583 - (tvp + i)->result = dtv_property_process_get(fe, tvp + i, inode, file); 1583 + (tvp + i)->result = dtv_property_process_get(fe, tvp + i, file); 1584 1584 err |= (tvp + i)->result; 1585 1585 } 1586 1586 ··· 1597 1597 return err; 1598 1598 } 1599 1599 1600 - static int dvb_frontend_ioctl_legacy(struct inode *inode, struct file *file, 1600 + static int dvb_frontend_ioctl_legacy(struct file *file, 1601 1601 unsigned int cmd, void *parg) 1602 1602 { 1603 1603 struct dvb_device *dvbdev = file->private_data; ··· 2022 2022 2023 2023 static const struct file_operations dvb_frontend_fops = { 2024 2024 .owner = THIS_MODULE, 2025 - .ioctl = dvb_generic_ioctl, 2025 + .unlocked_ioctl = dvb_generic_ioctl, 2026 2026 .poll = dvb_frontend_poll, 2027 2027 .open = dvb_frontend_open, 2028 2028 .release = dvb_frontend_release
+11 -4
drivers/media/dvb/dvb-core/dvb_net.c
··· 59 59 #include <linux/netdevice.h> 60 60 #include <linux/etherdevice.h> 61 61 #include <linux/dvb/net.h> 62 + #include <linux/smp_lock.h> 62 63 #include <linux/uio.h> 63 64 #include <asm/uaccess.h> 64 65 #include <linux/crc32.h> ··· 1334 1333 return 0; 1335 1334 } 1336 1335 1337 - static int dvb_net_do_ioctl(struct inode *inode, struct file *file, 1336 + static int dvb_net_do_ioctl(struct file *file, 1338 1337 unsigned int cmd, void *parg) 1339 1338 { 1340 1339 struct dvb_device *dvbdev = file->private_data; ··· 1436 1435 return 0; 1437 1436 } 1438 1437 1439 - static int dvb_net_ioctl(struct inode *inode, struct file *file, 1438 + static long dvb_net_ioctl(struct file *file, 1440 1439 unsigned int cmd, unsigned long arg) 1441 1440 { 1442 - return dvb_usercopy(inode, file, cmd, arg, dvb_net_do_ioctl); 1441 + int ret; 1442 + 1443 + lock_kernel(); 1444 + ret = dvb_usercopy(file, cmd, arg, dvb_net_do_ioctl); 1445 + unlock_kernel(); 1446 + 1447 + return ret; 1443 1448 } 1444 1449 1445 1450 static int dvb_net_close(struct inode *inode, struct file *file) ··· 1466 1459 1467 1460 static const struct file_operations dvb_net_fops = { 1468 1461 .owner = THIS_MODULE, 1469 - .ioctl = dvb_net_ioctl, 1462 + .unlocked_ioctl = dvb_net_ioctl, 1470 1463 .open = dvb_generic_open, 1471 1464 .release = dvb_net_close, 1472 1465 };
+11 -6
drivers/media/dvb/dvb-core/dvbdev.c
··· 154 154 EXPORT_SYMBOL(dvb_generic_release); 155 155 156 156 157 - int dvb_generic_ioctl(struct inode *inode, struct file *file, 158 - unsigned int cmd, unsigned long arg) 157 + long dvb_generic_ioctl(struct file *file, 158 + unsigned int cmd, unsigned long arg) 159 159 { 160 160 struct dvb_device *dvbdev = file->private_data; 161 + int ret; 161 162 162 163 if (!dvbdev) 163 164 return -ENODEV; ··· 166 165 if (!dvbdev->kernel_ioctl) 167 166 return -EINVAL; 168 167 169 - return dvb_usercopy (inode, file, cmd, arg, dvbdev->kernel_ioctl); 168 + lock_kernel(); 169 + ret = dvb_usercopy(file, cmd, arg, dvbdev->kernel_ioctl); 170 + unlock_kernel(); 171 + 172 + return ret; 170 173 } 171 174 EXPORT_SYMBOL(dvb_generic_ioctl); 172 175 ··· 382 377 define this as video_usercopy(). this will introduce a dependecy 383 378 to the v4l "videodev.o" module, which is unnecessary for some 384 379 cards (ie. the budget dvb-cards don't need the v4l module...) */ 385 - int dvb_usercopy(struct inode *inode, struct file *file, 380 + int dvb_usercopy(struct file *file, 386 381 unsigned int cmd, unsigned long arg, 387 - int (*func)(struct inode *inode, struct file *file, 382 + int (*func)(struct file *file, 388 383 unsigned int cmd, void *arg)) 389 384 { 390 385 char sbuf[128]; ··· 421 416 } 422 417 423 418 /* call driver */ 424 - if ((err = func(inode, file, cmd, parg)) == -ENOIOCTLCMD) 419 + if ((err = func(file, cmd, parg)) == -ENOIOCTLCMD) 425 420 err = -EINVAL; 426 421 427 422 if (err < 0)
+4 -7
drivers/media/dvb/dvb-core/dvbdev.h
··· 116 116 117 117 wait_queue_head_t wait_queue; 118 118 /* don't really need those !? -- FIXME: use video_usercopy */ 119 - int (*kernel_ioctl)(struct inode *inode, struct file *file, 120 - unsigned int cmd, void *arg); 119 + int (*kernel_ioctl)(struct file *file, unsigned int cmd, void *arg); 121 120 122 121 void *priv; 123 122 }; ··· 137 138 138 139 extern int dvb_generic_open (struct inode *inode, struct file *file); 139 140 extern int dvb_generic_release (struct inode *inode, struct file *file); 140 - extern int dvb_generic_ioctl (struct inode *inode, struct file *file, 141 + extern long dvb_generic_ioctl (struct file *file, 141 142 unsigned int cmd, unsigned long arg); 142 143 143 144 /* we don't mess with video_usercopy() any more, 144 145 we simply define out own dvb_usercopy(), which will hopefully become 145 146 generic_usercopy() someday... */ 146 147 147 - extern int dvb_usercopy(struct inode *inode, struct file *file, 148 - unsigned int cmd, unsigned long arg, 149 - int (*func)(struct inode *inode, struct file *file, 150 - unsigned int cmd, void *arg)); 148 + extern int dvb_usercopy(struct file *file, unsigned int cmd, unsigned long arg, 149 + int (*func)(struct file *file, unsigned int cmd, void *arg)); 151 150 152 151 /** generic DVB attach function. */ 153 152 #ifdef CONFIG_MEDIA_ATTACH
+2 -3
drivers/media/dvb/firewire/firedtv-ci.c
··· 175 175 return err; 176 176 } 177 177 178 - static int fdtv_ca_ioctl(struct inode *inode, struct file *file, 179 - unsigned int cmd, void *arg) 178 + static int fdtv_ca_ioctl(struct file *file, unsigned int cmd, void *arg) 180 179 { 181 180 struct dvb_device *dvbdev = file->private_data; 182 181 struct firedtv *fdtv = dvbdev->priv; ··· 216 217 217 218 static const struct file_operations fdtv_ca_fops = { 218 219 .owner = THIS_MODULE, 219 - .ioctl = dvb_generic_ioctl, 220 + .unlocked_ioctl = dvb_generic_ioctl, 220 221 .open = dvb_generic_open, 221 222 .release = dvb_generic_release, 222 223 .poll = fdtv_ca_io_poll,
+2 -2
drivers/media/dvb/ttpci/av7110.c
··· 708 708 709 709 710 710 #ifdef CONFIG_DVB_AV7110_OSD 711 - static int dvb_osd_ioctl(struct inode *inode, struct file *file, 711 + static int dvb_osd_ioctl(struct file *file, 712 712 unsigned int cmd, void *parg) 713 713 { 714 714 struct dvb_device *dvbdev = file->private_data; ··· 727 727 728 728 static const struct file_operations dvb_osd_fops = { 729 729 .owner = THIS_MODULE, 730 - .ioctl = dvb_generic_ioctl, 730 + .unlocked_ioctl = dvb_generic_ioctl, 731 731 .open = dvb_generic_open, 732 732 .release = dvb_generic_release, 733 733 };
+4 -4
drivers/media/dvb/ttpci/av7110_av.c
··· 1089 1089 } 1090 1090 1091 1091 1092 - static int dvb_video_ioctl(struct inode *inode, struct file *file, 1092 + static int dvb_video_ioctl(struct file *file, 1093 1093 unsigned int cmd, void *parg) 1094 1094 { 1095 1095 struct dvb_device *dvbdev = file->private_data; ··· 1297 1297 return ret; 1298 1298 } 1299 1299 1300 - static int dvb_audio_ioctl(struct inode *inode, struct file *file, 1300 + static int dvb_audio_ioctl(struct file *file, 1301 1301 unsigned int cmd, void *parg) 1302 1302 { 1303 1303 struct dvb_device *dvbdev = file->private_data; ··· 1517 1517 static const struct file_operations dvb_video_fops = { 1518 1518 .owner = THIS_MODULE, 1519 1519 .write = dvb_video_write, 1520 - .ioctl = dvb_generic_ioctl, 1520 + .unlocked_ioctl = dvb_generic_ioctl, 1521 1521 .open = dvb_video_open, 1522 1522 .release = dvb_video_release, 1523 1523 .poll = dvb_video_poll, ··· 1535 1535 static const struct file_operations dvb_audio_fops = { 1536 1536 .owner = THIS_MODULE, 1537 1537 .write = dvb_audio_write, 1538 - .ioctl = dvb_generic_ioctl, 1538 + .unlocked_ioctl = dvb_generic_ioctl, 1539 1539 .open = dvb_audio_open, 1540 1540 .release = dvb_audio_release, 1541 1541 .poll = dvb_audio_poll,
+2 -3
drivers/media/dvb/ttpci/av7110_ca.c
··· 248 248 return mask; 249 249 } 250 250 251 - static int dvb_ca_ioctl(struct inode *inode, struct file *file, 252 - unsigned int cmd, void *parg) 251 + static int dvb_ca_ioctl(struct file *file, unsigned int cmd, void *parg) 253 252 { 254 253 struct dvb_device *dvbdev = file->private_data; 255 254 struct av7110 *av7110 = dvbdev->priv; ··· 349 350 .owner = THIS_MODULE, 350 351 .read = dvb_ca_read, 351 352 .write = dvb_ca_write, 352 - .ioctl = dvb_generic_ioctl, 353 + .unlocked_ioctl = dvb_generic_ioctl, 353 354 .open = dvb_ca_open, 354 355 .release = dvb_generic_release, 355 356 .poll = dvb_ca_poll,