From patchwork Fri Dec 2 04:39:13 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: 9457789 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 87F286074E for ; Fri, 2 Dec 2016 04:39:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 808322847D for ; Fri, 2 Dec 2016 04:39:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73ED5284DE; Fri, 2 Dec 2016 04:39:37 +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 6662D2847D for ; Fri, 2 Dec 2016 04:39:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756862AbcLBEje (ORCPT ); Thu, 1 Dec 2016 23:39:34 -0500 Received: from mail-pg0-f53.google.com ([74.125.83.53]:32983 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756585AbcLBEjc (ORCPT ); Thu, 1 Dec 2016 23:39:32 -0500 Received: by mail-pg0-f53.google.com with SMTP id 3so102979186pgd.0 for ; Thu, 01 Dec 2016 20:39:32 -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=x24OfAqCFqj58mDqPzBJfJYU17y5/ESM9Xkccp56Q2g=; b=CCSJM8K+G+TpQabX2cq4fat1SCBgyJdHN0KKJO6GLA2wzZ7TEd69ss3jIuPplpEARo n8QxzSgHDadZ7D/KNERfKXfBbdZH/dTQqAD1XVcAepcqlS6dw4fCBnI2KrzTsvlBryuF e7O7l/St/qXdV7FialTn5fhdvNKeggkeUxAm4= 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=x24OfAqCFqj58mDqPzBJfJYU17y5/ESM9Xkccp56Q2g=; b=ElFiyau1ax1GH2s2XZ5PUxzxI253lQASUMq/o5xKNDIW18dtvxCbO+A1hautHU7FzM trSi04omcTNz10BPEjcqrGJ+CMEcBfBFJudbXEy8PwvPhr0QSvVyzNR29YBSwQ4KNYNt E4X8aaVwK1MyyhZWIhs2iwOr4cxAuAgMKwf6BrI8pPl9U3vQrLjIjRVpAX9zuyPU452p iBQL6S0TeWmZjQil3on7PLbt1tJsdA+3HvrIVdaVFm0QxerU4X72UkN+UuzYMW36bHlG QDOtTKNN/6YSp/dqeLqhdMqSXwNIxMa+7OGw8+bMO9d5iER4Wet/GO/eb+DFjKX+7+Ux ABAw== X-Gm-Message-State: AKaTC00MvjH7CCSoDC6e5XzSGI3HlgnaTxITrApchc375U1iSOhUfD9Ll7nTl4m0u9KsVWV6 X-Received: by 10.84.209.173 with SMTP id y42mr90188245plh.94.1480653571903; Thu, 01 Dec 2016 20:39:31 -0800 (PST) Received: from localhost.localdomain ([118.69.219.197]) by smtp.gmail.com with ESMTPSA id c8sm3630471pfe.15.2016.12.01.20.39.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Dec 2016 20:39:30 -0800 (PST) From: Tin Huynh To: Mika Westerberg , "Rafael J. Wysocki" , Richard Purdie , Jacek Anaszewski , Peter Rosin , Dan Carpenter 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 V5] leds: pca955x: Add ACPI support for pca955x Date: Fri, 2 Dec 2016 11:39:13 +0700 Message-Id: <1480653553-22911-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 --- drivers/leds/leds-pca955x.c | 24 ++++++++++++++++++++++-- 1 files changed, 22 insertions(+), 2 deletions(-) Change from V4: -Using client->name instead of id->name to avoid NULL pointer in ACPI. 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..78a7ce8 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); @@ -264,7 +283,7 @@ static int pca955x_probe(struct i2c_client *client, dev_info(&client->dev, "leds-pca955x: Using %s %d-bit LED driver at " "slave address 0x%02x\n", - id->name, chip->bits, client->addr); + client->name, chip->bits, client->addr); if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) return -EIO; @@ -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,