All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rajat Jain <rajatjain.linux@gmail.com>
To: Yijing Wang <wangyijing@huawei.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bjorn Helgaas <bhelgaas@google.com>,
	Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Paul Bolle <pebolle@tiscali.nl>,
	Rajat Jain <rajatjain@juniper.net>,
	Rajat Jain <rajatxjain@gmail.com>,
	Guenter Roeck <groeck@juniper.net>,
	Guenter Roeck <linux@roeck-us.net>
Subject: Re: [PATCH v2 2/4] pciehp: Use link change notifications for hot-plug and removal
Date: Thu, 05 Dec 2013 19:19:43 -0800	[thread overview]
Message-ID: <52A1424F.5060007@gmail.com> (raw)
In-Reply-To: <52A04235.9010801@huawei.com>

On 12/05/2013 01:07 AM, Yijing Wang wrote:
> 
> handle_link_up_event() and handle_link_down_event() are almost the same,
> what about use like:
> handle_link_state_change_event(p_slot, event) to reuse the the common code ?
> 
>

Sure, I can combine both of them to make it look more like this. Let me know
it this looks all right.

static void handle_link_event(struct slot *p_slot, unsigned int req)
{
	struct controller *ctrl = p_slot->ctrl;
	struct power_work_info *info;

	info = kmalloc(sizeof(*info), GFP_KERNEL);
	if (!info) {
		ctrl_err(p_slot->ctrl, "%s: Cannot allocate memory\n",
			 __func__);
		return;
	}
	info->p_slot = p_slot;
	info->req = req;
	INIT_WORK(&info->work, pciehp_power_thread);

	switch (p_slot->state) {
	case BLINKINGON_STATE:
	case BLINKINGOFF_STATE:
		cancel_delayed_work(&p_slot->work);
		/* Fall through */
	case STATIC_STATE:
		if (req == ENABLE_REQ)
			p_slot->state = POWERON_STATE;
		else
			p_slot->state = POWEROFF_STATE;

		queue_work(p_slot->wq, &info->work);
		break;
	case POWERON_STATE:
		if (req == ENABLE_REQ) {
			ctrl_info(ctrl,
				  "Link Up ignored on slot(%s): already powering on\n",
				  slot_name(p_slot));
			kfree(info);
		} else {
			ctrl_info(ctrl,
				  "Link Down queued on slot(%s): currently getting powered on\n",
				  slot_name(p_slot));
			p_slot->state = POWEROFF_STATE;
			queue_work(p_slot->wq, &info->work);
		}
		break;
	case POWEROFF_STATE:
		if (req == ENABLE_REQ) {
			ctrl_info(ctrl,
				  "Link Up queued on slot(%s): currently getting powered off\n",
				  slot_name(p_slot));
			p_slot->state = POWERON_STATE;
			queue_work(p_slot->wq, &info->work);
		} else {
			ctrl_info(ctrl,
				  "Link Down ignored on slot(%s): already powering off\n",
				  slot_name(p_slot));
			kfree(info);
		}
		break;
	default:
		ctrl_err(ctrl, "Not a valid state on slot(%s)\n",
			 slot_name(p_slot));
		kfree(info);
		break;
	}
}

Bjorn: was wondering if you'd able to take a look at this patchset in
this or next week some time. I'm eagerly waiting to address any comments.

Also, can you please let me know what is the protocol here? Should
I resubmit just the "v3" of this patch? Or bump up the version of all
the patches in the patchset to "v3" and resubmit them all?

Thanks & Best Regards,

Rajat

  reply	other threads:[~2013-12-06  3:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-03 22:32 [PATCH v2 2/4] pciehp: Use link change notifications for hot-plug and removal Rajat Jain
2013-12-05  9:07 ` Yijing Wang
2013-12-06  3:19   ` Rajat Jain [this message]
2013-12-12 22:44 ` Bjorn Helgaas
2013-12-13  6:26   ` Yinghai Lu
2013-12-13 13:21     ` Bjorn Helgaas
2013-12-13 19:04       ` Rajat Jain
2013-12-13 21:14         ` Bjorn Helgaas
2013-12-14  1:58           ` Yinghai Lu
2013-12-14  3:39             ` Guenter Roeck
2013-12-15 23:24               ` Rajat Jain
2013-12-16  0:18                 ` Bjorn Helgaas
2013-12-16 17:39                   ` Guenter Roeck
2013-12-17  1:14                     ` Bjorn Helgaas
2013-12-17  2:36                       ` Guenter Roeck
2013-12-15 22:23           ` Rajat Jain

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=52A1424F.5060007@gmail.com \
    --to=rajatjain.linux@gmail.com \
    --cc=alex.williamson@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=groeck@juniper.net \
    --cc=kaneshige.kenji@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=pebolle@tiscali.nl \
    --cc=rajatjain@juniper.net \
    --cc=rajatxjain@gmail.com \
    --cc=wangyijing@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.