netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v1 1/1] ptp: ocp: Use DEFINE_RES_*() in place
@ 2023-12-21 14:06 Andy Shevchenko
  2023-12-21 14:58 ` Vadim Fedorenko
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andy Shevchenko @ 2023-12-21 14:06 UTC (permalink / raw)
  To: Vadim Fedorenko, netdev, linux-kernel
  Cc: Jonathan Lemon, Vadim Fedorenko, Richard Cochran, Andy Shevchenko

There is no need to have an intermediate functions as DEFINE_RES_*()
macros are represented by compound literals. Just use them in place.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/ptp/ptp_ocp.c | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 4021d3d325f9..306353a69231 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -1716,20 +1716,6 @@ ptp_ocp_get_mem(struct ptp_ocp *bp, struct ocp_resource *r)
 	return __ptp_ocp_get_mem(bp, start, r->size);
 }
 
-static void
-ptp_ocp_set_irq_resource(struct resource *res, int irq)
-{
-	struct resource r = DEFINE_RES_IRQ(irq);
-	*res = r;
-}
-
-static void
-ptp_ocp_set_mem_resource(struct resource *res, resource_size_t start, int size)
-{
-	struct resource r = DEFINE_RES_MEM(start, size);
-	*res = r;
-}
-
 static int
 ptp_ocp_register_spi(struct ptp_ocp *bp, struct ocp_resource *r)
 {
@@ -1741,15 +1727,15 @@ ptp_ocp_register_spi(struct ptp_ocp *bp, struct ocp_resource *r)
 	int id;
 
 	start = pci_resource_start(pdev, 0) + r->offset;
-	ptp_ocp_set_mem_resource(&res[0], start, r->size);
-	ptp_ocp_set_irq_resource(&res[1], pci_irq_vector(pdev, r->irq_vec));
+	res[0] = DEFINE_RES_MEM(start, r->size);
+	res[1] = DEFINE_RES_IRQ(pci_irq_vector(pdev, r->irq_vec));
 
 	info = r->extra;
 	id = pci_dev_id(pdev) << 1;
 	id += info->pci_offset;
 
 	p = platform_device_register_resndata(&pdev->dev, info->name, id,
-					      res, 2, info->data,
+					      res, ARRAY_SIZE(res), info->data,
 					      info->data_size);
 	if (IS_ERR(p))
 		return PTR_ERR(p);
@@ -1768,11 +1754,11 @@ ptp_ocp_i2c_bus(struct pci_dev *pdev, struct ocp_resource *r, int id)
 
 	info = r->extra;
 	start = pci_resource_start(pdev, 0) + r->offset;
-	ptp_ocp_set_mem_resource(&res[0], start, r->size);
-	ptp_ocp_set_irq_resource(&res[1], pci_irq_vector(pdev, r->irq_vec));
+	res[0] = DEFINE_RES_MEM(start, r->size);
+	res[1] = DEFINE_RES_IRQ(pci_irq_vector(pdev, r->irq_vec));
 
 	return platform_device_register_resndata(&pdev->dev, info->name,
-						 id, res, 2,
+						 id, res, ARRAY_SIZE(res),
 						 info->data, info->data_size);
 }
 
-- 
2.43.0.rc1.1.gbec44491f096


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v1 1/1] ptp: ocp: Use DEFINE_RES_*() in place
  2023-12-21 14:06 [PATCH net-next v1 1/1] ptp: ocp: Use DEFINE_RES_*() in place Andy Shevchenko
@ 2023-12-21 14:58 ` Vadim Fedorenko
  2023-12-23 16:40 ` Simon Horman
  2024-01-02 12:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Vadim Fedorenko @ 2023-12-21 14:58 UTC (permalink / raw)
  To: Andy Shevchenko, netdev, linux-kernel
  Cc: Jonathan Lemon, Richard Cochran, Paolo Abeni, David S. Miller

On 21/12/2023 14:06, Andy Shevchenko wrote:
> There is no need to have an intermediate functions as DEFINE_RES_*()
> macros are represented by compound literals. Just use them in place.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/ptp/ptp_ocp.c | 26 ++++++--------------------
>   1 file changed, 6 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 4021d3d325f9..306353a69231 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -1716,20 +1716,6 @@ ptp_ocp_get_mem(struct ptp_ocp *bp, struct ocp_resource *r)
>   	return __ptp_ocp_get_mem(bp, start, r->size);
>   }
>   
> -static void
> -ptp_ocp_set_irq_resource(struct resource *res, int irq)
> -{
> -	struct resource r = DEFINE_RES_IRQ(irq);
> -	*res = r;
> -}
> -
> -static void
> -ptp_ocp_set_mem_resource(struct resource *res, resource_size_t start, int size)
> -{
> -	struct resource r = DEFINE_RES_MEM(start, size);
> -	*res = r;
> -}
> -
>   static int
>   ptp_ocp_register_spi(struct ptp_ocp *bp, struct ocp_resource *r)
>   {
> @@ -1741,15 +1727,15 @@ ptp_ocp_register_spi(struct ptp_ocp *bp, struct ocp_resource *r)
>   	int id;
>   
>   	start = pci_resource_start(pdev, 0) + r->offset;
> -	ptp_ocp_set_mem_resource(&res[0], start, r->size);
> -	ptp_ocp_set_irq_resource(&res[1], pci_irq_vector(pdev, r->irq_vec));
> +	res[0] = DEFINE_RES_MEM(start, r->size);
> +	res[1] = DEFINE_RES_IRQ(pci_irq_vector(pdev, r->irq_vec));
>   
>   	info = r->extra;
>   	id = pci_dev_id(pdev) << 1;
>   	id += info->pci_offset;
>   
>   	p = platform_device_register_resndata(&pdev->dev, info->name, id,
> -					      res, 2, info->data,
> +					      res, ARRAY_SIZE(res), info->data,
>   					      info->data_size);
>   	if (IS_ERR(p))
>   		return PTR_ERR(p);
> @@ -1768,11 +1754,11 @@ ptp_ocp_i2c_bus(struct pci_dev *pdev, struct ocp_resource *r, int id)
>   
>   	info = r->extra;
>   	start = pci_resource_start(pdev, 0) + r->offset;
> -	ptp_ocp_set_mem_resource(&res[0], start, r->size);
> -	ptp_ocp_set_irq_resource(&res[1], pci_irq_vector(pdev, r->irq_vec));
> +	res[0] = DEFINE_RES_MEM(start, r->size);
> +	res[1] = DEFINE_RES_IRQ(pci_irq_vector(pdev, r->irq_vec));
>   
>   	return platform_device_register_resndata(&pdev->dev, info->name,
> -						 id, res, 2,
> +						 id, res, ARRAY_SIZE(res),
>   						 info->data, info->data_size);
>   }
>   

Thanks, Andy!

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v1 1/1] ptp: ocp: Use DEFINE_RES_*() in place
  2023-12-21 14:06 [PATCH net-next v1 1/1] ptp: ocp: Use DEFINE_RES_*() in place Andy Shevchenko
  2023-12-21 14:58 ` Vadim Fedorenko
@ 2023-12-23 16:40 ` Simon Horman
  2024-01-02 12:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2023-12-23 16:40 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Vadim Fedorenko, netdev, linux-kernel, Jonathan Lemon,
	Vadim Fedorenko, Richard Cochran

On Thu, Dec 21, 2023 at 04:06:07PM +0200, Andy Shevchenko wrote:
> There is no need to have an intermediate functions as DEFINE_RES_*()
> macros are represented by compound literals. Just use them in place.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Thanks Andy,

this is a nice cleanup.

Reviewed-by: Simon Horman <horms@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v1 1/1] ptp: ocp: Use DEFINE_RES_*() in place
  2023-12-21 14:06 [PATCH net-next v1 1/1] ptp: ocp: Use DEFINE_RES_*() in place Andy Shevchenko
  2023-12-21 14:58 ` Vadim Fedorenko
  2023-12-23 16:40 ` Simon Horman
@ 2024-01-02 12:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-01-02 12:40 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: vadim.fedorenko, netdev, linux-kernel, jonathan.lemon, vadfed,
	richardcochran

Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Thu, 21 Dec 2023 16:06:07 +0200 you wrote:
> There is no need to have an intermediate functions as DEFINE_RES_*()
> macros are represented by compound literals. Just use them in place.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/ptp/ptp_ocp.c | 26 ++++++--------------------
>  1 file changed, 6 insertions(+), 20 deletions(-)

Here is the summary with links:
  - [net-next,v1,1/1] ptp: ocp: Use DEFINE_RES_*() in place
    https://git.kernel.org/netdev/net-next/c/07938d774f18

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-02 12:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-21 14:06 [PATCH net-next v1 1/1] ptp: ocp: Use DEFINE_RES_*() in place Andy Shevchenko
2023-12-21 14:58 ` Vadim Fedorenko
2023-12-23 16:40 ` Simon Horman
2024-01-02 12:40 ` patchwork-bot+netdevbpf

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).