mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Éric Piel" <Eric.Piel@tremplin-utc.net>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH resent] lis3: Add axes module parameter for custom axis-mapping
Date: Thu, 23 Sep 2010 21:37:48 +0200	[thread overview]
Message-ID: <s5h39t0mesz.wl%tiwai@suse.de> (raw)
In-Reply-To: <20100923122308.49c64e37.akpm@linux-foundation.org>

At Thu, 23 Sep 2010 12:23:08 -0700,
Andrew Morton wrote:
> 
> On Wed, 22 Sep 2010 13:31:19 +0200
> Takashi Iwai <tiwai@suse.de> wrote:
> 
> > The axis-mapping of lis3dev device on many (rather most) HP machines
> > doesn't follow the standard.  When each new model appears, users need
> > to adjust again.  Testing this requires the rebuild of kernel, thus
> > it's not trivial for end-users.
> > 
> > This patch adds a module parameter "axes" to allow a custom
> > axis-mapping without patching and recompiling the kernel driver.
> > User can pass the parameter such as axes=3,2,1.  Also it can be
> > changed via sysfs.
> 
> Is the sysfs interface documented anywhere?

It's the generic module parameters sysfs interface.


> > --- a/drivers/hwmon/hp_accel.c
> > +++ b/drivers/hwmon/hp_accel.c
> > @@ -146,7 +146,8 @@ int lis3lv02d_acpi_write(struct lis3lv02d *lis3, int reg, u8 val)
> >  
> >  static int lis3lv02d_dmi_matched(const struct dmi_system_id *dmi)
> >  {
> > -	lis3_dev.ac = *((struct axis_conversion *)dmi->driver_data);
> > +	memcpy(lis3_dev.axis_map, (int *)dmi->driver_data,
> > +	       sizeof(lis3_dev.axis_map));
> 
> It's unobvious why the (nice) three-member struct was converted to a
> (nasty) three-element array?  All those typesafe struct assignments
> were turned into non-typesafe memcpys?
> 
> > +module_param_array_named(axes, lis3_dev.axis_map, axis, NULL, 0644);
> 
> Just to support module_param_array_named()?

Yes, indeed.

>  If so, could have used a union?
> 
> union axis_conversion {	/* should be called lis3_axis_conversion! */
> 	struct {
> 		int x;
> 		int y;
> 		int z;
> 	};
> 	int as_array[3];
> };

This should be possible, yes.

> or use a tyecast in the module_param_array_named() statement, perhaps?

Using non-array for module parameter would become tricky like my
first version.  I'll try to rewrite with the union expression.


thanks,

Takashi


      reply	other threads:[~2010-09-23 19:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-22 11:31 Takashi Iwai
2010-09-23 19:23 ` Andrew Morton
2010-09-23 19:37   ` Takashi Iwai [this message]

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=s5h39t0mesz.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=Eric.Piel@tremplin-utc.net \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®