X86 platform drivers
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Matthew Garrett <mjg59@srcf.ucam.org>
Cc: Randy Dunlap <rdunlap@xenotime.net>,
	linux-kernel@vger.kernel.org,
	platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH] Platform: add Samsung Laptop platform driver
Date: Fri, 11 Feb 2011 10:42:23 -0800	[thread overview]
Message-ID: <20110211184223.GB10891@kroah.com> (raw)
In-Reply-To: <20110211154508.GA5435@srcf.ucam.org>

On Fri, Feb 11, 2011 at 03:45:08PM +0000, Matthew Garrett wrote:
> On Wed, Feb 09, 2011 at 02:40:06PM -0800, Greg KH wrote:
> 
> > +/* Structure to get data back to the calling function */
> > +struct sabi_retval {
> > +	u8 retval[20];
> > +};
> 
> 20 bytes, but only 4 of them end up being used?

Yes, for the commands we care about, we only pay attention to the first
4 bytes, but it really is 20 bytes long from what I can tell.

> > +	if (readb(sabi_iface + SABI_IFACE_COMPLETE) == 0xaa &&
> > +	    readb(sabi_iface + SABI_IFACE_DATA) != 0xff) {
> > +		/*
> > +		 * It did!
> > +		 * Save off the data into a structure so the caller use it.
> > +		 * Right now we only care about the first 4 bytes,
> > +		 * I suppose there are commands that need more, but I don't
> > +		 * know about them.
> > +		 */
> > +		sretval->retval[0] = readb(sabi_iface + SABI_IFACE_DATA);
> > +		sretval->retval[1] = readb(sabi_iface + SABI_IFACE_DATA + 1);
> > +		sretval->retval[2] = readb(sabi_iface + SABI_IFACE_DATA + 2);
> > +		sretval->retval[3] = readb(sabi_iface + SABI_IFACE_DATA + 3);
> > +		goto exit;
> > +	}
> 
> goto on success, continue failure? That's a pretty atypical pattern, and 
> the goto's not even really needed in this case.

Ah, good point.  The code was originally a port from some example code
provided by Samsung, this must have remained from that example, I'll go
fix it up.

Hm, in looking at the code, I think I did this just to make it "only
lock and unlock at one place in the function".  I'll rework it to be a
bit more "sane".


> > +	/* Something bad happened, so report it and error out */
> > +	printk(KERN_WARNING "SABI command 0x%02x failed with completion flag 0x%02x and output 0x%02x\n",
> > +		command, readb(sabi_iface + SABI_IFACE_COMPLETE),
> > +		readb(sabi_iface + SABI_IFACE_DATA));
> 
> Is it guaranteed that further reads will still return the failure state?

Nothing is guaranteed from this interface from what I can tell. :)

I really don't know, in my tests, I only had one failure, and that ended
up being my fault for sending the wrong command.

> > +	/* see if the command actually succeeded */
> > +	if (readb(sabi_iface + SABI_IFACE_COMPLETE) == 0xaa &&
> > +	    readb(sabi_iface + SABI_IFACE_DATA) != 0xff) {
> > +		/* it did! */
> > +		goto exit;
> > +	}
> 
> Ditto for this block.

Will do.

> > +static struct dmi_system_id __initdata samsung_dmi_table[] = {
> 
> This is kind of ugly. Are there any Samsung laptops where reading the 
> bios area is going to cause problems?

Yeah, I was thinking I should just accept all Samsung laptops now that
we can properly detect the type of SABI interface that the machine has.
That would reduce this table, and make users happy that they don't have
to keep adding new devices to it.  I'll make that change as well.

> > +	/* Get a pointer to the SABI Interface */
> > +	ifaceP = (readw(sabi + sabi_config->header_offsets.data_segment) & 0x0ffff) << 4;
> > +	ifaceP += readw(sabi + sabi_config->header_offsets.data_offset) & 0x0ffff;
> > +	sabi_iface = ioremap(ifaceP, 16);
> > +	if (!sabi_iface) {
> > +		printk(KERN_ERR "Can't remap %x\n", ifaceP);
> 
> dev_err()? It'd be nice to have a prefix on the failure cases.

It would, but at this point, we don't have a valid 'struct device' to
hang it off of.  I could create the platform device earlier in the
function, which would allow us to show errors a bit "prettier" if you
think that would be a good idea.

> > +	retval = init_wireless(sdev);
> 
> No way to identify whether or not the hardware has wifi before 
> registering rfkill?

I know of no way to detect this.  The driver assumes that we always have
wifi.  I actually haven't seen a Samsung laptop without it, have you?

thanks,

greg k-h

  reply	other threads:[~2011-02-11 18:42 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-09 22:40 [PATCH] Platform: add Samsung Laptop platform driver Greg KH
2011-02-09 22:44 ` Randy Dunlap
2011-02-09 22:50   ` Greg KH
2011-02-09 22:58     ` Matthew Garrett
2011-02-09 22:50 ` Matthew Garrett
2011-02-09 23:02   ` Greg KH
2011-02-11  9:17 ` Jouke Witteveen
2011-02-11 11:37 ` Richard Schütz
2011-02-11 15:22   ` Greg KH
2011-02-11 16:27     ` Richard Schütz
2011-02-25 21:01       ` Greg KH
2011-02-11 15:45 ` Matthew Garrett
2011-02-11 18:42   ` Greg KH [this message]
2011-02-16 10:06 ` Nikolai Kondrashov
2011-02-25 21:03   ` Greg KH
2011-02-25 21:49     ` Nikolai Kondrashov
2011-02-25 22:50       ` Greg KH
2011-03-10  7:00         ` Nikolai Kondrashov
2011-03-10 17:01           ` Greg KH
2011-03-10 17:13             ` Nikolai Kondrashov
2011-03-10 17:19               ` Greg KH
2011-03-10 17:28                 ` Nikolai Kondrashov
2011-03-10 18:09                   ` Greg KH
2011-03-10 21:05                     ` Nikolai Kondrashov
2011-03-10 21:15                       ` Greg KH
2011-03-11  7:12                         ` Nikolai Kondrashov
2011-03-11 17:03                           ` Greg KH
2011-03-11 19:07                             ` Nikolai Kondrashov
2011-03-11 19:34                               ` Greg KH
2011-03-11 20:20                                 ` Nikolai Kondrashov
2011-03-11 20:23                                   ` Nikolai Kondrashov
2011-03-11 20:35                                     ` Greg KH
2011-03-11 20:30                                   ` Greg KH
2011-03-13 10:03                                     ` Nikolai Kondrashov
2011-03-13 10:55                                       ` Richard Schütz
2011-03-13 13:02                                         ` Nikolai Kondrashov
2011-03-13 16:18                                           ` Greg KH
2011-03-13 17:49                                             ` Nikolai Kondrashov
2011-03-13 17:58                                               ` Greg KH
2011-03-13 16:17                                       ` Greg KH
2011-03-13 16:28                                         ` Matthew Garrett
2011-03-13 17:51                                           ` Nikolai Kondrashov
2011-03-13 17:50                                         ` Nikolai Kondrashov
  -- strict thread matches above, loose matches on Subject: below --
2011-02-25 22:47 Greg KH
2011-02-27 15:36 Greg KH
2011-03-05  4:24 Greg KH
2011-03-11 17:43 ` Matthew Garrett
2011-03-11 19:35   ` Greg KH
2011-03-11 19:44     ` Matthew Garrett
2011-03-11 19:52       ` Greg KH
2011-03-11 19:55         ` Matthew Garrett
2011-06-26 15:08 J Witteveen

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=20110211184223.GB10891@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rdunlap@xenotime.net \
    /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