05 Oct, 2020

17 commits

  • To perform partial reads, callers of kernel_read_file*() must have a
    non-NULL file_size argument and a preallocated buffer. The new "offset"
    argument can then be used to seek to specific locations in the file to
    fill the buffer to, at most, "buf_size" per call.

    Where possible, the LSM hooks can report whether a full file has been
    read or not so that the contents can be reasoned about.

    Signed-off-by: Kees Cook
    Link: https://lore.kernel.org/r/20201002173828.2099543-14-keescook@chromium.org
    Signed-off-by: Greg Kroah-Hartman

    Kees Cook
     
  • Now that security_post_load_data() is wired up, use it instead
    of the NULL file argument style of security_post_read_file(),
    and update the security_kernel_load_data() call to indicate that a
    security_kernel_post_load_data() call is expected.

    Wire up the IMA check to match earlier logic. Perhaps a generalized
    change to ima_post_load_data() might look something like this:

    return process_buffer_measurement(buf, size,
    kernel_load_data_id_str(load_id),
    read_idmap[load_id] ?: FILE_CHECK,
    0, NULL);

    Signed-off-by: Kees Cook
    Reviewed-by: Mimi Zohar
    Link: https://lore.kernel.org/r/20201002173828.2099543-10-keescook@chromium.org
    Signed-off-by: Greg Kroah-Hartman

    Kees Cook
     
  • There are a few places in the kernel where LSMs would like to have
    visibility into the contents of a kernel buffer that has been loaded or
    read. While security_kernel_post_read_file() (which includes the
    buffer) exists as a pairing for security_kernel_read_file(), no such
    hook exists to pair with security_kernel_load_data().

    Earlier proposals for just using security_kernel_post_read_file() with a
    NULL file argument were rejected (i.e. "file" should always be valid for
    the security_..._file hooks, but it appears at least one case was
    left in the kernel during earlier refactoring. (This will be fixed in
    a subsequent patch.)

    Since not all cases of security_kernel_load_data() can have a single
    contiguous buffer made available to the LSM hook (e.g. kexec image
    segments are separately loaded), there needs to be a way for the LSM to
    reason about its expectations of the hook coverage. In order to handle
    this, add a "contents" argument to the "kernel_load_data" hook that
    indicates if the newly added "kernel_post_load_data" hook will be called
    with the full contents once loaded. That way, LSMs requiring full contents
    can choose to unilaterally reject "kernel_load_data" with contents=false
    (which is effectively the existing hook coverage), but when contents=true
    they can allow it and later evaluate the "kernel_post_load_data" hook
    once the buffer is loaded.

    With this change, LSMs can gain coverage over non-file-backed data loads
    (e.g. init_module(2) and firmware userspace helper), which will happen
    in subsequent patches.

    Additionally prepare IMA to start processing these cases.

    Signed-off-by: Kees Cook
    Reviewed-by: KP Singh
    Link: https://lore.kernel.org/r/20201002173828.2099543-9-keescook@chromium.org
    Signed-off-by: Greg Kroah-Hartman

    Kees Cook
     
  • In preparation for adding partial read support, add an optional output
    argument to kernel_read_file*() that reports the file size so callers
    can reason more easily about their reading progress.

    Signed-off-by: Kees Cook
    Reviewed-by: Mimi Zohar
    Reviewed-by: Luis Chamberlain
    Reviewed-by: James Morris
    Acked-by: Scott Branden
    Link: https://lore.kernel.org/r/20201002173828.2099543-8-keescook@chromium.org
    Signed-off-by: Greg Kroah-Hartman

    Kees Cook
     
  • In preparation for refactoring kernel_read_file*(), remove the redundant
    "size" argument which is not needed: it can be included in the return
    code, with callers adjusted. (VFS reads already cannot be larger than
    INT_MAX.)

    Signed-off-by: Kees Cook
    Reviewed-by: Mimi Zohar
    Reviewed-by: Luis Chamberlain
    Reviewed-by: James Morris
    Acked-by: Scott Branden
    Link: https://lore.kernel.org/r/20201002173828.2099543-6-keescook@chromium.org
    Signed-off-by: Greg Kroah-Hartman

    Kees Cook
     
  • Move kernel_read_file* out of linux/fs.h to its own linux/kernel_read_file.h
    include file. That header gets pulled in just about everywhere
    and doesn't really need functions not related to the general fs interface.

    Suggested-by: Christoph Hellwig
    Signed-off-by: Scott Branden
    Signed-off-by: Kees Cook
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Mimi Zohar
    Reviewed-by: Luis Chamberlain
    Acked-by: Greg Kroah-Hartman
    Acked-by: James Morris
    Link: https://lore.kernel.org/r/20200706232309.12010-2-scott.branden@broadcom.com
    Link: https://lore.kernel.org/r/20201002173828.2099543-4-keescook@chromium.org
    Signed-off-by: Greg Kroah-Hartman

    Scott Branden
     
  • The "FIRMWARE_EFI_EMBEDDED" enum is a "where", not a "what". It
    should not be distinguished separately from just "FIRMWARE", as this
    confuses the LSMs about what is being loaded. Additionally, there was
    no actual validation of the firmware contents happening.

    Fixes: e4c2c0ff00ec ("firmware: Add new platform fallback mechanism and firmware_request_platform()")
    Signed-off-by: Kees Cook
    Reviewed-by: Luis Chamberlain
    Acked-by: Scott Branden
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20201002173828.2099543-3-keescook@chromium.org
    Signed-off-by: Greg Kroah-Hartman

    Kees Cook
     
  • FIRMWARE_PREALLOC_BUFFER is a "how", not a "what", and confuses the LSMs
    that are interested in filtering between types of things. The "how"
    should be an internal detail made uninteresting to the LSMs.

    Fixes: a098ecd2fa7d ("firmware: support loading into a pre-allocated buffer")
    Fixes: fd90bc559bfb ("ima: based on policy verify firmware signatures (pre-allocated buffer)")
    Fixes: 4f0496d8ffa3 ("ima: based on policy warn about loading firmware (pre-allocated buffer)")
    Signed-off-by: Kees Cook
    Reviewed-by: Mimi Zohar
    Reviewed-by: Luis Chamberlain
    Acked-by: Scott Branden
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20201002173828.2099543-2-keescook@chromium.org
    Signed-off-by: Greg Kroah-Hartman

    Kees Cook
     
  • The only usage of these structs is to assign their address to the fops
    field in the w1_family struct, which is a const pointer. Make them const
    to allow the compiler to put them in read-only memory.

    This was done with the following Coccinelle semantic patch
    (http://coccinelle.lip6.fr/):

    //
    @r1 disable optional_qualifier @
    identifier i;
    position p;
    @@
    static struct w1_family_ops i@p = {...};

    @ok1@
    identifier r1.i;
    position p;
    identifier s;
    @@
    static struct w1_family s = {
    .fops=&i@p,
    };

    @bad1@
    position p!={r1.p,ok1.p};
    identifier r1.i;
    @@
    i@p

    @depends on !bad1 disable optional_qualifier@
    identifier r1.i;
    @@
    static
    +const
    struct w1_family_ops i={};
    //

    Acked-by: Sebastian Reichel
    Signed-off-by: Rikard Falkeborn
    Link: https://lore.kernel.org/r/20201004193202.4044-4-rikard.falkeborn@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Rikard Falkeborn
     
  • The only usage of these structs is to assign their address to the fops
    field in the w1_family struct, which is a const pointer. Make them const
    to allow the compiler to put them in read-only memory.

    This was done with the following Coccinelle semantic patch
    (http://coccinelle.lip6.fr/):

    //
    @r1 disable optional_qualifier @
    identifier i;
    position p;
    @@
    static struct w1_family_ops i@p = {...};

    @ok1@
    identifier r1.i;
    position p;
    identifier s;
    @@
    static struct w1_family s = {
    .fops=&i@p,
    };

    @bad1@
    position p!={r1.p,ok1.p};
    identifier r1.i;
    @@
    i@p

    @depends on !bad1 disable optional_qualifier@
    identifier r1.i;
    @@
    static
    +const
    struct w1_family_ops i={};
    //

    Signed-off-by: Rikard Falkeborn
    Link: https://lore.kernel.org/r/20201004193202.4044-3-rikard.falkeborn@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Rikard Falkeborn
     
  • The fops field in the w1_family struct is never modified. Make it const
    to indicate that. Constifying the pointer makes it possible for drivers
    to declare static w1_family_ops structs const, which in turn will allow
    the compiler to put it in read-only memory.

    Reviewed-by: Sebastian Reichel
    Signed-off-by: Rikard Falkeborn
    Link: https://lore.kernel.org/r/20201004193202.4044-2-rikard.falkeborn@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Rikard Falkeborn
     
  • This adds support for the Trace Hub in Alder Lake CPU.

    Signed-off-by: Alexander Shishkin
    Link: https://lore.kernel.org/r/20201005071319.78508-9-alexander.shishkin@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Alexander Shishkin
     
  • This adds support for the Trace Hub in Alder Lake-S.

    Signed-off-by: Alexander Shishkin
    Link: https://lore.kernel.org/r/20201005071319.78508-8-alexander.shishkin@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Alexander Shishkin
     
  • To avoid mixup of packets from differnt ftrace packets simultaneously,
    use different channel for packets from different CPU.

    Reviewed-by: Steven Rostedt (VMware)
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Alexander Shishkin
    Link: https://lore.kernel.org/r/20201005071319.78508-7-alexander.shishkin@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     
  • Set flags for trace_export. Export function trace, event trace
    and trace marker to stm.

    Reviewed-by: Steven Rostedt (VMware)
    Reviewed-by: Alexander Shishkin
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Alexander Shishkin
    Link: https://lore.kernel.org/r/20201005071319.78508-6-alexander.shishkin@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     
  • We will support copying event trace to STM. Change
    STM_SOURCE_FTRACE to depend on TRACING since we will
    support multiple tracers.

    Reviewed-by: Steven Rostedt (VMware)
    Reviewed-by: Alexander Shishkin
    Signed-off-by: Tingwei Zhang
    Signed-off-by: Alexander Shishkin
    Link: https://lore.kernel.org/r/20201005071319.78508-2-alexander.shishkin@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Tingwei Zhang
     
  • …/git/chanwoo/extcon into char-misc-next

    Chanwoo writes:

    Detailed description for this pull request:

    1. Update extcon driver with minor updates:
    - Covert the devicetree binding format from txt to yaml and edit
    the bidning document for extcon-ptn5150.c.

    - Clean-up the code of extcon-ptn5150.c without any behavior changes.

    - Replace HTTP links with HTTPS ones on extcon-palmas.c and extcon-usb-gpio.c.

    - Return the proper error code on extcon-max14577/max77693/max77843.c.

    - Simplify with dev_err_probe() on extcon-palmas.c.

    - Use module_platform_driver to simplify the code on extcon-axp288.c.

    2. Update MAINTAINERS
    - Add Krzysztof Kozlowski as maintainer of NXP PTN5150A CC/extcon driver
    to provide review, feedback and testing.

    * tag 'extcon-next-for-5.10-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon: (25 commits)
    extcon: axp288: Use module_platform_driver to simplify the code
    extcon: ptn5150: Do not print error during probe if nothing is attached
    extcon: ptn5150: Use defines for registers
    extcon: palmas: Simplify with dev_err_probe()
    extcon: max8997: Return error code of extcon_dev_allocate()
    extcon: max77843: Return error code of extcon_dev_allocate()
    extcon: max77693: Return error code of extcon_dev_allocate()
    extcon: max14577: Return error code of extcon_dev_allocate()
    extcon: ptn5150: Set the VBUS and POLARITY property capability
    extcon: ptn5150: Switch to GENMASK() and BIT() macros
    extcon: ptn5150: Deduplicate parts of dev_err_probe()
    extcon: Replace HTTP links with HTTPS ones
    MAINTAINERS: Add entry for NXP PTN5150A CC driver
    extcon: ptn5150: Convert to .probe_new
    extcon: ptn5150: Convert to module_i2c_driver
    extcon: ptn5150: Reduce the amount of logs on deferred probe
    extcon: ptn5150: Make 'vbus-gpios' optional
    extcon: ptn5150: Check current USB mode when probing
    extcon: ptn5150: Lower the noisiness of probe
    extcon: ptn5150: Simplify getting vbus-gpios with flags
    ...

    Greg Kroah-Hartman
     

02 Oct, 2020

23 commits

  • The region size reported by the firmware for mc and software
    portals was less than allocated by the hardware. This may be
    problematic when mmapping the region in user space because the
    region size is less than page size. However the size as reserved
    by the hardware is 64K.

    Reviewed-by: Laurentiu Tudor
    Acked-by: Laurentiu Tudor
    Signed-off-by: Diana Craciun
    Link: https://lore.kernel.org/r/20200929085441.17448-14-diana.craciun@oss.nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Diana Craciun
     
  • In virtual machines the device-id range is defined
    between 0x10000-0x20000. The reason for using such a
    large range is to avoid overlapping with the PCI range.

    Reviewed-by: Laurentiu Tudor
    Acked-by: Laurentiu Tudor
    Signed-off-by: Bharat Bhushan
    Signed-off-by: Laurentiu Tudor
    Signed-off-by: Diana Craciun
    Link: https://lore.kernel.org/r/20200929085441.17448-13-diana.craciun@oss.nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Bharat Bhushan
     
  • The IRQ pool handling functions can be used by both DPRC
    driver and VFIO. Adapt and export those functions.

    Reviewed-by: Laurentiu Tudor
    Acked-by: Laurentiu Tudor
    Signed-off-by: Diana Craciun
    Link: https://lore.kernel.org/r/20200929085441.17448-12-diana.craciun@oss.nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Diana Craciun
     
  • Before destroying the mc_io, check first that it was
    allocated.

    Reviewed-by: Laurentiu Tudor
    Acked-by: Laurentiu Tudor
    Signed-off-by: Diana Craciun
    Link: https://lore.kernel.org/r/20200929085441.17448-11-diana.craciun@oss.nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Diana Craciun
     
  • Both DPRC driver and VFIO driver use the same initialization code
    for the DPRC. Introduced a new function which groups this
    initialization code. The function is exported and may be
    used by VFIO as well.

    Reviewed-by: Laurentiu Tudor
    Acked-by: Laurentiu Tudor
    Signed-off-by: Diana Craciun
    Link: https://lore.kernel.org/r/20200929085441.17448-10-diana.craciun@oss.nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Diana Craciun
     
  • Create and export a cleanup function for DPRC. The function
    is used by the DPRC driver, but it will be used by the VFIO
    driver as well.

    Reviewed-by: Laurentiu Tudor
    Acked-by: Laurentiu Tudor
    Signed-off-by: Diana Craciun
    Link: https://lore.kernel.org/r/20200929085441.17448-9-diana.craciun@oss.nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Diana Craciun
     
  • Currently the DPRC scan function is used only by the bus driver.
    But the same functionality will be needed by the VFIO driver.
    To support this, the dprc scan function was exported and a little
    bit adjusted to fit both scenarios. Also the scan mutex initialization
    is done when the bus object is created, not in dprc_probe in order
    to be used by both VFIO and bus driver.
    Similarily dprc_remove_devices is exported to be used by VFIO.

    Reviewed-by: Laurentiu Tudor
    Acked-by: Laurentiu Tudor
    Signed-off-by: Diana Craciun
    Link: https://lore.kernel.org/r/20200929085441.17448-8-diana.craciun@oss.nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Diana Craciun
     
  • DPRC reset is required by VFIO-mc in order to stop a device
    to further generate DMA transactions.

    Reviewed-by: Laurentiu Tudor
    Acked-by: Laurentiu Tudor
    Signed-off-by: Bharat Bhushan
    Signed-off-by: Laurentiu Tudor
    Signed-off-by: Diana Craciun
    Link: https://lore.kernel.org/r/20200929085441.17448-7-diana.craciun@oss.nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Bharat Bhushan
     
  • There are already firmware API commands that have multiple
    versions. For each multiple version command, another command
    to retrieve the API version is issued. This may introduce an important
    overhead. The version does not change while the system is running,
    so the DPRC API version can be safely cached.

    Reviewed-by: Laurentiu Tudor
    Acked-by: Laurentiu Tudor
    Signed-off-by: Diana Craciun
    Link: https://lore.kernel.org/r/20200929085441.17448-6-diana.craciun@oss.nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Diana Craciun
     
  • The QMAN region is memory mapped, so it should be of type
    IORESOURCE_MEM. The region flags bits were wrongly used to
    pass additional information. Use the bus specific bits for
    this purpose.

    Reviewed-by: Laurentiu Tudor
    Acked-by: Laurentiu Tudor
    Signed-off-by: Diana Craciun
    Link: https://lore.kernel.org/r/20200929085441.17448-5-diana.craciun@oss.nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Diana Craciun
     
  • This patch is required for vfio-fsl-mc meta driver to successfully bind
    layerscape container devices for device passthrough. This patch adds
    a mechanism to allow a layerscape device to specify a driver rather than
    a layerscape driver provide a device match.

    Example to allow a device (dprc.1) to specifically bind
    with driver (vfio-fsl-mc):-
    - echo vfio-fsl-mc > /sys/bus/fsl-mc/devices/dprc.1/driver_override
    - echo dprc.1 > /sys/bus/fsl-mc/drivers/fsl_mc_dprc/unbind
    - echo dprc.1 > /sys/bus/fsl-mc/drivers/vfio-fsl-mc/bind

    Reviewed-by: Laurentiu Tudor
    Acked-by: Laurentiu Tudor
    Signed-off-by: Bharat Bhushan
    Signed-off-by: Laurentiu Tudor
    Signed-off-by: Diana Craciun
    Link: https://lore.kernel.org/r/20200929085441.17448-4-diana.craciun@oss.nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Bharat Bhushan
     
  • Prepare the dprc_scan_objects function to be used by
    the VFIO mc driver code. The function is used to scan the mc
    objects by the bus driver. The same functionality is
    needed by the VFIO mc driver, but in this case the
    interrupt configuration is delayed until the userspace
    configures the interrupts. In order to use the same function
    in both drivers add a new parameter.

    Reviewed-by: Laurentiu Tudor
    Acked-by: Laurentiu Tudor
    Signed-off-by: Diana Craciun
    Link: https://lore.kernel.org/r/20200929085441.17448-3-diana.craciun@oss.nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Diana Craciun
     
  • The total number of interrupts is only used for some checks
    outside the dprc_scan_objects function. Furthermore, in some
    situations the check is made twice. Move the bounds check inside
    the function for all situations.

    Reviewed-by: Laurentiu Tudor
    Acked-by: Laurentiu Tudor
    Signed-off-by: Diana Craciun
    Link: https://lore.kernel.org/r/20200929085441.17448-2-diana.craciun@oss.nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Diana Craciun
     
  • Read and write io memory should address align on ARCH ARM. Change to use
    memcpy_toio to avoid kernel panic caused by the address un-align issue.

    Signed-off-by: Sherry Sun
    Signed-off-by: Joakim Zhang
    Link: https://lore.kernel.org/r/20200929091106.24624-5-sherry.sun@nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Sherry Sun
     
  • Since struct _mic_vring_info and vring are allocated together and follow
    vring, if the vring_size() is not four bytes aligned, which will cause
    the start address of struct _mic_vring_info is not four byte aligned.
    For example, when vring entries is 128, the vring_size() will be 5126
    bytes. The _mic_vring_info struct layout in ddr looks like:
    0x90002400: 00000000 00390000 EE010000 0000C0FF
    Here 0x39 is the avail_idx member, and 0xC0FFEE01 is the magic member.

    When EP use ioread32(magic) to reads the magic in RC's share memory, it
    will cause kernel panic on ARM64 platform due to the cross-byte io read.
    Here read magic in user space use le32toh(vr0->info->magic) will meet
    the same issue.
    So add round_up(x,4) for vring_size, then the struct _mic_vring_info
    will store in this way:
    0x90002400: 00000000 00000000 00000039 C0FFEE01
    Which will avoid kernel panic when read magic in struct _mic_vring_info.

    Signed-off-by: Sherry Sun
    Signed-off-by: Joakim Zhang
    Link: https://lore.kernel.org/r/20200929091106.24624-4-sherry.sun@nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Sherry Sun
     
  • Build module or builtin VOP based on CONFIG_VOP macro.

    Signed-off-by: Joakim Zhang
    Signed-off-by: Sherry Sun
    Link: https://lore.kernel.org/r/20200929091106.24624-3-sherry.sun@nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Sherry Sun
     
  • On my platform (i.MX53) bus access sometimes fails with
    w1_search: max_slave_count 64 reached, will continue next search.

    The reason is the use of jiffies to implement a 200us timeout in
    mxc_w1_ds2_touch_bit().
    On some platforms the jiffies timer resolution is insufficient for this.

    Fix by replacing jiffies by ktime_get().

    For consistency apply the same change to the other use of jiffies in
    mxc_w1_ds2_reset_bus().

    Fixes: f80b2581a706 ("w1: mxc_w1: Optimize mxc_w1_ds2_touch_bit()")
    Cc: stable
    Signed-off-by: Martin Fuzzey
    Link: https://lore.kernel.org/r/1601455030-6607-1-git-send-email-martin.fuzzey@flowbird.group
    Signed-off-by: Greg Kroah-Hartman

    Martin Fuzzey
     
  • Set VIRTIO_F_ACCESS_PLATFORM feature for vop driver, as the DMA mapping
    details shouldn't decide on the virtio implementation, but the host PCIe
    implementation.

    Reviewed-by: Christoph Hellwig
    Signed-off-by: Sherry Sun
    Signed-off-by: Joakim Zhang
    Link: https://lore.kernel.org/r/20200929084944.24146-1-sherry.sun@nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Sherry Sun
     
  • As per the device tree binding, in certain scenarios such as
    virtualization scenarios, the MC control registers are not
    available so don't error out if they are not present.

    Signed-off-by: Laurentiu Tudor
    Link: https://lore.kernel.org/r/20200914105459.27448-2-laurentiu.tudor@nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Laurentiu Tudor
     
  • There are certain scenarios where an iommu is not present, e.g.
    booting in a VM. Let's support these scenarios by dropping the
    check.

    Signed-off-by: Laurentiu Tudor
    Link: https://lore.kernel.org/r/20200914105459.27448-1-laurentiu.tudor@nxp.com
    Signed-off-by: Greg Kroah-Hartman

    Laurentiu Tudor
     
  • GX20MH01 device shares family number 0x28 with DS18B20. The device
    is generally compatible with DS18B20. Added are the lowest 2^-5, 2^-6
    temperature bits in Config register; R2 bit in Config register
    enabling 13 and 14 bit resolutions. It is powered up in 14 bit mode.

    Signed-off-by: Ivan Zaentsev
    Link: https://lore.kernel.org/r/20200904160004.87710-2-ivan.zaentsev@wirenboard.ru
    Acked-by: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    Ivan Zaentsev
     
  • The conversion time of common DS18B20 clones deviates from
    datasheet specs. Allow adjustment and automatic measure of the
    conversion time.

    Add 'conv_time' sysfs attribute:
    *read*: Current conversion time in milliseconds.
    *write*:
    '0': Set default conversion time.
    '1': Measure and set the conversion time. Make a
    single temperature conversion, poll and measure
    an actual value. Measured value is increased
    by 20% for temperature drift. A new conversion
    time is returned by reading the same attribute.
    other positive value:
    Set the conversion time in milliseconds.

    The setting is active until a resolution change. Then it is reset to
    default conversion time for a new resolution.

    Add 'features' sysfs attribute to control optional driver settings
    per device. Bit masks to read/write (logical OR):
    1: Enable check for conversion success. If byte 6 of
    scratchpad memory is 0xC after conversion, and
    temperature reads 85.00 (powerup value) or 127.94
    (insufficient power) - return a conversion error.

    2: Enable poll for conversion completion. Generate read cycles
    after the conversion start and wait for 1's. In parasite
    power mode this feature is not available.

    There are some clones of DS18B20 with fixed 12 bit resolution. Make the
    driver verify the resolution by reading back the device after resolution
    change.

    Signed-off-by: Ivan Zaentsev
    Acked-by: Evgeniy Polyakov
    Link: https://lore.kernel.org/r/20200904160004.87710-1-ivan.zaentsev@wirenboard.ru
    Signed-off-by: Greg Kroah-Hartman

    Ivan Zaentsev
     
  • Use the module_i2c_driver() macro to make the code smaller
    and a bit simpler.

    Signed-off-by: Liu Shixin
    Link: https://lore.kernel.org/r/20200918030225.3902750-1-liushixin2@huawei.com
    Signed-off-by: Greg Kroah-Hartman

    Liu Shixin