From patchwork Fri Mar 15 04:08:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 227845 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45E1D2C00D8 for ; Fri, 15 Mar 2013 15:09:30 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751255Ab3COEJ0 (ORCPT ); Fri, 15 Mar 2013 00:09:26 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:37797 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751057Ab3COEJZ (ORCPT ); Fri, 15 Mar 2013 00:09:25 -0400 Received: by mail-pb0-f46.google.com with SMTP id uo15so3235888pbc.33 for ; Thu, 14 Mar 2013 21:09:24 -0700 (PDT) X-Received: by 10.68.87.129 with SMTP id ay1mr12456729pbb.105.1363320564707; Thu, 14 Mar 2013 21:09:24 -0700 (PDT) Received: from localhost ([183.37.197.207]) by mx.google.com with ESMTPS id mz8sm6518282pbc.9.2013.03.14.21.09.18 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 14 Mar 2013 21:09:23 -0700 (PDT) From: Ming Lei To: "David S. Miller" , Greg Kroah-Hartman , Jiri Kosina Cc: Alan Stern , Oliver Neukum , netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-input@vger.kernel.org, Ming Lei Subject: [PATCH v3 1/7] USB: adds comment on suspend callback Date: Fri, 15 Mar 2013 12:08:53 +0800 Message-Id: <1363320539-23012-2-git-send-email-ming.lei@canonical.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1363320539-23012-1-git-send-email-ming.lei@canonical.com> References: <1363320539-23012-1-git-send-email-ming.lei@canonical.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds comments on interface driver suspend callback to emphasize that the failure return value is ignored by USB core in system sleep context, so do not try to recover device for this case and let resume/reset_resume callback handle the suspend failure if needed. Also kerneldoc for usb_suspend_both() is updated with the fact. Acked-by: Alan Stern Signed-off-by: Ming Lei --- drivers/usb/core/driver.c | 11 ++++++++--- include/linux/usb.h | 7 ++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index d938b2b..eb1d00a 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -1196,9 +1196,14 @@ done: * * This is the central routine for suspending USB devices. It calls the * suspend methods for all the interface drivers in @udev and then calls - * the suspend method for @udev itself. If an error occurs at any stage, - * all the interfaces which were suspended are resumed so that they remain - * in the same state as the device. + * the suspend method for @udev itself. When the routine is called in + * autosuspend, if an error occurs at any stage, all the interfaces + * which were suspended are resumed so that they remain in the same + * state as the device, but when called from system sleep, all error + * from suspend methods of interfaces and the non-root-hub device itself + * are simply ignored, so all suspended interfaces are only resumed + * to the device's state when @udev is root-hub and its suspend method + * returns failure. * * Autosuspend requests originating from a child device or an interface * driver may be made without the protection of @udev's device lock, but diff --git a/include/linux/usb.h b/include/linux/usb.h index 4d22d0f..f82ce57 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -978,7 +978,12 @@ struct usbdrv_wrap { * the "usbfs" filesystem. This lets devices provide ways to * expose information to user space regardless of where they * do (or don't) show up otherwise in the filesystem. - * @suspend: Called when the device is going to be suspended by the system. + * @suspend: Called when the device is going to be suspended by the + * system either from system sleep or runtime suspend context. The + * return value will be ignored in system sleep context, so do NOT + * try to continue using the device if suspend fails in this case. + * Instead, let the resume or reset-resume routine recover from + * the failure. * @resume: Called when the device is being resumed by the system. * @reset_resume: Called when the suspended device has been reset instead * of being resumed.