Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: ngn <ngn@ngn.tf>
Cc: Nam Cao <namcao@linutronix.de>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] PCI: shpchp: Remove hpc_ops
Date: Fri, 2 Aug 2024 11:41:43 -0500	[thread overview]
Message-ID: <20240802164143.GA153790@bhelgaas> (raw)
In-Reply-To: <ZqzZwRx0Fug4bcwv@archbtw>

On Fri, Aug 02, 2024 at 04:06:09PM +0300, ngn wrote:
> On Thu, Aug 01, 2024 at 07:08:52PM -0500, Bjorn Helgaas wrote:
> > On Tue, Jul 23, 2024 at 02:43:25PM +0300, ngn wrote:
> > > Remove the hpc_ops struct from shpchp. This struct is unnecessary as
> > > no other hotplug controller implements it. A similar thing has already
> > > been done in pciehp with commit 82a9e79ef132 ("PCI: pciehp: remove hpc_ops")
> > 
> > > +++ b/drivers/pci/hotplug/shpchp_hpc.c
> > > @@ -167,7 +167,6 @@
> > >  
> > >  static irqreturn_t shpc_isr(int irq, void *dev_id);
> > >  static void start_int_poll_timer(struct controller *ctrl, int sec);
> > > -static int hpc_check_cmd_status(struct controller *ctrl);
> > >  
> > >  static inline u8 shpc_readb(struct controller *ctrl, int reg)
> > >  {
> > > @@ -317,7 +316,7 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
> > >  	if (retval)
> > >  		goto out;
> > >  
> > > -	cmd_status = hpc_check_cmd_status(slot->ctrl);
> > > +	cmd_status = shpchp_check_cmd_status(slot->ctrl);
> > 
> > This rename looks like it should be a separate patch because it's not
> > part of removing hpc_ops.
> 
> I think hpc_check_cmd_status meant to be a part of the hpc_ops struct.
> Here is the original struct:
> 
> struct hpc_ops {
> 	int (*power_on_slot)(struct slot *slot);
> 	int (*slot_enable)(struct slot *slot);
> 	int (*slot_disable)(struct slot *slot);
> 	int (*set_bus_speed_mode)(struct slot *slot, enum pci_bus_speed speed);
> 	int (*get_power_status)(struct slot *slot, u8 *status);
> 	int (*get_attention_status)(struct slot *slot, u8 *status);
> 	int (*set_attention_status)(struct slot *slot, u8 status);
> 	int (*get_latch_status)(struct slot *slot, u8 *status);
> 	int (*get_adapter_status)(struct slot *slot, u8 *status);
> 	int (*get_adapter_speed)(struct slot *slot, enum pci_bus_speed *speed);
> 	int (*get_prog_int)(struct slot *slot, u8 *prog_int);
> 	int (*query_power_fault)(struct slot *slot);
> 	void (*green_led_on)(struct slot *slot);
> 	void (*green_led_off)(struct slot *slot);
> 	void (*green_led_blink)(struct slot *slot);
> 	void (*release_ctlr)(struct controller *ctrl);
> 	int (*check_cmd_status)(struct controller *ctrl);
> };
> 
> As you can see it contains a pointer for check_cmd_status function,
> however the hpc_check_cmd_status was never assigned to it:
> 
> static const struct hpc_ops shpchp_hpc_ops = {
> 	.power_on_slot			= hpc_power_on_slot,
> 	.slot_enable			= hpc_slot_enable,
> 	.slot_disable			= hpc_slot_disable,
> 	.set_bus_speed_mode		= hpc_set_bus_speed_mode,
> 	.set_attention_status	= hpc_set_attention_status,
> 	.get_power_status		= hpc_get_power_status,
> 	.get_attention_status	= hpc_get_attention_status,
> 	.get_latch_status		= hpc_get_latch_status,
> 	.get_adapter_status		= hpc_get_adapter_status,
> 
> 	.get_adapter_speed		= hpc_get_adapter_speed,
> 	.get_prog_int			= hpc_get_prog_int,
> 
> 	.query_power_fault		= hpc_query_power_fault,
> 	.green_led_on			= hpc_set_green_led_on,
> 	.green_led_off			= hpc_set_green_led_off,
> 	.green_led_blink		= hpc_set_green_led_blink,
> 
> 	.release_ctlr			= hpc_release_ctlr,
> };
> 
> Which made me believe that this function supposed to be a part of the
> hpc_ops struct and whoever wrote the code added a pointer for it but
> then they forgot to assign the function to it during the actual
> definition of the struct. So I renamed it anyway.

Good point, thanks.  Applied to pci/hotplug for v6.12, thanks for your
work!

Bjorn

      reply	other threads:[~2024-08-02 16:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-23 11:43 [PATCH v3] PCI: shpchp: Remove hpc_ops ngn
2024-08-02  0:08 ` Bjorn Helgaas
2024-08-02 13:06   ` ngn
2024-08-02 16:41     ` Bjorn Helgaas [this message]

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=20240802164143.GA153790@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=namcao@linutronix.de \
    --cc=ngn@ngn.tf \
    /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