All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Fainelli <florian@openwrt.org>
To: "Steven J. Hill" <sjhill@mips.com>
Cc: linux-mips@linux-mips.org, ralf@linux-mips.org
Subject: Re: [PATCH] MIPS: Make CP0 config registers readable via sysfs.
Date: Wed, 12 Dec 2012 15:26:09 +0100	[thread overview]
Message-ID: <50C89401.70705@openwrt.org> (raw)
In-Reply-To: <1354858280-29576-1-git-send-email-sjhill@mips.com>

Hello Steven,

Le 12/07/12 06:31, Steven J. Hill a écrit :

[snip]

> +
> +#define __BUILD_CP0_SYSFS(reg)					\
> +static DEFINE_PER_CPU(unsigned int, cpu_config##reg);		\
> +static ssize_t show_config##reg(struct device *dev,		\
> +		struct device_attribute *attr, char *buf)	\
> +{								\
> +	struct cpu *cpu = container_of(dev, struct cpu, dev);	\
> +	int n = snprintf(buf, PAGE_SIZE-2, "%x\n",		\
> +		per_cpu(cpu_config##reg, cpu->dev.id));		\
> +	return n;						\
> +}								\
> +static DEVICE_ATTR(config##reg, 0444, show_config##reg, NULL);
> +
> +__BUILD_CP0_SYSFS(0)
> +__BUILD_CP0_SYSFS(1)
> +__BUILD_CP0_SYSFS(2)
> +__BUILD_CP0_SYSFS(3)
> +__BUILD_CP0_SYSFS(4)
> +__BUILD_CP0_SYSFS(5)
> +__BUILD_CP0_SYSFS(6)
> +__BUILD_CP0_SYSFS(7)
> +
> +static void read_c0_registers(void *arg)
> +{
> +	struct device *dev = get_cpu_device(smp_processor_id());
> +	struct cpu *cpu;
> +	int ok;
> +
> +	if (dev != NULL) {
> +		cpu = container_of(dev, struct cpu, dev);
> +		per_cpu(cpu_config0, cpu->dev.id) = read_c0_config();
> +		device_create_file(dev, &dev_attr_config0);
> +		ok = per_cpu(cpu_config0, cpu->dev.id) & MIPS_CONF_M;
> +	} else

Is there any reason you are not using a macro here too?
--
Florian

  reply	other threads:[~2012-12-12 14:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-07  5:31 [PATCH] MIPS: Make CP0 config registers readable via sysfs Steven J. Hill
2012-12-12 14:26 ` Florian Fainelli [this message]
2012-12-12 16:45   ` Hill, Steven
2012-12-12 14:45 ` Lars-Peter Clausen
2012-12-12 16:44   ` Hill, Steven
2012-12-12 17:03     ` Florian Fainelli
2012-12-12 18:49     ` Lars-Peter Clausen
2012-12-12 19:08       ` David Daney
2012-12-12 19:14         ` Manuel Lauss

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=50C89401.70705@openwrt.org \
    --to=florian@openwrt.org \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=sjhill@mips.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.