Re: [PATCH V3 2/3] gpio: gpio-pmic-eic-sprd: Make the irqchip immutable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 12/28/2022 8:24 PM, Cixi Geng wrote:
From: Cixi Geng <cixi.geng1@xxxxxxxxxx>

Remove the irq_chip from pmic_eic structure,
use the various calls by defining the statically
irq_chip structure.

Signed-off-by: Cixi Geng <cixi.geng1@xxxxxxxxxx>
---
  drivers/gpio/gpio-pmic-eic-sprd.c | 29 ++++++++++++++++++-----------
  1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-pmic-eic-sprd.c b/drivers/gpio/gpio-pmic-eic-sprd.c
index e518490c4b68..add15416f7a6 100644
--- a/drivers/gpio/gpio-pmic-eic-sprd.c
+++ b/drivers/gpio/gpio-pmic-eic-sprd.c
@@ -47,7 +47,6 @@ enum {
  /**
   * struct sprd_pmic_eic - PMIC EIC controller
   * @chip: the gpio_chip structure.
- * @intc: the irq_chip structure.
   * @map:  the regmap from the parent device.
   * @offset: the EIC controller's offset address of the PMIC.
   * @reg: the array to cache the EIC registers.
@@ -56,7 +55,6 @@ enum {
   */
  struct sprd_pmic_eic {
  	struct gpio_chip chip;
-	struct irq_chip intc;
  	struct regmap *map;
  	u32 offset;
  	u8 reg[CACHE_NR_REGS];
@@ -151,15 +149,21 @@ static void sprd_pmic_eic_irq_mask(struct irq_data *data)
  {
  	struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
  	struct sprd_pmic_eic *pmic_eic = gpiochip_get_data(chip);
+	irq_hw_number_t hwirq = irqd_to_hwirq(data);

Please keep the same coding style in this driver:
u32 offset = irqd_to_hwirq(data);

pmic_eic->reg[REG_IE] = 0;
  	pmic_eic->reg[REG_TRIG] = 0;
+
+	gpiochip_disable_irq(chip, hwirq);
  }
static void sprd_pmic_eic_irq_unmask(struct irq_data *data)
  {
  	struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
  	struct sprd_pmic_eic *pmic_eic = gpiochip_get_data(chip);
+	irq_hw_number_t hwirq = irqd_to_hwirq(data);

Ditto

+
+	gpiochip_enable_irq(chip, hwirq);
pmic_eic->reg[REG_IE] = 1;
  	pmic_eic->reg[REG_TRIG] = 1;
@@ -292,6 +296,17 @@ static irqreturn_t sprd_pmic_eic_irq_handler(int irq, void *data)
  	return IRQ_HANDLED;
  }
+static const struct irq_chip pmic_eic_irq_chip = {
+	.name			= "sprd-pmic-eic-gpio",

Should be 'sprd-pmic-eic'.

With above fixes, you can add
Reviewed-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>

+	.irq_mask		= sprd_pmic_eic_irq_mask,
+	.irq_unmask		= sprd_pmic_eic_irq_unmask,
+	.irq_set_type		= sprd_pmic_eic_irq_set_type,
+	.irq_bus_lock		= sprd_pmic_eic_bus_lock,
+	.irq_bus_sync_unlock	= sprd_pmic_eic_bus_sync_unlock,
+	.flags			= IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE,
+	GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
  static int sprd_pmic_eic_probe(struct platform_device *pdev)
  {
  	struct gpio_irq_chip *irq;
@@ -338,16 +353,8 @@ static int sprd_pmic_eic_probe(struct platform_device *pdev)
  	pmic_eic->chip.set = sprd_pmic_eic_set;
  	pmic_eic->chip.get = sprd_pmic_eic_get;
- pmic_eic->intc.name = dev_name(&pdev->dev);
-	pmic_eic->intc.irq_mask = sprd_pmic_eic_irq_mask;
-	pmic_eic->intc.irq_unmask = sprd_pmic_eic_irq_unmask;
-	pmic_eic->intc.irq_set_type = sprd_pmic_eic_irq_set_type;
-	pmic_eic->intc.irq_bus_lock = sprd_pmic_eic_bus_lock;
-	pmic_eic->intc.irq_bus_sync_unlock = sprd_pmic_eic_bus_sync_unlock;
-	pmic_eic->intc.flags = IRQCHIP_SKIP_SET_WAKE;
-
  	irq = &pmic_eic->chip.irq;
-	irq->chip = &pmic_eic->intc;
+	gpio_irq_chip_set_chip(irq, &pmic_eic_irq_chip);
  	irq->threaded = true;
ret = devm_gpiochip_add_data(&pdev->dev, &pmic_eic->chip, pmic_eic);



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux