The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
To: Chunyan Zhang <zhang.chunyan@linaro.org>
Cc: "linux-kernel\@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Mathieu Poirier <mathieu.poirier@linaro.org>
Subject: Re: [PATCH] stm: the number of masters should be (sw_end - sw_start + 1)
Date: Fri, 11 Dec 2015 10:51:09 +0200	[thread overview]
Message-ID: <87mvthcqrm.fsf@ashishki-desk.ger.corp.intel.com> (raw)
In-Reply-To: <CAG2=9p-e7q-ysWR=y6WvrbERkMrPhEGHvYyOB9NTG6c2T5j4Uw@mail.gmail.com>

Chunyan Zhang <zhang.chunyan@linaro.org> writes:

> On Fri, Dec 11, 2015 at 3:31 PM, Alexander Shishkin
> <alexander.shishkin@linux.intel.com> wrote:
>> Chunyan Zhang <zhang.chunyan@linaro.org> writes:
>>
>>> sw_end represents the last software master, sw_start is index of the
>>> first master, so the number of software masters should be
>>> sw_end - sw_start + 1.
>>
>> Looks about right, but it needs to be in two separate patches.
>>
>>> Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
>>> ---
>>>  drivers/hwtracing/intel_th/sth.c | 2 +-
>>>  drivers/hwtracing/stm/core.c     | 2 +-
>>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/hwtracing/intel_th/sth.c b/drivers/hwtracing/intel_th/sth.c
>>> index 56101c3..28917d7 100644
>>> --- a/drivers/hwtracing/intel_th/sth.c
>>> +++ b/drivers/hwtracing/intel_th/sth.c
>>> @@ -173,7 +173,7 @@ static int intel_th_sw_init(struct sth_device *sth)
>>>       sth->stm.sw_start = reg & 0xffff;
>>>       sth->stm.sw_end = reg >> 16;
>>>
>>> -     sth->sw_nmasters = sth->stm.sw_end - sth->stm.sw_start;
>>> +     sth->sw_nmasters = sth->stm.sw_end - sth->stm.sw_start + 1;
>>>       dev_dbg(sth->dev, "sw_start: %x sw_end: %x masters: %x nchannels: %x\n",
>>>               sth->stm.sw_start, sth->stm.sw_end, sth->sw_nmasters,
>>>               sth->stm.sw_nchannels);
>>> diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
>>> index 7f7bdb3..cb676f2 100644
>>> --- a/drivers/hwtracing/stm/core.c
>>> +++ b/drivers/hwtracing/stm/core.c
>>> @@ -632,7 +632,7 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
>>>       if (!stm_data->packet || !stm_data->sw_nchannels)
>>>               return -EINVAL;
>>>
>>> -     nmasters = stm_data->sw_end - stm_data->sw_start;
>>> +     nmasters = stm_data->sw_end - stm_data->sw_start + 1;
>>>       stm = kzalloc(sizeof(*stm) + nmasters * sizeof(void *), GFP_KERNEL);
>>
>> Or even offsetof(struct stm_device, masters[stm_data->sw_end]).
>>
>
> This should use 'offsetofend()'.

No, actually, just scratch my previous comment as it was completely
wrong, just fix the off-by-one. If we were to use offsetof(), it should
rather be of masters[nmasters], but all we need is to fix the off-by-one
right now.

Regards,
--
Alex

  reply	other threads:[~2015-12-11  8:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-11  3:26 [PATCH] stm: the number of masters should be (sw_end - sw_start + 1) Chunyan Zhang
2015-12-11  7:31 ` Alexander Shishkin
2015-12-11  7:59   ` Chunyan Zhang
2015-12-11  8:38   ` Chunyan Zhang
2015-12-11  8:51     ` Alexander Shishkin [this message]
2015-12-11  9:10       ` Chunyan Zhang
2015-12-11  9:34         ` Alexander Shishkin

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=87mvthcqrm.fsf@ashishki-desk.ger.corp.intel.com \
    --to=alexander.shishkin@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=zhang.chunyan@linaro.org \
    /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