From patchwork Fri Sep 9 00:35:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andres Salomon X-Patchwork-Id: 114005 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1653AB6F82 for ; Fri, 9 Sep 2011 10:43:14 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757263Ab1IIAnJ (ORCPT ); Thu, 8 Sep 2011 20:43:09 -0400 Received: from lunge.queued.net ([173.255.254.236]:43530 "EHLO lunge.queued.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757049Ab1IIAnI (ORCPT ); Thu, 8 Sep 2011 20:43:08 -0400 X-Greylist: delayed 468 seconds by postgrey-1.27 at vger.kernel.org; Thu, 08 Sep 2011 20:43:08 EDT Received: from localhost (c-67-160-86-206.hsd1.wa.comcast.net [67.160.86.206]) by lunge.queued.net (Postfix) with ESMTPSA id 751DE2857FB; Thu, 8 Sep 2011 17:35:18 -0700 (PDT) Date: Thu, 8 Sep 2011 17:35:17 -0700 From: Andres Salomon To: Dan Williams Cc: linville@tuxdriver.com, libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, dsd@laptop.org, cjb@laptop.org Subject: [PATCH v3] libertas: prioritize usb8388_olpc.bin firmware on OLPC machines Message-ID: <20110908173517.5b8c90be@queued.net> X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; i486-pc-linux-gnu) Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Normally, the v9 firmware will be loaded if it's available. However, on OLPC XO-1 machines, the olpc-specific firmware supports extra functionality. This makes the libertas driver attempt to load the custom firmware first if the machine is an OLPC machine; if that fails (or it's not an OLPC machine), fall back to attempting to load the other firmwares. usb8388_olpc.bin is currently found in the linux-firmware repository. Signed-off-by: Andres Salomon Acked-by: Dan Williams --- v3: changed firmware path to include libertas/ subdirectory. Since the last submission (v2), usb8388_olpc.bin has found its way into wireless-firmware. It'd be nice to get this into the next merge window. drivers/net/wireless/libertas/if_usb.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c index b5acc39..94f8f3e 100644 --- a/drivers/net/wireless/libertas/if_usb.c +++ b/drivers/net/wireless/libertas/if_usb.c @@ -973,6 +973,23 @@ static const struct { { MODEL_8682, "libertas/usb8682.bin" } }; +#ifdef CONFIG_OLPC + +static int try_olpc_fw(struct if_usb_card *cardp) +{ + int retval = -ENOENT; + + /* try the OLPC firmware first; fall back to fw_table list */ + if (machine_is_olpc() && cardp->model == MODEL_8388) + retval = request_firmware(&cardp->fw, + "libertas/usb8388_olpc.bin", &cardp->udev->dev); + return retval; +} + +#else +static int try_olpc_fw(struct if_usb_card *cardp) { return -ENOENT; } +#endif /* !CONFIG_OLPC */ + static int get_fw(struct if_usb_card *cardp, const char *fwname) { int i; @@ -981,6 +998,10 @@ static int get_fw(struct if_usb_card *cardp, const char *fwname) if (fwname) return request_firmware(&cardp->fw, fwname, &cardp->udev->dev); + /* Handle OLPC firmware */ + if (try_olpc_fw(cardp) == 0) + return 0; + /* Otherwise search for firmware to use */ for (i = 0; i < ARRAY_SIZE(fw_table); i++) { if (fw_table[i].model != cardp->model)