From patchwork Wed Nov 30 09:47:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tnhuynh@apm.com X-Patchwork-Id: 9454193 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 06FEE6071E for ; Wed, 30 Nov 2016 11:33:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC4C32845B for ; Wed, 30 Nov 2016 11:33:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0A8F28459; Wed, 30 Nov 2016 11:33:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6551028451 for ; Wed, 30 Nov 2016 11:33:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755082AbcK3Jsm (ORCPT ); Wed, 30 Nov 2016 04:48:42 -0500 Received: from mail-pg0-f48.google.com ([74.125.83.48]:35831 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754786AbcK3Jrm (ORCPT ); Wed, 30 Nov 2016 04:47:42 -0500 Received: by mail-pg0-f48.google.com with SMTP id p66so80508252pga.2 for ; Wed, 30 Nov 2016 01:47:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id; bh=1MA2EoSrlGRYd0Op9wIcWobazijP0xomfPP+81DIQwU=; b=aq94UD2FxmDmG95sCjeJ/Smhed87LGo7Bv3V0tHlcPcGEp3iGRZdR/muSkyHfhW2AR w3WEZPCo5Z4XtNeDwzqeaPPoAtZ0AL2bPCpxYBzWX1Wvx/N/PkB9Q88ykehQVINu6xSE nU6tAo3q4OSgW/1ShQW+E3wKI7+hGDYInNsqk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1MA2EoSrlGRYd0Op9wIcWobazijP0xomfPP+81DIQwU=; b=YFc+dEFzL23ZMrr7wtXsUVffFEQXyBWEmcz1iVEBKWgWv2IdkXdnWStleaiyBtqiTk Ic5cfbjJP4LB8ujmK/luwoVMDGl1KCqh4NsFa9c+1Pu9mezX4PQdoOEwzZoK1hURCAKh aqYtBOPQmvZUTYH/BDHCui1jdvuS8/3A5kc2JDKYyeKro6NGYx313U0E3hfkhMrvbnu4 558HRbHSBXI8C8a34Sg4bZ5aYK2pW68RMHxlNWikmY2Y8Riohn44UImyqpszZlfY5zDT v7gAFvAD+sJPqHbVaQieujN+T+tG/QLh14QOtKaUNxcd+lKZafnyTLli9fZ5nFUUyhrE 0amA== X-Gm-Message-State: AKaTC02vQNeBXpQkZ264ux5SFlEIMMGZ+fEMrPW+Oqivp4PRUCjDQpCWcmVGqCzNRxCAQt4w X-Received: by 10.84.218.8 with SMTP id q8mr71331495pli.138.1480499261559; Wed, 30 Nov 2016 01:47:41 -0800 (PST) Received: from localhost.localdomain ([118.69.219.197]) by smtp.gmail.com with ESMTPSA id f81sm101340899pfd.71.2016.11.30.01.47.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Nov 2016 01:47:40 -0800 (PST) From: Tin Huynh To: Mika Westerberg , "Rafael J. Wysocki" , Richard Purdie , Jacek Anaszewski , Peter Rosin Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Loc Ho , Thang Nguyen , Phong Vo , patches@apm.com, Tin Huynh Subject: [PATCH V4] leds: pca955x: Add ACPI support for pca955x Date: Wed, 30 Nov 2016 16:47:25 +0700 Message-Id: <1480499245-25781-1-git-send-email-tnhuynh@apm.com> X-Mailer: git-send-email 1.7.1 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch enables ACPI support for leds-pca955x driver. Signed-off-by: Tin Huynh Acked-by: Mika Westerberg --- drivers/leds/leds-pca955x.c | 22 +++++++++++++++++++++- 1 files changed, 21 insertions(+), 1 deletions(-) Change from V3: -Drop ".id =" and ".driver_data =" from pca955x_acpi_ids initializers. Change from V2: -Correct coding conventions. Change from V1: -Remove CONFIG_ACPI. diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c index 840401a..e29151c 100644 --- a/drivers/leds/leds-pca955x.c +++ b/drivers/leds/leds-pca955x.c @@ -40,6 +40,7 @@ * bits the chip supports. */ +#include #include #include #include @@ -100,6 +101,15 @@ struct pca955x_chipdef { }; MODULE_DEVICE_TABLE(i2c, pca955x_id); +static const struct acpi_device_id pca955x_acpi_ids[] = { + { "PCA9550", pca9550 }, + { "PCA9551", pca9551 }, + { "PCA9552", pca9552 }, + { "PCA9553", pca9553 }, + { } +}; +MODULE_DEVICE_TABLE(acpi, pca955x_acpi_ids); + struct pca955x { struct mutex lock; struct pca955x_led *leds; @@ -250,7 +260,16 @@ static int pca955x_probe(struct i2c_client *client, struct led_platform_data *pdata; int i, err; - chip = &pca955x_chipdefs[id->driver_data]; + if (id) { + chip = &pca955x_chipdefs[id->driver_data]; + } else { + const struct acpi_device_id *acpi_id; + + acpi_id = acpi_match_device(pca955x_acpi_ids, &client->dev); + if (!acpi_id) + return -ENODEV; + chip = &pca955x_chipdefs[acpi_id->driver_data]; + } adapter = to_i2c_adapter(client->dev.parent); pdata = dev_get_platdata(&client->dev); @@ -358,6 +377,7 @@ static int pca955x_remove(struct i2c_client *client) static struct i2c_driver pca955x_driver = { .driver = { .name = "leds-pca955x", + .acpi_match_table = ACPI_PTR(pca955x_acpi_ids), }, .probe = pca955x_probe, .remove = pca955x_remove,