Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp541121lqe; Sat, 6 Apr 2024 11:54:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXk+NIaABNJogNyWfMmRf5EbUHY993JJZF+/56PA/KA57qyNychBU9gD0d8ySGJiMpfq+O2iE9M/91V0aoh7QZoax/4bx83FXubNNodyQ== X-Google-Smtp-Source: AGHT+IEKuHVfqytavhclVLI8NSF7BPK227zE0bMzVgu9vyb6KduhlUC61CHZJyvTBGMTKUsvLOjM X-Received: by 2002:a05:6a21:3990:b0:1a7:4e56:ef06 with SMTP id ad16-20020a056a21399000b001a74e56ef06mr2313442pzc.32.1712429678036; Sat, 06 Apr 2024 11:54:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712429678; cv=pass; d=google.com; s=arc-20160816; b=obiKtKVmU0sjLrtkZEZrrGAvel5spHnYZTeqs5BApzp0Owz8N7qMWIipZbepsS3Ncj VJaK99u1hm41rp8Ym5tkZ6WiTB810AeDa+7qJEh8BW26TKaFV1LSBYBH0pXWVR5Au80a xVEFKtHAWza1kXUTFZ7scbRfOPdWBjwly3IhQ1YEGOEvcHDOMgo+J6UxLlBrKzcfRTKJ MPW02+E8t2sxpmGvVq+n95BH5E/Hjiz/QkSnqM0QpDyf4wLq1ayhCoHAp/lRQQV3cOHb slVBAIDtew+STi0B1yufJrq+g5a1vo5fjHeGlQrpoQGbyEBzH5eckcSaREWOHud24YLg 2xiQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2L9HnQgvN2Ln6gPzcXIAxZFKswcGpDZCh6KtiR1B+2U=; fh=3j3lEceEnfiRJ1XCm1XsfOgRzAU8Kv+9kbbdOSgbvZg=; b=jIbnIH3KHqbxf59uKSsjFUPTg23LvkTdG6eL7XKcrgYxQk0yzI+q0LP0KdSQH3dXYz YgPlcztFretEa91XJl9cDlu/sWpSYEFFusUjksdNX18MQgrRePajy7FX/ozBX1fnmixo H54K8PERbSkkG5s1sgzA2Ah+vY6RcmyEZndGLwMA6qkw3ZczSDjMsnTRM3xjmWrh2XOV fjV8vAtFZ4uj6njpPen8QkaPtRpHbejQv0vg5leuP0mhgJatEAIBVP+1nfPABs+q5Z4i vrbGgFZ4o0u7ji6MNo1PflRwS9gKP5hVK8ezJkrpQI99UZsUEABMp4la1aEONs8kNIFs lDMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mt+h43s4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-134062-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134062-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id v4-20020aa78504000000b006ece021b536si3464975pfn.221.2024.04.06.11.54.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Apr 2024 11:54:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134062-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mt+h43s4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-134062-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134062-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A2EAEB21C5D for ; Sat, 6 Apr 2024 18:54:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9BE024CB30; Sat, 6 Apr 2024 18:54:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mt+h43s4" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C04B347F50; Sat, 6 Apr 2024 18:54:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712429664; cv=none; b=OuxkRehyt53h+NDKJRuVcNSTNPNpRHJXmrW6LHVPLNbgTSqx4i4SoXrqM8UGNhq+lnM3PbDDNns4tv+m04Prn48QjIFcFhGVaNJ4St0ru/MLIHxok9I6XUwrCcYulkgpL+VbUJHQ8ctr20uKL9TW4JJ4Xrl0xbrG/0Hkp4anZ8w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712429664; c=relaxed/simple; bh=x/6LCdwPe9bd7QfSYVBg8tXsBNqlRotB6R1Xk/M09xM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WTAN5nNC+9dXZhqMIlcrUi71R3U5R0NvGI/BNtJZXrKLAf2mvmQwbTWSjhSaosiN28/QeLwdAmIucE8ghAoN81JY7+X/woUma9HefSxHn9msLkd/VVfg+1Ff+AByykm6RqwGirEyzfmzuX9p8orZMZjy/eqhKaLlMZ5RGAEf+18= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mt+h43s4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42F49C433C7; Sat, 6 Apr 2024 18:54:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712429664; bh=x/6LCdwPe9bd7QfSYVBg8tXsBNqlRotB6R1Xk/M09xM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mt+h43s4WcFJYwx5FDWf/8nIINlT7Q9WhT7RR1uF+LePezACXIWjbT8oDWVgkpvto 5X9R1H4AU5DmGdMeLsPuWmbSszD54oa9M2rL4j5OTAEF8JRhMKoGC8syGOY7bLHj88 lrp2Hkhbcjce4fLImHkwTWAq1FyoJVi+viLo8gnfKNNeYS1lLF9KlM3lqHuxL+X36K 2RTcWQXWWoHOUP17rKuKm8rxMRVrgMHQLjlm1D1MegIEAk+7zd9L6635G/fVjWK000 Tqn0a15Wg4tw4tyrh744EEcintalJ9/wlrelWJtfqGiS352qwlElVwHiVm41P08kX1 CwkDP06v8Zz9A== Date: Sat, 6 Apr 2024 20:54:17 +0200 From: Andi Shyti To: Jonathan Cameron Cc: Andy Shevchenko , Nuno =?utf-8?B?U8Oh?= , Nuno Sa , Petr Mladek , Lars-Peter Clausen , Olivier Moysan , Jyoti Bhayana , Chris Down , John Ogness , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Subject: Re: [PATCH 3/4] iio: backend: make use of dev_errp_probe() Message-ID: <7ejh2r6zcripnptn3nbw2sa3mlfyleg4qg74rryxlut3fysneg@kuqwo5z2l65n> References: <20240404-dev-add_dev_errp_probe-v1-0-d18e3eb7ec3f@analog.com> <20240404-dev-add_dev_errp_probe-v1-3-d18e3eb7ec3f@analog.com> <9f91388faee750e16021f2c0544e7a158a16202b.camel@gmail.com> <20240406170717.31ab7e47@jic23-huawei> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240406170717.31ab7e47@jic23-huawei> Hi, On Sat, Apr 06, 2024 at 05:07:17PM +0100, Jonathan Cameron wrote: > On Thu, 4 Apr 2024 18:12:25 +0300 > Andy Shevchenko wrote: > > > On Thu, Apr 04, 2024 at 04:58:27PM +0200, Nuno S? wrote: > > > On Thu, 2024-04-04 at 15:23 +0300, Andy Shevchenko wrote: > > > > On Thu, Apr 04, 2024 at 01:06:25PM +0200, Nuno Sa wrote: > > > > > Using dev_errp_probe() to simplify the code. > > > > ... > > > > > > > + if (IS_ERR(fwnode)) > > > > > + return dev_errp_probe(dev, PTR_ERR(fwnode), > > > > > + ????? "Cannot get Firmware reference\n"); > > > > > > > > ERR_CAST() seems quite good candidate to have here. > > > > > > > > return dev_errp_probe(dev, fwnode, "Cannot get Firmware > > > > reference\n"); > > > > > > > > (Assuming dev_errp_probe() magically understands that, note you may have it as > > > > ?a macro and distinguish parameter type with _Generic() or so and behave > > > > ?differently: ERR_PTR() vs. ERR_CAST(), see acpi_dev_hid_uid_match() > > > > ?implementation, but also keep in mind that it doesn't distinguish NULL/0, > > > > there > > > > ?is a patch available in the mailing list to fix that, though.) > > > > > > Do we care that much for going with that trouble? > > > > I don't think we do. We are not supposed to be called with ret == 0/NULL. > > That's why I pointed out to the current version. > > > > > I understand like this we go > > > PTR_ERR() to then comeback to ERR_PTR() but this for probe() which is not a > > > fastpath. So perhaps we could just keep it simple? > > > > It's not about performance, it's about readability. See the difference between > > yours and mine. > > > > You are suggesting making it transparently take an error ptr or an integer? > Whilst clever, I'm not seeing that as a good idea for readability / reviewability. > I expect something that looks like a function to take the same parameters (other vargs) > always. _Generic messes with that. > > Maybe I just don't like to learn new things! If consensus comes down in favour > of _Generic trickery then I'll get used to it eventually. the whole point of the dev_err_...() functions is to add trickery in order to reduce code and brackets. The way I see this is to have a combination of functions: - takes integer, returns integer -> dev_err_probe() - takes integer, returns pointer -> dev_errp_probe() (or dev_err_ptr_probe()) - takes pointer, return integer -> ? dev_ptr_err_probe() - takes pointer, returns pointer -> ? dev_ptr_probe() Thoughts? Andi