Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1405302ybn; Wed, 25 Sep 2019 17:53:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaLceoKyoog4fJb7S3eQH1ovHHaxqPWcEBf7tA33C77+3zJKaSLDla/unUdqmVgVfb67Ca X-Received: by 2002:a50:f0db:: with SMTP id a27mr864032edm.17.1569459234208; Wed, 25 Sep 2019 17:53:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569459234; cv=none; d=google.com; s=arc-20160816; b=Wk6ctY+MtFCAiJjhpJDRgHnzP3ANzt0VilNe1hzjOryhkkuHnpyOqBLWarfWMLfD58 sRHUOlufq4tnuVDuRfnAVLMm+HpMoFhabh9SMg/8ZG7P4n3sk7Kjo+YcT+f0DezTEiwA oT6xLVMM5xYPgCzXb2nTowU/8AxmwPz4NStZjfikrbaWXaHCe2Gh2hE3hS+FpY5YZUqd d8S0qtX0ZY0jkhbaTQ1a/+R9ymT40mvBa44nInk5wyhNj1iTOQDLJ2xphSYjq6I7uWfz 4Nc7fodAXPZAFhIOJSMEr8nPUrR327iVWkHht2CizzAhD9TV82oOAO31ldGQPGVEfgrc dhzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=D0JwVV0SN0ksnpP3yqoschsLhQVQMNo5u7ySzLUo7CM=; b=XxNhh79Fax6h2zNOImY/Hzz4IZ5w8S0YcG7JE3FlpyX6ir7N5MMsi2te3ahtOqpDGV WkK3QG56JCdr7DqI7z9cAkwC00G4BreQN8SGWXRuDYCAZEQ7lK/EO/A4DwwiFTmNHODl xUBG+xLQ8XmUzDcngboK2JrRgYZM6cfE43zSE80tJfptvtquQPlrdI90f77Qq2FB0zcM ZHgsAxGORLx+mzYQi/wKhY9APXqpICBZRqG5Irv8RGw3DGLxoguxJD3EtxNSgwRLVqiZ nHVWggYnOEQ+U8KPv4o0EOtyfa3vnrkEO4B0IQIdwIXWHskND9Rujxv/a7n/FoinraPr n85A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hh9si234818ejb.313.2019.09.25.17.53.30; Wed, 25 Sep 2019 17:53:54 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733152AbfIXJF7 (ORCPT + 99 others); Tue, 24 Sep 2019 05:05:59 -0400 Received: from inva020.nxp.com ([92.121.34.13]:38736 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729641AbfIXJF7 (ORCPT ); Tue, 24 Sep 2019 05:05:59 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id F37031A0274; Tue, 24 Sep 2019 11:05:56 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id BDC021A0169; Tue, 24 Sep 2019 11:05:51 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id C4E4C402B4; Tue, 24 Sep 2019 17:05:45 +0800 (SGT) From: Anson Huang To: dmitry.torokhov@gmail.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, swboyd@chromium.org, mojha@codeaurora.org, linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Linux-imx@nxp.com Subject: [PATCH] input: keyboard: imx_keypad: Use 'dev' instead of dereferencing it repeatedly Date: Tue, 24 Sep 2019 17:04:19 +0800 Message-Id: <1569315859-7046-1-git-send-email-Anson.Huang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add helper variable dev = &pdev->dev to simply the code. Signed-off-by: Anson Huang --- drivers/input/keyboard/imx_keypad.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c index 5a46d11..3024d2a 100644 --- a/drivers/input/keyboard/imx_keypad.c +++ b/drivers/input/keyboard/imx_keypad.c @@ -418,14 +418,15 @@ MODULE_DEVICE_TABLE(of, imx_keypad_of_match); static int imx_keypad_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; const struct matrix_keymap_data *keymap_data = - dev_get_platdata(&pdev->dev); + dev_get_platdata(dev); struct imx_keypad *keypad; struct input_dev *input_dev; int irq, error, i, row, col; - if (!keymap_data && !pdev->dev.of_node) { - dev_err(&pdev->dev, "no keymap defined\n"); + if (!keymap_data && !dev->of_node) { + dev_err(dev, "no keymap defined\n"); return -EINVAL; } @@ -433,15 +434,15 @@ static int imx_keypad_probe(struct platform_device *pdev) if (irq < 0) return irq; - input_dev = devm_input_allocate_device(&pdev->dev); + input_dev = devm_input_allocate_device(dev); if (!input_dev) { - dev_err(&pdev->dev, "failed to allocate the input device\n"); + dev_err(dev, "failed to allocate the input device\n"); return -ENOMEM; } - keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad), GFP_KERNEL); + keypad = devm_kzalloc(dev, sizeof(*keypad), GFP_KERNEL); if (!keypad) { - dev_err(&pdev->dev, "not enough memory for driver data\n"); + dev_err(dev, "not enough memory for driver data\n"); return -ENOMEM; } @@ -456,16 +457,16 @@ static int imx_keypad_probe(struct platform_device *pdev) if (IS_ERR(keypad->mmio_base)) return PTR_ERR(keypad->mmio_base); - keypad->clk = devm_clk_get(&pdev->dev, NULL); + keypad->clk = devm_clk_get(dev, NULL); if (IS_ERR(keypad->clk)) { - dev_err(&pdev->dev, "failed to get keypad clock\n"); + dev_err(dev, "failed to get keypad clock\n"); return PTR_ERR(keypad->clk); } /* Init the Input device */ input_dev->name = pdev->name; input_dev->id.bustype = BUS_HOST; - input_dev->dev.parent = &pdev->dev; + input_dev->dev.parent = dev; input_dev->open = imx_keypad_open; input_dev->close = imx_keypad_close; @@ -474,7 +475,7 @@ static int imx_keypad_probe(struct platform_device *pdev) MAX_MATRIX_KEY_COLS, keypad->keycodes, input_dev); if (error) { - dev_err(&pdev->dev, "failed to build keymap\n"); + dev_err(dev, "failed to build keymap\n"); return error; } @@ -488,8 +489,8 @@ static int imx_keypad_probe(struct platform_device *pdev) } } } - dev_dbg(&pdev->dev, "enabled rows mask: %x\n", keypad->rows_en_mask); - dev_dbg(&pdev->dev, "enabled cols mask: %x\n", keypad->cols_en_mask); + dev_dbg(dev, "enabled rows mask: %x\n", keypad->rows_en_mask); + dev_dbg(dev, "enabled cols mask: %x\n", keypad->cols_en_mask); __set_bit(EV_REP, input_dev->evbit); input_set_capability(input_dev, EV_MSC, MSC_SCAN); @@ -502,22 +503,22 @@ static int imx_keypad_probe(struct platform_device *pdev) imx_keypad_inhibit(keypad); clk_disable_unprepare(keypad->clk); - error = devm_request_irq(&pdev->dev, irq, imx_keypad_irq_handler, 0, + error = devm_request_irq(dev, irq, imx_keypad_irq_handler, 0, pdev->name, keypad); if (error) { - dev_err(&pdev->dev, "failed to request IRQ\n"); + dev_err(dev, "failed to request IRQ\n"); return error; } /* Register the input device */ error = input_register_device(input_dev); if (error) { - dev_err(&pdev->dev, "failed to register input device\n"); + dev_err(dev, "failed to register input device\n"); return error; } platform_set_drvdata(pdev, keypad); - device_init_wakeup(&pdev->dev, 1); + device_init_wakeup(dev, 1); return 0; } -- 2.7.4