All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <guenter.roeck@ericsson.com>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCHv8 1/1] Hwmon: Merge Pkgtemp with Coretemp
Date: Wed, 18 May 2011 14:24:26 +0000	[thread overview]
Message-ID: <20110518142426.GA10953@ericsson.com> (raw)
In-Reply-To: <1305729702-11126-1-git-send-email-durgadoss.r@intel.com>

Hi Durga,

On Wed, May 18, 2011 at 10:41:42AM -0400, Durgadoss R wrote:
> This patch merges the pkgtemp with coretemp driver.
> The sysfs interfaces for all cores in the same pkg
> are shown under one directory, in hwmon. It also
> supports CONFIG_HOTPLUG_CPU. So, the sysfs interfaces
> are created when each core comes online and are
> removed when it goes offline.
> 
> Signed-off-by: Durgadoss R <durgadoss.r@intel.com>

[ ... ]
> v8:
> * Fixed retrieval of phys_proc_id in probe
> * Added coretemp_remove_device to handle CPU offlining properly

There is no coretemp_remove_device() in the code. You mean
coretemp_device_remove(), presumably.

[ ... ]
> +static struct platform_device *coretemp_get_pdev(unsigned int cpu)
> +{
> +       struct pdev_entry *p;
> +
> +       mutex_lock(&pdev_list_mutex);
> +       list_for_each_entry(p, &pdev_list, list)
> +               if (p->cpu = cpu) {
> +                       mutex_unlock(&pdev_list_mutex);
> +                       return p->pdev;
> +               }
> 
I have been wondering about this. In the non-SMP case, can there ever be more than one entry ?

If so, you should not need the loop but could just use list_first_entry() instead.

[ ... ]
> -static void __cpuinit coretemp_device_remove(unsigned int cpu)
> +static void coretemp_device_remove(unsigned int cpu)
>  {
>         struct pdev_entry *p;
> -       unsigned int i;
> 
>         mutex_lock(&pdev_list_mutex);
>         list_for_each_entry(p, &pdev_list, list) {

I think this should be list_for_each_safe() since you remove p. 

> +       #ifdef CONFIG_SMP
> +               if (p->phys_proc_id != cpu_data(cpu).phys_proc_id)
> +                       continue;
> +       #else
>                 if (p->cpu != cpu)
>                         continue;
> +       #endif
> 
#ifdef at column 0, please.

I wonder about the !SMP case. Doesn't that imply that there is only one CPU ?
If so, why compare the CPU ID ?

[ ... ]
> +{
> +       int i;
> +
> +       /* Find online cores, except pkgtemp data */
> +       for (i = MAX_CORE_DATA - 1; i >= 0; --i) {

Not that it matters, but starting at 0 and iterating upwards is more common.
Is that just personal preference, or do you have a reason ? Just wondering.

> +               if (pdata->core_data[i] &&
> +                       !pdata->core_data[i]->is_pkg_data) {
> +                       return 1;

Please return a boolean.

> +               }
> +       }
> +       return 0;
> +}
> +
[ ... ]
> +
> +static void put_core_offline(unsigned int cpu)
> +{
> +       int i, indx;
> +       struct platform_data *pdata;
> +       struct platform_device *pdev = coretemp_get_pdev(cpu);
> +
> +       /* If the physical CPU device does not exist, just return */
> +       if (!pdev)
> +               return;
> +
> +       pdata = platform_get_drvdata(pdev);
> +
> +       indx = get_attr_no(cpu, 0);
> +
> +       if (pdata->core_data[indx] && pdata->core_data[indx]->cpu = cpu)
> +               coretemp_remove_core(pdata, &pdev->dev, indx);
> +
> +       /* Online the HT version of this core, if any */
> +       for_each_cpu(i, cpu_sibling_mask(cpu))
> +               if (i != cpu) {
> +                       get_core_online(i);
> +                       break;
> +               }
> +
> +       /* If all cores in this pkg are offline, remove the device */
> +       if (!is_any_core_online(pdata))
> +               coretemp_device_remove(cpu);

Where do you remove the package sensor entry ?

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  reply	other threads:[~2011-05-18 14:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-18  9:10 [lm-sensors] [PATCHv8 1/1] Hwmon: Merge Pkgtemp with Coretemp Durgadoss R
2011-05-18 14:24 ` Guenter Roeck [this message]
2011-05-18 15:32 ` R, Durgadoss
2011-05-18 15:48 ` Guenter Roeck
2011-05-18 16:58 ` R, Durgadoss

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=20110518142426.GA10953@ericsson.com \
    --to=guenter.roeck@ericsson.com \
    --cc=lm-sensors@vger.kernel.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 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.