From: Bjorn Helgaas <helgaas@kernel.org>
To: Andy Shevchenko <andy@kernel.org>
Cc: Vaibhav Gupta <vaibhavgupta40@gmail.com>,
linux-gpio@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>
Subject: [PATCH 2/5] gpio: pch: Cache &pdev->dev to reduce repetition
Date: Tue, 30 Nov 2021 16:08:38 -0600 [thread overview]
Message-ID: <20211130220841.2776562-3-helgaas@kernel.org> (raw)
In-Reply-To: <20211130220841.2776562-1-helgaas@kernel.org>
From: Bjorn Helgaas <bhelgaas@google.com>
pch_gpio_probe() repeats the "&pdev->dev" expression several times. Cache
the result as "struct device *dev" to reduce the repetition. No functional
change intended.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/gpio/gpio-pch.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/gpio/gpio-pch.c b/drivers/gpio/gpio-pch.c
index 625920421990..3a0bd8795741 100644
--- a/drivers/gpio/gpio-pch.c
+++ b/drivers/gpio/gpio-pch.c
@@ -346,24 +346,25 @@ static int pch_gpio_alloc_generic_chip(struct pch_gpio *chip,
static int pch_gpio_probe(struct pci_dev *pdev,
const struct pci_device_id *id)
{
+ struct device *dev = &pdev->dev;
s32 ret;
struct pch_gpio *chip;
int irq_base;
- chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
+ chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
if (chip == NULL)
return -ENOMEM;
- chip->dev = &pdev->dev;
+ chip->dev = dev;
ret = pcim_enable_device(pdev);
if (ret) {
- dev_err(&pdev->dev, "pci_enable_device FAILED");
+ dev_err(dev, "pci_enable_device FAILED");
return ret;
}
ret = pcim_iomap_regions(pdev, BIT(1), KBUILD_MODNAME);
if (ret) {
- dev_err(&pdev->dev, "pci_request_regions FAILED-%d", ret);
+ dev_err(dev, "pci_request_regions FAILED-%d", ret);
return ret;
}
@@ -374,16 +375,16 @@ static int pch_gpio_probe(struct pci_dev *pdev,
spin_lock_init(&chip->spinlock);
pch_gpio_setup(chip);
- ret = devm_gpiochip_add_data(&pdev->dev, &chip->gpio, chip);
+ ret = devm_gpiochip_add_data(dev, &chip->gpio, chip);
if (ret) {
- dev_err(&pdev->dev, "PCH gpio: Failed to register GPIO\n");
+ dev_err(dev, "PCH gpio: Failed to register GPIO\n");
return ret;
}
- irq_base = devm_irq_alloc_descs(&pdev->dev, -1, 0,
+ irq_base = devm_irq_alloc_descs(dev, -1, 0,
gpio_pins[chip->ioh], NUMA_NO_NODE);
if (irq_base < 0) {
- dev_warn(&pdev->dev, "PCH gpio: Failed to get IRQ base num\n");
+ dev_warn(dev, "PCH gpio: Failed to get IRQ base num\n");
chip->irq_base = -1;
return 0;
}
@@ -393,10 +394,10 @@ static int pch_gpio_probe(struct pci_dev *pdev,
iowrite32(BIT(gpio_pins[chip->ioh]) - 1, &chip->reg->imask);
iowrite32(BIT(gpio_pins[chip->ioh]) - 1, &chip->reg->ien);
- ret = devm_request_irq(&pdev->dev, pdev->irq, pch_gpio_handler,
+ ret = devm_request_irq(dev, pdev->irq, pch_gpio_handler,
IRQF_SHARED, KBUILD_MODNAME, chip);
if (ret) {
- dev_err(&pdev->dev, "request_irq failed\n");
+ dev_err(dev, "request_irq failed\n");
return ret;
}
--
2.25.1
next prev parent reply other threads:[~2021-11-30 22:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-30 22:08 [PATCH 0/5] GPIO PCH/ML-IOH consolidation baby steps Bjorn Helgaas
2021-11-30 22:08 ` [PATCH 1/5] gpio: pch: Use .driver_data instead of checking Device IDs again Bjorn Helgaas
2021-11-30 22:08 ` Bjorn Helgaas [this message]
2021-11-30 22:08 ` [PATCH 3/5] gpio: ml-ioh: Cache &pdev->dev to reduce repetition Bjorn Helgaas
2021-11-30 22:08 ` [PATCH 4/5] gpio: ml-ioh: Use BIT() to match gpio-pch.c Bjorn Helgaas
2021-11-30 22:08 ` [PATCH 5/5] gpio: ml-ioh: Change whitespace " Bjorn Helgaas
2021-12-01 13:08 ` [PATCH 0/5] GPIO PCH/ML-IOH consolidation baby steps Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211130220841.2776562-3-helgaas@kernel.org \
--to=helgaas@kernel.org \
--cc=andy@kernel.org \
--cc=bhelgaas@google.com \
--cc=linux-gpio@vger.kernel.org \
--cc=vaibhavgupta40@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).