Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752591AbbLKHbY (ORCPT ); Fri, 11 Dec 2015 02:31:24 -0500 Received: from mga09.intel.com ([134.134.136.24]:27270 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751206AbbLKHbX (ORCPT ); Fri, 11 Dec 2015 02:31:23 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,412,1444719600"; d="scan'208";a="616288179" From: Alexander Shishkin To: Chunyan Zhang Cc: linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org Subject: Re: [PATCH] stm: the number of masters should be (sw_end - sw_start + 1) In-Reply-To: <1449804410-16833-1-git-send-email-zhang.chunyan@linaro.org> References: <1449804410-16833-1-git-send-email-zhang.chunyan@linaro.org> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Fri, 11 Dec 2015 09:31:20 +0200 Message-ID: <87mvthxwzb.fsf@ashishki-desk.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2072 Lines: 56 Chunyan Zhang 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 > --- > 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]). > if (!stm) > return -ENOMEM; > -- > 1.9.1 This is a very old version on git, btw. :) Thanks, -- Alex -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/