Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp3425141rwb; Mon, 7 Aug 2023 13:22:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGPt8cUp6icqNSh8Ntaj/iPr94gH40jtr11HBz26mwGeLaaCzg9I4NcwLLQNsXjnjbGpQed X-Received: by 2002:a17:903:230b:b0:1bc:2c58:ad97 with SMTP id d11-20020a170903230b00b001bc2c58ad97mr12227155plh.22.1691439748160; Mon, 07 Aug 2023 13:22:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691439748; cv=none; d=google.com; s=arc-20160816; b=fun3w8A0bSHA+K8IQD7MCatCTrBLGaK5ADqPiPqo/8RCbvPPysAcAx6mPTv2bmw6qR JHehlm8Mjb41wMAGGdF1YGJAP7950c8eEHSGSII2QWYFEXzRSYnlzqORCKqe+oj9HXx4 i60A7wYtu9snUHcgZNIvnrrTYghEOEIdktEtO+7k2ypVYA5+fLSFZXPk+j9Xi+XN1yUy 126pb27EOGojNyUYoiNJbuhXiRdUZc8PqkpvwS0stplJ6f1TcDGl+aF7rx/1OkkG2Fv4 uX9dFRK0EQx9FIM1snnL2gaPMAm4GF9N93zgkPc0kh+nHcDUpo8S5OOmGh4zahSDi3pR K7hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=NBU7EPRLwc6/gHY+xkWa/hJWYuPQd2qbUXf7TBY4Q1E=; fh=n5mE8N3BaCHrSX41PWDBF3hKixoO9Ih0DBX97iUIs68=; b=fFYGNcBp4aRyBOGbwopO5d1hpKNJp3WX4+3WufCt+46iu+DgLgGoOsZPI+T+VZ22tg ww6pXXMIvaMohGQ1MTkzgSEGnHtXkbIA+bRvrcDBWaXq9wVv2zY80X4+92qxc/BXcVBL TuknU0Qr8VkmTI58ut9v6dgDEKTaDroGModO3r2u74ERMqn1yGf8vAPjkPQ0JnBXXS8e SXJxURaqDxuS1R/TKp1SRb0vaSMYMsvy7gm6BNwz7XIDIup222LPyY5GptLtz8uywsmF 7aSuaPFWGtFjP1aCJ19zbeb+EY/WUAsGL6wRMAC6PZ6DPPxdzkfPmdAj2xVGeAM4p2LV OeuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shruggie-ro.20221208.gappssmtp.com header.s=20221208 header.b=fkjXXDZt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kx16-20020a170902f95000b001ae4a01a7e0si6179901plb.236.2023.08.07.13.22.15; Mon, 07 Aug 2023 13:22:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@shruggie-ro.20221208.gappssmtp.com header.s=20221208 header.b=fkjXXDZt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231261AbjHGS63 (ORCPT + 99 others); Mon, 7 Aug 2023 14:58:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230271AbjHGS6Z (ORCPT ); Mon, 7 Aug 2023 14:58:25 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B70BB1FE0 for ; Mon, 7 Aug 2023 11:57:57 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-4fe1c285690so7504591e87.3 for ; Mon, 07 Aug 2023 11:57:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shruggie-ro.20221208.gappssmtp.com; s=20221208; t=1691434650; x=1692039450; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=NBU7EPRLwc6/gHY+xkWa/hJWYuPQd2qbUXf7TBY4Q1E=; b=fkjXXDZtNsAvIRJwZta1Ja7LoLnOgQJMSwyuKKZ8+v9i8n5myXhd2WMcXM9t1adFgf efAPaZwAdK6Ar/VW0znV01Y5IApm8lX2vtmga4PgsbBT8Ma90n7u2UABzzfiUAe36KQW xspOIC3bD3Q8fAM+DnkgiJbxpMOzkeQ+OiW7Ij71lX5F4XVwoNufjr5MewytV0mBspQq 4H+06CnfogkVGrG/S+8nY0hkWAGyTK42ToNFZklOuUkLX7E6Tk0Xz6dqbLm0CCfyjTXh ywcD4XsapyhDy49THBG7Zvifjh5iDiwwhgzSixz33VfQO9IdDtXdGIvypgS6FjXC+qRV pfHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691434650; x=1692039450; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NBU7EPRLwc6/gHY+xkWa/hJWYuPQd2qbUXf7TBY4Q1E=; b=fJLmgm1MVmP/4jiR2U0G7KX82PC3VPWGPBbf8FP9f9Aa4/td1Qd26HGssdqJYomHV5 5XrM1oeo6R3fJHi8ZxyGjHdzNL0MHGhP4VS8mK5j/1DA1/6fc6DRO0Iu+YoVIZwoNgsP s9bRHwlSoGlIozIpucu1pYiq4pYT3R3dh5yw0WwQvJskvx9OR7WFly0kRXqfOgGL5HNy AH44FxgMrgYRr9O0ECcZH5BAkio4dlNusBTBom0AhyS2EtP9BQt9QqHeBO0bhKchUtam 6xYqzWZU1bWzOkAA7r5Gnu5AUb5YeDKqDbCj+RMVuv7ttqdH9BfwDaf7xzVkaEIt/hpP dSbQ== X-Gm-Message-State: AOJu0YzRhBW/9cxr5AOq+zHfSEeKDPrLIfJ/3ZRphlZ3VjBePG8Yj0BY hJo0LScdHx5d1OWvBTaT3Zd23a2Y+PTb6zyi78ldcA== X-Received: by 2002:a05:6512:3b29:b0:4fd:faa5:64ed with SMTP id f41-20020a0565123b2900b004fdfaa564edmr8806125lfv.11.1691434649713; Mon, 07 Aug 2023 11:57:29 -0700 (PDT) MIME-Version: 1.0 References: <20230807130217.17853-1-aboutphysycs@gmail.com> <196642e7-4136-4ba6-a918-8c759f27f818@sirena.org.uk> In-Reply-To: <196642e7-4136-4ba6-a918-8c759f27f818@sirena.org.uk> From: Alexandru Ardelean Date: Mon, 7 Aug 2023 21:57:18 +0300 Message-ID: Subject: Re: [PATCH] spi: gxp: removed unneeded call to platform_set_drvdata() To: Mark Brown Cc: Andrei Coardos , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, nick.hawkins@hpe.com, verdun@hpe.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 7, 2023 at 9:18=E2=80=AFPM Mark Brown wrot= e: > > On Mon, Aug 07, 2023 at 08:38:27PM +0300, Alexandru Ardelean wrote: > > On Mon, Aug 7, 2023 at 4:27=E2=80=AFPM Mark Brown = wrote: > > > > On Mon, Aug 07, 2023 at 04:02:17PM +0300, Andrei Coardos wrote: > > > > > This function call was found to be unnecessary as there is no equiv= alent > > > > platform_get_drvdata() call to access the private data of the drive= r. Also, > > > > the private data is defined in this driver, so there is no risk of = it being > > > > accessed outside of this driver file. > > > > That isn't enough of a check here - people can still reference the > > > driver data without going through the accessor function. > > > So, is that like calling `platform_get_drvdata()` in a parent/chid > > device, to check if the driver-data is set? > > That wasn't what I was thinking of, waht I was thinking of was just open > coding platform_get_drvdata() and looking directly at struct device. Ah. Right. I hadn't thought of checking "dev->driver_data" access. > Another common case is where drivers that support multiple bus types > will pass around the struct device and use dev_get_drvdata() to read the Agree. I see that happening with PM routines. It doesn't look like it's the case in this driver. > data rather than using platform_get_drvdata(). The driver data can be > allocated and initialised with bus specific bits before being passed off > to the generic code. If I'm looking more closely, I am seeing that the "platform_set_drvdata(pdev, spifi);" has no equivalent access to "pdev->dev.driver_data" Nor by open-coding, nor by "dev_get_drvdata(&pdev->dev)" But I do see that "spi_controller_get_devdata()" is calling "dev_get_drvdata()" on a device object allocated here via "devm_spi_alloc_master()" So, I agree. That a more thorough check is needed here. > > That said the looking at the parent's driver data is definitely a thing > that happens with MFDs. Yep. MFDs is one case I was thinking of too (with respect to parent/child lookup of driver data).