From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933967AbbHLI2O (ORCPT ); Wed, 12 Aug 2015 04:28:14 -0400 Received: from smtp-out-194.synserver.de ([212.40.185.194]:1090 "EHLO smtp-out-194.synserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933693AbbHLI2L (ORCPT ); Wed, 12 Aug 2015 04:28:11 -0400 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 2409 Message-ID: <55CB0396.2050303@metafoo.de> Date: Wed, 12 Aug 2015 10:28:06 +0200 From: Lars-Peter Clausen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: sdliyong@gmail.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, cristina.opriceana@gmail.com, tolga.ceylan@gmail.com, k.kozlowski@samsung.com, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] staging: iio: hmc5843: Set iio name dynamically based on i2c name References: <1439367630-8964-1-git-send-email-sdliyong@gmail.com> In-Reply-To: <1439367630-8964-1-git-send-email-sdliyong@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/12/2015 10:20 AM, sdliyong@gmail.com wrote: > From: Yong Li > > Load the driver using the below command: > echo hmc5983 0x1e > /sys/bus/i2c/devices/i2c-?/new_device > > In sysfs, the iio name is hmc5843, however the i2c name is hmc5983, > they are inconsistent. > > With this patch, the iio name will be the same as the i2c device name > > Signed-off-by: Yong Li > --- > drivers/staging/iio/magnetometer/hmc5843_i2c.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/staging/iio/magnetometer/hmc5843_i2c.c b/drivers/staging/iio/magnetometer/hmc5843_i2c.c > index ff08667..3b03644 100644 > --- a/drivers/staging/iio/magnetometer/hmc5843_i2c.c > +++ b/drivers/staging/iio/magnetometer/hmc5843_i2c.c > @@ -59,6 +59,7 @@ static const struct regmap_config hmc5843_i2c_regmap_config = { > static int hmc5843_i2c_probe(struct i2c_client *cli, > const struct i2c_device_id *id) > { > + cli->dev.driver->name = id->name; You are overwriting a the name of the driver, which is a struct that is shared between all instances of the device which specific data from one device. That is most certainly not correct. Update hmc5843_common_probe() and add a parameter that takes the name for the device and then pass the id->name when the function is called. > return hmc5843_common_probe(&cli->dev, > devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config), > id->driver_data); >