lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 6 May 2015 21:10:28 +0900
From:	Krzysztof Kozłowski <k.kozlowski.k@...il.com>
To:	Laurentiu Palcu <laurentiu.palcu@...el.com>
Cc:	Anda-Maria Nicolae <anda-maria.nicolae@...el.com>, sre@...nel.org,
	dbaryshkov@...il.com, robh+dt@...nel.org, pawel.moll@....com,
	mark.rutland@....com, ijc+devicetree@...lion.org.uk,
	galak@...eaurora.org, dwmw2@...radead.org,
	linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
	devicetree@...r.kernel.org
Subject: Re: [PATCH v3] power_supply: Add support for Richtek rt9455 battery charger

2015-05-06 20:40 GMT+09:00 Laurentiu Palcu <laurentiu.palcu@...el.com>:
> On Tue, May 05, 2015 at 07:32:10PM +0300, Anda-Maria Nicolae wrote:
>> +static int rt9455_probe(struct i2c_client *client,
>> +                     const struct i2c_device_id *id)
>> +{
>> +     struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
>> +     struct device *dev = &client->dev;
>> +     struct rt9455_info *info;
>> +     struct power_supply_config rt9455_charger_config = {};
>> +     /* mandatory device-specific data values */
>> +     u32 ichrg, ieoc_percentage, voreg;
>> +     /* optional device-specific data values */
>> +     u32 mivr = -1, iaicr = -1;
>> +     int i, ret;
>> +
>> +     if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
>> +             dev_err(dev, "No support for SMBUS_BYTE_DATA\n");
>> +             return -ENODEV;
>> +     }
>> +     info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
>> +     if (!info)
>> +             return -ENOMEM;
>> +
>> +     info->client = client;
>> +     i2c_set_clientdata(client, info);
>> +
>> +     info->regmap = devm_regmap_init_i2c(client,
>> +                                         &rt9455_regmap_config);
>> +     if (IS_ERR(info->regmap)) {
>> +             dev_err(dev, "Failed to initialize register map\n");
>> +             return -EINVAL;
>> +     }
>> +
>> +     for (i = 0; i < F_MAX_FIELDS; i++) {
>> +             info->regmap_fields[i] =
>> +                     devm_regmap_field_alloc(dev, info->regmap,
>> +                                             rt9455_reg_fields[i]);
>> +             if (IS_ERR(info->regmap_fields[i])) {
>> +                     dev_err(dev,
>> +                             "Failed to allocate regmap field = %d\n", i);
>> +                     return PTR_ERR(info->regmap_fields[i]);
>> +             }
>> +     }
>> +
>> +     ret = rt9455_discover_charger(info, &ichrg, &ieoc_percentage,
>> +                                   &voreg, &mivr, &iaicr);
>> +     if (ret) {
>> +             dev_err(dev, "Failed to discover charger\n");
>> +             return ret;
>> +     }
>> +
>> +#if IS_ENABLED(CONFIG_USB_PHY)
>> +     info->usb_phy = usb_get_phy(USB_PHY_TYPE_USB2);
> If you used devm_usb_get_phy() you wouldn't have to worry about
> releasing usb_phy(as Krzysztof suggested in the previous mail). It's up
> to you.

That's a good idea, it would simplify the exit and error paths. But
still usb_unregister_notifier() would be needed.

Best regards,
Krzysztof
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ