Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp868273pxb; Thu, 19 Nov 2020 16:16:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTFK5DePzW4pphhnZjG+tcAnAkKIZjV3+nVW4bvvMJ3mC+vuWc99Z2vfv12RBuylKXJ0g3 X-Received: by 2002:a17:906:a011:: with SMTP id p17mr31189103ejy.119.1605831413381; Thu, 19 Nov 2020 16:16:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605831413; cv=none; d=google.com; s=arc-20160816; b=yavlFEixXtXCK1TZqH5Grn2Mu7PQsjmwWAO/PQRO8oKKOwJUP2hgmda4vJIFyG3ERk 6Aow+UjBG7VeCUNHYeKcg8DowXasCjSmxrW4YMoOKjLIyCQiYwm+iYh/KwKI1A6SkOuK jhSGbOZk2AGfMNweEvIAuJCu2v8+42HNyZCD006cZoGaUZ45IflJKuskZN+hVkMqkh80 y6sqq7PS7rcf/2kdxsigXpy7J0E3T7WVfz1bSUR3nP+/S5X5KByt4JZf5K7eEKW6E+Kb Dldj1QIqnED1QtmwaVy+SecYNn6omOeGrJTF+ALvjjKfkQ60fkFwJT52xULw+fGSBLr+ kosQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=P5OhYmBegv8LFJMPiSgDQn820vqmFK8lV/b8jJC6wcs=; b=JRlGfpeTGBELKtI3pDLBVcDEqRS+e+a0f99utx8ZhXozhRx5fSQ1pSwNgCgJjYBv2B dpPaHvwrUD0fSviRFtXDP8nlozZ5gmbj4yrvwE97+w2DeCMNHU/QhkbMtTtcM5SmV/Cy nPu1ssT+/TltJ67fialtwS5RpVf9XYJG0+kp1YFbnRnXP5foSgvWMQU2kvv1jt9c0t1M XkU3xQRCQg7vl0fqITCbt74T0qIw2DccD60CZOYEIKoUHp0RAFhb6bky0Qv3Na/vcpf9 9xnM73MvGCZRIL8qEu/E9Sn6cTw9EKxiQ0N7I/tssQiSg2Kti7yet6J5RmSI+1a38ajt poFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gz19si799353ejb.18.2020.11.19.16.16.29; Thu, 19 Nov 2020 16:16:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727114AbgKTALR (ORCPT + 99 others); Thu, 19 Nov 2020 19:11:17 -0500 Received: from smtprelay0096.hostedemail.com ([216.40.44.96]:35014 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726913AbgKTALQ (ORCPT ); Thu, 19 Nov 2020 19:11:16 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id 126B1837F24F; Fri, 20 Nov 2020 00:11:14 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:355:379:599:800:960:968:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1431:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2553:2559:2562:2828:2892:2901:3138:3139:3140:3141:3142:3354:3622:3743:3865:3867:3868:3870:3871:3872:3874:4250:4321:5007:6119:6121:7514:7903:8660:9010:10004:10400:10848:11026:11232:11658:11914:12295:12297:12663:12740:12760:12895:13069:13148:13230:13255:13311:13357:13439:14096:14097:14180:14181:14659:14721:21067:21080:21212:21433:21627:21939:30012:30054:30070:30075:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: toy75_2e0778727347 X-Filterd-Recvd-Size: 2707 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf11.hostedemail.com (Postfix) with ESMTPA; Fri, 20 Nov 2020 00:11:12 +0000 (UTC) Message-ID: Subject: Re: Proposal for a new checkpatch check; matching _set_drvdata() & _get_drvdata() From: Joe Perches To: Andy Shevchenko , Alexandru Ardelean Cc: Robo Bot , LKML , Alexandru Ardelean , Julia Lawall , cocci Date: Thu, 19 Nov 2020 16:11:11 -0800 In-Reply-To: References: Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2020-11-19 at 17:16 +0200, Andy Shevchenko wrote: > On Thu, Nov 19, 2020 at 4:09 PM Alexandru Ardelean > wrote: > > > > Hey, > > > > So, I stumbled on a new check that could be added to checkpatch. > > Since it's in Perl, I'm reluctant to try it. > > > > Seems many drivers got to a point where they now call (let's say) > > spi_set_drvdata(), but never access that information via > > spi_get_drvdata(). > > Reasons for this seem to be: > > 1. They got converted to device-managed functions and there is no > > longer a remove hook to require the _get_drvdata() access > > 2. They look like they were copied from a driver that had a > > _set_drvdata() and when the code got finalized, the _set_drvdata() was > > omitted > > > > There are a few false positives that I can notice at a quick look, > > like the data being set via some xxx_set_drvdata() and retrieved via a > > dev_get_drvdata(). > > I can say quite a few. And this makes a difference. > So, basically all drivers that are using PM callbacks would rather use > dev_get_drvdata() rather than bus specific. > > > I think checkpatch reporting these as well would be acceptable simply > > from a reviewability perspective. > > > > I did a shell script to quickly check these. See below. > > It's pretty badly written but it is enough for me to gather a list. > > And I wrote it in 5 minutes :P > > I initially noticed this in some IIO drivers, and then I suspected > > that this may be more widespread. > > It seems more suitable for coccinelle. To me as well.