2 * Driver for s390 chsc subchannels
4 * Copyright IBM Corp. 2008, 2011
6 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
10 #include <linux/slab.h>
11 #include <linux/compat.h>
12 #include <linux/device.h>
13 #include <linux/module.h>
14 #include <linux/uaccess.h>
15 #include <linux/miscdevice.h>
16 #include <linux/kernel_stat.h>
18 #include <asm/compat.h>
24 #include "cio_debug.h"
29 static debug_info_t
*chsc_debug_msg_id
;
30 static debug_info_t
*chsc_debug_log_id
;
32 static struct chsc_request
*on_close_request
;
33 static struct chsc_async_area
*on_close_chsc_area
;
34 static DEFINE_MUTEX(on_close_mutex
);
36 #define CHSC_MSG(imp, args...) do { \
37 debug_sprintf_event(chsc_debug_msg_id, imp , ##args); \
40 #define CHSC_LOG(imp, txt) do { \
41 debug_text_event(chsc_debug_log_id, imp , txt); \
44 static void CHSC_LOG_HEX(int level
, void *data
, int length
)
47 debug_event(chsc_debug_log_id
, level
, data
, length
);
48 length
-= chsc_debug_log_id
->buf_size
;
49 data
+= chsc_debug_log_id
->buf_size
;
53 MODULE_AUTHOR("IBM Corporation");
54 MODULE_DESCRIPTION("driver for s390 chsc subchannels");
55 MODULE_LICENSE("GPL");
57 static void chsc_subchannel_irq(struct subchannel
*sch
)
59 struct chsc_private
*private = dev_get_drvdata(&sch
->dev
);
60 struct chsc_request
*request
= private->request
;
61 struct irb
*irb
= this_cpu_ptr(&cio_irb
);
64 CHSC_LOG_HEX(4, irb
, sizeof(*irb
));
65 inc_irq_stat(IRQIO_CSC
);
67 /* Copy irb to provided request and set done. */
69 CHSC_MSG(0, "Interrupt on sch 0.%x.%04x with no request\n",
70 sch
->schid
.ssid
, sch
->schid
.sch_no
);
73 private->request
= NULL
;
74 memcpy(&request
->irb
, irb
, sizeof(*irb
));
75 cio_update_schib(sch
);
76 complete(&request
->completion
);
77 put_device(&sch
->dev
);
80 static int chsc_subchannel_probe(struct subchannel
*sch
)
82 struct chsc_private
*private;
85 CHSC_MSG(6, "Detected chsc subchannel 0.%x.%04x\n",
86 sch
->schid
.ssid
, sch
->schid
.sch_no
);
87 sch
->isc
= CHSC_SCH_ISC
;
88 private = kzalloc(sizeof(*private), GFP_KERNEL
);
91 dev_set_drvdata(&sch
->dev
, private);
92 ret
= cio_enable_subchannel(sch
, (u32
)(unsigned long)sch
);
94 CHSC_MSG(0, "Failed to enable 0.%x.%04x: %d\n",
95 sch
->schid
.ssid
, sch
->schid
.sch_no
, ret
);
96 dev_set_drvdata(&sch
->dev
, NULL
);
99 if (dev_get_uevent_suppress(&sch
->dev
)) {
100 dev_set_uevent_suppress(&sch
->dev
, 0);
101 kobject_uevent(&sch
->dev
.kobj
, KOBJ_ADD
);
107 static int chsc_subchannel_remove(struct subchannel
*sch
)
109 struct chsc_private
*private;
111 cio_disable_subchannel(sch
);
112 private = dev_get_drvdata(&sch
->dev
);
113 dev_set_drvdata(&sch
->dev
, NULL
);
114 if (private->request
) {
115 complete(&private->request
->completion
);
116 put_device(&sch
->dev
);
122 static void chsc_subchannel_shutdown(struct subchannel
*sch
)
124 cio_disable_subchannel(sch
);
127 static int chsc_subchannel_prepare(struct subchannel
*sch
)
132 * Don't allow suspend while the subchannel is not idle
133 * since we don't have a way to clear the subchannel and
134 * cannot disable it with a request running.
136 cc
= stsch(sch
->schid
, &schib
);
137 if (!cc
&& scsw_stctl(&schib
.scsw
))
142 static int chsc_subchannel_freeze(struct subchannel
*sch
)
144 return cio_disable_subchannel(sch
);
147 static int chsc_subchannel_restore(struct subchannel
*sch
)
149 return cio_enable_subchannel(sch
, (u32
)(unsigned long)sch
);
152 static struct css_device_id chsc_subchannel_ids
[] = {
153 { .match_flags
= 0x1, .type
=SUBCHANNEL_TYPE_CHSC
, },
154 { /* end of list */ },
156 MODULE_DEVICE_TABLE(css
, chsc_subchannel_ids
);
158 static struct css_driver chsc_subchannel_driver
= {
160 .owner
= THIS_MODULE
,
161 .name
= "chsc_subchannel",
163 .subchannel_type
= chsc_subchannel_ids
,
164 .irq
= chsc_subchannel_irq
,
165 .probe
= chsc_subchannel_probe
,
166 .remove
= chsc_subchannel_remove
,
167 .shutdown
= chsc_subchannel_shutdown
,
168 .prepare
= chsc_subchannel_prepare
,
169 .freeze
= chsc_subchannel_freeze
,
170 .thaw
= chsc_subchannel_restore
,
171 .restore
= chsc_subchannel_restore
,
174 static int __init
chsc_init_dbfs(void)
176 chsc_debug_msg_id
= debug_register("chsc_msg", 8, 1, 4 * sizeof(long));
177 if (!chsc_debug_msg_id
)
179 debug_register_view(chsc_debug_msg_id
, &debug_sprintf_view
);
180 debug_set_level(chsc_debug_msg_id
, 2);
181 chsc_debug_log_id
= debug_register("chsc_log", 16, 1, 16);
182 if (!chsc_debug_log_id
)
184 debug_register_view(chsc_debug_log_id
, &debug_hex_ascii_view
);
185 debug_set_level(chsc_debug_log_id
, 2);
188 debug_unregister(chsc_debug_msg_id
);
192 static void chsc_remove_dbfs(void)
194 debug_unregister(chsc_debug_log_id
);
195 debug_unregister(chsc_debug_msg_id
);
198 static int __init
chsc_init_sch_driver(void)
200 return css_driver_register(&chsc_subchannel_driver
);
203 static void chsc_cleanup_sch_driver(void)
205 css_driver_unregister(&chsc_subchannel_driver
);
208 static DEFINE_SPINLOCK(chsc_lock
);
210 static int chsc_subchannel_match_next_free(struct device
*dev
, void *data
)
212 struct subchannel
*sch
= to_subchannel(dev
);
214 return sch
->schib
.pmcw
.ena
&& !scsw_fctl(&sch
->schib
.scsw
);
217 static struct subchannel
*chsc_get_next_subchannel(struct subchannel
*sch
)
221 dev
= driver_find_device(&chsc_subchannel_driver
.drv
,
222 sch
? &sch
->dev
: NULL
, NULL
,
223 chsc_subchannel_match_next_free
);
224 return dev
? to_subchannel(dev
) : NULL
;
228 * chsc_async() - try to start a chsc request asynchronously
229 * @chsc_area: request to be started
230 * @request: request structure to associate
232 * Tries to start a chsc request on one of the existing chsc subchannels.
234 * %0 if the request was performed synchronously
235 * %-EINPROGRESS if the request was successfully started
236 * %-EBUSY if all chsc subchannels are busy
237 * %-ENODEV if no chsc subchannels are available
239 * interrupts disabled, chsc_lock held
241 static int chsc_async(struct chsc_async_area
*chsc_area
,
242 struct chsc_request
*request
)
245 struct chsc_private
*private;
246 struct subchannel
*sch
= NULL
;
250 chsc_area
->header
.key
= PAGE_DEFAULT_KEY
>> 4;
251 while ((sch
= chsc_get_next_subchannel(sch
))) {
252 spin_lock(sch
->lock
);
253 private = dev_get_drvdata(&sch
->dev
);
254 if (private->request
) {
255 spin_unlock(sch
->lock
);
259 chsc_area
->header
.sid
= sch
->schid
;
260 CHSC_LOG(2, "schid");
261 CHSC_LOG_HEX(2, &sch
->schid
, sizeof(sch
->schid
));
262 cc
= chsc(chsc_area
);
263 snprintf(dbf
, sizeof(dbf
), "cc:%d", cc
);
270 sch
->schib
.scsw
.cmd
.fctl
|= SCSW_FCTL_START_FUNC
;
272 private->request
= request
;
280 spin_unlock(sch
->lock
);
281 CHSC_MSG(2, "chsc on 0.%x.%04x returned cc=%d\n",
282 sch
->schid
.ssid
, sch
->schid
.sch_no
, cc
);
283 if (ret
== -EINPROGRESS
)
285 put_device(&sch
->dev
);
292 static void chsc_log_command(void *chsc_area
)
296 snprintf(dbf
, sizeof(dbf
), "CHSC:%x", ((uint16_t *)chsc_area
)[1]);
298 CHSC_LOG_HEX(0, chsc_area
, 32);
301 static int chsc_examine_irb(struct chsc_request
*request
)
305 if (!(scsw_stctl(&request
->irb
.scsw
) & SCSW_STCTL_STATUS_PEND
))
307 backed_up
= scsw_cstat(&request
->irb
.scsw
) & SCHN_STAT_CHAIN_CHECK
;
308 request
->irb
.scsw
.cmd
.cstat
&= ~SCHN_STAT_CHAIN_CHECK
;
309 if (scsw_cstat(&request
->irb
.scsw
) == 0)
313 if (scsw_cstat(&request
->irb
.scsw
) & SCHN_STAT_PROG_CHECK
)
315 if (scsw_cstat(&request
->irb
.scsw
) & SCHN_STAT_PROT_CHECK
)
317 if (scsw_cstat(&request
->irb
.scsw
) & SCHN_STAT_CHN_DATA_CHK
)
319 if (scsw_cstat(&request
->irb
.scsw
) & SCHN_STAT_CHN_CTRL_CHK
)
324 static int chsc_ioctl_start(void __user
*user_area
)
326 struct chsc_request
*request
;
327 struct chsc_async_area
*chsc_area
;
331 if (!css_general_characteristics
.dynio
)
332 /* It makes no sense to try. */
334 chsc_area
= (void *)get_zeroed_page(GFP_DMA
| GFP_KERNEL
);
337 request
= kzalloc(sizeof(*request
), GFP_KERNEL
);
342 init_completion(&request
->completion
);
343 if (copy_from_user(chsc_area
, user_area
, PAGE_SIZE
)) {
347 chsc_log_command(chsc_area
);
348 spin_lock_irq(&chsc_lock
);
349 ret
= chsc_async(chsc_area
, request
);
350 spin_unlock_irq(&chsc_lock
);
351 if (ret
== -EINPROGRESS
) {
352 wait_for_completion(&request
->completion
);
353 ret
= chsc_examine_irb(request
);
355 /* copy area back to user */
357 if (copy_to_user(user_area
, chsc_area
, PAGE_SIZE
))
360 snprintf(dbf
, sizeof(dbf
), "ret:%d", ret
);
363 free_page((unsigned long)chsc_area
);
367 static int chsc_ioctl_on_close_set(void __user
*user_area
)
372 mutex_lock(&on_close_mutex
);
373 if (on_close_chsc_area
) {
377 on_close_request
= kzalloc(sizeof(*on_close_request
), GFP_KERNEL
);
378 if (!on_close_request
) {
382 on_close_chsc_area
= (void *)get_zeroed_page(GFP_DMA
| GFP_KERNEL
);
383 if (!on_close_chsc_area
) {
385 goto out_free_request
;
387 if (copy_from_user(on_close_chsc_area
, user_area
, PAGE_SIZE
)) {
395 free_page((unsigned long)on_close_chsc_area
);
396 on_close_chsc_area
= NULL
;
398 kfree(on_close_request
);
399 on_close_request
= NULL
;
401 mutex_unlock(&on_close_mutex
);
402 snprintf(dbf
, sizeof(dbf
), "ocsret:%d", ret
);
407 static int chsc_ioctl_on_close_remove(void)
412 mutex_lock(&on_close_mutex
);
413 if (!on_close_chsc_area
) {
417 free_page((unsigned long)on_close_chsc_area
);
418 on_close_chsc_area
= NULL
;
419 kfree(on_close_request
);
420 on_close_request
= NULL
;
423 mutex_unlock(&on_close_mutex
);
424 snprintf(dbf
, sizeof(dbf
), "ocrret:%d", ret
);
429 static int chsc_ioctl_start_sync(void __user
*user_area
)
431 struct chsc_sync_area
*chsc_area
;
434 chsc_area
= (void *)get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
437 if (copy_from_user(chsc_area
, user_area
, PAGE_SIZE
)) {
441 if (chsc_area
->header
.code
& 0x4000) {
445 chsc_log_command(chsc_area
);
446 ccode
= chsc(chsc_area
);
451 if (copy_to_user(user_area
, chsc_area
, PAGE_SIZE
))
456 free_page((unsigned long)chsc_area
);
460 static int chsc_ioctl_info_channel_path(void __user
*user_cd
)
462 struct chsc_chp_cd
*cd
;
465 struct chsc_header request
;
476 struct chsc_header response
;
477 u8 data
[PAGE_SIZE
- 20];
478 } __attribute__ ((packed
)) *scpcd_area
;
480 scpcd_area
= (void *)get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
483 cd
= kzalloc(sizeof(*cd
), GFP_KERNEL
);
488 if (copy_from_user(cd
, user_cd
, sizeof(*cd
))) {
492 scpcd_area
->request
.length
= 0x0010;
493 scpcd_area
->request
.code
= 0x0028;
494 scpcd_area
->m
= cd
->m
;
495 scpcd_area
->fmt1
= cd
->fmt
;
496 scpcd_area
->cssid
= cd
->chpid
.cssid
;
497 scpcd_area
->first_chpid
= cd
->chpid
.id
;
498 scpcd_area
->last_chpid
= cd
->chpid
.id
;
500 ccode
= chsc(scpcd_area
);
505 if (scpcd_area
->response
.code
!= 0x0001) {
507 CHSC_MSG(0, "scpcd: response code=%x\n",
508 scpcd_area
->response
.code
);
511 memcpy(&cd
->cpcb
, &scpcd_area
->response
, scpcd_area
->response
.length
);
512 if (copy_to_user(user_cd
, cd
, sizeof(*cd
)))
518 free_page((unsigned long)scpcd_area
);
522 static int chsc_ioctl_info_cu(void __user
*user_cd
)
524 struct chsc_cu_cd
*cd
;
527 struct chsc_header request
;
538 struct chsc_header response
;
539 u8 data
[PAGE_SIZE
- 20];
540 } __attribute__ ((packed
)) *scucd_area
;
542 scucd_area
= (void *)get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
545 cd
= kzalloc(sizeof(*cd
), GFP_KERNEL
);
550 if (copy_from_user(cd
, user_cd
, sizeof(*cd
))) {
554 scucd_area
->request
.length
= 0x0010;
555 scucd_area
->request
.code
= 0x0026;
556 scucd_area
->m
= cd
->m
;
557 scucd_area
->fmt1
= cd
->fmt
;
558 scucd_area
->cssid
= cd
->cssid
;
559 scucd_area
->first_cun
= cd
->cun
;
560 scucd_area
->last_cun
= cd
->cun
;
562 ccode
= chsc(scucd_area
);
567 if (scucd_area
->response
.code
!= 0x0001) {
569 CHSC_MSG(0, "scucd: response code=%x\n",
570 scucd_area
->response
.code
);
573 memcpy(&cd
->cucb
, &scucd_area
->response
, scucd_area
->response
.length
);
574 if (copy_to_user(user_cd
, cd
, sizeof(*cd
)))
580 free_page((unsigned long)scucd_area
);
584 static int chsc_ioctl_info_sch_cu(void __user
*user_cud
)
586 struct chsc_sch_cud
*cud
;
589 struct chsc_header request
;
601 struct chsc_header response
;
602 u8 data
[PAGE_SIZE
- 20];
603 } __attribute__ ((packed
)) *sscud_area
;
605 sscud_area
= (void *)get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
608 cud
= kzalloc(sizeof(*cud
), GFP_KERNEL
);
613 if (copy_from_user(cud
, user_cud
, sizeof(*cud
))) {
617 sscud_area
->request
.length
= 0x0010;
618 sscud_area
->request
.code
= 0x0006;
619 sscud_area
->m
= cud
->schid
.m
;
620 sscud_area
->fmt1
= cud
->fmt
;
621 sscud_area
->ssid
= cud
->schid
.ssid
;
622 sscud_area
->first_sch
= cud
->schid
.sch_no
;
623 sscud_area
->cssid
= cud
->schid
.cssid
;
624 sscud_area
->last_sch
= cud
->schid
.sch_no
;
626 ccode
= chsc(sscud_area
);
631 if (sscud_area
->response
.code
!= 0x0001) {
633 CHSC_MSG(0, "sscud: response code=%x\n",
634 sscud_area
->response
.code
);
637 memcpy(&cud
->scub
, &sscud_area
->response
, sscud_area
->response
.length
);
638 if (copy_to_user(user_cud
, cud
, sizeof(*cud
)))
644 free_page((unsigned long)sscud_area
);
648 static int chsc_ioctl_conf_info(void __user
*user_ci
)
650 struct chsc_conf_info
*ci
;
653 struct chsc_header request
;
663 struct chsc_header response
;
664 u8 data
[PAGE_SIZE
- 20];
665 } __attribute__ ((packed
)) *sci_area
;
667 sci_area
= (void *)get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
670 ci
= kzalloc(sizeof(*ci
), GFP_KERNEL
);
675 if (copy_from_user(ci
, user_ci
, sizeof(*ci
))) {
679 sci_area
->request
.length
= 0x0010;
680 sci_area
->request
.code
= 0x0012;
681 sci_area
->m
= ci
->id
.m
;
682 sci_area
->fmt1
= ci
->fmt
;
683 sci_area
->cssid
= ci
->id
.cssid
;
684 sci_area
->ssid
= ci
->id
.ssid
;
686 ccode
= chsc(sci_area
);
691 if (sci_area
->response
.code
!= 0x0001) {
693 CHSC_MSG(0, "sci: response code=%x\n",
694 sci_area
->response
.code
);
697 memcpy(&ci
->scid
, &sci_area
->response
, sci_area
->response
.length
);
698 if (copy_to_user(user_ci
, ci
, sizeof(*ci
)))
704 free_page((unsigned long)sci_area
);
708 static int chsc_ioctl_conf_comp_list(void __user
*user_ccl
)
710 struct chsc_comp_list
*ccl
;
713 struct chsc_header request
;
721 struct chsc_header response
;
722 u8 data
[PAGE_SIZE
- 36];
723 } __attribute__ ((packed
)) *sccl_area
;
730 } __attribute__ ((packed
)) *chpid_parm
;
736 } __attribute__ ((packed
)) *cssids_parm
;
738 sccl_area
= (void *)get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
741 ccl
= kzalloc(sizeof(*ccl
), GFP_KERNEL
);
746 if (copy_from_user(ccl
, user_ccl
, sizeof(*ccl
))) {
750 sccl_area
->request
.length
= 0x0020;
751 sccl_area
->request
.code
= 0x0030;
752 sccl_area
->fmt
= ccl
->req
.fmt
;
753 sccl_area
->ctype
= ccl
->req
.ctype
;
754 switch (sccl_area
->ctype
) {
757 chpid_parm
= (void *)&sccl_area
->list_parm
;
758 chpid_parm
->m
= ccl
->req
.chpid
.m
;
759 chpid_parm
->cssid
= ccl
->req
.chpid
.chp
.cssid
;
760 chpid_parm
->chpid
= ccl
->req
.chpid
.chp
.id
;
763 case CCL_CSS_IMG_CONF_CHAR
:
764 cssids_parm
= (void *)&sccl_area
->list_parm
;
765 cssids_parm
->f_cssid
= ccl
->req
.cssids
.f_cssid
;
766 cssids_parm
->l_cssid
= ccl
->req
.cssids
.l_cssid
;
769 ccode
= chsc(sccl_area
);
774 if (sccl_area
->response
.code
!= 0x0001) {
776 CHSC_MSG(0, "sccl: response code=%x\n",
777 sccl_area
->response
.code
);
780 memcpy(&ccl
->sccl
, &sccl_area
->response
, sccl_area
->response
.length
);
781 if (copy_to_user(user_ccl
, ccl
, sizeof(*ccl
)))
787 free_page((unsigned long)sccl_area
);
791 static int chsc_ioctl_chpd(void __user
*user_chpd
)
793 struct chsc_scpd
*scpd_area
;
794 struct chsc_cpd_info
*chpd
;
797 chpd
= kzalloc(sizeof(*chpd
), GFP_KERNEL
);
798 scpd_area
= (void *)get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
799 if (!scpd_area
|| !chpd
) {
803 if (copy_from_user(chpd
, user_chpd
, sizeof(*chpd
))) {
807 ret
= chsc_determine_channel_path_desc(chpd
->chpid
, chpd
->fmt
,
808 chpd
->rfmt
, chpd
->c
, chpd
->m
,
812 memcpy(&chpd
->chpdb
, &scpd_area
->response
, scpd_area
->response
.length
);
813 if (copy_to_user(user_chpd
, chpd
, sizeof(*chpd
)))
817 free_page((unsigned long)scpd_area
);
821 static int chsc_ioctl_dcal(void __user
*user_dcal
)
823 struct chsc_dcal
*dcal
;
826 struct chsc_header request
;
834 struct chsc_header response
;
835 u8 data
[PAGE_SIZE
- 36];
836 } __attribute__ ((packed
)) *sdcal_area
;
838 sdcal_area
= (void *)get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
841 dcal
= kzalloc(sizeof(*dcal
), GFP_KERNEL
);
846 if (copy_from_user(dcal
, user_dcal
, sizeof(*dcal
))) {
850 sdcal_area
->request
.length
= 0x0020;
851 sdcal_area
->request
.code
= 0x0034;
852 sdcal_area
->atype
= dcal
->req
.atype
;
853 sdcal_area
->fmt
= dcal
->req
.fmt
;
854 memcpy(&sdcal_area
->list_parm
, &dcal
->req
.list_parm
,
855 sizeof(sdcal_area
->list_parm
));
857 ccode
= chsc(sdcal_area
);
862 if (sdcal_area
->response
.code
!= 0x0001) {
864 CHSC_MSG(0, "sdcal: response code=%x\n",
865 sdcal_area
->response
.code
);
868 memcpy(&dcal
->sdcal
, &sdcal_area
->response
,
869 sdcal_area
->response
.length
);
870 if (copy_to_user(user_dcal
, dcal
, sizeof(*dcal
)))
876 free_page((unsigned long)sdcal_area
);
880 static long chsc_ioctl(struct file
*filp
, unsigned int cmd
,
885 CHSC_MSG(2, "chsc_ioctl called, cmd=%x\n", cmd
);
886 if (is_compat_task())
887 argp
= compat_ptr(arg
);
889 argp
= (void __user
*)arg
;
892 return chsc_ioctl_start(argp
);
893 case CHSC_START_SYNC
:
894 return chsc_ioctl_start_sync(argp
);
895 case CHSC_INFO_CHANNEL_PATH
:
896 return chsc_ioctl_info_channel_path(argp
);
898 return chsc_ioctl_info_cu(argp
);
899 case CHSC_INFO_SCH_CU
:
900 return chsc_ioctl_info_sch_cu(argp
);
902 return chsc_ioctl_conf_info(argp
);
904 return chsc_ioctl_conf_comp_list(argp
);
906 return chsc_ioctl_chpd(argp
);
908 return chsc_ioctl_dcal(argp
);
909 case CHSC_ON_CLOSE_SET
:
910 return chsc_ioctl_on_close_set(argp
);
911 case CHSC_ON_CLOSE_REMOVE
:
912 return chsc_ioctl_on_close_remove();
913 default: /* unknown ioctl number */
918 static atomic_t chsc_ready_for_use
= ATOMIC_INIT(1);
920 static int chsc_open(struct inode
*inode
, struct file
*file
)
922 if (!atomic_dec_and_test(&chsc_ready_for_use
)) {
923 atomic_inc(&chsc_ready_for_use
);
926 return nonseekable_open(inode
, file
);
929 static int chsc_release(struct inode
*inode
, struct file
*filp
)
934 mutex_lock(&on_close_mutex
);
935 if (!on_close_chsc_area
)
937 init_completion(&on_close_request
->completion
);
938 CHSC_LOG(0, "on_close");
939 chsc_log_command(on_close_chsc_area
);
940 spin_lock_irq(&chsc_lock
);
941 ret
= chsc_async(on_close_chsc_area
, on_close_request
);
942 spin_unlock_irq(&chsc_lock
);
943 if (ret
== -EINPROGRESS
) {
944 wait_for_completion(&on_close_request
->completion
);
945 ret
= chsc_examine_irb(on_close_request
);
947 snprintf(dbf
, sizeof(dbf
), "relret:%d", ret
);
949 free_page((unsigned long)on_close_chsc_area
);
950 on_close_chsc_area
= NULL
;
951 kfree(on_close_request
);
952 on_close_request
= NULL
;
954 mutex_unlock(&on_close_mutex
);
955 atomic_inc(&chsc_ready_for_use
);
959 static const struct file_operations chsc_fops
= {
960 .owner
= THIS_MODULE
,
962 .release
= chsc_release
,
963 .unlocked_ioctl
= chsc_ioctl
,
964 .compat_ioctl
= chsc_ioctl
,
968 static struct miscdevice chsc_misc_device
= {
969 .minor
= MISC_DYNAMIC_MINOR
,
974 static int __init
chsc_misc_init(void)
976 return misc_register(&chsc_misc_device
);
979 static void chsc_misc_cleanup(void)
981 misc_deregister(&chsc_misc_device
);
984 static int __init
chsc_sch_init(void)
988 ret
= chsc_init_dbfs();
991 isc_register(CHSC_SCH_ISC
);
992 ret
= chsc_init_sch_driver();
995 ret
= chsc_misc_init();
1000 chsc_cleanup_sch_driver();
1002 isc_unregister(CHSC_SCH_ISC
);
1007 static void __exit
chsc_sch_exit(void)
1009 chsc_misc_cleanup();
1010 chsc_cleanup_sch_driver();
1011 isc_unregister(CHSC_SCH_ISC
);
1015 module_init(chsc_sch_init
);
1016 module_exit(chsc_sch_exit
);