All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
	Wim Van Sebroeck <wim@iguana.be>, Len Brown <lenb@kernel.org>,
	Jean Delvare <jdelvare@suse.com>,
	Wolfram Sang <wsa@the-dreams.de>,
	Peter Tyser <ptyser@xes-inc.com>,
	Lee Jones <lee.jones@linaro.org>,
	Zha Qipeng <qipeng.zha@intel.com>,
	Darren Hart <dvhart@infradead.org>,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/4] ACPI / watchdog: Add support for WDAT hardware watchdog
Date: Tue, 20 Sep 2016 16:50:07 +0300	[thread overview]
Message-ID: <20160920135007.GR1811@lahna.fi.intel.com> (raw)
In-Reply-To: <26c6e893-4b57-c7d6-7ab3-16e4f3a8c946@roeck-us.net>

On Tue, Sep 20, 2016 at 06:37:23AM -0700, Guenter Roeck wrote:
> > +	for (i = 0; i < tbl->entries; i++) {
> > +		const struct acpi_generic_address *gas;
> > +		struct wdat_instruction *instr;
> > +		struct list_head *instructions;
> > +		unsigned int action;
> > +		struct resource r;
> > +		int j;
> > +
> > +		action = entries[i].action;
> > +		if (action >= MAX_WDAT_ACTIONS) {
> > +			dev_dbg(&pdev->dev, "Skipping unknown action: %u\n",
> > +				action);
> > +			continue;
> > +		}
> > +
> > +		instr = devm_kzalloc(&pdev->dev, sizeof(*instr), GFP_KERNEL);
> > +		if (!instr)
> > +			return -ENOMEM;
> > +
> > +		INIT_LIST_HEAD(&instr->node);
> > +		instr->entry = entries[i];
> > +
> > +		gas = &entries[i].register_region;
> > +
> > +		memset(&r, 0, sizeof(r));
> > +		r.start = gas->address;
> > +		r.end = r.start + gas->access_width;
> > +		if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
> > +			r.flags = IORESOURCE_MEM;
> > +		} else if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
> > +			r.flags = IORESOURCE_IO;
> > +		} else {
> > +			dev_dbg(&pdev->dev, "Unsupported address space: %d\n",
> > +				gas->space_id);
> > +			continue;
> > +		}
> > +
> > +		/* Find the matching resource */
> > +		for (j = 0; j < pdev->num_resources; j++) {
> > +			res = &pdev->resource[j];
> > +			if (resource_contains(res, &r)) {
> > +				instr->reg = regs[j] + r.start - res->start;
> > +				break;
> > +			}
> > +		}
> > +
> > +		if (!instr->reg) {
> > +			dev_err(&pdev->dev, "I/O resource not found\n");
> > +			return -EINVAL;
> > +		}
> > +
> I must be missing something here. What is happening with instr ?

Instr contains the actual instruction from WDAT table. There can be
many.

> > +		instructions = wdat->instructions[action];

This will be NULL first time so...

> > +		if (!instructions) {
> > +			instructions = devm_kzalloc(&pdev->dev,
> > +					sizeof(*instructions), GFP_KERNEL);
> > +			if (!instructions)
> > +				return -ENOMEM;
> > +
> > +			INIT_LIST_HEAD(instructions);
> > +			wdat->instructions[action] = instructions;
> 
> ... and I don't really see how wdat->instructions[action] contains anything but
> a zero filled array. Confused :-(.

...we allocate entry for that here. Next time it will not be NULL for
that action.

> 
> > +		}
> > +
> > +		list_add_tail(&instr->node, instructions);

Then we append each instr to the list for this action.

Hope this clarifies :)

  reply	other threads:[~2016-09-20 13:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20 12:30 [PATCH v2 0/4] ACPI / watchdog: Add support for WDAT (Watchdog Action Table) Mika Westerberg
2016-09-20 12:30 ` [PATCH v2 1/4] ACPI / watchdog: Add support for WDAT hardware watchdog Mika Westerberg
2016-09-20 13:37   ` Guenter Roeck
2016-09-20 13:50     ` Mika Westerberg [this message]
2016-09-20 14:48       ` Guenter Roeck
2016-09-20 14:49   ` Guenter Roeck
2016-09-20 12:30 ` [PATCH v2 2/4] mfd: lpc_ich: Do not create iTCO watchdog when WDAT table exists Mika Westerberg
2016-09-27 19:41   ` Lee Jones
2016-09-27 22:07     ` Rafael J. Wysocki
2016-09-28  1:09       ` Lee Jones
2016-09-28  1:24         ` Rafael J. Wysocki
2016-09-29 17:20           ` Lee Jones
2016-09-20 12:30 ` [PATCH v2 3/4] i2c: i801: " Mika Westerberg
2016-09-22 17:47   ` Wolfram Sang
2016-09-22 17:48   ` Wolfram Sang
2016-09-20 12:30 ` [PATCH v2 4/4] platform/x86: intel_pmc_ipc: " Mika Westerberg
2016-09-24  0:34 ` [PATCH v2 0/4] ACPI / watchdog: Add support for WDAT (Watchdog Action Table) Rafael J. Wysocki

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=20160920135007.GR1811@lahna.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=dvhart@infradead.org \
    --cc=jdelvare@suse.com \
    --cc=lee.jones@linaro.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=ptyser@xes-inc.com \
    --cc=qipeng.zha@intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=wim@iguana.be \
    --cc=wsa@the-dreams.de \
    /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.