<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en" style="--code-editor-font: var(--default-mono-font, "GitLab Mono"), JetBrains Mono, Menlo, DejaVu Sans Mono, Liberation Mono, Consolas, Ubuntu Mono, Courier New, andale mono, lucida console, monospace;">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>
GitLab
</title>
<style data-premailer="ignore" type="text/css">
a { color: #1068bf; }
</style>
<style>img {
max-width: 100%; height: auto;
}
body {
font-size: .875rem;
}
body {
-webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px;
}
body {
font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"; font-size: inherit;
}
</style>
</head>
<body style="font-size: inherit; -webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px; font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";">
<div class="content">
<p class="details" style="font-style: italic; color: #626168;">
<a href="https://gitlab.rtems.org/mohamedayman23">Mohamed Ayman</a> created a merge request: <a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1142">!1142</a>
</p>
<div class="branch">
Project:Branches: mohamedayman23/rtems:fix-some-possible-bugs-stm32f4-i2c to rtems/rtos/rtems:main
</div>
<div class="author">
Author: Mohamed Ayman
</div>
<div class="assignee">
Assignees:
</div>
<div class="reviewer">
Reviewers:
</div>
<div class="md gl-mt-5" style="position: relative; z-index: 1; color: #3a383f; word-wrap: break-word; margin-top: 1rem;">
<h2 id="user-content-summary" dir="auto" style="margin-top: 0; margin-bottom: 10px;" align="initial">Summary<a href="#summary" aria-label="Link to heading 'Summary'" data-heading-content="Summary" class="anchor" style="margin-top: 0;"></a>
</h2>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">arm/stm32f4: Fix I2C mutex initialization and potential mutex leak</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Fix two issues in the STM32F4 I2C driver related to mutex handling.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">The mutex protecting the I2C bus was created with an initial count of 0. For a binary semaphore used as a mutex this causes the first rtems_semaphore_obtain() call to block indefinitely since the semaphore starts in the locked state. Initialize the semaphore with a count of 1 so it starts unlocked.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Additionally, stm32f4_i2c_process_message() could return early if the STOP bit was set in CR1 without releasing the mutex. This would leave the mutex locked and cause subsequent calls to deadlock. Release the mutex before returning in this case.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Also cast dummy SR2 reads to (void) to make the intent explicit and avoid potential compiler warnings about statements with no effect.</p>
<p dir="auto" style="color: #3a383f; margin: 0;" align="initial">AI usage: yes<br style="margin-top: 0;">
Prompt used: help me to analyze this code in details and tell me the flow it written by, and what section in the reference manual should i read before coding<br>
AI model: gemini pro<br>
How AI was used: to help me in understanding the coding mindset of this file</p>
</div>
</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #626168;">
—
<br>
<a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1142">View it on GitLab</a>.
<br>
You're receiving this email because of your account on <a target="_blank" rel="noopener noreferrer" href="https://gitlab.rtems.org">gitlab.rtems.org</a>. <a href="https://gitlab.rtems.org/-/sent_notifications/2-d8487ul779ewjlqv9z7v9neok/unsubscribe" target="_blank" rel="noopener noreferrer">Unsubscribe</a> from this thread · <a href="https://gitlab.rtems.org/-/profile/notifications" target="_blank" rel="noopener noreferrer" class="mng-notif-link">Manage all notifications</a> · <a href="https://gitlab.rtems.org/help" target="_blank" rel="noopener noreferrer" class="help-link">Help</a>
<span style="color: transparent; font-size: 0; display: none; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0;">
Notification message regarding https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1142 at 1773695251
</span>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Merge request","url":"https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1142"}}</script>
</p>
</div>
</body>
</html>