public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Guilherme Giacomo Simoes <trintaeoitogc@gmail.com>
Cc: scott@spiteful.org, bhelgaas@google.com,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RESEND PATCH] PCI: cpci: remove unused fields
Date: Thu, 13 Feb 2025 15:26:27 -0600	[thread overview]
Message-ID: <20250213212627.GA129476@bhelgaas> (raw)
In-Reply-To: <20250213173925.200404-1-trintaeoitogc@gmail.com>

On Thu, Feb 13, 2025 at 02:39:25PM -0300, Guilherme Giacomo Simoes wrote:
> The `get_power()` and `set_power()` function pointers in the
> `cpci_hp_controller ops` struct were declared but never implemented by
> any driver. To improve code readability and reduce resource usage,
> remove this pointers and replace with a `flags` field.
> 
> Use the new `flags` field in `enable_slot()`, `disable_slot()`, and
> `cpci_get_power_s atus()` to track the slot's power state using the
> `SLOT_ENABLED` macro.
> 
> Signed-off-by: Guilherme Giacomo Simoes <trintaeoitogc@gmail.com>
> ---
>  drivers/pci/hotplug/cpci_hotplug.h      |  3 +--
>  drivers/pci/hotplug/cpci_hotplug_core.c | 21 +++++++--------------
>  2 files changed, 8 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/cpci_hotplug.h b/drivers/pci/hotplug/cpci_hotplug.h
> index 03fa39ab0c88..c5cb12cad2b4 100644
> --- a/drivers/pci/hotplug/cpci_hotplug.h
> +++ b/drivers/pci/hotplug/cpci_hotplug.h
> @@ -44,8 +44,7 @@ struct cpci_hp_controller_ops {
>  	int (*enable_irq)(void);
>  	int (*disable_irq)(void);
>  	int (*check_irq)(void *dev_id);
> -	u8  (*get_power)(struct slot *slot);
> -	int (*set_power)(struct slot *slot, int value);
> +	int flags;
>  };
>  
>  struct cpci_hp_controller {
> diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
> index d0559d2faf50..87a743c2a5f1 100644
> --- a/drivers/pci/hotplug/cpci_hotplug_core.c
> +++ b/drivers/pci/hotplug/cpci_hotplug_core.c
> @@ -27,6 +27,8 @@
>  #define DRIVER_AUTHOR	"Scott Murray <scottm@somanetworks.com>"
>  #define DRIVER_DESC	"CompactPCI Hot Plug Core"
>  
> +#define SLOT_ENABLED 0x00000001
> +
>  #define MY_NAME	"cpci_hotplug"
>  
>  #define dbg(format, arg...)					\
> @@ -71,13 +73,12 @@ static int
>  enable_slot(struct hotplug_slot *hotplug_slot)
>  {
>  	struct slot *slot = to_slot(hotplug_slot);
> -	int retval = 0;
>  
>  	dbg("%s - physical_slot = %s", __func__, slot_name(slot));
>  
> -	if (controller->ops->set_power)
> -		retval = controller->ops->set_power(slot, 1);
> -	return retval;
> +	controller->ops->flags |= SLOT_ENABLED;

There are no implementations of ->set_power() or ->get_power(), are
there?  If not, we can just remove them and the calls to them.

I don't see why we should add SLOT_ENABLED.

> +	return 0;
>  }
>  
>  static int
> @@ -109,11 +110,7 @@ disable_slot(struct hotplug_slot *hotplug_slot)
>  	}
>  	cpci_led_on(slot);
>  
> -	if (controller->ops->set_power) {
> -		retval = controller->ops->set_power(slot, 0);
> -		if (retval)
> -			goto disable_error;
> -	}
> +	controller->ops->flags &= ~SLOT_ENABLED;
>  
>  	slot->adapter_status = 0;
>  
> @@ -129,11 +126,7 @@ disable_slot(struct hotplug_slot *hotplug_slot)
>  static u8
>  cpci_get_power_status(struct slot *slot)
>  {
> -	u8 power = 1;
> -
> -	if (controller->ops->get_power)
> -		power = controller->ops->get_power(slot);
> -	return power;
> +	return controller->ops->flags & SLOT_ENABLED;
>  }
>  
>  static int
> -- 
> 2.34.1
> 

  parent reply	other threads:[~2025-02-13 21:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-13 17:39 [RESEND PATCH] PCI: cpci: remove unused fields Guilherme Giacomo Simoes
2025-02-13 20:44 ` Christophe JAILLET
2025-02-15  2:10   ` Guilherme Giacomo Simoes
2025-02-15  8:56     ` Christophe JAILLET
2025-02-15 14:05       ` Guilherme Giacomo Simoes
2025-02-13 21:26 ` Bjorn Helgaas [this message]
2025-02-15  2:06   ` Guilherme Giacomo Simoes
  -- strict thread matches above, loose matches on Subject: below --
2025-01-30 14:01 Guilherme Giacomo Simoes
2025-01-16 15:55 Guilherme Giacomo Simoes
2025-01-02 15:26 Guilherme Giacomo Simoes

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=20250213212627.GA129476@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=scott@spiteful.org \
    --cc=trintaeoitogc@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