irqchip/pruss-intc: Use match data directly
PATCH 1/2 irqchip/pruss-intc: Use match data directly
The match data is fetched before the instance data is available, but it is not used until after. Skip the temporary variable and fetch the match data after it has a place to be stored.
--- drivers/irqchip/irq-pruss-intc.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/irqchip/irq-pruss-intc.c +5 -8
@@ -516,24 +516,21 @@ static const char * const irq_names[MAX_NUM_HOST_IRQS] = {static int pruss_intc_probe (struct platform_device *pdev) { -const struct pruss_intc_match_data *data;struct device *dev = &pdev->dev;struct pruss_intc *intc;struct pruss_host_irq_data *host_data;int i, irq, ret;u8 max_system_events, irqs_reserved =0 ; - data =of_device_get_match_data (dev); -if (!data) -return -ENODEV ; - - max_system_events = data->num_system_events; - intc =devm_kzalloc (dev,sizeof (*intc),GFP_KERNEL );if (!intc)return -ENOMEM ; - intc->soc_config = data; + intc->soc_config =of_device_get_match_data (dev); +if (!intc->soc_config) +return -ENODEV ; + max_system_events = intc->soc_config->num_system_events; + intc->dev = dev;platform_set_drvdata (pdev, intc);
Signature · 1 line
2.39.2
PATCH 2/2 irqchip/pruss-intc: Use scoped lock guard and devm_mutex_init
Scoped locking simplifies the return path in a spot, and removes a couple lines in another couple spots. The devm mutex init will call mutex_destroy() for us on remove, which only really matters when CONFIG_DEBUG_MUTEXES is set, but it is nice to do anyway.
--- drivers/irqchip/irq-pruss-intc.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
drivers/irqchip/irq-pruss-intc.c +9 -16
@@ -181,7 +181,7 @@ static void pruss_intc_map(struct pruss_intc *intc, unsigned long hwirq)u8 ch, host, reg_idx;u32 val; -mutex_lock (&intc->lock); +guard (mutex)(&intc->lock); intc->event_channel[hwirq].ref_count++;
@@ -206,8 +206,6 @@ static void pruss_intc_map(struct pruss_intc *intc, unsigned long hwirq)dev_dbg (dev,"mapped system_event = %lu channel = %d host = %d" , hwirq, ch, host); - -mutex_unlock (&intc->lock); }/**
@@ -224,7 +222,7 @@ static void pruss_intc_unmap(struct pruss_intc *intc, unsigned long hwirq)u8 ch, host, reg_idx;u32 val; -mutex_lock (&intc->lock); +guard (mutex)(&intc->lock); ch = intc->event_channel[hwirq].value; host = intc->channel_host[ch].value;
@@ -251,8 +249,6 @@ static void pruss_intc_unmap(struct pruss_intc *intc, unsigned long hwirq)dev_dbg (intc->dev,"unmapped system_event = %lu channel = %d host = %d\n" , hwirq, ch, host); - -mutex_unlock (&intc->lock); }static void pruss_intc_init (struct pruss_intc *intc)
@@ -376,17 +372,15 @@ static int pruss_intc_validate_mapping(struct pruss_intc *intc, int event, int channel, int host) {struct device *dev = intc->dev; -int ret =0 ; -mutex_lock (&intc->lock); +guard (mutex)(&intc->lock);/* check if sysevent already assigned */ if (intc->event_channel[event].ref_count >0 && intc->event_channel[event].value != channel) {dev_err (dev,"event %d (req. ch %d) already assigned to channel %d\n" , event, channel, intc->event_channel[event].value); - ret = -EBUSY ; - goto unlock; +return -EBUSY ; }/* check if channel already assigned */
@@ -394,16 +388,13 @@ static int pruss_intc_validate_mapping(struct pruss_intc *intc, int event, intc->channel_host[channel].value != host) {dev_err (dev,"channel %d (req. host %d) already assigned to host %d\n" , channel, host, intc->channel_host[channel].value); - ret = -EBUSY ; - goto unlock; +return -EBUSY ; } intc->event_channel[event].value = channel; intc->channel_host[channel].value = host; -unlock: -mutex_unlock (&intc->lock); -return ret; +return 0 ; } static int
@@ -550,7 +541,9 @@ static int pruss_intc_probe(struct platform_device *pdev)pruss_intc_init (intc); -mutex_init (&intc->lock); + ret =devm_mutex_init (dev, &intc->lock); +if (ret) +return ret; intc->domain =irq_domain_create_linear (dev_fwnode (dev), max_system_events, &pruss_intc_irq_domain_ops, intc);
Signature · 1 line
2.39.2
Quoted 40 lines · Andrew Davis
The match data is fetched before the instance data is available, but it is not used until after. Skip the temporary variable and fetch the match data after it has a place to be stored.
Signed-off-by Andrew Davis <[email protected]>---
drivers/irqchip/irq-pruss-intc.c | 13 +++++--------1 file changed, 5 insertions(+), 8 deletions(-)drivers/irqchip/irq-pruss-intc.c +0
-0@@ -516,24 +516,21 @@ static const char * const irq_names[MAX_NUM_HOST_IRQS] = {
static intpruss_intc_probe(struct platform_device *pdev){drivers/irqchip/irq-pruss-intc.c +0
-1-const struct pruss_intc_match_data *data;struct device *dev =
&pdev->dev;
structpruss_intc*intc;
structpruss_host_irq_data*host_data;
int i, irq, ret;
u8max_system_events,irqs_reserved= 0;drivers/irqchip/irq-pruss-intc.c +0
-6- data =of_device_get_match_data (dev); -if (!data) -return -ENODEV ; - - max_system_events = data->num_system_events; -intc =
devm_kzalloc(dev, sizeof(*intc), GFP_KERNEL); if (!intc)
return-ENOMEM;drivers/irqchip/irq-pruss-intc.c +5
-1- intc->soc_config = data; + intc->soc_config =of_device_get_match_data (dev); +if (!intc->soc_config) +return -ENODEV ; + max_system_events = intc->soc_config->num_system_events; +
Quoted 3 lines
intc->dev= dev;
platform_set_drvdata(pdev, intc);
Re: [PATCH 2/2] irqchip/pruss-intc: Use scoped lock guard and devm_mutex_init
In reply to Andrew DavisQuoted 97 lines · Andrew Davis
Scoped locking simplifies the return path in a spot, and removes a couple lines in another couple spots. The devm mutex init will call
mutex_destroy()for us on remove, which only really matters whenCONFIG_DEBUG_MUTEXESis set, but it is nice to do anyway.Signed-off-by Andrew Davis <[email protected]>---
drivers/irqchip/irq-pruss-intc.c | 25 +++++++++----------------1 file changed, 9 insertions(+), 16 deletions(-)drivers/irqchip/irq-pruss-intc.c +0
-0@@ -181,7 +181,7 @@ static void pruss_intc_map(struct pruss_intc *intc, unsigned long hwirq) u8 ch, host, reg_idx; u32 val;drivers/irqchip/irq-pruss-intc.c +1
-1-mutex_lock (&intc->lock); +guard (mutex)(&intc->lock);
intc->event_channel[hwirq].ref_count++;drivers/irqchip/irq-pruss-intc.c +0
-0@@ -206,8 +206,6 @@ static void pruss_intc_map(struct pruss_intc *intc, unsigned long hwirq)
dev_dbg(dev, "mapped system_event = %lu channel = %d host = %d", hwirq, ch, host);drivers/irqchip/irq-pruss-intc.c +0
-2- -mutex_unlock (&intc->lock);}
/**drivers/irqchip/irq-pruss-intc.c +0
-0@@ -224,7 +222,7 @@ static void pruss_intc_unmap(struct pruss_intc *intc, unsigned long hwirq) u8 ch, host, reg_idx; u32 val;drivers/irqchip/irq-pruss-intc.c +1
-1-mutex_lock (&intc->lock); +guard (mutex)(&intc->lock);
ch = intc->event_channel[hwirq].value;
host = intc->channel_host[ch].value;drivers/irqchip/irq-pruss-intc.c +0
-0@@ -251,8 +249,6 @@ static void pruss_intc_unmap(struct pruss_intc *intc, unsigned long hwirq)
dev_dbg(intc->dev, "unmapped system_event = %lu channel = %d host = %d\n", hwirq, ch, host);drivers/irqchip/irq-pruss-intc.c +0
-2- -mutex_unlock (&intc->lock);}
static voidpruss_intc_init(struct pruss_intc *intc)drivers/irqchip/irq-pruss-intc.c +0
-1@@ -376,17 +372,15 @@ static int pruss_intc_validate_mapping(struct pruss_intc *intc, int event, int channel, int host) { struct device *dev = intc->dev; -int ret =0 ;drivers/irqchip/irq-pruss-intc.c +1
-1-mutex_lock (&intc->lock); +guard (mutex)(&intc->lock);
/* check if sysevent already assigned */
if (intc->event_channel[event].ref_count > 0 && intc->event_channel[event].value != channel) {
dev_err(dev, "event %d (req. ch %d) already assigned to channel %d\n", event, channel, intc->event_channel[event].value);drivers/irqchip/irq-pruss-intc.c +1
-2- ret = -EBUSY ; - goto unlock; +return -EBUSY ;}
/* check if channel already assigned */drivers/irqchip/irq-pruss-intc.c +1
-2@@ -394,16 +388,13 @@ static int pruss_intc_validate_mapping(struct pruss_intc *intc, int event, intc->channel_host[channel].value != host) { dev_err(dev, "channel %d (req. host %d) already assigned to host %d\n", channel, host, intc->channel_host[channel].value); - ret = -EBUSY ; - goto unlock; +return -EBUSY ; }
intc->event_channel[event].value = channel; intc->channel_host[channel].value = host;drivers/irqchip/irq-pruss-intc.c +1
-3-unlock: -mutex_unlock (&intc->lock); -return ret; +return 0 ;}
static intdrivers/irqchip/irq-pruss-intc.c +0
-0@@ -550,7 +541,9 @@ static int pruss_intc_probe(struct platform_device *pdev)
pruss_intc_init(intc);drivers/irqchip/irq-pruss-intc.c +3
-1-mutex_init (&intc->lock); + ret =devm_mutex_init (dev, &intc->lock); +if (ret) +return ret;
Quoted 3 lines
intc->domain=irq_domain_create_linear(dev_fwnode(dev), max_system_events, &pruss_intc_irq_domain_ops, intc);
[tip: irq/drivers] irqchip/pruss-intc: Use scoped lock guard and devm_mutex_init
In reply to Andrew DavisThe following commit has been merged into the irq/drivers branch of tip:
The following commit has been merged into the irq/drivers branch of tip:
Commit-ID: c23c3a1ec322f8bb9ed73bc1262d1083e76df23b Gitweb: https://git.kernel.org/tip/c23c3a1ec322f8bb9ed73bc1262d1083e76df23b Author: Andrew Davis <[email protected]> AuthorDate: Thu, 03 Sep 2026 13:52:20 -05:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Mon, 07 Sep 2026 21:47:51 +02:00
irqchip/pruss-intc: Use scoped lock guard and devm_mutex_init
Scoped locking simplifies the return path in a spot, and removes a couple lines in another couple spots. The devm mutex init will call mutex_destroy() for us on remove, which only really matters when CONFIG_DEBUG_MUTEXES is set, but it is nice to do anyway.
--- drivers/irqchip/irq-pruss-intc.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
drivers/irqchip/irq-pruss-intc.c +9 -16
@@ -181,7 +181,7 @@ static void pruss_intc_map(struct pruss_intc *intc, unsigned long hwirq)u8 ch, host, reg_idx;u32 val; -mutex_lock (&intc->lock); +guard (mutex)(&intc->lock); intc->event_channel[hwirq].ref_count++;
@@ -206,8 +206,6 @@ static void pruss_intc_map(struct pruss_intc *intc, unsigned long hwirq)dev_dbg (dev,"mapped system_event = %lu channel = %d host = %d" , hwirq, ch, host); - -mutex_unlock (&intc->lock); }/**
@@ -224,7 +222,7 @@ static void pruss_intc_unmap(struct pruss_intc *intc, unsigned long hwirq)u8 ch, host, reg_idx;u32 val; -mutex_lock (&intc->lock); +guard (mutex)(&intc->lock); ch = intc->event_channel[hwirq].value; host = intc->channel_host[ch].value;
@@ -251,8 +249,6 @@ static void pruss_intc_unmap(struct pruss_intc *intc, unsigned long hwirq)dev_dbg (intc->dev,"unmapped system_event = %lu channel = %d host = %d\n" , hwirq, ch, host); - -mutex_unlock (&intc->lock); }static void pruss_intc_init (struct pruss_intc *intc)
@@ -376,17 +372,15 @@ static int pruss_intc_validate_mapping(struct pruss_intc *intc, int event, int channel, int host) {struct device *dev = intc->dev; -int ret =0 ; -mutex_lock (&intc->lock); +guard (mutex)(&intc->lock);/* check if sysevent already assigned */ if (intc->event_channel[event].ref_count >0 && intc->event_channel[event].value != channel) {dev_err (dev,"event %d (req. ch %d) already assigned to channel %d\n" , event, channel, intc->event_channel[event].value); - ret = -EBUSY ; - goto unlock; +return -EBUSY ; }/* check if channel already assigned */
@@ -394,16 +388,13 @@ static int pruss_intc_validate_mapping(struct pruss_intc *intc, int event, intc->channel_host[channel].value != host) {dev_err (dev,"channel %d (req. host %d) already assigned to host %d\n" , channel, host, intc->channel_host[channel].value); - ret = -EBUSY ; - goto unlock; +return -EBUSY ; } intc->event_channel[event].value = channel; intc->channel_host[channel].value = host; -unlock: -mutex_unlock (&intc->lock); -return ret; +return 0 ; } static int
@@ -550,7 +541,9 @@ static int pruss_intc_probe(struct platform_device *pdev)pruss_intc_init (intc); -mutex_init (&intc->lock); + ret =devm_mutex_init (dev, &intc->lock); +if (ret) +return ret; intc->domain =irq_domain_create_linear (dev_fwnode (dev), max_system_events, &pruss_intc_irq_domain_ops, intc);
The following commit has been merged into the irq/drivers branch of tip:
The following commit has been merged into the irq/drivers branch of tip:
Commit-ID: 02a2db115989749b945fc1dc3e935a4a07eebb8e Gitweb: https://git.kernel.org/tip/02a2db115989749b945fc1dc3e935a4a07eebb8e Author: Andrew Davis <[email protected]> AuthorDate: Thu, 03 Sep 2026 13:52:19 -05:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Mon, 07 Sep 2026 21:47:51 +02:00
irqchip/pruss-intc: Use match data directly
The match data is fetched before the instance data is available, but it is not used until after. Skip the temporary variable and fetch the match data after it has a place to be stored.
--- drivers/irqchip/irq-pruss-intc.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/irqchip/irq-pruss-intc.c +5 -8
@@ -516,24 +516,21 @@ static const char * const irq_names[MAX_NUM_HOST_IRQS] = {static int pruss_intc_probe (struct platform_device *pdev) { -const struct pruss_intc_match_data *data;struct device *dev = &pdev->dev;struct pruss_intc *intc;struct pruss_host_irq_data *host_data;int i, irq, ret;u8 max_system_events, irqs_reserved =0 ; - data =of_device_get_match_data (dev); -if (!data) -return -ENODEV ; - - max_system_events = data->num_system_events; - intc =devm_kzalloc (dev,sizeof (*intc),GFP_KERNEL );if (!intc)return -ENOMEM ; - intc->soc_config = data; + intc->soc_config =of_device_get_match_data (dev); +if (!intc->soc_config) +return -ENODEV ; + max_system_events = intc->soc_config->num_system_events; + intc->dev = dev;platform_set_drvdata (pdev, intc);