From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 828ACC43441 for ; Tue, 27 Nov 2018 09:04:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 56DCD208E7 for ; Tue, 27 Nov 2018 09:04:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 56DCD208E7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729990AbeK0UBv (ORCPT ); Tue, 27 Nov 2018 15:01:51 -0500 Received: from mga07.intel.com ([134.134.136.100]:57280 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729387AbeK0UBv (ORCPT ); Tue, 27 Nov 2018 15:01:51 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Nov 2018 01:04:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,286,1539673200"; d="scan'208";a="111351113" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.157]) by fmsmga002.fm.intel.com with SMTP; 27 Nov 2018 01:04:33 -0800 Received: by lahna (sSMTP sendmail emulation); Tue, 27 Nov 2018 11:04:32 +0200 Date: Tue, 27 Nov 2018 11:04:32 +0200 From: Mika Westerberg To: Andy Shevchenko Cc: Darren Hart , platform-driver-x86@vger.kernel.org, "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Jonathan Cameron , Wolfram Sang , linux-i2c@vger.kernel.org, Hans de Goede , Heikki Krogerus , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 05/13] i2c: acpi: Return error pointers from i2c_acpi_new_device() Message-ID: <20181127090432.GK2296@lahna.fi.intel.com> References: <20181126150858.16901-1-andriy.shevchenko@linux.intel.com> <20181126150858.16901-6-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181126150858.16901-6-andriy.shevchenko@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 26, 2018 at 05:08:50PM +0200, Andy Shevchenko wrote: > The caller would like to know the reason why the i2c_acpi_new_device() fails. > For example, if adapter is not available, it might be in the future and we > would like to re-probe the clients again. But at the same time we would like to > bail out if the error seems unrecoverable, such as out of memory condition. > To achieve this, return error pointer in some cases. > > Signed-off-by: Andy Shevchenko > Reviewed-by: Hans de Goede > --- > drivers/i2c/i2c-core-acpi.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c > index 32affd3fa8bd..af4b5bd5d973 100644 > --- a/drivers/i2c/i2c-core-acpi.c > +++ b/drivers/i2c/i2c-core-acpi.c > @@ -387,6 +387,7 @@ struct notifier_block i2c_acpi_notifier = { > * Also see i2c_new_device, which this function calls to create the i2c-client. > * > * Returns a pointer to the new i2c-client, or NULL if the adapter is not found. > + * In some cases might return an error pointer. I would rather make it return error pointer always. Then the caller can just check for IS_ERR() and not need to deal with the possible NULL. It is also more consistent that way than saying "some cases might return an error pointer" (but some cases you get NULL or even pointer to the created object) ;-)