Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1492925ima; Sun, 21 Oct 2018 13:04:22 -0700 (PDT) X-Google-Smtp-Source: ACcGV60oWxuDVMwu0svkoD7hG08gnqZek2yinNsWFDiGSMs0tYCDxdwGgpdqCQCyU81xRlRfGQVq X-Received: by 2002:a63:4e4e:: with SMTP id o14-v6mr41286151pgl.181.1540152262712; Sun, 21 Oct 2018 13:04:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540152262; cv=none; d=google.com; s=arc-20160816; b=oFNufeklSjiHCD0JgwCwq4zgmsiodObIuNyxPHqHZX92WTHwqIJPhWHa+g7fDDsmoi +1xQYm5+1hn67BSA1s1cEt5ZkbTcVhvl0oLXtxhq9CubYAyH1gPlqZjAgy1GsQ0MSrT1 f+kdWiIveMoOCJdU+xTGBaiZ8ygQsJhnbqG4XNWeYbp5u2wajuNzySrIWEGGGEVQrvUy qfBuvJIhveO+/ALIwojODmLuG+ULprhRSE09HsfrXqsPBC0eEK/uwAfJqT8/7mK/ySky weVA0CdE9veyo3ZEpgSoWxo/Oac69qifjlSgiKuNFm3+1cTwRdzFSFfHaejTF2JQZrUm x1wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=AmxfBE1UodMSMpRibkJHgVb5iYZEzXEbmfGiup36qGQ=; b=YmcK+hyHNzFtp35PKgZo9NZNVe0MwRMzTKGLPcSldA+ibXYKlhfLjrpH9SyyaY55FY +eMV13xg1jaGaXbQpLNLLAbXcAXoFVUhDUpN+BDW18/FYglCBqjUzfElUoS4fq5VSfX3 MQeo0aqMk/C4LfhS6NWDJ6UukeqcYXPgBgyNf25dFnyciOT/JzsFhLrlwBrkwZMH2dyi 0d0xOL7I3MpuyNoxSgFHxEf6HFjTQFciZXLe34bPMm+LFhHQDUVN3BAKqlw2RHte7mhF zeQg7uu1fxJLC+6IusboQnjlNK242N7pkDROyw31UF7iMzVkAxzTIfso9Rq6O8obPyPh FY4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q16-v6si32374339pgb.266.2018.10.21.13.04.08; Sun, 21 Oct 2018 13:04:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728711AbeJVEQX (ORCPT + 99 others); Mon, 22 Oct 2018 00:16:23 -0400 Received: from sauhun.de ([88.99.104.3]:45930 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728644AbeJVEQW (ORCPT ); Mon, 22 Oct 2018 00:16:22 -0400 Received: from localhost (unknown [90.200.225.72]) by pokefinder.org (Postfix) with ESMTPSA id 6900E2E35C3; Sun, 21 Oct 2018 22:00:54 +0200 (CEST) From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Wolfram Sang , linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-rockchip@lists.infradead.org Subject: [PATCH 0/5] thermal: simplify getting .driver_data Date: Sun, 21 Oct 2018 22:00:47 +0200 Message-Id: <20181021200053.2194-1-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I got tired of fixing this in Renesas drivers manually, so I took the big hammer. Remove this cumbersome code pattern which got copy-pasted too much already: - struct platform_device *pdev = to_platform_device(dev); - struct ep93xx_keypad *keypad = platform_get_drvdata(pdev); + struct ep93xx_keypad *keypad = dev_get_drvdata(dev); A branch, tested by buildbot, can be found here: git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git coccinelle/get_drvdata I have been asked if it couldn't be done for dev_set_drvdata as well. I checked it and did not find one occasion where it could be simplified like this. Not much of a surprise because driver_data is usually set in probe() functions which access struct platform_device in many other ways. I am open for other comments, suggestions, too, of course. Here is the cocci-script I created: @@ struct device* d; identifier pdev; expression *ptr; @@ ( - struct platform_device *pdev = to_platform_device(d); | - struct platform_device *pdev; ... - pdev = to_platform_device(d); ) <... when != pdev - &pdev->dev + d ...> ptr = - platform_get_drvdata(pdev) + dev_get_drvdata(d) <... when != pdev - &pdev->dev + d ...> Kind regards, Wolfram Wolfram Sang (5): thermal: int340x_thermal: int3400_thermal: simplify getting .driver_data thermal: rockchip_thermal: simplify getting .driver_data thermal: spear_thermal: simplify getting .driver_data thermal: st: st_thermal: simplify getting .driver_data thermal: zx2967_thermal: simplify getting .driver_data drivers/thermal/int340x_thermal/int3400_thermal.c | 9 +++------ drivers/thermal/rockchip_thermal.c | 8 +++----- drivers/thermal/spear_thermal.c | 8 +++----- drivers/thermal/st/st_thermal.c | 6 ++---- drivers/thermal/zx2967_thermal.c | 6 ++---- 5 files changed, 13 insertions(+), 24 deletions(-) -- 2.19.0