summaryrefslogtreecommitdiff
path: root/hw/usb_cfs_client_common.c
AgeCommit message (Collapse)AuthorFilesLines
2020-04-08Mofidy indentINSUN PYO1-2/+2
Change-Id: I4d4d349b51d7feeac6912e08ac79e0b2695d3e7e (cherry picked from commit 30379cb9470e47417a07250d28177c335b1f4e5c)
2020-04-07Refactoring usb function variable in usb gadgetINSUN PYO1-1/+1
Change-Id: I494c5dbb285870f226fe64392b6b880797309761 (cherry picked from commit 8e03ec0d2c4b7beb09d8a49fa626fb807b991789)
2020-04-07Rework usb gadget validataionINSUN PYO1-15/+21
On SLP : check if /sys/class/usb_mode/usb0/f_[sdb|mtp|acm|rndis|diag|dm] exists On CFS : check if /usr/lib/systemd/system/[sdb|mpt].service exists or the result of usbg_lookup_function_type() Change-Id: I2cc8acc3553a8734484d50cfc0ede7a963a363b0 (cherry picked from commit 3bb736815986e6433b2a94555c4ceb64b2abea7a)
2020-03-30Remove unused usb_clientsubmit/tizen_5.5/20200331.081954submit/tizen_5.5/20200330.024853accepted/tizen/5.5/unified/20200331.180322accepted/tizen/5.5/unified/20200330.153516INSUN PYO1-5/+7
Change-Id: If2d574da915233d2849017892d64a7ea75191970 (cherry picked from commit 66aa88ba4c649532bef7c512eebdb24d9481568b)
2020-03-26Refactoring config's stringsubmit/tizen_5.5/20200326.062228submit/tizen_5.5/20200326.053433accepted/tizen/5.5/unified/20200326.232401INSUN PYO1-2/+2
The usb gadget's config uses only one string information. So instead of dynamically creating string information, only use one fixed. Change-Id: Ie7e5bb198a429c8ac766002711f6add47d06fa1e (cherry picked from commit f4221a979f17129610293fed809d7fd822d59f54)
2020-03-26Refactoring gadget's stringINSUN PYO1-23/+24
The usb gadget uses only one string information. So instead of dynamically creating string information, only use one fixed. Change-Id: I01adf3d0c7ce498e516b08b5a284c63d2940bcb6 (cherry picked from commit 998f44215d67cdf7aa33d63f012369c3a413bfaa)
2020-03-26Refactoring usb gadgetINSUN PYO1-15/+11
Move common USB gadget attribute value to header Change-Id: Id06fefc9af78876d46364b39893b4f25ebd9ed82 (cherry picked from commit a3a343526d84ad3c7097014bce38e7ca79bb3a0d)
2020-03-26Fixed incorrect use of errno in usb cfs clientINSUN PYO1-6/+3
Change-Id: Ib091544138444c4108c7b09eb3e70e830661648e (cherry picked from commit d8d490bd8049ccad9e5a8bede183ce63bbb7e78d)
2020-03-25Fixed configfs not supporting multi-configurationINSUN PYO1-12/+15
One usb function can be used in multiple config in configfs. So when you create a usb function, you have to check if it exists. Change-Id: I8f16fe4c542b277c12022d1c96d8ccb0aee32237 (cherry picked from commit 632729260576e9e7a81a18f8ef7dc9f51fe8c184)
2020-03-24Revert "Change global variable _available_funcs to const"submit/tizen_5.5/20200324.034815accepted/tizen/5.5/unified/20200325.144922INSUN PYO1-7/+7
This reverts commit 9065e52b99d5a10fa059c7337b7d693fa32584e5. The const variable is assigned to the read-only memory map area. So, we can not modify it. Change-Id: I8719eef3af23bd7c33e3419d94afdf4f5f19261c (cherry picked from commit 0eb9342b124760ee703d25bb4cd703338d58cdc1)
2020-03-20Change global variable _available_funcs to constsubmit/tizen_5.5/20200320.020709accepted/tizen/5.5/unified/20200320.124917INSUN PYO1-7/+7
Since the _available_funcs global variable is used in many places, it should be prevented from changing to const. Change-Id: I53404030e16361a70254fe2780176ac1441b1e13 (cherry picked from commit 9065e52b99d5a10fa059c7337b7d693fa32584e5)
2020-03-20Rewrite usb_function to hide global variable _available_funcsINSUN PYO1-103/+71
To prevent the global variable _available_funcs from being exposed. Change-Id: I26b09d3fa8fb5c8117c0029eb94dd3b7efe9a2c7 (cherry picked from commit 3d1a1c4e666cd31b88cd678968658368e988cbaa)
2020-03-20Rework reconfiguration configfs gadgetINSUN PYO1-168/+111
Before : add new functions -> enable new functions as linking to configs -> delete unused configs -> deleted unused functions After : remove all configs -> remove all functions -> add new functions -> enable new functions as linking to configs Change-Id: If0fdcb9a1cda9afcb6d865bee7f0db1539d4df2b (cherry picked from commit e513020a513815371d18079de80c55f370aa6ed6)
2020-03-19Fixed a possibility that the function handler might be called twiceINSUN PYO1-45/+47
Configfs can use more than one configs. (/sys/kernel/config/usb_gadget/hal-gadget/configs/hal-config.1 and /sys/kernel/config/usb_gadget/hal-gadget/configs/hal-config.2) One usb function can be included in two config simultaneously. In this situation, a handler associated with function can be called twice for a usb function. To prevent duplicate calls, it handles only the handlers of functions enabled in configfs, not the usb functions included in all configs. Change-Id: I5e02dadc5d2688f0ad9210ad5ab149fb95ab05ba (cherry picked from commit 7803a3c5a1b0293a5bda490c26c95ae8b967e001)
2020-03-18Fix build errorsubmit/tizen_5.5/20200318.072527Hyotaek Shim1-0/+1
Change-Id: I26a3d3db3fecdd5303d99fa1b003e446ba75e002 Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
2020-03-17Remove unused usb_client hal featuresubmit/tizen_5.5/20200318.064104submit/tizen_5.5/20200318.033330INSUN PYO1-392/+4
Change-Id: I0d9f5c77a729ca706b85ab988aecd76ccb4c12cc (cherry picked from commit 94e1d8be764c68c97c6f2ec15a0dc07ce6e3837f)
2020-03-16Fixed misuse of const variablesubmit/tizen_5.5/20200316.083018submit/tizen_5.5/20200316.065201accepted/tizen/5.5/unified/20200316.155231INSUN PYO1-28/+30
Change-Id: I148b8b5b1463c3593f3f609c5ba137403b9272f9 (cherry picked from commit 2f3aa72c35df8b372a583701d477e42150e825c5)
2020-03-16Remove unused usb functions after changing usb modesubmit/tizen_5.5/20200313.073358INSUN PYO1-3/+107
After setting the new usb mode, the configfs functions that was not used remain. For example, changing from rndis mode to sdb mode, /sys/kernel/config/usb_gadget/hal-gadget/rndis.default remains. A functionfs has to do a few extra things. - The socket and service associated with functionfs must be terminated. - Umount /dev/usb-funcs/[sdb|mtp]/default - Delete /dev/usb-funcs/[sdb|mtp]/default recursively Change-Id: I2d66f033babd5bea20cfc74d8bf23eb9a89c3be1 (cherry picked from commit 19877fd6f2488dca79d89c5b06f1673a624a5f32)
2020-03-13Fixed using wrong usb function list when usb gadget enable/disable in configfsINSUN PYO1-45/+51
When usb gadget is enabled/disabled in configfs, it retrieves the list of currently used usb functions in order to run the service handler. Before the modification, it retrieve a list of "all functions" used even once. So if you run "ifconfig" after changing usb mode to "sdb mode" -> "rndis mode" -> "sdb mode", even in sdb mode, the usb0 network interface appears. Change-Id: I83564591cd899197077823fdb2fbe25d034fcf46 (cherry picked from commit 25b632db82163a339c23ffafc1095be225816b25)
2020-03-12Refactoring: replace ffs_service to is_functionfsINSUN PYO1-16/+16
Change-Id: Ibb74b5627ef1376be141fb23e56787e45b34c142 (cherry picked from commit c1ef88b5dc9a2e8014ebf290e802fb57c34fd5f0)
2020-03-11Fixed to stop services of functionfs when gadget is disabledINSUN PYO1-2/+18
sdb.service and mtp-responder.service are alive when the usb cable is unplugged in the configfs environment. If the usb cable is disconnected, gadget disable is called. These services are stopped when the gadget is disabled. Caution 1 Note that the socket units for these services should remain. The scoket unit has ep0 in the functionfs environment. If ep0 disappears because the socket unit is stopped, the functionfs can never be enabled. Caution 2 Since ffs_service works by socket activation, it will be started automatically when data is enqueued to the usb socket. So when enabling configfs gadget, it doesn't start ffs_service. Change-Id: I660e0cf157320f6a4e8f152a028772547dd701f6 (cherry picked from commit 5e9327a2d5b5215b4371b406339dc83a89891074)
2020-02-21Remove workaround code that it makes usb work in Artiksubmit/tizen_5.5/20200221.073347accepted/tizen/5.5/unified/20200224.123548INSUN PYO1-16/+0
Excon does not work perfectly in Artik. So I added the workaround code, which causes some strange USB initialization. This problem disappears when the extcon value is always fixed at 1. So I asked the kernel team to fix the extcon value to 1 and removed the workaround code. If extcon is always 1, deviecd will not recognize when usb is disconnected, but it will work normally. Conclusion: For targets where extcon does not work perfectly, deviced do not support usb connect/disconnect. Change-Id: Idf06c987f589218a458df6904d8fb8f9132f05c3 (cherry picked from commit f68550cd0c83a60621de5ef70de2a9edcba8b5d7)
2020-02-07Apply mac addres for rndis modesubmit/tizen_5.5/20200207.085239accepted/tizen/5.5/unified/20200210.131643Youngjae Cho1-0/+38
Change-Id: Ic3472d6b6da35b199704ca6150447cab05638a71 Signed-off-by: Youngjae Cho <y0.cho@samsung.com> (cherry picked from commit afc9e97d20d06918ade6e6cc555226bc30131889)
2020-01-30Refactoring usb gadget header #2INSUN PYO1-1/+1
Change-Id: Ic9473dbbeee14d609e357c1d3fcc00dbea1dc434 (cherry picked from commit 1c426172aa3a5047914ee14bb0ade36bff0e6826)
2020-01-28Add USB enable/disable handlersubmit/tizen_5.5/20200128.045317accepted/tizen/5.5/unified/20200129.120429tizen_5.5_tvINSUN PYO1-0/+6
Change-Id: I2a488ef551a3c92a36cfa428787cdfdd31f82cab (cherry picked from commit 2dbaad820b5f0ca6c9b59ac61c3c14460775f915)
2020-01-28Refactoring usb gadget for functionfssubmit/tizen_5.5/20200128.022624INSUN PYO1-41/+22
Change-Id: Ieb87a66543095a44773bdfba105c37b19b3b2cfa
2020-01-22Refactoring usb gadget headersubmit/tizen_5.5/20200122.234617accepted/tizen/5.5/unified/20200128.034023INSUN PYO1-26/+19
Merge "struct usb_function_witch_service" into "struct usb_function". Change-Id: I9ed616f7e5933594093e9a027dd7d56cf1b016c8 (cherry picked from commit c76e213a9ecef080b7dc3ae92105969e9d531deb)
2020-01-15Add code to run rndis.service(rndis) and data-route.service(acm) in configfs ↵submit/tizen_5.5/20200115.105138accepted/tizen/5.5/unified/20200116.120643INSUN PYO1-8/+44
environment Rndis and acm need their services to complete initialization. Change-Id: I24381f2e30a4cf1e3051ea4a304d65ad8eb59f50 Signed-off-by: INSUN PYO <insun.pyo@samsung.com> (cherry picked from commit c0fb89192952ca0806c26abddf5daf0e3f3acc30)
2020-01-15Fix memory leak in configfssubmit/tizen_5.5/20200115.084508accepted/tizen/5.5/unified/20200116.120701INSUN PYO1-1/+4
Change-Id: I4df7a7dcb55382a18b93a9bd3afbe909c20c6998 (cherry picked from commit 5a43d7f0d0e7edc87e4afc5c1aa6fbc03b5cf212)
2020-01-03Change file permission from "-rwxr-xr-x" to "-rw-r--r--"submit/tizen_5.5/20200103.025031accepted/tizen/5.5/unified/20200105.221131INSUN PYO1-0/+0
Change-Id: I8dc05a6e62fd0a6a10199639d4316e22823776cd (cherry picked from commit 8725dfd7e408db4f59c1722475d2d98c71d48741)
2019-12-30Add USB_FUNCTION_GROUP_WITH_POST_SERVICE for cfs post service.submit/tizen_5.5/20191230.073843accepted/tizen/5.5/unified/20200102.013952INSUN PYO1-0/+2
To support CFS acm and rndis mode, add new USB_FUNCTION_GROUP_WITH_POST_SERVICE mode. Legacy mode : usb prepare --> usb enable --> start sdb, mtp, rndis, and data-router service CFS sdb, mtp mode : usb prepare -> start sdb and mtp service -> usb enable CFS acm, rndis mode : usb prepare -> usb enable -> start acm and rndis service Change-Id: I7199636d0b2bcfeac068e1c1575e89926c8f7134 (cherry picked from commit 6312d5a191ccc31b8c20ec109d4e2e3ba8406899)
2019-09-16usb_cfs_client: Enable gadget at reconfiguration #2submit/tizen/20191001.105102INSUN PYO1-3/+14
Because it is a workround code for Artik, restrict this patch to artik. (This workaround will be removed in tizen 6.0) Change-Id: Ice81dd8c37359bdc4a37099ecff27d696f7f9ec0 Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
2019-04-10Change libgdbus library name to libsyscommon.submit/tizen/20190410.090025accepted/tizen/unified/20190412.124555Yunmi Ha1-1/+1
Change-Id: I3611395b38a3858d0838ddf94dc12e958fd91856 Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
2019-03-25Rename systemd_stop_unit_sync() to systemd_stop_unit_wait_stopped()submit/tizen/20190325.102033accepted/tizen/unified/20190326.024559Hyotaek Shim1-3/+3
Change-Id: I94d972c7dc68d9e6b246702b9217d0b92c908d0c Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
2019-02-08dbus: remove systemd start/stop unit apisanghyeok.oh1-5/+5
Change-Id: Ic498a2c56ffaccdcacf2c01d5d20a169fc5324cf Signed-off-by: sanghyeok.oh <sanghyeok.oh@samsung.com>
2018-11-19Fix some static analysis warnings.submit/tizen/20181120.234806accepted/tizen/unified/20181121.060510Michal Bloch1-4/+1
Change-Id: I632bd9813094ade3b03dadd7d21bc62dc2152710 Signed-off-by: Michal Bloch <m.bloch@samsung.com>
2018-10-15usb: Move ffs services cleanup to hw_cfs_gadget_closesubmit/tizen/20181015.121248Paweł Szewczyk1-25/+25
Change-Id: I1fc61542b8228ff038b64ee1df3cd5b6c3947a1c Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
2018-10-12usb_client: Cleanup ffs services at gadget disablesubmit/tizen/20181015.022811Paweł Szewczyk1-0/+25
Each functionfs daemon spawned at gadget initialization should be closed before functionfs can be succesfully cleaned up. Change-Id: I97654fa882f5b7346e5aee3aedd3ea00e50fcb47 Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
2018-06-29usb_cfs_client: Enable gadget at reconfigurationPaweł Szewczyk1-0/+5
This workaround was introduced on artik, where gadget need to be enabled before usb connection can be properly monitored. As this does little harm, it's moved here to prevent regression on artik. The side effect of this is starting some functionfs daemons long before they are actually needed, so this should be removed when exton issue is fixed. Change-Id: Ia41c21e3c44d7d3a00d557f181e8c22766c6f31b Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
2018-06-26Add common code from usb_client HALPaweł Szewczyk1-0/+916
Change-Id: I863b5e9757f943eb6659e939118b9c03e22c8229 Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>