2019-05-28 14:33:09

by Charles Keepax

[permalink] [raw]
Subject: [PATCH v3 1/6] i2c: core: Allow whole core to use i2c_dev_irq_from_resources

Remove the static from i2c_dev_irq_from _resources so that other parts
of the core code can use this helper function.

Signed-off-by: Charles Keepax <[email protected]>
---

No changes since v2.

Thanks,
Charles

drivers/i2c/i2c-core-base.c | 4 ++--
drivers/i2c/i2c-core.h | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index d389d4fb0623a..84bf11b25a120 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -687,8 +687,8 @@ static void i2c_dev_set_name(struct i2c_adapter *adap,
i2c_encode_flags_to_addr(client));
}

-static int i2c_dev_irq_from_resources(const struct resource *resources,
- unsigned int num_resources)
+int i2c_dev_irq_from_resources(const struct resource *resources,
+ unsigned int num_resources)
{
struct irq_data *irqd;
int i;
diff --git a/drivers/i2c/i2c-core.h b/drivers/i2c/i2c-core.h
index c88cfef813431..8f3a08dc73a25 100644
--- a/drivers/i2c/i2c-core.h
+++ b/drivers/i2c/i2c-core.h
@@ -28,6 +28,8 @@ extern struct list_head __i2c_board_list;
extern int __i2c_first_dynamic_bus_num;

int i2c_check_7bit_addr_validity_strict(unsigned short addr);
+int i2c_dev_irq_from_resources(const struct resource *resources,
+ unsigned int num_resources);

/*
* We only allow atomic transfers for very late communication, e.g. to send
--
2.11.0


2019-05-28 14:33:31

by Charles Keepax

[permalink] [raw]
Subject: [PATCH v3 6/6] i2c: core: Tidy up handling of init_irq

Only set init_irq during i2c_device_new and only handle client->irq on
the probe/remove paths.

Suggested-by: Benjamin Tissoires <[email protected]>
Signed-off-by: Charles Keepax <[email protected]>
---

No changes since v2.

Thanks,
Charles

drivers/i2c/i2c-core-base.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 684ea2665d994..6d4904cdf58ac 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -322,6 +322,8 @@ static int i2c_device_probe(struct device *dev)

driver = to_i2c_driver(dev->driver);

+ client->irq = client->init_irq;
+
if (!client->irq && !driver->disable_i2c_core_irq_mapping) {
int irq = -ENOENT;

@@ -432,7 +434,7 @@ static int i2c_device_remove(struct device *dev)
dev_pm_clear_wake_irq(&client->dev);
device_init_wakeup(&client->dev, false);

- client->irq = client->init_irq;
+ client->irq = 0;
if (client->flags & I2C_CLIENT_HOST_NOTIFY)
pm_runtime_put(&client->adapter->dev);

@@ -749,7 +751,6 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf
if (!client->init_irq)
client->init_irq = i2c_dev_irq_from_resources(info->resources,
info->num_resources);
- client->irq = client->init_irq;

strlcpy(client->name, info->type, sizeof(client->name));

--
2.11.0

2019-05-29 07:36:46

by Mika Westerberg

[permalink] [raw]
Subject: Re: [PATCH v3 1/6] i2c: core: Allow whole core to use i2c_dev_irq_from_resources

On Tue, May 28, 2019 at 03:28:55PM +0100, Charles Keepax wrote:
> Remove the static from i2c_dev_irq_from _resources so that other parts
> of the core code can use this helper function.
>
> Signed-off-by: Charles Keepax <[email protected]>

Reviewed-by: Mika Westerberg <[email protected]>

2019-05-29 07:46:42

by Mika Westerberg

[permalink] [raw]
Subject: Re: [PATCH v3 6/6] i2c: core: Tidy up handling of init_irq

On Tue, May 28, 2019 at 03:29:00PM +0100, Charles Keepax wrote:
> Only set init_irq during i2c_device_new and only handle client->irq on
> the probe/remove paths.
>
> Suggested-by: Benjamin Tissoires <[email protected]>
> Signed-off-by: Charles Keepax <[email protected]>

Reviewed-by: Mika Westerberg <[email protected]>