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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42675C04A6A for ; Tue, 8 Aug 2023 17:28:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234559AbjHHR2i (ORCPT ); Tue, 8 Aug 2023 13:28:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234537AbjHHR2J (ORCPT ); Tue, 8 Aug 2023 13:28:09 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B08120D31; Tue, 8 Aug 2023 09:12:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691511129; x=1723047129; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=a5Pu3te7+j3RrMvIgzbzB1S8YTDD+wuRl/+kr86b66k=; b=aBP+M7ABiZJCUQs7jUGR34jdzHc+a8fI8LAXlKnMyFWCK8jHEgI+nxf9 4aBl9t+Ys7bUSw1soiWAG+s1WO14AuyZWzXwPJQ0vzFLEgIDJxh419uln 70Kg+RVEeDwJ9pCXvWuEeOyZfKkBc7MZlIcM+txcwudriZXiFx7FIMc7i z6i/Ymbp17Ym/4OD9rFHA5ZnE01mTytc1SickX0X4oI711noaR9QH5hPc qL8ndxI1W15wYhziU33UQhhGQbtZDe6DEq5af/0ETg0DG8LtGKg++uH5B Hw4LsR49smx0/QDhb3m1k6kv3w9LbpnChpJAaIlpa4YFDmrUN96UYxm+l g==; X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="355767105" X-IronPort-AV: E=Sophos;i="6.01,156,1684825200"; d="scan'208";a="355767105" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Aug 2023 07:08:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="845490938" X-IronPort-AV: E=Sophos;i="6.01,156,1684825200"; d="scan'208";a="845490938" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga002.fm.intel.com with ESMTP; 08 Aug 2023 07:08:07 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qTNNV-00B7YT-1f; Tue, 08 Aug 2023 17:08:05 +0300 Date: Tue, 8 Aug 2023 17:08:05 +0300 From: Andy Shevchenko To: Marcus Folkesson Cc: Kent Gustavsson , Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Cosmin Tanislav , Arnd Bergmann , ChiYuan Huang , Haibo Chen , Ramona Bolboaca , Ibrahim Tilki , ChiaEn Wu , William Breathitt Gray , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 2/4] iio: adc: mcp3911: simplify usage of spi->dev in probe function Message-ID: References: <20230808110432.240773-1-marcus.folkesson@gmail.com> <20230808110432.240773-2-marcus.folkesson@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230808110432.240773-2-marcus.folkesson@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 08, 2023 at 01:04:30PM +0200, Marcus Folkesson wrote: > Replace the usage of adc->spi->dev with spi->dev to make the code prettier. Suggested-by: ? > Signed-off-by: Marcus Folkesson ... > - adc->vref = devm_regulator_get_optional(&adc->spi->dev, "vref"); > + adc->vref = devm_regulator_get_optional(&spi->dev, "vref"); Why not struct device *dev = &spi->dev; and all the rest accordingly? > if (IS_ERR(adc->vref)) { > if (PTR_ERR(adc->vref) == -ENODEV) { > adc->vref = NULL; > } else { > - dev_err(&adc->spi->dev, > + dev_err(&spi->dev, > "failed to get regulator (%ld)\n", > PTR_ERR(adc->vref)); > return PTR_ERR(adc->vref); Actually, you may first to switch to dev_err_probe() with the above introduced struct device *dev = &spi->dev; ... return dev_err_probe(dev, PTR_ERR(adc->vref), "failed to get regulator\n", and in the second patch do what you are doing here. Will be much less changes and neater code at the end. -- With Best Regards, Andy Shevchenko