summaryrefslogtreecommitdiffstats
path: root/drivers/usb/phy/phy.c
Commit message (Collapse)AuthorAgeFilesLines
* usb: phy: constify the struct device_type usageRicardo B. Marliere2024-02-191-1/+1
| | | | | | | | | | | Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the usb_phy_dev_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime. Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net> Link: https://lore.kernel.org/r/20240218-device_cleanup-usb-v1-2-77423c4da262@marliere.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* driver core: make struct device_type.uevent() take a const *Greg Kroah-Hartman2023-01-271-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The uevent() callback in struct device_type should not be modifying the device that is passed into it, so mark it as a const * and propagate the function signature changes out into all relevant subsystems that use this callback. Cc: Alan Stern <stern@rowland.harvard.edu> Cc: Andreas Noever <andreas.noever@gmail.com> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Bard Liao <yung-chuan.liao@linux.intel.com> Cc: Chaitanya Kulkarni <kch@nvidia.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Cc: Frank Rowand <frowand.list@gmail.com> Cc: Ira Weiny <ira.weiny@intel.com> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: Jens Axboe <axboe@kernel.dk> Cc: Jilin Yuan <yuanjilin@cdjrlc.com> Cc: Jiri Slaby <jirislaby@kernel.org> Cc: Len Brown <lenb@kernel.org> Cc: Mark Gross <markgross@kernel.org> Cc: "Martin K. Petersen" <martin.petersen@oracle.com> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org> Cc: Maximilian Luz <luzmaximilian@gmail.com> Cc: Michael Jamet <michael.jamet@intel.com> Cc: Ming Lei <ming.lei@redhat.com> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Cc: Rob Herring <robh+dt@kernel.org> Cc: Sakari Ailus <sakari.ailus@linux.intel.com> Cc: Sanyog Kale <sanyog.r.kale@intel.com> Cc: Sean Young <sean@mess.org> Cc: Stefan Richter <stefanr@s5r6.in-berlin.de> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Won Chung <wonchung@google.com> Cc: Yehezkel Bernat <YehezkelShB@gmail.com> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> # for Thunderbolt Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org> Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Acked-by: Wolfram Sang <wsa@kernel.org> Acked-by: Vinod Koul <vkoul@kernel.org> Acked-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20230111113018.459199-6-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: phy: Fix page fault from usb_phy_ueventArtur Petrosyan2021-07-211-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the dwc2 platform device is removed, it unregisters the generic phy. usb_remove_phy() is called and the dwc2 usb_phy is removed from the "phy_list", but the uevent may still attempt to get the usb_phy from the list, resulting in a page fault bug. Currently we can't access the usb_phy from the "phy_list" after the device is removed. As a fix check to make sure that we can get the usb_phy before moving forward with the uevent. [ 84.949345] BUG: unable to handle page fault for address:00000007935688d8 [ 84.949349] #PF: supervisor read access in kernel mode [ 84.949351] #PF: error_code(0x0000) - not-present page [ 84.949353] PGD 0 P4D 0 [ 84.949356] Oops: 0000 [#1] SMP PTI [ 84.949360] CPU: 2 PID: 2081 Comm: rmmod Not tainted 5.13.0-rc4-snps-16547-ga8534cb092d7-dirty #32 [ 84.949363] Hardware name: Hewlett-Packard HP Z400 Workstation/0B4Ch, BIOS 786G3 v03.54 11/02/2011 [ 84.949365] RIP: 0010:usb_phy_uevent+0x99/0x121 [ 84.949372] Code: 8d 83 f8 00 00 00 48 3d b0 12 22 94 74 05 4c 3b 23 75 5b 8b 83 9c 00 00 00 be 32 00 00 00 48 8d 7c 24 04 48 c7 c2 d4 5d 7b 93 <48> 8b 0c c5 e0 88 56 93 e8 0f 63 8a ff 8b 83 98 00 00 00 be 32 00 [ 84.949375] RSP: 0018:ffffa46bc0f2fc70 EFLAGS: 00010246 [ 84.949378] RAX: 00000000ffffffff RBX: ffffffff942211b8 RCX: 0000000000000027 [ 84.949380] RDX: ffffffff937b5dd4 RSI: 0000000000000032 RDI: ffffa46bc0f2fc74 [ 84.949383] RBP: ffff94a306613000 R08: 0000000000000000 R09: 00000000fffeffff [ 84.949385] R10: ffffa46bc0f2faa8 R11: ffffa46bc0f2faa0 R12: ffff94a30186d410 [ 84.949387] R13: ffff94a32d188a80 R14: ffff94a30029f960 R15: ffffffff93522dd0 [ 84.949389] FS: 00007efdbd417540(0000) GS:ffff94a513a80000(0000) knlGS:0000000000000000 [ 84.949392] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 84.949394] CR2: 00000007935688d8 CR3: 0000000165606000 CR4: 00000000000006e0 [ 84.949396] Call Trace: [ 84.949401] dev_uevent+0x190/0x1ad [ 84.949408] kobject_uevent_env+0x18e/0x46c [ 84.949414] device_release_driver_internal+0x17f/0x18e [ 84.949418] bus_remove_device+0xd3/0xe5 [ 84.949421] device_del+0x1c3/0x31d [ 84.949425] ? kobject_put+0x97/0xa8 [ 84.949428] platform_device_del+0x1c/0x63 [ 84.949432] platform_device_unregister+0xa/0x11 [ 84.949436] dwc2_pci_remove+0x1e/0x2c [dwc2_pci] [ 84.949440] pci_device_remove+0x31/0x81 [ 84.949445] device_release_driver_internal+0xea/0x18e [ 84.949448] driver_detach+0x68/0x72 [ 84.949450] bus_remove_driver+0x63/0x82 [ 84.949453] pci_unregister_driver+0x1a/0x75 [ 84.949457] __do_sys_delete_module+0x149/0x1e9 [ 84.949462] ? task_work_run+0x64/0x6e [ 84.949465] ? exit_to_user_mode_prepare+0xd4/0x10d [ 84.949471] do_syscall_64+0x5d/0x70 [ 84.949475] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 84.949480] RIP: 0033:0x7efdbd563bcb [ 84.949482] Code: 73 01 c3 48 8b 0d c5 82 0c 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa b8 b0 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 95 82 0c 00 f7 d8 64 89 01 48 [ 84.949485] RSP: 002b:00007ffe944d7d98 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0 [ 84.949489] RAX: ffffffffffffffda RBX: 00005651072eb700 RCX: 00007efdbd563bcb [ 84.949491] RDX: 000000000000000a RSI: 0000000000000800 RDI: 00005651072eb768 [ 84.949493] RBP: 00007ffe944d7df8 R08: 0000000000000000 R09: 0000000000000000 [ 84.949495] R10: 00007efdbd5dfac0 R11: 0000000000000206 R12: 00007ffe944d7fd0 [ 84.949497] R13: 00007ffe944d8610 R14: 00005651072eb2a0 R15: 00005651072eb700 [ 84.949500] Modules linked in: uas configfs dwc2_pci(-) phy_generic fuse crc32c_intel [last unloaded: udc_core] [ 84.949508] CR2: 00000007935688d8 [ 84.949510] ---[ end trace e40c871ca3e4dc9e ]--- [ 84.949512] RIP: 0010:usb_phy_uevent+0x99/0x121 Fixes: a8534cb092d7 ("usb: phy: introduce usb_phy device type with its own uevent handler") Reviewed-by: Peter Chen <peter.chen@kernel.org> Signed-off-by: Artur Petrosyan <Arthur.Petrosyan@synopsys.com> Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Link: https://lore.kernel.org/r/20210710092247.D7AFEA005D@mailhost.synopsys.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: phy: introduce usb_phy device type with its own uevent handlerGrzegorz Jaszczyk2021-06-031-8/+47
| | | | | | | | | | | | | | | The USB charger type and status was already propagated to userspace through kobject_uevent_env during charger notify work. Nevertheless the uevent could be lost e.g. because it could be fired at an early kernel boot stage, way before udev daemon or any other user-space app was able to catch it. Registering uevent hook for introduced usb_phy_dev_type will allow to query sysfs 'uevent' file to restore that information at any time. Reviewed-by: Peter Chen <peter.chen@kernel.org> Signed-off-by: Grzegorz Jaszczyk <grzegorz.jaszczyk@linaro.org> Link: https://lore.kernel.org/r/20210531122222.453628-1-grzegorz.jaszczyk@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: phy: phy: Fix-up a whole bunch of formatting issuesLee Jones2020-07-031-24/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Kerneldoc expects arg descriptions to be in the format '@.*: '. If either the '@' or the ':' is omitted then kerneldoc complains that the description is missing. Add the missing ':'s here. Also provide a new description for 'event'. Fixes the following kernel build W=1 warnings: drivers/usb/phy/phy.c:106: warning: Function parameter or member 'work' not described in 'usb_phy_notify_charger_work' drivers/usb/phy/phy.c:172: warning: Function parameter or member 'nb' not described in 'usb_phy_get_charger_type' drivers/usb/phy/phy.c:172: warning: Function parameter or member 'state' not described in 'usb_phy_get_charger_type' drivers/usb/phy/phy.c:172: warning: Function parameter or member 'data' not described in 'usb_phy_get_charger_type' drivers/usb/phy/phy.c:194: warning: Function parameter or member 'usb_phy' not described in 'usb_phy_set_charger_current' drivers/usb/phy/phy.c:194: warning: Function parameter or member 'mA' not described in 'usb_phy_set_charger_current' drivers/usb/phy/phy.c:244: warning: Function parameter or member 'usb_phy' not described in 'usb_phy_get_charger_current' drivers/usb/phy/phy.c:244: warning: Function parameter or member 'min' not described in 'usb_phy_get_charger_current' drivers/usb/phy/phy.c:244: warning: Function parameter or member 'max' not described in 'usb_phy_get_charger_current' drivers/usb/phy/phy.c:281: warning: Function parameter or member 'usb_phy' not described in 'usb_phy_set_charger_state' drivers/usb/phy/phy.c:281: warning: Function parameter or member 'state' not described in 'usb_phy_set_charger_state' drivers/usb/phy/phy.c:427: warning: Function parameter or member 'dev' not described in 'devm_usb_get_phy' drivers/usb/phy/phy.c:427: warning: Function parameter or member 'type' not described in 'devm_usb_get_phy' drivers/usb/phy/phy.c:456: warning: Function parameter or member 'type' not described in 'usb_get_phy' drivers/usb/phy/phy.c:500: warning: Function parameter or member 'dev' not described in 'devm_usb_get_phy_by_node' drivers/usb/phy/phy.c:500: warning: Function parameter or member 'node' not described in 'devm_usb_get_phy_by_node' drivers/usb/phy/phy.c:500: warning: Function parameter or member 'nb' not described in 'devm_usb_get_phy_by_node' drivers/usb/phy/phy.c:558: warning: Function parameter or member 'dev' not described in 'devm_usb_get_phy_by_phandle' drivers/usb/phy/phy.c:558: warning: Function parameter or member 'phandle' not described in 'devm_usb_get_phy_by_phandle' drivers/usb/phy/phy.c:558: warning: Function parameter or member 'index' not described in 'devm_usb_get_phy_by_phandle' drivers/usb/phy/phy.c:590: warning: Function parameter or member 'dev' not described in 'devm_usb_put_phy' drivers/usb/phy/phy.c:590: warning: Function parameter or member 'phy' not described in 'devm_usb_put_phy' drivers/usb/phy/phy.c:627: warning: Function parameter or member 'type' not described in 'usb_add_phy' drivers/usb/phy/phy.c:721: warning: Function parameter or member 'event' not described in 'usb_phy_set_event' Cc: Felipe Balbi <balbi@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20200702144625.2533530-2-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: phy: show USB charger type for userPeter Chen2020-01-241-1/+12
| | | | | | | | | Current USB charger framework only shows charger state for user, but the user may also need charger type for further use, add support for it. Signed-off-by: Peter Chen <peter.chen@nxp.com> Link: https://lore.kernel.org/r/1579145333-1657-1-git-send-email-peter.chen@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* USB: phy: drop legacy board-file supportJohan Hovold2018-04-221-97/+2
| | | | | | | | | | | | | | The legacy interface for associating controllers with phys from board files and platform code has been unused since commit 9080b8dc761a ("ARM: OMAP2+: Remove legacy usb-host.c platform init code"). Since then, all calls to usb_get_phy_dev() and its devres version have been returning -ENODEV. Now that the final calls to these functions have been removed, we can drop this legacy lookup interface altogether. Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* USB: phy: drop unused legacy controller-phy bind helperJohan Hovold2018-04-221-34/+0
| | | | | | | | | | | | | | | Drop the unused legacy usb_bind_phy() helper whose last user was removed in 2016 when OMAP moved to device-tree boot (9080b8dc761a ("ARM: OMAP2+: Remove legacy usb-host.c platform init code")). Note that this means that for the last couple of years the phy_bind_list has been empty (when using mainline kernels) and that consequently all phy lookups using the usb_get_phy_dev() interface have failed with -ENODEV. This helper along with its current users will be removed by follow-on patches. Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: phy: Factor out the usb charger initializationBaolin Wang2017-12-121-4/+10
| | | | | | | | | | | Factor out the guts of usb charger initialization into usb_charger_init() function, to make the usb_add_extcon() only do the extcon related things. Meanwhile we also should initialize the USB charger before registering the extcon device, in case the extcon notification was issued earlier than usb charger initialization. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
* USB: phy: Remove redundant license textGreg Kroah-Hartman2017-11-071-5/+0
| | | | | | | | | | | | | | | | | | Now that the SPDX tag is in all USB files, that identifies the license in a specific and legally-defined manner. So the extra GPL text wording can be removed as it is no longer needed at all. This is done on a quest to remove the 700+ different ways that files in the kernel describe the GPL license text. And there's unneeded stuff like the address (sometimes incorrect) for the FSF which is never needed. No copyright headers or other non-license-description text was removed. Cc: Thierry Reding <thierry.reding@gmail.com> Cc: Jonathan Hunter <jonathanh@nvidia.com> Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* USB: add SPDX identifiers to all remaining files in drivers/usb/Greg Kroah-Hartman2017-11-041-0/+1
| | | | | | | | | | | | | | | | | | | | | It's good to have SPDX identifiers in all files to make it easier to audit the kernel tree for correct licenses. Update the drivers/usb/ and include/linux/usb* files with the correct SPDX license identifier based on the license text in the file itself. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. This work is based on a script and data from Thomas Gleixner, Philippe Ombredanne, and Kate Stewart. Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Kate Stewart <kstewart@linuxfoundation.org> Cc: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com> Acked-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Merge tag 'usb-for-v4.14' of ↵Greg Kroah-Hartman2017-08-221-0/+272
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next Felipe writes: usb: changes for v4.14 merge window Not a big pull request this time around. Only 49 non-merge commits. This pull request is, however, all over the place. Most of the changes are in the bdc driver adding support for USB Phy layer and PM. Renesas adds support for R-Car H3 ES2.0 and R-Car M3-W SoCs. Also here is PM_RUNTIME support for dwc3-keystone. UDC Core got a DMA unmap fix to make sure we only unmap requests that were, indeed, mapped. Other than these, we have a lot of cleanups, many of them adding 'const' to several places.
| * usb: phy: Add USB charger supportBaolin Wang2017-08-151-0/+272
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces the usb charger support based on usb phy that makes an enhancement to a power driver. The basic conception of the usb charger is that, when one usb charger is added or removed by reporting from the extcon device state change, the usb charger will report to power user to set the current limitation. Power user can register a notifiee on the usb phy by issuing usb_register_notifier() to get notified by charger status changes or charger current changes. we can notify what current to be drawn to power user according to different charger type, and now we have 2 methods to get charger type. One is get charger type from extcon subsystem, which also means the charger state changes. Another is we can get the charger type from USB controller detecting or PMIC detecting, and the charger state changes should be told by issuing usb_phy_set_charger_state(). Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
* | usb: Convert to using %pOF instead of full_nameRob Herring2017-07-221-2/+2
|/ | | | | | | | | | Now that we have a custom printf format specifier, convert users of full_name to use %pOF instead. This is preparation to remove storing of the full path string for each node. Signed-off-by: Rob Herring <robh@kernel.org> Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: phy: Introduce one extcon device into usb phyBaolin Wang2017-05-171-0/+57
| | | | | | | | | | | Usually usb phy need register one extcon device to get the connection notifications. It will remove some duplicate code if the extcon device is registered using common code instead of each phy driver having its own related extcon APIs. So we add one pointer of extcon device into usb phy structure, and some other helper functions to register extcon. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
* usb: phy: Add interface to get phy give of device_node.NeilBrown2015-05-261-27/+70
| | | | | | | | | | | | | | | | | | | Split the "get phy from device_node" functionality out of "get phy by phandle" so it can be used directly. This is useful when a battery-charger is intimately associated with a particular phy but handled by a separate driver. The charger can find the device_node based on sibling relationships without the need for a redundant declaration in the devicetree description. As a peripheral that gets a phy will often want to register a notifier block, and de-register it later, that functionality is included so the de-registration is automatic. Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: phy: Find the right match in devm_usb_phy_matchAxel Lin2015-03-191-1/+3
| | | | | | | | | | | The res parameter passed to devm_usb_phy_match() is the location where the pointer to the usb_phy is stored, hence it needs to be dereferenced before comparing to the match data in order to find the correct match. Fixes: 410219dcd2ba ("usb: otg: utils: devres: Add API's to associate a device with the phy") Signed-off-by: Axel Lin <axel.lin@ingics.com> Cc: <stable@vger.kernel.org> # v3.6+ Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: phy: never defer probe in non-OF caseHeikki Krogerus2015-01-191-1/+1
| | | | | | | | | | | | | | | In practice failure to find phy when requested in non-OF case means it will never become available, so __usb_find_phy() must return -ENODEV and not -EPROBE_DEFER. This fixes a regression caused by commit 9c9d82492b73 (usb: phy: Fix deferred probing), where the USB controller driver is left infinitely into deferred probe when there are no phys. Fixes: 9c9d82492b73 (usb: phy: Fix deferred probing) Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* Merge tag 'fixes-for-v3.19-rc5' of ↵Greg Kroah-Hartman2015-01-121-3/+9
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-linus Felipe writes: usb: fixes for v3.19-rc5 Just three fixes this time. An oops fix in ep_write() from gadgetfs, another oops for the Atmel UDC when unloading a gadget driver and the fix for PHY deferred probing. Signed-off-by: Felipe Balbi <balbi@ti.com> Conflicts: drivers/usb/phy/phy.c
| * usb: phy: Restore deferred probing pathThierry Reding2014-12-231-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 1290a958d48e ("usb: phy: propagate __of_usb_find_phy()'s error on failure") broke platforms that rely on deferred probing to order probing of PHY and host controller drivers. The reason is that the commit simply propagates errors from __of_usb_find_phy(), which returns -ENODEV if no PHY has been registered yet for a given device tree node. The only case in which -EPROBE_DEFER would now be returned is if try_module_get() did fail, which does not make sense. The correct thing to do is to return -EPROBE_DEFER if a PHY hasn't been registered yet. The only condition under which it makes sense to return -ENODEV is if the device tree node representing the PHY has been disabled (via the status property) because in that case the PHY will never be registered. This patch addresses the problem by making __of_usb_find_phy() return an appropriate error code while keeping in line with the above-mentioned commit to propagate error codes rather than overwriting them. At the same time the check for a valid PHY is decoupled from the check for the try_module_get() call and a separate error code is returned if the latter fails. Fixes: 1290a95 (usb: phy: propagate __of_usb_find_phy()'s error on failure) Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: phy: Fix deferred probingMaxime Ripard2015-01-091-3/+3
|/ | | | | | | | | | | | | | | | | | | Commit 1290a958d48e ("usb: phy: propagate __of_usb_find_phy()'s error on failure") actually broke the deferred probing mechanism, since it now returns EPROBE_DEFER only when the try_module_get call fails, but not when the phy lookup does. All the other similar functions seem to return ENODEV when try_module_get fails, and the error code of either __usb_find_phy or __of_usb_find_phy otherwise. In order to have a consistent behaviour, and a meaningful EPROBE_DEFER, always return EPROBE_DEFER when __(of_)usb_find_phy fails to look up the requested phy, that will be propagated by the caller, and ENODEV if try_module_get fails. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Tested-by: Olof Johansson <olof@lixom.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: phy: introduce usb_phy_set_event interfaceKiran Raparthy2014-11-211-0/+12
| | | | | | | | | | | | | | | | | | | | | PHY drivers require a generic interface to handle per-PHY events. usb_phy_set_event interface sets event to phy event. PHY drivers call this interface for each phy event. Cc: Felipe Balbi <balbi@ti.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: linux-kernel@vger.kernel.org Cc: linux-usb@vger.kernel.org Cc: Android Kernel Team <kernel-team@android.com> Cc: John Stultz <john.stultz@linaro.org> Cc: Sumit Semwal <sumit.semwal@linaro.org> Cc: Arve Hj�nnev�g <arve@android.com> Cc: Benoit Goby <benoit@android.com> [Original patch in Android from Todd] Cc: Todd Poynor <toddpoynor@google.com> Signed-off-by: Kiran Raparthy <kiran.kumar@linaro.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: phy: propagate __of_usb_find_phy()'s error on failureArjun Sreedharan2014-11-201-1/+3
| | | | | | | | | | | | When __of_usb_find_phy() fails, it returns -ENODEV - its error code has to be returned by devm_usb_get_phy_by_phandle(). Only when the former function succeeds and try_module_get() fails should -EPROBE_DEFER be returned. [ balbi@ti.com : remove trailing whitespace ] Signed-off-by: Arjun Sreedharan <arjun024@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: phy: return -ENODEV on failure of try_module_getArjun Sreedharan2014-08-191-0/+3
| | | | | | | | When __usb_find_phy_dev() does not return error and try_module_get() fails, return -ENODEV. Signed-off-by: Arjun Sreedharan <arjun024@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* Merge branch 'for-linus' of ↵Linus Torvalds2014-08-061-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial Pull trivial tree changes from Jiri Kosina: "Summer edition of trivial tree updates" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (23 commits) doc: fix two typos in watchdog-api.txt irq-gic: remove file name from heading comment MAINTAINERS: Add miscdevice.h to file list for char/misc drivers. scsi: mvsas: mv_sas.c: Fix for possible null pointer dereference doc: replace "practise" with "practice" in Documentation befs: remove check for CONFIG_BEFS_RW scsi: doc: fix 'SCSI_NCR_SETUP_MASTER_PARITY' drivers/usb/phy/phy.c: remove a leading space mfd: fix comment cpuidle: fix comment doc: hpfall.c: fix missing null-terminate after strncpy call usb: doc: hotplug.txt code typos kbuild: fix comment in Makefile.modinst SH: add proper prompt to SH_MAGIC_PANEL_R2_VERSION ARM: msm: Remove MSM_SCM crypto: Remove MPILIB_EXTRA doc: CN: remove dead link, kerneltrap.org no longer works media: update reference, kerneltrap.org no longer works hexagon: update reference, kerneltrap.org no longer works doc: LSM: update reference, kerneltrap.org no longer works ...
| * drivers/usb/phy/phy.c: remove a leading spaceAntonio Ospite2014-06-191-1/+1
| | | | | | | | | | | | Signed-off-by: Antonio Ospite <ao2@ao2.it> Acked-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* | usb: phy: return an error in usb_get_phy() if try_module_get() failsMathias Krause2014-04-161-0/+3
|/ | | | | | | | | In case we found a matching USB PHY in usb_get_phy() but the call to try_module_get() fails, we shouldn't return a (probably soon dangling) pointer but an ERR_PTR instead. Signed-off-by: Mathias Krause <minipli@googlemail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: phy: move some error messages to debugJosh Boyer2014-02-041-5/+3
| | | | | | | | | | | | | | | | | | | the PHY layer is supposed to be optional, considering some PHY have no control bus for SW to poke around. After commit 1ae5799 (usb: hcd: Initialize USB phy if needed) any HCD which didn't provide a PHY driver would emit annoying error messages. In this patch we're decreasing those messages to debugging only and we also add a PHY prefix or use dev_dbg so we know where they're coming from. Reported-by: Josh Boyer <jwboyer@fedoraproject.org> Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Josh Boyer <jwboyer@fedoraproject.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: phy: initialize the notifier when add a new phyNeil Zhang2013-12-121-0/+4
| | | | | | | | | | We need to initialize the notifer before use it. So lets initialize it when add a new phy device to reduce the code redundancy. Signed-off-by: Neil Zhang <zhangwm@marvell.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: phy: don't return with NULL from devm_usb_get_phy()Gabor Juhos2013-10-111-1/+1
| | | | | | | | | The callers are expecting an ERR_PTR value in case of an error. Change he code to return with an encoded -ENOMEM value in the case of a failed devres_alloc call. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: phy: remove exported function from __init sectionDenis Efremov2013-04-231-1/+1
| | | | | | | | | | | The symbol usb_bind_phy is exported and annotated __init. It looks like section mismatch. Fix by removing the __init annotation of usb_bind_phy. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Denis Efremov <yefremov.denis@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: phy: convert EXPORT_SYMBOL to EXPORT_SYMBOL_GPLFelipe Balbi2013-03-181-10/+10
| | | | | | | we only want GPL users for our generic functions, so let's switch over to EXPORT_SYMBOL_GPL. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: phy: move bulk of otg/otg.c to phy/phy.cSascha Hauer2013-03-181-0/+438
Most of otg/otg.c is not otg specific, but phy specific, so move it to the phy directory. Tested-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Reported-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>