From patchwork Tue Oct 25 19:23:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9395271 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 94B7B60233 for ; Tue, 25 Oct 2016 19:24:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5F962972E for ; Tue, 25 Oct 2016 19:24:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAAE929731; Tue, 25 Oct 2016 19:24:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CEF22972E for ; Tue, 25 Oct 2016 19:24:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932538AbcJYTYR (ORCPT ); Tue, 25 Oct 2016 15:24:17 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36391 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752488AbcJYTYP (ORCPT ); Tue, 25 Oct 2016 15:24:15 -0400 Received: by mail-wm0-f66.google.com with SMTP id c78so1922429wme.3 for ; Tue, 25 Oct 2016 12:24:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=xgP6i2Kgv+aia2FIwDaPyFTmddesK4gNLO0XIoKqWDU=; b=Twz+Go79RnaiyD/Y3sYtRt1+cEoDou+0thrZb+7R4wzpfDaTtlmA3e3TP0xjMG8VOT mTrv5IL1z2sAgm2ZAYvHjgYNnLH4Mu95hbUFUqJSao1exJqxIf/3ChDcljuxxpS3N+2J oLhym1ruj0j/2FawHnrqqyJxBNFSMDoHfnhUP0E5YlqoCu0oMJURzRmcWvR+JogHEYyj 8V9CVJODHeMBh+5mUFnu1lAIC1HAWpEaXAoW3jKH9mdlZCg/vdHSBL1S8siYfVqF7gTo bel6hpavTWwmyy09rqF0uJBnhuuH2uuiK8KcMAHyJ6d3mDDrN1VZZzgDl1UXU4oJWmwK VW2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:references:cc:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=xgP6i2Kgv+aia2FIwDaPyFTmddesK4gNLO0XIoKqWDU=; b=BYxoVXs1nHhobA3aWT2LclKFKrcIdq1mA+1BEBJeH7DLmZhNErFzapgjHlHGuyrp8Y MypfyTvPdysqqdgPO0SW3ddT0CVLGs3h4/UJPX8u64ubr2ztqybwVrzZN4Bz9WaXXQcS hHOaOUQ8CVEFwof6EYH+gW0bUGdAWyTCtSmYjsvHO9WNRtRjSLTefAvluIxFVeVbdfey yCvzI5mAd6agAAju7arjfnp2tPMTMmV/MUBnHK9pwL0aJmr2dvbqBnUUdOQCcnQbL/lj QFZaRQVK4Ysn5TOW6ij0yfczWa+WJ/rv8QQTmXxLPM6JujJ/96DyuYqIkP9d8a3VRXdD T0Wg== X-Gm-Message-State: ABUngvcUrxTVqVT6QVtOhDYSoBkB3rd5PpfcMsMm5oP8ggQqd7j7b7GU4ADVuiuFGWVp+w== X-Received: by 10.194.115.135 with SMTP id jo7mr18015445wjb.21.1477423453576; Tue, 25 Oct 2016 12:24:13 -0700 (PDT) Received: from ?IPv6:2003:62:5f6e:ba00:954e:ed47:430f:d580? (p200300625F6EBA00954EED47430FD580.dip0.t-ipconnect.de. [2003:62:5f6e:ba00:954e:ed47:430f:d580]) by smtp.googlemail.com with ESMTPSA id m194sm5288013wmg.11.2016.10.25.12.24.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Oct 2016 12:24:13 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH 2/5] media: rc: nuvoton: eliminate member pdev from struct nvt_dev To: Mauro Carvalho Chehab References: Cc: linux-media@vger.kernel.org Message-ID: <924ec6d5-32b0-6de1-691f-9a907bfd6e90@gmail.com> Date: Tue, 25 Oct 2016 21:23:37 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Member pdev of struct nvt_dev is needed only to access &pdev->dev. We can get rid of this it by using rdev->dev.parent instead (both point to the same struct device). Setting rdev->dev.parent can be removed from the probe function as this is done by devm_rc_allocate_device now. Signed-off-by: Heiner Kallweit --- drivers/media/rc/nuvoton-cir.c | 27 ++++++++++++++------------- drivers/media/rc/nuvoton-cir.h | 1 - 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c index 37fce7b..a583066 100644 --- a/drivers/media/rc/nuvoton-cir.c +++ b/drivers/media/rc/nuvoton-cir.c @@ -48,6 +48,11 @@ static const struct nvt_chip nvt_chips[] = { { "NCT6779D", NVT_6779D }, }; +static inline struct device *nvt_get_dev(const struct nvt_dev *nvt) +{ + return nvt->rdev->dev.parent; +} + static inline bool is_w83667hg(struct nvt_dev *nvt) { return nvt->chip_ver == NVT_W83667HG; @@ -385,6 +390,7 @@ static inline const char *nvt_find_chip(struct nvt_dev *nvt, int id) /* detect hardware features */ static int nvt_hw_detect(struct nvt_dev *nvt) { + struct device *dev = nvt_get_dev(nvt); const char *chip_name; int chip_id; @@ -405,8 +411,7 @@ static int nvt_hw_detect(struct nvt_dev *nvt) chip_id = nvt->chip_major << 8 | nvt->chip_minor; if (chip_id == NVT_INVALID) { - dev_err(&nvt->pdev->dev, - "No device found on either EFM port\n"); + dev_err(dev, "No device found on either EFM port\n"); return -ENODEV; } @@ -414,12 +419,11 @@ static int nvt_hw_detect(struct nvt_dev *nvt) /* warn, but still let the driver load, if we don't know this chip */ if (!chip_name) - dev_warn(&nvt->pdev->dev, + dev_warn(dev, "unknown chip, id: 0x%02x 0x%02x, it may not work...", nvt->chip_major, nvt->chip_minor); else - dev_info(&nvt->pdev->dev, - "found %s or compatible: chip id: 0x%02x 0x%02x", + dev_info(dev, "found %s or compatible: chip id: 0x%02x 0x%02x", chip_name, nvt->chip_major, nvt->chip_minor); return 0; @@ -616,7 +620,7 @@ static u32 nvt_rx_carrier_detect(struct nvt_dev *nvt) duration *= SAMPLE_PERIOD; if (!count || !duration) { - dev_notice(&nvt->pdev->dev, + dev_notice(nvt_get_dev(nvt), "Unable to determine carrier! (c:%u, d:%u)", count, duration); return 0; @@ -781,7 +785,7 @@ static void nvt_process_rx_ir_data(struct nvt_dev *nvt) static void nvt_handle_rx_fifo_overrun(struct nvt_dev *nvt) { - dev_warn(&nvt->pdev->dev, "RX FIFO overrun detected, flushing data!"); + dev_warn(nvt_get_dev(nvt), "RX FIFO overrun detected, flushing data!"); nvt->pkts = 0; nvt_clear_cir_fifo(nvt); @@ -976,9 +980,10 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) return -ENOMEM; /* input device for IR remote (and tx) */ - rdev = devm_rc_allocate_device(&pdev->dev); - if (!rdev) + nvt->rdev = devm_rc_allocate_device(&pdev->dev); + if (!nvt->rdev) return -ENOMEM; + rdev = nvt->rdev; /* activate pnp device */ ret = pnp_activate_dev(pdev); @@ -1017,7 +1022,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) spin_lock_init(&nvt->tx.lock); pnp_set_drvdata(pdev, nvt); - nvt->pdev = pdev; init_waitqueue_head(&nvt->tx.queue); @@ -1050,7 +1054,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) rdev->input_id.vendor = PCI_VENDOR_ID_WINBOND2; rdev->input_id.product = nvt->chip_major; rdev->input_id.version = nvt->chip_minor; - rdev->dev.parent = &pdev->dev; rdev->driver_name = NVT_DRIVER_NAME; rdev->map_name = RC_MAP_RC6_MCE; rdev->timeout = MS_TO_NS(100); @@ -1062,8 +1065,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) /* tx bits */ rdev->tx_resolution = XYZ; #endif - nvt->rdev = rdev; - ret = devm_rc_register_device(&pdev->dev, rdev); if (ret) return ret; diff --git a/drivers/media/rc/nuvoton-cir.h b/drivers/media/rc/nuvoton-cir.h index acf735f..77102a9 100644 --- a/drivers/media/rc/nuvoton-cir.h +++ b/drivers/media/rc/nuvoton-cir.h @@ -78,7 +78,6 @@ struct nvt_chip { }; struct nvt_dev { - struct pnp_dev *pdev; struct rc_dev *rdev; spinlock_t nvt_lock;