Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751814AbdHPKp6 (ORCPT ); Wed, 16 Aug 2017 06:45:58 -0400 Received: from protonic.xs4all.nl ([83.163.252.89]:5052 "EHLO protonic.xs4all.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751598AbdHPKpz (ORCPT ); Wed, 16 Aug 2017 06:45:55 -0400 From: Robin van der Gracht To: linux-kernel@vger.kernel.org Cc: Miguel Ojeda Sandonis , Dmitry Torokhov , Robin van der Gracht Subject: [PATCH] auxdisplay: ht16k33: Use unique prefixed i2c client device name Date: Wed, 16 Aug 2017 12:26:35 +0200 Message-Id: <20170816102635.25573-1-robin@protonic.nl> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2145 Lines: 58 Static naming causes problems when multiple devices are registered. Reported-by: Michael Kaplan Signed-off-by: Robin van der Gracht --- Michael Kaplan reported the issue with his multiple ht16k33 controller setup. [ 472.124385] sysfs: cannot create duplicate filename '/class/backlight/ht16k33-bl' So we've got to get rid of the static device names for backlight and keypad. I figured incoperating the i2c device name would make it generic enough. The default device name if on i2c adapter 0 with addres 0x70 is '0-0070' which might be fine for an input or framebuffer device, but IMO it looks odd for a backlight device (/sys/class/backlight/0-0070/). So I choose to prefix the default i2c device name (assigned in i2c-core.c) with the driver name which will result in 'ht16k33-0-0070'. drivers/auxdisplay/ht16k33.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c index 99ce9731fc9c..674a6c0cec2a 100644 --- a/drivers/auxdisplay/ht16k33.c +++ b/drivers/auxdisplay/ht16k33.c @@ -339,7 +339,7 @@ static int ht16k33_keypad_probe(struct i2c_client *client, input_set_drvdata(keypad->dev, keypad); - keypad->dev->name = DRIVER_NAME"-keypad"; + keypad->dev->name = dev_name(&client->dev); keypad->dev->id.bustype = BUS_I2C; keypad->dev->open = ht16k33_keypad_start; keypad->dev->close = ht16k33_keypad_stop; @@ -421,6 +421,7 @@ static int ht16k33_probe(struct i2c_client *client, priv->client = client; i2c_set_clientdata(client, priv); + dev_set_name(&client->dev, DRIVER_NAME"-%s", dev_name(&client->dev)); fbdev = &priv->fbdev; err = ht16k33_initialize(priv); @@ -476,7 +477,8 @@ static int ht16k33_probe(struct i2c_client *client, bl_props.type = BACKLIGHT_RAW; bl_props.max_brightness = MAX_BRIGHTNESS; - bl = devm_backlight_device_register(&client->dev, DRIVER_NAME"-bl", + bl = devm_backlight_device_register(&client->dev, + dev_name(&client->dev), &client->dev, priv, &ht16k33_bl_ops, &bl_props); if (IS_ERR(bl)) { -- 2.11.0